timplement dpkgdivert as a separate function - libdevuansdk - common library for devuan's simple distro kits HTML git clone https://git.parazyd.org/libdevuansdk DIR Log DIR Files DIR Refs DIR Submodules DIR README DIR LICENSE --- DIR commit a82bb122bf8282e2d1132dbd126ee408d50f8191 DIR parent 7f43df508dc3585db87e5d11cf3fc8199238a12a HTML Author: parazyd <parazyd@dyne.org> Date: Tue, 11 Oct 2016 22:36:32 +0200 implement dpkgdivert as a separate function Diffstat: M zlibs/bootstrap | 55 +++++++------------------------ M zlibs/helpers | 33 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 43 deletions(-) --- DIR diff --git a/zlibs/bootstrap b/zlibs/bootstrap t@@ -111,37 +111,20 @@ bootstrap_config_thirdstage() { cat << EOF #!/bin/sh -dpkg-divert --add --local \ - --divert /usr/sbin/invoke-rc.d.chroot \ - --rename /usr/sbin/invoke-rc.d -cp /bin/true /usr/sbin/invoke-rc.d -echo -e "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d -chmod +x /usr/sbin/policy-rc.d - apt-get update -apt-get --yes --force-yes install locales-all debconf-set-selections /debconf.set -apt-get update -apt-get --yes --force-yes install ${core_packages} - -echo "root:${os}" | chpasswd +echo "root:toor" | chpasswd sed -i -e 's/KERNEL\!=\"eth\*|/KERNEL\!=\"/' \ /lib/udev/rules.d/75-persistent-net-generator.rules rm -f /etc/udev/rules.d/70-persistent-net.rules export DEBIAN_FRONTEND=noninteractive -apt-get --yes --force-yes install \ - ${base_packages} \ - ${extra_packages} -apt-get --yes --force-yes dist-upgrade +apt-get --yes --force-yes install ${core_packages} +apt-get --yes --force-yes install ${base_packages} +apt-get --yes --force-yes purge ${purge_packages} apt-get --yes --force-yes autoremove - apt-get clean - -rm -f /usr/sbin/policy-rc.d -rm -f /usr/sbin/invoke-rc.d -dpkg-divert --remove --rename /usr/sbin/invoke-rc.d EOF } t@@ -187,40 +170,26 @@ bootstrap_tar_unpack() { ckreq || return 1 [[ -f ${unpath}/.done ]] && { - warning "bootstrap already unpacked in $unpath" - return 1 - } + warn "bootstrap already unpacked in $unpath" + return 1 } mkdir -p ${unpath} silly - sudo tar xf $bootstrap_tgz -C ${unpath} + sudo tar xfp $bootstrap_tgz -C ${unpath} sudo mkdir -p ${unpath}/{boot,dev,sys,proc} cat <<EOF | sudo tee ${strapdir}/postunpack #!/bin/sh -dpkg-divert --add --local \ - --divert /usr/sbin/invoke-rc.d.chroot \ - --rename /usr/sbin/invoke-rc.d -cp /bin/true /usr/sbin/invoke-rc.d -echo -e "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d -chmod +x /usr/sbin/policy-rc.d - apt-get update apt-get --yes --force-yes install ${extra_packages} -apt-get --yes --force-yes dist-upgrade apt-get --yes --force-yes autoremove - apt-get clean - -rm -f /usr/sbin/policy-rc.d -rm -f /usr/sbin/invoke-rc.d -dpkg-divert --remove --rename /usr/sbin/invoke-rc.d EOF - sudo chmod +x $strapdir/postunpack || zerr - sudo chroot $strapdir /postunpack || zerr + dpkgdivert on $strapdir + sudo chmod +x $strapdir/postunpack || zerr + sudo -E chroot $strapdir /postunpack || zerr + dpkgdivert off $strapdir - for i in $custmodules; do - print $i | sudo tee -a $strapdir/etc/modules - done + for i in $custmodules;do print $i | sudo tee -a $strapdir/etc/modules; done } DIR diff --git a/zlibs/helpers b/zlibs/helpers t@@ -83,6 +83,39 @@ qemu_install_user() { sudo cp $qemu_bin $strapdir/usr/bin } +dpkgdivert() { + fn dpkgdivert $@ + req=(watdo werdo) + local watdo="$1" + local werdo="$2" + ckreq || return 1 + + if [[ $watdo = on ]]; then + cat <<EOF | sudo tee ${werdo}/dpkgdivert +#!/bin/sh +dpkg-divert --add --local \ + --divert /usr/sbin/invoke-rc.d.chroot \ + --rename /usr/sbin/invoke-rc.d +cp /bin/true /usr/sbin/invoke-rc.d +echo -e "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d +chmod +x /usr/sbin/policy-rc.d +rm -f /dpkgdivert +EOF + chmod +x $werdo/dpkgdivert + sudo -E chroot $werdo/dpkgdivert || zerr + elif [[ $watdo = off ]]; then + cat <<EOF | sudo tee ${werdo}/dpkgdivert +#!/bin/sh +rm -f /usr/sbin/policy-rc.d +rm -f /usr/sbin/invoke-rc.d +dpkg-divert --remove --rename /usr/sbin/invoke-rc.d +rm -f /dpkgdivert +EOF + chmod +x $werdo/dpkgdivert + sudo -E chroot $werdo/dpkgdivert || zerr + fi +} + silly() { fn silly "$@" local arg1="$1"