History log of /netbsd-current/distrib/sets/maketars
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.102 22-Apr-2024 nia

Move MIPS N64 compat out of {base,debug}32 into {base,debug}64

martin requested separation by ABI and it doesn't make much sense
to have 64-bit binaries in a set called 32.


# 1.101 09-Apr-2024 nia

Add new sets: base32, debug32, manhtml

- base32 contains (when MKCOMPAT=yes) shared libraries for 32-bit
compatibility, previously included in base

- debug32 contains (when MKCOMPAT=yes) debug symbols and static libraries
containing debug symbols for 32-bit compatiblity, previously included
in debug

- manhtml contains (when MKHTML=yes) the HTML files previously included
in 'man', which are of limited utility without third-party software.

The motivation for this change is to be able to easily exclude sets
from CD-ROM images that go over the size limit without xz compression
(which many NetBSD platforms struggle to extract at acceptable speeds).


# 1.100 30-Jan-2024 martin

Fix previous, use sed to fix up the set.${set} line in non-METAFILE mode


# 1.99 29-Jan-2024 martin

When building in priviledged mode, remove the entry for the output file
from etc/mtree/set.* - it may exist and contain stale data.


# 1.98 08-Nov-2023 christos

More conservative umask


# 1.97 08-Nov-2023 christos

Set the file creation mask consistently because the files these scripts
create can become part of an iso image.


# 1.96 10-Jun-2023 lukem

sets: enhance MAKEVERBOSE support

Add more messages for various sets operations.
Add ${_MKMSG_CREATE} to bsd.own.mk.

Enhance maketars to be a bit more verbose even with -q,
to make it more obvious why certain operations may be slow.
May help debugging PR 47562.


# 1.95 10-Jun-2023 lukem

maketars: add comments for skipped mtree keywords

Reorder skipkeys alphabetically and add comment explaining
the purpose and why sha256 is not part of the variable.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.94 21-Aug-2022 lukem

Deprecate extsrc/, EXTSRCSRCDIR, MKEXTSRC

Remove support for building extsrc/:
1. Makefile: remove do-extsrc target.
2. build.sh: remove options -y and -Y extsrcdir.
3. distrib/sets: remove support for extsrc in various tools
including the options -L ext and -y, and the extsrc sets.
4. doc/BUILDING.mdoc: remove docs for extsrc/, EXTSRCSRCDIR, MKEXTSRC (etc)
5. bsd.own.mk and various Makefiles: remove support for extsrc/,
EXTSRCSRCDIR, MKEXTSRC.

As proposed on tech-kern and tech-userlevel on 2022-01-07
and followed up on 2022-08-21.


# 1.93 25-Sep-2021 maya

Move DRM-driver firmware from base to its own set, gpufw

This set is only installed on amd64,i386,evbarm.
This set is installed on minimal installs and on install media, in
case someone needs it for basic driver functionality.

Comments:
Switched to a single MK tunable for it - that is probably unneeded.

An upcoming DRM update will include even fatter firmware, and we'd
like to minimize the impact of it.


# 1.92 18-Sep-2021 christos

Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, but not LIBRARY_PATH because it breaks
the build. These variables are necessary to support building NetBSD
from a GNU Guix or NixOS host, where /usr/include, /lib, and all
but /bin/sh do not exist. In many cases, support for HOST_CPPFLAGS
was incomplete. From Ryan Sundberg


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.101 09-Apr-2024 nia

Add new sets: base32, debug32, manhtml

- base32 contains (when MKCOMPAT=yes) shared libraries for 32-bit
compatibility, previously included in base

- debug32 contains (when MKCOMPAT=yes) debug symbols and static libraries
containing debug symbols for 32-bit compatiblity, previously included
in debug

- manhtml contains (when MKHTML=yes) the HTML files previously included
in 'man', which are of limited utility without third-party software.

The motivation for this change is to be able to easily exclude sets
from CD-ROM images that go over the size limit without xz compression
(which many NetBSD platforms struggle to extract at acceptable speeds).


# 1.100 30-Jan-2024 martin

Fix previous, use sed to fix up the set.${set} line in non-METAFILE mode


# 1.99 29-Jan-2024 martin

When building in priviledged mode, remove the entry for the output file
from etc/mtree/set.* - it may exist and contain stale data.


# 1.98 08-Nov-2023 christos

More conservative umask


# 1.97 08-Nov-2023 christos

Set the file creation mask consistently because the files these scripts
create can become part of an iso image.


# 1.96 10-Jun-2023 lukem

sets: enhance MAKEVERBOSE support

Add more messages for various sets operations.
Add ${_MKMSG_CREATE} to bsd.own.mk.

Enhance maketars to be a bit more verbose even with -q,
to make it more obvious why certain operations may be slow.
May help debugging PR 47562.


# 1.95 10-Jun-2023 lukem

maketars: add comments for skipped mtree keywords

Reorder skipkeys alphabetically and add comment explaining
the purpose and why sha256 is not part of the variable.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.94 21-Aug-2022 lukem

Deprecate extsrc/, EXTSRCSRCDIR, MKEXTSRC

