blob: 0c762136a60ddd1b04123cfbd077cc8c696e5ce8 (
plain) (
blame)
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
#!/bin/sh
def_arch=x86_64
def_kernel=4.6
declare -r PROGNAME=$(basename $0)
warn() {
printf '>>> '
printf '\033[01;33mWARNING\033[00;39m '
printf '>>> '
printf '\033[01;33mWARNING\033[00;39m '
printf '>>> '
printf '\033[01;33mWARNING\033[00;39m '
printf '>>> '
printf '\033[01;33mWARNING\033[00;39m '
printf '>>>\n'
}
fatal() {
printf '>>> '
printf '\033[01;31mERROR\033[00;39m '
printf '>>> '
printf '\033[01;31mERROR\033[00;39m '
printf '>>> '
printf '\033[01;31mERROR\033[00;39m '
printf '>>> '
printf '\033[01;31mERROR\033[00;39m '
printf '>>>\n'
}
ensure_commands() {
if ! type apk>/dev/null; then
fatal
printf 'You must have apk installed. On Gentoo, see sys-devel/apk-tools.\n'
exit -1
fi
if ! type cpio>/dev/null; then
fatal
printf 'You must have cpio installed. On Gentoo, see app-arch/cpio.\n'
exit -1
fi
if ! type mksquashfs>/dev/null; then
fatal
printf 'You must have mksquashfs installed. On Gentoo, see sys-fs/squashfs-tools.\n'
exit -1
fi
if ! type mkisofs>/dev/null; then
fatal
printf 'You must have mkisofs installed. Try cdrtools or cdrkit.\n'
exit -1
fi
}
usage() {
printf 'usage: %s [-a ARCH] [-k KERNEL] [--help]\n\n' $PROGNAME
printf 'Create an Adélie Linux CD image (.ISO) using the specified parameters.\n'
printf 'Default ARCH: %s\nDefault kernel version: %s\n' $def_arch $def_kernel
}
while [ -n "$1" ]; do
case $1 in
-a | --arch)
shift
declare -r MY_ARCH=$1
;;
-h | --help)
usage
exit
;;
-k | --kernel)
shift
declare -r MY_KERNEL=$1
;;
*)
usage >&2
exit -1
;;
esac
shift
done
declare -r ARCH=${MY_ARCH:-$def_arch}
declare -r KERNEL=${MY_KERNEL:-$def_kernel}
declare -r LDARCH=${LDARCH:-$ARCH}
ensure_commands
warn
printf 'This will erase all files at the directories %s/cdroot-%s\n' `pwd` $ARCH
printf '%s/initrd-%s and %s/squashroot-%s.\n\n' `pwd` $ARCH `pwd` $ARCH
printf 'When you are ready, press RETURN. To cancel, press Ctrl-C.\n'
read
printf '\033[01;32m * \033[37mAdélie Linux CD Creation Tool\033[00;39m\n\n'
rm -rf cdroot-$ARCH
rm -rf initrd-$ARCH
rm -rf squashroot-$ARCH
mkdir cdroot-$ARCH
mkdir initrd-$ARCH
mkdir squashroot-$ARCH
printf '\033[01;32m * \033[37mInstalling base system to squash root...\033[00;39m\n'
apk --arch $ARCH -X "https://distfiles.adelielinux.org/adelie/1.0-alpha/$EXTRA_MIRROR" -U --allow-untrusted --root squashroot-$ARCH --initdb add shadow libffi adelie-base bash openrc openrc-openrc hwids eudev udev-init-scripts-openrc parted lvm2-openrc easy-kernel-modules easy-kernel-firmware dhcpcd net-tools ca-certificates
mkdir -p squashroot-$ARCH/etc/apk/keys
mkdir -p squashroot-$ARCH/home/live
mkdir squashroot-$ARCH/target
mkdir -p squashroot-$ARCH/media/live
ln -s /bin/bash squashroot-$ARCH/bin/sh
echo 'hostname="adelie"' > squashroot-$ARCH/etc/conf.d/hostname
echo 'mtab_is_file=no' > squashroot-$ARCH/etc/conf.d/mtab
cp -RPp squashroot-$ARCH/usr/share/openrc/runlevels squashroot-$ARCH/etc/runlevels
cp 'packages@adelielinux.org.pub' squashroot-$ARCH/etc/apk/keys/
ln -s /etc/init.d/udev squashroot-$ARCH/etc/runlevels/sysinit/udev
ln -s /etc/init.d/udev-trigger squashroot-$ARCH/etc/runlevels/sysinit/udev-trigger
ln -s /etc/init.d/lvmetad squashroot-$ARCH/etc/runlevels/sysinit/lvmetad
cat >squashroot-$ARCH/etc/fstab <<- FSTAB
# Welcome to Adélie Linux.
# This fstab(5) is for the live media only. Do not edit or use for your installation.
tmpfs /tmp tmpfs defaults 0 1
tmpfs /var/log tmpfs size=8m 0 1
tmpfs /root tmpfs size=16m 0 1
tmpfs /home/live tmpfs size=16m 0 1
proc /proc proc defaults 0 1
FSTAB
cat >squashroot-$ARCH/etc/passwd <<- PASSWD
root:x:0:0:Charlie Root:/root:/bin/bash
man:x:13:15:man-db:/usr/share/man:/sbin/nologin
at:x:25:25:at:/var/spool/at/atjobs:/sbin/nologin
fcron:x:101:206:fcron:/dev/null:/sbin/nologin
postfix:x:207:207:postfix:/var/spool/postfix:/sbin/nologin
live:x:1000:1000:Live User:/home/live:/bin/bash
PASSWD
cat >squashroot-$ARCH/etc/group <<- GROUP
root:x:0:
tty:x:5:
wheel:x:10:live
mail:x:12:postfix
uucp:x:14:
cron:x:16:
at:x:25:
fcron:x:206:
postfix:x:207:
postdrop:x:208:
live:x:1000:
GROUP
cat >squashroot-$ARCH/etc/shadow <<- SHADOW
root::::::::
man::::::::
at::::::::
fcron::::::::
postfix::::::::
live::::::::
SHADOW
cat >squashroot-$ARCH/etc/shells <<- SHELLS
/bin/bash
/bin/zsh
SHELLS
cat >squashroot-$ARCH/etc/resolv.conf <<- RESOLVE
nameserver 8.8.8.8
RESOLVE
cat >squashroot-$ARCH/etc/apk/repositories <<-REPOS
https://distfiles.adelielinux.org/adelie/1.0-alpha/$EXTRA_MIRROR
REPOS
cat >squashroot-$ARCH/etc/issue <<-ISSUE
Welcome to Adélie Linux!
You may log in as 'root' to install, or 'live' to play around.
Have fun.
ISSUE
chmod 600 squashroot-$ARCH/etc/shadow
printf '\033[01;32m * \033[37mCreating compressed file system image...\033[00;39m\n'
mksquashfs squashroot-$ARCH cdroot-$ARCH/adelie.squashfs
printf '\033[01;32m * \033[37mCreating initrd structure...\033[00;39m\n'
# mount points
mkdir initrd-$ARCH/dev
mkdir initrd-$ARCH/media
mkdir initrd-$ARCH/newroot
mkdir initrd-$ARCH/proc
mkdir initrd-$ARCH/sys
# manual /dev nodes for initial udev startup
mknod -m 600 initrd-$ARCH/dev/console c 5 1
mknod -m 666 initrd-$ARCH/dev/null c 1 3
mknod -m 666 initrd-$ARCH/dev/ptmx c 5 2
mknod -m 666 initrd-$ARCH/dev/random c 1 8
mknod -m 666 initrd-$ARCH/dev/tty c 5 0
mknod -m 620 initrd-$ARCH/dev/tty1 c 4 1
mknod -m 666 initrd-$ARCH/dev/urandom c 1 9
mknod -m 666 initrd-$ARCH/dev/zero c 1 5
# base
mkdir initrd-$ARCH/lib
cp squashroot-$ARCH/usr/lib/libc.so initrd-$ARCH/lib/ld-musl-$LDARCH.so.1
cp squashroot-$ARCH/lib/libblkid.so.1 initrd-$ARCH/lib/
cp squashroot-$ARCH/lib/libuuid.so.1 initrd-$ARCH/lib/
# udev
mkdir -p initrd-$ARCH/etc/udev
mkdir initrd-$ARCH/run
mkdir initrd-$ARCH/sbin
cp squashroot-$ARCH/bin/udevadm initrd-$ARCH/sbin/
cp squashroot-$ARCH/sbin/udevd initrd-$ARCH/sbin/
cp squashroot-$ARCH/lib/libkmod.so.2 initrd-$ARCH/lib/
cp squashroot-$ARCH/lib/libudev.so.1 initrd-$ARCH/lib/
cp squashroot-$ARCH/etc/udev/hwdb.bin initrd-$ARCH/etc/udev/
# init
cp cdinit-$ARCH initrd-$ARCH/init
printf '\033[01;32m * \033[37mCompressing initrd...\033[00;39m\n'
pushd initrd-$ARCH
find . | cpio -H newc -o > ../cdroot-$ARCH/initrd
popd
gzip -9 cdroot-$ARCH/initrd
mv cdroot-$ARCH/initrd.gz cdroot-$ARCH/initrd
printf '\033[01;32m * \033[37mAdding kernel...\033[00;39m\n'
cp bzImage-$ARCH cdroot-$ARCH/bzImage
printf '\033[01;32m * \033[37mInstalling ISOLINUX...\033[00;39m\n'
mkdir cdroot-$ARCH/isolinux
cat >cdroot-$ARCH/isolinux/isolinux.cfg <<BOOTCFG
prompt 1
default adelie
label adelie
kernel /bzImage
append initrd=/initrd
BOOTCFG
cp /usr/share/syslinux/isolinux-debug.bin cdroot-$ARCH/isolinux/isolinux.bin
cp /usr/share/syslinux/ldlinux.c32 cdroot-$ARCH/isolinux/
printf '\033[01;32m * \033[37mCreating the CD...\033[00;39m\n'
mkisofs -o adelie-live-$ARCH-1.0-ALPHA-$(date +%Y%m%d).iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -joliet cdroot-$ARCH
|