-
Notifications
You must be signed in to change notification settings - Fork 5
/
buildljt
executable file
·292 lines (271 loc) · 7.17 KB
/
buildljt
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#!/bin/bash
TMPDIR=
PREVDIR=`pwd`
export SCRIPT=$0
SCRIPTDIR=`dirname $0`
pushd $SCRIPTDIR >/dev/null
SCRIPTDIR=`pwd`
popd >/dev/null
set -u
set -e
trap onexit INT
trap onexit TERM
trap onexit EXIT
onexit()
{
cd $PREVDIR
if [ ! "$TMPDIR" = "" ]; then
RESULTS=`find $TMPDIR -uid 0 -print -quit`
if [ ! -z "$RESULTS" -a ! `uid` -eq 0 ]; then
sudo rm -rf $TMPDIR
else
rm -rf $TMPDIR
fi
fi
}
PLATFORM=
case "`uname -s`" in
Linux) export PLATFORM=linux ;;
Darwin) export PLATFORM=macos ;;
MINGW*) export PLATFORM=windows ;;
MSYS*) export PLATFORM=windows ;;
*) echo "Unsupported platform"; exit 1 ;;
esac
uid()
{
id | cut -f2 -d = | cut -f1 -d \(;
}
usage()
{
echo
echo "USAGE: $SCRIPT [options] [branch/tag (default = main)]"
echo
echo "Options:"
echo "-b <dir> = Specify build directory"
echo " (default = ~/src/ljt.nightly/$BUILD)"
echo "-e = Use existing source tarball in the build directory"
echo "-f = Force new build (deletes all existing build files in the build directory)"
echo "-fb = Use existing source tarball in the build directory, but force new"
echo " binaries to be built for this platform"
echo "-l = Generate file list and HTML index"
echo "-r <url> = Specify Git repository URL"
echo " (default = $DEFAULT_REPO)"
echo "-d <dir> = Build from existing source directory, located under <dir>"
echo " (useful for continuous integration)"
echo "-s = Generate source package(s) only"
echo "-v = Verbose (show the output of the build in real time)"
echo
exit 1
}
update_list()
{
if [ ! -d $OUTDIR/files ]; then
echo
echo Build does not exist in $OUTDIR/files!
echo
exit 1
fi
cd $OUTDIR/files
if [ -f files.txt ]; then rm -f files.txt; fi
if [ -f ../files.txt ]; then rm -f ../files.txt; fi
if [ -f index.html ]; then rm -f index.html; fi
if [ -f ../index.html ]; then rm -f ../index.html; fi
echo "<html><body><table border=1 cellpadding=5>" >../index.html
echo "<tr><th>File</th><th>Size</th><th>Date</th><th>MD5 sum</th></tr>" >>../index.html
for i in *; do
if [ -d $i ]; then continue; fi
LSL=`ls -l $i`
SIZE=
DATE=
MD5=
if [ ! -d $i ]; then
SIZE=`echo $LSL | awk '{print $5}'`
DATE=`echo $LSL | awk '{print $6" "$7}'`
MD5=`md5sum -b $i | awk '{print $1}'`
fi
echo -e "$i\t$SIZE\t\t$DATE\t$MD5" >>../files.txt
echo -e "<tr><td><a href=\"$i\">$i</a></td><td>$SIZE</td><td>$DATE</td><td>$MD5</td></tr>" >>../index.html
done
echo "</html></body>" >>../index.html
mv ../files.txt .
mv ../index.html .
}
BUILD=`date +%Y%m%d`
export OUTDIR=$HOME/src/ljt.nightly/$BUILD
LATEST=1
FORCE=0
export FORCEBINARY=0
SRCONLY=0
NOSRC=0
UPDATELIST=0
VERBOSE=0
TAG=main
DEFAULT_REPO=https://github.com/libjpeg-turbo/libjpeg-turbo.git
REPO=$DEFAULT_REPO
SRCDIR=
while [ $# -gt 0 ]; do
if [ "$1" = "-f" ]; then
FORCE=1
elif [ "$1" = "-fb" ]; then
export FORCEBINARY=1
NOSRC=1
elif [ "$1" = "-s" ]; then
SRCONLY=1
elif [ "$1" = "-e" ]; then
NOSRC=1
elif [ "$1" = "-b" ]; then
OUTDIR=$2
LATEST=0
shift
elif [ "$1" = "-l" ]; then
UPDATELIST=1
elif [ "$1" = "-v" ]; then
VERBOSE=1
elif [ "$1" = "-r" ]; then
REPO=$2
shift
elif [ "$1" = "-d" ]; then
SRCDIR=$2
shift
elif [ "$1" = "-h" -o "$1" = "-?" ]; then
usage
else
TAG=$1
fi
shift
done
if [ $SRCONLY = 1 -a $NOSRC = 1 ]; then
echo ERROR: Cannot specify -s with -fb or -e
exit 1
fi
if [ $UPDATELIST = 1 ]; then
update_list
exit 0
fi
if [ ! -d $OUTDIR ]; then
mkdir -p $OUTDIR/files
else
if [ $FORCE = 0 -a $NOSRC = 0 ]; then
if [ $SRCONLY = 0 ]; then
echo
echo Build already exists in $OUTDIR/files!
echo "Run $SCRIPT -f to force a full rebuild"
echo " or $SCRIPT -e to use existing source"
echo
exit 1
fi
else
if [ $NOSRC = 0 ]; then
if [ -d $OUTDIR/files ]; then
rm -f $OUTDIR/files/*
rmdir $OUTDIR/files
fi
rm -f $OUTDIR/*
rmdir $OUTDIR
mkdir -p $OUTDIR/files
fi
fi
fi
umask 022
if [ "$PLATFORM" = "windows" ]; then
# /tmp maps to a directory in c:\Documents and Settings, which causes
# barfage in the MinGW resource compiler because of the pathname
# spaces.
export TMPDIR=`mktemp -d /c/temp/ljtbuild.XXXXXX`
else
export TMPDIR=`mktemp -d /tmp/ljtbuild.XXXXXX`
fi
cd $TMPDIR
if [ $NOSRC = 0 ]; then
if [ ! "$SRCDIR" = "" ]; then
echo Using existing source directory $SRCDIR ...
DIR=$SRCDIR
else
echo Checking out libjpeg-turbo from $TAG ...
git clone --depth=1 -b $TAG $REPO libjpeg-turbo
DIR=libjpeg-turbo
fi
echo Creating source tarball and SRPM ...
cp -R $DIR libjpeg-turbo.pristine
pushd libjpeg-turbo.pristine
rm -rf .git .gitattributes .github .gitignore appveyor.yml
popd
pushd $DIR
VERSION=`grep "set(VERSION" CMakeLists.txt | sed -e s/[^0-9\.]//g`
if [ "$VERSION" = "" ]; then
echo Could not parse version from CMakeLists.txt!
exit 1
fi
if [ "$PLATFORM" = "windows" ]; then
CC=cl cmake -G"Ninja" .
ninja dist
elif [ "$PLATFORM" = "linux" ]; then
# We set these variables here in order to populate the RPM spec file
cmake -G"Unix Makefiles" -DCMAKE_POSITION_INDEPENDENT_CODE=1 -DPKGNAME=libjpeg-turbo-official -DREQUIRE_SIMD=1 -DWITH_JAVA=1 .
make dist
else
cmake -G"Unix Makefiles" .
make dist
fi
popd
mv $DIR/libjpeg-turbo-$VERSION.tar.gz $OUTDIR/files/
tar xfz $OUTDIR/files/libjpeg-turbo-$VERSION.tar.gz
diff -r libjpeg-turbo.pristine libjpeg-turbo-$VERSION
rm -rf libjpeg-turbo.pristine
if [ -f $SCRIPTDIR/gpgsign ]; then
. $SCRIPTDIR/gpgsign
if [ -f $OUTDIR/files/libjpeg-turbo-$VERSION.tar.gz.sig ]; then
rm -f $OUTDIR/files/libjpeg-turbo-$VERSION.tar.gz.sig
fi
gpg --pinentry-mode loopback --batch --default-key "$GPG_KEY_ID" --passphrase "$GPG_KEY_PASS" --detach-sig $OUTDIR/files/libjpeg-turbo-$VERSION.tar.gz \
|| gpg --batch --default-key "$GPG_KEY_ID" --passphrase "$GPG_KEY_PASS" --detach-sig $OUTDIR/files/libjpeg-turbo-$VERSION.tar.gz
gpg --verify $OUTDIR/files/libjpeg-turbo-$VERSION.tar.gz.sig
fi
if [ "$PLATFORM" = "linux" ]; then
pushd $DIR
make srpm
popd
mv $DIR/libjpeg-turbo-official-$VERSION.src.rpm $OUTDIR/files/
if [ -f $SCRIPTDIR/gpgsign ]; then
$SCRIPTDIR/rpmsign $OUTDIR/files/libjpeg-turbo-official-$VERSION.src.rpm
rpm --checksig -v $OUTDIR/files/libjpeg-turbo-official-$VERSION.src.rpm
fi
fi
rm -rf libjpeg-turbo-$VERSION
if [ "$SRCDIR" = "" ]; then
rm -rf libjpeg-turbo
fi
else
if [ "$PLATFORM" = "linux" ]; then
if ! ls $OUTDIR/files/libjpeg-turbo-[0-9]*.tar.gz >/dev/null 2>&1
-o ! ls $OUTDIR/files/libjpeg-turbo-[0-9]*.src.rpm >/dev/null 2>&1; then
echo Source files do not exist!
exit 1
fi
else
if [ ! -f $OUTDIR/files/libjpeg-turbo-[0-9]*.tar.gz ]; then
echo Source tarball does not exist!
exit 1
fi
fi
fi
if [ $SRCONLY = 1 ]; then
exit 0
fi
echo Untarring libjpeg-turbo ...
tar xfz $OUTDIR/files/libjpeg-turbo-[0-9]*.tar.gz
echo done.
echo Building libjpeg-turbo for $PLATFORM...
if [ $VERBOSE = 1 ]; then
$SCRIPTDIR/buildljt.$PLATFORM | tee $OUTDIR/log-$PLATFORM.txt
else
$SCRIPTDIR/buildljt.$PLATFORM > $OUTDIR/log-$PLATFORM.txt
fi
echo done.
update_list
if [ "$PLATFORM" != "windows" -a $LATEST = 1 ]; then
# sym links aren't implemented properly in MinGW
if [ -h $OUTDIR/../latest ]; then rm $OUTDIR/../latest; fi
ln -fs $BUILD $OUTDIR/../latest
fi
exit 0