Remove support for building extsrc/:
1. Makefile: remove do-extsrc target.
2. build.sh: remove options -y and -Y extsrcdir.
3. distrib/sets: remove support for extsrc in various tools
including the options -L ext and -y, and the extsrc sets.
4. doc/BUILDING.mdoc: remove docs for extsrc/, EXTSRCSRCDIR, MKEXTSRC (etc)
5. bsd.own.mk and various Makefiles: remove support for extsrc/,
EXTSRCSRCDIR, MKEXTSRC.

As proposed on tech-kern and tech-userlevel on 2022-01-07
and followed up on 2022-08-21.


# 1.93 25-Sep-2021 maya

Move DRM-driver firmware from base to its own set, gpufw

This set is only installed on amd64,i386,evbarm.
This set is installed on minimal installs and on install media, in
case someone needs it for basic driver functionality.

Comments:
Switched to a single MK tunable for it - that is probably unneeded.

An upcoming DRM update will include even fatter firmware, and we'd
like to minimize the impact of it.


# 1.92 18-Sep-2021 christos

Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, but not LIBRARY_PATH because it breaks
the build. These variables are necessary to support building NetBSD
from a GNU Guix or NixOS host, where /usr/include, /lib, and all
but /bin/sh do not exist. In many cases, support for HOST_CPPFLAGS
was incomplete. From Ryan Sundberg


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.100 30-Jan-2024 martin

Fix previous, use sed to fix up the set.${set} line in non-METAFILE mode


# 1.99 29-Jan-2024 martin

When building in priviledged mode, remove the entry for the output file
from etc/mtree/set.* - it may exist and contain stale data.


# 1.98 08-Nov-2023 christos

More conservative umask


# 1.97 08-Nov-2023 christos

Set the file creation mask consistently because the files these scripts
create can become part of an iso image.


# 1.96 10-Jun-2023 lukem

sets: enhance MAKEVERBOSE support

Add more messages for various sets operations.
Add ${_MKMSG_CREATE} to bsd.own.mk.

Enhance maketars to be a bit more verbose even with -q,
to make it more obvious why certain operations may be slow.
May help debugging PR 47562.


# 1.95 10-Jun-2023 lukem

maketars: add comments for skipped mtree keywords

Reorder skipkeys alphabetically and add comment explaining
the purpose and why sha256 is not part of the variable.


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.94 21-Aug-2022 lukem

Deprecate extsrc/, EXTSRCSRCDIR, MKEXTSRC

Remove support for building extsrc/:
1. Makefile: remove do-extsrc target.
2. build.sh: remove options -y and -Y extsrcdir.
3. distrib/sets: remove support for extsrc in various tools
including the options -L ext and -y, and the extsrc sets.
4. doc/BUILDING.mdoc: remove docs for extsrc/, EXTSRCSRCDIR, MKEXTSRC (etc)
5. bsd.own.mk and various Makefiles: remove support for extsrc/,
EXTSRCSRCDIR, MKEXTSRC.

As proposed on tech-kern and tech-userlevel on 2022-01-07
and followed up on 2022-08-21.


# 1.93 25-Sep-2021 maya

Move DRM-driver firmware from base to its own set, gpufw

This set is only installed on amd64,i386,evbarm.
This set is installed on minimal installs and on install media, in
case someone needs it for basic driver functionality.

Comments:
Switched to a single MK tunable for it - that is probably unneeded.

An upcoming DRM update will include even fatter firmware, and we'd
like to minimize the impact of it.


# 1.92 18-Sep-2021 christos

Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, but not LIBRARY_PATH because it breaks
the build. These variables are necessary to support building NetBSD
from a GNU Guix or NixOS host, where /usr/include, /lib, and all
but /bin/sh do not exist. In many cases, support for HOST_CPPFLAGS
was incomplete. From Ryan Sundberg


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.99 29-Jan-2024 martin

When building in priviledged mode, remove the entry for the output file
from etc/mtree/set.* - it may exist and contain stale data.


# 1.98 08-Nov-2023 christos

More conservative umask


# 1.97 08-Nov-2023 christos

Set the file creation mask consistently because the files these scripts
create can become part of an iso image.


# 1.96 10-Jun-2023 lukem

sets: enhance MAKEVERBOSE support

Add more messages for various sets operations.
Add ${_MKMSG_CREATE} to bsd.own.mk.

Enhance maketars to be a bit more verbose even with -q,
to make it more obvious why certain operations may be slow.
May help debugging PR 47562.


# 1.95 10-Jun-2023 lukem

maketars: add comments for skipped mtree keywords

Reorder skipkeys alphabetically and add comment explaining
the purpose and why sha256 is not part of the variable.


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.94 21-Aug-2022 lukem

Deprecate extsrc/, EXTSRCSRCDIR, MKEXTSRC

Remove support for building extsrc/:
1. Makefile: remove do-extsrc target.
2. build.sh: remove options -y and -Y extsrcdir.
3. distrib/sets: remove support for extsrc in various tools
including the options -L ext and -y, and the extsrc sets.
4. doc/BUILDING.mdoc: remove docs for extsrc/, EXTSRCSRCDIR, MKEXTSRC (etc)
5. bsd.own.mk and various Makefiles: remove support for extsrc/,
EXTSRCSRCDIR, MKEXTSRC.

As proposed on tech-kern and tech-userlevel on 2022-01-07
and followed up on 2022-08-21.


