OSDN Git Service

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