Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
2014-05-30 12:37:35 +04:00
|
|
|
# $NetBSD: regpkg,v 1.22 2014/05/30 08:37:35 uebayasi Exp $
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
#
|
2009-10-18 03:43:22 +04:00
|
|
|
# Copyright (c) 2003,2009 The NetBSD Foundation, Inc.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
# by Alistair Crooks (agc@NetBSD.org)
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
2009-10-18 03:43:22 +04:00
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
#
|
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
# Usage: regpkg [options] set pkgname
|
|
|
|
#
|
|
|
|
# Registers a syspkg in the database directory,
|
|
|
|
# and optionally creates a binary package.
|
|
|
|
#
|
|
|
|
# Options:
|
|
|
|
# -q Quiet.
|
|
|
|
# -v Verbose.
|
|
|
|
# -f Force.
|
|
|
|
# -m Ignore errors from missing files.
|
|
|
|
# -u Update.
|
|
|
|
# -c Use cached information from ${BUILD_INFO_CACHE}.
|
|
|
|
# -d destdir Sets DESTDIR.
|
|
|
|
# -t binpkgdir Create a binary package (in *.tgz format) in the
|
|
|
|
# specified directory. Without this option, a binary
|
|
|
|
# package is not created.
|
|
|
|
# -M metalog Use the specified metalog file to override file
|
|
|
|
# or directory attributes when creating a binary package.
|
|
|
|
# -N etcdir Use the specified directory for passwd and group files.
|
|
|
|
#
|
|
|
|
# When -f is set: If the desired syspkg already exists, it is overwritten.
|
|
|
|
# When -u is set: If the desired syspkg already exists, it might be
|
|
|
|
# overwritten or left alone, depending on whether it's older
|
|
|
|
# or newer than the files that belong to the syspkg.
|
|
|
|
# When neither -u nor -f are set: It's an error for the desired syspkg
|
|
|
|
# to already exist.
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
prog="${0##*/}"
|
|
|
|
toppid=$$
|
2006-01-03 21:31:09 +03:00
|
|
|
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
|
2006-01-04 17:14:35 +03:00
|
|
|
. "${rundir}/sets.subr"
|
2004-07-23 19:11:26 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
bomb()
|
|
|
|
{
|
|
|
|
#echo "${prog}: bomb: start, toppid=${toppid} \$\$=$$"
|
|
|
|
kill ${toppid} # in case we were invoked from a subshell
|
|
|
|
#echo "${prog}: bomb: killed ${toppid}"
|
|
|
|
exit 1
|
|
|
|
}
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
# A literal newline
|
|
|
|
nl='
|
|
|
|
'
|
|
|
|
# A literal tab
|
|
|
|
tab=' '
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
# Prefixes for error messages, warnings, and important informational
|
|
|
|
# messages.
|
|
|
|
ERROR="${prog}: ERROR: "
|
|
|
|
WARNING="${prog}: WARNING: "
|
|
|
|
NOTE="${prog}: NOTE: "
|
|
|
|
ERRWARN="${ERROR}" # may be changed by "-f" (force) command line flag
|
|
|
|
ERRWARNNOTE="${ERROR}" # may be changed by "-u" (update) command line flag
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
#
|
|
|
|
# All temporary files will go in ${SCRATCH}, which will be deleted on
|
|
|
|
# exit.
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
SCRATCH="$(${MKTEMP} -d "/var/tmp/${0##*/}.XXXXXX")"
|
2006-01-04 17:14:35 +03:00
|
|
|
if [ $? -ne 0 -o \! -d "${SCRATCH}" ]; then
|
2006-01-08 13:10:03 +03:00
|
|
|
echo >&2 "${prog}: Could not create scratch directory."
|
2006-01-04 17:14:35 +03:00
|
|
|
bomb
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
fi
|
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
#
|
|
|
|
# cleanup() always deletes the SCRATCH directory, and might also
|
|
|
|
# delete other files or directories.
|
|
|
|
#
|
|
|
|
es=0
|
|
|
|
cleanup_must_delete_binpkgfile=false
|
|
|
|
cleanup_must_delete_dbsubdir=false
|
2006-01-28 22:01:23 +03:00
|
|
|
cleanup()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
trap - 0
|
|
|
|
#echo "${prog}: cleanup start"
|
|
|
|
if ${cleanup_must_delete_binpkgfile:-false} && [ -e "${binpkgfile}" ]
|
|
|
|
then
|
|
|
|
echo >&2 "${prog}: deleting partially-created ${binpkgfile}"
|
|
|
|
rm -f "${binpkgfile}"
|
|
|
|
fi
|
|
|
|
if ${cleanup_must_delete_dbsubdir:-false} \
|
|
|
|
&& [ -e "${SYSPKG_DB_SUBDIR}" ]
|
|
|
|
then
|
|
|
|
echo >&2 "${prog}: deleting partially-created ${SYSPKG_DB_SUBDIR}"
|
|
|
|
rm -rf "${SYSPKG_DB_SUBDIR}"
|
|
|
|
fi
|
|
|
|
rm -rf "${SCRATCH}"
|
|
|
|
#echo "${prog}: cleanup done, exit ${es}"
|
|
|
|
exit ${es}
|
|
|
|
}
|
|
|
|
trap 'es=128; cleanup' 1 2 3 13 15 # HUP INT QUIT PIPE TERM
|
|
|
|
trap 'es=$?; cleanup' 0 # EXIT
|
|
|
|
|
|
|
|
#
|
|
|
|
# Parse command line args.
|
|
|
|
#
|
|
|
|
verbose=false
|
|
|
|
verbosity=0
|
|
|
|
quiet=false
|
|
|
|
force=false
|
|
|
|
update=false
|
|
|
|
allowmissing=false
|
|
|
|
DESTDIR="${DESTDIR}"
|
|
|
|
binpkgdir=""
|
|
|
|
metalog=""
|
|
|
|
etcdir=""
|
|
|
|
SYSPKG_DB_TOPDIR=""
|
|
|
|
pkgset=""
|
|
|
|
pkg=""
|
2006-01-28 22:01:23 +03:00
|
|
|
parse_args()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
while [ $# -gt 2 ]; do
|
|
|
|
case "$1" in
|
2006-01-28 22:01:23 +03:00
|
|
|
-q) quiet=true; verbose=false ;;
|
|
|
|
-v) verbose=true; quiet=false
|
2006-01-04 17:14:35 +03:00
|
|
|
verbosity=$(( ${verbosity} + 1 ))
|
|
|
|
;;
|
|
|
|
-f) force=true ;;
|
|
|
|
-u) update=true ;;
|
|
|
|
-m) allowmissing=true ;;
|
|
|
|
-c) # The -c option is ignored. The BUILD_INFO_CACHE
|
|
|
|
# environment variable is used instead.
|
|
|
|
;;
|
2006-01-28 22:01:23 +03:00
|
|
|
-d) DESTDIR="$2"; shift ;;
|
2006-01-04 17:14:35 +03:00
|
|
|
-d*) DESTDIR="${1#-?}" ;;
|
2006-01-28 22:01:23 +03:00
|
|
|
-t) binpkgdir="$2"; shift ;;
|
2006-01-04 17:14:35 +03:00
|
|
|
-t*) binpkgdir="${1#-?}" ;;
|
2006-01-28 22:01:23 +03:00
|
|
|
-M) metalog="$2"; shift ;;
|
2006-01-04 17:14:35 +03:00
|
|
|
-M*) metalog="${1#-?}" ;;
|
2006-01-28 22:01:23 +03:00
|
|
|
-N) etcdir="$2"; shift ;;
|
2006-01-04 17:14:35 +03:00
|
|
|
-N*) etcdir="${1#-?}" ;;
|
|
|
|
*) break ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
if ${force}; then
|
|
|
|
ERRWARN="${WARNING}"
|
|
|
|
else
|
|
|
|
ERRWARN="${ERROR}"
|
|
|
|
fi
|
|
|
|
if ${update}; then
|
|
|
|
ERRWARNNOTE="${NOTE}"
|
|
|
|
else
|
|
|
|
ERRWARNNOTE="${ERRWARN}"
|
|
|
|
fi
|
|
|
|
DESTDIR="${DESTDIR%/}" # delete trailing "/" if any
|
|
|
|
if [ \! -n "${etcdir}" ]; then
|
|
|
|
etcdir="${DESTDIR}/etc"
|
|
|
|
fi
|
|
|
|
if [ -n "${binpkgdir}" -a \! -d "${binpkgdir}" ]; then
|
|
|
|
echo >&2 "${ERROR}binary pkg directory ${binpkgdir} does not exist"
|
|
|
|
bomb
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
# SYSPKG_DB_TOPDIR is the top level directory for registering
|
|
|
|
# syspkgs. It defaults to ${DESTDIR}/var/db/syspkg, but can be
|
|
|
|
# overridden by environment variables SYSPKG_DBDIR or PKG_DBDIR.
|
|
|
|
#
|
|
|
|
# Note that this corresponds to the default value of PKG_DBDIR
|
|
|
|
# set in .../distrib/syspkg/mk/bsd.syspkg.mk.
|
|
|
|
#
|
|
|
|
SYSPKG_DB_TOPDIR="${SYSPKG_DBDIR:-${PKG_DBDIR:-${DESTDIR}/var/db/syspkg}}"
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
echo "Usage: regpkg [options] set pkgname"
|
|
|
|
bomb
|
|
|
|
fi
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
pkgset="$1"
|
|
|
|
pkg="$2"
|
|
|
|
}
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
#
|
|
|
|
# make_PLIST() creates a skeleton PLIST from the pkgset description.
|
|
|
|
#
|
|
|
|
# The result is stored in the file ${PLIST}.
|
|
|
|
#
|
|
|
|
PLIST="${SCRATCH}/PLIST"
|
2006-01-28 22:01:23 +03:00
|
|
|
make_PLIST()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
2006-01-28 22:01:23 +03:00
|
|
|
if ${verbose}; then
|
2006-01-04 17:14:35 +03:00
|
|
|
echo "Making PLIST for \"${pkg}\" package (part of ${pkgset} set)"
|
|
|
|
fi
|
|
|
|
prefix="${DESTDIR:-/}"
|
|
|
|
realprefix=/
|
|
|
|
${HOST_SH} "${rundir}/makeplist" -p "${prefix}" -I "${realprefix}" \
|
|
|
|
"${pkgset}" "${pkg}" \
|
|
|
|
>"${PLIST}" 2>"${SCRATCH}/makeplist-errors"
|
2006-01-28 22:01:23 +03:00
|
|
|
if ${EGREP} -v '^DEBUG:' "${SCRATCH}/makeplist-errors"; then
|
2006-01-04 17:14:35 +03:00
|
|
|
# "find" invoked from makeplist sometimes reports
|
|
|
|
# errors about missing files or directories, and
|
|
|
|
# makeplist ignores the errors. Catch them here.
|
|
|
|
echo >&2 "${ERROR}makeplist reported errors for ${pkg}:"
|
|
|
|
cat >&2 "${SCRATCH}/makeplist-errors"
|
|
|
|
echo >&2 "${ERROR}see above for errors from makeplist"
|
|
|
|
if ${allowmissing}; then
|
|
|
|
echo >&2 "${prog}: ${NOTE}: ignoring above errors, due to '-m' option."
|
|
|
|
else
|
|
|
|
${force} || bomb
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
#
|
|
|
|
# init_allfiles() converts the PLIST (which contains relative filenames)
|
|
|
|
# into a list of absolute filenames. Directories are excluded from the
|
|
|
|
# result.
|
|
|
|
#
|
|
|
|
# The result is stored in the variable ${allfiles}.
|
|
|
|
#
|
|
|
|
allfiles=''
|
2006-01-28 22:01:23 +03:00
|
|
|
init_allfiles()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
[ -f "${PLIST}" ] || make_PLIST
|
2006-01-28 22:01:23 +03:00
|
|
|
allfiles="$(${AWK} '
|
2006-01-04 17:14:35 +03:00
|
|
|
BEGIN { destdir = "'"${DESTDIR%/}"'" }
|
|
|
|
/^@cwd/ { prefix = $2; next }
|
|
|
|
/^@dirrm/ { next }
|
2006-01-28 22:01:23 +03:00
|
|
|
{ printf("%s%s%s\n", destdir, prefix, $0) }' "${PLIST}")"
|
2006-01-04 17:14:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# init_newestfile() finds the newest file (most recent mtime).
|
|
|
|
#
|
|
|
|
# The result is stored in the variable ${newestfile}.
|
|
|
|
#
|
|
|
|
newestfile=''
|
2006-01-28 22:01:23 +03:00
|
|
|
init_newestfile()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
[ -s "${allfiles}" ] || init_allfiles
|
|
|
|
# We assume no shell special characters in ${allfiles},
|
|
|
|
# and spaces only between file names, not inside file names.
|
|
|
|
# This should be safe, because it has no no user-specified parts.
|
2006-01-28 22:01:23 +03:00
|
|
|
newestfile="$(${LS} -1dt ${allfiles} | ${SED} '1q')"
|
2006-01-04 17:14:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Various ways of getting parts of the syspkg version number:
|
|
|
|
#
|
|
|
|
# get_osvers() - get the OS version number from osrelease.sh or $(uname -r),
|
|
|
|
# return it in ${osvers}, and set ${method}.
|
|
|
|
# get_tinyvers() - get the tiny version number from the "versions" file,
|
|
|
|
# and return it in ${tinyvers}. Does not set ${method}.
|
|
|
|
# get_newest_rcsid_date() - get the newest RCS date,
|
|
|
|
# and return it in ${newest}. Does not set ${method}.
|
|
|
|
# get_newest_mtime_date() - get the newest file modification date,
|
|
|
|
# and return it in ${newest}. Does not set ${method}.
|
|
|
|
# get_newest_date() - get date from rcsid or mtime, return it in ${newest},
|
|
|
|
# and set ${method}.
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
get_osvers()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
2003-06-18 14:53:52 +04:00
|
|
|
if [ -f ../../sys/conf/osrelease.sh ]; then
|
2006-01-03 21:31:09 +03:00
|
|
|
osvers="$(${HOST_SH} ../../sys/conf/osrelease.sh)"
|
2003-06-23 13:25:34 +04:00
|
|
|
method=osreleases
|
2003-06-18 14:53:52 +04:00
|
|
|
else
|
2006-01-03 21:31:09 +03:00
|
|
|
osvers="$(${UNAME} -r)"
|
2003-06-18 14:53:52 +04:00
|
|
|
method=uname
|
|
|
|
fi
|
2006-01-04 17:14:35 +03:00
|
|
|
#echo "${osvers}"
|
|
|
|
}
|
2006-01-28 22:01:23 +03:00
|
|
|
get_tinyvers()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
2006-01-28 22:01:23 +03:00
|
|
|
tinyvers="$(${AWK} '$1 ~ '/"${pkg}"/' { print $2 }' \
|
|
|
|
"${rundir}/versions")"
|
2006-01-04 17:14:35 +03:00
|
|
|
case "${tinyvers}" in
|
|
|
|
"") tinyvers=0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
#echo "${tinyvers}"
|
|
|
|
}
|
|
|
|
get_newest_rcsid_date()
|
|
|
|
{
|
|
|
|
[ -s "${allfiles}" ] || init_allfiles
|
|
|
|
|
|
|
|
# Old RCS identifiers might have 2-digit years, so we match both
|
|
|
|
# YY/MM/DD and YYYY/MM/DD. We also try to deal with the Y10K
|
|
|
|
# problem by allowing >4 digit years.
|
|
|
|
newest=0
|
|
|
|
case "${allfiles}" in
|
2003-06-18 14:53:52 +04:00
|
|
|
"") ;;
|
2006-01-28 22:01:23 +03:00
|
|
|
*) newest="$(${IDENT} ${allfiles} 2>/dev/null | ${AWK} '
|
2003-06-18 14:53:52 +04:00
|
|
|
BEGIN { last = 0 }
|
|
|
|
$2 == "crt0.c,v" { next }
|
2006-01-04 17:14:35 +03:00
|
|
|
NF == 8 && \
|
|
|
|
$4 ~ /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/ \
|
|
|
|
{ t = "19" $4; gsub("/", "", t);
|
|
|
|
if (t > last) last = t; }
|
|
|
|
NF == 8 && \
|
|
|
|
$4 ~ /^[0-9][0-9][0-9][0-9][0-9]*\/[0-9][0-9]\/[0-9][0-9]$/ \
|
|
|
|
{ t = $4; gsub("/", "", t);
|
|
|
|
if (t > last) last = t; }
|
2006-01-28 22:01:23 +03:00
|
|
|
END { print last }')"
|
2003-06-18 14:53:52 +04:00
|
|
|
method=ident
|
|
|
|
;;
|
|
|
|
esac
|
2006-01-04 17:14:35 +03:00
|
|
|
#echo "${newest}"
|
|
|
|
}
|
2006-01-28 22:01:23 +03:00
|
|
|
get_newest_mtime_date()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
[ -s "${newestfile}" ] || init_newestfile
|
|
|
|
|
|
|
|
# We could simplify the awk program to take advantage of the
|
|
|
|
# fact thet it should have exactly one line of input.
|
2006-01-28 22:01:23 +03:00
|
|
|
newest="$(${ENV_CMD} TZ=UTC LOCALE=C ${LS} -lT "${newestfile}" \
|
2006-01-04 17:14:35 +03:00
|
|
|
| ${AWK} '
|
|
|
|
BEGIN { newest = 0 }
|
|
|
|
{
|
|
|
|
t = $9 "";
|
|
|
|
if ($6 == "Jan") t = t "01";
|
|
|
|
if ($6 == "Feb") t = t "02";
|
|
|
|
if ($6 == "Mar") t = t "03";
|
|
|
|
if ($6 == "Apr") t = t "04";
|
|
|
|
if ($6 == "May") t = t "05";
|
|
|
|
if ($6 == "Jun") t = t "06";
|
|
|
|
if ($6 == "Jul") t = t "07";
|
|
|
|
if ($6 == "Aug") t = t "08";
|
|
|
|
if ($6 == "Sep") t = t "09";
|
|
|
|
if ($6 == "Oct") t = t "10";
|
|
|
|
if ($6 == "Nov") t = t "11";
|
|
|
|
if ($6 == "Dec") t = t "12";
|
|
|
|
if ($7 < 10) t = t "0";
|
|
|
|
t = t $7;
|
|
|
|
#these next two lines add the 24h clock onto the date
|
|
|
|
#gsub(":", "", $8);
|
|
|
|
#t = sprintf("%s.%4.4s", t, $8);
|
|
|
|
if (t > newest) newest = t;
|
|
|
|
}
|
2006-01-28 22:01:23 +03:00
|
|
|
END { print newest }')"
|
2006-01-04 17:14:35 +03:00
|
|
|
#echo "${newest}"
|
|
|
|
}
|
2006-01-28 22:01:23 +03:00
|
|
|
get_newest_date()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
get_newest_rcsid_date
|
|
|
|
case "${newest}" in
|
|
|
|
""|0) get_newest_mtime_date
|
2003-06-18 14:53:52 +04:00
|
|
|
method=ls
|
|
|
|
;;
|
2006-01-04 17:14:35 +03:00
|
|
|
*) method=rcsid
|
|
|
|
;;
|
2003-06-18 14:53:52 +04:00
|
|
|
esac
|
2006-01-04 17:14:35 +03:00
|
|
|
#echo "${newest}"
|
|
|
|
}
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
#
|
|
|
|
# choose_version_number() chooses the syspkg version number,
|
|
|
|
# by concatenating several components (OS version, syspkg "tiny"
|
|
|
|
# version and date). We end up with something like
|
|
|
|
# osvers="3.99.15", tinyvers="0", newest="20060104",
|
|
|
|
# and t="3.99.15.0.20060104".
|
|
|
|
#
|
|
|
|
# The result is stored in the variables ${t} and ${method}.
|
|
|
|
#
|
|
|
|
method=''
|
|
|
|
t=''
|
2006-01-28 22:01:23 +03:00
|
|
|
choose_version_number()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
2006-01-28 22:01:23 +03:00
|
|
|
get_osvers; m1="${method}"
|
2006-01-04 17:14:35 +03:00
|
|
|
get_tinyvers # does not set ${method}
|
2006-01-28 22:01:23 +03:00
|
|
|
get_newest_date; m2="${method}"
|
2006-01-04 17:14:35 +03:00
|
|
|
t="${osvers}.${tinyvers}.${newest}"
|
|
|
|
method="${m1}.${m2}"
|
|
|
|
|
|
|
|
# print version number that we're using
|
|
|
|
if ${verbose}; then
|
|
|
|
echo "${pkg} - ${t} version using ${method} method"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2006-01-28 21:42:23 +03:00
|
|
|
#
|
|
|
|
# init_db_opts() sets the dbfile, dbtype and db_opts variables,
|
|
|
|
# used for accessing the pkgdb.byfile.db database.
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
init_db_opts()
|
2006-01-28 21:42:23 +03:00
|
|
|
{
|
|
|
|
dbfile="${SYSPKG_DB_TOPDIR}/pkgdb.byfile.db"
|
|
|
|
dbtype="btree"
|
|
|
|
db_opts=''
|
2006-01-28 22:01:23 +03:00
|
|
|
: ${TARGET_ENDIANNESS:="$(arch_to_endian "${MACHINE_ARCH}")"}
|
2006-01-28 21:42:23 +03:00
|
|
|
case "${TARGET_ENDIANNESS}" in
|
|
|
|
4321) db_opts="${db_opts} -E B" # big-endian
|
|
|
|
;;
|
|
|
|
1234) db_opts="${db_opts} -E L" # little-endian
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "${WARNING}Unknown or unsupported target endianness"
|
|
|
|
echo >&2 "${NOTE}Using host endianness"
|
|
|
|
;;
|
|
|
|
esac
|
2006-01-28 22:01:23 +03:00
|
|
|
if ${update} || ${force}; then
|
2006-01-28 21:42:23 +03:00
|
|
|
# overwriting an existing entry is not an error
|
|
|
|
db_opts="${db_opts} -R"
|
|
|
|
fi
|
|
|
|
if [ ${verbosity} -lt 2 ]; then
|
|
|
|
# don't print all the keys added to the database
|
|
|
|
db_opts="${db_opts} -q"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
#
|
|
|
|
# print_dir_exec_lines outputs an "@exec install" line for each
|
|
|
|
# directory in ${PLIST}
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
print_dir_exec_lines()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
local dir uname gname mode
|
|
|
|
local dot_slash_dir
|
|
|
|
local no_dot_dir
|
|
|
|
local word line
|
|
|
|
${AWK} '/^@dirrm/ { print $2 }' <"${PLIST}" | \
|
|
|
|
${SORT} | \
|
2006-01-28 22:01:23 +03:00
|
|
|
while read dir; do
|
2006-01-04 17:14:35 +03:00
|
|
|
# Sanitise the name. ${dir} could be an absolute or
|
|
|
|
# relative name, with or without a leading "./".
|
|
|
|
# ${dot_slash_dir} always has a leading "./" (except when
|
|
|
|
# it's exactly equal to "."). ${no_dot_dir} never has a
|
|
|
|
# leading "." or "/" (except when it's exactly equal to
|
|
|
|
# ".").
|
|
|
|
case "${dir}" in
|
|
|
|
.|./|/) dot_slash_dir=. ;;
|
|
|
|
./*) dot_slash_dir="${dir}" ;;
|
|
|
|
/*) dot_slash_dir=".${dir}" ;;
|
|
|
|
*) dot_slash_dir="./${dir}" ;;
|
|
|
|
esac
|
|
|
|
no_dot_dir="${dot_slash_dir#./}"
|
|
|
|
# Get the directory's owner, group, and mode
|
|
|
|
# from the live file system, or let it be overridden
|
|
|
|
# by the metalog.
|
2006-01-28 22:01:23 +03:00
|
|
|
eval "$(${STAT} -f 'uname=%Su gname=%Sg mode=%#OLp' \
|
|
|
|
"${DESTDIR}/${dot_slash_dir}")"
|
2006-01-04 17:14:35 +03:00
|
|
|
if [ -n "${metalog}" ]; then
|
2006-01-28 22:01:23 +03:00
|
|
|
line="$(echo "${dot_slash_dir}" | \
|
2006-01-04 17:14:35 +03:00
|
|
|
${AWK} -f "${rundir}/join.awk" \
|
2006-01-28 22:01:23 +03:00
|
|
|
/dev/stdin "${metalog}")"
|
|
|
|
for word in ${line}; do
|
2006-01-04 17:14:35 +03:00
|
|
|
case "${word}" in
|
|
|
|
uname=*|gname=*|mode=*) eval "${word}" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
# XXX: Work around yet another pkg_add bug: @cwd lines
|
|
|
|
# do not actually cause the working directory to change,
|
|
|
|
# so file names in @exec lines need to be qualified by
|
|
|
|
# %D, which (in our case, since we know there's an
|
|
|
|
# "@cwd /" line) will be the dir name passed to
|
|
|
|
# "pkg_add -p PREFIX".
|
|
|
|
case "${no_dot_dir}" in
|
|
|
|
.) d="%D" ;;
|
|
|
|
*) d="%D/${no_dot_dir}" ;;
|
|
|
|
esac
|
|
|
|
cat <<EOF
|
|
|
|
@exec install -d -o ${uname} -g ${gname} -m ${mode} ${d}
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# register_syspkg() registers the syspkg in ${SYSPKG_DB_TOPDIR}.
|
|
|
|
# This involves creating the subdirectory ${SYSPKG_DB_SUBDIR}
|
|
|
|
# and populating it with several files.
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
register_syspkg()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
cleanup_must_delete_dbsubdir=true
|
|
|
|
[ -n "${SYSPKG_DB_SUBDIR}" ] || bomb
|
|
|
|
mkdir -p "${SYSPKG_DB_SUBDIR}"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Guess what versions of other packages to depend on.
|
|
|
|
#
|
|
|
|
# If we are using the OS version as part of the pkg
|
|
|
|
# version, then depend on any version ">=${osvers}". For
|
|
|
|
# example, etc-sys-etc-1.6ZI.0.20040206 might depend on
|
|
|
|
# base-sys-root>=1.6ZI.
|
|
|
|
#
|
|
|
|
# Failing that, depend on any version "-[0-9]*".
|
|
|
|
#
|
|
|
|
# XXX: We could extend the format of the "deps" file to carry
|
|
|
|
# this sort of information, so we wouldn't have to guess.
|
|
|
|
#
|
|
|
|
case "${t}" in
|
|
|
|
${osvers}.*) depversion=">=${osvers}" ;;
|
|
|
|
*) depversion="-[0-9]*" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add the dependencies.
|
|
|
|
#
|
|
|
|
# We always add a "@pkgdep" line for each prerequisite package.
|
|
|
|
#
|
|
|
|
# If the prerequisite pkg is already registered (as it should be
|
|
|
|
# if our caller is doing things in the right order), then we put
|
|
|
|
# its exact version number in a "@blddep" line.
|
|
|
|
#
|
|
|
|
${AWK} '$1 ~ '/"${pkg}"/' { print $2 }' "${rundir}/deps" | ${SORT} | \
|
2006-01-28 22:01:23 +03:00
|
|
|
while read depname; do
|
2006-01-04 17:14:35 +03:00
|
|
|
# ${pkgdepglob} is a shell glob pattern that should match
|
|
|
|
# any version of a pkg. ${pkgdep} uses the special syntax
|
|
|
|
# for pkg dependencies, and is not usable as a shell
|
|
|
|
# glob pattern.
|
|
|
|
pkgdepglob="${depname}-[0-9]*"
|
|
|
|
pkgdep="${depname}${depversion}"
|
|
|
|
echo "@pkgdep ${pkgdep}"
|
2006-01-28 22:01:23 +03:00
|
|
|
blddep="$(cd "${SYSPKG_DB_TOPDIR}" && echo ${pkgdepglob} \
|
|
|
|
|| bomb)"
|
2006-01-04 17:14:35 +03:00
|
|
|
case "${blddep}" in
|
|
|
|
*\*) # pkgdepglob did not match anything
|
|
|
|
echo >&2 "${WARNING}${pkg} depends on '${pkgdep}' but there is no matching syspkg in ${SYSPKG_DB_TOPDIR}"
|
|
|
|
;;
|
|
|
|
*\ *) # pkgdepglob matched more than once.
|
|
|
|
echo >&2 "${ERRWARN}${pkg} depends on '${pkgdep}' but there are multiple matching syspkgs in ${SYSPKG_DB_TOPDIR}"
|
|
|
|
${force} || bomb
|
|
|
|
# If ${force} is set, then assume that the last
|
|
|
|
# match is the most recent.
|
|
|
|
# XXX: This might be wrong, because of
|
|
|
|
# differences between lexical sorting and
|
|
|
|
# numeric sorting.
|
|
|
|
lastmatch="${blddep##* }"
|
|
|
|
echo "@blddep ${lastmatch}"
|
|
|
|
;;
|
|
|
|
*) # exactly one match.
|
|
|
|
# XXX: We ignore the possibility that the
|
|
|
|
# version we found via ${pkgdepglob} might not
|
|
|
|
# satisfy ${pkgdep}. We could conceivably use
|
|
|
|
# "pkg_admin pmatch" to check, but that's not a
|
|
|
|
# host tool so we can't assume that it will be
|
|
|
|
# available.
|
|
|
|
echo "@blddep ${blddep}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done >>"${PLIST}"
|
|
|
|
|
|
|
|
# create the comment (should be one line)
|
2006-01-28 22:01:23 +03:00
|
|
|
comment="$(${AWK} '$1 ~ '/"${pkg}"/' \
|
2006-01-04 17:14:35 +03:00
|
|
|
{ print substr($0, length($1) + 2) }' \
|
2006-01-28 22:01:23 +03:00
|
|
|
"${rundir}/comments")"
|
2006-01-04 17:14:35 +03:00
|
|
|
case "${comment}" in
|
|
|
|
"") echo >&2 "${WARNING}no comment for \"${pkg}\" (using placeholder)"
|
|
|
|
comment="System package for ${pkg}"
|
|
|
|
;;
|
|
|
|
*"${nl}"*)
|
|
|
|
echo >&2 "${ERRWARN}multi-line comment for \"${pkg}\""
|
|
|
|
${force} || bomb
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo "${comment}" > "${SYSPKG_DB_SUBDIR}/+COMMENT"
|
|
|
|
|
|
|
|
# create the description (could be multiple lines)
|
2006-01-28 22:01:23 +03:00
|
|
|
descr="$(${AWK} '$1 ~ '/"${pkg}"/' {
|
2006-01-04 17:14:35 +03:00
|
|
|
print substr($0, length($1) + 2) }' \
|
2006-01-28 22:01:23 +03:00
|
|
|
"${rundir}/descrs")"
|
2006-01-04 17:14:35 +03:00
|
|
|
case "${descr}" in
|
|
|
|
"") echo >&2 "${WARNING}no description for \"${pkg}\" (re-using comment)" 2>&1
|
|
|
|
descr="${comment}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo "${descr}" > "${SYSPKG_DB_SUBDIR}/+DESC"
|
|
|
|
${PRINTF} "\nHomepage:\nhttp://www.NetBSD.org/\n" >> "${SYSPKG_DB_SUBDIR}/+DESC"
|
|
|
|
|
|
|
|
# create the build information
|
|
|
|
if [ x"${BUILD_INFO_CACHE}" = x ]; then
|
|
|
|
{
|
|
|
|
# These variables describe the build
|
|
|
|
# environment, not the target.
|
|
|
|
echo "OPSYS=$(${UNAME} -s)"
|
|
|
|
echo "OS_VERSION=$(${UNAME} -r)"
|
2007-02-05 21:26:01 +03:00
|
|
|
${MAKE} -B -f- all <<EOF
|
2003-06-23 13:25:34 +04:00
|
|
|
.include <bsd.own.mk>
|
|
|
|
all:
|
|
|
|
@echo OBJECT_FMT=${OBJECT_FMT}
|
|
|
|
@echo MACHINE_ARCH=${MACHINE_ARCH}
|
|
|
|
@echo MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH}
|
|
|
|
EOF
|
2006-01-04 17:14:35 +03:00
|
|
|
} > "${SYSPKG_DB_SUBDIR}/+BUILD_INFO"
|
|
|
|
else
|
|
|
|
cp "${BUILD_INFO_CACHE}" "${SYSPKG_DB_SUBDIR}/+BUILD_INFO"
|
|
|
|
fi
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
# test for attributes
|
|
|
|
args=""
|
2006-01-28 22:01:23 +03:00
|
|
|
attrs="$(${AWK} '$1 ~ '/"${pkg}"/' { \
|
2006-01-04 17:14:35 +03:00
|
|
|
print substr($0, length($1) + 2) }' \
|
2006-01-28 22:01:23 +03:00
|
|
|
"${rundir}/attrs")"
|
2006-01-04 17:14:35 +03:00
|
|
|
for a in "${attrs}"; do
|
|
|
|
case "${attrs}" in
|
|
|
|
"") ;;
|
|
|
|
preserve)
|
|
|
|
echo "${pkg}-${t}" >"${SYSPKG_DB_SUBDIR}/+PRESERVE"
|
|
|
|
args="${args} -n ${SYSPKG_DB_SUBDIR}/+PRESERVE"
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
;;
|
2006-01-04 17:14:35 +03:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# Create ${SYSPKGSIR}/+CONTENTS from ${PLIST}, by adding an
|
|
|
|
# "@name" line and a lot of "@comment MD5:" lines.
|
|
|
|
#
|
|
|
|
{
|
2014-05-30 12:37:35 +04:00
|
|
|
rcsid='$NetBSD: regpkg,v 1.22 2014/05/30 08:37:35 uebayasi Exp $'
|
2006-01-28 22:01:23 +03:00
|
|
|
utcdate="$(${ENV_CMD} TZ=UTC LOCALE=C \
|
|
|
|
${DATE} '+%Y-%m-%d %H:%M')"
|
2006-01-04 17:14:35 +03:00
|
|
|
user="${USER:-root}"
|
2009-12-02 18:52:14 +03:00
|
|
|
host="$(${HOSTNAME_CMD})"
|
2006-01-04 17:14:35 +03:00
|
|
|
echo "@name ${pkg}-${t}"
|
|
|
|
echo "@comment Packaged at ${utcdate} UTC by ${user}@${host}"
|
|
|
|
echo "@comment Packaged using ${prog} ${rcsid}"
|
|
|
|
# XXX: "option extract-in-place" might help to get
|
|
|
|
# pkg_add to create directories.
|
|
|
|
# XXX: no, it doesn't work. Yet another pkg_add bug.
|
|
|
|
## echo "@option extract-in-place"
|
|
|
|
# Move the @pkgdep and @blddep lines up, so that
|
|
|
|
# they are easy to see when people do "less
|
|
|
|
# ${DESTDIR}/var/db/syspkg/*/+CONTENTS".
|
|
|
|
${EGREP} '^(@pkgdep|@blddep)' "${PLIST}" || true
|
|
|
|
# Now do the remainder of the file.
|
2006-01-28 22:01:23 +03:00
|
|
|
while read line; do
|
2006-01-04 17:14:35 +03:00
|
|
|
case "${line}" in
|
|
|
|
@pkgdep*|@blddep*)
|
|
|
|
# already handled by grep above
|
|
|
|
;;
|
|
|
|
@cwd*)
|
|
|
|
# There should be exactly one @cwd line.
|
|
|
|
# Just after it, add an "@exec mkdir"
|
|
|
|
# line for every directory. This is to
|
|
|
|
# work around a pkg-add bug (see
|
|
|
|
# <http://mail-index.NetBSD.org/tech-pkg/2003/12/11/0018.html>)
|
|
|
|
echo "${line}"
|
|
|
|
print_dir_exec_lines
|
|
|
|
;;
|
|
|
|
@*)
|
|
|
|
# just pass through all other @foo lines
|
|
|
|
echo "${line}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# This should be a file name. Pass it
|
|
|
|
# through, and append "@comment MD5:".
|
|
|
|
# XXX why not SHA256 ?
|
|
|
|
echo "${line}"
|
|
|
|
file="${DESTDIR}${line}"
|
|
|
|
if [ -f "${file}" -a -r "${file}" ];
|
|
|
|
then
|
2006-01-28 22:01:23 +03:00
|
|
|
md5sum="$(${CKSUM} -n -m "${file}" \
|
2006-01-04 17:14:35 +03:00
|
|
|
| ${AWK} '{print $1}'
|
|
|
|
)"
|
|
|
|
echo "@comment MD5:${md5sum}"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done <"${PLIST}"
|
|
|
|
} >"${SYSPKG_DB_SUBDIR}/+CONTENTS"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Update ${SYSPKG_DB_TOPDIR}/pkgdb.byfile.db.
|
|
|
|
#
|
|
|
|
{
|
2006-01-28 21:42:23 +03:00
|
|
|
init_db_opts # sets dbfile, dbtype, and db_opts
|
2006-01-04 17:14:35 +03:00
|
|
|
|
|
|
|
# Transform ${PLIST} into a form to be used as keys in
|
|
|
|
# ${dbfile}. The results look like absolute paths,
|
|
|
|
# but they are really relative to ${DESTDIR}.
|
|
|
|
#
|
|
|
|
# "@dirrm ." -> "/"
|
|
|
|
# "@dirrm foo/bar" -> "/foo/bar"
|
|
|
|
# "@dirrm ./foo/bar" -> "/foo/bar"
|
|
|
|
# "foo/bar/baz" -> "/foo/bar/baz"
|
|
|
|
# "./foo/bar/baz" -> "/foo/bar/baz"
|
|
|
|
#
|
|
|
|
dblist="${SCRATCH}/dblist"
|
|
|
|
${AWK} '/^@dirrm \.\// {gsub("^.", "", $2); print $2; next}
|
|
|
|
/^@dirrm \.$/ {print "/"; next}
|
|
|
|
/^@dirrm/ {print "/" $2; next}
|
|
|
|
/^@/ {next}
|
|
|
|
/^\.\// {gsub("^.", "", $0); print $0; next}
|
|
|
|
/./ {print "/" $0; next}' \
|
|
|
|
<"${PLIST}" >"${dblist}"
|
|
|
|
# Add all the path names to the database.
|
|
|
|
${AWK} '{print $1 "\t" "'"${pkg}-${t}"'"}' <"${dblist}" \
|
|
|
|
| ${DB} -w ${db_opts} -F "${tab}" -f - "${dbtype}" "${dbfile}"
|
|
|
|
}
|
|
|
|
|
2006-01-28 22:01:23 +03:00
|
|
|
if ${verbose}; then
|
2006-01-04 17:14:35 +03:00
|
|
|
echo "Registered ${pkg}-${t} in ${SYSPKG_DB_TOPDIR}"
|
2006-01-28 22:01:23 +03:00
|
|
|
elif ! ${quiet}; then
|
2006-01-04 17:14:35 +03:00
|
|
|
echo "Registered ${pkg}-${t}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cleanup_must_delete_dbsubdir=false
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# create_syspkg_tgz() creates the *.tgz file for the package.
|
|
|
|
#
|
|
|
|
# The output file is ${binpkgdir}/${pkg}-${t}.tgz.
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
create_syspkg_tgz()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
#
|
|
|
|
# pkg_create does not understand metalog files, so we have to
|
|
|
|
# use pax directly.
|
|
|
|
#
|
|
|
|
# We create two specfiles: specfile_overhead describes the
|
|
|
|
# special files that are part of the package system's metadata
|
|
|
|
# (+CONTENTS, +COMMENT, +DESCR, and more); and specfile_payload
|
|
|
|
# describes the files and directories that we actually want as
|
|
|
|
# part of the package's payload.
|
|
|
|
#
|
|
|
|
# We then use the specfiles to create a compressed tarball that
|
|
|
|
# contains both the overhead files and the payload files.
|
|
|
|
#
|
|
|
|
# There's no trivial way to get a single pax run to do
|
|
|
|
# everything we want, so we run pax twice, with a different
|
|
|
|
# working directory and a different specfile each time.
|
|
|
|
#
|
|
|
|
# We could conceivably make clever use of pax's "-s" option to
|
|
|
|
# get what we want from a single pax run with a single (more
|
|
|
|
# complicated) specfile, but the extra trouble doesn't seem
|
|
|
|
# warranted.
|
|
|
|
#
|
|
|
|
cleanup_must_delete_binpkgfile=true
|
|
|
|
specfile_overhead="${SCRATCH}/spec_overhead"
|
|
|
|
specfile_payload="${SCRATCH}/spec_payload"
|
|
|
|
tarball_uncompressed="${SCRATCH}/tarball_uncompressed"
|
|
|
|
|
|
|
|
# Create a specfile for all the overhead files (+CONTENTS and
|
|
|
|
# friends).
|
|
|
|
{
|
|
|
|
plusnames_first="${SCRATCH}/plusnames_first"
|
|
|
|
plusnames_rest="${SCRATCH}/plusnames_rest"
|
|
|
|
|
|
|
|
# Ensure that the first few files are in the same order
|
|
|
|
# that "pkg_create" would have used, just in case anything
|
|
|
|
# depends on that. Other files in alphabetical order.
|
|
|
|
SHOULD_BE_FIRST="+CONTENTS +COMMENT +DESC"
|
|
|
|
(
|
|
|
|
cd "${SYSPKG_DB_SUBDIR}" || bomb
|
|
|
|
for file in ${SHOULD_BE_FIRST}; do
|
|
|
|
[ -e "./${file}" ] && echo "${file}"
|
|
|
|
done >"${plusnames_first}"
|
|
|
|
${LS} -1 | ${FGREP} -v -f "${plusnames_first}" \
|
|
|
|
>"${plusnames_rest}" \
|
|
|
|
|| true
|
|
|
|
)
|
|
|
|
|
|
|
|
# Convert the file list to specfile format, and override the
|
|
|
|
# uid/gid/mode.
|
|
|
|
{
|
|
|
|
echo ". optional type=dir"
|
|
|
|
${AWK} '{print "./" $0 " type=file uid=0 gid=0 mode=0444"
|
|
|
|
}' "${plusnames_first}" "${plusnames_rest}"
|
|
|
|
} >"${specfile_overhead}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create a specfile for the payload of the package.
|
|
|
|
{
|
|
|
|
spec1="${SCRATCH}/spec1"
|
|
|
|
spec2="${SCRATCH}/spec2"
|
|
|
|
|
|
|
|
# Transform ${PLIST} into simple specfile format:
|
|
|
|
#
|
2006-01-08 13:24:04 +03:00
|
|
|
# "@dirrm ." -> ". type=dir"
|
|
|
|
# "@dirrm foo/bar" -> "./foo/bar type=dir"
|
|
|
|
# "@dirrm ./foo/bar" -> "./foo/bar type=dir"
|
2006-01-04 17:14:35 +03:00
|
|
|
# "foo/bar/baz" -> "./foo/bar/baz"
|
|
|
|
# "./foo/bar/baz" -> "./foo/bar/baz"
|
|
|
|
#
|
|
|
|
# Ignores @cwd lines. This should be safe, given how
|
|
|
|
# makeplist works.
|
2006-01-28 22:01:23 +03:00
|
|
|
${AWK} '/^@dirrm \.\// {print $2 " type=dir"; next}
|
2006-01-08 13:24:04 +03:00
|
|
|
/^@dirrm \.$/ {print ". type=dir"; next}
|
2006-01-28 22:01:23 +03:00
|
|
|
/^@dirrm/ {print "./" $2 " type=dir"; next}
|
2006-01-04 17:14:35 +03:00
|
|
|
/^@/ {next}
|
|
|
|
/^\.\// {print $0; next}
|
|
|
|
/./ {print "./" $0; next}' \
|
2014-05-24 17:27:13 +04:00
|
|
|
<"${PLIST}" |
|
|
|
|
# Escape some characters to match the new mtree(8) format.
|
|
|
|
# C.f. usr.sbin/mtree/spec.c:vispath()
|
|
|
|
# XXX escape only '[' for now
|
2014-05-30 12:37:35 +04:00
|
|
|
${SED} -e 's,\[,\\133,g' \
|
2014-05-24 17:27:13 +04:00
|
|
|
>"${spec1}"
|
2006-01-04 17:14:35 +03:00
|
|
|
|
|
|
|
# If metalog was specified, attributes from metalog override
|
|
|
|
# attributes in the file system. We also fake up an
|
|
|
|
# entry for the ./etc/mtree/set.${pkgset} file.
|
|
|
|
{
|
|
|
|
if [ -n "${metalog}" ]; then
|
|
|
|
${AWK} -f "${rundir}/join.awk" \
|
|
|
|
"${spec1}" "${metalog}"
|
|
|
|
${AWK} -f "${rundir}/join.awk" \
|
|
|
|
"${spec1}" /dev/stdin <<EOF
|
|
|
|
./etc/mtree/set.${pkgset} type=file mode=0444 uname=root gname=wheel
|
|
|
|
EOF
|
|
|
|
else
|
|
|
|
cat "${spec1}"
|
|
|
|
fi
|
|
|
|
} >"${spec2}"
|
|
|
|
|
|
|
|
#
|
|
|
|
# If a file or directory to was mentioned explicitly
|
|
|
|
# in ${PLIST} but not mentioned in ${metalog}, then the
|
|
|
|
# file or directory will not be mentioned in ${spec2}.
|
|
|
|
# This is an error, and means that the metalog was
|
|
|
|
# not built correctly.
|
|
|
|
#
|
|
|
|
if [ -n "${metalog}" ]; then
|
|
|
|
names1="${SCRATCH}/names1"
|
|
|
|
names2="${SCRATCH}/names2"
|
|
|
|
${AWK} '{print $1}' <"${spec1}" | ${SORT} >"${names1}"
|
|
|
|
${AWK} '{print $1}' <"${spec2}" | ${SORT} >"${names2}"
|
|
|
|
if ${FGREP} -v -f "${names2}" "${spec1}" >/dev/null
|
|
|
|
then
|
|
|
|
cat >&2 <<EOM
|
|
|
|
${ERRWARN}The metalog file (${metalog}) does not
|
|
|
|
contain entries for the following files or directories
|
|
|
|
which should be part of the ${pkg} syspkg:
|
|
|
|
EOM
|
|
|
|
${FGREP} -v -f "${names2}" "${spec1}" >&2
|
|
|
|
${force} || bomb
|
|
|
|
fi
|
|
|
|
if ${FGREP} -v -f "${names1}" "${spec2}" >/dev/null
|
|
|
|
then
|
|
|
|
cat >&2 <<EOM
|
|
|
|
${ERRWARN}The following lines are in the metalog file
|
|
|
|
(${metalog}), and the corresponding files or directories
|
|
|
|
should be in the ${pkg} syspkg, but something is wrong:
|
|
|
|
EOM
|
|
|
|
${FGREP} -v -f "${names1}" "${spec2}" >&2
|
|
|
|
bomb
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add lines (tagged "optional") for any implicit directories.
|
|
|
|
#
|
|
|
|
# For example, if we have a file ./foo/bar/baz, then we add
|
|
|
|
# "./foo/bar optional type=dir", "./foo optional type=dir",
|
|
|
|
# and ". optional type=dir", unless those directories were
|
|
|
|
# already mentioned explicitly.
|
|
|
|
#
|
|
|
|
${AWK} -f "${rundir}/getdirs.awk" "${spec2}" \
|
|
|
|
| ${SORT} -u >"${specfile_payload}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Use two pax invocations followed by gzip to create
|
|
|
|
# the tgz file.
|
|
|
|
#
|
|
|
|
# Remove any leading "./" from path names, because that
|
|
|
|
# could confuse tools that work with binary packages.
|
|
|
|
(
|
|
|
|
cd "${SYSPKG_DB_SUBDIR}" && \
|
|
|
|
${PAX} -O -w -d -N"${etcdir}" -M '-s,^\./,,' \
|
|
|
|
-f "${tarball_uncompressed}" \
|
|
|
|
<"${specfile_overhead}" \
|
|
|
|
|| bomb
|
|
|
|
)
|
|
|
|
(
|
|
|
|
cd "${DESTDIR:-/}" && \
|
|
|
|
${PAX} -O -w -d -N"${etcdir}" -M '-s,^\./,,' \
|
|
|
|
-a -f "${tarball_uncompressed}" \
|
|
|
|
<"${specfile_payload}" \
|
|
|
|
|| bomb
|
|
|
|
)
|
2009-04-04 02:36:34 +04:00
|
|
|
${GZIP_CMD} -9n <"${tarball_uncompressed}" >"${binpkgfile}" || bomb
|
2006-01-04 17:14:35 +03:00
|
|
|
|
|
|
|
# (Extra space is to make message line up with "Registered" message.)
|
2006-01-28 22:01:23 +03:00
|
|
|
if ${verbose}; then
|
2006-01-04 17:14:35 +03:00
|
|
|
echo " Packaged ${binpkgfile}"
|
2006-01-28 22:01:23 +03:00
|
|
|
elif ! ${quiet}; then
|
2006-01-04 17:14:35 +03:00
|
|
|
echo " Packaged ${binpkgfile##*/}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cleanup_must_delete_binpkgfile=false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# do_register_syspkg() registers the syspkg if appropriate.
|
|
|
|
#
|
|
|
|
# If SYSPKG_DB_SUBDIR already exists, that might be an error, depending
|
|
|
|
# on ${force} and ${update} flags.
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
do_register_syspkg()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
# Check that necessary variables are defined
|
|
|
|
[ -n "${SYSPKG_DB_TOPDIR}" ] || bomb
|
|
|
|
[ -n "${SYSPKG_DB_SUBDIR}" ] || bomb
|
|
|
|
|
|
|
|
# Create SYSPKG_DB_TOPDIR if necessary
|
|
|
|
[ -d "${SYSPKG_DB_TOPDIR}" ] || mkdir -p "${SYSPKG_DB_TOPDIR}" || bomb
|
|
|
|
|
2006-01-28 21:42:23 +03:00
|
|
|
# A function to delete db entries referring to any version of ${pkg}
|
2006-01-28 22:01:23 +03:00
|
|
|
delete_old_db_entries()
|
2006-01-28 21:42:23 +03:00
|
|
|
{
|
|
|
|
init_db_opts # sets dbfile, dbtype, and db_opts
|
|
|
|
dblist="${SCRATCH}/dblist"
|
|
|
|
${DB} ${db_opts} -O "${tab}" "${dbtype}" "${dbfile}" \
|
|
|
|
| ${AWK} -F "${tab}" '$2 ~ /^'"${pkg}"'-[0-9]/ { print $1 }' \
|
|
|
|
>"${dblist}"
|
|
|
|
${DB} -d ${db_opts} -f "${dblist}" "${dbtype}" "${dbfile}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# A function to delete any old version of ${pkg}
|
2006-01-28 22:01:23 +03:00
|
|
|
delete_old_pkg()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
2006-01-28 21:42:23 +03:00
|
|
|
pattern="${pkg}-[0-9]*"
|
2006-01-28 22:01:23 +03:00
|
|
|
matches="$(cd "${SYSPKG_DB_TOPDIR}" && echo ${pattern} \
|
|
|
|
|| bomb)"
|
2006-01-28 21:42:23 +03:00
|
|
|
echo >&2 "${NOTE}deleting old pkg (${matches})"
|
2006-01-04 17:14:35 +03:00
|
|
|
cleanup_must_delete_dbsubdir=true
|
2006-01-28 21:42:23 +03:00
|
|
|
delete_old_db_entries
|
|
|
|
( cd "${SYSPKG_DB_TOPDIR}" && rm -rf ${matches} )
|
2006-01-04 17:14:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Check whether another version of ${pkg} is already registered.
|
|
|
|
pattern="${pkg}-[0-9]*"
|
2006-01-28 22:01:23 +03:00
|
|
|
matches="$(cd "${SYSPKG_DB_TOPDIR}" && echo ${pattern} || bomb)"
|
2006-01-04 17:14:35 +03:00
|
|
|
case "${matches}" in
|
|
|
|
*\*) ;; # wildcard did not match anything
|
|
|
|
"${pkg}-${t}") ;; # exact match
|
2006-01-28 21:42:23 +03:00
|
|
|
*) echo >&2 "${ERRWARNNOTE}another version of ${pkg} is already registered"
|
|
|
|
${verbose} && echo >&2 " in ${SYSPKG_DB_TOPDIR}"
|
|
|
|
${verbose} && echo >&2 " (while registering ${pkg}-${t})"
|
|
|
|
${force} || ${update} || bomb
|
|
|
|
delete_old_pkg
|
2006-01-04 17:14:35 +03:00
|
|
|
;;
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
esac
|
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
# Check whether the desired version of ${pkg} is already registered,
|
|
|
|
# and create it if appropriate.
|
|
|
|
if [ -d "${SYSPKG_DB_SUBDIR}" ]; then
|
|
|
|
echo >&2 "${ERRWARNNOTE}${pkg}-${t} is already registered"
|
|
|
|
${verbose} && echo >&2 " in ${SYSPKG_DB_TOPDIR}"
|
|
|
|
if ${force}; then
|
2006-01-28 21:42:23 +03:00
|
|
|
delete_old_pkg
|
|
|
|
register_syspkg
|
2006-01-04 17:14:35 +03:00
|
|
|
elif ${update}; then
|
|
|
|
#
|
|
|
|
# If all files in SYSPKG_DB_SUBDIR are newer
|
|
|
|
# than all files in the pkg, then do nothing.
|
|
|
|
# Else delete and re-register the pkg.
|
|
|
|
#
|
|
|
|
[ -n "${newestfile}" ] || init_newestfile
|
|
|
|
if [ -n "${newestfile}" ]; then
|
2006-01-28 22:01:23 +03:00
|
|
|
case "$(${FIND} "${SYSPKG_DB_SUBDIR}" -type f \
|
|
|
|
! -newer "${newestfile}" -print)" \
|
2006-01-04 17:14:35 +03:00
|
|
|
in
|
|
|
|
"") ;;
|
2006-01-28 21:42:23 +03:00
|
|
|
*)
|
|
|
|
echo >&2 "${NOTE}some files are newer but pkg version is unchanged"
|
|
|
|
delete_old_pkg
|
|
|
|
register_syspkg
|
|
|
|
;;
|
2006-01-04 17:14:35 +03:00
|
|
|
esac
|
|
|
|
|
|
|
|
else
|
|
|
|
# No files in the pkg? (This could happen
|
|
|
|
# if a pkg contains only directories.)
|
2006-01-28 21:42:23 +03:00
|
|
|
# Do nothing (keep the already-registered pkg).
|
2009-12-02 18:52:14 +03:00
|
|
|
:
|
2006-01-04 17:14:35 +03:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
bomb
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
register_syspkg
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2012-11-03 11:59:45 +04:00
|
|
|
# do_create_syspkg_tgz() creates the binary pkg (*.tgz) if
|
2006-01-04 17:14:35 +03:00
|
|
|
# appropriate.
|
|
|
|
#
|
|
|
|
# If binpkgfile already exists, that might be an error, depending on
|
|
|
|
# ${force} and ${update} flags.
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
do_create_syspkg_tgz()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
[ -n "${binpkgfile}" ] || bomb
|
|
|
|
|
2006-01-28 22:01:23 +03:00
|
|
|
delete_and_recreate()
|
2006-01-04 17:14:35 +03:00
|
|
|
{
|
|
|
|
echo >&2 "${ERRWARNNOTE}deleting and re-creating ${pkg}-${t}.tgz"
|
|
|
|
rm -f "${binpkgfile}"
|
|
|
|
create_syspkg_tgz
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check whether another version of ${pkg} already exists.
|
|
|
|
pattern="${pkg}-[0-9]*"
|
2006-01-28 22:01:23 +03:00
|
|
|
matches="$(cd "${binpkgdir}" && echo ${pattern} || bomb)"
|
2006-01-04 17:14:35 +03:00
|
|
|
case "${matches}" in
|
|
|
|
*\*) ;; # wildcard did not match anything
|
|
|
|
"${pkg}-${t}.tgz") ;; # exact match
|
2006-01-28 21:42:23 +03:00
|
|
|
*) echo >&2 "${ERRWARNNOTE}another version of ${pkg} binary pkg already exists"
|
|
|
|
${verbose} && echo >&2 " in ${binpkgdir}"
|
|
|
|
${verbose} && echo >&2 " (while creating ${pkg}-${t}.tgz)"
|
|
|
|
# If neither force nor update, this is a fatal error.
|
|
|
|
# If force but not update, then leave old .tgz in place.
|
|
|
|
# If update, then delete the old .tgz.
|
|
|
|
${force} || ${update} || bomb
|
|
|
|
if ${update}; then
|
|
|
|
echo >&2 "${NOTE}deleting old binary pkg (${matches})"
|
|
|
|
( cd "${binpkgdir}" && rm -f ${matches} || bomb )
|
|
|
|
fi
|
2006-01-04 17:14:35 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Check whether the desired version of ${pkg} already exists,
|
|
|
|
# and create it if appropriate.
|
|
|
|
if [ -e "${binpkgfile}" ]; then
|
|
|
|
echo >&2 "${ERRWARNNOTE}${pkg}-${t}.tgz already exists"
|
|
|
|
${verbose} && echo >&2 " in ${binpkgdir}"
|
|
|
|
if ${force}; then
|
|
|
|
delete_and_recreate
|
|
|
|
elif ${update}; then
|
|
|
|
#
|
|
|
|
# If all files in SYSPKG_DB_SUBDIR are older
|
|
|
|
# than ${binpkgfile}, then do nothing.
|
|
|
|
# Else delete and re-create the tgz.
|
|
|
|
#
|
2006-01-28 22:01:23 +03:00
|
|
|
case "$(${FIND} "${SYSPKG_DB_SUBDIR}" -type f \
|
|
|
|
-newer "${binpkgfile}" -print)" \
|
2006-01-04 17:14:35 +03:00
|
|
|
in
|
|
|
|
"") ;;
|
|
|
|
*) delete_and_recreate ;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
bomb
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
create_syspkg_tgz
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
####################
|
|
|
|
# begin main program
|
|
|
|
|
|
|
|
parse_args ${1+"$@"}
|
|
|
|
make_PLIST
|
|
|
|
choose_version_number
|
|
|
|
SYSPKG_DB_SUBDIR="${SYSPKG_DB_TOPDIR}/${pkg}-${t}"
|
|
|
|
do_register_syspkg
|
|
|
|
if [ -n "${binpkgdir}" ]; then
|
|
|
|
binpkgfile="${binpkgdir}/${pkg}-${t}.tgz"
|
|
|
|
do_create_syspkg_tgz
|
|
|
|
fi
|
Add the comments file, which is a single file containing all the COMMENT
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Add the descrs file, which is a single file containing all the DESCR
file entries from the syspkg hierarchy, brought up to date to include some
that had been missed out.
Thanks to Jim Wise for all the work that went into the syspkg sets.
Add the attrs file, which is a single file to which can be added
attributes (like preserve).
Add a regpkg script, which allows a single system package to be
registered, based simply on its setname and syspkg name. All the
information is gleaned from the lists files by means of scripts, no
source tree is needed. The version number for the system package is
calculated automatically, based on the most recent mtime of the files
that constitute a system package.
Add a regpkgset script, to register all the system packages in a set.
The set names recognised are "all", "base", "comp", "etc", "games",
"man", "misc", "text".
2003-06-13 00:04:00 +04:00
|
|
|
|
2006-01-04 17:14:35 +03:00
|
|
|
exit 0
|