#!/bin/sh # Make .deb package # Usage: make-deb-package data control [-o p.deb] [-postinst postinst] [-postrm postrm] # Yves Piguet, 3 Sept 2008, http://nyctergatis.com # help if [ "$1" == --help -o -z "$1" -o -z "$2" ] then echo "Usage: $0 data control [-o p.deb] [-postinst postinst] [-postrm postrm]" echo "data: directory to be unarchived at the root of the target file system" echo "control: debian control file" echo "p.deb: output package file" echo "postinst: shell script to execute after installation" echo "postrm: shell script to execute after removal" exit 0 fi # default values DIR="$1" CONTROL="$2" DEB="$DIR".deb POSTINST="" POSTRM="" if [ -n "$TMPDIR" ] then TMP=$TMPDIR"debian-tmp" else TMP=/tmp/debian-tmp fi # decode optional arguments while [ -n "$3" ] do case "$3" in -o) DEB="$4" ;; -postinst) POSTINST="$4" ;; -postrm) POSTRM="$4" ;; *) echo "Unknown option $3" >&2 echo "Type $0 --help for help" >&2 exit 1 ;; esac shift shift done # create temporary directory rm -Rf "$TMP" mkdir "$TMP" # debian-binary echo 2.0 >"$TMP"/debian-binary # control.tar.gz mkdir "$TMP"/control cp "$CONTROL" "$TMP"/control/control if [ -n "$POSTINST" ] then cp "$POSTINST" "$TMP"/control/postinst chmod +x "$TMP"/control/postinst fi if [ -n "$POSTRM" ] then cp "$POSTRM" "$TMP"/control/postrm chmod +x "$TMP"/control/postrm fi (cd "$TMP"/control; COPY_EXTENDED_ATTRIBUTES_DISABLE=true tar cfz ../control.tar.gz *) # data.tar.gz (cd "$DIR"; COPY_EXTENDED_ATTRIBUTES_DISABLE=true tar cfz "$TMP"/data.tar.gz *) # deb ar -q "$DEB" \ "$TMP"/debian-binary "$TMP"/control.tar.gz "$TMP"/data.tar.gz # clean up rm -Rf $TMP exit 0