[gentoo-commits] proj/gentoolkit:master commit in: bin/

2024-05-24 Thread Matt Turner
commit: a667d934de4e5980111fb0b4e3ecae19b477131f
Author: Matt Turner  gentoo  org>
AuthorDate: Thu May 23 23:23:23 2024 +
Commit: Matt Turner  gentoo  org>
CommitDate: Sat May 25 03:44:14 2024 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=a667d934

bin/merge-driver-ekeyword: Look for KEYWORDS changes in upstream commit

Previously we only looked for changes to the KEYWORDS= line in our local
commit being rebased. If it contained no changes to KEYWORDS= then the
merge-driver gave up.

However our local patch may conflict with an upstream patch that changed
KEYWORDS.

In that case, we can look for changes to the KEYWORDS= line in the other
patch and try to apply its change to ours.

This happened in gentoo.git commits

2c5cd6c4e004 ("sys-fs/squashfs-tools-ng: Stabilize 1.3.0 amd64, #930693")
7129c2e4e5f3 ("sys-fs/squashfs-tools-ng: run elibtoolize in non-live ebuild")

leading to a rebase mistake in the latter (later fixed by commit
7579afbd4aa1 ("sys-fs/squashfs-tools-ng: stabilize 1.3.0 for amd64")).

With this patch applied, the merge conflicts are automatically resolved
between the two commits regardless of which is "ours" vs "theirs".

Signed-off-by: Matt Turner  gentoo.org>

 bin/merge-driver-ekeyword | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
index efdfbde..6d5f869 100755
--- a/bin/merge-driver-ekeyword
+++ b/bin/merge-driver-ekeyword
@@ -1,6 +1,6 @@
 #!/usr/bin/python3
 #
-# Copyright 2020-2023 Gentoo Authors
+# Copyright 2020-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2 or later
 
 """
@@ -119,12 +119,16 @@ def main(argv: Sequence[str]) -> int:
 B = argv[3]  # %B - filename of the other branch's version
 P = argv[4]  # %P - original path of the file
 
-# Get changes from %O to %B
-changes = keyword_changes(O, B)
-if changes:
-# Apply O -> B changes to A
+# Get changes to KEYWORDS= from %O to %B
+if changes := keyword_changes(O, B):
+# Apply %O -> %B changes to %A
 result = apply_keyword_changes(A, P, changes)
 sys.exit(result)
+# Get changes to KEYWORDS= from %O to %A
+elif changes := keyword_changes(O, A):
+# Apply %O -> %A changes to %B
+result = apply_keyword_changes(B, P, changes)
+sys.exit(result)
 else:
 try:
 os.execlp("git", "git", "merge-file", "-L", "HEAD", "-L", "base", 
"-L", "ours", A, O, B)



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2024-05-24 Thread Matt Turner
commit: 1fd8e83235dcd5cfd9fb2615c77f32da8b89d062
Author: Matt Turner  gentoo  org>
AuthorDate: Wed May  1 15:50:11 2024 +
Commit: Matt Turner  gentoo  org>
CommitDate: Sat May 25 03:44:14 2024 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=1fd8e832

bin/merge-driver-ekeyword: Remove unused imports

Fixes: 1a2c70d ("Run `pyupgrade --py39-plus`")
Signed-off-by: Matt Turner  gentoo.org>

 bin/merge-driver-ekeyword | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
index ae022f3..ff779c5 100755
--- a/bin/merge-driver-ekeyword
+++ b/bin/merge-driver-ekeyword
@@ -14,7 +14,7 @@ import os
 import sys
 import tempfile
 
-from typing import List, Optional, Tuple
+from typing import Optional
 from collections.abc import Sequence
 
 from gentoolkit.ekeyword import ekeyword



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2024-05-24 Thread Matt Turner
commit: 6b6fa781352b306f7b5aa387fffa53b9bc63f209
Author: Matt Turner  gentoo  org>
AuthorDate: Wed May  1 15:51:45 2024 +
Commit: Matt Turner  gentoo  org>
CommitDate: Sat May 25 03:44:14 2024 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=6b6fa781

bin/merge-driver-ekeyword: Two blank lines after function def

Signed-off-by: Matt Turner  gentoo.org>

 bin/merge-driver-ekeyword | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
index ff779c5..efdfbde 100755
--- a/bin/merge-driver-ekeyword
+++ b/bin/merge-driver-ekeyword
@@ -131,5 +131,6 @@ def main(argv: Sequence[str]) -> int:
 except OSError:
 sys.exit(-1)
 
+
 if __name__ == "__main__":
 main(sys.argv)



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2023-08-29 Thread Mike Gilbert
commit: 67983750f9014d5b1821b9cd2522b34f04ce1795
Author: Mike Gilbert  gentoo  org>
AuthorDate: Tue Aug 29 15:25:55 2023 +
Commit: Mike Gilbert  gentoo  org>
CommitDate: Tue Aug 29 15:41:11 2023 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=67983750

bin/merge-driver-ekeyword: replace os.system with os.execlp

Signed-off-by: Mike Gilbert  gentoo.org>

 bin/merge-driver-ekeyword | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
index 0235a98..ae022f3 100755
--- a/bin/merge-driver-ekeyword
+++ b/bin/merge-driver-ekeyword
@@ -126,11 +126,10 @@ def main(argv: Sequence[str]) -> int:
 result = apply_keyword_changes(A, P, changes)
 sys.exit(result)
 else:
-result = os.system(f"git merge-file -L HEAD -L base -L ours {A} {O} 
{B}")
-result = os.waitstatus_to_exitcode(result)
-if result < 0 or result >= 128:
+try:
+os.execlp("git", "git", "merge-file", "-L", "HEAD", "-L", "base", 
"-L", "ours", A, O, B)
+except OSError:
 sys.exit(-1)
-sys.exit(result)
 
 if __name__ == "__main__":
 main(sys.argv)



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2023-08-28 Thread Sam James
commit: fb45df369b4be7061fc14f5eb361c4d6c97e3f02
Author: Sam James  gentoo  org>
AuthorDate: Tue Aug 29 01:21:04 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Aug 29 01:21:17 2023 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=fb45df36

bin/merge-driver-ekeyword: mangle exit code correctly

Fixes: 263e3d64adac1ee2968233e151d1ee590532f42d
Signed-off-by: Sam James  gentoo.org>

 bin/merge-driver-ekeyword | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
index e59e10c..0235a98 100755
--- a/bin/merge-driver-ekeyword
+++ b/bin/merge-driver-ekeyword
@@ -1,6 +1,6 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
-# Copyright 2020 Gentoo Authors
+# Copyright 2020-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2 or later
 
 """
