-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmxe.postbuild.sh
executable file
·103 lines (85 loc) · 3.2 KB
/
mxe.postbuild.sh
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
#!/bin/bash
set -e
# avoid specific action names like "archive" or "codesign"
# -- all package grooming for deployment will happen here
TARGET="${2}"
TMPDIR="tmp-${1}_${2}-postbuild"
mkdir -p "$TMPDIR"
# The Debian convention is "Foo_ver[-rev]_arch"
FOONAME=`echo ${1} | tr '[:upper:] _' '[:lower:]-'`
FOO_VER=`echo $VERSION | tr '[:upper:] _' '[:lower:]-'`
OUTDIR="./out/${2}"
TGZDIR="$OUTDIR/tgz"
ZIPDIR="$OUTDIR/zip"
DEBDIR="$OUTDIR/deb"
mkdir -p "$TGZDIR/latest"
mkdir -p "$ZIPDIR/latest"
mkdir -p "$DEBDIR/latest"
# The target (Makefile's $(3) turned ${2}) won't be sanitized:
# 1. it's the last component anyway ("cut -d '_' 3-" will work),
# 2. packages for different targets are never deployed together;
# 3. unfortunately, x86_64 traditionally contains an underscore.
Q_NAME="${FOONAME}_${FOO_VER}_${2}" # =qualified (absolute) name
LATEST="latest/${FOONAME}_${2}" # =symbolic link to latest-built
OUTTGZ="$TGZDIR/$Q_NAME.tar.gz"
OUTZIP="$ZIPDIR/$Q_NAME.zip"
OUTDEB="$DEBDIR/$Q_NAME.deb" # not built yet: needs dep/graph
# tape archives are compressed in streaming mode for efficiency
# (dictionary reuse). first we append into them, then compress.
TMPTAR="$TMPDIR/$VERSION.tar" # ($TARGET is already in $TMPDIR)
TMPZIP="$TMPDIR/$VERSION.lst" # proto-zip is simply a file list
# absolute paths for access inside pushd-popd
ABSTAR=`realpath "$TMPTAR"`
ABSZIP=`realpath "$OUTZIP"`
ABSLST=`realpath "$TMPZIP"`
# TODO inject dependencies (with their own versions)
# ROADMAP fix non-comparable versions (e.g. commit hashes)
# Now: we are only interested in files in $PREFIX/$TARGET,
# and only if $TARGET != $BUILD:
if [ "x$TARGET" != "x$BUILD" ]; then
echo Locating tar:
which tar
echo Locating zip:
which zip
echo Locating gzip:
which gzip
rm -f "$TMPTAR"; touch "$TMPTAR"
rm -f "$TMPZIP"; touch "$TMPZIP"
fi
find "$PREFIX" -newer "$CUTOFF" | while read installable
do
# (We still sign PE32 binaries everywhere we find them.)
ext="${installable##*.}"
case "$ext" in
"exe" | "dll")
# FIXME errors are not propagated up from osslsigncode -- troubleshoot!
APPHDR="${1}" TMPDIR="$TMPDIR" "$PREFIX/bin/selfsign.sh" "$installable"
;;
esac
if [ "x$TARGET" != "x$BUILD" ]; then
innerpath=`realpath "$installable" "--relative-to=$PREFIX/$TARGET"`
if [ 'x..' != "x`echo $innerpath | cut -d '/' -f 1`" ]; then
pushd "$PREFIX/$TARGET"
tar --dereference --no-recursion --append -f "$ABSTAR" "$innerpath"
popd
echo "$innerpath" | tee >> "$TMPZIP"
fi
fi
# TODO add to <pkg>.tar.gz
# TODO add to <pkg>.deb
done
if [ -e "$TMPTAR" ]; then
gzip "$TMPTAR" -c > "$OUTTGZ"
echo ln -sf `realpath "$OUTTGZ" "--relative-to=$TGZDIR/latest"` "$TGZDIR/$LATEST.tar.gz"
ln -sf `realpath "$OUTTGZ" "--relative-to=$TGZDIR/latest"` "$TGZDIR/$LATEST.tar.gz"
fi
if [ -e "$TMPZIP" ]; then
pushd "$PREFIX/$TARGET"
# pack a list of files
zip "$ABSZIP" -@ < "$ABSLST"
popd
ln -sf `realpath "$OUTZIP" "--relative-to=$ZIPDIR/latest"` "$ZIPDIR/$LATEST.zip"
fi
# be conservative -- only remove (potentially) expected files here
rm -f "$TMPDIR"/signed* "$TMPTAR" "$TMPZIP"
rmdir "$TMPDIR"