This is an old revision of the document!


Use this skeleton script for your deb package.

#!/bin/bash -e
 
## Needful things
 
# Compute Installed-Size.
# It sums up the byte size of the directory tree given, then returns
# kilos.
# ex:
#     $ size_of_tree package/
size_of_tree() {
    python3 - "$1" <<EOF
import os, sys
gs = lambda p: os.stat(p).st_size
ctr, i = 0, 1
try:
    for d, dn, fn in os.walk(sys.argv[1]):
        if i:
            i = 0
            dn.remove("DEBIAN")
        for f in fn:
            ctr += gs(os.path.join(d, f))
    print(ctr // 1000)
except:
    print("???")
EOF
}
 
# Compute a md5sums control file.
# It uses recursion to walk the paths given to it in argv.
# ex:
#     $ md5_walk_dir package/usr package/etc
md5_walk_dir() {
    while (( "$#" )); do
        for file in $1/*; do
            if [[ $(basename $file) == "DEBIAN" ]]; then
                true
            elif [[ -d $file ]]; then
                md5_walk_dir "$file"
            elif [[ -f $file ]]; then
                echo "$(md5sum $file | cut -d " " -f 1)  $file"
            fi
        done
 
        shift
    done
}
 
## clean up from last time
rm *.deb || true
rm -rf package || true
rm -rf src || true
 
# PACKAGE_INFO? see https://wiki.tox.chat/developers/jenkins/packaging
set -a
source PACKAGE_INFO
set +a
 
mkdir -p package/DEBIAN
 
## Set up your package's files here.
## "package/" acts as the filesystem root.
 
INSTALLED_SIZE=$(size_of_tree package)
PACKAGE_VERS="$VERSION-$(echo $GIT_REF | cut -c 1-7)"
PACKAGE_NAME="$PROGRAM_NAME-$ARCH-$PACKAGE_VERS.deb"
 
## Change these to your liking. Be aware that shell expansion will happen here.
## For a literal $, use \$.
> package/DEBIAN/control cat <<EOF
Package: $PROGRAM_NAME
Version: $PACKAGE_VERS
License: GPLv3+
Vendor: Project Tox
Architecture: $ARCH
Maintainer: Project Tox <support@tox.chat>
Installed-Size: $INSTALLED_SIZE
Depends: < Dependencies go here, if you have any. >
Conflicts: < Packages that you conflict with, if any. >
Section: default
Priority: extra
Homepage: https://tox.chat
Description: The best Tox client.
EOF
 
md5_walk_dir package/* >> package/DEBIAN/md5sums
fakeroot dpkg-deb -b package && mv package.deb "$PACKAGE_NAME"
echo "$PACKAGE_NAME ready."
Print/export