From c22716a1319a0b277a72d3577c7bb92d6312003b Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Tue, 31 Oct 2017 18:28:57 +0000 Subject: day 4 : makeiso functions split complete --- src/backend/functions_makeiso.sh | 156 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) (limited to 'src') diff --git a/src/backend/functions_makeiso.sh b/src/backend/functions_makeiso.sh index e69de29..66d564f 100644 --- a/src/backend/functions_makeiso.sh +++ b/src/backend/functions_makeiso.sh @@ -0,0 +1,156 @@ +#!/usr/bin/env bash + +jailisomnt () { + mount -o bind packages "$jailsynctarget"/var/cache/packages + mount -t proc proc "$jailsynctarget"/proc + mount -t sysfs sysfs "$jailsynctarget"/sys + mount -t devtmpfs -o relatime,size=3055348k,nr_inodes=763837,mode=755 none "$jailsynctarget"/dev + mount -t devpts -o nosuid,noexec,relatime,gid=5,mode=620 none "$jailsynctarget"/dev/pts + mount -t tmpfs -o nosuid,nodev none "$jailsynctarget"/dev/shm + mount -t tmpfs -o nosuid,nodev,noexec none "$jailsynctarget"/tmp +} + +jailisodmnt () { + umount -l "$jailsynctarget"/proc > /dev/null 2>&1 + umount -l "$jailsynctarget"/sys > /dev/null 2>&1 + umount -l "$jailsynctarget"/dev/pts > /dev/null 2>&1 + umount -l "$jailsynctarget"/dev/shm > /dev/null 2>&1 + umount -l "$jailsynctarget"/dev > /dev/null 2>&1 + umount -l "$jailsynctarget"/tmp > /dev/null 2>&1 + umount -l "$jailsynctarget"/var/cache/packages > /dev/null 2>&1 +} + +jailisobinmode () { + chroot "$jailsynctarget" su - "$jailuser" -c "$jailbinmodecmd" +} + +jailisomkramfs () { + chroot "$jailsynctarget" su - "$jailuser" -c "$jaildracutcmd" +} + +jailisomkefi () { + chroot "$jailsynctarget" su - "$jailuser" -c "$jailmkx64eficmd" + chroot "$jailsynctarget" su - "$jailuser" -c "$jailmkia32eficmd" +} + +jailisomkchload () { + chroot "$jailsynctarget" su - "$jailuser" -c "$jailmkchainloadercmd" +} + +jailisoenserv () { + chroot "$overlaypath" su - "$jailuser" -c "rc-update add redcorelive boot" + for service in acpid dbus NetworkManager avahi-daemon syslog-ng cupsd cronie cgmanager consolekit alsasound bluetooth ntpd openrc-settingsd xdm virtualbox-guest-additions ; do + chroot "$overlaypath" su - "$jailuser" -c "rc-update add "$service" default" + done +} + +jailisomkdkms () { + chroot "$jailsynctarget" su - "$jailuser" -c "$jaildkmscmd" +} + +jailisostart () { + einfo "Oh no, I'm in jail!" + chroot "$jailsynctarget" su - "$jailuser" +} + +mkliveimg () { + # create live filesystem image layout + mkdir -p "$jailsynctarget" + dd if=/dev/zero of=""$jailsynctarget".img" bs=1M count=10240 + sync + mkfs.ext2 -F ""$jailsynctarget".img" + mkdir -p "$jailsyncsource" + mkdir -p "$jaildvdpath" + mkdir -p "$jailsquashfspath" + mkdir -p "$jailrealfspath" + mkdir -p "$jailbootldrpath" + mkdir -p "$jailefildrpath" + sync + # mount "stage4" image and sync live filesystem image core components + mount -t squashfs "$jailx64" "$jailsyncsource" + mount -t ext4 ""$jailsynctarget".img" "$jailsynctarget" + rsync -aHAXr --progress "$jailsyncsource/" "$jailsynctarget/" + sync + # umount "stage4" image + umount "$jailsyncsource" + # copy live kernel image + cp -avx ""$jailsynctarget"/boot/"$jailkernname"" ""$jailrootpath"/boot/vmlinuz" + # create and copy live initramfs + jailisomnt + jailisomkramfs + jailisodmnt + mv ""$jailsynctarget"/boot/"$jailramfsname"" ""$jailrootpath"/boot/initrd" + sync + # create and copy EFI loader + jailisomnt + jailisomkefi + jailisodmnt + mv ""$jailsynctarget"/root/bootx64.efi" "$jailefildrpath" + mv ""$jailsynctarget"/root/bootia32.efi" "$jailefildrpath" + chmod 755 ""$jailefildrpath"/bootx64.efi" + chmod 755 ""$jailefildrpath"/bootia32.efi" + sync + # create and copy syslinux -> grub chainloader for Unetbootin compatibility + jailisomnt + jailisomkchload + jailisodmnt + mv ""$jailsynctarget"/root/core.img" "$jailbootldrpath" + cp -avx ""$jailsynctarget"/usr/lib64/grub/i386-pc/lnxboot.img" "$jailbootldrpath" + sync + # chroot into live filesystem image + jailisomnt + jailisobinmode + jailisostart + jailisodmnt + sync + # compile and install DKMS modules, if any + jailisomnt + jailisomkdkms + jailisodmnt + sync + # enable live services + jailisomnt + jailisoenserv + jailisodmnt + sync + # unmount live filesystem image + umount -l "$jailsynctarget" > /dev/null 2>&1 + # move live filesystem image where it should be + mv ""$jailsynctarget".img" "$jaildvdpath" + sync + # compress live filesystem image + mksquashfs "$jaildvdpath" ""$jailrootpath"/squashfs.img" -b 1048576 -comp xz -Xdict-size 100% + sync + # move compressed live filesystem image where it should be + mv ""$jailrootpath/"squashfs.img" "$jailsquashfspath" + sync +} + +cfgbootldr () { + # fetch and install GRUB2 config files + git clone https://gitlab.com/"$distname"/boot-core.git "$jailbootldrdlpath" + cp -avx "$jailbootldrcfgpath" "$jailrootpath" + sync +} + +mkclean () { + # clean temporary resources + rm -rf "$jailsyncsource" + rm -rf "$jailsynctarget" + rm -rf "$jaildvdpath" + rm -rf "$jailbootldrpath" +} + +mkisoimg () { + # create the actual iso image + grub2-mkrescue -o ""$jailrootpath".iso" "$jailrootpath" +} + +makeiso () { + checkifroot + checkjailsum + mkliveimg + cfgbootldr + mkclean + mkisoimg +} -- cgit v1.2.3