OSDN Git Service

[NEW] Commands of show requirements and show dependents are added.
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sat, 28 Jul 2012 14:05:01 +0000 (23:05 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sat, 28 Jul 2012 14:05:01 +0000 (23:05 +0900)
modified:   portsreinstall
modified:   portsreinstall.8
modified:   portsreinstall.8~
modified:   portsreinstall~

.portsreinstall.kate-swp [new file with mode: 0644]
portsreinstall
portsreinstall.8
portsreinstall.8~
portsreinstall~

diff --git a/.portsreinstall.kate-swp b/.portsreinstall.kate-swp
new file mode 100644 (file)
index 0000000..ea6a463
Binary files /dev/null and b/.portsreinstall.kate-swp differ
index 6004b22..95b902d 100755 (executable)
@@ -10,7 +10,7 @@
 # ================================================
 
 APPNAME=`basename $0`
-MYVERSION=1.1.0+toward_1.2.0_20120726051358
+MYVERSION=1.1.0+toward_1.2.0_20120728230120
 
 PREFIX=${PREFIX:-/usr/local}
 CONFFILE=${PREFIX}/etc/${APPNAME}.conf
@@ -146,7 +146,7 @@ then
        echo "          | ok del globs... | taboo add globs... | taboo del globs..."
        echo "          | save [dir] | load path"
        echo "          | show todo | show done | show resolved | show failure | show taboo"
-       echo "          | show deleted"
+       echo "          | show deleted | show requirements glob | show dependents glob"
        echo
        echo "[DESCRIPTIONS]"
        echo " This utility is an alternative to portupgrade(1) and portmaster(8), and"
@@ -257,13 +257,15 @@ then
        echo "      taboo del glob1 [glob2 ...]: deregister taboo ports"
        echo "      save [dir] : save the current temporal database as a .tar.gz archive"
        echo "      load path : load a temporal database archive"
-       echo "      show [arg] : show the list of ports to be reinstalled"
+       echo "      show [args] : show the list of ports to be reinstalled"
        echo "              todo : ports to be reinstalled (default)"
        echo "              done : already reinstalled ports"
        echo "              resolved : manually reinstalled ports"
        echo "              failure : failed ports"
        echo "              taboo : taboo ports"
        echo "              deleted : obsolete ports to be or have been deleted"
+       echo "              requirements glob : ports required by a port identified by glob"
+       echo "              dependents glob : ports depending on a port identified by glob"
        echo
        echo "[CONFIGURATION FILE]"
        echo "          ${CONFFILE}"
@@ -830,6 +832,20 @@ show_list_failure ()
        done < ${DBDIR}/failed.list
 }
 
+_get_one_port_from_an_argument_as_a_glob ()
+{
+       local target_glog num_matches
+       target_glog=$1
+       [ -n "$target_glog" ] || { echo "ERROR: the argument as port glob is missing" >&2; return 1; }
+       ports_glob "$2" > ${TMPDIR}/_get_one_port_from_an_argument_as_a_glob:ports_glob_argements
+       num_matches=`cat "${TMPDIR}"/_get_one_port_from_an_argument_as_a_glob:ports_glob_argements | wc -l`
+       [ $num_matches -ge 1 ] || { echo "ERROR: no matching port for the glob" >&2; return 1; }
+       [ $num_matches -eq 1 ] || { echo "ERROR: multiple matching ports for the glob" >&2; return 1; }
+       origin_target=`cat "${TMPDIR}"/_get_one_port_from_an_argument_as_a_glob:ports_glob_argements`
+       [ -e "${DBDIR}/requires/$origin_target/pkgtag" ] || { echo "ERROR: the database for $origin_target is not ready" >&2; return 1; }
+       pkg_target=`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`
+}
+
 _chk_if_target ()
 {
        _is_all=y
@@ -1000,6 +1016,7 @@ show)
        [ -d "${DBDIR}" ] || { echo "ERROR: Database has not built yet." >&2; exit 1; }
        warn_update_ports
        _filter_skip_unchanged=
+       _filter_only_target=
        pkgnamedb=requires
        case ${1:-todo} in
        todo)
@@ -1007,17 +1024,20 @@ show)
                list=reinst_todo.list
                [ -e "${DBDIR}/reinst_todo.list" ] || list=reinst_order.list
                _filter_skip_unchanged=necessary_update
