build.sh

Published by mithat on Sunday, 21 June 2009

This is an example build.sh file for use in making SkinnyDebbie deb packages.

Note that by using fakeroot the package files can be owned and the build executed by user.

In the script’s present form, you will have to hand-tweak the PACKAGENAME variable as well as the names and places of the manpages.

#! /bin/bash

# bundles the stuff in 'debian' into a package, doing any needed preprocessing.
# (c) 2009 Mithat Konar
# TODO: get PACKAGENAME from DEBIAN/control file (i.e., make it a runtime constant)
# TODO: make manpage section check for directories and copy as needed.

#==========================
# Set write-time constants
#==========================
# set the PACKAGENAME by hand; should match the package name in DEBIAN/control
PACKAGENAME="skinny-xdm-beautify"
# you will also need to hand-tweak manpage stuff in the "man pages" section below

#=======================
# Set runtime constants
#=======================
APPDIR=`dirname "$0"`
cd -P "$APPDIR"
APPDIR="`pwd`"

PACKAGEROOT="$APPDIR/debian"

#=========================
# Deal with documentation
#=========================
# Quoted comments are from http://www.debian.org/doc/debian-policy/ch-docs.html

#-----------
# man pages
#-----------
# "You should install manual pages in nroff source form, in appropriate places under /usr/share/man ... Manual pages should be installed compressed using gzip -9."

# repeat the following for each manpage in this package 
# be sure to place it in the right destination directory (e.g. man1 vs. man8)

MANPAGENAME=skinnify-xdm.8
DESTDIR="$PACKAGEROOT/usr/share/man/man8"
mkdir -p "$DESTDIR"
gzip -9c "$APPDIR/docs/man/man8/$MANPAGENAME" > "$DESTDIR/$MANPAGENAME.gz"

#-----------
# copyright
#-----------
# "Every package must be accompanied by a verbatim copy of its copyright and distribution license in the file /usr/share/doc/package/copyright. This file must neither be compressed nor be a symbolic link."

mkdir -p "$PACKAGEROOT/usr/share/doc/$PACKAGENAME"
cp -dP "$APPDIR/docs/copyright" "$PACKAGEROOT/usr/share/doc/$PACKAGENAME/copyright"

#-----------
# changelog
#-----------
# "Packages that are not Debian-native must contain a compressed copy of the debian/changelog file from the Debian source tree in /usr/share/doc/package with the name changelog.Debian.gz. ... If the package has only one changelog which is used both as the Debian changelog and the upstream one because there is no separate upstream maintainer then that changelog should usually be installed as /usr/share/doc/package/changelog.gz; if there is a separate upstream maintainer, but no upstream changelog, then the Debian changelog should still be called changelog.Debian.gz. 
# "All of these files should be installed compressed using gzip -9"

changelogName=changelog.Debian
mkdir -p "$PACKAGEROOT/usr/share/doc/$PACKAGENAME"
gzip -9c "$APPDIR/docs/$changelogName" >"$PACKAGEROOT/usr/share/doc/$PACKAGENAME/$changelogName.gz"

# Note 1: I wasn't able to make a package with "changelog.gz" that didn't produce lintian errors, so I changed changelog.gz to changelog.Debian.gz, even though Debian's documentation says that that shouldn't be the case.
# Note 2: Lintial will produce a "new-package-should-close-itp-bug warning" from the changelog for new packages. This is a pseudobug: when new packages are intended to be introduced into the Debian repositories, the intent is announced via a bug. When the package is actually released that bug is closed.

#=====================
# Do the actual build
#=====================
# will build package into this script's directory in 'package_version_arch.deb'
fakeroot dpkg-deb --build debian "$APPDIR"