1802ef39d2
+ use "uname -r" if osrelease.sh isn't available + if SYSPKG_DATES is set in the environment, use the date for the version. For some reason, this is controversial, so the default is to use NetBSD kernel versions. Re-instate the code to calculate the date, but only use it if the date cannot be gleaned from the RCS Ids of the constituent parts. + re-work the versions file, since it was committed in an incomplete state - there were version numbers without package names in there. Instead, get the version number by exception - i.e. assume it's "0" unless specified in the versions file. This means less independent maintenance when a kernel version number is bumped, and less duplication of work (since any new system packages will now have the correct version number by default) + lose the section which duplicated the calculation of "tiny version" which was never used (and which didn't work correctly)
195 lines
5.6 KiB
Bash
Executable File
195 lines
5.6 KiB
Bash
Executable File
#! /bin/sh
|
|
#
|
|
# $NetBSD: regpkg,v 1.3 2003/06/18 10:53:52 agc Exp $
|
|
#
|
|
# Copyright (c) 2003 Alistair G. Crooks. All rights reserved.
|
|
#
|
|
# 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.
|
|
# 3. All advertising materials mentioning features or use of this software
|
|
# must display the following acknowledgement:
|
|
# This product includes software developed by Alistair G. Crooks.
|
|
# for the NetBSD project.
|
|
# 4. The name of the author may not be used to endorse or promote
|
|
# products derived from this software without specific prior written
|
|
# permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
#
|
|
|
|
# Usage: regpkg set pkgname
|
|
|
|
SYSPKGROOT=${PKG_DBDIR:-/var/db/pkg}
|
|
case "${SYSPKG_DBDIR}" in
|
|
"") ;;
|
|
*) SYSPKGROOT=${SYSPKG_DBDIR} ;;
|
|
esac
|
|
|
|
PLIST=/tmp/.PLIST.$$
|
|
|
|
verbose=""
|
|
while [ $# -gt 2 ]; do
|
|
case $1 in
|
|
-v) verbose=$1 ;;
|
|
*) break ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ $# -ne 2 ]; then
|
|
echo "Usage: regpkg set pkgname"
|
|
exit 1
|
|
fi
|
|
|
|
pkgset=$1
|
|
|
|
pkg=$2
|
|
|
|
case $verbose in
|
|
-v) echo "Making PLIST for \"$pkgset\" set and \"$pkg\" package" ;;
|
|
esac
|
|
|
|
# create the skeleton PLIST from the pkgset description
|
|
./makeplist $pkgset $pkg > $PLIST
|
|
|
|
# create the pkg tiny version
|
|
case "${SYSPKG_DATES}" in
|
|
"") tinyvers=`awk '$1 ~ '/$pkg/' { print $2 }' versions`
|
|
case "$tinyvers" in
|
|
"") tinyvers=0
|
|
;;
|
|
esac
|
|
if [ -f ../../sys/conf/osrelease.sh ]; then
|
|
osvers=`sh ../../sys/conf/osrelease.sh`
|
|
method=osreleasese
|
|
else
|
|
osvers=`uname -r`
|
|
method=uname
|
|
fi
|
|
t=$osvers.$tinyvers
|
|
;;
|
|
*) args=`awk '
|
|
/^@cwd/ { prefix = $2; next }
|
|
/^@dirrm/ { next }
|
|
{ printf("%s%s\n", prefix, $0) }' $PLIST`
|
|
# first try for any RCS identifiers in the files
|
|
t=0
|
|
case "$args" in
|
|
"") ;;
|
|
*) t=`ident $args 2>/dev/null | awk '
|
|
BEGIN { last = 0 }
|
|
$2 == "crt0.c,v" { next }
|
|
NF == 8 { t = $4; gsub("/", "", t); if (t > last) last = t; }
|
|
END { print last }'`
|
|
method=ident
|
|
;;
|
|
esac
|
|
case "$t" in
|
|
0) # we need the last mtime of the files which make up the package
|
|
t=`env TZ=UTC LOCALE=C ls -lT $args | 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;
|
|
}
|
|
END { print newest }'`
|
|
method=ls
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
# print version number that we're using
|
|
case "$verbose" in
|
|
-v) echo "$pkg - $t version using $method method" ;;
|
|
esac
|
|
|
|
# create the directory and minimal contents
|
|
SYSPKGDIR=${SYSPKGROOT}/$pkg-$t
|
|
if [ -d ${SYSPKGDIR} ]; then
|
|
echo "There is already a $pkg-$t package installed (${SYSPKGDIR})"
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p ${SYSPKGDIR}
|
|
|
|
# create the comment
|
|
comment=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' comments`
|
|
case "$comment" in
|
|
"") echo "***WARNING ***: no comment for \"$pkg\"" 2>&1
|
|
comment="System package for $pkg"
|
|
;;
|
|
esac
|
|
echo "$comment" > ${SYSPKGDIR}/+COMMENT
|
|
|
|
# create the description
|
|
descr=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' descrs`
|
|
case "$descr" in
|
|
"") echo "***WARNING ***: no description for \"$pkg\"" 2>&1
|
|
descr="System package for $pkg"
|
|
;;
|
|
esac
|
|
echo "$descr" > ${SYSPKGDIR}/+DESC
|
|
printf "\nHomepage:\nhttp://www.NetBSD.org/\n" >> ${SYSPKGDIR}/+DESC
|
|
|
|
# create the build information
|
|
echo "OPSYS=`uname -s`" > ${SYSPKGDIR}/+BUILD_INFO
|
|
echo "OS_VERSION=`uname -r`" >> ${SYSPKGDIR}/+BUILD_INFO
|
|
echo "OBJECT_FMT=`printf '.include <bsd.own.mk>\nall:\n\t@echo ${OBJECT_FMT}' | make -f- all`" >> ${SYSPKGDIR}/+BUILD_INFO
|
|
echo "MACHINE_ARCH=`printf '.include <bsd.own.mk>\nall:\n\t@echo ${MACHINE_ARCH}' | make -f- all`" >> ${SYSPKGDIR}/+BUILD_INFO
|
|
echo "MACHINE_GNU_ARCH=`printf '.include <bsd.own.mk>\nall:\n\t@echo ${MACHINE_GNU_ARCH}' | make -f- all`" >> ${SYSPKGDIR}/+BUILD_INFO
|
|
echo "_PKGTOOLS_VER=`pkg_create -V`" >> ${SYSPKGDIR}/+BUILD_INFO
|
|
|
|
# test for attributes
|
|
args=""
|
|
attrs=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' attrs`
|
|
for a in "$attrs"; do
|
|
case "$attrs" in
|
|
"") ;;
|
|
preserve) echo "$pkg-$t" > ${SYSPKGDIR}/+PRESERVE
|
|
args="$args -n ${SYSPKGDIR}/+PRESERVE"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
pkg_create -v -c ${SYSPKGDIR}/+COMMENT \
|
|
-d ${SYSPKGDIR}/+DESC \
|
|
$args \
|
|
-f $PLIST -l -b /dev/null -B ${SYSPKGDIR}/+BUILD_INFO \
|
|
-s /dev/null -S /dev/null -O $pkg-$t \
|
|
> ${SYSPKGDIR}/+CONTENTS
|
|
|