Add new feature "backportrepos" (trigger: --backportrepos )
authorMarkus Rekkenbeil <bionix@grml.org>
Mon, 4 Feb 2013 16:39:00 +0000 (17:39 +0100)
committerMarkus Rekkenbeil <bionix@grml.org>
Thu, 7 Feb 2013 21:36:17 +0000 (22:36 +0100)
This feature as a parameter allows the usage of the official
Debian backports repository (http://backports.debian.org), but only
if the release version provides by the backports repository.

Github pull request: https://github.com/grml/grml-debootstrap/pull/7

Signed-off-by: Markus Rekkenbeil <bionix@grml.org>
chroot-script
cmdlineopts.clp
config
grml-debootstrap
grml-debootstrap.8.txt

index 86f1535..751eac3 100755 (executable)
@@ -165,6 +165,32 @@ EOF
 }
 # }}}
 
 }
 # }}}
 
+# check available backports release version {{{
+checkbackports() {
+  wget -q -O/dev/null http://backports.debian.org/debian-backports/dists/${1}-backports/Release
+}
+# }}}
+
+# feature to provide Debian backports repos {{{
+backportrepos() {
+    if [ -n "$BACKPORTREPOS" ] ; then
+        if ! checkbackports $RELEASE ; then
+            echo "Backports for ${RELEASE} are not available." >&2
+            exit 1
+        else
+            # user might have provided their own apt sources.list
+            if ! grep -q backports /etc/apt/sources.list.d/backports.list 2>/dev/null ; then
+                cat >> /etc/apt/sources.list.d/backports.list << EOF
+# debian backports: ${RELEASE}-backports repository:
+deb     http://backports.debian.org/debian-backports ${RELEASE}-backports main
+deb-src http://backports.debian.org/debian-backports ${RELEASE}-backports main
+EOF
+            fi
+        fi
+    fi
+}
+# }}}
+
 # set up kernel-img.conf {{{
 kernelimg_conf() {
   if ! [ -r /etc/kernel-img.conf ] ; then
 # set up kernel-img.conf {{{
 kernelimg_conf() {
   if ! [ -r /etc/kernel-img.conf ] ; then
@@ -578,7 +604,7 @@ trap signal_handler HUP INT QUIT TERM
  # always execute install_policy_rcd
  install_policy_rcd
 
  # always execute install_policy_rcd
  install_policy_rcd
 
- for i in chrootmirror grmlrepos kernelimg_conf \
+ for i in chrootmirror grmlrepos backportrepos kernelimg_conf \
      kernel packages extrapackages  reconfigure hosts interfaces \
      timezone fstab hostname initrd grub_install passwords        \
      custom_scripts upgrade_system remove_apt_cache services \
      kernel packages extrapackages  reconfigure hosts interfaces \
      timezone fstab hostname initrd grub_install passwords        \
      custom_scripts upgrade_system remove_apt_cache services \
index a0dd2fe..db8ebf6 100644 (file)
@@ -12,7 +12,7 @@
 # should be handled in the main script, where it belongs.
 ################################################################################
 
 # should be handled in the main script, where it belongs.
 ################################################################################
 
-CMDLINE_OPTS=mirror:,iso:,release:,target:,mntpoint:,debopt:,interactive,nodebootstrap,nopackages,filesystem:,config:,confdir:,packages:,chroot-scripts:,scripts:,pre-scripts:,debconf:,vmfile,vmsize:,keep_src_list,hostname:,password:,nopassword,grmlrepos,bootappend:,grub:,arch:,insecure,verbose,help,version,force
+CMDLINE_OPTS=mirror:,iso:,release:,target:,mntpoint:,debopt:,interactive,nodebootstrap,nopackages,filesystem:,config:,confdir:,packages:,chroot-scripts:,scripts:,pre-scripts:,debconf:,vmfile,vmsize:,keep_src_list,hostname:,password:,nopassword,grmlrepos,backportrepos,bootappend:,grub:,arch:,insecure,verbose,help,version,force
 
 _opt_temp=`getopt --name grml-debootstrap -o +m:i:r:t:p:c:d:vhV --long \
     $CMDLINE_OPTS -- "$@"`
 
 _opt_temp=`getopt --name grml-debootstrap -o +m:i:r:t:p:c:d:vhV --long \
     $CMDLINE_OPTS -- "$@"`
@@ -113,6 +113,9 @@ while :; do
   --grmlrepos)         # Enable Grml repository
     _opt_grmlrepos=T
     ;;
   --grmlrepos)         # Enable Grml repository
     _opt_grmlrepos=T
     ;;
+  --backportrepos)     # Enable Debian backports repository
+    _opt_backportrepos=T
+    ;;
   --bootappend)        # Add specified appendline to kernel whilst booting
     shift; _opt_bootappend="$1"
     ;;
   --bootappend)        # Add specified appendline to kernel whilst booting
     shift; _opt_bootappend="$1"
     ;;
diff --git a/config b/config
index c50a300..3ae4cf6 100644 (file)
--- a/config
+++ b/config
 # Default: no default.
 # GRMLPACKAGES='grml-etc-core'
 
 # Default: no default.
 # GRMLPACKAGES='grml-etc-core'
 
