From e0c8365b2b0f909c47a64ad6fb04bad0b551dca7 Mon Sep 17 00:00:00 2001 From: codehelp Date: Mon, 3 May 2010 12:56:16 +0000 Subject: [PATCH] Add support for configurable single cross-toolchains in the chroot - using the dpkg-cross default_arch, if any. git-svn-id: http://emdebian.org/svn/current@7167 563faec7-e20c-0410-992a-a66f704d0ccd --- cross/armel.conf | 2 +- cross/mips.conf | 2 +- cross/mipsel.conf | 2 +- cross/powerpc.conf | 2 +- cross/setcrossarch.sh | 56 +++++++++++++++++++++++++++++++++++++++ debian/changelog | 3 ++- debian/control | 8 +++--- debian/multistrap.install | 2 ++ multistrap | 9 ++----- pod/multistrap | 14 ++++++++-- 10 files changed, 82 insertions(+), 18 deletions(-) create mode 100755 cross/setcrossarch.sh diff --git a/cross/armel.conf b/cross/armel.conf index 460c954..6582b99 100644 --- a/cross/armel.conf +++ b/cross/armel.conf @@ -2,7 +2,7 @@ include=/usr/share/multistrap/crosschroot.conf omitrequired=false configscript= -setupscript= +setupscript=/usr/share/multistrap/setcrossarch.sh debootstrap=Debian Base Toolchains aptsources=Debian Toolchains tarballname=pdebuild-cross.tgz diff --git a/cross/mips.conf b/cross/mips.conf index f02224e..f5cde2e 100644 --- a/cross/mips.conf +++ b/cross/mips.conf @@ -2,7 +2,7 @@ include=/usr/share/multistrap/crosschroot.conf omitrequired=false configscript= -setupscript= +setupscript=/usr/share/multistrap/setcrossarch.sh debootstrap=Debian Base Toolchains aptsources=Debian Toolchains tarballname=pdebuild-cross.tgz diff --git a/cross/mipsel.conf b/cross/mipsel.conf index 5d76e56..0460acc 100644 --- a/cross/mipsel.conf +++ b/cross/mipsel.conf @@ -2,7 +2,7 @@ include=/usr/share/multistrap/crosschroot.conf omitrequired=false configscript= -setupscript= +setupscript=/usr/share/multistrap/setcrossarch.sh debootstrap=Debian Base Toolchains aptsources=Debian Toolchains tarballname=pdebuild-cross.tgz diff --git a/cross/powerpc.conf b/cross/powerpc.conf index 942b748..f89d00d 100644 --- a/cross/powerpc.conf +++ b/cross/powerpc.conf @@ -2,7 +2,7 @@ include=/usr/share/multistrap/crosschroot.conf omitrequired=false configscript= -setupscript= +setupscript=/usr/share/multistrap/setcrossarch.sh debootstrap=Debian Base Toolchains aptsources=Debian Toolchains tarballname=pdebuild-cross.tgz diff --git a/cross/setcrossarch.sh b/cross/setcrossarch.sh new file mode 100755 index 0000000..df258a9 --- /dev/null +++ b/cross/setcrossarch.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +set -e + +# Copyright (C) 2009, 2010 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# meant to be called from multistrap with directory arch variables. +dir=$1 +hostarch=$2 + +if [ -z "$dir" ]; then + echo "No directory specified." + exit 1 +fi + +cfg="/etc/pdebuild-cross/pdebuild-cross.rc" +if [ -f $cfg ]; then + . $cfg +fi + +if [ -z "$CROSSARCH" ]; then + # get crossarch from dpkg-cross - check if it is not None + if [ -f /etc/dpkg-cross/cross-compile ]; then + DEFARCH=`grep "^default_arch" /etc/dpkg-cross/cross-compile|sed -e 's/default_arch *= *\(.*\)/\1/'` + if [ -n "$DEFARCH" -a "$DEFARCH" != "None" ]; then + CROSSARCH="$DEFARCH" + fi + else + echo "No CROSSARCH set in '$cfg' and no dpkg-cross default: using armel." + CROSSARCH="armel" + fi +fi + +# set the value inside the chroot +echo "#!/bin/sh" > $dir/tmp/set.sh +echo >> $dir/tmp/set.sh +echo "export DEBIAN_FRONTEND=noninteractive ". + "DEBCONF_NONINTERACTIVE_SEEN=true ". + "LC_ALL=C LANGUAGE=C LANG=C" >> $dir/tmp/set.sh +echo "echo debconf dpkg-cross/default-arch select $CROSSARCH|debconf-set-selections" >> $dir/tmp/set.sh +echo "dpkg-reconfigure dpkg-cross" >> $dir/tmp/set.sh +sudo chroot $dir sh /tmp/set.sh +sudo rm $dir/tmp/set.sh diff --git a/debian/changelog b/debian/changelog index 92ab66c..593c57e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ multistrap (2.1.4) experimental; urgency=low - * Add support for multiple cross-toolchains in the chroot + * Add support for configurable single cross-toolchains in + the chroot - using the dpkg-cross default_arch, if any. -- Neil Williams Fri, 30 Apr 2010 18:11:16 +0100 diff --git a/debian/control b/debian/control index e282727..afd63ab 100644 --- a/debian/control +++ b/debian/control @@ -3,12 +3,12 @@ Section: utils Priority: optional Maintainer: Neil Williams Uploaders: Wookey -Build-Depends: cdbs, debhelper (>= 5), po4a (>= 0.37.1), po-debconf -Build-Depends-Indep: devscripts, gnupg, intltool +Build-Depends: cdbs, debhelper (>= 5), po4a (>= 0.37.1) +Build-Depends-Indep: intltool Standards-Version: 3.8.4 Homepage: http://www.emdebian.org/multistrap -Vcs-Browser: http://buildd.emdebian.org/svn/browser/current/host/trunk/emdebian-rootfs/trunk/ -Vcs-Svn: http://buildd.emdebian.org/repos/current/host/trunk/emdebian-rootfs/trunk/ +Vcs-Browser: http://buildd.emdebian.org/svn/browser/current/ +Vcs-Svn: http://buildd.emdebian.org/repos/current/ Package: multistrap Section: admin diff --git a/debian/multistrap.install b/debian/multistrap.install index d710c2f..caeb315 100644 --- a/debian/multistrap.install +++ b/debian/multistrap.install @@ -13,3 +13,5 @@ update-rc.d ./usr/share/multistrap/ bash/multistrap ./etc/bash_completion.d/ cross/*.conf ./usr/share/multistrap/ cross/test.c ./usr/share/multistrap/ +cross/setcrossarch.sh ./usr/share/multistrap/ +cross/functions ./usr/share/multistrap/ diff --git a/multistrap b/multistrap index 189ef3f..4334813 100755 --- a/multistrap +++ b/multistrap @@ -160,10 +160,6 @@ system ("mkdir -p ${dir}etc/apt/preferences.d/") system ("mkdir -p ${dir}usr/share/info/") if (not -d "${dir}usr/share/info/"); system ("touch ${dir}usr/share/info/dir"); -#system ("mkdir -p ${dir}/usr/share/doc/gcc-4.2-base/") -# if (not -d "${dir}/usr/share/doc/gcc-4.2-base/"); -#system ("touch ${dir}/usr/share/doc/gcc-4.2-base/.copyright"); -#system ("touch ${dir}/usr/share/doc/gcc-4.2-base/#changelog.Debian.gz"); my $msg = sprintf(_g("Unable to create directory '%s'\n"), "${dir}etc/apt/preferences.d/"); die ($msg) if (not -d "${dir}etc/apt/preferences.d/"); @@ -348,9 +344,9 @@ print "apt-get $forceyes -y $config_str install $str\n"; $retval = system ("apt-get -y $config_str install $str"); die (sprintf (_g("apt download failed. Exit value: %d\n"),($retval/256))) if ($retval != 0); -system ("$setupsh $dir $arch") if (defined $setupsh); +system ("$setupsh $dir $arch") if ((defined $setupsh) and (-f $setupsh)); &force_unpack if ($unpack eq "true"); -system ("cp $configsh $dir/") if ((defined $configsh) and (-f "$configsh")); +system ("cp $configsh $dir/") if ((defined $configsh) and (-f $configsh)); system ("touch ${dir}${libdir}lists/lock"); &native if (not defined ($foreign)); &add_extra_packages; @@ -863,7 +859,6 @@ sub cascade $value = $key if (ref $key eq "HASH"); $keys{$type} = $value; } - foreach $section (sort keys %keys) { if ($section eq "general") diff --git a/pod/multistrap b/pod/multistrap index d6df2aa..db3fc7f 100644 --- a/pod/multistrap +++ b/pod/multistrap @@ -11,7 +11,12 @@ multistrap - extends debootstrap for multiple repository support =head1 Options -(These options can also be set in the configuration file.) +--dry-run - collate all the configuration settings and output a +bare summary. + +--simulate - same as --dry-run + +(The following options can also be set in the configuration file.) --tidy-up - remove apt cache data, downloaded Packages files and the apt package cache. Same as cleanup=true. @@ -19,6 +24,11 @@ the apt package cache. Same as cleanup=true. --no-auth - allow the use of unauthenticated repositories. Same as noauth=true +--sourcedir DIR - move the contents of var/cache/apt/archives/ from +inside the chroot to the specified external directory. Same as +retainsources=DIR + + =head1 Description multistrap provides a debootstrap-like method based on apt and @@ -46,10 +56,10 @@ Example configuration: # the /etc/apt/sources.list.d/multistrap.sources.list # of the target. Order is not important aptsources=Grip Updates - # the order of sections is not important. # the bootstrap option determines which repository # is used to calculate the list of Priority: required packages # and which packages go into the rootfs. + # The order of sections is not important. bootstrap=Debian [Debian]