From: Stefan Schantl Date: Mon, 1 Jun 2020 19:13:03 +0000 (+0200) Subject: libloc: Import latest upstream patches. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89be7032970737430281fe29139b47196a6e2058;p=people%2Fms%2Fipfire-2.x.git libloc: Import latest upstream patches. Signed-off-by: Stefan Schantl --- diff --git a/lfs/libloc b/lfs/libloc index ae1cee32f5..8e8d539a75 100644 --- a/lfs/libloc +++ b/lfs/libloc @@ -72,6 +72,11 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar xvf $(DIR_DL)/$(DL_FILE) + + # Add upstream patches. + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/libloc-0.9.1-location-downloader-do-not-change-content-of-open-database.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/libloc-0.9.1-remove-python-path-overrides-for-debian.patch + cd $(DIR_APP) && ./autogen.sh cd $(DIR_APP) && ./configure \ --prefix=/usr \ diff --git a/src/patches/libloc-0.9.1-location-downloader-do-not-change-content-of-open-database.patch b/src/patches/libloc-0.9.1-location-downloader-do-not-change-content-of-open-database.patch new file mode 100644 index 0000000000..857ab5c586 --- /dev/null +++ b/src/patches/libloc-0.9.1-location-downloader-do-not-change-content-of-open-database.patch @@ -0,0 +1,81 @@ +commit 679e5ae2e45b98e254c651cb3102a4331c2c22eb +Author: Michael Tremer +Date: Mon Jun 1 13:47:44 2020 +0000 + + location-downloader: Do not change content of open database files + + The database might be opened by another process. When modified, + it will return random results. + + Fixes: #12420 + Signed-off-by: Michael Tremer + +diff --git a/src/python/location-downloader.in b/src/python/location-downloader.in +index 7d06030..bf0d682 100644 +--- a/src/python/location-downloader.in ++++ b/src/python/location-downloader.in +@@ -24,6 +24,7 @@ import lzma + import os + import random + import shutil ++import stat + import sys + import tempfile + import time +@@ -116,7 +117,7 @@ class Downloader(object): + + return res + +- def download(self, url, public_key, timestamp=None, **kwargs): ++ def download(self, url, public_key, timestamp=None, tmpdir=None, **kwargs): + headers = {} + + if timestamp: +@@ -124,7 +125,7 @@ class Downloader(object): + "%a, %d %b %Y %H:%M:%S GMT", + ) + +- t = tempfile.NamedTemporaryFile(delete=False) ++ t = tempfile.NamedTemporaryFile(dir=tmpdir, delete=False) + with t: + # Try all mirrors + for mirror in self.mirrors: +@@ -175,6 +176,9 @@ class Downloader(object): + t.truncate() + continue + ++ # Make the file readable for everyone ++ os.chmod(t.name, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH) ++ + # Return temporary file + return t + +@@ -296,10 +300,13 @@ class CLI(object): + except FileNotFoundError as e: + db = None + ++ # Download the database into the correct directory ++ tmpdir = os.path.dirname(ns.database) ++ + # Try downloading a new database + try: + t = self.downloader.download("%s/%s" % (self.version, DATABASE_FILENAME), +- public_key=ns.public_key, timestamp=timestamp) ++ public_key=ns.public_key, timestamp=timestamp, tmpdir=tmpdir) + + # If no file could be downloaded, log a message + except FileNotFoundError as e: +@@ -310,11 +317,8 @@ class CLI(object): + if not t: + return 3 + +- # Write temporary file to destination +- shutil.copyfile(t.name, ns.database) +- +- # Remove temporary file +- os.unlink(t.name) ++ # Move temporary file to destination ++ shutil.move(t.name, ns.database) + + return 0 + diff --git a/src/patches/libloc-0.9.1-remove-python-path-overrides-for-debian.patch b/src/patches/libloc-0.9.1-remove-python-path-overrides-for-debian.patch new file mode 100644 index 0000000000..0656a030c2 --- /dev/null +++ b/src/patches/libloc-0.9.1-remove-python-path-overrides-for-debian.patch @@ -0,0 +1,37 @@ +commit 9df8db2ae6268b0901961625fd27b4dde1ed451f +Author: Michael Tremer +Date: Mon Jun 1 18:23:50 2020 +0000 + + Makefile: Remove Python path overrides for Debian + + Signed-off-by: Michael Tremer + +diff --git a/Makefile.am b/Makefile.am +index 570ec3a..31869e0 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -54,10 +54,6 @@ SED_PROCESS = \ + databasedir = $(localstatedir)/lib/location + pkgconfigdir = $(libdir)/pkgconfig + +-# XXX hardcode path for Debian +-pythondir = $(prefix)/lib/python3/dist-packages +-pyexecdir = $(prefix)/lib/python$(PYTHON_VERSION)/lib-dynload +- + # Overwrite Python path + pkgpythondir = $(pythondir)/location + +diff --git a/debian/libloc.install b/debian/libloc.install +index eb3b49a..30bbeca 100644 +--- a/debian/libloc.install ++++ b/debian/libloc.install +@@ -2,8 +2,7 @@ usr/bin/location-downloader + usr/bin/location-exporter + usr/bin/location-query + usr/lib/*/libloc.so.* +-usr/lib/python3*/dist-packages +-usr/lib/python3*/lib-dynload/*.so ++usr/lib/python3*/site-packages + src/systemd/*.service /lib/systemd/system/ + src/systemd/*.timer /lib/systemd/system/ + var/lib/location/signing-key.pem