# 1.93 25-Sep-2021 maya

Move DRM-driver firmware from base to its own set, gpufw

This set is only installed on amd64,i386,evbarm.
This set is installed on minimal installs and on install media, in
case someone needs it for basic driver functionality.

Comments:
Switched to a single MK tunable for it - that is probably unneeded.

An upcoming DRM update will include even fatter firmware, and we'd
like to minimize the impact of it.


# 1.92 18-Sep-2021 christos

Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, but not LIBRARY_PATH because it breaks
the build. These variables are necessary to support building NetBSD
from a GNU Guix or NixOS host, where /usr/include, /lib, and all
but /bin/sh do not exist. In many cases, support for HOST_CPPFLAGS
was incomplete. From Ryan Sundberg


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.98 08-Nov-2023 christos

More conservative umask


# 1.97 08-Nov-2023 christos

Set the file creation mask consistently because the files these scripts
create can become part of an iso image.


# 1.96 10-Jun-2023 lukem

sets: enhance MAKEVERBOSE support

Add more messages for various sets operations.
Add ${_MKMSG_CREATE} to bsd.own.mk.

Enhance maketars to be a bit more verbose even with -q,
to make it more obvious why certain operations may be slow.
May help debugging PR 47562.


# 1.95 10-Jun-2023 lukem

maketars: add comments for skipped mtree keywords

Reorder skipkeys alphabetically and add comment explaining
the purpose and why sha256 is not part of the variable.


Revision tags: netbsd-10-0-RC1 netbsd-10-base
# 1.94 21-Aug-2022 lukem

Deprecate extsrc/, EXTSRCSRCDIR, MKEXTSRC

Remove support for building extsrc/:
1. Makefile: remove do-extsrc target.
2. build.sh: remove options -y and -Y extsrcdir.
3. distrib/sets: remove support for extsrc in various tools
including the options -L ext and -y, and the extsrc sets.
4. doc/BUILDING.mdoc: remove docs for extsrc/, EXTSRCSRCDIR, MKEXTSRC (etc)
5. bsd.own.mk and various Makefiles: remove support for extsrc/,
EXTSRCSRCDIR, MKEXTSRC.

As proposed on tech-kern and tech-userlevel on 2022-01-07
and followed up on 2022-08-21.


# 1.93 25-Sep-2021 maya

Move DRM-driver firmware from base to its own set, gpufw

This set is only installed on amd64,i386,evbarm.
This set is installed on minimal installs and on install media, in
case someone needs it for basic driver functionality.

Comments:
Switched to a single MK tunable for it - that is probably unneeded.

An upcoming DRM update will include even fatter firmware, and we'd
like to minimize the impact of it.


# 1.92 18-Sep-2021 christos

Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, but not LIBRARY_PATH because it breaks
the build. These variables are necessary to support building NetBSD
from a GNU Guix or NixOS host, where /usr/include, /lib, and all
but /bin/sh do not exist. In many cases, support for HOST_CPPFLAGS
was incomplete. From Ryan Sundberg


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.96 10-Jun-2023 lukem

sets: enhance MAKEVERBOSE support

Add more messages for various sets operations.
Add ${_MKMSG_CREATE} to bsd.own.mk.

Enhance maketars to be a bit more verbose even with -q,
to make it more obvious why certain operations may be slow.
May help debugging PR 47562.


# 1.95 10-Jun-2023 lukem

maketars: add comments for skipped mtree keywords

Reorder skipkeys alphabetically and add comment explaining
the purpose and why sha256 is not part of the variable.


Revision tags: netbsd-10-base
# 1.94 21-Aug-2022 lukem

Deprecate extsrc/, EXTSRCSRCDIR, MKEXTSRC

Remove support for building extsrc/:
1. Makefile: remove do-extsrc target.
2. build.sh: remove options -y and -Y extsrcdir.
3. distrib/sets: remove support for extsrc in various tools
including the options -L ext and -y, and the extsrc sets.
4. doc/BUILDING.mdoc: remove docs for extsrc/, EXTSRCSRCDIR, MKEXTSRC (etc)
5. bsd.own.mk and various Makefiles: remove support for extsrc/,
EXTSRCSRCDIR, MKEXTSRC.

As proposed on tech-kern and tech-userlevel on 2022-01-07
and followed up on 2022-08-21.


# 1.93 25-Sep-2021 maya

Move DRM-driver firmware from base to its own set, gpufw

This set is only installed on amd64,i386,evbarm.
This set is installed on minimal installs and on install media, in
case someone needs it for basic driver functionality.

Comments:
Switched to a single MK tunable for it - that is probably unneeded.

An upcoming DRM update will include even fatter firmware, and we'd
like to minimize the impact of it.


# 1.92 18-Sep-2021 christos

Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, but not LIBRARY_PATH because it breaks
the build. These variables are necessary to support building NetBSD
from a GNU Guix or NixOS host, where /usr/include, /lib, and all
but /bin/sh do not exist. In many cases, support for HOST_CPPFLAGS
was incomplete. From Ryan Sundberg


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.94 21-Aug-2022 lukem

Deprecate extsrc/, EXTSRCSRCDIR, MKEXTSRC

