-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_deb.sh
executable file
·71 lines (54 loc) · 2.14 KB
/
create_deb.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
#!/bin/bash
# Create a debian package for dalyinski server
# https://senties-martinelli.com/articles/debian-packages
# https://stackoverflow.com/questions/1382569/how-do-i-do-debian-packaging-of-a-python-package
# exit immediatelly if some command below fails
set -e
if [[ -z $1 ]]
then
echo "Usage sudo ./create_deb.sh <version>"
exit 1
fi
TEMPLATE_DIR=debian-pkg/template
VERSION="$1"
OLD_VERSION=$(ls debian-pkg/ | awk -F\- '{ print $2 }')
APP_DIR=debian-pkg/dalyinski-${VERSION}
BINARY_SRC=dist/dalyinski-server
BINARY_DST=${APP_DIR}/usr/bin/
echo "[*] Update version string in .desktop, Debian control file and github workflow files"
sed -i "/Version/s/[[:digit:]]\+\.[[:digit:]]\+/${VERSION}/" ${TEMPLATE_DIR}/usr/share/applications/dalYinski.desktop
sed -i "/Version/s/[[:digit:]]\+\.[[:digit:]]\+/${VERSION}/" ${TEMPLATE_DIR}/DEBIAN/control
# sed -i "s/[[:digit:]]\+\.[[:digit:]]\+/${VERSION}/" .github/workflows/main.yml
echo "[*] Copy scripts to packaging dir"
if [[ ! -d ${APP_DIR}/usr/lib/python3/dist-packages/ ]]
then
mkdir -p ${APP_DIR}/usr/lib/python3/dist-packages/
fi
cp -r ${TEMPLATE_DIR}/* ${APP_DIR}
cp -r dalyinski ${APP_DIR}/usr/lib/python3/dist-packages/
cp dalyinski-server.py ${APP_DIR}/usr/bin/dalyinski-server
# echo "[*] Building the binary..."
# source venv/bin/activate
# pyinstaller --onefile launch.py --name dalyinski-server
# echo "[*] Move built binary to debian-pkg folder"
# mv ${BINARY_SRC} debian-pkg/${BINARY_DST}
echo "[*] Copy everything to /tmp"
sudo cp -r ${APP_DIR} /tmp
echo "[*] Change all the folder permission to root"
sudo chown -R root:root /tmp/dalyinski-${VERSION}
echo "[*] Change the script's permissions to executable"
sudo chmod 0755 /tmp/dalyinski-${VERSION}/usr/bin/dalyinski-server
echo "[*] Build the package"
dpkg -b /tmp/dalyinski-${VERSION}
echo "[*] Move deb package to $(realpath .)"
mv /tmp/dalyinski-${VERSION}.deb $(realpath .)
echo "[*] Cleanup"
if [[ -d /tmp/dalyinski-${VERSION} ]]
then
sudo rm -rf /tmp/dalyinski-${VERSION}
fi
if [[ -d ${APP_DIR}/usr/lib/python3/dist-packages/dalyinski ]]
then
rm -rf ${APP_DIR}/usr/lib/python3/dist-packages/dalyinski
fi
rm -rf ${APP_DIR}