Subject: Re: pkg/18710: redo cleanup for pkgtools/pkg_tarup
To: NetBSD GNATS submissions and followups <gnats-bugs@gnats.netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 10/19/2002 14:53:35
Oops!  Ignore the diff in the original PR.  It's wrong diff made in the
wrong working directory!  That'll teach me for not actually reading the
diffs!  ;-)


Index: pkgtools/pkg_tarup/Makefile
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/pkgtools/pkg_tarup/Makefile,v
retrieving revision 1.7
diff -c -r1.7 Makefile
*** pkgtools/pkg_tarup/Makefile	14 Oct 2002 15:28:43 -0000	1.7
--- pkgtools/pkg_tarup/Makefile	16 Oct 2002 23:54:39 -0000
***************
*** 15,33 ****
  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}			\
! 		PKG_SUFX=${PKG_SUFX}			\
! 		PREFIX=${PREFIX}			\
! 		PKG_TOOLS_BIN=${PKG_TOOLS_BIN}		\
! 		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}			\
--- 15,32 ----
  NO_BUILD=	yes
  NO_MTREE=	yes
  
! # Set SCRIPT_SUBST to substitute "@VARIABLE@" with "value"
! SCRIPT_SUBST+=	AWK=${AWK:Q}				\
! 		ECHO=${ECHO:Q}				\
! 		ID=${ID:Q}				\
! 		PKG_DBDIR=${PKG_DBDIR:Q}		\
! 		PKG_SUFX=${PKG_SUFX:Q}			\
! 		PREFIX=${PREFIX:Q}			\
! 		PKG_TOOLS_BIN=${PKG_TOOLS_BIN:Q}	\
! 		SH=${SH:Q}				\
! 		SU=${SU:Q}
  
! SCRIPT_SUBST_SED=	${SCRIPT_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/}
  
  do-configure:
  	${SED} ${SCRIPT_SUBST_SED}			\
Index: pkgtools/pkg_tarup/files/pkg_tarup
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/pkgtools/pkg_tarup/files/pkg_tarup,v
retrieving revision 1.7
diff -c -r1.7 pkg_tarup
*** pkgtools/pkg_tarup/files/pkg_tarup	14 Oct 2002 15:28:43 -0000	1.7
--- pkgtools/pkg_tarup/files/pkg_tarup	19 Oct 2002 18:46:08 -0000
***************
*** 1,4 ****
! #! ${SH}
  #
  # $Id: pkg_tarup,v 1.7 2002/10/14 15:28:43 hubertf Exp $
  #
--- 1,4 ----
! #! @SH@
  #
  # $Id: pkg_tarup,v 1.7 2002/10/14 15:28:43 hubertf Exp $
  #
***************
*** 7,13 ****
  # (c) Copyright 2000-2002 Hubert Feyrer <hubert@feyrer.de>
  #
  
! PATH=/sbin:/usr/sbin:/bin:/usr/bin:${PREFIX}/sbin:${PREFIX}/bin:${PKG_TOOLS_BIN}
  
  if [ `${ID} -u` != 0 ]; then
  	${ECHO} "Becoming root@`/bin/hostname` to create a binary package"
--- 7,23 ----
  # (c) Copyright 2000-2002 Hubert Feyrer <hubert@feyrer.de>
  #
  
! PREFIX=${PREFIX:-@PREFIX@}
! 
! PATH=/sbin:/usr/sbin:/bin:/usr/bin:${PREFIX}/sbin:${PREFIX}/bin:@PKG_TOOLS_BIN@
! export PATH
! 
! OS=`uname -s`
! 
! AWK=${AWK:-@AWK@}
! ECHO=${ECHO:-@ECHO@}
! ID=${ID:-@ID@}
! SU=${SU:-@SU@}
  
  if [ `${ID} -u` != 0 ]; then
  	${ECHO} "Becoming root@`/bin/hostname` to create a binary package"
***************
*** 15,29 ****
  	exec ${SU} 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
--- 25,39 ----
  	exec ${SU} root -c "$0 $@"
  fi
  
! PKG_DBDIR=${PKG_DBDIR:-@PKG_DBDIR@}
! PKG_SUFX=${PKG_SUFX:-@PKG_SUFX@}
  
  PKGREPOSITORY=${PKGREPOSITORY:-/tmp}
  
  PKG="$1"
  rPKG="`pkg_info -e \"$PKG\"`"
  
! if [ "$PKG" = "" -o "$rPKG" = "" -o -f "${PKG_DBDIR}/${rPKG}" ]
  then
       ${ECHO} Usage: $0 installed_pkg
       exit 1
***************
*** 48,71 ****
  	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
--- 58,81 ----
  	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
***************
*** 94,114 ****
  	-p "`pkg_info -qp ${PKG} | ${AWK} 'NR == 1 { print $2; exit }'`" \
  	-P "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgdep/ { print $2 }'`" \
  	-C "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgcfl/ { print $2 }'`" \
! 	${PKGREPOSITORY}/${PKG}${pkgsufx}
  
  rm -f ${PLIST}
  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?
--- 104,132 ----
  	-p "`pkg_info -qp ${PKG} | ${AWK} 'NR == 1 { print $2; exit }'`" \
  	-P "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgdep/ { print $2 }'`" \
  	-C "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgcfl/ { print $2 }'`" \
! 	${PKGREPOSITORY}/${PKG}${PKG_SUFX}
  
  rm -f ${PLIST}
  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!  ;-)
 

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>