From 367bf5fc2e718b78705ae618db360ea543f84ba0 Mon Sep 17 00:00:00 2001 From: parazyd Date: Sun, 18 Dec 2016 13:19:45 +0100 Subject: [PATCH 1/4] wrap chrooting in a function --- zlibs/bootstrap | 22 ++++++++-------------- zlibs/helpers | 46 ++++++++++++++++++++++++++++++++-------------- zlibs/iso | 6 ++---- zlibs/kernel | 4 ++-- zlibs/rsync | 3 ++- zlibs/sysconf | 2 +- 6 files changed, 47 insertions(+), 36 deletions(-) diff --git a/zlibs/bootstrap b/zlibs/bootstrap index 8225713..c561981 100644 --- a/zlibs/bootstrap +++ b/zlibs/bootstrap @@ -63,8 +63,6 @@ bootstrap_complete_base() { ## write third-stage for chroot bootstrap_config_thirdstage | sudo tee $strapdir/thirdstage bootstrap_config_cleanup | sudo tee $strapdir/cleanup - sudo chmod +x $strapdir/thirdstage - sudo chmod +x $strapdir/cleanup ## chroot into it and configure further ## debootstrap stage 3 @@ -72,10 +70,8 @@ bootstrap_complete_base() { devprocsys mount $strapdir || zerr - dpkgdivert on $strapdir - sudo -E chroot $strapdir /thirdstage || zerr - sudo -E chroot $strapdir /cleanup || zerr - dpkgdivert off $strapdir + chroot-script -d thirdstage || zerr + chroot-script -d cleanup || zerr sleep 1 devprocsys umount $strapdir || zerr @@ -94,7 +90,7 @@ rm -f /thirdstage rm -f /etc/ssh/*_key rm -f /etc/ssh/*.pub rm -f /root/.bash_history -#rm -f /usr/bin/qemu-* +rm -f /usr/bin/qemu-arm-static ## our file for which we check the bootstrap is complete echo "1" > .done rm -f /cleanup @@ -141,8 +137,7 @@ apt-get clean rm -f /prepack EOF - sudo chmod +x $strapdir/prepack || zerr - sudo -E chroot $strapdir /prepack || zerr + chroot-script prepack || zerr local _dest=$(dirname $bootstrap_tgz) @@ -185,14 +180,13 @@ apt-get clean rm -f /postunpack EOF - dpkgdivert on $strapdir devprocsys mount $strapdir - sudo chmod +x $strapdir/postunpack || zerr - sudo -E chroot $strapdir /postunpack || zerr + chroot-script -d postunpack || zerr devprocsys umount $strapdir - dpkgdivert off $strapdir ## below typically used in arm-sdk [[ -z $inittab ]] || { print $inittab | sudo tee -a $strapdir/etc/inittab } - 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 } diff --git a/zlibs/helpers b/zlibs/helpers index d9e0c4d..5d632cf 100644 --- a/zlibs/helpers +++ b/zlibs/helpers @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this source code. If not, see . -## helper functions that make your life easier +## helper functions that make my life easier build_image_dist() { fn build_image_dist @@ -138,8 +138,8 @@ dpkg-divert --remove --rename /usr/sbin/invoke-rc.d rm -f /dpkgdivert EOF fi - sudo chmod +x $werdo/dpkgdivert - sudo -E chroot $werdo /dpkgdivert || zerr + + chroot-script dpkgdivert || zerr } enableserv() { @@ -154,8 +154,7 @@ update-rc.d ${service} enable EOF notice "enabling $service service" - sudo chmod +x $strapdir/enserv - sudo -E chroot $strapdir /enserv + chroot-script enserv } disableserv() { @@ -170,8 +169,7 @@ update-rc.d ${service} disable EOF notice "disabling $service service" - sudo chmod +x $strapdir/disserv - sudo -E chroot $strapdir /disserv + chroot-script disserv } enablessh() { @@ -183,9 +181,9 @@ enablessh() { #!/bin/sh sed -i -e 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config update-rc.d ssh enable -chmod +x /etc/init.d/regensshkeys update-rc.d regensshkeys defaults update-rc.d regensshkeys enable +rm -f /enssh EOF cat <. -## ilporcodio +## ilpd rsync_to_raw_image() { fn rsync_to_raw_image @@ -35,6 +35,7 @@ rsync_to_raw_image() { die "not enough space. report a bug please" zerr } + if [[ $parted_type = dos ]]; then sudo rsync -HPavz -q ./boot/* $workdir/boot || { image_raw_umount diff --git a/zlibs/sysconf b/zlibs/sysconf index 26d115c..9e265a9 100644 --- a/zlibs/sysconf +++ b/zlibs/sysconf @@ -39,7 +39,7 @@ proc /proc proc nodev,noexec,nosuid 0 0 /dev/sda2 / ext4 errors=remount-ro 0 1 # boot -/dev/sda1 /boot ext2 noauto 0 0 +/dev/sda1 /boot ext2 defaults 0 0 EOF } From 420ba85a32652ab98ec25d1e7ffbabda2b7d6852 Mon Sep 17 00:00:00 2001 From: parazyd Date: Sun, 18 Dec 2016 13:54:07 +0100 Subject: [PATCH 2/4] update documentation about chroot-script --- doc/helper_functions.7.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/helper_functions.7.md b/doc/helper_functions.7.md index bf01c52..fd92a9c 100644 --- a/doc/helper_functions.7.md +++ b/doc/helper_functions.7.md @@ -50,5 +50,11 @@ so that apt doesn't autostart daemons when they are installed. this function will allow root login with password in the bootstrapped rootfs. +## chroot-script() +allows you to chroot inside the `$strapdir` and execute the +script/binary that's given to it. +takes an optional argument: `-d` (will call dpkgdivert on and off) + + ## silly() a funny function printing out random messages. From 8550bd607231d7f693dfe7dfe6716165e6b5cb54 Mon Sep 17 00:00:00 2001 From: parazyd Date: Sun, 18 Dec 2016 14:47:23 +0100 Subject: [PATCH 3/4] allow for multiple scripts in chroot-script --- config | 2 +- libdevuansdk | 2 +- zlibs/bootstrap | 5 ++--- zlibs/helpers | 36 +++++++++++++++++++++--------------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/config b/config index c873741..f7443e6 100644 --- a/config +++ b/config @@ -24,7 +24,7 @@ arrs+=(core_packages base_packages purge_packages blend_packages) os="devuan" release="jessie" -version="1.0.0-beta2.rc1" +version="1.0.0-beta2" mirror="http://auto.mirror.devuan.org/merged" section="main" diff --git a/libdevuansdk b/libdevuansdk index df78317..6293971 100644 --- a/libdevuansdk +++ b/libdevuansdk @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this source code. If not, see . -libdevuansdk_version="0.2" +libdevuansdk_version="0.3" LIBPATH=${LIBPATH:-`dirname $0`} source $LIBPATH/config diff --git a/zlibs/bootstrap b/zlibs/bootstrap index c561981..0570bc3 100644 --- a/zlibs/bootstrap +++ b/zlibs/bootstrap @@ -70,8 +70,7 @@ bootstrap_complete_base() { devprocsys mount $strapdir || zerr - chroot-script -d thirdstage || zerr - chroot-script -d cleanup || zerr + chroot-script -d thirdstage cleanup || zerr sleep 1 devprocsys umount $strapdir || zerr @@ -90,7 +89,7 @@ rm -f /thirdstage rm -f /etc/ssh/*_key rm -f /etc/ssh/*.pub rm -f /root/.bash_history -rm -f /usr/bin/qemu-arm-static +#rm -f /usr/bin/qemu-arm-static ## our file for which we check the bootstrap is complete echo "1" > .done rm -f /cleanup diff --git a/zlibs/helpers b/zlibs/helpers index 5d632cf..3925b1a 100644 --- a/zlibs/helpers +++ b/zlibs/helpers @@ -249,23 +249,29 @@ EOF chroot-script() { fn chroot-script "$@" - notice "chrooting for script $@" + case "x$1" in + x-d) + shift 1 + local scripts="$@" - if [[ "$1" == "-d" ]]; then - shift 1 - local _script="$1" - - dpkgdivert on $strapdir - sudo chmod +x $strapdir/$_script - sudo -E chroot $strapdir /$_script - dpkgdivert off $strapdir - else - local _script="$1" - - sudo chmod +x $strapdir/$_script - sudo -E chroot $strapdir /$_script - fi + dpkgdivert on $strapdir + for i in $scripts; do + notice "chrooting to execute $i..." + sudo chmod +x $strapdir/$i + sudo -E chroot $strapdir /$i + done + dpkgdivert off $strapdir + ;; + *) + local scripts="$@" + for i in $scripts; do + notice "chrooting to execute $i..." + sudo chmod +x $strapdir/$i + sudo -E chroot $strapdir /$i + done + ;; + esac } silly() { From a45d4dbeb9e9ee49092c92ed8d5496b1c2c2cc06 Mon Sep 17 00:00:00 2001 From: parazyd Date: Sun, 18 Dec 2016 15:52:11 +0100 Subject: [PATCH 4/4] move doc to docs (for GH pages) --- README.md | 2 +- {doc => docs}/Makefile | 0 {doc => docs}/configuration.7.md | 0 {doc => docs}/creating_wrappers.7.md | 0 {doc => docs}/helper_functions.7.md | 0 {doc => docs}/libdevuansdk.7.md | 0 {doc => docs}/nanodoc | 0 {doc => docs}/static/foot.html | 0 {doc => docs}/static/head.html | 0 {doc => docs}/workflow.7.md | 0 10 files changed, 1 insertion(+), 1 deletion(-) rename {doc => docs}/Makefile (100%) rename {doc => docs}/configuration.7.md (100%) rename {doc => docs}/creating_wrappers.7.md (100%) rename {doc => docs}/helper_functions.7.md (100%) rename {doc => docs}/libdevuansdk.7.md (100%) rename {doc => docs}/nanodoc (100%) rename {doc => docs}/static/foot.html (100%) rename {doc => docs}/static/head.html (100%) rename {doc => docs}/workflow.7.md (100%) diff --git a/README.md b/README.md index 2cd46f1..3f0dcd7 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ zsh debootstrap sudo kpartx cgpt xz-utils ## Documentation -Find documentation inside the `doc` directory of libdevuansdk. +Find documentation inside the `docs` directory of libdevuansdk. ## Notes diff --git a/doc/Makefile b/docs/Makefile similarity index 100% rename from doc/Makefile rename to docs/Makefile diff --git a/doc/configuration.7.md b/docs/configuration.7.md similarity index 100% rename from doc/configuration.7.md rename to docs/configuration.7.md diff --git a/doc/creating_wrappers.7.md b/docs/creating_wrappers.7.md similarity index 100% rename from doc/creating_wrappers.7.md rename to docs/creating_wrappers.7.md diff --git a/doc/helper_functions.7.md b/docs/helper_functions.7.md similarity index 100% rename from doc/helper_functions.7.md rename to docs/helper_functions.7.md diff --git a/doc/libdevuansdk.7.md b/docs/libdevuansdk.7.md similarity index 100% rename from doc/libdevuansdk.7.md rename to docs/libdevuansdk.7.md diff --git a/doc/nanodoc b/docs/nanodoc similarity index 100% rename from doc/nanodoc rename to docs/nanodoc diff --git a/doc/static/foot.html b/docs/static/foot.html similarity index 100% rename from doc/static/foot.html rename to docs/static/foot.html diff --git a/doc/static/head.html b/docs/static/head.html similarity index 100% rename from doc/static/head.html rename to docs/static/head.html diff --git a/doc/workflow.7.md b/docs/workflow.7.md similarity index 100% rename from doc/workflow.7.md rename to docs/workflow.7.md