Bug#773657: Obey bootstrap selection

2014-12-21 Thread jnqnfe
Package: live-build
Version: 4.0.4-1
Tags: patch

Attached is a patch (built against 4.x - assuming this is important
enough to get into jessie) which improves the processing of bootstrap
program selection.

Current logic takes my bootstrap selection and checks to see the program
is installed; if not, it completely disregards my choice and goes with
whatever program is actually installed on my system. I don't consider
this behaviour to be acceptable.

The patch:
 - Improves the logic so that if the user explicitly specifies a
particular bootloader to use, and it's not installed, an error is issued
to prompt the user to get it installed before trying again. It validates
the user's choice, and only resorts to looking for an installed program
if the user/config hasn't specified one.
 - Switches the newer cdebootstrap program round to be the preferred
choice, but only for when no specific choice has been made, and if
multiple bootstrap programs are installed.
 - Gets rid of an obsolete reference in the logic to an old 'copy'
bootstrap parameter choice.
commit 30d5774b753c25f4f42817e0b5c7547f7a4eb9ad
Author: jnqnfe jnq...@gmail.com
Date:   Sun Dec 21 16:39:16 2014 +

Properly obey bootstrap selection, update preferential default to 
cdebootstrap, and clear out remaining reference to old copy option.

diff --git a/functions/defaults.sh b/functions/defaults.sh
index c74d1c1..d341417 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -221,14 +221,20 @@ Set_defaults ()
esac
 
# Setting bootstrap program
-   if [ -z ${LB_BOOTSTRAP} ] || ( [ ! -x $(which ${LB_BOOTSTRAP} 
2/dev/null) ]  [ ${LB_BOOTSTRAP} != copy ] )
+   if [ -z ${LB_BOOTSTRAP} ]
then
-   if [ -x /usr/sbin/debootstrap ]
-   then
-   LB_BOOTSTRAP=debootstrap
-   elif [ -x /usr/bin/cdebootstrap ]
+   if [ -x /usr/bin/cdebootstrap ]
then
LB_BOOTSTRAP=cdebootstrap
+   elif [ -x /usr/bin/cdebootstrap-static ]
+   then
+   LB_BOOTSTRAP=cdebootstrap-static
+   elif [ -x /usr/sbin/debootstrap ]
+   then
+   LB_BOOTSTRAP=debootstrap
+   else
+   Echo_error No bootstrap program specified or otherwise 
found, please install one and try again!
+   exit 1
fi
fi
 
@@ -1053,6 +1059,20 @@ Check_defaults ()
fi
fi
 
+   case ${LB_BOOTSTRAP} in
+   cdebootstrap|cdebootstrap-static|debootstrap)
+   ;;
+   *)
+   Echo_error Bootstrap program selection '%s' is invalid 
or unsupported! ${LB_BOOTSTRAP}
+   exit 1
+   ;;
+   esac
+   if [ ! -x $(which ${LB_BOOTSTRAP} 2/dev/null) ]
+   then
+   Echo_error Command %s not found. Please check that the 
relevant bootstrap program is installed and try again! ${LB_BOOTSTRAP}
+   exit 1
+   fi
+
case ${LB_BINARY_FILESYSTEM} in
ntfs)
if [ ! -x $(which ntfs-3g 2/dev/null) ]
diff --git a/manpages/en/lb_config.1 b/manpages/en/lb_config.1
index b612f87..685cec6 100644
--- a/manpages/en/lb_config.1
+++ b/manpages/en/lb_config.1
@@ -268,7 +268,7 @@ sets boot parameters specific to debian\-live. A complete 
list of boot parameter
 .IP \fB\-\-bootloader\fR grub|grub2|syslinux 4
 defines which bootloader is being used in the generated image. This has only 
an effect if the selected binary image type does allow to choose the 
bootloader. For example, if you build a iso, always syslinux (or more precise, 
isolinux) is being used. Also note that some combinations of binary images 
types and bootloaders may be possible but live\-build does not support them 
yet. \fBlb config\fR will fail to create such a not yet supported configuration 
and give a explanation about it. For hdd images on amd64 and i386, the default 
is syslinux.
 .IP \fB\-\-bootstrap\fR cdebootstrap|cdebootstrap-static|debootstrap 4
-defines which program is used to bootstrap the debian chroot, default is 
debootstrap.
+defines which program is used to build a base debian filesystem, which 
provides the foundations for the live OS filesystem, and also a chroot 
environment for the build process. If a selection is not explicitly made via 
this parameter, an attempt will be made to find and default to one already 
installed on your system, in the order of preference cdebootstrap, then 
cdebootstrap, then finally debootstrap.
 .IP \fB\-\-cache\fR true|false 4
 defines globally if any cache should be used at all. Different caches can be 
controlled through the their own options.
 .IP \fB\-\-cache\-indices\fR true|false 4
diff --git a/scripts/build/bootstrap_cdebootstrap 
b/scripts/build/bootstrap_cdebootstrap
index 490352b..55bbdf3 100755
--- 

Bug#773657: Obey bootstrap selection

2014-12-21 Thread jnqnfe
(Sending this again, it went to the mailing list but not the BTS, stupid
mail client)

