OSDN Git Service

[BUG FIX] Packages of the same origin with different flavors were not processed corre...
authorMamoru Sakaue <sakaue.mamoru@mwghennndo.com>
Tue, 12 Apr 2022 22:56:59 +0000 (07:56 +0900)
committerMamoru Sakaue <sakaue.mamoru@mwghennndo.com>
Tue, 12 Apr 2022 22:56:59 +0000 (07:56 +0900)
 Changes to be committed:
modified:   HISTORY
modified:   lib/libcommand_do.sh
modified:   lib/libcommand_pkgs.sh
modified:   lib/libdatabase_build.sh
modified:   lib/libpkgsys.sh
modified:   lib/libreinstall.sh

HISTORY
lib/libcommand_do.sh
lib/libcommand_pkgs.sh
lib/libdatabase_build.sh
lib/libpkgsys.sh
lib/libreinstall.sh

diff --git a/HISTORY b/HISTORY
index 9f7b3c2..e0a0e1d 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -6,6 +6,7 @@
 [BUG FIX] Restarted runs failed if paths set to option values or their parent paths are symbolic links.
 [BUG FIX] The mount command of portsreinstall-chroot(8) failed to detect mounted and unmounted file systems on mount points under symbolic links.
 [BUG FIX] Command reselect ended up with "missing argument" error.
+[BUG FIX] Packages of the same origin with different flavors were not processed correctly.
 4.1.0 (22 September 2018)
 [NEW] Options -j and -x are added.
 [NEW] Option -J is added to the all utilities.
@@ -38,7 +39,7 @@
 [BUG FIX] Failure in unmounting of file systems by portsreinstall-chroot(8) left the privilege lock.
 [BUG FIX] Conflict was not correctly escaped in package installation.
 [BUG FIX] Evaluation of globs was incorrect for the regular expression form.
-[BUG FIX] Flavored requirements were incorrectly inspected. This also caused disability of the use of default packages for flavord ports with the default configuration.
+[BUG FIX] Flavored requirements were incorrectly inspected. This also caused disability of the use of default packages for flavored ports with the default configuration.
 [BUG FIX] The message about the evaluated dependency level in show command was wrong.
 [BUG FIX] Unselected leaf ports were skipped in (re)installtion.
 [BUG FIX] Some upgrading operations by portsreinstall-upgrade(8) were imperfect.
