diff options
author | jlam <jlam@pkgsrc.org> | 2005-01-28 18:00:28 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2005-01-28 18:00:28 +0000 |
commit | fc16f1f48c0c78a0e67011fe34576c05c734c407 (patch) | |
tree | 4f23363bb628643a3295916df1cf71a290f25907 /mk | |
parent | 35271fea8cb24f30d795c5b964ef6b8842e8100b (diff) | |
download | pkgsrc-fc16f1f48c0c78a0e67011fe34576c05c734c407.tar.gz |
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 (limited to 'mk')
-rw-r--r-- | mk/install/usergroup | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/mk/install/usergroup b/mk/install/usergroup index 32dacfb5abf..1b811880488 100644 --- a/mk/install/usergroup +++ b/mk/install/usergroup @@ -92,6 +92,29 @@ user_exists() 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 @@ CHECK-REMOVE) 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 @@ CHECK-REMOVE) 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 ;; |