[jhalfs] 10/12: BLFS: matching tarball of compound: return full line

"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]> Wed, 22 Jan 2025 11:27:25 +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 d378ac5c1ebf6f968561c9d0a4bd081ed9d79a78
Author: Pierre Labastie <[email protected]>
AuthorDate: Sun Jan 19 12:48:01 2025 +0100

    BLFS: matching tarball of compound: return full line
    
    The matching tarball algorithm only returned the tarball name
    and did not test whether the line was commented out. So add this
    test, and return the full line: this will allow using simple
    string functions for the md5 and the download directory
    instead of matching again the tarball...
    We change the name of the template to a more explicit one.
    Next change will use the line in the compound sect1 template.
---
 BLFS/xsl/make_book.xsl | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/BLFS/xsl/make_book.xsl b/BLFS/xsl/make_book.xsl
index 48554dc..627bcdb 100644
--- a/BLFS/xsl/make_book.xsl
+++ b/BLFS/xsl/make_book.xsl
@@ -667,11 +667,11 @@ name=$(echo $packagedir | sed 's/-[[:digit:]].*//')
 
   </xsl:template>
 
-<!-- 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.
-    -->
+<!-- get the line matching $package<digit> in the text for
+     the .md( (.dat) file. $package should begin with a space ' '
+     and end with a dash '-'. We must exclude lines starting with
+     a hash '#' too. -->
+  <xsl:template name="match-tarball">
     <xsl:param name="package"/>
     <xsl:param name="cat-md5"/>
     <xsl:variable name="tarball"
@@ -685,6 +685,19 @@ name=$(echo $packagedir | sed 's/-[[:digit:]].*//')
                              ),
                              '&#xA;'
                           )"/>
+<!-- To get the line, we need to break at a linefeed, but just before
+     the found tarball. So we backup 64 chars to be sure to be in the
+     preceding line (64 chars is twice the length of a md5 hash). -->
+    <xsl:variable name="cut"
+    select="string-length(substring-before($cat-md5,$tarball)) - 64"/>
+    <xsl:variable name="line"
+                  select="substring-before(
+                             substring-after(
+                                substring($cat-md5,$cut),
+                                '&#xA;'
+                             ),
+                             '&#xA;'
+                          )"/>
     <xsl:choose>
       <!-- tarball may be empty when we have found no match. For example
            when the current element is plasma and package is kwallet.
@@ -701,11 +714,12 @@ name=$(echo $packagedir | sed 's/-[[:digit:]].*//')
       <xsl:when test="contains(translate($tarball,'0123456789',
                                                   'XXXXXXXXXX'),
                         concat(translate($package,'0123456789',
-                                                  'XXXXXXXXXX'),'X'))">
-        <xsl:copy-of select="substring-after($tarball,' ')"/>
+                                                  'XXXXXXXXXX'),'X')) and
+                      not(starts-with($line,'#'))">
+        <xsl:copy-of select="$line"/>
       </xsl:when>
       <xsl:otherwise><!-- this is not the right tarball -->
-        <xsl:call-template name="tarball">
+        <xsl:call-template name="match-tarball">
           <xsl:with-param name="package" select="$package"/>
           <xsl:with-param name="cat-md5"
                           select="substring-after($cat-md5,$tarball)"/>

-- 
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