index 73bd344..82df622 100644 (file)
@@ -224,7 +224,7 @@ command_do_reset_changed_portdb ()
 {
        local tmp_ls
        program_chk_stage_complete INSPECT_DEPENDENTS || return
-       pkgsys_exists_saved_port_oprions_timestamps || return
+       pkgsys_exists_saved_port_options_timestamps || return
        message_section_title "Inspecting changes of port options"
        tmp_ls=${TMPDIR}/command_do_reset_changed_portdb
        rm -f "$tmp_ls.updated"
@@ -232,9 +232,9 @@ command_do_reset_changed_portdb ()
        then
                message_echo "WARNING: ${PORT_DBDIR} is missing. All port options are recognized as default."
        fi
-       pkgsys_get_saved_port_oprions_timestamps_all > $tmp_ls.db
-       pkgsys_get_current_port_oprions_timestamp > $tmp_ls.log
-       pkgsys_get_changed_port_oprions "$tmp_ls.db" "$tmp_ls.log" > $tmp_ls.diff
+       pkgsys_get_saved_port_options_timestamps_all > $tmp_ls.db
+       pkgsys_get_current_port_options_timestamp > $tmp_ls.log
+       pkgsys_get_changed_port_options "$tmp_ls.db" "$tmp_ls.log" > $tmp_ls.diff
        if ! [ `wc -l < $tmp_ls.diff` -gt 0 ]
        then
                message_echo
@@ -270,7 +270,7 @@ command_do_reset_changed_portdb ()
                fi
        done
        message_echo "INFO: Recording for not inspected ports..."
-       pkgsys_conv_portorigin_to_port_oprion_timestamp_logname < $tmp_ls.uninspected.origin > $tmp_ls.uninspected.logname
+       pkgsys_conv_portorigin_to_port_option_timestamp_logname < $tmp_ls.uninspected.origin > $tmp_ls.uninspected.logname
        str_escape_regexp_filter < $tmp_ls.uninspected.dbfile | sed 's/^/^/;s/$/[[:space:]]/' > $tmp_ls.uninspected.dbfile_ptn
        paste "$tmp_ls.uninspected.dbfile_ptn" "$tmp_ls.uninspected.logname" | while read -r dbfile_ptn logname
        do
index e0114fa..fd4f98e 100644 (file)
@@ -210,32 +210,34 @@ command_pkgs_pkgsanity ()
        do
                pkg=`sed -n ${iline}p "$tmp_list.pkgs"`
                iline=$((${iline}+1))
-               origin=`pkg_info_flavored_origin "$pkg"`
-               [ -n "$origin" ] || continue
-               env LANG=C grep -q -Fx "$origin" "${DBDIR}/damaged_package" 2>/dev/null && continue
-               pkgsys_sanitychk_pkgcontents "$pkg" is_reinstall_encouraged && continue
-               port_path=`pkgsys_get_portpath_from_origin "$origin"`
-               if [ ! -d "$port_path" ]
-               then
-                       message_echo "WARNING: $pkg ($origin) is obsolete." >&2
-                       message_echo >&2
-                       continue
-               fi
-               if [ $is_reinstall_encouraged = no ]
-               then
-                       if [ $opt_batch_mode = no ]
+               for origin in `pkg_info_flavored_origins "$pkg"`
+               do
+                       [ -n "$origin" ] || continue
+                       env LANG=C grep -q -Fx "$origin" "${DBDIR}/damaged_package" 2>/dev/null && continue
+                       pkgsys_sanitychk_pkgcontents "$pkg" is_reinstall_encouraged && continue
+                       port_path=`pkgsys_get_portpath_from_origin "$origin"`
+                       if [ ! -d "$port_path" ]
                        then
-                               message_echo "Do you want to reinstall it? (y/[n])"
-                               message_query_yn_default_no || continue
+                               message_echo "WARNING: $pkg ($origin) is obsolete." >&2
+                               message_echo >&2
+                               continue
                        fi
-               else
-                       if [ $opt_batch_mode = no ]
+                       if [ $is_reinstall_encouraged = no ]
                        then
-                               message_echo "Do you want to reinstall it? ([y]/n)"
-                               message_query_yn_default_yes || continue
+                               if [ $opt_batch_mode = no ]
+                               then
+                                       message_echo "Do you want to reinstall it? (y/[n])"
+                                       message_query_yn_default_no || continue
+                               fi
+                       else
+                               if [ $opt_batch_mode = no ]
+                               then
+                                       message_echo "Do you want to reinstall it? ([y]/n)"
+                                       message_query_yn_default_yes || continue
+                               fi
+                               database_record_reconf_recover_sanity "$origin"
                        fi
-                       database_record_reconf_recover_sanity "$origin"
-               fi
+               done
        done
 }
 
index b697cdf..8ef4362 100644 (file)
@@ -632,7 +632,7 @@ database_build_inspect_dependencies ()
                                        else
                                                cp /dev/null "$dbpath/ports_options.current"
                                        fi
-                                       pkgsys_save_port_oprion_timestamp "$origin"
+                                       pkgsys_save_port_option_timestamp "$origin"
                                        # Get the lists of requirements in the flavored form
                                        database_build_create_pkgtag "$origin"
                                        for variable in PKG_DEPENDS EXTRACT_DEPENDS PATCH_DEPENDS FETCH_DEPENDS BUILD_DEPENDS LIB_DEPENDS
index 2135359..d3ec488 100644 (file)
@@ -438,20 +438,29 @@ pkgsys_def_pkgtools ()
                        # Return the total storage space occupied by the installed files in bytes
                        pkg info -qs "$@" 2> /dev/null | sed 's/KiB$/*1024/;s/MiB$/*1024^2/;s/GiB$/*1024^3/;s/B$//' | tr '\n' + | sed 's/+$//' | bc -l
                }
-               pkg_info_flavor ()
+               pkg_info_flavors ()
+               # For an unflavored pattern, all matching flavors are returned.
                {
                        local glob_unflavored
                        glob_unflavored=$1
                        pkg query -g '%At\t%Av' "$glob_unflavored" 2> /dev/null | env LANG=C grep -E '^flavor[[:space:]]' | cut -f 2
                }
