pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/install Pretty-print the users and groups that may ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/442af2d8f5ca
branches:  trunk
changeset: 488355:442af2d8f5ca
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Fri Jan 28 18:00:28 2005 +0000

description:
Pretty-print the users and groups that may need to be removed during
CHECK-REMOVE.  The users and groups are now printed on the same line
with whitespace separating the entries (for easy copy-and-pasting info
commands), and wrapping to successive lines if we overflow the length
of the current line.

diffstat:

 mk/install/usergroup |  65 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 41 insertions(+), 24 deletions(-)

diffs (91 lines):

diff -r d03f6f422440 -r 442af2d8f5ca mk/install/usergroup
--- a/mk/install/usergroup      Fri Jan 28 16:20:26 2005 +0000
+++ b/mk/install/usergroup      Fri Jan 28 18:00:28 2005 +0000
@@ -92,6 +92,29 @@
        return 1
 }
 
+listwrap()
+{
+       length=$1
+       buffer=
+       while read line; do
+               set -- $line
+               for word; do
+                       case $buffer in
+                       "")     buffer="$word" ;;
+                       *)      buffer="$buffer  $word" ;;
+                       esac
+                       if ${TEST} ${#buffer} -gt $length; then
+                               ${ECHO} "       $buffer"
+                               buffer=
+                       fi
+               done
+       done
+       case $buffer in
+       "")     ;;
+       *)      ${ECHO} "       $buffer" ;;
+       esac
+}
+
 exitcode=0
 case $ACTION in
 ADD)
@@ -301,19 +324,16 @@
                esac
                shadow_dir="${PKG_REFCOUNT_USERS_DBDIR}/$user"
                ${TEST} -d "$shadow_dir" && continue    # refcount isn't zero
-               case "$printed_header" in
-               yes)    ;;
-               *)      printed_header=yes
-                       ${ECHO} "==========================================================================="
-                       ${ECHO} "The following users are no longer being used by ${PKGNAME},"
-                       ${ECHO} "and they can be removed if no other packages are using them:"
-                       ${ECHO} ""
-                       ;;
-               esac
-               ${ECHO} "       ${user}"
+               existing_users="$existing_users $user"
        done
-       case "$printed_header" in
-       yes)    ${ECHO} ""
+       case $existing_users in
+       "")     ;;
+       *)      ${ECHO} "==========================================================================="
+               ${ECHO} "The following users are no longer being used by ${PKGNAME},"
+               ${ECHO} "and they can be removed if no other packages are using them:"
+               ${ECHO} ""
+               ${ECHO} "$existing_users" | listwrap 40
+               ${ECHO} ""
                ${ECHO} "==========================================================================="
                exit 1
                ;;
@@ -331,19 +351,16 @@
                esac
                shadow_dir="${PKG_REFCOUNT_GROUPS_DBDIR}/$group"
                ${TEST} -d "$shadow_dir" && continue    # refcount isn't zero
-               case "$printed_header" in
-               yes)    ;;
-               *)      printed_header=yes
-                       ${ECHO} "==========================================================================="
-                       ${ECHO} "The following groups are no longer being used by ${PKGNAME},"
-                       ${ECHO} "and they can be removed if no other packages are using them:"
-                       ${ECHO} ""
-                       ;;
-               esac
-               ${ECHO} "       $group"
+               existing_groups="$existing_groups $group"
        done
-       case "$printed_header" in
-       yes)    ${ECHO} ""
+       case $existing_groups in
+       "")     ;;
+       *)      ${ECHO} "==========================================================================="
+               ${ECHO} "The following groups are no longer being used by ${PKGNAME},"
+               ${ECHO} "and they can be removed if no other packages are using them:"
+               ${ECHO} ""
+               ${ECHO} "$existing_groups" | listwrap 40
+               ${ECHO} ""
                ${ECHO} "==========================================================================="
                exit 1
                ;;



Home | Main Index | Thread Index | Old Index