OSDN Git Service

[NEW] show inst_by_pkg commands are added.
[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 | failure | taboo | freeze | need | noneed | deleted | restored | conflict )
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         initrequirements )
29                 grandtitle="Dependencies based on the initially installed packages"
30                 title="The following port(s) was/were required by %s:"
31                 list=requirements.$dbsuffix
32                 listdb='initial'
33                 pkgnamedb='initial'
34                 ;;
35         requirements )
36                 grandtitle="Dependencies based on the latest ports tree"
37                 title="The following port(s) is/are required by %s:"
38                 list=requirements.$dbsuffix
39                 listdb='requires'
40                 pkgnamedb='moved_from'
41                 ;;
42         initdependents )
43                 grandtitle="Dependencies based on the initially installed packages"
44                 title="The following port(s) depended on %s:"
45                 list=dependents.$dbsuffix
46                 listdb='initial'
47                 pkgnamedb='initial'
48                 ;;
49         dependents )
50                 grandtitle="Dependencies based on the latest ports tree"
51                 title="The following port(s) depend(s) on %s:"
52                 list=dependents.$dbsuffix
53                 listdb='requires'
54                 pkgnamedb='moved_from'
55                 ;;
56         conflict_files )
57                 grandtitle="Possible additional conflict files"
58                 title="The following packages' files conflict with %s:"
59                 list=possible_additional_conflist.csv
60                 listdb='requires'
61                 pkgnamedb='moved_from'
62                 database_query_show_two_column_lists "$grandtitle" "$title" "$list" "$listdb" "$pkgnamedb" "$@"
63                 ;;
64         status )
65                 grandtitle="Success/failure status in (re)installation"
66                 lists='todo|done|redo|resolved|inst_by_pkg|failure|taboo|freeze|need|noneed|deleted|restored|conflict'
67                 database_query_show_list_inclusion_of_matching_port "$grandtitle" "$lists" "$pkgnamedb" \
68                         "$COMMAND_SHOW_DEPTAG" "$COMMAND_SHOW_LEVEL" "$@"
69                 ;;
70         errormessage )
71                 grandtitle="Error messages in (re)installation:"
72                 title="\n==== %s ===="
73                 list=error.log
74                 listdb='requires'
75                 pkgnamedb='moved_from'
76                 database_query_show_log "$grandtitle" "$title" "$list" "$listdb" "$pkgnamedb" "$@"
77                 ;;
78         esac
79         case $COMMAND_SHOW_SUBJECT in
80         initrequirements | requirements | initdependents | dependents )
81                 [ $COMMAND_SHOW_DEPTAG = none ] && \
82                         message_echo "WARNING: This command has no meaning with the current options setting." >&2
83                 database_query_show_port_lists "$grandtitle" "$title" "$list" "$listdb" "$pkgnamedb" "$COMMAND_SHOW_DEPTAG" "$COMMAND_SHOW_LEVEL" "$@"
84                 ;;
85         esac
86 }