Skip to content

Commit

Permalink
gobject-introspection: 1.60.0 -> 1.60.1
Browse files Browse the repository at this point in the history
Updated the shlib patches:

- Upstream now forces basename in sanitize_shlib_path(lib) if the system isn't
  darwin. We patch the function to always prefer absolute paths
- Due to the above we no longer need the macos patch
- `sanitize_shlib_path` is applied after `resolve_from_ldd_output` so we need to
  apply `fallback_libpath` afterwards too (else we get stuff like
  `/nix/store/...@rpath/foo.dylib` on darwin)
- Note that the `fallback_path` no longer have any unit tests

https://gitlab.gnome.org/GNOME/gobject-introspection/blob/1.60.1/NEWS
  • Loading branch information
hedning authored and FRidh committed Apr 27, 2019
1 parent ee37299 commit d747f16
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -101,6 +101,39 @@
@@ -95,6 +95,39 @@ def get_windows_option_group(parser):
return group


Expand Down Expand Up @@ -40,7 +40,7 @@
def _get_option_parser():
parser = optparse.OptionParser('%prog [options] sources',
version='%prog ' + giscanner.__version__)
@@ -211,6 +244,10 @@
@@ -205,6 +238,10 @@ match the namespace prefix.""")
parser.add_option("", "--filelist",
action="store", dest="filelist", default=[],
help="file containing headers and sources to be scanned")
Expand All @@ -53,7 +53,7 @@
parser.add_option_group(group)
--- a/giscanner/shlibs.py
+++ b/giscanner/shlibs.py
@@ -62,6 +62,12 @@
@@ -57,6 +57,12 @@ def _ldd_library_pattern(library_name):
$""" % re.escape(library_name), re.VERBOSE)


Expand All @@ -66,21 +66,33 @@
# This is a what we do for non-la files. We assume that we are on an
# ELF-like system where ldd exists and the soname extracted with ldd is
# a filename that can be opened with dlopen().
@@ -110,17 +116,16 @@ def _resolve_non_libtool(options, binary, libraries):
if isinstance(output, bytes):
@@ -106,7 +112,8 @@ def _resolve_non_libtool(options, binary, libraries):
output = output.decode("utf-8", "replace")

- # Use absolute paths on OS X to conform to how libraries are usually
- # referenced on OS X systems, and file names everywhere else.
- basename = platform.system() != 'Darwin'
- return resolve_from_ldd_output(libraries, output, basename=basename)
+ # Never strip away absolute paths in Nix
+ basename = False
+ return resolve_from_ldd_output(libraries, output, basename=basename, fallback_libpath=options.fallback_libpath)
shlibs = resolve_from_ldd_output(libraries, output)
- return list(map(sanitize_shlib_path, shlibs))
+ fallback_libpath = options.fallback_libpath or "";
+ return list(map(lambda p: os.path.join(fallback_libpath, p), map(sanitize_shlib_path, shlibs)))


-def resolve_from_ldd_output(libraries, output, basename=False):
+def resolve_from_ldd_output(libraries, output, basename=False, fallback_libpath=""):
def sanitize_shlib_path(lib):
@@ -115,19 +122,18 @@ def sanitize_shlib_path(lib):
# In case we get relative paths on macOS (like @rpath) then we fall
# back to the basename as well:
# https://gitlab.gnome.org/GNOME/gobject-introspection/issues/222
- if sys.platform == "darwin":
- if not os.path.isabs(lib):
- return os.path.basename(lib)
- return lib
- else:
+
+ # Always use absolute paths if available
+ if not os.path.isabs(lib):
return os.path.basename(lib)
+ return lib


def resolve_from_ldd_output(libraries, output):
patterns = {}
for library in libraries:
if not os.path.isfile(library):
Expand All @@ -89,7 +101,7 @@
if len(patterns) == 0:
return []

