OSDN Git Service

Fixed a syntax error.
[portsreinstall/current.git] / lib / libdatabase_query.sh
index 5e381fa..4ced7ce 100644 (file)
@@ -95,6 +95,20 @@ database_query_show_list_failed_conflicts_restoration ()
        :
 }
 
+# ============= Show installed ports which have been neither upgraded or reinstalled from the initial state =============
+database_query_show_list_fossil ()
+{
+       local srclist origin pkg
+       srclist=`ls "${DBDIR}"/fossil_pkgs/fossil_since_* | head -n 1`
+       [ -e "$srclist" ] || return 0
+       while read origin
+       do
+               pkg=`pkgsys_get_init_pkg_from_orig "$origin"`
+               pkg_info_e "$pkg" || continue
+               printf '%s\t%s\n' "$origin" "$pkg"
+       done < $srclist
+}
+
 # ============= Insert initial flavored origins to a list of flavored origins =============
 database_query_add_initial_origins ()
 {
@@ -492,11 +506,15 @@ database_query_show_two_column_lists ()
 # ============= Output of "show" command for a single list =============
 database_query_show_single_list ()
 {
-       local list pkgnamedb flag_filter_skip_unchanged flag_filter_only_target tmpflag_exists put_blankline
+       local list pkgnamedb flag_filter_skip_unchanged flag_filter_only_target flag_negative_listdb tmpflag_exists put_blankline origin matches flag pkg table
+       local currentorigin_is_alll currentorigin_is_target currentorigin_is_requires_requirements
+       local currentorigin_is_initial_requirements currentorigin_is_requires_dependents
+       local currentorigin_is_initial_dependents currentorigin_is_requires_requirements_complement currentorigin_is_relevant
        list=$1
        pkgnamedb=$2
        flag_filter_skip_unchanged=$3
        flag_filter_only_target=$4
+       flag_negative_listdb=$5
        tmpflag_exists=${TMPDIR}/database_query_show_single_list::exists_item
        if [ `cat "${DBDIR}/$list" 2> /dev/null | wc -l` -eq 0 ]
        then
@@ -525,9 +543,20 @@ database_query_show_single_list ()
        [ -n "$put_blankline" ] && message_echo
        while read origin
        do
-               [ -n "$flag_filter_skip_unchanged" -a $opt_skip_unchanged = yes \
-                       -a ! -e "${DBDIR}/requires/$origin/$flag_filter_skip_unchanged" ] \
-                       && continue
+               [ -n "$flag_negative_listdb" ] && grep -Fx "$origin" "${DBDIR}/$flag_negative_listdb" 2> /dev/null && continue
+               if [ -n "$flag_filter_skip_unchanged" -a $opt_skip_unchanged = yes ]
+               then
+                       matches=no
+                       for flag in $flag_filter_skip_unchanged
+                       do
+                               if [ -e "${DBDIR}/requires/$origin/$flag" ]
+                               then
+                                       matches=yes
+                                       break
+                               fi
+                       done
+                       [ $matches = no ] && continue
+               fi
                if [ -n "$flag_filter_only_target" ]
                then
                        database_query_get_target_attributes currentorigin "$origin"
@@ -571,16 +600,51 @@ database_query_is_necessary_upgrade ()
        fileedit_exists_old_lines "$tmpfile_old" "$tmpfile_new"
 }
 
+# ============= Show moved or replaced ports to alternatives =============
+database_query_show_list_moved ()
+{
+       cat "${DBDIR}/moved_ports" 2> /dev/null | while read origin
+       do
+               lastorigin=$origin
+               while [ -n "$lastorigin" -a -e "${DBDIR}/replace/$lastorigin/origin" ]
+               do
+                       lastorigin=`cat "${DBDIR}/replace/$lastorigin/origin"`
+               done
+               [ -n "$lastorigin" ] || continue
+               pkg=
+               for table in $pkgnamedb
+               do
+                       pkg=`cat "${DBDIR}/$table/$origin/pkgtag" 2> /dev/null` || :
+                       [ -n "$pkg" ] && break
+               done
+               [ -n "$pkg" ] || pkg='not installed'
+               lastpkg=
+               for table in moved_from obsolete initial
+               do
+                       lastpkg=`cat "${DBDIR}/$table/$lastorigin/pkgtag" 2> /dev/null` || :
+                       [ -n "$lastpkg" ] && break
+               done
+               [ -n "$lastpkg" ] || lastpkg='not installed'
+               if [ $opt_batch_mode = no ]
+               then
+                       echo "$origin ($pkg) => $lastorigin ($lastpkg)"
+               else
+                       printf '%s\t%s\t%s\t%s\n' "$origin" "$pkg" "$lastorigin" "$lastpkg"
+               fi
+       done
+}
+
 # ============= Actual operations of "show" command for a single list =============
 database_query_show_single_list_exec ()
 {
-       local subject deptag level dbsuffix flag_filter_skip_unchanged flag_filter_only_target pkgnamedb
+       local subject deptag level dbsuffix flag_filter_skip_unchanged flag_filter_only_target flag_negative_listdb pkgnamedb
        subject=$1
        deptag=$2
        level=$3
        dbsuffix=$deptag.$level
        flag_filter_skip_unchanged=
        flag_filter_only_target=
+       flag_negative_listdb=
        pkgnamedb='moved_from obsolete initial'
        case $subject in
        todo )
@@ -602,30 +666,58 @@ database_query_show_single_list_exec ()
                flag_filter_only_target=y
                ;;
        redo )
