# ==============================================================================
# portsreinstall library script
# - Operations for building the temporary database -
-# Copyright (C) 2013-2014 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
+# Copyright (C) 2013-2016 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
# This software is distributed under the 2-Clause BSD License.
# ==============================================================================
# ============= Update the current package name of a port =============
database_build_update_pkgname ()
{
- local origin pkg savefile
+ local origin pkg savefile origin_orig
origin=$1
savefile=${DBDIR}/requires/$origin/current_version
- pkg=`pkg_info_qO "$origin" || :`
- if [ -z "$pkg" -a -e "${DBDIR}/requires/$origin/initial_orig" ]
+ if [ -e "${DBDIR}/REVERSE_REPLACE.complete_sed_pattern" ]
then
- origin_orig=`cat "${DBDIR}/requires/$origin/initial_orig"`
- pkg=`pkg_info_qO "$origin_orig" || :`
+ origin_orig=`echo "$origin" \
+ | sed -E -f "${DBDIR}/REVERSE_REPLACE.complete_sed_pattern"` || :
+ [ "x$origin_orig" = "x$origin" ] && origin_orig=
+ else
+ origin_orig=
fi
- echo -n "$pkg" > $savefile
+ echo "$origin_orig" "$origin" | tr ' ' '\n' | grep -v '^$' | while read orig
+ do
+ pkg=`pkg_info_qO "$orig" || :`
+ if [ -z "$pkg" -a -e "${DBDIR}/requires/$orig/initial_orig" ]
+ then
+ orig_init=`cat "${DBDIR}/requires/$orig/initial_orig"`
+ pkg=`pkg_info_qO "$orig_init" || :`
+ fi
+ [ -n "$pkg" ] && echo "$pkg"
+ :
+ done > $savefile
cat "$savefile"
}
{
local origin pkg_cur pkg_new
origin=$1
- pkg_cur=`database_build_get_pkgname "$origin"`
+ pkg_cur=`database_build_get_pkgname "$origin" | tr '\n' ' ' | sed 's/ *$//'`
pkg_new=`database_build_get_new_pkgname "$origin"`
[ "x$pkg_cur" = "x$pkg_new" ]
}
do
database_build_make "$origin" $tag-depends-list \
| sed -E "s/^`str_escape_regexp "${PORTSDIR}"`\///" \
+ | grep -Ev "`pkgsys_pkgtools_ports_filter_regexp`" \
> $dbpath/requirements.$tag.orig || :
sed -E -f "${DBDIR}/conf/REPLACE.sed_pattern" "$dbpath/requirements.$tag.orig" \
| grep -v '^$' > $dbpath/requirements.$tag.src || :
# ============= Build and get a list of the complete recursive dependencies of a port =============
database_build_get_complete_recursive_dependency ()
{
- local table origin dbpath suffix dstfile
+ local table origin suffix tmpdb_parents dbpath srcfile dstfile loophead origin_esc tmppath dstfile_tmp
table=$1
origin=$2
suffix=$3
+ tmpdb_parents=${TMPDIR}/database_build_get_complete_recursive_dependency.parents
dbpath=${DBDIR}/requires/$origin
- [ -e "$dbpath/$table.direct$suffix" ] || return 0
+ srcfile=$dbpath/$table.direct$suffix
+ [ -e "$srcfile" ] || return 0
dstfile=$dbpath/$table.full$suffix
if [ ! -e "$dstfile" ]
then
- while read origin_requirement
- do
- echo "$origin_requirement"
- database_build_get_complete_recursive_dependency "$table" "$origin_requirement" "$suffix"
- done < $dbpath/$table.direct$suffix | sort -u > $dstfile.tmp
- mv "$dstfile.tmp" "$dstfile"
+ origin_esc=`str_escape_regexp "$origin"`
+ touch "$tmpdb_parents"
+ num_parents=`wc -l < $tmpdb_parents`
+ if grep -Eq "^$origin_esc$" "$tmpdb_parents"
+ then
+ loophead=`grep -En "^$origin_esc$" "$tmpdb_parents" | tail -n 1 | cut -d : -f 1`
+ if [ "x$opt_force_continuation_for_looped_dependency" = xno ]
+ then
+ message_echo 'ERROR: The following loop was found:' >&2
+ else
+ message_echo 'WARNING: The following loop was found:' >&2
+ fi
+ message_echo " $origin" >&2
+ sed -n $(($loophead+1)),\$p "$tmpdb_parents" | sed 's/^/ -->/' | message_cat >&2
+ message_echo " -->$origin" >&2
+ if [ "x$opt_force_continuation_for_looped_dependency" = xno ]
+ then
+ message_echo 'Resolve the problem manually if possible, and then restart by' >&2
+ message_echo " ${APPNAME} reset keepopts" >&2
+ message_echo " ${APPNAME}" >&2
+ message_echo 'Otherwise, you may attempt to forcibly continue by' >&2
+ message_echo " ${APPNAME} -f" >&2
+ exit 1
+ else
+ message_echo '(Forcibly continue)' >&2
+ fi
+ else
+ echo "$origin" >> $tmpdb_parents
+ tmppath=${TMPDIR}/requires/$origin
+ dstfile_tmp=$tmppath/$table.full$suffix
+ [ -d "$tmppath" ] || mkdir -p "$tmppath"
+ while read origin_requirement
+ do
+ echo "$origin_requirement"
+ database_build_get_complete_recursive_dependency "$table" "$origin_requirement" "$suffix"
+ done < $srcfile > $dstfile_tmp
+ sort -u "$dstfile_tmp" > $dstfile
+ rm "$dstfile_tmp"
+ head -n ${num_parents}p "$tmpdb_parents" > $tmpdb_parents.tmp
+ mv "$tmpdb_parents.tmp" "$tmpdb_parents"
+ fi
fi
cat "$dstfile"
}
origin_regexp=`str_escape_regexp "$origin"`
origin_esc=`str_escape_replaceval "$origin"`
echo "s/^$origin_orig_regexp$/$origin_esc/" >> ${DBDIR}/REPLACE.complete_sed_pattern.tmp
+ [ -z "$origin_regexp" ] && continue
echo "s/^$origin_regexp$/$origin_orig_esc/" >> ${DBDIR}/REVERSE_REPLACE.complete_sed_pattern.tmp
done
mv "${DBDIR}/REPLACE.complete_sed_pattern.tmp" "${DBDIR}/REPLACE.complete_sed_pattern"