Remove support for building extsrc/:
1. Makefile: remove do-extsrc target.
2. build.sh: remove options -y and -Y extsrcdir.
3. distrib/sets: remove support for extsrc in various tools
including the options -L ext and -y, and the extsrc sets.
4. doc/BUILDING.mdoc: remove docs for extsrc/, EXTSRCSRCDIR, MKEXTSRC (etc)
5. bsd.own.mk and various Makefiles: remove support for extsrc/,
EXTSRCSRCDIR, MKEXTSRC.

As proposed on tech-kern and tech-userlevel on 2022-01-07
and followed up on 2022-08-21.


# 1.93 25-Sep-2021 maya

Move DRM-driver firmware from base to its own set, gpufw

This set is only installed on amd64,i386,evbarm.
This set is installed on minimal installs and on install media, in
case someone needs it for basic driver functionality.

Comments:
Switched to a single MK tunable for it - that is probably unneeded.

An upcoming DRM update will include even fatter firmware, and we'd
like to minimize the impact of it.


# 1.92 18-Sep-2021 christos

Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, but not LIBRARY_PATH because it breaks
the build. These variables are necessary to support building NetBSD
from a GNU Guix or NixOS host, where /usr/include, /lib, and all
but /bin/sh do not exist. In many cases, support for HOST_CPPFLAGS
was incomplete. From Ryan Sundberg


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.93 25-Sep-2021 maya

Move DRM-driver firmware from base to its own set, gpufw

This set is only installed on amd64,i386,evbarm.
This set is installed on minimal installs and on install media, in
case someone needs it for basic driver functionality.

Comments:
Switched to a single MK tunable for it - that is probably unneeded.

An upcoming DRM update will include even fatter firmware, and we'd
like to minimize the impact of it.


# 1.92 18-Sep-2021 christos

Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, but not LIBRARY_PATH because it breaks
the build. These variables are necessary to support building NetBSD
from a GNU Guix or NixOS host, where /usr/include, /lib, and all
but /bin/sh do not exist. In many cases, support for HOST_CPPFLAGS
was incomplete. From Ryan Sundberg


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.92 18-Sep-2021 christos

Patch the build script and toolchain to allow passing through
HOST_CPPFLAGS, HOST_CXXFLAGS, but not LIBRARY_PATH because it breaks
the build. These variables are necessary to support building NetBSD
from a GNU Guix or NixOS host, where /usr/include, /lib, and all
but /bin/sh do not exist. In many cases, support for HOST_CPPFLAGS
was incomplete. From Ryan Sundberg


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.91 18-May-2020 jmcneill

Separate devicetree .dts -> .dtb building from kernel builds. They are now
part of a separate set, "dtb.tgz", and only built when MKDTB=yes. This
defaults to yes for earmv[67]* and aarch64, and no everywhere else.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

branches: 1.89.2;
Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.90 02-Oct-2019 maya

Split out /rescue to its own set and adapt installers/images to add it.

This is meant to make updates safer: if something goes wrong with updating
base, we still have the old, standalone /rescue to recover from.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10; 1.86.12;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.89 28-Sep-2018 martin

Prepare for .tar.xz sets


# 1.88 26-Sep-2018 martin

Revert previous - will pass the additional args via the environment.


# 1.87 26-Sep-2018 martin

Allow for ${COMPRESS_PROGRAM} to hold the name of a compressor program
plus additional arguments (like -9).


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.86 21-Jan-2017 jklos

branches: 1.86.10;
This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

branches: 1.85.2; 1.85.4;
Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.86 21-Jan-2017 jklos

This fixes a bug where mtree would use names & IDs from the host system
instead of from the build.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 07-Feb-2013 christos

merge d flag.


# 1.78 07-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 06-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 10-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 16-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 21-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 19-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 03-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 29-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 30-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 23-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 19-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 17-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 26-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 24-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 18-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.85 19-Dec-2015 christos

Obey MKREPRO_TIMESTAMP when creating sets (create all the files in the
sets with that date).


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 06-Feb-2013 christos

merge d flag.


# 1.78 06-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 05-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


Revision tags: yamt-pagecache-base8
# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


Revision tags: matt-premerge-20091211
# 1.73 09-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 02-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 15-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


Revision tags: mjf-devfs-base cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 20-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.52 18-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 02-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 28-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 29-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


Revision tags: fvdl_fs64_base
# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 22-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 18-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 18-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 16-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 25-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


Revision tags: netbsd-1-6-base
# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 12-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 23-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


Revision tags: netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 28-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


Revision tags: netbsd-1-3-base
# 1.3 17-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.84 27-May-2015 martin

Simplify slightly


# 1.83 27-May-2015 martin

Instead of guessing wether to preserve permissions on install operations
from the METALOG variable, default them to yes and add a new argument -U to
switch preservation off.


# 1.82 26-May-2015 martin

Do not try to preserve permissions when copying to the -i installdir
in the METALOG case (it makes no sense at all).


# 1.81 26-Apr-2015 martin

Add a new arg to override the value of the "setlistdir" variable (that is:
where the mtree spec files are created)


# 1.80 07-Feb-2013 christos

We always have a valid mtree file, so always specify -M


# 1.79 06-Feb-2013 christos

merge d flag.


# 1.78 06-Feb-2013 christos