@@ -129,11 +134,14 @@ def resolve_from_ldd_output(libraries, output, basename=False):
@@ -139,8 +145,11 @@ def resolve_from_ldd_output(libraries, output):
if line.endswith(':'):
continue
for word in line.split():
Expand All @@ -102,14 +114,10 @@
+ m = pattern.match(word)
if m:
del patterns[library]
- shlibs.append(_sanitize_install_name(m.group()))
+ shlibs.append(os.path.join(fallback_libpath, _sanitize_install_name(m.group())))
break

if len(patterns) > 0:
shlibs.append(m.group())
--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -116,17 +116,11 @@
@@ -111,17 +111,11 @@ def extract_libtool_shlib(la_file):
if dlname is None:
return None

Expand Down
5 changes: 2 additions & 3 deletions pkgs/development/libraries/gobject-introspection/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

let
pname = "gobject-introspection";
version = "1.60.0";
version = "1.60.1";
in
with stdenv.lib;
stdenv.mkDerivation rec {
name = "${pname}-${version}";

src = fetchurl {
url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
sha256 = "0pgk9lcvz3i79m6g2ynlp00ghws7g0p0d5qyf0k72warrf841zly";
sha256 = "1cr4r3lh5alrks9q2ycs1kn2crnkhrhn2wrmibng6dndkr4x2i6q";
};

outputs = [ "out" "dev" "man" ];
Expand All @@ -40,7 +40,6 @@ stdenv.mkDerivation rec {
setupHook = ./setup-hook.sh;

patches = [
./macos-shared-library.patch
(substituteAll {
src = ./test_shlibs.patch;
inherit nixStoreDir;
Expand Down

This file was deleted.

31 changes: 12 additions & 19 deletions pkgs/development/libraries/gobject-introspection/test_shlibs.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/tests/scanner/test_shlibs.py
+++ b/tests/scanner/test_shlibs.py
@@ -10,6 +10,46 @@ from giscanner.shlibs import resolve_from_ldd_output
@@ -7,6 +7,30 @@ from giscanner.shlibs import resolve_from_ldd_output, sanitize_shlib_path

class TestLddParser(unittest.TestCase):

Expand All @@ -26,25 +26,18 @@
+ self.assertEqual(
+ ['@nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libglib-2.0.so.0',
+ '@nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libgio-2.0.so.0'],
+ resolve_from_ldd_output(libraries, output, basename=False))
+
+ def test_resolve_from_ldd_output_macos(self):
+ output = '''\
+ @rpath/libatk-1.0.0.dylib
+ @rpath/libgstreamer-1.0.0.dylib (compatibility version 0.0.0, current version 0.0.0)
+ /Volumes/USB_SSD/cerbero/build/dist/darwin_x86_64/lib/libglib-2.0.0.dylib (compatibility version 0.0.0, current version 0.0.0)
+ /Volumes/USB_SSD/cerbero/build/dist/darwin_x86_64/lib/libintl.dylib (compatibility version 0.0.0, current version 0.0.0)
+ /Volumes/USB_SSD/cerbero/build/dist/darwin_x86_64/lib/libgobject-2.0.0.dylib (compatibility version 0.0.0, current version 0.0.0)
+ /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
+ '''
+ libraries = ['atk-1.0']
+ fallback_libpath = '@nixStoreDir@/1ynd5b01z87c1nw75k5iy7sq49hpkw53-atk-2.30.0/lib'
+
+ self.assertEqual(
+ [ '%s/libatk-1.0.0.dylib' % fallback_libpath ],
+ resolve_from_ldd_output(libraries, output, basename=False, fallback_libpath=fallback_libpath))
+ resolve_from_ldd_output(libraries, output))
+
def test_resolve_from_ldd_output(self):
output = '''\
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fbe12d68000)

@@ -40,7 +64,8 @@ class TestLddParser(unittest.TestCase):

self.assertEqual(
sanitize_shlib_path('/foo/bar'),
- '/foo/bar' if sys.platform == 'darwin' else 'bar')
+ # NixOS always want the absolute path
+ '/foo/bar')

def test_unresolved_library(self):
output = ''

0 comments on commit d747f16

Please sign in to comment.