From f9364747fc3e530fee6ac42927b4458cb9328dab Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Tue, 5 Sep 2017 10:04:18 +0300 Subject: [PATCH] gnulib-tool.py: fix errors on building wget2; use UTF-8 in subprocess --- gnulib-tool.py | 21 ++++++++++++++++++++- pygnulib/GLEmiter.py | 2 +- pygnulib/GLFileSystem.py | 4 ++-- pygnulib/GLInfo.py | 6 +++--- pygnulib/GLModuleSystem.py | 6 +++--- pygnulib/GLTestDir.py | 2 +- 6 files changed, 30 insertions(+), 11 deletions(-) mode change 100644 => 100755 gnulib-tool.py diff --git a/gnulib-tool.py b/gnulib-tool.py old mode 100644 new mode 100755 index 8137ea3eb4..d76901d894 --- a/gnulib-tool.py +++ b/gnulib-tool.py @@ -118,7 +118,7 @@ def main(): parser.add_argument('-i', '--import', dest='mode_import', default=None, - nargs='+') + nargs='*') # add-import parser.add_argument('-a', '--add-import', dest='mode_add_import', @@ -213,6 +213,11 @@ def main(): dest='mode_xmaintainer', default=None, nargs='*') + # no-changelog + parser.add_argument('--no-changelog', + dest='changelog', + default=None, + action='store_false') # destdir parser.add_argument('-d', '--destdir', dest='destdir', @@ -241,6 +246,11 @@ def main(): dest='inctests', default=None, action='store_true') + # makefile + parser.add_argument("--makefile-name", + dest="makefile", + default=None, + type=str) # obsolete parser.add_argument('--with-obsolete', dest='obsolete', @@ -281,6 +291,11 @@ def main(): dest='libname', default=None, nargs=1) + # libtool + parser.add_argument("--libtool", + dest=libtool, + default=False, + action="store_true") # sourcebase parser.add_argument('-sb', '--source-base', dest='sourcebase', @@ -489,6 +504,8 @@ def main(): elif index == 6: testflags += [constants.TESTS['all-tests']] lgpl = cmdargs.lgpl + libtool = cmdargs.libtool + makefile = cmdargs.makefile if lgpl == None: lgpl = True avoids = cmdargs.avoids @@ -922,6 +939,8 @@ def main(): if __name__ == '__main__': try: # Try to execute main() + except: + raise except BaseException as error: errmode = 0 # gnulib-style errors errno = error.errno diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index 3a6ee00980..3895f4d514 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -172,7 +172,7 @@ class GLEmiter(object): file.write(snippet) stdin = codecs.open(path, 'rb', 'UTF-8') snippet = sp.check_output(args, stdin=stdin, shell=False) - snippet = snippet.decode(ENCS['shell']) + snippet = snippet.decode("UTF-8") os.remove(path) if disable_libtool: snippet = snippet.replace('$gl_cond_libtool', 'false') diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py index 6ccdc0b7ed..588df95cea 100644 --- a/pygnulib/GLFileSystem.py +++ b/pygnulib/GLFileSystem.py @@ -302,7 +302,7 @@ class GLFileAssistant(object): try: # Try to move file if os.path.exists(basepath): os.remove(basepath) - shutil.move(tmpfile, rewritten) + shutil.copy(tmpfile, rewritten) except Exception as error: raise(GLError(17, original)) else: # if self.config['dryrun'] @@ -352,7 +352,7 @@ class GLFileAssistant(object): stdin = codecs.open(lookedup, 'rb', 'UTF-8') try: # Try to transform file data = sp.check_output(args, stdin=stdin, shell=False) - data = data.decode(ENCS['shell']) + data = data.decode("UTF-8") except Exception as error: raise(GLError(16, lookedup)) with codecs.open(tmpfile, 'wb', 'UTF-8') as file: diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py index dd6b2675c4..646b20cf65 100644 --- a/pygnulib/GLInfo.py +++ b/pygnulib/GLInfo.py @@ -97,7 +97,7 @@ class GLInfo(object): counter = int() # Create counter result = string() # Create string args = ['git', 'log'] - result = sp.check_output(args).decode(ENCS['shell']) + result = sp.check_output(args).decode("UTF-8") # Get date as "Fri Mar 21 07:16:51 2008 -0600" from string pattern = re.compile('Date:[\t ]*(.*?)$', re.S | re.M) result = pattern.findall(result)[0] @@ -107,7 +107,7 @@ class GLInfo(object): # Use GNU date to compute the time in GMT args = ['date', '-d', result, '-u', '+%Y-%m-%d %H:%M:%S'] proc = sp.check_output(args) - result = string(proc, ENCS['shell']) + result = string(proc, "UTF-8") result = result.rstrip(os.linesep) return(result) @@ -294,7 +294,7 @@ Report bugs to .''' if isdir(DIRS['git']): version_gen = joinpath(DIRS['build-aux'], 'git-version-gen') args = [version_gen, DIRS['root']] - result = sp.check_output(args).decode(ENCS['shell']) + result = sp.check_output(args).decode("UTF-8") result = result.strip() if result == 'UNKNOWN': result = string() diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 53fe0a2712..34501e20e2 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -151,13 +151,13 @@ class GLModuleSystem(object): # Read modules from gnulib root directory. os.chdir(constants.DIRS['root']) find = sp.Popen(find_args, stdout=sp.PIPE) - result += find.stdout.read().decode(ENCS['shell']) + result += find.stdout.read().decode("UTF-8") # Read modules from local directory. if localdir and isdir(joinpath(localdir, 'modules')): os.chdir(localdir) find = sp.Popen(find_args, stdout=sp.PIPE) - result += find.stdout.read().decode(ENCS['shell']) + result += find.stdout.read().decode("UTF-8") sed_args += ['-e', r's,\.diff$,,'] # Save the list of the modules to file. @@ -169,7 +169,7 @@ class GLModuleSystem(object): # Filter the list of the modules. stdin = codecs.open(path, 'rb', 'UTF-8') sed = sp.Popen(sed_args, stdin=stdin, stdout=sp.PIPE) - result = sed.stdout.read().decode(ENCS['shell']) + result = sed.stdout.read().decode("UTF-8") stdin.close(); os.remove(path) listing = [line for line in result.split('\n') if line.strip()] listing = sorted(set(listing)) diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py index 8652d1ffc3..58663eab00 100644 --- a/pygnulib/GLTestDir.py +++ b/pygnulib/GLTestDir.py @@ -903,7 +903,7 @@ class GLMegaTestDir(object): vc_witness = joinpath(DIRS['root'], '.git', 'refs', 'heads', 'master') mdate_sh = joinpath(DIRS['root'], 'build-aux', 'mdate-sh') args = ['sh', mdate_sh, vc_witness] - cvsdate = sp.check_output(args).decode(ENCS['shell']).strip() + cvsdate = sp.check_output(args).decode("UTF-8").strip() for key in repdict: if len(key) > 3: cvsdate = cvsdate.replace(key, repdict[key]) -- 2.39.5