- use dest instead of DESTDIR
- factor out pax usage, and make it use only the first word from the sets


# 1.77 05-Feb-2013 christos

Create full sets using mtree from the flists (not just filenames).


# 1.76 16-Jan-2013 christos

- add xdebug set
- document debug better
- fix previous debug fallout.


# 1.75 16-Jan-2013 christos

Add a new "debug" set that gets built when ${MKDEBUG} is set. On evbarm:
-rw-r--r-- 1 root src 35806068 Jan 16 10:47 base.tgz
-rw-r--r-- 1 root src 57374069 Jan 16 10:48 comp.tgz
-rw-r--r-- 1 root src 101286193 Jan 16 10:49 debug.tgz
...
This allows always building the debugging code and libraries but not
installing it (although now it is placed in the default sets if ${MKDEBUG}
is set


# 1.74 15-Aug-2010 mrg

branches: 1.74.6; 1.74.12;
add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)

you can set it to "yes" on most modern platforms just fine.


# 1.73 09-Dec-2009 uebayasi

sh(1) style. No functional changes.


# 1.72 05-Dec-2009 cegger

Fix syntax error on OSX 10.5.
While here, simplify handling with OPTARG using IFS.

developped with and 'go for it' dsl@


# 1.71 03-Dec-2009 apb

Exit with a sensible error message if makeflist output is empty.
This should be better than an incomprehensible error message from
mtree.


# 1.70 30-Nov-2009 uebayasi

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)


# 1.69 12-Sep-2009 apb

If there are errors in creating a ${set}.tgz tar file, then don't
just press on regardless.


# 1.68 11-Apr-2009 apb

In various places that manipulate mtree specs, use "mtree -CS" to sort.
Remove some now-redundant standalone sort commands.


# 1.67 03-Apr-2009 perry

Consistently use gzip with the -n flag so dates are not embedded.

Not tested on all platforms.


# 1.66 02-Apr-2009 tsutsui

Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.65 02-Apr-2009 perry

Clean up set files to make them consistent using mtree. Patch from lukem.


# 1.64 16-Mar-2008 lukem

branches: 1.64.6; 1.64.8;
Add '-q' to maketars and makesrctars, to quieten them.
Improve MAKEVERBOSE support.


# 1.63 15-Mar-2008 lukem

Cleanup .tgz.tmp files on exit.


# 1.62 12-Nov-2007 jmmv

branches: 1.62.6; 1.62.8;
Add the tests.tgz set

This adds a new tests.tgz set to releases which includes all the tests
for the system. It is important to note that this set does not rely on
comp.tgz: a user of the system can run the tests without having the
development tools installed, which can be useful in a production machine.


# 1.61 28-Jan-2006 apb

branches: 1.61.10;
No space in "function()", "command;" or "$(command)".
Requested by christos.


# 1.60 08-Jan-2006 apb

When printing messages to stderr, always use
echo >&2 "${prog}: ..."

Approved by christos


# 1.59 04-Jan-2006 apb

Remove the code that used "${MTREE} -C ..." to sanitise the plist. We
can now assume that it's already been sanitised before maketars was
invoked.

Reviewed by agc


# 1.58 03-Jan-2006 apb

