From b159ec7ae0faddb3c4ad16f8109b666c2cdc43e7 Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Jul 29 2019 20:40:39 +0000 Subject: Fix build with python3-scons --- diff --git a/0001-Use-RPM_OPT_FLAGS-for-the-natively-built-parts.patch b/0001-Use-RPM_OPT_FLAGS-for-the-natively-built-parts.patch index a6e67ec..47d8716 100644 --- a/0001-Use-RPM_OPT_FLAGS-for-the-natively-built-parts.patch +++ b/0001-Use-RPM_OPT_FLAGS-for-the-natively-built-parts.patch @@ -1,6 +1,6 @@ -diff -rupN nsis-3.03-src/SCons/Config/gnu nsis-3.03-src-new/SCons/Config/gnu ---- nsis-3.03-src/SCons/Config/gnu 2017-10-06 21:30:20.000000000 +0200 -+++ nsis-3.03-src-new/SCons/Config/gnu 2018-01-31 13:13:31.856956034 +0100 +diff -rupN nsis-3.04-src/SCons/Config/gnu nsis-3.04-src-new/SCons/Config/gnu +--- nsis-3.04-src/SCons/Config/gnu 2017-10-06 21:30:20.000000000 +0200 ++++ nsis-3.04-src-new/SCons/Config/gnu 2019-07-29 18:00:46.633960946 +0200 @@ -1,5 +1,7 @@ print("Using GNU tools configuration") diff --git a/mingw-nsis.spec b/mingw-nsis.spec index 269bdb3..fb2b25e 100644 --- a/mingw-nsis.spec +++ b/mingw-nsis.spec @@ -10,11 +10,13 @@ URL: http://nsis.sourceforge.net/ Source0: http://downloads.sourceforge.net/nsis/nsis-%{version}-src.tar.bz2 # Use RPM_OPT_FLAGS for the natively-built parts -Patch: 0001-Use-RPM_OPT_FLAGS-for-the-natively-built-parts.patch +Patch1: 0001-Use-RPM_OPT_FLAGS-for-the-natively-built-parts.patch +# Port scons scripts to python3 +Patch2: nsis_python3.patch BuildRequires: gcc-c++ BuildRequires: python3 -BuildRequires: scons +BuildRequires: python3-scons BuildRequires: zlib-devel BuildRequires: mingw32-filesystem >= 40 diff --git a/nsis_python3.patch b/nsis_python3.patch new file mode 100644 index 0000000..3a71e7d --- /dev/null +++ b/nsis_python3.patch @@ -0,0 +1,268 @@ +diff -rupN nsis-3.04-src/Contrib/ExDLL/SConscript nsis-3.04-src-new/Contrib/ExDLL/SConscript +--- nsis-3.04-src/Contrib/ExDLL/SConscript 2015-06-21 18:13:45.000000000 +0200 ++++ nsis-3.04-src-new/Contrib/ExDLL/SConscript 2019-07-29 18:00:46.674960703 +0200 +@@ -47,7 +47,7 @@ if PerformPluginExtrasDistOperationOnce( + env.DistributeExamples(api_files, path='Plugin/nsis') + env.DistributeExamples(example, path='Plugin') + if env['PLATFORM'] != 'win32': +- if env.has_key('PREFIX_PLUGINAPI_INC'): ++ if 'PREFIX_PLUGINAPI_INC' in env: + env.Distribute(api_files, None, 'pluginapi_inc', '', 'nsis', 'pluginapi', 'pluginapi') + + +@@ -56,7 +56,7 @@ if env['PLATFORM'] == 'win32': + else: + example += lib_files + +- if env.has_key('PREFIX_PLUGINAPI_LIB'): ++ if 'PREFIX_PLUGINAPI_LIB' in env: + env.Distribute(lib, None, 'pluginapi_lib', '', 'nsis', 'pluginapi', 'pluginapi') + + +diff -rupN nsis-3.04-src/Contrib/Graphics/SConscript nsis-3.04-src-new/Contrib/Graphics/SConscript +--- nsis-3.04-src/Contrib/Graphics/SConscript 2018-10-30 23:33:18.000000000 +0100 ++++ nsis-3.04-src-new/Contrib/Graphics/SConscript 2019-07-29 22:29:55.181779206 +0200 +@@ -90,8 +90,8 @@ wizards = Split(""" + + Import('defenv') + +-def join(prefix, list): +- return map(lambda x: '%s/%s' % (prefix, x), list) ++def join(prefix, lst): ++ return list(map(lambda x: '%s/%s' % (prefix, x), lst)) + + def dist(dir, files): + defenv.DistributeContrib(join(dir, files), path='Graphics/%s' % dir) +diff -rupN "nsis-3.04-src/Contrib/Modern UI/SConscript" "nsis-3.04-src-new/Contrib/Modern UI/SConscript" +--- "nsis-3.04-src/Contrib/Modern UI/SConscript" 2007-08-09 04:52:50.000000000 +0200 ++++ "nsis-3.04-src-new/Contrib/Modern UI/SConscript" 2019-07-29 22:30:30.702820469 +0200 +@@ -22,8 +22,8 @@ contribs = Split(""" + + Import('defenv') + +-def join(prefix, list): +- return map(lambda x: '%s/%s' % (prefix, x), list) ++def join(prefix, lst): ++ return list(map(lambda x: '%s/%s' % (prefix, x), lst)) + + defenv.DistributeDocs(docs, path=target) + path = 'images' +diff -rupN "nsis-3.04-src/Contrib/Modern UI 2/SConscript" "nsis-3.04-src-new/Contrib/Modern UI 2/SConscript" +--- "nsis-3.04-src/Contrib/Modern UI 2/SConscript" 2007-12-22 11:13:29.000000000 +0100 ++++ "nsis-3.04-src-new/Contrib/Modern UI 2/SConscript" 2019-07-29 22:30:25.801814859 +0200 +@@ -34,8 +34,8 @@ pages = Split(""" + + Import('defenv') + +-def join(prefix, list): +- return map(lambda x: '%s/%s' % (prefix, x), list) ++def join(prefix, lst): ++ return list(map(lambda x: '%s/%s' % (prefix, x), lst)) + + defenv.DistributeDocs(docs, path=target) + defenv.DistributeDocs(join('../Modern UI/images',doc_images), path='%s/%s'%(target,'images')) +diff -rupN nsis-3.04-src/Docs/src/SConscript nsis-3.04-src-new/Docs/src/SConscript +--- nsis-3.04-src/Docs/src/SConscript 2017-07-24 01:38:22.000000000 +0200 ++++ nsis-3.04-src-new/Docs/src/SConscript 2019-07-29 22:31:52.744910698 +0200 +@@ -50,8 +50,8 @@ chapters = 5 + appendices = 9 + + htmls = Split('IndexPage.html Contents.html') \ +- + map(lambda ch: 'Chapter' + str(ch + 1) + '.html', range(chapters)) \ +- + map(lambda ap: 'Appendix' + chr(ord('A') + ap) + '.html', range(appendices)) ++ + list(map(lambda ch: 'Chapter' + str(ch + 1) + '.html', range(chapters))) \ ++ + list(map(lambda ap: 'Appendix' + chr(ord('A') + ap) + '.html', range(appendices))) + + docsdefault_install_basepath = 'Docs' + +@@ -134,12 +134,12 @@ def docs_fixer(target, source, env): + return + + for i, html in enumerate(target): +- data = open(html.path,'rb').read() ++ data = open(html.path,'rb').read().decode('utf-8') + + for pat, repl in fixes.items(): + data = re.sub(env.subst(pat), env.subst(repl), data) + +- open(html.path, 'wb').write(data) ++ open(html.path, 'wb').write(data.encode('utf-8')) + + + def docs_extras(target, source, env): +diff -rupN nsis-3.04-src/SCons/Tools/crossmingw.py nsis-3.04-src-new/SCons/Tools/crossmingw.py +--- nsis-3.04-src/SCons/Tools/crossmingw.py 2016-10-01 01:32:40.000000000 +0200 ++++ nsis-3.04-src-new/SCons/Tools/crossmingw.py 2019-07-29 18:05:44.724766672 +0200 +@@ -98,7 +98,7 @@ def shlib_emitter(target, source, env): + no_import_lib = env.get('no_import_lib', 0) + + if not dll: +- raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX") ++ raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")) + + if not no_import_lib and \ + not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'): +@@ -141,9 +141,9 @@ def generate(env): + if not path: + path = [] + if SCons.Util.is_String(path): +- path = string.split(path, os.pathsep) ++ path = path.split(os.pathsep) + +- env['ENV']['PATH'] = string.join([dir] + path, os.pathsep) ++ env['ENV']['PATH'] = os.pathsep.join([dir] + path) + + # Most of mingw is the same as gcc and friends... + gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas'] +diff -rupN nsis-3.04-src/SCons/Tools/mstoolkit.py nsis-3.04-src-new/SCons/Tools/mstoolkit.py +--- nsis-3.04-src/SCons/Tools/mstoolkit.py 2018-06-03 23:00:53.000000000 +0200 ++++ nsis-3.04-src-new/SCons/Tools/mstoolkit.py 2019-07-29 18:00:46.675960697 +0200 +@@ -67,13 +67,13 @@ def get_msvctoolkit_paths(): + raise SCons.Errors.InternalError, "No Windows registry module was found" + + # look for toolkit +- if os.environ.has_key('VCToolkitInstallDir'): ++ if os.'VCToolkitInstallDir' in environ: + MSToolkitDir = os.path.normpath(os.environ['VCToolkitInstallDir']) + else: + raise SCons.Errors.InternalError, "Microsoft Visual C++ Toolkit 2003 directory was not found in the `VCToolkitInstallDir` environment variable." + + # look for platform sdk +- if os.environ.has_key('MSSdk'): ++ if os.'MSSdk' in environ: + PlatformSDKDir = os.path.normpath(os.environ['MSSdk']) + else: + try: +@@ -93,8 +93,8 @@ def get_msvctoolkit_paths(): + + def validate_vars(env): + """Validate the PDB, PCH, and PCHSTOP construction variables.""" +- if env.has_key('PCH') and env['PCH']: +- if not env.has_key('PCHSTOP'): ++ if 'PCH' in env and env['PCH']: ++ if not 'PCHSTOP' in env: + raise SCons.Errors.UserError, "The PCHSTOP construction must be defined if PCH is defined." + if not SCons.Util.is_String(env['PCHSTOP']): + raise SCons.Errors.UserError, "The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP'] +@@ -119,7 +119,7 @@ def pch_emitter(target, source, env): + + target = [pch, obj] # pch must be first, and obj second for the PCHCOM to work + +- if env.has_key('PDB') and env['PDB']: ++ if 'PDB' in env and env['PDB']: + env.SideEffect(env['PDB'], target) + env.Precious(env['PDB']) + +@@ -132,11 +132,11 @@ def object_emitter(target, source, env, + + parent_emitter(target, source, env) + +- if env.has_key('PDB') and env['PDB']: ++ if 'PDB' in env and env['PDB']: + env.SideEffect(env['PDB'], target) + env.Precious(env['PDB']) + +- if env.has_key('PCH') and env['PCH']: ++ if 'PCH' in env and env['PCH']: + env.Depends(target, env['PCH']) + + return (target, source) +@@ -153,7 +153,7 @@ pch_builder = SCons.Builder.Builder(acti + res_builder = SCons.Builder.Builder(action='$RCCOM', suffix='.res') + + def pdbGenerator(env, target, source, for_signature): +- if target and env.has_key('PDB') and env['PDB']: ++ if target and 'PDB' in env and env['PDB']: + return ['/PDB:%s'%target[0].File(env['PDB']).get_string(for_signature), + '/DEBUG'] + +@@ -197,7 +197,7 @@ def win32LibEmitter(target, source, env) + "SHLIBPREFIX", "SHLIBSUFFIX", + "WIN32DEFPREFIX", "WIN32DEFSUFFIX")) + +- if env.has_key('PDB') and env['PDB']: ++ if 'PDB' in env and env['PDB']: + env.SideEffect(env['PDB'], target) + env.Precious(env['PDB']) + +@@ -217,14 +217,14 @@ def win32LibEmitter(target, source, env) + def prog_emitter(target, source, env): + #SCons.Tool.msvc.validate_vars(env) + +- if env.has_key('PDB') and env['PDB']: ++ if 'PDB' in env and env['PDB']: + env.SideEffect(env['PDB'], target) + env.Precious(env['PDB']) + + return (target,source) + + def RegServerFunc(target, source, env): +- if env.has_key('register') and env['register']: ++ if 'register' in env and env['register']: + ret = regServerAction([target[0]], [source[0]], env) + if ret: + raise SCons.Errors.UserError, "Unable to register %s" % target[0] +diff -rupN nsis-3.04-src/SCons/utils.py nsis-3.04-src-new/SCons/utils.py +--- nsis-3.04-src/SCons/utils.py 2018-06-03 23:00:53.000000000 +0200 ++++ nsis-3.04-src-new/SCons/utils.py 2019-07-29 18:00:46.675960697 +0200 +@@ -125,9 +125,9 @@ def GetOptionOrEnv(name, defval = None): + import os + #if optenv and optenv.has_key(name): + # return optenv[name] +- if ARGUMENTS.has_key(name): ++ if name in ARGUMENTS: + return ARGUMENTS[name] +- if os.environ.has_key(name): ++ if name in os.environ: + return os.environ[name] + return defval + +diff -rupN nsis-3.04-src/SConstruct nsis-3.04-src-new/SConstruct +--- nsis-3.04-src/SConstruct 2018-12-07 23:06:47.000000000 +0100 ++++ nsis-3.04-src-new/SConstruct 2019-07-29 22:25:27.479413445 +0200 +@@ -260,7 +260,7 @@ if (not defenv.has_key('VER_PACKED')) an + if not defenv.has_key('VER_PACKED'): + import re + found = None +- for v in re.compile(r'^\\H\{[v]?(\S+)\}', re.M).finditer(File('#/Docs/src/history.but').get_contents()): # Try to parse the Halibut history file ++ for v in re.compile(r'^\\H\{[v]?(\S+)\}', re.M).finditer(File('#/Docs/src/history.but').get_contents().decode('utf-8')): # Try to parse the Halibut history file + if v and not found: + v = v.group(1).split('.') + if len(v) >= 2: +@@ -305,9 +305,8 @@ def GetArcSuffix(env, unicode = None): + return GetArcCPU(env) + suff + + def SafeFile(f): +- from types import StringType + +- if isinstance(f, StringType): ++ if type(f) is str: + return File(f) + + return f +@@ -363,21 +362,20 @@ defenv.Execute(Delete('$INSTDISTDIR')) + defenv.Execute(Delete('$TESTDISTDIR')) + + def Distribute(files, names, component, path, subpath, alias, install_alias=None): +- from types import StringType + + files = MakeFileList(files) + +- names = names or map(lambda x: x.name, files) +- if isinstance(names, StringType): ++ names = names or list(map(lambda x: x.name, files)) ++ if type(names) is str: + names = [names] + + for d in ('$ZIPDISTDIR', '$INSTDISTDIR', '$TESTDISTDIR'): +- paths = map(lambda file: os.path.join(d, path, subpath, file), names) ++ paths = list(map(lambda file: os.path.join(d, path, subpath, file), names)) + defenv.InstallAs(paths, files) + + if (defenv.has_key('PREFIX') and defenv['PREFIX']) or (defenv.has_key('PREFIX_DEST') and defenv['PREFIX_DEST']) : + prefix = '${PREFIX_DEST}${PREFIX_%s}' % component.upper() +- paths = map(lambda file: os.path.join(prefix, path, subpath, file), names) ++ paths = list(map(lambda file: os.path.join(prefix, path, subpath, file), names)) + ins = defenv.InstallAs(paths, files) + else: + ins = []