Annotation of pkgsrc/pkgtools/pkg_tarup/files/pkg_tarup, Revision 1.6
1.6 ! hubertf 1: #! ${SH}
! 2: #
! 3: # $Id: pkg_tarup,v 1.5 2001/09/20 17:06:01 agc Exp $
1.1 hubertf 4: #
5: # Tar up installed package
6: #
1.6 ! hubertf 7: # (c) Copyright 2000-2002 Hubert Feyrer <hubert@feyrer.de>
1.1 hubertf 8: #
9:
1.6 ! hubertf 10: PATH=/sbin:/usr/sbin:/bin:/usr/bin:${PREFIX}/sbin:${PREFIX}/bin
1.5 agc 11:
1.6 ! hubertf 12: if [ `${ID} -u` != 0 ]; then
! 13: ${ECHO} "Becoming root@`/bin/hostname` to create a binary package"
! 14: ${ECHO} -n "`${ECHO} ${SU} | ${AWK} '{ print $$1 }'` ";\
! 15: exec ${SU} root -c "$0 $@"
1.5 agc 16: fi
17:
1.6 ! hubertf 18: pkgdbdir=${PKG_DBDIR:-${PKG_DBDIR}}
! 19: pkgsufx=${PKG_SUFX:-${PKG_SUFX}}
! 20:
1.1 hubertf 21: PKGREPOSITORY=${PKGREPOSITORY:-/tmp}
22:
23: PKG="$1"
24: rPKG="`pkg_info -e \"$PKG\"`"
25:
1.6 ! hubertf 26: if [ "$PKG" = "" -o "$rPKG" = "" -o -f "${pkgdbdir}/${rPKG}" ]
1.1 hubertf 27: then
1.6 ! hubertf 28: ${ECHO} Usage: $0 installed_pkg
1.1 hubertf 29: exit 1
30: fi
31:
32: PKG=$rPKG
1.6 ! hubertf 33: ${ECHO} "Creating binary package: $PKG"
1.1 hubertf 34:
35:
36: check_and_add() {
37: opt="$1"
38: file="$2"
39:
40: if [ x"$opt" = x"" -o x"$file" = x"" ]; then
1.6 ! hubertf 41: ${ECHO} Usage: check_and_add -opt +FILE
1.1 hubertf 42: exit 1
43: fi
44:
45: if [ -f "$file" ]
46: then
47: PKG_ARGS="${PKG_ARGS} ${opt} ${file}"
48: fi
49: }
50:
1.6 ! hubertf 51: check_and_add -c ${pkgdbdir}/${PKG}/+COMMENT
! 52: check_and_add -d ${pkgdbdir}/${PKG}/+DESC
! 53: check_and_add -b ${pkgdbdir}/${PKG}/+BUILD_VERSION
! 54: check_and_add -B ${pkgdbdir}/${PKG}/+BUILD_INFO
! 55: check_and_add -s ${pkgdbdir}/${PKG}/+SIZE_PKG
! 56: check_and_add -S ${pkgdbdir}/${PKG}/+SIZE_ALL
! 57: check_and_add -i ${pkgdbdir}/${PKG}/+INSTALL
! 58: check_and_add -k ${pkgdbdir}/${PKG}/+DEINSTALL
! 59: check_and_add -r ${pkgdbdir}/${PKG}/+REQUIRE
! 60: check_and_add -D ${pkgdbdir}/${PKG}/+DISPLAY
! 61: check_and_add -m ${pkgdbdir}/${PKG}/+MTREE #NOTYET#
1.1 hubertf 62:
63: PLIST=/tmp/+CONTENTS.$$
64: sed -n \
65: -e '/^@comment MD5:/d' \
66: -e '/^@cwd \.$/,$d' \
67: -e '/\$NetBSD/,$p' \
1.6 ! hubertf 68: <${pkgdbdir}/${PKG}/+CONTENTS >$PLIST
1.1 hubertf 69:
70: # Duplicate first @cwd (work around pkg_create "feature" ...)
71: grep '^@cwd' $PLIST | head -1 >$PLIST.1
72: if [ -s ${PLIST}.1 ]
73: then
74: sed \
75: -e "/`cat ${PLIST}.1 | sed 's,/,\\\\/,g'`/r${PLIST}.1" \
76: <${PLIST} >${PLIST}.2
77: mv ${PLIST}.2 ${PLIST}
78: fi
79: rm ${PLIST}.1
80:
1.6 ! hubertf 81: # ${ECHO} -----
1.1 hubertf 82: # cat $PLIST
1.6 ! hubertf 83: # ${ECHO} -----
1.1 hubertf 84: # exit 0
85:
86: # Just for kicks ...
87: # pkg_admin check "${PKG}"
88:
89: pkg_create \
90: ${PKG_ARGS} \
91: -v \
92: -f ${PLIST} \
93: -l \
1.6 ! hubertf 94: -p "`pkg_info -qp ${PKG} | ${AWK} 'NR == 1 { print $2; exit }'`" \
! 95: -P "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgdep/ { print $2 }'`" \
! 96: -C "`pkg_info -qf ${PKG} | ${AWK} '/^@pkgcfl/ { print $2 }'`" \
! 97: ${PKGREPOSITORY}/${PKG}${pkgsufx}
1.1 hubertf 98:
99: rm -f ${PLIST}
100: exit 0
101:
102:
103:
1.6 ! hubertf 104:
1.1 hubertf 105: mtree file considerations:
1.4 hubertf 106: - keeping uncompressed mtree file adds ~10% to the size of /var/db/pkg
1.1 hubertf 107: - could gzip file, space saving: 5kb->850b (plus some intelligence to
108: uncompress them when needed)
109: - not keeping mtree file results in pkgs w/o mtree file (but should work)
110:
111: integration:
1.6 ! hubertf 112: - how/where? I'd prefer not to have yet another pkg_* utility flying
! 113: around, integration into pkg_admin would be nice. But how merge a
! 114: shell script into a C executable?
CVSweb <webmaster@jp.NetBSD.org>