libdevuansdk

common library for devuan's simple distro kits
git clone https://git.parazyd.org/libdevuansdk
Log | Files | Refs | Submodules | README | LICENSE

commit 1aaa86ffbdcfb99b537dd53abc50e955e968c4da
parent cf0a59cbf55eb066bd679481ce191fbbf0cc5ae6
Author: parazyd <parazyd@dyne.org>
Date:   Sun, 18 Dec 2016 15:52:19 +0100

Merge branch 'next'

Diffstat:
MREADME.md | 2+-
Mconfig | 2+-
Ddoc/helper_functions.7.md | 54------------------------------------------------------
Rdoc/Makefile -> docs/Makefile | 0
Rdoc/configuration.7.md -> docs/configuration.7.md | 0
Rdoc/creating_wrappers.7.md -> docs/creating_wrappers.7.md | 0
Adocs/helper_functions.7.md | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rdoc/libdevuansdk.7.md -> docs/libdevuansdk.7.md | 0
Rdoc/nanodoc -> docs/nanodoc | 0
Rdoc/static/foot.html -> docs/static/foot.html | 0
Rdoc/static/head.html -> docs/static/head.html | 0
Rdoc/workflow.7.md -> docs/workflow.7.md | 0
Mlibdevuansdk | 2+-
Mzlibs/bootstrap | 21+++++++--------------
Mzlibs/helpers | 52++++++++++++++++++++++++++++++++++++++--------------
Mzlibs/iso | 6++----
Mzlibs/kernel | 4++--
Mzlibs/rsync | 3++-
Mzlibs/sysconf | 2+-
19 files changed, 115 insertions(+), 93 deletions(-)

