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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
#!/bin/bash
set -e
set -u
dpkg -l ufsutils genisoimage debootstrap
TMP="${TMP:-/var/tmp}"
DATE=$(date '+%Y-%m-%d-%H%M')
DIST="${DIST:-bok}"
REPO="${REPO:-http://apt.osdyson.org}"
# We will search for usr archive on CD:
USR_IMG=usr.img.$(echo $DATE | md5sum | cut -f1 -d ' ')
ISOLABEL="${ISOLABEL:-dyson-netinst}"
ISONAME="${ISONAME:-${ISOLABEL}-${DATE}}.iso"
ROOT="${TMP}/ROOT"
BOOTSTRAPFS="${BOOTSTRAPFS:-rpool/deb}"
ROOT="/$BOOTSTRAPFS"
BOOTARCH="${ROOT}/boot_archive"
# Move files from usr to usr1,
# Create links from usr to usr1.
# E. g.:
# usr_symlink_move usr/bin/bash
# /usr/bin/bash -> /usr1/bin/bash
# usr_symlink_move usr/lib/devfsadm
# /usr/lib/devfsadm -> /usr1/lib/devfsadm
usr_symlink_move() {
f=${1#*/} # NO LEADING SLASH!
d=$(dirname "$f")
if [ ! -d "usr1/$d" ]; then
mkdir -p "usr1/$d"
fi
mv -v "usr/$f" "usr1/$f"
ln -sf "/usr1/$f" "usr/$f"
}
if [ -z "${ROOT}" ] || [ "${ROOT}" = / ]; then
echo "WTF? Bad root: \`${ROOT}'" >&2
exit 1
fi
rm -rf "${ROOT}"/*
if ! zfs list "${BOOTSTRAPFS}"; then
zfs create "${BOOTSTRAPFS}"
fi
if zfs list "${BOOTSTRAPFS}@init"; then
zfs rollback "${BOOTSTRAPFS}@init"
else
echo "Preparing base system (debootstrap)..."
debootstrap \
--exclude=logrotate,locales,rsyslog,cron,gawk,aptitude,aptitude-common,libboost-iostreams1.48.0,libboost-iostreams1.49.0,libcwidget3 \
--include=python-newt,truss,installgrub,illumos-grub-eltorito,illumos-kernel,mc,vim,screen,openssh-client,wget,bzip2,xz-utils,debootstrap,less,file,lynx,bash-completion,drvtools,mdb-proc,mdb-kvm,dtrace,inetutils-ping,inetutils-traceroute \
"${DIST}" \
"${ROOT}" \
"${REPO}"
zfs snapshot ${BOOTSTRAPFS}@init
fi
# http://osdyson.org/issues/120
# Dyson always boots with only one CPU
if ! [ -e "${ROOT}/etc/mach" ]; then
echo -e 'pcplusmp\napix\nxpv_psm\n' > "${ROOT}/etc/mach"
fi
dpkg -l --root "${ROOT}" > pkg.list
mkdir "$ROOT/usr/install"
cp -a install DysonInstaller $ROOT/usr/install/
cat installer-screenrc > $ROOT/etc/screenrc
cat bash_profile > $ROOT/root/.bash_profile
cat vimrc > $ROOT/root/.vimrc
# debootstrap copied from the host system:
rm -f $ROOT/etc/resolv.conf
mv $ROOT/var/lib/dpkg $ROOT/usr/dpkg
ln -sf /usr/dpkg $ROOT/var/lib/dpkg
rm -rf "${ROOT}"/var/cache/*
rm -rf "${ROOT}"/etc/cron.*
rm -rf "${ROOT}"/var/log/*
rm -rf "${ROOT}"/usr/share/doc/*
# Remove messages and localized mans:
rm -rf "${ROOT}"/usr/share/locale/*/LC_MESSAGES
rm -rf "${ROOT}"/usr/share/man/*/man[0-9]*
#sed -i '/^PermitRootLogin/ s,no,yes,' /etc/ssh/sshd_config
cat <<VFSTAB > $ROOT/etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
/devices/ramdisk:a - / ufs 1 no rw,nologging
fd - /dev/fd fd - no -
swap - /tmp tmpfs - yes -
VFSTAB
echo "dyson-${DIST}-live" > "${ROOT}/etc/nodename"
# Set root password (just "root"):
echo 'root:root' | chpasswd -R "$ROOT"
# Script to find and mount usr.lzma:
sed "s/##USR_IMG##/$USR_IMG/g" "fs-root" > "${ROOT}/lib/svc/method/fs-root"
cat console-login > "${ROOT}/lib/svc/method/console-login"
cat net-physical > "${ROOT}/lib/svc/method/net-physical"
chmod +x "${ROOT}/lib/svc/method"/*
dummy_prog='#!/sbin/sh
exit 0
'
echo "$dummy_prog" > "${ROOT}/lib/svc/method/fs-usr"
echo "$dummy_prog" > "${ROOT}/lib/svc/method/boot-archive"
echo "$dummy_prog" > "${ROOT}/lib/svc/method/boot-archive-update"
echo "Importing manifests..."
rm -f "${ROOT}/etc/svc/repository.db"
# bash or ksh, please:
bash "${ROOT}/lib/svc/method/manifest-import" \
-f "${ROOT}/etc/svc/repository.db" \
-d "${ROOT}/lib/svc/manifest"
# Thank you! Bye-bye!
echo "$dummy_prog" > "${ROOT}/lib/svc/method/manifest-import"
mkdir -p "${BOOTARCH}"
mkdir -p "${BOOTARCH}/usr"
mkdir -p "${BOOTARCH}/cdrom"
touch "${BOOTARCH}/reconfigure"
pushd "${ROOT}"
# We use 32-bit installgrub, but is not required to boot ;-)
if [ -e lib32 ]; then
mkdir -p usr/lib32
mv lib32/* usr/lib32/
ln -sf usr/lib32 $BOOTARCH/lib32
fi
# Move some critical libs:
march=`dpkg-architecture -qDEB_HOST_MULTIARCH`
mkdir -p lib/$march
for lib in \
libdiskmgt \
libexacct \
libfmevent \
libidmap \
libipmi \
liblzma \
libpool \
libproject \
libsmbios \
libsunavl \
libtecla \
libtopo \
libxml2 \
libz \
libzonecfg \
; do
mv -v -f usr/lib/$march/$lib.so.* lib/$march/ || \
mv -v -f usr/lib/$lib.so.* lib/$march/
done
# Moving some files from usr to usr1
# and creating symlinks from usr to usr1
usr_symlink_move usr/bin/cat
usr_symlink_move usr/bin/dash
usr_symlink_move usr/bin/grep
usr_symlink_move usr/bin/hostname
usr_symlink_move usr/bin/ln
usr_symlink_move usr/bin/ls
usr_symlink_move usr/bin/rm
usr_symlink_move usr/bin/sh
usr_symlink_move usr/lib/devfsadm
usr_symlink_move usr/lib/fs/hsfs/mount
usr_symlink_move usr/lib/fs/ufs/mount
usr_symlink_move usr/sbin/devfsadm
usr_symlink_move usr/sbin/dladm
usr_symlink_move usr/sbin/ipadm
usr_symlink_move usr/sbin/lofiadm
# usr2 will be packed and stored on CD:
mv usr usr2
# This is usr before usr2 is mounted,
# fs-root will mount usr2 and replace usr -> usr2
ln -sf usr1 usr
ln -sf ../../sbin usr1/sbin
# List here files or directories which
# should be *moved* to boot archive.
# Caution: files from /usr require
# special treating: see above
tar --remove-files -c -f - \
bin \
boot/solaris \
dev \
devices \
etc \
home \
kernel \
lib \
media \
mnt \
opt \
platform \
proc \
root \
run \
sbin \
srv \
system \
tmp \
usr \
usr1 \
var \
| tar xf - -C "${BOOTARCH}"
# Restore the kernel:
mkdir -p platform/i86pc/kernel/amd64
cp -p "${BOOTARCH}/platform/i86pc/kernel/amd64/unix" \
platform/i86pc/kernel/amd64/
# Mount point for compressed /usr:
mkdir "${BOOTARCH}/usr2"
popd # Exit from $ROOT
find "${BOOTARCH}" -ls > bootarch.list
echo "Making boot archive..."
sync; sync
size=$(du -s -m "${BOOTARCH}" | cut -f1)
((size+=20)) # +20 MB of free space
dd if=/dev/zero of="${ROOT}/boot/boot_archive" bs=1M count="$size"
lofidev=$(lofiadm -a "${ROOT}/boot/boot_archive")
rlofidev="${lofidev/lofi/rlofi}"
yes | newfs -m 0 "${rlofidev}"
mkdir -p "${ROOT}/boot/boot_archive.mount"
mount "${lofidev}" "${ROOT}/boot/boot_archive.mount"
mv "${BOOTARCH}"/* "${ROOT}/boot/boot_archive.mount"/
umount "${ROOT}/boot/boot_archive.mount"
lofiadm -d "${lofidev}"
rmdir "${BOOTARCH}"
rmdir "${ROOT}/boot/boot_archive.mount"
gzip -9 -f "${ROOT}/boot/boot_archive"
echo "Making usr archive..."
# usr will be mounted from usr.lzma:
genisoimage \
-o "${ROOT}/${USR_IMG}" \
-N -l -R -U \
-allow-multidot \
-quiet -no-iso-translate -cache-inodes -d -D \
-V "usr" \
"${ROOT}/usr2"
rm -rf "${ROOT}/usr2"
lofiadm -C lzma "${ROOT}/${USR_IMG}"
echo "Configuring GRUB..."
cat <<GRUB > "${ROOT}/boot/grub/menu.lst"
default=0
timeout=3
foreground=ffffff
background=215ECA
title Dyson ($DIST) installer and LiveCD, $DATE
kernel /platform/i86pc/kernel/amd64/unix
module /boot/boot_archive.gz
GRUB
echo "Making final ${ISONAME}..."
genisoimage \
-o "${ISONAME}" \
-b boot/grub/stage2_eltorito \
-c .catalog \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-N -l -R -U \
-allow-multidot \
-no-iso-translate \
-cache-inodes \
-d -D \
-V "${ISOLABEL}" \
"${ROOT}"
ls -lh "${ISONAME}"
exit 0
|