Skip to content

Instantly share code, notes, and snippets.

@nunogrl
Created April 18, 2020 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nunogrl/a2122120b77b40c391cfbe215c678ba6 to your computer and use it in GitHub Desktop.
Save nunogrl/a2122120b77b40c391cfbe215c678ba6 to your computer and use it in GitHub Desktop.
create a deb file from an existing directory tree
#/bin/sh
# usage:
# version=123 sh create_debpackage.sh
package=bcwebsite
# version=234
if [ ! -d ${package} ]; then
mkdir -p ${package}/DEBIAN
cat << EOF1 > ${package}/DEBIAN/control
Package: bcwebsite
Version: ${version}
Architecture: amd64
Depends:
Maintainer: Nuno Leitao <nunogrl@gmail.com>
Description: SMF engine to serve Barbear Classico site.
EOF1
cat << EOF2 > ${package}/DEBIAN/postinst
#!/bin/sh
set -e
echo "this is the postinstall"
#Move the bootstrap file to proper location
# mv /opt/myPackage/packaging/bootstrap.prod /opt/myPackage/.bootstraprc
#Clear the DEBIAN folder
# rm -rf /opt/myPackage/packaging/DEBIAN
EOF2
cat << EOF3 > ${package}/DEBIAN/preinst
#!/bin/sh
echo "Do something"
EOF3
chmod 755 bcwebsite/DEBIAN/*inst
fi
ver=$(grep Version ${package}/DEBIAN/control | cut -d" " -f2)
newver=$(( $ver + 1 ))
sed -i "s/Version: .*/Version: $newver/g" bcwebsite/DEBIAN/control
tar cf - /opt/nci | (cd ${package} ; tar xf -)
dpkg-deb --build ${package} && dpkg-name -o -s .. ${package}.deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment