-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall-pkgs.sparc
executable file
·247 lines (229 loc) · 5.78 KB
/
install-pkgs.sparc
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
#!/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 2025 Peter Tribble
#
RELEASE=32
THOME=${THOME:-/packages/localsrc/Tribblix}
DESTDIR=/export/tribblix/dist
INSTZAP=/usr/lib/zap/instzap
DRYRUN=""
ECHO="echo"
OVLIST="core-tribblix base-iso"
#
# flags
# -D desttop -> DESTTOP
# -N -> no install, dry run
# -O overlay -> install additional overlay
# -Q -> quiet, less output
# -R release string -> RELEASE
#
while getopts "D:NO:QR:" opt; do
case $opt in
D)
DESTTOP="$OPTARG"
DESTDIR=${DESTTOP}/dist
;;
N)
DRYRUN=y
;;
O)
OVLIST="${OVLIST} $OPTARG"
;;
Q)
ECHO="true"
;;
R)
RELEASE="$OPTARG"
;;
esac
done
shift $((OPTIND-1))
OVDIR=${THOME}/overlays.sparc
RPKGDIR=${THOME}/release-repos/m${RELEASE}.sparc
TPKGDIR=${THOME}/pkgs.sparc
EXTRAPKGDIR=${THOME}/opensxce-pkgs/pkgs
IPKGDIR=${THOME}/illumos-pkgs-m${RELEASE}.sparc/pkgs
ILVER="0.${RELEASE}"
EXTRAVER="2014"
case $RELEASE in
*.*)
RELVER="$RELEASE"
;;
*)
RELVER="${RELEASE}.0"
;;
esac
URELVER="${RELEASE}.0"
#
# the one argument is a variant, which sets the destination directory
#
case $# in
1)
DESTDIR=${DESTDIR}.$1
;;
esac
#
# this is the starting install, plus we add TRIBsys-install-media-internal
# to the iso
#
PKGLIST=""
#
# collect package lists from requested overlays
#
for OVL in $OVLIST
do
case $# in
0|1)
if [ -f "${OVDIR}/${OVL}.pkgs" ]; then
PKGLIST="${PKGLIST} ${OVDIR}/${OVL}.pkgs"
else
echo "Missing overlay $OVL"
exit 1
fi
;;
*)
echo "Too many arguments"
exit 1
;;
esac
done
#
# check we have illumos packages, and a catalog
#
if [ ! -f "${IPKGDIR}/catalog" ]; then
echo "ERROR: no illumos packages (or catalog) for release $RELEASE"
exit 1
fi
#
# check we have a matching release repo
#
if [ ! -d "${RPKGDIR}" ]; then
echo "Cannot find release directory ${RPKGDIR}"
exit 1
fi
#
# and that the release packages exist
#
if [ ! -f "${RPKGDIR}/TRIBrelease-name.0.${RELVER}.zap" ]; then
echo "Cannot find release package"
exit 1
fi
if [ ! -f "${RPKGDIR}/TRIBzap-upgrade.0.${URELVER}.zap" ]; then
echo "Cannot find zap upgrade package"
exit 1
fi
if [ ! -f "${RPKGDIR}/TRIBzap.0.0.${RELVER}.zap" ]; then
echo "Cannot find zap package"
exit 1
fi
#
# first verify
#
VALID=yes
ERRLIST=""
for mypkg in $(egrep -vh '^(TRIBzap|TRIBzap-upgrade|TRIBrelease-name)$' ${PKGLIST} | sort -u) TRIBsys-install-media-internal
do
THISVER="XXX"
ILVER="XXX"
PKGI=${THOME}/build/${mypkg}/pkginfo
if [ -f "${PKGI}" ]; then
if [ -f "${THOME}/build/${mypkg}/version.sparc" ]; then
THISVER=$(<"${THOME}/build/${mypkg}/version.sparc")
else
THISVER=$(awk -F= '{if ($1 == "VERSION") print $2}' "$PKGI" | sed 's="==g')
fi
fi
ILVER=$(awk -v V=${mypkg} -F'|' '{if ($1==V) print $2}' "${IPKGDIR}/catalog")
if [ -f "${TPKGDIR}/${mypkg}.${THISVER}.zap" ]; then
$ECHO "Installing $mypkg from Tribblix"
elif [ -f "${IPKGDIR}/${mypkg}.${ILVER}.zap" ]; then
$ECHO "Installing $mypkg from Illumos"
elif [ -f "${EXTRAPKGDIR}/${mypkg}.${EXTRAVER}.zap" ]; then
$ECHO "Installing $mypkg from OpenSXCE"
else
echo "ERROR: package $mypkg not found"
VALID=no
ERRLIST="$ERRLIST $mypkg"
fi
done
if [ "X$VALID" = "Xno" ]; then
echo "ERROR: missing packages, install aborted"
echo "Missing: $ERRLIST"
exit 1
fi
if [ ! -d "${DESTDIR}" ]; then
echo "ERROR: Target destination ${DESTDIR} not found, install aborted"
exit 1
fi
if [ ! -x ${INSTZAP} ]; then
echo "No installer $INSTZAP, install aborted"
exit 1
fi
if [ ! -f "${RPKGDIR}/catalog" ]; then
echo "WARN: Cannot find release catalog"
fi
if [ -n "${DRYRUN}" ]; then
exit 0
fi
#
# now install, force SUNWcsd first to make sure state files exist
#
for mypkg in SUNWcsd $(egrep -vh '^(SUNWcsd|TRIBzap|TRIBzap-upgrade|TRIBrelease-name)$' ${PKGLIST}) TRIBsys-install-media-internal
do
THISVER="XXX"
ILVER="XXX"
PKGI=${THOME}/build/${mypkg}/pkginfo
if [ -f "${PKGI}" ]; then
if [ -f "${THOME}/build/${mypkg}/version.sparc" ]; then
THISVER=$(<"${THOME}/build/${mypkg}/version.sparc")
else
THISVER=$(awk -F= '{if ($1 == "VERSION") print $2}' "$PKGI" | sed 's="==g')
fi
fi
ILVER=$(awk -v V=${mypkg} -F'|' '{if ($1==V) print $2}' "${IPKGDIR}/catalog")
if [ -f "${TPKGDIR}/${mypkg}.${THISVER}.zap" ]; then
$INSTZAP -R "$DESTDIR" "${TPKGDIR}/${mypkg}.${THISVER}.zap" "${mypkg}"
elif [ -f "${IPKGDIR}/${mypkg}.${ILVER}.zap" ]; then
$INSTZAP -R "$DESTDIR" "${IPKGDIR}/${mypkg}.${ILVER}.zap" "${mypkg}"
elif [ -f "${EXTRAPKGDIR}/${mypkg}.${EXTRAVER}.zap" ]; then
$INSTZAP -R "$DESTDIR" "${EXTRAPKGDIR}/${mypkg}.${EXTRAVER}.zap" "${mypkg}"
fi
done
#
# now the release packages
#
echo "Installing release packages for $RELEASE"
$INSTZAP -R "$DESTDIR" "${RPKGDIR}/TRIBrelease-name.0.${RELVER}.zap" TRIBrelease-name
$INSTZAP -R "$DESTDIR" "${RPKGDIR}/TRIBzap-upgrade.0.${URELVER}.zap" TRIBzap-upgrade
$INSTZAP -R "$DESTDIR" "${RPKGDIR}/TRIBzap.0.0.${RELVER}.zap" TRIBzap
if [ -f "${RPKGDIR}/catalog" ]; then
cp "${RPKGDIR}/catalog" "${DESTDIR}/etc/zap/repositories/release.catalog"
fi
#
# need to mark the designated overlay(s) as installed
#
mkdir -p "${DESTDIR}/var/sadm/overlays/installed"
for OVL in $OVLIST
do
touch "${DESTDIR}/var/sadm/overlays/installed/${OVL}"
done
#
# close pkgserv to stop it holding files open
#
sync
pkgadm sync -R "${DESTDIR}" -q