Utilizzare pbuilder per compilare pacchetti debian di architetture diverse

From RVM Wiki
Jump to navigation Jump to search

Su un host AMD64 si possono compilare pacchetti per i386 e amd64.

TODO

Installazione e configurazione di Pbuilder

  • Installare pbuilder
sudo aptitude install pbuilder debootstrap devscripts cdebootstrap
  • Configuralo in modo da supportare più architetture e distribuzioni settando delle variabili:

(Vedi *Using Pbuilder for making Debian and/or Ubuntu Packages | MegaTunix)

cat > /root/.pbuilderrc <<'EOFile'
# Proxy configuration
# Uncomment the next line if using apt-cacher-ng on the local machine
#export http_proxy=http://localhost:3142/
# Uncomment the next line if using squid-deb-proxy on the local machine.
#export http_proxy=http://localhost:8000/

# Codenames for Debian suites according to their alias. Update these when needed.
UNSTABLE_CODENAME="sid"
TESTING_CODENAME="jessie"
STABLE_CODENAME="wheezy"
STABLE_BACKPORTS_SUITE="$STABLE_CODENAME-backports"

# List of Debian suites.
DEBIAN_SUITES=($UNSTABLE_CODENAME $TESTING_CODENAME $STABLE_CODENAME
"unstable" "testing" "stable")

# List of Ubuntu suites. Update these when needed.
UBUNTU_SUITES=("saucy" "raring" "quantal" "precise" "trusty")

# Mirrors to use. Update these to your preferred mirror.
DEBIAN_MIRROR="ftp.us.debian.org"
UBUNTU_MIRROR="mirrors.kernel.org"

# Optionally use the changelog of a package to determine the suite to use if
# none set.
if [ -z "${DIST}" ] && [ -r "debian/changelog" ]; then
DIST=$(dpkg-parsechangelog | awk '/^Distribution: / {print $2}')
# Use the unstable suite for certain suite values.
if $(echo "experimental UNRELEASED" | grep -q $DIST); then
DIST="$UNSTABLE_CODENAME"
fi
fi

# Optionally set a default distribution if none is used. Note that you can set
# your own default (i.e. ${DIST:="unstable"}).
: ${DIST:="$(lsb_release --short --codename)"}

# Optionally change Debian release states in $DIST to their names.
case "$DIST" in
unstable)
DIST="$UNSTABLE_CODENAME"
;;
testing)
DIST="$TESTING_CODENAME"
;;
stable)
DIST="$STABLE_CODENAME"
;;
esac

# 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"
# Optionally, set BASEPATH (and not BASETGZ) if using cowbuilder
# BASEPATH="/var/cache/pbuilder/$NAME/base.cow/"
DISTRIBUTION="$DIST"
BUILDRESULT="/var/cache/pbuilder/$NAME/result/"
APTCACHE="/var/cache/pbuilder/aptcache/$NAME/"
BUILDPLACE="/var/cache/pbuilder/build/"

if $(echo ${DEBIAN_SUITES[@]} | grep -q $DIST); then
# Debian configuration
MIRRORSITE="http://$DEBIAN_MIRROR/debian/"
COMPONENTS="main contrib non-free"
# This is for enabling backports for the Debian stable suite.
#if $(echo "$STABLE_CODENAME stable" | grep -q $DIST); then
# EXTRAPACKAGES="$EXTRAPACKAGES debian-backports-keyring"
# OTHERMIRROR="$OTHERMIRROR | deb http://www.backports.org/debian $STABLE_BACKPORTS_SUITE $COMPONENTS"
#fi
elif $(echo ${UBUNTU_SUITES[@]} | grep -q $DIST); then
# Ubuntu configuration
MIRRORSITE="http://$UBUNTU_MIRROR/ubuntu/"
COMPONENTS="main restricted universe multiverse"
else
echo "Unknown distribution: $DIST"
exit 1
fi
EOFile
  • Creare le tarball per la chroot delle due architetture:
sudo -i
DIST=wheezy ARCH=amd64 pbuilder --create --debootstrap debootstrap --debootstrapopts --keyring=/usr/share/keyrings/debian-archive-keyring.gpg
sudo DIST=lenny ARCH=i386 pbuilder create -debootstrapopts --variant=buildd
sudo DIST=lenny ARCH=amd64 pbuilder create -debootstrapopts --variant=buildd

Aggiornamento della tarball image

  • Prima di ogni build, è meglio aggiornare la relativa immagine ad esempio con:
 sudo DIST=lenny ARCH=i386 pbuilder update

Compilazione di un pacchetto con file .dsc

  • Ipotizzando di avere già un pacchetto da compilare con un file .dsc, invece di usare dpkg-buildpackage, usare:
sudo DIST=lenny ARCH=i386 pbuilder build iptables-initd_1.0.0-4.dsc
  • I pacchetti risultanti saranno in
/var/cache/pbuilder/lenny-i386/result/
  • Se si devono utilizzare delle opzioni da passare dpkg-buildpackage, usarle così:
export DEBFULLNAME="Gabriele Vivinetto"
export DEBEMAIL=gabriele.mailing@rvmgroup.it
sudo DIST=lenny ARCH=i386 pbuilder build --debbuildopts -kF6D289F6 -tc pigz_2.1.6-1.dsc


Compilazione di un pacchetto per backport

  • Prelevare i sorgenti con:
dget http://ftp.de.debian.org/debian/pool/main/a/amanda/amanda_3.2.1-1.1.dsc
  • Oppure manualmente dalla pagine del pacchetto source di packages.debian.org
  • A questo punto proseguire come al punto precedente

Compilazione di un pacchetto con sorgenti

  • Utilizzare pdebuild, che produce i .dsc, e poi proseguire
sudo DIST=squeeze ARCH=amd64 pdebuild
sudo DIST=squeeze ARCH=amd64 pbuilder build iptables-initd_1.0.0-5.dsc

Riferimenti