INIT.2014-12-24
[INIT.git] / bin / package
blob389f52e0cbaab0afec923c45aa23b457c7be8941
1 USAGE_LICENSE="[-author?Glenn Fowler <glenn.s.fowler@gmail.com>][-copyright?Copyright (c) 1994-2015 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html]"
2 ########################################################################
3 #                                                                      #
4 #               This software is part of the ast package               #
5 #          Copyright (c) 1994-2013 AT&T Intellectual Property          #
6 #                      and is licensed under the                       #
7 #                 Eclipse Public License, Version 1.0                  #
8 #                    by AT&T Intellectual Property                     #
9 #                                                                      #
10 #                A copy of the License is available at                 #
11 #          http://www.eclipse.org/org/documents/epl-v10.html           #
12 #         (with md5 checksum b35adb5213ca9657e911e9befb180842)         #
13 #                                                                      #
14 #              Information and Software Systems Research               #
15 #                            AT&T Research                             #
16 #                           Florham Park NJ                            #
17 #                                                                      #
18 #               Glenn Fowler <glenn.s.fowler@gmail.com>                #
19 #                                                                      #
20 ########################################################################
21 ### this script contains archaic constructs that work with all sh variants ###
22 # package - source and binary package control
23 # Glenn Fowler <gsf@research.att.com>
25 command=package
27 case $-:$BASH_VERSION in
28 *x*:[0123456789]*)      : bash set -x is broken :; set +ex ;;
29 esac
31 # ksh checks -- ksh between 2007-11-05 and 2011-11-11 conflict with new -lcmd -- wea culpa
32 checksh()
34         egrep 'Version.*(88|1993)' $1 >/dev/null 2>&1 ||
35         $1 -c '(( .sh.version >= 20111111 ))' >/dev/null 2>&1
38 case $_AST_BIN_PACKAGE_:$SHELL:$0 in
39 1:*:*|*:/bin/sh:*)
40         ;;
41 *:*/*:*/*)
42         _AST_BIN_PACKAGE_=1 # prevent non-interactive sh .rc referencing bin/package recursion #
43         export _AST_BIN_PACKAGE_
44         if      checksh $SHELL
45         then    : no -lcmd conflict :
46         else    case " $* " in
47                 *" debug "*|*" DEBUG "*|*" show "*)
48                         echo $command: $SHELL: warning: possible -lcmd conflict -- falling back to /bin/sh >&2
49                         ;;
50                 esac
51                 SHELL=/bin/sh
52                 export SHELL
53                 exec $SHELL "$0" "$@"
54         fi
55         ;;
56 esac
58 LC_ALL=C
59 export LC_ALL
61 src="cmd contrib etc lib"
62 use="/usr/common /exp /usr/local /usr/add-on /usr/addon /usr/tools /usr /opt"
63 usr="/home"
64 lib="" # nee /usr/local/lib /usr/local/shlib
65 ccs="/usr/kvm /usr/ccs/bin"
66 org="gnu GNU"
67 makefiles="Mamfile Nmakefile nmakefile Makefile makefile"
68 env="HOSTTYPE NPROC PACKAGEROOT INSTALLROOT PATH"
69 checksum=md5sum
70 checksum_commands="$checksum md5"
71 checksum_empty="d41d8cd98f00b204e9800998ecf8427e"
73 package_use='=$HOSTTYPE=$PACKAGEROOT=$INSTALLROOT=$EXECROOT=$CC='
75 PACKAGE_admin_tail_timeout=${PACKAGE_admin_tail_timeout:-"1m"}
77 CROSS=0
78 OK=ok
80 admin_db=admin.db
81 admin_env=admin.env
82 admin_ditto="ditto --checksum --delete --verbose"
83 admin_ditto_update=--update
84 admin_ditto_skip="OFFICIAL|core|old|*.core|*.tmp|.nfs*"
85 admin_list='PACKAGE.$type.lst'
86 admin_ping="ping -c 1 -w 5"
88 pid=$$
90 default_url=default.url
91 MAKESKIP=${MAKESKIP:-"*[-.]*"}
92 RATZ=ratz
93 SED=
94 TAR=tar
95 TARFLAGS=xv
96 TARPROBE=B
97 TR=
99 all_types='*.*|sun4'            # all but sun4 match *.*
101 case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
102 0123)   USAGE=$'
104 @(#)$Id: package (AT&T Research) 2013-12-05 $
105 ]'$USAGE_LICENSE$'
106 [+NAME?package - source and binary package control]
107 [+DESCRIPTION?The \bpackage\b command controls source and binary
108     packages. It is a \bsh\b(1) script coded for maximal portability. All
109     package files are in the \b$PACKAGEROOT\b directory tree.
110     \b$PACKAGEROOT\b must at minumum contain a \bbin/package\b command or a
111     \blib/package\b directory. Binary package files are in the
112     \b$INSTALLROOT\b (\b$PACKAGEROOT/arch/\b\ahosttype\a) tree, where
113     \ahosttpe\a=`\bpackage\b`. All \aactions\a but \bhost\b and \buse\b
114     require the current directory to be under \b$PACKAGEROOT\b. See
115     \bDETAILS\b for more information.]
116 [+?Note that no environment variables need be set by the user;
117     \bpackage\b determines the environment based on the current working
118     directory. The \buse\b action starts a \bsh\b(1) with the environment
119     initialized. \bCC\b, \bCCFLAGS\b, \bHOSTTYPE\b and \bSHELL\b may be set
120     by explicit command argument assignments to override the defaults.]
121 [+?Packages are composed of components. Each component is built and
122     installed by an \bast\b \bnmake\b(1) makefile. Each package is also
123     described by an \bnmake\b makefile that lists its components and
124     provides a content description. The package makefile and component
125     makefiles provide all the information required to read, write, build
126     and install packages.]
127 [+?Package recipients only need \bsh\b(1) and \bcc\b(1) to build and
128     install source packages, and \bsh\b to install binary packages.
129     \bnmake\b and \bksh93\b are required to write new packages. An
130     \b$INSTALLROOT/bin/cc\b script may be supplied for some architectures.
131     This script supplies a reasonable set of default options for compilers
132     that accept multiple dialects or generate multiple object/executable
133     formats.]
134 [+?The command arguments are composed of a sequence of words: zero or
135     more \aqualifiers\a, one \aaction\a, and zero or more action-specific
136     \aarguments\a, and zero or more \aname=value\a definitions. \apackage\a
137     names a particular package. The naming scheme is a \b-\b separated
138     hierarchy; the leftmost parts describe ownership, e.g.,
139     \bgnu-fileutils\b, \bast-base\b. If no packages are specified then all
140     packages are operated on. \boptget\b(3) documentation options are also
141     supported. The default with no arguments is \bhost type\b.]
142 [+?The qualifiers are:]
143     {
144         [+authorize \aname\a?Remote authorization user name or license
145             acceptance phrase.]
146         [+debug|environment?Show environment and actions but do not
147             execute.]
148         [+flat?Collapse \b$INSTALLROOT\b { bin fun include lib } onto
149             \b$PACKAGEROOT\b.]
150         [+force?Force the action to override saved state.]
151         [+never?Run make -N and show other actions.]
152         [+only?Only operate on the specified packages.]
153         [+password \apassword\a?Remote authorization or license
154             acceptance password.]
155         [+quiet?Do not list captured action output.]
156         [+show?Run make -n and show other actions.]
157         [+verbose?Provide detailed action output.]
158         [+DEBUG?Trace the package script actions in detail.]
159     }
160 [+?The actions are:]
161     {
162         [+admin\b [\ball\b]] [\bdb\b \afile\a]] [\bon\b \apattern\a]][\aaction\a ...]]?Apply
163             \aaction\a ... to the hosts listed in \afile\a. If \afile\a is
164             omitted then \badmin.db\b is assumed. The caller must have
165             \brcp\b(1) and \brsh\b(1) or \bscp\b(1) and \bssh\b(1) access
166             to the hosts. Output for \aaction\a is saved per-host in the
167             file \aaction\a\b.log/\b\ahost\a. Logs can be viewed by
168             \bpackage admin\b [\bon\b \ahost\a]] \bresults\b [\aaction\a]].
169             By default only local PACKAGEROOT hosts are selected from
170             \afile\a; \ball\b selects all hosts. \bon\b \apattern\a selects
171             only hosts matching the \b|\b separated \apattern\a. \afile\a
172             contains four types of lines. Blank lines and lines beginning
173             with \b#\b are ignored. Lines starting with \aid\a=\avalue\a
174             are variable assignments. Set admin_ping to local conventions
175             if \"'$admin_ping$'\" fails. If a package list is not specified
176             on the command line the \aaction\a applies to all packages; a
177             variable assigment \bpackage\b=\"\alist\a\" applies \aaction\a
178             to the packages in \alist\a for subsequent hosts in \afile\a.
179             The remaining line type is a host description consisting of 6
180             tab separated fields. The first 3 are mandatory; the remaining
181             3 are updated by the \badmin\b action. \afile\a is saved in
182             \afile\a\b.old\b before update. The fields are:]
183             {
184                 [+hosttype?The host type as reported by
185                     \"\bpackage\b\".]
186                 [+[user@]]host?The host name and optionally user name
187                     for \brcp\b(1) and \brsh\b(1) access.]
188                 [+[remote::[[master]]::]]]]PACKAGEROOT?The absolute remote package
189                     root directory and optionally the remote protocol (rsh
190                     or ssh) if the directory is on a different server than
191                     the master package root directory. If
192                     \blib/package/admin/'$admin_env$'\b exists under this
193                     directory then it is sourced by \bsh\b(1) before
194                     \aaction\a is done. If this field begins with \b-\b
195                     then the host is ignored. If this field contains \b:\b
196                     then \bditto\b(1) is used to sync the remote \bsrc\b
197                     directory hierarchy to the local one. If [\amaster\a]]:
198                     is specified then the sync is deferred to the \amaster\a
199                     host. If \amaster\a is omitted (two :) then the sync is
200                     disabled. These directories must exist on the remote side:
201                     \blib/package\b, \bsrc/cmd\b, \bsrc/lib\b.]
202                 [+date?\aYYMMDD\a of the last action.]
203                 [+time?Elapsed wall time for the last action.]
204                 [+M T W?The \badmin\b action \bmake\b, \btest\b and
205                     \bwrite\b action error counts. A non-numeric value in
206                     any of these fields disables the corresponding action.]
207                 [+owner?The owner contact information.]
208                 [+attributes?\aname=value\a attributes. Should at least contain
209                     \bcc\b=\acompiler-version\a.]
210             }
211         [+clean | clobber?Delete the \barch/\b\aHOSTTYPE\a hierarchy; this
212             deletes all generated files and directories for \aHOSTTYPE\a.
213             The heirarchy can be rebuilt by \bpackage make\b.]
214         [+contents\b [ \apackage\a ... ]]?List description and
215             components for \apackage\a on the standard output.]
216         [+copyright\b [ \apackage\a ... ]]?List the general copyright
217             notice(s) for \apackage\a on the standard output. Note that
218             individual components in \apackage\a may contain additional or
219             replacement notices.]
220         [+export\b [ \avariable\a ...]]?List \aname\a=\avalue\a for
221             \avariable\a, one per line. If the \bonly\b attribute is
222             specified then only the variable values are listed. If no
223             variables are specified then \b'$env$'\b are assumed.]
224         [+help\b [ \aaction\a ]]?Display help text on the standard
225             error (standard output for \aaction\a).]
226         [+host\b [ \aattribute\a ... ]]?List
227             architecture/implementation dependent host information on the
228             standard output. \btype\b is listed if no attributes are
229             specified. Information is listed on a single line in
230             \aattribute\a order. The attributes are:]
231             {
232                 [+canon \aname\a?An external host type name to be
233                     converted to \bpackage\b syntax.]
234                 [+cpu?The number of cpus; 1 if the host is not a
235                     multiprocessor.]
236                 [+name?The host name.]
237                 [+rating?The cpu rating in pseudo mips; the value is
238                     useful useful only in comparisons with rating values of
239                     other hosts. Other than a vax rating (mercifully) fixed
240                     at 1, ratings can vary wildly but consistently from
241                     vendor mips ratings. \bcc\b(1) may be required to
242                     determine the rating.]
243                 [+type?The host type, usually in the form
244                     \avendor\a.\aarchitecture\a, with an optional trailing
245                     -\aversion\a. The main theme is that type names within
246                     a family of architectures are named in a similar,
247                     predictable style. OS point release information is
248                     avoided as much as possible, but vendor resistance to
249                     release incompatibilities has for the most part been
250                     futile.]
251             }
252         [+html\b [ \aaction\a ]]?Display html help text on the standard
253             error (standard output for \aaction\a).]
254         [+install\b [ \aarchitecture\a ... ]] \adirectory\a [ \apackage\a ... ]]?Copy
255             the package binary hierarchy to \adirectory\a. If
256             \aarchitecture\a is omitted then all architectures are
257             installed. If \bflat\b is specified then exactly one
258             \aarchitecture\a must be specified; this architecture will be
259             installed in \adirectory\a without the \barch/\b\aHOSTTYPE\a
260             directory prefixes. Otherwise each architecture will be
261             installed in a separate \barch/\b\aHOSTTYPE\a subdirectory of
262             \adirectory\a. The \aarchitecture\a \b-\b names the current
263             architecture. \adirectory\a must be an existing directory. If
264             \apackage\a is omitted then all binary packages are installed.
265             This action requires \bnmake\b.]
266         [+license\b [ \apackage\a ... ]]?List the source license(s) for
267             \apackage\a on the standard output. Note that individual
268             components in \apackage\a may contain additional or replacement
269             licenses.]
270         [+list\b [ \apackage\a ... ]]?List the name, version and
271             prerequisites for \apackage\a on the standard output.]
272         [+make\b [ \apackage\a ]] [ \aoption\a ... ]] [ \atarget\a ... ]]?Build
273             and install. The default \atarget\a is \binstall\b, which makes
274             and installs \apackage\a. If the standard output is a terminal
275             then the output is also captured in
276             \b$INSTALLROOT/lib/package/gen/make.out\b. The build is done in
277             the \b$INSTALLROOT\b directory tree viewpathed on top of the
278             \b$PACKAGEROOT\b directory tree. If \bflat\b is specified then
279             the \b$INSTALLROOT\b { bin fun include lib } directories are
280             linked to the same directories in the package root. Only one
281             architecture may be \bflat\b. Leaf directory names matching the
282             \b|\b-separated shell pattern \b$MAKESKIP\b are ignored. The
283             \bview\b action is done before making. \aoption\a operands are
284             passed to the underlying make command.]
285         [+read\b [ \apackage\a ... | \aarchive\a ... ]]?Read the named
286             package or archive(s). Must be run from the package root
287             directory. Archives are searched for in \b.\b and
288             \blib/package/tgz\b. Each package archive is read only once.
289             The file \blib/package/tgz/\b\apackage\a[.\atype\a]]\b.tim\b
290             tracks the read time. See the \bwrite\b action for archive
291             naming conventions. Text file archive member are assumed to be
292             ASCII or UTF-8 encoded.]
293         [+regress?\bdiff\b(1) the current and previous \bpackage test\b
294             results.]
295         [+release\b [ [\aCC\a]]\aYY-MM-DD\a [ [\acc\a]]\ayy-mm-dd\a ]]]] [ \apackage\a ]]?Display
296             recent changes for the date range [\aCC\a]]\aYY-MM-DD\a (up to
297         [\acc\a]]\ayy-mm-dd\a.), where \b-\b means lowest (or highest.)
298             If no dates are specified then changes for the last 4 months
299             are listed. \apackage\a may be a package or component name.]
300         [+remove\b [ \apackage\a ]]?Remove files installed for
301             \apackage\a.]
302         [+results\b [ \bfailed\b ]] [ \bpath\b ]] [ \bold\b ]] [\bmake\b | \btest\b | \bwrite\b ]]?List
303             results and interesting messages captured by the most recent
304             \bmake\b (default), \btest\b or \bwrite\b action. \bold\b
305             specifies the previous results, if any (current and previous 9
306             results are retained.) \b$HOME/.pkgresults\b, if it exists,
307             must contain an \begrep\b(1) expression of result lines to be
308             ignored. \bfailed\b lists failures only and \bpath\b lists the
309             results file path name only.]
310         [+setup\b [ beta ]] [ binary ]] [ source ]] [ \aarchitecture\a ... ]] [ \aurl\a ]] [ \apackage\a ... ]]?This
311             action initializes the current directory as a package root, runs the
312             \bupdate\b action to download new or out of date packages, and runs the
313             \bread\b action on those packages. If \bflat\b is specified then the
314             \b$INSTALLROOT\b { bin fun include lib } directories are linked to the
315             same directories in the package root. Only one architecture may be
316             \bflat\b. See the \bupdate\b and \bread\b action descriptions for
317             argument details.]
318         [+test\b [ \apackage\a ]]?Run the regression tests for
319             \apackage\a. If the standard output is a terminal then the
320             output is also captured in
321             \b$INSTALLROOT/lib/package/gen/test.out\b. In general a package
322             must be made before it can be tested. Components tested with
323             the \bregress\b(1) command require \bksh93\b. If \bonly\b is
324             also specified then only the listed package components are
325             tested, otherwise the closure of the components is tested.]
326         [+update\b [ beta ]] [ binary ]] [ source ]] [\aarchitecture\a ... ]] [ \aurl\a ]] [ \apackage\a ... ]]?Download
327             the latest release of the selected and required packages from \aurl\a
328             (e.g., \bhttp://www.research.att.com/sw/download\b) into the directory
329             \b$PACKAGEROOT/lib/package/tgz\b. \bbeta\b acesses beta packages;
330             download these at your own risk. If \aarchitecture\a is omitted then
331             only architectures already present in the \btgz\b directory will be
332             downloaded. If \aarchitecture\a is \b-\b then all posted architectures
333             will be downloaded. If \aurl\a matches \b*.url\b then it is interpreted
334             as a file containing shell variable assignments for \burl\b,
335             \bauthorize\b and \bpassword\b. If \aurl\a is omitted then the
336             definitions for \burl\b, \bauthorize\b and \bpassword\b in
337             \b$PACKAGEROOT/lib/package/tgz/default.url\b, if it exists, are used.
338             If \b$PACKAGEROOT/lib/package/tgz/default.url\b does not exist then it
339             is initialized with the current \burl\b, \bauthorize\b and \bpassword\b
340             values and read permission for the current user only. If \apackage\a is
341             omitted then only packages already present in the tgz directory will be
342             downloaded. If \apackage\a is \b-\b then all posted packages will be
343             downloaded. If \bsource\b and \bbinary\b are omitted then both source
344             and binary packages will be downloaded. If \bonly\b is specified then
345             only the named packages are updated; otherwise the closure of required
346             packages is updated. This action requires \bwget\b(1), \blynx\b(1),
347             \bcurl\b(1) or a shell that supports io to
348             \b/dev/tcp/\b\ahost\a/\aport\a.]
349         [+use\b [ \auid\a | \apackage\a | . [ 32 | 64 ]] | 32 | 64 | - ]] [ command ...]]?Run
350             \acommand\a, or an interactive shell if \acommand\a is omitted,
351             with the environment initialized for using the package (can you
352             say \ashared\a \alibrary\a or \adll\a without cussing?) If
353             \auid\a or \apackage\a or \a.\a is specified then it is used
354             to determine a \b$PACKAGEROOT\b, possibly different from
355             the current directory. For example, to try out bozo`s package:
356             \bpackage use bozo\b. The \buse\b action may be run from any
357             directory. If the file \b$INSTALLROOT/lib/package/profile\b is
358             readable then it is sourced to initialize the environment. 32 or 64
359             implies \b$PACKAGEROOT\b of . and specifies the target architecture
360             word size (which may be silently ignored.)]
361         [+verify\b [ \apackage\a ]]?Verify installed binary files
362             against the checksum files in
363             \b$INSTALLROOT/lib/\b\apackage\a\b/gen/*.sum\b. The checksum
364             files contain mode, user and group information. If the checksum
365             matches for a given file then the mode, user and group are
366             changed as necessary to match the checksum entry. A warning is
367             printed on the standard error for each mismatch. Requires the
368             \bast\b package \bcksum\b(1) command.]
369         [+view\b?Initialize the architecture specific viewpath
370             hierarchy. If \bflat\b is specified then the \b$INSTALLROOT\b {
371             bin fun include lib } directories are linked to the same
372             directories in the package root. Only one architecture may be
373             \bflat\b. The \bmake\b action implicitly calls this action.]
374         [+write\b [\aformat\a]] \atype\a ... [ \apackage\a ...]]?Write
375             a package archive for \apackage\a. All work is done in the
376             \b$PACKAGEROOT/lib/package\b directory. \aformat\a-specific
377             files are placed in the \aformat\a subdirectory. A
378             \apackage\a[.\atype\a]]\b.tim\b file in this directory tracks
379             the write time and prevents a package from being read in the
380             same root it was written. If more than one file is generated
381             for a particular \aformat\a then those files are placed in the
382             \aformat\a/\apackage\a subdirectory. File names in the
383             \aformat\a subdirectory will contain the package name, a
384             \ayyyy-mm-dd\a date, and for binary packages, \aHOSTTYPE\a. If
385             \apackage\a is omitted then an ordered list of previously
386             written packages is generated. If \bonly\b is specified then
387             only the named packages will be written; otherwise prerequisite
388             packages are written first. Package components must be listed
389             in \apackage\a\b.pkg\b. \aformat\a may be one of:]
390             {
391                 [+cyg?Generate a \bcygwin\b package.]
392                 [+exp?Generate an \bexptools\b maintainer source
393                     archive and \aNPD\a file, suitable for \bexpmake\b(1)]
394                 [+lcl?Generate a package archive suitable for
395                     restoration into the local source tree (i.e., the
396                     source is not annotated for licencing.)]
397                 [+pkg?Generate a \bpkgmk\b(1) package suitable for
398                     \bpkgadd\b(1).]
399                 [+rpm?Generate an \brpm\b(1) package.]
400                 [+tgz?Generate a \bgzip\b(1) \btar\b(1) package
401                     archive. This is the default.]
402                 [+tst?Generate a \btgz\b format package archive in the
403                     \btst\b subdirectory. Version state files are not updated.]
404             }
405         [+?\btype\b specifies the package type which must be one of
406             \bsource\b, \bbinary\b or \bruntime\b. A source package
407             contains the source needed to build the corresponding binary
408             package. A binary package includes the libraries and headers
409             needed for compiling and linking against the public interfaces.
410             A runtime package contains the commands and required dynamic
411             libraries.]
412         [+?A package may be either a \bbase\b or \bdelta\b. A base
413             package contains a complete copy of all components. A delta
414             package contains only changes from a previous base package.
415             Delta recipients must have the \bast\b \bpax\b(1) command (in
416             the \bast-base\b package.) If neither \bbase\b nor \bdelta\b is
417             specified, then the current base is overwritten if there are no
418             deltas referring to the current base. Only the \btgz\b and
419             \blcl\b formats support \bdelta\b. If \bbase\b is specified
420             then a new base and two delta archives are generated: one delta
421             to generate the new base from the old, and one delta to
422             generate the old base from the new; the old base is then
423             removed. If \bdelta\b is specified then a new delta referring
424             to the current base is written.]
425         [+?\apackage\a\b.pkg\b may reference other packages. By default
426             a pointer to those packages is written. The recipient \bpackage
427             read\b will then check that all required packages have been
428             downloaded. If \bclosure\b is specified then the components for
429             all package references are included in the generated package.
430             This may be useful for \blcl\b and versioning.]
431         [+?All formats but \blcl\b annotate each \bsource\b file (not
432             already annotated) with a license comment as it is written to
433             the package archive using \bproto\b(1).]
434     }
435 [+DETAILS?The package directory hierarchy is rooted at
436     \b$PACKAGEROOT\b. All source and binaries reside under this tree. A two
437     level viewpath is used to separate source and binaries. The top view is
438     architecture specific, the bottom view is shared source. All building
439     is done in the architecture specific view; no source view files are
440     intentionally changed. This means that many different binary
441     architectures can be made from a single copy of the source.]
442 [+?Independent \b$PACKAGEROOT\b hierarchies can be combined by
443     appending \b$INSTALLROOT:$PACKAGEROOT\b pairs to \bVPATH\b. The
444     \bVPATH\b viewing order is from left to right. Each \b$PACKAGEROOT\b
445     must have a \b$PACKAGEROOT/lib/package\b directory.]
446 [+?Each package contains one or more components. Component source for
447     the \afoo\a command is in \b$PACKAGEROOT/src/cmd/\b\afoo\a, and source
448     for the \abar\a library is in \b$PACKAGEROOT/src/lib/lib\b\abar\a. This
449     naming is for convenience only; the underlying makefiles handle
450     inter-component build order. The \bINIT\b component, which contains
451     generic package support files, is always made first, then the
452     components named \bINIT\b*, then the component order determined by the
453     closure of component makefile dependencies.]
454 [+?\b$PACKAGEROOT/lib/package\b contains package specific files. The
455     package naming convention is \agroup\a[-\apart\a]]; e.g., \bast-base\b,
456     \bgnu-fileutils\b. The *\b.pkg\b files are ast \bnmake\b(1) makefiles
457     that contain the package name, package components, references to other
458     packages, and a short package description. *\b.pkg\b files are used by
459     \bpackage write\b to generate new source and binary packages.]
460 [+?\b$PACKAGEROOT/lib/package/\b\agroup\a\b.lic\b files contain license
461     information that is used by the \bast\b \bproto\b(1) and \bnmake\b(1)
462     commands to generate source and binary license strings. \agroup\a is
463     determined by the first \b:PACKAGE:\b operator name listed in the
464     component \bnmake\b makefile. \agroup\a\b.lic\b files are part of the
465     licensing documentation. Each component may have its own \bLICENSE\b file
466     that overrides the \agroup\a\b.lic\b file. The full text of the licenses
467     are in the \b$PACKAGEROOT/lib/package/LICENSES\b and
468     \b$INSTALLROOT/lib/package/LICENSES\b directories.]
469 [+?A few files are generated in \b$PACKAGEROOT/lib/package/gen\b and
470     \b$INSTALLROOT/lib/package/gen\b. \apackage\a\b.ver\b contains one line
471     consisting of \apackage version release\a \b1\b for the most recent
472     instance of \apackage\a read into \b$PACKAGEROOT\b, where \apackage\a
473     is the package name, \aversion\a is the \aYYYY-MM-DD\a base version,
474     and \arelease\a is \aversion\a for the base release or \aYYYY-MM-DD\a
475     for delta releases. \apackage\a\b.req\b contains *\b.ver\b entries for
476     the packages required by \apackage\a, except that the fourth field is
477     \b0\b instead of \b1\b. All packages except \bINIT\b require the
478     \bINIT\b package. A simple sort of \apackage\a\b.pkg\b and *\b.ver\b
479     determines if the required package have been read in. Finally,
480     \apackage\a\b.README\b and \apackage\a\a.html\b contain the README text
481     for \apackage\a and all its components. Included are all changes added
482     to the component \bRELEASE\b, \bCHANGES\b or \bChangeLog\b files dated
483     since the two most recent base releases. Component \bRELEASE\b files
484     contain tag lines of the form [\aYY\a]]\aYY-MM-DD\a [ \atext\a ]] (or
485     \bdate\b(1) format dates) followed by README text, in reverse
486     chronological order (newer entries at the top of the file.) \bpackage
487     release\b lists this information, and \bpackage contents ...\b lists
488     the descriptions and components.]
489 [+?\b$HOSTYPE\b names the current binary architecture and is determined
490     by the output of \bpackage\b (no arguments.) The \b$HOSTTYPE\b naming
491     scheme is used to separate incompatible executable and object formats.
492     All architecture specific binaries are placed under \b$INSTALLROOT\b
493     (\b$PACKAGEROOT/arch/$HOSTTYPE\b.) There are a few places that match
494     against \b$HOSTTYPE\b when making binaries; these are limited to
495     makefile compiler workarounds, e.g., if \b$HOSTTYPE\b matches \bhp.*\b
496     then turn off the optimizer for these objects. All other architecture
497     dependent logic is handled either by the \bast\b \biffe\b(1) command or
498     by component specific configure scripts. Explicit \b$HOSTYPE\b
499     values matching *,*cc*[,-*,...]] optionally set the default \bCC\b and
500     \bCCFLAGS\b. This is handy for build farms that support different
501     compilers on the same architecture.]
502 [+?Each component contains an \bast\b \bnmake\b(1) makefile (either
503     \bNmakefile\b or \bMakefile\b) and a \bMAM\b (make abstract machine)
504     file (\bMamfile\b.) A Mamfile contains a portable makefile description
505     that is used by \bmamake\b(1) to simulate \bnmake\b. Currently there is
506     no support for old-make/gnu-make makefiles; if the binaries are just
507     being built then \bmamake\b will suffice; if source or makefile
508     modifications are anticipated then \bnmake\b (in the \bast-base\b
509     package) should be used. Mamfiles are automatically generated by
510     \bpackage write\b.]
511 [+?Most component C source is prototyped. If \b$CC\b (default value
512     \bcc\b) is not a prototyping C compiler then \bpackage make\b runs
513     \bproto\b(1) on portions of the \b$PACKAGEROOT/src\b tree and places
514     the converted output files in the \b$PACKAGEROOT/proto/src\b tree.
515     Converted files are then viewpathed over the original source.
516     \bproto\b(1) converts an ANSI C subset to code that is compatible with
517     K&R, ANSI, and C++ dialects.]
518 [+?All scripts and commands under \b$PACKAGEROOT\b use \b$PATH\b
519     relative pathnames (via the \bast\b \bpathpath\b(3) function); there
520     are no imbedded absolute pathnames. This means that binaries generated
521     under \b$PACKAGEROOT\b may be copied to a different root; users need
522     only change their \b$PATH\b variable to reference the new installation
523     root \bbin\b directory. \bpackage install\b installs binary packages in
524     a new \b$INSTALLROOT\b.]
526 [ qualifier ... ] [ action ] [ arg ... ] [ n=v ... ]
528 [+SEE ALSO?\bautoconfig\b(1), \bcksum\b(1), \bexecrate\b(1), \bexpmake\b(1),
529         \bgzip\b(1), \bmake\b(1), \bmamake\b(1), \bnmake\b(1), \bpax\b(1),
530         \bpkgadd\b(1), \bpkgmk\b(1), \bproto\b(1), \bratz\b(1), \brpm\b(1),
531         \bsh\b(1), \btar\b(1), \boptget\b(3)]
533         case $* in
534         help)   set -- --man ;;
535         esac
536         while   getopts -a $command "$USAGE" OPT
537         do      :
538         done
539         shift $OPTIND-1
540         ;;
541 esac
543 # check the args
545 case $AR in
546 '')     AR=ar ;;
547 esac
548 case $CC in
549 '')     CC=cc ;;
550 esac
551 case $LD in
552 '')     LD=ld ;;
553 esac
554 case $NM in
555 '')     NM=nm ;;
556 esac
558 action=
559 admin_all=1
560 admin_on=
561 authorize=
562 bit=
563 exec=
564 flat=0
565 force=0
566 global=
568 html=0
569 ifs=${IFS-'
570          '}
572 make=
573 makeflags='-k -K'
574 nmakeflags=
575 nmakesep=
576 nl="
578 noexec=
579 only=0
580 output=
581 package_src=
582 password=
583 quiet=0
584 show=:
585 tab="        "
586 verbose=0
587 AUTHORIZE=
588 DEBUG=
589 HURL=
590 PROTOROOT=-
591 SHELLMAGIC=-
593 unset FIGNORE BINDIR DLLDIR ETCDIR FUNDIR INCLUDEDIR LIBDIR LOCALEDIR MANDIR SHAREDIR 2>/dev/null || true
595 while   :
596 do      case $# in
597         0)      set host type ;;
598         esac
599         case $1 in
600         admin|clean|clobber|contents|copyright|export|host|install|license|list|make|read|regress|release|remove|results|setup|test|update|use|verify|view|write|TEST)
601                 action=$1
602                 shift
603                 break
604                 ;;
605         authorize)
606                 case $# in
607                 1)      echo $command: $1: authorization user name argument expected >&2; exit 1 ;;
608                 esac
609                 shift
610                 authorize=$1
611                 shift
612                 continue
613                 ;;
614         debug|environment)
615                 exec=echo make=echo show=echo
616                 ;;
617         flat)   flat=1
618                 ;;
619         force)  force=1
620                 ;;
621         never)  exec=echo noexec=-N
622                 ;;
623         only)   only=1
624                 ;;
625         password)
626                 case $# in
627                 1)      echo $command: $1: authorization password argument expected >&2; exit 1 ;;
628                 esac
629                 shift
630                 password=$1
631                 shift
632                 continue
633                 ;;
634         quiet)  quiet=1
635                 ;;
636         show)   exec=echo noexec=-n
637                 ;;
638         verbose)verbose=1
639                 ;;
640         DEBUG)  DEBUG=1
641                 PS4='+$LINENO:$SECONDS+ '
642                 set -x
643                 ;;
644         help|HELP|html|man|--[?m]*)
645                 case $1 in
646                 help)   code=0
647                         case $2 in
648                         '')     exec 1>&2 ;;
649                         esac
650                         ;;
651                 html)   code=0 html=1
652                         ;;
653                 *)      code=2
654                         exec 1>&2
655                         ;;
656                 esac
657                 case $html in
658                 1)      bO="<HTML>
659 <HEAD>
660 <TITLE>$2 package installation instructions</TITLE>
661 <HEAD>
662 <BODY bgcolor=white link=teal vlink=dimgray>"
663                         eO='</BODY>
664 </HTML>'
665                         bH="<CENTER><H3><FONT face=courier color=red>"
666                         eH='</FONT></H3></CENTER>'
667                         bP='<P>'
668                         bL='<P><TABLE cellpadding=0 cellspacing=2>'
669                         bL2='<P><TABLE border=0 cellpadding=0 cellspacing=2>'
670                         eL='</TABLE><P>'
671                         bT='<TR><TD align=right valign=top><B>'
672                         bD='</B></TD><TD align=left>'   eD='</TD></TR>'
673                         bB='<B>'                        eB='</B>'
674                         bI='<I>'                        eI='</I>'
675                         bX='<PRE>'                      eX='</PRE>'
676                         bF='<TT>'                       eF='</TT>'
677                         Camp='&amp;'
678                         Mcurl='<A href=../../man/man1/curl.html>curl</A>(1)'
679                         Mdate='<A href=../../man/man1/date.html>date</A>(1)'
680                         Mfile='<A href=../../man/man1/file.html>file</A>(1)'
681                         Mgunzip='<A href=../../man/man1/gzip.html>gunzip</A>(1)'
682                         Mhurl='<A href=../../man/man1/hurl.html>hurl</A>(1)'
683                         Mlynx='<A href=../../man/man1/lynx.html>lynx</A>(1)'
684                         Mnmake='<A href=../../man/man1/nmake.html>nmake</A>(1)'
685                         Mpackage='<A href=../../man/man1/package.html>package</A>(1)'
686                         Mproto='<A href=../../man/man1/proto.html>proto</A>(1)'
687                         Mratz='<A href=../../man/man1/ratz.html>ratz</A>'
688                         Mtar='<A href=../../man/man1/tar.html>tar</A>(1)'
689                         Mwget='<A href=../../man/man1/wget.html>wget</A>(1)'
690                         ;;
691                 *)      bO=''                           eO=''
692                         bH=''                           eH=':'
693                         bP=''
694                         bL=''                           eL=''
695                         bL2=''
696                         bT='  '
697                         bD=' '                          eD=''
698                         bB=''                           eB=''
699                         bI=''                           eI=''
700                         bX=''                           eX=''
701                         bF='"'                          eF='"'
702                         Camp='&'
703                         Mcurl='curl(1)'
704                         Mdate='date(1)'
705                         Mfile='file(1)'
706                         Mgunzip='gunzip(1)'
707                         Mhurl='hurl(1)'
708                         Mlynx='lynx(1)'
709                         Mnmake='nmake(1)'
710                         Mpackage='package(1)'
711                         Mproto='proto(1)'
712                         Mratz='ratz'
713                         Mtar='tar(1)'
714                         Mwget='wget(1)'
715                         ;;
716                 esac
717                 case $2 in
718                 binary) echo "${bO}
719 ${bH}Binary Package Installation Instructions${eH}
720 ${bL}
721 ${bT}(1)${bD}Do not install packages as ${bI}root/super-user${eI}. Although some components may
722       have setuid executables, few must be owned by ${bI}root${eI}. These are best
723       changed manually when the security implications are understood.${eD}
724 ${bT}(2)${bD}Choose a package root directory and cd to it. This will be a local work
725       area for all packages.${eD}
726 ${bT}(3)${bD}These instructions bypass the ${bI}click to download${eI} package links on the
727       download site. If you already clicked, or if your system does not have
728       ${Mcurl}, ${Mhurl}, ${Mlynx} or ${Mwget} then use the alternate instructions
729       for (3),(4),(5) in plan ${bB}B${eB} below. Plan ${bB}B${eB} installs the ${Mhurl}
730       script which works with ksh and modern bash. The top level URL is:${bX}
731                 URL=http://www.research.att.com/sw/download${eX}${eD}
732 ${bT}(4)${bD}If the ${bB}bin/package${eB} script does not exist then run:${bX}
733                 test -d bin || mkdir bin
734                 url=\$URL/package
735                 (wget -O - \$url||curl -L \$url||hurl \$url) > bin/package
736                 chmod +x bin/package${eX}${eD}
737 ${bT}(5)${bD}Determine the list of package names you want from the download site, then
738       use the ${Mpackage} command to do the actual download:${bX}
739                 bin/package authorize \"${bI}NAME${eI}\" password \"${bI}PASSWORD${eI}\" \\
740                         setup binary \$URL ${bI}PACKAGE${eI} ...${eX}
741       (Refer to the ${bB}AUTHORIZATION${eB} paragraph on the main download page for
742       ${bI}NAME${eI}/${bI}PASSWORD${eI} details.)  This downloads the closure of the latest
743       binary package(s); covered and up-to-date packages are not downloaded again unless
744       ${bB}package force ...${eB} is specified. Package content is verified using ${bB}${checksum}${eB}.
745       If the package root will contain only one architecture then you can install in ${bB}bin${eB} and
746       ${bB}lib${eB} instead of ${bB}arch/${eB}${bI}HOSTTYPE${eI}${bB}/bin${eB} and ${bB}arch/${eB}${bI}HOSTTYPE${eI}${bB}/lib${eB} by running this
747       instead:${bX}
748                 bin/package authorize \"${bI}NAME${eI}\" password \"${bI}PASSWORD${eI}\" \\
749                         flat setup binary \$URL ${bB}PACKAGE${eB} ...${eX}
750       To update the same packages from the same URL run:${bX}
751                 bin/package setup binary${eX}${eD}
752 ${bT}(6)${bD}The packaged binaries are position independent, i.e., they do not
753       contain hard-coded paths. However, commands with related files, like
754       ${Mfile} and ${Mnmake}, require the path of the bin directory to be
755       exported in ${bB}PATH${eb}.${eD}
756 ${bT}(7)${bD}You can run the binaries directly from the package root, or you can
757       install them in a public root (requires the ${bI}AT${Camp}T${eI} ${Mnmake} command):${bX}
758                 bin/package flat install ${bI}DIRECTORY PACKAGE${eI}${eX}
759       This will install in ${bI}DIRECTORY${eI}${bB}/bin${eB} and ${bI}DIRECTORY${eI}${bB}/lib${eB}. If you want to
760       preserve the ${bB}arch/${eB}${bI}HOSTTYPE${eI} hierarchy under ${bI}DIRECTORY${eI} then omit the
761       ${bB}flat${eB} argument. If you don't have ${Mnmake} then the following will do a
762       flat install:${bX}
763                 cd \$INSTALLROOT
764                 cp -p -r bin lib include ${bI}DIRECTORY${eI}${eX}${eD}
765 ${bT}(8)${bD}To summarize, after the first time, the download cycle for the latest
766       binary release is:${bX}
767                 bin/package setup binary${eX}${eD}${eL}
769 ${bH}Binary Package Installation Instructions -- Plan B${eH}
770 ${bL}
771 ${bT}(3)${bD}Create the subdirectory ${bB}lib/package/tgz${eB} and download all package archives
772       into that directory.${eD}
773 ${bT}(4)${bD}If the ${bB}bin/package${eB} script does not exist then manually read the ${bB}INIT${eB}
774       binary package:${bX}
775                 gunzip < lib/package/tgz/INIT.${bI}YYYY-MM-DD.HOSTTYPE${eI}.tgz |
776                         ${TAR} ${TARFLAGS}f -${eX}
777       Note that some browsers automatically unzip downloaded without warning.
778       If the gunzip fails try:
779                 ${TAR} ${TARFLAGS}f -${eX} lib/package/tgz/INIT.${bI}YYYY-MM-DD.HOSTTYPE${eI}.tgz
780       If your system does not have ${Mtar} or ${Mgunzip} then download the ${Mratz}
781       binary package:${bX}
782                 mkdir bin
783                 cp lib/package/tgz/ratz.${bI}YYYY-MM-DD.HOSTTYPE${eI}.exe bin/ratz
784                 chmod +x bin/ratz
785                 bin/ratz -lm < lib/package/tgz/INIT.${bI}YYYY-MM-DD/HOSTTYPE${eI}.tgz
786 ${bT}(5)${bD}Read all unread package archive(s):${bX}
787                 bin/package read${eX}
788       Both source and binary packages will be read by this step.${eD}${eL}${eO}"
789                         ;;
790                 intro)  echo "${bO}
791 ${bH}Package Hierarchy Details${eH}
792 ${bP}
793 The package directory hierarchy is rooted at ${bB}\$PACKAGEROOT${eB}. All source and
794 binaries reside under this tree. A two level viewpath is used to separate
795 source and binaries. The top view is architecture specific, the bottom view
796 is shared source. All building is done in the architecture specific view;
797 no source view files are intentionally changed. This means that many
798 different binary architectures can be made from a single copy of the source.
799 ${bP}
800 Each package contains one or more components. Component source for the ${bI}FOO${eI}
801 command is in ${bB}\$PACKAGEROOT/src/cmd/${eB}${bI}FOO${eI}, and source for the ${bI}BAR${eI} library is
802 in ${bB}\$PACKAGEROOT/src/lib/lib${eB}${bI}BAR${eI}. This naming is for convenience only; the
803 underlying makefiles handle inter-component build order. The ${bB}INIT${eB} component,
804 which contains generic package support files, is always made first, then the
805 components named ${bB}INIT${eB}*, then the order determined by the closure of component
806 makefile dependencies.
807 ${bP}
808 ${bB}\$PACKAGEROOT/lib/package${eB} contains package specific files. The package naming
809 convention is ${bI}GROUP${eI}[${bI}-PART${eI}]; e.g., ${bB}ast-base${eB}, ${bB}gnu-fileutils${eB}. The *${bB}.pkg${eB} files
810 are ${bB}ast${eB} ${Mnmake} makefiles that contain the package name, package components,
811 references to other packages, and a short package description. *${bB}.pkg${eB} files
812 are used by ${bF}package write${eF} to generate new source and binary packages.
813 ${bP}
814 ${bB}\$PACKAGEROOT/lib/package/${eB}${bI}GROUP${eI}${bB}.lic${eB} files contain license information that
815 is used by the ${bB}ast${eB} ${Mproto} and ${Mnmake} commands to generate source and
816 binary license strings. ${bI}GROUP${eI} is determined by the first ${bB}:PACKAGE:${eB} operator
817 name listed in the component ${bB}nmake${eB} makefile. ${bI}GROUP${eI}${bB}.lic${eB} files are part of the
818 licensing documentation.  Each component may have its own ${bB}LICENSE${eB} file that
819 overrides the ${bI}GROUP${eI}${bB}.lic${eB} file.  The full text of the licenses are in the
820 ${bB}\$PACKAGEROOT/lib/package/LICENSES${eB} and ${bB}\$INSTALLROOT/lib/package/LICENSES${eB}
821 directories.
822 ${bP}
823 A few files are generated in ${bB}\$PACKAGEROOT/lib/package/gen${eB} and
824 ${bB}\$INSTALLROOT/lib/package/gen${eB}. ${bI}PACKAGE${eI}${bB}.ver${eB} contains one line consisting of${bX}
825         ${bI}PACKAGE VERSION RELEASE${eI} 1${eX}
826 for the most recent instance of ${bI}PACKAGE${eI} read into ${bB}\$PACKAGEROOT${eB}, where
827 ${bI}PACKAGE${eI} is the package name, ${bI}VERSION${eI} is the ${bI}YYYY-MM-DD${eI} base version,
828 and ${bI}RELEASE${eI} is ${bI}VERSION${eI} for the base release or ${bI}YYYY-MM-DD${eI} for delta releases.
829 ${bI}PACKAGE${eI}${bB}.req${eB} contains *${bB}.ver${eB} entries for the packages required by
830 ${bI}PACKAGE${eI}, except that the fourth field is 0 instead of 1. All packages
831 except ${bB}INIT${eB} and ${Mratz} require the ${bB}INIT${eB} package. A simple sort of ${bI}PACKAGE${eI}${bB}.pkg${eB}
832 and *${bB}.ver${eB} determines if the required package have been read in. Finally,
833 ${bI}PACKAGE${eI}${bB}.README${eB} contains the ${bB}README${eB} text for ${bI}PACKAGE${eI} and all its
834 components. Included are all changes added to the component ${bB}RELEASE${eB},
835 ${bB}CHANGES${eB} or ${bB}ChangeLog${eB} files dated since the two most recent base
836 releases. Component ${bB}RELEASE${eB} files contain tag lines of the form
837 [${bI}CC${eI}]${bI}YY-MM-DD${eI} [ ${bI}TEXT${eI} ] (or ${Mdate} format dates) followed by README
838 text, in reverse chronological order (newer entries at the top of the
839 file.) ${bF}package release${eF} generates this information, and
840 ${bF}package contents ...${eF} lists the descriptions and components.
841 ${bP}
842 ${bB}\$HOSTYPE${eB} names the current binary architecture and is determined by the
843 output of ${bF}package${eF} (no arguments.) The ${bB}\$HOSTTYPE${eB} naming scheme is used
844 to separate incompatible executable and object formats. All architecture
845 specific binaries are placed under ${bB}\$INSTALLROOT${eB} (${bB}\$PACKAGEROOT/arch/\$HOSTTYPE${eB}.)
846 There are a few places that match against ${bB}\$HOSTTYPE${eB} when making binaries; these
847 are limited to makefile compiler workarounds, e.g., if ${bB}\$HOSTTYPE${eB} matches
848 'hp.*' then turn off the optimizer for these objects. All other architecture
849 dependent logic is handled either by ${bB}\$INSTALLROOT/bin/iffe${eB} or by component
850 specific configure scripts. Explicit ${bB}\$HOSTYPE${eB} values matching *,*cc*[,-*,...]
851 optionally set the default ${bB}CC${eB} and ${bB}CCFLAGS${eB}. This is handy for build
852 farms that support different compilers on the same architecture.
853 ${bP}
854 Each component contains an ${bB}ast${eB} ${Mnmake} makefile (either ${bB}Nmakefile${eB} or ${bB}Makefile${eB})
855 and a ${bI}MAM${eI} (make abstract machine) file (${bB}Mamfile${eB}.) A Mamfile contains a portable
856 makefile description that is used by ${bB}\$INSTALLROOT/bin/mamake${eB} to simulate
857 ${bB}nmake${eB}. Currently there is no support for old-make/gnu-make makefiles; if
858 the binaries are just being built then ${bB}mamake${eB} will suffice; if source or
859 makefile modifications are anticipated then ${bB}nmake${eB} (from the ${bB}ast-open${eB} or
860 ${bB}ast-base${eB} package) should be used. Mamfiles are automatically generated by
861 ${bF}package write${eF}.
862 ${bP}
863 Most component C source is prototyped. If ${bB}\$CC${eB} (default value ${bB}cc${eB}) is not a
864 prototyping C compiler then ${bF}package make${eF} runs ${Mproto} on portions of the
865 ${bB}\$PACKAGEROOT/src${eB} tree and places the converted output files in the
866 ${bB}\$PACKAGEROOT/proto/src${eB} tree. Converted files are then viewpathed over the
867 original source. The ${bB}ast${eB} ${Mproto} command converts an ANSI C subset to code
868 that is compatible with K&R, ANSI, and C++ dialects.
869 ${bP}
870 All scripts and commands under ${bB}\$PACKAGEROOT${eB} use ${bB}\$PATH${eB} relative pathnames;
871 there are no imbedded absolute pathnames. This means that binaries generated
872 under ${bB}\$PACKAGEROOT${eB} may be copied to a different root; users need only change
873 their ${bB}\$PATH${eB} variable to reference the new instalation root bin directory.
874 ${bF}package install${eF} installs binary packages in a new ${bB}\$INSTALLROOT${eB}.
875 ${eO}"
876                         ;;
877                 source) echo "${bO}
878 ${bH}Source Package Installation Instructions${eH}
879 ${bL}
880 ${bT}(1)${bD}Do not install packages as ${bI}root/super-user${eI}. Although some components may
881       have setuid executables, few must be owned by ${bI}root${eI}. These are best
882       changed manually when the security implications are understood.${eD}
883 ${bT}(2)${bD}Choose a package root directory and cd to it. This will be a local work
884       area for all packages.
885 ${bT}(3)${bD}These instructions bypass the ${bI}click to download${eI} package links on the
886       download site. If you already clicked, or if your system does not have
887       ${Mcurl}, ${Mhurl}, ${Mlynx} or ${Mwget} then use the alternate instructions
888       for (3),(4),(5) in plan ${bB}B${eB} below. Plan ${bB}B${eB} installs the ${Mhurl}
889       script which works with ksh and modern bash. The top level URL is:${bX}
890                 URL=http://www.research.att.com/sw/download${eX}${eD}
891 ${bT}(4)${bD}If the ${bB}bin/package${eB} script does not exist then run:${bX}
892                 test -d bin || mkdir bin
893                 url=\$URL/package
894                 (wget -O - \$url||curl -L \$url||hurl \$url) > bin/package
895                 chmod +x bin/package${eX}${eD}
896 ${bT}(5)${bD}Determine the list of package names you want from the download site, then
897       use the ${Mpackage} command to do the actual download:${bX}
898                 bin/package authorize \"${bI}NAME${eI}\" password \"${bI}PASSWORD${eI}\" \\
899                         setup source \$URL ${bB}PACKAGE${eB} ...${eX}
900       (Refer to the ${bB}AUTHORIZATION${eB} paragraph on the main download page for
901       ${bI}NAME${eI}/${bI}PASSWORD${eI} details.)  This downloads the closure of the latest
902       source package(s); covered and up-to-date packages are not downloaded again unless
903       ${bB}package force ...${eB} is specified. Package content is verified using ${bB}${checksum}${eB}.
904       If the package root will contain only one architecture then you can install in ${bB}bin${eB} and
905       ${bB}lib${eB} instead of ${bB}arch/${eB}${bI}HOSTTYPE${eI}${bB}/bin${eB} and ${bB}arch/${eB}${bI}HOSTTYPE${eI}${bB}/lib${eB} by running this
906       instead:${bX}
907                 bin/package authorize \"${bI}NAME${eI}\" password \"${bI}PASSWORD${eI}\" \\
908                         flat setup source \$URL ${bB}PACKAGE${eB} ...${eX}
909       To update the same packages from the same URL run:${bX}
910                 bin/package setup source${eX}${eD}
911 ${bT}(6)${bD}Build and install; all generated files are placed under ${bB}arch/${eB}${bI}HOSTTYPE${eI}
912       (${bB}\$INSTALLROOT${eB}), where ${bI}HOSTTYPE${eI} is the output of ${bB}bin/package${eB} (with no
913       arguments.) ${bI}name=value${eI} arguments are supported; ${bB}CC${eB} and ${bB}debug=1${eB} (compile
914       with -g instead of -O) are likely candidates. The output is written to
915       the terminal and captured in ${bB}\$INSTALLROOT/lib/package/gen/make.out${eB}:${bX}
916                 bin/package make${eX}${eD}
917 ${bT}(7)${bD}List make results and interesting errors:${bX}
918                 bin/package results${eX}
919       Run the regression tests:${bX}
920                 bin/package test${eX}
921       List test results and errors:${bX}
922                 bin/package results test${eX}${eD}
923 ${bT}(8)${bD}The generated binaries are position independent, i.e., they do not
924       contain hard-coded paths. However, commands with related files, like
925       ${Mfile} and ${Mnmake}, require the path of the bin directory to be
926       exported in ${bB}PATH${eb}.${eD}
927 ${bT}(9)${bD}You can run the binaries directly from the package root, or you can
928       install them in a public root after you are satisfied with the make and
929       test actions (requires the ${bI}AT${Camp}T${eI} ${Mnmake} command):${bX}
930                 bin/package flat install ${bI}DIRECTORY PACKAGE${eI}${eX}
931       This will install in ${bI}DIRECTORY${eI}${bB}/bin${eB} and ${bI}DIRECTORY${eI}${bB}/lib${eB}. If you want to
932       preserve the ${bB}arch/${eB}${bI}HOSTTYPE${eI} hierarchy under ${bI}DIRECTORY${eI} then omit the
933       ${bB}flat${eB} argument. If you don't have ${Mnmake} then the following will do a
934       flat install:${bX}
935                 cd \$INSTALLROOT
936                 cp -p -r bin lib include ${bI}DIRECTORY${eI}${eX}${eD}
937 ${bT}(10)${bD}To summarize, after the first time the download, build, and test cycle
938       for the latest source release is:${bX}
939                 bin/package setup source
940                 bin/package make
941                 bin/package test${eX}${eD}${eL}
943 ${bH}Source Package Installation Instructions -- Plan B${eH}
944 ${bL}
945 ${bT}(3)${bD}Create the subdirectory ${bB}lib/package/tgz${eB} and download all package archives
946       into that directory.${eD}
947 ${bT}(4)${bD}If the ${bB}bin/package${eB} script does not exist then manually read the ${bB}INIT${eB}
948       source package:${bX}
949                 gunzip < lib/package/tgz/INIT.${bI}YYYY-MM-DD${eI}.tgz | ${TAR} ${TARFLAGS}f -${eX}
950       Note that some browsers automatically unzip downloaded without warning.
951       If the gunzip fails try:
952                 ${TAR} ${TARFLAGS}f -${eX} lib/package/tgz/INIT.${bI}YYYY-MM-DD${eI}.tgz
953       If your system does not have ${Mtar} or ${Mgunzip} then download the ${Mratz}
954       source package, compile it, and manually read the ${bB}INIT${eB}
955       source package:${bX}
956                 mkdir bin
957                 cp lib/package/tgz/ratz.${bI}YYYY-MM-DD${eI}.c lib/package/tgz/ratz.c
958                 cc -o bin/ratz lib/package/tgz/ratz.c
959                 bin/ratz -lm < lib/package/tgz/INIT.${bI}YYYY-MM-DD${eI}.tgz
960 ${bT}(5)${bD}Read all unread package archive(s):${bX}
961                 bin/package read${eX}
962       Both source and binary packages will be read by this step.${eD}${eL}${eO}"
963                         ;;
964                 *)      echo "Usage: $command [ qualifier ... ] [ action ] [ arg ... ] [ n=v ... ]
966    The $command command controls source and binary packages. It must be run
967    within the package root directory tree. See \"$command help intro\" for
968    details. In the following, PACKAGE names either a package or a component
969    within a package; if omitted, all packages are operated on. The default
970    action is \"host type\".
972    qualifier:
973         authorize NAME Remote authorization name or license acceptance phrase.
974         debug|environment Show environment and actions; do not execute.
975         flat    Collapse \$INSTALLROOT { bin fun include lib } onto \$PACKAGEROOT.
976         force   Force the action to override saved state.
977         never   Run make -N; otherwise show other actions.
978         only    Only operate on the specified packages.
979         password PASSWORD Remote authorization or license acceptance password.
980         quiet   Do not list captured make and test action output.
981         show    Run make -n; otherwise show other actions.
982         DEBUG   Trace the package script actions in detail for debugging.
983    action:
984         admin [ all ] [ db FILE ] [ on PATTERN ] [ action ... ]
985                 Apply ACTION ... to the hosts listed in FILE. If FILE is
986                 omitted then "admin.db" is assumed. The caller must have rcp(1)
987                 and rsh(1) or scp(1) and ssh(1) access to the hosts. Output
988                 for the action is saved per-host in ACTION.log/HOST. Logs
989                 can be viewed by \"package admin [on HOST] results [ACTION]\".
990                 By default only local PACKAGEROOT hosts are selected from FILE;
991                 \"all\" selects all hosts. \"on PATTERN\" selects only
992                 hosts matching the | separated PATTERN. FILE contains four
993                 types of lines. Blank lines and lines beginning with # are
994                 ignored. Lines starting with id=value are variable assignments.
995                 Set admin_ping to local conventions if \"$admin_ping\" fails.
996                 If a package list is not specified on the command line the
997                 action applies to all packages; a variable assigment
998                 package=list applies action to the packages in list for
999                 subsequent hosts in FILE. The remaining line type is a host
1000                 description consisting of 6 tab separated fields. The first 3
1001                 are mandatory; the remaining 3 are updated by the admin action:
1002                    hosttype
1003                            The host type as reported by package.
1004                    [user@]host
1005                            The host name and optionally user name for rcp(1)
1006                            and rsh(1) access.
1007                    [remote:[[master]:]]PACKAGEROOT
1008                            The absolute remote package root directory and
1009                            optionally the remote prorocol (rsh or ssh) if
1010                            the directory is on a different server than the
1011                            master package root directory. If
1012                            lib/package/admin/$admin_env exists under
1013                            this directory then it is sourced by sh(1)
1014                            before ACTION is done. If this field begins with -
1015                            then the host is ignored. If this field contains
1016                            : then ditto(1) is used to sync the remote src
1017                            directory hierarchy to the local one. If [master]:
1018                            is specified then the sync is deferred to the
1019                            master host. If master is omitted (two :) then
1020                            the sync is disabled. These directories must exist
1021                            on the remote side: lib/package, src/cmd, src/lib.
1022                    date    YYMMDD of the last action.
1023                    date    Elapsed wall time of the last action.
1024                    M T W   The admin action make, test and write action error
1025                            counts. A non-numeric value in any of these fields
1026                            disables the corresponding action.
1027                    owner   The owner contact information.
1028                    attributes
1029                            NAME=VALUE attributes. Should at least contain
1030                            cc=compiler-version.
1031         clean | clobber
1032             Delete the arch/HOSTTYPE hierarchy; this deletes all generated
1033             files and directories for HOSTTYPE. The heirarchy can be rebuilt
1034             by package make.]
1035         contents [ package ... ]
1036                 List description and components for PACKAGE on the standard
1037                 output.
1038         copyright [ package ... ]
1039                 List the general copyright notice(s) for PACKAGE on the
1040                 standard output. Note that individual components in PACKAGE
1041                 may contain additional or replacement notices.
1042         export [ VARIABLE ... ]
1043                 List NAME=VALUE for each VARIABLE, one per line. If the
1044                 \"only\" attribute is specified then only the variable
1045                 values are listed. If no variables are specified then
1046                 $env are assumed.
1047         help [ ACTION ]
1048                 Display help text on the standard error [ standard output
1049                 for ACTION ].
1050         host [ canon cpu name rating type ... ]
1051                 List architecture/implementation dependent host information
1052                 on the standard output. type is listed if no attributes are
1053                 specified. Information is listed on a single line in attributes
1054                 order. The attributes are:
1055                    canon   The next argument is a host type name to be
1056                            converted to package syntax.
1057                    cpu     The number of cpus; 1 if the host is not a
1058                            multiprocessor.
1059                    name    The host name.
1060                    rating  The cpu rating in pseudo mips; the value is useful
1061                            useful only in comparisons with rating values of
1062                            other hosts. Other than a vax rating fixed at 1,
1063                            ratings can vary wildly but consistently from
1064                            vendor mips ratings. cc(1) may be required to
1065                            determine the rating.
1066                    type    The host type, usually of the form
1067                            vendor.architecture, with an optional trailing
1068                            -version. The main theme is that type names within
1069                            a family of architectures are named in a similar,
1070                            predictable style. Os point release information is
1071                            avoided as much as possible, but vendor resistance
1072                            to release incompatibilities has for the most part
1073                            been futile.
1074         html [ ACTION ]
1075                 Display html help text on the standard error [ standard output
1076                 for ACTION ].
1077         install [ ARCHITECTURE ... ] DIR [ PACKAGE ... ]
1078                 Copy the package binary hierarchy to DIR. If ARCHITECTURE is
1079                 omitted then all architectures are installed. If the \"flat\"
1080                 attribute is specified then exactly one ARCHITECTURE must be
1081                 specified; this architecture will be installed in DIR without
1082                 the \"arch/HOSTTYPE\" directory prefixes. Otherwise each
1083                 architecture will be installed in a separate \"arch/HOSTTYPE\"
1084                 subdirectory of DIR. The ARCHITECTURE - names the current
1085                 architecture. DIR must be an existing directory. If PACKAGE
1086                 is omitted then all binary packages are installed. This action
1087                 requires nmake.
1088         license [ package ... ]
1089                 List the source license(s) for PACKAGE on the standard output.
1090                 Note that individual components in PACKAGE may contain
1091                 additional or replacement licenses.
1092         list [ PACKAGE ... ]
1093                 List the name, version and prerequisites for PACKAGE on the
1094                 standard output.
1095         make [ PACKAGE ] [ OPTION ... ] [ TARGET ... ]
1096                 Build and install. The default TARGET is install, which
1097                 makes and installs all packages. If the standard output
1098                 is a terminal then the output is also captured in
1099                 \$INSTALLROOT/lib/package/gen/make.out. The build is done
1100                 in the \$INSTALLROOT directory tree viewpathed on top of
1101                 the \$PACKAGEROOT directory tree. If \"flat\" is specified then
1102                 the \$INSTALLROOT { bin fun include lib } directories are
1103                 linked to the same directories in the package root. Only
1104                 one architecture may be flat. Leaf directory names matching
1105                 the |-separated shell pattern \$MAKESKIP are ignored. The
1106                 view action is done before making. OPTION operands are
1107                 passed to the underlying make command.
1108         read [ package ... | archive ... ]
1109                 Read the named package archive(s). Must be run from the
1110                 package root directory. Archives are searched for in .
1111                 and lib/package/tgz. Each package is read only once. The
1112                 file lib/package/tgz/package[.type].tim tracks the read time.
1113                 See the write action for archive naming conventions. Text
1114                 file archive member are assumed to be ASCII or UTF-8 encoded.
1115         regress diff(1) the current and previous package test results.
1116         release [ [CC]YY-MM-DD [ [cc]yy-mm-dd ] ] [ package ]
1117                 Display recent changes since [CC]YY-MM-DD (up to [cc]yy-mm-dd),
1118                 where - means lowest (or highest.) If no dates are specified
1119                 then changes for the last 4 months are listed. PACKAGE may
1120                 be a package or component name.
1121         remove PACKAGE
1122                 Remove files installed for PACKAGE.
1123         results [ path ] [ old ] [ make | test ]
1124                 List results and interesting messages captured by the most
1125                 recent make (default), test or write action. old specifies the
1126                 previous results, if any (current and previous 9 results are
1127                 retained.) $HOME/.pkgresults, if it exists, must contain an
1128                 egrep(1) expression of result lines to be ignored. failed lists
1129                 failures only and path lists the results file path only.
1130         setup [ beta ] [ binary ] [ source ] [ ARCHITECTURE ... ] [ URL ] [ PACKAGE ... ]
1131                 The action initializes the current directory as a package root,
1132                 runs the update action to download new or out of date packages,
1133                 and runs the read action on those packages. If \"flat\" is
1134                 specified then the \$INSTALLROOT { bin fun include lib }
1135                 directories are linked to the same directories in the package
1136                 root. Only one architecture may be flat. See the update and
1137                 read actions for argument details.
1138         test [ PACKAGE ]
1139                 Run the regression tests for PACKAGE. If the standard output
1140                 is a terminal then the output is also captured in
1141                 \$INSTALLROOT/lib/package/gen/test.out. In general a package
1142                 must be made before it can be tested. Components tested with
1143                 the \bregress\b(1) command require \bksh93\b. If only is
1144                 also specified then only the listed package components are
1145                 tested, otherwise the closure of the components is tested.
1146         update [ beta ] [ binary ] [ source ] [ ARCHITECTURE ... ] [ URL ] [ PACKAGE ... ]
1147                 Download the latest release of the selected and required
1148                 packages from URL (e.g.,
1149                 http://www.research.att.com/sw/download) into the directory
1150                 \$PACKAGEROOT/lib/package/tgz. beta acesses beta packages;
1151                 download these at your own risk. If ARCHITECTURE is omitted
1152                 then only architectures already present in the tgz directory
1153                 will be downloaded. If ARCHITECTURE is - then all posted
1154                 architectures will be downloaded. If URL matches *.url then
1155                 it is interpreted as a file containing shell variable
1156                 assignments for url, authorize and password. If URL is
1157                 omitted then the definitions for url, authorize and password
1158                 in \$PACKAGEROOT/lib/package/tgz/$default_url, if it exists,
1159                 are used. If \$PACKAGEROOT/lib/package/tgz/$default_url does
1160                 not exist then it is initialized with the current url,
1161                 authorize and password values and read permission for the
1162                 current user only. If PACKAGE is omitted then only
1163                 packages already present in the tgz directory will be
1164                 downloaded. If PACKAGE is - then all posted packages will be
1165                 downloaded. If source and binary are omitted then both source
1166                 and binary packages will be downloaded. If \bonly\b is
1167                 specified then only the named packages are updated; otherwise
1168                 the closure of required packages is updated. This action
1169                 requires wget(1), lynx(1), curl(1) or a shell that supports
1170                 io to /dev/tcp/HOST/PORT.
1171         use [ uid | PACKAGE | . [ 32 | 64 ] | 32 | 64 | - ] [ COMMAND ... ]
1172                 Run COMMAND or an interactive shell if COMMAND is omitted, with
1173                 the environment initialized for using the package (can you say
1174                 shared library without cussing?) If uid or PACKAGE or . is
1175                 specified then it is used to determine a \$PACKAGEROOT,
1176                 possibly different from the current directory. For example, to
1177                 try out bozo's package: \"package use bozo\". In this case the
1178                 command may be run from any directory. If the file
1179                 \$INSTALLROOT/lib/package/profile is readable then it is
1180                 sourced to initialize the environment. 32 or 64 implies
1181                 \$PACKAGEROOT of . and specifies the target architecture word
1182                 size (which may be silently ignored.)
1183         verify [ PACKAGE ]
1184                 Verify installed binary files against the checksum files in
1185                 \$INSTALLROOT/lib/package/gen/*.sum. The checksum files contain
1186                 mode, user and group information. If the checksum matches
1187                 for a given file then the mode, user and group are changed
1188                 as necessary to match the checksum entry. A warning is printed
1189                 on the standard error for each mismatch. Requires the ast
1190                 package cksum(1) command.
1191         view
1192                 Initialize the architecture specific viewpath hierarchy. The
1193                 make action implicitly calls this action. If \"flat\" is specified
1194                 then the \$INSTALLROOT { bin fun include lib } directories are
1195                 linked to the same directories in the package root. Only one
1196                 architecture may be flat.
1197         write [closure] [cyg|exp|lcl|pkg|rpm|tgz|tst] [base|delta]
1198                         [binary|runtime|source] PACKAGE
1199                 Write a package archive for PACKAGE. All work is done in the
1200                 \$PACKAGEROOT/lib/package directory. FORMAT-specific files
1201                 are placed in the FORMAT subdirectory. A PACKAGE[.TYPE].tim
1202                 file in this directory tracksthe write time and prevents a
1203                 package from being read in the same root it was written. If
1204                 more than one file is generated for a particular FORMAT then
1205                 those files are placed in the FORMAT/PACKAGE subdirectory.
1206                 File names in the FORMAT subdirectory will contain the package
1207                 name, a YYYY-MM-DD date, and for binary packages, HOSTTYPE.
1208                 If PACKAGE is omitted then an ordered list of previously
1209                 written packages is generated. If \"only\" is specified then
1210                 only the named packages will be written; otherwise
1211                 prerequisite packages are written first. Package components
1212                 must be listed in PACKAGE.pkg. FORMAT may be one of:
1213                    cyg  generate a cygwin package
1214                    exp  generate an exptools(1) maintainer source archive
1215                         and NPD file in the exp subdirectory, suitable for
1216                         expmake(1); support files are placed in the
1217                         exp/PACKAGE subdirectory
1218                    lcl  generate a package archive or delta in the lcl
1219                         subdirectory, suitable for restoration into the
1220                         primary source tree (no source licence annotation)
1221                    pkg  generate a pkgmk(1) package, suitable for pkgadd(1)
1222                    rpm  generate an rpm(1) package
1223                    tgz  generate a gzip(1) tar(1) package archive; this is
1224                         the default
1225                    tst  generate tgz FORMAT package archive in the tst
1226                         subdirectory; version state files are not updated
1227                 The package type must be one of source, binary or runtime.
1228                 A source package contains the source needed to build the
1229                 corresponding binary package. A binary package includes the
1230                 libraries and headers needed for compiling and linking
1231                 against the public interfaces. A runtime package contains
1232                 the commands and required dynamic libraries.  A package may
1233                 be either a base or delta. A base package contains a
1234                 complete copy of all components.  A delta package contains
1235                 only changes from a previous base package. Delta recipients
1236                 must have the ast pax(1) command (in the ast-base package.)
1237                 If neither base nor delta is specified, then the current
1238                 base is overwritten if there are no deltas referring to the
1239                 current base. Only the tgz and lcl formats support delta.
1240                 If base is specified then a new base and two delta archives
1241                 are generated: one delta to generate the new base from the
1242                 old, and one delta to generate the old base from the new;
1243                 the old base is then removed. If delta is specified then a
1244                 new delta referring to the current base is written.
1245                 package.pkg may reference other packages. By default a
1246                 pointer to those packages is written. The recipient package
1247                 read will then check that all required packages have been
1248                 downloaded. If closure is specified then the components for
1249                 all package references are included in the generated
1250                 package.  This may be useful for lcl and versioning.  All
1251                 formats but lcl annotate each source file (not already
1252                 annotated) with a license comment as it is written to the
1253                 package archive using proto(1).
1254    name=value:
1255         variable definition: typically CC=cc or CCFLAGS=-g."
1256                         ;;
1257                 esac
1258                 exit $code
1259                 ;;
1260         *=*)    set DEFAULT host type "$@"
1261                 ;;
1262         *)      echo "Usage: $command [ options ] [ qualifier ... ] [ action ] [ arg ... ] [ n=v ... ]" >&2
1263                 exit 2
1264                 ;;
1265         esac
1266         global="$global $1"
1267         shift
1268 done
1270 # gather HOSTTYPE *,* options
1271 #       ,*cc*,-*,...    set CC and CCFLAGS
1273 hostopts()
1275         _ifs_=$IFS
1276         IFS=,
1277         set '' $HOSTTYPE
1278         IFS=$_ifs_
1279         shift
1280         while   :
1281         do      case $# in
1282                 0|1)    break ;;
1283                 esac
1284                 shift
1285                 case $1 in
1286                 *cc*)   CC=$1
1287                         while   :
1288                         do      case $# in
1289                                 0|1)    break ;;
1290                                 esac
1291                                 case $2 in
1292                                 -*)     case $assign_CCFLAGS in
1293                                         ?*)     assign_CCFLAGS="$assign_CCFLAGS " ;;
1294                                         esac
1295                                         assign_CCFLAGS="$assign_CCFLAGS$2"
1296                                         shift
1297                                         ;;
1298                                 *)      break
1299                                         ;;
1300                                 esac
1301                         done
1302                         ;;
1303                 esac
1304         done
1307 # collect command line targets and definitions
1309 case $_PACKAGE_HOSTTYPE_ in
1310 ?*)     HOSTTYPE=$_PACKAGE_HOSTTYPE_
1311         KEEP_HOSTTYPE=1
1312         ;;
1313 *)      KEEP_HOSTTYPE=0
1314         ;;
1315 esac
1316 KEEP_PACKAGEROOT=0
1317 KEEP_SHELL=0
1318 USER_VPATH=
1319 args=
1320 assign=
1321 assign_CCFLAGS=
1322 for i
1323 do      case $i in
1324         *:*=*)  args="$args $i"
1325                 continue
1326                 ;;
1327         *=*)    eval `echo ' ' "$i" | sed 's,^[         ]*\([^=]*\)=\(.*\),n=\1 v='\''\2'\'','`
1328                 ;;
1329         esac
1330         case $i in
1331         AR=*|LD=*|NM=*)
1332                 assign="$assign $n='$v'"
1333                 eval $n='$'v
1334                 ;;
1335         CC=*)   eval $n='$'v
1336                 ;;
1337         CCFLAGS=*)
1338                 eval $n='$'v
1339                 assign_CCFLAGS="CCFLAGS=\"\$CCFLAGS\""
1340                 ;;
1341         HOSTTYPE=*)
1342                 eval $n='$'v
1343                 case $HOSTTYPE in
1344                 ?*)     KEEP_HOSTTYPE=1 ;;
1345                 esac
1346                 ;;
1347         HURL=*) eval $n='$'v
1348                 ;;
1349         PACKAGEROOT=*)
1350                 eval $n='$'v
1351                 case $PACKAGEROOT in
1352                 ?*)     KEEP_PACKAGEROOT=1 ;;
1353                 esac
1354                 ;;
1355         SHELL=*)eval $n='$'v
1356                 case $SHELL in
1357                 ?*)     KEEP_SHELL=1 ;;
1358                 esac
1359                 ;;
1360         TAR=*)  eval $n='$'v
1361                 ;;
1362         TARFLAGS=*)
1363                 eval $n='$'v
1364                 ;;
1365         VPATH=*)eval USER_$n='$'v
1366                 ;;
1367         'debug=1')
1368                 makeflags="$makeflags --debug-symbols"
1369                 ;;
1370         'strip=1')
1371                 makeflags="$makeflags --strip-symbols"
1372                 ;;
1373         *=*)    assign="$assign $n='$v'"
1374                 ;;
1375         *)      args="$args $i"
1376                 ;;
1377         esac
1378 done
1379 case $HOSTTYPE in
1380 *,*)    hostopts $HOSTTYPE ;;
1381 esac
1382 case $assign_CCFLAGS in
1383 ?*)     assign="$assign $assign_CCFLAGS"
1384 esac
1385 case $CC in
1386 ''|cc)  ;;
1387 *)      export CC ;;
1388 esac
1390 # grab action specific args
1392 case $action in
1393 admin)  while   :
1394         do      case $# in
1395                 0)      set list
1396                         break
1397                         ;;
1398                 esac
1399                 case $1 in
1400                 all)    admin_all=1
1401                         ;;
1402                 db)     case $# in
1403                         1)      echo $command: $action: $1: db file argument expected >&2
1404                                 exit 1
1405                                 ;;
1406                         esac
1407                         shift
1408                         admin_db=$1
1409                         ;;
1410                 on)     case $# in
1411                         1)      echo $command: $action: $1: host pattern argument expected >&2
1412                                 exit 1
1413                                 ;;
1414                         esac
1415                         shift
1416                         admin_on=$1
1417                         ;;
1418                 *)      break
1419                         ;;
1420                 esac
1421                 shift
1422         done
1423         admin_action=$1
1424         admin_args=$*
1425         for i
1426         do      case $i in
1427                 debug|environment|force|never|only|quiet|show|DEBUG)
1428                         ;;
1429                 *)      admin_action=$i
1430                         break
1431                         ;;
1432                 esac
1433         done
1434         ;;
1435 setup)  PACKAGEROOT=${PWD:-`pwd`}
1436         export PACKAGEROOT
1437         KEEP_PACKAGEROOT=1
1438         ;;
1439 use)    case $1 in
1440         .|32|64)case $1 in
1441                 32|64)  bit=$1 ;;
1442                 esac
1443                 shift
1445                 # HOSTTYPE specific setup
1447                 case $HOSTTYPE in
1448                 win32.*)sys=uwin
1449                         wow=`uname -i`
1450                         case $bit in
1451                         32)     case $HOSTTYPE in
1452                                 *-64)   HOSTTYPE=${HOSTTYPE%-64} ;;
1453                                 esac
1454                                 case $wow in
1455                                 */32)   ;;
1456                                 *)      vpath / /$bit ;;
1457                                 esac
1458                                 ;;
1459                         64)     case $HOSTTYPE in
1460                                 *-64)   ;;
1461                                 *)      HOSTTYPE=$HOSTTYPE-64 ;;
1462                                 esac
1463                                 case $wow in
1464                                 */32)   echo $command: cannot build $bit-bit on $wow $sys >&2; exit 2 ;;
1465                                 *)      vpath / /$bit ;;
1466                                 esac
1467                                 ;;
1468                         esac
1469                         case $bit in
1470                         '')     PS1="($sys) " ;;
1471                         *)      PS1="($sys-$bit) " ;;
1472                         esac
1474                         $exec umask 002
1475                         $exec unset MAKESKIP
1477                         $exec export P=$PWD
1478                         $exec export A=$P/arch/$HOSTTYPE
1480                         $exec export CDPATH=:..:$A/src/cmd:$A/src/lib:$A/src/uwin:$P/lib/package
1481                         $exec export INSTALLROOT=$A
1482                         $exec export PACKAGEROOT=$P
1483                         $exec export PATH=$A/bin:$P/bin:$PATH
1484                         $exec export PS1="$PS1"
1485                         $exec export VPATH=$A:$P
1486                         $exec export nativepp=/usr/lib
1488                         if      test '' != "$INSTALLROOT" -a -d $INSTALLROOT/include/ast
1489                         then    $exec export PACKAGE_ast=$INSTALLROOT
1490                         elif    test -d ${PWD%/*}/ast/arch/$HOSTTYPE
1491                         then    $exec export PACKAGE_ast=${PWD%/*}/ast/arch/$HOSTTYPE
1492                         fi
1494                         # run the command
1496                         case $# in
1497                         0)      case $show in
1498                                 ':')    $exec exec $SHELL ;;
1499                                 esac
1500                                 ;;
1501                         *)      $exec exec $SHELL -c "$@"
1502                                 ;;
1503                         esac
1504                         exit
1505                         ;;
1506                 esac
1507                 PACKAGEROOT=${PWD:-`pwd`}
1508                 $show export PACKAGEROOT
1509         esac
1510         ;;
1511 esac
1513 # true if arg is a valid PACKAGEROOT
1515 packageroot() # dir
1517         test -d $1/lib/$command -o -x $1/bin/$command
1520 # true if arg is executable
1522 executable() # [!] command
1524         case $1 in
1525         '!')    test ! -x "$2" -a ! -x "$2.exe"; return ;;
1526         *)      test -x "$1" -o -x "$1.exe"; return ;;
1527         esac
1530 # initialize SHELLMAGIC
1531 # tangible proof of cygwin's disdain for unix (well, this and execrate)
1533 shellmagic()
1535         case $SHELLMAGIC in
1536         '')     ;;
1537         -)      if      test -f /emx/bin/sh.exe
1538                 then    SHELLMAGIC='#!/emx/bin/sh.exe'$nl
1539                 elif    test -f /bin/env.exe
1540                 then    SHELLMAGIC='#!/bin/env sh'$nl
1541                 else    SHELLMAGIC=
1542                 fi
1543                 ;;
1544         esac
1547 # true if arg is executable command on $PATH
1549 onpath() # command
1551         _onpath_b=$1
1552         case $_onpath_b in
1553         /*)     if      executable $_onpath_b
1554                 then    _onpath_=$_onpath_b
1555                         return 0
1556                 fi
1557                 return 1
1558                 ;;
1559         esac
1560         IFS=':'
1561         set '' $PATH
1562         IFS=$ifs
1563         shift
1564         for _onpath_d
1565         do      case $_onpath_d in
1566                 '')     _onpath_d=. ;;
1567                 esac
1568                 if      executable "$_onpath_d/$_onpath_b"
1569                 then    _onpath_=$_onpath_d/$_onpath_b
1570                         return 0
1571                 fi
1572         done
1573         return 1
1576 # true if no nmake or nmake not from AT&T or nmake too old
1578 nonmake() # nmake
1580         _nonmake_version=`( $1 -n -f - 'print $(MAKEVERSION:@/.*AT&T.* //:/-//G:@/.* .*/19960101/)' . ) </dev/null 2>/dev/null || echo 19840919`
1581         if      test $_nonmake_version -lt 20001031
1582         then    return 0
1583         fi
1584         return 1
1587 # determine local host attributes
1589 hostinfo() # attribute ...
1591         case $DEBUG in
1592         1)      set -x ;;
1593         esac
1594         map=
1595         something=
1596         path=$PATH
1597         for i in $ccs
1598         do      PATH=$PATH:$i
1599         done
1600         for i in $use
1601         do      for j in $org
1602                 do      PATH=$PATH:$i/$j/bin
1603                 done
1604                 PATH=$PATH:$i/bin
1605         done
1606         # LD_LIBRARY_PATH may be out of sync with PATH here
1607         case $SED in
1608         '')     SED=sed
1609                 $SED 1d < /dev/null > /dev/null 2>&1 ||
1610                 for dir in /bin /usr/bin
1611                 do      if      test -x $dir/$SED
1612                         then    SED=$dir/$SED
1613                                 break
1614                         fi
1615                 done
1616                 TR=tr
1617                 $TR < /dev/null > /dev/null 2>&1 ||
1618                 for dir in /bin /usr/bin
1619                 do      if      test -x $dir/$TR
1620                         then    TR=$dir/$TR
1621                                 break
1622                         fi
1623                 done
1624                 ;;
1625         esac
1626         case $PACKAGE_PATH in
1627         ?*)     for i in `echo $PACKAGE_PATH | $SED 's,:, ,g'`
1628                 do      PATH=$PATH:$i/bin
1629                 done
1630                 ;;
1631         esac
1633         # validate the args
1635         canon=
1636         cc=$CC
1637         for info
1638         do      case $canon in
1639                 -)      canon=$info
1640                         ;;
1641                 *)      case $info in
1642                         */*|*[cC][cC])
1643                                 cc=$info
1644                                 ;;
1645                         canon)  canon=-
1646                                 something=1
1647                                 ;;
1648                         cpu|name|rating|type)
1649                                 something=1
1650                                 ;;
1651                         *)      echo "$command: $action: $info: unknown attribute" >&2
1652                                 exit 1
1653                                 ;;
1654                         esac
1655                         ;;
1656                 esac
1657         done
1658         case $canon in
1659         -)      echo "$command: $action: canon: host type name expected" >&2
1660                 exit 1
1661                 ;;
1662         esac
1663         case $something in
1664         "")     set "$@" type ;;
1665         esac
1666         case $DEBUG in
1667         '')     exec 9>&2
1668                 exec 2>/dev/null
1669                 ;;
1670         esac
1672         # compute the info
1674         _hostinfo_=
1675         for info
1676         do
1677         case $info in
1678         cpu)    case $NPROC in
1679                 [123456789]*)
1680                         _hostinfo_="$_hostinfo_ $NPROC"
1681                         continue
1682                         ;;
1683                 esac
1684                 cpu=`grep -ic '^processor[      ][      ]*:[    ]*[0123456789]' /proc/cpuinfo`
1685                 case $cpu in
1686                 [123456789]*)
1687                         _hostinfo_="$_hostinfo_ $cpu"
1688                         continue
1689                         ;;
1690                 esac
1691                 cpu=1
1692                 # exact match
1693                 set                                                     \
1694                         hinv                    '^Processor [0123456789]'       \
1695                         psrinfo                 'on-line'               \
1696                         'cat /reg/LOCAL_MACHINE/Hardware/Description/System/CentralProcessor'                                   '.'                     \
1697                         'cat /proc/registry/HKEY_LOCAL_MACHINE/Hardware/Description/System/CentralProcessor'                    '.'                     \
1699                 while   :
1700                 do      case $# in
1701                         0)      break ;;
1702                         esac
1703                         i=`$1 2>/dev/null | grep -c "$2"`
1704                         case $i in
1705                         [123456789]*)
1706                                 cpu=$i
1707                                 break
1708                                 ;;
1709                         esac
1710                         shift;shift
1711                 done
1712                 case $cpu in
1713                 0|1)    set                                             \
1714                         /bin/mpstat
1716                         while   :
1717                         do      case $# in
1718                                 0)      break ;;
1719                                 esac
1720                                 if      executable $1
1721                                 then    case `$1 | grep -ic '^cpu '` in
1722                                         1)      cpu=`$1 | grep -ic '^ *[0123456789][0123456789]* '`
1723                                                 break
1724                                                 ;;
1725                                         esac
1726                                 fi
1727                                 shift
1728                         done
1729                         ;;
1730                 esac
1731                 case $cpu in
1732                 0|1)    # token match
1733                         set                                             \
1734                         /usr/kvm/mpstat                 'cpu[0123456789]'       \
1735                         /usr/etc/cpustatus              'enable'        \
1736                         /usr/alliant/showsched          'CE'            \
1737                         'ls /config/hw/system/cpu'      'cpu'           \
1738                         prtconf                         'cpu-unit'      \
1740                         while   :
1741                         do      case $# in
1742                                 0)      break ;;
1743                                 esac
1744                                 i=`$1 2>/dev/null | $TR '       ' '
1746 ' | grep -c "^$2"`
1747                                 case $i in
1748                                 [123456789]*)
1749                                         cpu=$i
1750                                         break
1751                                         ;;
1752                                 esac
1753                                 shift;shift
1754                         done
1755                         ;;
1756                 esac
1757                 case $cpu in
1758                 0|1)    # special match
1759                         set                                             \
1760                                                                         \
1761                         hinv                                            \
1762                         '/^[0123456789][0123456789]* .* Processors*$/'          \
1763                         '/[     ].*//'                                  \
1764                                                                         \
1765                         /usr/bin/hostinfo                               \
1766                         '/^[0123456789][0123456789]* .* physically available\.*$/'      \
1767                         '/[     ].*//'                                  \
1769                         while   :
1770                         do      case $# in
1771                                 0)      break ;;
1772                                 esac
1773                                 i=`$1 2>/dev/null | $SED -e "${2}!d" -e "s${3}"`
1774                                 case $i in
1775                                 [123456789]*)
1776                                         cpu=$i
1777                                         break
1778                                         ;;
1779                                 esac
1780                                 shift;shift;shift
1781                         done
1782                         ;;
1783                 esac
1784                 case $cpu in
1785                 0|1)    cpu=`(
1786                         cd ${TMPDIR:-/tmp}
1787                         tmp=hi$pid
1788                         trap 'rm -f $tmp.*' 0 1 2
1789                         cat > $tmp.c <<!
1790 #include <stdio.h>
1791 #include <pthread.h>
1792 int main()
1794         printf("%d\n", pthread_num_processors_np());
1795         return 0;
1798                         for o in -lpthread ''
1799                         do      if      $CC $o -O -o $tmp.exe $tmp.c $o >/dev/null 2>&1 ||
1800                                         gcc $o -O -o $tmp.exe $tmp.c $o >/dev/null 2>&1
1801                                 then    ./$tmp.exe
1802                                         break
1803                                 fi
1804                         done
1805                         )`
1806                         case $cpu in
1807                         [0123456789]*)  ;;
1808                         *)      cpu=1 ;;
1809                         esac
1810                         ;;
1811                 esac
1812                 _hostinfo_="$_hostinfo_ $cpu"
1813                 ;;
1814         name)   _name_=`hostname || uname -n || cat /etc/whoami || echo local`
1815                 _hostinfo_="$_hostinfo_ $_name_"
1816                 ;;
1817         rating) for rating in `grep -i ^bogomips /proc/cpuinfo 2>/dev/null | $SED -e 's,.*:[    ]*,,' -e 's,\(...*\)\..*,\1,' -e 's,\(\..\).*,\1,'`
1818                 do      case $rating in
1819                         [0123456789]*)  break ;;
1820                         esac
1821                 done
1822                 case $rating in
1823                 [0123456789]*)  ;;
1824                 *)      cd ${TMPDIR:-/tmp}
1825                         tmp=hi$pid
1826                         trap 'rm -f $tmp.*' 0 1 2
1827                         cat > $tmp.c <<!
1828 #include <stdio.h>
1829 #include <sys/types.h>
1830 #if TD || TZ
1831 #include <sys/time.h>
1832 #else
1833 extern time_t   time();
1834 #endif
1835 int main()
1837         register unsigned long  i;
1838         register unsigned long  j;
1839         register unsigned long  k;
1840         unsigned long           l;
1841         unsigned long           m;
1842         unsigned long           t;
1843         int                     x;
1844 #if TD || TZ
1845         struct timeval          b;
1846         struct timeval          e;
1847 #if TZ
1848         struct timezone         z;
1849 #endif
1850 #endif
1851         l = 500;
1852         m = 890;
1853         x = 0;
1854         for (;;)
1855         {
1856 #if TD || TZ
1857 #if TZ
1858                 gettimeofday(&b, &z);
1859 #else
1860                 gettimeofday(&b);
1861 #endif
1862 #else
1863                 t = (unsigned long)time((time_t*)0);
1864 #endif
1865                 k = 0;
1866                 for (i = 0; i < l; i++)
1867                         for (j = 0; j < 50000; j++)
1868                                 k += j;
1869 #if TD || TZ
1870 #if TZ
1871                 gettimeofday(&e, &z);
1872 #else
1873                 gettimeofday(&e);
1874 #endif
1875                 t = (e.tv_sec - b.tv_sec) * 1000 + (e.tv_usec - b.tv_usec) / 1000;
1876                 if (!x++ && t < 1000)
1877                 {
1878                         t = 10000 / t;
1879                         l = (l * t) / 10;
1880                         continue;
1881                 }
1882 #else
1883                 t = ((unsigned long)time((time_t*)0) - t) * 1000;
1884                 if (!x++ && t < 20000)
1885                 {
1886                         t = 200000l / t;
1887                         l = (l * t) / 10;
1888                         continue;
1889                 }
1890 #endif
1891 #if PR
1892                 printf("[ k=%lu l=%lu m=%lu t=%lu ] ", k, l, m, t);
1893 #endif
1894                 if (t == 0)
1895                         t = 1;
1896                 break;
1897         }
1898         printf("%lu\n", ((l * m) / 10) / t);
1899         return k == 0;
1902                         rating=
1903                         for o in -DTZ -DTD ''
1904                         do      if      $CC $o -O -o $tmp.exe $tmp.c >/dev/null 2>&1 ||
1905                                         gcc $o -O -o $tmp.exe $tmp.c >/dev/null 2>&1
1906                                 then    rating=`./$tmp.exe`
1907                                         break
1908                                 fi
1909                         done
1910                         case $rating in
1911                         [0123456789]*)  ;;
1912                         *)      rating=1 ;;
1913                         esac
1914                         ;;
1915                 esac
1916                 _hostinfo_="$_hostinfo_ $rating"
1917                 ;;
1918         type|canon)
1919                 case $CROSS:$canon in
1920                 0:)     case $cc in
1921                         cc)     case $KEEP_HOSTTYPE:$HOSTTYPE in
1922                                 0:?*)   if      test -d ${PACKAGEROOT:-.}/arch/$HOSTTYPE
1923                                         then    KEEP_HOSTTYPE=1
1924                                         fi
1925                                         ;;
1926                                 esac
1927                                 ;;
1928                         esac
1929                         case $KEEP_HOSTTYPE in
1930                         1)      _hostinfo_="$_hostinfo_ $HOSTTYPE"
1931                                 continue
1932                                 ;;
1933                         esac
1934                         ;;
1935                 esac
1936                 case $cc in
1937                 /*)     a=`$cc -dumpmachine $CCFLAGS 2>/dev/null`
1938                         case $a in
1939                         '')     case $CCFLAGS in
1940                                 ?*)     a=`$cc -dumpmachine 2>/dev/null` ;;
1941                                 esac
1942                                 ;;
1943                         esac
1944                         case $a in
1945                         ''|*' '*|*/*:*)
1946                                 ;;
1947                         *.*-*)  _hostinfo_="$_hostinfo_ $a"
1948                                 continue
1949                                 ;;
1950                         *-*-*)  case $canon in
1951                                 '')     canon=$a ;;
1952                                 esac
1953                                 ;;
1954                         *)      _hostinfo_="$_hostinfo_ $a"
1955                                 continue
1956                                 ;;
1957                         esac
1958                         ;;
1959                 esac
1960                 IFS=:
1961                 set /$IFS$PATH
1962                 IFS=$ifs
1963                 shift
1964                 f=../lib/hostinfo/typemap
1965                 for i
1966                 do      case $i in
1967                         "")     i=. ;;
1968                         esac
1969                         case $canon in
1970                         '')     case $cc in
1971                                 /*|cc)  ;;
1972                                 *)      if      executable $i/$cc
1973                                         then    a=`$i/$cc -dumpmachine $CCFLAGS 2>/dev/null`
1974                                                 case $a in
1975                                                 '')     case $CCFLAGS in
1976                                                         ?*)     a=`$cc -dumpmachine 2>/dev/null` ;;
1977                                                         esac
1978                                                         ;;
1979                                                 esac
1980                                                 case $a in
1981                                                 ''|*' '*|*/*:*)
1982                                                         ;;
1983                                                 *-*)    canon=$a
1984                                                         ;;
1985                                                 *)      _hostinfo_="$_hostinfo_ $a"
1986                                                         continue 2
1987                                                         ;;
1988                                                 esac
1989                                         fi
1990                                         ;;
1991                                 esac
1992                                 ;;
1993                         esac
1994                         if      test -f "$i/$f"
1995                         then    map="`grep -v '^#' $i/$f` $map"
1996                         fi
1997                 done
1999                 # inconsistent -dumpmachine filtered here
2001                 case -${canon}- in
2002                 --|*-powerpc-*)
2003                         h=`hostname || uname -n || cat /etc/whoami`
2004                         case $h in
2005                         '')     h=local ;;
2006                         esac
2007                         a=`arch || uname -m || att uname -m || uname -s || att uname -s`
2008                         case $a in
2009                         *[\ \   ]*)     a=`echo $a | $SED "s/[  ]/-/g"` ;;
2010                         esac
2011                         case $a in
2012                         '')     a=unknown ;;
2013                         esac
2014                         m=`mach || machine || uname -p || att uname -p`
2015                         case $m in
2016                         *[\ \   ]*)     m=`echo $m | $SED "s/[  ]/-/g"` ;;
2017                         esac
2018                         case $m in
2019                         '')     m=unknown ;;
2020                         esac
2021                         x=`uname -a || att uname -a`
2022                         case $x in
2023                         '')     x="unknown $host unknown unknown unknown unknown unknown" ;;
2024                         esac
2025                         set "" $h $a $m $x
2026                         expected=$1 host=$2 arch=$3 mach=$4 os=$5 sys=$6 rel=$7 ver=$8
2027                         ;;
2028                 *)      case $canon in
2029                         *-*)    IFS=-
2030                                 set "" $canon
2031                                 shift
2032                                 IFS=$ifs
2033                                 case $# in
2034                                 2)      host= mach= arch=$1 os=$2 sys= rel= ;;
2035                                 *)      host= mach=$2 arch=$1 os=$3 sys= rel= ;;
2036                                 esac
2037                                 case $os in
2038                                 [abcdefghijklmnopqrstuvwxyz]*[0123456789])
2039                                         eval `echo $os | $SED -e 's/^\([^0123456789.]*\)\.*\(.*\)/os=\1 rel=\2/'`
2040                                         ;;
2041                                 esac
2042                                 ;;
2043                         *)      arch=$canon mach= os= sys= rel=
2044                                 ;;
2045                         esac
2046                         ;;
2047                 esac
2048                 type=unknown
2049                 case $host in
2050                 *.*)    host=`echo $host | $SED -e 's/\..*//'` ;;
2051                 esac
2052                 case $mach in
2053                 unknown)
2054                         mach=
2055                         ;;
2056                 [Rr][0123][0123456789][0123456789][0123456789])
2057                         mach=mips1
2058                         ;;
2059                 [Rr][4][0123456789][0123456789][0123456789])
2060                         mach=mips2
2061                         ;;
2062                 [Rr][56789][0123456789][0123456789][0123456789]|[Rr][123456789][0123456789][0123456789][0123456789][0123456789])
2063                         mach=mips4
2064                         ;;
2065                 pc)     arch=i386
2066                         mach=
2067                         ;;
2068                 [Pp][Oo][Ww][Ee][Rr][Pp][Cc])
2069                         arch=ppc
2070                         mach=
2071                         ;;
2072                 *)      case $arch in
2073                         34[0123456789][0123456789])
2074                                 os=ncr
2075                                 arch=i386
2076                                 ;;
2077                         esac
2078                         ;;
2079                 esac
2080                 case $canon in
2081                 '')     set                                             \
2082                                                                         \
2083                         /NextDeveloper          -d      next    -       \
2084                         /config/hw/system/cpu   -d      tandem  mach    \
2086                         while   :
2087                         do      case $# in
2088                                 0)      break ;;
2089                                 esac
2090                                 if      test $2 $1
2091                                 then    os=$3
2092                                         case $4 in
2093                                         arch)   mach=$arch ;;
2094                                         mach)   arch=$mach ;;
2095                                         esac
2096                                         break
2097                                 fi
2098                                 shift;shift;shift;shift
2099                         done
2100                         ;;
2101                 esac
2102                 case $os in
2103                 AIX*|aix*)
2104                         type=ibm.risc
2105                         ;;
2106                 HP-UX)  case $arch in
2107                         9000/[78]*)
2108                                 type=hp.pa
2109                                 ;;
2110                         */*)    type=hp.`echo $arch | $SED 's,/,_,g'`
2111                                 ;;
2112                         *)      type=hp.$arch
2113                                 ;;
2114                         esac
2115                         ;;
2116                 [Ii][Rr][Ii][Xx]*)
2117                         set xx `hinv | $SED -e '/^CPU:/!d' -e 's/CPU:[  ]*\([^  ]*\)[   ]*\([^  ]*\).*/\1 \2/' -e q | $TR ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
2118                         shift
2119                         type=$1
2120                         n=
2121                         case $2 in
2122                         r[0123][0123456789][0123456789][0123456789])
2123                                 n=1
2124                                 ;;
2125                         r[4][0123][0123456789][0123456789])
2126                                 n=2
2127                                 ;;
2128                         r[4][456789][0123456789][0123456789]|r[5][0123456789][0123456789][0123456789])
2129                                 n=3
2130                                 ;;
2131                         r[6789][0123456789][0123456789][0123456789]|r[123456789][0123456789][0123456789][0123456789][0123456789])
2132                                 n=4
2133                                 ;;
2134                         esac
2135                         case $rel in
2136                         [01234].*|5.[012]|5.[012].*)
2137                                 case $n in
2138                                 1)      ;;
2139                                 *)      n=2 ;;
2140                                 esac
2141                                 ;;
2142                         5.*)    case $n in
2143                                 2)      n=3 ;;
2144                                 esac
2145                                 ;;
2146                         esac
2147                         if      executable $cc
2148                         then    a=$cc
2149                         else    IFS=:
2150                                 set /$IFS$PATH
2151                                 IFS=$ifs
2152                                 shift
2153                                 for i
2154                                 do      a=$i/$cc
2155                                         if      executable $a
2156                                         then    break
2157                                         fi
2158                                 done
2159                         fi
2160                         split='
2162                         a=`strings $a < /dev/null | $SED -e 's/[^abcdefghijklmnopqrstuvwxyz0123456789]/ /g' -e 's/[     ][      ]*/\'"$split"'/g' | $SED -e "/^${type}[0123456789]$/!d" -e "s/^${type}//" -e q`
2163                         case $a in
2164                         [0123456789])   n=$a ;;
2165                         esac
2166                         case $n in
2167                         4)      a=`$cc -${type}3 2>&1`
2168                                 case $a in
2169                                 *unknown*|*install*|*conflict*)
2170                                         ;;
2171                                 *)      n=3
2172                                         ;;
2173                                 esac
2174                                 ;;
2175                         esac
2176                         a=`$cc -show F0oB@r.c 2>&1`
2177                         case $n:$a in
2178                         [!2]:*mips2*)   n=2 ;;
2179                         [!23]:*mips3*)  n=3 ;;
2180                         [!234]:*mips4*) n=4 ;;
2181                         esac
2182                         case $n:$a in
2183                         [!2]:*[Oo]32*)  abi=-o32 ;;
2184                         [!3]:*[Nn]32*)  abi=-n32 ;;
2185                         esac
2186                         mach=${type}$n
2187                         type=sgi.$mach
2188                         ;;
2189                 OSx*|SMP*|pyramid)
2190                         type=pyr
2191                         ;;
2192                 OS/390) type=mvs.390
2193                         ;;
2194                 [Ss][Cc][Oo]*)
2195                         type=sco
2196                         ;;
2197                 [Ss]ol*)
2198                         v=`echo $rel | $SED -e 's/^[25]\.//' -e 's/\.[^.]*$//'`
2199                         case $v in
2200                         [6789]|[1-9][0-9])
2201                                 ;;
2202                         *)      v=
2203                                 ;;
2204                         esac
2205                         case $arch in
2206                         '')     case $mach in
2207                                 '')     arch=sun4 ;;
2208                                 *)      arch=$mach ;;
2209                                 esac
2210                                 ;;
2211                         esac
2212                         case $arch in
2213                         sparc)  arch=sun4 ;;
2214                         esac
2215                         type=sol$v.$arch
2216                         ;;
2217                 [Ss]un*)type=`echo $arch | $SED -e 's/\(sun.\).*/\1/'`
2218                         case $type in
2219                         sparc)  type=sun4 ;;
2220                         esac
2221                         case $rel in
2222                         [01234]*)
2223                                 ;;
2224                         '')     case $os in
2225                                 *[Oo][Ss])
2226                                         ;;
2227                                 *)      type=sol.$type
2228                                         ;;
2229                                 esac
2230                                 ;;
2231                         *)      case $type in
2232                                 '')     case $mach in
2233                                         sparc*) type=sun4 ;;
2234                                         *)      type=$mach ;;
2235                                         esac
2236                                         ;;
2237                                 esac
2238                                 v=`echo $rel | $SED -e 's/^[25]\.//' -e 's/\.[^.]*$//'`
2239                                 case $v in
2240                                 [6789]|[1-9][0-9])
2241                                         ;;
2242                                 *)      v=
2243                                         ;;
2244                                 esac
2245                                 type=sol$v.$type
2246                                 ;;
2247                         esac
2248                         case $type in
2249                         sun*|*.*)
2250                                 ;;
2251                         *)      type=sun.$type
2252                                 ;;
2253                         esac
2254                         ;;
2255                 [Uu][Nn][Ii][Xx]_[Ss][Vv])
2256                         type=unixware
2257                         ;;
2258                 UTS*|uts*)
2259                         if      test -x /bin/u370 -o -x /bin/u390
2260                         then    type=uts.390
2261                         else    case $arch in
2262                                 '')     arch=$mach ;;
2263                                 esac
2264                                 type=uts.$arch
2265                         fi
2266                         ;;
2267                 $host)  type=$arch
2268                         case $type in
2269                         *.*|*[0123456789]*86|*68*)
2270                                 ;;
2271                         *)      case $mach in
2272                                 *[0123456789]*86|*68*|mips)
2273                                         type=$type.$mach
2274                                         ;;
2275                                 esac
2276                                 ;;
2277                         esac
2278                         ;;
2279                 unknown)
2280                         case $arch in
2281                         ?*)     case $arch in
2282                                 sun*)   mach= ;;
2283                                 esac
2284                                 type=$arch
2285                                 case $mach in
2286                                 ?*)     type=$type.$mach ;;
2287                                 esac
2288                                 ;;
2289                         esac
2290                         ;;
2291                 *)      case $ver in
2292                         FTX*|ftx*)
2293                                 case $mach in
2294                                 *[0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*)
2295                                         mach=`echo $mach | $SED -e 's/[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*$//'`
2296                                         ;;
2297                                 esac
2298                                 type=stratus.$mach
2299                                 ;;
2300                         *)      case $arch in
2301                                 [Oo][Ss][-/.]2)
2302                                         type=os2
2303                                         arch=$rel
2304                                         ;;
2305                                 *)      type=`echo $os | $SED -e 's/[0123456789].*//' -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789.].*//'`
2306                                         ;;
2307                                 esac
2308                                 case $type in
2309                                 [Cc][Yy][Gg][Ww][Ii][Nn]_*)
2310                                         type=cygwin
2311                                         ;;
2312                                 [Uu][Ww][Ii][Nn]*|[Ww]indows_[0123456789][0123456789]|[Ww]indows_[Nn][Tt])
2313                                         type=win32
2314                                         arch=`echo $arch | $SED -e 's/_[^_]*$//'`
2315                                         ;;
2316                                 esac
2317                                 case $arch in
2318                                 '')     case $mach in
2319                                         ?*)     type=$type.$mach ;;
2320                                         esac
2321                                         ;;
2322                                 *)      type=$type.$arch ;;
2323                                 esac
2324                                 ;;
2325                         esac
2326                 esac
2327                 case $type in
2328                 [0123456789]*)
2329                         case $mach in
2330                         ?*)     type=$mach ;;
2331                         esac
2332                         case $type in
2333                         */MC)   type=ncr.$type ;;
2334                         esac
2335                         ;;
2336                 *.*)    ;;
2337                 *[0123456789]*86|*68*)
2338                         case $rel in
2339                         [34].[0123456789]*)
2340                                 type=att.$type
2341                                 ;;
2342                         esac
2343                         ;;
2344                 [abcdefghijklmnopqrstuvwxyz]*[0123456789])
2345                         ;;
2346                 [abcdefghijklmnopqrstuvwxyz]*)  case $mach in
2347                         $type)  case $ver in
2348                                 Fault*|fault*|FAULT*)
2349                                         type=ft.$type
2350                                         ;;
2351                                 esac
2352                                 ;;
2353                         ?*)     case $arch in
2354                                 '')     type=$type.$mach ;;
2355                                 *)      type=$type.$arch ;;
2356                                 esac
2357                                 ;;
2358                         esac
2359                         ;;
2360                 esac
2361                 case $type in
2362                 *[-_]32|*[-_]64|*[-_]128)
2363                         bits=`echo $type | $SED 's,.*[-_],,'`
2364                         type=`echo $type | $SED 's,[-_][0-9]*$,,'`
2365                         ;;
2366                 *)      bits=
2367                         ;;
2368                 esac
2369                 type=`echo $type | $SED -e 's%[-+/].*%%' | $TR ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
2370                 case $type in
2371                 *.*)    lhs=`echo $type | $SED -e 's/\..*//'`
2372                         rhs=`echo $type | $SED -e 's/.*\.//'`
2373                         case $rhs in
2374                         [x0123456789]*86)       rhs=i$rhs ;;
2375                         68*)                    rhs=m$rhs ;;
2376                         esac
2377                         case $rhs in
2378                         i[x23456789]86|i?[x23456789]86|*86pc)
2379                                                 rhs=i386 ;;
2380                         powerpc)                rhs=ppc ;;
2381                         s[0123456789]*[0123456789]x)
2382                                                 rhs=`echo $rhs | $SED -e 's/x$/-64/'` ;;
2383                         esac
2384                         case $rhs in
2385                         arm[abcdefghijklmnopqrstuvwxyz_][0123456789]*)
2386                                                 rhs=arm ;;
2387                         hppa)                   rhs=pa ;;
2388                         esac
2389                         case $lhs in
2390                         ?*coff|?*dwarf|?*elf)
2391                                 case $lhs in
2392                                 ?*coff) x=coff ;;
2393                                 ?*dwarf)x=coff ;;
2394                                 ?*elf)  x=elf ;;
2395                                 esac
2396                                 lhs=`echo ${lhs}XXX | $SED -e "s/${x}XXX//"`
2397                                 ;;
2398                         esac
2399                         case $lhs in
2400                         bsdi)                   lhs=bsd ;;
2401                         darwin)                 case $rel in
2402                                                 [01234567].*)   lhs=${lhs}7 ;;
2403                                                 esac
2404                                                 ;;
2405                         freebsd)                case $rel in
2406                                                 [01234].*)      lhs=${lhs}4 ;;
2407                                                 [123456789]*.*) lhs=${lhs}`echo $rel | $SED -e 's/\..*//'` ;;
2408                                                 esac
2409                                                 ;;
2410                         hpux)                   lhs=hp ;;
2411                         mvs)                    rhs=390 ;;
2412                         esac
2413                         case $lhs in
2414                         '')                     type=$rhs ;;
2415                         $rhs)                   type=$lhs ;;
2416                         *)                      type=$lhs.$rhs ;;
2417                         esac
2418                         ;;
2419                 esac
2420                 case $type in
2421                 sgi.mips*)
2422                         case $mach in
2423                         mips2)  type=sgi.$mach
2424                                 abi=-o32
2425                                 ;;
2426                         mips3)  type=sgi.$mach
2427                                 abi=-n32
2428                                 ;;
2429                         mips[456789])
2430                                 type=sgi.$mach
2431                                 case $abi in
2432                                 *-n32) ;;
2433                                 *) abi=-64 ;;
2434                                 esac
2435                                 ;;
2436                         *)      pwd=`pwd`
2437                                 cd ${TMPDIR:-/tmp}
2438                                 tmp=hi$pid
2439                                 trap 'rm -f $tmp.*' 0 1 2
2440                                 cat > $tmp.a.c <<!
2441 extern int b();
2442 int main() { return b(); }
2444                                 cat > $tmp.b.c <<!
2445 int b() { return 0; }
2447                                 abi=
2448                                 if      $cc -c $tmp.a.c
2449                                 then    for i in -n32 -o32 -64
2450                                         do      if      $cc $i -c $tmp.b.c &&
2451                                                         $cc -o $tmp.exe $tmp.a.o $tmp.b.o
2452                                                 then    abi=$i
2453                                                         for i in 2 3 4 5 6 7 8 9
2454                                                         do      case $i:$abi in
2455                                                                 2:-n32|2:-64|3:-64)
2456                                                                         continue
2457                                                                         ;;
2458                                                                 esac
2459                                                                 if      $cc $abi -mips$i -c $tmp.b.c &&
2460                                                                         $cc -o $tmp.exe $tmp.a.o $tmp.b.o
2461                                                                 then    type=`echo $type | $SED -e 's/.$//'`$i
2462                                                                         break
2463                                                                 fi
2464                                                         done
2465                                                         break
2466                                                 fi
2467                                         done
2468                                 fi </dev/null >/dev/null 2>&1
2469                                 rm -f $tmp.*
2470                                 trap - 0 1 2
2471                                 cd $pwd
2472                                 ;;
2473                         esac
2474                         case $type$abi in
2475                         sgi.mips2-o32)
2476                                 ;;
2477                         sgi.mips3)
2478                                 type=$type-o32
2479                                 ;;
2480                         sgi.mips3-n32)
2481                                 ;;
2482                         sgi.mips4)
2483                                 type=$type-o32
2484                                 ;;
2485                         sgi.mips[456789]-64)
2486                                 ;;
2487                         *)      type=$type$abi
2488                                 ;;
2489                         esac
2490                         ;;
2491                 *)      case $bits in
2492                         '')     case `file /bin/sh 2>/dev/null` in
2493                                 *universal*64*)
2494                                         pwd=`pwd`
2495                                         cd ${TMPDIR:-/tmp}
2496                                         tmp=hi$pid
2497                                         trap 'rm -f $tmp.*' 0 1 2
2498                                         cat > $tmp.a.c <<!
2499 int main() { return 0; }
2501                                         if      $cc -o $tmp.a.exe $tmp.a.c
2502                                         then    case `file $tmp.a.exe` in
2503                                                 *64*)   bits=64 ;;
2504                                                 esac
2505                                         fi </dev/null >/dev/null 2>&1
2506                                         rm -f $tmp.*
2507                                         trap - 0 1 2
2508                                         cd $pwd
2509                                         ;;
2510                                 esac
2511                                 ;;
2512                         esac
2513                         ;;
2514                 esac
2515                 case $bits in
2516                 32)     case $CC-$CCFLAGS in
2517                         *-m64*) case $type in
2518                                 *.i386) bits=32 ;;
2519                                 esac
2520                                 ;;
2521                         *)      case $type in
2522                                 *.i386) bits= ;;
2523                                 esac
2524                                 ;;
2525                         esac
2526                         ;;
2527                 64)     case $CC-$CCFLAGS in
2528                         *-m32*) case $type in
2529                                 *.i386) bits= ;;
2530                                 esac
2531                                 ;;
2532                         esac
2533                         ;;
2534                 esac
2535                 case $bits in
2536                 ?*)     type=$type-$bits ;;
2537                 esac
2539                 # last chance mapping
2541                 set "" "" $map
2542                 while   :
2543                 do      case $# in
2544                         [012])  break ;;
2545                         esac
2546                         shift;shift
2547                         eval "  case \$type in
2548                                 $1)     type=\$2; break ;;
2549                                 esac"
2550                 done
2551                 _hostinfo_="$_hostinfo_ $type"
2552                 ;;
2553         esac
2554         done
2555         set '' $_hostinfo_
2556         shift
2557         _hostinfo_=$*
2559         # restore the global state
2561         PATH=$path
2562         case $DEBUG in
2563         '')     exec 2>&9
2564                 exec 9>&-
2565                 ;;
2566         esac
2569 # info message
2571 note() # message ...
2573         echo $command: "$@" >&2
2576 # cc checks
2578 #       CC: compiler base name name
2579 #       cc: full path, empty if not found
2581 checkcc()
2583         cc=
2584         if      onpath $CC
2585         then    cc=$_onpath_
2586         else    case $CC in
2587                 cc)     if      onpath gcc
2588                         then    CC=gcc
2589                                 cc=$_onpath_
2590                         fi
2591                         ;;
2592                 esac
2593         fi
2594         case $cc in
2595         '')     case $action in
2596                 make|test)      note "$CC: not found"; exit 1 ;;
2597                 *)              note "warning: $CC: not found" ;;
2598                 esac
2599                 ;;
2600         esac
2603 # some actions have their own PACKAGEROOT or kick out early
2605 case $action in
2606 host)   eval u=$package_use
2607         case $u in
2608         $PACKAGE_USE)
2609                 ;;
2610         *)      if      onpath $0
2611                 then    case $_onpath_ in
2612                         */arch/$HOSTTYPE/bin/package)
2613                                 KEEP_HOSTTYPE=1
2614                                 ;;
2615                         *)      KEEP_HOSTTYPE=0
2616                                 ;;
2617                         esac
2618                 else    KEEP_HOSTTYPE=0
2619                 fi
2620                 ;;
2621         esac
2622         hostinfo $args
2623         echo $_hostinfo_
2624         exit 0
2625         ;;
2626 export|setup|use)
2627         x=
2628         ;;
2629 *)      x=
2630         eval u=$package_use
2631         case $u in
2632         $PACKAGE_USE)
2633                 case :$PATH: in
2634                 *:$INSTALLROOT/bin:*)
2635                         case $LIBPATH: in
2636                         $INSTALLROOT/bin:$INSTALLROOT/lib:*)
2637                                 case $SHLIB_PATH: in
2638                                 $INSTALLROOT/lib:*)
2639                                         x=1
2640                                         ;;
2641                                 esac
2642                                 ;;
2643                         esac
2644                         ;;
2645                 esac
2646                 ;;
2647         esac
2648         ;;
2649 esac
2650 run=-
2651 case $x in
2652 1)      : accept the current package use environment
2654         KSH=$EXECROOT/bin/ksh
2655         MAKE=nmake
2656         NMAKE=$EXECROOT/bin/$MAKE
2657         SUM=$EXECROOT/bin/sum
2658         TEE=$EXECROOT/bin/tee
2659         INITROOT=$PACKAGEROOT/src/cmd/INIT
2660         checkcc
2661         ;;
2662 *)      hosttype=
2663         case $KEEP_PACKAGEROOT in
2664         0)      case $action in
2665                 use)    PACKAGEROOT=
2666                         case $show in
2667                         echo)   exec=echo make=echo show=echo ;;
2668                         esac
2669                         set '' $args
2670                         shift
2671                         case $# in
2672                         0)      ;;
2673                         *)      case $1 in
2674                                 -|.)    ;;
2675                                 /*)     PACKAGEROOT=$1
2676                                         ;;
2677                                 *)      i=`echo ~$1`
2678                                         if      packageroot $i
2679                                         then    PACKAGEROOT=$i
2680                                         else    for i in `echo $HOME | sed -e 's,/[^/]*$,,'` $usr $use
2681                                                 do      if      packageroot $i/$1
2682                                                         then    PACKAGEROOT=$i/$1
2683                                                                 break
2684                                                         fi
2685                                                 done
2686                                                 case $PACKAGEROOT in
2687                                                 '')     hosttype=$1 ;;
2688                                                 esac
2689                                         fi
2690                                         ;;
2691                                 esac
2692                                 shift
2693                                 ;;
2694                         esac
2695                         run="$@"
2696                         ;;
2697                 esac
2698                 case $PACKAGEROOT in
2699                 '')     PACKAGEROOT=${PWD:-`pwd`} ;;
2700                 esac
2702                 # . must be within the PACKAGEROOT tree
2704                 i=X$PACKAGEROOT
2705                 IFS=/
2706                 set $i
2707                 IFS=$ifs
2708                 while   :
2709                 do      i=$1
2710                         shift
2711                         case $i in
2712                         X)      break ;;
2713                         esac
2714                 done
2715                 case $PACKAGEROOT in
2716                 //*)    d=/ ;;
2717                 *)      d= ;;
2718                 esac
2719                 case $1 in
2720                 home)   k=1 ;;
2721                 *)      k=0 ;;
2722                 esac
2723                 for i
2724                 do      case $i in
2725                         '')     continue ;;
2726                         esac
2727                         d=$d/$i
2728                         case $k in
2729                         2)      k=1
2730                                 ;;
2731                         1)      k=0
2732                                 ;;
2733                         0)      case $i in
2734                                 arch)   k=2
2735                                         ;;
2736                                 *)      if      packageroot $d
2737                                         then    PACKAGEROOT=$d
2738                                         fi
2739                                         ;;
2740                                 esac
2741                                 ;;
2742                         esac
2743                 done
2744                 ;;
2745         esac
2746         INITROOT=$PACKAGEROOT/src/cmd/INIT
2747         $show PACKAGEROOT=$PACKAGEROOT
2748         $show export PACKAGEROOT
2749         export PACKAGEROOT
2751         # initialize the architecture environment
2753         case $KEEP_HOSTTYPE in
2754         0)      hostinfo type
2755                 HOSTTYPE=$_hostinfo_
2756                 ;;
2757         1)      _PACKAGE_HOSTTYPE_=$HOSTTYPE
2758                 export _PACKAGE_HOSTTYPE_
2759                 ;;
2760         esac
2761         $show HOSTTYPE=$HOSTTYPE
2762         $show export HOSTTYPE
2763         export HOSTTYPE
2764         INSTALLROOT=$PACKAGEROOT/arch/$HOSTTYPE
2765         case $action in
2766         admin|install|make|read|remove|test|verify|view|write)
2767                 ;;
2768         *)      if      test ! -d $INSTALLROOT
2769                 then    INSTALLROOT=$PACKAGEROOT
2770                 fi
2771                 ;;
2772         esac
2773         $show INSTALLROOT=$INSTALLROOT
2774         $show export INSTALLROOT
2775         export INSTALLROOT
2777         # check the basic package hierarchy
2779         case $action in
2780         export|use)
2781                 packageroot $PACKAGEROOT || {
2782                         echo "$command: $PACKAGEROOT: invalid package root directory" >&2
2783                         exit 1
2784                 }
2785                 case $KEEP_HOSTTYPE:$hosttype in
2786                 0:?*)   if      test -d ${PACKAGEROOT:-.}/arch/$hosttype
2787                         then    KEEP_HOSTTYPE=1
2788                                 HOSTTYPE=$hosttype
2789                         else    echo "$command: $hosttype: package root not found" >&2
2790                                 exit 1
2791                         fi
2792                         ;;
2793                 esac
2794                 ;;
2795         *)      packageroot $PACKAGEROOT || {
2796                         case $KEEP_PACKAGEROOT in
2797                         1)      ;;
2798                         *)      echo "$command: $PACKAGEROOT: must be in the package root directory tree" >&2
2799                                 exit 1
2800                                 ;;
2801                         esac
2802                 }
2804                 case $action in
2805                 admin)  ;;
2806                 *)      for i in arch arch/$HOSTTYPE
2807                         do      test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
2808                         done
2809                         for i in lib
2810                         do      test -d $INSTALLROOT/$i || $exec mkdir $INSTALLROOT/$i || exit
2811                         done
2812                         ;;
2813                 esac
2815                 # no $INITROOT means INIT already installed elsewhere
2817                 if      test -d $INITROOT
2818                 then
2819                         # update the basic package commands
2821                         for i in execrate ignore mamprobe silent
2822                         do      test -h $PACKAGEROOT/bin/$i 2>/dev/null ||
2823                                 case `ls -t $INITROOT/$i.sh $PACKAGEROOT/bin/$i 2>/dev/null` in
2824                                 "$INITROOT/$i.sh"*)
2825                                         note update $PACKAGEROOT/bin/$i
2826                                         shellmagic
2827                                         case $SHELLMAGIC in
2828                                         '')     $exec cp $INITROOT/$i.sh $PACKAGEROOT/bin/$i || exit
2829                                                 ;;
2830                                         *)      case $exec in
2831                                                 '')     {
2832                                                         echo "$SHELLMAGIC"
2833                                                         cat $INITROOT/$i.sh
2834                                                         } > $PACKAGEROOT/bin/$i || exit
2835                                                         ;;
2836                                                 *)      echo "{
2837 echo \"$SHELLMAGIC\"
2838 cat $INITROOT/$i.sh
2839 } > $PACKAGEROOT/bin/$i"
2840                                                         ;;
2841                                                 esac
2842                                                 ;;
2843                                         esac
2844                                         $exec chmod +x $PACKAGEROOT/bin/$i || exit
2845                                         ;;
2846                                 esac
2847                         done
2848                 fi
2849                 ;;
2850         esac
2851         path=$PATH
2852         PATH=$INSTALLROOT/bin:$PACKAGEROOT/bin:$PATH
2853         checkcc
2854         PATH=$path
2855         case $cc in
2856         ?*)     if      test -f $INITROOT/hello.c
2857                 then
2858                         # check if $CC (full path $cc) is a cross compiler
2860                         (
2861                                 cd /tmp || exit 3
2862                                 trap "rm -f pkg$pid.*" 0 1 2
2863                                 cp $INITROOT/hello.c pkg$pid.c || exit 3
2864                                 $cc -o pkg$pid.exe pkg$pid.c > pkg$pid.e 2>&1 || {
2865                                         if      $cc -Dnew=old -o pkg$pid.exe pkg$pid.c > /dev/null 2>&1
2866                                         then    echo "$command: ${warn}$CC: must be a C compiler (not C++)" >&2
2867                                         else    cat pkg$pid.e
2868                                                 echo "$command: ${warn}$CC: failed to compile and link $INITROOT/hello.c -- is it a C compiler?" >&2
2869                                         fi
2870                                         exit 2
2871                                 }
2872                                 if      ./pkg$pid.exe >/dev/null 2>&1
2873                                 then    code=0
2874                                 else    code=1
2875                                 fi
2876                                 exit $code
2877                         )
2878                         code=$?
2879                         case $code in
2880                         1)      CROSS=1 ;;
2881                         esac
2882                 fi
2883                 ;;
2884         esac
2885         EXECTYPE=$HOSTTYPE
2886         EXECROOT=$INSTALLROOT
2887         case $CROSS in
2888         0)      # dll hackery -- why is this so complicated?
2890                 abi=
2891                 case $HOSTTYPE in
2892                 sgi.mips[0123456789]*)
2893                         x=rld
2894                         if      executable /lib32/$x || executable /lib64/$x
2895                         then    case $INSTALLROOT in
2896                                 */sgi.mips[0123456789]*)
2897                                         u=`echo $INSTALLROOT | sed -e 's,-[^-/]*$,,' -e 's,.$,,'`
2898                                         ;;
2899                                 *)      u=
2900                                         ;;
2901                                 esac
2902                                 for a in "n=2 v= l=" "n=3 v=N32 l=lib32" "n=4-n32 v=N32 l=lib32" "n=4 v=64 l=lib64"
2903                                 do      eval $a
2904                                         case $v in
2905                                         N32)    case $n:$HOSTTYPE in
2906                                                 *-n32:*-n32)    ;;
2907                                                 *-n32:*)        continue ;;
2908                                                 *:*-n32)        continue ;;
2909                                                 esac
2910                                                 ;;
2911                                         esac
2912                                         case $l in
2913                                         ?*)     if      executable ! /$l/$x
2914                                                 then    continue
2915                                                 fi
2916                                                 ;;
2917                                         esac
2918                                         case $u in
2919                                         '')     case $HOSTTYPE in
2920                                                 sgi.mips$n|sgi.mips$n-*)
2921                                                         abi="$abi 'd=$INSTALLROOT v=$v'"
2922                                                         ;;
2923                                                 *)      continue
2924                                                         ;;
2925                                                 esac
2926                                                 ;;
2927                                         *)      if      test -d $u$n
2928                                                 then    abi="$abi 'd=$u$n v=$v'"
2929                                                 fi
2930                                                 ;;
2931                                         esac
2932                                 done
2933                         fi
2934                         ;;
2935                 esac
2936                 case $abi in
2937                 '')     abi="'d=$INSTALLROOT v='" ;;
2938                 esac
2939                 p=0
2940                 eval "
2941                         for a in $abi
2942                         do      eval \$a
2943                                 eval \"
2944                                         case \\\$LD_LIBRARY\${v}_PATH: in
2945                                         \\\$d/lib:*)
2946                                                 ;;
2947                                         *)      x=\\\$LD_LIBRARY\${v}_PATH
2948                                                 case \\\$x in
2949                                                 ''|:*)  ;;
2950                                                 *)      x=:\\\$x ;;
2951                                                 esac
2952                                                 LD_LIBRARY\${v}_PATH=\$d/lib\\\$x
2953                                                 export LD_LIBRARY\${v}_PATH
2954                                                 p=1
2955                                                 ;;
2956                                         esac
2957                                 \"
2958                         done
2959                 "
2960                 case $LD_LIBRARY_PATH in
2961                 '')     ;;
2962                 *)      for d in $lib
2963                         do      case $HOSTTYPE in
2964                                 *64)    if      test -d ${d}64
2965                                         then    d=${d}64
2966                                         fi
2967                                         ;;
2968                                 esac
2969                                 case :$LD_LIBRARY_PATH: in
2970                                 *:$d:*) ;;
2971                                 *)      if      test -d $d
2972                                         then    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$d
2973                                                 p=1
2974                                         fi
2975                                         ;;
2976                                 esac
2977                         done
2978                         ;;
2979                 esac
2980                 case $p in
2981                 1)      $show LD_LIBRARY_PATH=$LD_LIBRARY_PATH
2982                         $show export LD_LIBRARY_PATH
2983                         export LD_LIBRARY_PATH
2984                         ;;
2985                 esac
2986                 case $LIBPATH: in
2987                 $INSTALLROOT/bin:$INSTALLROOT/lib:*)
2988                         ;;
2989                 *)      case $LIBPATH in
2990                         '')     LIBPATH=/usr/lib:/lib ;;
2991                         esac
2992                         LIBPATH=$INSTALLROOT/bin:$INSTALLROOT/lib:$LIBPATH
2993                         $show LIBPATH=$LIBPATH
2994                         $show export LIBPATH
2995                         export LIBPATH
2996                         ;;
2997                 esac
2998                 case $SHLIB_PATH: in
2999                 $INSTALLROOT/lib:*)
3000                         ;;
3001                 *)      SHLIB_PATH=$INSTALLROOT/lib${SHLIB_PATH:+:$SHLIB_PATH}
3002                         $show SHLIB_PATH=$SHLIB_PATH
3003                         $show export SHLIB_PATH
3004                         export SHLIB_PATH
3005                         ;;
3006                 esac
3007                 case $DYLD_LIBRARY_PATH: in
3008                 $INSTALLROOT/lib:*)
3009                         ;;
3010                 *)      DYLD_LIBRARY_PATH=$INSTALLROOT/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
3011                         $show DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
3012                         $show export DYLD_LIBRARY_PATH
3013                         export DYLD_LIBRARY_PATH
3014                         ;;
3015                 esac
3016                 case $_RLD_ROOT in
3017                 $INSTALLROOT/arch*)     ;;
3018                 ':')    _RLD_ROOT=$INSTALLROOT/arch:/ ;;
3019                 /|*:/)  _RLD_ROOT=$INSTALLROOT/arch:$_RLD_ROOT ;;
3020                 *)      _RLD_ROOT=$INSTALLROOT/arch:$_RLD_ROOT:/ ;;
3021                 esac
3022                 $show _RLD_ROOT=$_RLD_ROOT
3023                 $show export _RLD_ROOT
3024                 export _RLD_ROOT
3026                 # now set up PATH
3027                 #
3028                 # NOTE: PACKAGEROOT==INSTALLROOT is possible for binary installations
3030                 case $PATH: in
3031                 $PACKAGEROOT/bin:*)
3032                         ;;
3033                 *)      PATH=$PACKAGEROOT/bin:$PATH
3034                         ;;
3035                 esac
3036                 case $PATH: in
3037                 $INSTALLROOT/bin:*)
3038                         ;;
3039                 *)      PATH=$INSTALLROOT/bin:$PATH
3040                         ;;
3041                 esac
3042                 $show PATH=$PATH
3043                 $show export PATH
3044                 export PATH
3045                 ;;
3046         *)      for i in package proto nmake
3047                 do      if      onpath $i
3048                         then    EXECROOT=`echo $_onpath_ | sed -e 's,//*[^/]*//*[^/]*$,,'`
3049                                 EXECTYPE=`echo $EXECROOT | sed -e 's,.*/,,'`
3050                                 break
3051                         fi
3052                 done
3053                 case $HOSTTYPE in
3054                 $EXECTYPE)
3055                         OCC=$CC
3056                         CC=cc
3057                         hostinfo type
3058                         EXECTYPE=$_hostinfo_
3059                         case $HOSTTYPE in
3060                         $EXECTYPE)
3061                                 echo "$command: $CC: seems to be a cross-compiler" >&2
3062                                 echo "$command: set HOSTTYPE to something other than the native $EXECTYPE" >&2
3063                                 exit 1
3064                                 ;;
3065                         esac
3066                         ;;
3067                 esac
3068                 $show EXECTYPE=$EXECTYPE
3069                 $show export EXECTYPE
3070                 export EXECTYPE
3071                 ;;
3072         esac
3073         $show EXECROOT=$EXECROOT
3074         $show export EXECROOT
3075         export EXECROOT
3077         # use these if possible
3079         KSH=$EXECROOT/bin/ksh
3080         MAKE=nmake
3081         NMAKE=$EXECROOT/bin/$MAKE
3082         SUM=$EXECROOT/bin/sum
3083         TEE=$EXECROOT/bin/tee
3085         # grab a decent default shell
3087         case $KEEP_SHELL in
3088         0)      executable "$SHELL" || SHELL=
3089                 case $SHELL in
3090                 ?*)     checksh $SHELL || SHELL= ;;
3091                 esac
3092                 case $SHELL in
3093                 ''|/bin/*|/usr/bin/*)
3094                         case $SHELL in
3095                         '')     SHELL=/bin/sh ;;
3096                         esac
3097                         for i in ksh sh bash
3098                         do      if      onpath $i && checksh $_onpath_
3099                                 then    SHELL=$_onpath_
3100                                         break
3101                                 fi
3102                         done
3103                         ;;
3104                 */*ksh) if      executable $KSH
3105                         then    SHELL=$KSH
3106                         fi
3107                         ;;
3108                 esac
3109                 ;;
3110         esac
3112         # $SHELL must be /bin/sh compatible
3114         case $SHELL in
3115         /bin/sh);;
3116         '')     SHELL=/bin/sh
3117                 ;;
3118         *)      $SHELL -c 'trap "exit 0" 0; exit 1' 2>/dev/null
3119                 case $? in
3120                 1)      SHELL=/bin/sh
3121                         ;;
3122                 *)      # catch (our own) pipe/socket configuration mismatches
3123                         $SHELL -c "date | $SHELL -c 'read x'"
3124                         case $? in
3125                         0)      ;;
3126                         *)      SHELL=/bin/sh ;;
3127                         esac
3128                         ;;
3129                 esac
3130                 ;;
3131         esac
3132         export SHELL
3133         $show SHELL=$SHELL
3134         $show export SHELL
3135         COSHELL=$SHELL
3136         export COSHELL
3137         $show COSHELL=$COSHELL
3138         $show export COSHELL
3140         # tame the environment
3142         case $action in
3143         use)    ;;
3144         *)      ENV=
3145                 ERROR_OPTIONS=
3146                 export ENV ERROR_OPTIONS
3147                 ;;
3148         esac
3150         # finalize the views
3152         case $USER_VPATH in
3153         '')     case $VPATH in
3154                 ?*)     IFS=':'
3155                         set '' $VPATH
3156                         shift
3157                         IFS=$ifs
3158                         USER_VPATH=
3159                         for i
3160                         do      case $i in
3161                                 */arch/$HOSTTYPE)       ;;
3162                                 */arch/*/*)             ;;
3163                                 */arch/*)               continue ;;
3164                                 esac
3165                                 if      packageroot $i
3166                                 then    case $USER_VPATH in
3167                                         '')     USER_VPATH=$i ;;
3168                                         ?*)     USER_VPATH=$USER_VPATH:$i ;;
3169                                         esac
3170                                 fi
3171                         done
3172                 esac
3173                 ;;
3174         esac
3175         case $USER_VPATH in
3176         ?*)     IFS=':'
3177                 set '' $USER_VPATH
3178                 shift
3179                 IFS=$ifs
3180                 USER_VPATH=
3181                 USER_VPATH_CHAIN=
3182                 p=$PACKAGEROOT
3183                 for i
3184                 do      case $i in
3185                         ''|$PACKAGEROOT|$INSTALLROOT)
3186                                 ;;
3187                         ?*)     USER_VPATH=$USER_VPATH:$i
3188                                 USER_VPATH_CHAIN="$USER_VPATH_CHAIN $p $i"
3189                                 p=$i
3190                                 case $PROTOROOT in
3191                                 -)      executable $i/bin/mamake && PROTOROOT= ;;
3192                                 esac
3193                                 ;;
3194                         esac
3195                 done
3196                 ;;
3197         esac
3198         ;;
3199 esac
3201 PACKAGESRC=$PACKAGEROOT/lib/package
3202 PACKAGEBIN=$INSTALLROOT/lib/package
3203 case $action:$run in
3204 use:-)  set '' $args
3205         shift
3206         case $# in
3207         0)      ;;
3208         *)      shift ;;
3209         esac
3210         run="$@"
3211         ;;
3212 esac
3214 # HOSTTYPE specific package profile
3216 if      test -r $INSTALLROOT/lib/package/profile
3217 then    . $INSTALLROOT/lib/package/profile
3220 # more cygwin hassles
3222 case $HOSTTYPE in
3223 cygwin.*)
3224         lose=
3225         case $CYGWIN in
3226         *nontsec*)
3227                 lose=ntsec
3228                 ;;
3229         *ntsec*);;
3230         *)      exe=/tmp/pkg$pid.exe
3231                 rm -f $exe
3232                 : > $exe
3233                 if      test -x $exe
3234                 then    lose=ntsec
3235                 fi
3236                 ;;
3237         esac
3238         case $CYGWIN in
3239         *nobinmode*)
3240                 case $lose in
3241                 '')     lose=binmode ;;
3242                 *)      lose="$lose binmode" ;;
3243                 esac
3244                 ;;
3245         esac
3246         case $lose in
3247         ?*)     echo "$command: $HOSTTYPE: export '$lose' in CYGWIN or languish in windows" >&2
3248                 exit 1
3249                 ;;
3250         esac
3251         ;;
3252 esac
3254 # set up the view state
3256 VIEW_bin=$INSTALLROOT VIEW_src=$PACKAGEROOT VIEW_all="$INSTALLROOT $PACKAGEROOT"
3257 if      (vpath $INSTALLROOT $PACKAGEROOT $USER_VPATH_CHAIN) >/dev/null 2>&1 &&
3258          vpath $INSTALLROOT $PACKAGEROOT $USER_VPATH_CHAIN
3259 then    $show vpath $INSTALLROOT $PACKAGEROOT $USER_VPATH_CHAIN
3260 else    VPATH=$INSTALLROOT:$PACKAGEROOT$USER_VPATH
3261         $show VPATH=$VPATH
3262         $show export VPATH
3263         export VPATH
3264         IFS=':'
3265         set '' $VPATH
3266         shift
3267         IFS=$ifs
3268         for i
3269         do      case $i in
3270                 */arch/*/*)
3271                         VIEW_src="$VIEW_src $i"
3272                         ;;
3273                 */arch/*)
3274                         VIEW_bin="$VIEW_bin $i"
3275                         ;;
3276                 *)
3277                         VIEW_src="$VIEW_src $i"
3278                         ;;
3279                 esac
3280                 VIEW_all="$VIEW_all $i"
3281         done
3284 # return 0 if arg in src|bin|all view
3286 view() # [test] [-|type] [src|bin|all] file
3288         case $1 in
3289         -[dfsx])_view_T_=$1; shift ;;
3290         *)      _view_T_=-f ;;
3291         esac
3292         case $1 in
3293         -)      _view_t_= ;;
3294         *)      _view_t_=$1 ;;
3295         esac
3296         shift
3297         case $1 in
3298         all)    shift; _view_v_=$VIEW_all ;;
3299         bin)    shift; _view_v_=$VIEW_bin ;;
3300         src)    shift; _view_v_=$VIEW_src ;;
3301         *)      _view_v_=$VIEW_all ;;
3302         esac
3303         case $1 in
3304         /*)     if      test $_view_T_ $1
3305                 then    _view_=$1
3306                         return 0
3307                 fi
3308                 ;;
3309         *)      for _view_d_ in $_view_v_
3310                 do      if      test $_view_T_ $_view_d_/$1
3311                         then    _view_=$_view_d_/$1
3312                                 return 0
3313                         fi
3314                 done
3315                 ;;
3316         esac
3317         _view_=
3318         case $_view_t_ in
3319         ?*)     echo $command: $1: $_view_t_ not found >&2 ;;
3320         esac
3321         return 1
3324 # determine the package and targets
3326 case $action in
3327 admin)  case $admin_action in
3328         results)action=$admin_action
3329                 set '' $admin_args
3330                 shift;shift
3331                 admin_args="admin $*"
3332                 case $admin_on in
3333                 '')     target=$admin_args ;;
3334                 *)      target="on $admin_on $admin_args" ;;
3335                 esac
3336                 ;;
3337         esac
3338         ;;
3339 release)set '' $args
3340         target=
3341         while   :
3342         do      shift
3343                 case $1 in
3344                 -|[0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789])
3345                         target="$target $1"
3346                         ;;
3347                 *)      break
3348                         ;;
3349                 esac
3350         done
3351         package=$*
3352         ;;
3353 setup)  # { update read } with optional (bin|fun|include|lib) symlinks
3354         # flat option sets up { bin fun include lib } symlinks from
3355         # $INSTALLROOT to $PACKAGEROOT
3357         # . is the package root
3359         set '' $args
3360         shift
3361         types=
3362         url=
3363         while   :
3364         do      case $# in
3365                 0)      break ;;
3366                 esac
3367                 case $1 in
3368                 --)     shift
3369                         break
3370                         ;;
3371                 flat)   flat=1 # backwards compatibility -- documentation dropped
3372                         ;;
3373                 *://*|*.url)
3374                         url=$1
3375                         shift
3376                         break
3377                         ;;
3378                 *)      types="$types $1"
3379                         ;;
3380                 esac
3381                 shift
3382         done
3383         if      test ! -d $PACKAGEROOT/lib/package/tgz
3384         then    $exec mkdir -p $PACKAGEROOT/lib/package/tgz || exit
3385         fi
3386         case " $types " in
3387         *" source "*)
3388                 case " $* " in
3389                 '  ')   ;;
3390                 *" INIT "*)
3391                         ;;
3392                 *)      view - all src/cmd/INIT ||
3393                         set INIT "$@"
3394                         ;;
3395                 esac
3396                 ;;
3397         esac
3398         packages=`$0 $global authorize "$authorize" password "$password" update setup $types $url "$@" PACKAGEROOT=$PACKAGEROOT`
3399         case $packages in
3400         ?*)     $0 $global read $packages PACKAGEROOT=$PACKAGEROOT
3401         esac
3402         exit
3403         ;;
3404 *)      package=
3405         target=
3406         set '' $args
3407         while   :
3408         do      shift
3409                 case $# in
3410                 0)      break ;;
3411                 esac
3412                 case $1 in
3413                 ''|-)   target="$target $package"
3414                         package=
3415                         ;;
3416                 *)      if      view - src "lib/package/$1.pkg"
3417                         then    package="$package $1"
3418                         else    target="$target $package $1"
3419                                 package=
3420                         fi
3421                         ;;
3422                 esac
3423         done
3424         ;;
3425 esac
3427 # flatten -- assumes symlink support
3429 case $flat in
3430 1)      case $action in
3431         make|read|setup|update|use|view)
3432                 if      test ! -d $INSTALLROOT
3433                 then    $exec mkdir -p $INSTALLROOT || exit
3434                 fi
3435                 for i in bin include lib fun man share
3436                 do      if      test ! -d $INSTALLROOT/../../$i
3437                         then    $exec mkdir $INSTALLROOT/../../$i
3438                         fi
3439                         if      test ! -d $INSTALLROOT/$i
3440                         then    if      test ! -h $INSTALLROOT/$i
3441                                 then    $exec ln -s ../../$i $INSTALLROOT/$i
3442                                 fi
3443                         elif    test ! -h $INSTALLROOT/$i
3444                         then    for x in $INSTALLROOT/$i/.[a-z]* $INSTALLROOT/$i/*
3445                                 do      if      test -f $x -o -d $x
3446                                         then    if      test ! -d $INSTALLROOT/$i/$x || test ! -d $INSTALLROOT/../../$i/$x
3447                                                 then    $exec mv $x $INSTALLROOT/../../$i
3448                                                 fi
3449                                         fi
3450                                 done
3451                                 $exec rm -rf $INSTALLROOT/$i
3452                                 $exec ln -s ../../$i $INSTALLROOT/$i
3453                         fi
3454                 done
3455                 ;;
3456         esac
3457         ;;
3458 esac
3460 # check that cmd args are up to date a.out's
3462 checkaout()     # cmd ...
3464         case $PROTOROOT in
3465         -)      PROTOROOT=
3466                 case $* in
3467                 ratz)   if      test -f $INITROOT/ratz.c -a -w $PACKAGEROOT
3468                         then    test -f $INITROOT/hello.c || {
3469                                         cat > $INITROOT/hello.c <<'!'
3470 #ifndef printf
3471 #include <stdio.h>
3472 #endif
3473 int main() { int new = 0; printf("hello world\n"); return new;}
3475                                 }
3476                                 test -f $INITROOT/p.c || {
3477                                         cat > $INITROOT/p.c <<'!'
3479  * small test for prototyping cc
3480  */
3482 int main(int argc, char** argv) { return argc || argv; }
3484                                 }
3485                         fi
3486                         ;;
3487                 esac
3488                 test -f $INITROOT/hello.c -a -f $INITROOT/p.c -a -w $PACKAGEROOT || {
3489                         for i
3490                         do      onpath $i || {
3491                                         echo "$command: $i: command not found" >&2
3492                                         return 1
3493                                 }
3494                         done
3495                         return 0
3496                 }
3497                 case $cc in
3498                 '')     _PACKAGE_cc=0
3499                         ;;
3500                 *)      _PACKAGE_cc=1
3501                         test -f $INITROOT/hello.c -a -f $INITROOT/p.c || {
3502                                 echo "$command: $INITROOT: INIT package source not found" >&2
3503                                 return 1
3504                         }
3505                         executable $INSTALLROOT/bin/nmake || {
3506                                 # check for prototyping cc
3507                                 # NOTE: proto.c must be K&R compatible
3509                                 $CC -c $INITROOT/p.c >/dev/null 2>&1
3510                                 c=$?
3511                                 rm -f p.*
3512                                 test 0 != "$c" && {
3513                                         checkaout proto || return
3514                                         PROTOROOT=$PACKAGEROOT/proto
3515                                         $show PROTOROOT=$PACKAGEROOT/proto
3516                                         export PROTOROOT
3517                                         INITPROTO=$PROTOROOT/src/cmd/INIT
3518                                         note proto convert $PACKAGEROOT/src into $PROTOROOT/src
3519                                         if      test -d $PACKAGEROOT/src/cmd/nmake
3520                                         then    dirs="src/cmd/INIT src/lib/libast src/lib/libardir src/lib/libcoshell src/lib/libpp src/cmd/probe src/cmd/cpp src/cmd/nmake"
3521                                         else    dirs="src"
3522                                         fi
3523                                         (
3524                                                 if      test -f $PROTOROOT/UPDATE
3525                                                 then    newer="-newer $PROTOROOT/UPDATE"
3526                                                 else    newer=""
3527                                                 fi
3528                                                 case $exec in
3529                                                 '')     cd $PACKAGEROOT
3530                                                         find $dirs -name '*.[CcHh]' $newer -print | proto -v -L - -C proto
3531                                                         ;;
3532                                                 *)      $exec cd $PACKAGEROOT
3533                                                         $exec "find $dirs -name '*.[CcHh]' $newer -print | proto -L - -C proto"
3534                                                         ;;
3535                                                 esac
3536                                                 $exec touch $PROTOROOT/UPDATE
3537                                         )
3538                                         if      (vpath $INSTALLROOT - $INSTALLROOT $PROTOROOT $PROTOROOT $PACKAGEROOT) >/dev/null 2>&1 &&
3539                                                  vpath $INSTALLROOT - $INSTALLROOT $PROTOROOT $PROTOROOT $PACKAGEROOT
3540                                         then    $show vpath $INSTALLROOT $PROTOROOT $PROTOROOT $PACKAGEROOT $USER_VPATH_CHAIN
3541                                         else    VPATH=$INSTALLROOT:$PROTOROOT:$PACKAGEROOT$USER_VPATH
3542                                                 $show VPATH=$VPATH
3543                                                 export VPATH
3544                                         fi
3545                                 }
3546                         }
3547                         for i in arch arch/$HOSTTYPE arch/$HOSTTYPE/bin
3548                         do      test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || return
3549                         done
3550                         ;;
3551                 esac
3552                 ;;
3553         esac
3554         case $_PACKAGE_cc in
3555         '')     case $cc in
3556                 '')     _PACKAGE_cc=0 ;;
3557                 *)      _PACKAGE_cc=1 ;;
3558                 esac
3559                 ;;
3560         esac
3561         for i
3562         do      eval j=\$_PACKAGE_AOUT_$i
3563                 case $j in
3564                 '')     eval _PACKAGE_AOUT_$i=1 ;;
3565                 *)      continue ;;
3566                 esac
3567                 k=$_PACKAGE_cc
3568                 if      test -f $INITROOT/$i.c
3569                 then    k=${k}1
3570                 else    k=${k}0
3571                 fi
3572                 if      executable $EXECROOT/bin/$i
3573                 then    k=${k}1
3574                 else    k=${k}0
3575                 fi
3576                 : $k : compiler : source : binary :
3577                 case $k in
3578                 *00)    view - bin/$i && continue ;;
3579                 esac
3580                 case $k in
3581                 000)    echo "$command: $i: not found: download the INIT package $HOSTTYPE binary to continue" >&2
3582                         return 1
3583                         ;;
3584                 010)    echo "$command: $i: not found: set CC=C-compiler or download the INIT package $HOSTTYPE binary to continue" >&2
3585                         return 1
3586                         ;;
3587                 100)    echo "$command: $i: not found: download the INIT package source or $HOSTTYPE binary to continue" >&2
3588                         return 1
3589                         ;;
3590                 110)    case $CROSS in
3591                         1)      echo "$command: $i: not found: make the local $EXECTYPE binary package before $HOSTTYPE" >&2
3592                                 return 1
3593                                 ;;
3594                         esac
3595                         ;;
3596                 ?01)    : accept binary
3597                         continue
3598                         ;;
3599                 011)    : accept binary
3600                         continue
3601                         ;;
3602                 ??1)    case $CROSS in
3603                         1)      continue ;;
3604                         esac
3605                         ;;
3606                 esac
3607                 case `ls -t $INITROOT/$i.c $INSTALLROOT/bin/$i 2>/dev/null` in
3608                 "$INITROOT/$i.c"*)
3609                         note update $INSTALLROOT/bin/$i
3610                         if      test proto != "$i" && executable $INSTALLROOT/bin/proto
3611                         then    case $exec in
3612                                 '')     $INSTALLROOT/bin/proto -p $INITROOT/$i.c > $i.c || return ;;
3613                                 *)      $exec "$INSTALLROOT/bin/proto -p $INITROOT/$i.c > $i.c" ;;
3614                                 esac
3615                                 $exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $i.c || return
3616                                 $exec rm -f $i.c
3617                         else    if      test ! -d $INSTALLROOT/bin
3618                                 then    for j in arch arch/$HOSTTYPE arch/$HOSTTYPE/bin
3619                                         do      test -d $PACKAGEROOT/$j || $exec mkdir $PACKAGEROOT/$j || return
3620                                         done
3621                                 fi
3622                                 if      test '' != "$PROTOROOT" -a -f $INITPROTO/$i.c
3623                                 then    $exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $INITPROTO/$i.c || return
3624                                 else    $exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $INITROOT/$i.c || return
3625                                 fi
3626                                 case $i:$exec in
3627                                 proto:) test -d $INSTALLROOT/include || mkdir $INSTALLROOT/include
3628                                         $INSTALLROOT/bin/proto -f /dev/null > $i.c
3629                                         cmp -s $i.c $INSTALLROOT/include/prototyped.h 2>/dev/null || cp $i.c $INSTALLROOT/include/prototyped.h
3630                                         rm $i.c
3631                                         ;;
3632                                 esac
3633                         fi
3634                         test -f $i.o && $exec rm -f $i.o
3635                         i=$PATH
3636                         PATH=/bin
3637                         PATH=$i
3638                         ;;
3639                 esac
3640         done
3641         return 0
3644 # check package requirements against received packages
3646 requirements() # source|binary [ package ]
3648         case $1 in
3649         binary) r=$VIEW_BIN ;;
3650         source) r=$VIEW_SRC ;;
3651         *)      r=$VIEW_ALL ;;
3652         esac
3653         shift
3654         case $1 in
3655         '')     x= ;;
3656         *)      x=$* ;;
3657         esac
3658         set ''
3659         for d in $r
3660         do      set "$@" $d/gen/*.ver
3661                 case $x in
3662                 '')     set "$@" $d/gen/*.req
3663                         ;;
3664                 *)      for p in $x
3665                         do      set "$@" $d/gen/$p.req
3666                         done
3667                         ;;
3668                 esac
3669         done
3670         shift
3671         e=0
3672         x=$*
3673         y=
3674         n=
3675         set ''
3676         for i in $x
3677         do      p=`echo $i | sed -e 's,.*/,,' -e 's,\....$,,'`
3678                 if      test -f $i
3679                 then    set "$@" $i
3680                         y="$y $p"
3681                 else    case $p in
3682                         '*')    ;;
3683                         *)      n="$n $p" ;;
3684                         esac
3685                 fi
3686         done
3687         for i in $n
3688         do      case " $y " in
3689                 *" $i "*)
3690                         ;;
3691                 *)      echo "$command: $i: must read or write package" >&2
3692                         e=1
3693                         ;;
3694                 esac
3695         done
3696         case $e in
3697         1)      exit 1 ;;
3698         esac
3699         shift
3700         test 0 != "$#" && release=`sort -r "$@" | {
3701                 q=
3702                 e=0
3703                 o=
3704                 while   read p v r s
3705                 do      q="$q
3706 $v $r"
3707                         case $p in
3708                         $o)     continue ;;
3709                         esac
3710                         case $s in
3711                         0)      e=1
3712                                 case $r in
3713                                 base)   echo "$command: base package $p.$v or newer required" >&2 ;;
3714                                 *)      echo "$command: delta package $p.$v.$r or newer required" >&2 ;;
3715                                 esac
3716                                 ;;
3717                         esac
3718                         o=$p
3719                 done
3720                 case $e in
3721                 0)      echo "$q" | sort | { read v r; read v r; echo $v; } ;;
3722                 1)      echo ERROR ;;
3723                 esac
3724         }`
3725         case $release in
3726         ERROR)  case $force in
3727                 0)      exit 1 ;;
3728                 esac
3729                 ;;
3730         ?*)     eval `echo $release | sed -e 's,\(.*\)-\(.*\)-\(.*\),yy=\1 mm=\2 dd=\3,'`
3731                 # slide back 4 months
3732                 case $mm in
3733                 01)     mm=09 dd=1 ;;
3734                 02)     mm=10 dd=1 ;;
3735                 03)     mm=11 dd=1 ;;
3736                 04)     mm=12 dd=1 ;;
3737                 05)     mm=01 dd=0 ;;
3738                 06)     mm=02 dd=0 ;;
3739                 07)     mm=03 dd=0 ;;
3740                 08)     mm=04 dd=0 ;;
3741                 09)     mm=05 dd=0 ;;
3742                 10)     mm=06 dd=0 ;;
3743                 11)     mm=07 dd=0 ;;
3744                 12)     mm=08 dd=0 ;;
3745                 esac
3746                 case $dd in
3747                 1)      yy=`expr $yy - 1` ;;
3748                 esac
3749                 release=$yy-$mm-01
3750                 count=1
3751                 lo=$release
3752                 release="-f $release -r $count"
3753                 ;;
3754         esac
3757 # write ordered package prerequisite list to the standard output
3759 order() # [ package ]
3761         _order_t_=lib/package/tgz
3762         case $action in
3763         binary) _order_a_=.$HOSTTYPE ;;
3764         *)      _order_a_= ;;
3765         esac
3766         _order_n_=$#
3767         case $_order_n_ in
3768         0)      _order_p_=
3769                 for _order_v_ in $VIEW_all
3770                 do      for _order_f_ in $_order_v_/lib/package/*.pkg
3771                         do      if      test -f $_order_f_
3772                                 then    _order_p_="$_order_p_ $_order_f_"
3773                                 fi
3774                         done
3775                 done
3776                 set '' $_order_p_
3777                 shift
3778         esac
3779         {
3780         if      test ratz != "$*"
3781         then    for _order_f_ in ratz INIT
3782                 do      if      view -s - src $_order_t_/$_order_f_$_order_a_.tim
3783                         then    echo $_order_f_ $_order_f_
3784                         fi
3785                 done
3786         fi
3787         for _order_f_
3788         do      while   :
3789                 do      view - src $_order_f_ && break
3790                         case $_order_f_ in
3791                         *.pkg)  ;;
3792                         *)      _order_f_=$_order_f_.pkg; view - src $_order_f_ && break ;;
3793                         esac
3794                         case $_order_f_ in
3795                         */*)    ;;
3796                         *)      _order_f_=lib/package/$_order_f_; view - src $_order_f_ && break ;;
3797                         esac
3798                         echo "$command: $_order_f_: not a package" >&2
3799                         continue 2
3800                 done
3801                 _order_f_=$_view_
3802                 _order_p_=`echo $_order_f_ | sed -e 's,.*/,,' -e 's,\.pkg$,,'`
3803                 case $_order_n_ in
3804                 0)      view -s - src $_order_t_/$_order_p_$_order_a_.tim || continue ;;
3805                 esac
3806                 echo $_order_p_ $_order_p_
3807                 case $_order_p_ in
3808                 INIT|ratz)
3809                         ;;
3810                 *)      echo INIT $_order_p_
3811                         ;;
3812                 esac
3813                 {
3814                 req= req_sep=
3815                 op=::
3816                 while   read line
3817                 do      IFS='   \\'
3818                         set '' $line
3819                         IFS=$ifs
3820                         while   :
3821                         do      shift
3822                                 case $# in
3823                                 0)      break ;;
3824                                 esac
3825                                 case $1 in
3826                                 :*:)    op=$1
3827                                         ;;
3828                                 INIT|'$('*|*')')
3829                                         ;;
3830                                 *)      case $op in
3831                                         :REQUIRES:)
3832                                                 req="$req$req_sep$1"
3833                                                 req_sep=" "
3834                                                 ;;
3835                                         esac
3836                                         ;;
3837                                 esac
3838                         done
3839                 done
3840                 for _order_i_ in $req
3841                 do      if      view - src lib/package/$_order_i_.pkg
3842                         then    case $_order_u_ in
3843                                 0)      view -s - src $_order_t_/$_order_i_$_order_a_.tim || continue ;;
3844                                 esac
3845                                 echo $_order_i_ $_order_i_; echo INIT $_order_i_; echo $_order_i_ $_order_p_
3846                         fi
3847                 done
3848                 } < $_order_f_
3849         done
3850         } | tsort
3853 # generate the package component list in _components_
3855 components() # [ package ]
3857         _components_=
3858         for p
3859         do      case $p in
3860                 '')     ;;
3861                 INIT)   case " $_components_ " in
3862                         *" $p "*)       ;;
3863                         *)              _components_="$_components_ $p" ;;
3864                         esac
3865                         ;;
3866                 *)      if      view - src lib/package/$p.pkg
3867                         then    p=$_view_
3868                                 op=::
3869                                 exec < $p
3870                                 while   read line
3871                                 do      IFS='   \\'
3872                                         set '' $line
3873                                         IFS=$ifs
3874                                         while   :
3875                                         do      shift
3876                                                 case $# in
3877                                                 0)      break ;;
3878                                                 esac
3879                                                 case $1 in
3880                                                 :*:)    op=$1
3881                                                         ;;
3882                                                 INIT|'$('*|*')')
3883                                                         ;;
3884                                                 *)      case $op in
3885                                                         :PACKAGE:)
3886                                                                 case " $_components_ " in
3887                                                                 *" $1 "*)       ;;
3888                                                                 *)              _components_="$_components_ $1" ;;
3889                                                                 esac
3890                                                                 ;;
3891                                                         esac
3892                                                         ;;
3893                                                 esac
3894                                         done
3895                                 done
3896                                 exec < /dev/null
3897                         elif    test -d $PACKAGEROOT/src/cmd/$p -o -d $PACKAGEROOT/src/lib/$p
3898                         then    _components_="$_components_ $p"
3899                         else    echo "$command: $p: package or component not found" >&2
3900                                 exit 1
3901                         fi
3902                         ;;
3903                 esac
3904         done
3907 # list main environment values
3909 showenv()
3911         case $1 in
3912         ''|make)for __i__ in CC SHELL $env
3913                 do      eval echo $__i__='$'$__i__
3914                 done
3915                 ;;
3916         esac
3919 # capture command output
3921 capture() # file command ...
3923         case $make:$noexec in
3924         :)      case $action in
3925                 install|make|view)
3926                         o=$action
3927                         ;;
3928                 *)      case $package in
3929                         ''|*' '*)
3930                                 o=$action
3931                                 ;;
3932                         *)      o=$package
3933                                 ;;
3934                         esac
3935                         ;;
3936                 esac
3937                 case $action in
3938                 write)  d=$PACKAGESRC/gen ;;
3939                 *)      d=$PACKAGEBIN/gen ;;
3940                 esac
3941                 test -d $d || $exec mkdir $d
3942                 o=$d/$o
3943                 case $o in
3944                 $output)o=$o.out
3945                         s=
3946                         ;;
3947                 *)      output=$o
3948                         if      test -f $o.old
3949                         then    mv $o.old $o.out.1
3950                                 if      test -f $o.out
3951                                 then    mv $o.out $o.out.2
3952                                 fi
3953                         elif    test -f $o.out
3954                         then    for i in `ls -t $o.out.? 2>/dev/null`
3955                                 do      break
3956                                 done
3957                                 case $i in
3958                                 *.1)    i=2 ;;
3959                                 *.2)    i=3 ;;
3960                                 *.3)    i=4 ;;
3961                                 *.4)    i=5 ;;
3962                                 *.5)    i=6 ;;
3963                                 *.6)    i=7 ;;
3964                                 *.7)    i=8 ;;
3965                                 *.8)    i=9 ;;
3966                                 *)      i=1 ;;
3967                                 esac
3968                                 mv $o.out $o.out.$i
3969                         fi
3970                         o=$o.out
3971                         : > $o
3972                         note $action output captured in $o
3973                         s="$command: $action start at `date` in $INSTALLROOT"
3974                         case $quiet in
3975                         0)      trap "echo \"$command: $action done  at \`date\`\" in $INSTALLROOT 2>&1 | \$TEE -a $o" 0 1 2 ;;
3976                         *)      trap "echo \"$command: $action done  at \`date\`\" in $INSTALLROOT >> $o" 0 1 2 ;;
3977                         esac
3978                         ;;
3979                 esac
3980                 case $quiet in
3981                 0)      if      executable ! $TEE
3982                         then    TEE=tee
3983                         fi
3984                         {
3985                                 case $s in
3986                                 ?*)     echo "$s"  ;;
3987                                 esac
3988                                 showenv $action
3989                                 "$@"
3990                         } < /dev/null 2>&1 | $TEE -a $o
3991                         ;;
3992                 *)      {
3993                                 case $s in
3994                                 ?*)     echo "$s"  ;;
3995                                 esac
3996                                 showenv $action
3997                                 "$@"
3998                         } < /dev/null > $o 2>&1
3999                         ;;
4000                 esac
4001                 ;;
4002         *)      $make "$@"
4003                 ;;
4004         esac
4007 package_install() # dest sum
4009         dest=$1 sum=$2
4010         ot=
4011         code=0
4012         sed -e '/ /!d' -e 's,[^ ]* ,,' -e 's, \(arch/[^/]*\)/, \1 ,' -e '/ arch\//!s,^[^ ]* [^ ]* [^ ]*,& .,' -e 's,/\([^ /]*\)$, \1,' $sum |
4013         while   read mode user group arch dir file
4014         do      case $flat:$arch in
4015                 1:*|?:.)t=$dest/$dir ;;
4016                 *)      t=$dest/$arch/$dir ;;
4017                 esac
4018                 case $t in
4019                 $ot)    ;;
4020                 *)      if      test ! -d "$t"
4021                         then    $exec mkdir -p "$t" || exit
4022                         fi
4023                         ot=$t
4024                         ;;
4025                 esac
4026                 case $file in
4027                 ?*)     case $arch in
4028                         .)      f=$dir/$file ;;
4029                         *)      f=$arch/$dir/$file ;;
4030                         esac
4031                         if      test -f "$f"
4032                         then    t=$t/$file
4033                                 case $quiet in
4034                                 0)      echo "$t" ;;
4035                                 esac
4036                                 $exec cp -f "$f" "$t" || code=1
4037                                 $exec chmod $mode "$t" || code=1
4038                         fi
4039                         ;;
4040                 esac
4041         done
4042         return $code
4045 package_verify() # sum
4047         $exec $SUM -cp $1
4050 make_recurse() # dir
4052         for _make_recurse_j in $makefiles
4053         do      if      view - $1/$_make_recurse_j
4054                 then    return
4055                 fi
4056         done
4057         if      test -d $1
4058         then    case $exec in
4059                 '')     echo :MAKE: > $1/Makefile || exit ;;
4060                 *)      $exec "echo :MAKE: > $1/Makefile" ;;
4061                 esac
4062         fi
4065 get() # host path [ file size ]
4067         case $HURL in
4068         '')     HURL=.
4069                 for i in wget lynx curl
4070                 do      if      onpath $i
4071                         then    HURL=$i
4072                                 break;
4073                         fi
4074                 done
4075                 AUTHORIZE="User-Agent: package AT&T Research\\r\\n"
4076                 case $HURL:$authorize in
4077                 .:?*)   AUTHORIZE="${AUTHORIZE}Authorization: Basic `print -n -r -- $authorize:$password | uuencode -h -x base64`\\r\\n" ;;
4078                 esac
4079                 ;;
4080         esac
4081         getfd=8
4082         case $3 in
4083         '')     case $HURL in
4084                 .)      host=$1
4085                         path=$2
4086                         while   :
4087                         do      eval "exec $getfd<> /dev/tcp/$host/80" || exit
4088                                 case $path in
4089                                 /*)     ;;
4090                                 *)      path=/$path ;;
4091                                 esac
4092                                 print "GET $path HTTP/1.0\\r\\nHost: $host\\r\\n$AUTHORIZE\\r" >&$getfd
4093                                 cat <&8 > get.tmp
4094                                 got=`sed -e 1q get.tmp`
4095                                 case $got in
4096                                 *" "200" "*)
4097                                         got=`sed -e '1,/^.$/d' -e '/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]/!d' get.tmp`
4098                                         : > get.err
4099                                         code=0
4100                                         break
4101                                         ;;
4102                                 *" "30[123]" "*)
4103                                         got=`sed -e '/^Location: /!d' -e 's,^Location: \(.*\)://\([^/]*\)\(/.*\),prot='\''\1'\'' host='\''\2'\'' path='\''\3'\'',' get.tmp`
4104                                         case $got in
4105                                         '')     rm get.tmp
4106                                                 echo "$command: $action: $url: redirect error" >&2
4107                                                 exit 1
4108                                                 ;;
4109                                         esac
4110                                         eval $got
4111                                         ;;
4112                                 *)      rm get.tmp
4113                                         echo "$command: $action: $url: $got" >&2
4114                                         echo '' "$got" > get.err
4115                                         code=1
4116                                         break
4117                                         ;;
4118                                 esac
4119                         done
4120                         ;;
4121                 curl)   case $authorize in
4122                         '')     curl -s -L -o get.tmp http://$1/$2 2> get.err; code=$? ;;
4123                         *)      curl -s -L -o get.tmp -u "$authorize":"$password" http://$1/$2 2> get.err; code=$? ;;
4124                         esac
4125                         got=`grep '^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]' get.tmp 2>/dev/null`
4126                         case $code in
4127                         0)      if      grep '^<H1>Authorization Required</H1>' get.tmp > get.err
4128                                 then    code=1
4129                                 fi
4130                                 ;;
4131                         esac
4132                         ;;
4133                 hurl)   case $authorize in
4134                         '')     hurl http://$1/$2 > get.tmp 2> get.err; code=$? ;;
4135                         *)      hurl -a "$authorize":"$password" http://$1/$2 > get.tmp 2> get.err; code=$? ;;
4136                         esac
4137                         got=`grep '^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]' get.tmp`
4138                         ;;
4139                 lynx)   case $authorize in
4140                         '')     lynx -source http://$1/$2 > get.tmp 2> get.err; code=$? ;;
4141                         *)      lynx -source -auth "$authorize":"$password" http://$1/$2 > get.tmp 2> get.err; code=$? ;;
4142                         esac
4143                         got=`grep '^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]' get.tmp`
4144                         ;;
4145                 wget)   wget -nv -O get.tmp ${authorize:+--http-user="$authorize"} ${password:+--http-passwd="$password"} http://$1/$2 2> get.err
4146                         code=$?
4147                         got=`grep '^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]' get.tmp 2>/dev/null`
4148                         ;;
4149                 *)      echo $command: $action: $HURL: url get command not found >&2
4150                         exit 1
4151                         ;;
4152                 esac
4153                 if      test 0 != "$code"
4154                 then    case `cat get.err get.tmp 2>/dev/null` in
4155                         *[Aa][Uu][Tt][Hh][Oo][Rr][Ii][SsZz]*|*[Dd][Ee][Nn][Ii][Ee][Dd]*)
4156                                 echo $command: $action: authorization required -- see $url for license acceptance authorization name and password >&2
4157                                 ;;
4158                         *)      cat get.err
4159                                 ;;
4160                         esac
4161                         rm -f get.tmp get.err
4162                         echo $command: $action: $2: download failed >&2
4163                         exit 1
4164                 fi
4165                 rm -f get.tmp get.err
4166                 ;;
4167         *)      case $exec in
4168                 '')     echo "$3 ($4 bytes):" >&2
4169                         case $HURL in
4170                         .)      eval "exec $getfd<> /dev/tcp/$1/80" || exit
4171                                 path=$2/$3
4172                                 case $path in
4173                                 /*)     ;;
4174                                 *)      path=/$path ;;
4175                                 esac
4176                                 print "GET $path HTTP/1.0\\r\\nHost: $host\\r\\n$AUTHORIZE\\r" >&$getfd
4177                                 read got <&$getfd
4178                                 case $got in
4179                                 *" 200 "*)
4180                                         code=0
4181                                         : > get.err
4182                                         ;;
4183                                 *)      echo '' "$got" > get.err
4184                                         code=1
4185                                         ;;
4186                                 esac
4187                                 while   read got <&$getfd
4188                                 do      case $got in
4189                                         ''|?)   break ;;
4190                                         esac
4191                                 done
4192                                 cat <&$getfd > get.tmp
4193                                 ;;
4194                         curl)   case $authorize in
4195                                 '')     curl -s -L -o get.tmp http://$1/$2/$3 2> get.err; code=$? ;;
4196                                 *)      curl -s -L -o get.tmp -u "$authorize":"$password" http://$1/$2/$3 2> get.err; code=$?
4197                                 esac
4198                                 case $code in
4199                                 0)      if      grep '^<H1>Authorization Required</H1>' get.tmp > get.err
4200                                         then    code=1
4201                                         fi
4202                                         ;;
4203                                 esac
4204                                 ;;
4205                         hurl)   case $authorize in
4206                                 '')     ksh -x hurl http://$1/$2/$3 > get.tmp 2> get.err; code=$? ;;
4207                                 *)      ksh -x hurl -a "$authorize":"$password" http://$1/$2/$3 > get.tmp 2> get.err; code=$? ;;
4208                                 esac
4209                                 ;;
4210                         lynx)   case $authorize in
4211                                 '')     lynx -source http://$1/$2/$3 > get.tmp 2> get.err; code=$? ;;
4212                                 *)      lynx -source -auth "$authorize":"$password" http://$1/$2/$3 > get.tmp 2> get.err; code=$? ;;
4213                                 esac
4214                                 ;;
4215                         wget)   wget -nv -O get.tmp ${authorize:+--http-user="$authorize"} ${password:+--http-passwd="$password"} http://$1/$2/$3 2> get.err
4216                                 code=$?
4217                                 ;;
4218                         *)      echo $command: $action: $HURL: url get command not found >&2
4219                                 exit 1
4220                                 ;;
4221                         esac
4222                         if      test 0 != "$code"
4223                         then    case `cat get.err get.tmp` in
4224                                 *[Aa][Uu][Tt][Hh][Oo][Rr][Ii][SsZz]*|*[Dd][Ee][Nn][Ii][Ee][Dd]*)
4225                                         echo $command: $action: authorization required -- see $url for license acceptance authorization name and password >&2
4226                                         ;;
4227                                 *)      cat get.err
4228                                         ;;
4229                                 esac
4230                                 rm get.tmp get.err
4231                                 echo $command: $action: $3: download failed >&2
4232                                 exit 1
4233                         fi
4234                         rm get.err
4235                         case $checksum:$5 in
4236                         :*|*:-) z=`wc -c < get.tmp`
4237                                 case " $z " in
4238                                 *" $4 "*)
4239                                         ;;
4240                                 *)      rm -f get.tmp
4241                                         echo $command: $3: download error: expected $4 bytes, got $z >&2
4242                                         exit 1
4243                                         ;;
4244                                 esac
4245                                 ;;
4246                         *)      z=`$checksum < get.tmp | sed -e 's,^[   ][      ]*,,' -e 's,[   ].*,,'`
4247                                 case " $z " in
4248                                 *" $5 "*)
4249                                         ;;
4250                                 *)      rm -f get.tmp
4251                                         echo $command: $3: download $checksum error: expected $5, got $z >&2
4252                                         exit 1
4253                                         ;;
4254                                 esac
4255                                 ;;
4256                         esac
4257                         mv get.tmp $3 || exit
4258                         ;;
4259                 *)      echo "$3 ($4 bytes)" >&2
4260                         ;;
4261                 esac
4262         esac
4265 # generate copyright notice
4267 copyright()
4269         if      test -f $1.lic
4270         then    echo $1 package general copyright notice
4271                 echo
4272                 proto -c'#' -p -s -l $1.lic -o type=verbose,author='*' /dev/null
4273                 return 0
4274         fi
4275         case $1 in
4276         *-*)    eval `echo '' $1 | sed 's/\([^-]*\)-\(.*\)/__j__="\1" __i__="\2"/'`
4277                 if      copyright $__i__ || copyright $__j__
4278                 then    return 0
4279                 fi
4280                 ;;
4281         esac
4282         return 1
4285 # run remote make on host
4287 remote() # host no-exec-background
4289         host=$1
4290         background=$2
4291         eval name=\$${host}_name user=\$${host}_user snarf=\$${host}_snarf type=\$${host}_type rsh=\$${host}_rsh root=\$${host}_root keep=\$${host}_keep log=\$${host}_log
4292         case $keep in
4293         1*)     ;;
4294         *)      return ;;
4295         esac
4296         case $host in
4297         $main)  ;;
4298         *)      case $exec in
4299                 '')     exec > $admin_log/$log 2>&1 ;;
4300                 *)      echo "exec > $admin_log/$log 2>&1" ;;
4301                 esac
4302                 ;;
4303         esac
4304         if      $admin_ping $name >/dev/null 2>&1 || $admin_ping $name >/dev/null 2>&1
4305         then    cmd=". ./.profile"
4306                 case $root in
4307                 .)      root=
4308                         ;;
4309                 *)      cmd="$cmd && cd $root"
4310                         root=$root/
4311                         ;;
4312                 esac
4313                 cmd="$cmd && { test -f lib/package/admin/$admin_env && . ./lib/package/admin/$admin_env || true ;} && PATH=\${PWD:-\`pwd\`}/bin:\$PATH \${SHELL:-/bin/sh} -c 'package $admin_args PACKAGEROOT=\${PWD:-\`pwd\`} HOSTTYPE=$type VPATH='"
4314                 case $admin_binary in
4315                 '')     snarf= ;;
4316                 esac
4317                 case $snarf in
4318                 '')     $exec $rsh $user$name "$cmd" $background
4319                         ;;
4320                 *?)     rcp=`echo $rsh | sed 's/\(.\).*/\1/'`cp
4321                         case $background in
4322                         ?*)     $exec "{" ;;
4323                         esac
4324                         $exec $rsh $user$name "$cmd"
4325                         eval lst=$admin_list
4326                         case $admin_pkgs in
4327                         '')     filter=cat ;;
4328                         *)      filter="egrep lib/package/tgz/($admin_pkgs)\\." ;;
4329                         esac
4330                         if      $exec $rcp $user$name:${root}lib/package/tgz/$lst $PACKAGESRC/tgz
4331                         then    $exec $rcp `$filter $PACKAGESRC/tgz/$lst | sed "s,^,$user$name:,"` $PACKAGESRC/tgz
4332                         else    echo "$command: $user$name:${root}lib/package/tgz/$lst: not found" >&2
4333                         fi
4334                         case $background in
4335                         ?*)     $exec "} $background" ;;
4336                         esac
4337                         ;;
4338                 esac
4339         else    echo "$command: $name: down" >&2
4340         fi
4343 # update package_src
4345 checksrc()
4347         case $package_src in
4348         '')     package_src=$src
4349                 for _i_ in `cd $PACKAGESRC; ls *.def *.lic *.pkg 2>/dev/null | sed 's/[-.].*//'`
4350                 do      case " $package_src " in
4351                         *" $_i_ "*)
4352                                 ;;
4353                         *)      package_src="$package_src $_i_"
4354                                 ;;
4355                         esac
4356                 done
4357                 ;;
4358         esac
4361 # check for native ascii 0:yes 1:no
4363 __isascii__=
4365 isascii()
4367         case $__isascii__ in
4368         '')     case `echo A | od -o | sed -e 's/[      ]*$//' -e '/[   ]/!d' -e 's/.*[         ]//'` in
4369                 005101|040412)  __isascii__=0 ;;
4370                 *)              __isascii__=1 ;;
4371                 esac
4372         esac
4373         return $__isascii__
4376 case $action in
4378 admin)  while   test ! -f $admin_db
4379         do      case $admin_db in
4380                 /*)     echo $command: $action: $admin_db: data file not found >&2
4381                         exit 1
4382                         ;;
4383                 esac
4384                 view file src lib/package/admin/$admin_db || exit 1
4385                 admin_db=$_view_
4386         done
4387         admin_components=
4388         case $admin_action in
4389         list)   cat $admin_db
4390                 exit
4391                 ;;
4392         test)   set $admin_args
4393                 while   :
4394                 do      case $# in
4395                         1)      break ;;
4396                         esac
4397                         shift
4398                         case $1 in
4399                         *=*)    ;;
4400                         *)      admin_components=-$1
4401                                 break
4402                                 ;;
4403                         esac
4404                 done
4405                 ;;
4406         esac
4407         : all work done in $PACKAGESRC/admin
4408         cd $PACKAGESRC/admin || exit
4409         checksrc
4410         packages=
4411         admin_log=${admin_action}${admin_components}.log
4412         exec < $admin_db || exit
4413         test -d $admin_log || $exec mkdir $admin_log || exit
4414         case $admin_on in
4415         '')     admin_on="*" ;;
4416         esac
4417         hostname=
4418         hosts=
4419         logs=
4420         local_hosts=
4421         local_types=
4422         pids=
4423         remote_hosts=
4424         sync_hosts=
4425         admin_host=_admin_host_
4426         admin_out=
4427         case " $admin_args " in
4428         *" write binary "*|*" write "*" binary "*)
4429                 admin_binary=1
4430                 ;;
4431         *)      admin_binary=
4432                 ;;
4433         esac
4434         case $only in
4435         1)      admin_args="only $admin_args" ;;
4436         esac
4437         trap 'kill $pids >/dev/null 2>&1' 1 2 3 15
4438         index=0
4439         while   read type host root date time make test write owner attributes
4440         do      case $type in
4441                 ''|'#'*);;
4442                 *=*)    eval "$type $host $root $date $time $make $test $write $owner $attributes"
4443                         ;;
4444                 *)      case $admin_action in
4445                         make|test|write)
4446                                 eval f='$'$admin_action
4447                                 case $f in
4448                                 *[!0123456789]*)        continue ;;
4449                                 esac
4450                                 ;;
4451                         esac
4452                         rsh=rsh
4453                         case $host in
4454                         *@*)    IFS=@
4455                                 set '' $host
4456                                 IFS=$ifs
4457                                 user=${2}@
4458                                 host=$3
4459                                 ;;
4460                         *)      user=
4461                                 ;;
4462                         esac
4463                         : type=$type host=$host root=$root date=$date time=$time make=$make test=$test write=$write :
4464                         name=$host
4465                         hash=`echo $name | sed 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789],__,g'`
4466                         eval x='$'${hash}_index
4467                         eval ${hash}_index=1
4468                         case $x in
4469                         1)      i=0
4470                                 while   :
4471                                 do      case $i in
4472                                         $index) h=''
4473                                                 break
4474                                                 ;;
4475                                         esac
4476                                         i=`expr $i + 1`
4477                                         eval h='$'${admin_host}${i}_hash
4478                                         case $h in
4479                                         $hash)  host=${admin_host}${i}
4480                                                 eval user='$'${host}_user root='$'${host}_rsh:$host:'$'${host}_root
4481                                                 break
4482                                                 ;;
4483                                         esac
4484                                 done
4485                                 ;;
4486                         esac
4487                         case $root in
4488                         *:$name:*)root=`echo '' $root | sed 's,:.*,:,'` ;;
4489                         esac
4490                         case $root in
4491                         *:*:*)  index=`expr $index + 1`
4492                                 host=${admin_host}$index
4493                                 ;;
4494                         *:*)    case " $sync_hosts " in
4495                                 *" $name ${admin_host}"*)
4496                                         set '' '' $sync_hosts
4497                                         while   :
4498                                         do      shift
4499                                                 shift
4500                                                 case $1 in
4501                                                 $name)  host=$2
4502                                                         break
4503                                                         ;;
4504                                                 esac
4505                                         done
4506                                         ;;
4507                                 *)      index=`expr $index + 1`
4508                                         host=${admin_host}$index
4509                                         sync_hosts="$sync_hosts $name $host"
4510                                         ;;
4511                                 esac
4512                                 ;;
4513                         *)      index=`expr $index + 1`
4514                                 host=${admin_host}$index
4515                                 ;;
4516                         esac
4517                         case $root in
4518                         -*)     continue
4519                                 ;;
4520                         *:*)    case $admin_all in
4521                                 0)      continue ;;
4522                                 esac
4523                                 case $root in
4524                                 *:)     root=${root}. ;;
4525                                 esac
4526                                 IFS=:
4527                                 set '' $root
4528                                 IFS=$ifs
4529                                 sync=$host
4530                                 case $hostname in
4531                                 '')     hostinfo name
4532                                         hostname=$_hostinfo_
4533                                         ;;
4534                                 esac
4535                                 shift
4536                                 case $# in
4537                                 0)      ;;
4538                                 1)      root=$1
4539                                         ;;
4540                                 2)      rsh=$1 root=$2
4541                                         ;;
4542                                 *)      rsh=$1 sync=$2 root=$3
4543                                         case $sync in
4544                                         ${admin_host}*)
4545                                                 ;;
4546                                         ?*)     case " $sync_hosts " in
4547                                                 *" $sync ${admin_host}"*)
4548                                                         set '' '' $sync_hosts
4549                                                         while   :
4550                                                         do      shift
4551                                                                 shift
4552                                                                 case $1 in
4553                                                                 $sync)  sync=$2
4554                                                                         break
4555                                                                         ;;
4556                                                                 esac
4557                                                         done
4558                                                         ;;
4559                                                 *)      index=`expr $index + 1`
4560                                                         x=${admin_host}$index
4561                                                         sync_hosts="$sync_hosts $sync $x"
4562                                                         sync=$x
4563                                                         ;;
4564                                                 esac
4565                                                 ;;
4566                                         esac
4567                                         ;;
4568                                 esac
4569                                 ;;
4570                         *)      sync=
4571                                 ;;
4572                         esac
4573                         case $name in
4574                         $admin_on)
4575                                 keep=1
4576                                 ;;
4577                         *)      case " $admin_on " in
4578                                 *" $name "*)    keep=1 ;;
4579                                 *)              keep=0 ;;
4580                                 esac
4581                                 ;;
4582                         esac
4583                         case " $admin_out " in
4584                         *" $name "*)
4585                                 log=$name.$type
4586                                 ;;
4587                         *)      admin_out="$admin_out $name"
4588                                 log=$name
4589                                 ;;
4590                         esac
4591                         case $sync in
4592                         '')     local_types="$local_types $type" ;;
4593                         esac
4594                         case $sync in
4595                         $host)  remote_hosts="$remote_hosts $host"
4596                                 ;;
4597                         ?*)     eval ${sync}_share=\"\$${sync}_share $host\"
4598                                 ;;
4599                         '')     local_hosts="$local_hosts $host"
4600                                 ;;
4601                         esac
4602                         eval ${host}_name='$'name ${host}_hash='$'hash ${host}_type='$'type ${host}_user='$'user ${host}_sync='$'sync ${host}_snarf='$'sync ${host}_rsh='$'rsh ${host}_root='$'root ${host}_keep='$'keep ${host}_log='$'log
4603                         ;;
4604                 esac
4605         done
4606         p=
4607         for i in $admin_args
4608         do      p="$i $p"
4609         done
4610         admin_pkgs=
4611         for i in $p
4612         do      if      view - src "lib/package/$i.pkg"
4613                 then    case $admin_pkgs in
4614                         '')     admin_pkgs="$i" ;;
4615                         *)      admin_pkgs="$admin_pkgs|$i" ;;
4616                         esac
4617                 fi
4618         done
4619         : "admin_binary :" $admin_binary
4620         : "admin_args   :" $admin_args
4621         : "admin_pkgs   :" $admin_pkgs
4622         : "admin_on     :" "$admin_on"
4623         : "local_hosts  :" $local_hosts
4624         : "local_types  :" $local_types
4625         : "remote_hosts :" $remote_hosts
4626         : "sync_hosts   :" $sync_hosts
4627         : "sync_share   :" $sync_share
4628         case $admin_binary in
4629         1)      admin_bin_types=
4630                 admin_bin_main=
4631                 for main in $local_hosts $remote_hosts
4632                 do      eval share=\$${main}_share keep=\$${main}_keep
4633                         case $keep in
4634                         0*)     continue ;;
4635                         esac
4636                         for host in $main $share
4637                         do      case " $admin_bin_hosts " in
4638                                 *" $host "*)
4639                                         continue
4640                                         ;;
4641                                 esac
4642                                 eval type=\$${host}_type
4643                                 case " $admin_bin_types " in
4644                                 *" $type "*)
4645                                         continue
4646                                         ;;
4647                                 esac
4648                                 case " $types " in
4649                                 "  ")   ;;
4650                                 *" $type "*)
4651                                         ;;
4652                                 *)      continue
4653                                         ;;
4654                                 esac
4655                                 admin_bin_hosts="$admin_bin_hosts $host"
4656                                 admin_bin_types="$admin_bin_types $type"
4657                                 case " $admin_bin_hosts " in
4658                                 *" $main "*)
4659                                         ;;
4660                                 *)      case " $admin_bin_main " in
4661                                         *" $main "*)
4662                                                 ;;
4663                                         *)      admin_bin_main="$admin_bin_main $main"
4664                                                 ;;
4665                                         esac
4666                                         ;;
4667                                 esac
4668                         done
4669                 done
4670                 local=
4671                 remote=
4672                 for host in $admin_bin_main $admin_bin_hosts
4673                 do      case " $local_hosts " in
4674                         *" $host "*)
4675                                 local="$local $host"
4676                                 ;;
4677                         *)      case " $remote_hosts " in
4678                                 *" $host "*)
4679                                         remote="$remote $host"
4680                                         ;;
4681                                 esac
4682                                 ;;
4683                         esac
4684                 done
4685                 local_hosts=$local
4686                 remote_hosts=$remote
4687                 ;;
4688         esac
4689         for host in $remote_hosts $local_hosts
4690         do      eval share=\$${host}_share
4691                 case $share in
4692                 ?*)     while   :
4693                         do      oshare=$share
4694                                 for s in $share
4695                                 do      eval r='$'${s}_share
4696                                         case $r in
4697                                         ?*)     case " $share " in
4698                                                 *" $r "*)       ;;
4699                                                 *)              share="$share $r" ;;
4700                                                 esac
4701                                                 ;;
4702                                         esac
4703                                 done
4704                                 case $share in
4705                                 $oshare)        eval ${host}_share="'$share'"
4706                                                 break
4707                                                 ;;
4708                                 esac
4709                         done
4710                         ;;
4711                 esac
4712         done
4713         for host in $remote_hosts
4714         do      eval type=\$${host}_type
4715                 case " $local_types " in
4716                 *" $type "*)
4717                         eval ${host}_snarf=
4718                         ;;
4719                 esac
4720                 eval name=\$${host}_name keep=\$${host}_keep share=\$${host}_share
4721                 for share in $share
4722                 do      eval type=\$${share}_type keep=\$keep\$${share}_keep
4723                         case " $local_types " in
4724                         *" $type "*)
4725                                 eval ${share}_snarf=
4726                                 ;;
4727                         esac
4728                 done
4729                 case $keep in
4730                 0*1*)   keep=2$keep ;;
4731                 *1*)    ;;
4732                 *)      keep=0 ;;
4733                 esac
4734                 eval ${host}_keep=$keep
4735         done
4736         for host in $remote_hosts $local_hosts
4737         do      eval name=\$${host}_name user=\$${host}_user type=\$${host}_type sync=\$${host}_sync snarf=\$${host}_snarf share=\$${host}_share rsh=\$${host}_rsh root=\$${host}_root keep=\$${host}_keep
4738                 case $keep in
4739                 0*)     continue ;;
4740                 esac
4741                 case $sync in
4742                 '')     case $admin_action in
4743                         ditto)  continue ;;
4744                         esac
4745                         case $admin_binary in
4746                         1)      case $keep in
4747                                 1*|?*1*);;
4748                                 *)      continue ;;
4749                                 esac
4750                                 ;;
4751                         esac
4752                         ;;
4753                 esac
4754                 eval main_log='$'${host}_log
4755                 main=
4756                 share_keep=
4757                 for i in $host $share
4758                 do      eval n='$'${i}_name t='$'${i}_type q='$'${i}_sync s='$'${i}_snarf l='$'${i}_log k='$'${i}_keep
4759                         case $main:$k in
4760                         :*)     ;;
4761                         *:0)    continue ;;
4762                         esac
4763                         case $admin_binary in
4764                         1)      case $s:$q in
4765                                 :?*)    continue ;;
4766                                 esac
4767                                 case " $admin_bin_hosts " in
4768                                 *" $i "*)
4769                                         ;;
4770                                 *)      continue
4771                                         ;;
4772                                 esac
4773                                 ;;
4774                         esac
4775                         case $main in
4776                         '')     main=$i ;;
4777                         *)      share_keep="$share_keep $i" ;;
4778                         esac
4779                         echo package "$admin_args" "[ $n $t ]"
4780                         case $exec in
4781                         '')     : > $admin_log/$l ;;
4782                         *)      $exec ": > $admin_log/$l" ;;
4783                         esac
4784                 done
4785                 host=$main
4786                 share=$share_keep
4787                 case $force in
4788                 0)      admin_ditto_update=--update ;;
4789                 *)      admin_ditto_update= ;;
4790                 esac
4791                 case $exec in
4792                 '')     {
4793                         case $admin_binary:$sync in
4794                         :?*)    eval syncname='$'${sync}_name
4795                                 test -x $PACKAGEROOT/bin/package && $admin_ditto $admin_ditto_update --remote=$rsh --expr="name=='package'" $PACKAGEROOT/bin $user$syncname:$root/bin
4796                                 test -d $PACKAGESRC && $admin_ditto $admin_ditto_update --remote=$rsh --expr="if(level>1&&path!='LICENSES/*')status=SKIP;path=='LICENSES*|*.(pkg|lic|def)'" $PACKAGESRC $user$syncname:$root/lib/package
4797                                 for dir in $package_src
4798                                 do      case $MAKESKIP in
4799                                         '')     expr="--expr=if(name=='$admin_ditto_skip')status=SKIP" ;;
4800                                         *)      expr="--expr=if(name=='$admin_ditto_skip'||level==1&&name=='$MAKESKIP')status=SKIP" ;;
4801                                         esac
4802                                         test -d $PACKAGEROOT/src/$dir && $admin_ditto $admin_ditto_update --remote=$rsh "$expr" $PACKAGEROOT/src/$dir $user$syncname:$root/src/$dir
4803                                 done
4804                                 ;;
4805                         esac
4806                         case $admin_action in
4807                         ditto)  ;;
4808                         ?*)     pids=
4809                                 set '' $host $share
4810                                 while   :
4811                                 do      shift
4812                                         case $# in
4813                                         0)      break
4814                                                 ;;
4815                                         1)      remote $1
4816                                                 ;;
4817                                         *)      remote $1 &
4818                                                 pids="$pids $!"
4819                                                 ;;
4820                                         esac
4821                                 done
4822                                 case $pids in
4823                                 ?*)     wait $pids ;;
4824                                 esac
4825                                 ;;
4826                         esac
4827                         } < /dev/null > $admin_log/$main_log 2>&1 &
4828                         pids="$pids $!"
4829                         ;;
4830                 *)      echo "{"
4831                         case $admin_binary:$sync in
4832                         :?*)    eval syncname='$'${sync}_name
4833                                 test -d $PACKAGESRC && echo $admin_ditto $admin_ditto_update --remote=$rsh --expr="if(level>1)status=SKIP;name=='*.(pkg|lic|def)'" $PACKAGESRC $user$syncname:$root/lib/package
4834                                 for dir in $package_src
4835                                 do      case $MAKESKIP in
4836                                         '')     expr="--expr=if(name=='$admin_ditto_skip')status=SKIP" ;;
4837                                         *)      expr="--expr=if(name=='$admin_ditto_skip'||level==1&&name=='$MAKESKIP')status=SKIP" ;;
4838                                         esac
4839                                         test -d $PACKAGEROOT/src/$dir && echo $admin_ditto $admin_ditto_update --remote=$rsh "$expr" $PACKAGEROOT/src/$dir $user$syncname:$root/src/$dir
4840                                 done
4841                                 ;;
4842                         esac
4843                         case $admin_action in
4844                         ditto)  ;;
4845                         ?*)     pids=
4846                                 set '' $host $share
4847                                 while   :
4848                                 do      shift
4849                                         case $# in
4850                                         0)      break
4851                                                 ;;
4852                                         1)      remote $1
4853                                                 ;;
4854                                         *)      remote $1 "&"
4855                                                 pids=1
4856                                                 ;;
4857                                         esac
4858                                 done
4859                                 case $pids in
4860                                 1)      echo wait ;;
4861                                 esac
4862                                 ;;
4863                         esac
4864                         echo "} < /dev/null > $admin_log/$main_log 2>&1 &"
4865                         ;;
4866                 esac
4867                 eval name='$'${main}_name
4868                 hosts="$hosts $name"
4869                 logs="$logs $main_log"
4870                 for share in $share
4871                 do      eval keep=\$${share}_keep
4872                         case $keep in
4873                         1)      eval name='$'${share}_name log='$'${share}_log
4874                                 hosts="$hosts $name"
4875                                 logs="$logs $log"
4876                                 ;;
4877                         esac
4878                 done
4879         done
4880         case $exec in
4881         '')     # track the progress
4882                 case $quiet in
4883                 0)      cd $admin_log
4884                         tail -t $PACKAGE_admin_tail_timeout -f $logs
4885                         cd ..
4886                         ;;
4887                 esac
4888                 # wait for the remote actions to complete
4889                 wait
4890                 trap - 1 2 3 15
4891                 # update the db
4892                 exec < $admin_db || exit
4893                 exec 9>&1
4894                 D=`date +%y%m%d`
4895                 while   read line
4896                 do      set -- $line
4897                         case $1 in
4898                         ''|'#'*|*=*)
4899                                 ;;
4900                         *)      case " $hosts " in
4901                                 *" $2 "*)
4902                                         : ast date command assumed :
4903                                         log=$admin_log/$2
4904                                         if      [[ -f $log.$1 ]]
4905                                         then    log=$log.$1
4906                                         fi
4907                                         E=`eval date -E \`egrep '[      ](start|done)[  ][      ]*at[   ]' $log | sed -e 's/.*[         ][      ]*at[   ][      ]*//' -e 's/[   ][      ]*in[   ].*$//' -e 's/.*/"&"/'\``
4908                                         M=$6 T=$7 W=$8
4909                                         case $admin_action in
4910                                         make|view)
4911                                                 M=`egrep -c ']:.* (\*\*\*.* code|don'\''t know) | \*\*\* termination code ' $log` ;;
4912                                         test)   T=`grep -ci 'fail[es]' $log` ;;
4913                                         *)      W=`grep '^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*:.' $log | egrep -cv 'start at|done  at|output captured|warning:|: package not found|whence: command not found'` ;;
4914                                         esac
4915                                         case $1 in
4916                                         ?|??|???|????|?????|??????|???????)
4917                                                 t1='            '
4918                                                 ;;
4919                                         ????????|?????????|??????????|???????????|????????????|?????????????|??????????????|???????????????)
4920                                                 t1='    '
4921                                                 ;;
4922                                         *)      t1=''
4923                                                 ;;
4924                                         esac
4925                                         case $2 in
4926                                         ?|??|???|????|?????|??????|???????)
4927                                                 t2='    '
4928                                                 ;;
4929                                         *)      t2=''
4930                                                 ;;
4931                                         esac
4932                                         case $3 in
4933                                         ?|??|???|????|?????|??????|???????)
4934                                                 t3='    '
4935                                                 ;;
4936                                         *)      t3=''
4937                                                 ;;
4938                                         esac
4939                                         case $E in
4940                                         ?????)  E=" $E" ;;
4941                                         ????)   E="  $E" ;;
4942                                         ???)    E="   $E" ;;
4943                                         ??)     E="    $E" ;;
4944                                         ?)      E="     $E" ;;
4945                                         esac
4946                                         case $M in
4947                                         ???)    M="$M" ;;
4948                                         ??)     M=" $M" ;;
4949                                         ?)      M="  $M" ;;
4950                                         '')     M="  0" ;;
4951                                         esac
4952                                         case $T in
4953                                         ???)    T="$T" ;;
4954                                         ??)     T=" $T" ;;
4955                                         ?)      T="  $T" ;;
4956                                         '')     T="  0" ;;
4957                                         esac
4958                                         case $W in
4959                                         ???)    W="$W" ;;
4960                                         ??)     W=" $W" ;;
4961                                         ?)      W="  $W" ;;
4962                                         '')     W="  0" ;;
4963                                         esac
4964                                         A=$1$t1
4965                                         H=$2$t2
4966                                         R=$3$t3
4967                                         case $# in
4968                                         [0-8])  O=
4969                                                 K=
4970                                                 ;;
4971                                         *)      shift 8
4972                                                 O=$1
4973                                                 K=$2
4974                                                 case $O in
4975                                                 ''|?|??|???)    K="     $K" ;;
4976                                                 esac
4977                                                 case $# in
4978                                                 [0-2])  ;;
4979                                                 *)      K="$K $*" ;;
4980                                                 esac
4981                                                 ;;
4982                                         esac
4983                                         echo "$A        $H      $R      $D      $E      $M $T $W $O     $K"
4984                                         echo "$A        $H      $R      $D      $E      $M $T $W $O     $K" >&9
4985                                         continue
4986                                         ;;
4987                                 esac
4988                                 ;;
4989                         esac
4990                         echo "$line"
4991                 done > $admin_db.new
4992                 mv $admin_db $admin_db.old
4993                 mv $admin_db.new $admin_db
4994                 ;;
4995         esac
4996         ;;
4998 clean|clobber)
4999         cd $PACKAGEROOT
5000         $exec rm -rf $INSTALLROOT
5001         exit
5002         ;;
5004 contents|list)
5005         # all work in $PACKAGESRC
5007         cd $PACKAGESRC
5009         # generate the package list
5011         set '' $target $package
5012         shift
5013         argc=$#
5014         case $# in
5015         0)      set '' *.pkg
5016                 case $2 in
5017                 '*.pkg')
5018                         echo $command: $action: no packages >&2
5019                         exit 1
5020                         ;;
5021                 esac
5022                 set '' `echo $* | sed 's,\.pkg,,g'`
5023                 shift
5024                 ;;
5025         esac
5026         sep="$nl    "
5027         echo packages in $PACKAGEROOT
5028         case $action in
5029         list)   echo
5030                 echo "NAME${nl}VERSION${nl}RELEASE${nl}TYPE${nl}STATUS${nl}REQUIRES${nl}----${nl}-------${nl}-------${nl}----${nl}------${nl}--------" | pr -6 -a -o4 -t
5031                 ;;
5032         esac
5033         {
5034         omit=:
5035         for pkg
5036         do      if      test ! -f $pkg.pkg
5037                 then    echo $command: $action: $pkg: not a package >&2
5038                 else    if      test -f gen/$pkg.ver
5039                         then    set '' `cat gen/$pkg.ver`
5040                                 case $3 in
5041                                 $2)     ver=base ;;
5042                                 *)      ver=$3 ;;
5043                                 esac
5044                                 if      test -s tgz/$pkg.tim
5045                                 then    sts=local
5046                                 else    sts=
5047                                 fi
5048                         else    ver=
5049                                 sts=unwritten
5050                         fi
5051                         typ=
5052                         txt=
5053                         cmp= cmp_sep=
5054                         req= req_sep=
5055                         op=::
5056                         exec < $pkg.pkg
5057                         while   read line
5058                         do      IFS='   \\'
5059                                 set '' $line
5060                                 IFS=$ifs
5061                                 while   :
5062                                 do      shift
5063                                         case $# in
5064                                         0)      break ;;
5065                                         esac
5066                                         case $1 in
5067                                         :*:)    op=$1
5068                                                 ;;
5069                                         INIT|'$('*|*')')
5070                                                 ;;
5071                                         *)      case $op in
5072                                                 :DESCRIPTION:)
5073                                                         txt="$txt$sep$line"
5074                                                         break
5075                                                         ;;
5076                                                 :PACKAGE:)
5077                                                         cmp="$cmp$cmp_sep$1"
5078                                                         cmp_sep=$nl
5079                                                         ;;
5080                                                 :REQUIRES:)
5081                                                         req="$req$req_sep$1"
5082                                                         req_sep=" "
5083                                                         ;;
5084                                                 esac
5085                                                 ;;
5086                                         esac
5087                                 done
5088                         done
5089                         exec < /dev/null
5090                         case $txt in
5091                         ?*)     txt="$nl$txt" ;;
5092                         esac
5093                         case :$ver: in
5094                         *::*)   ;;
5095                         *)      case $action in
5096                                 list)   case $sts in
5097                                         '')     case `ls -t "tgz/$pkg.$ver.base" "tgz/$pkg.tim" 2>/dev/null` in
5098                                                 "tgz/$pkg.tim"*)
5099                                                         sts=read
5100                                                         ;;
5101                                                 *)      sts=unread
5102                                                         ;;
5103                                                 esac
5104                                                 ;;
5105                                         esac
5106                                         echo "$pkg${nl}$ver${nl}base${nl}$typ${nl}$sts${nl}$req"
5107                                         case $typ in
5108                                         '')     omit=$omit$pkg.$ver.base: ;;
5109                                         esac
5110                                         ;;
5111                                 *)      case $req in
5112                                         ?*)     req=": $req" ;;
5113                                         esac
5114                                         echo
5115                                         echo $pkg $ver $req "$txt"
5116                                         case $cmp in
5117                                         ?*)     echo "${sep}Components in this package:$nl"
5118                                                 echo "$cmp" | pr -4 -o4 -t ;;
5119                                         esac
5120                                         ;;
5121                                 esac
5122                                 ;;
5123                         esac
5124                 fi
5125         done
5126         case $argc:$action in
5127         0:list) if      test -d tgz
5128                 then    cd tgz
5129                         # f:file p:package v:version r:release t:type u:update
5130                         for f in `find . -name '*?[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]*' -print | sed 's,^\./,,' | sort -r`
5131                         do      eval `echo "$f" | sed -e 's,\.c$,,' -e 's,\.gz$,,' -e 's,\.exe$,,' -e 's,\.tgz$,,' -e 's,\([^_.]*\)[_.]\([0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]\)[_.]\([0123456789][0123456789][0123456789][0123456789][^_.]*\)[_.]*\(.*\),p=\1 v=\2 r=\3 t=\4,' -e 's,\([^_.]*\)[_.]\([0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]\)[_.]*\(.*\),p=\1 v=\2 r=base t=\3,'`
5132                                 case $t in
5133                                 '')     case $omit in
5134                                         *:$p.$v.$r:*)   continue ;;
5135                                         esac
5136                                         u=$p.tim
5137                                         ;;
5138                                 *)      u=$p.$t.tim
5139                                         ;;
5140                                 esac
5141                                 if      test -s "$u"
5142                                 then    s=local
5143                                 elif    test -f "$u"
5144                                 then    case `ls -t "$f" "$u" 2>/dev/null` in
5145                                         "$u"*)  s=read ;;
5146                                         *)      s=unread ;;
5147                                         esac
5148                                 else    s=unread
5149                                 fi
5150                                 echo "$p$nl$v$nl$r$nl$t$nl$s$nl"
5151                         done
5152                 fi
5153                 ;;
5154         esac
5155         } |
5156         case $action in
5157         list)   pr -6 -a -o4 -t | sort -u ;;
5158         *)      cat ;;
5159         esac
5160         case $argc in
5161         0)      if      test -d $PACKAGEROOT/arch
5162                 then    echo
5163                         echo architectures in $PACKAGEROOT
5164                         echo
5165                         for i in `ls $PACKAGEROOT/arch`
5166                         do      if      test -f $PACKAGEROOT/arch/$i/lib/package/gen/host
5167                                 then    h=`cat $PACKAGEROOT/arch/$i/lib/package/gen/host`
5168                                 else    h=
5169                                 fi
5170                                 echo $i
5171                                 echo $h
5172                                 echo
5173                                 echo
5174                         done | pr -4 -a -o4 -t
5175                 fi
5176                 ;;
5177         esac
5178         ;;
5180 copyright)
5181         # all work in $PACKAGESRC
5183         cd $PACKAGESRC
5185         # generate the package list
5187         set '' $target $package
5188         shift
5189         argc=$#
5190         case $# in
5191         0)      set '' `echo *.lic | sed 's,\.lic,,g'`
5192                 shift
5193                 case $1 in
5194                 '*')    echo $command: $action: no packages >&2
5195                         exit 1
5196                         ;;
5197                 esac
5198                 ;;
5199         esac
5200         checkaout proto || exit
5201         for i
5202         do      copyright $i
5203         done
5204         ;;
5206 export) case $INSTALLROOT in
5207         $PACKAGEROOT)
5208                 INSTALLROOT=$INSTALLROOT/arch/$HOSTTYPE
5209                 ;;
5210         esac
5211         case $only in
5212         0)      v='$i=' ;;
5213         *)      v= ;;
5214         esac
5215         set '' $target $package
5216         case $# in
5217         1)      set '' $env ;;
5218         esac
5219         while   :
5220         do      case $# in
5221                 1)      break ;;
5222                 esac
5223                 shift
5224                 i=$1
5225                 eval echo ${v}'$'${i}
5226         done
5227         ;;
5229 install)cd $PACKAGEROOT
5230         set '' $package
5231         shift
5232         case $only in
5233         0)      set '' `order "$@"`
5234                 shift
5235                 ;;
5236         esac
5237         case $# in
5238         0)      echo "$command: at least one package name expected" >&2
5239                 exit 1
5240                 ;;
5241         esac
5242         package=$*
5243         requirements - $package
5244         set '' $target
5245         shift
5246         case $1 in
5247         flat)   flat=1 # backwards compatibility -- documentation dropped
5248                 shift
5249                 ;;
5250         esac
5251         case $# in
5252         0)      echo "$command: $action: target directory argument expected" >&2
5253                 exit 1
5254                 ;;
5255         esac
5256         target=
5257         while   :
5258         do      case $# in
5259                 1)      directory=$1
5260                         break
5261                         ;;
5262                 esac
5263                 target="$target $1"
5264                 shift
5265         done
5266         if      test ! -d $directory
5267         then    echo "$command: $action: $directory: target directory not found" >&2
5268                 exit 1
5269         fi
5270         case $target in
5271         '')     cd arch
5272                 set '' *
5273                 shift
5274                 target=$*
5275                 cd ..
5276                 ;;
5277         esac
5278         code=0
5279         makecheck=1
5280         for a in $target
5281         do      case $a in
5282                 -)      a=$HOSTTYPE ;;
5283                 esac
5284                 case $flat:$a in
5285                 1:*|?:.)dest=$directory
5286                         ;;
5287                 *)      dest=$directory/arch/$a
5288                         if      test "" = "$exec" -a ! -d $dest
5289                         then    mkdir -p $dest || {
5290                                         echo "$command: $dest: destination directory must exist" >&2
5291                                         exit 1
5292                                 }
5293                         fi
5294                         ;;
5295                 esac
5296                 for i in $package
5297                 do      if      test "ratz" = "$i"
5298                         then    : skip
5299                         elif    test -f arch/$a/lib/package/gen/$i.sum
5300                         then    package_install $directory arch/$a/lib/package/gen/$i.sum || code=1
5301                         elif    test ! -d arch/$a/bin
5302                         then    echo "$command: $a: invalid architecture" >&2
5303                         elif    test ! -d $dest
5304                         then    echo "$command: $dest: destination directory must exist" >&2
5305                         else    if      test "" != "$makecheck"
5306                                 then    if      onpath $MAKE
5307                                         then    MAKE=$_onpath_
5308                                         else    echo "$command: $MAKE: not found" >&2
5309                                                 exit 1
5310                                         fi
5311                                         makecheck=
5312                                 fi
5313                                 if      test "" != "$exec"
5314                                 then    (
5315                                                 trap - 0 1 2 15
5316                                                 echo "=== $i installation manifest ==="
5317                                                 cd arch/$a
5318                                                 (
5319                                                 cd lib/package
5320                                                 INSTALLROOT=$PACKAGEROOT/arch/$a
5321                                                 VPATH=$INSTALLROOT:$PACKAGEROOT:$VPATH
5322                                                 export INSTALLROOT VPATH
5323                                                 $MAKE -s $makeflags -f $i.pkg $qualifier list.installed $assign
5324                                                 ) | sort -u
5325                                         )
5326                                 else    (
5327                                                 set -
5328                                                 cd arch/$a
5329                                                 (
5330                                                 cd lib/package
5331                                                 INSTALLROOT=$PACKAGEROOT/arch/$a
5332                                                 VPATH=$INSTALLROOT:$PACKAGEROOT:$VPATH
5333                                                 export INSTALLROOT VPATH
5334                                                 echo lib/$command
5335                                                 $MAKE -s $makeflags -f $i.pkg $qualifier list.installed $assign
5336                                                 ) | sort -u | pax -drw -ps $dest
5337                                         )
5338                                 fi
5339                         fi
5340                 done
5341         done
5342         exit $code
5343         ;;
5345 license)# all work in $PACKAGESRC/LICENSES
5347         cd $PACKAGESRC/LICENSES || exit
5349         # generate the package list
5351         set '' $target $package
5352         shift
5353         argc=$#
5354         case $# in
5355         0)      set '' *
5356                 shift
5357                 case $1 in
5358                 '*')    echo $command: $action: no licenses >&2
5359                         exit 1
5360                         ;;
5361                 esac
5362                 ;;
5363         *)      checkaout proto || exit
5364                 a=
5365                 for i
5366                 do      while   :
5367                         do      if      test -f ../$i.lic
5368                                 then    j=`proto -df -l ../$i.lic -o query=type /dev/null 2>/dev/null`
5369                                         case $j in
5370                                         ?*)     if      test -f $j
5371                                                 then    case " $a " in
5372                                                         *" $j "*)       ;;
5373                                                         *)              a="$a $j" ;;
5374                                                         esac
5375                                                 fi
5376                                                 break
5377                                                 ;;
5378                                         esac
5379                                 fi
5380                                 case $i in
5381                                 *-*)    i=`echo $i | sed 's/-[^-]*$//'`
5382                                         ;;
5383                                 *)      echo "$command: $i: package license not found" >&2
5384                                         break
5385                                         ;;
5386                                 esac
5387                         done
5388                 done
5389                 set '' $a
5390                 shift
5391                 ;;
5392         esac
5393         for i
5394         do      case $exec in
5395                 '')     echo
5396                         echo "          --- $i source license ---"
5397                         echo
5398                         cat $i
5399                         ;;
5400                 *)      echo $PACKAGESRC/LICENSES/$i
5401                         ;;
5402                 esac
5403         done
5404         ;;
5406 make|view)
5407         cd $PACKAGEROOT
5408         case $package in
5409         '')     lic="lib/package/*.lic"
5410                 ;;
5411         *)      for i in $package
5412                 do      lic="$lic lib/package/$i.lic"
5413                         case $i in
5414                         *-*)    lic="$lic lib/package/"`echo $i | sed 's,-.*,,'`".lic" ;;
5415                         esac
5416                 done
5417                 ;;
5418         esac
5419         checksrc
5420         requirements source $package
5421         components $package
5422         package=$_components_
5424         # check for some required commands
5426         must="$AR"
5427         warn="$NM yacc bison"
5428         test="$must $warn"
5429         have=
5430         IFS=:
5431         set /$IFS$PATH
5432         IFS=$ifs
5433         shift
5434         for t in $test
5435         do      if      executable $t
5436                 then    have="$have $t"
5437                 fi
5438         done
5439         for d
5440         do      for t in $test
5441                 do      case " $have " in
5442                         *" $t "*)
5443                                 ;;
5444                         *)      if      executable $d/$t
5445                                 then    have="$have $t"
5446                                 fi
5447                                 ;;
5448                         esac
5449                 done
5450         done
5451         case " $have " in
5452         *" bison "*)    ;;
5453         *" yacc "*)     have="$have bison" ;;
5454         esac
5455         case " $have " in
5456         *" yacc "*)     ;;
5457         *" bison "*)    have="$have yacc" ;;
5458         esac
5459         for t in $test
5460         do      case " $have " in
5461                 *" $t "*)
5462                         ;;
5463                 *)      case " $must " in
5464                         *" $t "*)
5465                                 echo "$command: $t: not found -- must be on PATH to $action" >&2
5466                                 exit 1
5467                                 ;;
5468                         *)      echo "$command: warning: $t: not found -- some $action actions may fail" >&2
5469                                 ;;
5470                         esac
5471                         ;;
5472                 esac
5473         done
5475         # verify the top view
5477         if      test ! -d $PACKAGEROOT/src
5478         then    note no source packages to make
5479                 exit 0
5480         elif    test ! -d $INSTALLROOT/src
5481         then    note initialize the $INSTALLROOT view
5482         fi
5483         for i in arch arch/$HOSTTYPE
5484         do      test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
5485         done
5486         for i in bin fun include lib lib/package lib/package/gen src man man/man1 man/man3 man/man8 $OK $OK/bin $OK/lib
5487         do      test -d $INSTALLROOT/$i || $exec mkdir $INSTALLROOT/$i || exit
5488         done
5489         make_recurse src
5490         o= k=
5491         for i in $makefiles
5492         do      case $o in
5493                 ?*)     o="$o -o" k="$k|" ;;
5494                 esac
5495                 o="$o -name $i"
5496                 k="$k$i"
5497         done
5498         o="( $o ) -print"
5499         for d in $package_src
5500         do      i=src/$d
5501                 if      test -d $i
5502                 then    test -d $INSTALLROOT/$i || $exec mkdir $INSTALLROOT/$i || exit
5503                         make_recurse $i
5504                         for j in `cd $i; find . $o 2>/dev/null | sed -e 's,^\./,,' -e '/\//!d' -e 's,/[^/]*$,,' | sort -u`
5505                         do      case $j in
5506                                 $k|$MAKESKIP) continue ;;
5507                                 esac
5508                                 test -d $INSTALLROOT/$i/$j ||
5509                                 $exec mkdir -p $INSTALLROOT/$i/$j || exit
5510                         done
5511                 fi
5512         done
5513         def=
5514         for i in $lic
5515         do      test -f $i || continue
5516                 cmp -s $i $INSTALLROOT/$i 2>/dev/null ||
5517                 $exec cp $PACKAGEROOT/$i $INSTALLROOT/$i
5518                 for j in `grep '^. .*\.def$' $i`
5519                 do      case $j in
5520                         .)      ;;
5521                         *)      case " $def " in
5522                                 *" $i "*)       ;;
5523                                 *)              def="$def $i" ;;
5524                                 esac
5525                                 ;;
5526                         esac
5527                 done
5528         done
5529         for i in $def
5530         do      i=lib/package/$i
5531                 test -f $i || continue
5532                 cmp -s $i $INSTALLROOT/$i 2>/dev/null ||
5533                 $exec cp $PACKAGEROOT/$i $INSTALLROOT/$i
5534         done
5536         # check $CC and { ar cc ld ldd } intercepts
5538         h="${HOSTTYPE} ${HOSTTYPE}.*"
5539         case $HOSTTYPE in
5540         *.*)    t=`echo $HOSTTYPE | sed 's/[.][^.]*//'`
5541                 h="$h $t"
5542                 ;;
5543         *)      t=$HOSTTYPE
5544                 ;;
5545         esac
5546         case $t in
5547         *[0123456789])
5548                 t=`echo $t | sed 's/[0123456789]*$//'`
5549                 h="$h $t"
5550                 ;;
5551         esac
5552         case $CC in
5553         cc)     c=cc
5554                 b=$INSTALLROOT/bin/$c
5555                 t=$INSTALLROOT/lib/package/gen/$c.tim
5556                 intercept=0
5557                 for k in $h
5558                 do      for s in $INITROOT/$c.$k
5559                         do      test -x "$s" || continue
5560                                 if      cmp -s "$s" "$b" >/dev/null 2>&1
5561                                 then    intercept=1
5562                                         break 2
5563                                 fi
5564                                 case `ls -t "$t" "$b" "$s" 2>/dev/null` in
5565                                 $t*)    ;;
5566                                 $b*)    cc=$b
5567                                         ;;
5568                                 $s*)    cd $INSTALLROOT/lib/package/gen
5569                                         tmp=pkg$pid
5570                                         eval '$'exec echo "'int main(){return 0;}' > $tmp.c"
5571                                         if      $exec $s -o $tmp.exe $tmp.c >/dev/null 2>&1 &&
5572                                                 test -x $tmp.exe
5573                                         then    case $HOSTTYPE in
5574                                                 *.mips*)$s -version >/dev/null 2>&1 || s= ;;
5575                                                 esac
5576                                                 case $s in
5577                                                 ?*)     $exec sed "s/^HOSTTYPE=.*/HOSTTYPE=$HOSTTYPE/" < "$s" > "$b" || exit
5578                                                         $exec chmod +x "$b" || exit
5579                                                         cc=$b
5580                                                         intercept=1
5581                                                         note update $b
5582                                                         ;;
5583                                                 esac
5584                                         fi
5585                                         $exec rm -f $tmp.*
5586                                         $exec touch "$t"
5587                                         cd $PACKAGEROOT
5588                                         ;;
5589                                 esac
5590                                 break 2
5591                         done
5592                 done
5593                 case $intercept in
5594                 1)      c=ld
5595                         b=$INSTALLROOT/bin/$c
5596                         for k in $h
5597                         do      for s in $INITROOT/$c.$k
5598                                 do      test -x "$s" || continue
5599                                         case `ls -t "$b" "$s" 2>/dev/null` in
5600                                         $b*)    ;;
5601                                         $s*)    $exec cp "$s" "$b"
5602                                                 note update $b
5603                                                 ;;
5604                                         esac
5605                                 done
5606                         done
5607                         ;;
5608                 esac
5609                 ;;
5610         esac
5611         c=ldd
5612         b=$INSTALLROOT/bin/$c
5613         for t in $h
5614         do      s=$INITROOT/$c.$t
5615                 test -x "$s" || continue
5616                 onpath $c ||
5617                 case `ls -t "$b" "$s" 2>/dev/null` in
5618                 $b*)    ;;
5619                 $s*)    $exec cp "$s" "$b"
5620                         note update $b
5621                         ;;
5622                 esac
5623         done
5624 # following code stubbed out just in case ar.ibm.risc is needed
5625 #       c=ar
5626 #       b=$INSTALLROOT/bin/$c
5627 #       for t in $h
5628 #       do      s=$INITROOT/$c.$t
5629 #               test -x "$s" || continue
5630 #               onpath $c ||
5631 #               case `ls -t "$b" "$s" 2>/dev/null` in
5632 #               $b*)    ;;
5633 #               $s*)    x=`$s -tv /foo/bar.a 2>&1 | egrep -i 'option|usage'`
5634 #                       case $x in
5635 #                       '')     $exec cp "$s" "$b"
5636 #                               note update $b
5637 #                               ;;
5638 #                       esac
5639 #                       ;;
5640 #               esac
5641 #       done
5642         case $cc in
5643         /*)     ;;
5644         *)      echo "$command: $CC: not found -- set CC=C-compiler" >&2
5645                 exit 1
5646                 ;;
5647         esac
5648         case $exec in
5649         '')     cd $INSTALLROOT/lib/package/gen
5650                 tmp=pkg$pid
5651                 echo 'int main(){return 0;}' > $tmp.c
5652                 if      $CC -o $tmp.exe $tmp.c > /dev/null 2> $tmp.err &&
5653                         test -x $tmp.exe
5654                 then    : ok
5655                 else    echo "$command: $CC: failed to compile this program:" >&2
5656                         cat $tmp.c >&2
5657                         if      test -s $tmp.err
5658                         then    cat $tmp.err >&2
5659                         else    echo "$command: $CC: not a C compiler" >&2
5660                         fi
5661                         rm -f $tmp.*
5662                         exit 1
5663                 fi
5664                 rm -f $tmp.*
5665                 cd $PACKAGEROOT
5666                 ;;
5667         esac
5669         # remember the default $CC
5671         case $CC in
5672         cc)     ;;
5673         *)      if      test -x $INSTALLROOT/bin/cc
5674                 then    case `sed 1q $INSTALLROOT/bin/cc` in
5675                         ": $CC :")
5676                                 CC=cc
5677                                 export CC
5678                                 ;;
5679                         *)      assign="$assign CC=\"\$CC\""
5680                                 ;;
5681                         esac
5682                 else    case $CROSS in
5683                         1)      assign="$assign CC=\"\$CC\""
5684                                 ;;
5685                         *)      case $exec in
5686                                 '')     {
5687                                         echo ": $CC :"
5688                                         echo "$CC \"\$@\""
5689                                         } > $INSTALLROOT/bin/cc
5690                                         chmod +x $INSTALLROOT/bin/cc
5691                                         ;;
5692                                 *)      note generate a $INSTALLROOT/bin/cc wrapper for $CC
5693                                         ;;
5694                                 esac
5695                                 CC=cc
5696                                 export CC
5697                                 ;;
5698                         esac
5699                 fi
5700                 ;;
5701         esac
5703         # no $INITROOT means INIT already installed elsewhere
5705         if      test -d $INITROOT
5706         then
5707                 # update probe scripts
5709                 for i in lib/probe lib/probe/C lib/probe/C/make
5710                 do      test -d $INSTALLROOT/$i || $exec mkdir $INSTALLROOT/$i || exit
5711                 done
5712                 i=$INSTALLROOT/lib/probe/C/make/probe
5713                 j=$INITROOT/C+probe
5714                 k=$INITROOT/make.probe
5715                 case `ls -t $i $j $k 2>/dev/null` in
5716                 $i*)    ;;
5717                 *)      if      test -f $j -a -f $k
5718                         then    note update $i
5719                                 shellmagic
5720                                 case $exec in
5721                                 '')     {
5722                                         case $SHELLMAGIC in
5723                                         ?*)     echo "$SHELLMAGIC" ;;
5724                                         esac
5725                                         cat $j $k
5726                                         } > $i || exit
5727                                         ;;
5728                                 *)      echo "{
5729 echo $SHELLMAGIC
5730 cat $j $k
5731 } > $i"
5732                                         ;;
5733                                 esac
5734                                 $exec chmod +x $i || exit
5735                         fi
5736                         ;;
5737                 esac
5738         fi
5740         # initialize a few mamake related commands
5742         checkaout mamake proto ratz release || exit
5744         # execrate if necessary
5746         if      (execrate) >/dev/null 2>&1
5747         then    execrate=execrate
5748                 $make cd $INSTALLROOT/$OK/bin
5749                 for i in chmod chgrp cmp cp ln mv rm
5750                 do      if      test ! -x $i -a -x /bin/$i.exe
5751                         then    shellmagic
5752                                 case $exec in
5753                                 '')     echo "$SHELLMAGIC"'execrate /bin/'$i' "$@"' > $i
5754                                         chmod +x $i
5755                                         ;;
5756                                 *)      $exec echo \'"$SHELLMAGIC"'execrate /bin/'$i' "$@"'\'' >' $i
5757                                         $exec chmod +x $i
5758                                         ;;
5759                                 esac
5760                         fi
5761                 done
5762                 PATH=$INSTALLROOT/$OK/bin:$PATH
5763                 export PATH
5764         else    execrate=
5765         fi
5766         case $action in
5767         view)   exit 0 ;;
5768         esac
5770         # all work under $INSTALLROOT/src
5772         $make cd $INSTALLROOT/src
5774         # record the build host name
5776         case $noexec in
5777         '')     hostinfo name
5778                 echo "$_hostinfo_" | sed 's,\..*,,' > $PACKAGEBIN/gen/host
5779                 ;;
5780         esac
5782         # make in parallel if possible
5784         case $NPROC in
5785         '')     hostinfo cpu
5786                 case $_hostinfo_ in
5787                 0|1)    ;;
5788                 *)      NPROC=$_hostinfo_
5789                         $show NPROC=$NPROC
5790                         $show export NPROC
5791                         export NPROC
5792                         ;;
5793                 esac
5794                 ;;
5795         esac
5797         # separate flags from target list
5799         case $target in
5800         *-*)    a=
5801                 for t in $target
5802                 do      case $t in
5803                         -[eiknFKNV]*|--*-symbols)
5804                                 makeflags="$makeflags $t"
5805                                 ;;
5806                         -*)     nmakeflags="$nmakeflags $t"
5807                                 ;;
5808                         *)      a="$a $t"
5809                                 ;;
5810                         esac
5811                 done
5812                 target=$a
5813                 ;;
5814         esac
5816         # generate nmake first if possible
5818         if      executable ! $NMAKE && test -d $PACKAGEROOT/src/cmd/nmake
5819         then    if      nonmake $MAKE
5820                 then    note make $NMAKE with mamake
5821                         c=$CC
5822                         a=$assign
5823                         case $HOSTTYPE in
5824                         win32*|cygwin*)
5825                                 CC="$CC -D_BLD_STATIC"
5826                                 accept="libast"
5827                                 case $assign in
5828                                 *' CC='*)       ;;
5829                                 *)              assign="$assign CC=\"\$CC\"" ;;
5830                                 esac
5831                                 ;;
5832                         *)      accept=nmake
5833                                 ;;
5834                         esac
5835                         eval capture mamake \$makeflags \$nmakeflags \$noexec install nmake $assign
5836                         assign=$a
5837                         CC=$c
5838                         case $make$noexec in
5839                         '')     if      executable ! $NMAKE
5840                                 then    echo "$command: $action: errors making $NMAKE" >&2
5841                                         exit 1
5842                                 fi
5843                                 ;;
5844                         *)      make=echo
5845                                 ;;
5846                         esac
5847                         if      test '' != "$PROTOROOT"
5848                         then    if      (vpath $INSTALLROOT - $PROTOROOT - $INSTALLROOT $PACKAGEROOT) >/dev/null 2>&1 &&
5849                                          vpath $INSTALLROOT - $PROTOROOT - $INSTALLROOT $PACKAGEROOT
5850                                 then    $show vpath $INSTALLROOT $PACKAGEROOT $USER_VPATH_CHAIN
5851                                 else    VPATH=$INSTALLROOT:$PACKAGEROOT$USER_VPATH
5852                                         $show VPATH=$VPATH
5853                                         export VPATH
5854                                 fi
5855                         fi
5856                         note believe generated files for $accept
5857                         eval capture \$NMAKE \$makeflags \$nmakeflags \$noexec recurse believe \$nmakesep $accept $assign
5858                         $exec touch $INSTALLROOT/bin/.paths
5859                         note make the remaining targets with $NMAKE
5860                 else    eval capture $MAKE \$makeflags \$nmakeflags \$noexec install nmake $assign
5861                         case $make$noexec in
5862                         '')     if      executable ! $NMAKE
5863                                 then    echo "$command: $action: errors making $NMAKE" >&2
5864                                         exit 1
5865                                 fi
5866                                 ;;
5867                         *)      make=echo
5868                                 ;;
5869                         esac
5870                 fi
5871         fi
5873         # generate ksh next if possible
5875         if      nonmake $MAKE
5876         then    : no need to generate ksh next -- it could be the only package
5877         elif    test "$KEEP_SHELL" != 1 -a -d $PACKAGEROOT/src/cmd/ksh93 && executable ! $KSH
5878         then    eval capture nmake $nmakeflags \$makeflags \$noexec install ksh93 $assign
5879                 case $make$noexec in
5880                 '')     if      executable ! $KSH
5881                         then    echo "$command: $action: warning: errors making $KSH" >&2
5882                         fi
5883                         ;;
5884                 *)      make=echo
5885                         ;;
5886                 esac
5887         fi
5889         # mamprobe data should have been generated by this point
5891         case $exec in
5892         '')     if      test ! -f $INSTALLROOT/bin/.paths -o -w $INSTALLROOT/bin/.paths
5893                 then    N='
5895                         a= b= f= h= n= p= u= B= L=
5896                         if      test -f $INSTALLROOT/bin/.paths
5897                         then    exec < $INSTALLROOT/bin/.paths
5898                                 while   read x
5899                                 do      case $x in
5900                                         '#'?*)          case $h in
5901                                                         '')     h=$x ;;
5902                                                         esac
5903                                                         ;;
5904                                         *BIN=*)         a=$x
5905                                                         ;;
5906                                         *BUILTIN_LIB=*) b=$x
5907                                                         ;;
5908                                         *FPATH=*)       f=$x
5909                                                         ;;
5910                                         *PLUGIN_LIB=*)  p=$x
5911                                                         ;;
5912                                         *)              case $u in
5913                                                         ?*)     u=$u$N ;;
5914                                                         esac
5915                                                         u=$u$x
5916                                                         ;;
5917                                         esac
5918                                 done
5919                         fi
5920                         ifs=$IFS
5921                         m=
5922                         case $p in
5923                         ?*)     b=
5924                                 ;;
5925                         esac
5926                         case $a in
5927                         '')     a="BIN=1"
5928                                 m=1
5929                                 ;;
5930                         esac
5931                         case $b in
5932                         ?*)     IFS='='
5933                                 set $b
5934                                 IFS=$ifs
5935                                 shift
5936                                 p="PLUGIN_LIB=$*"
5937                                 case $b in
5938                                 [Nn][Oo]*)      p=no$p ;;
5939                                 esac
5940                                 m=1
5941                                 ;;
5942                         esac
5943                         case $f in
5944                         '')     f="FPATH=../fun"
5945                                 m=1
5946                                 ;;
5947                         esac
5948                         case $h in
5949                         '')     h='# use { no NO } prefix to permanently disable #' ;;
5950                         esac
5951                         case $p in
5952                         '')     p="PLUGIN_LIB=cmd"
5953                                 if      grep '^setv mam_cc_DIALECT .* EXPORT=[AD]LL' $INSTALLROOT/lib/probe/C/mam/* >/dev/null 2>&1
5954                                 then    p=no$p
5955                                 fi
5956                                 m=1
5957                                 ;;
5958                         esac
5959                         case $m in
5960                         1)      case $u in
5961                                 ?*)     u=$N$u ;;
5962                                 esac
5963                                 echo "$h$N$a$N$p$N$f$N$u" > $INSTALLROOT/bin/.paths
5964                                 ;;
5965                         esac
5966                 fi
5967                 ;;
5968         esac
5970         # run from separate copies since nmake and ksh may be rebuilt
5972         case $EXECROOT in
5973         $INSTALLROOT)
5974                 $make cd $INSTALLROOT/bin
5975                 if      executable /bin/cp
5976                 then    cp=/bin/cp
5977                 else    cp=cp
5978                 fi
5979                 if      executable /bin/mv
5980                 then    mv=/bin/mv
5981                 else    mv=mv
5982                 fi
5983                 if      executable /bin/rm
5984                 then    rm=/bin/rm
5985                 else    rm=rm
5986                 fi
5987                 for i in \
5988                         ksh nmake tee cp ln mv rm \
5989                         *ast*.dll *cmd*.dll *dll*.dll *shell*.dll
5990                 do      executable $i && {
5991                                 cmp -s $i ../$OK/bin$i 2>/dev/null || {
5992                                         test -f ../$OK/bin/$i &&
5993                                         $exec $execrate $rm ../$OK/bin/$i </dev/null
5994                                         test -f ../$OK/bin/$i &&
5995                                         $exec $execrate $mv ../$OK/bin/$i ../$OK/bin/$i.old </dev/null
5996                                         test -f ../$OK/bin/$i &&
5997                                         case $exec:$i in
5998                                         :nmake|:ksh)
5999                                                 echo "$command: ../$OK/bin/$i: cannot update [may be in use by a running process] remove manually and try again" >&2
6000                                                 exit 1
6001                                                 ;;
6002                                         esac
6003                                         $exec $execrate $cp $i ../$OK/bin/$i
6004                                 }
6005                         }
6006                 done
6007                 if      executable ../$OK/bin/nmake
6008                 then    MAKE="$INSTALLROOT/$OK/bin/nmake LOCALRULESPATH=$INSTALLROOT/$OK/lib/make"
6009                 fi
6010                 if      executable ../$OK/bin/tee
6011                 then    TEE=$INSTALLROOT/$OK/bin/tee
6012                 fi
6013                 $make cd $INSTALLROOT/lib
6014                 for i in *ast.* *cmd.* *dll.* *shell.*
6015                 do      case $i in
6016                         *.a)    ;;
6017                         *)      cmp -s $i ../$OK/lib/$i || $exec $cp -f $i ../$OK/lib ;;
6018                         esac
6019                 done
6020                 if      test "$KEEP_SHELL" != 1 && executable $INSTALLROOT/$OK/bin/ksh
6021                 then    SHELL=$INSTALLROOT/$OK/bin/ksh
6022                         export SHELL
6023                         COSHELL=$SHELL
6024                         export COSHELL
6025                 fi
6026                 case :$PATH: in
6027                 *:$INSTALLROOT/$OK:*)
6028                         ;;
6029                 *)      PATH=$INSTALLROOT/$OK/bin:$PATH
6030                         export PATH
6031                         ;;
6032                 esac
6033                 $make cd $INSTALLROOT/src
6034                 ;;
6035         esac
6037         # fall back to mamake if nmake not found or too old
6039         if      nonmake $MAKE
6040         then    note make with mamake
6041                 case $target in
6042                 '')     target="install" ;;
6043                 esac
6044                 eval capture mamake \$makeflags \$noexec \$target $assign
6045         else    case $target in
6046                 '')     target="install cc-" ;;
6047                 esac
6048                 eval capture \$MAKE \$makeflags \$nmakeflags \$noexec recurse \$target \$nmakesep \$package $assign
6049         fi
6050         ;;
6052 read)   case ${PWD:-`pwd`} in
6053         $PACKAGEROOT)
6054                 ;;
6055         *)      echo "$command: must be in package root directory" >&2
6056                 exit 1
6057                 ;;
6058         esac
6059         PAX=
6060         if      onpath pax
6061         then    case `$_onpath_ -rw --?meter 2>&1` in
6062                 *--meter*)      PAX=pax ;;
6063                 esac
6064         fi
6065         code=0
6066         i=
6067         x=
6068         remove=
6069         touch=
6070         set '' $target
6071         case $2 in
6072         lcl|tgz)tgz=$2
6073                 shift 2
6074                 target=$*
6075                 ;;
6076         *)      tgz=tgz
6077                 ;;
6078         esac
6079         set '' $package $target
6080         case $# in
6081         1)      verbose=:
6082                 set '' `ls lib/package/$tgz/*?[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]* 2>/dev/null`
6083                 ;;
6084         *)      verbose=
6085                 ;;
6086         esac
6087         shift
6088         files=
6089         for f
6090         do      if      test -f "$f"
6091                 then    : ok
6092                 elif    test -f "lib/package/$tgz/$f"
6093                 then    f=lib/package/$tgz/$f
6094                 else    set '' `ls -r ${f}[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]* 2>/dev/null`
6095                         if      test '' != "$2" -a -f "$2"
6096                         then    f=$2
6097                         else    set '' `ls -r lib/package/$tgz/${f}[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]* 2>/dev/null`
6098                                 if      test '' != "$2" -a -f "$2"
6099                                 then    f=$2
6100                                 else    echo "$command: $f: package archive not found" >&2
6101                                         continue
6102                                 fi
6103                         fi
6104                 fi
6105                 files="$files $f"
6106         done
6107         case $files in
6108         '')     echo "$command: lib/package/$tgz: no package archives" >&2
6109                 exit 1
6110                 ;;
6111         esac
6112         set '' `ls -r $files 2>/dev/null`
6113         shift
6114         f1= f2= f3= f4=
6115         for f
6116         do      case $f in
6117                 ratz.*|*/ratz.*)
6118                         f1="$f1 $f"
6119                         ;;
6120                 INIT.*|*/INIT.*)
6121                         f2="$f2 $f"
6122                         ;;
6123                 INIT*|*/INIT*)
6124                         f3="$f3 $f"
6125                         ;;
6126                 *)      f4="$f4 $f"
6127                         ;;
6128                 esac
6129         done
6130         gen=
6131         set '' $f1 $f2 $f3 $f4
6132         while   :
6133         do      shift
6134                 case $# in
6135                 0)      break ;;
6136                 esac
6137                 f=$1
6138                 case $f in
6139                 *.gz)   : standalone packages unbundled manually
6140                         continue
6141                         ;;
6142                 *.md5)  : tarball checksum
6143                         continue
6144                         ;;
6145                 *?[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]*)
6146                         ;;
6147                 *)      echo "$command: $f: not a package archive" >&2
6148                         code=1
6149                         continue
6150                         ;;
6151                 esac
6152                 case $f in
6153                 */*)    eval `echo "$f" | sed -e 's,\(.*/\)\(.*\),d=\1 a=\2,'` ;;
6154                 *)      d= a=$f ;;
6155                 esac
6156                 # f:file d:dir a:base p:package v:version r:release t:type
6157                 eval `echo "$a" | sed -e 's,\.c$,,' -e 's,\.gz$,,' -e 's,\.exe$,,' -e 's,\.tgz$,,' -e 's,\([^_.]*\)[_.]\([0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]\)[_.]\([0123456789][0123456789][0123456789][0123456789][^_.]*\)[_.]*\(.*\),p=\1 v=\2 r=\3 t=\4,' -e 's,\([^_.]*\)[_.]\([0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]\)[_.]*\(.*\),p=\1 v=\2 r=base t=\3,'`
6158                 case $r in
6159                 base)   y=$p.base ;;
6160                 *)      y=$p.delta ;;
6161                 esac
6162                 case " $x " in
6163                 *" $y "*)
6164                         continue
6165                         ;;
6166                 esac
6167                 case $t in
6168                 '')     w=$PACKAGESRC
6169                         q=
6170                         Q=
6171                         m=
6172                         ;;
6173                 *)      w=$PACKAGEROOT/arch/$t/lib/package
6174                         q=".$t"
6175                         Q="_$t"
6176                         m="[_.]$t"
6177                         ;;
6178                 esac
6179                 u=$d$p$q.tim
6180                 if      test -s "$u"
6181                 then    continue
6182                 else    case $force in
6183                         0)      case `ls -t "$f" "$u" 2>/dev/null` in
6184                                 "$u"*)  case $verbose in
6185                                         1)      note $p already read ;;
6186                                         esac
6187                                         continue
6188                                         ;;
6189                                 esac
6190                                 ;;
6191                         esac
6192                 fi
6193                 case $p in
6194                 INIT)   if      test -f $PACKAGEROOT/bin/package
6195                         then    $exec mv $PACKAGEROOT/bin/package $PACKAGEROOT/bin/package.old
6196                         fi
6197                         ;;
6198                 esac
6199                 z=
6200                 case $r in
6201                 base)   # base archive
6202                         if      test ratz = "$p"
6203                         then    # ratz packages are not archives
6204                                 case $t in
6205                                 '')     for i in src src/cmd src/cmd/INIT
6206                                         do      test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
6207                                         done
6208                                         $exec cp $f $PACKAGEROOT/src/cmd/INIT/$p.c
6209                                         ;;
6210                                 *)      for i in arch arch/$t arch/$t/bin
6211                                         do      test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
6212                                         done
6213                                         $exec cp $f $PACKAGEROOT/arch/$t/bin/$p &&
6214                                         $exec chmod +x $PACKAGEROOT/arch/$t/bin/$p
6215                                         ;;
6216                                 esac
6217                         elif    test "" != "$PAX"
6218                         then    $exec pax -L --from=ascii --local -m -ps -rvf "$f" || {
6219                                         code=1
6220                                         continue
6221                                 }
6222                         else    if      onpath gunzip && onpath $TAR && isascii
6223                                 then    case $TARPROBE in
6224                                         ?*)     for i in $TARPROBE
6225                                                 do      if      $TAR ${i}f - /dev/null > /dev/null 2>&1
6226                                                         then    TARFLAGS=$TARFLAGS$i
6227                                                         fi
6228                                                 done
6229                                                 TARPROBE=
6230                                                 ;;
6231                                         esac
6232                                         if      gunzip -l < "$f" > /dev/null 2>&1
6233                                         then    case $exec in
6234                                                 '')     $exec gunzip < "$f" | $TAR ${TARFLAGS}f - ;;
6235                                                 *)      $exec "gunzip < $f | $TAR ${TARFLAGS}f -" ;;
6236                                                 esac || {
6237                                                         code=1
6238                                                         continue
6239                                                 }
6240                                         else    $exec $TAR ${TARFLAGS}f "$f" || {
6241                                                         code=1
6242                                                         continue
6243                                                 }
6244                                         fi
6245                                 else    checkaout ratz && onpath ratz || {
6246                                                 code=1
6247                                                 continue
6248                                         }
6249                                         RATZ=$_onpath_
6250                                         case $exec in
6251                                         '')     echo $f:
6252                                                 $exec $RATZ -lm < "$f"
6253                                                 ;;
6254                                         *)      $exec "$RATZ -lm < $f"
6255                                                 ;;
6256                                         esac || {
6257                                                 code=1
6258                                                 continue
6259                                         }
6260                                 fi
6261                                 if      test -f $PACKAGEBIN/gen/$p.sum
6262                                 then    while   read md5 mode usr grp file
6263                                         do      case $file in
6264                                                 -*)     file=./$file ;;
6265                                                 esac
6266                                                 case $mode in
6267                                                 [01234567][01234567][01234567][01234567])
6268                                                         case $grp in
6269                                                         -)      ;;
6270                                                         *)      $exec chgrp $grp "$file" ;;
6271                                                         esac
6272                                                         case $usr in
6273                                                         -)      ;;
6274                                                         *)      $exec chown $usr "$file" ;;
6275                                                         esac
6276                                                         $exec chmod $mode "$file"
6277                                                         ;;
6278                                                 esac
6279                                         done < $PACKAGEBIN/gen/$p.sum
6280                                 fi
6281                         fi
6282                         ;;
6283                 *)      # delta archive
6284                         test "" != "$PAX" || {
6285                                 echo "$command: $f: pax required to read delta archive" >&2
6286                                 code=1
6287                                 continue
6288                         }
6289                         case `echo "$v:
6290 $r:" | sort` in
6291                         $r:*)   y=$p.base
6292                                 b=${d}${p}_${r}${Q}.tgz
6293                                 test -f "$b" || b=${d}${p}.${r}${q}.tgz
6294                                 test -f "$b" || {
6295                                         case " $gen " in
6296                                         *" $b "*)
6297                                                 ;;
6298                                         *)      case $# in
6299                                                 1)      echo "$command: $f: base archive $b required to read delta" >&2
6300                                                         code=1
6301                                                         ;;
6302                                                 *)      shift
6303                                                         y=$1
6304                                                         shift
6305                                                 set '' $y $f "$@"
6306                                                 esac
6307                                                 continue
6308                                                 ;;
6309                                         esac
6310                                 }
6311                                 # -m with delta bug fixed 2005-02-08
6312                                 $exec pax -L --from=ascii --local -ps -rvf "$f" -z "$b" || {
6313                                         code=1
6314                                         continue
6315                                 }
6316                                 note $f: generate new base $d$p.$v$q.tgz
6317                                 $exec pax -rf "$f" -z "$b" -wf $d$p.$v$q.tgz -x tgz || {
6318                                         code=1
6319                                         continue
6320                                 }
6321                                 case $exec in
6322                                 '')     echo $p $v $v 1 > $w/gen/$p.ver
6323                                         ;;
6324                                 *)      z=$d${p}[_.]$v$q.tgz
6325                                         $exec "echo $p $v $v 1 > $w/gen/$p.ver"
6326                                         gen="$gen $d$p.$v$q.tgz"
6327                                         ;;
6328                                 esac
6329                                 case " $remove " in
6330                                 *" $f "*)       ;;
6331                                 *)              remove="$remove $f" ;;
6332                                 esac
6333                                 ;;
6334                         *)      b=${d}${p}_${v}${Q}.tgz
6335                                 test -f "$b" || b=${d}${p}.${v}${q}.tgz
6336                                 test -f "$b" || {
6337                                         case " $gen " in
6338                                         *" $b "*)
6339                                                 ;;
6340                                         *)      case $# in
6341                                                 1)      echo "$command: $f: base archive $b required to read delta" >&2
6342                                                         code=1
6343                                                         ;;
6344                                                 *)      shift
6345                                                         y=$1
6346                                                         shift
6347                                                         set '' $y $f "$@"
6348                                                 esac
6349                                                 continue
6350                                                 ;;
6351                                         esac
6352                                 }
6353                                 # -m with delta bug fixed 2005-02-08
6354                                 $exec pax -L --from=ascii --local -ps -rvf "$f" -z "$b" || {
6355                                         code=1
6356                                         continue
6357                                 }
6358                                 ;;
6359                         esac
6360                         ;;
6361                 *)      echo "$command: $f: unknown archive type" >&2
6362                         code=1
6363                         continue
6364                         ;;
6365                 esac
6367                 # check for ini files
6369                 if      executable $w/$p.ini
6370                 then    $exec $w/$p.ini read || {
6371                                 code=1
6372                                 continue
6373                         }
6374                 fi
6376                 # add to the obsolete list
6378                 k=
6379                 for i in `ls $d$p[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]????$m* $z 2>/dev/null`
6380                 do      case $i in
6381                         *.md5)  continue
6382                                 ;;
6383                         $d${p}[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]$m*)
6384                                 ;;
6385                         $d${p}[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]$m*)
6386                                 continue
6387                                 ;;
6388                         esac
6389                         case $k in
6390                         ?*)     case " $remove " in
6391                                 *" $k "*)       ;;
6392                                 *)              remove="$remove $k" ;;
6393                                 esac
6394                                 ;;
6395                         esac
6396                         k=$i
6397                 done
6398                 x="$x $y"
6399                 case " $touch " in
6400                 *" $u "*)       ;;
6401                 *)              touch="$touch $u" ;;
6402                 esac
6403         done
6404         if      test ! -f $PACKAGEROOT/bin/package -a -f $PACKAGEROOT/bin/package.old
6405         then    $exec cp $PACKAGEROOT/bin/package.old $PACKAGEROOT/bin/package
6406         fi
6408         # drop obsolete archives
6410         case $remove in
6411         ?*)     $exec rm -f $remove ;;
6412         esac
6414         # mark the updated archives
6416         case $touch in
6417         ?*)     sleep 1; $exec touch $touch ;;
6418         esac
6420         # check the requirements
6422         case $code$exec in
6423         0)      requirements - $x ;;
6424         esac
6425         exit $code
6426         ;;
6428 regress)if      test ! -d $PACKAGEBIN/gen
6429         then    echo "$command: 'package make' and 'package test' required for regression" >&2
6430                 exit 1
6431         fi
6432         dir=$PACKAGEBIN/gen
6433         cd $dir
6434         for s in out old
6435         do      case `ls -t regress.$s test.$s 2>/dev/null` in
6436                 regress*)
6437                         ;;
6438                 test*)  if      test -f regress.$s
6439                         then    $exec mv regress.$s regress.old
6440                         fi
6441                         case $exec in
6442                         '')     egrep -i '\*\*\*|FAIL|^TEST.* [123456789][0123456789]* error|core.*dump' test.$s |
6443                                 sed     -e '/\*\*\* [0123456789]/d' \
6444                                         -e '/^TEST.\//s,/[^ ]*/,,' \
6445                                         -e 's,[         ][      ]*$,,' \
6446                                         -e 's/[0123456789][0123456789]*:* \([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 ]*([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 ]*[Cc][Oo][Rr][Ee][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 ]*)\)/\1/' \
6447                                         -e 's/\.sh failed at .* with /.sh failed /' \
6448                                         > regress.$s
6449                                 ;;
6450                         *)      $exec filter test failures from $dir/test.$s to $dir/regress.$s
6451                                 ;;
6452                         esac
6453                         ;;
6454                 esac
6455         done
6456         if      test -f regress.out -a -f regress.old
6457         then    $exec diff -b regress.out regress.old
6458         else    echo "$command: at least 2 test runs required for regression" >&2
6459                         exit 1
6460         fi
6461         ;;
6463 release)count= lo= hi=
6464         checksrc
6465         checkaout release || exit
6466         requirements source $package
6467         components $package
6468         package=$_components_
6469         set '' $target
6470         shift
6471         case $# in
6472         0)      ;;
6473         *)      case $1 in
6474                 -|[0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789])
6475                         case $1 in
6476                         -)      lo= release= ;;
6477                         *)      lo=$1 release="-f $1" ;;
6478                         esac
6479                         shift
6480                         case $1 in
6481                         -|[0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789])
6482                                 case $1 in
6483                                 -)      hi= ;;
6484                                 *)      hi=$1 release="$release -t $1" ;;
6485                                 esac
6486                                 shift
6487                                 ;;
6488                         esac
6489                         ;;
6490                 [0123456789]|[0123456789][0123456789]|[0123456789][0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789][0123456789]*)
6491                         count=$1
6492                         release="-r $count"
6493                         shift
6494                         ;;
6495                 esac
6496                 ;;
6497         esac
6498         case $# in
6499         0)      case $package in
6500                 '')     package=* ;;
6501                 esac
6502                 ;;
6503         *)      case $package in
6504                 '')     package=$*
6505                         ;;
6506                 *)      echo $command: $*: lo-date hi-date arguments expected >&2
6507                         exit 1
6508                         ;;
6509                 esac
6510                 ;;
6511         esac
6512         echo
6513         case $count:$lo:$hi in
6514         ::)     echo "All recorded changes follow." ;;
6515         1::)    echo "Changes since the last release follow." ;;
6516         ?*::)   echo "Changes since the last $count releases follow." ;;
6517         1:?*:)  echo "Changes since $lo or the last release follow." ;;
6518         *:?*:*) echo "Changes since $lo follow." ;;
6519         *::?*)  echo "Changes before $hi follow." ;;
6520         *)      echo "Changes between $lo and $hi follow." ;;
6521         esac
6522         x=
6523         for r in $INSTALLROOT $PACKAGEROOT
6524         do      for s in $package_src
6525                 do      d=$r/src/$s
6526                         if      test -d $d
6527                         then    cd $d
6528                                 for i in $package
6529                                 do      if      test -h $i 2>/dev/null
6530                                         then    continue
6531                                         fi
6532                                         case " $x " in
6533                                         *" $i "*)       continue ;;
6534                                         esac
6535                                         for f in RELEASE CHANGES ChangeLog
6536                                         do      if      test -f $i/$f
6537                                                 then    $exec release $release $i/$f
6538                                                         x="$x $i"
6539                                                         for f in $i/*/$f
6540                                                         do      if      test -f $f
6541                                                                 then    $exec release $release $f
6542                                                                 fi
6543                                                         done
6544                                                         break
6545                                                 fi
6546                                         done
6547                                 done
6548                         fi
6549                 done
6550         done
6551         ;;
6553 remove) echo "$command: $action: not implemented yet" >&2
6554         exit 1
6555         ;;
6557 results)set '' $target
6558         shift
6559         def=make
6560         dir=$PACKAGEBIN/gen
6561         case $verbose in
6562         0)      filter=yes ;;
6563         *)      filter=cat ;;
6564         esac
6565         path=0
6566         suf=out
6567         on=
6568         while   :
6569         do      case $# in
6570                 0)      break ;;
6571                 esac
6572                 case $1 in
6573                 --)     shift
6574                         break
6575                         ;;
6576                 admin)  dir=$PACKAGESRC/admin
6577                         ;;
6578                 error*|fail*)
6579                         filter=errors
6580                         ;;
6581                 make|test|view|write)
6582                         def=$1
6583                         case $filter:$1:$SHELL in
6584                         errors:*:*)     ;;
6585                         *:test:*/ksh*)  filter=rt ;;
6586                         esac
6587                         ;;
6588                 old)    suf=$suf.*
6589                         ;;
6590                 on)     case $# in
6591                         1)      echo $command: $action: $1: host pattern argument expected >&2
6592                                 exit 1
6593                                 ;;
6594                         esac
6595                         shift
6596                         case $on in
6597                         ?*)     on="$on|" ;;
6598                         esac
6599                         on="$on$1"
6600                         ;;
6601                 path)   path=1
6602                         ;;
6603                 test)   def=test
6604                         filter=rt
6605                         ;;
6606                 *)      break
6607                         ;;
6608                 esac
6609                 shift
6610         done
6611         case $dir in
6612         */admin)case $on in
6613                 '')     on="*" ;;
6614                 *)      on="@($on)" ;;
6615                 esac
6616                 def=$def.log/$on
6617                 ;;
6618         esac
6619         case $# in
6620         0)      set "$def" ;;
6621         esac
6622         m=
6623         t=
6624         for i
6625         do      k=0
6626                 eval set '""' $i - $i.$suf - $dir/$i - $dir/$i.$suf -
6627                 shift
6628                 for j
6629                 do      case $j in
6630                         -)      case $k in
6631                                 1)      continue 2 ;;
6632                                 esac
6633                                 ;;
6634                         *)      if      test -f $j
6635                                 then    k=1
6636                                         case /$j in
6637                                         */test.*)       t="$t $j" ;;
6638                                         *)              m="$m $j" ;;
6639                                         esac
6640                                 fi
6641                                 ;;
6642                         esac
6643                 done
6644                 echo "$command: $i action output not found" >&2
6645                 exit 1
6646         done
6647         sep=
6648         case $t in
6649         ?*)     case $path in
6650                 0)      for j in $t
6651                         do      echo "$sep==> $j <=="
6652                                 sep=$nl
6653                                 case $filter in
6654                                 cat)    $exec cat $j
6655                                         ;;
6656                                 errors) $exec egrep -i '\*\*\*|FAIL[ES]|^TEST.* [123456789][0123456789]* error|core.*dump' $j | sed -e '/^TEST.\//s,/[^ ]*/,,'
6657                                         ;;
6658                                 rt)     $exec $KSH rt - $j
6659                                         ;;
6660                                 *)      $exec egrep -i '^TEST|FAIL' $j
6661                                         ;;
6662                                 esac
6663                         done
6664                         ;;
6665                 1)      echo $t
6666                         ;;
6667                 esac
6668                 ;;
6669         esac
6670         case $m in
6671         ?*)     case $path in
6672                 0)      case $filter in
6673                         cat)    cat $m
6674                                 ;;
6675                         *)      if      test -f $HOME/.pkgresults
6676                                 then    i="`cat $HOME/.pkgresults`"
6677                                         case $i in
6678                                         '|'*)   ;;
6679                                         *)      i="|$i" ;;
6680                                         esac
6681                                 else    i=
6682                                 fi
6683                                 for j in $m
6684                                 do      echo "$sep==> $j <=="
6685                                         sep=$nl
6686                                         case $filter in
6687                                         errors) $exeg egrep '^pax:|\*\*\*' $j
6688                                                 ;;
6689                                         *)      $exec egrep -iv '^($|\e|[\+\[]|cc[^-:]|kill |make.*(file system time|has been replaced)|so|[0123456789]+ error|uncrate |[0123456789]+ block|ar: creat|iffe: test: |conf: (check|generate|test)|[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*=|gsf@research|ar:.*warning|cpio:|ld:.*(duplicate symbol|to obtain more information)|[0123456789]*$|(checking|creating|touch) [/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789])| obsolete predefined symbol | is (almost always misused|dangerous|deprecated|not implemented)| trigraph| assigned to | cast .* different size| integer overflow .*<<| optimization may be attained | passed as |::__builtin|pragma.*prototyped|^creating.*\.a$|warning.*not optimized|exceeds size thresh|ld:.*preempts|is unchanged|with value >=|(-l|lib)\*|/(ast|sys)/(dir|limits|param|stropts)\.h.*redefined|usage|base registers|`\.\.\.` obsolete'"$i" $j |
6690                                                 $exec grep :
6691                                                 ;;
6692                                         esac
6693                                 done
6694                                 ;;
6695                         esac
6696                         ;;
6697                 1)      echo $m
6698                         ;;
6699                 esac
6700         esac
6701         ;;
6703 test)   requirements source $package
6704         components $package
6705         package=$_components_
6706         case $only in
6707         0)      only= ;;
6708         1)      only=--recurse=only ;;
6709         esac
6711         # must have nmake
6713         if      nonmake $MAKE
6714         then    echo $command: $action: must have $MAKE to test >&2
6715                 exit 1
6716         fi
6718         # all work under $INSTALLROOT/src
6720         $make cd $INSTALLROOT/src
6722         # disable core dumps (could be disasterous over nfs)
6724         (ulimit -c 0) > /dev/null 2>&1 && ulimit -c 0
6726         # do the tests
6728         eval capture \$MAKE \$makeflags \$noexec \$only recurse test \$target \$nmakesep \$package $assign
6729         ;;
6731 update) # download the latest release.version for selected packages
6733         # all work in $PACKAGEROOT/lib/package/tgz
6735         if      test ! -d $PACKAGEROOT/lib/package/tgz
6736         then    $exec mkdir -p $PACKAGEROOT/lib/package/tgz || exit
6737                 $exec cd $PACKAGEROOT/lib/package/tgz
6738         else    cd $PACKAGEROOT/lib/package/tgz
6739         fi
6741         # get the architectures, update query url, and packages
6743         set '' $args
6744         op=update
6745         tgz=tgz
6746         source=
6747         binary=
6748         setup=
6749         types=
6750         url=
6751         urlfile=$default_url
6752         while   :
6753         do      shift
6754                 case $# in
6755                 0)      break ;;
6756                 esac
6757                 case $1 in
6758                 --)     shift
6759                         break
6760                         ;;
6761                 beta)   op=beta
6762                         tgz=beta
6763                         ;;
6764                 binary) binary=1
6765                         ;;
6766                 setup)  setup=1
6767                         ;;
6768                 source) source=1
6769                         ;;
6770                 *://*)  url=$1
6771                         shift
6772                         break
6773                         ;;
6774                 *.url)  urlfile=$1
6775                         if      test ! -s $urlfile
6776                         then    echo $command: $urlfile: not found >&2; exit 1
6777                         fi
6778                         break
6779                         ;;
6780                 $all_types)
6781                         binary=1
6782                         types="$types $1"
6783                         ;;
6784                 *)      break
6785                         ;;
6786                 esac
6787         done
6788         case $source:$binary in
6789         :)      source=1 binary=1
6790                 ;;
6791         :1)     case $types in
6792                 '')     types=$HOSTTYPE ;;
6793                 esac
6794                 ;;
6795         esac
6796         case $url in
6797         '')     case $urlfile in
6798                 $default_url)
6799                         if      test ! -s $urlfile
6800                         then    echo $command: url argument expected >&2; exit 1
6801                         fi
6802                         ;;
6803                 *)      default_url=
6804                         ;;
6805                 esac
6806                 url=
6807                 if      grep '^url=' $urlfile >/dev/null
6808                 then    a=$authorize
6809                         p=$password
6810                         case $urlfile in
6811                         */*)    ;;
6812                         *)      urlfile=./$urlfile ;;
6813                         esac
6814                         . $urlfile
6815                         case $a:$p in
6816                         $authorize:$password)
6817                                 default_url=
6818                                 ;;
6819                         *)      case $a in
6820                                 ?*)     authorize=$a ;;
6821                                 esac
6822                                 case $p in
6823                                 ?*)     password=$p ;;
6824                                 esac
6825                                 ;;
6826                         esac
6827                 else    url=`cat $urlfile`
6828                 fi
6829                 ;;
6830         esac
6831         case $exec in
6832         ?*)     default_url= ;;
6833         esac
6835         # get the update list
6837         eval `echo $url | sed 's,\(.*\)://\([^/]*\)/\(.*\),prot=\"\1\" host=\"\2\" dir=\"\3\",'`
6838         get $host $dir/$op.html
6840         # get/check the package names
6842         case " $* " in
6843         *" - "*)case $source in
6844                 1)      source_packages=$* ;;
6845                 *)      source_packages= ;;
6846                 esac
6847                 case $binary in
6848                 1)      binary_packages=$* ;;
6849                 *)      binary_packages= ;;
6850                 esac
6851                 package_hit=$*
6852                 ;;
6853         "  ")   nl="
6855                 case $source in
6856                 1)      p=
6857                         for f in `ls *.????-??-??.* 2>/dev/null`
6858                         do      case $f in
6859                                 *.????-??-??.????-??-??.*.*)
6860                                         ;;
6861                                 *.????-??-??.????-??-??.*)
6862                                         p=$p$nl$f
6863                                         ;;
6864                                 *.????-??-??.*.*)
6865                                         ;;
6866                                 *.????-??-??.*)
6867                                         p=$p$nl$f
6868                                         ;;
6869                                 esac
6870                         done
6871                         set '' `echo "$p" | sed 's,\..*,,' | sort -u`
6872                         shift
6873                         source_packages=$*
6874                         ;;
6875                 *)      source_packages=
6876                         ;;
6877                 esac
6878                 case $binary in
6879                 1)      p=
6880                         for f in `ls *.????-??-??.* 2>/dev/null`
6881                         do      case $f in
6882                                 *.????-??-??.????-??-??.*.*)
6883                                         p=$p$nl$f
6884                                         ;;
6885                                 *.????-??-??.????-??-??.*)
6886                                         ;;
6887                                 *.????-??-??.*.*)
6888                                         p=$p$nl$f
6889                                         ;;
6890                                 *.????-??-??.*)
6891                                         ;;
6892                                 esac
6893                         done
6894                         set '' `echo "$p" | sed 's,\..*,,' | sort -u`
6895                         shift
6896                         binary_packages=$*
6897                         ;;
6898                 *)      binary_packages=
6899                         ;;
6900                 esac
6901                 package_hit="$source_packages $binary_packages"
6902                 ;;
6903         *)      case $source in
6904                 1)      source_packages=$* ;;
6905                 *)      source_packages= ;;
6906                 esac
6907                 case $binary in
6908                 1)      binary_packages=$* ;;
6909                 *)      binary_packages= ;;
6910                 esac
6911                 package_hit=
6912                 ;;
6913         esac
6915         # get the latest updates
6917         types_test=
6918         types_local=
6919         dir=$dir/$tgz
6920         case $default_url in
6921         ?*)     echo "url='$url' authorize='$authorize' password='$password'" > $default_url
6922                 case $authorize in
6923                 ?*)     chmod go-rwx $default_url ;;
6924                 esac
6925                 ;;
6926         esac
6927         echo "$got" > got.tmp
6928         case $only in
6929         0)      exec < got.tmp
6930                 covered=
6931                 while   read name suffix type base base_size delta delta_size sync sync_size requires covers base_sum delta_sum sync_sum comment
6932                 do      case $requires in
6933                         ''|-*)  continue ;;
6934                         esac
6935                         IFS=:
6936                         set '' $requires
6937                         IFS=$ifs
6938                         case $type in
6939                         -)      case " $source_packages " in
6940                                 *" $name "*|*" - "*)
6941                                         for name
6942                                         do      case " $source_packages " in
6943                                                 *" $name "*)
6944                                                         ;;
6945                                                 *)      source_packages="$source_packages $name"
6946                                                         covered=$covered:$covers
6947                                                         ;;
6948                                                 esac
6949                                         done
6950                                         ;;
6951                                 esac
6952                                 ;;
6953                         *)      case " $binary_packages " in
6954                                 *" $name "*|*" - "*)
6955                                         for name
6956                                         do      case " $binary_packages " in
6957                                                 *" $name "*)
6958                                                         ;;
6959                                                 *)      binary_packages="$binary_packages $name"
6960                                                         covered=$covered:$covers
6961                                                         ;;
6962                                                 esac
6963                                         done
6964                                         ;;
6965                                 esac
6966                                 ;;
6967                         esac
6968                 done
6969                 case $covered in
6970                 ?*)     x=$source_packages
6971                         source_packages=
6972                         for name in $x
6973                         do      case :$covered: in
6974                                 *:$name:*)      ;;
6975                                 *)              source_packages="$source_packages $name" ;;
6976                                 esac
6977                         done
6978                         x=$binary_packages
6979                         binary_packages=
6980                         for name in $x
6981                         do      case :$covered: in
6982                                 *:$name:*)      ;;
6983                                 *)              binary_packages="$binary_packages $name" ;;
6984                                 esac
6985                         done
6986                         ;;
6987                 esac
6988                 ;;
6989         esac
6990         checksum=
6991         for i in $checksum_commands
6992         do      case `( $i ) < /dev/null 2> /dev/null` in
6993                 ${checksum_empty}|${checksum_empty}[\ \ ]*)
6994                         checksum=$i
6995                         break
6996                         ;;
6997                 esac
6998         done
6999         case $checksum in
7000         '')     echo $command: warning: '{' $checksum_commands '}' command not found -- only download sizes will be checked >&2 ;;
7001         esac
7002         exec < got.tmp
7003         while   read name suffix type base base_size delta delta_size sync sync_size requires covers base_sum delta_sum sync_sum comment
7004         do      case $verbose in
7005                 1)      case $type in
7006                         -)      i= ;;
7007                         *)      i=.$type ;;
7008                         esac
7009                         j="$name.$base$i.$suffix"
7010                         case $delta in
7011                         -)      j="$j -" ;;
7012                         *)      j="$j $name.$base.$delta$i.$suffix" ;;
7013                         esac
7014                         case $sync in
7015                         -)      j="$j -" ;;
7016                         *)      j="$j $name.$base.$sync$i.$suffix" ;;
7017                         esac
7018                         echo $command: $j $base_size:$base_sum $delta_size:$delta_sum $sync_size:$sync_sum $requires >&2
7019                 esac
7020                 case " $package_hit " in
7021                 *" $name "*|*" - "*)
7022                         ;;
7023                 *)      package_hit="$package_hit $name"
7024                         ;;
7025                 esac
7026                 case $type in
7027                 -)      case " $source_packages " in
7028                         *" $name "*|*" - "*)
7029                                 if      test -s $name.tim
7030                                 then    continue
7031                                 fi
7032                                 lcl=$name.$base.$suffix
7033                                 if      test -f $lcl
7034                                 then    case $checksum:$base_sum in
7035                                         :*|*:-) size=`wc -c < $lcl | sed 's, ,,g'` sum=$base_sum ;;
7036                                         *)      size=$base_size sum=`$checksum < $lcl | sed -e 's,^[    ][      ]*,,' -e 's,[   ].*,,'` ;;
7037                                         esac
7038                                 else    size=X sum=X
7039                                 fi
7040                                 if      test "0" != "$force" -a "X-" = "X$delta" -o "$base_size" != "$size" -o "$base_sum" != "$sum"
7041                                 then    rmt=
7042                                         case $sync:$sync_size in
7043                                         -*|*[-:])
7044                                                 ;;
7045                                         *)      lcl=$name.$base.$sync.$suffix
7046                                                 if      test -f $lcl
7047                                                 then    rmt=1
7048                                                         get $host $dir $lcl $sync_size $sync_sum
7049                                                 fi
7050                                                 ;;
7051                                         esac
7052                                         case $base:$base_size in
7053                                         -*|*[-:])
7054                                                 ;;
7055                                         *)      case $rmt in
7056                                                 '')     lcl=$name.$base.$suffix
7057                                                         get $host $dir $lcl $base_size $base_sum
7058                                                         ;;
7059                                                 esac
7060                                                 ;;
7061                                         esac
7062                                 fi
7063                                 case $delta:$delta_size in
7064                                 -*|*[-:])
7065                                         ;;
7066                                 *)      lcl=$name.$delta.$base.$suffix
7067                                         if      test -f $lcl
7068                                         then    case $checksum:$delta_sum in
7069                                                 :*|*:-) size=`wc -c < $lcl | sed 's, ,,g'` sum=$delta_sum ;;
7070                                                 *)      size=$base_size sum=`$checksum < $lcl | sed -e 's,^[    ][      ]*,,' -e 's,[   ].*,,'` ;;
7071                                                 esac
7072                                         else    size=X sum=X
7073                                         fi
7074                                         if      test "0" != "$force" -o "$delta_size" != "$size" -o "$delta_sum" != "$sum"
7075                                         then    get $host $dir $lcl $delta_size $delta_sum
7076                                         fi
7077                                         ;;
7078                                 esac
7079                                 ;;
7080                         esac
7081                         ;;
7082                 *)      case " $binary_packages " in
7083                         *" $name "*|*" - "*)
7084                                 if      test -s $name.$type.tim
7085                                 then    continue
7086                                 fi
7087                                 case " $types " in
7088                                 *" - "*);;
7089                                 "  ")   case " $types_test " in
7090                                         *" $type "*)
7091                                                 ;;
7092                                         *)      types_test="$types_test $type"
7093                                                 for i in *.????-??-??.$type.* *.????-??-??.????-??-??.$type.*
7094                                                 do      if      test -f $i
7095                                                         then    types_local="$types_local $type"
7096                                                         fi
7097                                                         break
7098                                                 done
7099                                                 ;;
7100                                         esac
7101                                         case " $types_local " in
7102                                         *" $type "*)
7103                                                 ;;
7104                                         *)      continue
7105                                                 ;;
7106                                         esac
7107                                         ;;
7108                                 *)      case " $types " in
7109                                         *" $type "*)
7110                                                 ;;
7111                                         *)      continue
7112                                                 ;;
7113                                         esac
7114                                         ;;
7115                                 esac
7116                                 lcl=$name.$base.$type.$suffix
7117                                 if      test -f $lcl
7118                                 then    case $checksum:$base_sum in
7119                                         :*|*:-) size=`wc -c < $lcl | sed 's, ,,g'` sum=$base_sum ;;
7120                                         *)      size=$base_size sum=`$checksum < $lcl | sed -e 's,^[    ][      ]*,,' -e 's,[   ].*,,'` ;;
7121                                         esac
7122                                 else    size=X sum=X
7123                                 fi
7124                                 if      test "0" != "$force" -a "X-" = "X$delta" -o "$base_size" != "$size" -o "$base_sum" != "$sum"
7125                                 then    rmt=
7126                                         case $sync:$sync_size in
7127                                         -*|*[-:])
7128                                                 ;;
7129                                         *)      lcl=$name.$base.$sync.$type.$suffix
7130                                                 if      test -f $lcl
7131                                                 then    rmt=1
7132                                                         get $host $dir $lcl $sync_size $sync_sum
7133                                                 fi
7134                                                 ;;
7135                                         esac
7136                                         case $base:$base_size in
7137                                         -*|*[-:])
7138                                                 ;;
7139                                         *)      case $rmt in
7140                                                 '')     lcl=$name.$base.$type.$suffix
7141                                                         get $host $dir $lcl $base_size $base_sum
7142                                                         ;;
7143                                                 esac
7144                                                 ;;
7145                                         esac
7146                                 fi
7147                                 case $delta:$delta_size in
7148                                 -*|*[-:])
7149                                         ;;
7150                                 *)      lcl=$name.$delta.$base.$type.$suffix
7151                                         if      test -f $lcl
7152                                         then    sum=`$checksum < $lcl | sed -e 's,^[    ][      ]*,,' -e 's,[   ].*,,'`
7153                                         else    sum=X
7154                                         fi
7155                                         if      test -f $lcl
7156                                         then    case $checksum:$delta_sum in
7157                                                 :*|*:-) size=`wc -c < $lcl | sed 's, ,,g'` sum=$delta_sum ;;
7158                                                 *)      size=$base_size sum=`$checksum < $lcl | sed -e 's,^[    ][      ]*,,' -e 's,[   ].*,,'` ;;
7159                                                 esac
7160                                         else    size=X sum=X
7161                                         fi
7162                                         if      test "0" != "$force" -o "$delta_size" != "$size" -o "$delta_sum" != "$sum"
7163                                         then    get $host $dir $lcl $delta_size $delta_sum
7164                                         fi
7165                                         ;;
7166                                 esac
7167                                 ;;
7168                         esac
7169                         ;;
7170                 esac
7171         done
7172         closure=
7173         for name in $source_packages $binary_packages
7174         do      case $name in
7175                 -)      ;;
7176                 *)      case " $package_hit " in
7177                         *" $name "*)
7178                                 case $setup in
7179                                 1)      case " $closure " in
7180                                         *" $name "*)
7181                                                 ;;
7182                                         *)      closure="$closure $name"
7183                                                 ;;
7184                                         esac
7185                                         ;;
7186                                 esac
7187                                 ;;
7188                         *)      echo $command: $name: unknown package >&2
7189                                 ;;
7190                         esac
7191                         ;;
7192                 esac
7193         done
7194         exec <&-
7195         rm -f got.tmp
7196         case $closure in
7197         ?*)     echo $closure ;;
7198         esac
7199         ;;
7201 use)    # finalize the environment
7203         x=:..
7204         for d in `( cd $PACKAGEROOT; ls src/*/Makefile src/*/Nmakefile 2>/dev/null | sed 's,/[^/]*$,,' | sort -u )`
7205         do      x=$x:$INSTALLROOT/$d
7206         done
7207         x=$x:$INSTALLROOT
7208         case $CDPATH: in
7209         $x:*)   ;;
7210         *)      CDPATH=$x:$CDPATH
7211                 $show CDPATH=$CDPATH
7212                 $show export CDPATH
7213                 export CDPATH
7214                 ;;
7215         esac
7216         P=$PACKAGEROOT
7217         $show P=$P
7218         $show export P
7219         export P
7220         A=$INSTALLROOT
7221         $show A=$A
7222         $show export A
7223         export A
7224         case $NPROC in
7225         '')     hostinfo cpu
7226                 case $_hostinfo_ in
7227                 0|1)    ;;
7228                 *)      NPROC=$_hostinfo_
7229                         $show NPROC=$NPROC
7230                         $show export NPROC
7231                         export NPROC
7232                         ;;
7233                 esac
7234                 ;;
7235         esac
7236         eval PACKAGE_USE=$package_use
7237         export PACKAGE_USE
7239         # run the command
7241         case $run in
7242         '')     case $show in
7243                 ':')    $exec exec $SHELL ;;
7244                 esac
7245                 ;;
7246         *)      $exec exec $SHELL -c "$run"
7247                 ;;
7248         esac
7249         ;;
7251 verify) cd $PACKAGEROOT
7252         requirements binary $package
7253         if      executable ! $SUM
7254         then    echo "$command: $action: $SUM command required" >&2
7255                 exit 1
7256         fi
7257         case $target in
7258         '')     cd arch
7259                 set '' *
7260                 shift
7261                 target=$*
7262                 cd ..
7263                 ;;
7264         esac
7265         code=0
7266         for a in $target
7267         do      case $package in
7268                 '')     set '' arch/$a/lib/package/gen/*.sum
7269                         shift
7270                         if      test -f $1
7271                         then    for i
7272                                 do      package_verify $i || code=1
7273                                 done
7274                         else    echo "$command: warning: $a: no binary packages" >&2
7275                         fi
7276                         ;;
7277                 *)      for i in $package
7278                         do      if      test -f arch/$a/lib/package/gen/$i.sum
7279                                 then    package_verify arch/$a/lib/package/gen/$i.sum || code=1
7280                                 else    echo "$command: warning: $a: no binary package for $i" >&2
7281                                 fi
7282                         done
7283                         ;;
7284                 esac
7285         done
7286         exit $code
7287         ;;
7289 write)  set '' $target
7290         shift
7291         action=
7292         list=
7293         qualifier=
7294         while   :
7295         do      case $1 in
7296                 base|closure|delta|exp|lcl|pkg|rpm|tgz)
7297                         qualifier="$qualifier $1"
7298                         ;;
7299                 binary) action=$1
7300                         type=$HOSTTYPE
7301                         eval list=$PACKAGESRC/tgz/$admin_list
7302                         ;;
7303                 cyg)    qualifier="$qualifier $1"
7304                         assign="$assign closure=1"
7305                         only=1
7306                         ;;
7307                 runtime|source)
7308                         action=$1
7309                         ;;
7310                 tst)    qualifier="$qualifier tgz"
7311                         assign="$assign copyright=0 'PACKAGEDIR=\$(PACKAGESRC)/tst'"
7312                         ;;
7313                 nocopyright)
7314                         assign="$assign copyright=0"
7315                         ;;
7316                 *)      break
7317                         ;;
7318                 esac
7319                 shift
7320         done
7321         case $action in
7322         '')     echo "$command: binary or source operand expected" >&2
7323                 exit 1
7324                 ;;
7325         esac
7326         set '' "$@" $package
7327         shift
7328         case $only in
7329         0)      set '' `order "$@"`
7330                 shift
7331                 ;;
7332         esac
7333         case $# in
7334         0)      echo "$command: at least one package name expected" >&2
7335                 exit 1
7336                 ;;
7337         esac
7338         if      nonmake $MAKE
7339         then    echo "$command: must have $MAKE to generate archives" >&2
7340                 exit 1
7341         fi
7343         # all work under $PACKAGEBIN
7345         $make cd $PACKAGEBIN
7346         case $list in
7347         ?*)     $exec rm -f $list ;;
7348         esac
7350         # go for it
7352         for package
7353         do      if      view - all $package.pkg || view - all lib/package/$package.pkg
7354                 then    eval capture \$MAKE \$makeflags -X ignore \$noexec -f \$package.pkg \$qualifier \$action $assign
7355                 else    echo "$command: $package: not a package" >&2
7356                 fi
7357         done
7358         ;;
7360 TEST)   set '' $target $package
7361         shift
7362         case $1 in
7363         binary|source)
7364                 action=$1
7365                 shift
7366                 ;;
7367         esac
7368         order "$@"
7369         ;;
7371 *)      echo "$command: $action: internal error" >&2
7372         exit 1
7373         ;;
7375 esac