+               _filter_only_target=y
                ;;
        done)
                echo "The following ports have been successfully reinstalled or newly installed:"
                list=success.list
                _filter_skip_unchanged=necessary_update_completed
+               _filter_only_target=y
                ;;
        redo)
                echo "The following ports themselves have been successfully reinstalled or newly installed,"
                echo "but are to be reinstalled again because their dependencies were failed:"
                list=success_but_dependencies_failed.list
                _filter_skip_unchanged=necessary_update
+               _filter_only_target=y
                ;;
        resolved)
                echo "The following ports had problems which have been manually resolved:"
@@ -1036,6 +1056,18 @@ show)
                echo "The following ports are to be or have been deleted:"
                list=moved_or_lost.actual.list
                pkgnamedb=obsolete
+               _filter_only_target=y
+               ;;
+       requirements)
+               _get_one_port_from_an_argument_as_a_glob "$2"
+               pkg_target=`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`
+               echo "The following ports are required by $origin_target ($pkg_target):"
+               list=requires/$origin_target/requires
+               ;;
+       dependents)
+               _get_one_port_from_an_argument_as_a_glob "$2"
+               echo "The following ports depend on $origin_target ($pkg_target):"
+               list=requires/$origin_target/dependents
                ;;
        *)
                echo "ERROR: Invalid show argument [$1]" >&2
@@ -1049,6 +1081,11 @@ show)
                while read origin
                do
                        [ -e "${DBDIR}/requires/$origin/${_filter_skip_unchanged}" ] || continue
+                       if [ -n "${_filter_only_target}" ]
+                       then
+                               _chk_if_target "$origin"
+                               [ -n "${_is_all}${_is_target}${_is_dependent}${_is_required}" ] || continue
+                       fi
                        if [ -e "${DBDIR}/$pkgnamedb/$origin/pkgtag" ]
                        then
                                echo $origin '('`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`')'
@@ -1059,6 +1096,11 @@ show)
        else
                while read origin
                do
+                       if [ -n "${_filter_only_target}" ]
+                       then
+                               _chk_if_target "$origin"
+                               [ -n "${_is_all}${_is_target}${_is_dependent}${_is_required}" ] || continue
+                       fi
                        if [ -e "${DBDIR}/$pkgnamedb/$origin/pkgtag" ]
                        then
                                echo $origin '('`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`')'
index a574145..30487d1 100644 (file)
@@ -75,6 +75,10 @@ The following \fIargs\fR are available.
 \fBtaboo\fR : taboo ports
 
 \fBdeleted\fR : obsolete ports to be or have been deleted
+
+\fBrequirements\fR \fIglob\fR : ports required by a port identified by \fIglob\fR
+
+\fBdependents\fR \fIglob\fR : ports depending on a port identified by \fIglob\fR
 .SH OPTIONS
 The following options are available.
 They must be given separately with each other.
@@ -97,7 +101,7 @@ This option is recognized in the first \fBdo\fR or \fBredo\fR runs, and transfer
 Dependency relations are inspected for all installed packages as well.
 Combination with options \fB\-T\f','\fB\-r\fR and \fB\-R\fR is available..
 .TP
-\fB\-r\fR \fIglob
+\fB\-r\fR \fIglob\fR
 Reinstall only target ports and their dependents.
 This option can be given multiply.
 The difference from \fB\-t\fR is that only one port glob can be specified.
@@ -113,7 +117,7 @@ This option is recognized in the first \fBdo\fR or \fBredo\fR runs, and transfer
 Dependency relations are inspected for all installed packages as well.
 Combination with options \fB\-t\fR, \fB\-r\fR and \fB\-R\fR is available.
 .TP
-\fB\-R\fR \fIglob
+\fB\-R\fR \fIglob\fR
 Reinstall only target ports and their requirements.
 This option can be given multiply.
 The difference from \fB\-T\fR is that only one port glob can be specified.
@@ -133,7 +137,7 @@ Alternatively you can do the same thing by
 If you want to register permanently, set to the configuration file.
 Combination with options \fB\-X\fR is available.
 .TP
-\fB\-X\fR \fIglob
+\fB\-X\fR \fIglob\fR
 This option can be given multiply.
 The difference from \fB\-x\fR is that only one port glob can be specified.
 Thus a package name with commas is available.