-               pkg_info_flavored_origin ()
+               pkg_info_flavored_origins ()
+               # For an unflavored pattern, all matching flavors are returned.
                {
                        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"
+                       flavors=`pkg_info_flavors "$glob_unflavored" 2> /dev/null || :`
+                       if [ -z "$flavors" ]
+                       then
+                               echo "$origin_unflavored"
+                       else
+                               for flavor in $flavors
+                               do
+                                       echo "$origin_unflavored@$flavor"
+                               done
+                       fi
                }
                pkg_info_all_flavored_origins ()
                {
@@ -866,7 +875,7 @@ pkgsys_def_pkgtools ()
                        # Return the total storage space occupied by the installed files in bytes
                        pkg_info -qs "$@" 2> /dev/null | sed 's/[^0-9]*/*1024/' | tr '\n' + | sed 's/+$//' | bc -l
                }
-               pkg_info_flavor ()
+               pkg_info_flavors ()
                {
                        pkg_info -qe "$@" 2> /dev/null && echo
                        :
@@ -1105,15 +1114,22 @@ pkgsys_get_installed_pkg_from_origin ()
        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
+       if [ -n "$flavor_origin" ]
+       then
+               for pkgname in `pkg_info_qO "$origin_unflavored" 2> /dev/null`
+               do
+                       for flavor_pkg in `pkg_info_flavors "$pkgname"`
+                       do
+                               if [ "x$flavor_origin" = "x$flavor_pkg" ]
+                               then
+                                       echo "$pkgname"
+                                       return
+                               fi
+                       done
+               done
+       else
+               pkg_info_qO "$origin_unflavored" 2> /dev/null
+       fi
        :
 }
 
@@ -1141,8 +1157,11 @@ pkgsys_exists_from_orig ()
        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" ]
+       for flavor_pkg in `pkg_info_flavors "$origin_unflavored"`
+       do
+               [ "x$flavor_origin" = "x$flavor_pkg" ] && return
+       done
+       false
 }
 
 # ============= Generate the package names vs origins table at the initial state =============
@@ -1178,14 +1197,16 @@ pkgsys_get_init_pkg_from_orig ()
        else
                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
+               for pkgname in `pkg_info_qO "$origin_unflavored" 2> /dev/null`
                do
-                       flavor_pkg=`pkg_info_flavor "$pkgname"`
-                       if [ "x$flavor_origin" = "x$flavor_pkg" ]
-                       then
-                               echo "$pkgname"
-                               break
-                       fi
+                       for flavor_pkg in `pkg_info_flavors "$pkgname"`
+                       do
+                               if [ "x$flavor_origin" = "x$flavor_pkg" ]
+                               then
+                                       echo "$pkgname"
+                                       return
+                               fi
+                       done
                done
        fi
        :
@@ -1671,13 +1692,13 @@ pkgsys_sanitychk_pkgcontents ()
 }
 
 # ============= Check whether the port options database is once saved =============
-pkgsys_exists_saved_port_oprions_timestamps ()
+pkgsys_exists_saved_port_options_timestamps ()
 {
        [ -d "${DBDIR}/ls_dbdir" ]
 }
 
 # ============= Get the current all timestamp information of port options =============
-pkgsys_get_current_port_oprions_timestamp ()
+pkgsys_get_current_port_options_timestamp ()
 {
        local portdb_needle_regexp
        portdb_needle_regexp=`str_escape_regexp "$1"`
@@ -1700,20 +1721,20 @@ pkgsys_get_current_port_oprions_timestamp ()
 }
 
 # ============= Get the saved all timestamp information of port options =============
-pkgsys_get_saved_port_oprions_timestamps_all ()
+pkgsys_get_saved_port_options_timestamps_all ()
 {
        mkdir -p "${DBDIR}/ls_dbdir"
        cat "${DBDIR}/ls_dbdir/"*.log 2> /dev/null || :
 }
 
 # ============= Convert a list of port origins to port options timestamp log names =============
-pkgsys_conv_portorigin_to_port_oprion_timestamp_logname ()
+pkgsys_conv_portorigin_to_port_option_timestamp_logname ()
 {
        sed 's|/|_|'
 }
 
 # ============= Get the file name of the port options database of a port =============
-pkgsys_get_port_oprion_database ()
+pkgsys_get_port_option_database ()
 {
        local origin
        origin=$1
@@ -1726,23 +1747,23 @@ pkgsys_get_port_oprion_database ()
 }
 
 # ============= Save the timestamp information of port options of a port =============
