[jhalfs] 03/04: Check version mismatch between book and directory name

"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]> Fri, 24 Jan 2025 18:01:00 +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 plabs/check-version
in repository jhalfs.

commit b47a9808ae2a9158b3c5ae7b5b043ab5721a4716
Author: Pierre Labastie <[email protected]>
AuthorDate: Fri Jan 24 14:31:57 2025 +0100

    Check version mismatch between book and directory name
    
    This is done when downloading (or retrieving from SRC_ARCHIVE) packages.
    The drawback is that if the user does not tick "Retrieve source files",
    the check is not run. The advantage is that if there is a mismatch, it
    is caught early.
---
 common/libs/func_download_pkgs | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/common/libs/func_download_pkgs b/common/libs/func_download_pkgs
index a6d9c7e..aeeec3f 100644
--- a/common/libs/func_download_pkgs
+++ b/common/libs/func_download_pkgs
@@ -8,6 +8,7 @@ get_sources() {              # Download file, write name to MISSING_FILES.DMP if
   [ "$GETPKG" = y ] || return 0
 
   local URL FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM MAYBEMORE
+  local PKGVER PKGDIR
 
   WGETPARAM=""
   if [[ "${RETRYSRCDOWNLOAD}" = "y" ]] ; then
@@ -114,7 +115,20 @@ get_sources() {              # Download file, write name to MISSING_FILES.DMP if
         echo "Storing file:<$FILE> in the package archive"
         cp -f "$FILE" "${SRC_ARCHIVE}"
    fi
-
+    # Check for version mismatch between what is known to the book and
+    # the extracted source directory
+    PKGVER=$(xsltproc --stringparam package "$URL" $JHALFSDIR/pkgver.xsl $JHALFSDIR/prbook.xml)
+    if [ -n "$PKGVER" ]; then
+      PKGDIR=$(tar -tf "$FILE" | head -n1 | sed 's@^./@@;s@/.*@@')
+      # DEBUG
+      # echo "PKGVER: $PKGVER"
+      # echo "PKGDIR: $PKGDIR"
+      # echo "{PKGSIR%PKGVER}: ${PKGDIR%$PKGVER}"
+      # end DEBUG
+      if [ "${PKGDIR%$PKGVER}" = "${PKGDIR}" ]; then
+        error_message Package version $PKGVER does not match extracted directory name $PKGDIR
+      fi
+    fi
   done
 
   if [[ -s MISSING_FILES.DMP ]]; then

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