/
mkiso
executable file
·132 lines (104 loc) · 3.1 KB
/
mkiso
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
set -e
#Prereqs
pkgr -i dosfstools cpio squashfs-tools xorriso mtools grub &> /dev/null
#Current options: core, mate, xfce4, enlightenment, kde, everything
export NOOP_ISO_CREATE=$1
#Yes this is bad, but ISO creation is done in a VM anyways.
cd /root
if [ -e iso-fs ];
then
umount iso-fs/dev iso-fs/sys iso-fs/proc || true
fi
if [ -z "$KEEP" ]; then
rm -rf iso iso-fs efs
else
rm -rf iso/root.sqsh
fi
mkdir -p iso iso-fs efs
#Initramfs
/var/noop/initramfs/mkinitramfs-live
#Instlr
/var/noop/instlr /root/iso-fs $2
umount iso-fs/dev iso-fs/sys iso-fs/proc;
#Install grub to iso, fails on encrypted drives, doesn't matter though.
grub-install \
--boot-directory=/root/iso/boot \
--no-bootsector \
--no-rs-codes \
--target=i386-pc \
--skip-fs-probe \
--no-nvram \
/dev/zero || true
#Create fat partition image, 30MB
dd if=/dev/zero of=/root/iso/boot/efs.img bs=1024 count=30720
mkfs.fat /root/iso/boot/efs.img
mount /root/iso/boot/efs.img /root/efs
#Get grub config
cp /var/noop/etc/iso-grub.cfg /root/iso/boot/grub/grub.cfg
#Copy initrd
cp noop-initramfs-live.igz /root/iso/boot
mv noop-initramfs-live.igz /root/efs/
#Copy kernel
cp -r /root/iso-fs/boot/vmlinuz /root/iso/boot/vmlinuz
cp -r /root/iso-fs/boot/vmlinuz /root/efs/vmlinuz.efi
#Copy systemd-boot (gummiboot)
mkdir -p /root/efs/EFI/boot/
cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi /root/efs/EFI/boot/bootx64.efi
#Create initial grub config
rm -rf init.grub.config
for i in part_acorn part_amiga part_apple part_bsd part_dfly part_dvh part_gpt part_msdos part_plan part_sun part_sunpc;
do
echo "insmod $i" >> init.grub.config
done
#Create loader for systemd-boot
mkdir -p /root/efs/loader/entries
echo "timeout 3" >> /root/efs/loader/loader.conf
echo "default noop-live*" >> /root/efs/loader/loader.conf
echo "title noop live" >> /root/efs/loader/entries/noop-live.conf
echo "linux /vmlinuz.efi" >> /root/efs/loader/entries/noop-live.conf
echo "initrd /noop-initramfs-live.igz" >> /root/efs/loader/entries/noop-live.conf
umount /root/efs
if [ "$NOOP_ISO_CREATE" == "enlightenment" ];
then
pushd /root/iso-fs/home/livecd
wget http://www.nooplinux.org/dist/enlightenemnt-livecd-home.tar.xz
tar xf enlightenemnt-livecd-home.tar.xz && rm enlightenemnt-livecd-home.tar.xz
popd
fi
cd /root/iso-fs
rm -rf tmp/*
mksquashfs * ../iso/root.sqsh
cd ..
grub-mkimage \
--directory '/usr/lib/grub/i386-pc' \
--prefix '/boot/grub' \
--output '/root/iso/boot/grub/i386-pc/eltorito.img' \
--format 'i386-pc-eltorito' \
--compression 'auto' \
--config '/root/init.grub.config' 'biosdisk' 'iso9660'
NAME_DATE=`date +%Y%m%d`
if [ -e "$1" ]; then
iso_name=custom
else
iso_name=$1
fi
xorriso -as mkisofs \
-graft-points \
-b boot/grub/i386-pc/eltorito.img \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--grub2-boot-info \
--grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img \
-apm-block-size 2048 \
--efi-boot boot/efs.img \
-efi-boot-part \
--efi-boot-image \
--protective-msdos-label \
-o "noop-${iso_name}-${NAME_DATE}${2}.iso" \
-rational-rock \
--sort-weight 0 / --sort-weight 1 /boot \
iso
rm init.grub.config
rm -r efs