-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-deb-package
executable file
·98 lines (86 loc) · 2.6 KB
/
make-deb-package
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
#!/bin/sh
# run from anywhere
APP_DIR_FULL=$(realpath "$0")
APP_DIR=$(dirname "$APP_DIR_FULL")
cd "$APP_DIR" || exit 1
# automatic increase minor version number whith each build
VERSION_FILE="version"
VERSION_MAJOR=$(sed -n '1p' $VERSION_FILE)
VERSION_MINOR=$(sed -n '2p' $VERSION_FILE)
VERSION_MINOR_NEW=$((1 + VERSION_MINOR))
sed -i "2 s/$VERSION_MINOR\$/$VERSION_MINOR_NEW/g" $VERSION_FILE
VERSION="$VERSION_MAJOR.$VERSION_MINOR_NEW"
# variables
NAME="cinac"
README="README.md"
RELEASES="releases"
TARGET="DEBIAN"
MAN_PAGE=1
FILE_MAN="$NAME.$MAN_PAGE"
PATH_BASE="./$RELEASES/$NAME-$VERSION"
PATH_INSTALL="$PATH_BASE/usr/local"
PATH_BASH_COMP="$PATH_BASE/usr/share/bash-completion/completions"
PATH_BIN="$PATH_INSTALL/bin"
PATH_SHARE="$PATH_INSTALL/share/$NAME"
PATH_DOCS="$PATH_SHARE/docs"
PATH_BP="$PATH_SHARE/demo-blueprints"
PATH_TARGET="$PATH_BASE/$TARGET"
PATH_MAN="$PATH_INSTALL/share/man/man$MAN_PAGE"
# delete the old build
echo "Cleaning up old build"
rm -rf "$PATH_BASE"
# copy relevant files from source to release
echo "Copying relevant source files"
chmod 0755 "cinac-init" "cinac-load" "cinac-unload" \
"autokiosk_keys"
mkdir -p "$PATH_SHARE" "$PATH_BIN" "$PATH_MAN" "$PATH_BASH_COMP" "$PATH_DOCS" "$PATH_BP"
rsync -rLv "./docs/" "$PATH_DOCS" || exit 1
rsync -rLv "./demo-blueprints/" "$PATH_BP" || exit 1
cp -t "$PATH_SHARE" "README.md" "copyright" "autokiosk_keys" "autokiosk.png" \
"notification.wav" "fail.wav" "favicon.ico" "index-template.html" \
"nginx-site" || exit 1
cp -t "$PATH_BIN" "$NAME" "cinac-init" "cinac-load" "cinac-unload" || exit 1
cp -t "$PATH_BASH_COMP" "bash_completion/cinac" || exit 1
# build man page
ronn -r <"$README" | gzip -9n >"$PATH_MAN/$FILE_MAN" || exit 1
# get description
DESCRIPTION=$(sed -n -e '1 s/^.*) -- //p' <"$README") || exit 1
# create Debian control file
echo "Creating CONTROL file"
mkdir -p "$PATH_TARGET"
echo "Package: $NAME
Version: $VERSION
Section: net
Priority: optional
Architecture: all
Depends: fastpkg,
inventorymaker,
vmh,
wildwest,
fonts-dejavu-core,
xterm,
ufw
Maintainer: Bodo Endres <[email protected]>
Description: $DESCRIPTION
" >"$PATH_TARGET/control"
# build
echo "Building"
fakeroot dpkg-deb --build "$PATH_BASE"
# pack source files
echo "Packing source"
zip -q -r "$RELEASES/$NAME-$VERSION.source.zip" ./* \
-x $RELEASES\* \
-x .*\* \
-x ./*DEV_\*
wait
# replace latest version
cd "$RELEASES" || exit 1
ln -sf "$NAME-$VERSION.deb" "$NAME-LATEST.deb"
ln -sf "$NAME-$VERSION.source.zip" "$NAME-LATEST.source.zip"
cd "$APP_DIR" || exit 1
# clean up
echo "Clean up"
rm -rf "$PATH_BASE"
# check
echo "Checking:"
lintian -c "$PATH_BASE.deb"