You are here: Home / Debian GNU/Linux / System / Software / Backport a Debian package from testing to stable

Backport a Debian package from testing to stable

by Pierre-Yves Landuré last modified Nov 11, 2017 10:40

This how-to ease the upgrade of a software by creating a Debian package from the sources available in testing repositories.

This how-to is tested on:

  • Debian 7.0 Wheezy

This how-to is tested with these softwares:

  • iproute2
  • openvpn (depends on iproute, iproute2)

Warning

The success of a package backport depends greatly on the dependences of the backported software. This post is not an exact step by step how-to for backport. It is a document giving the main steps to create a backport. There is no result warranty.

Prerequisites

This how-to needs:

Parameters

Provide the name of the backported package:

PACKAGE="openvpn"

Setup

Detect the name of the source package for the backported software:

SRC_PACKAGE="$(command apt-cache show "${PACKAGE}" \
    | command grep --max-count=1 "Source:" \
    | command cut --delimiter=' ' --fields=2)"
test -z "${SRC_PACKAGE}" && SRC_PACKAGE="${PACKAGE}"

Environment preparation

Install the needed software:

command apt-get install build-essential fakeroot

Install the build dependencies for the backported package:

command apt-get build-dep "${SRC_PACKAGE}"

Note: in case of failure of this command, try to backport the missing packages.

Downloading the sources

Enter the folder dedicated to sources building:

command pushd '/usr/src'

Fetch the sources of the backported package:

command apt-get source "${SRC_PACKAGE}"

Detect the name of the source folder:

SOURCE_PATH="$(command find '/usr/src' -maxdepth 1 -type d -name "${SRC_PACKAGE}-*" \
    | command sort \
    | command tail -n 1)"

Package building

Enter the sources of the package:

command cd "${SOURCE_PATH}"

Build the backport:

command dpkg-buildpackage -rfakeroot

Note: Ignore the following warning at the end of package creation:

(WARNING: Failed to sign .dsc and .changes file)

Once the build done, exit the sources folder:

command popd

Package installation

Compute the list of created packages:

command cat "${SOURCE_PATH}/debian/files" \
| command cut --delimiter=' ' --fields=1 \
| command sed -e "s|^|$(command dirname "${SOURCE_PATH}")/|"

Install the new packages with 'dpkg -i' or 'gdebi'.

Note: the following command automatically install the packages listed by the previous command:

command cat "${SOURCE_PATH}/debian/files" \
| command cut --delimiter=' ' --fields=1 \
| command sed -e "s|^|$(command dirname "${SOURCE_PATH}")/|" \
| command xargs dpkg -i