blob: 6fe2914dad6c47f809d2a2506eb6f5a67464d996 (
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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
#!/bin/sh
ISO_NAME="xilinux-$(date -u +%Y%m%d)"
ISO_LABEL="XILINUX"
PUBLISHER="davidovski"
SYSLINUX_VER=6.04-pre1
TO_MIRROR="file:///var/lib/xib/repo"
XI_ARGS="-yv"
WORKDIR=/tmp/xiiso
chroot=$WORKDIR/chroot
isoroot=$WORKDIR/iso
iso_pkgs="linux linux-firmware base dracut grub mksh xipkg squashfs-tools lvm2 cryptsetup networkmanager stty xitui neofetch vim nano gnupg dosfstools"
cmdline="splash console=tty0 console=ttyS0,9600 root=live:CDLABEL=$ISO_LABEL rd.live.dir=/ rd.live.squashimg=filesystem.squashfs rd.live.debug=1 quiet"
grub_mod="all_video disk part_gpt part_msdos linux normal configfile search search_label efi_gop fat iso9660 cat echo ls test true help gzio"
mkdir -p $WORKDIR
create_basesystem () {
mkdir -p $chroot
xipkg $XI_ARGS sync
xipkg $XI_ARGS -r "$chroot" bootstrap
xipkg $XI_ARGS -r "$chroot" install "$iso_pkgs"
}
configure_system() {
cat > $chroot/etc/resolv.conf << EOF
nameserver 80.80.80.80
EOF
hostname=xilinux
echo xilinux > $chroot/etc/hostname
cat > $chroot/etc/hosts << EOF
127.0.0.1 localhost
::1 localhost
127.0.1.1 $hostname.local $hostname
EOF
cp -r ./root $chroot/
cat > $chroot/etc/conf.d/agetty << EOF
agetty_options="--autologin root --noclear"
EOF
xichroot $chroot rc-update add networkmanager
}
build_initramfs () {
kernel_version=$(ls $chroot/usr/lib/modules | tail -1)
export kernel_version
mkdir -p "$chroot"/var/tmp
xichroot "$chroot" dracut --nomdadmconf --nolvmconf --xz --add dmsquash-live --add bash --add convertfs --add pollcdrom --force --kver $kernel_version
}
create_isoroot() {
mkdir -p $isoroot/
cp $chroot/boot/vmlinuz-** $isoroot/vmlinuz
cp $chroot/boot/initramfs-** $isoroot/initrd.img
mkdir -p $isoroot/isolinux
}
install_syslinux () {
curl https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/Testing/$(echo $SYSLINUX_VER | cut -d'-' -f1)/syslinux-$SYSLINUX_VER.tar.xz > syslinux-$SYSLINUX_VER.tar.xz
tar -C $WORKDIR -xf syslinux-$SYSLINUX_VER.tar.xz
#cp syslinux-$SYSLINUX_VER
cp $WORKDIR/syslinux-$SYSLINUX_VER/bios/core/isolinux.bin $isoroot/isolinux/isolinux.bin
cp $WORKDIR/syslinux-$SYSLINUX_VER/bios/com32/elflink/ldlinux/ldlinux.c32 $isoroot/isolinux/ldlinux.c32
cat > $isoroot/isolinux/isolinux.cfg << EOF
default 1
label 1
kernel /vmlinuz
append initrd=/initrd.img $cmdline
EOF
}
build_grub_efi () {
mkdir -p $isoroot/boot/grub
cat > $isoroot/boot/grub/grub.cfg << EOF
set timeout_style=hidden
set timeout=0
menuentry "XiLinux" {
linux /vmlinuz $cmdline
initrd /initrd.img
}
EOF
cksum=$(md5sum $isoroot/boot/grub/grub.cfg | cut -d' ' -f1)
mkdir -p $isoroot/efi/boot
cat > $WORKDIR/grub_early.$cksum.cfg << EOF
search --no-floppy --set=root --label "$ISO_LABEL"
set prefix=(\$root)/boot/grub
EOF
grub-mkimage \
--config="$WORKDIR/grub_early.$cksum.cfg" \
--prefix="/boot/grub" \
--output="$isoroot/efi/boot/bootx64.efi" \
--format="x86_64-efi" \
--compression="xz" \
$grub_mod
mformat -i $isoroot/boot/grub/efi.img -C -f 1440 -N 0 ::
mcopy -i $isoroot/boot/grub/efi.img -s $isoroot/efi ::
}
build_iso () {
local name=${1:-netinst}
mksquashfs $chroot $isoroot/filesystem.squashfs -noappend -no-progress -e "/proc/*" -e "/dev/*" -e "/sys/*"
xorrisofs -output ${name}.iso \
-joliet \
-rational-rock \
-sysid LINUX \
-volid "$ISO_LABEL" \
-eltorito-boot isolinux/isolinux.bin \
-eltorito-catalog isolinux/boot.cat \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-eltorito-alt-boot \
-e boot/grub/efi.img \
-no-emul-boot \
-isohybrid-gpt-basdat \
-follow-links \
$isoroot
printf "ISO written to $name.iso\n"
}
create_full_iso () {
xipkg $XI_ARGS -r $chroot mirror
cat > $chroot/etc/xipkg.conf << EOF
include /etc/xipkg.d/default.conf
sources {
local file:///var/lib/xipkg/mirror/
}
default_cmd install
EOF
build_iso "full"
}
[ "$#" = 0 ] && {
steps="
create_basesystem
configure_system
build_initramfs
create_isoroot
install_syslinux
build_grub_efi
build_iso
create_full_iso
"
} || {
steps="$*"
}
for step in $steps; do
$step || {
printf "%s\n" "${RED}An error occured!"
exit 1
}
done
|