diff options
author | V3n3RiX <venerix@rogentos.ro> | 2016-11-18 18:09:48 +0000 |
---|---|---|
committer | V3n3RiX <venerix@rogentos.ro> | 2016-11-18 18:09:48 +0000 |
commit | da7769eb337baf8cc5b288acb6b797bf50132f7f (patch) | |
tree | 923df9a9010ba19df581ecaa2483cdc6962e6b82 | |
parent | 0f4c653ab18eedc704efe87f6a3b7aa74e79f6ff (diff) |
merge makeiso and makepkg scripts into libvasile
-rwxr-xr-x | libvasile | 98 | ||||
-rwxr-xr-x | makeiso | 89 | ||||
-rwxr-xr-x | makepkg | 36 | ||||
-rwxr-xr-x | vasile | 4 |
4 files changed, 100 insertions, 127 deletions
@@ -97,6 +97,25 @@ chrootchecksum () { # build functions +chrootprepare () { + while : true ; do + if [[ ! -d "$rodir" && ! -d "$rwdir" && ! -d "$workdir" && ! -d "$overlaydir" ]] ; then + for i in "$rodir" "$rwdir" "$workdir" "$overlaydir" ; do + mkdir "$i" + done + chrootstart + break + elif [[ -d "$rodir" && -d "$rwdir" && -d "$workdir" && -d "$overlaydir" ]] ; then + chrootstop + for i in "$rodir" "$rwdir" "$workdir" "$overlaydir" ; do + rm -rf "$i" + done + continue + fi + done + +} + chrootstop () { umount -l "$overlaydir"/proc > /dev/null 2>&1 umount -l "$overlaydir"/sys > /dev/null 2>&1 @@ -155,6 +174,17 @@ chrootx64 () { chroot "$overlaydir" su - "$chrootuser" } +makepkg () { + chrootchecksum + chrootprepare + chrootoverlays + chrootbuildsystem + chrootdevtree + chrootbuild + chrootx64 + chrootstop +} + # iso functions isostart () { @@ -219,3 +249,71 @@ isochroot () { einfo "EXIT WHEN YOU'RE DONE AND I'LL CREATE THE IMAGE" chroot "$isosyncdir" su - "$isouser" } + +prepareiso () { + mkdir -p "$isosyncdir" + dd if=/dev/zero of=""$isosyncdir".img" bs=50M count=400 + mkfs.ext4 ""$isosyncdir".img" + mkdir -p "$isostagingdir" + mkdir -p "$isobootdir" + mkdir -p "$isoefibootdir" + mkdir -p "$isoliveosdir" + mkdir -p "$isosupersquashdir" + mkdir -p "$isolivesqfsdir" + mount -t squashfs "$chrootx64" "$isostagingdir" + mount -t ext4 ""$isosyncdir".img" "$isosyncdir" + rsync -aHAXr --progress "$isostagingdir/" "$isosyncdir/" + cp -avx ""$isosyncdir"/boot/"$isokernelname"" ""$isorootdir"/boot/vmlinuz" + isostart + isoramfs + isostop + mv ""$isosyncdir"/boot/"$isodracutrd"" ""$isorootdir"/boot/initrd" + isostart + isoefiimg + isostop + mv ""$isosyncdir"/root/bootx64.efi" "$isoefibootdir" + chmod 755 ""$isoefibootdir"/bootx64.efi" + isostart + isochainload + isostop + mv ""$isosyncdir"/root/core.img" "$isobootdir" + cp -avx ""$isosyncdir"/usr/lib64/grub/i386-pc/lnxboot.img" "$isobootdir" + isostart + isooverlays + isobuildsystem + isousertree + isochroot + isostop + isostart + isoservices + isostop + umount -l "$isosyncdir" > /dev/null 2>&1 + mv ""$isosyncdir".img" "$isolivesqfsdir" + mksquashfs "$isosupersquashdir" ""$isorootdir"/squashfs.img" -b 1048576 -comp xz -Xdict-size 100% + mv ""$isorootdir/"squashfs.img" "$isoliveosdir" +} + +bootcoreiso () { + git clone https://gitlab.com/"$releasename"/boot-core.git "$bootcorepath" + cp -avx "$bootcorefiles" "$isorootdir" +} + +cleanupiso () { + umount "$isostagingdir" + rm -rf "$isosyncdir" + rm -rf "$isostagingdir" + rm -rf "$isosupersquashdir" + rm -rf "$bootcorepath" +} + +makeisoimg () { + grub2-mkrescue -o ""$releasename"-"$releasetarget"-"$releaseversion"-"$isomainarch".iso" "$isorootdir" +} + +makeiso () { + chrootchecksum + prepareiso + bootcoreiso + cleanupiso + makeisoimg +} diff --git a/makeiso b/makeiso deleted file mode 100755 index e6ef8dc..0000000 --- a/makeiso +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env bash - -prepareiso () { - # we really need this folder as quick as possible - mkdir -p "$isosyncdir" - # create an empty 20GB ext4 fs were our rootfs will stay - dd if=/dev/zero of=""$isosyncdir".img" bs=50M count=400 - mkfs.ext4 ""$isosyncdir".img" - # create live iso layout - mkdir -p "$isostagingdir" - mkdir -p "$isobootdir" - mkdir -p "$isoefibootdir" - mkdir -p "$isoliveosdir" - mkdir -p "$isosupersquashdir" - mkdir -p "$isolivesqfsdir" - # mount && copy core stage 4 image - mount -t squashfs "$chrootx64" "$isostagingdir" - mount -t ext4 ""$isosyncdir".img" "$isosyncdir" - rsync -aHAXr --progress "$isostagingdir/" "$isosyncdir/" - # copy kernel into cdroot - cp -avx ""$isosyncdir"/boot/"$isokernelname"" ""$isorootdir"/boot/vmlinuz" - # generate live initramfs - isostart - isoramfs - isostop - # copy live initramfs into cdroot - mv ""$isosyncdir"/boot/"$isodracutrd"" ""$isorootdir"/boot/initrd" - # generate live efi image - isostart - isoefiimg - isostop - # copy efi image into cdroot - mv ""$isosyncdir"/root/bootx64.efi" "$isoefibootdir" - chmod 755 ""$isoefibootdir"/bootx64.efi" - # generate grub chainloader for syslinux - isostart - isochainload - isostop - # copy chainloader parts into cdroot - mv ""$isosyncdir"/root/core.img" "$isobootdir" - cp -avx ""$isosyncdir"/usr/lib64/grub/i386-pc/lnxboot.img" "$isobootdir" - # configure portage && give up control for package / desktop environment installation - isostart - isooverlays - isobuildsystem - isousertree - isochroot - isostop - # enable system services - isostart - isoservices - isostop - # unmount rootfs before compression - umount -l "$isosyncdir" > /dev/null 2>&1 - # move rootfs in place - mv ""$isosyncdir".img" "$isolivesqfsdir" - # squash rootfs with best compression - mksquashfs "$isosupersquashdir" ""$isorootdir"/squashfs.img" -b 1048576 -comp xz -Xdict-size 100% - # move squashed rootfs in place - mv ""$isorootdir/"squashfs.img" "$isoliveosdir" -} - -bootcoreiso () { - # configure live bootloader - git clone https://gitlab.com/"$releasename"/boot-core.git "$bootcorepath" - cp -avx "$bootcorefiles" "$isorootdir" -} - -cleanupiso () { - umount "$isostagingdir" - rm -rf "$isosyncdir" - rm -rf "$isostagingdir" - rm -rf "$isosupersquashdir" - rm -rf "$bootcorepath" -} - -makeiso () { - grub2-mkrescue -o ""$releasename"-"$releasetarget"-"$releaseversion"-"$isomainarch".iso" "$isorootdir" -} - -main () { - chrootchecksum - prepareiso - bootcoreiso - cleanupiso - makeiso -} - -main diff --git a/makepkg b/makepkg deleted file mode 100755 index d8590b5..0000000 --- a/makepkg +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -chrootprepare () { - # check our environment for sanity - # if safe, trigger start && break the loop to build packages - # else trigger stop && cleanup && check again - while : true ; do - if [[ ! -d "$rodir" && ! -d "$rwdir" && ! -d "$workdir" && ! -d "$overlaydir" ]] ; then - for i in "$rodir" "$rwdir" "$workdir" "$overlaydir" ; do - mkdir "$i" - done - chrootstart - break - elif [[ -d "$rodir" && -d "$rwdir" && -d "$workdir" && -d "$overlaydir" ]] ; then - chrootstop - for i in "$rodir" "$rwdir" "$workdir" "$overlaydir" ; do - rm -rf "$i" - done - continue - fi - done -} - -main () { - chrootchecksum - chrootprepare - chrootoverlays - chrootbuildsystem - chrootdevtree - chrootbuild - chrootx64 - chrootstop -} - -main -exit 0 @@ -18,10 +18,10 @@ kernelconfig case $1 in --makepkg) - source /usr/share/vasile/makepkg + makepkg ;; --makeiso) - source /usr/share/vasile/makeiso + makeiso ;; --resetmode) source /usr/share/vasile/resetmode |