commit 9e6fd1988b4278600b319504954cad06b8362969
parent 53cb23a2c55d7ab2c3582dc58d4d0e6af23aa5db
Author: parazyd <parazyd@dyne.org>
Date: Wed, 8 Jun 2016 21:07:08 +0200
drop escalate wrapper
Diffstat:
4 files changed, 59 insertions(+), 30 deletions(-)
diff --git a/zlibs/debootstrap b/zlibs/debootstrap
@@ -41,25 +41,25 @@ bootstrap() {
bootstrap_tar_unpack ${strapdir}
else
# Debootstrap stage 1
- escalate "root" "debootstrap --foreign --arch ${arch} ${release} ${strapdir} ${mirror}"
+ sudo debootstrap --foreign --arch ${arch} ${release} ${strapdir} ${mirror}
# Debootstrap stage 2
- escalate "root" "chroot ${strapdir} /debootstrap/debootstrap --second-stage"
+ sudo chroot ${strapdir} /debootstrap/debootstrap --second-stage
# write all system configuration
- conf_print_debconf | escalate "root" "tee ${strapdir}/debconf.set"
- conf_print_fstab | escalate "root" "tee ${strapdir}/etc/fstab"
- conf_print_hostname | escalate "root" "tee ${strapdir}/etc/hostname"
- conf_print_hosts | escalate "root" "tee ${strapdir}/etc/hosts"
- conf_print_networkifaces | escalate "root" "tee ${strapdir}/etc/network/interfaces"
- conf_print_resolvconf | escalate "root" "tee ${strapdir}/etc/resolv.conf"
- conf_print_sourceslist | escalate "root" "tee ${strapdir}/etc/apt/sources.list"
+ conf_print_debconf | sudo tee ${strapdir}/debconf.set
+ conf_print_fstab | sudo tee ${strapdir}/etc/fstab
+ conf_print_hostname | sudo tee ${strapdir}/etc/hostname
+ conf_print_hosts | sudo tee ${strapdir}/etc/hosts
+ conf_print_networkifaces | sudo tee ${strapdir}/etc/network/interfaces
+ conf_print_resolvconf | sudo tee ${strapdir}/etc/resolv.conf
+ conf_print_sourceslist | sudo tee ${strapdir}/etc/apt/sources.list
# write third-stage for chroot
- bootstrap_config_thirdstage | escalate "root" "tee ${strapdir}/thirdstage.sh"
- bootstrap_config_cleanup | escalate "root" "tee ${strapdir}/cleanup.sh"
- escalate "root" "chmod +x ${strapdir}/thirdstage.sh"
- escalate "root" "chmod +x ${strapdir}/cleanup.sh"
+ bootstrap_config_thirdstage | sudo tee ${strapdir}/thirdstage.sh
+ bootstrap_config_cleanup | sudo tee ${strapdir}/cleanup.sh
+ sudo chmod +x ${strapdir}/thirdstage.sh
+ sudo chmod +x ${strapdir}/cleanup.sh
# chroot into it and configure further
# Debootstrap stage 3
@@ -68,8 +68,8 @@ bootstrap() {
mountdevproc ${strapdir}
- escalate "root" "chroot ${strapdir} /thirdstage.sh"
- escalate "root" "chroot ${strapdir} /cleanup.sh"
+ sudo chroot ${strapdir} /thirdstage.sh
+ sudo chroot ${strapdir} /cleanup.sh
umountdevproc ${strapdir}
@@ -87,6 +87,7 @@ rm -f /debconf.set
rm -f /thirdstage.sh
rm -f /etc/ssh/*key
rm -f /etc/ssh/*.pub
+rm -f /root/.bash_history
EOF
}
@@ -122,6 +123,8 @@ 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
@@ -139,9 +142,15 @@ bootstrap_tar_pack() {
act "tarball found already in ::1 dir::" $_dest
else
notice "Creating boostrap tarball in ::1 tgz::" $bootstrap_tgz
+ silly
+
pushd ${strapdir}
+
mkdir -p ${_dest}
- escalate root "tar czf $bootstrap_tgz . --exclude=dev,sys,proc"
+ sudo tar czf $bootstrap_tgz \
+ --exclude={./boot,./dev,./sys,./proc} \
+ ./
+
popd
fi
ls -lh $bootstrap_tgz
@@ -160,5 +169,7 @@ bootstrap_tar_unpack() {
}
mkdir -p ${unpath}
+ silly
tar xf $bootstrap_tgz -C ${unpath}
+ sudo mkdir -p ${unpath}/{boot,dev,sys,proc}
}
diff --git a/zlibs/helpers b/zlibs/helpers
@@ -39,10 +39,11 @@ escalate() {
findloopmapp() {
fn findloopmapp
- req=(imgpath)
+ req=(imgpath imgname workdir)
ckreq || return 1
- loopdevice=`sudo losetup -f --show ${imgpath}`
+ pushd ${workdir}
+ loopdevice=`sudo losetup -f --show ${imgname}`
mappdevice=`sudo kpartx -va $loopdevice | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1`
func "Loop device: ::1 loopdev::" $loopdevice
func "Mapper device: ::1 mappdev::" $mappdevice
@@ -52,6 +53,8 @@ findloopmapp() {
mappdevice="/dev/mapper/${mappdevice}"
bootpart=${mappdevice}p1
rootpart=${mappdevice}p2
+
+ popd
}
mountdevproc() {
@@ -60,9 +63,9 @@ mountdevproc() {
req=(mntdir)
ckreq || return 1
- escalate "root" "mount -t proc proc ${mntdir}/proc" && act "mounted /proc"
- escalate "root" "mount -o bind /dev ${mntdir}/dev" && act "mounted /dev"
- escalate "root" "mount -o bind /dev/pts ${mntdir}/dev/pts" && act "mounted /dev/pts"
+ 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"
}
umountdevproc() {
@@ -71,9 +74,9 @@ umountdevproc() {
req=(mntdir)
ckreq || return 1
- escalate "root" "umount ${mntdir}/dev/pts" && act "unmounted /dev/pts" && sleep 2
- escalate "root" "umount ${mntdir}/dev" && act "unmounted /dev" && sleep 2
- escalate "root" "umount ${mntdir}/proc" && act "unmounted /proc" && sleep 2
+ 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
}
silly() {
diff --git a/zlibs/imaging b/zlibs/imaging
@@ -45,6 +45,7 @@ img_partition_dos() {
ckreq || return 1
notice "Partitioning with dos"
+ silly
dos_boot_size=(ext2 0 64)
dos_root_size=(ext4 64 -1)
@@ -71,6 +72,7 @@ img_partition_gpt() {
ckreq || return 1
notice "Partitioning with gpt"
+ silly
pushd ${workdir}
@@ -106,8 +108,10 @@ img_mount() {
mkdir -p ${workdir}/rootp
- escalate root "mount ${rootpart} ${workdir}/rootp" && act "mounted root partition"
- escalate root "mount ${bootpart} ${workdir}/rootp/boot" && act "mounted root partition"
+ sudo mount ${rootpart} ${workdir}/rootp && act "mounted root partition"
+ sudo mount ${bootpart} ${workdir}/rootp/boot && act "mounted boot partition"
+
+ mountdevproc ${workdir}/rootp
}
img_umount() {
diff --git a/zlibs/sysconf b/zlibs/sysconf
@@ -23,13 +23,24 @@
## Default system configuration
+conf_install_grub() {
+ fn conf_install_grub $@
+ chrootpath="$1"
+ req=(chrootpath)
+ ckreq || return 1
+
+ notice "Installing grub-pc"
+ sudo chroot ${chrootpath} apt-get --yes --force-yes install grub-pc
+}
+
conf_install_kernel() {
- fn conf_install_kernel
- req=(arch strapdir)
- freq=($strapdir/bin/bash)
+ fn conf_install_kernel $@
+ chrootpath="$1"
+ req=(arch chrootpath)
ckreq || return 1
- escalate root "chroot $strapdir apt-get install linux-image-$arch"
+ notice "Installing stock kernel (linux-image-$arch)"
+ sudo chroot ${chrootpath} apt-get --yes --force-yes install linux-image-$arch
}
conf_print_debconf() {