Subject: pkg/18546: some tweaks and improvements for pkgtools/pkg_tarup
To: None <gnats-bugs@gnats.netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 10/05/2002 15:43:35
>Number:         18546
>Category:       pkg
>Synopsis:       some tweaks and improvements for pkgtools/pkg_tarup
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 05 12:44:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Greg A. Woods
>Release:        pkgsrc-current 2002/10/04
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:
System: NetBSD 1.5W
>Description:

	here are some "tweaks" and improvements to pkgtools/pkg_tarup

>How-To-Repeat:

>Fix:


Index: pkg_tarup/Makefile
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/pkgtools/pkg_tarup/Makefile,v
retrieving revision 1.5
diff -c -r1.5 Makefile
*** pkg_tarup/Makefile	20 Sep 2001 17:06:01 -0000	1.5
--- pkg_tarup/Makefile	5 Oct 2002 19:32:16 -0000
***************
*** 8,21 ****
  MAINTAINER=	hubertf@netbsd.org
  COMMENT=	Generates binary package from installed pkg
  
  WRKSRC=		${WRKDIR}
  NO_CHECKSUM=    yes
  NO_PATCH=       yes
- NO_CONFIGURE=   yes
  NO_BUILD=	yes
  NO_MTREE=	yes
  
  do-install:
! 	${INSTALL_SCRIPT} ${FILESDIR}/pkg_tarup ${PREFIX}/bin
  
  .include "../../mk/bsd.pkg.mk"
--- 8,38 ----
  MAINTAINER=	hubertf@netbsd.org
  COMMENT=	Generates binary package from installed pkg
  
+ EXTRACT_ONLY=	# empty
  WRKSRC=		${WRKDIR}
  NO_CHECKSUM=    yes
  NO_PATCH=       yes
  NO_BUILD=	yes
  NO_MTREE=	yes
  
+ # Set SCRIPT_SUBST to substitute "${variable}" to "value" in MESSAGE
+ SCRIPT_SUBST+=	AWK=${AWK}				\
+ 		ECHO=${ECHO}				\
+ 		ID=${ID}				\
+ 		PKG_DBDIR=${PKG_DBDIR}			\
+ 		PREFIX=${PREFIX}			\
+ 		SH=${SH}				\
+ 		SU=${SU}
+ 
+ # XXX this should probably use the @VAR@ form instead of ${VAR}...
+ SCRIPT_SUBST_SED=	${SCRIPT_SUBST:S/=/}!/:S/$/!g/:S/^/ -e s!\\\${/}
+ 
+ do-configure:
+ 	${SED} ${SCRIPT_SUBST_SED}			\
+ 			< ${FILESDIR}/pkg_tarup		\
+ 			> ${WRKSRC}/pkg_tarup		\
+ 
  do-install:
! 	${INSTALL_SCRIPT} ${WRKSRC}/pkg_tarup ${PREFIX}/bin
  
  .include "../../mk/bsd.pkg.mk"
Index: pkg_tarup/files/pkg_tarup
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/pkgtools/pkg_tarup/files/pkg_tarup,v
retrieving revision 1.5
diff -c -r1.5 pkg_tarup
*** pkg_tarup/files/pkg_tarup	20 Sep 2001 17:06:01 -0000	1.5
--- pkg_tarup/files/pkg_tarup	5 Oct 2002 19:36:06 -0000
***************
*** 1,4 ****
! #!/bin/sh
  # $Id: pkg_tarup,v 1.5 2001/09/20 17:06:01 agc Exp $
  #
  # Tar up installed package
--- 1,5 ----
! #! ${SH}
! #
  # $Id: pkg_tarup,v 1.5 2001/09/20 17:06:01 agc Exp $
  #
  # Tar up installed package
***************
*** 6,40 ****
  # (c) Copyright 2000 Hubert Feyrer <hubert@feyrer.de>
  #
  
  OS=`uname -s`
  
! case ${OS} in
! NetBSD)
! 	awkprog=/usr/bin/awk
! 	echoprog=echo
! 	idprog=/usr/bin/id
! 	suprog=/usr/bin/su
! 	;;
! SunOS)
! 	awkprog=/usr/bin/nawk
! 	echoprog=/usr/ucb/echo
! 	idprog=/usr/xpg4/bin/id
! 	suprog=/usr/bin/su
! 	;;
! Linux)
! 	awkprog=/usr/bin/awk
! 	echoprog=/bin/echo
! 	idprog=/usr/bin/id
! 	suprog=/bin/su
! 	;;
! *)
! 	echo "Unusual OS - thanks for using pkgsrc"
! 	awkprog=awk
! 	echoprog=echo
! 	idprog=id
! 	suprog=su
! 	;;
! esac
  
  if [ `${idprog} -u` != 0 ]; then
  	${echoprog} "Becoming root@`/bin/hostname` to create a binary package"
--- 7,20 ----
  # (c) Copyright 2000 Hubert Feyrer <hubert@feyrer.de>
  #
  
+ PATH=/sbin:/usr/sbin:/bin:/usr/bin:${PREFIX}/sbin:${PREFIX}/bin
+ 
  OS=`uname -s`
  
! awkprog=${AWK}
! echoprog=${ECHO}
! idprog=${ID}
! suprog=${SU}
  
  if [ `${idprog} -u` != 0 ]; then
  	${echoprog} "Becoming root@`/bin/hostname` to create a binary package"
***************
*** 42,55 ****
  	exec ${suprog} root -c "$0 $@"
  fi
  
