X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=blobdiff_plain;f=grml-debootstrap;h=7246c4588e6ae87fcd5a00133e03c472eb867aa4;hp=5dbe1a77ffd4e7155d810265816fc29e605f70dd;hb=refs%2Fheads%2Fmika%2Fc-utf8;hpb=0b1d9821475753d8580982724b807cc8f2daa7e5 diff --git a/grml-debootstrap b/grml-debootstrap index 5dbe1a7..7246c45 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -54,8 +54,6 @@ MNTPOINT="/mnt/debootstrap.$$" [ -n "$DEBCONF" ] || DEBCONF='yes' [ -n "$DEBIAN_FRONTEND" ] || DEBIAN_FRONTEND='noninteractive' [ -n "$DEBOOTSTRAP" ] || DEBOOTSTRAP='debootstrap' -[ -n "$DEFAULT_LANGUAGE" ] || DEFAULT_LANGUAGE='en_US:en' -[ -n "$DEFAULT_LOCALES" ] || DEFAULT_LOCALES='en_US.UTF-8' [ -n "$DISK_IDENTIFIER" ] || DISK_IDENTIFIER='26ada0c0-1165-4098-884d-aafd2220c2c6' [ -n "$EXTRAPACKAGES" ] || EXTRAPACKAGES='yes' [ -n "$FALLBACK_MIRROR" ] || FALLBACK_MIRROR='http://deb.debian.org/debian' @@ -64,7 +62,6 @@ MNTPOINT="/mnt/debootstrap.$$" [ -n "$HOSTNAME" ] || HOSTNAME='grml' [ -n "$INITRD" ] || INITRD='yes' [ -n "$INSTALL_NOTES" ] || INSTALL_NOTES='/etc/debootstrap/install_notes' -[ -n "$LOCALES" ] || LOCALES='yes' [ -n "$MIRROR" ] || MIRROR="$FALLBACK_MIRROR" [ -n "$MKFS" ] || MKFS='mkfs.ext4' [ -n "$MKFS_OPTS" ] || MKFS_OPTS='' @@ -580,6 +577,23 @@ done [ "$_opt_contrib" ] && COMPONENTS="$COMPONENTS contrib" [ "$_opt_non_free" ] && COMPONENTS="$COMPONENTS non-free" +# variable checks +if [ -n "${LOCALES:-}" ] ; then + ewarn "Deprecation NOTE: LOCALES handling is deprecated, please customize locale handling via post scripts instead." +fi + +if [ -n "${DEFAULT_LOCALES:-}" ] ; then + ewarn "Deprecation NOTE: DEFAULT_LOCALES handling is deprecated, please customize locale handling via post scripts instead." +fi + +if [ -n "${DEFAULT_DEFAULT_LANGUAGE:-}" ] ; then + ewarn "Deprecation NOTE: DEFAULT_DEFAULT_LANGUAGE handling is deprecated, please customize locale handling via post scripts instead." +fi + +if [ -r "${CONFFILES:-}"/locale.gen ] ; then + ewarn "Deprecation NOTE: ${CONFFILES}/locale.gen handling is deprecated, please customize locale handling via post scripts instead." +fi + # command line option checks if [ "$_opt_scripts_set" ] ; then ewarn "Deprecation NOTE: --scripts option is deprecated, please switch to --post-scripts instead." @@ -1621,8 +1635,6 @@ preparechroot() { [ -n "$DEBCONF" ] && echo "DEBCONF='$(sed "s,','\\\\'',g" <<<"${DEBCONF}")'" >> "$CHROOT_VARIABLES" [ -n "$DEBIAN_FRONTEND" ] && echo "DEBIAN_FRONTEND='$(sed "s,','\\\\'',g" <<<"${DEBIAN_FRONTEND}")'" >> "$CHROOT_VARIABLES" [ -n "$DEBOOTSTRAP" ] && echo "DEBOOTSTRAP='$(sed "s,','\\\\'',g" <<<"${DEBOOTSTRAP}")'" >> "$CHROOT_VARIABLES" - [ -n "$DEFAULT_LOCALES" ] && echo "DEFAULT_LOCALES='$(sed "s,','\\\\'',g" <<<"${DEFAULT_LOCALES}")'" >> "$CHROOT_VARIABLES" - [ -n "$DEFAULT_LANGUAGE" ] && echo "DEFAULT_LANGUAGE='$(sed "s,','\\\\'',g" <<<"${DEFAULT_LANGUAGE}")'" >> "$CHROOT_VARIABLES" [ -n "$EXTRAPACKAGES" ] && echo "EXTRAPACKAGES='$(sed "s,','\\\\'',g" <<<"${EXTRAPACKAGES}")'" >> "$CHROOT_VARIABLES" [ -n "$EFI" ] && echo "EFI='$(sed "s,','\\\\'',g" <<<"${EFI}")'" >> "$CHROOT_VARIABLES" [ -n "$FALLBACK_MIRROR" ] && echo "FALLBACK_MIRROR='$(sed "s,','\\\\'',g" <<<"${FALLBACK_MIRROR}")'" >> "$CHROOT_VARIABLES" @@ -1635,7 +1647,6 @@ preparechroot() { [ -n "$ISODIR" ] && echo "ISODIR='$(sed "s,','\\\\'',g" <<<"${ISO}")'" >> "$CHROOT_VARIABLES" [ -n "$ISO" ] && echo "ISO='$(sed "s,','\\\\'',g" <<<"${ISO}")'" >> "$CHROOT_VARIABLES" [ -n "$KEEP_SRC_LIST" ] && echo "KEEP_SRC_LIST='$(sed "s,','\\\\'',g" <<<"${KEEP_SRC_LIST}")'" >> "$CHROOT_VARIABLES" - [ -n "$LOCALES" ] && echo "LOCALES='$(sed "s,','\\\\'',g" <<<"${LOCALES}")'" >> "$CHROOT_VARIABLES" [ -n "$MIRROR" ] && echo "MIRROR='$(sed "s,','\\\\'',g" <<<"${MIRROR}")'" >> "$CHROOT_VARIABLES" [ -n "$MKFS" ] && echo "MKFS='$(sed "s,','\\\\'',g" <<<"${MKFS}")'" >> "$CHROOT_VARIABLES" [ -n "$NOPASSWORD" ] && echo "NOPASSWORD=\"true\"" >> "$CHROOT_VARIABLES" @@ -1699,9 +1710,6 @@ preparechroot() { # make sure we can access network [relevant for cdebootstrap/mmdebstrap] [ -f "${MNTPOINT}"/etc/resolv.conf ] || cp $VERBOSE /etc/resolv.conf "${MNTPOINT}"/etc/resolv.conf - # setup default locales - [ -n "$LOCALES" ] && cp $VERBOSE "${CONFFILES}"/locale.gen "${MNTPOINT}"/etc/locale.gen - # MAKEDEV is just a forking bomb crap, let's do it on our own instead :) ( cd "${MNTPOINT}"/dev && tar zxf /etc/debootstrap/devices.tar.gz ) @@ -1728,42 +1736,78 @@ allow-hotplug eth0 iface eth0 inet dhcp " + # add dhcp setting for Predictable Network Interface Names + if [ -x /bin/udevadm ]; then + tmpfile=$(mktemp) + for interface in /sys/class/net/*; do + udevadm info --query=all --path="${interface}" > "${tmpfile}" + # skip virtual devices, like bridges, vboxnet,... + if grep -q 'P: /devices/virtual/net/' "${tmpfile}" ; then + continue + fi + + # iterate over possible naming policies by precedence (see udev/net/link-config.c), + # use and stop on first match to have same behavior as udev's link_config_apply() + for property in ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT ID_NET_NAME_PATH ID_NET_NAME_MAC ; do + if grep -q "${property}" "${tmpfile}" ; then + interface=$(grep "${property}" "${tmpfile}" | sed -n -e "s/E: ${property}=\([^\$*]\)/\1/p") + DEFAULT_INTERFACES="${DEFAULT_INTERFACES} +allow-hotplug ${interface} +iface ${interface} inet dhcp +" + break + fi + done + done + rm -f "${tmpfile}" + fi + if [ -n "$NOINTERFACES" ] ; then einfo "Not installing /etc/network/interfaces as requested via --nointerfaces option" ; eend 0 elif [ -n "$USE_DEFAULT_INTERFACES" ] ; then einfo "Installing default /etc/network/interfaces as requested via --defaultinterfaces options." + mkdir -p "${MNTPOINT}/etc/network" echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces" eend $? elif [ -n "$VIRTUAL" ] ; then einfo "Setting up Virtual Machine, installing default /etc/network/interfaces" + mkdir -p "${MNTPOINT}/etc/network" echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces" eend $? elif [ -r /etc/network/interfaces ] ; then einfo "Copying /etc/network/interfaces from host to target system" + mkdir -p "${MNTPOINT}/etc/network" cp $VERBOSE /etc/network/interfaces "${MNTPOINT}/etc/network/interfaces" eend $? else ewarn "Couldn't read /etc/network/interfaces, installing default /etc/network/interfaces" + mkdir -p "${MNTPOINT}/etc/network" echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces" eend $? fi # install config file providing some example entries if [ -r /etc/network/interfaces.examples ] && [ ! -r "$MNTPOINT/etc/network/interfaces.examples" ] ; then - cp /etc/network/interfaces.examples "$MNTPOINT/etc/network/interfaces.examples" + mkdir -p "${MNTPOINT}/etc/network" + cp /etc/network/interfaces.examples "$MNTPOINT/etc/network/interfaces.examples" fi if [ -n "${SSHCOPYID}" ] ; then - ssh-add -L > /dev/null 2>&1 ; RC=$? - if [ $RC -eq 0 ] ; then + if ssh-add -L >/dev/null 2>&1 ; then einfo "Use locally available public keys to authorise root login on the target system as requested via --sshcopyid option." - mkdir "${MNTPOINT}"/root/.ssh + mkdir -p "${MNTPOINT}"/root/.ssh chmod 0700 "${MNTPOINT}"/root/.ssh - ssh-add -L > "${MNTPOINT}"/root/.ssh/authorized_keys - eend 0 + if ssh-add -L >> "${MNTPOINT}"/root/.ssh/authorized_keys ; then + eend 0 + else + eerror "Error: executing 'ssh-add -L' failed." + eend 1 + bailout 1 + fi else - ewarn "Could not open a connection to your authentication agent or the agent has no identites." - eend $? + eerror "Could not open a connection to your authentication agent or the agent has no identites." + eend 1 + bailout 1 fi fi