# ==============================================================================
# portsreinstall library script
# - Wrappers for hiding version differences in the Ports/Packages system -
-# Copyright (C) 2013-2017 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
+# Copyright (C) 2013-2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
# This software is distributed under the 2-Clause BSD License.
# ==============================================================================
# ============= Variables =============
PKGSYS_USE_PKGNG=yes # no: legacy pkg_* tools, yes: the new generation package (pkgng)
-PKGSYS_CMD_PKG_INFO='pkg info' # Corresponding command for pkg_info
-PKGSYS_CMD_PKG_CREATE='pkg create' # Corresponding command for pkg_create
PKGSYS_CMD_PKG_DELETE='pkg delete' # Corresponding command for pkg_delete
-PKGSYS_CMD_PKG_ADD='pkg add' # Corresponding command for pkg_add
PKGSYS_AVR_REFETCH_TIMES_PER_SITE=1 # Average number (integer) of retrials for retrieving package or distfiles per mirror site
PKGSYS_AVR_REFETCH_TIMES_FOR_CHKSUMERR=2 # Number (integer) of retrials for check sum error in retrieving a package
# ============= Check implementation of the ports tree =============
pkgsys_chk_ports_tree_implementation ()
{
- local var tmp_work
+ fs_fix_unionfs_image_if_hidden "${PORTSDIR}/Mk/bsd.port.mk" || :
+ fs_fix_unionfs_image_if_hidden "${PORTSDIR}/Makefile" || :
if [ ! -d "${PORTSDIR}" ]
then
message_echo "ERROR: Ports directory ${PORTSDIR} is not found." >&2
tmp_work=${TMPDIR}/pkgsys_sysvar:work
rm -rf "$tmp_work"
mkdir "$tmp_work"
+ fs_fix_unionfs_image_if_hidden "${PORTSDIR}/Mk/bsd.port.mk"
make -C "$tmp_work" -f "${PORTSDIR}/Mk/bsd.port.mk" -V "$var" 2> /dev/null
}
}
# ============= Get the origin of the currently used pkg(8) =============
+# NOTE: Assumed to be unflavored.
pkgsys_portsmgmt_pkg ()
{
- local origin
+ local origin_unflavored
if [ ! -e "${DBDIR}/PKG_ORIGIN" ]
then
- origin=`pkgsys_sysvar PKG_ORIGIN` || :
- [ -n "$origin" -a -d "${PORTSDIR}/$origin" ] || origin=ports-mgmt/pkg
- echo "$origin" > ${DBDIR}/PKG_ORIGIN
+ origin_unflavored=`pkgsys_sysvar PKG_ORIGIN` || :
+ [ -n "$origin_unflavored" -a -d "${PORTSDIR}/$origin_unflavored" ] || origin_unflavored=ports-mgmt/pkg
+ echo "$origin_unflavored" > ${DBDIR}/PKG_ORIGIN
fi
cat "${DBDIR}/PKG_ORIGIN"
}
# ============= Get the origin of the currently used dialog4ports(1) =============
+# NOTE: Assumed to be unflavored.
pkgsys_portsmgmt_dialog4ports ()
{
- echo "$origin"
- local origin
+ local origin_unflavored
if [ ! -e "${DBDIR}/DIALOGPORT" ]
then
- origin=`pkgsys_sysvar DIALOGPORT` || :
- [ -n "$origin" -a -d "${PORTSDIR}/$origin" ] || origin=ports-mgmt/dialog4ports
- echo "$origin" > ${DBDIR}/DIALOGPORT
+ origin_unflavored=`pkgsys_sysvar DIALOGPORT` || :
+ [ -n "$origin_unflavored" -a -d "${PORTSDIR}/$origin_unflavored" ] || origin_unflavored=ports-mgmt/dialog4ports
+ echo "$origin_unflavored" > ${DBDIR}/DIALOGPORT
fi
cat "${DBDIR}/DIALOGPORT"
}
# ============= Check whether a port is indispensable for the standard function of the ports/packages system =============
pkgsys_is_pkgtool ()
{
- case $1 in
- ports-mgmt/pkg|ports-mgmt/pkg-devel|ports-mgmt/dialog4ports)
+ local origin origin_unflavored
+ origin=$1
+ origin_unflavored=`echo "$origin" | sed 's/@.*$//'`
+ case $origin_unflavored in
+ ports-mgmt/pkg | ports-mgmt/pkg-devel | ports-mgmt/dialog4ports | ports-mgmt/dialog4ports-static )
+ ;;
+ *) return 1
;;
- *) return 1;;
esac
}
# ============= Check whether a port is indispensable for package operations =============
pkgsys_is_necessary_pkgtool ()
{
- [ x"$WITH_PKGNG" = x'yes' -a \( x"$1" = x'ports-mgmt/pkg' -o x"$1" = x'ports-mgmt/pkg-devel' \) ]
+ local origin origin_unflavored
+ origin=$1
+ origin_unflavored=`echo "$origin" | sed 's/@.*$//'`
+ [ x"$WITH_PKGNG" = x'yes' -a \( x"$origin_unflavored" = x'ports-mgmt/pkg' -o x"$origin_unflavored" = x'ports-mgmt/pkg-devel' \) ]
}
# ============= Get the extended regular expression pattern of ports for pkg(8) =============
pkgsys_pkgtools_ports_filter_regexp ()
{
- echo '^ports-mgmt/(pkg|pkg-devel)$'
+ echo '^ports-mgmt/(pkg|pkg-devel)(|@.*)$'
+}
+
+# ============= Get the extended regular expression pattern of package names for pkg(8) =============
+pkgsys_pkgtools_pkgs_filter_regexp ()
+{
+ echo '^(pkg|pkg-devel)-[0-9]\.'
}
# ============= Check whether the dialog for selecting port options is dialog4ports =============
return 1
fi
needs_fetch=yes
- [ -d "${PKGREPOSITORY}" ] || mkdir -p "${PKGREPOSITORY}"
+ mkdir -p "${PKGREPOSITORY}"
if [ -e "${PKGREPOSITORY}/$pkg.tbz" ]
then
if [ -e "${PKGREPOSITORY}/$pkg.md5=$validMD5.tbz" ]
}
# ============= Check whether the dependency of a legacy package is the latest =============
-pkg_is_dependency_of_a_legacypkg_latest ()
+pkgsys_is_dependency_of_a_legacypkg_latest ()
{
local pkgarc tmp_extract tmp_contents tmp_origin tmp_pkg pkg nlines iline origin_req pkg_req pkg_new
pkgarc=$1
- tmp_extract=${TMPDIR}/pkgng:pkg_is_dependency_of_a_legacypkg_latest:extract
- tmp_contents=${TMPDIR}/pkgng:pkg_is_dependency_of_a_legacypkg_latest:contents
- tmp_origin=${TMPDIR}/pkgng:pkg_is_dependency_of_a_legacypkg_latest:origin
- tmp_pkg=${TMPDIR}/pkgng:pkg_is_dependency_of_a_legacypkg_latest:pkg
+ tmp_extract=${TMPDIR}/pkgng:pkgsys_is_dependency_of_a_legacypkg_latest:extract
+ tmp_contents=${TMPDIR}/pkgng:pkgsys_is_dependency_of_a_legacypkg_latest:contents
+ tmp_origin=${TMPDIR}/pkgng:pkgsys_is_dependency_of_a_legacypkg_latest:origin
+ tmp_pkg=${TMPDIR}/pkgng:pkgsys_is_dependency_of_a_legacypkg_latest:pkg
pkg=`pkgsys_pkgarc_to_pkgname "$pkgarc"`
[ -e "$pkgarc" ] || return
rm -rf "$tmp_extract"
which -s pkg_info
}
+# ============= Load portsnap.conf(5) for important directories =============
+pkgsys_load_portsnap_conf ()
+{
+ if which -s portsnap
+ then
+ PORTSNAP_WORKDIR=`sed -n '/^[[:space:]]*WORKDIR[[:space:]]*=[[:space:]]*\([^[:space:]#]*\)/s//\1/p' /etc/portsnap.conf || :`
+ PORTSNAP_WORKDIR=${PORTSNAP_WORKDIR:-/var/db/portsnap}
+ PORTSNAP_PORTSDIR=`sed -n '/^[[:space:]]*PORTSDIR[[:space:]]*=[[:space:]]*\([^[:space:]#]*\)/s//\1/p' /etc/portsnap.conf || :`
+ PORTSNAP_PORTSDIR=${PORTSNAP_PORTSDIR:-/usr/ports}
+ else
+ PORTSNAP_WORKDIR=
+ PORTSNAP_PORTSDIR=
+ fi
+}
+
# ============= Define wrapper commands for hiding the differences between pkg_* tools and pkgng =============
pkgsys_def_pkgtools ()
{
then
PKGSYS_USE_PKGNG=`cat "${DBDIR}/WITH_PKGNG"`
else
- PKGSYS_USE_PKGNG=`pkgsys_sysvar WITH_PKGNG | tr '[:upper:]' '[:lower:]'`
+ PKGSYS_USE_PKGNG=`pkgsys_sysvar WITH_PKG | tr '[:upper:]' '[:lower:]'`
+ [ -n "$PKGSYS_USE_PKGNG" ] || PKGSYS_USE_PKGNG=`pkgsys_sysvar WITH_PKGNG | tr '[:upper:]' '[:lower:]'`
if [ -d "${DBDIR}" ] && misc_is_superuser_privilege
then
echo "$PKGSYS_USE_PKGNG" > ${DBDIR}/WITH_PKGNG.tmp
fi
if [ "x$PKGSYS_USE_PKGNG" = xyes ]
then
+ export WITH_PKG=yes
export WITH_PKGNG=yes
- PKGSYS_CMD_PKG_INFO='pkg info'
- PKGSYS_CMD_PKG_CREATE='pkg create'
PKGSYS_CMD_PKG_DELETE='pkg delete'
- PKGSYS_CMD_PKG_ADD='pkg add'
pkg_is_tool_available ()
{
if [ -x /usr/sbin/pkg ]
{
pkg info -qa 2> /dev/null
}
- pkg_info_qoa ()
- {
- pkg info -qoa 2> /dev/null
- }
+# pkg_info_qoa ()
+# {
+# pkg info -qoa 2> /dev/null
+# }
# pkg_info_qox ()
# {
# pkg info -qox "$@" 2> /dev/null
# }
- pkg_info_qoX ()
- {
- pkg info -qox "$@" 2> /dev/null
- }
+# pkg_info_qoX ()
+# {
+# pkg info -qox "$@" 2> /dev/null
+# }
pkg_info_qO ()
{
pkg info -qO "$@" 2> /dev/null
}
pkg_info_eO ()
{
- pkg info -eO "$1" 2> /dev/null
+ pkg info -eO "$@" 2> /dev/null
}
pkg_info_Eg ()
{
{
pkg info -ql "$@" 2> /dev/null
}
+ pkg_info_flavor ()
+ {
+ local glob_unflavored
+ glob_unflavored=$1
+ pkg query -g '%At\t%Av' "$glob_unflavored" 2> /dev/null | grep -E '^flavor[[:space:]]' | cut -f 2
+ }
+ pkg_info_flavored_origin ()
+ {
+ local glob_unflavored origin_unflavored
+ glob_unflavored=$1
+ origin_unflavored=`pkg_info_qo "$glob_unflavored" 2> /dev/null || :`
+ flavor=`pkg_info_flavor "$glob_unflavored" 2> /dev/null || :`
+ [ -z "$flavor" ] || flavor=@$flavor
+ echo "$origin_unflavored$flavor"
+ }
+ pkg_info_all_flavored_origins ()
+ {
+ local tmp_flavored tmp_flavored_ptn
+ tmp_flavored_ptn=${TMPDIR}/pkg_info_all_flavored_origins:flavored_ptn
+ pkg query '%o\t%At\t%Av' 2> /dev/null | grep -E '^[^[:space:]]+[[:space:]]flavor[[:space:]]' | cut -f 1,3 | tr '\t' @ | sed 's/@$//'
+ pkg query '%n\t%At' 2> /dev/null | grep -E '^[^[:space:]]+[[:space:]]flavor$' | cut -f 1 > $tmp_flavored_ptn
+ pkg query '%n\t%o' 2> /dev/null | grep -vFx -f "$tmp_flavored_ptn" | cut -f 2
+ }
pkg_check_sanity ()
{
local pkg tmp_stdout tmp_stderr
tmp_stdout=${TMPDIR}/pkgng:pkg_check_sanity:stdout
tmp_stderr=${TMPDIR}/pkgng:pkg_check_sanity:stderr
pkg check -s "$pkg" > $tmp_stdout 2> $tmp_stderr || :
- grep '^[^:]*: checksum mismatch for ' "$tmp_stderr" | sed 's/^[^:]*: checksum mismatch for //' || :
- if grep -q '^pkg: .*: No such file or directory$' "$tmp_stderr"
- then
- pkg info -ql "$pkg" | while read filepath
- do
- [ -e "$filepath" ] || echo "$filepath"
- done
- fi
- :
+ {
+ grep '^[^:]*: checksum mismatch for ' "$tmp_stderr" | sed 's/^[^:]*: checksum mismatch for //' || :
+ grep '^[^:]*: missing file ' "$tmp_stderr" | sed 's/^[^:]*: missing file //' || :
+ if grep -q '^pkg: .*: No such file or directory$' "$tmp_stderr" # For the old specification of pkg(8)
+ then
+ pkg info -ql "$pkg" | while read filepath
+ do
+ [ -e "$filepath" ] || echo "$filepath"
+ done
+ fi
+ } | sort -u || :
}
pkg_which ()
{
}
pkg_info_gen_pkg_origin_table ()
{
- pkg query -g '%n-%v\t%o' \* 2> /dev/null > ${DBDIR}/installed_ports:pkg_vs_origin.tbl
+ # pkg query -g '%n-%v\t%o' \* 2> /dev/null > ${DBDIR}/installed_ports:pkg_vs_origin.tbl
+ pkg info -qa | while read pkgname
+ do
+ origin=`pkg_info_flavored_origin "$pkgname"`
+ printf '%s\t%s\n' "$pkgname" "$origin"
+ done > ${DBDIR}/installed_ports:pkg_vs_origin.tbl
}
pkg_create_b ()
{
}
pkg_delete_f ()
{
- pkg delete -fqy "$@"
+ local opt_del
+ opt_del=
+ [ $no_exec_inst_script = yes ] && opt_del='-D'
+ pkg delete -fqy $opt_del "$@"
pkg -N 2> /dev/null || return 0 # If pkg(8) is deinstalled successfully
pkg info -e "$@" || return 0 # Countermeasure for a bug found for pkg-1.3.4 (at least not until 1.2.7_4)
- pkg delete -fy "$@"
+ pkg delete -fy $opt_del "$@"
}
pkg_add_tools ()
{
rm -rf "$tmp_extract"
mkdir "$tmp_extract"
tar xf "$pkgarc" -C "$tmp_extract"
- prefix=`grep -m 1 '^prefix: ' "$tmp_extract/+MANIFEST" | sed 's/^prefix: *//'`
- prefix_parent=`dirname "$prefix"`
- cp -Rp "$tmp_extract/$prefix" "$prefix_parent"/
pkg=`pkgsys_pkgarc_to_pkgname "$pkgarc"`
- message_echo "INFO: Contents of $pkg are temporarily installed by simple copy."
- if env ASSUME_ALWAYS_YES=YES pkg add "$pkgarc"
+ if env ASSUME_ALWAYS_YES=YES $tmp_extract/usr/local/sbin/pkg-static add "$pkgarc"
then
message_echo "INFO: $pkg is successfully registered."
else
}
pkg_add_f ()
{
- local pkgarc pkg pkg_tool pkg_gen
+ local pkgarc pkg pkg_tool pkg_gen opt_add
pkg_tool=
pkg_gen=
for pkgarc in "$@"
fi
done
[ -n "$pkg_tool" ] && pkg_add_tools "$pkg_tool"
- [ -n "$pkg_gen" ] && env ASSUME_ALWAYS_YES=YES pkg add $pkg_gen
+ if [ -n "$pkg_gen" ]
+ then
+ rm -rf "${TMPDIR}/pkg_add_f"
+ mkdir -p "${TMPDIR}/pkg_add_f"
+ opt_add=
+ [ $no_exec_inst_script = yes ] && opt_add='-I'
+ ( cd "${TMPDIR}/pkg_add_f" && ln -s $pkg_gen && env ASSUME_ALWAYS_YES=YES pkg add $opt_add * )
+ fi
}
pkg_add_fF ()
{
pkg_add_f "$@"
}
+ pkg_inst_verify_pkg ()
+ {
+ local pkg pkgarc
+ pkg=$1
+ pkgarc=`pkgsys_pkgname_to_pkgarc "${PKGNG_PKG_CACHEDIR}" "$pkg"` || return
+ tar tf "$pkgarc" > /dev/null 2> /dev/null
+ }
pkg_inst_remote_fetch ()
{
- local pkg mode pkgarc
+ local pkg
pkg=$1
- mode=$2
- tmp_extract=${TMPDIR}/pkgng:pkg_inst_remote:extract
- pkg fetch -yU "$pkg" || return
- pkgarc=`pkgsys_pkgname_to_pkgarc "${PKGNG_PKG_CACHEDIR}/All" "$pkg"` || return
- [ "x$mode" = xnodepschk ] && return
- rm -rf "$tmp_extract"
- mkdir "$tmp_extract"
- tar xf "$pkgarc" -C "$tmp_extract" +MANIFEST
- sed -E '1,/^deps:/d;/^[^[:space:]]/,$d;s/^[[:space:]]*([^:]+):[[:space:]]*\{origin:[[:space:]]*([^,]+),[[:space:]]*version:[[:space:]]*([^}]+)\}/\2\\\1-\3/' "$tmp_extract/+MANIFEST" \
- | tr '\\' '\t' | while read origin_req pkg_req
- do
- pkg_new=`cat "${DBDIR}/requires/$origin_req/new_version" 2> /dev/null` || :
- if [ -z "$pkg_new" -o "$pkg_new" != "$pkg_req" ]
- then
- message_echo "WARNING: Requirements of remote package $pkg are not latest." >&2
- return 1
- fi
- done
- :
+ pkg fetch -yU "$pkg"
+ }
+ pkg_inst_remote_verify_fetch ()
+ {
+ local pkg
+ pkg=$1
+ pkg_inst_verify_pkg "$pkg" && return
+ pkg_inst_remote_fetch "$pkg" && pkg_inst_verify_pkg "$pkg"
}
pkg_inst_remote ()
{
- local pkg mode pkgarc
+ local pkg pkgarc opt_add
pkg=$1
- mode=$2
- pkg_inst_remote_fetch "$pkg" "$mode" || return
- pkgarc=`pkgsys_pkgname_to_pkgarc "${PKGNG_PKG_CACHEDIR}/All" "$pkg"` || return
- env ASSUME_ALWAYS_YES=YES pkg add "$pkgarc"
+ pkg_inst_remote_verify_fetch "$pkg" || return
+ pkgarc=`pkgsys_pkgname_to_pkgarc "${PKGNG_PKG_CACHEDIR}" "$pkg"` || return
+ rm -rf "${TMPDIR}/pkg_inst_remote"
+ mkdir -p "${TMPDIR}/pkg_inst_remote"
+ opt_add=
+ [ $no_exec_inst_script = yes ] && opt_add='-I'
+ ( cd "${TMPDIR}/pkg_inst_remote" && ln -s "$pkgarc" && env ASSUME_ALWAYS_YES=YES pkg add $opt_add * )
+ }
+ pkg_inst_wild_verify_pkg ()
+ {
+ local pkg pkgarc
+ pkg=$1
+ pkgarc=`pkgsys_pkgname_to_pkgarc "${PKGNG_PKG_CACHEDIR}" "$pkg"` || return
+ pkgsys_is_dependency_of_a_legacypkg_latest "$pkgarc"
}
pkg_inst_remote_wild_fetch ()
{
- local pkg mode pkgarc
+ local pkg
pkg=$1
- mode=$2
if pkg_is_tool_available
then
- pkg_inst_remote "$pkg" "$mode" && return
+ pkg_inst_remote "$pkg" && return
fi
pkgsys_is_legacy_tool_available || return
message_echo "INFO: Trying to use a legacy package and convert it to pkgng."
- pkgsys_fetch_legacy_remote "$pkg" || return
- pkgarc=`pkgsys_fetch_legacy_remote__fetched_pkg`
- [ "x$mode" = xnodepschk ] && return
- pkg_is_dependency_of_a_legacypkg_latest "$pkgarc"
+ pkgsys_fetch_legacy_remote "$pkg"
+ }
+ pkg_inst_remote_wild_verify_fetch ()
+ {
+ local pkg
+ pkg=$1
+ pkg_inst_wild_verify_pkg "$pkg" && return
+ pkg_inst_remote_wild_fetch "$pkg" && pkg_inst_wild_verify_pkg "$pkg"
}
pkg_inst_remote_wild ()
{
- local pkg mode pkgarc
+ local pkg pkgarc opt_add
pkg=$1
- mode=$2
- pkg_inst_remote_wild_fetch "$pkg" "$mode" || return
- pkgarc=`pkgsys_fetch_legacy_remote__fetched_pkg`
- pkg_add -ifF "$pkgarc" || return
- message_echo "INFO: Trying to convert the installed legacy package to pkgng."
- pkg2ng || :
- message_echo "INFO: Checking whether the conversion is successful."
- pkg info -e "$pkg"
+ if pkg_inst_remote_wild_verify_fetch "$pkg"
+ then
+ pkgarc=`pkgsys_fetch_legacy_remote__fetched_pkg`
+ rm -rf "${TMPDIR}/pkg_inst_remote_wild"
+ mkdir -p "${TMPDIR}/pkg_inst_remote_wild"
+ opt_add=
+ [ $no_exec_inst_script = yes ] && opt_add='-I'
+ ( cd "${TMPDIR}/pkg_inst_remote_wild" && ln -s "$pkgarc" && pkg_add -ifF $opt_add * ) || return
+ message_echo "INFO: Trying to convert the installed legacy package to pkgng."
+ pkg2ng || :
+ message_echo "INFO: Checking whether the conversion is successful."
+ pkg info -e "$pkg"
+ fi
+ }
+ pkg_get_remote_repository_version ()
+ {
+ local origin origin_unflavored pkg
+ origin=$1
+ origin_unflavored=`expr "$origin" : '\([^@]*\)'` || return
+ [ -n "$origin_unflavored" ] || return
+ pkg fetch -qyU "$origin_unflavored" > /dev/null || return
+ pkg=`pkg rquery -U %n-%v "$origin_unflavored"` || return
+ echo "$pkg"
+ }
+ pkg_get_pkgs_timestamps ()
+ {
+ pkg query '%n-%v\tng-epoch:%t' "$@"
+ }
+ pkg_get_pkg_timestamp ()
+ {
+ local pkg
+ pkg=$1
+ pkg query '%t' "$pkg"
}
pkg_loadconf ()
{
var=`expr "$srcline" : '^[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*:.*'` || :
val=`expr "$srcline" : '^[[:space:]]*[A-Z0-9_]*[[:space:]]*:[[:space:]]*\(.*\)'` || :
eval PKGNG_$var=\$val
- misc_get_all_vardefs | grep -E "^PKGNG_$var="
+ misc_get_all_vardefs | grep "^PKGNG_$var="
done > ${TMPDIR}/pkgsys_def_pkgtools:pkg.conf.sh
. "${TMPDIR}/pkgsys_def_pkgtools:pkg.conf.sh"
}
pkg_rescue_tools ()
{
- local packagepath checksumpath pkgname is_successful
- packagepath=`pkgsys_get_backup_pkg \`pkgsys_portsmgmt_pkg\`` && \
+ local origin_portsmgmt packagepath checksumpath pkgname is_successful
+ origin_portsmgmt=`pkgsys_portsmgmt_pkg`
+ packagepath=`pkgsys_get_backup_pkg "$origin_portsmgmt"` && \
pkg_add_tools "$packagepath" && return
pkg_is_tool_available && return
- message_echo "WARNING: WITH_PKGNG is set, but pkgng is still missing. It is installed now." >&2
+ message_echo "WARNING: WITH_PKG or WITH_PKGNG is set, but pkgng is still missing. It is installed now." >&2
pkgsys_ready_checksum_file || return
message_echo "INFO: Installing pkgng by legacy package tool."
checksumpath=`pkgsys_ready_checksum_file__fetched_file`
pkgname=`sed 's/^MD5[[:space:]]*(//;s/\.tbz)[[:space:]]*=[^=]*$//' "$checksumpath" \
- | grep -m 1 -E -e "^pkg-[0-9]"` || :
- [ -n "$pkgname" ] && pkg_inst_remote_wild "$pkgname" nodepschk && return
+ | grep -m 1 '^pkg-[0-9]'` || :
+ [ -n "$pkgname" ] && pkg_inst_remote_wild "$pkgname" && return
message_echo "INFO: Failed by package, so installing pkgng by port."
- grep -v '^[[:space:]]*WITH_PKGNG=' /etc/make.conf > ${TMPDIR}/make.conf
+ grep -Ev '^[[:space:]]*WITH_PKG(|NG)=' /etc/make.conf > ${TMPDIR}/make.conf 2> /dev/null || :
+ echo WITHOUT_PKG=yes >> ${TMPDIR}/make.conf
echo WITHOUT_PKGNG=yes >> ${TMPDIR}/make.conf
( set -e
+ unset WITH_PKG
unset WITH_PKGNG
+ unset WITHOUT_PKG
unset WITHOUT_PKGNG
-
message_echo "INFO: Attempting deinstallation of pkg(8) to make sure."
- env __MAKE_CONF="${TMPDIR}/make.conf" make -C "${PORTSDIR}/`pkgsys_portsmgmt_pkg`" deinstall || :
+ portsmgmt_port_path=`pkgsys_get_portpath_from_origin "$origin_portsmgmt"`
+ fs_fix_unionfs_image_if_hidden "${TMPDIR}/make.conf"
+ env __MAKE_CONF="${TMPDIR}/make.conf" make -C "$portsmgmt_port_path" deinstall || :
message_echo "INFO: Attempting (re)installation by pkg(8)."
- env __MAKE_CONF="${TMPDIR}/make.conf" make -C "${PORTSDIR}/`pkgsys_portsmgmt_pkg`" reinstall clean
+ env __MAKE_CONF="${TMPDIR}/make.conf" make -C "$portsmgmt_port_path" reinstall clean
) && {
pkg2ng || :
pkg_is_tool_available
message_echo "ERROR: Pkgng is disabled although the legacy packages tools are unavailable. Resolve the problem manually." >&2
exit 1
else
+ unset WITH_PKG
unset WITH_PKGNG
PKGSYS_USE_PKGNG=no
- PKGSYS_CMD_PKG_INFO='pkg_info'
- PKGSYS_CMD_PKG_CREATE='pkg_create'
PKGSYS_CMD_PKG_DELETE='pkg_delete'
- PKGSYS_CMD_PKG_ADD='pkg_add'
pkg_is_tool_available ()
{
pkgsys_is_legacy_tool_available
{
pkg_info -Ea 2> /dev/null
}
- pkg_info_qoa ()
- {
- pkg_info -qoa 2> /dev/null
- }
+# pkg_info_qoa ()
+# {
+# pkg_info -qoa 2> /dev/null
+# }
# pkg_info_qox ()
# {
# pkg_info -qox "$@" 2> /dev/null
# }
- pkg_info_qoX ()
- {
- pkg_info -qoX "$@" 2> /dev/null
- }
+# pkg_info_qoX ()
+# {
+# pkg_info -qoX "$@" 2> /dev/null
+# }
pkg_info_qO ()
{
pkg_info -qO "$@" 2> /dev/null
}
pkg_info_qr ()
{
- pkg_info -qr "$@" | grep '^@pkgdep ' | sed 's/^@pkgdep[[:space:]]*//' 2> /dev/null
+ pkg_info -qr "$@" 2> /dev/null | sed -n 's/^@pkgdep[[:space:]]*//p'
}
pkg_info_e ()
{
}
pkg_info_eO ()
{
- [ `pkg_info -qO "$1" 2> /dev/null | wc -l` -gt 0 ]
+ [ `pkg_info -qO "$@" 2> /dev/null | wc -l` -gt 0 ]
}
pkg_info_Eg ()
{
}
pkg_info_qR ()
{
- pkg_info -qR "$@" | grep -v '^$' 2> /dev/null
+ pkg_info -qR "$@" 2> /dev/null | grep -v '^$'
}
pkg_info_Ex ()
{
{
pkg_info -qL "$@" 2> /dev/null
}
+ pkg_info_flavor ()
+ {
+ pkg_info -e "$@" 2> /dev/null && echo
+ :
+ }
+ pkg_info_flavored_origin ()
+ {
+ local glob_unflavored tmp_stdout
+ glob_unflavored=$1
+ pkg_info_qo "$glob_unflavored" 2> /dev/null
+ }
+ pkg_info_all_flavored_origins ()
+ {
+ pkg_info_qoa 2> /dev/null
+ }
pkg_check_sanity ()
{
local pkg tmp_stdout tmp_stderr
tmp_stdout=${TMPDIR}/pkgng:pkg_check_sanity:stdout
tmp_stderr=${TMPDIR}/pkgng:pkg_check_sanity:stderr
pkg_info -qg "$pkg" > $tmp_stdout 2> $tmp_stderr || :
- grep ' fails the original MD5 checksum$' "$tmp_stdout" | sed 's/ fails the original MD5 checksum$//' || :
- grep "^pkg_info: .* doesn't exist$" "$tmp_stderr" | sed -E "s/^pkg_info: (.*) doesn't exist$/\1/" || :
+ sed -n 's/ fails the original MD5 checksum$//p' "$tmp_stdout" 2> /dev/null || :
+ sed -nE "s/^pkg_info: (.*) doesn't exist$/\1/p" "$tmp_stderr" 2> /dev/null || :
}
pkg_which ()
{
}
pkg_delete_f ()
{
- pkg_delete -f "$@"
+ local opt_del
+ opt_del=
+ [ $no_exec_inst_script = yes ] && opt_del='-D'
+ pkg_delete -f $opt_del "$@"
}
pkg_add_f ()
{
- pkg_add -if "$@"
+ local opt_add
+ rm -rf "${TMPDIR}/pkg_add_f"
+ mkdir -p "${TMPDIR}/pkg_add_f"
+ ln -s "$@" "${TMPDIR}/pkg_add_f"
+ opt_add=
+ [ $no_exec_inst_script = yes ] && opt_add='-I'
+ ( cd "${TMPDIR}/pkg_add_f" && pkg_add -if $opt_add * )
}
pkg_add_fF ()
{
- pkg_add -ifF "$@"
+ local opt_add
+ rm -rf "${TMPDIR}/pkg_add_f"
+ mkdir -p "${TMPDIR}/pkg_add_f"
+ ln -s "$@" "${TMPDIR}/pkg_add_f"
+ opt_add=
+ [ $no_exec_inst_script = yes ] && opt_add='-I'
+ ( cd "${TMPDIR}/pkg_add_f" && pkg_add -ifF $opt_add * )
+ }
+ pkg_inst_verify_pkg ()
+ {
+ local pkg pkgarc
+ pkg=$1
+ pkgarc=`pkgsys_fetch_legacy_remote__fetched_pkg` || return
+ pkgsys_is_dependency_of_a_legacypkg_latest "$pkgarc"
}
pkg_inst_remote_fetch ()
{
- local pkg mode pkgarc
+ local pkg
pkg=$1
- mode=$2
- pkgsys_fetch_legacy_remote "$pkg" || return
- pkgarc=`pkgsys_fetch_legacy_remote__fetched_pkg`
- [ "x$mode" = xnodepschk ] && return
- pkg_is_dependency_of_a_legacypkg_latest "$pkgarc"
+ pkgsys_fetch_legacy_remote "$pkg"
+ }
+ pkg_inst_remote_verify_fetch ()
+ {
+ local pkg
+ pkg=$1
+ pkg_inst_verify_pkg "$pkg" && return
+ pkg_inst_remote_fetch "$pkg" && pkg_inst_verify_pkg "$pkg"
}
pkg_inst_remote ()
{
- local pkg mode pkgarc
+ local pkg pkgarc opt_add
pkg=$1
- mode=$2
- pkg_inst_remote_fetch "$pkg" "$mode" || return
- pkgarc=`pkgsys_fetch_legacy_remote__fetched_pkg`
- pkg_add "$pkgarc" || return
+ if pkg_inst_remote_verify_fetch "$pkg"
+ then
+ pkgarc=`pkgsys_fetch_legacy_remote__fetched_pkg`
+ rm -rf "${TMPDIR}/pkg_inst_remote"
+ mkdir -p "${TMPDIR}/pkg_inst_remote"
+ ln -s "$@" "${TMPDIR}/pkg_add_f"
+ opt_add=
+ [ $no_exec_inst_script = yes ] && opt_add='-I'
+ ( cd "${TMPDIR}/pkg_inst_remote" && ls -s "$pkgarc" && pkg_add -ifF $opt_add * )
+ fi
+ }
+ pkg_inst_wild_verify_pkg ()
+ {
+ pkg_inst_verify_pkg "$@"
}
pkg_inst_remote_wild_fetch ()
{
- pkg_inst_remote_fetch "$1" "$2"
+ pkg_inst_remote_fetch "$@"
+ }
+ pkg_inst_remote_wild_verify_fetch ()
+ {
+ pkg_inst_remote_verify_fetch "$@"
}
pkg_inst_remote_wild ()
{
- pkg_inst_remote "$1" "$2"
+ pkg_inst_remote "$@"
+ }
+ pkg_get_remote_repository_version ()
+ {
+ local origin checksumpath version_regexp pkgbase_regexp pkg
+ origin=$1
+ pkgsys_ready_checksum_file > /dev/null || return
+ checksumpath=`pkgsys_ready_checksum_file__fetched_file`
+ version_regexp=`database_build_make "$origin" -V PORTVERSION | str_escape_regexp_filter`
+ pkgbase_regexp=`database_build_get_new_pkgname "$origin" | sed -E "s/$version_regexp$//" | str_escape_regexp_filter`
+ pkg=`sed -nE "s/^MD5[[:space:]]*\(($pkgbase_regexp.*)\.tbz\)[[:space:]]*=.*/\1/p" "$checksumpath" | head -n 1`
+ echo "$pkg"
+ }
+ pkg_get_pkgs_timestamps ()
+ {
+ ls -lD legacy:%s ${PKG_DBDIR} | \
+ sed -E 's/[[:space:]]+/ /g' | cut -w -f 6,7 | grep -v '^$' | \
+ sed -E 's/^([^[:space:]]*)[[:space:]]*([^[:space:]]*)/\2 \1/' | tr ' ' '\t'
+ }
+ pkg_get_pkg_timestamp ()
+ {
+ local pkg portdb
+ pkg=$1
+ portdb=`echo "$pkg" | sed 's/-[0-9].*//'`
+ ls -lD legacy:%s "${PKG_DBDIR}/$portdb" | \
+ sed -E 's/[[:space:]]+/ /g' | cut -w -f 6 | grep -v '^$'
}
pkg_loadconf () { :; }
pkg_rescue_tools () { :; }
fi
}
-# ============= Check existence of initially or currently installed package for an origin =============
-pkgsys_pkg_info_eO ()
+# ============= Get the unflavored part of a flavored origin =============
+pkgsys_get_unflavored_origin ()
{
- local origin origin_regexp
+ local origin origin_unflavored
+ origin=$1
+ origin_unflavored=`echo "$origin" | sed 's/@.*$//'`
+ echo "$origin_unflavored"
+}
+
+# ============= Get the port path from a flavored origin =============
+pkgsys_get_portpath_from_origin ()
+{
+ local origin origin_unflavored
+ origin=$1
+ origin_unflavored=`pkgsys_get_unflavored_origin "$origin"`
+ echo "${PORTSDIR}/$origin_unflavored"
+}
+
+# ============= Get the flavor from a flavored origin =============
+pkgsys_get_flavor_from_origin ()
+{
+ local origin flavor
+ origin=$1
+ flavor=`echo "$origin" | sed -E 's/^[^@]*@?//'`
+ echo "$flavor"
+}
+
+# ============= Compose a flavored origin name =============
+pkgsys_compose_flavored_origin ()
+{
+ local origin flavor
+ origin=$1
+ flavor=$2
+ origin_unflavored=`pkgsys_get_unflavored_origin "$origin"`
+ [ -z "$flavor" ] || flavor=@$flavor
+ echo "$origin_unflavored$flavor"
+}
+
+# ============= Check existence of a port for a flavored origin =============
+pkgsys_exists_port ()
+{
+ local origin port_path
+ origin=$1
+ port_path=`pkgsys_get_portpath_from_origin "$origin"`
+ [ -d "$port_path" ]
+}
+
+# ============= Get the installed package name from a flavored origin =============
+pkgsys_get_installed_pkg_from_origin ()
+{
+ local origin origin_unflavored flavor_origin flavor_pkg
+ origin=$1
+ origin_unflavored=`pkgsys_get_unflavored_origin "$origin"`
+ flavor_origin=`pkgsys_get_flavor_from_origin "$origin"`
+ pkg_info_qO "$origin_unflavored" 2> /dev/null | while read pkgname
+ do
+ flavor_pkg=`pkg_info_flavor "$pkgname"`
+ if [ "x$flavor_origin" = "x$flavor_pkg" ]
+ then
+ echo "$pkgname"
+ break
+ fi
+ done
+ :
+}
+
+# ============= Get the installed package name from glob patterns =============
+pkgsys_get_installed_pkg_from_glob ()
+{
+ local glob regexp
+ for glob in "$@"
+ do
+ if regexp=`expr "$glob" : ':\(.*\)'`
+ then
+ pkg_info_Ex "$regexp"
+ else
+ pkg_info_Eg "$glob"
+ fi
+ done | sort -u
+}
+
+# ============= Check existence of an installed package for a flavored origin =============
+pkgsys_exists_from_orig ()
+{
+ local origin origin_unflavored flavor_origin flavor_pkg
+ origin=$1
+ origin_unflavored=`pkgsys_get_unflavored_origin "$origin"`
+ pkg_info_eO "$origin_unflavored" 2> /dev/null || return
+ flavor_origin=`pkgsys_get_flavor_from_origin "$origin"`
+ flavor_pkg=`pkg_info_flavor "$origin_unflavored"`
+ [ "x$flavor_origin" = "x$flavor_pkg" ]
+}
+
+# ============= Check existence of initially or currently installed package for a flavored origin =============
+pkgsys_exists_or_existed_from_orig ()
+{
+ local origin
origin=$1
- origin_regexp=`str_escape_regexp "$origin"`
cut -f 2 "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
- | grep -q -E "^$origin_regexp$" && return
- pkg_info_eO "$origin"
+ | grep -q -Fx "$origin" || pkgsys_exists_from_orig "$origin"
}
-# ============= Get the name of an initially installed package for an origin =============
-pkgsys_pkg_info_qO_init ()
+# ============= Get the name of an initially installed package for a flavored origin =============
+pkgsys_get_init_pkg_from_orig ()
{
- local origin tmppkg origin_regexp npkgs
+ local origin tmppkg origin_regexp npkgs origin_unflavored flavor_origin flavor_pkg
origin=$1
- tmppkg=${TMPDIR}/pkgsys_pkg_info_qO_init::pkg
+ tmppkg=${TMPDIR}/pkgsys_get_init_pkg_from_orig::pkg
origin_regexp=`str_escape_regexp "$origin"`
sed -n -E "/[[:space:]]$origin_regexp$/p" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
| cut -f 1 > $tmppkg || :
then
cat "$tmppkg"
else
- pkg_info_qO "$origin"
+ origin_unflavored=`pkgsys_get_unflavored_origin "$origin"`
+ flavor_origin=`pkgsys_get_flavor_from_origin "$origin"`
+ pkg_info_qO "$origin_unflavored" 2> /dev/null | while read pkgname
+ do
+ flavor_pkg=`pkg_info_flavor "$pkgname"`
+ if [ "x$flavor_origin" = "x$flavor_pkg" ]
+ then
+ echo "$pkgname"
+ break
+ fi
+ done
fi
+ :
}
# ============= Get the package name of this utility =============
pkg_info_Ex "${APPNAME}-[0-9].*"
}
-# ============= Get the origin of this utility =============
+# ============= Get the flavored origin of this utility =============
pkgsys_get_my_origin ()
{
- pkg_info_qo "`pkgsys_get_my_current_pkg`"
+ pkgsys_get_my_current_pkg | while read pkgname
+ do
+ pkg_info_flavored_origin "$pkgname"
+ done
}
-# ============= Get the origin of an initially installed package by ambiguous matching =============
+# ============= Get the flavored origin of an initially installed package by ambiguous matching =============
pkgsys_init_pkg_orig_by_ambiguous_matching ()
{
local pkg origin tmporigin ambsuffix len_pkg pkg_regexp norigins
pkg=$1
- origin=`pkg_info_qo "$pkg" || :`
+ origin=`pkg_info_flavored_origin "$pkg"`
[ -n "$origin" ] && { echo "$origin"; return; }
tmporigin=${TMPDIR}/pkgsys_init_pkg_orig_by_ambiguous_matching::origin
ambsuffix=
fi
}
-# ============= Evaluation of ports globs =============
+# ============= Evaluation of flavored ports globs =============
pkgsys_eval_ports_glob ()
{
- local pkglist origlist
+ local pkglist unflavored_origlist tmp_flavors
pkglist=${DBDIR}/pkgsys_eval_ports_glob:pkg.lst
- origlist=${DBDIR}/pkgsys_eval_ports_glob:origin.lst
+ unflavored_origlist=${DBDIR}/pkgsys_eval_ports_glob:origin_unflavored.lst
+ tmp_flavors=${TMPDIR}/pkgsys_eval_ports_glob:flavors
+ # Test the access privilege as the superuser or not
if [ ! -r "$pkglist" ]
then
if touch "$pkglist" 2>/dev/null
pkglist=${TMPDIR}/pkgsys_eval_ports_glob:pkg.lst
fi
fi
- if [ ! -r "$origlist" ]
+ if [ ! -r "$unflavored_origlist" ]
then
- if touch "$origlist" 2>/dev/null
+ if touch "$unflavored_origlist" 2>/dev/null
then
- rm "$origlist"
+ rm "$unflavored_origlist"
else
- origlist=${TMPDIR}/pkgsys_eval_ports_glob:origin.lst
+ unflavored_origlist=${TMPDIR}/pkgsys_eval_ports_glob:origin.lst
fi
fi
+ # Preparation of customized databases
[ -f "$pkglist" ] \
|| cut -d \| -f 1 "${PORTS_INDEX_DB}" > $pkglist
- [ -f "$origlist" ] \
+ [ -f "$unflavored_origlist" ] \
|| cut -d \| -f 2 "${PORTS_INDEX_DB}" \
- | sed -E "s/^`str_escape_regexp "${PORTSDIR}"`\///" > $origlist
+ | sed -E "s/^`str_escape_regexp "${PORTSDIR}"`\///" > $unflavored_origlist
+ # Evaluation
while [ $# -gt 0 ]
do
glob=$1
glob_regexp=`str_convert_portsglob_to_regexp_pattern "$glob"`
if expr "$glob" : '.*/' > /dev/null 2>&1
then
- grep -E "$glob_regexp" "$origlist" 2>&1 || :
+ if expr "$glob" : '.*@' > /dev/null 2>&1
+ then
+ glob_regexp_unflavored=`expr "$glob_regexp" : '\([^@]*\)' || :`$
+ glob_regexp_flavor=^`expr "$glob_regexp" : '[^@]*@\([^@]*\)' || :`
+
+ grep -E "$glob_regexp_unflavored" "$unflavored_origlist" 2>&1 | while read origin_unflavored
+ do
+ fs_fix_unionfs_image_if_hidden "${PORTSDIR}/$origin_unflavored"
+ make -C "${PORTSDIR}/$origin_unflavored" -V FLAVORS 2> /dev/null | \
+ tr '[:space:]' '\n' | grep -v '^$' | grep -E "$glob_regexp_flavor" | sed -E "s|^|$origin_unflavored@|"
+ done
+ {
+ pkg_info_all_flavored_origins
+ cut -f 2 "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null
+ } | grep -E "$glob_regexp" 2>&1 || :
+ else
+ grep -E "$glob_regexp" "$unflavored_origlist" 2>&1 | while read origin_unflavored
+ do
+ origin_unflavored_rpl=`str_escape_replaceval "$origin_unflavored"`
+ fs_fix_unionfs_image_if_hidden "${PORTSDIR}/$origin_unflavored"
+ make -C "${PORTSDIR}/$origin_unflavored" -V FLAVORS 2> /dev/null | \
+ tr '[:space:]' '\n' | grep -v '^$' > $tmp_flavors || :
+ if [ `wc -l < $tmp_flavors` -gt 0 ]
+ then
+ sed -E "s|^|$origin_unflavored_rpl@|" "$tmp_flavors"
+ else
+ echo "$origin_unflavored"
+ fi
+ done
+ fi
+ glob_regexp_allflavors=`echo "$glob_regexp" | sed 's/$$/(|@.*)$/'`
{
- pkg_info_qoa
+ pkg_info_all_flavored_origins
cut -f 2 "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null
- } | grep -E "$glob_regexp" 2>&1 || :
+ } | grep -E "$glob_regexp_allflavors" 2>&1 || :
else
- if expr "$glob" : '^[a-z][a-zA-Z0-9_.+-]*[a-zA-Z0-9_.+]$' > /dev/null 2>&1 && \
+ if expr "$glob" : '[a-z][a-zA-Z0-9_.+-]*[a-zA-Z0-9_.+]$' > /dev/null 2>&1 && \
[ `expr "$glob" : '.*-[0-9]' 2>&1` -eq 0 ]
then
- glob_regexp2=`expr "$glob_regexp" : '\(.*\)\$$' 2>&1`'-[0-9]'
+ glob_regexp2=`expr "$glob_regexp" : '\(.*\)\$$' 2>&1 || :`'-[0-9]'
else
glob_regexp2=$glob_regexp
fi
grep -n -E "$glob_regexp2" "$pkglist" 2>&1 | cut -d : -f 1 \
| while read index
do
- sed -n ${index}p "$origlist"
+ sed -n ${index}p "$unflavored_origlist"
+ done | while read origin_unflavored
+ do
+ origin_unflavored_rpl=`str_escape_replaceval "$origin_unflavored"`
+ fs_fix_unionfs_image_if_hidden "${PORTSDIR}/$origin_unflavored"
+ make -C "${PORTSDIR}/$origin_unflavored" -V FLAVORS 2> /dev/null | \
+ tr '[:space:]' '\n' | grep -v '^$' > $tmp_flavors || :
+ [ `wc -l < $tmp_flavors` -gt 0 ] || echo > $tmp_flavors
+ sed -E "s/^/$origin_unflavored_rpl /" "$tmp_flavors"
+ done | while read origin_unflavored flavor
+ do
+ if [ -n "$flavor" ]
+ then
+ if make -C "${PORTSDIR}/$origin_unflavored" package-name FLAVOR=$flavor 2> /dev/null | \
+ grep -qE "$glob_regexp2"
+ then
+ echo "$origin_unflavored@$flavor"
+ fi
+ else
+ if make -C "${PORTSDIR}/$origin_unflavored" package-name 2> /dev/null | \
+ grep -qE "$glob_regexp2"
+ then
+ echo "$origin_unflavored"
+ fi
+ fi
done || :
- glob_regexp2=`expr "$glob_regexp" : '\(.*\)\$$' 2>&1`'[[:space:]]'
- sed -n -E "/$glob_regexp2/p" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
+ glob_regexp2=`echo "$glob_regexp" | sed -E 's/\$*$//' 2>&1 || :`'[[:space:]]'
+ grep -E "$glob_regexp2" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
| cut -f 2 || :
- pkg_info_qoX "$glob_regexp" || :
+ pkg_info_Ex "$glob_regexp" | while read pkgname
+ do
+ pkg_info_flavored_origin "$pkgname"
+ done
fi
done | sort -u
}
# ============= Create a back-up package archive =============
pkgsys_create_backup_pkg ()
{
- local pkgname dstdir origin backup_pkg_old pkgname_ptn backup_pkg dbpath pkgpath origin_regexp
+ local pkgname dstdir origin backup_pkg_old pkgname_ptn backup_pkg dbpath pkgpath
pkgname=$1
dstdir=$2
rm -rf "${TMPDIR}"/package.tmp
mkdir "${TMPDIR}"/package.tmp
- origin=`pkg_info_qo "$pkgname"`
- if backup_pkg_old=`pkgsys_get_backup_pkg "$origin"` \
- [ "$backup_pkg_old" -nt "${DBDIR}/requires/$origin/installed_timestamp" ]
+ origin=`pkg_info_flavored_origin "$pkgname"`
+ if backup_pkg_old=`pkgsys_get_backup_pkg "$origin"` && \
+ [ ! -e "${DBDIR}/requires/$origin/installed_timestamp" -o \
+ "$backup_pkg_old" -nt "${DBDIR}/requires/$origin/installed_timestamp" ]
then
echo "$backup_pkg_old"
return
return 1
fi
dbpath=${DBDIR}/backup/$origin
- [ -d "$dbpath" ] || mkdir -p "$dbpath"
- pkg_info_qL > $dbpath/previously_installed_files
- [ -d "$dstdir" ] || mkdir -p "$dstdir"
+ mkdir -p "$dbpath"
+ pkg_info_qL "$pkgname" > $dbpath/previously_installed_files
+ mkdir -p "$dstdir"
mv "${TMPDIR}/package.tmp/$backup_pkg" "$dstdir"
pkgpath=$dstdir/$backup_pkg
- origin_regexp=`str_escape_regexp "$origin"`
cat "${DBDIR}/backup_pkgarcs.lst" 2> /dev/null | \
while read origin_cur pkgpath_cur
do
echo "$pkgpath"
}
-# ============= Delete a back-up package archive for a port origin =============
+# ============= Delete a back-up package archive for a flavored port origin =============
pkgsys_delete_backup_pkg ()
{
local origin origin_regexp
mv "${DBDIR}/backup_pkgarcs.lst.tmp" "${DBDIR}/backup_pkgarcs.lst"
}
-# ============= Get an existing package archive path for a port origin =============
+# ============= Get an existing package archive path for a flavored port origin =============
pkgsys_get_backup_pkg ()
{
local origin tmpnewest origin_regexp
cat "$tmpnewest" 2> /dev/null
}
-# ============= Get a file list to be restored by the current backup package for a port origin =============
+# ============= Get a file list to be restored by the current backup package for a flavored port origin =============
pkgsys_get_restored_files_by_backup_pkg ()
{
local origin
cat "${DBDIR}/backup/$origin/previously_installed_files" 2> /dev/null || :
}
-# ============= Check whether any file match restored files by the current backup package for a port origin =============
+# ============= Check whether any file match restored files by the current backup package for a flavored port origin =============
pkgsys_chk_match_to_restored_files_by_backup_pkg ()
{
- local origin
+ local origin filelist dbfile
origin=$1
- pattern_file=$2
- while read pattern
- do
- grep -qE "$pattern" "${DBDIR}/backup/$origin/previously_installed_files" && return
- done < $pattern_file
- false
+ filelist=$2
+ dbfile=${DBDIR}/backup/$origin/previously_installed_files
+ grep -qFx -f "$filelist" "$dbfile" 2> /dev/null
}
# ============= Get a package name from a package archive file name =============
echo "$pkgdir/$pkgnode"
}
-# ============= Get port origins matching a glob pattern even if nonexistent =============
+# ============= Get flavored port origins matching a glob pattern even if nonexistent =============
pkgsys_eval_ports_glob_even_if_nonexistent ()
{
local glob_pattern
glob_pattern=$1
{
pkgsys_eval_ports_glob "$glob_pattern" 2> /dev/null || :
- echo "$glob_pattern" | grep '^[a-z][a-z]*/[a-zA-Z0-9_.+-][a-zA-Z0-9_.+-]*$' || :
+ echo "$glob_pattern" | grep -E '^[a-z]+/[a-zA-Z0-9_.+-]+(|@[a-zA-Z0-9_.+-]+)$' || :
} | grep -v -e '^$' | sort -u
}
dirpath=`dirname "$listpath"`
tmp_evaluated=${TMPDIR}/pkgsys_register_evaluated_globs:pkgsys_eval_ports_glob
echo "$@" | sed -E 's/[ :]+/\
-/g' | grep -v '^$' | sort -u | while read glob
+/g' | grep -v '^$' | sort -u | while read -r glob
do
pkgsys_eval_ports_glob "$glob" > $tmp_evaluated
[ `wc -l < $tmp_evaluated` -ge 1 ] || \
cat "$tmp_evaluated"
done | while read origin
do
- [ -d "$dirpath" ] || mkdir -p "$dirpath"
+ mkdir -p "$dirpath"
case $mode in
- remove) fileedit_rm_a_line "$origin" "$listpath";;
- add) fileedit_add_a_line_if_new "$origin" "$listpath";;
+ remove ) fileedit_rm_a_line "$origin" "$listpath"
+ ;;
+ add ) fileedit_add_a_line_if_new "$origin" "$listpath"
+ ;;
esac
done
}
[ -e "$tmp_evaluated" ] || return 0
while read origin
do
- pkgsys_pkg_info_eO "$origin" || echo "$origin"
+ pkgsys_exists_or_existed_from_orig "$origin" || echo "$origin"
done < $tmp_evaluated
}
# ============= Get glob patterns of conflicting packages of a port =============
pkgsys_get_conflicting_pkgs_patterns ()
{
- local mode origin conflicts
+ local mode origin conflicts conflicts_makevar conflicts_config
mode=$1
origin=$2
conflicts=`database_query_get_makevar_val "$origin" CONFLICTS`
case $mode in
- build)
- conflicts=$conflicts' '`database_query_get_makevar_val "$origin" CONFLICTS_BUILD`
+ build )
+ conflicts_makevar=`database_query_get_makevar_val "$origin" CONFLICTS_BUILD`
+ conflicts_config=`database_query_get_config_val "$origin" BUILDCONFLICT`
;;
- install)
- conflicts=$conflicts' '`database_query_get_makevar_val "$origin" CONFLICTS_INSTALL`
+ install )
+ conflicts_makevar=`database_query_get_makevar_val "$origin" CONFLICTS_INSTALL`
+ conflicts_config=`database_query_get_config_val "$origin" INSTCONFLICT`
+ ;;
+ *)
+ conflicts_makevar=
+ conflicts_config=
;;
esac
- echo "$conflicts" | tr ' ' '\n' | grep -v '^$' || :
+ echo "$conflicts $conflicts_makevar $conflicts_config" | tr ' ' '\n' | grep -v '^$' | sort -u
}
# ============= Get conflicting installed packages of a port =============
tmp_conflicts=${TMPDIR}/pkgsys_get_conflicting_installed_pkgs::conflicts
pkgsys_get_conflicting_pkgs_patterns "$mode" "$origin" | while read pkg_pattern
do
- pkg_info_Eg "$pkg_pattern" || :
+ pkgsys_get_installed_pkg_from_glob "$pkg_pattern" || :
done > $tmp_conflicts
cat "$tmp_conflicts"
[ `wc -l < $tmp_conflicts` -gt 0 ]
fi
done
eval "$var_is_reinstall_encouraged=\$_is_reinstall_encouraged"
- origin=`pkg_info_qo "$pkg"`
+ origin=`pkg_info_flavored_origin "$pkg"`
if [ $opt_batch_mode = no ]
then
message_echo "[$pkg ($origin)]"
fi
return 1
}
+
+# ============= Check whether the port options database is once saved =============
+pkgsys_exists_saved_port_oprions_timestamps ()
+{
+ [ -d "${DBDIR}/ls_dbdir" ]
+}
+
+# ============= Get the current all timestamp information of port options =============
+pkgsys_get_current_port_oprions_timestamp ()
+{
+ local portdb_needle_regexp
+ portdb_needle_regexp=`str_escape_regexp "$1"`
+ {
+ ls -lD %Y%m%d:%H%M%S "${PORT_DBDIR}" | if [ -n "$portdb_needle_regexp" ]
+ then
+ grep -E "[[:space:]]$portdb_needle_regexp$" || :
+ else
+ cat
+ fi
+ } 2> /dev/null | cut -w -f 6,7 | while read datetime portdb
+ do
+ [ -d "${PORT_DBDIR}/$portdb" ] || continue
+ if [ -e "${PORT_DBDIR}/$portdb/options" ]
+ then
+ datetime=`ls -lD %Y%m%d:%H%M%S "${PORT_DBDIR}/$portdb/options" 2> /dev/null | cut -w -f 6`
+ fi
+ printf '%s\t%s\n' "$portdb" "$datetime"
+ done
+}
+
+# ============= Get the saved all timestamp information of port options =============
+pkgsys_get_saved_port_oprions_timestamps_all ()
+{
+ cat "${DBDIR}/ls_dbdir/"*.log > $tmp_ls.db 2> /dev/null || :
+}
+
+# ============= Convert a list of port origins to port options timestamp log names =============
+pkgsys_conv_portorigin_to_port_oprion_timestamp_logname ()
+{
+ sed 's|/|_|'
+}
+
+# ============= Save the timestamp information of port options of a port =============
+pkgsys_save_port_oprion_timestamp ()
+{
+ local origin portoptlog portoptdb
+ origin=$1
+ portoptlog=`echo "$origin" | pkgsys_conv_portorigin_to_port_oprion_timestamp_logname`
+ if pkgsys_is_dialog4ports_used
+ then
+ portoptdb=`echo "$portoptlog" | sed 's/@.*//'`
+ else
+ portoptdb=`database_build_make "$origin" -V UNIQUENAME`
+ fi
+ mkdir -p "${DBDIR}/ls_dbdir"
+ pkgsys_get_current_port_oprions_timestamp "$portoptdb" > ${DBDIR}/ls_dbdir/$portoptlog.log 2> /dev/null || :
+}
+
+# ============= Get changed port options from the saved point =============
+pkgsys_get_changed_port_oprions ()
+{
+ local saved_log current_log tmp_log
+ saved_log=$1
+ current_log=$2
+ tmp_log=${TMPDIR}/pkgsys_get_changed_port_oprions.log
+ {
+ grep -vxF -f "$current_log" "$saved_log" || :
+ grep -vxF -f "$saved_log" "$current_log" || :
+ } | cut -w -f 1 | grep -v '^$' | sort -u > $tmp_log
+ if pkgsys_is_dialog4ports_used
+ then
+ grep '_' "$tmp_log" || :
+ else
+ cat "$tmp_log"
+ fi
+}
+
+# ============= Convert a list of port origins to port options database names =============
+pkgsys_conv_portorigins_to_portoptiondbs ()
+{
+ if pkgsys_is_dialog4ports_used
+ then
+ sed 's|_|/|'
+ else
+ cat "$tmp_ls.diff"
+ fi
+}
+
+# ============= Register nonexistent port options databases =============
+pkgsys_register_list_nonexistent_portopriondb ()
+{
+ local dbpath
+ dbpath=${DBDIR}/ls_dbdir/%NONEXISTENT%.log
+ cat > $dbpath.new
+ touch "$dbpath"
+ sort -u "$dbpath.new" "$dbpath" > $dbpath.tmp
+ mv "$dbpath.tmp" "$dbpath"
+}