Home | History | Annotate | Line # | Download | only in sets
regpkg revision 1.2
      1  1.1    agc #! /bin/sh
      2  1.1    agc #
      3  1.2  jwise # $NetBSD: regpkg,v 1.2 2003/06/13 02:32:26 jwise Exp $
      4  1.1    agc #
      5  1.1    agc # Copyright (c) 2003 Alistair G. Crooks.  All rights reserved.
      6  1.1    agc #
      7  1.1    agc # Redistribution and use in source and binary forms, with or without
      8  1.1    agc # modification, are permitted provided that the following conditions
      9  1.1    agc # are met:
     10  1.1    agc # 1. Redistributions of source code must retain the above copyright
     11  1.1    agc #    notice, this list of conditions and the following disclaimer.
     12  1.1    agc # 2. Redistributions in binary form must reproduce the above copyright
     13  1.1    agc #    notice, this list of conditions and the following disclaimer in the
     14  1.1    agc #    documentation and/or other materials provided with the distribution.
     15  1.1    agc # 3. All advertising materials mentioning features or use of this software
     16  1.1    agc #    must display the following acknowledgement:
     17  1.1    agc #	This product includes software developed by Alistair G. Crooks.
     18  1.1    agc #	for the NetBSD project.
     19  1.1    agc # 4. The name of the author may not be used to endorse or promote
     20  1.1    agc #    products derived from this software without specific prior written
     21  1.1    agc #    permission.
     22  1.1    agc #
     23  1.1    agc # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     24  1.1    agc # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     25  1.1    agc # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.1    agc # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     27  1.1    agc # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.1    agc # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     29  1.1    agc # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30  1.1    agc # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     31  1.1    agc # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     32  1.1    agc # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     33  1.1    agc # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     34  1.1    agc #
     35  1.1    agc 
     36  1.1    agc # Usage: regpkg set pkgname
     37  1.1    agc 
     38  1.1    agc SYSPKGROOT=${PKG_DBDIR:-/var/db/pkg}
     39  1.1    agc case "${SYSPKG_DBDIR}" in
     40  1.1    agc "")	;;
     41  1.1    agc *)	SYSPKGROOT=${SYSPKG_DBDIR} ;;
     42  1.1    agc esac
     43  1.1    agc 
     44  1.1    agc PLIST=/tmp/.PLIST.$$
     45  1.1    agc 
     46  1.1    agc verbose=""
     47  1.1    agc while [ $# -gt 2 ]; do
     48  1.1    agc 	case $1 in
     49  1.1    agc 	-v)	verbose=$1 ;;
     50  1.1    agc 	*)	break ;;
     51  1.1    agc 	esac
     52  1.1    agc 	shift
     53  1.1    agc done
     54  1.1    agc 
     55  1.1    agc if [ $# -ne 2 ]; then
     56  1.1    agc 	echo "Usage: regpkg set pkgname"
     57  1.1    agc 	exit 1
     58  1.1    agc fi
     59  1.1    agc 
     60  1.1    agc pkgset=$1
     61  1.1    agc 
     62  1.1    agc pkg=$2
     63  1.1    agc 
     64  1.1    agc case $verbose in
     65  1.1    agc -v)	echo "Making PLIST for \"$pkgset\" set and \"$pkg\" package" ;;
     66  1.1    agc esac
     67  1.1    agc 
     68  1.1    agc # create the skeleton PLIST from the pkgset description
     69  1.1    agc ./makeplist $pkgset $pkg > $PLIST
     70  1.1    agc 
     71  1.2  jwise # create the pkg tiny version
     72  1.2  jwise tinyvers=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' versions`
     73  1.2  jwise case "$tinyvers" in
     74  1.2  jwise "")	echo "***WARNING ***: no version for \"$pkg\"" 2>&1
     75  1.2  jwise 	tinyvers="System package for $pkg"
     76  1.2  jwise 	;;
     77  1.2  jwise esac
     78  1.2  jwise 
     79  1.1    agc # we need the last mtime of the files which make up the package
     80  1.2  jwise osvers=`sh ../../sys/conf/osrelease.sh`
     81  1.2  jwise t=$osvers.$tinyvers
     82  1.1    agc 
     83  1.1    agc # create the directory and minimal contents
     84  1.1    agc SYSPKGDIR=${SYSPKGROOT}/$pkg-$t
     85  1.1    agc if [ -d ${SYSPKGDIR} ]; then
     86  1.1    agc 	echo "There is already a $pkg-$t package installed (${SYSPKGDIR})"
     87  1.1    agc 	exit 1
     88  1.1    agc fi
     89  1.1    agc 
     90  1.1    agc mkdir -p ${SYSPKGDIR}
     91  1.1    agc 
     92  1.1    agc # create the comment
     93  1.1    agc comment=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' comments`
     94  1.1    agc case "$comment" in
     95  1.1    agc "")	echo "***WARNING ***: no comment for \"$pkg\"" 2>&1
     96  1.1    agc 	comment="System package for $pkg"
     97  1.1    agc 	;;
     98  1.1    agc esac
     99  1.1    agc echo "$comment" > ${SYSPKGDIR}/+COMMENT
    100  1.1    agc 
    101  1.1    agc # create the description
    102  1.1    agc descr=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' descrs`
    103  1.1    agc case "$descr" in
    104  1.1    agc "")	echo "***WARNING ***: no description for \"$pkg\"" 2>&1
    105  1.1    agc 	descr="System package for $pkg"
    106  1.1    agc 	;;
    107  1.1    agc esac
    108  1.1    agc echo "$descr" > ${SYSPKGDIR}/+DESC
    109  1.1    agc printf "\nHomepage:\nhttp://www.NetBSD.org/\n" >> ${SYSPKGDIR}/+DESC
    110  1.2  jwise 
    111  1.2  jwise # create the pkg tiny version
    112  1.2  jwise tinyvers=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' versions`
    113  1.2  jwise case "$tinyvers" in
    114  1.2  jwise "")	echo "***WARNING ***: no version for \"$pkg\"" 2>&1
    115  1.2  jwise 	tinyvers="System package for $pkg"
    116  1.2  jwise 	;;
    117  1.2  jwise esac
    118  1.1    agc 
    119  1.1    agc # create the build information
    120  1.1    agc echo "OPSYS=`uname -s`" > ${SYSPKGDIR}/+BUILD_INFO
    121  1.1    agc echo "OS_VERSION=`uname -r`" >> ${SYSPKGDIR}/+BUILD_INFO
    122  1.1    agc echo "OBJECT_FMT=`printf '.include <bsd.own.mk>\nall:\n\t@echo ${OBJECT_FMT}' | make -f- all`" >> ${SYSPKGDIR}/+BUILD_INFO
    123  1.1    agc echo "MACHINE_ARCH=`printf '.include <bsd.own.mk>\nall:\n\t@echo ${MACHINE_ARCH}' | make -f- all`" >> ${SYSPKGDIR}/+BUILD_INFO
    124  1.1    agc echo "MACHINE_GNU_ARCH=`printf '.include <bsd.own.mk>\nall:\n\t@echo ${MACHINE_GNU_ARCH}' | make -f- all`" >> ${SYSPKGDIR}/+BUILD_INFO
    125  1.1    agc echo "_PKGTOOLS_VER=`pkg_create -V`" >> ${SYSPKGDIR}/+BUILD_INFO
    126  1.1    agc 
    127  1.1    agc # test for attributes
    128  1.1    agc args=""
    129  1.1    agc attrs=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' attrs`
    130  1.1    agc for a in "$attrs"; do
    131  1.1    agc 	case "$attrs" in
    132  1.1    agc 	"")		;;
    133  1.1    agc 	preserve)	echo "$pkg-$t" > ${SYSPKGDIR}/+PRESERVE
    134  1.1    agc 			args="$args -n ${SYSPKGDIR}/+PRESERVE"
    135  1.1    agc 			;;
    136  1.1    agc 	esac
    137  1.1    agc done
    138  1.1    agc 
    139  1.1    agc pkg_create -v -c ${SYSPKGDIR}/+COMMENT \
    140  1.1    agc 	-d ${SYSPKGDIR}/+DESC \
    141  1.1    agc 	$args \
    142  1.1    agc 	-f $PLIST -l -b /dev/null -B ${SYSPKGDIR}/+BUILD_INFO \
    143  1.1    agc 	-s /dev/null -S /dev/null -O $pkg-$t \
    144  1.1    agc 		> ${SYSPKGDIR}/+CONTENTS
    145  1.1    agc 
    146