[jhalfs] 04/06: BLFS tools: allow selecting installed packages

"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]> Mon, 01 Dec 2025 17:41:41 +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 d41ac80963754ff4338ed3821bf20783d835354c
Author: Pierre Labastie <[email protected]>
AuthorDate: Mon Dec 1 18:08:57 2025 +0100

    BLFS tools: allow selecting installed packages
    
    The program update-installed.sh opens a menu where you can select
    installed packages. If a tracking file already exists, packages
    that are in it are selected by default with their installed version.
    They can be removed, or the version cna be changed...
    If a package is not in the tracking file, it can be selected, and
    by default, its version is the one in the current books. This
    version can be modified too.
    At the end, a new tracking file is created with what has been selected
    or deselected.
---
 BLFS/update-installed.sh |  67 ++++++++++++++++
 BLFS/xsl/gen_newpack.xsl | 203 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 270 insertions(+)

diff --git a/BLFS/update-installed.sh b/BLFS/update-installed.sh
new file mode 100755
index 0000000..54666df
--- /dev/null
+++ b/BLFS/update-installed.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+#------
+# Launch a menu containing all packages. Selected pacakges will
+# be added to the tracking file, so that they will be considered
+# "installed" (even if not!). Note that a package can also be removed
+# from the tracking file if not selected. In other words, the
+# resulting tracking file will only contain the selected packages.
+# Initially, the packages already installed known to the system are
+# selected in the menu.
+# Usually, all LFS packages are supposed
+# to be installed, so you can put "A" in the tick box of LFS
+# packages. For BLFS packages, you'll have to select them
+# individually, unless you are sure that all the packages in a
+# menu are installed, in which case you can put a "A" in the menu
+# tick box.
+#------
+
+# The tracking file is taken from Makefile in the same directory.
+MYDIR=$( cd $(dirname $0); pwd )
+if [ -f $MYDIR/Makefile ]; then
+    TRACKING_DIR=$(sed -n 's/TRACKING_DIR[ ]*=[ ]*//p' $MYDIR/Makefile)
+    TRACKFILE=${TRACKING_DIR}/instpkg.xml
+else
+    echo The directory where $0 resides does not contain a Makefile
+    exit 1
+fi
+PACK_LIST="$MYDIR"/packages.xml
+XSLDIR="$MYDIR"/xsl
+
+
+# First generate "packages.xml".
+make packages.xml
+# Generate a Kconfig file (named newpack.in)
+xsltproc --nonet -o newpack.in ${XSLDIR}/gen_newpack.xsl ${PACK_LIST}
+# Launch the menu
+# First remove the existing .conf to be sure to get the defaults
+rm -f newpack.conf
+CONFIG_= KCONFIG_CONFIG=newpack.conf menu/menuconfig.py newpack.in
+if ! [ -f newpack.conf ]; then
+	echo Configuration was not saved. Exiting
+	exit
+fi
+# Erase and initialize the tracking file:
+cat >$TRACKFILE << EOF
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!DOCTYPE sublist SYSTEM "${MYDIR}/packdesc.dtd">
+<sublist>
+  <name>Installed</name>
+</sublist>
+EOF
+# Populate the tracking file
+sed -n 's/CONFIG_\([^=[:space:]]\+\)[[:space:]]*=[[:space:]]*y/\1/p' newpack.conf | while read pack; do
+   version=$(sed -n s/VERSION_$pack'[[:space:]]*=[[:space:]"]*\([^"]*\).*/\1/p' newpack.conf)
+   if [ -z "$version" ]; then version=N; fi # special value to use
+                                            # the version in packages.xml
+   # Add pack to trackfile
+   xsltproc --stringparam packages "${PACK_LIST}" \
+            --stringparam package "$pack" \
+            --stringparam version "$version" \
+            -o track.tmp "${XSLDIR}/bump.xsl" "$TRACKFILE"
+   sed -i "s@PACKDESC@${MYDIR}/packdesc.dtd@" track.tmp
+   xmllint --format --postvalid track.tmp > "$TRACKFILE"
+done #while read pack
+rm newpack.{in,conf}
+exit
diff --git a/BLFS/xsl/gen_newpack.xsl b/BLFS/xsl/gen_newpack.xsl
new file mode 100644
index 0000000..46cf18b
--- /dev/null
+++ b/BLFS/xsl/gen_newpack.xsl
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    version="1.0">
+
+  <xsl:output method="text"
+              encoding='ISO-8859-1'/>
+
+  <xsl:template match="/">
+    <xsl:text>config MODULES
+    bool
+    default y
+</xsl:text>
+    <xsl:apply-templates select="//list"/>
+  </xsl:template>
+
+  <xsl:template match="list">
+    <xsl:variable name="default">
+      <xsl:choose>
+        <xsl:when test=".//*[self::package or self::module][inst-version]">
+          <xsl:text>m</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:text>n</xsl:text>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:text>menuconfig&#9;MENU_</xsl:text>
+    <xsl:value-of select="@id"/>
+    <xsl:text>
+tristate&#9;"</xsl:text>
+    <xsl:value-of select="name"/>
+    <xsl:text>"
+default&#9;"</xsl:text>
+    <xsl:value-of select="$default"/>
+    <xsl:text>"
+
+if&#9;MENU_</xsl:text>
+    <xsl:value-of select="@id"/>
+    <xsl:text> != n
+
+</xsl:text>
+    <xsl:apply-templates select="sublist"/>
+    <xsl:text>endif
+
+</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="sublist">
+    <xsl:variable name="default">
+      <xsl:choose>
+        <xsl:when test=".//*[self::package or self::module][inst-version]">
+          <xsl:text>m</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:text>n</xsl:text>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:text>&#9;menuconfig&#9;MENU_</xsl:text>
+    <xsl:value-of select="@id"/>
+    <xsl:text>
+&#9;tristate&#9;"</xsl:text>
+    <xsl:value-of select="name"/>
+    <xsl:text>"
+&#9;&#9;default&#9;y if MENU_</xsl:text>
+    <xsl:value-of select="../@id"/>
+    <xsl:text> = y
+&#9;&#9;default&#9;"</xsl:text>
+    <xsl:value-of select="$default"/>
+    <xsl:text>"
+
+&#9;if&#9;MENU_</xsl:text>
+    <xsl:value-of select="@id"/>
+    <xsl:text> != n
+
+</xsl:text>
+    <xsl:apply-templates select="package"/>
+    <xsl:text>&#9;endif
+
+</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="package">
+    <xsl:variable name="default">
+      <xsl:choose>
+        <xsl:when test="inst-version">
+          <xsl:text>y</xsl:text>
+        </xsl:when>
+	<xsl:when test="./module[inst-version]">
+          <xsl:text>m</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:text>n</xsl:text>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:if test="version">
+      <xsl:text>&#9;&#9;config&#9;CONFIG_</xsl:text>
+      <xsl:value-of select="name"/>
+      <xsl:text>
+&#9;&#9;bool&#9;"</xsl:text>
+      <xsl:value-of select="name"/>
+      <xsl:text>"
+&#9;&#9;default&#9;y if MENU_</xsl:text>
+      <xsl:value-of select="../@id"/>
+      <xsl:text> = y
+&#9;&#9;default&#9;"</xsl:text>
+      <xsl:value-of select="$default"/>
+      <xsl:text>"
+&#9;&#9;config&#9;VERSION_</xsl:text>
+      <xsl:value-of select="name"/>
+      <xsl:text>
+&#9;&#9;string&#9;"Version of </xsl:text>
+      <xsl:value-of select="name"/>
+      <xsl:text>" if CONFIG_</xsl:text>
+      <xsl:value-of select="name"/>
+      <xsl:text>
+&#9;&#9;default&#9;"</xsl:text>
+      <xsl:choose>
+        <xsl:when test="inst-version">
+          <xsl:value-of select="inst-version"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="version"/>
+        </xsl:otherwise>
+      </xsl:choose>
+      <xsl:text>"
+
+</xsl:text>
+    </xsl:if>
+    <xsl:if test="./module">
+      <xsl:text>&#9;&#9;menuconfig&#9;MENU_</xsl:text>
+      <xsl:value-of select="translate(name,' ()','___')"/>
+      <xsl:text>
+&#9;&#9;tristate&#9;"</xsl:text>
+      <xsl:value-of select="name"/>
+      <xsl:text>"
+      &#9;&#9;default&#9;y if MENU_</xsl:text>
+      <xsl:value-of select="../@id"/>
+      <xsl:text> = y
+&#9;&#9;default&#9;"</xsl:text>
+      <xsl:value-of select="$default"/>
+      <xsl:text>"
+
+&#9;&#9;if&#9;MENU_</xsl:text>
+      <xsl:value-of select="translate(name,' ()','___')"/>
+      <xsl:text> != n
+
+</xsl:text>
+      <xsl:apply-templates select="module"/>
+      <xsl:text>&#9;&#9;endif
+
+</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="module">
+    <xsl:variable name="default">
+      <xsl:choose>
+        <xsl:when test="inst-version">
+          <xsl:text>y</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:text>n</xsl:text>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:text>&#9;&#9;&#9;config&#9;CONFIG_</xsl:text>
+    <xsl:value-of select="name"/>
+    <xsl:text>
+&#9;&#9;&#9;bool&#9;"</xsl:text>
+    <xsl:value-of select="name"/>
+      <xsl:text>"
+&#9;&#9;&#9;default&#9; y if MENU_</xsl:text>
+      <xsl:value-of select="translate(../name,' ()','___')"/>
+      <xsl:text> = y
+&#9;&#9;&#9;default&#9;"</xsl:text>
+    <xsl:value-of select="$default"/>
+    <xsl:text>"
+&#9;&#9;&#9;config&#9;VERSION_</xsl:text>
+    <xsl:value-of select="name"/>
+    <xsl:text>
+&#9;&#9;&#9;string&#9;"Version of </xsl:text>
+    <xsl:value-of select="name"/>
+    <xsl:text>" if CONFIG_</xsl:text>
+    <xsl:value-of select="name"/>
+    <xsl:text>
+&#9;&#9;&#9;default&#9;"</xsl:text>
+    <xsl:choose>
+      <xsl:when test="inst-version">
+        <xsl:value-of select="inst-version"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="version"/>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:text>"
+
+</xsl:text>
+  </xsl:template>
+
+</xsl:stylesheet>

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