-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall-fix-split
executable file
·268 lines (256 loc) · 7.03 KB
/
install-fix-split
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
#!/bin/sh
#
# SPDX-License-Identifier: CDDL-1.0
#
# {{{ CDDL HEADER
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# }}}
#
# Copyright 2024 Peter Tribble
#
DESTTOP=/export/tribblix
DESTDIR=${DESTTOP}/dist
THOME=${THOME:-/packages/localsrc/Tribblix}
MKREPO=${THOME}/tribblix-build/mkrepo
#
# This sets the default size of the ramdisk.
# More inodes on x86 as each disk has more device nodes.
#
case `uname -p` in
i386)
MRSIZE=140m
NBPI=8192
XARCH="i86"
;;
sparc)
MRSIZE=160m
BASIZE=163840
NBPI=20480
XARCH="sparcv7"
;;
*)
echo "ERROR: unrecognized architecture"
exit 1
;;
esac
#
# allow MRSIZE to be overridden
# -M new_size
#
while getopts "M:" opt; do
case $opt in
M)
MRSIZE="$OPTARG"
;;
esac
done
shift $((OPTIND-1))
case $MRSIZE in
*m)
:
;;
*)
MRSIZE="${MRSIZE}m"
;;
esac
case $# in
1)
DESTDIR=${DESTDIR}.$1
;;
esac
#
# Add an unpackaged copy of mkisofs to the bootable media which we use to
# optimize boot archive creation. The installers will remove this file from the
# installed system (allowing a pkgadd of cdrtools to install it properly)
#
cp /usr/bin/mkisofs ${DESTDIR}/usr/bin/mkisofs
#
# customize jack's environment
#
if [ ! -d ${DESTDIR}/jack ]; then
mkdir ${DESTDIR}/jack
chown 123:10 ${DESTDIR}/jack
fi
if /usr/bin/grep -q jack ${DESTDIR}/etc/passwd
then
printf ""
else
echo 'jack:x:123:10:Tribblix Jack:/jack:/bin/bash' >> ${DESTDIR}/etc/passwd
echo 'jack:$5$robNc/Vf$orrY6BIeUzrqk/IyZFuvf.4Pw2XzysreXiTqq//7mu3:15634::::::' >> ${DESTDIR}/etc/shadow
fi
if /usr/bin/grep -q jack ${DESTDIR}/etc/user_attr
then
printf ""
else
echo 'jack::::roles=root' >> ${DESTDIR}/etc/user_attr
fi
if [ ! -d ${DESTDIR}/jack/.config ]; then
if [ -f ${DESTTOP}/prebuilt/dot-config.tar ]; then
cd ${DESTDIR}/jack
tar xf ${DESTTOP}/prebuilt/dot-config.tar
chown -R 123:10 .config
fi
fi
cp ${DESTDIR}/root/.bashrc ${DESTDIR}/jack/.bashrc
grep export ${DESTDIR}/root/.profile > ${DESTDIR}/jack/.bash_profile
chown 123:10 ${DESTDIR}/jack/.bash_profile
cat ${DESTDIR}/jack/.bashrc >> ${DESTDIR}/jack/.bash_profile
cat ${DESTDIR}/root/.profile | /bin/sed -e 's:root:jack:' -e 's:}#:}\\\$:' > ${DESTDIR}/jack/.profile
chown 123:10 ${DESTDIR}/jack/.profile ${DESTDIR}/jack/.bashrc
case `uname -p` in
i386)
#
# https://blogs.oracle.com/darren/entry/sending_a_break_to_opensolaris
#
cat >> ${DESTDIR}/etc/system << _EOF
set pcplusmp:apic_kmdb_on_nmi=1
_EOF
#
# create the uefi boot block
#
${THOME}/tribblix-build/uefi.sh ${DESTDIR}
;;
esac
#
# it isn't safe to use the new devfsadm because it's built against
# a newer system (and libraries) than we currently have installed
#
/usr/sbin/devfsadm -r ${DESTDIR}
if [ -f ${DESTTOP}/prebuilt/repository.db ]; then
cp -p ${DESTTOP}/prebuilt/repository.db ${DESTDIR}/etc/svc/repository.db
else
env SVCCFG_CHECKHASH=1 $MKREPO ${DESTDIR} ${DESTDIR}
fi
if [ -d ${DESTTOP}/prebuilt ]; then
cd ${DESTTOP}/prebuilt
for repofile in repository-*.db
do
cp -p ${repofile} ${DESTDIR}/usr/lib/zap
rm -f ${DESTDIR}/usr/lib/zap/${repofile}.gz
gzip -9 ${DESTDIR}/usr/lib/zap/${repofile}
done
fi
cd ${DESTDIR}
#
# we don't need the splash images
#
rm -f ${DESTDIR}/boot/solaris.xpm
rm -f ${DESTDIR}/boot/splashimage.xpm
#
# This is based on the joyent list; the live-media method scripts call
# svcadm and fstyp
#
# net-fs-root needs tmpfs mount
# plus wget, which pulls in libidn
# and needs both architectures of prtconf, and libpcidb
# and add the whole of boot so we don't need to get it from anywhere else
#
rm -f ${DESTDIR}/platform/i86pc/amd64/boot_archive
rm -f ${DESTDIR}/platform/*/boot_archive
mkfile ${MRSIZE} /tmp/${MRSIZE}
#
# gzip doesn't like the sticky bit
#
chmod o-t /tmp/${MRSIZE}
LOFIDEV=`lofiadm -a /tmp/${MRSIZE}`
LOFINUM=`echo $LOFIDEV|awk -F/ '{print $NF}'`
echo "y" | env NOINUSE_CHECK=1 /usr/sbin/newfs -o space -m 0 -i $NBPI /dev/rlofi/$LOFINUM
BFS=/tmp/nb.$$
mkdir $BFS
mount -Fufs -o nologging $LOFIDEV $BFS
cd ${DESTDIR}
case `uname -p` in
i386)
tar cf - `bootadm list-archive` | ( cd $BFS ; tar xf -)
;;
sparc)
tar cf - kernel platform | ( cd $BFS ; tar xf -)
;;
esac
tar cfp - boot lib system tmp proc sbin etc var zonelib root jack | ( cd $BFS ; tar xf -)
mkdir ${BFS}/usr
cd usr
tar cf - bin/cat bin/head bin/${XARCH}/ksh93 bin/ls bin/sh sbin/lofiadm \
bin/sed bin/cut sbin/svcadm \
lib/fs/ufs/fstyp* lib/fs/hsfs/fstyp* lib/libfstyp.so* \
lib/libzonecfg* lib/libbrand* \
lib/libidn.s* bin/wget lib/fs/tmpfs/mount \
lib/libproject.so lib/libproject.so.1 lib/libshell.so.1 \
lib/libcmd.so.1 lib/libast.so.1 lib/libsum.so.1 lib/libdll.so.1 \
lib/libidmap.so lib/libidmap.so.1 lib/libpkcs11.so lib/libpkcs11.so.1 \
lib/fm/libfmevent.so lib/fm/libfmevent.so.1 lib/fm/libtopo.so \
lib/fm/libtopo.so.1 lib/libexacct.so lib/libexacct.so.1 \
lib/libipmi.so lib/libipmi.so.1 lib/libpool.so lib/libpool.so.1 \
lib/libsmbios.so lib/libsmbios.so.1 | ( cd ${BFS}/usr ; tar xf -)
cd $BFS
ln -s usr/bin bin
strip usr/bin/* usr/sbin/* usr/lib/*
mkdir -p dev/fd devices/pseudo opt var var/run mnt
/usr/sbin/devfsadm -r ${BFS}
#
# clean up entries that shouldn't exist in the device tree, as
# they're incompatible with the empty path_to_inst we supply
#
rm -f ${BFS}/dev/dsk/* ${BFS}/dev/rdsk/* ${BFS}/dev/usb/h*
rm -f ${BFS}/dev/removable-media/dsk/* ${BFS}/dev/removable-media/rdsk/*
# mounting /usr calls lofiadm, which calls devfsadm
# we don't have devfsadm at that point, so ensure that the
# correct symlinks exist in /dev
rm -f ${BFS}/dev/lofi/* ${BFS}/dev/rlofi/*
ln -s ../../devices/pseudo/lofi@1:disk ${BFS}/dev/lofi/1
ln -s ../../devices/pseudo/lofi@1:disk,raw ${BFS}/dev/rlofi/1
rm -fr ${BFS}/dev/zcons/*
#
mkdir .cdrom
touch .livecd
cp ${DESTDIR}/.volsetid .
touch etc/mnttab
touch reconfigure
if [ -f ${DESTTOP}/prebuilt/repository.db ]; then
cp -p ${DESTTOP}/prebuilt/repository.db ${BFS}/etc/svc/repository.db
else
env SVCCFG_CHECKHASH=1 $MKREPO ${BFS} ${BFS}
fi
cd /
DF=/usr/bin/df
if [ -x /usr/gnu/bin/df ]; then
DF=/usr/gnu/bin/df
fi
$DF -h $BFS
$DF -i $BFS
#
# boot archive needs a boot block on sparc
# and /etc/system tweaks
#
case `uname -p` in
sparc)
echo "set root_is_ramdisk=1" >> ${BFS}/etc/system
echo "set ramdisk_size=${BASIZE}" >> ${BFS}/etc/system
echo "Installing bootblock to miniroot"
/usr/sbin/installboot ${DESTDIR}/usr/platform/sun4u/lib/fs/ufs/bootblk /dev/rlofi/$LOFINUM
;;
esac
umount $BFS
lofiadm -d /dev/lofi/$LOFINUM
case `uname -p` in
i386)
gzip /tmp/${MRSIZE}
cp /tmp/${MRSIZE}.gz ${DESTDIR}/platform/i86pc/boot_archive
rm /tmp/${MRSIZE}.gz
;;
sparc)
cp /tmp/${MRSIZE} ${DESTDIR}/platform/sun4v/boot_archive
ln -s ../../platform/sun4v/boot_archive ${DESTDIR}/platform/sun4u/boot_archive
rm /tmp/${MRSIZE}
;;
esac
rmdir $BFS