From 9e0384be71bf31bee6778fd35d0f37c3a8c71f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Safa=20Ar=C4=B1man?= Date: Mon, 5 Aug 2019 21:32:54 +0300 Subject: [PATCH 1/7] updated gitignore --- .gitignore | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5b2f737c..edd590bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,127 @@ -*~ -*.mo -*.py[co] +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python build/ +develop-eggs/ dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# PyCharm +.idea/ From f81864efd59c83aa62335d204a36252da44152e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Safa=20Ar=C4=B1man?= Date: Mon, 5 Aug 2019 21:39:38 +0300 Subject: [PATCH 2/7] detect_patch_level patch applied --- pisi/util.py | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/pisi/util.py b/pisi/util.py index 6768064c..1b9c6414 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -516,6 +516,17 @@ def uncompress(patchFile, compressType="gz", targetDir=""): return filePath.split(".%s" % extension)[0] +def check_patch_level(workdir, path): + level = 0 + while path: + if os.path.isfile("%s/%s" % (workdir, path)): + return level + if path.find("/") == -1: + return None + level += 1 + path = path[path.find("/")+1:] + + def do_patch(sourceDir, patchFile, level=0, name=None, reverse=False): """Apply given patch to the sourceDir.""" cwd = os.getcwd() @@ -524,14 +535,42 @@ def do_patch(sourceDir, patchFile, level=0, name=None, reverse=False): else: raise Error(_("ERROR: WorkDir (%s) does not exist\n") % (sourceDir)) - if level == None: + check_file(patchFile) + + if level is None: + with open(patchFile, "r") as patchfile: + lines = patchfile.readlines() + try: + paths_m = [l.strip().split()[1] for l in lines if l.startswith("---") and "/" in l] + try: + paths_p = [l.strip().split()[1] for l in lines if l.startswith("+++")] + except IndexError: + paths_p = [] + except IndexError: + pass + else: + if not paths_p: + paths_p = paths_m[:] + try: + paths_m = [l.strip().split()[1] for l in lines if l.startswith("***") and "/" in l] + except IndexError: + pass + + for path_p, path_m in zip(paths_p, paths_m): + if "/dev/null" in path_m and not len(paths_p) -1 == paths_p.index(path_p): continue + level = check_patch_level(sourceDir, path_p) + if level is None and len(paths_m) - 1 == paths_m.index(path_m): + level = check_patch_level(sourceDir, path_m) + if level is not None: + ctx.ui.debug("Detected patch level=%s for %s" % (level, os.path.basename(patchFile))) + break + + if level is None: level = 0 if name is None: name = os.path.basename(patchFile) - check_file(patchFile) - if ctx.get_option('use_quilt'): patchesDir = join_path(sourceDir, ctx.const.quilt_dir_suffix) # Make sure sourceDir/patches directory exists and if not create one! From fbf2c05545d0f54db8e02b7685de5123ce14b5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Safa=20Ar=C4=B1man?= Date: Mon, 5 Aug 2019 21:50:00 +0300 Subject: [PATCH 3/7] improve_emul32 patch applied --- pisi/actionsapi/autotools.py | 31 ++++++++++++++++++++++++++++++- pisi/actionsapi/get.py | 3 +++ pisi/actionsapi/variables.py | 1 + pisi/operations/build.py | 4 ++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/pisi/actionsapi/autotools.py b/pisi/actionsapi/autotools.py index 1bb94fc6..575800a7 100644 --- a/pisi/actionsapi/autotools.py +++ b/pisi/actionsapi/autotools.py @@ -26,6 +26,11 @@ from pisi.actionsapi.shelltools import system from pisi.actionsapi.shelltools import can_access_file from pisi.actionsapi.shelltools import unlink from pisi.actionsapi.libtools import gnuconfig_update +from pisi.actionsapi.shelltools import isDirectory +from pisi.actionsapi.shelltools import ls +from pisi.actionsapi.pisitools import dosed +from pisi.actionsapi.pisitools import removeDir + class ConfigureError(pisi.actionsapi.Error): def __init__(self, value=''): @@ -59,6 +64,8 @@ def configure(parameters = ''): if can_access_file('configure'): gnuconfig_update() + prefix = get.emul32prefixDIR() if get.buildTYPE() == "emul32" else get.defaultprefixDIR() + args = './configure \ --prefix=/%s \ --build=%s \ @@ -68,11 +75,14 @@ def configure(parameters = ''): --sysconfdir=/%s \ --localstatedir=/%s \ --libexecdir=/%s \ - %s' % (get.defaultprefixDIR(), \ + %s' % (prefix, \ get.HOST(), get.manDIR(), \ get.infoDIR(), get.dataDIR(), \ get.confDIR(), get.localstateDIR(), get.libexecDIR(), parameters) + if get.buildTYPE() == "emul32": + args += " --libdir=/usr/lib32" + if system(args): raise ConfigureError(_('Configure failed.')) else: @@ -101,6 +111,15 @@ def fixInfoDir(): if can_access_file(infoDir): unlink(infoDir) + +def fixpc(): + ''' fix .pc files in installDIR()/usr/lib32/pkgconfig''' + path = "%s/usr/lib32/pkgconfig" % get.installDIR() + if isDirectory(path): + for f in ls("%s/*.pc" % path): + dosed(f, get.emul32prefixDIR(), get.defaultprefixDIR()) + + def install(parameters = '', argument = 'install'): '''install source into install directory with given parameters''' args = 'make prefix=%(prefix)s/%(defaultprefix)s \ @@ -127,6 +146,11 @@ def install(parameters = '', argument = 'install'): else: fixInfoDir() + if get.buildTYPE() == "emul32": + fixpc() + if isDirectory("%s/emul32" % get.installDIR()): + removeDir("/emul32") + def rawInstall(parameters = '', argument = 'install'): '''install source into install directory with given parameters = PREFIX=%s % get.installDIR()''' @@ -135,6 +159,11 @@ def rawInstall(parameters = '', argument = 'install'): else: fixInfoDir() + if get.buildTYPE() == "emul32": + fixpc() + if isDirectory("%s/emul32" % get.installDIR()): + removeDir("/emul32") + def aclocal(parameters = ''): '''generates an aclocal.m4 based on the contents of configure.in.''' if system('aclocal %s' % parameters): diff --git a/pisi/actionsapi/get.py b/pisi/actionsapi/get.py index e39762e5..36ad5b69 100644 --- a/pisi/actionsapi/get.py +++ b/pisi/actionsapi/get.py @@ -157,6 +157,9 @@ def libexecDIR(): def defaultprefixDIR(): return dirs.defaultprefix +def emul32prefixDIR(): + return dirs.emul32prefix + def kdeDIR(): return dirs.kde diff --git a/pisi/actionsapi/variables.py b/pisi/actionsapi/variables.py index 7c4f9dca..196e6749 100644 --- a/pisi/actionsapi/variables.py +++ b/pisi/actionsapi/variables.py @@ -84,6 +84,7 @@ class Dirs: localstate = 'var' libexec = 'usr/libexec' defaultprefix = 'usr' + emul32prefix = 'emul32' # These should be owned by object not the class. Or else Python # will bug us with NoneType errors because of uninitialized diff --git a/pisi/operations/build.py b/pisi/operations/build.py index b7491f27..b11a33ab 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -403,6 +403,10 @@ class Builder: "SRC_NAME": self.spec.source.name, "SRC_VERSION": self.spec.getSourceVersion(), "SRC_RELEASE": self.spec.getSourceRelease()} + + if self.build_type == "emul32": + env["CC"] = "%s -m32" % os.getenv("CC") + env["CXX"] = "%s -m32" % os.getenv("CXX") os.environ.update(env) # First check icecream, if not found use ccache From 8add680d13ab8ebc27eed3e5d499bb47744e8bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Safa=20Ar=C4=B1man?= Date: Mon, 5 Aug 2019 21:53:10 +0300 Subject: [PATCH 4/7] fix_emul32_flags patch applied --- pisi/operations/build.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pisi/operations/build.py b/pisi/operations/build.py index b11a33ab..1586932d 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -407,6 +407,8 @@ class Builder: if self.build_type == "emul32": env["CC"] = "%s -m32" % os.getenv("CC") env["CXX"] = "%s -m32" % os.getenv("CXX") + env["CFLAGS"] = os.getenv("CFLAGS").replace("-fPIC", "") + env["CXXFLAGS"] = os.getenv("CXXFLAGS").replace("-fPIC", "") os.environ.update(env) # First check icecream, if not found use ccache From 10f828be409dfdf3adb61330c2cc9d4e294324c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Safa=20Ar=C4=B1man?= Date: Mon, 5 Aug 2019 21:53:37 +0300 Subject: [PATCH 5/7] disable-sandbox-for-emul32-builds patch applied --- pisi/operations/build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pisi/operations/build.py b/pisi/operations/build.py index 1586932d..ad20a158 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -706,7 +706,8 @@ class Builder: if func in self.actionLocals: if ctx.get_option('ignore_sandbox') or \ - not ctx.config.values.build.enablesandbox: + not ctx.config.values.build.enablesandbox or \ + "emul32" in self.build_type: self.actionLocals[func]() else: import catbox From 92962daab0449f6982747694c789edf546e8ca78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Safa=20Ar=C4=B1man?= Date: Mon, 5 Aug 2019 21:58:46 +0300 Subject: [PATCH 6/7] WorkDir patch applied --- pisi/operations/build.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pisi/operations/build.py b/pisi/operations/build.py index ad20a158..8e4ab03b 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -682,6 +682,10 @@ class Builder: src_dir, ext = os.path.splitext(src_dir) if not ext: break + if not os.path.exists(src_dir): + src_dir = util.join_path(self.pkg_work_dir(), [d for d in os.walk(self.pkg_work_dir()).next()[1] if not d.startswith(".")][0]) + if self.get_state() == "unpack": + ctx.ui.debug("Using %s as WorkDir" % src_dir) return src_dir From c8c768f5edb4f7fdb951e7ba64004b0f4b3bf69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Safa=20Ar=C4=B1man?= Date: Mon, 5 Aug 2019 22:03:17 +0300 Subject: [PATCH 7/7] fix_improve_emul32 patch applied --- pisi/actionsapi/autotools.py | 10 ++++++---- pisi/operations/build.py | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pisi/actionsapi/autotools.py b/pisi/actionsapi/autotools.py index 575800a7..ab9cb473 100644 --- a/pisi/actionsapi/autotools.py +++ b/pisi/actionsapi/autotools.py @@ -75,10 +75,12 @@ def configure(parameters = ''): --sysconfdir=/%s \ --localstatedir=/%s \ --libexecdir=/%s \ - %s' % (prefix, \ - get.HOST(), get.manDIR(), \ - get.infoDIR(), get.dataDIR(), \ - get.confDIR(), get.localstateDIR(), get.libexecDIR(), parameters) + %s%s' % (prefix, \ + get.HOST(), get.manDIR(), \ + get.infoDIR(), get.dataDIR(), \ + get.confDIR(), get.localstateDIR(), get.libexecDIR(), + "--libdir=/usr/lib32 " if get.buildTYPE() == "emul32" else "", + parameters) if get.buildTYPE() == "emul32": args += " --libdir=/usr/lib32" diff --git a/pisi/operations/build.py b/pisi/operations/build.py index 8e4ab03b..51c5f8af 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -409,6 +409,7 @@ class Builder: env["CXX"] = "%s -m32" % os.getenv("CXX") env["CFLAGS"] = os.getenv("CFLAGS").replace("-fPIC", "") env["CXXFLAGS"] = os.getenv("CXXFLAGS").replace("-fPIC", "") + env["PKG_CONFIG_PATH"] = "/usr/lib32/pkgconfig" os.environ.update(env) # First check icecream, if not found use ccache