wiki:DebianUbuntuPackaging

Version 221 (modified by martinl, 4 years ago) ( diff )

--

This page contains notes about Debian and Ubuntu packaging.

Debian

Ubuntu

Launchpad

Requirement to upload packages:

Git workflow using the GRASS specific branches

Set up building environment

Install requirements:

sudo apt-get install git-buildpackage
# on Debian also
sudo apt-get install ubuntu-archive-keyring 
Set sudo access

Run

sudo visudo

and add lines bellow:

# Cmnd alias specification
Cmnd_Alias PBUILDERS=/usr/sbin/pbuilder, /usr/sbin/cowbuilder

# User privilege specification
<username>     ALL=(root)     NOPASSWD:SETENV:PBUILDERS
Configuration file

Configuration file for pbuilder ($HOME/.pbuilderrc):

# Optionally set the architecture to the host architecture if none set. Note
# that you can set your own default (i.e. ${ARCH:="i386"}).
###: ${ARCH:="$(dpkg --print-architecture)"}

NAME="$DIST"
if [ -n "${ARCH}" ]; then
    NAME="$NAME-$ARCH"
    DEBOOTSTRAPOPTS=("--arch" "$ARCH" "${DEBOOTSTRAPOPTS[@]}")
fi
BASETGZ="/var/cache/pbuilder/$NAME-base.tgz"
DISTRIBUTION="$DIST"
BUILDRESULT="/var/cache/pbuilder/$NAME/result/"
APTCACHE="/var/cache/pbuilder/$NAME/aptcache/"
BUILDPLACE="/var/cache/pbuilder/build/"

DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" "--keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg")
MIRRORSITE="http://cz.archive.ubuntu.com/ubuntu/"
# OTHERMIRROR="deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu $DIST main"
COMPONENTS="main restricted universe multiverse"

BUILDRESULT=${HOME}/tmp/pbuilder-results
HOOKDIR=${HOME}/pbuilder-hooks
EXTRAPACKAGES="${EXTRAPACKAGES} devscripts gnupg patchutils vim-tiny openssh-client lintian"
ALLOWUNTRUSTED=yes

Define pbuilder hook:

sudo mkdir $HOME/pbuilder-hooks
echo "#!/bin/bash

set -e

apt -y install gnupg
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6B827C12C2D425E227EDCA75089EBE08314DF160" > /root/pbuilder-hooks/G10extra-apt-keys
sudo chmod +x /root/pbuilder-hooks/G10extra-apt-keys

It's a good idea to configure also lintian pbuilder hook:

cp /usr/share/doc/pbuilder/examples/B90lintian /root/pbuilder-hooks/
sed -i 's/lintian -I --show-overrides/& --pedantic -E/; s/^su /##&/; s/^#su /su /' /root/pbuilder-hooks/B90lintian
sudo chmod +x /root/pbuilder-hooks/B90lintian
Create chroot environment

Create specific chroot environment by (example for Ubuntu Bionic - 18.04):

export DIST=bionic
sudo -E cowbuilder --create --distribution=$DIST --basepath=/var/cache/pbuilder/base-${DIST}-ubuntugis-unstable.cow --save-after-login

Build new package

Clone Git repository

mkdir pkg && cd pkg
# debcheckout --user <username> --git-track '*' grass
git clone https://salsa.debian.org/debian-gis-team/grass.git
cd grass
git remote set-url origin --push git@salsa.debian.org:debian-gis-team/grass.git

and checkout selected branch (example for Ubuntu Bionic - 18.04):

export BRANCH=ubuntugis
export PKGNAME=grass
export PATCH=1

export DIST=bionic
export VERSION=7.0.3~rc2
export EXP=~exp1
export NUM=1

Update tarball:

git checkout pristine-tar && git pull
git checkout ${BRANCH}/${DIST} && git pull --rebase

Merge changes related to given tag:

git merge debian/`echo $VERSION | sed 's/~/_/g'`-${PATCH}`echo $EXP | sed 's/~/_/g'`
# solve changelog conflict issues
git checkout ORIG_HEAD -- debian/gbp.conf 

Solve conflict in debian/control file.

Update changelog:

# dch -v ${VERSION}-${PATCH}~exp1~${DIST}${NUM}
dch -b -v $(dpkg-parsechangelog | grep Version: | awk -F': ' '{print $2}')~${DIST}${NUM} -D ${DIST} -m "Rebuild for ${DIST}."

and compare the debian tag to your branch and inspect the diff in the future, it the only changes you should see are the versions for the dependencies and the git branches.

git add debian/changelog
git diff --cached debian/changelog debian/control

Commit changes to Git repository:

git commit -am"Rebuild $VERSION for $DIST"

Build package:

gbp buildpackage --git-pbuilder-options=--source-only-changes -sa --git-pbuilder --git-dist=${DIST}-ubuntugis-unstable >../log.packager-$DIST 2>&1

Note1: use -sa only when build/uploading first package for GRASS version

Note2: replace --git-pbuilder-options=--source-only-changes by -S when using older versions of gbp Note3: all lintian issues of severity info (I:) and higher need to be reviewed and fixed before the upload