@@ -127,8 +127,10 @@ def main(argv: Sequence[str]) -> int:
 sys.exit(result)
 else:
 result = os.system(f"git merge-file -L HEAD -L base -L ours {A} {O} 
{B}")
+result = os.waitstatus_to_exitcode(result)
+if result < 0 or result >= 128:
+sys.exit(-1)
 sys.exit(result)
 
-
 if __name__ == "__main__":
 main(sys.argv)



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2023-08-28 Thread Sam James
commit: 263e3d64adac1ee2968233e151d1ee590532f42d
Author: Sam James  gentoo  org>
AuthorDate: Tue Aug 29 00:50:11 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Aug 29 00:51:32 2023 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=263e3d64

bin/merge-driver-ekeyword: fix compatibility with >=git-2.42.0

Commit 2b7b788fb31a74bcbff4e4c6efc6f3db6c3a49b7 upstream makes more use
of the result from a merge driver.

Correctly surface the result from `git merge-file` so that we don't wrongly
throw away information but also don't make git think the driver crashed (-1
is for exceptional cases, not "failed to merge").

Signed-off-by: Sam James  gentoo.org>

 bin/merge-driver-ekeyword | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
index f75056c..e59e10c 100755
--- a/bin/merge-driver-ekeyword
+++ b/bin/merge-driver-ekeyword
@@ -127,7 +127,7 @@ def main(argv: Sequence[str]) -> int:
 sys.exit(result)
 else:
 result = os.system(f"git merge-file -L HEAD -L base -L ours {A} {O} 
{B}")
-sys.exit(0 if result == 0 else -1)
+sys.exit(result)
 
 
 if __name__ == "__main__":



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2022-12-03 Thread Michał Górny
commit: 62d22ed69cecd3ae416b3b899062244865659d5b
Author: Michał Górny  gentoo  org>
AuthorDate: Sat Dec  3 13:54:06 2022 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sat Dec  3 13:54:06 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=62d22ed6

ebump: Use `git rev-parse --is-inside-work-tree`

Signed-off-by: Michał Górny  gentoo.org>

 bin/ebump | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/ebump b/bin/ebump
index 06264c4..25e9a7c 100755
--- a/bin/ebump
+++ b/bin/ebump
@@ -277,7 +277,7 @@ get_vcs() {
return 0
else
if command -v git >/dev/null; then
-   if [ -n "$(git rev-parse --git-dir 2>/dev/null)" ]; then
+   if [ "$(git rev-parse --is-inside-work-tree)" = true ]; 
then
echo "git"
return 0
fi



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2022-12-03 Thread Michał Górny
commit: 932473493220d48457aeb547018d040138c1e161
Author: Michał Górny  gentoo  org>
AuthorDate: Sat Dec  3 13:45:14 2022 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sat Dec  3 13:45:14 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=93247349

ebump: Replace which(1) with `command -v`

Signed-off-by: Michał Górny  gentoo.org>

 bin/ebump | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/ebump b/bin/ebump
index 7f6e3ce..06264c4 100755
--- a/bin/ebump
+++ b/bin/ebump
@@ -276,7 +276,7 @@ get_vcs() {
echo "svn"
return 0
else
-   if [ -x "$(which git)" ]; then
+   if command -v git >/dev/null; then
if [ -n "$(git rev-parse --git-dir 2>/dev/null)" ]; then
echo "git"
return 0



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2022-07-28 Thread Brian Dolbec
commit: 4a56a7feff4fe8ed427cddff6e6b2719f0fe58c3
Author: Brian Dolbec  gentoo  org>
AuthorDate: Tue Jul 12 00:58:23 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Tue Jul 12 00:58:23 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=4a56a7fe

revdep-rebuild.sh: Create its cache dir if it doesn't exist

Bug: https://bugs.gentoo.org/382009

Signed-off-by: Brian Dolbec  gentoo.org>

 bin/revdep-rebuild.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/revdep-rebuild.sh b/bin/revdep-rebuild.sh
index 5fecf97..7ee3647 100755
--- a/bin/revdep-rebuild.sh
+++ b/bin/revdep-rebuild.sh
@@ -570,7 +570,8 @@ verify_tmpdir() {
elif [[ -d $1 ]]; then
cd "$1"
else
-   die 1 "Unable to find a satisfactory location for temporary 
files ($1)"
+   mkdir -p "$1"
+   cd "$1"
fi
[[ $VERBOSE ]] && einfo "Temporary cache files are located in $PWD"
setup_rm



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2022-07-09 Thread Brian Dolbec
commit: b22f6af5e32950859390dc2efd0379c572258bda
Author: Hadrien Lacour  posteo  net>
AuthorDate: Sat Mar 31 20:39:01 2018 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sat Jul  9 19:29:48 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b22f6af5

revdep-rebuild.sh: use awk instead of gawk

Bug: https://bugs.gentoo.org/652078
Signed-off-by: Zac Medico  gentoo.org>
Closes: https://github.com/gentoo/gentoolkit/pull/6
Signed-off-by: Brian Dolbec  gentoo.org>

 bin/revdep-rebuild.sh | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/bin/revdep-rebuild.sh b/bin/revdep-rebuild.sh
index 633701e..5fecf97 100755
--- a/bin/revdep-rebuild.sh
+++ b/bin/revdep-rebuild.sh
@@ -235,9 +235,19 @@ countdown() {
 # Replace whitespace with linebreaks, normalize repeated '/' chars, and sort -u
 # (If any libs have whitespace in their filenames, someone needs punishment.)
 clean_var() {
-   gawk 'BEGIN {RS="[[:space:]]"}
-/-\*/ {exit}
-/[^[:space:]]/ {gsub(/\/\/+/, "/"); print}' | sort -u
+   awk '
+   BEGIN {FS = "[[:space:]]"}
+
+   {
+   for(i = 1; i <= NF; ++i) {
+   if($i ~ /-\*/)
+   exit
+   else if($i){
+   gsub(/\/\/+/, "/", $i)
+   print $i
+   }
+   }
+   }' | sort -u
 }
 ##
 # Exit and optionally output to sterr
@@ -805,8 +815,8 @@ main_checks() {
# Look for symbol not defined errors
if grep -vF "${LD_LIBRARY_MASK:=$'\a'}" 
<<< "$ldd_output" |
grep -q -E 'symbol .* not 
defined'; then
-   message=$(gawk '/symbol .* not 
defined/ {NF--; print $0}' <<< "$ldd_output")
-   broken_lib=$(gawk '/symbol .* 
not defined/ {print $NF}' <<< "$ldd_output" | \
+   message=$(awk '/symbol .* not 
defined/ {ORS = FS; for(i = 1; i < NF; ++i) print $i; printf "\n"}' <<< 
"$ldd_output")
+   broken_lib=$(awk '/symbol .* 
not defined/ {print $NF}' <<< "$ldd_output" | \
sed 's/[()]//g')
echo "obj $broken_lib" >> 
"$BROKEN_FILE"
echo_v "  broken $broken_lib 
($message)"
@@ -820,7 +830,7 @@ main_checks() {
*)
if grep -vF 
"${LD_LIBRARY_MASK:=$'\a'}" <<< "$ldd_output" |
grep -q -F 'undefined 
symbol:'; then
-   message=$(gawk 
'/undefined symbol:/ {print $3}' <<< "$ldd_output")
+   message=$(awk 
'/undefined symbol:/ {print $3}' <<< "$ldd_output")

message="${message//$'\n'/ }"
echo "obj $target_file" 
>> "$BROKEN_FILE"
echo_v "  broken 
$target_file (undefined symbols(s): $message)"
@@ -835,7 +845,7 @@ main_checks() {
la_broken=""
la_lib=""
for depend in $(
-   gawk -F"[=']" '/^dependency_libs/{
+   awk -F"[=']" '/^dependency_libs/{
print $3
}' "$target_file"
); do
@@ -876,7 +886,7 @@ main_checks() {
done < <(
# Regexify LD_LIBRARY_MASK. Exclude it from the 
search.
LD_LIBRARY_MASK="${LD_LIBRARY_MASK//$'\n'/|}"
-   gawk -v ldmask="(${LD_LIBRARY_MASK//./.})" '
+   awk -v ldmask="(${LD_LIBRARY_MASK//./.})" '
/no version information available/ && 
$0 !~ ldmask {
gsub(/[()]/, "", $NF)
if (seen[$NF]++)  next
@@ -1068,7 +1078,7 @@ show_unowned_files() {
ewarn "The broken files are:"
while read filename junk; do
[[ $junk = *none* ]] && ewarn "  $filename"
-   done < "$OWNERS_FILE" | gawk '!s[$0]++' # (omit dupes)
+   done < "$OWNERS_FILE" | awk 

[gentoo-commits] proj/gentoolkit:master commit in: bin/, pym/gentoolkit/equery/

2022-07-08 Thread Brian Dolbec
commit: 71c6d4d94a5bd5aac3fb090e2e306c278a83b954
Author: Marco Sirabella  sirabella  org>
AuthorDate: Sat May  8 13:45:08 2021 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sat Jul  9 02:44:08 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=71c6d4d9

metadata.py: Don't fail on unmatched package

Added a warning hook too to reuse the GentoolkitNoMatches machinery

This allows users to do something like:
  equery list @selected | xargs equery metadata
successfuly, even if there are some selected packages that don't exist
anymore.

Signed-off-by: Marco Sirabella  sirabella.org>
Signed-off-by: Brian Dolbec  gentoo.org>

 bin/equery| 10 ++
 pym/gentoolkit/equery/meta.py |  4 +++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/bin/equery b/bin/equery
index 0e52294..3b3e850 100755
--- a/bin/equery
+++ b/bin/equery
@@ -29,6 +29,16 @@ except KeyboardInterrupt:
 sys.exit(1)
 
 from gentoolkit import equery, errors
+import warnings
+
+
+def formatwarning(message, category, filename, llineno, line=None):
+from gentoolkit import pprinter as pp
+return pp.warn(str(message))
+
+
+if '--debug' not in sys.argv and not bool(os.getenv('DEBUG', False)):
+warnings.formatwarning = formatwarning
 
 try:
 equery.main(sys.argv)

diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index 4cf4bc6..2e8dc36 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -13,6 +13,7 @@ __docformat__ = "epytext"
 import re
 import os
 import sys
+import warnings
 from getopt import gnu_getopt, GetoptError
 
 import gentoolkit.pprinter as pp
@@ -524,7 +525,8 @@ def main(input_args):
 best_match = query.find_best()
 matches = query.find(include_masked=True)
 if best_match is None or not matches:
-raise errors.GentoolkitNoMatches(query)
+warnings.warn(errors.GentoolkitNoMatches(query))
+continue
 
 if best_match.metadata is None:
 print(



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2022-05-18 Thread Sam James
commit: 049b80cd6b4ffe3929fd95a9f9b21582fd2373f4
Author: Sam James  gentoo  org>
AuthorDate: Sun May 15 05:47:58 2022 +
Commit: Sam James  gentoo  org>
CommitDate: Sun May 15 05:48:10 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=049b80cd

euse: egrep -> grep -E

egrep is considered an obsolete alias and newer greps will warn on this.

Signed-off-by: Sam James  gentoo.org>

 bin/euse | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/bin/euse b/bin/euse
index c3b6638..daffd66 100755
--- a/bin/euse
+++ b/bin/euse
@@ -338,11 +338,11 @@ get_useflaglist() {
descdir="${profiledir}/profiles"
if [[ -z ${SCOPE} || ${SCOPE} == "global" ]]; then
[[ ! -s "${descdir}/use.desc" ]] && continue
-   egrep "^[^# ]+ +-" "${descdir}/use.desc"
+   grep -E "^[^# ]+ +-" "${descdir}/use.desc"
fi
if [[ -z ${SCOPE} || ${SCOPE} == "local" ]]; then
[[ ! -s "${descdir}/use.local.desc" ]] && continue
-   egrep "^[^# :]+:[^ ]+ +-" "${descdir}/use.local.desc" \
+   grep -E "^[^# :]+:[^ ]+ +-" "${descdir}/use.local.desc" 
\
| cut -d: -f 2
fi
done | cut -d " "  -f1 | sort --field=":" --key=1,1 --unique
@@ -370,7 +370,7 @@ get_useflaglist() {
 # ACTIVE_FLAGS - Array of current use flag info
 #
 get_useflaglist_ebuild() {
-   local known=$(echo "${ACTIVE_FLAGS[5]}" | egrep "^${1}")
+   local known=$(echo "${ACTIVE_FLAGS[5]}" | grep -E "^${1}")
local cacheformat
if [[ -n $known ]]; then
# No need to recache
@@ -397,7 +397,7 @@ get_useflaglist_ebuild() {
return 1
fi
append=$(set +f; ls ${portdir}/metadata/${cacheformat}/${1}-* \
-   | egrep "${1}-[0-9.]+" \
+   | grep -E "${1}-[0-9.]+" \
| sed -e 
"s:${portdir}/metadata/${cacheformat}/${1}-::g" \
| while read -d $'\n' version; do
IFS=$'\n'
@@ -454,7 +454,7 @@ traverse_profile() {
curdir="${2:-$(get_real_path ${MAKE_PROFILE_PATH})}"
 
if [[ -f "${curdir}/parent" ]]; then
-   for parent in $(egrep -v '(^#|^ *$)' ${curdir}/parent); do
+   for parent in $(grep -E -v '(^#|^ *$)' ${curdir}/parent); do
# Bug 231394, handle parent path being absolute
index=$(expr index "${parent}" :)
if [[ ${parent:0:1} == "/" ]]; then
@@ -906,9 +906,9 @@ showflags() {
get_flagstatus ${1}
echo
fi
-   if echo " ${ACTIVE_FLAGS[4]} " | egrep -e " -?${1} " > 
/dev/null; then
+   if echo " ${ACTIVE_FLAGS[4]} " | grep -E -e " -?${1} " > 
/dev/null; then
for pkg in $( echo "${ACTIVE_FLAGS[4]}" | \
-   egrep " -?${1} " | cut -d " " -f 2); do
+   grep -E " -?${1} " | cut -d " " -f 2); 
do
printf "%-20s" ${1}
SCOPE="local" get_flagstatus ${1} "${pkg}"
printf "(%s)\n" ${pkg}
@@ -992,7 +992,7 @@ scrub_use_flag() {
# If line only has this use flag, let it be removed
# (used if PACKAGE is not defined -- from pruning)
elif [[ -n $(echo "${line}" | \
-   egrep "^[^#]*${atom_re}.*-?${flag}") ]]; then
+   grep -E "^[^#]*${atom_re}.*-?${flag}") ]]; then
echo "Removing use flag from ${line}" >&2
if [[ -z $(echo "${line}" | \
grep -Ee "${atom_re} *-?${flag} *$") 
]]; then
@@ -1068,10 +1068,10 @@ modify_package() {
# XXX: Handle version or version wildcard?
warn "USE flag \"${flag}\" is not used by $PACKAGE"
# Don't necessarily bail for this, just warn
-   elif [[ -n "${V}" && -z "$(egrep "<|>|=" <<< "${PACKAGE:0:1}")" ]]; then
+   elif [[ -n "${V}" && -z "$(grep -E "<|>|=" <<< "${PACKAGE:0:1}")" ]]; 
then
error "Invalid package atom. Did you forget the leading '='?"
continue
-   elif [[ -z "${V}" && -n "$(egrep "<|>|=" <<< "${PACKAGE:0:1}")" ]]; then
+   elif [[ -z "${V}" && -n "$(grep -E "<|>|=" <<< "${PACKAGE:0:1}")" ]]; 
then
error "Invalid package atom. Did you forget the version?"
continue
fi
@@ -1114,7 +1114,7 @@ modify_package() {
echo "Adding \"${PACKAGE}[${flag}]\" use flag in 
\"${filename}\""
local added=0
  

[gentoo-commits] proj/gentoolkit:master commit in: bin/, pym/gentoolkit/ekeyword/, man/

2022-02-09 Thread Sam James
commit: 0064df828104e2fda3b552c02c56f1ef1fb9c613
Author: Sam James  gentoo  org>
AuthorDate: Tue Dec 14 05:19:37 2021 +
Commit: Sam James  gentoo  org>
CommitDate: Wed Feb  9 10:49:44 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=0064df82

*/*: drop obsolete Changelog references

We got rid of Changelogs years ago in ::gentoo and most Portage
support is gone too.

Closes: https://bugs.gentoo.org/832369
Signed-off-by: Sam James  gentoo.org>

 bin/ebump   | 35 ---
 man/ebump.1 | 29 +
 pym/gentoolkit/ekeyword/ekeyword.py |  7 +--
 3 files changed, 2 insertions(+), 69 deletions(-)

diff --git a/bin/ebump b/bin/ebump
index a0d4d56..7f6e3ce 100755
--- a/bin/ebump
+++ b/bin/ebump
@@ -39,9 +39,7 @@ print_usage() {
echo "  -v|--verbose   increase verbosity"
echo "  -q|--quiet turn off output"
echo "  -a|--no-auxfiles   don't bump auxfiles (files/*)"
-   echo "  -c|--no-changelog  do not update ChangeLog (via echangelog)"
echo "  -C|--no-vcsdo not add to VCS"
-   echo "  -m|--message   append message to ChangeLog"
echo "  -d|--delete-olddelete previous revision from VCS 
(DANGEROUS!)"
 }
 
@@ -55,17 +53,9 @@ load_options() {
if [ -f "/etc/gentoolkit/ebump.conf" ] ; then
. /etc/gentoolkit/ebump.conf
fi
-   if [ -f "${HOME}/.gentoo/gentool-env" ] ; then
-   . ${HOME}/.gentoo/gentool-env
-   fi
if [ -f "${HOME}/.gentoo/ebump.conf" ] ; then
. ${HOME}/.gentoo/ebump.conf
fi
-
-   # FIXME: remove this warning in 2-3 releases.
-   if [ -n "${opt_add_cvs}" ]; then
-   echo "Warning: opt_add_cvs is deprecated, please use 
opt_add_vcs from now on!" >&2
-   fi
 }
 
 #
@@ -276,26 +266,6 @@ process_ebuild() {
fi
einfo "Removed ${delfiles} from VCS"
fi
-
-   #
-   # (Optional) Add ChangeLog entry
-   #
-   if [ "${opt_add_changelog}" = "y" ] && [ "${opt_add_vcs}" = "y" ]; then
-   # FIXME: remove this warning in 2-3 releases
-   if [ -n "${AUTHORNAME}" ] || [ -n "${AUTHOREMAIL}" ]; then
-   echo "Warning: AUTHORNAME and AUTHOREMAIL is 
deprecated!" >&2
-   echo "Please take a look at echangelog(1)." >&2
-   echo "To avoid this warning unset AUTHORNAME and 
AUTHOREMAIL." >&2
-   fi
-
-   echangelog "${opt_commitmessage}" || set $?
-
-   if [ ${1:-0} -ne 0 ]; then
-   einfo "Modifying ChangeLog failed!"
-   else
-   einfo "Added ChangeLog entry"
-   fi
-   fi
 }
 
 get_vcs() {
@@ -322,7 +292,6 @@ get_vcs() {
 # Global options
 #
 opt_verbosity=0
-opt_add_changelog=y
 opt_add_vcs=y
 opt_bump_auxfiles=y
 opt_delete_old=n
@@ -348,10 +317,6 @@ while [ ${#} -gt 0 ] ; do
opt_bump_auxfiles=n
continue
;;
-   -c|--no-changelog)
-   opt_add_changelog=n
-   continue
-   ;;
-C|--no-vcs)
opt_add_vcs=n
continue

diff --git a/man/ebump.1 b/man/ebump.1
index 1754cf9..72c0d05 100644
--- a/man/ebump.1
+++ b/man/ebump.1
@@ -54,21 +54,6 @@ Do not output any non-essential information.
 .IP
 don't bump auxfiles (files/*)
 
-.LP
-\fB\-c\fR
-.br
-\fB--no-changelog\fB
-.IP
-do not update ChangeLog (via echangelog)
-
-.LP
-\fB\-m\fR <\fIChangeLog text\fR>
-.br
-\fB\--message\fR <\fIChangeLog text\fR>
-.IP
-Specifies the message to add to the ChangeLog, instead of the standard
-placeholder.
-
 .LP
 \fB\-d\fR
 .br
@@ -96,28 +81,16 @@ From these files, \fIebump\fR will load the settings
 .br
 \fBopt_verbosity\fR (default \fI1\fR) - verbosity level 0-10
 .br
-\fBopt_add_changelog\fR (default \fIy\fR) - add entry in ChangeLog
-.br
 \fBopt_add_vcs\fR (default \fIy\fR) - add new files to VCS
 .br
 \fBopt_bump_auxfiles\fR (default \fIy\fR) - bump auxiliary files in files/
 .br
 \fBopt_delete_old\fR (default \fIn\fR) - delete old revision (DANGEROUS!)
-.br
-\fBopt_commitmessage\fR (default \fI""\fR) - default ChangeLog message
-
-.LP
-\fB(DEPRECATED)\fR
-.br
-\fB~/.gentoo/gentool-env\fR
-.IR
-From this file, \fIebump\fR will load the env vars \fBAUTHORNAME\fR and
-\fBAUTHOREMAIL\fR, which are used to generate proper ChangeLog entries.
 
 .SH "SEE ALSO"
 .LP
 The rest of the utilities in \fIapp-portage/gentoolkit-dev\fR, such as
-\fIechangelog(1)\fR and \fIekeyword(1)\fR.
+\fIekeyword(1)\fR.
 
 .SH "AUTHORS"
 .LP

diff --git a/pym/gentoolkit/ekeyword/ekeyword.py 
b/pym/gentoolkit/ekeyword/ekeyword.py
index 13b93ad..7d3a1ef 100755
--- a/pym/gentoolkit/ekeyword/ekeyword.py

[gentoo-commits] proj/gentoolkit:master commit in: bin/

2021-03-11 Thread Matt Turner
commit: 273b4530ebb098fa140614d72532e5c6cb277df2
Author: Matt Turner  gentoo  org>
AuthorDate: Fri Mar 12 02:24:29 2021 +
Commit: Matt Turner  gentoo  org>
CommitDate: Fri Mar 12 02:31:16 2021 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=273b4530

bin: Fix type annotations

Signed-off-by: Matt Turner  gentoo.org>

 bin/merge-driver-ekeyword | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
index d24aaf9..7f4a10b 100755
--- a/bin/merge-driver-ekeyword
+++ b/bin/merge-driver-ekeyword
@@ -14,11 +14,13 @@ import os
 import sys
 import tempfile
 
-from typing import List, Optional, Tuple
+from typing import List, Optional, Sequence, Tuple
 
 from gentoolkit.ekeyword import ekeyword
 
 
+KeywordChanges = List[Tuple[Optional[List[str]], Optional[List[str
+
 def keyword_array(keyword_line: str) -> List[str]:
 # Find indices of string inside the double-quotes
 i1: int = keyword_line.find('"') + 1
@@ -28,14 +30,13 @@ def keyword_array(keyword_line: str) -> List[str]:
 return keyword_line[i1:i2].split(' ')
 
 
-def keyword_line_changes(old: str, new: str) -> List[Tuple[Optional[str],
-   Optional[str]]]:
+def keyword_line_changes(old: str, new: str) -> KeywordChanges:
 a: List[str] = keyword_array(old)
 b: List[str] = keyword_array(new)
 
 s = difflib.SequenceMatcher(a=a, b=b)
 
-changes = []
+changes: KeywordChanges = []
 for tag, i1, i2, j1, j2 in s.get_opcodes():
 if tag == 'replace':
 changes.append((a[i1:i2], b[j1:j2]),)
@@ -48,8 +49,7 @@ def keyword_line_changes(old: str, new: str) -> 
List[Tuple[Optional[str],
 return changes
 
 
-def keyword_changes(ebuild1: str, ebuild2: str) -> List[Tuple[Optional[str],
-  Optional[str]]]:
+def keyword_changes(ebuild1: str, ebuild2: str) -> Optional[KeywordChanges]:
 with open(ebuild1) as e1, open(ebuild2) as e2:
 lines1 = e1.readlines()
 lines2 = e2.readlines()
@@ -82,8 +82,7 @@ def keyword_changes(ebuild1: str, ebuild2: str) -> 
List[Tuple[Optional[str],
 
 
 def apply_keyword_changes(ebuild: str, pathname: str,
-  changes: List[Tuple[Optional[str],
-  Optional[str]]]) -> int:
+  changes: KeywordChanges) -> int:
 result: int = 0
 
 with tempfile.TemporaryDirectory() as tmpdir:
@@ -109,7 +108,7 @@ def apply_keyword_changes(ebuild: str, pathname: str,
 return result
 
 
-def main(argv):
+def main(argv: Sequence[str]) -> int:
 if len(argv) != 5:
 sys.exit(-1)
 
@@ -122,10 +121,10 @@ def main(argv):
 changes = keyword_changes(O, B)
 if changes:
 # Apply O -> B changes to A
-result: int = apply_keyword_changes(A, P, changes)
+result = apply_keyword_changes(A, P, changes)
 sys.exit(result)
 else:
-result: int = os.system(f"git merge-file -L HEAD -L base -L ours {A} 
{O} {B}")
+result = os.system(f"git merge-file -L HEAD -L base -L ours {A} {O} 
{B}")
 sys.exit(0 if result == 0 else -1)
 
 



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2021-02-24 Thread Matt Turner
commit: 6e85d8a770ebc9f00e53a61cdd098caefeb3cbbf
Author: Matt Turner  gentoo  org>
AuthorDate: Thu Feb 25 00:04:02 2021 +
Commit: Matt Turner  gentoo  org>
CommitDate: Thu Feb 25 00:05:56 2021 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=6e85d8a7

bin: Handle case of no KEYWORD removals

Signed-off-by: Matt Turner  gentoo.org>

 bin/merge-driver-ekeyword | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
index 2df83fc..d24aaf9 100755
--- a/bin/merge-driver-ekeyword
+++ b/bin/merge-driver-ekeyword
@@ -93,10 +93,11 @@ def apply_keyword_changes(ebuild: str, pathname: str,
 
 for removals, additions in changes:
 args = []
-for rem in removals:
-# Drop leading '~' and '-' characters and prepend '^'
-i = 1 if rem[0] in ('~', '-') else 0
-args.append('^' + rem[i:])
+if removals:
+for rem in removals:
+# Drop leading '~' and '-' characters and prepend '^'
+i = 1 if rem[0] in ('~', '-') else 0
+args.append('^' + rem[i:])
 if additions:
 args.extend(additions)
 args.append(ebuild_symlink)



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2020-12-31 Thread Matt Turner
commit: 9f01c8b098484866974407bb74680debf0d64e4f
Author: Matt Turner  gentoo  org>
AuthorDate: Sun Dec 20 22:12:49 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Thu Dec 31 19:44:17 2020 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=9f01c8b0

bin: Add merge-driver-ekeyword

Since the KEYWORDS=... assignment is a single line, git struggles to
handle conflicts. When rebasing a series of commits that modify the
KEYWORDS=... it's usually easier to throw them away and reapply on the
new tree than it is to manually handle conflicts during the rebase.

git allows a 'merge driver' program to handle conflicts; this program
handles conflicts in the KEYWORDS=... assignment. E.g., given an ebuild
with these keywords:

KEYWORDS="~alpha amd64 arm arm64 ~hppa ppc ppc64 x86"

One developer drops the ~alpha keyword and pushes to gentoo.git, and
another developer stabilizes hppa. Without this merge driver, git
requires the second developer to manually resolve the conflict which is
tedious and prone to mistakes when rebasing a long series of patches.
With the custom merge driver, it automatically resolves the conflict.

To use the merge driver, configure your gentoo.git as such:

gentoo.git/.git/config:

[merge "keywords"]
name = KEYWORDS merge driver
driver = merge-driver-ekeyword %O %A %B %P

gentoo.git/.git/info/attributes:

*.ebuild merge=keywords

Signed-off-by: Matt Turner  gentoo.org>

 bin/merge-driver-ekeyword | 132 ++
 1 file changed, 132 insertions(+)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
new file mode 100755
index 000..2df83fc
--- /dev/null
+++ b/bin/merge-driver-ekeyword
@@ -0,0 +1,132 @@
+#!/usr/bin/python
+#
+# Copyright 2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2 or later
+
+"""
+Custom git merge driver for handling conflicts in KEYWORDS assignments
+
+See https://git-scm.com/docs/gitattributes#_defining_a_custom_merge_driver
+"""
+
+import difflib
+import os
+import sys
+import tempfile
+
+from typing import List, Optional, Tuple
+
+from gentoolkit.ekeyword import ekeyword
+
+
+def keyword_array(keyword_line: str) -> List[str]:
+# Find indices of string inside the double-quotes
+i1: int = keyword_line.find('"') + 1
+i2: int = keyword_line.rfind('"')
+
+# Split into array of KEYWORDS
+return keyword_line[i1:i2].split(' ')
+
+
+def keyword_line_changes(old: str, new: str) -> List[Tuple[Optional[str],
+   Optional[str]]]:
+a: List[str] = keyword_array(old)
+b: List[str] = keyword_array(new)
+
+s = difflib.SequenceMatcher(a=a, b=b)
+
+changes = []
+for tag, i1, i2, j1, j2 in s.get_opcodes():
+if tag == 'replace':
+changes.append((a[i1:i2], b[j1:j2]),)
+elif tag == 'delete':
+changes.append((a[i1:i2], None),)
+elif tag == 'insert':
+changes.append((None, b[j1:j2]),)
+else:
+assert tag == 'equal'
+return changes
+
+
+def keyword_changes(ebuild1: str, ebuild2: str) -> List[Tuple[Optional[str],
+  Optional[str]]]:
+with open(ebuild1) as e1, open(ebuild2) as e2:
+lines1 = e1.readlines()
+lines2 = e2.readlines()
+
+diff = difflib.unified_diff(lines1, lines2, n=0)
+assert next(diff) == '--- \n'
+assert next(diff) == '+++ \n'
+
+hunk: int = 0
+old: str = ''
+new: str = ''
+
+for line in diff:
+if line.startswith('@@ '):
+if hunk > 0:
+break
+hunk += 1
+elif line.startswith('-'):
+if old or new:
+break
+old = line
+elif line.startswith('+'):
+if not old or new:
+break
+new = line
+else:
+if 'KEYWORDS=' in old and 'KEYWORDS=' in new:
+return keyword_line_changes(old, new)
+return None
+
+
+def apply_keyword_changes(ebuild: str, pathname: str,
+  changes: List[Tuple[Optional[str],
+  Optional[str]]]) -> int:
+result: int = 0
+
+with tempfile.TemporaryDirectory() as tmpdir:
+# ekeyword will only modify files named *.ebuild, so make a symlink
+ebuild_symlink: str = os.path.join(tmpdir, os.path.basename(pathname))
+os.symlink(os.path.join(os.getcwd(), ebuild), ebuild_symlink)
+
+for removals, additions in changes:
+args = []
+for rem in removals:
+# Drop leading '~' and '-' characters and prepend '^'
+i = 1 if rem[0] in ('~', '-') else 0
+args.append('^' + rem[i:])
+if 

[gentoo-commits] proj/gentoolkit:master commit in: bin/

2020-03-16 Thread Ben Kohler
commit: 26620fa90335a7b7921d41711ee9baf82eb41784
Author: Ben Kohler  gentoo  org>
AuthorDate: Mon Mar 16 14:21:34 2020 +
Commit: Ben Kohler  gentoo  org>
CommitDate: Mon Mar 16 14:23:57 2020 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=26620fa9

euse: don't fail on repos missing use.desc

Signed-off-by: Ben Kohler  gentoo.org>

 bin/euse | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/euse b/bin/euse
index 56fc917..15a2a6e 100755
--- a/bin/euse
+++ b/bin/euse
@@ -842,7 +842,8 @@ showinstdesc() {
while [ -n "${1}" ]; do
case "${SCOPE}" in
"global")
-   if desc=$(grep "^${1}  *-" 
${PORTAGE_REPO_PATHS[@]/%//profiles/use.desc}); then
+   local desc=$(grep "^${1}  *-" 
${PORTAGE_REPO_PATHS[@]/%//profiles/use.desc} 2>/dev/null)
+   if [ ! -z "${desc}" ]; then
get_flagstatus "${1}"
echo "$desc"
# get list of installed packages 
matching this USE flag.



[gentoo-commits] proj/gentoolkit:master commit in: bin/, pym/gentoolkit/ekeyword/, /

2017-03-22 Thread Brian Dolbec
commit: 60d2f9b26ba4cff6782062a7cb1fdb289bd8276e
Author: Brian Dolbec  gentoo  org>
AuthorDate: Wed Mar 22 12:18:20 2017 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Wed Mar 22 12:49:51 2017 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=60d2f9b2

ekeyword: Initial updates for gentoolkit eco-system

 bin/ekeyword| 45 +
 pym/gentoolkit/ekeyword/__init__.py |  0
 pym/gentoolkit/ekeyword/ekeyword.py |  4 ++--
 setup.py|  1 +
 4 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/bin/ekeyword b/bin/ekeyword
new file mode 100755
index 000..6fb3036
--- /dev/null
+++ b/bin/ekeyword
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+#
+# Copyright 2002-2017 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2 or later
+#
+# $Header$
+
+"""Manage KEYWORDS in ebuilds easily.
+
+This tool provides a simple way to add or update KEYWORDS in a set of ebuilds.
+Each command-line argument is processed in order, so that keywords are added to
+the current list as they appear, and ebuilds are processed as they appear.
+
+"""
+
+from __future__ import print_function
+
+import os
+import sys
+# This block ensures that ^C interrupts are handled quietly.
+try:
+   import signal
+
+   def exithandler(signum,frame):
+   signal.signal(signal.SIGINT, signal.SIG_IGN)
+   signal.signal(signal.SIGTERM, signal.SIG_IGN)
+   print()
+   sys.exit(1)
+
+   signal.signal(signal.SIGINT, exithandler)
+   signal.signal(signal.SIGTERM, exithandler)
+   signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+
+except KeyboardInterrupt:
+   print()
+   sys.exit(1)
+
+from gentoolkit.ekeyword import ekeyword
+
+try:
+   ekeyword.main(sys.argv[1:])
+except KeyboardInterrupt:
+   print("Aborted.")
+   sys.exit(130)
+sys.exit(0)

diff --git a/pym/gentoolkit/ekeyword/__init__.py 
b/pym/gentoolkit/ekeyword/__init__.py
new file mode 100644
index 000..e69de29

diff --git a/pym/gentoolkit/ekeyword/ekeyword.py 
b/pym/gentoolkit/ekeyword/ekeyword.py
index 31225b0..170c25b 100755
--- a/pym/gentoolkit/ekeyword/ekeyword.py
+++ b/pym/gentoolkit/ekeyword/ekeyword.py
@@ -51,7 +51,7 @@ import portage
 from portage.output import colorize, nocolor
 
 
-VERSION = '1.0 awesome'
+__version__ = 'git'
 
 # Operation object that describes how to perform a change.
 # Args:
@@ -475,7 +475,7 @@ def get_parser():
parser.add_argument('--format', default='auto', dest='style',
choices=('auto', 'color-inline', 'inline', 'short-multi', 
'long-multi'),
help='Selet output format for showing differences')
-   parser.add_argument('-V', '--version', action='version', 
version=VERSION,
+   parser.add_argument('-V', '--version', action='version', 
version=__version__,
help='Show version information')
return parser
 

diff --git a/setup.py b/setup.py
index d16a56b..02363ec 100755
--- a/setup.py
+++ b/setup.py
@@ -44,6 +44,7 @@ python_scripts = [(os.path.join(cwd, path), '__version__ = ') 
for path in (
'bin/glsa-check',
'pym/gentoolkit/eclean/cli.py',
'pym/gentoolkit/enalyze/__init__.py',
+   'pym/gentoolkit/ekeyword/ekeyword.py',
'pym/gentoolkit/equery/__init__.py',
'pym/gentoolkit/eshowkw/__init__.py',
'pym/gentoolkit/revdep_rebuild/__init__.py'



[gentoo-commits] proj/gentoolkit:master commit in: bin/

2016-10-17 Thread Paul Varner
commit: b5e71f6f2ed3483422df611fc2450081c72332ac
Author: Paul Varner  gentoo  org>
AuthorDate: Mon Oct 17 17:38:09 2016 +
Commit: Paul Varner  gentoo  org>
CommitDate: Mon Oct 17 17:38:09 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b5e71f6f

eread: Fix bash error when the elog directory is empty

This fixes the following error from bash which causes an infinite loop.

/usr/bin/eread: line 64: break: only meaningful in a `for', `while', or
`until' loop

X-Gentoo-bug: 597132
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=597132

 bin/eread | 124 +++---
 1 file changed, 62 insertions(+), 62 deletions(-)

diff --git a/bin/eread b/bin/eread
index fe095a6..2289f2d 100755
--- a/bin/eread
+++ b/bin/eread
@@ -57,72 +57,72 @@ find_files() {
 }
 
 select_loop() {
-   ANY_FILES=$(find_files)
-
-   if [[ -z ${ANY_FILES} ]]; then
-   echo "No log items to read"
-   break
-   fi
-
-   echo
-   echo "This is a list of portage log items. Choose a number to view that 
file or type q to quit."
-   echo
-
-   # Pick which file to read
-   select FILE in ${ANY_FILES}; do
-   case ${REPLY} in
-   q)
-   echo "Quitting"
-   QUIT="yes"
-   break
-   ;;
-   a)
-   SORT="alphabet"
-   ;;
-   t)
-   SORT="time"
-   ;;
-   *)
-   if [ -f "$FILE" ]; then
-   ${PAGER} ${FILE}
-   read -p "Delete file? [y/N] " DELETE
-   case ${DELETE} in
-   q)
-   echo "Quitting"
-   QUIT="yes"
-   break
-   ;;
-   y|Y)
-   rm -f ${FILE}
-   SUCCESS=$?
-   if [[ ${SUCCESS} = 0 
]]; then
-   echo "Deleted 
${FILE}"
-   else
-   echo "Unable to 
delete ${FILE}"
-   fi
-   ;;
-   # Empty string defaults to N 
(save file)
-   n|N|"")
-   echo "Saving ${FILE}"
-   ;;
-   *)
-   echo "Invalid response. 
Saving ${FILE}"
-   ;;
-   esac
-   else
-   echo
-   echo "Invalid response."
-   fi
-   ;;
-   esac
-   break
+   until [[ -n ${QUIT} ]]; do
+   ANY_FILES=$(find_files)
+
+   if [[ -z ${ANY_FILES} ]]; then
+   echo "No log items to read"
+   break
+   fi
+
+   echo
+   echo "This is a list of portage log items. Choose a number to 
view that file or type q to quit."
+   echo
+
+   # Pick which file to read
+   select FILE in ${ANY_FILES}; do
+   case ${REPLY} in
+   q)
+   echo "Quitting"
+   QUIT="yes"
+   break
+   ;;
+   a)
+   SORT="alphabet"
+   ;;
+   t)
+   SORT="time"
+   ;;
+   *)
+   if [ -f "$FILE" ]; then
+   ${PAGER} ${FILE}
+   read -p "Delete file? [y/N] " 
DELETE
+ 

[gentoo-commits] proj/gentoolkit:master commit in: bin/

2016-06-06 Thread Paul Varner
commit: d158f2e656bd72f01b72bb94cb734fb1021934b5
Author: Paul Varner  gentoo  org>
AuthorDate: Mon Jun  6 21:14:27 2016 +
Commit: Paul Varner  gentoo  org>
CommitDate: Mon Jun  6 21:14:27 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=d158f2e6

glsa-check: Apply list only affected versions patch from bug 400763

Author: Roland Hopferwieser  int0x80.at>
X-Gentoo-bug: 400763
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=400763

 bin/glsa-check | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/bin/glsa-check b/bin/glsa-check
index 46088d7..3f691b8 100755
--- a/bin/glsa-check
+++ b/bin/glsa-check
@@ -240,11 +240,15 @@ def summarylist(myglsalist, fd1=sys.stdout, 
fd2=sys.stderr, encoding="utf-8"):
if len(myglsa.packages) > 3:
fd1.write("... ")
else:
-   for pkg in myglsa.packages.keys():
-   mylist = 
vardb.match(portage.dep_getkey(str(pkg)))
+   for cpv in myglsa.packages.keys():
+   pkg = myglsa.packages[cpv]
+   for path in pkg:
+   v_installed = reduce(operator.add, 
[match(v, "vartree") for v in path["vul_atoms"]], [])
+   u_installed = reduce(operator.add, 
[match(u, "vartree") for u in path["unaff_atoms"]], [])
+   mylist = 
sorted(set(v_installed).difference(set(u_installed)))
if len(mylist) > 0:
-   pkg = color(" ".join(mylist))
-   fd1.write(" " + pkg + " ")
+   cpv = color(" ".join(mylist))
+   fd1.write(" " + cpv + " ")
 
fd1.write(")")
if list_cve: