[jhalfs] 04/04: Implementation of dependency checking 4

"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]>
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 1bf09c15a7bc85a01a996453bc9d11fa36ba1331
Author: Pierre Labastie <[email protected]>
AuthorDate: Thu Mar 23 18:38:51 2023 +0100

    Implementation of dependency checking 4
    
    Implement generation of a modified script if dependency checking is
    requested.
---
 BLFS/gen_pkg_book.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/BLFS/gen_pkg_book.sh b/BLFS/gen_pkg_book.sh
index dd8f633..e953013 100755
--- a/BLFS/gen_pkg_book.sh
+++ b/BLFS/gen_pkg_book.sh
@@ -297,4 +297,50 @@ xsltproc --xinclude --nonet                           \
 chmod -R +x scripts
 echo -e "done\n"
 
+if [ -n "$DEP_CHECK" ]; then
+   if (( ${#TARGET[*]} != 1 )); then
+      printf "\nWARNING: If dependencies are checked, only one package\n"
+      printf "         shoud be selected. Not generating check code.\n"
+      exit
+   fi
+
+   LIST_LFS="$(xsltproc $ListLFS $LFS_FULL)"
+   LIST_NEEDED="$(echo $FULL_LIST)"
+   LIST_INSTALLED="$(porg -a | sed 's/-[[:digit:]].*//')"
+   LIST_UNNEEDED=
+   for p in $LIST_INSTALLED; do
+      case " $LIST_LFS " in *" $p "*)  continue ;; esac
+      case " $LIST_NEEDED " in *" $p "*)  continue ;; esac
+      LIST_UNNEEDED="$LIST_UNNEEDED $p"
+   done
+   cat >head.tmp <<EOF
+#!/bin/bash
+set -e
+
+# Remove all unneeded packages
+VERSIONED_LIST=
+for p in $LIST_UNNEEDED; do
+   VERSIONED_LIST="\$VERSIONED_LIST \$(porg \$p)"
+   porg -rb \$p
+done
+
+# Function to restore packages
+restore_pack {
+for p in \$VERSIONED_LIST; do
+   porgball -e -l /var/lib/packages/\${p}.porg.tar.gz
+done
+}
+
+trap restore_pack ERR
+
+EOF
+   cat >tail.tmp <<EOF
+restore_pack
+exit
+EOF
+
+   sed -e "1,2d" -e '$d' scripts/*${TARGET} >script.tmp
+   cat head.tmp script.tmp tail.tmp >scripts/*${TARGET}
+   rm *.tmp
+fi
 #clean_configuration

-- 
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.