svn commit: r198220 - in user/dougb: . portmaster

Doug Barton dougb at FreeBSD.org
Sun Oct 18 23:15:25 UTC 2009


Author: dougb
Date: Sun Oct 18 23:15:25 2009
New Revision: 198220
URL: http://svn.freebsd.org/changeset/base/198220

Log:
  Add a user area for portmaster so that everyone can see the work that
  is being done as part of the funding project.
  
  Add the portmaster script version 2.12 directly from the ports tree
  with the exception that %%LOCALBASE%% has been substituted with
  /usr/local so that this development version can be used directly
  by most users.
  
  Add the man page version 2.10 directly from ports.
  
  Sponsored by:	http://dougbarton.us/portmaster-proposal.html
  Funded by:	JAN HORNYAK
  Funded by:	Christer Solskogen
  Funded by:	R Koole

Added:
  user/dougb/
  user/dougb/portmaster/
  user/dougb/portmaster/portmaster   (contents, props changed)
  user/dougb/portmaster/portmaster.8   (contents, props changed)

Added: user/dougb/portmaster/portmaster
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/dougb/portmaster/portmaster	Sun Oct 18 23:15:25 2009	(r198220)
@@ -0,0 +1,2543 @@
+#!/bin/sh
+
+# Copyright (c) 2005-2009 Douglas Barton, All rights reserved
+# Please see detailed copyright below
+
+trap trap_exit INT
+
+# Initialize crucial values for the parent, and export them for the children
+if [ -z "$PM_PARENT_PID" ]; then
+	PM_PARENT_PID=$$
+	: ${TMPDIR:=/tmp}
+	UPGRADE_TOOL=portmaster
+
+	# /usr/local is needed in the path for make
+	PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
+	[ -e /usr/X11R6 -a ! -L /usr/X11R6 ] && PATH=$PATH:/usr/X11R6/bin
+	if [ -n "$CCACHE_PATH" ]; then
+		if [ -z "$NOCCACHE" ]; then
+			PATH="/usr/local/libexec/ccache:$PATH"
+		fi
+	fi
+	export PM_PARENT_PID TMPDIR UPGRADE_TOOL PATH
+
+	set -o allexport
+	# Read a global rc file first
+	[ -r /etc/portmaster.rc ] && . /etc/portmaster.rc
+	[ -r /usr/local/etc/portmaster.rc ] && . /usr/local/etc/portmaster.rc
+
+	# Read a local one next, and allow the command line to override
+	[ -r "$HOME/.portmasterrc" ] && . $HOME/.portmasterrc
+	set +o allexport
+
+	# If we are already root, unset this to avoid potential conflict
+	euid=`ps -o uid $$` ; euid=${euid##* }
+	[ "$euid" -eq 0 ] && unset PM_SU_CMD
+fi
+
+umask 022
+
+#=============== Begin functions we always want to have ===============
+
+version () {
+	local rcs cvs
+
+	rcs='$Id: portmaster,v 2.54 2009/09/15 07:50:11 dougb Exp $'
+	cvs='$FreeBSD$'
+
+	rcs="${rcs#*,v }" ; rcs="${rcs%% *}"
+	cvs="${cvs#*,v }" ; cvs="${cvs%% *}"
+
+	echo ''
+	[ "${cvs#$}" != 'FreeBSD$' ] &&
+		{ echo "===>>> FreeBSD version $cvs" ; return 0; }
+	echo "===>>> Development version $rcs"
+}
+
+fail () {
+	echo '' ; echo "===>>> $1" ; echo "===>>> Aborting update"
+	[ "$$" -eq "$PM_PARENT_PID" ] && trap_exit fail
+	safe_exit 1
+}
+
+trap_exit () {
+	TRAP=trap
+
+	echo ''		# Helps if the previous message was 'echo -n'
+	if [ -n "$portdir" -a -z "$1" ]; then
+		echo "===>>> Build/Install for $portdir exiting due to signal"
+	elif [ -z "$1" ]; then
+		echo "===>>> Exiting due to signal"
+	fi
+
+	if [ "$$" -eq "$PM_PARENT_PID" ]; then
+		local n=0
+		while ps -axo pid,ppid,command | grep -v egrep | egrep -q "(make -DBATCH checksum|/fetch |\[sh\])"; do
+			# Protect from infinite loop if there is another fetch
+			[ $n -gt 9 ] && break
+			n=$(( $n + 1 ))
+			kill_bad_children
+		done
+		if [ -n "$HIDE_BUILD" ]; then
+			local logs file
+			logs=`echo ${TMPDIR}/port_log-${PM_PARENT_PID}-*`
+			case "$logs" in *\*) unset logs ;; esac
+			if [ -n "$logs" ]; then
+				echo ''
+				echo "===>>> Build/Install logs available:"
+				for file in $logs; do
+					echo "	$file"
+				done
+			fi
+			[ -n "$logs" ] && echo ''
+		fi
+	fi
+	safe_exit 1
+}
+
+kill_bad_children () {
+	local mypgid pid ppid pgid command ; IFS=' '
+
+	mypgid=`ps -o pgid -p $PM_PARENT_PID` ; mypgid=${mypgid##*PGID[^0-9]}
+
+	ps -axo pid,ppid,pgid,command | sed '1d' |
+	    while read pid ppid pgid command; do
+		[ "$pid" -gt 25 ] || continue
+		case "$ppid" in
+		1)	case "$command" in
+			*" $0 "*) pm_kill $pid ;;
+			*'make -DBATCH checksum'*|*'/fetch '*|\[sh\])
+				pm_kill -9 $pid ;;
+			esac
+			;;
+		*)	[ $pgid -eq $mypgid ] || continue
+			case "$command" in
+			*" $0 "*) [ $pid -ne $PM_PARENT_PID ] && pm_kill $pid ;;
+			*'make -DBATCH checksum'*|*'/fetch '*|\[sh\])
+				pm_kill $pid ;;
+			esac
+			;;
+		esac
+	done
+}
+
+safe_exit () {
+	local files p f show_list
+
+	if [ "$$" -eq "$PM_PARENT_PID" ]; then
+		if [ -s "$DI_FILES" ]; then
+			grep -q '%%%%%%%%%%%%' $DI_FILES || kill_bad_children
+		fi
+		[ -n "$FETCH_ONLY" -a -z "$FETCH_ONLY_DONE" ] &&
+			kill_bad_children
+
+		if [ -z "$TRAP" ]; then
+			if [ -n "$UPDATE_REQ_BYS" -o -n "$PM_FORCE" ]; then
+	# Outdent
+	[ -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_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_cd $pbu || fail "Cannot cd to $pbu"
+				pm_rm_s $NB_DELETE
+			fi
+		fi
+
+		[ -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_rmdir_s $pbu
+		fi
+
+		for f in ${TMPDIR}/f-${PM_PARENT_PID}-*; do pm_unlink $f ; done
+
+		case "$DISPLAY_LIST" in
+		*' '*)	if [ -n "$TRAP" ]; then
+	echo "===>>> There are messages from installed ports to display,"
+	echo "       but first take a moment to review the error messages"
+	echo -n "       above.  Then press Enter when ready to proceed. "
+				read DISCARD
+				echo ''
+			fi
+
+			[ -n "$PAGER" ] && p=$PAGER || p='less -e'
+			( for f in $DISPLAY_LIST; do
+				echo "===>>> pkg-message for $f"
+					cat $pdb/$f/+DISPLAY
+					echo ''
+				done
+			echo "===>>> Done displaying pkg-message files" ) | $p
+			;;
+		esac
+
+		if [ -n "$UPDATE_ALL" -a -n "$INSTALLED_LIST" ]; then
+			show_list=all
+		else
+			case "$INSTALLED_LIST" in
+			*\\n\\t*)	show_list=all ;;
+			*\\n)		show_list=one ;;
+			esac
+		fi
+		case "$show_list" in
+		all)	echo "===>>> The following actions were performed:"
+			echo -e $INSTALLED_LIST ;;
+		one)	echo "===>>> $ilist complete" ; echo '' ;;
+		esac
+	else
+		[ -n "$grep_deps" ] && pm_unlink $grep_deps
+
+		# Save state for the parent process to read back in
+		echo "CUR_DEPS='$CUR_DEPS'" >> $IPC_SAVE
+		if [ -z "$CONFIG_ONLY" ]; then
+			echo "DISPLAY_LIST='$DISPLAY_LIST'" >> $IPC_SAVE
+			echo "INSTALLED_LIST='$INSTALLED_LIST'" >> $IPC_SAVE
+		elif [ -z "$NO_DEP_UPDATES" ]; then
+			echo 'unset NO_DEP_UPDATES' >> $IPC_SAVE
+		fi
+		[ -z "$NO_BACKUP" -a -z "$BACKUP" ] &&
+			echo "NB_DELETE='$NB_DELETE'" >> $IPC_SAVE
+		[ -n "$PM_MULTI_BUILT" ] &&
+			echo "PM_MULTI_BUILT='$PM_MULTI_BUILT'" >> $IPC_SAVE
+		if [ -n "$INTERACTIVE_UPDATE" ]; then
+			echo "INTERACTIVE_YES='$INTERACTIVE_YES'" >> $IPC_SAVE
+			echo "INTERACTIVE_NO='$INTERACTIVE_NO'" >> $IPC_SAVE
+		fi
+		[ -n "$URB_YES" ] &&
+			echo "URB_DONE_LIST='$URB_DONE_LIST'" >> $IPC_SAVE
+	fi
+
+	exit ${1:-0}
+}
+
+usage () {
+	version
+	echo ''
+	echo 'Usage:'
+	echo "Common flags: [--force-config] [-CGHKgntvw B|b f|i D|d]"
+	echo "    [-m <arguments for make>]"
+	echo "    [-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>"
+	echo "${0##*/} [Common flags] <glob pattern of directories in $pdb>"
+	echo "${0##*/} [Common flags] Multiple full names/paths from $pdb|$pd"
+	echo "                          and/or multiple globs from $pdb"
+	echo ''
+	echo "${0##*/} [Common flags] -p <port directory in $pd>"
+	echo "${0##*/} [Common flags] . [Use in $pd/foo/bar to build that port]"
+	echo ''
+	echo "${0##*/} --show-work [-Gv] [-m <args>] <single port, as above>"
+	echo ''
+	echo "${0##*/} [Common flags] -o <new port dir in $pd> <installed port>"
+	echo "${0##*/} [Common flags] [-R] -r <name/glob of port directory in $pdb>"
+	echo ''
+	echo "${0##*/} [Common flags] -a"
+	echo ''
+	echo "${0##*/} -[l|L]"
+	echo ''
+	echo "${0##*/} [-b D|d] -e <full name of port directory in $pdb>"
+	echo "${0##*/} [-b D|d] -s"
+	echo ''
+	echo "${0##*/} [--force-config] [-aftv] -F"
+	echo ''
+	echo "${0##*/} --clean-distfiles"
+	echo "${0##*/} --clean-distfiles-all"
+	echo ''
+	echo "${0##*/} --check-depends"
+	echo ''
+	echo "${0##*/} --check-port-dbdir [-v]"
+	echo ''
+	echo "${0##*/} --list-origins"
+	echo ''
+	echo "${0##*/} -h|--help"
+	echo "${0##*/} --version"
+	echo ''
+	echo "--force-config 'make config' for all ports (must be first option)"
+	echo "-C prevents 'make clean' from being run before building"
+	echo "-G prevents recursive 'make config' (overrides --force-config)"
+	echo "-H hide details of the port build and install in a log file"
+	echo "-K prevents 'make clean' from being run after building"
+	echo '-B prevents creation of the backup package for the installed port'
+	echo '-b create and keep a backup package of an installed port'
+	echo '-g create a package of the new port'
+	echo '-n run through configure, but do not make or install any ports'
+	echo '-t recurse dependencies thoroughly, using all-depends-list'
+	echo '-v verbose output'
+	echo '-w save old shared libraries before deinstall'
+	echo "-u DEPRECATED"
+	echo '[-R] -f always rebuild ports (overrides -i)'
+	echo '-i interactive update -- ask whether to rebuild ports'
+	echo '-D no cleaning of distfiles'
+	echo '-d always clean distfiles'
+	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 '--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 '-a check all ports, update as necessary'
+	echo ''
+	echo '-l list installed ports by category'
+	echo '-L list installed ports by category, and search for updates'
+	echo ''
+	echo '-e expunge a port via pkg_delete, and remove its distfiles'
+	echo '-s clean out stale ports that used to be depended on'
+	echo ''
+	echo '[--force-config] [-aftv] -F fetch distfiles only (mutually exclusive of -G)'
+	echo ''
+	echo '--clean-distfiles offer to delete stale distfiles'
+	echo '--clean-distfiles-all delete stale distfiles without prompting'
+	echo ''
+	echo '--check-depends cross-check and update dependency information for all ports'
+	echo ''
+	echo "--check-port-dbdir check for stale entries in $port_dbdir"
+	echo ''
+	echo "--list-origins list directories from $pd for root and leaf ports"
+	echo ''
+	echo '-h|--help display this help message'
+	echo '--version display the version number'
+	echo ''
+	echo 'Please see the portmaster(8) man page for more information'
+	safe_exit ${1:-1}
+}
+
+pm_cd     () { builtin cd $1 2>/dev/null || return 1; }
+pm_kill   () { /bin/kill $* >/dev/null 2>/dev/null; }
+pm_make   () { ( unset -v CUR_DEPS INSTALLED_LIST PM_DEPTH;
+		 unset -v MASTER_RB_LIST CONFIG_SEEN_LIST;
+		 /usr/bin/make $PM_MAKE_ARGS $*; ); }
+pm_make_b () { /usr/bin/make $PM_MAKE_ARGS BEFOREPORTMK=bpm $*; }
+pm_mktemp () { /usr/bin/mktemp -t f-${PM_PARENT_PID}-$1; }
+pm_unlink () { /bin/test -e $1 && /bin/unlink $1; }
+
+# Superuser versions for commands that need root privileges
+#
+# The following are used once, so they have $PM_SU_CMD in line:
+# truncate, pkg_create, cp, /etc/rc.d/ldconfig, touch
+
+pm_find_s         () { $PM_SU_CMD /usr/bin/find $*; }
+pm_install_s      () { $PM_SU_CMD /usr/bin/install -o root \
+			-g wheel -m 644 $1 $2; }
+pm_make_s         () { ( unset -v CUR_DEPS INSTALLED_LIST PM_DEPTH;
+			 unset -v MASTER_RB_LIST CONFIG_SEEN_LIST;
+			 $PM_SU_CMD /usr/bin/make $PM_MAKE_ARGS $*; ); }
+pm_mkdir_s        () { $PM_SU_CMD /bin/mkdir -p $1; }
+pm_pkg_delete_s   () { $PM_SU_CMD /usr/sbin/pkg_delete $*; }
+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 ===============
+
+# 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
+
+case "$1" in
+--help)			usage 0 ;;
+--version)		version ; exit 0 ;;
+--clean-distfiles)	CLEAN_DISTFILES=clean_distfiles ;;
+--clean-distfiles-all)	CLEAN_DISTFILES=clean_distfiles_all ; ALL=cda ;;
+--check-depends)	CHECK_DEPENDS=check_depends ;;
+--check-port-dbdir)	CHECK_PORT_DBDIR=check_port_dbdir ;;
+--list-origins)		LIST_ORIGINS=list_origins ;;
+--show-work)		SHOW_WORK=show ; RECURSE_THOROUGH=thorough ; shift ;;
+--force-config)		export FORCE_CONFIG=force_config ; shift ;;
+--*)			echo "Illegal option $1" ; echo ''
+			echo "===>>> Try ${0##*/} --help"; exit 1 ;;
+esac
+
+#=============== Begin functions relevant to --features and main ===============
+
+iport_from_origin () {
+	local dir
+	dir=`grep -l "@comment ORIGIN:${1}$" $pdb/*/+CONTENTS`
+
+	# It should not happen that more than one port meets this
+	# requirement, but it can if the pkg data is corrupted.
+	dir="${dir%%/+CONTENTS*}"
+	echo ${dir#$pdb/}
+}
+
+origin_from_pdb () {
+	local o
+	o=`grep '@comment ORIGIN:' $pdb/$1/+CONTENTS 2>/dev/null`
+	echo ${o#@comment ORIGIN:}
+}
+
+check_regular_file () {
+	[ ! -L "$1" -a -f "$1" ] || fail "ERROR: $1 is not a regular file!"
+}
+
+check_dependency_files () {
+	# Global: grep_deps
+	local origin iport ro_opd
+
+	origin=$1 ; iport=$2
+
+	# egrep hates + in file names
+	case "$origin" in *+*)
+		origin=`echo $origin | sed 's#\+#\\\\+#g'` ;; esac
+	case "$ro_opd" in
+	'')	ro_opd=a/a ;;
+	*+*)	ro_opd=`echo $ro_opd | sed 's#\+#\\\\+#g'` ;; esac
+
+	# Always rely on the grep'ed dependencies instead of +REQUIRED_BY
+	grep_deps=`pm_mktemp grep-deps-${iport}`
+	egrep -l "DEPORIGIN:($origin|$ro_opd)$" $pdb/*/+CONTENTS |
+	    cut -f 5 -d '/' | sort -u > $grep_deps
+
+	if [ ! -s "$grep_deps" ]; then
+		if [ -s "$pdb/$iport/+REQUIRED_BY" ]; then
+			# No actual dependencies exist, so this file is stale
+			# Zero it out so that -s mode can find it
+# Outdent
+if [ -n "$PM_VERBOSE" -o -n "$CHECK_DEPENDS" ]; then
+	echo "	===>>> No installed ports depend on $iport"
+	echo "	===>>> Emptying +REQUIRED_BY file.  Try ${0##*/} -s"
+fi
+# Outdent
+			check_regular_file $pdb/$iport/+REQUIRED_BY
+			$PM_SU_CMD truncate -s0 $pdb/$iport/+REQUIRED_BY
+		fi
+	fi
+	return 0
+}
+
+update_contents () {
+	local IFS delete contents origin n_port old_origin iport new_cont
+	local o_seen line d_missing d_origin d_iport prev_line answer
+
+# To prevent words in a line being treated individually
+IFS='
+'
+	[ "$1" = 'delete' ] && { delete=delete ; shift; }
+
+	contents=$1 ; origin=$2 ; n_port=$3 ; old_origin=$4
+	iport=${contents#$pdb/} ; iport=${iport%/+CONTENTS}
+	new_cont=`pm_mktemp contents-${iport}`
+
+	if [ -z "$delete" ]; then o_seen=':'; else o_seen=":${origin}:"; fi
+
+	for line in `cat $contents`; do
+		if [ -n "$d_missing" ]; then
+			unset d_missing
+			d_origin=${line#*DEPORIGIN:}
+
+			case "$o_seen" in *:${d_origin}:*)
+				unset prev_line line ; continue ;; esac
+			o_seen="${o_seen}${d_origin}:"
+
+			if [ "$d_origin" = "$old_origin" ]; then
+				d_iport=$n_port
+				d_origin=$origin
+			else
+				d_iport=`iport_from_origin $d_origin`
+			fi
+
+			if [ -n "$d_iport" ]; then
+				[ -n "$PM_VERBOSE" -o -n "$CHECK_DEPENDS" ] &&
+			echo "	===>>> Updating @pkgdep for $d_origin"
+			else
+			echo "	===>>> $d_origin is listed as a dependency"
+			echo "	===>>> but there is no installed version"
+			echo ''
+				if [ -n "$CHECK_DEPENDS" ]; then
+		echo -n "	===>>> Delete this dependency data? [n] "
+					read answer
+					case "$answer" in
+					[yY]) unset prev_line line ; continue ;;
+					esac
+				else
+				echo "	===>>> Try ${0##*/} --check-depends"
+				fi
+			fi
+
+			# Could be fixed or not, but if we get here write it
+			# so we can warn the user again later if we need to.
+			echo "@pkgdep $d_iport" >> $new_cont
+			echo "@comment DEPORIGIN:$d_origin" >> $new_cont
+			unset prev_line
+			continue
+		fi
+		case "$line" in
+		"@comment DEPORIGIN:$origin"|"@comment DEPORIGIN:$old_origin")
+			d_origin=${line#*DEPORIGIN:}
+			unset prev_line line
+
+			case "$o_seen" in *:${d_origin}:*) continue ;; esac
+			o_seen="${o_seen}${d_origin}:"
+
+			echo "@pkgdep $n_port" >> $new_cont
+			echo "@comment DEPORIGIN:$origin" >> $new_cont
+			;;
+		'@comment DEPORIGIN:'*)
+			d_origin=${line#*DEPORIGIN:}
+			case "$o_seen" in *:${d_origin}:*)
+				unset prev_line line ; continue ;; esac
+			o_seen="${o_seen}${d_origin}:"
+			;;
+		'@pkgdep '|@pkgdep) d_missing=d_missing ;;
+		@pkgdep*)	d_iport="${line#@pkgdep }"
+				[ -d "$pdb/$d_iport" ] || d_missing=dm2 ;;
+		esac
+		[ -n "$prev_line" ] && echo $prev_line >> $new_cont
+		prev_line=$line
+	done
+	[ -n "$prev_line" ] && echo $prev_line >> $new_cont
+
+	cmp -s $contents $new_cont && { pm_unlink $new_cont ; return; }
+
+	check_regular_file $contents
+	[ -n "$PM_VERBOSE" -o -n "$CHECK_DEPENDS" ] &&
+		echo "	===>>> Installing the new +CONTENTS file"
+	pm_install_s $new_cont $contents
+	pm_unlink $new_cont
+}
+
+find_moved_port () {
+	# Global: moved_npd
+	local sf iport IFS l reason
+
+	sf=$1	# Search for
+	iport=$2
+
+	# To avoid having each word of the reason treated separately
+	IFS='
+'
+	for l in `grep "^$sf|" $pd/MOVED`; do
+		case "$l" in
+		${sf}\|\|*) [ -n "$iport" ] || iport=`iport_from_origin $sf`
+			if [ -e "$pdb/$iport/+IGNOREME" ]; then
+				if [ -n "$PM_VERBOSE" ]; then
+			echo ''
+			echo "	===>>> The $sf port has been deleted"
+			echo "	===>>> Reason: ${l##*|}"
+			echo "	===>>> Skipping it due to +IGNOREME file"
+			echo ''
+				fi
+				return 0
+			else
+				reason=${l##*|}
+				[ "$3" != 'nonfatal' ] &&
+				  fail "The $sf port has been deleted: $reason"
+			fi
+			;;
+		${sf}\|*) moved_npd=${l#*\|}	# New port directory
+			moved_npd=${moved_npd%%\|*}
+			echo ''
+			echo "	===>>> The $sf port moved to $moved_npd"
+			echo "	===>>> Reason: ${l##*|}"
+			echo ''
+			find_moved_port $moved_npd
+			;;
+		esac
+	done
+
+	if [ -z "$moved_npd" ]; then
+		if [ -z "$reason" ]; then
+			echo ''
+			echo "	===>>> No $pd/$1 exists, and no information"
+			echo "	===>>> about $1 can be found in $pd/MOVED"
+		else	# Only reached in LIST_PLUS
+			echo "	===>>> The $sf port has been deleted: $reason"
+		fi
+		echo ''
+
+		[ -n "$iport" ] || iport=`iport_from_origin $sf`
+		if [ -e "$pdb/$iport/+IGNOREME" ]; then
+			return 0
+		else
+			return 1
+		fi
+	fi
+	return 0
+}
+
+read_distinfos () {
+	local pkg iport origin distinfo disc1 f disc2
+
+	echo '############' > $DI_FILES		# Make the file > 0 bytes
+	echo "===>>> Gathering distinfo list for installed ports"
+	echo ''
+	for pkg in ${pdb}/*; do
+		[ -d $pkg ] || continue
+		iport=${pkg#$pdb/}
+
+		case "$iport" in bsdpan-*) continue ;; esac
+
+		origin=`origin_from_pdb $iport`
+
+		if [ ! -d "$pd/$origin" ]; then
+			find_moved_port $origin $iport nonfatal >/dev/null
+			[ -n "$moved_npd" ] || continue
+			origin=$moved_npd
+		fi
+
+		pm_cd $pd/$origin || continue
+
+		if [ -s distinfo ]; then
+			distinfo=distinfo
+		else
+			distinfo=`pm_make -V MD5_FILE`
+		fi
+
+		if [ -s "$distinfo" ]; then
+			grep '^MD5' $distinfo | while read disc1 f disc2; do
+				f=${f#(} ; f=${f%)}
+				echo $f >> $DI_FILES
+			done
+		fi
+	done
+
+	# Tell safe_exit that we are done
+	[ -e "${DI_FILES}-e" ] && unlink ${DI_FILES}-e
+	sed -i -e 1s/############/%%%%%%%%%%%%/ $DI_FILES
+	[ -e "${DI_FILES}-e" ] && unlink ${DI_FILES}-e
+}
+
+globstrip () {
+	local in
+
+	in=${1%[*]}
+	in=${in%\\}
+
+	echo $in
+}
+
+ports_by_category () {
+	local pkg
+	[ -n "$PM_VERBOSE" ] && echo "===>>> Sorting ports by category"
+
+	for pkg in $pdb/*; do
+		if [ -s "$pkg/+REQUIRED_BY" ]; then
+			if grep -ql '^@pkgdep ' $pkg/+CONTENTS 2>/dev/null; then
+				branches="$branches ${pkg#$pdb/}"
+			else
+				trunks="$trunks ${pkg#$pdb/}"
+			fi
+		else
+			if grep -ql '^@pkgdep ' $pkg/+CONTENTS 2>/dev/null; then
+				leaves="$leaves ${pkg#$pdb/}"
+			else
+				[ -d "$pkg" ] || continue
+				roots="$roots ${pkg#$pdb/}"
+			fi
+		fi
+	done
+}
+
+#=============== End functions relevant to --features and main ===============
+#=============== Begin code relevant only to --features ===============
+
+if [ -n "$CLEAN_DISTFILES" ]; then
+	# Set the file name here since we are usually called in a subshell
+	DI_FILES=`pm_mktemp DI-FILES`
+	read_distinfos
+
+	echo "===>>> Checking for stale distfiles"
+	for df in `find $distdir -type f`; do
+		f=${df#$distdir}
+		if ! grep -ql $f $DI_FILES; then
+			if [ -n "$ALL" ]; then
+				echo "===>>> Deleting $f"
+				pm_unlink $df
+			else
+				echo -n "===>>> Delete stale file: ${f}? [y] "
+				read answer
+				case "$answer" in
+				[nN]*)	continue ;;
+				*)	pm_unlink $df ;;
+				esac
+			fi
+		fi
+	done
+
+	find -d $distdir -type d -empty -delete
+	safe_exit
+fi
+
+if [ -n "$CHECK_DEPENDS" ]; then
+	d_orig_ok=':'
+IFS='
+'
+	for pkg in $pdb/*; do
+		[ -d "$pkg" ] || continue
+
+		iport=${pkg#$pdb/}
+
+		case "$iport" in bsdpan-*)
+		echo "===>>> BSDPAN ports do not record dependencies ($iport)"
+		continue ;; esac
+
+		echo "===>>> Checking $iport"
+
+		[ -r "$pkg/+CONTENTS" ] || {
+			echo "	===>>> Warning: No +CONTENTS file!";
+			continue; }
+
+		origin=`origin_from_pdb ${pkg#$pdb/}`
+		[ -n "$origin" ] || {
+			echo "	===>>> Warning: No ORIGIN in +CONTENTS file";
+			continue; }
+
+		if [ ! -d "$pd/$origin" ]; then
+			echo "	===>>> $pd/$origin does not exist"
+			echo "	===>>> This port should probably be updated"
+			continue
+		fi
+
+		check_dependency_files $origin $iport
+		if [ -s "$grep_deps" ]; then
+			if [ -e "$pkg/+REQUIRED_BY" ]; then
+				sort $pkg/+REQUIRED_BY | cmp -s $grep_deps - ||
+					do_update=do_update
+				check_regular_file $pkg/+REQUIRED_BY
+			else
+				do_update=do_update2
+			fi
+			if [ -n "$do_update" ]; then
+				unset do_update
+				echo "	===>>> Updating +REQUIRED_BY"
+				pm_install_s $grep_deps $pkg/+REQUIRED_BY
+			fi
+		fi
+		[ -n "$grep_deps" ] && {
+			pm_unlink $grep_deps && unset grep_deps; }
+
+		update_contents $pkg/+CONTENTS
+	done
+	exit 0
+fi
+
+if [ -n "$CHECK_PORT_DBDIR" ]; then
+	if [ "$2" = "-v" ]; then PM_VERBOSE=vopt; fi
+
+	unique_list=':'
+
+	echo "===>>> Building list of installed port names"; echo ''
+	for pkg in $pdb/*; do
+		unset unique_name
+
+		iport=${pkg#$pdb/}
+		origin=`origin_from_pdb $iport`
+
+		if [ ! -d "$pd/$origin" ]; then
+			find_moved_port $origin $iport nonfatal >/dev/null
+			[ -n "$moved_npd" ] || continue
+			origin=$moved_npd
+		fi
+
+		pm_cd $pd/$origin || {
+			echo "	===>>> $pd/$origin does not exist for $pkg";
+			continue; }
+		unique_name=`make -V UNIQUENAME`
+		unique_list="${unique_list}${unique_name}:"
+	done
+
+	echo "===>>> Checking $port_dbdir"
+
+	[ -n "$PM_VERBOSE" ] && { print='-print'; echo '';
+		echo "===>>> Deleting empty directories (if any)"; }
+	pm_find_s $port_dbdir -type d -empty $print -delete
+	[ -n "$PM_VERBOSE" ] && echo ''
+
+	for dir in ${port_dbdir}/*; do
+		dbdir=${dir#$port_dbdir/}
+
+		[ -n "$PM_VERBOSE" ] && echo -n "===>>> Checking ${dbdir}: "
+		case "$unique_list" in
+		*:${dbdir}:*)	[ -n "$PM_VERBOSE" ] && echo "Ok" ;;
+		*)	[ -n "$PM_VERBOSE" ] && echo ''
+			echo ''
+			echo "	===>>> $dbdir does not seem to be installed"
+			echo -n "	===>>> Delete ${dir}? [n] "
+			read answer
+			case "$answer" in
+			[yY])	pm_rm_s -rf $dir ;;
+			esac
+			;;
+		esac
+	done
+	exit 0
+fi
+
+if [ -n "$LIST_ORIGINS" ]; then
+	ports_by_category
+
+	for iport in $roots $leaves; do
+		origin=`origin_from_pdb $iport`
+		echo $origin
+	done
+
+	exit 0
+fi
+
+#=============== End code relevant only to --features ===============
+
+# Save switches for potential child processes
+while getopts 'BCDFGHKLRabde:fghilm:nop:r:stuvwx:' COMMAND_LINE_ARGUMENT ; do
+	case "${COMMAND_LINE_ARGUMENT}" in
+	B)	NO_BACKUP=Bopt; ARGS="-B $ARGS" ;;
+	C)	DONT_PRE_CLEAN=Copt; ARGS="-C $ARGS" ;;
+	D)	DONT_SCRUB_DISTFILES=Dopt; ARGS="-D $ARGS" ;;
+	F)	FETCH_ONLY=Fopt; ARGS="-F $ARGS" ;;
+	G)	NO_RECURSIVE_CONFIG=Gopt; unset FORCE_CONFIG; ARGS="-G $ARGS" ;;
+	H)	HIDE_BUILD=Hopt; ARGS="-H $ARGS" ;;
+	K)	DONT_POST_CLEAN=Kopt; ARGS="-K $ARGS" ;;
+	L)	LIST_PLUS=Lopt ;;
+	R)	RESTART=Ropt ; ARGS="-R $ARGS" ;;
+	a)	UPDATE_ALL=aopt ;;
+	b)	BACKUP=bopt; ARGS="-b $ARGS" ;;
+	d)	ALWAYS_SCRUB_DISTFILES=dopt; ARGS="-d $ARGS" ;;
+	e)	EXPUNGE=$OPTARG ;;
+	f)	export PM_FORCE=fopt ;;
+	g)	MAKE_PACKAGE=gopt; ARGS="-g $ARGS" ;;
+	h)	usage 0 ;;
+	i)	INTERACTIVE_UPDATE=iopt; ARGS="-i $ARGS" ;;
+	l)	LIST=lopt ;;
+	m)	export PM_MAKE_ARGS=$OPTARG	# For 'make checksum'
+		ARGS="-m $PM_MAKE_ARGS $ARGS"
+		;;
+	n)	NO_ACTION=nopt; ARGS="-n $ARGS" ;;
+	o)	REPLACE_ORIGIN=oopt ;;
+	p)	portdir="${OPTARG#$pd/}" ; portdir=${portdir%/} ;;
+	r)	UPDATE_REQ_BYS=ropt ; portdir=`origin_from_pdb $OPTARG` ;;
+	s)	CLEAN_STALE=sopt ;;
+	t)	RECURSE_THOROUGH=topt; ARGS="-t $ARGS" ;;
+	u)	echo "===>>> The -u option has been deprecated" ; echo '' ;;
+	v)	PM_VERBOSE=vopt; ARGS="-v $ARGS" ;;
+	w)	SAVE_SHARED=wopt; ARGS="-w $ARGS" ;;
+	x)	case "$OPTARG" in
+		-*)	fail 'The -x option requires an argument' ;;
+		esac
+		PM_EXCL="${PM_EXCL}`globstrip ${OPTARG}` " ;;
+	*)	echo '' ; echo "===>>> Try ${0##*/} --help"; exit 1 ;;
+	esac
+done
+shift $(( $OPTIND - 1 ))
+
+[ -n "$PM_EXCL" ] && export PM_EXCL
+
+# 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"
+[ -n "$FETCH_ONLY" -a -n "$NO_RECURSIVE_CONFIG" ] &&
+	fail "The -F and -G options are mutually exclusive"
+
+#=============== Begin functions for getopts features and main ===============
+
+check_state () {
+	# Global: state
+	local state_set
+
+	if egrep -ql '^(FORBIDDEN|DEPRECATED|BROKEN|IGNORE)' Makefile; then
+		for state in FORBIDDEN DEPRECATED BROKEN IGNORE; do
+			state_set=`pm_make -V $state`
+			if [ -n "$state_set" ]; then
+				echo "	===>>> This port is marked $state"
+				printf "	===>>> $state_set\n"
+				echo ''
+				return 1
+			fi
+		done
+	fi
+	return 0
+}
+
+check_for_updates () {
+	# Global: num_updates
+	local list_only nf iport origin port_ver udf do_update
+
+	[ "$1" = 'list' ] && { list_only=list_only; nf=nonfatal; shift; }
+
+	iport=$1
+
+	case "$iport" in bsdpan-*)	[ -n "$PM_VERBOSE" ] &&
+	echo "	===>>> BSDPAN ports cannot be upgraded with portmaster"
+	return 0 ;; esac
+
+	origin=${2:-`origin_from_pdb $iport`}
+	if [ -z "$origin" ]; then
+		if [ -n "$PM_VERBOSE" ]; then
+			echo "===>>> No ORIGIN in $pdb/$iport/+CONTENTS"
+			echo ''
+		fi
+		return 0
+	fi
+
+	if [ -d "$pd/$origin" ]; then
+		if ! pm_cd $pd/$origin; then
+			if [ -e "$pdb/$iport/+IGNOREME" ]; then
+			echo "	===>>> Warning: Unable to cd to $pd/$origin"
+			echo "	===>>> Continuing due to $pdb/$iport/+IGNOREME"
+				return 0
+			else
+				fail "Cannot cd to port directory: $pd/$origin"
+			fi
+		fi
+		port_ver=`pm_make -V PKGNAME`
+		[ -z "$port_ver" ] && fail "Is $pd/$origin/Makefile missing?"
+
+		udf="$pdb/$iport/PM_UPGRADE_DONE_FLAG"
+		if [ "$iport" = "$port_ver" ]; then
+			if [ -n "$PM_FORCE" ]; then
+				check_restart_and_udf $udf $iport ||
+					do_update=do_update
+			elif [ -n "$URB_YES" ]; then
+		# Outdent
+		case "$MASTER_RB_LIST" in *" $iport "*)
+			if ! check_restart_and_udf $udf $iport; then
+				do_update=do_update2
+			else
+				URB_DONE_LIST="${URB_DONE_LIST}${upg_port}:"
+			fi ;;
+		esac
+		# Outdent
+			elif [ -n "$PM_MULTI_PORTS" ]; then
+				case "$PM_MULTI_PORTS" in
+				*:${iport}:*)	do_update=do_update7 ;;
+				*:${origin}:*)	do_update=do_update8 ;;
+				esac
+			elif [ -n "$LIST_PLUS" ]; then
+				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
+		fi
+	else
+		find_moved_port $origin $iport $nf
+
+		# If the port has moved, we have to update it, otherwise ignore
+		[ -n "$moved_npd" ] && do_update=do_update6
+	fi
+
+	[ -z "$do_update" ] && {
+		CUR_DEPS="${CUR_DEPS}${iport}:${origin}:" ; return 0; }
+
+	if [ -n "$list_only" ]; then
+		if [ -z "$moved_npd" ]; then
+			echo "	===>>> New version available: $port_ver"
+			[ -e "$pdb/$iport/+IGNOREME" ] &&
+				echo "	===>>> +IGNOREME file is present for $1"
+			check_state
+			num_updates=$(( $num_updates + 1 ))
+		else
+			unset moved_npd
+		fi
+		return 0
+	fi
+
+	# No need for check_exclude here because it is already
+	# run in the places that call check_for_updates().
+	check_interactive $iport $port_ver || return 0
+	update_port $iport $port_ver || return 1
+	return 0
+}

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-user mailing list