-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-package.sh
executable file
·64 lines (53 loc) · 1.45 KB
/
build-package.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
#!/bin/sh -e
_SCRIPT_DIR="$( cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P )"
ARCHITECTURE=x64
CONFIGURATION=Debug
while [ $# -gt 0 ]; do
case "$1" in
--architecture|-a)
ARCHITECTURE=$2
shift
;;
--configuration|-c)
CONFIGURATION=$2
shift
;;
*)
echo "Invalid argument: $1"
exit 1
;;
esac
shift
done
dpkgdir="$_SCRIPT_DIR/src/dpkg"
destination=`mktemp -d`
echo "temporary package location: $destination"
# copy the files
cp -r $dpkgdir/* $destination
# create the directory structure
mkdir -p $destination/usr/share/bcad
# copy the files
cp -r $_SCRIPT_DIR/artifacts/publish/$CONFIGURATION/bcad-linux-$ARCHITECTURE/* $destination/usr/share/bcad
# map the architecture
LINUX_ARCHITECTURE=$ARCHITECTURE
case "$ARCHITECTURE" in
x64)
LINUX_ARCHITECTURE=amd64
;;
# arm64 is already correct
esac
# patch the control file
size=$(du -s $destination/usr/share/bcad | cut -f1)
versionPrefix=$(cat $_SCRIPT_DIR/version.txt)
versionSuffix="0"
if [ "$VERSION_SUFFIX" != "" ]; then
versionSuffix="$VERSION_SUFFIX"
fi
version="$versionPrefix.$versionSuffix"
sed -i "s/%ARCHITECTURE%/$LINUX_ARCHITECTURE/" $destination/DEBIAN/control
sed -i "s/%SIZE%/$size/" $destination/DEBIAN/control
sed -i "s/%VERSION%/$version/" $destination/DEBIAN/control
# now build the package
dpkg-deb --build $destination $_SCRIPT_DIR/artifacts/packages/$CONFIGURATION
# clean up
rm -rf $destination