Skip to content

Instantly share code, notes, and snippets.

@petervanderdoes
Last active April 12, 2017 03:15
Show Gist options
  • Save petervanderdoes/12893534755f2e9f0564e813e4aac7ca to your computer and use it in GitHub Desktop.
Save petervanderdoes/12893534755f2e9f0564e813e4aac7ca to your computer and use it in GitHub Desktop.
My workflow and files for building Ubuntu packages

Intro

These are files I use for creating Ubuntu Packages. It's a semi automated system, including docker images for building the packages.

Layout

  • My general directory for packaging is /d1/development/packaging.
  • Each package has it's own directory, as an example I'll be using Dovecot.
  • The directory /d1/development/packaging contains the file build_package.
  • In the directory /d1/development/packaging/dovecot, there are three directories bin, source, upstream.
  • The bin directory contains the files vars, update_branches, 4_start_packaging.
  • The source directory is a git repository. Each distro I build a package for has it's own branch, the master branch is the lastest upstream release.
  • The upstream directory contains the upstream files of the package and the orig file for Ubuntu packaging will be created here as well.
  • Packages will be created in /d3/packaging/ where each distro has it's own directory. as an example I'll be using zesty
  • Within the /d3/packaging/zesty directory are directories for each package build for that distro.

General work flow

  • Download the latest upstream release and unpack it.
  • Merge the upstream release in the master branch.
  • Tag with the upstream version.
  • Update the file vars.
  • In the source directory run ../bin/update_branches.
  • Checkout the latest distro branch.
  • Using quilt, check all the patches, update, refresh them if needed.
  • Pop all the quilt patches.
  • If patches are refreshed commit them.
  • Repeat the previous three steps for all distro branches.
  • Run the file ../bin/4_start_packaging. Update the changelog as needed during this process, correct the version.
  • Upload the packages to Launchpad for building.
#!/bin/sh
SCRIPT=`realpath $0`
SCRIPTPATH=`dirname $SCRIPT`
. ${SCRIPTPATH}/vars
. ${SCRIPTPATH}/../../build_package
#!/bin/sh
PACKAGE_DIR="/d1/development/packaging/${PACKAGE}"
cd ${PACKAGE_DIR}/source
UPSTREAM_PKG="${PACKAGE}_${TAG}.orig.tar.${ARCHIVE_EXT}"
for DISTRO in ${DISTRO_ARRAY}; do
cd ${PACKAGE_DIR}/source
git checkout ${DISTRO}
dch -l "~${DISTRO}" "New upstream release"
dch -r --distribution ${DISTRO}
git commit -a -m "Updated changelog"
PKGOPTION="-sd"
if [ ! -f ../upstream/${UPSTREAM_PKG} ]; then
PKGOPTION="-sa"
git checkout "master"
mkdir -p ../${DISTRO}/
git archive --format=tar --prefix=${PACKAGE}-${TAG}/ ${FULL_TAG} | ${ARCHIVE} > ../upstream/${UPSTREAM_PKG}
git checkout ${DISTRO}
fi
if [ ! -d "/d3/packaging/${DISTRO}/${PACKAGE}" ]; then
mkdir -p /d3/packaging/${DISTRO}/${PACKAGE}
fi
cd /d3/packaging/${DISTRO}/${PACKAGE}
sudo rm * -rf
cp ${PACKAGE_DIR}/upstream/${UPSTREAM_PKG} .
tar xf ${UPSTREAM_PKG}
cd ${PACKAGE}-${TAG}
if [ ! -z "$PACKAGE_EXTRA" ]; then
mkdir ${PACKAGE_EXTRA}
tar -C ${PACKAGE_EXTRA} -zxf ../upstream/${PACKAGE}_${TAG}.orig-${PACKAGE_EXTRA}.tar.xz
fi
cp ${PACKAGE_DIR}/source/debian . -rv
docker run \
-v /d3/packaging/${DISTRO}/${PACKAGE}:/packaging \
-t petervanderdoes/buildenv-${DISTRO}:${PACKAGE} \
/bin/bash -c "cd /packaging/${PACKAGE}-${TAG}; dpkg-buildpackage -Zxz -S ${PKGOPTION} -us -uc"
cd ..
debsign *.changes
done
#!/bin/sh
SCRIPT=`realpath $0`
SCRIPTPATH=`dirname $SCRIPT`
. ${SCRIPTPATH}/vars
warn() { echo "$@" >&2; }
die() { warn "Fatal: $@"; exit 1; }
if [ -z $1 ]; then
echo "Need a version as parameter"
exit 127
else
VERSION=$1
fi
[ -n "$(git for-each-ref --format='%(refname:short)' refs/tags/$VERSION)" ] || die "Invalid tag"
for DISTRO in ${DISTRO_ARRAY}; do
git checkout $DISTRO
git merge $VERSION
done
git checkout master
#!/bin/sh
# The version of the package. This needs to be without any prequels as it's also used to created the orig package.
TAG="2.2.29"
# All the distros this package is build for.
DISTRO_ARRAY="zesty yakkety xenial trusty"
# The package name
PACKAGE="dovecot"
# The tag as used by the upstream and in git. This can have a prequel.
FULL_TAG="${TAG}"
# The archive command and extension for the archive.
ARCHIVE="xz -c"
ARCHIVE_EXT="xz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment