commit:     56350cb6b1ee0b93a86e27bc59f7d3a0e73ad220
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sun Mar  4 05:32:20 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Mar  4 18:22:05 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=56350cb6

xattr-helper.py: Make restoring of extended attributes work again.

Set options.paths using standard input only in dump mode.
Also fix support for paths passed as arguments.

Bug: https://bugs.gentoo.org/649528
Fixes: 345c54de9e8c9daac190fbb07d33bf40e7bac5a9

 bin/xattr-helper.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/bin/xattr-helper.py b/bin/xattr-helper.py
index b5faed044..75844f279 100755
--- a/bin/xattr-helper.py
+++ b/bin/xattr-helper.py
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 2012-2014 Gentoo Foundation
+# Copyright 2012-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 doc = """Dump and restore extended attributes.
@@ -147,12 +147,13 @@ def main(argv):
        actions.add_argument('--dump',
                action='store_true',
                help='Dump the values of all extended '
-                       'attributes associated with null-separated'
-                       ' paths read from stdin.')
+                       'attributes associated with paths '
+                       'passed as arguments or null-separated '
+                       'paths read from stdin.')
        actions.add_argument('--restore',
                action='store_true',
-               help='Restore extended attributes using'
-                       ' a dump read from stdin.')
+               help='Restore extended attributes using '
+                       'a dump read from stdin.')
 
        options = parser.parse_args(argv)
 
@@ -160,10 +161,12 @@ def main(argv):
                file_in = sys.stdin.buffer.raw
        else:
                file_in = sys.stdin
-       if not options.paths:
-               options.paths += [x for x in file_in.read().split(b'\0') if x]
 
        if options.dump:
+               if options.paths:
+                       options.paths = [unicode_encode(x) for x in 
options.paths]
+               else:
+                       options.paths = [x for x in file_in.read().split(b'\0') 
if x]
                if sys.hexversion >= 0x3000000:
                        file_out = sys.stdout.buffer
                else:

Reply via email to