+# To enable Debian's backports repository via
+# /etc/apt/sources.list.d/backports.list set this variable to 'yes'.
+# Default: 'no'
+# BACKPORTREPOS='yes'
+
 # Debian release that should be installed.
 # Supported values: lenny, squeeze, wheezy, sid
 # Default: 'wheezy'
 # Debian release that should be installed.
 # Supported values: lenny, squeeze, wheezy, sid
 # Default: 'wheezy'
index 62e2c7e..0068542 100755 (executable)
@@ -94,6 +94,7 @@ Configuration options:
                              /etc/debootstrap/packages
       --debconf <file>     Pre-seed packages using specified pre-seed db file.
       --grmlrepos          Enable Grml's Debian repository (deb.grml.org).
                              /etc/debootstrap/packages
       --debconf <file>     Pre-seed packages using specified pre-seed db file.
       --grmlrepos          Enable Grml's Debian repository (deb.grml.org).
+      --backportrepos      Enable Debian's backports repository (backports.debian.org).
       --keep_src_list      Do not overwrite user provided apt sources.list.
       --hostname <name>    Hostname of Debian system.
       --nopassword         Do not prompt for the root password.
       --keep_src_list      Do not overwrite user provided apt sources.list.
       --hostname <name>    Hostname of Debian system.
       --nopassword         Do not prompt for the root password.
@@ -321,6 +322,7 @@ fi
 [ "$_opt_chroot_scripts_set" ]  && CHROOT_SCRIPTS='yes'
 [ "$_opt_keep_src_list" ]       && KEEP_SRC_LIST='yes'
 [ "$_opt_grmlrepos" ]           && GRMLREPOS='yes'
 [ "$_opt_chroot_scripts_set" ]  && CHROOT_SCRIPTS='yes'
 [ "$_opt_keep_src_list" ]       && KEEP_SRC_LIST='yes'
 [ "$_opt_grmlrepos" ]           && GRMLREPOS='yes'
+[ "$_opt_backportrepos" ]       && BACKPORTREPOS='yes'
 [ "$_opt_hostname" ]            && HOSTNAME=$_opt_hostname
 [ "$_opt_password" ]            && ROOTPASSWORD=$_opt_password
 [ "$_opt_nopassword" ]          && NOPASSWORD='yes'
 [ "$_opt_hostname" ]            && HOSTNAME=$_opt_hostname
 [ "$_opt_password" ]            && ROOTPASSWORD=$_opt_password
 [ "$_opt_nopassword" ]          && NOPASSWORD='yes'
@@ -1092,6 +1094,7 @@ preparechroot() {
   chmod 600 $CHROOT_VARIABLES # make sure nobody except root can read it
   echo "# Configuration of ${PN}"                              > $CHROOT_VARIABLES
   [ -n "$ARCH" ]                && echo "ARCH=\"$ARCH\""                               >> $CHROOT_VARIABLES
   chmod 600 $CHROOT_VARIABLES # make sure nobody except root can read it
   echo "# Configuration of ${PN}"                              > $CHROOT_VARIABLES
   [ -n "$ARCH" ]                && echo "ARCH=\"$ARCH\""                               >> $CHROOT_VARIABLES
+  [ -n "$BACKPORTREPOS" ]       && echo "BACKPORTREPOS=\"$BACKPORTREPOS\""             >> $CHROOT_VARIABLES
   [ -n "$CHROOT_SCRIPTS" ]      && echo "CHROOT_SCRIPTS=\"$CHROOT_SCRIPTS\""           >> $CHROOT_VARIABLES
   [ -n "$CONFFILES" ]           && echo "CONFFILES=\"$CONFFILES\""                     >> $CHROOT_VARIABLES
   [ -n "$DEBCONF" ]             && echo "DEBCONF=\"$DEBCONF\""                         >> $CHROOT_VARIABLES
   [ -n "$CHROOT_SCRIPTS" ]      && echo "CHROOT_SCRIPTS=\"$CHROOT_SCRIPTS\""           >> $CHROOT_VARIABLES
   [ -n "$CONFFILES" ]           && echo "CONFFILES=\"$CONFFILES\""                     >> $CHROOT_VARIABLES
   [ -n "$DEBCONF" ]             && echo "DEBCONF=\"$DEBCONF\""                         >> $CHROOT_VARIABLES
index f751cb5..24dd4ae 100644 (file)
@@ -38,6 +38,12 @@ Options and environment variables
     deploy an i386 system use this option. Note: deploying amd64 from an i386
     kernel does *not* work. Example: "_--arch i386_"
 
     deploy an i386 system use this option. Note: deploying amd64 from an i386
     kernel does *not* work. Example: "_--arch i386_"
 
+*--backportrepos*::
+
+    Enable Debian's Backports repository (http://backports.debian.org/) via the
+    /etc/apt/sources.list.d/backports.list configuration file. This provides the
+    option to install Debian packages from Debian's backports repository.
+
 *--bootappend* _appendline-for-the-kernel_::
 
     Specify appendline for the kernel.
 *--bootappend* _appendline-for-the-kernel_::
 
     Specify appendline for the kernel.