Date: Thu, 9 Aug 2012 22:12:10 +0800 From: =?UTF-8?B?5LmU5qWa?= <honestqiao@gmail.com> To: Chris Rees <utisoft@gmail.com> Cc: "O. Hartmann" <ohartman@mail.zedat.fu-berlin.de>, Current FreeBSD <freebsd-current@freebsd.org>, "O. Hartmann" <ohartman@zedat.fu-berlin.de>, FreeBSD Mailing List <freebsd-ports@freebsd.org>, Bryan Drewery <bryan@shatow.net> Subject: Re: pkg and portmaster: Downgrading ports? Why? portmaster messes up ... Message-ID: <CAMAY4VgiixdpFwyt5ZdWn_tjbXKVTJYw4objWSf8j2j1ZEheBg@mail.gmail.com> In-Reply-To: <CADLo839cz-5EfKZ=MuNZSp0wmhSRhxwAgdGT=wqdMjZoXQke7g@mail.gmail.com> References: <5020E05C.3000704@zedat.fu-berlin.de> <50211A8F.40108@shatow.net> <50211CEA.6030108@mail.zedat.fu-berlin.de> <CADLo839cz-5EfKZ=MuNZSp0wmhSRhxwAgdGT=wqdMjZoXQke7g@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] 2012/8/9 Chris Rees <utisoft@gmail.com>: > On 7 Aug 2012 15:50, "O. Hartmann" <ohartman@mail.zedat.fu-berlin.de> wrote: >> >> On 08/07/12 15:39, Bryan Drewery wrote: >> > On 8/7/2012 4:31 AM, O. Hartmann wrote: >> >> ports-mgmt/portmaster installs still the old fashioned style folders of >> >> ports in /var/db/pkg. I thought ith the new scheme of pkg, everything > is >> >> going into a file based SQLite3 DB? >> > >> > Also ensure WITH_PKGNG=yes is in your /etc/make.conf. My last comment >> > still stands though, portmaster will store distifile information in >> > /var/db/pkg. >> > >> >> WITH_PKGNG=yes is set in /etc/make.conf. > > Also in your portmasterrc? > > Chris > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" You can use this patch. [-- Attachment #2 --] $FreeBSD$ --- portmaster.sh.in.orig +++ portmaster.sh.in @@ -47,7 +47,7 @@ #=============== Begin functions we always want to have =============== version () { - echo '' ; echo "===>>> Version 3.13.13" + echo '' ; echo "===>>> Version 3.13.13 (pkgng patch 1.3)" #svn='$FreeBSD: user/dougb/portmaster/portmaster 238754 2012-07-24 20:15:41Z dougb $' } @@ -134,6 +134,8 @@ if [ -n "$files" ]; then pm_sv Deleting \'install complete\' flags pm_find_s $pdb -type f -name PM_UPGRADE_DONE_FLAG -delete + [ -n "$use_pkgng" ] && + pm_find_s $pdb -type d -depth 1 -empty ! -path \*\.zfs/\* -delete 2>/dev/null fi fi if [ -z "$BACKUP" -a -z "$NO_BACKUP" -a -n "$NB_DELETE" ]; then @@ -187,9 +189,14 @@ fi : ${PAGER:='less -e'} - ( for f in $DISPLAY_LIST; do - echo "===>>> pkg-message for $f" ; cat $pdb/$f/+DISPLAY ; echo '' - done + ( if [ -z "$use_pkgng" ]; then + for f in $DISPLAY_LIST; do + echo "===>>> pkg-message for $f" + cat $pdb/$f/+DISPLAY ; echo '' + done + else + pkg query "===>>> pkg-message for %n-%v\n%M" $DISPLAY_LIST + fi echo "===>>> Done displaying pkg-message files" ; echo '' ) | $PAGER ;; esac @@ -232,10 +239,14 @@ if [ -n "$build_deps_il" ]; then echo "===>>> Deleting installed build-only dependencies" cd - for f in $build_deps_il; do - pm_v " $f" - pm_pkg_delete_s -f $f - done + if [ -z "$use_pkgng" ]; then + for f in $build_deps_il; do + pm_v " $f" + pm_pkg_delete_s -f $f + done + else + pm_pkg_delete_s -f $build_deps_il + fi echo '' fi @@ -323,7 +334,13 @@ pm_make_s () { ( unset -v CUR_DEPS INSTALLED_LIST PM_DEPTH build_l PM_URB_LIST; $PM_SU_CMD /usr/bin/nice /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_pkg_delete_s () { + if [ -z "$use_pkgng" ]; then + $PM_SU_CMD /usr/sbin/pkg_delete $*; + else + $PM_SU_CMD /usr/local/sbin/pkg delete -y $*; + fi +} pm_rm_s () { $PM_SU_CMD /bin/rm $*; } pm_rmdir_s () { $PM_SU_CMD /bin/rmdir $*; } pm_unlink_s () { [ -e "$1" ] && $PM_SU_CMD /bin/unlink $1; } @@ -371,6 +388,10 @@ [ -z "$port_dbdir" ] && port_dbdir=`pm_make_b -f/usr/share/mk/bsd.port.mk -V PORT_DBDIR 2>/dev/null` [ -n "$port_dbdir" ] && export port_dbdir + + # Detect if pkgng is being used + use_pkgng="`pm_make_b -V WITH_PKGNG`" + [ -n "$use_pkgng" ] && export use_pkgng fi usage () { @@ -527,12 +548,17 @@ pattern=`globstrip $1` - glob_dirs=`find $pdb -maxdepth 1 -type d -name ${pattern}\*` + if [ -z "$use_pkgng" ]; then + glob_dirs=`find $pdb -depth 1 -type d -name ${pattern}\*` + else + glob_dirs=`pkg query -g "%n-%v" ${pattern}\*` + fi case "$glob_dirs" in # Match a newline in multiple responses from find *' '*) return 2 ;; - $pdb/*) return ;; + '') ;; + *) return ;; esac unset glob_dirs @@ -542,20 +568,35 @@ origin_from_pdb () { local o - o=`grep -m1 '@comment ORIGIN:' $pdb/$1/+CONTENTS 2>/dev/null` && { - echo ${o#@comment ORIGIN:}; return 0; } + if [ -z "$use_pkgng" ]; then + o=`grep -m1 '@comment ORIGIN:' $pdb/$1/+CONTENTS 2>/dev/null` && { + echo ${o#@comment ORIGIN:}; return 0; } + else + pkg info -qo $1 2>/dev/null && return 0 + fi case "$1" in bsdpan-*) return 3 ;; esac - if [ -e "$pdb/$1/+IGNOREME" ]; then + if [ -e "$pdb/$1/+IGNOREME" ] && ( [ -z "$use_pkgng" ] || pkg info -e $1 ); then if [ -n "$PM_VERBOSE" -o -n "$LIST_ORIGINS" ]; then - echo " ===>>> No ORIGIN in $pdb/$1/+CONTENTS" >&2 + if [ -z "$use_pkgng" ]; then + echo " ===>>> No ORIGIN in $pdb/$1/+CONTENTS" >&2 + else + # An error above doesn't necessarily mean there's + # a problem in +MANIFEST, so don't mention it + echo " ===>>> No origin available for $1" >&2 + fi echo " ===>>> $pdb/$1/+IGNOREME exists" >&2 echo '' >&2 fi return 2 else - echo " ===>>> No ORIGIN in $pdb/$1/+CONTENTS" >&2 + if [ -z "$use_pkgng" ]; then + echo " ===>>> No ORIGIN in $pdb/$1/+CONTENTS" >&2 + else + # Same as above + echo " ===>>> No origin available for $1" >&2 + fi echo '' >&2 fi return 1 @@ -697,12 +738,17 @@ o) REPLACE_ORIGIN=oopt ;; p) fail 'The -p option has been deprecated' ;; r) PM_URB=ropt - if [ -d "$pdb/$OPTARG" ]; then + if [ -d "$pdb/$OPTARG" ] && ( [ -z "$use_pkgng" ] || pkg info -e $OPTARG ); then glob_dirs=$OPTARG else + case "$OPTARG" in */*) fail 'The argument to -r must be a package name, or a glob pattern' ;; esac find_glob_dirs $OPTARG case $? in - 1) fail "$pdb/$OPTARG does not exist" ;; + 1) if [ -z "$use_pkgng" ]; then + fail "$pdb/$OPTARG does not exist" + else + fail "$OPTARG is not installed" + fi ;; 2) fail 'The argument to -r must match only one port' ;; esac fi @@ -784,6 +830,12 @@ fail 'The -[ar] options are not compatible with other updates' if [ -n "$PM_PACKAGES" -o -n "$PM_PACKAGES_BUILD" ]; then + if [ -n "$use_pkgng" ]; then + unset PM_PACKAGES PM_PACKAGES_BUILD PM_PACKAGES_LOCAL PM_PACKAGES_NEWER PM_ALWAYS_FETCH PM_DELETE_PACKAGES + echo "===>>> Package installation support cannot be used with pkgng yet," + echo " it will be disabled" + echo '' + fi [ `/sbin/sysctl -n kern.osreldate 2>/dev/null` -lt 600400 ] && fail Package installation support requires FreeBSD 6.4 or newer fi @@ -850,7 +902,12 @@ fi unset INDEXFILE INDEXDIR - PM_INDEX_PORTS=`pkg_version -Ivl\< $PM_INDEX | cut -f1 -d\<` + if [ -z "$use_pkgng" ]; then + pkg_version="pkg_version" + else + pkg_version="pkg version" + fi + PM_INDEX_PORTS=`$pkg_version -Ivl\< $PM_INDEX | cut -f1 -d\<` export PM_INDEX_PORTS if [ -z "$pd" -o "$pd" != /usr/ports ]; then @@ -907,6 +964,10 @@ iport_from_origin () { local sn dir + if [ -n "$use_pkgng" ]; then + pkg info -qO ${1} || return 1 + return + fi sn=${1#*/} ; sn=${sn%-*} ; sn=${sn%%[0-9]*} if ! dir=`grep -l "@comment ORIGIN:${1}$" $pdb/${sn}*/+CONTENTS 2>/dev/null`; then @@ -935,7 +996,9 @@ done } +# Redundant with pkgng check_dependency_files () { + [ -n "$use_pkgng" ] && return # Global: grep_deps local origin iport ro_opd @@ -1017,7 +1080,9 @@ fi } +# redundant with pkgng update_contents () { + [ -n "$use_pkgng" ] && return local IFS delete contents origin n_port old_origin iport local o_seen line d_missing d_origin d_iport prev_line answer @@ -1117,7 +1182,7 @@ 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 [ -e "$pdb/$iport/+IGNOREME" ] && ( [ -z "$use_pkgng" ] || pkg info -e $iport ); then if [ -n "$PM_VERBOSE" ]; then echo '' echo " ===>>> The $sf port has been deleted" @@ -1152,24 +1217,36 @@ echo '' [ -n "$iport" ] || iport=`iport_from_origin $sf` - [ -e "$pdb/$iport/+IGNOREME" ] || return 1 + [ -e "$pdb/$iport/+IGNOREME" ] && ( [ -z "$use_pkgng" ] || pkg info -e $iport ) || return 1 fi return 0 } +all_pkgs_by_origin () { + if [ -z "$use_pkgng" ]; then + local pkg iport origin + + for pkg in ${pdb}/* ; do + [ -d $pkg ] || continue + iport=${pkg#$pdb/} + + origin=`origin_from_pdb $iport` || continue + echo $iport $origin + done + else + pkg query -a "%n-%v %o" + fi + return +} + read_distinfos () { - local pkg iport origin distinfo s f discard + local iport origin distinfo s f discard 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/} - - origin=`origin_from_pdb $iport` || continue - + all_pkgs_by_origin | while read iport origin; do if [ ! -d "$pd/$origin" ]; then find_moved_port $origin $iport nonfatal >/dev/null [ -n "$moved_npd" ] || continue @@ -1245,29 +1322,43 @@ pm_v "===>>> Sorting ports by category" - num_roots=0; num_trunks=0; num_branches=0; num_leaves=0 - 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/}" - num_branches=$(( $num_branches + 1 )) - else - trunks="$trunks ${pkg#$pdb/}" - num_trunks=$(( $num_trunks + 1 )) - fi - else - if grep -ql '^@pkgdep ' $pkg/+CONTENTS 2>/dev/null; then - leaves="$leaves ${pkg#$pdb/}" - num_leaves=$(( $num_leaves + 1 )) + if [ -z "$use_pkgng" ]; then + num_roots=0; num_trunks=0; num_branches=0; num_leaves=0 + 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/}" + num_branches=$(( $num_branches + 1 )) + else + trunks="$trunks ${pkg#$pdb/}" + num_trunks=$(( $num_trunks + 1 )) + fi else - [ -d "$pkg" ] || continue - roots="$roots ${pkg#$pdb/}" - num_roots=$(( $num_roots + 1 )) + if grep -ql '^@pkgdep ' $pkg/+CONTENTS 2>/dev/null; then + leaves="$leaves ${pkg#$pdb/}" + num_leaves=$(( $num_leaves + 1 )) + else + [ -d "$pkg" ] || continue + roots="$roots ${pkg#$pdb/}" + num_roots=$(( $num_roots + 1 )) + fi fi - fi - done + done - num_ports=$(( $num_roots + $num_trunks + $num_branches + $num_leaves )) + num_ports=$(( $num_roots + $num_trunks + $num_branches + $num_leaves )) + else + roots=` pkg query -e "%#d = 0 && %#r = 0" "%n-%v"` + trunks=` pkg query -e "%#d = 0 && %#r > 0" "%n-%v"` + branches=`pkg query -e "%#d > 0 && %#r > 0" "%n-%v"` + leaves=` pkg query -e "%#d > 0 && %#r = 0" "%n-%v"` + + num_roots=$(echo $(echo $roots | wc -w)) + num_trunks=$(echo $(echo $trunks | wc -w)) + num_branches=$(echo $(echo $branches | wc -w)) + num_leaves=$(echo $(echo $leaves | wc -w)) + + num_ports=$(echo $(pkg query -a "%n-%v" | wc -w)) + fi } delete_empty_dist_subdirs () { @@ -1315,7 +1406,9 @@ esac } +# Redundant with pkgng update_required_by () { + [ -n "$use_pkgng" ] && /bin/unlink $grep_deps && unset grep_deps && return # Global: needws local do_update @@ -1325,7 +1418,7 @@ else do_update=do_update2 fi - if [ -n "$do_update" ]; then + if [ -n "$do_update" ]; then pm_v " ===>>> Updating $1/+REQUIRED_BY" needws=needws_urb pm_install_s $grep_deps $pdb/$1/+REQUIRED_BY @@ -1371,11 +1464,15 @@ echo "===>>> Checking for stale packages" for package in `find $PACKAGES -type f | sort`; do - pkg_dir=${package##*/} ; pkg_dir=${pkg_dir%\.tbz} ; echo '' + pkg_dir=${package##*/} ; pkg_dir=${pkg_dir%\.*} ; echo '' - origin=`tar -O -zxvf $package '+CONTENTS' 2>/dev/null | grep '@comment ORIGIN:'` || - fail Empty origin in $package + [ -n "$use_pkgng" ] && + origin=`pkg query -F $package "%o" 2>/dev/null` || + origin=`tar -O -zxvf $package '+CONTENTS' 2>/dev/null | grep '@comment ORIGIN:'` || + origin=`tar -O -zxvf $package '+MANIFEST' 2>/dev/null | grep '^origin:'` || + fail "Empty origin in $package" origin=${origin#@comment ORIGIN:} + origin=${origin#origin: } if [ -z "$PM_INDEX" ]; then if [ -d "$pd/$origin" ]; then @@ -1391,16 +1488,28 @@ fi if [ -n "$port_ver" ]; then - if [ "${port_ver}.tbz" = "${package##*/}" ]; then + if [ "$port_ver" = "$pkg_dir" ]; then echo "===>>> ${package##*/} is up to date" - if [ ! -d "${pdb}/${pkg_dir}" ]; then - echo " ===>>> $pkg_dir is not installed" - echo " ===>>> Path: ${package}" - get_answer_yn y "\n\t===>>> Delete stale package: ${package##*/}" - case "$?" in - 0) echo " ===>>> Deleting $package" - pm_unlink_s $package ;; - esac + if [ -z "$use_pkgng" ]; then + if [ ! -d "${pdb}/${pkg_dir}" ]; then + echo " ===>>> $pkg_dir is not installed" + echo " ===>>> Path: ${package}" + get_answer_yn y "\n\t===>>> Delete stale package: ${package##*/}" + case "$?" in + 0) echo " ===>>> Deleting $package" + pm_unlink_s $package ;; + esac + fi + else + if ! pkg info -e $pkg_dir; then + echo " ===>>> $pkg_dir is not installed" + echo " ===>>> Path: ${package}" + get_answer_yn y "\n\t===>>> Delete stale package: ${package##*/}" + case "$?" in + 0) echo " ===>>> Deleting $package" + pm_unlink_s $package ;; + esac + fi fi unset port_ver continue @@ -1411,10 +1520,18 @@ unset port_ver - if [ -d "${pdb}/${pkg_dir}" ]; then - echo " ===>>> ${package##*/} matches the installed version" + if [ -z "$use_pkgng" ]; then + if [ -d "${pdb}/${pkg_dir}" ]; then + echo " ===>>> ${package##*/} matches the installed version" + else + echo " ===>>> ${package##*/} is not installed" + fi else - echo " ===>>> ${package##*/} is not installed" + if pkg info -e $pkg_dir; then + echo " ===>>> ${package##*/} matches the installed version" + else + echo " ===>>> ${package##*/} is not installed" + fi fi fi @@ -1453,6 +1570,10 @@ fi # [ -n "$CLEAN_PACKAGES" ] if [ -n "$CHECK_DEPENDS" ]; then + if [ -n "$use_pkgng" ]; then + pkg check -adv + exit + fi PM_VERBOSE=pmv_check_depends IFS=' ' @@ -1499,24 +1620,42 @@ unique_list=':' echo "===>>> Building list of installed port names"; echo '' - for pkg in $pdb/*; do - [ -d $pkg ] || continue + if [ -z "$use_pkgng" ]; then + for pkg in $pdb/*; do + [ -d $pkg ] || continue - iport=${pkg#$pdb/} - origin=`origin_from_pdb $iport` || continue + iport=${pkg#$pdb/} + origin=`origin_from_pdb $iport` || continue - if [ ! -d "$pd/$origin" ]; then - find_moved_port $origin $iport nonfatal >/dev/null - [ -n "$moved_npd" ] || continue - origin=$moved_npd - fi + if [ ! -d "$pd/$origin" ]; then + find_moved_port $origin $iport nonfatal >/dev/null + [ -n "$moved_npd" ] || continue + origin=$moved_npd + fi - if ! pm_cd $pd/$origin; then - echo " ===>>> $pd/$origin does not exist for $pkg" - continue - fi - unique_list="${unique_list}`make -V UNIQUENAME`:" - done + if ! pm_cd $pd/$origin; then + echo " ===>>> $pd/$origin does not exist for $pkg" + continue + fi + unique_list="${unique_list}`make -V UNIQUENAME`:" + done + else + while read pkg origin; do + if [ ! -d "$pd/$origin" ]; then + find_moved_port $origin $pkg nonfatal >/dev/null + [ -n "$moved_npd" ] || continue + origin=$moved_npd + fi + + if ! pm_cd $pd/$origin; then + echo " ===>>> $pd/$origin does not exist for $pkg" + continue + fi + unique_list="${unique_list}`make -V UNIQUENAME`:" + done << EOF +`pkg query -a "%n-%v %o"` +EOF + fi echo "===>>> Checking $port_dbdir" @@ -1617,7 +1756,7 @@ if [ -z "$do_update" -a -z "$skip" -a -z "$PM_INDEX_ONLY" ] && [ -d "$pd/$origin" ]; then if ! pm_cd $pd/$origin; then - if [ -e "$pdb/$iport/+IGNOREME" ]; then + if [ -e "$pdb/$iport/+IGNOREME" ] && ( [ -z "$use_pkgng" ] || pkg info -e $iport ); then echo " ===>>> Warning: Unable to cd to $pd/$origin" echo " ===>>> Continuing due to $pdb/$iport/+IGNOREME" echo '' @@ -1634,13 +1773,13 @@ # If the port has moved and no +IGNOREME, we have to update it if [ -n "$moved_npd" ]; then - if [ ! -e "$pdb/$iport/+IGNOREME" ]; then - do_update=do_update_moved - else + if [ -e "$pdb/$iport/+IGNOREME" ] && ( [ -z "$use_pkgng" ] || pkg info -e $iport ); then echo " ===>>> Continuing due to $pdb/$iport/+IGNOREME" echo '' CUR_DEPS="${CUR_DEPS}${iport}:${origin}:" return 0 + else + do_update=do_update_moved fi fi fi @@ -1657,14 +1796,20 @@ unset port_ver fi else - case `pkg_version -t $iport $port_ver` in + local pkg_version + if [ -z "$use_pkgng" ]; then + pkg_version="pkg_version" + else + pkg_version="pkg version" + fi + case `$pkg_version -t $iport $port_ver` in \<) do_update=upd_lt ;; =) ;; # Can be reached if same version with different options \>) if [ -n "$PM_VERBOSE" ]; then echo " ===>>> Port version $port_ver does not" echo " ===>>> seem newer than installed $iport" fi ;; - *) fail "pkg_version -t $iport $port_ver gave an unexpected result" + *) fail "$pkg_version -t $iport $port_ver gave an unexpected result" esac [ -z "$do_update" ] && { @@ -1680,8 +1825,9 @@ if [ -n "$LIST_PLUS" ]; then if [ -z "$moved_npd" ]; then echo " ===>>> New version available: $port_ver" - [ -e "$pdb/$iport/+IGNOREME" ] && + if [ -e "$pdb/$iport/+IGNOREME" ] && ( [ -z "$use_pkgng" ] || pkg info -e $iport ); then echo " ===>>> +IGNOREME file is present for $1" + fi pm_cd_pd $origin && check_state num_updates=$(( $num_updates + 1 )) else @@ -1736,7 +1882,13 @@ fi pm_cd $pkgdir || fail "Cannot cd into $pkgdir to create a package" - if $PM_SU_CMD pkg_create -b $2; then + local pkg_create + if [ -z "$use_pkgng" ]; then + pkg_create="pkg_create -b" + else + pkg_create="pkg create " + fi + if $PM_SU_CMD $pkg_create $2; then if [ "$1" = "$pbu" ]; then if [ -n "$BACKUP" ]; then echo " ===>>> Package saved to $1" ; echo '' @@ -2085,10 +2237,14 @@ fi if [ -n "$EXPUNGE" ]; then - if [ ! -d "$pdb/$EXPUNGE" ]; then + if [ ! -d "$pdb/$EXPUNGE" ] || ( [ -n "$use_pkgng" ] && ! pkg info -e $EXPUNGE ); then find_glob_dirs $EXPUNGE case $? in - 1) fail "No such directory/port: $pdb/$EXPUNGE" ;; + 1) if [ -z "$use_pkgng" ]; then + fail "No such directory/port: $pdb/$EXPUNGE" + else + fail "No such port: $EXPUNGE" + fi ;; 2) echo "===>>> $EXPUNGE matched multiple ports" fail "The -e option works with only one port at a time" ;; 0) EXPUNGE=${glob_dirs#$pdb/} @@ -2097,15 +2253,24 @@ fi origin=`origin_from_pdb $EXPUNGE` - deplist=`grep -l DEPORIGIN:$origin$ $pdb/*/+CONTENTS` + if [ -z "$use_pkgng" ]; then + deplist=`grep -l DEPORIGIN:$origin$ $pdb/*/+CONTENTS` + else + deplist=`pkg query "%rn-%rv" $origin` + fi if [ -n "$deplist" ]; then echo "===>>> Warning: Ports with dependencies on ${EXPUNGE}:" - for dep in $deplist; do - dep=${dep%/+CON*} ; echo " ${dep##*/}" - done + if [ -z "$use_pkgng" ]; then + for dep in $deplist; do + dep=${dep%/+CON*} ; echo " ${dep##*/}" + done + else + echo "$deplist" | sed 's/^/ /' + fi get_answer_yn n "\n\t===>>> Delete this dependency data" case "$?" in - 0) for f in $deplist; do + 0) [ -n "$use_pkgng" ] && exit 1 #TODO + for f in $deplist; do update_contents delete $f $origin done ;; *) exit 1 ;; @@ -2115,8 +2280,13 @@ [ -n "$BACKUP" ] && { init_packages ; pm_pkg_create $pbu $EXPUNGE; } [ -z "$DONT_SCRUB_DISTFILES" ] && delete_all_distfiles $origin - echo "===>>> Running pkg_delete -f $EXPUNGE" - pm_pkg_delete_s -f $EXPUNGE || fail 'pkg_delete failed' + if [ -z "$use_pkgng" ]; then + pkg_delete="pkg_delete" + else + pkg_delete="pkg delete" + fi + echo "===>>> Running $pkg_delete -f $EXPUNGE" + pm_pkg_delete_s -f $EXPUNGE || fail "$pkg_delete failed" echo '' ; echo "===>>> Running ${0##*/} -s $ARGS" exec $0 -s $ARGS @@ -2126,13 +2296,21 @@ if [ -n "$CLEAN_STALE" ]; then [ -z "$no_del_list" ] && export no_del_list=':' - for file in `find $pdb -type f -name \+REQUIRED_BY -empty` ; do + if [ -z "$use_pkgng" ]; then + find_stale_ports="find $pdb -type f -name \+REQUIRED_BY -empty" + else + find_stale_ports="pkg query -a \"%?r %n-%v\" | awk '/^0/ { print \$2 }'" + fi + for file in `eval $find_stale_ports` ; do iport="${file%/+REQUIRED_BY}" ; iport=${iport#$pdb/} case "$no_del_list" in *:${iport}:*) continue ;; esac origin=`origin_from_pdb $iport` - deplist=`grep -l DEPORIGIN:$origin$ $pdb/*/+CONTENTS` + deplist="" + if [ -z "$use_pkgng" ]; then + deplist=`grep -l DEPORIGIN:$origin$ $pdb/*/+CONTENTS` + fi if [ -n "$deplist" ]; then echo '' echo "===>>> Warning: Unrecorded dependencies on ${iport}:" @@ -2145,22 +2323,32 @@ continue fi - echo '' ; pkg_info $iport + if [ -z "$use_pkgng" ]; then + echo '' ; pkg_info $iport + pkg_delete="pkg_delete" + else + echo '' ; pkg info -f $iport + pkg_delete="pkg delete" + fi get_answer_yn n "\t===>>> ${iport} is no longer depended on, delete" case "$?" in 0) [ -n "$BACKUP" ] && { init_packages ; pm_pkg_create $pbu $iport; } [ -z "$DONT_SCRUB_DISTFILES" ] && delete_all_distfiles $origin - echo "===>>> Running pkg_delete -f $iport" - pm_pkg_delete_s -f $iport || fail 'pkg_delete failed' + echo "===>>> Running $pkg_delete -f $iport" + pm_pkg_delete_s -f $iport || fail "$pkg_delete failed" exec $0 -s $ARGS ;; - *) get_answer_yn n "\t===>>> Delete this dependency data" - case "$?" in - 0) pm_unlink_s $file ;; - *) no_del_list="${no_del_list}${iport}:" ;; - esac ;; + *) if [ -z "$use_pkgng" ]; then + get_answer_yn n "\t===>>> Delete this dependency data" + case "$?" in + 0) pm_unlink_s $file ;; + *) no_del_list="${no_del_list}${iport}:" ;; + esac + else + no_del_list="${no_del_list}${iport}:" + fi ;; esac done exit 0 @@ -2183,7 +2371,7 @@ # to go out to the disk if we don't have to. [ -z "$RESTART" ] && return 1 - if [ ! -e "$pdb/${1}/PM_UPGRADE_DONE_FLAG" ]; then + if [ ! -e "$pdb/${1}/PM_UPGRADE_DONE_FLAG" ] || ( [ -n "$use_pkgng" ] && ! pkg info -e $1 ); then return 1 else already_done $1 @@ -2200,7 +2388,7 @@ case "$INTERACTIVE_YES" in *:${1}:*) return 0 ;; esac case "$INTERACTIVE_NO" in *:${1}:*) return 1 ;; esac - if [ -e "$pdb/$1/+IGNOREME" ]; then + if [ -e "$pdb/$1/+IGNOREME" ] && ( [ -z "$use_pkgng" ] || pkg info -e $1 ); then echo '' echo "===>>> +IGNOREME file is present for $1" echo '' @@ -2312,7 +2500,13 @@ fail "No entry for $origin in $PM_INDEX" fi - case `pkg_version -t $iport $new_port 2>/dev/null` in + local pkg_version + if [ -z "$use_pkgng" ]; then + pkg_version="pkg_version" + else + pkg_version="pkg version" + fi + case `$pkg_version -t $iport $new_port 2>/dev/null` in \<) build_l="${build_l}\tUpgrade $iport to $new_port\n" ;; =) build_l="${build_l}\tRe-install $iport\n" ;; \>) build_l="${build_l}\tDowngrade $iport to $new_port\n" ;; @@ -2463,6 +2657,18 @@ rundeps=`gen_dep_list run-depends-list` for dep in $d_port_list; do + # If the port is already installed, do not mark + # it as a build-only dependency, or it will be + # installed by package and/or removed + if [ -z "$use_pkgng" ]; then + iport_from_origin ${dep#$pd/} >/dev/null && + run_dl="$run_dl $dep" && + continue + else + pkg info -e ${dep#$pd/} && + run_dl="$run_dl $dep" && + continue + fi case "$rundeps" in *" ${dep} "*|*${dep}*) varname=`echo ${dep#$pd/} | sed 's#[-+/\.]#_#g'` @@ -2532,7 +2738,11 @@ fail "Cannot cd to $d_port" fi for glob in $conflicts; do - confl_p=`pkg_info -I $glob 2>/dev/null` + if [ -z "$use_pkgng" ]; then + confl_p=`pkg_info -I $glob 2>/dev/null` + else + confl_p=`pkg query -g "%n-%v" $glob 2>/dev/null` + fi if [ -n "$confl_p" ]; then confl_p=${confl_p%% *} d_port="$pd/`origin_from_pdb $confl_p`" @@ -2672,7 +2882,11 @@ done for dep in $build_only_dl_g; do - grep -q "@comment DEPORIGIN:${dep#$pd/}$" $pdb/*/+CONTENTS && continue + if [ -z "$use_pkgng" ]; then + grep -q "@comment DEPORIGIN:${dep#$pd/}$" $pdb/*/+CONTENTS && continue + else + [ "`pkg query "%?r" ${dep#$pd/}`" = "1" ] && continue + fi [ -n "$PM_DEL_BUILD_ONLY" ] && iport_from_origin ${dep#$pd/} >/dev/null && continue temp_bodlg="$temp_bodlg $dep" @@ -2699,7 +2913,7 @@ urb_update () { # Global: PM_URB_UP - local verb origin req_by + local verb origin req_by req_by_o verb=checking ; [ -n "$1" ] && verb=updating @@ -2709,15 +2923,25 @@ echo '' for origin in $PM_URB_ORIGINS; do - for req_by in `grep -l DEPORIGIN:${origin}$ $pdb/*/+CONTENTS`; do - req_by="${req_by%/+CONTENTS}" - req_by="${req_by##*/}" + if [ -z "$use_pkgng" ]; then + for req_by in `grep -l DEPORIGIN:${origin}$ $pdb/*/+CONTENTS`; do + req_by="${req_by%/+CONTENTS}" + req_by="${req_by##*/}" - case " $PM_URB_IPORTS" in *" $req_by "*) continue ;; esac - case " $PM_URB_ORIGINS" in *" `origin_from_pdb $req_by` "*) continue ;; esac + case " $PM_URB_IPORTS" in *" $req_by "*) continue ;; esac + case " $PM_URB_ORIGINS" in *" `origin_from_pdb $req_by` "*) continue ;; esac - PM_URB_LIST="${PM_URB_LIST} ${req_by}" - done + PM_URB_LIST="${PM_URB_LIST} ${req_by}" + done + else + while read req_by req_by_o; do + case " $PM_URB_IPORTS" in *" $req_by "*) continue ;; esac + case " $PM_URB_ORIGINS" in *" $req_by_o "*) continue ;; esac + PM_URB_LIST="${PM_URB_LIST} ${req_by}" + done << EOF +`pkg query "%rn-%rv %ro" ${origin}` +EOF + fi done if [ -n "$PM_URB_LIST" ]; then @@ -2729,7 +2953,11 @@ for req_by in $PM_URB_LIST; do # Probably not needed, but JIC - [ -d "$pdb/$req_by" ] || continue + if [ -z "$use_pkgng" ]; then + [ -d "$pdb/$req_by" ] || continue + else + pkg info -e $req_by || continue + fi pm_v "===>>> $req_by depends on $PM_URB_IPORTS" @@ -2770,12 +2998,16 @@ else fail "$pd/${port} does not exist" fi ;; - *) if [ -d "$pdb/$port" ]; then + *) if [ -d "$pdb/$port" ] && ( [ -z "$use_pkgng" ] || pkg info -e $port ); then worklist_temp="$worklist_temp $port" else find_glob_dirs $port case $? in - 1) fail "$pdb/$port does not exist" ;; + 1) if [ -z "$use_pkgng" ]; then + fail "$pdb/$port does not exist" + else + fail "$port is not installed" + fi ;; *) local dir for dir in $glob_dirs; do worklist_temp="$worklist_temp ${dir#$pdb/}" @@ -2887,9 +3119,16 @@ */*) origin=$port ;; *) # If an installed version does not exist at this # point it probably got updated as a dependency - if [ ! -d "$pdb/$port" ]; then - numports=$(( $numports - 1 )) - continue + if [ -z "$use_pkgng" ]; then + if [ ! -d "$pdb/$port" ]; then + numports=$(( $numports - 1 )) + continue + fi + else + if ! pkg info -e $port; then + numports=$(( $numports - 1 )) + continue + fi fi origin=`origin_from_pdb $port` ;; esac @@ -3112,17 +3351,22 @@ case "$argv" in $pd/*) portdir=${argv#$pd/} ;; - $pdb/*) upg_port=${argv#$pdb/} ;; + $pdb/*) if [ -z "$use_pkgng" ]; then + upg_port=${argv#$pdb/} + else + echo '' ; no_valid_port + fi ;; /*) echo '' ; no_valid_port ;; */*) portdir=$argv ;; \.|'') portdir="$PWD" while : ; do case "$portdir" in */*/*) portdir="${portdir#*/}" ;; */*) break ;; *) echo '' ; no_valid_port ;; esac done ;; - *) [ -d "$pdb/$argv" ] && upg_port=$argv ;; + *) [ -d "$pdb/$argv" ] && ( [ -z "$use_pkgng" ] || pkg info -e $argv ) && + upg_port=$argv ;; esac if [ -z "$portdir" -a -z "$upg_port" ]; then @@ -3149,7 +3393,7 @@ case "$arg2" in */*) ro_opd=$arg2 ; ro_upg_port=`iport_from_origin $ro_opd` ;; - *) if [ -d "$pdb/$arg2" ]; then + *) if [ -d "$pdb/$arg2" ] && ( [ -z "$use_pkgng" ] || pkg info -e $arg2 ); then ro_upg_port=$arg2 else find_glob_dirs $arg2 && ro_upg_port=${glob_dirs#$pdb/} @@ -3164,12 +3408,21 @@ unset arg2 if [ -z "$ro_upg_port" ]; then - if ! grep -ql "DEPORIGIN:$ro_opd$" $pdb/*/+CONTENTS; then + if [ -z "$use_pkgng" ]; then + grep -ql "DEPORIGIN:$ro_opd$" $pdb/*/+CONTENTS + else + pkg query -a "%do" | grep -q "^$ro_opd$" + fi + if [ "$?" -eq 1 ]; then echo '' - echo "===>>> The second argument to -o can be a port in $pdb," + if [ -z "$use_pkgng" ]; then + echo "===>>> The second argument to -o can be a port in $pdb," + else + echo "===>>> The second argument to -o can be a package name," + fi echo " or a port directory from $pd" echo '' - echo " $ro_opd does not seem to be installed," + echo " $arg2 does not seem to be installed," echo ' or listed as a dependency' echo '' ; no_valid_port fi @@ -3201,7 +3454,7 @@ fi [ -z "$upg_port" -a -z "$REPLACE_ORIGIN" ] && upg_port=`iport_from_origin ${portdir}` -if [ -e "$pdb/$upg_port/+IGNOREME" ]; then +if [ -e "$pdb/$upg_port/+IGNOREME" ] && ( [ -z "$use_pkgng" ] || pkg info -e $upg_port ); then # Adding to CUR_DEPS means we will not get here in the build if [ -z "$PM_BUILDING" ]; then # Only need to prompt for this once if -ai @@ -3599,7 +3852,12 @@ pm_v "===>>> Available package ($latest_pv) matches the current version" elif [ -n "$latest_pv" -a -n "$PM_PACKAGES_NEWER" ]; then if [ -n "$upg_port" ]; then - case `pkg_version -t $upg_port $latest_pv` in + if [ -z "$use_pkgng" ]; then + pkg_version="pkg_version" + else + pkg_version="pkg version" + fi + case `$pkg_version -t $upg_port $latest_pv` in \<) use_package=up_newer pm_v "===>>> Available package ($latest_pv)" pm_v " is newer than installed ($upg_port)" ;; @@ -3615,7 +3873,12 @@ pm_v "===>>> There is a package available ($latest_pv)" fi elif [ -n "$latest_pv" ]; then - case `pkg_version -t $new_port $latest_pv` in + if [ -z "$use_pkgng" ]; then + pkg_version="pkg_version" + else + pkg_version="pkg version" + fi + case `$pkg_version -t $new_port $latest_pv` in \<) # Could happen if ports tree is out of date use_package=up_old_tree pm_v "===>>> Available package ($latest_pv)" @@ -3715,7 +3978,12 @@ grep -v ^$LOCALBASE_COMPAT > $pm_mktemp_file unset temp - for file in `pkg_info -q -L $UPGRADE_PORT | + if [ -z "$use_pkgng" ]; then + pkglist="pkg_info -q -L" + else + pkglist="pkg query %Fp" + fi + for file in `$pkglist $UPGRADE_PORT | sort - $pm_mktemp_file | uniq -d`; do temp="${temp}$file " done @@ -3738,6 +4006,7 @@ if [ -n "$REPLACE_ORIGIN" -a -n "$ro_upg_port" ]; then # Delete any existing versions of the old port + np_orphan=`pkg query "%a" $ro_upg_port` pm_sv "Running pkg_delete for $ro_upg_port" pm_pkg_delete_s -f $ro_upg_port fi @@ -3757,6 +4026,8 @@ unset preserve_port files esac + # Orphan state of $ro_upg_port has precedence + : ${np_orphan:=`pkg query "%a" $upg_port`} pm_sv "Running pkg_delete for $upg_port" pm_pkg_delete_s -f $upg_port fi @@ -3803,6 +4074,18 @@ unset port_log_args fi + if [ -z "$UPDATE_ALL" -a -z "$REPLACE_ORIGIN" -a -z "$PM_URB" -a "${np_orphan:-1}" -eq 1 ]; then + if [ -n "$PM_MULTI_PORTS" ]; then + case "$PM_MULTI_PORTS" in + *:${upg_port:-NONE}:*) np_orphan=0 ;; + *:${portdir}:*) np_orphan=0 ;; + esac + else + [ "$$" -eq "$PM_PARENT_PID" ] && np_orphan=0 + fi + fi + [ "${np_orphan:-1}" -eq 1 ] && PM_MAKE_ARGS="${PM_MAKE_ARGS} -DINSTALLS_DEPENDS" + unset np_orphan # Defining NO_DEPENDS ensures that we will control the installation # of the depends, not bsd.port.mk. eval pm_make_s -DNO_DEPENDS install $port_log_args || install_failed $new_port @@ -3820,29 +4103,31 @@ fi fi -for file in $preserve_port_files; do - mv $file ${file}-new - mv ${preserve_dir}/${file##*/} $file - oldmd5="MD5:`md5 -q $file`" - - pm_mktemp contents - while read left right; do - case "$left" in - @cwd) short_file="${file#${right}/}" ;; - $short_file) found_it=found_it ; continue;; - @comment) if [ -n "$found_it" ]; then - echo -e "${short_file}-new\n$left $right" - echo -e "$short_file\n@comment $oldmd5" - unset found_it - continue - fi ;; - esac - echo "$left $right" - done < $pdb/$new_port/+CONTENTS > $pm_mktemp_file - pm_install_s $pm_mktemp_file $contents - pm_unlink $pm_mktemp_file - unset file oldmd5 pm_mktemp_file left right short_file -done +if [ -z "$use_pkgng" ]; then + for file in $preserve_port_files; do + mv $file ${file}-new + mv ${preserve_dir}/${file##*/} $file + oldmd5="MD5:`md5 -q $file`" + + pm_mktemp contents + while read left right; do + case "$left" in + @cwd) short_file="${file#${right}/}" ;; + $short_file) found_it=found_it ; continue;; + @comment) if [ -n "$found_it" ]; then + echo -e "${short_file}-new\n$left $right" + echo -e "$short_file\n@comment $oldmd5" + unset found_it + continue + fi ;; + esac + echo "$left $right" + done < $pdb/$new_port/+CONTENTS > $pm_mktemp_file + pm_install_s $pm_mktemp_file $contents + pm_unlink $pm_mktemp_file + unset file oldmd5 pm_mktemp_file left right short_file + done +fi if [ -n "$preserve_dir" ]; then rmdir $preserve_dir 2>/dev/null unset preserve_dir preserve_port_files @@ -3858,14 +4143,19 @@ temp=`find $LOCALBASE_COMPAT -type d -empty 2>/dev/null` if [ -z "$temp" ] && [ -d "$LOCALBASE_COMPAT" ]; then unset files - for file in `pkg_info -q -L $new_port`; do + if [ -z "$use_pkgng" ]; then + pkglist="pkg_info -q -L" + else + pkglist="pkg query %Fp" + fi + for file in `$pkglist $new_port`; do [ -f "${LOCALBASE_COMPAT}/${file##*/}" ] && files="${files}${LOCALBASE_COMPAT}/${file##*/} " done if [ -n "$files" ]; then pm_sv Removing old shared libraries, and running ldconfig - pm_rm_s $files + pm_rm_s `make -V FILES:O:u FILES="$files"` $PM_SU_CMD /etc/rc.d/ldconfig start > /dev/null fi unset temp file files @@ -3917,11 +4207,13 @@ done pm_sv "Installing $dist_list\n" + pm_mkdir_s ${dist_list%/*} pm_install_s $pm_mktemp_file $dist_list /bin/unlink $pm_mktemp_file ; unset distinfo pm_mktemp_file file line fi -if [ -n "$use_package" ]; then +# pkgng does not need this +if [ -z "$use_pkgng" -a -n "$use_package" ]; then if grep -q DEPORIGIN $pdb/$new_port/+CONTENTS; then echo -e "===>>> Updating dependencies for $new_port to match installed versions\n" update_contents $pdb/$new_port/+CONTENTS ; pm_v @@ -3943,7 +4235,7 @@ if [ -n "$MAKE_PACKAGE" ]; then if [ -z "$use_package" ]; then echo "===>>> Creating a package for new version $new_port" - pm_make_s package >/dev/null || fail "Package creation of $new_port failed" + pm_make_s -D_OPTIONS_OK package >/dev/null || fail "Package creation of $new_port failed" echo " ===>>> Package saved to $PACKAGES/All" ; echo '' else pm_pkg_create $PACKAGES $new_port @@ -3956,29 +4248,37 @@ pm_v fi -check_dependency_files $portdir $new_port -if [ -s "$grep_deps" ]; then - echo -e "===>>> Updating dependency entry for $new_port in each dependent port\n" - while read d_port; do - pm_v "===>>> $d_port" - dp_cont=$pdb/$d_port/+CONTENTS - [ -e "$dp_cont" ] || continue - - if [ -n "$ro_opd" ] && grep -ql "DEPORIGIN:$ro_opd$" $dp_cont; then - update_contents $dp_cont $portdir $new_port $ro_opd - fi - # Do this one last so it can get deleted as a duplicate - # if ro_opd is present. - if grep -ql "DEPORIGIN:$portdir$" $dp_cont; then - update_contents $dp_cont $portdir $new_port - fi - done < $grep_deps - unset d_port dp_cont ; pm_v - - update_required_by $new_port - [ -n "$needws" ] && { pm_v; unset needws; } +if [ -z "$use_pkgng" ]; then + check_dependency_files $portdir $new_port + if [ -s "$grep_deps" ]; then + echo -e "===>>> Updating dependency entry for $new_port in each dependent port\n" + while read d_port; do + pm_v "===>>> $d_port" + dp_cont=$pdb/$d_port/+CONTENTS + [ -e "$dp_cont" ] || continue + + if [ -n "$ro_opd" ] && grep -ql "DEPORIGIN:$ro_opd$" $dp_cont; then + update_contents $dp_cont $portdir $new_port $ro_opd + fi + # Do this one last so it can get deleted as a duplicate + # if ro_opd is present. + if grep -ql "DEPORIGIN:$portdir$" $dp_cont; then + update_contents $dp_cont $portdir $new_port + fi + done < $grep_deps + unset d_port dp_cont ; pm_v + + update_required_by $new_port + [ -n "$needws" ] && { pm_v; unset needws; } + fi +else + if [ -n "$ro_opd" ]; then + echo "===>>> Updating dependency entry for $new_port in each dependent port" + pkg set -yo $ro_opd:$portdir + fi fi + if [ -n "$upg_port" ]; then if [ ! "$upg_port" = "$new_port" ]; then ilist="Upgrade of $upg_port to $new_port" @@ -3994,13 +4294,15 @@ fi INSTALLED_LIST="${INSTALLED_LIST}\t${ilist}\n" -[ -e "$pdb/$new_port/+DISPLAY" ] && DISPLAY_LIST="${DISPLAY_LIST}$new_port " +[ -z "$use_pkgng" -a -e "$pdb/$new_port/+DISPLAY" -o -n "$use_pkgng" -a -n "`pkg query "%M" $new_port`" ] && + DISPLAY_LIST="${DISPLAY_LIST}$new_port " CUR_DEPS="${CUR_DEPS}${new_port}:${portdir}:" [ -n "$HIDE_BUILD" -a -n "$port_log" ] && pm_unlink $port_log [ -n "$PM_URB" -o -n "$PM_URB_UP" ] && PM_URB_DONE="${PM_URB_DONE}${new_port}:" [ -n "$PM_URB" -o -n "$PM_URB_UP" -o -n "$PM_FORCE" ] && + pm_mkdir_s $pdb/$new_port && $PM_SU_CMD touch $pdb/$new_port/PM_UPGRADE_DONE_FLAG if [ -z "$DONT_SCRUB_DISTFILES" ]; thenhelp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMAY4VgiixdpFwyt5ZdWn_tjbXKVTJYw4objWSf8j2j1ZEheBg>
