-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmk-pkgs-zap.sparc
executable file
·275 lines (260 loc) · 6.89 KB
/
mk-pkgs-zap.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
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
#!/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
#
#
# copy packages into the pkgs folder on the iso, including all the packages
# necessary for the shipped overlays
#
RELEASE=32
DISTROOT=/export/tribblix/dist
ZAPDIR=${DISTROOT}/pkgs
THOME=${THOME:-/packages/localsrc/Tribblix}
VARIANT=""
OVDIR="overlays.sparc"
DRYRUN=""
ECHO="echo"
#
# flags
# -D desttop -> DESTTOP
# -N -> no install, dry run
# -Q -> quiet, less output
# -R release string -> RELEASE
#
while getopts "D:NQR:" opt; do
case $opt in
D)
DESTTOP="$OPTARG"
DISTROOT=${DESTTOP}/dist
ZAPDIR=${DISTROOT}/pkgs
;;
N)
DRYRUN=y
;;
Q)
ECHO="true"
;;
R)
RELEASE="$OPTARG"
;;
esac
done
shift $((OPTIND-1))
#
# Tribblix and illumos packages are explicitly versioned
# we fake a version based on the current release for OpenSXCE
#
EXTRAVER="2014"
ILVER="0.${RELEASE}"
TPKGDIR=${THOME}/pkgs.sparc
EXTRAPKGDIR=${THOME}/opensxce-pkgs/pkgs
IPKGDIR=${THOME}/illumos-pkgs-m${RELEASE}.sparc/pkgs
#
# check we have packages, and metadata
#
if [ ! -d ${IPKGDIR} ]; then
echo "ERROR: no illumos packages for release $RELEASE"
exit 1
fi
if [ ! -d ${TPKGDIR} ]; then
echo "ERROR: no tribblix packages found"
exit 1
fi
if [ ! -d ${EXTRAPKGDIR} ]; then
echo "ERROR: no opensxce packages found"
exit 1
fi
if [ ! -d ${THOME}/${OVDIR} ]; then
echo "ERROR: no overlays found"
exit 1
fi
if [ ! -d ${THOME}/build ]; then
echo "ERROR: missing build directory"
exit 1
fi
if [ ! -f ${IPKGDIR}/catalog ]; then
echo "ERROR: no illumos package catalog for release $RELEASE"
exit 1
fi
if [ ! -f ${TPKGDIR}/catalog ]; then
echo "ERROR: no tribblix package catalog found"
exit 1
fi
if [ ! -f ${EXTRAPKGDIR}/catalog ]; then
echo "ERROR: no opensxce package catalog found"
exit 1
fi
if [ ! -f ${THOME}/${OVDIR}/catalog ]; then
echo "ERROR: no overlay catalog found"
exit 1
fi
if [ ! -f ${IPKGDIR}/aliases ]; then
echo "ERROR: no illumos package aliases for release $RELEASE"
exit 1
fi
if [ ! -f ${TPKGDIR}/aliases ]; then
echo "ERROR: no tribblix package aliases found"
exit 1
fi
if [ ! -f ${IPKGDIR}/filelist.bz2 ]; then
echo "ERROR: no illumos package filelist for release $RELEASE"
exit 1
fi
if [ ! -f ${TPKGDIR}/filelist.bz2 ]; then
echo "ERROR: no tribblix package filelist found"
exit 1
fi
#
# the one argument is a variant, which sets the destination directory
#
# if there's a variant overlays.iso, then use that
#
OVLIST=${THOME}/${OVDIR}/overlays.iso
case $# in
1)
DISTROOT=${DISTROOT}.$1
ZAPDIR=${DISTROOT}/pkgs
VARIANT=$1
if [ -f ${THOME}/${OVDIR}/overlays.${VARIANT}.iso ]; then
OVLIST=${THOME}/${OVDIR}/overlays.${VARIANT}.iso
fi
;;
esac
if [ ! -f ${OVLIST} ]; then
echo "ERROR: no overlay list found"
exit 1
fi
TFILE="/tmp/mkzap.$$"
rm -fr ${TFILE}
touch $TFILE
for opkg in $(<${OVLIST})
do
if [ -f ${THOME}/${OVDIR}/${opkg}.pkgs ]; then
cat ${THOME}/${OVDIR}/${opkg}.pkgs >> $TFILE
else
echo "ERROR: missing overlay $opkg"
rm -f $TFILE
exit 1
fi
done
#
# we look in ${TPKGDIR}, then ${IPKGDIR} and ${EXTRAPKGDIR}
#
#
# verify first
#
VALID=yes
ERRLIST=""
for ipkg in `sort -u ${TFILE}|egrep -v '^(TRIBzap|TRIBzap-upgrade|TRIBrelease-name)$'`
do
THISVER="XXX"
ILVER="XXX"
PKGI=${THOME}/build/${ipkg}/pkginfo
if [ -f ${PKGI} ]; then
if [ -f ${THOME}/build/${ipkg}/version.sparc ]; then
THISVER=`cat ${THOME}/build/${ipkg}/version.sparc`
else
THISVER=`awk -F= '{if ($1 == "VERSION") print $2}' $PKGI | sed 's="==g'`
fi
fi
ILVER=`awk -v V=${ipkg} -F'|' '{if ($1==V) print $2}' ${IPKGDIR}/catalog`
if [ -f ${TPKGDIR}/${ipkg}.${THISVER}.zap ]; then
$ECHO "Installing $ipkg ${THISVER} from Tribblix"
elif [ -f ${IPKGDIR}/${ipkg}.${ILVER}.zap ]; then
$ECHO "Installing $ipkg from Illumos"
elif [ -f ${EXTRAPKGDIR}/${ipkg}.${EXTRAVER}.zap ]; then
$ECHO "Installing $ipkg from OpenSXCE"
else
echo "ERROR: package $ipkg not found"
VALID=no
ERRLIST="$ERRLIST $ipkg"
fi
done
if [ "X$VALID" = "Xno" ]; then
echo "ERROR: missing packages, mk-pkgs-zap aborted"
echo "Missing: $ERRLIST"
rm -f $TFILE
exit 1
fi
if [ -n "${DRYRUN}" ]; then
rm -f $TFILE
exit 0
fi
#
# delete the pkgs directory to avoid lingering leftovers
#
rm -fr $ZAPDIR
mkdir -p $ZAPDIR
if [ ! -d $ZAPDIR ]; then
echo "ERROR: unable to create $ZAPDIR"
rm -f $TFILE
exit 1
fi
rm -f ${ZAPDIR}/catalog
touch ${ZAPDIR}/catalog
chmod 644 ${ZAPDIR}/catalog
#
# use pre-existing zap files
#
for ipkg in `sort -u ${TFILE}|egrep -v '^(TRIBzap|TRIBzap-upgrade|TRIBrelease-name)$'`
do
if [ -f ${DISTROOT}/var/sadm/pkg/${ipkg}/pkginfo ]; then
echo "Skipping installed ${ipkg}"
else
THISVER="XXX"
ILVER="XXX"
PKGI=${THOME}/build/${ipkg}/pkginfo
if [ -f ${PKGI} ]; then
if [ -f ${THOME}/build/${ipkg}/version.sparc ]; then
THISVER=`cat ${THOME}/build/${ipkg}/version.sparc`
else
THISVER=`awk -F= '{if ($1 == "VERSION") print $2}' $PKGI | sed 's="==g'`
fi
fi
ILVER=`awk -v V=${ipkg} -F'|' '{if ($1==V) print $2}' ${IPKGDIR}/catalog`
if [ -f ${TPKGDIR}/${ipkg}.${THISVER}.zap ]; then
cp ${TPKGDIR}/${ipkg}.${THISVER}.zap $ZAPDIR
elif [ -f ${IPKGDIR}/${ipkg}.${ILVER}.zap ]; then
cp ${IPKGDIR}/${ipkg}.${ILVER}.zap ${ZAPDIR}/${ipkg}.${ILVER}.zap
THISVER=${ILVER}
else
cp ${EXTRAPKGDIR}/${ipkg}.${EXTRAVER}.zap ${ZAPDIR}/${ipkg}.${EXTRAVER}.zap
THISVER=${EXTRAVER}
fi
echo "${ipkg}|${THISVER}|"`unzip -p ${ZAPDIR}/${ipkg}.${THISVER}.zap ${ipkg}/install/depend 2>/dev/null | /usr/bin/awk '{if ($1 == "P") print $2}'` >> ${ZAPDIR}/catalog
fi
done
rm -f $TFILE
#
# preload repository metadata
# existence was checked for earlier
#
cp ${TPKGDIR}/catalog ${DISTROOT}/etc/zap/repositories/tribblix.catalog
cp ${IPKGDIR}/catalog ${DISTROOT}/etc/zap/repositories/illumos.catalog
cp ${TPKGDIR}/aliases ${DISTROOT}/etc/zap/repositories/tribblix.aliases
cp ${IPKGDIR}/aliases ${DISTROOT}/etc/zap/repositories/illumos.aliases
cp ${EXTRAPKGDIR}/catalog ${DISTROOT}/etc/zap/repositories/opensxce.catalog
touch ${DISTROOT}/etc/zap/repositories/opensxce.aliases
cp ${TPKGDIR}/filelist.bz2 ${DISTROOT}/etc/zap/repositories/tribblix.filelist.bz2
cp ${IPKGDIR}/filelist.bz2 ${DISTROOT}/etc/zap/repositories/illumos.filelist.bz2
cp ${THOME}/${OVDIR}/catalog ${DISTROOT}/etc/zap/repositories/tribblix.overlays
#
# show the space used
#
sync
/usr/bin/du -hds $ZAPDIR