-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathpkg-build-deb
More file actions
executable file
·154 lines (128 loc) · 2.83 KB
/
pkg-build-deb
File metadata and controls
executable file
·154 lines (128 loc) · 2.83 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
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
#!/bin/sh -ex
case "$0" in
/*) SCRIPTDIR=`dirname "$0"`;;
*) SCRIPTDIR=`pwd`/`dirname "$0"`;;
esac
BASEDIR=`dirname "$SCRIPTDIR"`
BASEDIR=`dirname "$BASEDIR"`
PATH="$PATH:$SCRIPTDIR"
usage()
{
exec >&2
echo "$0 <pkgname> <tests> <cross-target/native> <optimize> <debugsymbols> <version>"
exit 1
}
fatal()
{
echo "$@" >&2
exit 42
}
if [ $# -ne 6 ]; then
usage
fi
PKGNAME="$1"
TESTS="$2"
TARGET="$3"
OPTIMIZE="$4"
DEBUGSYM="$5"
VERSION="$6"
P=$BASEDIR/buildscripts/deps-packaging/$PKGNAME
PKGDIR=$BASEDIR/$PKGNAME/pkg
# Copy source code
rm -rf $BASEDIR/$PKGNAME
mkdir -p $PKGDIR
SRCFILES=$(pkg-get-src $P)
echo "$SRCFILES" | while read srcfile opts; do
case "$srcfile" in
*.gz|*.tgz)
UNCOMPRESS=zcat;;
*.bz2)
UNCOMPRESS=bzcat;;
*.xz)
UNCOMPRESS=xzcat;;
*)
echo "Unknown compression: $srcfile"
exit 42;;
esac
if [ x$opts = xsubdir ]; then
$UNCOMPRESS $srcfile | tar -C $PKGDIR -xf -
else
TD=/tmp/`basename $srcfile`.$$
mkdir -p "$TD"
$UNCOMPRESS $srcfile | tar -C $TD -xf -
mv $TD/*/* $PKGDIR
# Also move dot files (.gitignore, etc.), skipping . and ..
for _dotfile in $TD/*/.*; do
case "${_dotfile##*/}" in
.|..) continue ;;
*) mv "$_dotfile" "$PKGDIR" ;;
esac
done
rm -r "$TD"
fi
done
cp -a $P/. $PKGDIR
# Prepare options
case "$TARGET" in
native)
;;
*)
if [ -d $PKGDIR/mingw ]; then
rm -rf $PKGDIR/debian
mv $PKGDIR/mingw/debian $PKGDIR
fi
case "$TARGET" in
x86)
ARCH_OPTIONS="-ti686-w64-mingw32";;
x64)
ARCH_OPTIONS="-tx86_64-w64-mingw32";;
*)
fatal "Unknown architecture: $ARCH" 2>&1;;
esac
# Architecture needs to be the build machine architecture, since we will
# install the package on that machine afterwards and the package
# architecture needs to match.
case "$(uname -m)" in
i*86)
ARCH_OPTIONS="$ARCH_OPTIONS -ai386";;
x86_64)
ARCH_OPTIONS="$ARCH_OPTIONS -aamd64";;
*)
fatal "Unknown architecture" 2>&1;;
esac
;;
esac
case "$TESTS" in
no)
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS nocheck";;
yes)
;;
*)
fatal "Unknown tests option: $TESTS";;
esac
case "$OPTIMIZE" in
no)
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS noopt";;
yes)
;;
*)
fatal "Unknown optimize option: $OPTIMIZE";;
esac
case "$DEBUGSYM" in
yes)
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS nostrip";;
no)
;;
*)
fatal "Unknown debugsym option: $DEBUGSYM";;
esac
BUILDDATE=$(date -R)
cat << EOF > $PKGDIR/debian/changelog
cfbuild-$PKGNAME ($VERSION) unstable; urgency=low
* New build.
-- CFEngine Autobuild System <[email protected]> $BUILDDATE
EOF
# Build!
cd $PKGDIR
export DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS"
dpkg-buildpackage $ARCH_OPTIONS -b -us -uc -rfakeroot