From: Andres Salomon Date: Tue, 28 Oct 2008 04:56:24 +0000 (-0400) Subject: initchroot: change up the mirror handling X-Git-Tag: v0.3~8 X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d92506af5d462b3ce814abb5e982f95e5f74ae9b;p=xodist initchroot: change up the mirror handling Rather than specifying fragments of sources.list on the command line, just specify the whole thing. --apt-sources allows you to specify the /etc/apt/sources.list that will be shipped, and --local-apt-mirror allows you to specify a local mirror to use (ie, if approx is being used) when building the chroot. --distribution, --mirror, and --othermirror have been dropped. Signed-off-by: Andres Salomon --- diff --git a/README.approx b/README.approx index f93bb4a..c5616c0 100644 --- a/README.approx +++ b/README.approx @@ -21,5 +21,7 @@ add the --mirror option, like this: sudo ./initchroot.sh \ --package-list kde.packages \ - --mirror http://localhost:9999/debian kde.root + --local-apt-mirror "deb http://localhost:9999/debian lenny main contrib non-free +deb http://localhost:9999/security lenny/updates main contrib non-free" \ + kde.root diff --git a/initchroot.sh b/initchroot.sh index 0818015..d657170 100755 --- a/initchroot.sh +++ b/initchroot.sh @@ -16,11 +16,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -DIST=lenny DEFUSER=olpc PLIST=gnome.packages -MIRROR=http://http.us.debian.org/debian/ -OTHERMIRROR= +APT_SOURCES="deb http://http.us.debian.org/debian/ lenny main contrib non-free +deb http://security.debian.org/ lenny/updates main contrib non-free" +LOCAL_APT_MIRROR= . functions.sh @@ -30,11 +30,10 @@ usage() echo "Usage: $0 [] " 1>&2 echo "" 1>&2 echo "Options:" 1>&2 - echo " --distribution Which distribution to use" 1>&2 echo " --user Username for default user" 1>&2 echo " --package-list File containing package list" 1>&2 - echo " --mirror Main Mirror URL prefix" 1>&2 - echo " --othermirror An additional sources.list line" 1>&2 + echo " --apt-sources Contents of /etc/apt/sources.list" 1>&2 + echo " --local-apt-mirror sources.list for local mirror" 1>&2 echo "" 1>&2 exit 1 } @@ -42,13 +41,6 @@ usage() while test $# != 0 do case $1 in - --distribution) - DIST=$2 - shift - if [ -z "${OTHERMIRROR}" ]; then - OTHERMIRROR="deb http://security.debian.org/ ${DIST}/updates main contrib non-free" - fi - ;; --user) DEFUSER=$2 shift @@ -61,12 +53,12 @@ do } shift ;; - --mirror) - MIRROR=$2 + --apt-sources) + APT_SOURCES="$2" shift ;; - --othermirror) - OTHERMIRROR=$2 + --local-apt-mirror) + LOCAL_APT_MIRROR="$2" shift ;; *) @@ -95,10 +87,14 @@ fi check_for_cmds debootstrap || exit 1 -if [ -z "${OTHERMIRROR}" ]; then - OTHERMIRROR="deb http://security.debian.org/ ${DIST}/updates main contrib non-free" +if [ -z "${LOCAL_APT_MIRROR}" ]; then + LOCAL_APT_MIRROR="${APT_SOURCES}" fi +# parse apt mirror +MIRROR=$(printf "${LOCAL_APT_MIRROR}\n" | awk '/deb /{print $2}' | head -n1) +DIST=$(printf "${LOCAL_APT_MIRROR}\n" | awk '/deb /{print $3}' | head -n1) + # create chroot debootstrap --arch i386 ${DIST} ${ROOT_DIR} ${MIRROR} mkdir ${ROOT_DIR}/ofw @@ -127,10 +123,7 @@ Dir { }; }; EOF -cat >${ROOT_DIR}/etc/apt/sources.list<${ROOT_DIR}/etc/apt/sources.list (chroot ${ROOT_DIR} aptitude update) # set up base system and base packages @@ -251,6 +244,10 @@ sugar EOF fi +# override sources.list with shipping version +printf "${APT_SOURCES}\n" >${ROOT_DIR}/etc/apt/sources.list +(chroot ${ROOT_DIR} aptitude update) + # done, clean up mv ${ROOT_DIR}/sbin/start-stop-daemon.REAL ${ROOT_DIR}/sbin/start-stop-daemon (chroot ${ROOT_DIR} aptitude clean)