cat ../log.packager-$DIST | awk '/+++ lintian output +++/,/+++ end of lintian output +++/' | grep -v ^+++

Tag release version in Git repository:

git tag $BRANCH/`echo $VERSION | sed 's/~/_/g'`-${PATCH}`echo $EXP | sed 's/~/_/g'`.${DIST}${NUM}

Push changes:

git push origin --set-upstream ; git push origin --tags

Upload to Launchpad

Configuration file ~/.dput.cf:

[ubuntugis-experimental]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~ubuntugis/ubuntugis-experimental/ubuntu/
login = <yours-launchpad-id>
allow_unsigned_uploads = 0

Sign created package

debsign ../${PKGNAME}_${VERSION}-${PATCH}${EXP}~${DIST}${NUM}_source.changes

and upload to Launchpad:

dput ubuntugis-experimental ../${PKGNAME}_${VERSION}-${PATCH}${EXP}~${DIST}${NUM}_source.changes

Notes

Create new branch for Ubuntu version

Create a new branch if not exists:

git checkout -b ${BRANCH}/${DIST} debian/`echo $VERSION | sed 's/~/_/g'`-${PATCH}_exp1
git push origin ${BRANCH}/${DIST}

Update branch in gbp.conf & Vcs-Git URL, see example.

Copy packages from Expr to Unstable PPA

Build package from tarball

Warning: this part is out-dated, use Git workflow using the GRASS specific branches instead.

### Based on notes by Ivan Mincik 
### http://lists.osgeo.org/pipermail/grass-dev/2015-January/073444.html

export BASE=7
export MVER=70
export CUR=7.0.1RC1-1
export NEW=7.0.1RC2
export PATCH=1

# 1. Download latest existing version of package from Launchpad
dget https://launchpad.net/~grass/+archive/ubuntu/grass-stable/+files/grass${BASE}_${CUR}~ubuntu14.04.1.dsc

# 2. Prepare working directory with git enabled
mkdir pkg-grass
cd pkg-grass
git init

# 3. Import downloaded version of package from Launchpad
git-import-dsc ../grass${BASE}_${CUR}~ubuntu14.04.1.dsc

# 4. Import new tarball we want to build
(cd .. ; wget http://grass.osgeo.org/grass${MVER}/source/grass-${NEW}.tar.gz)
git-import-orig ../grass-${NEW}.tar.gz

# 5. Optionally, merge Debian packaging
bzr branch lp:~grass/grass/grass70_release_debian debian

### RUN IN LOOP
# Update Debian changelog
dch -i
# enter lines like: 
# grass${BASE} (${NEW}-${PATCH}~ubuntu15.10.1) wily; urgency=medium
# ...
# grass${BASE} (${NEW}-${PATCH}~ubuntu15.04.1) vivid; urgency=medium
# ...
# grass${BASE} (${NEW}-${PATCH}~ubuntu14.04.1) trusty; urgency=medium
# ...
# grass${BASE} (${NEW}-${PATCH}~ubuntu12.04.1) precise; urgency=medium

# Update local Git
git add debian/changelog
git commit -m "Debian changelog update"

# Prepare source upload
git-buildpackage --git-debian-branch=master --git-builder="debuild -S -sa" --git-ignore-new
### LOOP ENDS HERE

# Upload source package for build to Launchpad
dput ppa:grass/grass-stable ../grass${BASE}_${NEW}-${PATCH}~ubuntu15.10.1_source.changes
dput ppa:grass/grass-stable ../grass${BASE}_${NEW}-${PATCH}~ubuntu15.04.1_source.changes
dput ppa:grass/grass-stable ../grass${BASE}_${NEW}-${PATCH}~ubuntu14.04.1_source.changes
dput ppa:grass/grass-stable ../grass${BASE}_${NEW}-${PATCH}~ubuntu12.04.1_source.changes

Notes on GDAL-GRASS extension

Clone repository:

git clone https://salsa.debian.org/debian-gis-team/gdal-grass.git
cd gdal-grass
git remote set-url origin --push git@salsa.debian.org:debian-gis-team/gdal-grass.git

Define variables for packaging:

export BRANCH=ubuntu
export PKGNAME=libgdal-grass
export PATCH=1
export EXP=

export DIST=bionic
export VERSION=2.2.2
export NUM=1

Update cowbuilder:

sudo -E cowbuilder --update --distribution=$DIST --basepath=/var/cache/pbuilder/base-${DIST}-ubuntugis-experimental.cow --save-after-login

Update debian/control file (GRASS minimum version: Build-Depends).

Notes on QGIS packaging

Clone repository:

git clone https://salsa.debian.org/debian-gis-team/qgis.git
cd qgis
git remote set-url origin --push git@salsa.debian.org:debian-gis-team/qgis.git

Note also dependency outside chroot: pkg-kde-tools

Define variables for packaging:

export BRANCH=ubuntu
export PKGNAME=qgis
export PATCH=1
export EXP=

export DIST=bionic
export VERSION=3.4.5+dfsg
export NUM=1
Note: See TracWiki for help on using the wiki.