Create a little helper

Let's create a little script which creates the minimum of files we need for a package.

Works well if you just want to package a bunch of files

mkdir -p ~/packaging/mkdeb/

~/packaging/mkdeb/mkdeb

#!/usr/bin/env bash

#
# Usage
#

if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
  echo
  echo "  mkdeb [package_name] (default: basename of \$PWD)"
  echo
  exit
fi

TAB="$(printf '\t')"

#
# Package name
#

if [[ -z ${1} ]]; then
  PKG=$(basename ${PWD})
else
  PKG=${1}
fi

#
# Email
#

if [[ ${DEBEMAIL} == *@* ]]; then
  EMAIL=${DEBEMAIL}
else
  EMAIL="${USER}@${HOSTNAME}"
fi

#
# Fullname
#

NAME=$(getent passwd ${USER} | awk -F: '{print $5}')

if [[ ${NAME} =~ [0-9a-zA-Z] ]]; then
  FULL_NAME=${NAME}
else
  FULL_NAME=${USER}
fi

#
# debian/
#

if [[ -d debian ]]; then
  echo "There is already a debian folder"
  exit
fi

echo
echo "Creating debian/"
mkdir debian

#
# debian/rules
#
   
echo "Creating debian/rules"

cat << EOF > debian/rules
#!/usr/bin/make -f

%:
${TAB}dh \$@
EOF

chmod +x debian/rules

#
# debian/install
#

echo "Creating debian/install"

cat << EOF > debian/install
${PKG} usr/bin
EOF

#
# debian/changelog
#

echo "Creating debian/changelog"

cat << EOF > debian/changelog
${PKG} (0.1-1) unstable; urgency=medium

  * Initial release

 -- ${FULL_NAME} <${EMAIL}>  $(date "+%a, %d %b %Y %T %z")
EOF

#
# debian/control
#

echo "Creating debian/control"

cat << EOF > debian/control
Source: ${PKG}
Section: utils
Priority: optional
Maintainer: ${FULL_NAME} <${EMAIL}>
Build-Depends: debhelper-compat (= 12)
Standards-Version: 4.6.0
Homepage: https://${PKG}.de

Package: ${PKG}
Architecture: all
Depends: \${misc:Depends}
Description: short description of ${PKG}
 Long description of ${PKG}

EOF

You could use this shell script as is
but of course we make a package out of it

~/packaging/mkdeb/debian/control

Source: mkdeb
Section: utils
Priority: optional
Maintainer: Sven Wick <sven.wick@gmx.de>
Build-Depends: debhelper-compat (= 12)
Standards-Version: 4.6.0
Homepage: https://vaporup.github.io/books/the-pragmatic-sysadmin

Package: mkdeb
Architecture: all
Depends: bash
Description: quickly create the files for a deb package
 mkdeb creates the minimum of files
 to quickly prepare a Debian package

~/packaging/mkdeb/debian/install

mkdeb usr/bin

~/packaging/mkdeb/debian/changelog

mkdeb (0.1-1) unstable; urgency=medium

  * Initial release

 -- Sven Wick <sven.wick@gmx.de>  Sun, 12 Dec 2021 02:14:45 +0100

~/packaging/mkdeb/debian/rules

#!/usr/bin/make -f

%:
    dh $@
  • The rules file is a Makefile and MUST be executable ( chmod +x )
  • The line with dh MUST be indented with a TAB (not spaces)
cd ~/packaging/mkdeb
dpkg-buildpackage -uc -us