@@ -259,7 +263,7 @@ Configuration file of portupgrade(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-1.2.0 (26 July 2012)
+1.2.0 (28 July 2012)
 [BUG FIX] Termination message is corrected (portsreinstall ok => portsreinstall ok add).
 
 [CHANGE] Functionalities of options \fB\-t\fR and \fB\-T\fR are changed so as to prevent deinstallation of irrelevant packages.
@@ -267,6 +271,10 @@ Configuration file of portupgrade(1).
 [NEW] Options \fB\-X\fR, \fB\-r\fR and \fB\-R\fR are added so as to compensate a fact that \fB\-x\fR, \fB\-t\fR and \fB\-T\fR cannot specify package names with commas.
 
 [CHANGE] Use of commas as delimiters in \fBok\fR and \fBtaboo\fR commands is abolished.
+
+[CHANGE] The specification of \fBshow\fR command is changed to exclude irrelevant packages/ports when options \fB\-r\fR, \fB\-R\fR, \fB\-t\fR and \fB\-T\fR are enabled.
+
+[NEW] Commands of \fBshow requirements\fR and  \fBshow dependents\fR are added.
 .TP
 1.1.0 (28 April 2012)
 [NEW] Command of show deleted is newly added.
index bae7af8..8688be4 100644 (file)
@@ -75,6 +75,10 @@ The following \fIargs\fR are available.
 \fBtaboo\fR : taboo ports
 
 \fBdeleted\fR : obsolete ports to be or have been deleted
+
+\fBrequirements\fR \fIglob\fR : ports required by a port
+
+\fBdependents\fR \fIglob\fR : ports depending on a port
 .SH OPTIONS
 The following options are available.
 They must be given separately with each other.
@@ -259,14 +263,18 @@ Configuration file of portupgrade(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-1.2.0 (26 July 2012)
+1.2.0 (28 July 2012)
 [BUG FIX] Termination message is corrected (portsreinstall ok => portsreinstall ok add).
 
-[CHANGE] Functionalities of options -t and -T are changed so as to prevent deinstallation of irrelevant packages.
+[CHANGE] Functionalities of options \fB\-t\fR and \fB\-T\fR are changed so as to prevent deinstallation of irrelevant packages.
 
-[NEW] Options -X, -r and -R are added so as to compensate a fact that -x, -t and -T cannot specify package names with commas.
+[NEW] Options \fB\-X\fR, \fB\-r\fR and \fB\-R\fR are added so as to compensate a fact that \fB\-x\fR, \fB\-t\fR and \fB\-T\fR cannot specify package names with commas.
 
 [CHANGE] Use of commas as delimiters in \fBok\fR and \fBtaboo\fR commands is abolished.
+
+[CHANGE] The specification of \fBshow\fR command is changed to exclude irrelevant packages/ports when options \fB\-r\fR, \fB\-R\fR, \fB\-t\fR and \fB\-T\fR are enabled.
+
+[NEW] Commands of \fBshow requirements\fR and  \fBshow dependents\fR are added.
 .TP
 1.1.0 (28 April 2012)
 [NEW] Command of show deleted is newly added.
index 024974f..241ad50 100755 (executable)
@@ -10,7 +10,7 @@
 # ================================================
 
 APPNAME=`basename $0`
-MYVERSION=1.1.0+toward_1.2.0_20120723065730
+MYVERSION=1.1.0+toward_1.2.0_20120726051358
 
 PREFIX=${PREFIX:-/usr/local}
 CONFFILE=${PREFIX}/etc/${APPNAME}.conf
@@ -146,7 +146,7 @@ then
        echo "          | ok del globs... | taboo add globs... | taboo del globs..."
        echo "          | save [dir] | load path"
        echo "          | show todo | show done | show resolved | show failure | show taboo"
-       echo "          | show deleted"
+       echo "          | show deleted | show requirements glob | show dependents glob"
        echo
        echo "[DESCRIPTIONS]"
        echo " This utility is an alternative to portupgrade(1) and portmaster(8), and"
@@ -257,13 +257,15 @@ then
        echo "      taboo del glob1 [glob2 ...]: deregister taboo ports"
        echo "      save [dir] : save the current temporal database as a .tar.gz archive"
        echo "      load path : load a temporal database archive"
-       echo "      show [arg] : show the list of ports to be reinstalled"
+       echo "      show [args] : show the list of ports to be reinstalled"
        echo "              todo : ports to be reinstalled (default)"
        echo "              done : already reinstalled ports"
        echo "              resolved : manually reinstalled ports"
        echo "              failure : failed ports"
        echo "              taboo : taboo ports"
        echo "              deleted : obsolete ports to be or have been deleted"
+       echo "              requirements glob : ports required by a port identified by glob"
+       echo "              dependents glob : ports depending on a port identified by glob"
        echo
        echo "[CONFIGURATION FILE]"
        echo "          ${CONFFILE}"
@@ -830,6 +832,20 @@ show_list_failure ()
        done < ${DBDIR}/failed.list
 }
 
+_get_one_port_from_an_argument_as_a_glob ()
+{
+       local target_glog num_matches
+       target_glog=$1
+       [ -n "$target_glog" ] || { echo "ERROR: the argument as port glob is missing" >&2; return 1; }
+       ports_glob "$2" > ${TMPDIR}/_get_one_port_from_an_argument_as_a_glob:ports_glob_argements
+       num_matches=`cat "${TMPDIR}"/_get_one_port_from_an_argument_as_a_glob:ports_glob_argements | wc -l`
+       [ $num_matches -ge 1 ] || { echo "ERROR: no matching port for the glob" >&2; return 1; }
+       [ $num_matches -eq 1 ] || { echo "ERROR: multiple matching ports for the glob" >&2; return 1; }
+       origin_target=`cat "${TMPDIR}"/_get_one_port_from_an_argument_as_a_glob:ports_glob_argements`
+       [ -e "${DBDIR}/requires/$origin_target/pkgtag" ] || { echo "ERROR: the database for $origin_target is not ready" >&2; return 1; }
+       pkg_target=`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`
+}
+
 _chk_if_target ()
 {
        _is_all=y
@@ -1000,6 +1016,7 @@ show)
        [ -d "${DBDIR}" ] || { echo "ERROR: Database has not built yet." >&2; exit 1; }
        warn_update_ports
        _filter_skip_unchanged=
+       _filter_only_target=
        pkgnamedb=requires
        case ${1:-todo} in
        todo)
