libdevuansdk

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

commit cb7edb49bf935aa76fccb4c8021cf1e927f05ba8
parent 5b23dfda98750b7fd69f739a2d160568ab373ba3
Author: parazyd <parazyd@dyne.org>
Date:   Mon, 25 Sep 2017 12:17:36 +0200

Merge branch 'next'

Diffstat:
Mconfig | 3++-
Mzlibs/bootstrap | 61++++++++++++++++++++++++++++++++++++++++---------------------
Mzlibs/imaging | 22++++++++++++++++------
Mzlibs/iso | 7+++----
Mzlibs/sysconf | 7+++++++
Mzlibs/vm | 5++++-
6 files changed, 72 insertions(+), 33 deletions(-)

diff --git a/config b/config @@ -73,7 +73,8 @@ base_packages=( mawk tmux screen - openntpd + #openntpd + ntp wpasupplicant wireless-tools elinks diff --git a/zlibs/bootstrap b/zlibs/bootstrap @@ -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/>. -vars+=(bootstrap_tgz) +vars+=(bootstrap_tgz_stage3 bootstrap_tgz_stage4 TAR_STAGE4) bootstrap_complete_base() { fn bootstrap_complete_base "$@" @@ -26,19 +26,31 @@ bootstrap_complete_base() { notice "bootstrapping $os $arch base" - bootstrap_tgz="$R/tmp/bootstrap-${os}-${arch}.tgz" - - [[ -f $bootstrap_tgz ]] && { - notice "using the existing bootstrap tarball found in $R/tmp" - bootstrap_tar_unpack $strapdir || { die "failed to extract"; zerr } - return 0 - } - notice "running debootstrap stage 1" - ## deboostrap stage 1 export LANG=C export LC_ALL=C export DEBIAN_FRONTEND=noninteractive + bootstrap_tgz_stage3="$R/tmp/bootstrap-${os}-${arch}-stage3.tgz" + bootstrap_tgz_stage4="$R/tmp/bootstrap-${os}-${arch}-stage4.tgz" + + if [[ -n "$TAR_STAGE4" && -f "$bootstrap_tgz_stage4" ]]; then + notice "using the existing stage4 bootstrap tarball found in $R/tmp" + bootstrap_tar_unpack "$bootstrap_tgz_stage4" "$strapdir" || { + die "failed to extract tarball" + zerr + } + return + elif [[ -f "$bootstrap_tgz_stage3" ]]; then + notice "using the existing stage3 bootstrap tarball found in $R/tmp" + bootstrap_tar_unpack "$bootstrap_tgz_stage3" "$strapdir" || { + die "failed to extract tarball" + zerr + } + return + fi + + notice "running debootstrap stage 1" + sudo -E "$LIBPATH/extra/debootstrap/debootstrap" \ --keyring="$LIBPATH/extra/devuan-keyring/keyrings/devuan-archive-keyring.gpg" \ --foreign \ @@ -85,10 +97,12 @@ EOF chroot-script addcachepubkey || zerr } - sleep 1 - - bootstrap_tar_pack || zerr - bootstrap_tar_unpack $strapdir || zerr + if [[ -n "$TAR_STAGE4" ]]; then + bootstrap_tar_unpack "$bootstrap_tgz_stage4" "$strapdir" || zerr + else + bootstrap_tar_pack "$bootstrap_tgz_stage3" || zerr + bootstrap_tar_unpack "$bootstrap_tgz_stage3" "$strapdir" || zerr + fi } bootstrap_config_thirdstage() { @@ -122,6 +136,7 @@ EOF bootstrap_tar_pack() { fn bootstrap_tar_pack req=(bootstrap_tgz) + bootstrap_tgz="$1" ckreq || return 1 local _dest=$(dirname $bootstrap_tgz) @@ -144,7 +159,8 @@ bootstrap_tar_pack() { bootstrap_tar_unpack() { fn bootstrap_tar_unpack $@ - local unpath="$1" + local bootstrap_tgz="$1" + local unpath="$2" req=(unpath bootstrap_tgz) ckreq || return 1 @@ -188,12 +204,15 @@ EOF chroot-script -d postunpack || zerr - ## below typically used in arm-sdk - [[ -n "$inittab" ]] && { - print $inittab | sudo tee -a $strapdir/etc/inittab >/dev/null - } + for i in $inittab; do + grep -q "^$i" $strapdir/etc/inittab && continue + print "$i" | sudo tee -a $strapdir/etc/inittab >/dev/null + done for i in $custmodules; do - print $i | sudo tee -a $strapdir/etc/modules >/dev/null - done || return 0 + grep -q "^$i" $strapdir/etc/modules && continue + print "$i" | sudo tee -a $strapdir/etc/modules >/dev/null + done + + [[ -n "$TAR_STAGE4" ]] && bootstrap_tar_pack "$bootstrap_tgz_stage4" } diff --git a/zlibs/imaging b/zlibs/imaging @@ -19,7 +19,8 @@ ## imagine images -vars+=(image_name bootpart rootpart loopdevice) +vars+=(image_name bootpart rootpart loopdevice filesystem) +arrs+=(fsargs) image_prepare_raw() { fn image_prepare_raw @@ -115,11 +116,11 @@ image_pack_dist() { } _xz=(xz -zv) - [[ $(command -v pixz) ]] && _xz=pixz + [[ $(command -v pixz) ]] && _xz=(pixz) notice "compressing image with $_xz" silly pushd $workdir - ${xz} "${image_name}.img" + ${=_xz} "${image_name}.img" notice "generating sha256 for ${image_name}.img.xz" sha256sum ${image_name}.img.xz > ${image_name}.img.xz.sha @@ -129,7 +130,7 @@ image_pack_dist() { mv -v ${image_name}.img.xz.sha $R/dist/ popd - [[ $DEBUG = 1 ]] || { sudo rm -r $workdir } + [[ $DEBUG = 1 ]] || sudo rm -r $workdir notice "finished packing $image_name" act "find it in $R/dist/" @@ -194,7 +195,10 @@ image_qcow2_as_strapdir() { pushd "$workdir" - notice "creating qcow2 image of $size MB" + # default filesystem fallback to ext4 + filesystem=${filesystem:-ext4} + + notice "creating qcow2 image of $size MB formatted with $filesystem" rm -f base.qcow2 qemu-img create -f qcow2 base.qcow2 ${size}M || zerr sudo modprobe nbd max_part=8 || zerr @@ -202,10 +206,16 @@ image_qcow2_as_strapdir() { [ -n "$loopdevice" ] || zerr act "$loopdevice" sudo qemu-nbd --connect=${loopdevice} base.qcow2 || zerr + notice "partitioning" sudo parted ${loopdevice} mktable msdos || zerr sudo parted ${loopdevice} mkpart primary '0%' '100%' || zerr - sudo mkfs.ext4 ${loopdevice}p1 || zerr + + notice "formatting with $filesystem" + command -v mkfs.${filesystem} >/dev/null || { + error "filesystem tools not found in path: mkfs.${filesystem}" + zerr } + sudo mkfs.${filesystem} ${=fsargs} ${loopdevice}p1 || zerr notice "mounting qcow2 image to strapdir" sudo mount ${loopdevice}p1 $strapdir || zerr diff --git a/zlibs/iso b/zlibs/iso @@ -103,13 +103,12 @@ iso_squash_strap() { notice "creating squashfs out of strapdir" - [[ -n "$mkefi" ]] && uefi_opt="-Xbcj x86" + [[ -n "$mkefi" ]] && _uefi_opt="-Xbcj x86" pushd $workdir sudo mksquashfs $strapdir binary/live/filesystem.squashfs \ - ${=uefi_opt} \ - -noappend -comp xz || zerr + ${=_uefi_opt} -noappend -comp xz || zerr + popd - unset uefi_opt } iso_xorriso_build() { diff --git a/zlibs/sysconf b/zlibs/sysconf @@ -117,6 +117,13 @@ conf_print_sourceslist() { req=(mirror release section) ckreq || return 1 + [[ $APT_CACHE = 1 ]] && { + cat <<EOF +deb file:/mnt ./ + +EOF + } + cat <<EOF deb file:/mnt ./ diff --git a/zlibs/vm b/zlibs/vm @@ -40,7 +40,8 @@ EOF print "rootfs / rootfs rw 0 0" | sudo tee ${strapdir}/etc/fstab >/dev/null sudo sed -i ${strapdir}/etc/ssh/sshd_config \ - -e 's/without-password/yes/' || zerr + -e 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' \ + -e 's/PermitRootLogin without-password/PermitRootLogin yes/'|| zerr } vm_setup_grub() { @@ -54,6 +55,8 @@ vm_setup_grub() { export DEBIAN_FRONTEND=noninteractive apt-get --yes --force-yes install linux-image-amd64 grub-pc sed -e 's:GRUB_TIMEOUT=5:GRUB_TIMEOUT=1:' -i /etc/default/grub +sed -e 's:GRUB_CMDLINE_LINUX_DEFAULT=".*":GRUB_CMDLINE_LINUX_DEFAULT="quiet net.ifnames=0":' \ + -i /etc/default/grub update-grub grub-install --no-floppy --recheck --modules="biosdisk part_msdos" \ ${loopdevice}