Sorry, I noticed a small mistake in the documentation which I had failed
to spot before submitting. Updated patch attached!

commit 207a4ce153fdfb03ad49576f835b45f5f0ca5507
Author: jnqnfe jnq...@gmail.com
Date:   Sun Dec 21 17:19:20 2014 +

Properly obey bootstrap selection, update preferential default to 
cdebootstrap, and clear out remaining reference to old copy option.

diff --git a/functions/defaults.sh b/functions/defaults.sh
index c74d1c1..d341417 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -221,14 +221,20 @@ Set_defaults ()
esac
 
# Setting bootstrap program
-   if [ -z ${LB_BOOTSTRAP} ] || ( [ ! -x $(which ${LB_BOOTSTRAP} 
2/dev/null) ]  [ ${LB_BOOTSTRAP} != copy ] )
+   if [ -z ${LB_BOOTSTRAP} ]
then
-   if [ -x /usr/sbin/debootstrap ]
-   then
-   LB_BOOTSTRAP=debootstrap
-   elif [ -x /usr/bin/cdebootstrap ]
+   if [ -x /usr/bin/cdebootstrap ]
then
LB_BOOTSTRAP=cdebootstrap
+   elif [ -x /usr/bin/cdebootstrap-static ]
+   then
+   LB_BOOTSTRAP=cdebootstrap-static
+   elif [ -x /usr/sbin/debootstrap ]
+   then
+   LB_BOOTSTRAP=debootstrap
+   else
+   Echo_error No bootstrap program specified or otherwise 
found, please install one and try again!
+   exit 1
fi
fi
 
@@ -1053,6 +1059,20 @@ Check_defaults ()
fi
fi
 
+   case ${LB_BOOTSTRAP} in
+   cdebootstrap|cdebootstrap-static|debootstrap)
+   ;;
+   *)
+   Echo_error Bootstrap program selection '%s' is invalid 
or unsupported! ${LB_BOOTSTRAP}
+   exit 1
+   ;;
+   esac
+   if [ ! -x $(which ${LB_BOOTSTRAP} 2/dev/null) ]
+   then
+   Echo_error Command %s not found. Please check that the 
relevant bootstrap program is installed and try again! ${LB_BOOTSTRAP}
+   exit 1
+   fi
+
case ${LB_BINARY_FILESYSTEM} in
ntfs)
if [ ! -x $(which ntfs-3g 2/dev/null) ]
diff --git a/manpages/en/lb_config.1 b/manpages/en/lb_config.1
index b612f87..d9e045f 100644
--- a/manpages/en/lb_config.1
+++ b/manpages/en/lb_config.1
@@ -268,7 +268,7 @@ sets boot parameters specific to debian\-live. A complete 
list of boot parameter
 .IP \fB\-\-bootloader\fR grub|grub2|syslinux 4
 defines which bootloader is being used in the generated image. This has only 
an effect if the selected binary image type does allow to choose the 
bootloader. For example, if you build a iso, always syslinux (or more precise, 
isolinux) is being used. Also note that some combinations of binary images 
types and bootloaders may be possible but live\-build does not support them 
yet. \fBlb config\fR will fail to create such a not yet supported configuration 
and give a explanation about it. For hdd images on amd64 and i386, the default 
is syslinux.
 .IP \fB\-\-bootstrap\fR cdebootstrap|cdebootstrap-static|debootstrap 4
-defines which program is used to bootstrap the debian chroot, default is 
debootstrap.
+defines which program is used to build a base debian filesystem, which 
provides the foundations for the live OS filesystem, and also a chroot 
environment for the build process. If a selection is not explicitly made via 
this parameter, an attempt will be made to find and default to one already 
installed on your system, in the order of preference: cdebootstrap, then 
cdebootstrap-static, then finally debootstrap.
 .IP \fB\-\-cache\fR true|false 4
 defines globally if any cache should be used at all. Different caches can be 
controlled through the their own options.
 .IP \fB\-\-cache\-indices\fR true|false 4
diff --git a/scripts/build/bootstrap_cdebootstrap 
b/scripts/build/bootstrap_cdebootstrap
index 490352b..55bbdf3 100755
--- a/scripts/build/bootstrap_cdebootstrap
+++ b/scripts/build/bootstrap_cdebootstrap
@@ -31,9 +31,7 @@ fi
 
 if [ ! -x $(which cdebootstrap 2/dev/null) ]
 then
-   echo E: cdebootstrap - command not found
-   echo I: cdebootstrap can be obtained from 
http://ftp.debian.org/debian/pool/main/d/cdebootstrap/;
-   echo I: On Debian based systems, cdebootstrap can be installed with 
'apt-get install cdebootstrap'.
+   Echo_error Command %s not found. Please check that your selected 
bootstrap program is installed and try again! ${LB_BOOTSTRAP}
exit 1
 fi
 
diff --git a/scripts/build/bootstrap_debootstrap 
b/scripts/build/bootstrap_debootstrap
index 76fe32e..3cbe29b 100755
--- a/scripts/build/bootstrap_debootstrap
+++ b/scripts/build/bootstrap_debootstrap
@@ -31,9 +31,7 @@ fi
 
 if [ ! -x $(which debootstrap 2/dev/null) ]