diff options
author | dougb <dougb@FreeBSD.org> | 2007-08-28 06:48:24 +0800 |
---|---|---|
committer | dougb <dougb@FreeBSD.org> | 2007-08-28 06:48:24 +0800 |
commit | 4b1a1187ed02462180169bea47f04748de04a699 (patch) | |
tree | c2ed0cac5a840595d1ee6e79278c10872b38df18 /ports-mgmt | |
parent | 399894ef432b632769d5b1afc08413e947a2c37e (diff) | |
download | freebsd-ports-gnome-4b1a1187ed02462180169bea47f04748de04a699.tar.gz freebsd-ports-gnome-4b1a1187ed02462180169bea47f04748de04a699.tar.zst freebsd-ports-gnome-4b1a1187ed02462180169bea47f04748de04a699.zip |
Improvement
===========
1. Before calling pkg_create for the installed version of the port,
cd into the PKGREPOSITORY directory. This not only simplifies the code,
it helps handle the problems of ports trees mounted read-only. [1]
2. Factor out initialization of the $pkgrep directory into a function.
Bug fixes
=========
1. Before calling 'find ${pkgrep}/ ... -delete' assert that $pkgrep is
not empty.
2. Make sure that $pkgrep is initialized everywhere it's needed.
Suggested by: Hans Lambermont <hans@lambermont.dyndns.org> [1]
Diffstat (limited to 'ports-mgmt')
-rw-r--r-- | ports-mgmt/portmaster/files/portmaster.sh.in | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/ports-mgmt/portmaster/files/portmaster.sh.in b/ports-mgmt/portmaster/files/portmaster.sh.in index f5693d10284d..5d4d8baaade5 100644 --- a/ports-mgmt/portmaster/files/portmaster.sh.in +++ b/ports-mgmt/portmaster/files/portmaster.sh.in @@ -1,6 +1,6 @@ #!/bin/sh -# Local version: 1.183 +# Local version: 1.184 # $FreeBSD$ # Copyright (c) 2005-2007 Douglas Barton, All rights reserved @@ -217,7 +217,8 @@ safe_exit () { fi if [ -z "$TRAP" -a \ - -e "${TMPDIR}/f-${PARENT_PID}-package-flag" ]; then + -e "${TMPDIR}/f-${PARENT_PID}-package-flag" -a \ + -n "$pkgrep" ]; then find ${pkgrep}/ -type f -newer ${TMPDIR}/f-${PARENT_PID}-package-flag -delete fi @@ -850,14 +851,18 @@ delete_all_distfiles () { fi } -backup_package () { - # bu_pkg_name is used globally +init_pkgrep () { + pkgrep=`make $PM_MAKE_ARGS -f/usr/share/mk/bsd.port.mk -VPKGREPOSITORY` + export pkgrep + mkdir -p $pkgrep +} +backup_package () { echo "===>>> Creating a backup package for old version $1" + [ -n "$pkgrep" ] || fail "No package repository variable set" + cd $pkgrep || fail "Cannot cd into the $pkgrep directory for backup" if pkg_create -b $1; then - bu_pkg_name=`echo ${1}.*` - mv $bu_pkg_name $pkgrep/ && - echo " ===>>> Package can be found in $pkgrep" + echo " ===>>> Package can be found in $pkgrep" else local PROCEED @@ -1079,7 +1084,10 @@ if [ -n "$EXPUNGE" ]; then exit 1 fi - [ -n "$BACKUP" ] && backup_package $EXPUNGE + if [ -n "$BACKUP" ]; then + init_pkgrep + backup_package $EXPUNGE + fi find_contents_distfiles $EXPUNGE @@ -1125,7 +1133,10 @@ if [ -n "$CLEAN_STALE" ]; then echo -n "===>>> ${iport} is no longer depended on, delete? [n] " read YESNO case "$YESNO" in - [yY]) [ -n "$BACKUP" ] && backup_package $iport + [yY]) if [ -n "$BACKUP" ]; then + [ -z "$pkgrep" ] && init_pkgrep + backup_package $iport + fi find_contents_distfiles $iport @@ -1196,10 +1207,7 @@ if [ "$$" -eq "$PARENT_PID" ]; then fi if [ -z "$NO_BACKUP" ]; then - pkgrep=`make $PM_MAKE_ARGS -f/usr/share/mk/bsd.port.mk -VPKGREPOSITORY` - export pkgrep - mkdir -p $pkgrep - + init_pkgrep if [ -z "$BACKUP" ]; then touch ${TMPDIR}/f-${PARENT_PID}-package-flag fi |