Subject: Re: bug#36535: [PATCH] gnu: gobject-introspection: Update absolute-shlib-path.patch.

From: Christopher Baines <[email-masked]>
Date: Sat, 13 Jul 2019 00:22:59 +0100

Marius Bakke <[email-masked]> writes:

> severity 36535 important
>
>>>>> ++def _get_default_fallback_libpath():
>>>>> ++    # Newer multiple-output-optimized stdenv has an environment variable
>>>>> ++    # $outputLib which in turn specifies another variable which then is used as
>>>>> ++    # the destination for the library contents (${!outputLib}/lib).
>>>>> ++    store_path = os.environ.get(os.environ.get("outputLib")) if "outputLib" in os.environ else None
>>>>> ++    if store_path is None:
>>>>> ++        outputs = os.environ.get("outputs", "out").split()
>>>>
>>>> gnu-build-system does not currently export an "outputs" variable.
>>>> Perhaps it should?
>>>
>>> Ah, I didn't realise this part of the patch was as Nix specific as it
>>> is...
>>>
>>> At least for the change I was trying to affect, this seems to be
>>> probably redundant, or somehow doing the job. Maybe this part of the
>>> patch relating to the fallback_libpath should be removed.
>>
>> I'd keep the "$outputs" logic, it sounds like a useful and easy change
>> to do in gnu-build-system, although maybe not for this 'core-updates'
>> round.  We can use it in package recipes for fun and profit meanwhile.
>
> We now have a user of the $outputs variable:
>
> https://git.savannah.gnu.org/cgit/guix.git/commit/?id=7555d539245ff3456848c02d61f9e601ee5af463

Ooh, interesting :)

> Incidentally, then package was broken because of the very same feature :-)
>
> But we can not merge this with the hard-coded /gnu/store paths, as that
> is likely to cause strange problems for users with a non-default store
> prefix.
>
> Unless someone steps up to fix it within a few days, I think we'll have
> to revert it for now.

I have some time now to look at this, I'm currently building libsoup
with these changes to the patch.

modified   gnu/packages/patches/gobject-introspection-absolute-shlib-path.patch
@@ -61,12 +61,14 @@
      parser.add_option_group(group)
 --- a/giscanner/shlibs.py
 +++ b/giscanner/shlibs.py
-@@ -57,6 +57,12 @@ def _ldd_library_pattern(library_name):
+@@ -57,6 +57,14 @@ def _ldd_library_pattern(library_name):
      $""" % re.escape(library_name), re.VERBOSE)

 +def _ldd_library_guix_pattern(library_name):
-+    store_dir = re.escape('/gnu/store')
++    store_dir = re.escape(
++      os.environ.get("NIX_STORE", default="/gnu/store")
++    )
 +    pattern = r'(%s(?:/[^/]*)+lib%s[^A-Za-z0-9_-][^\s\(\)]*)'
 +    return re.compile(pattern % (store_dir, re.escape(library_name)))
 +
@@ -109,14 +111,15 @@
      if len(patterns) == 0:
          return []
  
-@@ -139,8 +145,11 @@ def resolve_from_ldd_output(libraries, output):
+@@ -139,8 +145,12 @@ def resolve_from_ldd_output(libraries, output):
          if line.endswith(':'):
              continue
          for word in line.split():
 -            for library, pattern in patterns.items():
 -                m = pattern.match(word)
 +            for library, (pattern, guix_pattern) in patterns.items():
-+                if line.find('/gnu/store') != -1:
++                store_dir = os.environ.get("NIX_STORE", default="/gnu/store")
++                if line.find(store_dir) != -1:
 +                    m = guix_pattern.match(word)
 +                else:
 +                    m = pattern.match(word)