#!/bin/sh set -e -x NAME="server22" PATH_TMP="/tmp/$NAME" PATH_USR="$PATH_TMP/usr" # Deletes server22 dir from /tmp if exists (that was for testing) sudo rm -rf $PATH_TMP # Python installation executed, for debian layout and install it to /tmp/server22 python3 setup.py install --install-layout deb --root $PATH_TMP # Remove .egg-info and build dir from root folder sudo rm -rf ./src/$NAME.egg-info sudo rm -rf ./build # Show actual tree of root dir to the user tree # Copy /DEBIAN to /tmp/$NAME sudo cp -R ./DEBIAN $PATH_TMP # Deletes __pycache__ from /tmp/$NAME sudo rm -r $PATH_USR/lib/python3/dist-packages/$NAME/__pycache__ # Creates a dir: /tmp/$NAME/usr/share/doc/$NAME/ mkdir $PATH_USR/share/ mkdir $PATH_USR/share/doc mkdir $PATH_USR/share/doc/$NAME/ # Copy share folder with subdirs to PATH_USR sudo cp -r -v share $PATH_USR # Zip the changelog sudo gzip -9 -n $PATH_USR/share/doc/server22/changelog # Change owners sudo chown -R 0:50 $PATH_TMP sudo chown -R 0:0 $PATH_USR/share # Delete write permissions from group sudo chmod -R g-w $PATH_USR # Show actual tree of /tmp/$NAME dir to the user tree $PATH_TMP # dpkg will pack this modified folder to .deb dpkg -b $PATH_TMP # Show lintian output to the user. If there will be some red E, means that installation was not successful lintian -c $PATH_TMP.deb # Rename .deb package (name_of_the_package-version-binary) dpkg-name -o $PATH_TMP.deb