OSDN Git Service

165ade30bd8192108054e128376b3029ea4f4bcf
[portsreinstall/current.git] / lib / libcommand_show.sh
1 #!/bin/sh -e
2 # ==============================================================================
3 # portsreinstall library script
4 # - "show" command operation -
5 # Copyright (C) 2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
6 # This software is distributed under the 2-Clause BSD License.
7 # ==============================================================================
8
9 # ============= Execute command operations which should be done without upgrade of tools =============
10 command_show ()
11 {
12         local flag_filter_skip_unchanged flag_filter_only_target listdb pkgnamedb dbsuffix list origin_target
13         flag_filter_skip_unchanged=
14         flag_filter_only_target=
15         pkgnamedb='moved_from obsolete initial'
16         [ -n "$COMMAND_SHOW_DEPTAG" ] || COMMAND_SHOW_DEPTAG=`options_get_dependency_type`
17         [ -n "$COMMAND_SHOW_LEVEL" ] || COMMAND_SHOW_LEVEL=`options_get_dependency_level`
18         dbsuffix=$COMMAND_SHOW_DEPTAG.$COMMAND_SHOW_LEVEL
19         case $COMMAND_SHOW_SUBJECT in
20         todo | done | redo | resolved | inst_by_pkg | inst_built_default | inst_built_custom | failure | taboo | freeze | need | noneed | deleted | restored | fossil |conflict | moved )
21                 database_query_show_single_list_exec "$COMMAND_SHOW_SUBJECT" \
22                         "$COMMAND_SHOW_DEPTAG" "$COMMAND_SHOW_LEVEL" || :
23                 ;;
24         leaves | obsolete )
25                 database_query_show_single_list_exec "$COMMAND_SHOW_SUBJECT" \
26                         "$COMMAND_SHOW_KEYWORD" '' || :
27                 ;;
28         build_conflict_pkgs | inst_conflict_pkgs )
29                 case $COMMAND_SHOW_SUBJECT in
30                 build_conflict_pkgs )
31                         message_echo "Installed conflicting packages in the build:"
32                         mode=build
33                         ;;
34                 inst_conflict_pkgs )
35                         message_echo "Installed conflicting packages in the installation:"
36                         mode=install
37                         ;;
38                 esac
39                 pkgsys_eval_ports_glob "$@" | while read origin
40                 do
41                         pkgsys_get_conflicting_installed_pkgs "$mode" "$origin"
42                 done | sort -u
43                 ;;
44         initrequirements )
45                 grandtitle="Dependencies based on the initially installed packages"
46                 title="The following port(s) was/were required by %s:"
47                 list=requirements.$dbsuffix
48                 listdb='initial'
49                 pkgnamedb='initial'
50                 ;;
51         requirements )
52                 grandtitle="Dependencies based on the latest ports tree"
53                 title="The following port(s) is/are required by %s:"
54                 list=requirements.$dbsuffix
55                 listdb='requires'
56                 pkgnamedb='moved_from'
57                 ;;
58         initdependents )
59                 grandtitle="Dependencies based on the initially installed packages"
60                 title="The following port(s) depended on %s:"
61                 list=dependents.$dbsuffix
62                 listdb='initial'
63                 pkgnamedb='initial'
64                 ;;
65         dependents )
66                 grandtitle="Dependencies based on the latest ports tree"
67                 title="The following port(s) depend(s) on %s:"
68                 list=dependents.$dbsuffix
69                 listdb='requires'
70                 pkgnamedb='moved_from'
71                 ;;
72         conflict_files )
73                 grandtitle="Possible additional conflict files"
74                 title="The following packages' files conflict with %s:"
75                 list=possible_additional_conflict.csv
76                 listdb='requires'
77                 pkgnamedb='moved_from'
78                 database_query_show_two_column_lists "$grandtitle" "$title" "$list" "$listdb" "$pkgnamedb" "$@"
79                 ;;
80         status )
81                 grandtitle="Success/failure status in (re)installation"
82                 lists='todo|done|redo|resolved|inst_by_pkg|inst_built_default|inst_built_custom|failure|taboo|freeze|need|noneed|deleted|restored|fossil|conflict'
83                 database_query_show_list_inclusion_of_matching_port "$grandtitle" "$lists" "$pkgnamedb" \
84                         "$COMMAND_SHOW_DEPTAG" "$COMMAND_SHOW_LEVEL" "$@"
85                 ;;
86         errormessage )
87                 grandtitle="Error messages in (re)installation:"
88                 title="\n==== %s ===="
89                 list=error.log
90                 listdb='requires'
91                 pkgnamedb='moved_from'
92                 database_query_show_log "$grandtitle" "$title" "$list" "$listdb" "$pkgnamedb" "$@"
93                 ;;
94         esac
95         case $COMMAND_SHOW_SUBJECT in
96         initrequirements | requirements | initdependents | dependents )
97                 [ $COMMAND_SHOW_DEPTAG = none ] && \
98                         message_echo "WARNING: This command has no meaning with the current options setting." >&2
99                 database_query_show_port_lists "$grandtitle" "$title" "$list" "$listdb" "$pkgnamedb" "$COMMAND_SHOW_DEPTAG" "$COMMAND_SHOW_LEVEL" "$@"
100                 ;;
101         esac
102 }