/[polypkg]/trunk/pp.back.kit.kits
ViewVC logotype

Contents of /trunk/pp.back.kit.kits

Parent Directory Parent Directory | Revision Log Revision Log


Revision 208 - (show annotations)
Wed Feb 11 21:26:56 2009 UTC (9 months, 1 week ago) by dleonard
File size: 7546 byte(s)
Tru64 support - experimental, but seems to work
1
2 ##### TODO
3 ##### The .inv file should be created directly from %files.run
4 #####
5
6 # Pulled from /usr/bin/kits by Seth and cleaned up by David
7 #
8 # kits(1)
9 #
10 # kits - Generates setld format distribution kits
11 #
12 # DESCRIPTION
13 #
14 # The kits command produces subset images, inventories, and control files for
15 # an installation using the setld command. You need to know the key file
16 # which describes the product to be built, a hierarchy from which the com-
17 # ponent files to be kitted are to be taken, and a destination directory into
18 # which the kit information is to be placed.
19 #
20 # In the output-path directory, the kits command produces a subset image file
21 # for each subset and a product_code.image file listing all the kit's sub-
22 # sets. In the instctrl subdirectory of output-path, kits produces an inven-
23 # tory file and a control file. The optional subset control program for any
24 # subset in the kit is transferred to output-path/instctrl. An instctrl
25 # directory is created if none existed.
26 #
27 # RESTRICTIONS
28 #
29 # Any subset control programs to be provided with the kit must be located in
30 # a directory named scps in the working directory where the kits program is
31 # invoked. If no subset control program is found for a subset, an empty one
32 # is created.
33
34 # Deviations from Tru64's kit(1)
35 # * the scps directory must be in $pp_wrkdir/scps
36
37 pp_backend_kit_sizes () {
38 awk '
39 BEGIN { root = usr = var = 0; }
40 {
41 if (substr($9, 1, 1) != "l")
42 if (substr($10, 1, 6) == "./var/")
43 var += $2;
44 else if (substr($10, 1, 10) == "./usr/var/")
45 var += $2
46 else if (substr($10, 1, 6) == "./usr/")
47 usr += $2
48 else
49 root += $2
50 }
51 END { printf "%d\t%d\t%d", root, usr, var }
52 ' "$@"
53 }
54
55 # extracts a variable setting from a spec file
56 pp_kit_kits_global () {
57 line=`sed -n '/^%%/q;/^'$2'=/{s/^'$2'=//p;q;}' <"$1"`
58 test -z "$line" && return 1
59 eval "echo $line"
60 :
61 }
62
63 #@ pp_backend_kit_kits(key-file input-path output-path [subset...])
64 pp_backend_kit_kits () {
65 typeset KITFILE FROMDIR TODIR
66 typeset SCPDIR
67
68 SCPDIR="$pp_wrkdir/scps"
69
70 PATH="/usr/lbin:/usr/bin:/etc:/usr/ucb:$PATH"; export PATH # XXX
71 #umask 2 # XXX
72
73 test $# -ge 3 || pp_die "pp_backend_kit_kits: too few arguments"
74 KITFILE="$1"; shift
75 FROMDIR="$1"; shift
76 TODIR="$1"; shift
77
78 test -f "$KITFILE" || pp_die "$KITFILE not found"
79 test -d "$FROMDIR" || pp_die "$FROMDIR not found"
80 test -d "$TODIR" || pp_die "$TODIR not found"
81
82 INSTCTRL="$TODIR/instctrl"
83 mkdir -p "$INSTCTRL" || pp_die "cannot create instctrl directory"
84 chmod 775 "$INSTCTRL"
85
86 grep "%%" $KITFILE > /dev/null || pp_die "no %% in $KITFILE"
87
88 typeset NAME CODE VERS MI ROOT COMPRESS
89 typeset S_LIST ALLSUBS
90
91 NAME=`pp_kit_kits_global "$KITFILE" NAME` || pp_die "no NAME in $KITFILE"
92 CODE=`pp_kit_kits_global "$KITFILE" CODE` || pp_die "no CODE in $KITFILE"
93 VERS=`pp_kit_kits_global "$KITFILE" VERS` || pp_die "no VERS in $KITFILE"
94 MI=`pp_kit_kits_global "$KITFILE" MI` || pp_die "no MI in $KITFILE"
95 ROOT=`pp_kit_kits_global "$KITFILE" ROOT`
96 COMPRESS=`pp_kit_kits_global "$KITFILE" COMPRESS`
97
98 test -f "$MI" || pp_die "Inventory file $MI not found"
99
100 case "$ROOT" in
101 *ROOT)
102 test -f "$TODIR/$ROOT" ||
103 pp_die "Root image $ROOT not found in $TODIR" ;;
104 esac
105
106 ALLSUBS=`awk 'insub==1 {print $1} /^%%/ {insub=1}' <"$KITFILE"`
107 test $# -eq 0 && set -- $ALLSUBS
108
109 pp_debug "Creating $# $NAME subsets."
110 pp_debug "ALLSUBS=<$ALLSUBS>"
111
112 if test x"$COMPRESS" = x"1"; then
113 COMPRESS=:
114 else
115 COMPRESS=false
116 fi
117
118 #rm -f *.ctrl Volume*
119
120 for SUB
121 do
122 test -z "$SUB" && pp_die "SUB is empty"
123
124 typeset INV CTRL ROOTSIZE USRSIZE VARSIZE TSSUB
125 #rm -f Volume*
126 case $SUB in
127 .*) :;;
128 *) pp_verbose rm -f "$TODIR/$SUB"* "$INSTCTRL/$SUB"*;;
129 esac
130
131 TSSUB="$pp_wrkdir/ts.$SUB"
132
133 pp_debug "kits: Subset $SUB"
134
135 INV="$SUB.inv"
136 CTRL="$SUB.ctrl"
137 pp_debug "kits: Generating media creation information..."
138
139 # Invcutter takes as input
140 # SUB dir/path
141 # and generates stl_inv(4) files, like this
142 # f 0 00000 0 0 100644 2/11/09 010 f dir/path none SUB
143 grep " $SUB\$" "$MI" |
144 pp_verbose /usr/lbin/invcutter \
145 -v "$VERS" -f "$FROMDIR" > "$INSTCTRL/$INV" ||
146 pp_die "failed to create $INSTCTRL/$INV"
147 chmod 664 "$INSTCTRL/$INV"
148
149 pp_backend_kit_sizes "$INSTCTRL/$INV" > "$pp_wrkdir/kit.sizes"
150 read ROOTSIZE USRSIZE VARSIZE < "$pp_wrkdir/kit.sizes"
151
152 # Prefix each line with $FROMDIR. This will be stripped
153 awk '$1 != "d" {print from $10}' from="$FROMDIR/" \
154 > "$TSSUB" < "$INSTCTRL/$INV" ||
155 pp_die "failed"
156
157 NVOLS=0
158
159 pp_debug "kits: Creating $SUB control file..."
160
161 sed '1,/^%%/d;/^'"$SUB"'/{p;q;}' < "$KITFILE" > "$pp_wrkdir/kit.line"
162 read _SUB _IGNOR DEPS FLAGS DESC < "$pp_wrkdir/kit.line"
163 if test -z "$_SUB"; then
164 pp_warn "No such subset $SUB in $KITFILE"
165 continue
166 fi
167 DEPS=`echo $DEPS | tr '|' ' '`
168 case $FLAGS in
169 FLGEXP*) pp_verbose FLAGS='"${'"$FLAGS"'}"' ;;
170 esac
171 case $DESC in
172 *%*) DESC=`echo $DESC|awk -F% '{printf "%-36s%%%s\n", $1, $2}'`;;
173 esac
174
175 cat > "$INSTCTRL/$CTRL" <<-.
176 NAME='$NAME $SUB'
177 DESC=$DESC
178 ROOTSIZE=$ROOTSIZE
179 USRSIZE=$USRSIZE
180 VARSIZE=$VARSIZE
181 NVOLS=1:$NVOLS
182 MTLOC=1:$TLOC
183 DEPS="$DEPS"
184 FLAGS=$FLAGS
185 .
186 chmod 664 "$INSTCTRL/$CTRL"
187
188 pp_debug "kits: Making tar image"
189
190 # (cd "$FROMDIR" && tar cfR - $TSSUB) > "$TODIR/$SUB" ||
191 # pp_error "problem creating kit file"
192 pp_verbose tar cfPR "$TODIR/$SUB" "$FROMDIR/" "$TSSUB" ||
193 pp_error "problem creating kit file"
194
195 if $COMPRESS; then
196 pp_debug "kits: Compressing"
197 (cd "$TODIR" && compress -f -v "$SUB") ||
198 pp_die "problem compressing $TODIR/$SUB"
199 SPC=`expr $SUB : '\(...\).*'` # first three characters
200 SVC=`expr $SUB : '.*\(...\)'` # last three characters
201 : > "$INSTCTRL/$SPC$SVC.comp"
202 chmod 664 "$INSTCTRL/$SPC$SVC.comp"
203 pp_debug "kits: Padding compressed file to 10kB" # wtf?
204 rm -f "$TODIR/$SUB"
205 pp_verbose \
206 dd if="$TODIR/$SUB.Z" of="$TODIR/$SUB" bs=10k conv=sync ||
207 pp_die "problem moving compressed file"
208 rm -f "$TODIR/$SUB.Z"
209 fi
210 chmod 664 "$TODIR/$SUB"
211
212 if test -f "$SCPDIR/$SUB.scp"; then
213 cp "$SCPDIR/$SUB.scp" "$INSTCTRL/$SUB.scp"
214 chmod 755 "$INSTCTRL/$SUB.scp"
215 else
216 pp_debug "kits: null subset control program for $SUB"
217 : > "$INSTCTRL/$SUB.scp"
218 chmod 744 "$INSTCTRL/$SUB.scp"
219 fi
220
221 pp_debug "kits: Finished creating media image for $SUB"
222 done
223
224 pp_debug "kits: Creating $CODE.image"
225
226 case "$ROOT" in
227 *ROOT) ALLSUBS="$ROOT $ALLSUBS"
228 ;;
229 esac
230
231 (cd "$TODIR" && sum $ALLSUBS) > "$INSTCTRL/$CODE.image"
232 chmod 664 "$INSTTRL/$CODE.image"
233 pp_debug "kits: Creating INSTCTRL"
234 (cd "$INSTCTRL" && tar cpvf - *) > "$TODIR/INSTCTRL"
235 chmod 664 "$TODIR/INSTCTRL"
236 cp "$INSTCTRL/$CODE.image" "$TODIR/$CODE.image"
237 chmod 664 "$TODIR/$CODE.image"
238
239 pp_debug "kits: Media image production complete"
240 }

Ted.Percival@quest.com
ViewVC Help
Powered by ViewVC 1.1.2