Ensure that (almost) all shell variables in distrib/sets/* scripts are
used with curly braces and quotes, as in "${var}".

Also ensure that command substitution is quoted, as in "$(command)", and
convert `command` to $(command).

Reviewed by agc


# 1.57 03-Jan-2006 apb

Add shell variables defined in sets.subr for almost all commands used
by scripts in distrib/sets/*. This is intended to be useful when cross
building. Only trivial commands like echo, cat, and rm are excluded
from this treatment.

While I am here, make ${MTREE} and ${DB} follow the pattern used by most
other such variables.

Reviewed by agc.


# 1.56 03-Jan-2006 apb

Move default values for several shell variables into sets.subr.

Reviewed by agc


# 1.55 20-Oct-2005 jmc

Set default vars so blank and unset both end up w. a reasonable default


# 1.54 23-Jul-2004 erh

Make all the sets scripts work even when not run from the directory that
they reside in.
Change any uses of dirname to use shell variable substitution instead.


# 1.53 18-Apr-2004 dsl

Write to a temporary file and mv to real name to avoid getting a
truncated file if/when interrupted.


# 1.52 18-Feb-2004 dyoung

Clearly the error message was supposed to print $metalog, not
$METALOG.


# 1.51 06-Feb-2004 lukem

When not using a metalog, only copy the generated flist.<set> over
/etc/mtree/set.<set> if they are different. This should allow
installsets to operate from a pre-populated read-only DESTDIR.
Based on fix from Juergen Hannken-Illjes.


# 1.50 30-Jan-2004 lukem

Create ${DESTDIR}/etc/mtree/set.<setname> setfiles for each given <setname>.
Add `-S' to exit after creating the setfiles.
Send errors to stderr instead of stdout.


# 1.49 29-Jan-2004 lukem

Also remove "xetc" from the default list of sets copied with -i installdir


# 1.48 02-Jan-2004 lukem

rename all the <bsd.own.mk> derived variables to uppercase, and export
them to the environment.


# 1.47 28-Dec-2003 lukem

Significant overhaul of how the sets are used:

* Add an optional third field to the sets file which is a list of
comma separated keywords that control if the line is printed.
Currently supported keywords
kerberos4 ${MKKERBEROS4} != no
kerberos ${MKKERBEROS} != no
lint ${MKLINT} != no
obsolete ${obsolete} != 0.
In this case, non obsolete files are not printed.
(This will allow future support for builds with variables such as
MKHESIOD and MKYP set to "no".)

* Use sh(1)'s getopts where appropriate, and otherwise cleanup the
various scripts.

* Move defaults for sets.subr from sets.defaults into sets.subr.
Move replicated code for determining stuff such as shlibs type
from various scripts into sets.subr.

* Merge the obsolete.*, krb.*, krb4.* and lint.* into the appropriate
main lists with the relevant third field keyword(s).


# 1.46 19-Dec-2003 jmc

Redo creation of sets/sums so this can be parallelized if using -j.
Suggested in PR#20115 and PR#20116


# 1.45 25-Nov-2003 dyoung

Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.


# 1.44 16-Oct-2003 dsl

Report correct error code (in particular when mtree objects to METALOG file).


# 1.43 29-Sep-2003 lukem

* use ${MKTEMP} -d instead of home-grown tempdir creation code
* use $(...) instead of `...`
* fix a recent modification to follow the same coding style as the
rest of the file... (mmm, consistency)


# 1.42 22-Aug-2003 dsl

Since the METALOG is updated by every install, there is no need to
remake the sets if the set files are newer than METALOG.
Useful for running DISTRIBUTION_DONE= nbmake in src/etc in order to
rebuild with new kernels and/or new ramdisk.


# 1.41 03-Jul-2003 lukem

if the mtree parse of METALOG fails, exit.


# 1.40 07-Apr-2003 perry

Temporarily revert last. It now screws over symlinks from the destdir,
which is the inverse problem. It is fixable by piping one pax -w into
a pax -r instead of using a pax -rw, but unfortunately that won't work
yet because I've hit a pax issue. I'll fix that and then fix this right.


# 1.39 06-Apr-2003 perry

do pax -L so that symlinks aren't blown away.
Beginning of work to fix PR install/8090 from Luke Mewburn


# 1.38 21-Jan-2003 erh

Return the correct exit status in the trap handler so errors get caught.
Also make sure the status is less than 256.


# 1.37 06-Jan-2003 wiz

writable, not writeable.


# 1.36 03-Jan-2003 lukem

improve description of -t


# 1.35 25-Dec-2002 lukem

improve description


# 1.34 25-Dec-2002 lukem

fix header to match usage


# 1.33 22-Dec-2002 lukem

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";

Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.


# 1.32 21-Dec-2002 lukem

Invoke ${PAX} with '-O' so that various errors don't hang the make
or the command with an interactive question. (This also prevents
weird problems if a directory element of '-f path' is missing and
'make -j N' is being used).


# 1.31 19-Dec-2002 lukem

Always call maketars (and subsequently pax) with -N ${NETBSDSRCDIR}/etc,
so that we always use the user & group databases from there rather than
the host systems.


# 1.30 18-Dec-2002 lukem

maketars:
- add "-N etcdir", to be used for pax & mtree -N. defaults to ${DESTDIR}/etc

Makefile:
- if UNPRIVED, call maketars with "-N ${NETBSDSRCDIR}/etc", so that
"make UNPRIVED= DESTDIR=/foo installsets" can work with an empty
${DESTDIR}/etc. (i.e, after a make build without install-etc-files)


# 1.29 16-Dec-2002 lukem

consistently use $dest instead of $DESTDIR


# 1.28 12-Dec-2002 lukem

Add '-i installdir', to copy the given sets from $DESTDIR to installdir
instead of creating tar files. If the default sets are used, "etc" is
removed from the list, because it's highly unlikely that it's wanted
in that case.

Tested against a DESTDIR created with "make UNPRIVED= DESTDIR=.... build".


# 1.27 25-Nov-2002 lukem

use ${make} instead of ${MAKE} in the shell scripts, to prevent weird
lossage with the modified ${MAKE} getting passed to child make's


# 1.26 25-Nov-2002 lukem

explicitly add " -f `dirname $0`/Makefile " to ${MAKE}, so that
these scripts do not need to be run from this directory in order
to function correctly


# 1.25 23-Jul-2002 lukem

set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


# 1.24 19-May-2002 lukem

branches: 1.24.2;
keep separate temp files for "full" flists


# 1.23 13-Apr-2002 lukem

- clean up SDIR (temporary directory) creation
- improve munging of NetBSD.dist and METALOG into metalog, using mtree to
"cleanup" / "merge" entries, and don't sort the result.
relies upon mtree to not change the order (see below)
- use (newly added) join.awk to output lines in metalog that are listed
in flist.${set}. join.awk doesn't require either file to be sorted
(unlike join(1)), which is required because we want to retain the
order of the metalog, because certain entries in the metalog (such
as hard links) make assumptions about the permissions of earlier entries.
this should fix [toolchain/16207]


# 1.22 08-Apr-2002 tron

Solve problem with with XFree86 3.3.6/4.x set "maketars" differently:
We don't want e.g. a seperate "xbase.tgz" and "xbase3.tgz" but one
combined archive.


# 1.21 08-Apr-2002 tron

Fix problem with building X11 release "tar" archives after support for
XFree86 4.x sets has been added. Problem noted by Richard Earnshaw in
private e-mail.


# 1.20 01-Apr-2002 bjh21

Instead of using mktemp -d (which isn't available on many systems), use mkdir
in a loop to create a temporary directory. Add a few chacks for the sanity
of /tmp first, so as to avoid making the loop infinite.


# 1.19 01-Mar-2002 lukem

- use numeric rather than symbolic trap names; it's more portable
- read NetBSD.dist from ${DESTDIR}/etc/mtree instead of /usr/src/etc/mtree
- run mtree with "-N ${DESTDIR}/etc" instead of using the host user databases


# 1.18 27-Feb-2002 lukem

Fixes to allow unprivileged building of the binary tar files to
contain the correct permissions.

Makefile:
- set SETSENV to the list of variables we wish to pass to each shell
script and use that, rather than duplicating the effort below
- call maketars with "-M ${METALOG}" if UNPRIVED is set.

getdirs.awk:
- takes a list of filenames and outputs the list along with all the
directories used by those filenames

maketars:
- support "-M metalog"
- merge etc/mtree/NetBSD.dist with the "-M metalog" for use in the tgz build
- for a given set, find the union between the set list and the metalog
generated above and use that as the list of files to ${PAX} up as the
tgz file.


# 1.17 26-Feb-2002 he

Wait with exiting on error until all the install sets have been
attempted to be created.

This way, in "discover missing files" mode, you'll get the benefit
of getting all the missing files listed before this script bombs
out with a non-zero exit status, something which can be of benefit
on slow machines.


# 1.16 23-Nov-2001 thorpej

Use the logic in bsd.own.mk to determine machine/machine_arch.


# 1.15 22-Jan-2001 jmc

Change pipeline in sets building so proper error detection for each stage
can be detected. This way sets stop building at the exact file that doesn't
exist rather than continuing.


# 1.14 01-Oct-2000 thorpej

Add the xmisc set.


# 1.13 13-Feb-1999 itohy

branches: 1.13.10;
Use "$MAKE" instead of "make" for cross environment.


# 1.12 03-Dec-1998 frueauf

Use $out correctly, pointed out in pr 6526 by Dave Huang.


# 1.11 18-Nov-1998 he

There should be no need for the "set -x" now, it clutters output.


# 1.10 27-Jun-1998 ross

The newly churned maketars was apparently not tested in its normal
mode with no options and no parameters.

You have to be careful about the difference between $@ and $*.
In particular, "if [ -n "$@" ]" does not do what you think it will.


# 1.9 15-Jun-1998 lukem

* replace '-arch arch' with '-m machine' (as per make(1)'s $MACHINE). e.g, i386
* add '-a arch' - $MACHINE_ARCH. e.g, m68k, powerpc
* replace long -options with short -options (with backward compat)
* ``knf''ify scripts


# 1.8 27-Nov-1997 jonathan

Change ".tar.gz" tarball suffix to ".tgz", per release(7).


# 1.7 09-Nov-1997 chopps

add -both arg for when one puts xsrc and src builds in same DESTDIR


# 1.6 05-Nov-1997 scottr

When deciding which md set lists to use, prefer $MACHINE over
uname -m


# 1.5 27-Oct-1997 veego

Add xcontrib to xlists.


# 1.4 28-Oct-1997 veego

Add a new option '-x11' for the xsets.


# 1.3 17-Feb-1997 mikel

branches: 1.3.2;
Feed makeflist to sh, instead of relying on x-bits; from Andrew
Wheadon in PR 3116.


# 1.2 20-May-1996 gwr

More portable versions of makeflist and maketars that can be used to
cross-make a distribution. Also avoid duplicating makeflist logic.


# 1.1 29-Aug-1994 cgd

branches: 1.1.1;
Initial revision


# 1.1.1.1 29-Aug-1994 cgd

branches: 1.1.1.1.2;
distribution sets contents lists


# 1.1.1.1.2.2 29-Aug-1994 cgd

distribution sets contents lists


# 1.1.1.1.2.1 29-Aug-1994 cgd

file maketars was added on branch netbsd-1-0 on 1994-08-29 15:21:04 +0000


# 1.3.2.5 28-Nov-1997 mellon

Pull rev 1.8 up from trunk (jonathan)


# 1.3.2.4 09-Nov-1997 mellon

Pull rev 1.7 up from trunk (chopps)


# 1.3.2.3 06-Nov-1997 mellon

Pull rev 1.6 up from trunk (scottr)


# 1.3.2.2 28-Oct-1997 mellon

Pull rev 1.5 up from trunk (veego)


# 1.3.2.1 28-Oct-1997 mellon

Pull rev 1.4 up from trunk (veego)


# 1.13.10.4 27-Feb-2002 he

Apply patch (requested by he):
Actually make the exit status collection work.


# 1.13.10.3 26-Feb-2002 he

Pull up revision 1.17 (via patch, requested by he):
Collect exit status for all set constructions before exiting.


# 1.13.10.2 23-Feb-2002 he

Pull up revision 1.15 (requested by jmc):
If, during construction of an install set, pax did not find one
or more files, error out.


# 1.13.10.1 31-Oct-2000 tv

Pullup 1.14 [jmc]:
Enable xmisc in sysinst.


# 1.24.2.1 23-Jul-2002 lukem

Pull up revision 1.25 (requested by lukem):
set MAKE="${MAKE:-make} -j 1" to prevent problems where the output
of make -j N>1 would result in junk in various shell variables


# 1.61.10.2 22-Mar-2008 matt

sync with HEAD


# 1.61.10.1 08-Jan-2008 matt

sync with HEAD


# 1.62.8.2 05-Oct-2008 mjf

Sync with HEAD.


# 1.62.8.1 03-Apr-2008 mjf

Sync with HEAD.


# 1.62.6.1 24-Mar-2008 keiichi

sync with head.


# 1.64.8.1 13-May-2009 jym

Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html


# 1.64.6.3 06-Jun-2009 bouyer

Pull up following revision(s) (requested by snj in ticket #790):
share/mk/bsd.lib.mk: revision 1.298
share/mk/bsd.man.mk: revision 1.100
share/mk/bsd.hostprog.mk: revision 1.55
distrib/sets/maketars: revision 1.66
share/zoneinfo/Makefile: revision 1.43
share/mk/bsd.kmodule.mk: revision 1.19
usr.bin/xinstall/xinstall.c: revisions 1.106 - 1.108 via patch
share/mk/bsd.prog.mk: revision 1.241
share/dict/Makefile: revision 1.17
share/mk/bsd.README: revision 1.249
distrib/common/parselist.awk: revision 1.16
share/mk/bsd.links.mk: revision 1.34
Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.
Changes for installing with a metalog:
* When installing hard links and using a metalog, if -o, -g, -m, or -f
args were explicitly specified on the command line, then believe them,
but do not implicitly believe uname/gname/mode/flags from the file
system.
* Output fields in the same order used by mtree.
Fix -Wshadow -Wcast-qual issues
Re-calculate size and digestresult after stripping, to ensure that
correct values appear in the metalog.
Add LINKSOWN, LINKSGRP, and LINKSMODE variables for use by bsd.links.mk
when installing hard links. They have no effect except when using a
metalog, in which case the information is added to the metalog. In
the future, these variables may be replaced by a method for explicitly
recording hard links in a metadata log.
Also change a few things that called ${INSTALL_LINK} without going
through bsd.links.mk.
Reviewed by perry and joerg. This should fix PR 24457 and PR 41155.


# 1.64.6.2 07-Apr-2009 snj

branches: 1.64.6.2.2;
Back out ticket 654, as it exposes issues with mtree's handling
of hard links.


# 1.64.6.1 04-Apr-2009 snj

Pull up following revision(s) (requested by tsutsui in ticket #654):
distrib/sets/maketars: revision 1.66
Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.


# 1.64.6.2.2.1 06-Jun-2009 bouyer

branches: 1.64.6.2.2.1.2;
Pull up following revision(s) (requested by snj in ticket #790):
share/mk/bsd.lib.mk: revision 1.298
share/mk/bsd.man.mk: revision 1.100
share/mk/bsd.hostprog.mk: revision 1.55
distrib/sets/maketars: revision 1.66
share/zoneinfo/Makefile: revision 1.43
share/mk/bsd.kmodule.mk: revision 1.19
usr.bin/xinstall/xinstall.c: revisions 1.106 - 1.108 via patch
share/mk/bsd.prog.mk: revision 1.241
share/dict/Makefile: revision 1.17
share/mk/bsd.README: revision 1.249
distrib/common/parselist.awk: revision 1.16
share/mk/bsd.links.mk: revision 1.34
Explicitly sort entries on preparing set files from METALOG.
METALOG could have different order due to install(1) race
on parallel builds, and mtree(8) doesn't sort files.
Should fix inconsistent shared sets among builds as seen in
/pub/NetBSD-daily/netbsd-5/200904010000Z/shared/ and
/pub/NetBSD-daily/netbsd-5/200904010002Z/shared/ dirs.
Okay'ed by snj@.
Changes for installing with a metalog:
* When installing hard links and using a metalog, if -o, -g, -m, or -f
args were explicitly specified on the command line, then believe them,
but do not implicitly believe uname/gname/mode/flags from the file
system.
* Output fields in the same order used by mtree.
Fix -Wshadow -Wcast-qual issues
Re-calculate size and digestresult after stripping, to ensure that
correct values appear in the metalog.
Add LINKSOWN, LINKSGRP, and LINKSMODE variables for use by bsd.links.mk
when installing hard links. They have no effect except when using a
metalog, in which case the information is added to the metalog. In
the future, these variables may be replaced by a method for explicitly
recording hard links in a metadata log.
Also change a few things that called ${INSTALL_LINK} without going
through bsd.links.mk.
Reviewed by perry and joerg. This should fix PR 24457 and PR 41155.


# 1.64.6.2.2.1.2.1 20-Apr-2010 matt

sync to netbsd-5


# 1.74.12.1 24-Feb-2013 tls

resync with head


# 1.74.6.2 22-May-2014 yamt

sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")


# 1.74.6.1 22-Jan-2013 yamt

sync with head