! PKG_DBDIR=${PKG_DBDIR:-/var/db/pkg}
  PKGREPOSITORY=${PKGREPOSITORY:-/tmp}
- PKG_SUFX=${PKG_SUFX:-tgz}
  
  PKG="$1"
  rPKG="`pkg_info -e \"$PKG\"`"
  
! if [ "$PKG" = "" -o "$rPKG" = "" -o -f "${PKG_DBDIR}/${rPKG}" ]
  then
       echo Usage: $0 installed_pkg
       exit 1
--- 22,36 ----
  	exec ${suprog} root -c "$0 $@"
  fi
  
! pkgdbdir=${PKG_DBDIR:-${PKG_DBDIR}}
! pkgsufx=${PKG_SUFX:-${PKG_SUFX}}
! 
  PKGREPOSITORY=${PKGREPOSITORY:-/tmp}
  
  PKG="$1"
  rPKG="`pkg_info -e \"$PKG\"`"
  
! if [ "$PKG" = "" -o "$rPKG" = "" -o -f "${pkgdbdir}/${rPKG}" ]
  then
       echo Usage: $0 installed_pkg
       exit 1
***************
*** 74,97 ****
  	fi
  }
  
! check_and_add -c ${PKG_DBDIR}/${PKG}/+COMMENT
! check_and_add -d ${PKG_DBDIR}/${PKG}/+DESC
! check_and_add -b ${PKG_DBDIR}/${PKG}/+BUILD_VERSION
! check_and_add -B ${PKG_DBDIR}/${PKG}/+BUILD_INFO
! check_and_add -s ${PKG_DBDIR}/${PKG}/+SIZE_PKG
! check_and_add -S ${PKG_DBDIR}/${PKG}/+SIZE_ALL
! check_and_add -i ${PKG_DBDIR}/${PKG}/+INSTALL
! check_and_add -k ${PKG_DBDIR}/${PKG}/+DEINSTALL
! check_and_add -r ${PKG_DBDIR}/${PKG}/+REQUIRE
! check_and_add -D ${PKG_DBDIR}/${PKG}/+DISPLAY
! check_and_add -m ${PKG_DBDIR}/${PKG}/+MTREE		#NOTYET#
  
  PLIST=/tmp/+CONTENTS.$$
  sed -n \
      -e '/^@comment MD5:/d' \
      -e '/^@cwd \.$/,$d' \
      -e '/\$NetBSD/,$p' \
!     <${PKG_DBDIR}/${PKG}/+CONTENTS >$PLIST
  
  # Duplicate first @cwd (work around pkg_create "feature" ...)
  grep '^@cwd' $PLIST | head -1 >$PLIST.1
--- 55,78 ----
  	fi
  }
  
! check_and_add -c ${pkgdbdir}/${PKG}/+COMMENT
! check_and_add -d ${pkgdbdir}/${PKG}/+DESC
! check_and_add -b ${pkgdbdir}/${PKG}/+BUILD_VERSION
! check_and_add -B ${pkgdbdir}/${PKG}/+BUILD_INFO
! check_and_add -s ${pkgdbdir}/${PKG}/+SIZE_PKG
! check_and_add -S ${pkgdbdir}/${PKG}/+SIZE_ALL
! check_and_add -i ${pkgdbdir}/${PKG}/+INSTALL
! check_and_add -k ${pkgdbdir}/${PKG}/+DEINSTALL
! check_and_add -r ${pkgdbdir}/${PKG}/+REQUIRE
! check_and_add -D ${pkgdbdir}/${PKG}/+DISPLAY
! check_and_add -m ${pkgdbdir}/${PKG}/+MTREE		#NOTYET#
  
  PLIST=/tmp/+CONTENTS.$$
  sed -n \
      -e '/^@comment MD5:/d' \
      -e '/^@cwd \.$/,$d' \
      -e '/\$NetBSD/,$p' \
!     <${pkgdbdir}/${PKG}/+CONTENTS >$PLIST
  
  # Duplicate first @cwd (work around pkg_create "feature" ...)
  grep '^@cwd' $PLIST | head -1 >$PLIST.1
***************
*** 126,140 ****
  exit 0
  
  
  
  mtree file considerations:
   - keeping uncompressed mtree file adds ~10% to the size of /var/db/pkg
   - could gzip file, space saving: 5kb->850b (plus some intelligence to
     uncompress them when needed)
   - not keeping mtree file results in pkgs w/o mtree file (but should work)
  
  integration:
!  - how/where? I'd prefer not to have yet another pkg_* utility flying
!     around, integration into pkg_admin would be nice. But how merge a
!     shell script into a C executable?
!  
--- 107,128 ----
  exit 0
  
  
+ +REQUIRED_BY:
+ 
+  - maybe the squirelling away of +REQUIRED_BY should be done here
+    instead of in the bsd.pkg.mk framework that normally calls this.
  
  mtree file considerations:
+ 
   - keeping uncompressed mtree file adds ~10% to the size of /var/db/pkg
+ 
   - could gzip file, space saving: 5kb->850b (plus some intelligence to
     uncompress them when needed)
+ 
   - not keeping mtree file results in pkgs w/o mtree file (but should work)
  
  integration:
! 
!  - how/where?  I'd prefer not to have yet another pkg_* utility flying
!    around, integration into pkg_admin would be nice.  But how merge a
!    shell script into a C executable?  REWRITE in C of course!  ;-)
>Release-Note:
>Audit-Trail:
>Unformatted: