summaryrefslogtreecommitdiff
path: root/buildiso
blob: 86c20b35f174e5d6e5bbe3ba5b84b59413ae37ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash

# Vasile needs root privileges and a proper kernel to run

kernelconfig
checkroot

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
	# generate system initramfs
	isostart
	systemramfs
	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"
	# configure portage && give up control for package / desktop environment installation
	isostart
	isooverlays
	isobuildsystem
	isousertree
	isochroot
	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