-               message_echo "The following ports need (re)installation but are to be skipped until any of their failed requirements succeeds:"
+               message_echo "The following ports need (re)installation after success of the all requirements:"
                message_dependency_scope "$deptag" "$level"
                message_echo
                list=todo_after_requirements_succeed.$dbsuffix.list
-               flag_filter_skip_unchanged=necessary_upgrade.$dbsuffix
+               flag_filter_skip_unchanged="necessary_upgrade.$dbsuffix necessary_upgrade_completed.$dbsuffix"
                flag_filter_only_target=y
+               flag_negative_listdb=leaf_ports_to_delete.unselected
                ;;
        resolved )
                message_echo "The following ports had problems which have been manually resolved:"
                message_echo
                list=manually_done.list
                ;;
+       inst_by_pkg )
+               message_echo "The following ports are configured default and installed by prebuilt packages"
+               message_echo
+               list=installation_complete_by_pkg.list
+               ;;
+       inst_built_default )
+               message_echo "The following ports are configured default and installed by ports"
+               message_echo
+               list=inst_by_port_with_default_conf.list
+               ;;
+       inst_built_custom )
+               message_echo "The following ports are configured non-default and installed by ports"
+               message_echo
+               list=inst_by_port_with_custom_conf.list
+               ;;
        failure )
                message_echo "The following ports experienced failures and kept to be old or uninstalled:"
                message_echo
                database_query_show_list_failure
                return
                ;;
+       fossil )
+               message_echo "The following ports are neither upgraded or reinstalled from the initial state:"
+               message_echo
+               database_query_show_list_fossil
+               return
+               ;;
        conflict )
                message_echo "The following ports are temporarily deleted due to conflict:"
                message_echo
                database_query_show_list_failed_conflicts_restoration
                return
                ;;
+       moved )
+               message_echo "The following ports are moved/replaced to new alternatives:"
+               message_echo
+               database_query_show_list_moved
+               return
+               ;;
        taboo )
                message_echo "The following ports are registered as taboo:"
                message_echo
@@ -688,7 +780,7 @@ database_query_show_single_list_exec ()
                ;;
        esac
        database_query_show_single_list "$list" "$pkgnamedb" \
-               "$flag_filter_skip_unchanged" "$flag_filter_only_target"
+               "$flag_filter_skip_unchanged" "$flag_filter_only_target" "$flag_negative_listdb"
 }
 
 # ============= Check whether a port is registered in a list =============
@@ -716,9 +808,21 @@ database_query_exists_in_list ()
        resolved )
                list=manually_done.list
                ;;
+       inst_by_pkg )
+               list=installation_complete_by_pkg.list
+               ;;
+       inst_built_default )
+               list=inst_by_port_with_default_conf.list
+               ;;
+       inst_built_custom )
+               list=inst_by_port_with_custom_conf.list
+               ;;
        failure )
                list=failed.list
                ;;
+       fossil )
+               list=`ls "${DBDIR}"/fossil_pkgs/fossil_since_* | head -n 1`
+               ;;
        conflict )
                grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" 2> /dev/null \
                        | grep -q -E "^${origin_esc}[[:space:]]"