diff options
author | dougb <dougb@FreeBSD.org> | 2010-04-10 12:32:58 +0800 |
---|---|---|
committer | dougb <dougb@FreeBSD.org> | 2010-04-10 12:32:58 +0800 |
commit | b8d44964e84fe8d2c7557ea76268b2524c072550 (patch) | |
tree | fe3026978491d50f8e6ba21f930a37a0b6197ad1 /ports-mgmt | |
parent | 595fbc95edf241fdee7026c0e49192843101035a (diff) | |
download | freebsd-ports-gnome-b8d44964e84fe8d2c7557ea76268b2524c072550.tar.gz freebsd-ports-gnome-b8d44964e84fe8d2c7557ea76268b2524c072550.tar.zst freebsd-ports-gnome-b8d44964e84fe8d2c7557ea76268b2524c072550.zip |
New Features
============
1. Introducing the new options --index and --index-only. The first
will use the INDEX file to check if a port is up to date. The
second allows the use of portmaster with no /usr/ports directory.
2. The second argument to -o and the port name for -e can now be globs
3. For the -d|-D and -b|-B options allow the command line to override
any values that might be set in .portmasterrc
Internals
=========
1. Add a pm_sv() function to handle verbose messages for PM_SU_CMD
2. Add a find_glob_dirs() function, and use it instead of custom
versions each place this is needed.
3. For -o, add -DDISABLE_CONFLICTS
Bug Fixes
=========
1. If running as root, unset PM_SU_VERBOSE
2. Minor tweaks to improve usage()
Diffstat (limited to 'ports-mgmt')
-rw-r--r-- | ports-mgmt/portmaster/files/portmaster.sh.in | 597 |
1 files changed, 405 insertions, 192 deletions
diff --git a/ports-mgmt/portmaster/files/portmaster.sh.in b/ports-mgmt/portmaster/files/portmaster.sh.in index f2f748a381e7..d7780938e5d1 100644 --- a/ports-mgmt/portmaster/files/portmaster.sh.in +++ b/ports-mgmt/portmaster/files/portmaster.sh.in @@ -36,9 +36,12 @@ if [ -z "$PM_PARENT_PID" ]; then [ -r "$HOME/.portmasterrc" ] && . $HOME/.portmasterrc set +o allexport + my_environment=`set` + # If we are already root, unset this to avoid potential conflict euid=`ps -o uid $$` ; euid=${euid##* } - [ "$euid" -eq 0 ] && unset PM_SU_CMD + [ "$euid" -eq 0 ] && unset PM_SU_CMD PM_SU_VERBOSE + unset euid fi umask 022 @@ -141,16 +144,14 @@ safe_exit () { [ -n "$UPDATE_REQ_BYS" -o -n "$PM_FORCE" ] && files=`find $pdb -type f -name PM_UPGRADE_DONE_FLAG` if [ -n "$files" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Deleting 'install complete' flags" + pm_sv Deleting \'install complete\' flags pm_find_s $pdb -type f -name PM_UPGRADE_DONE_FLAG -delete fi # Outdent fi if [ -z "$BACKUP" -a -z "$NO_BACKUP" -a \ -n "$NB_DELETE" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Deleting safety packages for successful installs" + pm_sv Deleting safety packages for successful installs pm_cd $pbu || fail "Cannot cd to $pbu" pm_rm_s $NB_DELETE fi @@ -158,8 +159,7 @@ safe_exit () { [ -n "$pbu" ] && pbu=`find $pbu -type d -empty 2>/dev/null` if [ -d "$pbu" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Removing empty backup package directory" + pm_sv Removing empty backup package directory pm_rmdir_s $pbu fi @@ -249,10 +249,10 @@ usage () { echo '' echo 'Usage:' echo "Common flags: [--force-config] [-CGHKgntvw B|b f|i D|d]" - echo " [[--packages|--packages-only] [-P|-PP] | [--packages-build]]" + echo " [[[--packages|-P]|[--packages-only|-PP]] | [--packages-build]]" echo " [--packages-if-newer] [--delete-build-only] [--always-fetch]" echo " [--local-packagedir=<path>] [--delete-packages]" - echo " [--no-confirm] [--no-term-title]" + echo " [--no-confirm] [--no-term-title] [--index|--index-only]" echo " [-m <arguments for make>] [-x <glob pattern to exclude from building>]" echo "${0##*/} [Common flags] <full name of port directory in $pdb>" echo "${0##*/} [Common flags] <full path to $pd/foo/bar>" @@ -271,7 +271,7 @@ usage () { echo '' echo "${0##*/} -[l|L]" echo '' - echo "${0##*/} [-b D|d] -e <full name of port directory in $pdb>" + echo "${0##*/} [-b D|d] -e <name/glob of port directory in $pdb>" echo "${0##*/} [-b D|d] -s" echo '' echo "${0##*/} [--force-config] [-aftv] -F" @@ -308,15 +308,20 @@ usage () { echo "-m <arguments for the 'make' command line>" echo "-x <avoid building or updating ports that match this pattern>" echo ' Can be specified more than once' + echo '' echo '--no-confirm do not ask user to confirm list of ports to be' echo ' installed and/or updated before proceeding' echo '--no-term-title do not update the xterm title bar' echo '' + echo '--index use INDEX-[6-9] to check if a port is out of date' + echo '--index-only do not try to use /usr/ports' + echo '' echo '--show-work list what ports are and would be installed' echo '' echo '-o replace the installed port with a port from a different origin' echo '[-R] -r rebuild port, and all ports that depend on it' echo '-R used with -[rf] to skip ports updated on a previous run' + echo '' echo '-a check all ports, update as necessary' echo '' echo '--delete-build-only delete ports that are build-only dependencies' @@ -384,32 +389,9 @@ pm_rm_s () { $PM_SU_CMD /bin/rm $*; } pm_rmdir_s () { $PM_SU_CMD /bin/rmdir $*; } pm_unlink_s () { /bin/test -e $1 && $PM_SU_CMD /bin/unlink $1; } -#=============== End functions we always want to have =============== +pm_sv () { [ -n "$PM_SU_VERBOSE" ] && echo "===>>> SU $*"; } -# Do this here so it can use the fancy functions above, and default values -# can be overridden in the rc files -if [ "$$" -eq "$PM_PARENT_PID" ]; then - if [ -z "$pd" ]; then - pd=`pm_make_b -f/usr/share/mk/bsd.port.mk -V PORTSDIR` - [ -n "$pd" ] || fail 'The value of PORTSDIR cannot be empty' - fi - if [ -z "$pdb" ]; then - pdb=`pm_make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR` - [ -n "$pdb" ] || fail 'The value of PKG_DBDIR cannot be empty' - fi - if [ -z "$distdir" ]; then - distdir=`pm_make_b -f/usr/share/mk/bsd.port.mk -VDISTDIR` - [ -n "$distdir" ] || fail 'The value of DISTDIR cannot be empty' - # In case it is a symlink - distdir="${distdir}/" - fi - if [ -z "$port_dbdir" ]; then - port_dbdir=`pm_make_b -f/usr/share/mk/bsd.port.mk -V PORT_DBDIR` - [ -n "$port_dbdir" ] && export port_dbdir - fi - - export pd pdb distdir -fi +#=============== End functions we always want to have =============== packages_init () { local e1 e2 @@ -456,6 +438,9 @@ for var in "$@" ; do export PM_NO_CONFIRM ;; --no-term-title) PM_NO_TERM_TITLE=pm_no_term_title export PM_NO_TERM_TITLE ;; + --index) PM_INDEX=pm_index ; export PM_INDEX ;; + --index-only) PM_INDEX=pm_index ; PM_INDEX_ONLY=pm_index_only + export PM_INDEX PM_INDEX_ONLY ;; --help) usage 0 ;; --version) version ; exit 0 ;; --clean-distfiles) CLEAN_DISTFILES=clean_distfiles ;; @@ -471,7 +456,90 @@ for var in "$@" ; do esac done +# Do this here so it can use the fancy functions above, and default values +# can be overridden in the rc files if [ "$$" -eq "$PM_PARENT_PID" ]; then + if [ -n "$PM_INDEX" ]; then + [ -d "$pd" ] && pm_cd_pd + if [ -z "$FETCHINDEX" ]; then + [ -d "$pd" ] && FETCHINDEX=`pm_make_b -V FETCHINDEX` + [ -n "$FETCHINDEX" ] || FETCHINDEX='fetch -am -o' + fi + if [ -z "$MASTER_SITE_INDEX" ]; then + [ -d "$pd" ] && + MASTER_SITE_INDEX=`pm_make_b -V MASTER_SITE_INDEX` + [ -n "$MASTER_SITE_INDEX" ] || + MASTER_SITE_INDEX='http://www.FreeBSD.org/ports/' + fi + if [ -z "$INDEXDIR" ]; then + [ -d "$pd" ] && INDEXDIR=`pm_make_b -V INDEXDIR` + [ -n "$INDEXDIR" ] || INDEXDIR="$TMPDIR" + fi + if [ -z "$INDEXFILE" ]; then + [ -d "$pd" ] && INDEXFILE=`pm_make_b -V INDEXFILE` + if [ -z "$INDEXFILE" ]; then + ver=`uname -r` + INDEXFILE=INDEX-${ver%%\.*} + unset ver + fi + fi + + PM_INDEX="${INDEXDIR}/${INDEXFILE}" + index_time=`stat -f '%Ua' $PM_INDEX 2>/dev/null` + pm_sv Updating INDEX file + $PM_SU_CMD $FETCHINDEX ${PM_INDEX}.bz2 ${MASTER_SITE_INDEX}${INDEXFILE}.bz2 + if [ $index_time -ne `stat -f '%Ua' $PM_INDEX 2>/dev/null` ]; then + temp_index=`pm_mktemp index` + bunzip2 < ${PM_INDEX}.bz2 > $temp_index + pm_install_s $temp_index $PM_INDEX + unlink $temp_index + unset temp_index + fi + unset index_time + fi + + if [ -z "$pd" ]; then + if [ -z "$PORTSDIR" ]; then + pd=`pm_make_b -f/usr/share/mk/bsd.port.mk -V PORTSDIR 2>/dev/null` + else + pd=$PORTSDIR + fi + if [ -z "$pd" ]; then + if [ -n "$PM_INDEX_ONLY" ]; then + pd=`head -1 $PM_INDEX | cut -f 2 -d\|` + pd=${pd%/*} + pd=${pd%/*} + fi + fi + [ -z "$pd" ] && fail 'The value of PORTSDIR cannot be empty' + fi + if [ -z "$pdb" ]; then + if [ -z "$PKG_DBDIR" ]; then + pdb=`pm_make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2>/dev/null` + else + pdb=$PKG_DBDIR + fi + if [ -z "$pdb" ]; then + if [ -d /var/db/pkg ]; then + pdb='/var/db/pkg' + else + fail 'The value of PKG_DBDIR cannot be empty' + fi + fi + fi + if [ -z "$distdir" -a "$PM_PACKAGES" != only ]; then + distdir=`pm_make_b -f/usr/share/mk/bsd.port.mk -V DISTDIR 2>/dev/null` + # In case it is a symlink + distdir="${distdir%/}/" + fi + if [ -z "$port_dbdir" ]; then + port_dbdir=`pm_make_b -f/usr/share/mk/bsd.port.mk -V PORT_DBDIR 2>/dev/null` + [ -z "$port_dbdir" -a -d /var/db/ports ] && port_dbdir='/var/db/ports' + [ -n "$port_dbdir" ] && export port_dbdir + fi + + export pd pdb distdir + if [ -n "$PM_PACKAGES_BUILD" -o -n "$PM_DEL_BUILD_ONLY" ]; then PM_BUILD_ONLY_LIST=pm_bol export PM_BUILD_ONLY_LIST @@ -782,6 +850,30 @@ delete_empty_dist_subdirs () { find -d $distdir -type d \( -empty -and ! -path \*\.zfs/\* \) -delete } +# Takes a pattern as input +# Return values: +# 0 - Matched one and only one directory in $pdb +# 1 - No match +# 2 - Matched multiple directories +# +find_glob_dirs () { + # Global: glob_dirs + local pattern + + pattern=`globstrip $1` + + glob_dirs=`find $pdb -maxdepth 1 -type d -name ${pattern}\*` + case "$glob_dirs" in + # Match a newline in multiple responses from find + *' +'*) return 2 ;; + $pdb/*) return ;; + esac + + unset glob_dirs + return 1 +} + #=============== End functions relevant to --features and main =============== #=============== Begin code relevant only to --features =============== @@ -968,15 +1060,11 @@ while getopts 'BCDFGHKLPRabde:fghilm:nop:r:stuvwx:' COMMAND_LINE_ARGUMENT ; do if [ -d "$pdb/$OPTARG" ]; then glob_dirs=$OPTARG else - port=`globstrip $OPTARG` - glob_dirs=`find $pdb -maxdepth 1 -type d -name ${port}\*` - case "$glob_dirs" in - *\*|'') fail "$pdb/$port does not exist" ;; - # Match a newline in multiple responses from find - *' -'*) fail 'The argument to -r must match only one port' ;; + find_glob_dirs $OPTARG + case $? in + 1) fail "$pdb/$OPTARG does not exist" ;; + 2) fail 'The argument to -r must match only one port' ;; esac - unset port fi portdir=`origin_from_pdb ${glob_dirs##*/}` ; unset glob_dirs ;; s) CLEAN_STALE=sopt ;; @@ -996,20 +1084,44 @@ unset -f packages_init [ -n "$PM_EXCL" ] && export PM_EXCL +test_command_line () { + local var envar + + for var in $my_environment; do + case "$var" in + ${1}=*) envar=$1 ;; + ${2}=*) envar=$2 ;; + esac + done + + if [ -n "$envar" ]; then + unset $envar + return 0 + fi + + return 1 +} + # Error checking for getopts [ -n "$PM_FORCE" -a "$INTERACTIVE_UPDATE" ] && fail "The -f and -i options are mutually exclusive" -[ -n "$BACKUP" -a -n "$NO_BACKUP" ] && - fail "The -b and -B options are mutually exclusive" -[ -n "$ALWAYS_SCRUB_DISTFILES" -a -n "$DONT_SCRUB_DISTFILES" ] && - fail "The -d and -D options are mutually exclusive" +if [ -n "$BACKUP" -a -n "$NO_BACKUP" ]; then + test_command_line NO_BACKUP BACKUP || + fail "The -b and -B options are mutually exclusive" +fi +if [ -n "$ALWAYS_SCRUB_DISTFILES" -a -n "$DONT_SCRUB_DISTFILES" ]; then + test_command_line ALWAYS_SCRUB_DISTFILES DONT_SCRUB_DISTFILES || + fail "The -d and -D options are mutually exclusive" +fi [ -n "$FETCH_ONLY" -a -n "$NO_RECURSIVE_CONFIG" ] && - fail "The -F and -G options are mutually exclusive" + unset NO_RECURSIVE_CONFIG [ -n "$NO_RECURSIVE_CONFIG" -a -n "$PM_PACKAGES_BUILD" ] && fail 'The --packages-build and -G options are mutually exclusive' [ -n "$NO_RECURSIVE_CONFIG" -a -n "$PM_DEL_BUILD_ONLY" ] && fail 'The --delete-build-only and -G options are mutually exclusive' +unset my_environment + #=============== Begin functions for getopts features and main =============== check_state () { @@ -1030,6 +1142,52 @@ check_state () { return 0 } +parse_index () { + local pd line + + [ -z "$pd" -a -n "$PM_INDEX_ONLY" ] && pd=/usr/ports + + line=`grep -m1 .*\|${pd}/${1}\|.* $PM_INDEX` + + case "$2" in + name) echo ${line%%|*} ;; + localbase) echo $line | cut -f 3 -d\| ;; + comment) echo $line | cut -f 4 -d\| ;; + descr) echo $line | cut -f 5 -d\| ;; + maintainer) echo $line | cut -f 6 -d\| ;; + category) echo $line | cut -f 7 -d\| ;; + b-deps) echo $line | cut -f 8 -d\| ;; + r-deps) echo $line | cut -f 9 -d\| ;; + www) echo $line | cut -f 10 -d\| ;; + esac +} + +check_pkg_version () { + local iport port_ver udf + + iport=$1 ; port_ver=$2 ; udf=$3 + + case `pkg_version -t $iport $port_ver` in + \<) return 1 ;; + =) return ;; + \>) if [ -n "$PM_VERBOSE" ]; then + echo " ===>>> Port version $port_ver does not" + echo " ===>>> seem newer than installed $iport" + fi + if [ -n "$PM_FORCE" ]; then + check_restart_and_udf $udf $iport || return 1 + elif [ -n "$URB_YES" ]; then + case "$MASTER_RB_LIST" in *" $iport "*) + if ! check_restart_and_udf $udf $iport; then + return 1 + else + URB_DONE_LIST="${URB_DONE_LIST}${upg_port}:" + fi ;; + esac + fi ;; + esac +} + check_for_updates () { # Global: num_updates local list_only nf iport origin port_ver udf do_update @@ -1051,7 +1209,12 @@ check_for_updates () { return 0 fi - if [ -d "$pd/$origin" ]; then + if [ -n "$PM_INDEX" ]; then + port_ver=`parse_index $origin name` + check_pkg_version $iport $port_ver || { do_update=update_index ; } + fi + + if [ -d "$pd/$origin" -a -z "$do_update" -a -z "$PM_INDEX_ONLY" ]; then if ! pm_cd $pd/$origin; then if [ -e "$pdb/$iport/+IGNOREME" ]; then echo " ===>>> Warning: Unable to cd to $pd/$origin" @@ -1085,36 +1248,15 @@ check_for_updates () { *:${origin}:*) do_update=do_update_mo ;; esac elif [ -n "$LIST_PLUS" ]; then - check_state + [ -z "$PM_INDEX_ONLY" ] && check_state return 0 elif [ -n "$LIST" ]; then return 0 fi else - case `pkg_version -t $iport $port_ver` in - \<) do_update=do_update3 ;; - =) ;; # Should not be reached - \>) if [ -n "$PM_VERBOSE" ]; then - echo " ===>>> Port version $port_ver does not" - echo " ===>>> seem newer than installed $iport" - fi - if [ -n "$PM_FORCE" ]; then - check_restart_and_udf $udf $iport || - do_update=do_update4 - elif [ -n "$URB_YES" ]; then - # Outdent - case "$MASTER_RB_LIST" in *" $iport "*) - if ! check_restart_and_udf $udf $iport; then - do_update=do_update5 - else - URB_DONE_LIST="${URB_DONE_LIST}${upg_port}:" - fi ;; - esac - # Outdent - fi ;; - esac + check_pkg_version $iport $port_ver $udf || do_update=do_update_check fi - else + elif [ -z "$do_update" -a -z "$PM_INDEX_ONLY" ]; then find_moved_port $origin $iport $nf # If the port has moved, we have to update it, otherwise ignore @@ -1129,7 +1271,7 @@ check_for_updates () { echo " ===>>> New version available: $port_ver" [ -e "$pdb/$iport/+IGNOREME" ] && echo " ===>>> +IGNOREME file is present for $1" - check_state + [ -z "$PM_INDEX_ONLY" ] && check_state num_updates=$(( $num_updates + 1 )) else unset moved_npd @@ -1176,8 +1318,7 @@ init_packages () { pbu=$PACKAGES/portmaster-backup if [ ! -d "$pbu" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Creating $pbu" + pm_sv Creating $pbu pm_mkdir_s $pbu fi export pbu @@ -1186,6 +1327,8 @@ init_packages () { pm_pkg_create () { local pkgdir + init_packages + if [ "$1" = "$PACKAGES" ]; then for pkgdir in All Latest ${portdir%/*}; do pm_mkdir_s ${PACKAGES}/${pkgdir} || @@ -1208,13 +1351,17 @@ pm_pkg_create () { NB_DELETE="${NB_DELETE}${pkg} " fi elif [ "$1" = "$PACKAGES" ]; then - local pkg latest_link + local pkg ; pkg=`echo $2.*` + + if [ -z "$PM_INDEX_ONLY" ]; then + local latest_link + + pm_cd_pd $portdir + latest_link=`pm_make -V LATEST_LINK` + cd ${1}/Latest + $PM_SU_CMD ln -sf ../All/$pkg ${latest_link}.tbz + fi - pkg=`echo $2.*` - pm_cd_pd $portdir - latest_link=`pm_make -V LATEST_LINK` - cd ${1}/Latest - $PM_SU_CMD ln -sf ../All/$pkg ${latest_link}.tbz cd ${1}/${portdir%/*} $PM_SU_CMD ln -sf ../All/$pkg $pkg echo " ===>>> Package saved to ${1}/All" ; echo '' @@ -1272,13 +1419,12 @@ delete_dist_list () { local dir - [ -n "$PM_SU_VERBOSE" ] && echo "===>>> Deleting $dist_list" + pm_sv Deleting $dist_list pm_unlink_s $dist_list dir=`find ${dist_list%/distfiles} -type d -empty 2>/dev/null` if [ -d "$dir" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Deleting the $dir directory" + pm_sv Deleting the $dir directory pm_rmdir_s $dir fi } @@ -1532,7 +1678,14 @@ if [ -n "$LIST" -o -n "$LIST_PLUS" ]; then fi if [ -n "$EXPUNGE" ]; then - [ -d "$pdb/$EXPUNGE" ] || fail "No such directory/port: $pdb/$EXPUNGE" + if [ ! -d "$pdb/$EXPUNGE" ]; then + if find_glob_dirs $EXPUNGE; then + EXPUNGE=${glob_dirs#$pdb/} + unset glob_dirs + else + fail "No such directory/port: $pdb/$EXPUNGE" + fi + fi origin=`origin_from_pdb $EXPUNGE` deplist=`grep -l DEPORIGIN:$origin$ $pdb/*/+CONTENTS` @@ -1591,11 +1744,7 @@ if [ -n "$CLEAN_STALE" ]; then echo -n "===>>> ${iport} is no longer depended on, delete? y/n [n] " read answer case "$answer" in - [yY]) if [ -n "$BACKUP" ]; then - [ -z "$PACKAGES" ] && init_packages - pm_pkg_create $pbu $iport - fi - + [yY]) [ -n "$BACKUP" ] && { init_packages ; pm_pkg_create $pbu $iport; } [ -z "$DONT_SCRUB_DISTFILES" ] && delete_all_distfiles $origin @@ -1733,7 +1882,11 @@ update_build_l () { origin=`origin_from_pdb $1` ;; esac - pm_cd $pd/$origin && new_port=`pm_make -V PKGNAME` + if [ -z "$PM_INDEX_ONLY" ]; then + pm_cd $pd/$origin && new_port=`pm_make -V PKGNAME` + else + new_port=`parse_index $origin name` + fi case `pkg_version -t $iport $new_port 2>/dev/null` in \<) build_l="${build_l}\tUpgrade $iport to $new_port\n" ;; @@ -1824,6 +1977,32 @@ clean_build_only_list () { build_only_dl_g=" `uniquify_list $temp_bodlg` " } +gen_dep_list () { + local list + + if [ -z "$PM_INDEX_ONLY" ]; then + pm_cd_pd $portdir + list=`pm_make $* | sort -u` + else + local temp_list l + + case "$*" in + 'build-depends-list run-depends-list'|all-depends-list) + temp_list="`parse_index $portdir b-deps` `parse_index $portdir r-deps`" ;; + build-depends-list) temp_list=`parse_index $portdir b-deps` ;; + run-depends-list) temp_list=`parse_index $portdir r-deps` ;; + esac + + temp_list=`uniquify_list $temp_list` + + for l in $temp_list ; do + list="$list `grep -m1 ^${l}\| $PM_INDEX | cut -f 2 -d \|`" + done + fi + + echo "$list" +} + dependency_check () { # Global: doing_dep_check # Global: run_dl_g build_only_dl_g @@ -1833,8 +2012,7 @@ dependency_check () { # Print a message here because sometimes list generation takes # a long time to return. echo "===>>> Gathering dependency list for $portdir from ports" - pm_cd_pd $portdir - d_port_list=`pm_make $1 | sort -u` + d_port_list=`gen_dep_list $1` if [ -z "$d_port_list" ]; then echo "===>>> No dependencies for $portdir" @@ -1853,11 +2031,11 @@ dependency_check () { if [ "$PM_BUILD_ONLY_LIST" = pmp_doing_build_deps ]; then local rundeps dep varname run_dl build_only_dl - rundeps=`pm_make run-depends-list | sort -u` + rundeps=" `gen_dep_list run-depends-list` " for dep in $d_port_list; do case "$rundeps" in - *${dep}*) + *" ${dep} "*) varname=`echo ${dep#$pd/} | sed 's#[-+/\.]#_#g'` rundep_list="$rundep_list $varname" eval $varname=\"$portdir \$$varname\" @@ -1872,7 +2050,7 @@ dependency_check () { if [ -z "$RECURSE_THOROUGH" ]; then d_port_list="$build_only_dl $run_dl" else - build_only_dl=`pm_make build-depends-list | sort -u` + build_only_dl=`gen_dep_list build-depends-list` fi run_dl_g="$run_dl_g $run_dl " @@ -1913,24 +2091,26 @@ dependency_check () { [ -z "$URB_YES" ] && case "$CUR_DEPS" in *:${origin}:*) continue ;; esac - conflicts='' - if pm_cd $d_port; then - grep -ql ^CONFLICTS Makefile && - conflicts=`pm_make_b -V CONFLICTS` - else - fail "Cannot cd to $d_port" - fi - for glob in $conflicts; do - confl_p=`pkg_info -I $glob 2>/dev/null` - if [ -n "$confl_p" ]; then - confl_p=${confl_p%% *} - echo '' - echo "===>>> The dependency for ${origin}" - echo " seems to be handled by $confl_p" - echo '' - d_port="$pd/`origin_from_pdb $confl_p`" + if [ -z "$PM_INDEX_ONLY" ]; then + conflicts='' + if pm_cd $d_port; then + grep -ql ^CONFLICTS Makefile && + conflicts=`pm_make_b -V CONFLICTS` + else + fail "Cannot cd to $d_port" fi - done + for glob in $conflicts; do + confl_p=`pkg_info -I $glob 2>/dev/null` + if [ -n "$confl_p" ]; then + confl_p=${confl_p%% *} + echo '' + echo "===>>> The dependency for ${origin}" + echo " seems to be handled by $confl_p" + echo '' + d_port="$pd/`origin_from_pdb $confl_p`" + fi + done + fi # In case d_port changed above origin="${d_port#$pd/}" ; iport=`iport_from_origin ${origin}` @@ -2106,16 +2286,15 @@ multiport () { *) if [ -d "$pdb/$port" ]; then worklist_temp="$worklist_temp $port" else - # Keep synched with code in MAIN - local glob_dirs dir - port=`globstrip $port` - glob_dirs=`find $pdb -maxdepth 1 -type d -name ${port}\*` - case "$glob_dirs" in - *\*|'') fail "$pdb/$port does not exist" ;; - *) for dir in $glob_dirs; do - worklist_temp="$worklist_temp ${dir#$pdb/}" + find_glob_dirs $port + case $? in + 1) fail "$pdb/$port does not exist" ;; + *) local dir + for dir in $glob_dirs; do + worklist_temp="$worklist_temp ${dir#$pdb/}" done ;; esac + unset glob_dirs fi ;; esac done @@ -2184,8 +2363,7 @@ multiport () { make_config () { config_type=config-conditional [ -n "$FORCE_CONFIG" ] && config_type=config - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Running 'make $config_type'" + pm_sv Running \'make $config_type\' pm_cd_pd $portdir pm_make_s $config_type } @@ -2199,10 +2377,22 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$SHOW_WORK" ]; then PM_DEPTH='' ; IPC_SAVE=`pm_mktemp IPC_SAVE` export CUR_DEPS DISPLAY_LIST INSTALLED_LIST PM_DEPTH IPC_SAVE - PORTS_LOCALBASE=`pm_make_b -f/usr/share/mk/bsd.port.mk -V LOCALBASE` - [ -n "$PORTS_LOCALBASE" ] || - fail 'The value of LOCALBASE cannot be empty' - LOCALBASE_COMPAT="$PORTS_LOCALBASE/lib/compat" + if [ -n "$LOCALBASE" ]; then + LOCALBASE_COMPAT="$LOCALBASE/lib/compat" + else + PLB=`pm_make_b -f/usr/share/mk/bsd.port.mk -V LOCALBASE 2>/dev/null` + if [ -n "$PLB" ]; then + LOCALBASE_COMPAT="$PLB/lib/compat" + else + PLB=`head -1 $PM_INDEX | cut -f 3 -d\|` + if [ -d "$PLB" ]; then + LOCALBASE_COMPAT="${PLB}/lib/compat" + else + fail 'The value of LOCALBASE cannot be empty' + fi + fi + unset PLB + fi export LOCALBASE_COMPAT if [ -n "$INTERACTIVE_UPDATE" ]; then @@ -2220,10 +2410,9 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$SHOW_WORK" ]; then echo -n " -[rf] run of ${0##*/}, delete them? y/n [n] " read answer case "$answer" in - [yY]) [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Deleting 'install complete' flags" - pm_find_s $pdb -type f -name PM_UPGRADE_DONE_FLAG -delete ;; - *) echo -n "===>>> Enable the -R option? y/n [n] " + [yY]) pm_sv Deleting \'install complete\' flags + pm_find_s $pdb -type f -name PM_UPGRADE_DONE_FLAG -delete ;; + *) echo -n "===>>> Enable the -R option? y/n [n] " read answer case "$answer" in [yY]) RESTART=Ropt ; ARGS="-R $ARGS" ;; @@ -2248,8 +2437,16 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$SHOW_WORK" ]; then fi fi - [ -n "$NO_BACKUP" -a -z "$MAKE_PACKAGE" ] || init_packages + [ -z "$NO_BACKUP" ] && init_packages [ -z "$NO_BACKUP" -a -z "$BACKUP" ] && export NB_DELETE + if [ -n "$MAKE_PACKAGE" ]; then + init_packages_var + + if [ ! -d "$PACKAGES" ]; then + pm_sv Creating $PACKAGES + pm_mkdir_s $PACKAGES + fi + fi # Set the file name here so it's visible to the children if [ -z "$DONT_SCRUB_DISTFILES" -a -z "$FETCH_ONLY" \ @@ -2389,40 +2586,47 @@ if [ -z "$REPLACE_ORIGIN" ]; then esac if [ -z "$portdir" -a -z "$upg_port" ]; then - # Keep synched with code in multiport() - glob_dirs=`find $pdb -maxdepth 1 -type d -name ${argv}\*` - case "$glob_dirs" in - *\*|'') echo '' ; no_valid_port ;; - # Match a newline in multiple responses from find - *' -'*) multiport $glob_dirs ;; - $pdb/*) upg_port=${glob_dirs#$pdb/} ;; - *) echo '' ; no_valid_port ;; + find_glob_dirs $argv + case $? in + 1) echo '' ; no_valid_port ;; + 2) multiport $glob_dirs ;; + 0) upg_port=${glob_dirs#$pdb/} ;; esac + unset glob_dirs fi else portdir="${1#$pd/}" ; portdir="${portdir%/}" [ -d "$pd/$portdir" ] || { echo '' - echo "===>>> The first argument must be a directory in $pd" + echo "===>>> The first argument to -o must be a directory in $pd" echo '' ; no_valid_port; } - upg_port=${2#$pdb/} ; upg_port="${upg_port%/}" - if [ -d "$pdb/$upg_port" ]; then - ro_opd=`origin_from_pdb $upg_port` # Old port directory - else - ro_opd=${upg_port#$pd/} # Portupgrade syntax - upg_port=`iport_from_origin $ro_opd` - if [ -z "$upg_port" -o ! -d "$pdb/$upg_port" ]; then - if grep -ql "DEPORIGIN:$ro_opd$" $pdb/*/+CONTENTS; then - unset upg_port + + arg2=${2#$pd/} ; arg2=${arg2#$pdb/} ; arg2=${arg2%/} + + case "$arg2" in + */*) ro_opd=$arg2 ; upg_port=`iport_from_origin $ro_opd` ;; + *) if [ -d "$pdb/$arg2" ]; then + upg_port=$arg2 + else + find_glob_dirs $arg2 && upg_port=${glob_dirs#$pdb/} + unset glob_dirs + fi + [ -n "$upg_port" ] && ro_opd=`origin_from_pdb $upg_port` + esac + unset arg2 + + if [ -z "$upg_port" ]; then + if grep -ql "DEPORIGIN:$ro_opd$" $pdb/*/+CONTENTS; then + unset upg_port PM_MAKE_ARGS="-DFORCE_PKG_REGISTER $PM_MAKE_ARGS" - else - echo '' - echo "===>>> The second argument can be a port in $pdb," - echo " or a port directory from $pd" - echo '' ; no_valid_port - fi + else + echo '' + echo "===>>> The second argument to -o can be a port in $pdb," + echo " or a port directory from $pd" + echo '' ; no_valid_port fi fi + + PM_MAKE_ARGS="-DDISABLE_CONFLICTS $PM_MAKE_ARGS" fi if [ -n "$upg_port" -a -z "$REPLACE_ORIGIN" ]; then @@ -2439,7 +2643,7 @@ elif [ -z "$portdir" ]; then no_valid_port fi -if [ ! -d "$pd/$portdir" ]; then +if [ ! -d "$pd/$portdir" -a -z "$PM_INDEX_ONLY" ]; then find_moved_port $portdir $upg_port || no_valid_port [ -n "$moved_npd" ] || no_valid_port [ -d "$pd/$moved_npd" ] || no_valid_port @@ -2502,7 +2706,7 @@ fi # Should only be reached for multiport already built as a dependency case "$CONFIG_SEEN_LIST" in *:${portdir}:*) safe_exit ;; esac -pm_cd $pd/$portdir || no_valid_port +[ -z "$PM_INDEX_ONLY" ] && { pm_cd $pd/$portdir || no_valid_port; } if [ -z "$PM_DEPTH" ]; then PM_DEPTH="${upg_port:-$portdir} " @@ -2522,6 +2726,8 @@ fi echo '' [ "$$" -eq "$PM_PARENT_PID" -a -n "$upg_port" ] && echo "===>>> Currently installed version: $upg_port" + +if [ -z "$PM_INDEX_ONLY" ]; then echo "===>>> Port directory: $pd/$portdir" check_state || { @@ -2589,6 +2795,7 @@ dofetch () { echo '' fi fi +fi # [ -z "$PM_INDEX_ONLY" ] if [ -n "$CONFIG_ONLY" ]; then [ "$$" -eq "$PM_PARENT_PID" -a -n "$PM_BUILD_ONLY_LIST" ] && @@ -2663,7 +2870,7 @@ fi [ -z "$PM_BUILDING" ] && export PM_BUILDING=pmbuildingmain -pm_cd_pd $portdir +[ -z "$PM_INDEX_ONLY" ] && pm_cd_pd $portdir if [ -n "$PM_BUILD_ONLY_LIST" ]; then case "$build_only_dl_g" in @@ -2685,7 +2892,7 @@ if [ -z "$NO_DEP_UPDATES" ]; then echo "===>>> Starting check for all dependencies" dependency_check all-depends-list fi - cd $pd/$portdir + [ -z "$PM_INDEX_ONLY" ] && pm_cd_pd $portdir elif [ -z "$NO_RECURSIVE_CONFIG" -a "$$" -eq "$PM_PARENT_PID" ]; then echo "===>>> All dependencies are up to date" echo '' @@ -2696,7 +2903,13 @@ if [ -n "$NO_ACTION" -a -z "$CONFIG_ONLY" ]; then safe_exit fi -[ -z "$new_port" ] && new_port=`pm_make -V PKGNAME` +if [ -z "$new_port" ]; then + if [ -z "$PM_INDEX_ONLY" ]; then + new_port=`pm_make -V PKGNAME` + else + new_port=`parse_index $portdir name` + fi +fi if [ -n "$PM_PACKAGES" -o "$PM_PACKAGES_BUILD" = doing_build_only_dep ]; then fetch_package () { @@ -2709,7 +2922,7 @@ fetch_package () { fi if [ ! -d "$ppd" ]; then - [ -n "$PM_SU_VERBOSE" ] && echo "===>>> Creating $ppd" + pm_sv Creating $ppd pm_mkdir_s $ppd fi @@ -2740,7 +2953,7 @@ fetch_package () { fi fi - [ -n "$PM_SU_VERBOSE" ] && echo "===>>> Fetching ${1}.tbz" + pm_sv Fetching ${1}.tbz $PM_SU_CMD fetch $FETCH_ARGS -o $ppd ${sitepath}${1}.tbz 2>/dev/null || { pm_unlink_s ${ppd}/${1}.tbz; $PM_SU_CMD fetch $FETCH_ARGS -o $ppd ${sitepath}${1}.tbz 2>/dev/null; } @@ -2774,14 +2987,21 @@ fetch_package () { echo "===>>> Checking package repository for latest available version" if [ -n "$LOCAL_PACKAGEDIR" ]; then - s=`pm_make -V LATEST_LINK` - if [ -r "${LOCAL_PACKAGEDIR}/Latest/${s}.tbz" ]; then - local_package=${LOCAL_PACKAGEDIR}/Latest/${s}.tbz - latest_pv=`readlink ${LOCAL_PACKAGEDIR}/Latest/${s}.tbz` - latest_pv=${latest_pv##*/} + if [ -z "$PM_INDEX_ONLY" ]; then + s=`pm_make -V LATEST_LINK` + if [ -r "${LOCAL_PACKAGEDIR}/Latest/${s}.tbz" ]; then + local_package=${LOCAL_PACKAGEDIR}/Latest/${s}.tbz + latest_pv=`readlink ${LOCAL_PACKAGEDIR}/Latest/${s}.tbz` + latest_pv=${latest_pv##*/} + else + [ -n "$PM_VERBOSE" ] && + echo "===>>> No local package for $new_port exists, attempting fetch" + fi else - [ -n "$PM_VERBOSE" ] && - echo "===>>> No local package for $new_port exists, attempting fetch" + if [ -r "${LOCAL_PACKAGEDIR}/All/${new_port}.tbz" ]; then + local_package=${LOCAL_PACKAGEDIR}/All/${new_port}.tbz + latest_pv=${local_package##*/} + fi fi fi @@ -2958,13 +3178,11 @@ if [ -n "$upg_port" ]; then done if [ -n "$temp" ]; then if [ ! -d "$LOCALBASE_COMPAT/pkg" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Creating $LOCALBASE_COMPAT/pkg for -w" + pm_sv Creating $LOCALBASE_COMPAT/pkg for -w pm_mkdir_s $LOCALBASE_COMPAT/pkg fi - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Copying old shared libraries for -w" + pm_sv Copying old shared libraries for -w $PM_SU_CMD cp -p $temp $LOCALBASE_COMPAT/pkg/ fi @@ -2978,22 +3196,20 @@ if [ -n "$upg_port" ]; then # Delete any existing versions of the new port iport=`iport_from_origin $portdir` if [ -n "$iport" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Running pkg_delete for $iport" + pm_sv Running pkg_delete for $iport pm_pkg_delete_s -f $iport fi fi - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Running pkg_delete for $upg_port" + pm_sv Running pkg_delete for $upg_port pm_pkg_delete_s -f $upg_port - cd $pd/$portdir + [ -z "$PM_INDEX_ONLY" ] && pm_cd_pd $portdir fi if [ -z "$RECURSE_THOROUGH" -a -z "$NO_DEP_UPDATES" ]; then echo '' ; echo "===>>> Starting check for runtime dependencies" dependency_check run-depends-list - cd $pd/$portdir + [ -z "$PM_INDEX_ONLY" ] && pm_cd_pd $portdir fi install_failed () { @@ -3006,7 +3222,7 @@ install_failed () { } if [ -z "$use_package" ]; then - [ -n "$PM_SU_VERBOSE" ] && echo "===>>> Running make install" + pm_sv Running make install if [ -n "$PM_SU_UNSET_PORT_LOG_ARGS" ]; then unset port_log_args @@ -3047,8 +3263,7 @@ if [ -z "$temp" -a -d "$LOCALBASE_COMPAT/pkg" ]; then done if [ -n "$files" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Removing old shared libraries, and running ldconfig" + pm_sv Removing old shared libraries, and running ldconfig pm_rm_s $files $PM_SU_CMD /etc/rc.d/ldconfig start > /dev/null fi @@ -3057,8 +3272,7 @@ fi [ -z "$temp" ] && temp=`find $LOCALBASE_COMPAT/pkg -type d -empty 2>/dev/null` if [ -d "$temp" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Deleting the empty $LOCALBASE_COMPAT/pkg" + pm_sv Deleting the empty $LOCALBASE_COMPAT/pkg pm_rmdir_s $temp fi unset temp @@ -3074,8 +3288,7 @@ if [ -n "$distfiles" ]; then dist_list=`pm_make_b -V OPTIONSFILE` dist_list="${dist_list%options}distfiles" if [ ! -d "${dist_list%/distfiles}" ]; then - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Creating ${dist_list%/distfiles}" + pm_sv Creating ${dist_list%/distfiles} pm_mkdir_s ${dist_list%/distfiles} fi @@ -3101,8 +3314,7 @@ if [ -n "$distfiles" ]; then echo "${ds}$file" >> $DI_FILES done - [ -n "$PM_SU_VERBOSE" ] && - echo "===>>> Installing $dist_list" + pm_sv Installing $dist_list pm_install_s $dist_list_temp $dist_list pm_unlink $dist_list_temp ; unset ds dist_list_temp fi @@ -3128,7 +3340,8 @@ fi if [ -z "$use_package" ]; then [ -z "$DONT_POST_CLEAN" ] && { - pm_make clean NOCLEANDEPENDS=ncd2 ; echo ''; } + pm_sv Running \'make clean\' + pm_make_s clean NOCLEANDEPENDS=ncd2 ; echo ''; } fi check_dependency_files $portdir $new_port |