diff --git 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/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/doc/helper_functions.7.md b/doc/helper_functions.7.md @@ -1,54 +0,0 @@ -helper functions -================ - -you can find useful helper functions in `libdevuansdk/zlibs/helpers`. they are -intended to help you with writing wrappers, as well as making my job easier -within developing libdevuansdk. some of these functions are required for -libdevuansdk to properly work as well. - - -## build_image_dist() -this function is kind of a wrapper function, mostly used in `arm-sdk` to build a -complete "dd-able" image from start to end. to run, it requires `$arch`, -`$size`, `$parted_type`, `$workdir`, and `$strapdir` to be declared. as well as -`$parted_root`, `$parted_boot` if `$parted_type=dos`, or `$gpt_root`, -`$gpt_boot` if `$parted_type=gpt`. see `creating_wrappers(7)` for insight on -these variables. - -the workflow of this function is bootstrapping a complete rootfs, creating a raw -image, installing/compiling a kernel, rsyncing everything to the raw image, and -finally, compressing the raw image. - - -## devprocsys() -this function is a simple helper function that takes two arguments: `watdo` and -`werdo`. it mounts or umounts `/sys`, `/dev`, `/dev/pts`, and `procfs` where you -tell it to. for example: - -``` -devprocsys mount $strapdir -devprocsys umount $strapdir -``` - - -## findloopmapp() -this functions takes the raw image and finds a free loopdevice for it to be -mounted. it calls `losetup(8)` and `kpartx(8)`. - - -## qemu_install_user() -helper function to install the userspace qemu to `$strapdir`. - - -## dpkgdivert() -this one takes two arguments, `watdo` and `werdo` (much like `devprocsys`). it -will create a dpkg diversion in the place you tell it to and remove invoke-rc.d -so that apt doesn't autostart daemons when they are installed. - - -## enablessh() -this function will allow root login with password in the bootstrapped rootfs. - - -## silly() -a funny function printing out random messages. diff --git a/doc/Makefile b/docs/Makefile diff --git a/doc/configuration.7.md b/docs/configuration.7.md diff --git a/doc/creating_wrappers.7.md b/docs/creating_wrappers.7.md diff --git a/docs/helper_functions.7.md b/docs/helper_functions.7.md @@ -0,0 +1,60 @@ +helper functions +================ + +you can find useful helper functions in `libdevuansdk/zlibs/helpers`. they are +intended to help you with writing wrappers, as well as making my job easier +within developing libdevuansdk. some of these functions are required for +libdevuansdk to properly work as well. + + +## build_image_dist() +this function is kind of a wrapper function, mostly used in `arm-sdk` to build a +complete "dd-able" image from start to end. to run, it requires `$arch`, +`$size`, `$parted_type`, `$workdir`, and `$strapdir` to be declared. as well as +`$parted_root`, `$parted_boot` if `$parted_type=dos`, or `$gpt_root`, +`$gpt_boot` if `$parted_type=gpt`. see `creating_wrappers(7)` for insight on +these variables. + +the workflow of this function is bootstrapping a complete rootfs, creating a raw +image, installing/compiling a kernel, rsyncing everything to the raw image, and +finally, compressing the raw image. + + +## devprocsys() +this function is a simple helper function that takes two arguments: `watdo` and +`werdo`. it mounts or umounts `/sys`, `/dev`, `/dev/pts`, and `procfs` where you +tell it to. for example: + +``` +devprocsys mount $strapdir +devprocsys umount $strapdir +``` + + +## findloopmapp() +this functions takes the raw image and finds a free loopdevice for it to be +mounted. it calls `losetup(8)` and `kpartx(8)`. + + +## qemu_install_user() +helper function to install the userspace qemu to `$strapdir`. + + +## dpkgdivert() +this one takes two arguments, `watdo` and `werdo` (much like `devprocsys`). it +will create a dpkg diversion in the place you tell it to and remove invoke-rc.d +so that apt doesn't autostart daemons when they are installed. + + +## enablessh() +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. diff --git a/doc/libdevuansdk.7.md b/docs/libdevuansdk.7.md diff --git a/doc/nanodoc b/docs/nanodoc diff --git a/doc/static/foot.html b/docs/static/foot.html diff --git a/doc/static/head.html b/docs/static/head.html diff --git a/doc/workflow.7.md b/docs/workflow.7.md diff --git 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 <http://www.gnu.org/licenses/>. -libdevuansdk_version="0.2" +libdevuansdk_version="0.3" LIBPATH=${LIBPATH:-`dirname $0`} source $LIBPATH/config diff --git 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,7 @@ 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 cleanup || zerr sleep 1 devprocsys umount $strapdir || zerr @@ -94,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-* +#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 +136,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 +179,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 @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this source code. If not, see <http://www.gnu.org/licenses/>. -## 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 <<EOF | sudo tee ${strapdir}/etc/init.d/regensshkeys @@ -222,10 +220,9 @@ case "\$1" in esac EOF - dpkgdivert on $strapdir - sudo chmod +x $strapdir/enssh - sudo -E chroot $strapdir /enssh - dpkgdivert off $strapdir + sudo chmod +x $strapdir/etc/init.d/regensshkeys + + chroot-script -d enssh } install-custdebs() { @@ -246,8 +243,35 @@ apt-get autoremove apt-get clean rm -rf /debs install-debs EOF - sudo chmod +x $strapdir/install-debs - sudo -E chroot $strapdir /install-debs + chroot-script install-debs +} + +chroot-script() { + fn chroot-script "$@" + + case "x$1" in + x-d) + shift 1 + local scripts="$@" + + 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() { diff --git a/zlibs/iso b/zlibs/iso @@ -36,10 +36,8 @@ apt-get --yes --force-yes autoremove apt-get clean rm -f /isoprep EOF - dpkgdivert on $strapdir - sudo chmod +x $strapdir/isoprep - sudo -E chroot $strapdir /isoprep - dpkgdivert off $strapdir + + chroot-script -d isoprep || zerr } iso_setup_isolinux() { diff --git a/zlibs/kernel b/zlibs/kernel @@ -33,7 +33,7 @@ build_kernel_amd64() { dpkgdivert on $strapdir devprocsys mount $strapdir - sudo chroot $strapdir \ + sudo -E chroot $strapdir \ apt-get --yes --force-yes install $kernel devprocsys umount $strapdir @@ -54,7 +54,7 @@ build_kernel_i386() { dpkgdivert on $strapdir devprocsys mount $strapdir - sudo chroot $strapdir \ + sudo -E chroot $strapdir \ apt-get --yes --force-yes install $kernel devprocsys umount $strapdir diff --git a/zlibs/rsync b/zlibs/rsync @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this source code. If not, see <http://www.gnu.org/licenses/>. -## 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 @@ -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 }