forked from Pyomo/pyomo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzipbuilder
executable file
·197 lines (169 loc) · 4.84 KB
/
zipbuilder
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/sh
# The old version of "rebuild". I am mostly keeping this here so for
# archival purposes.
#
#\rm -Rf coopr_release
#./coopr_install --preinstall --rebuild coopr_release 2>&1 > coopr.out
#python ./rebuild.py
#exit
set -o pipefail
PACKAGE=pyomo
INI=config
BASE_OS=`uname | cut -d'-' -f1`
if test "$BASE_OS" == "Darwin"; then
SED_RE=-E
XARGS_REPL='-x -L 1 -J'
LS_COLOR=
else
#SED_RE=-r
#LS_COLOR=--color=none
#XARGS_REPL='-x -L 1 -J'
XARGS_REPL=-I
SED_RE=-E
LS_COLOR=
fi
USAGE="Usage: $0 --trunk|--release|--pypi [--zip-only]"
if test -z "$1"; then
echo "Missing mode argument."
echo "$USAGE"
exit 1
fi
if test "$2" == "--zip-only"; then
ZIP_ONLY=1
elif test -n "$2"; then
echo "UNKNOWN OPTION: $2"
echo "$USAGE"
exit 1
fi
if test -n "$3"; then
echo "UNKNOWN OPTION: $3"
echo "$USAGE"
exit 1
fi
if test "$1" == "--trunk"; then
MODE="'--trunk'"
elif test "$1" == "--release"; then
MODE=
elif test "$1" == "--pypi"; then
MODE=
PYPY=1
else
echo "Unknown argument $1"
echo "$USAGE"
exit 1
fi
if test -n "$PYPI"; then
rm -f ../${PACKAGE}.zip
touch ${PACKAGE}.zip
fi
#if test ! -d hudson; then
# svn co --trust-server-cert https://software.sandia.gov/svn/fast/hudson/python hudson || exit 1
#fi
if test ! -d vpy; then
git clone https://github.com/PyUtilib/pyutilib.virtualenv.git vpy || exit 1
fi
# Leverage the Hudson/Jenkins build harness to drive vpy_install to get
# a current checkout
SCRIPT="
import sys
import os
import os.path
admin_path = os.path.join(os.environ['WORKSPACE'], 'pyomo/admin')
sys.argv = ['dummy', '--preinstall', $MODE]
sys.path.append(os.getcwd())
sys.path.append(admin_path)
os.environ['WORKSPACE'] = os.getcwd()
print(sys.path)
print(os.environ)
import driver
driver.perform_build(
'${PACKAGE}', cat=None, config=os.path.join(admin_path, '${INI}.ini'), dest='preinstall' )
"
python -c "$SCRIPT" | tee ${PACKAGE}.log || exit 1
if test -n "$PYPI"; then
if test -z "$ZIP_ONLY"; then
python `dirname $0`/rebuild.py ${PACKAGE}
fi
exit 0
fi
cd preinstall || exit 1
# Remove the ZIP created by vpy_install
rm -f python.zip
# Promote *.txt from the ${PACKAGE} package
mkdir tmp
mv *.txt tmp
cp -p src/${PACKAGE}/*.txt .
mv tmp/*.txt .
rmdir tmp
VER=VERSION.txt
LOG=../${PACKAGE}.log
if test -z "$MODE"; then
# release
PKG_SVN=`grep -i "Git switching ${PACKAGE} to tag" $LOG | cut -d: -f2- \
| xargs basename | tr -d ' '`
REV=$PKG_SVN
printf "${PACKAGE} installer for release: %s\n" $PKG_SVN > $VER
echo "This installer includes the following component versions:" >> $VER
for PKG in `\ls src | sort`; do
VCS=`grep -A1 "package ${PKG}\$" $LOG | tail -1 | sed 's/ //g' | cut -c1`
if test "$VCS" == 'S'; then
SVN=`grep -A1 "package ${PKG}\$" $LOG | tail -1 | cut -d: -f2- \
| xargs basename`
elif test "$VCS" == 'G'; then
SVN=`grep "Git switching ${PKG} to" $LOG | cut -d: -f2-`
else
SVN='(unknown)'
fi
printf '%12s %s\n' $SVN $PKG >> $VER
done
echo RELEASE
else
# trunk
pushd ../../pyomo
pwd
REV=`git log -1 --format="%h"`
popd
printf "${PACKAGE} installer for: VOTD.%s\n" $REV > $VER
# Update the VOTD micro version number
VER_FILE=src/${PACKAGE}/${PACKAGE}/version/__init__.py
cat $VER_FILE | sed $SED_RE "s/_micro=[0-9]*/_micro=$REV/" > tmp
mv tmp $VER_FILE
echo "This installer includes the following package revisions:" >> $VER
for PKG in `\ls src | sort`; do
VCS=`grep -A1 "package ${PKG}\$" $LOG | tail -1 | sed 's/ //g' | cut -c1`
if test "$VCS" == 'S'; then
SVN=`grep -A1 "package ${PKG}\$" $LOG | tail -1 | cut -d: -f2- \
| xargs svn info | grep 'Last Changed Rev' | cut -d: -f2`
elif test "$VCS" == 'G'; then
pushd src/${PKG}
SVN=`git log -1 --format="%h"`
popd
else
SVN='(unknown)'
fi
printf '%12s %s\n' $SVN $PKG >> $VER
done
fi
# Remove any .git / .svn directories
find . -name .git | xargs rm -rf
find . -name .svn | xargs rm -rf
if test -z "$MODE"; then
ZIPFILE=${PACKAGE}_${REV}.zip
else
ZIPFILE=${PACKAGE}_votd_${REV}.zip
fi
# build the ZIP needed for ${PACKAGE}_install
pwd
echo $ZIPFILE
rm -f ../${PACKAGE}.zip ../${ZIPFILE}
\ls $LS_COLOR | grep -v '^bin' | grep -v '^include' | grep -v '^lib' \
| xargs -I % zip -r ../${ZIPFILE} % -x \*.pyc
#\ls --color=none | grep -v '^bin' | grep -v '^include' | grep -v '^lib' \
# | xargs -i zip -r ../${PACKAGE}.zip {} -x \*.pyc
#\ls | grep -v '^bin' | grep -v '^include' | grep -v '^lib' \
# | xargs -J % zip -r ../${PACKAGE}.zip % -x \*.pyc
cd ..
ln -s ${ZIPFILE} ${PACKAGE}.zip
if test -z "$ZIP_ONLY"; then
python `dirname $0`/rebuild.py ${PACKAGE}
fi