[jhalfs] 03/12: Make extraction of packages from compound more robust

"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]> Wed, 22 Jan 2025 11:27:18 +0000
Newsgroups gmane.linux.lfs.automated
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch trunk
in repository jhalfs.

commit 7ba75fb5127ae84fab876996cdcebf2f2d545273
Author: Pierre Labastie <[email protected]>
AuthorDate: Tue Jan 14 16:10:45 2025 +0100

    Make extraction of packages from compound more robust
    
    When we want to build a package from a compound one, we look for
    ' '<package>-, but this may match ' '<package>-<something>', either
    in the same compound package or even in another one. So we have to
    test that the first character after the dash is a digit. Note that
    we also modify the search for the tarball (remove recursive calls).
    This is a slight optimization. Then the tarball name is verified to
    contain <package>-<digit>. If not the tarball search is recursively
    called for the following occurence. Note that if the compound
    package is not the right one, the returned tarball is empty.
---
 BLFS/xsl/make_book.xsl | 47 +++++++++++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/BLFS/xsl/make_book.xsl b/BLFS/xsl/make_book.xsl
index d13b0a5..7c780dd 100644
--- a/BLFS/xsl/make_book.xsl
+++ b/BLFS/xsl/make_book.xsl
@@ -653,31 +653,46 @@ name=$(echo $packagedir | sed 's/-[[:digit:]].*//')
 <!-- get the tarball name from the text that comes from the .md5 file -->
   <xsl:template name="tarball">
     <!-- $package must start with a space, and finish with a "-", to be
-         sure to match exactly the package. Note that if we have two
-         packages named e.g. "pkg1" and "pkg1-add", the second one may be
-         matched by " pkg1-". So this only works if "pkg1" comes before
-         "pkg1-add" in the md5 file. Presently this is the case in the book...
+         sure to match exactly the package.
     -->
     <xsl:param name="package"/>
     <xsl:param name="cat-md5"/>
+    <xsl:variable name="tarball"
+                  select="substring-before(
+                             substring-after(
+                                $cat-md5,
+                                substring-before(
+                                   $cat-md5,
+                                   $package
+                                )
+                             ),
+                             '&#xA;'
+                          )"/>
     <xsl:choose>
-      <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
-        <xsl:call-template name="tarball">
-          <xsl:with-param name="package" select="$package"/>
-          <xsl:with-param name="cat-md5"
-                          select="substring-after($cat-md5,'&#xA;')"/>
-        </xsl:call-template>
+      <!-- tarball may be empty when we have found no match. For example
+           when the current element is plasma and package is kwallet.
+           This can happen because the test for kwallet- matches
+           kwallet-pam in plasma, while kwallet is in kf6.
+           The test below fails so that we call again the tarball
+           template, with a cat-md5 variable which does not contain
+           kwallet. We just do nothing in this case. -->
+      <xsl:when test="$tarball=''"/>
+      <!-- This is the test for matching $package-<digit>. We
+           change all digits to X in tarball (which also contains a space
+           before), and in $package (because it may also contain
+           digits). We then compare both strings.-->
+      <xsl:when test="contains(translate($tarball,'0123456789',
+                                                  'XXXXXXXXXX'),
+                        concat(translate($package,'0123456789',
+                                                  'XXXXXXXXXX'),'X'))">
+        <xsl:copy-of select="substring-after($tarball,' ')"/>
       </xsl:when>
-      <xsl:when test="contains(substring-before($cat-md5,$package),' ')">
+      <xsl:otherwise><!-- this is not the right tarball -->
         <xsl:call-template name="tarball">
           <xsl:with-param name="package" select="$package"/>
           <xsl:with-param name="cat-md5"
-                          select="substring-after($cat-md5,' ')"/>
+                          select="substring-after($cat-md5,$tarball)"/>
         </xsl:call-template>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:copy-of select="substring-after(
-                                substring-before($cat-md5,'&#xA;'),' ')"/>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

-- 
http://lists.linuxfromscratch.org/sympa/info/alfs-discuss
Unsubscribe: See the above information page