libdevuansdk

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

commit fb9cb40d333bf36b17920d1d17bf82494929a614
parent e3c0e5595be96a45d2e5861d37c77e5af4c611a2
Author: Jaromil <jaromil@dyne.org>
Date:   Mon, 13 Jun 2016 18:12:32 +0200

simplified loading of library

config moved to each sdk implementation, library checks if config
variables are set. other minor fixes (missing zlibs/grub source)

Diffstat:
Mconfig | 24------------------------
Mlibdevuansdk | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
Mzlibs/grub | 4++--
Mzlibs/helpers | 19+++++++++----------
Mzlibs/isolinux | 2+-
Mzlibs/qemu | 2+-
6 files changed, 72 insertions(+), 63 deletions(-)

diff --git a/config b/config @@ -37,27 +37,3 @@ mirror="http://packages.devuan.org/merged" # mirror repo section section="main" - -# core packages for the system -core_packages=(devuan-keyring debian-keyring) -core_packages+=(initramfs-tools binutils ca-certificates curl) -core_packages+=(console-common less nano vim) - -# base packages for the system -base_packages=(bzip2 dialog apt-utils fakeroot e2fsprogs parted) - -# other system packages -system_packages=(sysvinit ssh) - -# size of raw image file in MB -imgsize=1337 - -## libdevuansdk-specific settings -workdir="$H/workdir" -strapdir="${workdir}/${os}-${release}-${version}" -outdir="$H/builds" - -# declare zuper globals -vars+=(os release version mirror section) -vars+=(workdir strapdir) -vars+=(imgsize) diff --git a/libdevuansdk b/libdevuansdk @@ -26,25 +26,44 @@ devuan_sdk_version=0.1 setopt pushdsilent # export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin" -SDK_PREFIX=`pwd` -SDK_HOME=`pwd` -SDK_CONF=`pwd` +SDK_LIB=${SDK_LIB:-`pwd`} -R=${SDK_PREFIX:-/usr/local/devuan-sdk} -H=${SDK_HOME:-$HOME/.devuan-sdk} -E=${SDK_CONF:-/etc/devuan-sdk} +[[ "$core_packages" = "" ]] && { + # core packages for the system + core_packages=(devuan-keyring debian-keyring) + core_packages+=(initramfs-tools binutils ca-certificates curl) + core_packages+=(console-common less nano vim) +} +[[ "$base_packages" = "" ]] && { + # base packages for the system + base_packages=(bzip2 dialog apt-utils fakeroot e2fsprogs parted) +} +[[ "$system_packages" = "" ]] && { + # other system packages + system_packages=(sysvinit ssh) +} +# default size for an img +imgsize=${imgsize:-1337} + + +## libdevuansdk-specific settings +workdir="$H/workdir" +strapdir="${workdir}/${os}-${release}-${version}" +outdir="$H/builds" -[[ -r $R ]] || { - print "Devuan SDK is not installed in: $R" - print "export SDK_PREFIX if installed on a different path" + + +[[ -r $SDK_LIB/libdevuansdk ]] || { + print "Devuan SDK is not installed in: $SDK_LIB" + print "export SDK_LIB if installed on a different path" } ######################## ## Load Zuper extensions # conclude initialization -if [[ -r $R/zuper/zuper ]]; then - source $R/zuper/zuper +if [[ -r $SDK_LIB/zuper/zuper ]]; then + source $SDK_LIB/zuper/zuper else source ./zuper/zuper; fi DEBUG=${DEBUG:-0} @@ -53,29 +72,35 @@ LOG=${LOG:-""} # path and debugging vars+=(R H E) -vars+=(name_default) +vars+=(SDK_LIB SDK_PREFIX SDK_CONF SDK_HOME) + +# config globals +vars+=(os release version mirror section) +vars+=(workdir strapdir) +vars+=(imgsize) + # source $R/zlibs/library -source $E/config -source $R/zlibs/bootstrap -source $R/zlibs/helpers +source $SDK_LIB/zlibs/bootstrap +source $SDK_LIB/zlibs/helpers # source $R/zlibs/imaging -source $R/zlibs/isolinux -source $R/zlibs/kernel -source $R/zlibs/qemu -source $R/zlibs/sysconf +source $SDK_LIB/zlibs/isolinux +source $SDK_LIB/zlibs/kernel +source $SDK_LIB/zlibs/qemu +source $SDK_LIB/zlibs/grub +source $SDK_LIB/zlibs/sysconf +# name of target by default, omits arch +vars+=(name_default) +name_default=${os}_${release}_${version} # conclude initialization -if [[ -r $R/zuper/zuper.init ]]; then - source $R/zuper/zuper.init +if [[ -r $SDK_LIB/zuper/zuper.init ]]; then + source $SDK_LIB/zuper/zuper.init else source ./zuper/zuper.init; fi -# name of target by default, omits arch -name_default=${os}_${release}_${version} - # add all other binaries to the path -path+=($R/bin) +path+=($SDK_LIB/bin) rehash @@ -89,4 +114,13 @@ notice "Loading Devuan SDK library v$devuan_sdk_version" # ... +req=(os release version mirror section) +ckreq || { error "configuration is missing"; zshexit; return 1 } + act "library succesfully loaded" + +# default operational paths +R=${R:-$SDK_PREFIX} +H=${H:-$SDK_HOME} +E=${E:-$SDK_CONF} + diff --git a/zlibs/grub b/zlibs/grub @@ -22,12 +22,12 @@ # along with this source code. If not, see <http://www.gnu.org/licenses/>. -grub_install_target_dev(){ +grub_install_target_dev() { fn grub_install_target_dev $@ root=$1 install_dev=$2 req=(root install_dev) - freq=($root/.done $root/dev/pts/0) + freq=($root/.done) ckreq || return 1 # TODO: should we use qemu-chroot here for $arch = arm (parazyd?) diff --git a/zlibs/helpers b/zlibs/helpers @@ -73,10 +73,10 @@ mountdevprocsys() { req=(mntdir) ckreq || return 1 - sudo mount -o bind /sys ${mntdir}/sys && act "mounted /sys" - sudo mount -t proc proc ${mntdir}/proc && act "mounted /proc" - sudo mount -o bind /dev ${mntdir}/dev && act "mounted /dev" - sudo mount -o bind /dev/pts ${mntdir}/dev/pts && act "mounted /dev/pts" + sudo mount -o bind /sys ${mntdir}/sys && act "mounted /sys in $mntdir" + sudo mount -t proc proc ${mntdir}/proc && act "mounted /proc in $mntdir" + sudo mount -o bind /dev ${mntdir}/dev && act "mounted /dev in $mntdir" + sudo mount -o bind /dev/pts ${mntdir}/dev/pts && act "mounted /dev/pts $mntdir" } umountdevprocsys() { @@ -85,10 +85,10 @@ umountdevprocsys() { req=(mntdir) ckreq || return 1 - sudo umount ${mntdir}/dev/pts && act "unmounted /dev/pts" && sleep 2 - sudo umount ${mntdir}/dev && act "unmounted /dev" && sleep 2 - sudo umount ${mntdir}/proc && act "unmounted /proc" && sleep 2 - sudo umount ${mntdir}/sys && act "unmounted /sys" && sleep 2 + sudo umount ${mntdir}/dev/pts && act "unmounted /dev/pts in $mntdir" && sleep 2 + sudo umount ${mntdir}/dev && act "unmounted /dev in $mntdir" && sleep 2 + sudo umount ${mntdir}/proc && act "unmounted /proc in $mntdir" && sleep 2 + sudo umount ${mntdir}/sys && act "unmounted /sys in $mntdir" && sleep 2 } aptautostart() { @@ -185,4 +185,4 @@ check_executable() { return 1; fi -}- \ No newline at end of file +} diff --git a/zlibs/isolinux b/zlibs/isolinux @@ -136,7 +136,7 @@ isolinux_mkusr() { mkdir -p $usrdir - rsync -av $strapdir/ $usrdir --exclude-from=$ztmpfile + rsync -raX $strapdir/ $usrdir --exclude-from=$ztmpfile mkdir -p $isodir/live mksquashfs $usrdir/ $isodir/live/filesystem.squashfs -noappend diff --git a/zlibs/qemu b/zlibs/qemu @@ -26,7 +26,7 @@ qemu_make_img(){ fn qemu_make_img $@ local imgfile=${1:-"$H/builds/${name_default}_${arch}.img"} - local imgsize=${2:-4G} + local imgsize=${2:-2G} local imgformat=${3:-raw} req=(strapdir os release version arch imgfile imgsize) root=$strapdir