regpkg revision 1.2
11.1Sagc#! /bin/sh 21.1Sagc# 31.2Sjwise# $NetBSD: regpkg,v 1.2 2003/06/13 02:32:26 jwise Exp $ 41.1Sagc# 51.1Sagc# Copyright (c) 2003 Alistair G. Crooks. All rights reserved. 61.1Sagc# 71.1Sagc# Redistribution and use in source and binary forms, with or without 81.1Sagc# modification, are permitted provided that the following conditions 91.1Sagc# are met: 101.1Sagc# 1. Redistributions of source code must retain the above copyright 111.1Sagc# notice, this list of conditions and the following disclaimer. 121.1Sagc# 2. Redistributions in binary form must reproduce the above copyright 131.1Sagc# notice, this list of conditions and the following disclaimer in the 141.1Sagc# documentation and/or other materials provided with the distribution. 151.1Sagc# 3. All advertising materials mentioning features or use of this software 161.1Sagc# must display the following acknowledgement: 171.1Sagc# This product includes software developed by Alistair G. Crooks. 181.1Sagc# for the NetBSD project. 191.1Sagc# 4. The name of the author may not be used to endorse or promote 201.1Sagc# products derived from this software without specific prior written 211.1Sagc# permission. 221.1Sagc# 231.1Sagc# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 241.1Sagc# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 251.1Sagc# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261.1Sagc# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 271.1Sagc# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281.1Sagc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 291.1Sagc# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 301.1Sagc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 311.1Sagc# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 321.1Sagc# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 331.1Sagc# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 341.1Sagc# 351.1Sagc 361.1Sagc# Usage: regpkg set pkgname 371.1Sagc 381.1SagcSYSPKGROOT=${PKG_DBDIR:-/var/db/pkg} 391.1Sagccase "${SYSPKG_DBDIR}" in 401.1Sagc"") ;; 411.1Sagc*) SYSPKGROOT=${SYSPKG_DBDIR} ;; 421.1Sagcesac 431.1Sagc 441.1SagcPLIST=/tmp/.PLIST.$$ 451.1Sagc 461.1Sagcverbose="" 471.1Sagcwhile [ $# -gt 2 ]; do 481.1Sagc case $1 in 491.1Sagc -v) verbose=$1 ;; 501.1Sagc *) break ;; 511.1Sagc esac 521.1Sagc shift 531.1Sagcdone 541.1Sagc 551.1Sagcif [ $# -ne 2 ]; then 561.1Sagc echo "Usage: regpkg set pkgname" 571.1Sagc exit 1 581.1Sagcfi 591.1Sagc 601.1Sagcpkgset=$1 611.1Sagc 621.1Sagcpkg=$2 631.1Sagc 641.1Sagccase $verbose in 651.1Sagc-v) echo "Making PLIST for \"$pkgset\" set and \"$pkg\" package" ;; 661.1Sagcesac 671.1Sagc 681.1Sagc# create the skeleton PLIST from the pkgset description 691.1Sagc./makeplist $pkgset $pkg > $PLIST 701.1Sagc 711.2Sjwise# create the pkg tiny version 721.2Sjwisetinyvers=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' versions` 731.2Sjwisecase "$tinyvers" in 741.2Sjwise"") echo "***WARNING ***: no version for \"$pkg\"" 2>&1 751.2Sjwise tinyvers="System package for $pkg" 761.2Sjwise ;; 771.2Sjwiseesac 781.2Sjwise 791.1Sagc# we need the last mtime of the files which make up the package 801.2Sjwiseosvers=`sh ../../sys/conf/osrelease.sh` 811.2Sjwiset=$osvers.$tinyvers 821.1Sagc 831.1Sagc# create the directory and minimal contents 841.1SagcSYSPKGDIR=${SYSPKGROOT}/$pkg-$t 851.1Sagcif [ -d ${SYSPKGDIR} ]; then 861.1Sagc echo "There is already a $pkg-$t package installed (${SYSPKGDIR})" 871.1Sagc exit 1 881.1Sagcfi 891.1Sagc 901.1Sagcmkdir -p ${SYSPKGDIR} 911.1Sagc 921.1Sagc# create the comment 931.1Sagccomment=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' comments` 941.1Sagccase "$comment" in 951.1Sagc"") echo "***WARNING ***: no comment for \"$pkg\"" 2>&1 961.1Sagc comment="System package for $pkg" 971.1Sagc ;; 981.1Sagcesac 991.1Sagcecho "$comment" > ${SYSPKGDIR}/+COMMENT 1001.1Sagc 1011.1Sagc# create the description 1021.1Sagcdescr=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' descrs` 1031.1Sagccase "$descr" in 1041.1Sagc"") echo "***WARNING ***: no description for \"$pkg\"" 2>&1 1051.1Sagc descr="System package for $pkg" 1061.1Sagc ;; 1071.1Sagcesac 1081.1Sagcecho "$descr" > ${SYSPKGDIR}/+DESC 1091.1Sagcprintf "\nHomepage:\nhttp://www.NetBSD.org/\n" >> ${SYSPKGDIR}/+DESC 1101.2Sjwise 1111.2Sjwise# create the pkg tiny version 1121.2Sjwisetinyvers=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' versions` 1131.2Sjwisecase "$tinyvers" in 1141.2Sjwise"") echo "***WARNING ***: no version for \"$pkg\"" 2>&1 1151.2Sjwise tinyvers="System package for $pkg" 1161.2Sjwise ;; 1171.2Sjwiseesac 1181.1Sagc 1191.1Sagc# create the build information 1201.1Sagcecho "OPSYS=`uname -s`" > ${SYSPKGDIR}/+BUILD_INFO 1211.1Sagcecho "OS_VERSION=`uname -r`" >> ${SYSPKGDIR}/+BUILD_INFO 1221.1Sagcecho "OBJECT_FMT=`printf '.include <bsd.own.mk>\nall:\n\t@echo ${OBJECT_FMT}' | make -f- all`" >> ${SYSPKGDIR}/+BUILD_INFO 1231.1Sagcecho "MACHINE_ARCH=`printf '.include <bsd.own.mk>\nall:\n\t@echo ${MACHINE_ARCH}' | make -f- all`" >> ${SYSPKGDIR}/+BUILD_INFO 1241.1Sagcecho "MACHINE_GNU_ARCH=`printf '.include <bsd.own.mk>\nall:\n\t@echo ${MACHINE_GNU_ARCH}' | make -f- all`" >> ${SYSPKGDIR}/+BUILD_INFO 1251.1Sagcecho "_PKGTOOLS_VER=`pkg_create -V`" >> ${SYSPKGDIR}/+BUILD_INFO 1261.1Sagc 1271.1Sagc# test for attributes 1281.1Sagcargs="" 1291.1Sagcattrs=`awk '$1 ~ '/$pkg/' { print substr($0, length($1) + 2) }' attrs` 1301.1Sagcfor a in "$attrs"; do 1311.1Sagc case "$attrs" in 1321.1Sagc "") ;; 1331.1Sagc preserve) echo "$pkg-$t" > ${SYSPKGDIR}/+PRESERVE 1341.1Sagc args="$args -n ${SYSPKGDIR}/+PRESERVE" 1351.1Sagc ;; 1361.1Sagc esac 1371.1Sagcdone 1381.1Sagc 1391.1Sagcpkg_create -v -c ${SYSPKGDIR}/+COMMENT \ 1401.1Sagc -d ${SYSPKGDIR}/+DESC \ 1411.1Sagc $args \ 1421.1Sagc -f $PLIST -l -b /dev/null -B ${SYSPKGDIR}/+BUILD_INFO \ 1431.1Sagc -s /dev/null -S /dev/null -O $pkg-$t \ 1441.1Sagc > ${SYSPKGDIR}/+CONTENTS 1451.1Sagc 146