-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsysroot.sh
More file actions
executable file
·175 lines (162 loc) · 3.37 KB
/
Copy pathsysroot.sh
File metadata and controls
executable file
·175 lines (162 loc) · 3.37 KB
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
#!/bin/ksh
#
# 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 2026 Peter Tribble
#
#
# create an illumos sysroot, which is like an mvi zone image
#
#
# Tribblix version for illumos pkgs
#
DISTVER=40
#
# where the output should end up
#
ISO_NAME=/var/tmp/sysroot.${DISTVER}.tar.gz
#
# *** CUSTOMIZE ***
# where your illumos and other packages live
#
THOME=${THOME:-/packages/localsrc/Tribblix}
export THOME
PROTO_DIR=${THOME}/illumos-pkgs-m${DISTVER}
INSTZAP=/usr/lib/zap/instzap
if [ ! -x ${INSTZAP} ]; then
INSTZAP=${THOME}/zap/usr/lib/zap/instzap
fi
if [ ! -x "${INSTZAP}" ]; then
echo "ERROR: unable to find instzap"
exit 1
fi
#
# *** CUSTOMIZE ***
# where your mvi configuration lives
#
MVI_DIR=${THOME}/mvi
#
# this is the starting list of packages
#
PKG_LIST="sysroot"
#
# argument processing
#
INSTALL_PKGS=${MVI_DIR}/install-from-local.sh
while getopts "frso:p:uv:" opt; do
case $opt in
f)
# install from file system
INSTALL_PKGS=${MVI_DIR}/install-from-local.sh
if [ ! -d "$PROTO_DIR" ]; then
echo "ERROR: unable to find packages area $PROTO_DIR"
exit 1
fi
;;
r)
# install from repo
INSTALL_PKGS=${MVI_DIR}/install-from-repo.sh
echo "WARNING: not yet supported"
exit 2
;;
s)
# install via system (direct zap)
INSTALL_PKGS=${MVI_DIR}/install-with-zap.sh
;;
o)
# output file
ISO_NAME="$OPTARG"
;;
p)
# name of file containing pkg list
PKG_LIST="$OPTARG"
;;
u)
# user install, using zapadd
INSTALL_PKGS=${MVI_DIR}/mzapadd
;;
v)
# tribblix version
DISTVER="$OPTARG"
PROTO_DIR=${THOME}/illumos-pkgs-m${DISTVER}
ISO_NAME=/var/tmp/sysroot.${DISTVER}.tar.gz
;;
*)
exit 1
;;
esac
done
shift $((OPTIND-1))
#
# this is the temporary area where we dump stuff while building
#
DESTDIR=/tmp/mvi.$$
#
# bail if something is already there
#
if [ -d "$DESTDIR" ]; then
echo "ERROR: $DESTDIR already exists"
exit 1
fi
if [ -f "$DESTDIR" ]; then
echo "ERROR: $DESTDIR already exists (as a file)"
exit 1
fi
#
# check we have input to deal with
#
if [ ! -d "$MVI_DIR" ]; then
echo "ERROR: unable to find mvi area $MVI_DIR"
exit 1
fi
if [ ! -x "${INSTALL_PKGS}" ]; then
echo "ERROR: unable to find install script ${INSTALL_PKGS}"
exit 1
fi
if [ ! -f "${MVI_DIR}/${PKG_LIST}.pkgs" ]; then
echo "ERROR: unable to find package list ${MVI_DIR}/${PKG_LIST}.pkgs"
exit 1
fi
if [ ! -d "$PROTO_DIR" ]; then
echo "ERROR: unable to find packages for release ${DISTVER}"
exit 1
fi
#
# clean up and populate
#
${INSTALL_PKGS} "${DISTVER}" "${DESTDIR}" "${MVI_DIR}/${PKG_LIST}.pkgs"
#
# this is where we deviate from mvi
# all we're really after are headers and libraries
#
cd ${DESTDIR} || exit
rm -fr usr/share \
etc \
var \
usr/bin \
usr/sbin \
usr/ccs \
sbin \
bin
rm -f prototype
cd ${DESTDIR} || exit
tar cfz "$ISO_NAME" *
ls -lsh "$ISO_NAME"
#
# and clean up
#
cd /
rm -fr ${DESTDIR}