-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate-python-pypi-pkg.revs.sh
More file actions
102 lines (89 loc) · 2.29 KB
/
create-python-pypi-pkg.revs.sh
File metadata and controls
102 lines (89 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
#this script should build pypi pkg from specified branch and revision
#common debian reqs:
#devscripts fakeroot build-essential debhelper
#in params:
#<projectname> <branch> [revisionid] [reposerver]
PROGNAME=$(basename $0)
#PRJNAME="frontend.2.0"
function print_usage(){
echo "this script may accept next params"
echo "-P projectname - name of the project we are building, like frontend2.0, search, tornado and such. should be the same as github repo name."
echo "-B branch - branch to checkout"
echo "-R revision id - revision to check out"
echo "-S reposerver - ssh servername in format user@host, like git@github.com"
echo "-E environment"
echo ""
echo "example:"
echo "$PROGNAME -P apilib -B master -R fcd3d2c172d244bf3355efff86ee7800702ce69f -S git@github.com -E dev"
}
print_help() {
echo ""
print_usage
echo ""
}
if [ -z $2 ];then
print_usage;
exit 1
fi
# parsing arguments
while getopts ":hP:B:R:S:L:E:" Option; do
case $Option in
h)
print_help
exit 0
;;
P)
PRJNAME="${OPTARG}"
;;
B)
BRANCH="${OPTARG}"
;;
R)
REVID_PARAM="${OPTARG}"
;;
S)
REPOSERVER_PARAM="${OPTARG}"
;;
E)
ENVIRONMENT="${OPTARG}"
;;
*)
print_help
exit 1
;;
esac
done
shift $(($OPTIND - 1))
REVID=${REVID_PARAM:-NONE}
REPOSERVER=${REPOSERVER_PARAM:-github-${PRJNAME}}
REPOURL="${REPOSERVER}:kupishoes/${PRJNAME}.git"
ENVIRONMENT=${ENVIRONMENT:-dev}
BUILDDIR=$(mktemp -d -p . -t ${PRJNAME}-XXXXXX)
pushd -n $PWD
cd ${BUILDDIR}
bdir="$PWD"
(
git clone "${REPOURL}" "${PRJNAME}" && \
cd "${PRJNAME}" && \
BRANCHCUR=$(git branch|grep '^*'|cut -f 2 -d ' ') && \
if [ $BRANCH != "$BRANCHCUR" ];then
git checkout -b $BRANCH origin/$BRANCH
else
echo "branch is specified as $BRANCH, skipping additional checkout"
fi && \
if [ "$REVID" != "NONE" ];then
git reset --hard "$REVID"
fi
)
if [ $? -ne 0 ];then
echo "git operations failed, exiting"
exit 1
fi
pwd && ls -la
#--suppress-packaging-version=True
cd "${PRJNAME}" &&\
python setup.py sdist || exit 1
ssh pypi.moda.local mkdir /data/pypi/local/${ENVIRONMENT}/${PRJNAME}
scp dist/*.tar.gz pypi.moda.local:/data/pypi/local/${ENVIRONMENT}/${PRJNAME}/ || exit 1
cat ${PRJNAME}.egg-info/PKG-INFO