@@ -1007,17 +1024,20 @@ show)
                list=reinst_todo.list
                [ -e "${DBDIR}/reinst_todo.list" ] || list=reinst_order.list
                _filter_skip_unchanged=necessary_update
+               _filter_only_target=y
                ;;
        done)
                echo "The following ports have been successfully reinstalled or newly installed:"
                list=success.list
                _filter_skip_unchanged=necessary_update_completed
+               _filter_only_target=y
                ;;
        redo)
                echo "The following ports themselves have been successfully reinstalled or newly installed,"
                echo "but are to be reinstalled again because their dependencies were failed:"
                list=success_but_dependencies_failed.list
                _filter_skip_unchanged=necessary_update
+               _filter_only_target=y
                ;;
        resolved)
                echo "The following ports had problems which have been manually resolved:"
@@ -1036,6 +1056,18 @@ show)
                echo "The following ports are to be or have been deleted:"
                list=moved_or_lost.actual.list
                pkgnamedb=obsolete
+               _filter_only_target=y
+               ;;
+       requirements)
+               _get_one_port_from_an_argument_as_a_glob "$2"
+               pkg_target=`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`
+               echo "The following ports are required by $origin_target ($pkg_target):"
+               list=requires/$origin_target/requires
+               ;;
+       dependents)
+               _get_one_port_from_an_argument_as_a_glob "$2"
+               echo "The following ports depend on $origin_target ($pkg_target):"
+               list=requires/$origin_target/dependents
                ;;
        *)
                echo "ERROR: Invalid show argument [$1]" >&2
@@ -1049,6 +1081,11 @@ show)
                while read origin
                do
                        [ -e "${DBDIR}/requires/$origin/${_filter_skip_unchanged}" ] || continue
+                       if [ -n "${_filter_only_target}" ]
+                       then
+                               _chk_if_target "$origin"
+                               [ -n "${_is_all}${_is_target}${_is_dependent}${_is_required}" ] || continue
+                       fi
                        if [ -e "${DBDIR}/$pkgnamedb/$origin/pkgtag" ]
                        then
                                echo $origin '('`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`')'
@@ -1059,6 +1096,11 @@ show)
        else
                while read origin
                do
+                       if [ -n "${_filter_only_target}" ]
+                       then
+                               _chk_if_target "$origin"
+                               [ -n "${_is_all}${_is_target}${_is_dependent}${_is_required}" ] || continue
+                       fi
                        if [ -e "${DBDIR}/$pkgnamedb/$origin/pkgtag" ]
                        then
                                echo $origin '('`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`')'