-pkgsys_save_port_oprion_timestamp ()
+pkgsys_save_port_option_timestamp ()
 {
        local origin portoptlog portoptdb
        origin=$1
-       portoptlog=`echo "$origin" | pkgsys_conv_portorigin_to_port_oprion_timestamp_logname`
-       portoptdb=`pkgsys_get_port_oprion_database "$origin"`
+       portoptlog=`echo "$origin" | pkgsys_conv_portorigin_to_port_option_timestamp_logname`
+       portoptdb=`pkgsys_get_port_option_database "$origin"`
        mkdir -p "${DBDIR}/ls_dbdir"
-       pkgsys_get_current_port_oprions_timestamp "$portoptdb" > ${DBDIR}/ls_dbdir/$portoptlog.log 2> /dev/null || :
+       pkgsys_get_current_port_options_timestamp "$portoptdb" > ${DBDIR}/ls_dbdir/$portoptlog.log 2> /dev/null || :
 }
 
 # ============= Get changed port options from the saved point =============
-pkgsys_get_changed_port_oprions ()
+pkgsys_get_changed_port_options ()
 {
        local saved_log current_log tmp_log
        saved_log=$1
        current_log=$2
-       tmp_log=${TMPDIR}/pkgsys_get_changed_port_oprions.log
+       tmp_log=${TMPDIR}/pkgsys_get_changed_port_options.log
        {
                env LANG=C grep -vxF -f "$current_log" "$saved_log" || :
                env LANG=C grep -vxF -f "$saved_log" "$current_log" || :
index 74731bc..2bfd341 100644 (file)
@@ -249,41 +249,43 @@ reinstall_backup_and_delete_conflicts ()
        message_echo "INFO: Deinstalling conflicting packages for $REINSTALL_ORIGPKGTAG."
        while read pkg
        do
-               origin=`pkg_info_flavored_origin "$pkg"`
-               origin_equiv=`database_query_get_equivalent_orgin "$origin"`
-               message_echo "INFO: Backing up and deleting a conflict, $origin ($pkg)."
-               origin_regexp_esc=`str_escape_regexp "$origin"`
-               origin_equiv_regexp_esc=`str_escape_regexp "$origin_equiv"`
-               if [ -d "${DBDIR}/requires/$origin" ]
-               then
-                       backup_pkgdir=${DBDIR}/backup_packages
-               else
-                       backup_pkgdir=${PKGREPOSITORY}
-               fi
-               mkdir -p "$backup_pkgdir"
-               if backup_pkg=`pkgsys_get_backup_pkg "$origin"` || backup_pkg=`pkgsys_get_backup_pkg "$origin_equiv"`
-               then
-                       message_echo "INFO: backup package already exists as $backup_pkg"
-               elif ! backup_pkg=`pkgsys_create_backup_pkg "$pkg" "$backup_pkgdir"`
-               then
-                       message_echo "WARNING: Failed to create the backup package, the conflict is kept installed." >&2
-                       continue
-               fi
-               env LANG=C grep -v -E "^${origin_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts" \
-                       > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || :
-               if [ -n "$origin_equiv_regexp_esc" ]
-               then
-                       env LANG=C grep -v -E "^${origin_equiv_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts.tmp" \
-                               > ${DBDIR}/deleted_conflicts.tmp2 2> /dev/null || :
-                       mv "${DBDIR}/deleted_conflicts.tmp2" "${DBDIR}/deleted_conflicts.tmp"
-               fi
-               printf '%s\t%s\n' "$origin" "$pkg" >> ${DBDIR}/deleted_conflicts.tmp
-               [ -n "$origin_equiv" ] && printf '%s\t%s\n' "$origin_equiv" "$pkg" >> ${DBDIR}/deleted_conflicts.tmp
-               mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
-               pkg_delete_f "$pkg" || \
-               {
-                       message_echo "WARNING: Failed to deinstall $pkg by $PKGSYS_CMD_PKG_DELETE." >&2
-               }
+               for origin in `pkg_info_flavored_origins "$pkg"`
+               do
+                       origin_equiv=`database_query_get_equivalent_orgin "$origin"`
+                       message_echo "INFO: Backing up and deleting a conflict, $origin ($pkg)."
+                       origin_regexp_esc=`str_escape_regexp "$origin"`
+                       origin_equiv_regexp_esc=`str_escape_regexp "$origin_equiv"`
+                       if [ -d "${DBDIR}/requires/$origin" ]
+                       then
+                               backup_pkgdir=${DBDIR}/backup_packages
+                       else
+                               backup_pkgdir=${PKGREPOSITORY}
+                       fi
+                       mkdir -p "$backup_pkgdir"
+                       if backup_pkg=`pkgsys_get_backup_pkg "$origin"` || backup_pkg=`pkgsys_get_backup_pkg "$origin_equiv"`
+                       then
+                               message_echo "INFO: backup package already exists as $backup_pkg"
+                       elif ! backup_pkg=`pkgsys_create_backup_pkg "$pkg" "$backup_pkgdir"`
+                       then
+                               message_echo "WARNING: Failed to create the backup package, the conflict is kept installed." >&2
+                               continue
+                       fi
+                       env LANG=C grep -v -E "^${origin_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts" \
+                               > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || :
+                       if [ -n "$origin_equiv_regexp_esc" ]
+                       then
+                               env LANG=C grep -v -E "^${origin_equiv_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts.tmp" \
+                                       > ${DBDIR}/deleted_conflicts.tmp2 2> /dev/null || :
+                               mv "${DBDIR}/deleted_conflicts.tmp2" "${DBDIR}/deleted_conflicts.tmp"
+                       fi
+                       printf '%s\t%s\n' "$origin" "$pkg" >> ${DBDIR}/deleted_conflicts.tmp
+                       [ -n "$origin_equiv" ] && printf '%s\t%s\n' "$origin_equiv" "$pkg" >> ${DBDIR}/deleted_conflicts.tmp
+                       mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
+                       pkg_delete_f "$pkg" || \
+                       {
+                               message_echo "WARNING: Failed to deinstall $pkg by $PKGSYS_CMD_PKG_DELETE." >&2
+                       }
+               done
        done
        cat "${DBDIR}/deleted_conflicts" 2> /dev/null | sort -u > ${DBDIR}/deleted_conflicts.tmp
        mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
@@ -325,12 +327,14 @@ reinstall_backup_and_delete_remaining_install_conflicts ()
                pkg=`pkg_which "$filepath" || :`
                [ -z "$pkg" ] && continue
                env LANG=C grep -qFx "$pkg" "$tmp_conflicts.pkgs" && continue
-               origin=`pkg_info_flavored_origin "$pkg"`
-               [ x"$origin" = x"$REINSTALL_ORIGIN" ] && continue
-               [ x"$origin" = x"$REINSTALL_ORIGIN_equiv" ] && continue
-               origin_equiv=`database_query_get_equivalent_orgin "$origin"`
-               [ x"$origin_equiv" = x"$REINSTALL_ORIGIN" ] && continue
-               printf '%s\t%s\n' "$pkg" "$filepath" >> $db_conflict.tmp
+               for origin in `pkg_info_flavored_origins "$pkg"`
+               do
+                       [ x"$origin" = x"$REINSTALL_ORIGIN" ] && continue
+                       [ x"$origin" = x"$REINSTALL_ORIGIN_equiv" ] && continue
+                       origin_equiv=`database_query_get_equivalent_orgin "$origin"`
+                       [ x"$origin_equiv" = x"$REINSTALL_ORIGIN" ] && continue
+                       printf '%s\t%s\n' "$pkg" "$filepath" >> $db_conflict.tmp
+               done
        done
        if [ -e "$db_conflict.tmp" ]
        then
@@ -620,9 +624,11 @@ reinstall_pkg_backup ()
 }
 
 # ============= Deinstallation of the currently installed package =============
+# For a flavored package, its unflavored one is also deinstalled if existing.
+# For an unflavored package, its all flavored ones are also deinstalled if existing.
 reinstall_deinstall ()
 {
-       local tmp_installedpkg REINSTALL_ORIGIN_equiv installed_pkgs dev_out dev_err
+       local tmp_installedpkg REINSTALL_ORIGIN_equiv installed_pkgs dev_out dev_err flavor
        dev_out=/dev/stdout
        dev_err=/dev/stderr
        if [ $opt_batch_mode = yes ]
@@ -643,6 +649,12 @@ reinstall_deinstall ()
                        message_echo "WARNING: Failed to deinstall." >&2
                }
        else
+               flavor=`pkgsys_get_flavor_from_origin "$REINSTALL_ORIGIN"`
+               if [ -n "$flavor" ]
+               then
+                       pkgsys_get_unflavored_origin "$REINSTALL_ORIGIN" >> $tmp_installedpkg
+               else
+               fi
                while read pkg
                do
                        message_echo "INFO: Deinstalling $pkg by $PKGSYS_CMD_PKG_DELETE." >&2