diff --git a/Config.in b/Config.in
index f93b48d..cdb65d0 100644
--- a/Config.in
+++ b/Config.in
@@ -868,7 +868,7 @@ depends on !BOOK_BLFS
         default PKG_PACK
 
         config PKG_PACK
-            bool "Build and pack (pacman or dpkg style)"
+            bool "Build and install (create package archives)"
 
         config LIB_LOAD
             bool "Preload a library before installing (porg style)"
@@ -878,6 +878,23 @@ depends on !BOOK_BLFS
         bool
         default y if LIB_LOAD
         default n if PKG_PACK
+
+        config     PKG_TYPE
+        string     "Packaging type"
+        default    "pacman"
+        depends on PKG_PACK
+        help
+            #--Packaging type must have a corresponding
+            #  packInstall.sh.<type> and
+            #  packageManagement.xml.<type> file in
+            #  the pkgmngt directory, and can optionally
+            #  use a packFixScritps.sh.<type> file to be
+            #  run immediately before the makefile
+            #  Valid default types are:
+            #    * dpkg    -  Debian packages
+            #    * pacman  -  pacman packges
+            #    * rpm     -  RPM packages
+
     #--- End package management
 
     #--- Installed files logs
@@ -891,11 +908,15 @@ depends on !BOOK_BLFS
     #--- End Installed files logs
 
     config    STRIP
+        depends on !PKG_TYPE="pacman"
+        depends on !PKG_TYPE="rpm"
         bool "Strip Installed Binaries/Libraries"
         default n
         depends on !BOOK_CLFS3
 
     config    DEL_LA_FILES
+        depends on !PKG_TYPE="pacman"
+        depends on !PKG_TYPE="rpm"
         bool "Remove libtool .la files"
         default y
         help
diff --git a/LFS/lfs.xsl b/LFS/lfs.xsl
index aa4c847..ec42315 100644
--- a/LFS/lfs.xsl
+++ b/LFS/lfs.xsl
@@ -224,14 +224,52 @@ otherwise it is in /bin.-->
   </xsl:template>
 
   <xsl:template match="sect2">
-    <xsl:apply-templates
-      select=".//screen[not(@role) or @role != 'nodump']/userinput[
-                             @remap = 'pre' or
-                             @remap = 'configure' or
-                             @remap = 'make' or
+    <!-- Divide up the remap attributes - this will be identical for every
+         package in LFS except the expect package, where it makes no diff -->
+    <xsl:if test=".//screen[not(@role) or @role != 'nodump']/userinput[
+                                           @remap = 'pre']">
+      <xsl:if test="$pkgtype = 'pacman' or $pkgtype = 'rpm'">
+        <xsl:text># remap=pre&#xA;</xsl:text>
+      </xsl:if> <!-- pacman or rpm -->
+      <xsl:apply-templates
+            select=".//screen[not(@role) or @role != 'nodump']/userinput[
+                             @remap = 'pre' and
+                             not(current()/../@id='ch-tools-dejagnu') and
+                             not(current()/../@id='ch-system-systemd')]"/>
+    </xsl:if>
+    <xsl:if test=".//screen[not(@role) or @role != 'nodump']/userinput[
+                                           @remap = 'configure']">
+      <xsl:if test="$pkgtype = 'pacman' or $pkgtype = 'rpm'">
+        <xsl:text># remap=configure&#xA;</xsl:text>
+      </xsl:if> <!-- pacman or rpm -->
+      <xsl:apply-templates
+           select=".//screen[not(@role) or @role != 'nodump']/userinput[
+                             @remap = 'configure' and
+                             not(current()/../@id='ch-tools-dejagnu') and
+                             not(current()/../@id='ch-system-systemd')]"/>
+    </xsl:if>
+    <xsl:if test=".//screen[not(@role) or @role != 'nodump']/userinput[
+                                           @remap = 'make']">
+      <xsl:if test="$pkgtype = 'pacman' or $pkgtype = 'rpm'">
+        <xsl:text># remap=make&#xA;</xsl:text>
+      </xsl:if> <!-- pacman or rpm -->
+      <xsl:apply-templates
+            select=".//screen[not(@role) or @role != 'nodump']/userinput[
+                             @remap = 'make' and
+                             not(current()/../@id='ch-tools-dejagnu') and
+                             not(current()/../@id='ch-system-systemd')]"/>
+    </xsl:if>
+    <xsl:if test=".//screen[not(@role) or @role != 'nodump']/userinput[
+                                           @remap = 'test']">
+      <xsl:if test="$pkgtype = 'pacman' or $pkgtype = 'rpm'">
+        <xsl:text># remap=test&#xA;</xsl:text>
+      </xsl:if> <!-- pacman or rpm -->
+      <xsl:apply-templates
+            select=".//screen[not(@role) or @role != 'nodump']/userinput[
                              @remap = 'test' and
                              not(current()/../@id='ch-tools-dejagnu') and
                              not(current()/../@id='ch-system-systemd')]"/>
+    </xsl:if>
     <xsl:if
          test="ancestor::chapter[@id = 'chapter-building-system' or
                                  @id = 'chapter-config'          or
@@ -241,6 +279,9 @@ otherwise it is in /bin.-->
                descendant::screen[not(@role) or
                                   @role != 'nodump']/userinput[
                                                     @remap='install']">
+      <xsl:if test="$pkgtype = 'pacman' or $pkgtype = 'rpm'">
+        <xsl:text># remap=install&#xA;</xsl:text>
+      </xsl:if> <!-- pacman or rpm -->
       <xsl:choose>
         <xsl:when test="$wrap-install='y'">
           <xsl:text>wrapInstall '
@@ -249,10 +290,17 @@ otherwise it is in /bin.-->
         <xsl:otherwise>
 <!-- We cannot know which directory(ies) are needed by the package. Create a
      reasonable bunch of them. Should be close to "Creating Directories".-->
-          <xsl:text>mkdir -pv $PKG_DEST/{bin,boot,etc,lib,sbin}
+          <xsl:text>mkdir -pv $PKG_DEST/{boot,etc}
 mkdir -pv $PKG_DEST/usr/{bin,include,lib/pkgconfig,sbin}
 mkdir -pv $PKG_DEST/usr/share/{doc,info,bash-completion/completions}
 mkdir -pv $PKG_DEST/usr/share/man/man{1..8}
+if [ -d /bin ]; then
+  for dir in bin lib sbin; do
+    ln -s usr/$dir $PKG_DEST/$dir
+  done
+else
+  mkdir -pv $PKG_DEST/{bin,lib,sbin}
+fi
 case $(uname -m) in
  x86_64) mkdir -v $PKG_DEST/lib64 ;;
 esac
@@ -308,17 +356,24 @@ rm -fv $PKG_DEST/sbin/nologin
            $PKG_DEST/usr/share/{doc,info,man,} \
            $PKG_DEST/usr/lib/pkgconfig \
            $PKG_DEST/usr/{lib,bin,sbin,include} \
-           $PKG_DEST/{boot,etc,lib,bin,sbin}; do
-  [ -d "$dir" ] &amp;&amp; [ -z "$(ls $dir)" ] &amp;&amp; rmdir -v $dir
+           $PKG_DEST/{boot,etc}; do
+  [ -d "$dir" ] &amp;&amp; [ -z "$(ls $dir)" ] &amp;&amp; rmdir -v $dir || true
 done
+if [ -L /bin ]; then
+  rm -fv $PKG_DEST/{bin,lib,sbin}
+else
+  for dir in $PKG_DEST/{bin,lib,sbin}; do
+    [ -z "$(ls $dir)" ] &amp;&amp; rmdir -v $dir || true
+  done
+fi
 [ -d $PKG_DEST/lib64 ] &amp;&amp; [ -z "$(ls $PKG_DEST/lib64)" ] &amp;&amp;
-  rmdir -v $PKG_DEST/lib64
+  rmdir -v $PKG_DEST/lib64 || true
 <!-- prevent overwriting symlinks: if a package install something in
      these directories, it'll be lost if not using package management,
      since they are symlinks to tmpfs. So, remove it too if using PM. -->
 rm -rf $PKG_DEST/var/{run,lock}
 <!-- Remove /var if it is empty, then -->
-[ -d $PKG_DEST/var ] &amp;&amp; [ -z "$(ls $PKG_DEST/var)" ] &amp;&amp; rmdir -v $PKG_DEST/var
+[ -d $PKG_DEST/var ] &amp;&amp; [ -z "$(ls $PKG_DEST/var)" ] &amp;&amp; rmdir -v $PKG_DEST/var || true
 PREV_SEC=${SECONDS}
 packInstall
 SECONDS=${PREV_SEC}
@@ -336,12 +391,24 @@ rm -rf $PKG_DEST
     <xsl:if test="../@id='ch-system-glibc' and @role='installation'">
       <xsl:choose>
         <xsl:when test="$full-locale='y'">
+          <xsl:if test="$pkgtype = 'pacman' or
+                        $pkgtype = 'rpm'">
+            <xsl:text>####POSTINST####&#xA;</xsl:text>
+          </xsl:if> <!-- pacman or rpm -->
           <xsl:for-each select="//userinput[@remap='locale-full']">
             <xsl:copy-of select="."/>
             <xsl:text>&#xA;</xsl:text>
           </xsl:for-each>
+          <xsl:if test="$pkgtype = 'pacman' or
+                        $pkgtype = 'rpm'">
+            <xsl:text>####ENDPOSTINST####&#xA;</xsl:text>
+          </xsl:if> <!-- pacman or rpm -->
         </xsl:when>
         <xsl:otherwise>
+          <xsl:if test="$pkgtype = 'pacman' or
+                        $pkgtype = 'rpm'">
+            <xsl:text>####POSTINST####&#xA;</xsl:text>
+          </xsl:if> <!-- pacman or rpm -->
           <xsl:copy-of select="//userinput[@remap='locale-test']"/>
           <xsl:text>&#xA;</xsl:text>
           <xsl:if test="not(contains(string(//userinput[@remap='locale-test']),$lang)) and $lang!='C' and $lang!='POSIX'">
@@ -355,6 +422,10 @@ rm -rf $PKG_DEST
 fi
 </xsl:text>
           </xsl:if>
+          <xsl:if test="$pkgtype = 'pacman' or
+                        $pkgtype = 'rpm'">
+            <xsl:text>####ENDPOSTINST####&#xA;</xsl:text>
+          </xsl:if> <!-- pacman or rpm -->
         </xsl:otherwise>
       </xsl:choose>
     </xsl:if>
diff --git a/README.PACKAGE_MANAGEMENT b/README.PACKAGE_MANAGEMENT
index bad7409..bc64b83 100644
--- a/README.PACKAGE_MANAGEMENT
+++ b/README.PACKAGE_MANAGEMENT
@@ -11,9 +11,8 @@ $Id$
   I hope it is flexible enough to support several package managers, at least
   among those who use DESTDIR install and/or LD_PRELOAD during install.
   It has been tested with dpkg from Debian, pacman from Arch Linux,
-  and porg. Sample configuration files are given for those three packages.
-  I am sorry to say I have (almost) no experience with rpm, so I cannot
-  tell whether it would fit.
+  porg, and rpm from RedHat. Sample configuration files are given for those
+  four package managers.
 
 2. OVERVIEW OF THE SYSTEM:
 
@@ -23,14 +22,17 @@ $Id$
   to adapt this tool for the other flavours of LFS (TODO).
 
       This tool comes in two flavours:
-  - for distros package managers (e.g dpkg or pacman), it basically performs
-    a "DESTDIR install" for all pages in chapter 6, 7 and 8 of the book. The
-    name of the DESTDIR directory is the same as the one of the executed
-    script. The path to this directory is available to the scriplets through
-    the PKG_DEST variable. The details of the DESTDIR part are given below.
-    After the package is installed in $PKG_DEST, a function "packInstall" is
-    called, which is supposed to create a binary package (e.g. make a .deb
-    file), store it to a repository and install it to the system.
+  - for distro package managers (e.g dpkg, pacman, or rpm), it basically
+    performs a "DESTDIR install" for all pages in chapters 8, 9 and 10 of the
+    book. Pacman and RPM have scripts that further adjust the jhalfs scripts
+    for use as PKGBUILD or spec files, while dpkg simply does a binary install
+    where the  name of the DESTDIR directory is the same as the one of the
+    executed script. The path to this directory is available to the scriplets
+    through the PKG_DEST variable. The details of the DESTDIR part are given
+    below.  After the package is installed into the DESTDIR, a function
+    "packInstall" is called, which is supposed to create a binary package
+    (e.g. make a .deb file), store it to a repository and install it to the
+    system.
   - for porg style package manager, the install instructions are wrapped
     between pairs of single quotes ('). This allows passing those instructions
     to a function ("wrapInstall"), which may itself call porg or another
@@ -56,34 +58,37 @@ $Id$
   files to non existent directories. There is no simple way to automatically
   create those directories, because you have sometimes to use the full path
   (instructions of the form `cp file dir') and sometimes only the dirname
-  (instructions of the form `cp file1 file2'). So the XSL stylesheet
-  creates a reasonable subset of the FHS hierarchy into the destination
-  directory. Empty directories are then removed before packing the
-  binary package.
+  (instructions of the form `cp file1 file2'). Pacman and RPM installs modify
+  the $PKG_DEST value to ${pkgdir} or %{buildroot} as appropriate.
+  The XSL stylesheet creates a reasonable subset of the FHS hierarchy into the
+  destination directory, and empty directories are removed before packaging.
 
       In order to use the package manager, it has to be installed at the end of
-  chapter 5 (temporary installation in /tools) and chapter 6 (final install).
-  Furthermore, the administrative files and directories have to be created
-  during the `Creating Directories' and `Creating Essential Files' stages.
-  For all this, the user has to supply a file in docbook XML format, with
-  the necessary instructions and enough information to download the tarball.
-  This file should reside in the `pkgmngt' directory and be named
-  `packageManager.xml'. A template named `packageManager.xml.template' is
-  provided in the `pkgmngt' subdirectory. There are also three XML files for
-  dpkg, pacman, and porg, respectively `packageManager.xml.dpkg',
-  `packageManager.xml.pacman',  and `packageManager.xml.porg', that you can
-  copy to `packageManager.xml' and modify to suit your needs.
-  They are not updated often, so the versions used can be rather old.
+  chapter 7 (temporary tools) and chapter 8 (final install). Furthermore, the
+  administrative files and directories have to be created during the 
+ `Creating Directories' and `Creating Essential Files' stages. For all this,
+  the user has to supply a file in docbook XML format, with the necessary
+  instructions and enough information to download the tarball. This file should
+  reside in the `pkgmngt' directory and be named `packageManager.xml.$pkgtype'.
+  A template named `packageManager.xml.template' is provided in the `pkgmngt'
+  subdirectory if you'd like to add an additional package type. There are also
+  four XML files for dpkg, pacman, porg, and rpm. They are not updated often,
+  so the versions used can be rather old. Additionally, the files
+  `packFixScripts.sh.$pkgtype' and `licenses.list.$pkgtype' will be copied to
+  the jhalfs directory if they exist, and packFixScripts.sh will be executed
+  as the last commmand after jhalfs is run, which is responsible for adapting
+  the jhlafs scripts for use by the package manager.
 
       The last thing to do is to tell how to use the package manager. The user
-  has to provide two functions, "wrapInstall" and "packInstall", as described
-  above. Please note that nothing has been done to manage configuration files,
-  which are ususally treated specially by package managers: depending on
-  the book layout, it is sometimes possible to create those files afterwards,
-  and sometimes not, which means that you have to check them after each
-  upgrade. Both functions should be defined in a file named `packInstall.sh',
-  residing in the `pkgmngt' directory. A template is provided (actually a copy
-  of the file for dpkg), as well as three example scripts for dpkg, pacman,
-  and porg. Pacman Note: due to the way pacman checks the available space on
-  disk, the root directory in chroot must be a mount point, otherwise the
-  installation of packages fails.
+  has to provide two functions, "wrapInstall" (if applicable) and
+  "packInstall", as described above. Both functions should be defined in a file
+  named `packInstall.sh.$pkgtype' and placed into the `pkgmngt' directory. A
+  template is provided (actually a copy of the file for dpkg), as well as four
+  example scripts for dpkg, pacman, porg, and rpm. Please note that nothing has
+  been done to manage configuration files or dependencies for the porg or dpkg
+  exmaple configurations, however, two xsl files, `configfiles.xsl' and
+  `dependencies.xsl', have been provided to extract the necessary information
+  from the LFS book. The `packFixScripts.sh` script for both pacman and rpm
+  configurations provide examples for their use. Pacman Note: due to the way
+  pacman checks the available space on disk, the root directory in chroot must
+  be a mount point, otherwise the installation of packages fails.
diff --git a/common/libs/func_book_parser b/common/libs/func_book_parser
index 8dbbd8d..e139420 100644
--- a/common/libs/func_book_parser
+++ b/common/libs/func_book_parser
@@ -172,6 +172,7 @@ extract_commands() {         #
                  --stringparam lang           "$LANG"         \
                  --stringparam pkgmngt        "$PKGMNGT"      \
                  --stringparam wrap-install   "$WRAP_INSTALL" \
+                 --stringparam pkgtype        "$PKG_TYPE"     \
                  --stringparam hostname       "$HOSTNAME"     \
                  --stringparam interface      "$INTERFACE"    \
                  --stringparam ip             "$IP_ADDR"      \
diff --git a/common/libs/func_validate_configs.sh b/common/libs/func_validate_configs.sh
index 7560bc0..27e8587 100644
--- a/common/libs/func_validate_configs.sh
+++ b/common/libs/func_validate_configs.sh
@@ -206,23 +206,23 @@ inline_doc
         # must exist in $PKGMNGTDIR if PKGMNGT='y':
       PKGMNGT) echo -e "`eval echo $PARAM_VALS`"
                if [ "$PKGMNGT" = y ]; then
-                 if [ ! -e "$PKGMNGTDIR/packageManager.xml" ]; then
-                   write_pkg_and_die $PKGMNGTDIR/packageManager.xml does not exist
+                 if [ ! -e "$PKGMNGTDIR/packageManager.xml.$PKG_TYPE" ]; then
+                   write_pkg_and_die $PKGMNGTDIR/packageManager.xml.$PKG_TYPE does not exist
                  fi
-                 if [ ! -e "$PKGMNGTDIR/packInstall.sh" ]; then
-                   write_pkg_and_die $PKGMNGTDIR/packInstall.sh does not exist
+                 if [ ! -e "$PKGMNGTDIR/packInstall.sh.$PKG_TYPE" ]; then
+                   write_pkg_and_die $PKGMNGTDIR/packInstall.sh.${PKG_TYPE} does not exist
                  fi
-                 if [ ! -s "$PKGMNGTDIR/packageManager.xml" ]; then
-                   write_pkg_and_die $PKGMNGTDIR/packageManager.xml has zero size
+                 if [ ! -s "$PKGMNGTDIR/packageManager.xml.$PKG_TYPE" ]; then
+                   write_pkg_and_die $PKGMNGTDIR/packageManager.xml.$PKG_TYPE has zero size
                  fi
-                 if [ ! -s "$PKGMNGTDIR/packInstall.sh" ]; then
-                   write_pkg_and_die $PKGMNGTDIR/packInstall.sh has zero size
+                 if [ ! -s "$PKGMNGTDIR/packInstall.sh.$PKG_TYPE" ]; then
+                   write_pkg_and_die $PKGMNGTDIR/packInstall.sh.$PKG_TYPE has zero size
                  fi
-                 if [ ! -r "$PKGMNGTDIR/packageManager.xml" ]; then
-                   write_pkg_and_die $PKGMNGTDIR/packageManager.xml is not readable
+                 if [ ! -r "$PKGMNGTDIR/packageManager.xml.$PKG_TYPE" ]; then
+                   write_pkg_and_die $PKGMNGTDIR/packageManager.xml.$PKG_TYPE is not readable
                  fi
-                 if [ ! -r "$PKGMNGTDIR/packInstall.sh" ]; then
-                   write_pkg_and_die $PKGMNGTDIR/packInstall.sh is not readable
+                 if [ ! -r "$PKGMNGTDIR/packInstall.sh.$PKG_TYPE" ]; then
+                   write_pkg_and_die $PKGMNGTDIR/packInstall.sh.$PKG_TYPE is not readable
                  fi
                fi
                ;;
diff --git a/common/urls.xsl b/common/urls.xsl
index c2a5e66..8d740d3 100644
--- a/common/urls.xsl
+++ b/common/urls.xsl
@@ -44,7 +44,8 @@
                   or not(ancestor::varlistentry[@vendor])) and
                   (contains(@url, '.bz2') or contains(@url, '.tar.gz') or
                   contains(@url, '.tgz') or contains(@url, '.patch') or
-                  contains(@url, '.xz') or contains(@url, '.lzma')) and
+                  contains(@url, '.xz') or contains(@url, '.lzma') or
+                  contains(@url, '.zip')) and
                   not(ancestor-or-self::*/@condition = 'pdf')">
       <!-- Extract the package name -->
       <xsl:variable name="package">
diff --git a/jhalfs b/jhalfs
index 75e83f1..1b27aa3 100755
--- a/jhalfs
+++ b/jhalfs
@@ -388,7 +388,7 @@ if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
   cp "$COMMON_DIR"/{makefile-functions,progress_bar.sh} "$JHALFSDIR/"
 
 # Copy needed stylesheets
-  cp "$COMMON_DIR"/{packages.xsl,chroot.xsl,kernfs.xsl} "$JHALFSDIR/"
+  cp "$COMMON_DIR"/{packages,chroot,kernfs}.xsl "$JHALFSDIR/"
 
 # Fix the XSL book parser
   case $PROGNAME in
@@ -400,14 +400,26 @@ if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
 
 # Copy packageManager.xml, if needed
   [[ "$PKGMNGT" = "y" ]] && [[ "$PROGNAME" = "lfs" ]] && {
-    sed s@BOOK@"$BOOK"@ "$PKGMNGTDIR/packageManager.xml" > \
+    sed s@BOOK@"$BOOK"@ "$PKGMNGTDIR/packageManager.xml.${PKG_TYPE}" > \
                         "$JHALFSDIR/"packageManager.xml
-    cp "$PKGMNGTDIR/packInstall.sh" "$JHALFSDIR/"
+    cp "$PKGMNGTDIR/packInstall.sh.${PKG_TYPE}" "$JHALFSDIR/packInstall.sh"
+    [[ -f "$PKGMNGTDIR/packFixScripts.sh.${PKG_TYPE}" ]] && {
+      cp "$PKGMNGTDIR/packFixScripts.sh.${PKG_TYPE}" \
+         "$JHALFSDIR/packFixScripts.sh"
+      }
+    [[ -f "$PKGMNGTDIR/licenses.list.${PKG_TYPE}" ]] && {
+      cp "$PKGMNGTDIR/licenses.list.${PKG_TYPE}" \
+         "$JHALFSDIR/licenses.list"
+      }
     }
 
 # Copy urls.xsl, if needed
   [[ "$GETPKG" = "y" ]] && cp "$COMMON_DIR/urls.xsl" "$JHALFSDIR/"
 
+# Copy dependencies.xsl and configfiles.xsl if needed
+  [[ "$PKG_TYPE" = "pacman" || "$PKG_TYPE" = "rpm" ]] && \
+    cp "$PKGMNGTDIR"/{dependencies,configfiles}.xsl "$JHALFSDIR/"
+
 # Always create the test-log directory to allow user to "uncomment" test
 # instructions
   install -d -m 1777 "$TESTLOGDIR"
@@ -503,5 +515,10 @@ echo "${SD_BORDER}${nl_}"
   cd "$CWD"
   check_prerequisites
   echo "${SD_BORDER}${nl_}"
+
+# if needed, run fix scripts
+  [[ -f ${JHALFSDIR}/packFixScripts.sh ]] &&
+    JHALFSDIR=${JHALFSDIR} bash ${JHALFSDIR}/packFixScripts.sh ${CONFIG}
+
 # All is well, run the build (if requested)
 run_make
diff --git a/pkgmngt/configfiles.xsl b/pkgmngt/configfiles.xsl
new file mode 100644
index 0000000..04c787a
--- /dev/null
+++ b/pkgmngt/configfiles.xsl
@@ -0,0 +1,45 @@
+<xsl:stylesheet
+      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+      xmlns:exsl="http://exslt.org/common"
+      extension-element-prefixes="exsl"
+      version="1.0">
+
+<!-- Start of templates -->
+  <!-- This whole thing is ugly hackery becasue we aren't consistent, but
+       we only need the packages, so it works with a bit of post processing -->
+  <xsl:template match="/">
+    <xsl:apply-templates select="//chapter[
+                                @id='chapter-building-system' or
+                                @id='chapter-config' or
+                                @id='chapter-bootable']"/>
+  </xsl:template>
+
+  <xsl:template match="chapter">
+    <xsl:apply-templates select="./sect1/sect2[@role='configuration']"/>
+    <xsl:apply-templates select="./sect1/sect2/sect3[@role='configuration']"/>
+  </xsl:template>
+
+  <xsl:template match="sect2">
+    <xsl:variable name="id" select="substring-after(@id,'conf-')"/>
+    <xsl:value-of select="$id"/>
+    <xsl:text>="</xsl:text>
+    <xsl:for-each select=".//indexterm">
+      <xsl:apply-templates select="primary[starts-with(@sortas,'e-')]"/>
+      <xsl:text>, </xsl:text>
+    </xsl:for-each>
+    <xsl:text>&#xA;</xsl:text> -->
+    <xsl:text>"&#xA;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="sect3">
+    <xsl:variable name="id" select="substring-after(@id,'conf-')"/>
+    <xsl:value-of select="$id"/>
+    <xsl:text>="</xsl:text>
+    <xsl:for-each select=".//indexterm">
+      <xsl:apply-templates select=".//primary[starts-with(@sortas,'e-')]"/>
+      <xsl:text>, </xsl:text>
+    </xsl:for-each>
+    <xsl:text>"&#xA;</xsl:text>
+  </xsl:template>
+
+</xsl:stylesheet>
diff --git a/pkgmngt/dependencies.xsl b/pkgmngt/dependencies.xsl
new file mode 100644
index 0000000..62bada6
--- /dev/null
+++ b/pkgmngt/dependencies.xsl
@@ -0,0 +1,45 @@
+<xsl:stylesheet
+      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+      xmlns:exsl="http://exslt.org/common"
+      extension-element-prefixes="exsl"
+      version="1.0">
+
+<!-- Start of templates -->
+  <xsl:template match="/">
+    <xsl:text># LFS Dependency List&#xA;&#xA;</xsl:text>
+    <xsl:apply-templates select="//appendix[@id='appendixc']"/>
+  </xsl:template>
+
+  <xsl:template match="appendix">
+    <xsl:apply-templates select="./segmentedlist"/>
+  </xsl:template>
+
+  <xsl:template match="segmentedlist">
+    <xsl:variable name="id" select="@id"/>
+    <xsl:if test="contains($id,'-depends')">
+      <xsl:value-of select="$id"/><xsl:text>="</xsl:text>
+      <xsl:apply-templates select=".//seglistitem/seg"/>
+      <xsl:text>"&#xA;</xsl:text>
+    </xsl:if>
+    <xsl:if test="contains($id,'-rundeps')">
+      <xsl:value-of select="$id"/><xsl:text>="</xsl:text>
+      <xsl:apply-templates select=".//seglistitem/seg"/>
+      <xsl:text>"&#xA;</xsl:text>
+    </xsl:if>
+    <xsl:if test="contains($id,'-testdeps')">
+      <xsl:value-of select="$id"/><xsl:text>="</xsl:text>
+      <xsl:apply-templates select=".//seglistitem/seg"/>
+      <xsl:text>"&#xA;</xsl:text>
+    </xsl:if>
+    <xsl:if test="contains($id,'-optdeps')">
+      <xsl:value-of select="$id"/><xsl:text>="</xsl:text>
+      <xsl:apply-templates select=".//seglistitem/seg"/>
+      <xsl:text>"&#xA;&#xA;</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="text()">
+    <xsl:value-of select="normalize-space(.)"/>
+  </xsl:template>
+
+</xsl:stylesheet>
diff --git a/pkgmngt/licenses.list.pacman b/pkgmngt/licenses.list.pacman
new file mode 100644
index 0000000..2eabf1b
--- /dev/null
+++ b/pkgmngt/licenses.list.pacman
@@ -0,0 +1,105 @@
+acl="GPLv2 LGPLv2.1"
+attr="GPLv2 LGPLv2.1"
+autoconf="custom GPLv2"
+automake="GPLv2"
+bash="GPLv3"
+bc="custom MIT"
+binutils="GPLv2 GPLv3 LGPLv2 LGPLv3"
+bison="GPLv3"
+bzip2="BSD3C custom"
+check="LGPLv2.1"
+coreutils="GPLv3 LGPLv2.1 LGPLv3"
+curl="BSD3C custom MIT"
+dbus="AFL2.1 GPLv2 GPLv3"
+dejagnu="GPLv3"
+diffutils="GPLv3"
+e2fsprogs="custom GPLv2 MIT"
+elfutils="GPLv2 GPLv3 LGPLv3"
+eudev="custom GPLv2 MIT"
+expat="custom MIT"
+expect="PD"
+fakeroot="GPLv3"
+file="BSD3C custom"
+findutils="GPLv3"
+flex="BSD3C custom"
+gawk="GPLv3"
+gcc="custom GPLv2 GPLv3 LGPLv2.1 LGPLv3"
+gdbm="GPLv3"
+gettext="GPLv3"
+glibc="GPLv2 LGPLv2.1 PD"
+gmp="GPLv2 GPLv3 LGPLv3"
+gnupg="CC0 custom GPLv2 GPLv3 LGPLv2.1 LGPLv3 MIT"
+gperf="GPLv3"
+gpgme="GLLv2 LGPLv2.1"
+grep="GPLv3"
+groff="GPLv3"
+grub="GPLv3"
+gzip="GPLv3"
+iana-etc="PD"
+inetutils="GPLv3"
+intltool="GPLv2"
+iproute2="GPLv2"
+Jinja2="BSD3C custom"
+kbd="GPLv2"
+kmod="LGPLv2.1"
+less="GPLv3"
+lfs-bootscripts="custom MIT"
+libarchive="Apachev2 CC0v1U custom MIT OpenSSL PD UC-Regents3C"
+libassuan="GPLv3 LGPLv2.1"
+libcap="BSD3C GPLv2"
+libffi="custom GPLv2 MIT"
+libgcrypt="GPLv2 LGPLv2.1"
+libgpg-error="GPLv2 LGPLv2.1"
+libksba="GPLv2 GPLv3 LGPLv3"
+libpipeline="GPLv3"
+libtasn1="GPLv3 LGPLv2.1"
+libtool="GPLv2"
+libxml2="custom MIT"
+linux="custom GPLv2"
+linux-api-headers="GPLv2"
+m4="GPLv3"
+make="GPLv3"
+make-ca="custom GPLv3 MIT"
+man-db="GPLv2 LGPLv2.1"
+man-pages="custom"
+MarkupSafe="BSD3C custom"
+meson="Apachev2"
+mpc="LGPLv3"
+mpfr="GPLv3 LGPLv3"
+ncurses="custom MIT"
+nettle="GPLv2 GPLv3 LGPLv3"
+ninja="Apachev2"
+npth="LGPLv2.1"
+openssl="OpenSSL SSLeay"
+p11-kit="custom MIT"
+pacman="GPLv2"
+pacman-contrib="GPLv2"
+patch="GPLv3"
+perl="GPLv1"
+pip="custom MIT"
+pkg-config="GPLv2"
+procps-ng="GPLv2 LGPLv2"
+psmisc="GPLv2"
+pth="LGPLv2.1"
+Python="PSFLv2"
+readline="GPLv3"
+rootfs="CC-BY-SA-2.0"
+sed="GPLv3"
+setuptools="custom MIT"
+shadow="BSD3C custom"
+sqlite="custom PD GPLv3"
+sysklogd="GPLv2"
+systemd="GPLv2 GPLv3 LGPLv2.1 LGPLv3"
+sysvinit="GPLv2"
+tar="GPLv3"
+tcl="UC-Regents3C"
+texinfo="GPLv3"
+tzdata="PD"
+udev="GPLv2 GPLv3 LGPLv2.1 LGPLv3"
+util-linux="GPLv2"
+unzip="BSD3C"
+vim="VIM"
+XML-Parser="custom"
+xz="custom GPLv2 GPLv3 LGPLv2.1 PD"
+zlib="custom MIT"
+zstd="GPLv2"
diff --git a/pkgmngt/licenses.list.rpm b/pkgmngt/licenses.list.rpm
new file mode 100644
index 0000000..9b66573
--- /dev/null
+++ b/pkgmngt/licenses.list.rpm
@@ -0,0 +1,105 @@
+# Licenses follow Fedora Packaging Guidelines at
+# https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#SoftwareLicenses
+acl="GPLv2+ and LGPLv2.1+"
+attr="GPLv2+ and LGPLv2.1+"
+autoconf="GPLv2+ with configure exception"
+automake="GPLv2+"
+bash="GPLv3+"
+bc="MIT"
+binutils="GPLv2+ and LGPLv2+"
+bison="GPLv3+"
+bzip2="BSD"
+check="LGPLv2.1+"
+coreutils="GPLv3+ and LGPLv2.1+"
+cpio="GPLv3+"
+dbus="AFPL2.1 or GPLv2+"
+dejagnu="GPLv3+"
+diffutils="GPLv3+"
+e2fsprogs="GPLv2+ and MIT"
+elfutils="GPLv2+ LGPLv3+"
+eudev="GPLv2+ and MIT"
+expat="MIT"
+expect="Public Domain"
+fakeroot="GPLv3+"
+file="BSD"
+findutils="GPLv3+"
+flex="BSD"
+gawk="GPLv3+"
+gcc="BSD and GPLv2+ with exceptions and GPLv3+ and GPLv3+ with exceptions and LGPLv2+"
+gdbm="GPLv3+"
+gettext="GPLv3+"
+glibc="GPLv2+ and LGPLv2.1+ and Public Domain"
+gmp="GPLv2+ and LGPLv3+"
+gperf="GPLv3+"
+gpgme="GLLv2+ LGPLv2.1+"
+grep="GPLv3+"
+groff="GPLv3+"
+grub="GPLv3+"
+gzip="GPLv3+"
+iana-etc="Public Domain"
+inetutils="GPLv3+"
+intltool="GPLv2+"
+iproute2="GPLv2+"
+Jinja2="BSD"
+kbd="GPLv2+"
+kmod="LGPLv2.1+"
+less="GPLv3+"
+lfs-bootscripts="MIT"
+libarchive="ASL 2.0 and BSD"
+libassuan="GPLv3+ and LGPLv2.1+"
+libcap="BSD and GPLv2+"
+libffi="GPLv2+ and MIT"
+libgcrypt="GPLv2+ and LGPLv2.1+"
+libgpg-error="GPLv2+ and LGPLv2.1+"
+libpipeline="GPLv3+"
+libtool="GPLv2+"
+libxml2="MIT"
+linux="GPLv2+"
+linux-api-headers="GPLv2+"
+lua="MIT"
+m4="GPLv3+"
+make="GPLv3+"
+man-db="GPLv2+ and LGPLv2.1+"
+man-pages="BSD and Copyright only and GPL+ and GPLv2+ and MIT and IEEE"
+MarkupSafe="BSD"
+meson="ASL 2.0"
+mpc="LGPLv3+"
+mpfr="GPLv3+ and LGPLv3+"
+ncurses="MIT"
+nettle="GPLv2+ and LGPLv3+"
+ninja="ASL 2.0"
+npth="LGPLv2.1+"
+openssl="OpenSSL"
+popt="MIT"
+pacman="GPLv2+"
+pacman-contrib="GPLv2+"
+patch="GPLv3+"
+perl="GPL+"
+pip="MIT"
+pkg-config="GPLv2+"
+procps-ng="GPLv2+ and LGPLv2+"
+psmisc="GPLv2+"
+pth="LGPLv2.1+"
+Python="PSFLv2+"
+readline="GPLv3+"
+rootfs="CC-BY-SA"
+rpm="GPLv2+"
+sed="GPLv3+"
+setuptools="MIT"
+shadow="BSD and GPLv2+"
+sqlite="GPLv3+ and Public Domain"
+sysklogd="GPLv2+"
+systemd="GPLv2+ and LGPLv2.1+"
+systemd-udev="GPLv2+ and LGPLv2.1+"
+sysvinit="GPLv2+"
+tar="GPLv3+"
+tcl="BSD"
+texinfo="GPLv3+"
+tzdata="Public Domain"
+util-linux="GPLv2+"
+unzip="BSD"
+vim="Vim"
+XML-Parser="Artistic or GPL+"
+xz="GPLv2+ and LGPLv2.1+ and Public Domain"
+zlib="MIT"
+zstd="GPLv2+"
diff --git a/pkgmngt/packFixScripts.sh.pacman b/pkgmngt/packFixScripts.sh.pacman
new file mode 100644
index 0000000..7ba0663
--- /dev/null
+++ b/pkgmngt/packFixScripts.sh.pacman
@@ -0,0 +1,965 @@
+#!/bin/bash
+
+#### Create dependencies
+echo -n "Extracting dependency list..."
+xsltproc --nonet -o ${JHALFSDIR}/dependencies.list \
+         ${JHALFSDIR}/dependencies.xsl ${JHALFSDIR}/prbook.xml
+# Some Fixups:
+# Remove the xml header
+sed '/xml version/d' -i ${JHALFSDIR}/dependencies.list
+# Get rid of all lines containing "None"
+sed '/None/d' -i ${JHALFSDIR}/dependencies.list
+# No checkdepends for "No test suite"
+sed '/No test/d' -i ${JHALFSDIR}/dependencies.list
+# Make everything lowercase
+sed -e 's/\(.*\)/\L\1/' -i ${JHALFSDIR}/dependencies.list
+# Fix a minor wrinkle with ulink space normalization
+sed -e 's/, and/, and /' \
+    -e '/[a-z]and[a-z]/s/and/ and /' -i ${JHALFSDIR}/dependencies.list
+# "and" is unnecessary, but we have multiple variants in English
+sed '/[a-z], and/s/ and / /' -i ${JHALFSDIR}/dependencies.list
+sed 's/ and /, /' -i ${JHALFSDIR}/dependencies.list
+# Additional issue with ulink space normalization
+sed -e '/[a-z],[a-z]/s/,/, /g' -e 's/  / /g' -i ${JHALFSDIR}/dependencies.list
+# Hypenate packages with sapces in them
+sed 's/berkeley db/berkeley-db/' -i ${JHALFSDIR}/dependencies.list
+sed 's/linux api headers/linux-api-headers/' -i ${JHALFSDIR}/dependencies.list
+# Replace :: in perl package names with hyphen
+sed 's/::/-/g' -i ${JHALFSDIR}/dependencies.list
+sed 's@,@@g' -i ${JHALFSDIR}/dependencies.list
+# Remove trailing '.' characters
+sed 's@\.@@g' -i ${JHALFSDIR}/dependencies.list
+echo "done"
+
+
+
+#### Extracting urls and md5sums
+echo -n "Extracting URLs and MD5Sums list..."
+xsltproc --nonet --stringparam pkgmngt "y" \
+         --output ${JHALFSDIR}/urls.list   \
+         ${JHALFSDIR}/urls.xsl ${JHALFSDIR}/prbook.xml
+echo "done"
+
+
+
+#### Create config files
+# Ugly, ugly, ugly hackery (no idea where the "--&gt;" are coming from), but
+# the following gets the job done for now (but should fix it if I can):
+echo -n "Extracting configuration files list...."
+xsltproc --nonet --output ${JHALFSDIR}/configfiles.list \
+         ${JHALFSDIR}/configfiles.xsl ${JHALFSDIR}/prbook.xml
+sed -e '/--&gt;/d' -e '/"$/d' -e 's@, $@"@' -e '/""/d' \
+    -e 's@", @"@' -e '/^</d' -e 's/,/ /g' -i $JHALFSDIR/configfiles.list
+# modprobe config file is named modprobe, despite being part of linux package
+sed 's@^modprobe@linux@' -i $JHALFSDIR/configfiles.list
+echo "done"
+
+
+
+#### Convert scripts to output PKGBUILD files
+
+# Generic command and header for PKGBUILD files
+tempfile=`mktemp`
+cat > ${tempfile} << "EOF"
+cat > PKGBUILD << "REALEOF"
+# Maintainer Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>
+
+pkgname=""
+pkgver=""
+pkgrel="1"
+pkgdesc=""
+arch=()
+license=()
+groups=('core')
+depends=()
+makedepends=()
+checkdepends=()
+optdepends=()
+backup=()
+source=()
+md5sums=()
+
+EOF
+
+echo -e "\nProcessing PKGBUILD files (this may take a while):"
+sleep 3
+# For each file, several changes need to be made and need to be done in order
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  echo -n "Processing ${file}..."
+
+  # Skip pkgmgt, stripping, and revisedchroot and 8??-?? files
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep -q "pkgmgt" &&
+       echo "skip" && continue;
+  echo "${scriptfile}" | grep -q "stripping" &&
+       echo "skip" && continue;
+  echo "${scriptfile}" | grep -q "revisedchroot" &&
+       echo "skip" && continue;
+  echo "${scriptfile}" | grep -q "8[0-9][0-9]-[0-9][0-9]" &&
+       echo "skip" && continue;
+
+  # The glibc package is a bit of a mess, so normalize it (ugly)...
+  if $(echo "${scriptfile}" | grep -q "glibc"); then
+    #Note: These break if anybody messes with the directory creation in
+    #      LFS/lfs.xsl
+    sed '/^mkdir -pv $PKG_DEST\/{/,+13d' -i ${file}
+    sed '/^for dir in/,+20d' -i ${file}
+    sed '0,/^PREV_SEC/s//PREVSEC/' -i ${file}
+    sed '/^PREV_SEC/,+3d' -i ${file}
+    sed 's/^PREVSEC/PREV_SEC/' -i ${file}
+    sed "s@^ln -sfv@PREV_SEC=\${SECONDS}\npackInstall\nSECONDS=\${PREV_SEC}\nrm -rf \$PKG_DEST\nln -sfv@" \
+        -i ${file}
+    # The glibc package no longer uses jhalfs's DESTDIR pre-populate and prune
+    sed "s@^touch@mkdir -pv \$PKG_DEST/etc\ntouch@" -i ${file}
+  fi
+
+  # adding in the non-wide ncurses also creates some issues
+  if $(echo "${scriptfile}" | grep -q "ncurses"); then
+    if $(grep -q "^make distclean" ${file}); then
+      start=`grep -n "^make distclean" ${file} | cut -d ":" -f 1`
+      stop=`grep -n "^cp -av lib/lib" ${file} | cut -d ":" -f 1`
+      # cp -v -R doc/* $PKG_DEST/usr/share/doc/ncurses-6.2
+      nwtempfile=`mktemp`
+      sed -n "${start},${stop}p" ${file} > ${nwtempfile}
+      sed "${start},${stop}d" -i ${file}
+      sed "s@^for dir in@FIXME\nfor dir in@" -i ${file}
+      sed "/^FIXME/e cat ${nwtempfile}" -i ${file}
+      sed 's@^FIXME@EOF@' -i ${file}
+      rm -f ${nwtempfile}
+      unset start stop nwtempfile
+    fi
+  fi
+
+  unset scriptfile
+
+  # 1.  Don't untar the package, create the source direcotry, and give our
+  #     pacman user ownership of the new build directory - reuse $PKG_DEST
+  sed -e "s@^tar -xf \$PACKAGE@rm -rf \$PKG_DEST\ninstall -d -o pacman \$PKG_DEST@" \
+      -i ${file}
+
+  # 2.  Remove "# remap=make" comments as configure and make are combined
+  #     into build() in PKGBUILD files
+  count=`grep -c "^# remap=configure" ${file}`
+  if test "${count}" != "0"; then
+    sed '/^# remap=make/d' -i ${file}
+  else
+    sed 's@^# remap=make@# remap=configure@' -i ${file}
+  fi
+
+  # 3.  Insert cat > commands and generic PKGBUUILD headers at
+  #     "# Start of LFS book script"
+  sed "/# Start of LFS book script/e cat ${tempfile}" -i ${file}
+  sed -e '/^# Start of LFS book script/d' -i ${file}
+
+  # 4.  End the dump to PKGBUILD - ugly but better than ranges at this point
+  sed -e '0,/^PREV_SEC/s@PREV_SEC@PREVSEC@' -i ${file}
+  sed -e "/^PREV_SEC/s@^PREV_SEC@REALEOF\nPREV_SEC@" -i ${file}
+  sed 's@^PREVSEC@PREV_SEC@' -i ${file}
+
+  # 5.  Remove any duplicate "# remap={pre,configure,test,install}"
+  sed '0,/^# remap=pre/s@^# remap=pre@# remap=apre@' -i ${file}
+  sed '/^# remap=pre/d' -i ${file}
+  sed 's@^# remap=apre@# remap=pre@' -i ${file}
+  sed '0,/^# remap=conf/s@^# remap=conf@# remap=aconf@' -i ${file}
+  sed '/^# remap=conf/d' -i ${file}
+  sed 's@^# remap=aconf@# remap=conf@' -i ${file}
+  sed '0,/^# remap=test/s@^# remap=test@# remap=atest@' -i ${file}
+  sed '/^# remap=test/d' -i ${file}
+  sed 's@^# remap=atest@# remap=test@' -i ${file}
+  sed '0,/^# remap=install/s@^# remap=install@# remap=ainstall@' -i ${file}
+  sed '/^# remap=install/d' -i ${file}
+  sed 's@^# remap=ainstall@# remap=install@' -i ${file}
+
+  # 6.  Create any install files...
+  grep "####POSTINST####" $file >/dev/null 2>&1
+  if test "$?" -eq "0"; then
+    start=`grep -n "####POSTINST####" ${file} | cut -d ":" -f 1`
+    stop=`grep -n "####ENDPOSTINST####" ${file} | cut -d ":" -f 1`
+    version=`grep "^VERSION=" ${file} | cut -d "=" -f 2 | sed 's@"@@g'`
+    package=`grep "^PACKAGE=" ${file} | cut -d "=" -f 2 | sed 's@"@@g'`
+    package=`echo ${package} | sed "s@-${version}.*@@"`
+    insttempfile=`mktemp`
+    post_install=`sed -n "$((${start} + 1)),$(( ${stop} - 1))p" ${file}`
+    newfile="${package}.install"
+    echo -e "# ${newfile}\n" > ${insttempfile}
+    echo "post_install(){" >> ${insttempfile}
+    echo "${post_install}" | sed 's@^@  @' >> ${insttempfile}
+    echo "}" >> ${insttempfile}
+    sed "${start},${stop}d" -i ${file}
+    sed "/\"REALE/s@cat@cat > ${newfile} << \"EOF\"\nFIXME\ncat@" \
+        -i $file
+    sed "/^FIXME/e cat ${insttempfile}" -i ${file}
+    sed 's@^FIXME@EOF@' -i ${file}
+    rm -f ${insttempfile}
+    sed "s@^groups@install=\"${newfile}\"\ngroups@" -i ${file}
+    unset version pacakge insttempfile post_install newfile
+  fi
+
+  # 7.  Insert the functions
+  sed "s@^# remap=pre@prepare(){\ncd \${pkgname}-\${pkgver}@" -i ${file}
+  sed "s@^# remap=configure@build(){\ncd \${pkgname}-\${pkgver}@" -i ${file}
+  sed "s@^# remap=test@check(){\ncd \${pkgname}-\${pkgver}@" -i ${file}
+  sed "s@^# remap=install@package(){\ncd \${pkgname}-\${pkgver}@" -i ${file}
+  # now end the functions - nested but works
+  sed "s@^REALEOF@chown -R root:root \${pkgdir}\n}\n\nREALEOF@" -i ${file}
+#  sed "s@^REALEOF@}\n\nREALEOF@" -i ${file}
+  if test "$(grep "^check()" ${file})" != "" \
+       -o "$(grep "^build()" ${file})" != "" \
+       -o "$(grep "^prepare()" ${file})" != ""; then
+    sed "s@^package()@}\n\npackage()@" -i ${file}
+    if test "$(grep "^build()" ${file})" != "" \
+         -o "$(grep "^prepare()" ${file})" != ""; then
+      sed "s@^check()@}\n\ncheck()@" -i ${file}
+      if test "$(grep "^prepare()" ${file})" != ""; then
+        sed "s@^build()@}\n\nbuild()@" -i ${file}
+      fi
+    fi
+  fi
+
+  # 8.  We won't use $PKGDIR, just reuse $PKG_DEST
+  sed 's@^cd $PKGDIR@cd $PKG_DEST@' -i ${file}
+  sed '/^rm -rf $PKGDIR/d' -i ${file}
+  sed '/^if \[ -d "${PKGDIR/d' -i ${file}
+
+  # 9.  Account for packages that use an alternate build dir
+  count=`grep -c "^prepare" ${file}`
+  if test ${count} -gt 0; then
+    start=`grep -n "^prepare" ${file} | head -n1 | cut -d ":" -f 1`
+    stoplist=`grep -n "^}" ${file} | cut -d ":" -f 1`
+    for stop in $stoplist; do
+       if test $stop -gt $start; then
+         break;
+       fi
+    done
+    prepare=`sed -n "$((${start} + 1)),$(( ${stop} - 1))p" ${file}`
+    echo ${prepare} | grep -q "mkdir.*build"
+    if test "${?}" == "0"; then
+      sed -e "${stop},$ {/^cd/s@ver\}@ver\}/build@}" -i ${file}
+    fi
+  fi
+  unset count start stop stoplist prepare
+
+  # 10. Remove instances of ">> $TEST_LOG " - pacman has its own logging
+  sed 's@>> $TEST_LOG @@' -i ${file}
+
+  # 11. Populate pkgname, pkgver, and pkgdesc values
+  version=`grep "^VERSION" ${file} | cut -d "=" -f 2 | sed 's@"@@g'`
+  package=`grep "^PACKAGE" ${file} | cut -d "=" -f 2 | sed 's@"@@g'`
+  pkgname=`echo ${package} | sed "s@${version}.*@@" | sed 's@"@@g'`
+  echo ${pkgname} | grep -q ".*-$" && \
+       pkgname=`echo ${pkgname} | sed 's@-$@@'` || true
+  # special case for only udev to avoid dependency conflicts
+  if $(echo $file | grep -q udev); then
+    pkgname="udev"
+  fi
+  sed "s@^pkgname=\"\"@pkgname=\"${pkgname}\"@" -i ${file}
+  sed "s@^pkgver=\"\"@pkgver=\"${version}\"@" -i ${file}
+  sed "s@^pkgdesc=\"\"@pkgdesc=\"${pkgname} ${version}\"@" -i ${file}
+  unset version package pkgname
+
+  # 12. Use ${pkgdir} instead of $PKG_DEST in install()
+  if test "$(grep "^package" $file)" != ""; then
+    start=`grep -n "^package\(\)" ${file} | head -n1 | cut -d ":" -f 1`
+    stoplist=`grep -n "^}" ${file} | cut -d ":" -f 1`
+      for stop in $stoplist; do
+        if test $stop -gt $start; then
+          break;
+        fi
+      done
+    sed -e "${start},${stop} {s@\$PKG_DEST@\${pkgdir}@g}" -i ${file}
+  fi
+  unset start stop stoplist
+
+  # 13. Use ${srcdir} instead of relative links (globally)
+  sed -e '/^tar/s@ ../../@ ${srcdir}/@' \
+      -e '/^tar/s@ ../@ ${srcdir}/@' \
+      -e '/^patch/s@ ../../@ ${srcdir}/@' \
+      -e '/^patch/s@ ../@ ${srcdir}/@' -i ${file}
+
+  # 14. Don't remove PKG_DEST before cd'ing out of it!
+  sed "s@^packInstall@packInstall\ncd \$SRC_DIR@" -i $file
+
+  # 15. We don't untar, and we are done with $PREV_SEC, so don't juggle time
+  sed '/PREV_SEC/d' -i ${file}
+
+  echo "done"
+done
+
+rm -f ${tempfile}
+unset tempfile file
+
+# We still need to do these few for the chapter-08 addtions
+for file in ${JHALFSDIR}/lfs-commands/chapter08/8[0-9][0-9]-[0-9][0-9]-* ; do
+  sed -e "s@^tar -xf \$PACKAGE@rm -rf \$PKG_DEST\ninstall -d -o pacman \$PKG_DEST@" \
+      -i ${file}
+  sed 's@^cd $PKGDIR@cd $PKG_DEST@' -i ${file}
+  sed '/^rm -rf $PKGDIR/d' -i ${file}
+  sed '/^if \[ -d "${PKGDIR/d' -i ${file}
+done
+
+#### Set arch specific to build host and package
+echo -n "Processing arch=() values..."
+myarch=$(uname -m)
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  # Skip pkgmgt, stripping, and revisedchroot
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep "pkgmgt" > /dev/null && continue;
+  echo "${scriptfile}" | grep "stripping" > /dev/null && continue;
+  echo "${scriptfile}" | grep "revisedchroot" > /dev/null && continue;
+  unset scriptfile
+
+  pkgname=`grep "^pkgname" ${file} | sed 's@pkgname=@@;s@\"@@g'`
+  if test "${pkgname}"x != "x"; then
+    if test "${pkgname}" == "man-pages"  -o \
+            "${pkgname}" == "iana-etc"   -o \
+            "${pkgname}" == "xml-parser" -o \
+            "${pkgname}" == "lfs-bootscripts"; then
+      sed "s@^arch=()@arch=('any')@" -i ${file}
+    else
+      sed "s@^arch=()@arch=('$myarch')@" -i ${file}
+    fi
+  fi
+done
+unset file
+echo "done"
+
+
+
+#### Add license info
+echo -n "Processing license() values..."
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  # Skip pkgmgt, stripping, and revisedchroot
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep "pkgmgt" > /dev/null && continue;
+  echo "${scriptfile}" | grep "stripping" > /dev/null && continue;
+  echo "${scriptfile}" | grep "revisedchroot" > /dev/null && continue;
+  unset scriptfile
+
+  pkgname=`grep "^pkgname" ${file} | sed 's@pkgname=@@;s@\"@@g'`
+  if test "${pkgname}"x != "x"; then
+    licenses=`grep "^${pkgname}=" ${JHALFSDIR}/licenses.list | \
+              cut -d "=" -f 2 | sed 's@"@@g'`
+    if test "${licenses}x" == "x"; then
+      continue;
+    else
+      licenses="$licenses END"
+      tempfile=`mktemp`
+      echo -n "license=(" > ${tempfile}
+      for i in ${licenses}; do
+        if test "${i}" == "END"; then
+          echo ")" >> ${tempfile}
+          break;
+        elif test "${c}x" != "x"; then
+          echo "" >> ${tempfile}
+        fi
+        if test "${c}" == "1"; then
+          echo -n "         '${i}'" >> ${tempfile}
+        else
+          echo -n "'${i}'" >> ${tempfile}
+          c="1"
+        fi
+      done
+      unset c
+      sed "/^license/e cat ${tempfile}" -i ${file}
+      rm ${tempfile}
+      unset tempfile licenses
+    fi
+    sed '/^license=()/d' -i ${file}
+  fi
+done
+unset file
+echo "done"
+
+
+#### Add dependency array info
+echo "Processing depends(), makedepends(), checkdepends(), and"
+echo -n "optdepends() values..."
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  # Skip pkgmgt, stripping, revisedchroot, and PM packages
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep -q "pkgmgt" && continue;
+  echo "${scriptfile}" | grep -q "stripping" && continue;
+  echo "${scriptfile}" | grep -q "revisedchroot" && continue;
+  echo "${scriptfile}" | grep -q "8[0-9][0-9]-[0-9][0-9]" && continue;
+  unset scriptfile
+
+  pkgname=`grep "^pkgname" ${file} | sed 's@pkgname=@@;s@\"@@g'`
+  if test "${pkgname}"x != "x"; then
+    depends=`grep "^${pkgname}-rundeps" ${JHALFSDIR}/dependencies.list`
+    makedeps=`grep "^${pkgname}-depends" ${JHALFSDIR}/dependencies.list`
+    checkdeps=`grep "^${pkgname}-testdeps" ${JHALFSDIR}/dependencies.list`
+    optdeps=`grep "^${pkgname}-optdeps" ${JHALFSDIR}/dependencies.list`
+  fi
+  # depends()
+  if test "${depends}x" != "x"; then
+    depends=`echo "${depends} rootfs END" | cut -d "=" -f 2 | sed 's@"@@g'`
+    tempfile=`mktemp`
+    echo -n "depends=(" > ${tempfile}
+    for i in ${depends}; do
+      if test "${i}" == "END"; then
+        echo ")" >> ${tempfile}
+        break;
+      elif test "${c}x" != "x"; then
+        echo "" >> ${tempfile}
+      fi
+      if test "${c}" == "1"; then
+        echo -n "         '${i}'" >> ${tempfile}
+      else
+        echo -n "'${i}'" >> ${tempfile}
+        c="1"
+      fi
+    done
+    unset c
+    sed "/^depends/e cat ${tempfile}" -i ${file}
+    rm ${tempfile}
+    unset tempfile
+    depends=`echo ${depends} | sed 's@ END@@'`
+  fi
+  sed '/^depends=()/d' -i ${file}
+  # makedepends()
+  if test "${makedeps}x" != "x"; then
+    makedeps=`echo "${makedeps} END" | cut -d "=" -f 2 | sed 's@"@@g'`
+    tempfile=`mktemp`
+    echo -n "makedepends=(" > ${tempfile}
+    for i in ${makedeps}; do
+      # skip depends
+      echo "${depends}" | grep -q "${i}" && continue;
+      if test "${i}" == "END"; then
+        echo ")" >> ${tempfile}
+        break;
+      elif test "${c}x" != "x"; then
+        echo "" >> ${tempfile}
+      fi
+      if test "${c}" == "1"; then
+        echo -n "             '${i}'" >> ${tempfile}
+      else
+        echo -n "'${i}'" >> ${tempfile}
+        c="1"
+      fi
+    done
+    unset c
+    sed "/^makedepends/e cat ${tempfile}" -i ${file}
+    rm ${tempfile}
+    unset tempfile
+  fi
+  sed '/^makedepends=()/d' -i ${file}
+  # checkdepends()
+  if test "${checkdeps}x" != "x"; then
+    checkdeps=`echo "${checkdeps} END" | cut -d "=" -f 2 | sed 's@"@@g'`
+    tempfile=`mktemp`
+    echo -n "checkdepends=(" > ${tempfile}
+    for i in ${checkdeps}; do
+      if test "${i}" == "END"; then
+        echo ")" >> ${tempfile}
+        break;
+      elif test "${c}x" != "x"; then
+        echo "" >> ${tempfile}
+      fi
+      if test "${c}" == "1"; then
+        echo -n "              '${i}'" >> ${tempfile}
+      else
+        echo -n "'${i}'" >> ${tempfile}
+        c="1"
+      fi
+    done
+    unset c
+    sed "/^checkdepends/e cat ${tempfile}" -i ${file}
+    rm ${tempfile}
+    unset tempfile
+  fi
+  sed '/^checkdepends=()/d' -i ${file}
+  # optdepends()
+  if test "${optdeps}x" != "x"; then
+    optdeps=`echo "${optdeps} END" | cut -d "=" -f 2 | sed 's@"@@g'`
+    tempfile=`mktemp`
+    echo -n "optdepends=(" > ${tempfile}
+    for i in ${optdeps}; do
+      if test "${i}" == "END"; then
+        echo ")" >> ${tempfile}
+        break;
+      elif test "${c}x" != "x"; then
+        echo "" >> ${tempfile}
+      fi
+      if test "${c}" == "1"; then
+        echo -n "            '${i}'" >> ${tempfile}
+      else
+        echo -n "'${i}'" >> ${tempfile}
+        c="1"
+      fi
+    done
+    unset c
+    sed "/^optdepends/e cat ${tempfile}" -i ${file}
+    rm ${tempfile}
+    unset tempfile
+  fi
+  sed '/^optdepends=()/d' -i ${file}
+done
+unset file pkgname depends makedeps checkdeps optdeps
+echo "done"
+
+
+#### Add source and md5sums arrays
+echo -n "Processing source() and md5sums() values..."
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  # Skip pkgmgt, stripping, revisedchroot, and PM packages
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep -q "pkgmgt" && continue;
+  echo "${scriptfile}" | grep -q "stripping" && continue;
+  echo "${scriptfile}" | grep -q "revisedchroot" && continue;
+  echo "${scriptfile}" | grep -q "8[0-9][0-9]-[0-9][0-9]" && continue;
+  unset scriptfile
+
+  pkgname=`grep "^pkgname" ${file} | sed 's@pkgname=@@;s@\"@@g'`
+  if test "${pkgname}"x != "x"; then
+    tempfile=`mktemp`
+    tempfile2=`mktemp`
+    tempfile3=`mktemp`
+    # expect and tcl are special cases
+    if test "${pkgname}" == "tcl" -o "${pkgname}" == "expect"; then
+      grep "/${pkgname}/" ${JHALFSDIR}/urls.list > ${tempfile}
+      if test "${pkgname}" == "tcl"; then
+        htmlfile=$(basename `grep "${pkgname}.*-html" ${JHALFSDIR}/urls.list \
+                     | cut -d " " -f 1`)
+        sed -e "s@^md5sums=()@noextract=(\'${htmlfile}\')\nmd5sums=()@" \
+            -i ${file}
+        unset htmlfile
+      fi
+    else
+      grep "${pkgname}-" ${JHALFSDIR}/urls.list > ${tempfile}
+    fi
+    # libelf is a special case
+    if test "${pkgname}" == "libelf"; then
+      pkgnametmp=`grep "^_pkgname" ${file} | sed 's@_pkgname=@@;s@\"@@g'`
+      grep "/${pkgnametmp}/" ${JHALFSDIR}/urls.list > ${tempfile}
+    fi
+    # Special case for glibc
+    if test "${pkgname}" == "glibc"; then
+      grep "tzdata" ${JHALFSDIR}/urls.list >> ${tempfile}
+      tzdatafile=`basename $(grep "tzdata" ${JHALFSDIR}/urls.list | \
+                   cut -d " " -f 1)`
+      sed -e "s@^md5sums=()@noextract=(\'${tzdatafile}\')\nmd5sums=()@" \
+          -i ${file}
+    fi
+    # Special case for linux
+    if test "${pkgname}" == "linux"; then
+      sed -e '/util-linux/d' -e '/libcap/d' -i ${tempfile}
+    fi
+    # Special case for Python
+    if test "${pkgname}" == "Python"; then
+      grep "Python-" ${JHALFSDIR}/urls.list > ${tempfile}
+      grep "python.*docs-html" ${JHALFSDIR}/urls.list >> ${tempfile}
+      pydocs=`basename $(grep "python.*docs-html" ${JHALFSDIR}/urls.list | \
+                cut -d " " -f 1)`
+      sed -e "s@^md5sums=()@noextract=(\'${pydocs}\')\nmd5sums=()@" -i ${file}
+    fi
+    # Special case for make - it pulls in automake
+    if test "${pkgname}" == "make"; then
+      sed '/automake/d' -i ${tempfile}
+    fi
+    # Special case for eudev
+    if test "${pkgname}" == "eudev"; then
+      grep "udev-lfs" ${JHALFSDIR}/urls.list >> ${tempfile}
+      lfsudevtar=`basename $(grep "udev-lfs" ${JHALFSDIR}/urls.list | \
+                    cut -d " " -f 1)`
+      sed -e "s@^md5sums=()@noextract=('${lfsudevetar}'\)\nmd5sums=()@" \
+          -i ${file}
+      sed -e 's@xvf  ..@xvf ${srcdir}@' -i ${file}
+    fi
+    # Special case for udev
+    if test "${pkgname}" == "udev"; then
+      grep "systemd" ${JHALFSDIR}/urls.list > ${tempfile}
+      grep "udev-lfs" ${JHALFSDIR}/urls.list >> ${tempfile}
+      lfsudevtar=`basename $(grep "udev-lfs" ${JHALFSDIR}/urls.list | \
+                    cut -d " " -f 1)`
+      sysdman=`basename $(grep "systemd-man-pages" ${JHALFSDIR}/urls.list | \
+                          cut -d " " -f 1)`
+      sed -e "s@^md5sums=()@noextract=('${lfsudevtar}'\n           '${sysdman}'\)\nmd5sums=()@" \
+          -i ${file}
+      sed -e 's@xvf  ..@xvf ${srcdir}@' -i ${file}
+      sed -e "s@^pkgname=\"udev\"@pkgname=\"udev\"\n_pkgname=\"systemd\"@" \
+          -e 's@${pkgname}@${_pkgname}@g' -i ${file}
+    fi
+    cut -d " " -f 1 ${tempfile} > ${tempfile2}
+    cut -d " " -f 3 ${tempfile} > ${tempfile3}
+    sed -e "s/^/'/" -e "s/$/'/" -i ${tempfile2}
+    sed -e "s/^/'/" -e "s/$/'/" -i ${tempfile3}
+    sed '1s/^/source=(/' -i ${tempfile2}
+    sed "s/^'/        '/" -i ${tempfile2}
+    sed '$ s/$/)/' -i ${tempfile2}
+    sed '1s/^/md5sums=(/' -i ${tempfile3}
+    sed "s/^'/         '/" -i ${tempfile3}
+    sed '$ s/$/)/' -i ${tempfile3}
+    sed "/^source=\(\)/e cat ${tempfile2}" -i ${file}
+    sed "/^md5sums=\(\)/e cat ${tempfile3}" -i ${file}
+    sed '/^source=()/d' -i ${file}
+    sed '/^md5sums=()/d' -i ${file}
+    rm ${tempfile} ${tempfile2} ${tempfile3}
+    unset tempfile tempfile2 tempfile3 pkgname
+  fi
+done
+unset file
+echo "done"
+
+
+#### Add backup array contents
+echo -n "Processing backup() values..."
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  # Skip pkgmgt, stripping, revisedchroot, and PM packages
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep -q "pkgmgt" && continue;
+  echo "${scriptfile}" | grep -q "stripping" && continue;
+  echo "${scriptfile}" | grep -q "revisedchroot" && continue;
+  echo "${scriptfile}" | grep -q "8[0-9][0-9]-[0-9][0-9]" && continue;
+  unset scriptfile
+
+  pkgname=`grep "^pkgname" ${file} | sed 's@pkgname=@@;s@\"@@g'`
+  if test "${pkgname}"x != "x"; then
+    backup=`grep "^${pkgname}" ${JHALFSDIR}/configfiles.list`
+    # Special case for shadow
+    if test "${pkgname}" == "shadow"; then
+      backup='shadow="/etc/shadow /etc/gshadow"'
+    fi
+    if test "${backup}x" == "x"; then
+      sed '/^backup=()/d' -i ${file}
+      continue;
+    fi
+    backup=`echo "${backup}" | cut -d "=" -f 2 | sed 's@"@@g'`
+    # /etc/ld.so.conf will be part of rootfs
+    backup=`echo ${backup} | sed 's@/etc/ld.so.conf@@'`
+    backup="${backup} END"
+    tempfile=`mktemp`
+    echo -n "backup=(" > ${tempfile}
+    for i in ${backup}; do
+      if test "${i}" == "END"; then
+        echo ")" >> ${tempfile}
+        break;
+      elif test "${c}x" != "x"; then
+        echo "" >> ${tempfile}
+      fi
+      if test "${c}" == "1"; then
+        echo -n "        '${i}'" >> ${tempfile}
+      else
+        echo -n "'${i}'" >> ${tempfile}
+        c="1"
+      fi
+    done
+    unset c
+    # No leading slash
+    sed "s@'/@'@" -i ${tempfile}
+    sed "/^backup\(\)/e cat ${tempfile}" -i ${file}
+    rm ${tempfile}
+    unset tempfile
+  fi
+  sed '/^backup=()/d' -i ${file}
+done
+unset backup file
+echo "done"
+
+#### Package specific fixes
+
+echo -n "Applying package specific fixes..."
+
+# Special cases for zoneinfo in chapter08 glibc
+# It should install to $pkgdir, but not try to use $pkdir/dev/null
+# Also use the just built zic
+# Remove /etc/ld.so.{conf,cache}
+sed "s@ZONEINFO=@# Note: you may want to separate zoneinfo from glibc\nZONEINFO=@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+sed 's@${pkgdir}/dev/null@/dev/null@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+sed 's@zic @${pkgdir}/usr/sbin/zic @g' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+# The glibc package should also leave emptydirs, staticlibs, and don't strip
+sed "s@^groups=@options=('!emptydirs' 'staticlibs' '!strip')\ngroups=@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+# Don't overwrite /etc/ld.so.conf
+sed '/^cat > \/etc\/ld.so.conf/,+5 d' \
+   -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+sed '/^unset ZONEINFO/a rm -f ${pkgdir}\/etc\/ld.so.c{onf,ache}' \
+   -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+# nsswitch.conf isn't in remap=install tags
+sed '/^cat > \/etc\/nss/s@/etc@${pkgdir}/etc@' \
+   -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+
+
+# Same thing for gcc - leave emptydirs, staticlibs around and don't strip
+sed "s@^groups=@options=('!emptydirs' 'staticlibs' '!strip')\ngroups=@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-gcc
+# GCC also needs /usr/lib/bfd-plugins
+sed "s@^mkdir -pv \${pkgdir}/{boot,etc}@mkdir -pv \${pkgdir}/usr/lib/bfd-plugins\nmkdir -pv \${pkgdir}/{boot,etc}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-gcc
+
+
+# binutils - skip the expect -c check
+sed '/^expect -c "spawn ls"/d' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-binutils
+# Don't strip
+sed "s@^groups=@options=('!emptydirs' 'staticlibs' '!strip')\ngroups=@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-binutils
+
+
+# GMP - make it build for uname -m, not cpu generation
+sed "s@./configure@cp -v config{fsf,}.guess\ncp -v config{fsf,}.sub\n./configure@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-gmp
+
+
+# Shadow in chapter08 will already have /usr/bin/passwd
+sed '/^touch \/usr\/bin\/passwd/d' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-shadow
+# Also, the useradd command is not yet present so do it the other way
+sed "s@^useradd -D --gid 999@install -vdm755 \${pkgdir}/etc/default\necho \"GROUPS=999\" >> \${pkgdir}/etc/default/useradd@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-shadow
+
+
+# libelf - change pkgname
+sed -e 's@"elfutils@"libelf@' \
+    -e 's@{pkgname@{_pkgname@g' \
+    -e 's@^pkgname="libelf"@pkgname="libelf"\n_pkgname="elfutils"@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-libelf
+
+# Python in LFS chapter08 should not install ensurepip - it was installed in
+# chapter07 and pip and setuptools will be reinstalled in chapter08 sepearately
+sed '/ensurepip/s/yes/no /' -i ${JHALFSDIR}/lfs-commands/chapter08/*-Python
+# python change pkgname to lower case
+sed -e 's@{pkgname@{_pkgname@g' \
+    -e "s@^pkgname=\"Python\"@pkgname=\"python\"\n_pkgname=\"Python\"@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-Python
+
+# Make xml-parser lowercase
+sed -e 's@{pkgname@{_pkgname@g' \
+    -e "s@^pkgname=\"XML-Parser\"@pkgname=\"xml-parser\"\n_pkgname=\"XML-Parser\"@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-xml-parser
+
+# rootfs is a special case too...no source file
+sed -e '/^PKGDIR/d' \
+    -e '/^tar -xf $PACKAGE/d' \
+    -e '/^cd $PKGDIR/d' \
+    -i ${JHALFSDIR}/lfs-commands/chapter07/*-rootfs
+
+
+# tcl needs a bit of help getting the pkgname and pkgver correct
+origpkgname=`grep "^pkgname=" ${JHALFSDIR}/lfs-commands/chapter08/*-tcl | \
+             cut -d "=" -f 2 | sed 's@"@@g'`
+pkgname="tcl"
+pkgver=`echo "${origpkgname}" | sed "s@${pkgname}@@"`
+sed "/^pkgname/s@${pkgname}${pkgver}@${pkgname}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-tcl
+sed "/^pkgver/s@src@${pkgver}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-tcl
+sed "/^pkgdesc/s@${origpkgname} src@${pkgname} ${pkgver}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-tcl
+# tcl also needs a noextract added
+sed "s@^md5sums=()@noextract=('${origpkgname}-html.tar.gz')\nmd5sums=()@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-tcl
+# tcl also has a weird extract directory and a strange subdir build
+file="${JHALFSDIR}/lfs-commands/chapter08/*-tcl"
+sed 's@${pkgname}-${pkgver}@${pkgname}${pkgver}@' -i ${file}
+start1=`grep -n "^check()" ${file} | cut -d ":" -f 1`
+start2=`grep -n "^package()" ${file} | cut -d ":" -f 1`
+stoplist=`grep -n "^}" ${file} | cut -d ":" -f 1`
+for stop in ${stoplist}; do
+  if test ${stop} -gt ${start1}; then
+    stop1=${stop}
+    break;
+  fi
+done
+for stop in ${stoplist}; do
+  if test ${stop} -gt ${start2}; then
+    stop2=${stop}
+    break;
+  fi
+done
+sed "${start1},${stop1} {s@^cd \"\${pkgname}\${pkgver}@cd \"\${pkgname}\${pkgver}/unix@}" -i $file
+sed "${start2},${stop2} {s@^cd \"\${pkgname}\${pkgver}@cd \"\${pkgname}\${pkgver}/unix@}" -i $file
+unset file start1 stop1 stoplist stop1 stop2
+# tcl too has a subdir dir
+file="${JHALFSDIR}/lfs-commands/chapter08/*-tcl"
+sed "s@^make -k test@cd unix\nmake -k test@" -i ${file}
+sed "s@^mkdir -pv \${pkgdir}/{boot,etc}@cd unix\nmkdir -pv \${pkgdir}/{boot,etc}@" -i ${file}
+
+
+# expect also has a weird tarball name
+origpkgname=`grep "^pkgver=" ${JHALFSDIR}/lfs-commands/chapter08/*-expect | \
+             cut -d "=" -f 2 | sed 's@"@@g'`
+pkgname="expect"
+pkgver=`echo "${origpkgname}" | sed "s@${pkgname}@@"`
+sed "/^pkgname/s@\"\"@\"${pkgname}\"@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-expect
+sed "/^pkgver/s@${pkgname}${pkgver}@${pkgver}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-expect
+sed "/^pkgdesc/s@ ${origpkgname}@${pkgname} ${pkgver}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-expect
+sed 's@${pkgname}-${pkgver}@${pkgname}${pkgver}@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-expect
+
+
+# ncurses - again, fix installation of non-wide libraries
+#           won't hurt anything if missing
+sed '/^cp -av lib\/lib/s@ /usr/lib@ ${pkgdir}/usr/lib@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-ncurses
+sed 's@^EOF@@' -i ${JHALFSDIR}/lfs-commands/chapter08/*-ncurses
+# Also, fix a potential race condition when building non-wide ncurses
+sed 's@^make sources@make -j1 sources@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-ncurses
+
+
+# procps-ng extracts to procps-${pkgver}
+sed -e "s@^pkgname=\"procps-ng\"@pkgname=\"procps-ng\"\n_pkgname=\"procps\"@" \
+    -e "s@\${pkgname}@\${_pkgname}@g" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-procps-ng
+
+
+# We are already building as the unprivileged pacman user in chapter 8, so
+# remove most of the tester user
+
+sed -e '/^chown -Rv tester/d' \
+    -e "s@^su tester -c \"PATH=\$PATH make -k check\"@make -k check@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-{bash,findutils,gcc,sed}
+
+sed -e '/^chown -Rv tester/d' \
+    -e "s@^su tester -c \"LANG=en_US.UTF-8 make -k -j1 test\"@LANG=en_US.UTF-8 make -k -j1 test@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-vim
+
+sed -e '/^chown -Rv tester/d' \
+    -e "s@^su tester -c \"make -k check\"@make -k check@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-util-linux
+
+# Bash works as is, so leave it alone for now
+
+# Coreutils - pacman user doesn't have permission to do anything by design
+# We are already running unprivileged, so just do a regular make check
+sed -e 's/NON_ROOT_USERNAME=tester check-root/check/' \
+    -e '/dummy/d' \
+    -e '/chown -Rv tester/d' \
+    -e '/^su tester/d' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-coreutils
+
+
+# Python has a multiline tar command that wasn't fixed earlier
+sed -e '/\.\.\/python-.*-docs-html/s@\.\.@${srcdir}@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-Python
+
+
+# e2fsprogs unzips the info files and then attempts to install directly
+# we are gzipping the info files anyway as part of our pacman install
+sed -e '/^gunzip/d' \
+    -e '/^install-info/d' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-e2fsprogs
+
+
+# metapackages have no source
+sed '/^PACKAGE/d' -i ${JHALFSDIR}/lfs-commands/chapter08/*-{core,core-pacman}*
+
+
+# /usr/bin/wall should be root:tty, this is the only package where a workaround
+# is necessary beyond changing ownership to root:root
+sed "s@chown -R root:root \${pkgdir}@chown -R root:root \${pkgdir}\nchown root:tty \${pkgdir}/usr/bin/wall@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-util-linux
+
+# MarkupSafe -- fix install
+if [ -f ${JHALFSDIR}/lfs-commands/chapter08/*-markupsafe ]; then
+  sed 's@setup\.py install@setup.py install --root=${pkgdir}@' \
+      -i ${JHALFSDIR}/lfs-commands/chapter08/*-markupsafe
+  # fix package name
+  sed -e "s@^pkgname=\"MarkupSafe\"@pkgname=\"markupsafe\"\n_pkgname=\"MarkupSafe\"@" \
+      -e 's@${pkgname}@${_pkgname}@g' \
+      -i ${JHALFSDIR}/lfs-commands/chapter08/*-markupsafe
+fi
+
+# Jinja2 -- fix install
+if [ -f ${JHALFSDIR}/lfs-commands/chapter08/*-jinja2 ]; then
+  sed 's@setup\.py install@setup.py install --root=${pkgdir}@' \
+      -i ${JHALFSDIR}/lfs-commands/chapter08/*-jinja2
+  # fix package name
+  sed -e "s@^pkgname=\"Jinja2\"@pkgname=\"jinja2\"\n_pkgname=\"Jinja2\"@" \
+      -e 's@${pkgname}@${_pkgname}@g' \
+      -i ${JHALFSDIR}/lfs-commands/chapter08/*-jinja2
+fi
+
+
+# systemd - package uses build dir differently
+if [ -f ${JHALFSDIR}/lfs-commands/chapter08/*-systemd ]; then
+  line=$(grep -n "^package()" ${JHALFSDIR}/lfs-commands/chapter08/*-systemd | \
+         cut -d ":" -f 1)
+  line=$(( ${line} + 1))
+  sed "${line}s@pkgver}@pkgver}/build@" \
+      -i ${JHALFSDIR}/lfs-commands/chapter08/*-systemd
+fi
+
+
+# udev
+# package uses build dir differently
+if [ -f ${JHALFSDIR}/lfs-commands/chapter08/*-udev ]; then
+  line=$(grep -n "^package()" ${JHALFSDIR}/lfs-commands/chapter08/*-udev | \
+         cut -d ":" -f 1)
+  line=$(( ${line} + 1))
+  sed "${line}s@pkgver}@pkgver}/build@" \
+      -i ${JHALFSDIR}/lfs-commands/chapter08/*-udev
+  # misses a ${pkgdir} because of brace
+  sed '/^install -vdm755 {/s@{/usr@${pkgdir}/{/usr@' \
+      -i ${JHALFSDIR}/lfs-commands/chapter08/*-udev
+  # need to create /usr/share/pkgconfig
+  sed "/^install -vm644 src\/u/s@^install@install -vdm755 \${pkgdir}/usr/share/pkgconfig\ninstall@" \
+      -i ${JHALFSDIR}/lfs-commands/chapter08/*-udev
+fi
+
+
+# lfs-bootscripts needs a real md5sum
+file=`basename $(grep "lfs-bootscripts" ${JHALFSDIR}/urls.list | cut -d " " -f 1)`
+md5sum=`md5sum $BUILDDIR/sources/${file} | cut -d " " -f 1`
+sed "s@BOOTSCRIPTS-MD5SUM@${md5sum}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter09/*-bootscripts
+unset file md5sum
+
+
+# kernel -- FIXME - get the name of the file to here....
+md5sum=`md5sum ${1} | cut -d " " -f 1`
+kconfig=`basename "${1}"`
+## DEBUG
+echo "CONFIG is ${1}, md5sum is ${md5sum}, kconfig is ${kconfig}"
+sed -e "s@^cat > PKGDIR@cp \${BUILDDIR}/sources/${kconfig} .\ncat > PKGDIR@" \
+    -e "s@^source=(@source=('${kconfig}'\n        @" \
+    -e "s@^md5sums=(@md5sums=('${md5sum}'\n         @" \
+    -e "s@../${kconfig}@\${srcdir}/${kconfig}@" \
+    -i  ${JHALFSDIR}/lfs-commands/chapter10/*-kernel
+unset md5sum kconfig
+# Dont' strip the kernel
+sed "s@^groups=@options=('!strip')\ngroups=@" \
+    -i  ${JHALFSDIR}/lfs-commands/chapter10/*-kernel
+
+
+echo "done"
+
+#### WARNING
+echo -en "\n\nWARNING!\n\n"
+echo "While the installed packages created here should be identical to more"
+echo "traditional packages created elsewhere with the same commands from the"
+echo "LFS book, there are many instructions, especially in the package()"
+echo "fucntions, that could be streamlined. For instance, creating an entire"
+echo "directory tree in DESTDIR is unnecessary. This is a function of modifying"
+echo "the instructions in the LFS book, which are intended to be used when"
+echo "installing directly to the target, to use DESTDIR style installations"
+echo "in an automated way. Additonally, if you've used optimizations for the"
+echo "initial build, you'll want to remove those and the use the packaing"
+echo "tool's method to introduce global optimizations and override on an"
+echo "as needed basis. Finally, if you used the 'continue on test failures'"
+echo "option, you should remove the '|| true' in the check function, and adjust"
+echo -e "for specific, known failures.\n"
+
+echo "It is expected that you modify the resultant PKGBUILD files to elminiate"
+echo "these extraneous commands, and use more PM specific commands as you"
+echo "maintain the system through package upgrades and ongoing system"
+echo -e "maintenance.\n"
+
diff --git a/pkgmngt/packFixScripts.sh.rpm b/pkgmngt/packFixScripts.sh.rpm
new file mode 100644
index 0000000..b7e71c4
--- /dev/null
+++ b/pkgmngt/packFixScripts.sh.rpm
@@ -0,0 +1,699 @@
+#!/bin/bash
+
+#### Create dependencies
+echo -n "Extracting dependency list..."
+xsltproc --nonet -o ${JHALFSDIR}/dependencies.list \
+         ${JHALFSDIR}/dependencies.xsl ${JHALFSDIR}/prbook.xml
+# Some Fixups:
+# Remove the xml header
+sed '/xml version/d' -i ${JHALFSDIR}/dependencies.list
+# Get rid of all lines containing "None"
+sed '/None/d' -i ${JHALFSDIR}/dependencies.list
+# No checkdepends for "No test suite"
+sed '/No test/d' -i ${JHALFSDIR}/dependencies.list
+# Make everything lowercase
+sed -e 's/\(.*\)/\L\1/' -i ${JHALFSDIR}/dependencies.list
+# Fix a minor wrinkle with ulink space normalization
+sed -e 's/, and/, and /' \
+    -e '/[a-z]and[a-z]/s/and/ and /' -i ${JHALFSDIR}/dependencies.list
+# "and" is unnecessary, but we have multiple variants in English
+sed '/[a-z], and/s/ and / /' -i ${JHALFSDIR}/dependencies.list
+sed 's/ and /, /' -i ${JHALFSDIR}/dependencies.list
+# Additional issue with ulink space normalization
+sed -e '/[a-z],[a-z]/s/,/, /g' -e 's/  / /g' -i ${JHALFSDIR}/dependencies.list
+# Hypenate packages with sapces in them
+sed 's/berkeley db/berkeley-db/' -i ${JHALFSDIR}/dependencies.list
+sed 's/linux api headers/linux-api-headers/' -i ${JHALFSDIR}/dependencies.list
+# Replace :: in perl package names with hyphen
+sed 's/::/-/g' -i ${JHALFSDIR}/dependencies.list
+sed 's@,@@g' -i ${JHALFSDIR}/dependencies.list
+# Remove trailing '.' characters
+sed 's@\.@@g' -i ${JHALFSDIR}/dependencies.list
+echo "done"
+
+
+
+#### Extracting urls and md5sums
+echo -n "Extracting URLs and MD5Sums list..."
+xsltproc --nonet --stringparam pkgmngt "y" \
+         --output ${JHALFSDIR}/urls.list   \
+         ${JHALFSDIR}/urls.xsl ${JHALFSDIR}/prbook.xml
+echo "done"
+
+
+
+#### Convert scripts to output spec files
+
+# Generic command and header for .spec files
+header=`mktemp`
+cat > ${header} << "EOF"
+cat > %PKGNAME%.spec << "REALEOF"
+Packager: Linux From Scratch <lfs-dev@linuxfromscratch.org>
+Name:
+Version:
+Release: 1
+Summary:
+License:
+Group: base
+BuildRequires:
+Requires:
+Suggests:
+SourceX:
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "<lfs-dev@linuxfromscrtach.org>"
+%define postinsttasks ""
+
+%description
+
+# filetriggers - only need ldconfig and install-info in LFS packages
+%transfiletriggerin -- /usr/lib /usr/lib64
+test -x /usr/sbin/ldconfig &&
+/usr/sbin/ldconfig
+
+%transfiletriggerpostun -- /usr/lib /usr/lib64
+test -x /usr/sbin/ldconfig &&
+/usr/sbin/ldconfig
+
+%filetriggerin -- /usr/share/info
+test -x /usr/bin/install-info &&
+rm -f /usr/share/info/dir &&
+for file in /usr/share/info/*.info*; do
+  /usr/bin/install-info ${file} /usr/share/info/dir
+done
+
+%filetriggerpostun -- /usr/share/info
+test -x /usr/bin/install-info &&
+rm -f /usr/share/info/dir &&
+for file in /usr/share/info/*.info*; do
+  /usr/bin/install-info ${file} /usr/share/info/dir
+done
+
+EOF
+
+# Generic command and header for .spec files
+filescl=`mktemp`
+cat > ${filescl} << "EOF"
+
+#### Generic addition to %install for all specs
+# Remove libtool archives
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF
+
+echo -e "\nProcessing .spec files (this may take a while):"
+sleep 3
+# For each file, several changes need to be made and need to be done in order
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  echo -n "Processing ${file}..."
+
+  # Skip pkgmgt, stripping, and revisedchroot and 8??-?? files
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep -q "pkgmgt" &&
+       echo "skip" && continue;
+  echo "${scriptfile}" | grep -q "stripping" &&
+       echo "skip" && continue;
+  echo "${scriptfile}" | grep -q "revisedchroot" &&
+       echo "skip" && continue;
+  echo "${scriptfile}" | grep -q "8[0-9][0-9]-[0-9][0-9]" &&
+       echo "skip" && continue;
+
+  # The glibc package is a bit of a mess, so normalize it (ugly)...
+  if $(echo "${scriptfile}" | grep -q "glibc"); then
+    #Note: These break if anybody messes with the directory creation in
+    #      LFS/lfs.xsl
+    sed '/^mkdir -pv $PKG_DEST\/{/,+13d' -i ${file}
+    sed '/^for dir in/,+20d' -i ${file}
+    sed '0,/^PREV_SEC/s//PREVSEC/' -i ${file}
+    sed '/^PREV_SEC/,+3d' -i ${file}
+    sed 's/^PREVSEC/PREV_SEC/' -i ${file}
+    sed "s@^ln -sfv@PREV_SEC=\${SECONDS}\npackInstall\nSECONDS=\${PREV_SEC}\nrm -rf \$PKG_DEST\nln -sfv@" \
+        -i ${file}
+    # The glibc package no longer uses jhalfs's DESTDIR pre-populate and prune
+    sed "s@^touch@mkdir -pv \$PKG_DEST/etc\ntouch@" -i ${file}
+  fi
+
+  # adding in the non-wide ncurses also creates some issues
+  if $(echo "${scriptfile}" | grep -q "ncurses"); then
+    if $(grep -q "^make distclean" ${file}); then
+      start=`grep -n "^make distclean" ${file} | cut -d ":" -f 1`
+      stop=`grep -n "^cp -av lib/lib" ${file} | cut -d ":" -f 1`
+      # cp -v -R doc/* $PKG_DEST/usr/share/doc/ncurses-6.2
+      nwtempfile=`mktemp`
+      sed -n "${start},${stop}p" ${file} > ${nwtempfile}
+      sed "${start},${stop}d" -i ${file}
+      sed "s@^for dir in@FIXME\nfor dir in@" -i ${file}
+      sed "/^FIXME/e cat ${nwtempfile}" -i ${file}
+      sed 's@^FIXME@EOF@' -i ${file}
+      rm -f ${nwtempfile}
+      unset start stop nwtempfile
+    fi
+  fi
+  unset scriptfile
+
+  # 1.  Don't untar the package, create the source direcotry, reuse $PKG_DEST
+  sed -e "s@^tar -xf \$PACKAGE@rm -rf \$PKG_DEST\ninstall -d  \$PKG_DEST@" \
+      -i ${file}
+
+  # 2.  Remove "# remap=make" comments as configure and make are combined
+  #     into %build in spec files
+  count=`grep -c "^# remap=configure" ${file}`
+  if test "${count}" != "0"; then
+    sed '/^# remap=make/d' -i ${file}
+  else
+    sed 's@^# remap=make@# remap=configure@' -i ${file}
+  fi
+
+  # 3.  Insert cat > commands and generic spec headers at
+  #     "# Start of LFS book script"
+  sed "/# Start of LFS book script/e cat ${header}" -i ${file}
+  sed -e '/^# Start of LFS book script/d' -i ${file}
+
+  # 4.  End the dump to spec - ugly but better than ranges at this point
+  sed -e '0,/^PREV_SEC/s@PREV_SEC@PREVSEC@' -i ${file}
+  sed -e "/^PREV_SEC/s@^PREV_SEC@REALEOF\nPREV_SEC@" -i ${file}
+  sed 's@^PREVSEC@PREV_SEC@' -i ${file}
+
+  # 5.  Remove any duplicate "# remap={pre,configure,test,install}"
+  sed '0,/^# remap=pre/s@^# remap=pre@# remap=apre@' -i ${file}
+  sed '/^# remap=pre/d' -i ${file}
+  sed 's@^# remap=apre@# remap=pre@' -i ${file}
+  sed '0,/^# remap=conf/s@^# remap=conf@# remap=aconf@' -i ${file}
+  sed '/^# remap=conf/d' -i ${file}
+  sed 's@^# remap=aconf@# remap=conf@' -i ${file}
+  sed '0,/^# remap=test/s@^# remap=test@# remap=atest@' -i ${file}
+  sed '/^# remap=test/d' -i ${file}
+  sed 's@^# remap=atest@# remap=test@' -i ${file}
+  sed '0,/^# remap=install/s@^# remap=install@# remap=ainstall@' -i ${file}
+  sed '/^# remap=install/d' -i ${file}
+  sed 's@^# remap=ainstall@# remap=install@' -i ${file}
+
+  # 6.  Insert the command blocks
+  sed "s@^# remap=pre@\n%prep\n%setup -n %{name}-%{version}@" -i ${file}
+  sed "s@^# remap=configure@\n%build@" -i ${file}
+  sed "s@^# remap=test@\n%check@" -i ${file}
+  sed "s@^# remap=install@\n%install@" -i ${file}
+  # now end the file
+  sed "/^REALEOF/e cat ${filescl}" -i ${file}
+
+
+  # 7.  Create the %post instrucitons (only glibc needs this in LFS)
+  grep "####POSTINST####" $file >/dev/null 2>&1
+  if test "$?" -eq "0"; then
+    start=`grep -n "####POSTINST####" ${file} | cut -d ":" -f 1`
+    stop=`grep -n "####ENDPOSTINST####" ${file} | cut -d ":" -f 1`
+    version=`grep "^VERSION=" ${file} | cut -d "=" -f 2 | sed 's@"@@g'`
+    package=`grep "^PACKAGE=" ${file} | cut -d "=" -f 2 | sed 's@"@@g'`
+    package=`echo ${package} | sed "s@-${version}.*@@"`
+    post_install=`sed -n "$((${start} + 1)),$(( ${stop} - 1))p" ${file}`
+    tempfile=`mktemp`
+    echo -e "\n%post\n${post_install}\n\n" > ${tempfile}
+    sed "/^REALEOF/e cat ${tempfile}" -i ${file}
+    sed "${start},${stop}d" -i ${file}
+    rm ${tempfile}
+    unset version pacakge post_install tempfile
+  fi
+
+  # 8.  We won't use $PKGDIR, just reuse $PKG_DEST
+  sed 's@^cd $PKGDIR@cd $PKG_DEST@' -i ${file}
+  sed '/^rm -rf $PKGDIR/d' -i ${file}
+  sed '/^if \[ -d "${PKGDIR/d' -i ${file}
+
+  # 9.  Account for packages that use an alternate build dir
+  count=`grep -c "%prep" ${file}`
+  if test ${count} -gt 0; then
+    start=`grep -n "%prep" ${file} | head -n1 | cut -d ":" -f 1`
+    stoplist=`grep -n "^$" ${file} | cut -d ":" -f 1`
+    for stop in $stoplist; do
+       if test $stop -gt $start; then
+         break;
+       fi
+    done
+    prepare=`sed -n "$((${start} + 1)),$(( ${stop} - 1))p" ${file}`
+    echo ${prepare} | grep -q "mkdir.*build"
+    if test "${?}" == "0"; then
+      sed -e '/^%build/a cd build' -i ${file}
+      sed -e '/^%check/a cd build' -i ${file}
+      sed -e '/^%install/a cd build' -i ${file}
+      sed -e '/^%files/s@files\.@build/files.@' -i ${file}
+    fi
+  fi
+  unset count start stop stoplist prepare
+
+  # 10. Remove instances of ">> $TEST_LOG " - rpm has its own logging
+  sed 's@>> $TEST_LOG @@' -i ${file}
+
+  # 11. Populate Description, Name, Summary and Version values
+  version=`grep "^VERSION" ${file} | cut -d "=" -f 2 | sed 's@"@@g'`
+  package=`grep "^PACKAGE" ${file} | cut -d "=" -f 2 | sed 's@"@@g'`
+  pkgname=`echo ${package} | sed "s@${version}.*@@" | sed 's@"@@g'`
+  echo ${pkgname} | grep -q ".*-$" && \
+       pkgname=`echo ${pkgname} | sed 's@-$@@'` || true
+  sed "s@^Name:@Name: ${pkgname}@" -i ${file}
+  sed "s@^Version:@Version: ${version}@" -i ${file}
+  sed "s@^Summary:@Summary: ${pkgname} ${version}@" -i ${file}
+  # Same for %description
+  sed "/%description/a ${pkgname} ${version}" -i $file
+  # Set spec filename
+  sed "s@%PKGNAME%@${pkgname}@" -i ${file}
+  unset version package
+
+  # 12. Use %{buildroot} instead of $PKG_DEST in %install
+  if test "$(grep "^%install" $file)" != ""; then
+    start=`grep -n "^%install" ${file} | head -n1 | cut -d ":" -f 1`
+    stoplist=`grep -n "^#### Generic" ${file} | cut -d ":" -f 1`
+      for stop in $stoplist; do
+        if test $stop -gt $start; then
+          break;
+        fi
+      done
+    sed -e "${start},${stop} {s@\$PKG_DEST@%{buildroot}@g}" -i ${file}
+  fi
+  unset start stop stoplist
+
+  # 13. Use Source1 instead of tar relative paths
+  # LFS doesn't use more than one extra source file
+  sed -e '/^tar/s@\.\./@../../SOURCES/@' \
+      -e '/^tar/s@\.\./SOURCES/\.\./@../../SOURCES/@' -i ${file}
+
+  # 14. Use "%patchX -p1" instead of patch -Np1 -i ../patch
+  patchlines=`grep -n "^patch" ${file} | cut -d ":" -f 1`
+  if test "${patchlines}x" != "x"; then
+    count=0
+    for line in ${patchlines}; do
+      sed "${line}s@^.*@%patch${count} -p1@" -i ${file}
+      let count++
+    done
+  fi
+  unset patchlines count
+
+  # 15. Don't remove PKG_DEST before cd'ing out of it and pass the spec file
+  sed "s@^packInstall@packInstall ${pkgname}.spec\ncd \$SRC_DIR@" -i ${file}
+
+  # 16. If there isn't a prep stage, add one
+  grep -q "^%prep" ${file} || for block in build check install; do
+    grep -q "^%${block}" ${file} && sed "s@^%${block}@%prep\n%setup -n %{name}-%{version}\n\n%${block}@" -i ${file} && break;
+  done
+
+  # 17. We don't untar, and we are done with $PREV_SEC, so don't juggle time
+  sed '/PREV_SEC/d' -i ${file}
+
+  echo "done"
+done
+
+rm -f ${tempfile}
+unset tempfile file pkgname
+
+# We still need to do these few for the chapter-08 addtions
+for file in ${JHALFSDIR}/lfs-commands/chapter08/8[0-9][0-9]-[0-9][0-9]-* ; do
+  pkgname=`grep -m1 "^Name:" ${file} | cut -d " " -f 2`
+  sed "s@^packInstall@packInstall ${pkgname}.spec@" -i ${file}
+  sed -e "s@^tar -xf \$PACKAGE@rm -rf \$PKG_DEST\ninstall -d \$PKG_DEST@" \
+      -i ${file}
+  sed 's@^cd $PKGDIR@cd $PKG_DEST@' -i ${file}
+  sed '/^rm -rf $PKGDIR/d' -i ${file}
+  sed '/^if \[ -d "${PKGDIR/d' -i ${file}
+done
+
+unset file
+echo "done"
+
+
+
+#### Add license info
+echo -n "Processing License values..."
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  # Skip pkgmgt, stripping, and revisedchroot
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep "pkgmgt" > /dev/null && continue;
+  echo "${scriptfile}" | grep "stripping" > /dev/null && continue;
+  echo "${scriptfile}" | grep "revisedchroot" > /dev/null && continue;
+  unset scriptfile
+
+  pkgname=`grep "^Name: " ${file} | sed 's@Name: @@'`
+  if test "${pkgname}"x != "x"; then
+    license=`grep "^${pkgname}=" ${JHALFSDIR}/licenses.list | \
+              cut -d "=" -f 2 | sed 's@"@@g'`
+    if test "${license}x" == "x"; then
+      continue;
+    else
+      sed "s@^License:@License: ${license}@" -i ${file}
+    fi
+  fi
+done
+unset file license
+echo "done"
+
+
+#### Add dependency info
+echo -n "Processing BuildRequires, Requires, and Suggests values..."
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  # Skip pkgmgt, stripping, revisedchroot, and PM packages
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep -q "pkgmgt" && continue;
+  echo "${scriptfile}" | grep -q "stripping" && continue;
+  echo "${scriptfile}" | grep -q "revisedchroot" && continue;
+  echo "${scriptfile}" | grep -q "8[0-9][0-9]-[0-9][0-9]" && continue;
+  unset scriptfile
+
+  pkgname=`grep "^Name:" ${file} | sed 's@Name: @@'`
+  if test "${pkgname}"x != "x"; then
+    depends=`grep "^${pkgname}-rundeps" ${JHALFSDIR}/dependencies.list`
+    makedeps=`grep "^${pkgname}-depends" ${JHALFSDIR}/dependencies.list`
+    checkdeps=`grep "^${pkgname}-testdeps" ${JHALFSDIR}/dependencies.list`
+    optdeps=`grep "^${pkgname}-optdeps" ${JHALFSDIR}/dependencies.list`
+  fi
+  # Requires:
+  depends=`echo ${depends} | cut -d "=" -f 2 | sed 's@"@@g' | sed 's@,@@g'`
+  sed "s@^Requires:@Requires: rootfs ${depends}@" -i ${file}
+  # BuildRequires: (includes checkdeps for rpm)
+  if test "${makedeps}x" != "x"; then
+    makedeps=`echo "${makedeps}" | cut -d "=" -f 2 | sed 's@"@@g' | sed 's@,@@g'`
+    checkdeps=`echo "${checkdeps}" | cut -d "=" -f 2 | sed 's@"@@g' | sed 's@,@@g'`
+    makedeps="${makedeps} ${checkdeps}"
+    sed "s@^BuildRequires:@BuildRequires: ${makedeps}@" -i ${file}
+  else
+    sed '/^BuildRequires:/d' -i ${file}
+  fi
+  # Suggests:
+  if test "${optdeps}x" != "x"; then
+    optdeps=`echo "${optdeps}" | cut -d "=" -f 2 | sed 's@"@@g' | sed 's@,@@g'`
+    sed "s@^Suggests:@Suggests: ${optdeps}@" -i ${file}
+  else
+    sed '/^Suggests:/d' -i ${file}
+  fi
+done
+unset file pkgname depends makedeps checkdeps optdeps
+echo "done"
+
+
+#### Add source files
+echo -n "Processing Source values..."
+for file in \
+  ${JHALFSDIR}/lfs-commands/chapter{08/*,09/*-bootscripts,10/*-kernel}; do
+
+  # Skip pkgmgt, stripping, revisedchroot, and PM packages
+  scriptfile=`basename ${file}`
+  echo "${scriptfile}" | grep -q "pkgmgt" && continue;
+  echo "${scriptfile}" | grep -q "stripping" && continue;
+  echo "${scriptfile}" | grep -q "revisedchroot" && continue;
+  echo "${scriptfile}" | grep -q "8[0-9][0-9]-[0-9][0-9]" && continue;
+  unset scriptfile
+
+  pkgname=`grep "^Name:" ${file} | sed 's@Name: @@'`
+  if test "${pkgname}"x != "x"; then
+    tempfile=`mktemp`
+    tempfile2=`mktemp`
+    tempfile3=`mktemp`
+    tempfile4=`mktemp`
+    # expect and tcl are special cases
+    if test "${pkgname}" == "tcl" -o "${pkgname}" == "expect"; then
+      grep "/${pkgname}/" ${JHALFSDIR}/urls.list > ${tempfile}
+    else
+      grep "${pkgname}-" ${JHALFSDIR}/urls.list > ${tempfile}
+    fi
+    # libelf is a special case
+    if test "${pkgname}" == "libelf"; then
+      grep "elfutils" ${JHALFSDIR}/urls.list > ${tempfile}
+    fi
+    # Special case for glibc
+    if test "${pkgname}" == "glibc"; then
+      grep "tzdata" ${JHALFSDIR}/urls.list >> ${tempfile}
+    fi
+    # Special case for linux
+    if test "${pkgname}" == "linux"; then
+      sed -e '/util-linux/d' -e '/libcap/d' -i ${tempfile}
+    fi
+    # Special case for Python
+    if test "${pkgname}" == "Python"; then
+      grep "Python-" ${JHALFSDIR}/urls.list > ${tempfile}
+      grep "python.*docs-html" ${JHALFSDIR}/urls.list >> ${tempfile}
+    fi
+    # Special case for make -- it pulls in automake
+    if test "${pkgname}" == "make"; then
+      sed '/automake/d' -i ${tempfile}
+    fi
+    # Sepcial case for eudev
+    if test "${pkgname}" == "eudev"; then
+      grep "udev-lfs" ${JHALFSDIR}/urls.list >> ${tempfile}
+    fi
+    cut -d " " -f 1 ${tempfile} > ${tempfile2}
+    scount=0
+    pcount=0
+    for dl in `cat ${tempfile2}`; do
+      echo ${dl} | grep -q "\.patch"
+      if test ${?} == 0; then
+        echo "Patch${pcount}: $( basename ${dl})" >> ${tempfile4}
+        let pcount++
+      else
+        echo "Source${scount}: $(basename ${dl})" >> ${tempfile3}
+        let scount++
+      fi
+    done
+    if test "${scount}" != "0"; then
+      sed "/^SourceX:/e cat ${tempfile3}" -i ${file}
+    fi
+    if test "${pcount}" != "0"; then
+      sed "/^SourceX:/e cat ${tempfile4}" -i ${file}
+    fi
+    sed '/^SourceX:/d' -i ${file}
+    rm -f ${tempfile} ${tempfile2} ${tempfile3} ${tempfile4}
+    unset tempfile tempfile2 tempfile3 tempfile4 pkgname scount pcount dl
+  fi
+done
+unset file
+echo "done"
+
+
+#### Package specific fixes
+
+echo -n "Applying package specific fixes..."
+
+# Special cases for chapter08 glibc
+# Don't strip
+sed -e "s@%description@%define __os_install_post %{?__brp_compress} %{nil}\n\n%description@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+# It should install to %{buildroot}, but not try to use %{buildroot}/dev/null
+# Also use the just built zic
+sed "s@ZONEINFO=@# Note: you may want to separate zoneinfo from glibc\nZONEINFO=%{buildroot}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+sed 's@$PKG_DEST/dev/null@/dev/null@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+sed 's@zic @%{buildroot}/usr/sbin/zic @g' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+# Don't overwrite ld.so.c{ache,onf}
+sed "s@^#### Generic@# Included in rootfs\nrm -f %{buildroot}/etc/ld.so.{conf,cache}\nrm -rf %{buildroot}/root\n\n#### Generic@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+sed '/^cat > \/etc\/ld.so.conf/,+5 d' \
+   -i ${JHALFSDIR}/lfs-commands/chapter08/*-glibc
+
+
+# Special cases for GCC
+# don't strip
+sed -e "s@%description@%define __os_install_post %{?__brp_compress} %{nil}\n\n%description@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-gcc
+# needs /usr/lib/bfd-plugins
+sed "s@^mkdir -pv %{buildroot}/{boot,etc}@mkdir -pv %{buildroot}/usr/lib/bfd-plugins\nmkdir -pv %{buildroot}/{boot,etc}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-gcc
+
+
+# binutils
+# Don't strip
+sed -e "s@%description@%define __os_install_post %{?__brp_compress} %{nil}\n\n%description@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-binutils
+#skip the expect -c check
+sed '/^expect -c "spawn ls"/d' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-binutils
+
+# GMP - make it build for uname -m, not cpu generation
+sed "s@./configure@cp -v config{fsf,}.guess\ncp -v config{fsf,}.sub\n./configure@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-gmp
+
+
+# Shadow in chapter08 will already have /usr/bin/passwd
+sed '/^touch \/usr\/bin\/passwd/d' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-shadow
+# Also, the useradd command is not yet present so do it the other way
+sed "s@^useradd -D --gid 999@install -vdm755 %{buildroot}/etc/default\necho \"GROUPS=999\" >> %{buildroot}/etc/default/useradd@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-shadow
+
+
+# libelf - change name
+sed -e "s@Name: elfutils@Name: libelf@" \
+    -e "s@elfutils @libelf @g" \
+    -e "s@elfutils\.spec@libelf.spec@g" \
+    -e "/^%setup/s@%{name}@elfutils@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-libelf
+
+# xml-parser - change name
+sed -e "s@Name: XML-Parser@Name: xml-parser@" \
+    -e "s@XML-Parser @xml-parser @g" \
+    -e "s@XML-Parser\.spec@xml-parser.spec@g" \
+    -e "/^%setup/s@%{name}@XML-Parser@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-xml-parser
+
+# Python in LFS chapter08 should not install ensurepip - it was installed in
+# chapter07 and pip and setuptools will be reinstalled in chapter08 sepearately
+sed '/ensurepip/s/yes/no /' -i ${JHALFSDIR}/lfs-commands/chapter08/*-Python
+# python change pkgname to lower case
+sed -e "s@Name: Python@Name: python@" \
+    -e "s@Python @python @g" \
+    -e "s@Python\.spec@python.spec@g" \
+    -e "/^%setup/s@%{name}@Python@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-Python
+
+
+# rootfs is a special case too...no source file
+sed -e '/^PKGDIR/d' \
+    -e '/^tar -xf $PACKAGE/d' \
+    -e '/^cd $PKGDIR/d' \
+    -i ${JHALFSDIR}/lfs-commands/chapter07/*-rootfs
+
+
+# tcl needs a bit of help getting the pkgname and pkgver correct
+origpkgname=`grep "^Name:" ${JHALFSDIR}/lfs-commands/chapter08/*-tcl | \
+             cut -d " " -f 2`
+pkgname="tcl"
+pkgver=`echo "${origpkgname}" | sed "s@${pkgname}@@"`
+sed "/^Name:/s@${pkgname}${pkgver}@${pkgname}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-tcl
+sed "/^Version:/s@src@${pkgver}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-tcl
+sed "/^Summary:/s@${origpkgname} src@${pkgname} ${pkgver}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-tcl
+sed "/\.spec/s@${origpkgname}@${pkgname}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-tcl
+# tcl also has a weird extract directory and a subdir build
+file="${JHALFSDIR}/lfs-commands/chapter08/*-tcl"
+sed '/^%setup/s@%{name}-%{version}@%{name}%{version}@' -i ${file}
+sed "s@^%check@%check\ncd unix@" -i ${file}
+sed "s@^%install@%install\ncd unix@" -i ${file}
+sed -e '/^%files/s@files\.@unix/files.@' -i ${file}
+unset file origpkgname pkgname pkgver
+
+
+# expect also has a weird tarball name
+origpkgname=`grep "^Version:" ${JHALFSDIR}/lfs-commands/chapter08/*-expect | \
+             cut -d " " -f 2`
+pkgname="expect"
+pkgver=`echo "${origpkgname}" | sed "s@${pkgname}@@"`
+sed "s@^Name: ${origpkgname}@Name: ${pkgname}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-expect
+sed "s@^Version: ${pkgname}${pkgver}@Version: ${pkgver}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-expect
+sed "s@^Summary: ${origpkgname}@Summary: ${pkgname} ${pkgver}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-expect
+sed "s@${pkgname}-${pkgver}@${pkgname}${pkgver}@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-expect
+sed '/^%setup/s@%{name}-%{version}@%{name}%{version}@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-expect
+
+# ncurses - again, fix installation of non-wide libraries
+#           won't hurt anything if missing
+sed '/^cp -av lib\/lib/s@ /usr/lib@ %{buildroot}/usr/lib@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-ncurses
+sed 's@^EOF@@' -i ${JHALFSDIR}/lfs-commands/chapter08/*-ncurses
+# Also, fix a potential race condition when building non-wide ncurses
+sed 's@^make sources@make -j1 sources@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-ncurses
+
+
+# Python has a multiline tar command that wasn't fixed earlier
+sed -e '/\.\.\/python-.*-docs-html/s@\.\.@../../SOURCES@' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-Python
+
+
+# procps-ng extracts to procps-${pkgver}
+sed -e "/^%setup/s@%{name}@procps@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-procps-ng
+
+
+# e2fsprogs unzips the info files and attempts to install with install-info
+# don't update info's dir, this will be done after the fact
+sed -e '/^install-info/d' \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-e2fsprogs
+
+# libxml2's testsuite leaves an extra file around
+sed -e "s@ install@ install\nrm -f %{buildroot}/missing.xml@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter08/*-libxml2
+
+# metapackages have no source
+sed '/^PKGDIR/d' -i ${JHALFSDIR}/lfs-commands/chapter08/*-{base,base-rpm}*
+
+
+# kernel -- FIXME - get the name of the file to here....
+sed -e "/cp -v ..\/kernel-config/d" \
+    -e "s@make mrproper@make mrproper\ncp /sources/kernel-config .config@" \
+    -i  ${JHALFSDIR}/lfs-commands/chapter10/*-kernel
+# run depmod when modules are installed
+tempfile=`mktemp`
+cat > ${tempfile} << "EOF"
+%transfiletriggerin -- /usr/lib/modules
+test -x /usr/sbin/depmod &&
+/usr/sbin/depmod %{version}
+
+%transfiletriggerpostun -- /usr/lib/modules
+test -x /usr/sbin/depmod &&
+/usr/sbin/ldconfig %{version}
+
+EOF
+sed "/^%description/e cat ${tempfile}" \
+    -i ${JHALFSDIR}/lfs-commands/chapter10/*-kernel
+rm -f "${tempfile}"
+unset tempfile
+# Don't strip the kernel
+sed -e "s@%description@%define __os_install_post %{?__brp_compress} %{nil}\n\n%description@" \
+    -i ${JHALFSDIR}/lfs-commands/chapter10/*-kernel
+unset md5sum
+
+echo "done"
+
+#### WARNING
+echo -en "\n\nWARNING!\n\n"
+echo "While the installed packages created here should be identical to more"
+echo "traditional packages created elsewhere with the same commands from the"
+echo "LFS book, there are many instructions, especially in the %install"
+echo "block, that could be streamlined. For instance, creating an entire"
+echo "directory tree in DESTDIR is unnecessary. This is a function of modifying"
+echo "the instructions in the LFS book, which are intended to be used when"
+echo "installing directly to the target, to use DESTDIR style installations"
+echo "in an automated way. Additonally, if you've used optimizations for the"
+echo "initial build, you'll want to remove those and the use the packaing"
+echo "tool's method to introduce global optimizations and override on an"
+echo "as needed basis. Finally, if you used the 'continue on test failures'"
+echo "option, you should remove the '|| true' in the %check block, and adjust"
+echo -e "for specific, known failures.\n"
+
+echo "It is expected that you modify the resultant spec files to elminiate"
+echo "these extraneous commands, and use more PM specific commands as you"
+echo "maintain the system through package upgrades and ongoing system"
+echo -e "maintenance.\n"
+
diff --git a/pkgmngt/packInstall.sh.pacman b/pkgmngt/packInstall.sh.pacman
index 00d036c..408b71e 100644
--- a/pkgmngt/packInstall.sh.pacman
+++ b/pkgmngt/packInstall.sh.pacman
@@ -4,59 +4,30 @@
 # Other variables can be passed on the command line, or in the environment
 
 packInstall() {
+  # Get the name, version, release, and arch of the package
+  pkgname=$(grep "^pkgname" PKGBUILD | cut -d "=" -f 2 | sed 's@"@@g')
+  pkgver=$(grep "^pkgver" PKGBUILD | cut -d "=" -f 2 | sed 's@"@@g')
+  pkgrel=$(grep "^pkgrel" PKGBUILD | cut -d "=" -f 2 | sed 's@"@@g')
+  arch=$(grep "^arch" PKGBUILD | cut -d "=" -f 2 | sed 's@"@@g' | \
+                                                   sed "s@'@@g" | \
+                                                   sed "s@(@@g" | \
+                                                   sed "s@)@@g")
 
-# A proposed implementation for versions and package names.
-local PCKGVRS=$(basename $PKGDIR)
-local TGTPKG=$(basename $PKG_DEST)
-local PACKAGE=$(echo ${TGTPKG} | sed 's/^[0-9]\{3,4\}-//' |
-           sed 's/^[0-9]\{2\}-//')
-# version is only accessible from PKGDIR name. Since the format of the
-# name is not normalized, several hacks are necessary...
-case $PCKGVRS in
-  expect*|tcl*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*//') ;;
-  unzip*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*\([0-9]\)\([0-9]\)/\1.\2/') ;;
-  docbook-xml) local VERSION=4.5 ;;
-  *) local VERSION=$(echo ${PCKGVRS} | sed 's/^.*[-_]\([0-9]\)/\1/' |
-                   sed 's/_/./g');;
-# the last sed above is because some package managers do not want a '_'
-# in version.
-esac
-case $(uname -m) in
-  x86_64) local ARCH=x86_64 ;;
-  *) local ARCH=i686 ;;
-esac
-local ARCHIVE_NAME=${PACKAGE}-${VERSION}-1-${ARCH}.pkg.tar.gz
+  # Save the source files
+  mkdir -p /srv/pacman/source/LFS/${pkgname}
+  cp * /srv/pacman/source/LFS/${pkgname}/
 
-pushd $PKG_DEST
-rm -fv ./usr/share/info/dir  # recommended since this directory is already there
-                             # on the system
-# Right now, we have the files in the current directory. They should be moved
-# to /sources/$PACKAGE/src.
-mkdir -p ../$PACKAGE/src
-# We'll build as user builder. We need this directory to be owned by that user.
-chown -R builder ../$PACKAGE
-mv * ../$PACKAGE/src
-chown -R builder $PKG_DEST
-chmod -R o+r ../$PACKAGE
+  # Now build the thing
+  su pacman -c "LANG=en_US.UTF-8 /usr/bin/makepkg -L --nodeps"
 
-cat > PKGBUILD <<EOF
-pkgname=( '$PACKAGE' )
-pkgver=$VERSION
-pkgrel=1
-pkgdesc=$PACKAGE
-arch=( '$ARCH' )
+  # Add it to the local repo
+  repo-add \
+    /srv/pacman/repos/LFS/LFS.db.tar.xz \
+    /srv/pacman/repos/LFS/${pkgname}-${pkgver}-${pkgrel}-${arch}.pkg.tar.xz
 
-package() {
-cp -a * \$pkgdir
-}
-EOF
-# Building the binary package
-su builder -c"PATH=$PATH; makepkg -c --skipinteg" || true
-# Installing it on LFS
-if ! pacman -U --noconfirm /var/lib/packages/$ARCHIVE_NAME; then
-     pacman -U --noconfirm --overwrite '*' /var/lib/packages/$ARCHIVE_NAME
-fi
-popd                         # Since the $PKG_DEST directory is destroyed
-                             # immediately after the return of the function,
-                             # getting back to $PKGDIR is important...
+  # Sync with the repo
+  pacman -Syu
+
+  # Finally, install from the local repo
+  pacman -S ${pkgname} --nodeps --overwrite "*" --noconfirm -dd
 }
diff --git a/pkgmngt/packInstall.sh.rpm b/pkgmngt/packInstall.sh.rpm
new file mode 100644
index 0000000..d89ce9c
--- /dev/null
+++ b/pkgmngt/packInstall.sh.rpm
@@ -0,0 +1,64 @@
+# $Id$
+# function for packing and installing a tree. We only have access
+# to variables PKGDIR and PKG_DEST
+# Other variables can be passed on the command line, or in the environment
+
+packInstall() {
+  # Get the name, version, release, and arch of the package
+  name=$(grep -m1 "^Name:" $1 | sed 's@Name: @@')
+  version=$(grep -m1 "^Version:" $1 | sed 's@Version: @@')
+  release=$(grep -m1 "^Release:" $1 | sed 's@Release: @@')
+  arch=$(uname -m)
+
+  # Move spec files into root's rpmbuild dir
+  mkdir -p /root/rpmbuild/SPECS
+  echo "Copying ${name}.spec to /root/rpmbuild/SPECS"
+  cp ${name}.spec /root/rpmbuild/SPECS
+  
+
+  # copy sources (rather than download again) into root's rpmbuild dir
+  mkdir -p /root/rpmbuild/SOURCES
+  for file in $(grep "^Source" "${1}" | cut -d ":" -f 2); do
+    filename=$(echo "${file}" | sed 's@ @@g')
+    echo "Copying /sources/${filename} to /root/rpmbuild/SOURCES"
+    cp "/sources/${filename}" /root/rpmbuild/SOURCES
+  done
+
+  # same thing for patches
+  mkdir -p /root/rpmbuild/SOURCES
+  for file in $(grep "^Patch" "${1}" | cut -d ":" -f 2); do
+    filename=$(echo "${file}" | sed 's@ @@g')
+    echo "Copying /sources/${filename} to /root/rpmbuild/SOURCES"
+    cp "/sources/${filename}" /root/rpmbuild/SOURCES
+  done
+
+  # Now build the thing
+  rpmbuild -ba --nodeps /root/rpmbuild/SPECS/${name}.spec
+
+  # Because files may already exist in the filesystem, just update the database
+  rpm --install --nodeps --justdb \
+      /root/rpmbuild/RPMS/${arch}/${name}-${version}-${release}.${arch}.rpm
+
+  # Finally, do the actual installation with replacepkgs
+  rpm --install --nodeps --replacepkgs \
+      /root/rpmbuild/RPMS/${arch}/${name}-${version}-${release}.${arch}.rpm
+
+  # Clean up the build and install directories
+  case ${name} in
+    xml-parser)
+      rm -rf /root/rpmbuild/BUILD/XML-Parser-*
+      rm -rf /root/rpmbuild/BUILDROOT/${name}*
+    ;;
+    libelf)
+      rm -rf /root/rpmbuild/BUILD/elfutils-*
+      rm -rf /root/rpmbuild/BUILDROOT/${name}*
+    ;;
+    linux-api-headers)
+      rm -rf /root/rpmbuild/BUILD/linux-*
+      rm -rf /root/rpmbuild/BUILDROOT/${name}*
+    ;;
+    *)
+      rm -rf /root/rpmbuild/BUILD{,ROOT}/${name}*
+    ;;
+  esac
+}
diff --git a/pkgmngt/packageManager.xml.pacman b/pkgmngt/packageManager.xml.pacman
index aa4e9ce..16cb844 100644
--- a/pkgmngt/packageManager.xml.pacman
+++ b/pkgmngt/packageManager.xml.pacman
@@ -9,18 +9,94 @@ book if you prefer. That slightly changes the aspect if you render
 it in html -->
 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY libarchive-version "3.4.3">
-<!ENTITY curl-version       "7.71.1">
-<!ENTITY fakeroot-version   "1.24">
-<!ENTITY pacman-version     "5.2.2">
-<!ENTITY libarchive-url "https://github.com/libarchive/libarchive/releases/download/v&libarchive-version;/libarchive-&libarchive-version;.tar.xz">
-<!ENTITY curl-url       "https://curl.haxx.se/download/curl-&curl-version;.tar.xz">
-<!ENTITY fakeroot-url   "http://deb.debian.org/debian/pool/main/f/fakeroot/fakeroot_&fakeroot-version;.orig.tar.gz">
-<!ENTITY pacman-url     "https://sources.archlinux.org/other/pacman/pacman-&pacman-version;.tar.gz">
-<!ENTITY curl-md5       "b54b386057846ce3edd3584b19741569">
-<!ENTITY libarchive-md5 "4b216ea3015ecf8ae555a2026f9a6b73">
-<!ENTITY fakeroot-md5   "964e5f438f1951e5a515dd54edd50fa6">
-<!ENTITY pacman-md5     "3a9b078a83996a3272844807b91959c6">
+<!ENTITY curl-version         "7.78.0">
+<!ENTITY fakeroot-version     "1.25.3">
+<!ENTITY gnupg-version        "2.2.29">
+<!ENTITY gpgme-version        "1.16.0">
+<!ENTITY libarchive-version   "3.5.1">
+<!ENTITY libassuan-version    "2.5.5">
+<!ENTITY libgpg-error-version "1.42">
+<!ENTITY libgcrypt-version    "1.9.4">
+<!ENTITY libksba-version      "1.6.0">
+<!ENTITY libtasn1-version     "4.17.0">
+<!ENTITY libxml2-version      "2.9.12">
+<!ENTITY libxml2-testsuite-version "20130923">
+<!ENTITY make-ca-version      "1.8.1">
+<!ENTITY nettle-version       "3.7.3">
+<!ENTITY npth-version         "1.6">
+<!ENTITY p11-kit-version      "0.24.0">
+<!ENTITY pacman-version       "6.0.1">
+<!ENTITY pacman-contrib-version "1.4.0">
+<!ENTITY pacman-hooks-version "20210910">
+<!ENTITY pip-version          "21.1.3">
+<!ENTITY pth-version          "2.0.7">
+<!ENTITY setuptools-version   "56.0.0">
+<!ENTITY sqlite-version       "3.36.0">
+<!ENTITY sqlite-short-version "3360000">
+<!ENTITY unzip-version        "6.0">
+<!ENTITY curl-url           "https://curl.haxx.se/download/curl-&curl-version;.tar.xz">
+<!ENTITY fakeroot-url       "http://deb.debian.org/debian/pool/main/f/fakeroot/fakeroot_&fakeroot-version;.orig.tar.gz">
+<!ENTITY fakeroot-patch "fakeroot-&fakeroot-version;-glibc_fixes-1.patch">
+<!ENTITY fakeroot-patch-url "https://www.linuxfromscratch.org/~dj/&fakeroot-patch;">
+<!ENTITY fakeroot-chroot-patch "fakeroot-&fakeroot-version;-glibc_fixes-no_autoconf-1.patch">
+<!ENTITY fakeroot-chroot-patch-url "https://www.linuxfromscratch.org/~dj/&fakeroot-chroot-patch;">
+<!ENTITY gnupg-url          "https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-&gnupg-version;.tar.bz2">
+<!ENTITY gpgme-url          "https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-&gpgme-version;.tar.bz2">
+<!ENTITY libarchive-url     "https://github.com/libarchive/libarchive/releases/download/&libarchive-version;/libarchive-&libarchive-version;.tar.xz">
+<!ENTITY libassuan-url      "https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-&libassuan-version;.tar.bz2">
+<!ENTITY libgpg-error-url   "https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-&libgpg-error-version;.tar.bz2">
+<!ENTITY libgcrypt-url      "https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-&libgcrypt-version;.tar.bz2">
+<!ENTITY libksba-url        "https://www.gnupg.org/ftp/gcrypt/libksba/libksba-&libksba-version;.tar.bz2">
+<!ENTITY libtasn1-url       "https://ftp.gnu.org/gnu/libtasn1/libtasn1-&libtasn1-version;.tar.gz">
+<!ENTITY libxml2-url        "http://xmlsoft.org/sources/libxml2-&libxml2-version;.tar.gz">
+<!ENTITY libxml2-testsuite  "xmlts&libxml2-testsuite-version;.tar.gz">
+<!ENTITY libxml2-testsuite-url "https://www.w3.org/XML/Test/&libxml2-testsuite;">
+<!ENTITY make-ca-url        "https://github.com/djlucas/make-ca/releases/download/v&make-ca-version;/make-ca-&make-ca-version;.tar.xz">
+<!ENTITY nettle-url         "https://ftp.gnu.org/gnu/nettle/nettle-&nettle-version;.tar.gz">
+<!ENTITY npth-url           "https://www.gnupg.org/ftp/gcrypt/npth/npth-&npth-version;.tar.bz2">
+<!ENTITY p11-kit-url        "https://github.com/p11-glue/p11-kit/releases/download/0.24.0/p11-kit-0.24.0.tar.xz">
+<!ENTITY pacman-url         "https://sources.archlinux.org/other/pacman/pacman-&pacman-version;.tar.xz">
+<!ENTITY pacman-contrib-url "https://gitlab.archlinux.org/pacman/pacman-contrib/-/archive/v&pacman-contrib-version;/pacman-contrib-v&pacman-contrib-version;.tar.gz">
+<!ENTITY pip-url            "https://files.pythonhosted.org/packages/4d/0c/3b63fe024414a8a48661cf04f0993d4b2b8ef92daed45636474c018cd5b7/pip-&pip-version;.tar.gz">
+<!ENTITY pth-url            "https://ftp.gnu.org/gnu/pth/pth-&pth-version;.tar.gz">
+<!ENTITY setuptools-url     "https://files.pythonhosted.org/packages/f6/e9/19af16328705915233299f6f1f02db95899fb00c75ac9da4757aa1e5d1de/setuptools-&setuptools-version;.tar.gz">
+<!ENTITY sqlite-url         "https://sqlite.org/2021/sqlite-autoconf-&sqlite-short-version;.tar.gz">
+<!ENTITY sqlite-doc-url     "https://sqlite.org/2021/sqlite-doc-&sqlite-short-version;.zip">
+<!ENTITY unzip-url          "https://downloads.sourceforge.net/infozip/unzip60.tar.gz">
+<!ENTITY pacman-contrib-patch "pacman-contrib-&pacman-contrib-version;-fix_pacman6_no_autoconf-1.patch">
+<!ENTITY pacman-contrib-patch-url "https://www.linuxfromscratch.org/~dj/&pacman-contrib-patch;">
+<!ENTITY pacman-hooks-url   "https://linuxfromscratch.org/~dj/pacman-hooks-&pacman-hooks-version;.tar.xz">
+<!ENTITY unzip-patch        "unzip-6.0-consolidated_fixes-1.patch">
+<!ENTITY unzip-patch-url    "https://www.linuxfromscratch.org/patches/blfs/svn/&unzip-patch;">
+<!ENTITY curl-md5           "419c2461366cf404160a820f7a902b7e">
+<!ENTITY fakeroot-md5       "f6104ef6960c962377ef062bf222a1d2">
+<!ENTITY fakeroot-patch-md5 "9f7bf30389d8012752f3dce80feaa382">
+<!ENTITY fakeroot-chroot-patch-md5 "c1a4573bfed039c84a81159880922a86">
+<!ENTITY gnupg-md5          "5db3334b528cf756b1e583db01319a24">
+<!ENTITY gpgme-md5          "e31b9e0efc5a2e1ec1bbed22e7a082a4">
+<!ENTITY libarchive-md5     "2ba9f1f8c169aa9caf8e2d34dde323be">
+<!ENTITY libassuan-md5      "7194453152bb67e3d45da698762b5d6f">
+<!ENTITY libgpg-error-md5   "133fed221ba8f63f5842858a1ff67cb3">
+<!ENTITY libgcrypt-md5      "edc7becfe09c75d8f95ff7623e40c52e">
+<!ENTITY libksba-md5        "d333b2e1381068d4f9a328240f062f0f">
+<!ENTITY libtasn1-md5       "c46f6eb3bd1287031ae5d36465094402">
+<!ENTITY libxml2-md5        "f433a39be087a9f0b197eb2307ad9f75">
+<!ENTITY libxml2-testsuite-md5 "ef8fbe0c92efd9a60d7f320e211d10b2">
+<!ENTITY make-ca-md5        "957c39206ba0e9139807c5a47535747f">
+<!ENTITY nettle-md5         "a60273d0fab9c808646fcf5e9edc2e8f">
+<!ENTITY npth-md5           "375d1a15ad969f32d25f1a7630929854">
+<!ENTITY p11-kit-md5        "8ccf11c4a2e2e505b8e516d8549e64a5">
+<!ENTITY pacman-md5         "f71e6f06867749735960d0c1d199d375">
+<!ENTITY pacman-contrib-md5 "98bfa108b24e35b100100588392103ae">
+<!ENTITY pacman-contrib-patch-md5 "f8033bfd8ae8e8c72ca12d5e5955bb95">
+<!ENTITY pacman-hooks-md5   "721fd08ae68cae1a0f0f849436c51145">
+<!ENTITY pip-md5            "e459d41a10ce33688b5d389216a8876f">
+<!ENTITY pth-md5            "9cb4a25331a4c4db866a31cbe507c793">
+<!ENTITY setuptools-md5     "d9715b19a0d894539285655fd5c69109">
+<!ENTITY sqlite-md5         "f5752052fc5b8e1b539af86a3671eac7">
+<!ENTITY sqlite-doc-md5     "9abe65c7295fd0a2462f7c61f95400fd">
+<!ENTITY unzip-md5          "62b490407489521db863b523a7f86375">
+<!ENTITY unzip-patch-md5    "14c119ef7019f769497363e5cec306e0">
 <!ENTITY % general-entities SYSTEM "BOOK/general.ent">
 %general-entities;
 ]>
@@ -41,402 +117,405 @@ Do not change  anything, except the url and the md5 checksum. -->
         <para>MD5 sum: <literal>&curl-md5;</literal></para>
         <para>Download: <ulink url="&fakeroot-url;"/></para>
         <para>MD5 sum: <literal>&fakeroot-md5;</literal></para>
+        <para>Download: <ulink url="&gnupg-url;"/></para>
+        <para>MD5 sum: <literal>&gnupg-md5;</literal></para>
+        <para>Download: <ulink url="&gpgme-url;"/></para>
+        <para>MD5 sum: <literal>&gpgme-md5;</literal></para>
         <para>Download: <ulink url="&libarchive-url;"/></para>
         <para>MD5 sum: <literal>&libarchive-md5;</literal></para>
+        <para>Download: <ulink url="&libassuan-url;"/></para>
+        <para>MD5 sum: <literal>&libassuan-md5;</literal></para>
+        <para>Download: <ulink url="&libgcrypt-url;"/></para>
+        <para>MD5 sum: <literal>&libgcrypt-md5;</literal></para>
+        <para>Download: <ulink url="&libgpg-error-url;"/></para>
+        <para>MD5 sum: <literal>&libgpg-error-md5;</literal></para>
+        <para>Download: <ulink url="&libksba-url;"/></para>
+        <para>MD5 sum: <literal>&libksba-md5;</literal></para>
+        <para>Download: <ulink url="&libtasn1-url;"/></para>
+        <para>MD5 sum: <literal>&libtasn1-md5;</literal></para>
+        <para>Download: <ulink url="&libxml2-url;"/></para>
+        <para>MD5 sum: <literal>&libxml2-md5;</literal></para>
+        <para>Download: <ulink url="&libxml2-testsuite-url;"/></para>
+        <para>MD5 sum: <literal>&libxml2-testsuite-md5;</literal></para>
+        <para>Download: <ulink url="&make-ca-url;"/></para>
+        <para>MD5 sum: <literal>&make-ca-md5;</literal></para>
+        <para>Download: <ulink url="&nettle-url;"/></para>
+        <para>MD5 sum: <literal>&nettle-md5;</literal></para>
+        <para>Download: <ulink url="&npth-url;"/></para>
+        <para>MD5 sum: <literal>&npth-md5;</literal></para>
+        <para>Download: <ulink url="&p11-kit-url;"/></para>
+        <para>MD5 sum: <literal>&p11-kit-md5;</literal></para>
         <para>Download: <ulink url="&pacman-url;"/></para>
         <para>MD5 sum: <literal>&pacman-md5;</literal></para>
+        <para>Download: <ulink url="&pacman-contrib-url;"/></para>
+        <para>MD5 sum: <literal>&pacman-contrib-md5;</literal></para>
+        <para>Download: <ulink url="&pacman-hooks-url;"/></para>
+        <para>MD5 sum: <literal>&pacman-hooks-md5;</literal></para>
+        <para>Download: <ulink url="&pip-url;"/></para>
+        <para>MD5 sum: <literal>&pip-md5;</literal></para>
+        <para>Download: <ulink url="&pth-url;"/></para>
+        <para>MD5 sum: <literal>&pth-md5;</literal></para>
+        <para>Download: <ulink url="&setuptools-url;"/></para>
+        <para>MD5 sum: <literal>&setuptools-md5;</literal></para>
+        <para>Download: <ulink url="&sqlite-url;"/></para>
+        <para>MD5 sum: <literal>&sqlite-md5;</literal></para>
+        <para>Download: <ulink url="&sqlite-doc-url;"/></para>
+        <para>MD5 sum: <literal>&sqlite-doc-md5;</literal></para>
+        <para>Download: <ulink url="&unzip-url;"/></para>
+        <para>MD5 sum: <literal>&unzip-md5;</literal></para>
 </sect1>
 
-<!-- If needed, uncomment and edit this:
 <sect1 id="patches">
-        <para>Download: <ulink url="somepatch-url"/></para>
-        <para>MD5 sum: <literal>somepatch-md5</literal></para>
+        <para>Download: <ulink url="&fakeroot-patch-url;"/></para>
+        <para>MD5 sum: <literal>&fakeroot-patch-md5;</literal></para>
+        <para>Download: <ulink url="&fakeroot-chroot-patch-url;"/></para>
+        <para>MD5 sum: <literal>&fakeroot-chroot-patch-md5;</literal></para>
+        <para>Download: <ulink url="&pacman-contrib-patch-url;"/></para>
+        <para>MD5 sum: <literal>&pacman-contrib-patch-md5;</literal></para>
+        <para>Download: <ulink url="&unzip-patch-url;"/></para>
+        <para>MD5 sum: <literal>&unzip-patch-md5;</literal></para>
 </sect1>
--->
 
-<!-- Do not change the next line. The name of the scriptlet will be taken
-from the dbhtml instruction: it is the name of the file less .html, with
-xxx-x-added before (x, digits).-->
-<sect1 id="ch-tools-libarchive" role="wrap">
-  <?dbhtml filename="libarchive.html"?>
+<!-- Removed ch-tools as newer book is required anyway -->
+
+<!-- version for new book: needs ninja and meson, which needs
+     Python rebuilt with libffi and zlib. Needs also pkg-config -->
+<sect1 id="ch-chroot-bzip2" role="wrap">
+  <?dbhtml filename="bzip2.html"?>
 
   <sect1info condition="script">
-    <productname>libarchive</productname>
-    <productnumber>&libarchive-version;</productnumber>
-    <address>&libarchive-url;</address>
+    <productname>bzip2</productname>
+    <productnumber>&bzip2-version;</productnumber>
+    <address>&bzip2-url;</address>
   </sect1info>
 
-  <title>Libarchive-&libarchive-version;</title>
+  <title>Bzip2-&bzip2-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/tools \
-            --without-bz2lib \
-            --without-xml2   \
-            --enable-bsdtar=static \
-            --enable-bsdcpio=static</userinput></screen>
-<screen><userinput remap="make">make</userinput></screen>
-<screen><userinput remap="install">make install</userinput></screen>
+<screen><userinput remap="pre">patch -Np1 -i ../bzip2-1.0.8-install_docs-1.patch
+sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
+sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile</userinput></screen>
+<screen><userinput remap="make">make -f Makefile-libbz2_so
+make clean
+make</userinput></screen>
+<screen><userinput remap="install">make PREFIX=/usr install
+cp -av libbz2.so.* /usr/lib
+cp -v bzip2-shared /usr/bin/bzip2
+rm -fv /usr/lib/libbz2.a
+ln -sv libbz2.so.1.0.8 /usr/lib/libbz2.so</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-tools-openssl" role="wrap">
-  <?dbhtml filename="openssl.html"?>
+<sect1 id="ch-chroot-libgpg-error" role="wrap">
+  <?dbhtml filename="libgpg-error.html"?>
 
   <sect1info condition="script">
-    <productname>openssl</productname>
-    <productnumber>&openssl-version;</productnumber>
-    <address>&openssl-url;</address>
+    <productname>libgpg-error</productname>
+    <productnumber>&libgpg-error-version;</productnumber>
+    <address>&libgpg-error-url;</address>
   </sect1info>
 
-  <title>openssl-&openssl-version;</title>
+  <title>libgpg-error-&libgpg-error-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./config --prefix=/tools            \
-         --openssldir=/tools/etc/ssl \
-         --libdir=lib</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
 <screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-tools-curl" role="wrap">
-  <?dbhtml filename="curl.html"?>
+<sect1 id="ch-chroot-libassuan" role="wrap">
+  <?dbhtml filename="libassuan.html"?>
 
   <sect1info condition="script">
-    <productname>curl</productname>
-    <productnumber>&curl-version;</productnumber>
-    <address>&curl-url;</address>
+    <productname>libassuan</productname>
+    <productnumber>&libassuan-version;</productnumber>
+    <address>&libassuan-url;</address>
   </sect1info>
 
-  <title>Curl-&curl-version;</title>
+  <title>libassuan-&libassuan-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/tools \
-            --disable-static</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
 <screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-tools-libcap" role="wrap">
-  <?dbhtml filename="libcap.html"?>
-
-  <sect1info condition="script">
-    <productname>libcap</productname>
-    <productnumber>&libcap-version;</productnumber>
-    <address>&libcap-url;</address>
-  </sect1info>
-
-  <title>libcap-&libcap-version;</title>
-
-  <sect2 role="installation">
-    <title/>
-<screen><userinput remap="make">make lib=lib prefix=/tools GOLANG=no PAM_CAP=no</userinput></screen>
-<screen><userinput remap="install">make lib=lib prefix=/tools GOLANG=no PAM_CAP=no install</userinput></screen>
-  </sect2>
-
-</sect1>
-
-<sect1 id="ch-tools-fakeroot" role="wrap">
-  <?dbhtml filename="fakeroot.html"?>
+<sect1 id="ch-chroot-pth" role="wrap">
+  <?dbhtml filename="pth.html"?>
 
   <sect1info condition="script">
-    <productname>fakeroot</productname>
-    <productnumber>&fakeroot-version;</productnumber>
-    <address>&fakeroot-url;</address>
+    <productname>pth</productname>
+    <productnumber>&pth-version;</productnumber>
+    <address>&pth-url;</address>
   </sect1info>
 
-  <title>fakeroot-&fakeroot-version;</title>
+  <title>pth-&pth-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen>
+<screen><userinput remap="pre">sed -i 's#$(LOBJS): Makefile#$(LOBJS): pth_p.h Makefile#' Makefile.in</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr \
+           --mandir=/usr/share/man</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
 <screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-tools-pkgmngt" role="wrap">
-  <?dbhtml filename="pacman.html"?>
+<sect1 id="ch-chroot-libgcrypt" role="wrap">
+  <?dbhtml filename="libgcrypt.html"?>
 
   <sect1info condition="script">
-    <productname>pacman</productname>
-    <productnumber>&pacman-version;</productnumber>
-    <address>&pacman-url;</address>
+    <productname>libgcrypt</productname>
+    <productnumber>&libgcrypt-version;</productnumber>
+    <address>&libgcrypt-url;</address>
   </sect1info>
 
-  <title>Pacman-&pacman-version;</title>
+  <title>libgcrypt-&libgcrypt-version;</title>
 
   <sect2 role="installation">
     <title/>
-<!-- You can use any number of remap="pre", "configure", "make", "test", "install"
-<screen><userinput remap="something">Instructions</userinput></screen>.
-They are executed in that order. "pre" can be used for patching for example.
-In case testing is enabled, the instructions flagged test are logged to a different
-file (test-log). If testing is not enabled, they are not executed at all. Do not
-put line breaks before and after your instructions. <userinput> without
-remap attribute are considered configuration instructions and executed last. You
-can also use remap="adjust" for the same purpose. -->
-<screen><userinput remap="configure">mkdir build
-cd build
-meson --prefix=/tools                        \
-      --sysconfdir=/tools/etc                \
-      --localstatedir=/tools/var             \
-      -Dcrypto=openssl                       \
-      -Ddoc=disabled                         \
-      -Dgpgme=disabled                       \
-      -Dpkg_config_path=/tools/lib/pkgconfig</userinput></screen>
-
-<screen><userinput remap="make">ninja</userinput></screen>
-
-<screen><userinput remap="install">ninja install</userinput></screen>
-
-<screen><userinput>sed -e 's@/usr@/tools@g' \
-    -e 's/\([^!]\)strip/\1!strip/' \
-    -e 's/\([^!]\)libtool/\1!libtool/' \
-    -e 's/\([^!]\)zipman/\1!zipman/' \
-    -i /tools/etc/makepkg.conf
-cat &gt;&gt; /tools/etc/makepkg.conf &lt;&lt; EOF
-BUILDDIR=/sources
-PKGDEST=/var/lib/packages
-PACKAGER="Pierre Labastie &lt;lnimbus@club-internet.fr&gt;"
-EOF
-cat &gt;&gt; /tools/etc/pacman.conf &lt;&lt; EOF
-DBPath   = /var/lib/pacman/
-CacheDir = /var/cache/pacman/pkg/
-LogFile  = /var/log/pacman.log
-SigLevel = Never
-# Repository: do not add one now: repo-add needs openssl.
-EOF</userinput></screen>
-
+<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<!-- version for new book: needs ninja and meson, which needs
-     Python rebuilt with libffi and zlib. Needs also pkg-config -->
-<sect1 id="ch-chroot-libarchive" role="wrap">
-  <?dbhtml filename="libarchive.html"?>
+<sect1 id="ch-chroot-libksba" role="wrap">
+  <?dbhtml filename="libksba.html"?>
 
   <sect1info condition="script">
-    <productname>libarchive</productname>
-    <productnumber>&libarchive-version;</productnumber>
-    <address>&libarchive-url;</address>
+    <productname>libksba</productname>
+    <productnumber>&libksba-version;</productnumber>
+    <address>&libksba-url;</address>
   </sect1info>
 
-  <title>Libarchive-&libarchive-version;</title>
+  <title>libksba-&libksba-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/usr \
-            --without-bz2lib \
-            --without-xml2   \
-            --enable-bsdtar=static \
-            --enable-bsdcpio=static</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
 <screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-openssl" role="wrap">
-  <?dbhtml filename="openssl.html"?>
+<sect1 id="ch-chroot-libtasn1" role="wrap">
+  <?dbhtml filename="libtasn1.html"?>
 
   <sect1info condition="script">
-    <productname>openssl</productname>
-    <productnumber>&openssl-version;</productnumber>
-    <address>&openssl-url;</address>
+    <productname>libtasn1</productname>
+    <productnumber>&libtasn1-version;</productnumber>
+    <address>&libtasn1-url;</address>
   </sect1info>
 
-  <title>openssl-&openssl-version;</title>
+  <title>libtasn1-&libtasn1-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">
-./config --prefix=/usr         \
-         --openssldir=/etc/ssl \
-         --libdir=lib          \
-         shared</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr --disable-static</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
 <screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-curl" role="wrap">
-  <?dbhtml filename="curl.html"?>
+<sect1 id="ch-chroot-libffi" role="wrap">
+  <?dbhtml filename="libffi.html"?>
 
   <sect1info condition="script">
-    <productname>curl</productname>
-    <productnumber>&curl-version;</productnumber>
-    <address>&curl-url;</address>
+    <productname>libffi</productname>
+    <productnumber>&libffi-version;</productnumber>
+    <address>&libffi-url;</address>
   </sect1info>
 
-  <title>Curl-&curl-version;</title>
+  <title>libffi-&libffi-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/usr \
-            --disable-static</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr --disable-static --with-gcc-arch=native</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
 <screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-libcap" role="wrap">
-  <?dbhtml filename="libcap.html"?>
+<sect1 id="ch-chroot-zlib" role="wrap">
+  <?dbhtml filename="zlib.html"?>
 
   <sect1info condition="script">
-    <productname>libcap</productname>
-    <productnumber>&libcap-version;</productnumber>
-    <address>&libcap-url;</address>
+    <productname>zlib</productname>
+    <productnumber>&zlib-version;</productnumber>
+    <address>&zlib-url;</address>
   </sect1info>
 
-  <title>libcap-&libcap-version;</title>
+  <title>zlib-&zlib-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="pre">sed -i '/install.*STACAPLIBNAME/d' libcap/Makefile</userinput></screen>
-<screen><userinput remap="make">make lib=lib</userinput></screen>
-<screen><userinput remap="install">make lib=lib PKGCONFIGDIR=/usr/lib/pkgconfig install
-chmod -v 755 /lib/libcap.so.&libcap-version;
-mv -v /lib/libpsx.a /usr/lib
-rm -v /lib/libcap.so
-ln -sfv ../../lib/libcap.so.2 /usr/lib/libcap.so</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install
+rm -fv /usr/lib/libz.a</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-fakeroot" role="wrap">
-  <?dbhtml filename="fakeroot.html"?>
+<sect1 id="ch-chroot-openssl" role="wrap">
+  <?dbhtml filename="openssl.html"?>
 
   <sect1info condition="script">
-    <productname>fakeroot</productname>
-    <productnumber>&fakeroot-version;</productnumber>
-    <address>&fakeroot-url;</address>
+    <productname>openssl</productname>
+    <productnumber>&openssl-version;</productnumber>
+    <address>&openssl-url;</address>
   </sect1info>
 
-  <title>fakeroot-&fakeroot-version;</title>
+  <title>openssl-&openssl-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="configure">./config --prefix=/usr         \
+         --openssldir=/etc/ssl \
+         --libdir=lib          \
+         shared                \
+         zlib-dynamic</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
-<screen><userinput remap="install">make install</userinput></screen>
+<screen><userinput remap="install">sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
+make MANSUFFIX=ssl install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-zlib" role="wrap">
-  <?dbhtml filename="zlib.html"?>
+<sect1 id="ch-chroot-sqlite" role="wrap">
+  <?dbhtml filename="sqlite.html"?>
 
   <sect1info condition="script">
-    <productname>zlib</productname>
-    <productnumber>&zlib-version;</productnumber>
-    <address>&zlib-url;</address>
+    <productname>sqlite</productname>
+    <productnumber>&sqlite-short-version;</productnumber>
+    <address>&sqlite-url;</address>
   </sect1info>
 
-  <title>zlib-&zlib-version;</title>
+  <title>sqlite-&sqlite-short-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr     \
+            --disable-static  \
+            --enable-fts5     \
+            CPPFLAGS="-DSQLITE_ENABLE_FTS3=1  \
+            -DSQLITE_ENABLE_FTS4=1            \
+            -DSQLITE_ENABLE_COLUMN_METADATA=1 \
+            -DSQLITE_ENABLE_UNLOCK_NOTIFY=1   \
+            -DSQLITE_ENABLE_DBSTAT_VTAB=1     \
+            -DSQLITE_SECURE_DELETE=1          \
+            -DSQLITE_ENABLE_FTS3_TOKENIZER=1"</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
-<screen><userinput remap="install">make install
-mv -v /usr/lib/libz.so.* /lib
-ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-libffi" role="wrap">
-  <?dbhtml filename="libffi.html"?>
+<sect1 id="ch-chroot-gmp" role="wrap">
+  <?dbhtml filename="gmp.html"?>
 
   <sect1info condition="script">
-    <productname>libffi</productname>
-    <productnumber>&libffi-version;</productnumber>
-    <address>&libffi-url;</address>
+    <productname>gmp</productname>
+    <productnumber>&gmp-version;</productnumber>
+    <address>&gmp-url;</address>
   </sect1info>
 
-  <title>libffi-&libffi-version;</title>
+  <title>gmp-&gmp-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/usr --disable-static --with-gcc-arch=native</userinput></screen>
+<screen><userinput remap="pre">cp -v configfsf.guess config.guess
+cp -v configfsf.sub   config.sub</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --enable-cxx     \
+            --disable-static \
+            --docdir=/usr/share/doc/gmp-6.2.1</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
 <screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-python" role="wrap">
-  <?dbhtml filename="Python-pass2.html"?>
+<sect1 id="ch-chroot-nettle" role="wrap">
+  <?dbhtml filename="nettle.html"?>
 
   <sect1info condition="script">
-    <productname>Python</productname>
-    <productnumber>&python-version;</productnumber>
-    <address>&python-url;</address>
+    <productname>nettle</productname>
+    <productnumber>&nettle-version;</productnumber>
+    <address>&nettle-url;</address>
   </sect1info>
 
-  <title>Python-&python-version;</title>
+  <title>nettle-&nettle-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/usr --without-ensurepip --enable-shared</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr --disable-static</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
-<screen><userinput remap="install">make install</userinput></screen>
+<screen><userinput remap="install">make install
+chmod -v 755 /usr/lib/lib{hogweed,nettle}.so</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-ninja" role="wrap">
-  <?dbhtml filename="ninja.html"?>
+<sect1 id="ch-chroot-libarchive" role="wrap">
+  <?dbhtml filename="libarchive.html"?>
 
   <sect1info condition="script">
-    <productname>ninja</productname>
-    <productnumber>&ninja-version;</productnumber>
-    <address>&ninja-url;</address>
+    <productname>libarchive</productname>
+    <productnumber>&libarchive-version;</productnumber>
+    <address>&libarchive-url;</address>
   </sect1info>
 
-  <title>ninja-&ninja-version;</title>
+  <title>Libarchive-&libarchive-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">python3 configure.py --bootstrap</userinput></screen>
-<screen><userinput remap="install">install -vm755 ninja /usr/bin/</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr \
+            --disable-static</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-meson" role="wrap">
-  <?dbhtml filename="meson.html"?>
+<sect1 id="ch-chroot-expat" role="wrap">
+  <?dbhtml filename="expat.html"?>
 
   <sect1info condition="script">
-    <productname>meson</productname>
-    <productnumber>&meson-version;</productnumber>
-    <address>&meson-url;</address>
+    <productname>expat</productname>
+    <productnumber>&expat-version;</productnumber>
+    <address>&expat-url;</address>
   </sect1info>
 
-  <title>meson-&meson-version;</title>
+  <title>expat-&expat-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="install">cp meson.py /usr/bin/meson
-cp -rv mesonbuild /usr/bin</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --disable-static \
+            --docdir=/usr/share/doc/expat-&expat-version;</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-pkgconfig" role="wrap">
-  <?dbhtml filename="pkgconfig.html"?>
+<sect1 id="ch-chroot-pkg-config" role="wrap">
+  <?dbhtml filename="pkg-config.html"?>
 
   <sect1info condition="script">
     <productname>pkg-config</productname>
@@ -444,7 +523,7 @@ cp -rv mesonbuild /usr/bin</userinput></screen>
     <address>&pkgconfig-url;</address>
   </sect1info>
 
-  <title>pkg-config-&pkgconfig-version;</title>
+  <title>pkgconfig-&pkgconfig-version;</title>
 
   <sect2 role="installation">
     <title/>
@@ -458,164 +537,117 @@ cp -rv mesonbuild /usr/bin</userinput></screen>
 
 </sect1>
 
-<sect1 id="ch-chroot-pkgmngt" role="wrap">
-  <?dbhtml filename="pacman.html"?>
+<sect1 id="ch-chroot-python" role="wrap">
+  <?dbhtml filename="python.html"?>
 
   <sect1info condition="script">
-    <productname>pacman</productname>
-    <productnumber>&pacman-version;</productnumber>
-    <address>&pacman-url;</address>
+    <productname>python</productname>
+    <productnumber>&python-version;</productnumber>
+    <address>&python-url;</address>
   </sect1info>
 
-  <title>Pacman-&pacman-version;</title>
+  <title>Python-&python-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">mkdir build
-cd build
-meson --prefix=/usr                        \
-      -Dcrypto=openssl                     \
-      -Ddoc=disabled                       \
-      -Dgpgme=disabled</userinput></screen>
-
-<screen><userinput remap="make">ninja</userinput></screen>
-
-<screen><userinput remap="install">ninja install</userinput></screen>
-
-<screen><userinput>sed -e 's/\([^!]\)strip/\1!strip/' \
-    -e 's/\([^!]\)libtool/\1!libtool/' \
-    -e 's/\([^!]\)zipman/\1!zipman/' \
-    -i /etc/makepkg.conf
-cat &gt;&gt; /etc/makepkg.conf &lt;&lt; EOF
-BUILDDIR=/sources
-PKGDEST=/var/lib/packages
-PACKAGER="Pierre Labastie &lt;lnimbus@club-internet.fr&gt;"
-EOF
-cat &gt;&gt; /etc/pacman.conf &lt;&lt; EOF
-DBPath   = /var/lib/pacman/
-CacheDir = /var/cache/pacman/pkg/
-LogFile  = /var/log/pacman.log
-SigLevel = Never
-# Repository: do not add one now: repo-add needs openssl.
-EOF</userinput></screen>
-
+<screen><userinput remap="configure">./configure --prefix=/usr        \
+            --enable-shared      \
+            --with-system-expat  \
+            --with-system-ffi    \
+            --with-ensurepip=yes \
+            --enable-optimizations</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-chroot-shadow" role="wrap">
-  <?dbhtml filename="shadow.html"?>
+<sect1 id="ch-chroot-setuptools" role="wrap">
+  <?dbhtml filename="setuptools.html"?>
 
   <sect1info condition="script">
-    <productname>shadow</productname>
-    <productnumber>&shadow-version;</productnumber>
-    <address>&shadow-url;</address>
+    <productname>setuptools</productname>
+    <productnumber>&setuptools-version;</productnumber>
+    <address>&setuptools-url;</address>
   </sect1info>
 
-  <title>shadow-&shadow-version;</title>
+  <title>setuptools-&setuptools-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="pre">sed -i 's/groups$(EXEEXT) //' src/Makefile.in
-find man -name Makefile.in -exec sed -i 's/groups\.1 / /'   {} \;
-find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
-find man -name Makefile.in -exec sed -i 's/passwd\.5 / /'   {} \;
-sed -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD SHA512:' \
-    -e 's:/var/spool/mail:/var/mail:'                 \
-    -i etc/login.defs
-sed -i 's/1000/999/' etc/useradd</userinput></screen>
-<screen><userinput remap="configure">touch /usr/bin/passwd
-./configure --sysconfdir=/etc \
-            --with-group-name-max-length=32</userinput></screen>
-<screen><userinput remap="make">make</userinput></screen>
-<screen><userinput remap="install">make install</userinput></screen>
+<screen><userinput remap="make">python3 setup.py build</userinput></screen>
+<screen><userinput remap="install">python3 setup.py install --optimize=1 --skip-build</userinput></screen>
   </sect2>
 
 </sect1>
 
-<!-- Mandatory section for creating dirs. These instructions are added at the
-end of the creating dirs instructions of the book. Do not change the
-following line -->
-<sect1 id="ch-pkgmngt-creatingdirs">
-
-  <title>Creating Directories</title>
-
-<screen><userinput>mkdir -pv /var/{lib/{packages,pacman},cache/pkg}</userinput></screen>
+<sect1 id="ch-chroot-pip" role="wrap">
+  <?dbhtml filename="pip.html"?>
 
-</sect1>
-<!-- Same for files. Do not change the following line -->
-<sect1 id="ch-pkgmngt-createfiles">
+  <sect1info condition="script">
+    <productname>pip</productname>
+    <productnumber>&pip-version;</productnumber>
+    <address>&pip-url;</address>
+  </sect1info>
 
-  <title>Creating Essential Files</title>
+  <title>pip-&pip-version;</title>
 
-<screen><userinput>if ! grep -q tester /etc/passwd; then
-    echo "builder:x:101:101::/home/builder:/bin/bash" >> /etc/passwd
-    echo "builder:x:101:" >> /etc/group
-    install -o builder -d /home/builder
-else
-    TEST_UID=$(grep tester /etc/passwd | cut -d: -f3)
-    TEST_GID=$(grep tester /etc/group | cut -d: -f3)
-    echo "builder:x:$((TEST_UID+1)):$((TEST_GID+1))::/home/builder:/bin/bash" >> /etc/passwd
-    echo "builder:x:$((TEST_GID+1)):" >> /etc/group
-    install -o builder -d /home/builder
-fi
-chown builder:builder /var/lib/{packages,pacman}</userinput></screen>
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="make">python3 setup.py build</userinput></screen>
+<screen><userinput remap="install">python3 setup.py install --prefix=/usr --optimize=1
+ln -sfv pip3.9 /usr/bin/pip3
+ln -sfv pip3.9 /usr/bin/pip</userinput></screen>
+  </sect2>
 
 </sect1>
-
-<!-- Last but not least : Final instructions for installing the
-package manager at the end of chapter 6. Again, the scriptlet file name is
-taken from the dbhtml instruction, with digits added before and .html cut
-and the tarball name is formed from this name + version. So the file
-here _must_ be the same as in chapter 5. If rendering in html, both
-sets of instructions end up in the same file, which is usually not a problem.
 -->
-<sect1 id="ch-system-libarchive" role="wrap">
-  <?dbhtml filename="libarchive.html"?>
+<sect1 id="ch-chroot-libcap" role="wrap">
+  <?dbhtml filename="libcap.html"?>
 
   <sect1info condition="script">
-    <productname>libarchive</productname>
-    <productnumber>&libarchive-version;</productnumber>
-    <address>&libarchive-url;</address>
+    <productname>libcap</productname>
+    <productnumber>&libcap-version;</productnumber>
+    <address>&libcap-url;</address>
   </sect1info>
 
-  <title>Libarchive-&libarchive-version;</title>
+  <title>libcap-&libcap-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/usr \
-            --disable-static</userinput></screen>
-<screen><userinput remap="make">make</userinput></screen>
-<screen><userinput remap="install">make DESTDIR=$PKG_DEST install</userinput></screen>
+<screen><userinput remap="make">make prefix=/usr lib=lib</userinput></screen>
+<screen><userinput remap="install">make prefix=/usr lib=lib install
+chmod -v 755 /lib/lib{cap,psx}.so.&libcap-version;
+rm -f /usr/lib/lib{cap,psx}.a</userinput></screen>
   </sect2>
 
 </sect1>
-<sect1 id="ch-system-curl" role="wrap">
-  <?dbhtml filename="curl.html"?>
+
+<sect1 id="ch-chroot-coreutils" role="wrap">
+  <?dbhtml filename="coreutils.html"?>
 
   <sect1info condition="script">
-    <productname>curl</productname>
-    <productnumber>&curl-version;</productnumber>
-    <address>&curl-url;</address>
+    <productname>coreutils</productname>
+    <productversion>&coreutils-version;</productversion>
+    <address>&coreutils-url;</address>
   </sect1info>
 
-  <title>Curl-&curl-version;</title>
+  <title>coreutils-&coreutils-version;</title>
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/usr \
-            --disable-static \
-            --enable-threaded-resolver</userinput></screen>
+<screen><userinput remap="configure">FORCE_UNSAFE_CONFIGURE=1 ./configure \
+            --prefix=/usr            \
+            --enable-no-install-program=kill,uptime</userinput></screen>
 <screen><userinput remap="make">make</userinput></screen>
-<screen><userinput remap="install">make DESTDIR=$PKG_DEST install
-find docs \( -name "Makefile*" -o -name "*.1" -o -name "*.3" \) -exec rm {} \;
-install -v -d -m755 $PKG_DEST/usr/share/doc/curl-&curl-version;
-cp -v -R docs/*     $PKG_DEST/usr/share/doc/curl-&curl-version;</userinput></screen>
+<screen><userinput ramap="install">make install
+rm -f /usr/bin/chroot</userinput></screen>
+
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-system-fakeroot" role="wrap">
+<sect1 id="ch-chroot-fakeroot" role="wrap">
   <?dbhtml filename="fakeroot.html"?>
 
   <sect1info condition="script">
@@ -628,14 +660,86 @@ cp -v -R docs/*     $PKG_DEST/usr/share/doc/curl-&curl-version;</userinput></scr
 
   <sect2 role="installation">
     <title/>
-<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
-<screen><userinput remap="make">make</userinput></screen>
-<screen><userinput remap="install">make DESTDIR=$PKG_DEST install</userinput></screen>
+<screen><userinput remap="pre">patch -Np1 -i ../&fakeroot-chroot-patch;
+chmod 755 configure</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr                 \
+            --disable-static</userinput></screen>
+<screen><userinput remap="make">sed '/SUBDIRS/s/doc //' -i Makefile
+make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
   </sect2>
 
 </sect1>
 
-<sect1 id="ch-system-pkgmngt" role="wrap">
+<sect1 id="ch-chroot-ninja" role="wrap">
+  <?dbhtml filename="ninja.html"?>
+
+  <sect1info condition="script">
+    <productname>ninja</productname>
+    <productnumber>&ninja-version;</productnumber>
+    <address>&ninja-url;</address>
+  </sect1info>
+
+  <title>ninja-&ninja-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="pre">sed -i '/int Guess/a \
+  int   j = 0;\
+  char* jobs = getenv( "NINJAJOBS" );\
+  if ( jobs != NULL ) j = atoi( jobs );\
+  if ( j > 0 ) return j;\
+' src/ninja.cc</userinput></screen>
+<screen><userinput remap="configure">python3 configure.py --bootstrap</userinput></screen>
+<screen><userinput remap="install">install -vm755 ninja /usr/bin/</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-meson" role="wrap">
+  <?dbhtml filename="meson.html"?>
+
+  <sect1info condition="script">
+    <productname>meson</productname>
+    <productnumber>&meson-version;</productnumber>
+    <address>&meson-url;</address>
+  </sect1info>
+
+  <title>meson-&meson-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="make">python3 setup.py install --root=dest</userinput></screen>
+<screen><userinput remap="install">cp -rv dest/* /</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-curl" role="wrap">
+  <?dbhtml filename="curl.html"?>
+
+  <sect1info condition="script">
+    <productname>curl</productname>
+    <productnumber>&curl-version;</productnumber>
+    <address>&curl-url;</address>
+  </sect1info>
+
+  <title>Curl-&curl-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">
+./configure --prefix=/usr              \
+            --disable-static           \
+            --enable-threaded-resolver \
+            --with-ca-path=/etc/ssl/certs</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-pacman" role="wrap">
   <?dbhtml filename="pacman.html"?>
 
   <sect1info condition="script">
@@ -646,39 +750,1868 @@ cp -v -R docs/*     $PKG_DEST/usr/share/doc/curl-&curl-version;</userinput></scr
 
   <title>Pacman-&pacman-version;</title>
 
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="pre">tar -xf ../pacman-hooks-&pacman-hooks-version;.tar.xz</userinput></screen>
+
+<screen><userinput remap="configure">meson --prefix=/usr                   \
+      --buildtype=plain               \
+      -Ddoc=disabled                  \
+      -Ddoxygen=disabled              \
+      -Dscriptlet-shell=/usr/bin/bash \
+      -Dldconfig=/usr/bin/ldconfig    \
+      build</userinput></screen>
+
+<screen><userinput remap="make">meson compile -C build</userinput></screen>
+
+
+<screen><userinput remap="install">meson install -C build
+rm -f pacman-hooks-&pacman-hooks-version;/hooks/*systemd*
+rm -f pacman-hooks-&pacman-hooks-version;/hooks/dbus-reload.hook
+rm -f pacman-hooks-&pacman-hooks-version;/scripts/*systemd*
+sed '/^Target/s@/\*@/*.info*@' -i \
+    pacman-hooks-&pacman-hooks-version;/hooks/texinfo-install.hook
+install -vdm755 /usr/share/libalpm/{hooks,scripts}/
+install -vm644  pacman-hooks-&pacman-hooks-version;/hooks/* \
+                /usr/share/libalpm/hooks/
+install -vm755  pacman-hooks-$&pacman-hooks-version;/scripts/* \
+                /usr/share/libalpm/scripts/</userinput></screen>
+
+<screen><userinput>cat &gt;&gt; /etc/makepkg.conf &lt;&lt; "EOF"
+PACKAGER="Linux From Scratch &lt;lfs-dev@lists.linuxfromscrtch.org&gt;"
+PKGDEST="/srv/pacman/repos/LFS"
+SRCDEST="/sources"
+LOGDEST="/srv/pacman/logs/LFS"
+EOF
+
+sed -e /PKGEXT/s/gz/xz/                                \
+    -e /SRCEXT/s/gz/xz/                                \
+    -e /^INTEGRITY/s/ck/md5/                           \
+    -e '/^OPTIONS/s/\([^!]\)emptydirs/\1!emptydirs/'   \
+    -e '/^OPTIONS/s/\([^!]\)libtoo/\1!libtool/'        \
+    -e '/^OPTIONS/s/\([^!]\)staticlibs/\1!staticlibs/' \
+    -i ${pkgdir}/etc/makepkg.conf
+cat &gt;&gt; /etc/pacman.conf &lt;&lt; "EOF"
+
+[LFS]
+# Uncomment after GPGME is installed in the final build
+# SigLevel = Optional TrustAll
+Server = file:///srv/pacman/repos/LFS
+
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-pacman-contrib" role="wrap">
+  <?dbhtml filename="pacman-contrib.html"?>
+
+  <sect1info condition="script">
+    <productname>pacman-contrib</productname>
+    <productnumber>&pacman-contrib-version;</productnumber>
+    <address>&pacman-contrib-url;</address>
+  </sect1info>
+
+  <title>pacman-contrib-&pacman-contrib-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="pre">patch -Np1 -i ../&pacman-contrib-patch;
+chmod 755 configure</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr        \
+            --sysconfdir=/etc    \
+            --localstatedir=/var \
+            --disable-doc</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install
+rm -rf /usr/share/vim</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-shadow" role="wrap">
+  <?dbhtml filename="shadow.html"?>
+
+  <sect1info condition="script">
+    <productname>shadow</productname>
+    <productnumber>&shadow-version;</productnumber>
+    <address>&shadow-url;</address>
+  </sect1info>
+
+  <title>shadow-&shadow-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="pre">sed -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD SHA512:' \
+    -e 's:/var/spool/mail:/var/mail:'                 \
+    -e '/PATH=/{s@/sbin:@@;s@/bin:@@}'                \
+    -i etc/login.defs
+sed -e "224s/rounds/min_rounds/" -i libmisc/salt.c</userinput></screen>
+<screen><userinput remap="configure">touch /usr/bin/passwd
+./configure --sysconfdir=/etc \
+            --with-group-name-max-length=32</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make exec_prefix=/usr install
+mkdir -p /etc/default
+useradd -D --gid 999</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<!-- It is not ideal to do build the next two packages here ( without officially
+     being in chapter08), but it gets the order correct, and we already do this
+     in LFS with the linux-api-headers package, it must be done here as well-->
+
+<sect1 id="ch-chroot-rootfs" role="wrap">
+  <?dbhtml filename="rootfs.html"?>
+
+  <sect1info condition="script">
+    <productname>rootfs</productname>
+    <productnumber>1.0</productnumber>
+    <address>https://www.linuxfromscratch.org/</address>
+  </sect1info>
+
+  <title>rootfs-1.0</title>
+
+  <sect2 role="installation">
+    <title/>
+
+<screen><userinput remap="make"># Not actually part of the package, but this needs to be done now...
+# Delete all man/info pages, documentation, and libtool archives
+rm -rf /usr/share/man/*
+rm -f /usr/share/info/*
+rm -rf /usr/share/doc/*
+find /usr/{lib,libexec} -name \*.la -delete
+
+# Here we create our first pacakge
+# Note: this combines many sections from LFS and configuration files that
+# will be overwritten as jhalfs progresses are marked as config files
+mkdir rootfs
+cd rootfs
+cat &gt; PKGBUILD &lt;&lt; "REALEOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname=rootfs
+pkgver=1.0
+pkgrel=1
+pkgdesc="Skeleton directory layout"
+arch=('any')
+license=('CC-BY-SA-2.0')
+groups=('core')
+backup=('etc/fstab'
+        'etc/group'
+        'etc/hosts'
+        'etc/inputrc'
+        'etc/ld.so.conf'
+        'etc/ld.so.cache'
+        'etc/passwd'
+        'etc/resolv.conf'
+        'etc/shells'
+        'usr/share/info/dir'
+        'var/log/btmp'
+        'var/log/faillog'
+        'var/log/lastlog'
+        'var/log/wtmp')
+# Don't compress /usr/share/info/dir
+options=(!zipman)
+
+package(){
+  # Don't remove /usr/share/info/dir for only this package
+  PURGE_TARGETS=(.packlist *.pod)
+
+  # LFS Section 4.2
+  install -vdm755 ${pkgdir}/{etc,lib64,usr/{bin,lib,sbin},var}
+  for i in bin lib sbin; do
+    ln -sfv usr/$i ${pkgdir}/$i
+  done
+
+  # LFS Section 7.3
+  install -vdm755 ${pkgdir}/{dev,proc,run,sys}
+
+  # LFS Section 7.3.1
+  mknod -m 666 ${pkgdir}/dev/console c 5 1
+  mknod -m 666 ${pkgdir}/dev/null c 1 3
+
+  # LFS Section 7.5
+  install -vdm755 ${pkgdir}/{boot,home,mnt,opt,srv}
+  install -vdm755 ${pkgdir}/etc/{opt,sysconfig}
+  install -vdm755 ${pkgdir}/lib/firmware
+  install -vdm755 ${pkgdir}/media/{floppy,cdrom}
+  install -vdm755 ${pkgdir}/usr/{,local/}{include,src}
+  install -vdm755 ${pkgdir}/usr/local/{bin,lib,sbin}
+  install -vdm755 ${pkgdir}/usr/{,local/}share/{color,dict,doc,info,locale,man}
+  install -vdm755 ${pkgdir}/usr/{,local/}share/{misc,terminfo,zoneinfo}
+  install -vdm755 ${pkgdir}/usr/{,local/}share/man/man{1..8}
+  install -vdm755 ${pkgdir}/var/{cache,local,log,mail,opt,spool}
+  install -vdm755 ${pkgdir}/var/lib/{color,misc,locate}
+  install -vdm750 ${pkgdir}/root
+  install -vdm1777 ${pkgdir}{,/var}/tmp
+  ln -sfv /run ${pkgdir}/var/run
+  ln -sfv /run/lock ${pkgdir}/var/lock
+
+  # LFS Section 7.6
+  ln -sfv /proc/self/mounts ${pkgdir}/etc/mtab
+  cat &gt; ${pkgdir}/etc/passwd &lt;&lt; "EOF"
+root:x:0:0:root:/root:/bin/bash
+bin:x:1:1:bin:/dev/null:/bin/false
+daemon:x:6:6:Daemon User:/dev/null:/bin/false
+messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/bin/false
+uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/bin/false
+nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
+tester:x:1001:101::/home/tester:/bin/bash
+pacman:x:102:102:Pacman Packaging User:/home/pacman:/bin/bash
+EOF
+  cat &gt; ${pkgdir}/etc/group &lt;&lt; "EOF"
+root:x:0:
+bin:x:1:daemon
+sys:x:2:
+kmem:x:3:
+tape:x:4:
+tty:x:5:
+daemon:x:6:
+floppy:x:7:
+disk:x:8:
+lp:x:9:
+dialout:x:10:
+audio:x:11:
+video:x:12:
+utmp:x:13:
+usb:x:14:
+cdrom:x:15:
+adm:x:16:
+messagebus:x:18:
+input:x:24:
+mail:x:34:
+kvm:x:61:
+uuidd:x:80:
+wheel:x:97:
+nogroup:x:99:
+tester:x:101:
+pacman:x:102:
+users:x:999:
+EOF
+
+  touch ${pkgdir}/var/log/{btmp,lastlog,faillog,wtmp}
+  chgrp -v utmp ${pkgdir}/var/log/lastlog
+  chmod -v 664  ${pkgdir}/var/log/lastlog
+  chmod -v 600  ${pkgdir}/var/log/btmp
+
+  # LFS Sections 7.6 and 9.5.4
+  cat &gt; ${pkgdir}/etc/hosts &lt;&lt; "EOF"
+# Begin /etc/hosts
+
+# IPv4
+127.0.0.1 localhost.localdomain localhost
+# Populate the follwoing lines after installation
+#127.0.1.1 &lt;FQDN&gt; &lt;HOSTNAME&gt;
+#&lt;192.168.1.1&gt; &lt;FQDN&gt; &lt;HOSTNAME&gt; [alias1] [alias2 ...]
+
+# IPv6
+::1       localhost ip6-localhost ip6-loopback
+ff02::1   ip6-allnodes
+ff02::2   ip6-allrouters
+
+# End /etc/hosts
+EOF
+
+  # LFS Section 8.5.2.3
+  install -vdm755 ${pkgdir}/etc/ld.so.conf.d/
+  cat &gt; ${pkgdir}/etc/ld.so.conf &lt;&lt; "EOF"
+# Begin /etc/ld.so.conf
+
+/usr/local/lib
+/opt/lib
+
+# Add an include directory
+include /etc/ld.so.conf.d/*.conf
+
+# End /etc/ld.so.conf
+EOF
+
+  # LFS Section 9.5.2
+  cat &gt; ${pkgdir}/etc/resolv.conf &lt;&lt; "EOF"
+# Begin /etc/resolv.conf
+
+domain localdomain
+nameserver 8.8.8.8
+nameserver 8.8.4.4
+
+# End /etc/resolv.conf
+EOF
+
+  # LFS Section 9.5.3
+  echo "lfs" &gt; ${pkgdir}/etc/hostname
+
+  # LFS Section 9.8
+  cat &gt; ${pkgdir}/etc/inputrc &lt;&lt; "EOF"
+# Begin /etc/inputrc
+# Modified by Chris Lynn &lt;roryo@roryo.dynup.net&gt;
+
+# Allow the command prompt to wrap to the next line
+set horizontal-scroll-mode Off
+
+# Enable 8bit input
+set meta-flag On
+set input-meta On
+
+# Turns off 8th bit stripping
+set convert-meta Off
+
+# Keep the 8th bit for display
+set output-meta On
+
+# none, visible or audible
+set bell-style none
+
+# All of the following map the escape sequence of the value
+# contained in the 1st argument to the readline specific functions
+"\eOd": backward-word
+"\eOc": forward-word
+
+# for linux console
+"\e[1~": beginning-of-line
+"\e[4~": end-of-line
+"\e[5~": beginning-of-history
+"\e[6~": end-of-history
+"\e[3~": delete-char
+"\e[2~": quoted-insert
+
+# for xterm
+"\eOH": beginning-of-line
+"\eOF": end-of-line
+
+# for Konsole
+"\e[H": beginning-of-line
+"\e[F": end-of-line
+
+# End /etc/inputrc"${pkgdir}/
+EOF
+
+  # LFS Section 9.9
+  cat &gt; ${pkgdir}/etc/shells &lt;&lt; "EOF"
+# Begin /etc/shells
+
+/bin/sh
+/bin/bash
+
+# End /etc/shells
+EOF
+
+  # LFS Section 10.2
+  cat &gt; ${pkgdir}/etc/fstab &lt;&lt; "EOF"
+# Begin /etc/fstab
+
+# file system  mount-point  type     options             dump  fsck
+#                                                              order
+/dev/&lt;xxx&gt;     /            &lt;fff&gt;    defaults            1     1
+/dev/&lt;yyy&gt;     swap         swap     pri=1               0     0
+proc           /proc        proc     nosuid,noexec,nodev 0     0
+sysfs          /sys         sysfs    nosuid,noexec,nodev 0     0
+devpts         /dev/pts     devpts   gid=5,mode=620      0     0
+tmpfs          /run         tmpfs    defaults            0     0
+devtmpfs       /dev         devtmpfs mode=0755,nosuid    0     0
+
+# End /etc/fstab
+EOF
+
+  # Post LFS fixes:
+  touch ${pkgdir}/usr/share/info/dir
+  chmod 0644 ${pkgdir}/usr/share/info/dir
+  touch ${pkgdir}/etc/ld.so.cache
+  chmod 0644 ${pkgdir}/etc/ld.so.cache
+  chmod 0555 ${pkgdir}/proc
+  chmod 1777 ${pkgdir}/run
+  chmod 0555 ${pkgdir}/sys
+}
+REALEOF
+chown -R pacman:pacman ../rootfs 
+su pacman -c "/usr/bin/makepkg -L --nodeps"
+repo-add \
+    /srv/pacman/repos/LFS/LFS.db.tar.xz \
+    /srv/pacman/repos/LFS/rootfs-1.0-1-any.pkg.tar.xz
+pacman -Syu
+pacman -Sy rootfs --nodeps --overwrite "*" --noconfirm
+mkdir -pv /srv/pacman/source/LFS/rootfs
+cp PKGBUILD /srv/pacman/source/LFS/rootfs/
+cd ..
+rm -rf rootfs</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-linux-api-headers" role="wrap">
+  <?dbhtml filename="linux-api-headers.html"?>
+
+  <sect1info condition="script">
+    <productname>linux-api-headers</productname>
+    <productnumber>&linux-version;</productnumber>
+    <address>&linux-url;</address>
+  </sect1info>
+
+  <title>linux-api-headers-&linux-version;</title>
+
   <sect2 role="installation">
     <title/>
 
-<screen><userinput remap="configure">mkdir build
-cd build
-meson --prefix=/usr \
-      -Dcrypto=openssl</userinput></screen>
+<screen><userinput remap="install">mkdir linux-api-headers
+cd linux-api-headers
+cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="linux-api-headers"
+pkgver="&linux-version;"
+pkgrel="1"
+pkgdesc="Linux Kernel Application Programming Interface (API)"
+arch=('any')
+license=('GPLv2')
+groups=('core')
+depends=('rootfs')
+makedepends=('bash'
+             'binutils'
+             'coreutils'
+             'findutils'
+             'gcc'
+             'glibc'
+             'grep'
+             'gzip'
+             'make'
+             'perl'
+             'sed')
+source=('https://www.kernel.org/pub/linux/kernel/v5.x/linux-&linux-version;.tar.xz')
+md5sums=('&linux-md5;')
+
+prepare(){
+  cd "linux-${pkgver}"
+  make mrproper
+}
+
+build(){
+  cd "linux-${pkgver}"
+  make headers
+  find usr/include -name '.*' -delete
+  rm usr/include/Makefile
+}
+
+package(){
+  cd "linux-${pkgver}"
+  mkdir "${pkgdir}/usr"
+  cp -rv usr/include "${pkgdir}/usr/"
+}
 
-<screen><userinput remap="make">ninja</userinput></screen>
+EOF
+chown -R pacman:pacman ../linux-api-headers
+cp /sources/linux-&linux-version;.tar.xz .
+su pacman -c "/usr/bin/makepkg -L --nodeps --nodeps"
+repo-add \
+    /srv/pacman/repos/LFS/LFS.db.tar.xz \
+    /srv/pacman/repos/LFS/linux-api-headers-&linux-version;-1-any.pkg.tar.xz
+pacman -Syu
+pacman -Sy linux-api-headers --nodeps --overwrite "*" --noconfirm
+mkdir -pv /srv/pacman/source/LFS/linux-api-headers
+cp PKGBUILD /srv/pacman/source/LFS/linux-api-headers/
+cd ..
+rm -rf linux-api-headers</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<!-- Mandatory section for creating dirs. These instructions are added at the
+end of the creating dirs instructions of the book. Do not change the
+following line -->
+<sect1 id="ch-pkgmngt-creatingdirs">
+
+  <title>Creating Directories</title>
+
+<screen><userinput>mkdir -p /srv/pacman/{logs,repos,source}/LFS</userinput></screen>
+
+</sect1>
+<!-- Same for files. Do not change the following line -->
+<sect1 id="ch-pkgmngt-createfiles">
+
+  <title>Creating Essential Files</title>
+
+<screen><userinput>echo "pacman:x:102:102:Pacman Packaging User:/home/pacman:/bin/bash" >> /etc/passwd
+echo "pacman:x:102:" >> /etc/group
+install -o pacman -d /home/pacman
+chown -R root:pacman /srv/pacman
+chmod 2775 /srv/pacman/{repos{,/LFS},source{,/LFS},logs{,/LFS}}</userinput></screen>
+
+</sect1>
+
+<!-- Last but not least : Final instructions for installing the
+package manager at the end of chapter 6. Again, the scriptlet file name is
+taken from the dbhtml instruction, with digits added before and .html cut
+and the tarball name is formed from this name + version. So the file
+here _must_ be the same as in chapter 5. If rendering in html, both
+sets of instructions end up in the same file, which is usually not a problem.
+-->
+<sect1 id="ch-system-core" role="wrap">
+  <?dbhtml filename="core.html"?>
+
+  <sect1info condition="script">
+    <productname>core</productname>
+    <productnumber>1.0</productnumber>
+    <address>&lfs-root;</address>
+  </sect1info>
 
-<!-- Those instructions are executed with PKG_DEST set. They are not processed
-in any way to add $PKG_DEST at some place, and the PKG_DEST directory is not
-populated before, so it is basically empty. You have thus to create any directory
-needed in $PKG_DEST and not otherwise created by the make install command. -->
-<screen><userinput remap="install">DESTDIR=$PKG_DEST ninja install</userinput></screen>
+  <title>core-1.0</title>
 
-<screen><userinput>sed -e 's/\([^!]\)strip/\1!strip/' \
-    -e 's/\([^!]\)zipman/\1!zipman/' \
-    -e 's/\([^!]\)libtool/\1!libtool/' \
-    -i /etc/makepkg.conf
-cat &gt;&gt; /etc/makepkg.conf &lt;&lt; EOF
-BUILDDIR=/sources
-PKGDEST=/var/lib/packages
-PACKAGER="Pierre Labastie &lt;lnimbus@club-internet.fr&lt;"
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">pacman -Qg | grep core | cut -d " " -f 2 | \
+    sed 's@^@          @' &gt; pkglist
+    echo "          'linux'" &gt;&gt; pkglist
+cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="core"
+pkgver="1.0"
+pkgrel="1"
+pkgdesc="core meta-package"
+url="https://www.linuxfromscratch.org/"
+arch=('any')
+license=('CC-BY-SA-2.0')
+depends=(
 EOF
-cat &gt;&gt; /etc/pacman.conf &lt;&lt; EOF
-DBPath   = /var/lib/pacman/
-CacheDir = /var/cache/pacman/pkg/
-LogFile  = /var/log/pacman.log
-SigLevel = Never
+cat pkglist >> PKBUILD
+echo "         )" >> PKGBUILD</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-fakeroot" role="wrap">
+  <?dbhtml filename="fakeroot.html"?>
+
+  <sect1info condition="script">
+    <productname>fakeroot</productname>
+    <productnumber>&fakeroot-version;</productnumber>
+    <address>&fakeroot-url;</address>
+  </sect1info>
+
+  <title>fakeroot-&fakeroot-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="fakeroot"
+pkgver="&fakeroot-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+checkdepends=('sharutils')
+source=('&fakeroot-url;'
+        '&fakeroot-patch;')
+md5sums=('&fakeroot-md5;'
+         '&fakeroot-patch-md5;')
+
+prepare(){
+  cd "${pkgname}-${pkgver}"
+  patch -Np1 -i ${srcdir}/&fakeroot-patch;
+  autoreconf -fi
+}
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr --disable-static
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make -k check || true
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  sed '/SUBDIRS/s/doc //' -i Makefile
+  make DESTDIR="${pkgdir}" install
+  install -vdm755 ${pkgdir}/usr/share/man/man1
+  install -vm644  doc/fake{d,root}.1 ${pkgdir}/usr/share/man/man1
+  chown -R root:root ${pkgdir}/*
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+<sect1 id="ch-system-libxml2" role="wrap">
+  <?dbhtml filename="libxml2.html"?>
+
+  <sect1info condition="script">
+    <productname>libxml2</productname>
+    <productnumber>&libxml2-version;</productnumber>
+    <address>&libxml2-url;</address>
+  </sect1info>
+
+  <title>Libxml2-&libxml2-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="libxml2"
+pkgver="&libxml2-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+optdepends=('icu'
+            'valgrind')
+source=('&libxml2-url;'
+        '&libxml2-testsuite-url;')
+md5sums=('&libxml2-md5;'
+         '&libxml2-testsuite-md5;')
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr    \
+              --disable-static \
+              --with-history   \
+              --with-python=/usr/bin/python3
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  tar -xf ${srcdir}/&libxml2-testsuite;
+  make check
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  make DESTDIR="${pkgdir}" install
+  chown -Rv root:root ${pkgdir}/*
+}
 EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-libarchive" role="wrap">
+  <?dbhtml filename="libarchive.html"?>
+
+  <sect1info condition="script">
+    <productname>libarchive</productname>
+    <productnumber>&libarchive-version;</productnumber>
+    <address>&libarchive-url;</address>
+  </sect1info>
+
+  <title>Libarchive-&libarchive-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="libarchive"
+pkgver="&libarchive-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+optdepends=('libxml2'
+            'lzo'
+            'nettle')
+source=('&libarchive-url;')
+md5sums=('&libarchive-md5;')
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr \
+              --disable-static
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  LC_ALL=C make check
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  make DESTDIR="${pkgdir}" install
+  chown -Rv root:root ${pkgdir}/*
+}
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-libgpg-error" role="wrap">
+  <?dbhtml filename="libgpg-error.html"?>
+
+  <sect1info condition="script">
+    <productname>libgpg-error</productname>
+    <productnumber>&libgpg-error-version;</productnumber>
+    <address>&libgpg-error-url;</address>
+  </sect1info>
+
+  <title>libgpg-error-&libgpg-error-version;</title>
 
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="libgpg-error"
+pkgver="&libgpg-error-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+source=('&libgpg-error-url;')
+md5sums=('&libgpg-error-md5;')
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make check
+}
+
+package(){
+  cd ${pkgname}-${pkgver}
+  make DESTDIR="${pkgdir}/" install
+}
+EOF</userinput></screen>
   </sect2>
 
 </sect1>
+
+<sect1 id="ch-system-libassuan" role="wrap">
+  <?dbhtml filename="libassuan.html"?>
+
+  <sect1info condition="script">
+    <productname>libassuan</productname>
+    <productnumber>&libassuan-version;</productnumber>
+    <address>&libassuan-url;</address>
+  </sect1info>
+
+  <title>libassuan-&libassuan-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="libassuan"
+pkgver="&libassuan-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core'
+         'libgpg-error')
+source=('&libassuan-url;')
+md5sums=('&libassuan-md5;')
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make check
+}
+
+package(){
+  cd ${pkgname}-${pkgver}
+  make DESTDIR="${pkgdir}/" install
+}
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-npth" role="wrap">
+  <?dbhtml filename="npth.html"?>
+
+  <sect1info condition="script">
+    <productname>npth</productname>
+    <productnumber>&npth-version;</productnumber>
+    <address>&npth-url;</address>
+  </sect1info>
+
+  <title>npth-&npth-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="npth"
+pkgver="&npth-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+source=('&npth-url;')
+md5sums=('&npth-md5;')
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make -k check || true
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  make DESTDIR=${pkgdir} install
+}
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-gnupg" role="wrap">
+  <?dbhtml filename="gnupg.html"?>
+
+  <sect1info condition="script">
+    <productname>gnupg</productname>
+    <productnumber>&gnupg-version;</productnumber>
+    <address>&gnupg-url;</address>
+  </sect1info>
+
+  <title>gnupg-&gnupg-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="gnupg"
+pkgver="&gnupg-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groupd=('core-pacman')
+depends=('core'
+         'libassuan'
+         'libgcrypt'
+         'libksba'
+         'npth')
+optdepends=('curl'
+            'fuse'
+            'gnutls'
+            'imagemagick'
+            'libusb'
+            'openldap'
+            'sqlite'
+            'texlive'
+            'fig2dev'
+            'adns')
+checkdepends=('gnupg')
+source=('&gnupg-url;')
+md5sums=('&gnupg-md5;')
+
+prepare(){
+  cd "${pkgname}-${pkgver}"
+  sed -e '/noinst_SCRIPTS = gpg-zip/c sbin_SCRIPTS += gpg-zip' \
+      -i tools/Makefile.in
+}
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr            \
+              --localstatedir=/var     \
+              --docdir=/usr/share/doc/${pkgname}-${pkgver}
+  make
+  makeinfo --html --no-split -o doc/gnupg_nochunks.html doc/gnupg.texi
+  makeinfo --plaintext       -o doc/gnupg.txt           doc/gnupg.texi
+  make -C doc html
+  # REQUIRES texlive
+  # make -C doc pdf ps
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make check || true
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  make DESTDIR=${pkgdir} install
+  install -vdm755 ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
+  install -vm644  doc/gnupg_nochunks.html \
+                  ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/gnupg.html
+  install -vm644  doc/*.texi doc/gnupg.txt \
+                  ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
+  install -vm644  doc/gnupg.html/* \
+                  ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
+  # REQUIRES texlive
+  # install -vm644  doc/gnupg.{pdf,dvi,ps} \
+  #                 ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
+}
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-gpgme" role="wrap">
+  <?dbhtml filename="gpgme.html"?>
+
+  <sect1info condition="script">
+    <productname>gpgme</productname>
+    <productnumber>&gpgme-version;</productnumber>
+    <address>&gpgme-url;</address>
+  </sect1info>
+
+  <title>gpgme-&gpgme-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="gpgme"
+pkgver="&gpgme-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+optdepends=('clisp'
+            'doxygen'
+            'gnupg'
+            'graphviz'
+            'qt'
+            'swig')
+checkdepends=('gnupg')
+source=('&gpgme-url;')
+md5sums=('&gpgme-md5;')
+
+prepare(){
+  cd "${pkgname}-${pkgver}"
+  sed 's/defined(__sun.*$/1/' -i src/posix-io.c
+}
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make -k check || true
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  make DESTDIR=${pkgdir} install
+}
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-pth" role="wrap">
+  <?dbhtml filename="pth.html"?>
+
+  <sect1info condition="script">
+    <productname>pth</productname>
+    <productnumber>&pth-version;</productnumber>
+    <address>&pth-url;</address>
+  </sect1info>
+
+  <title>pth-&pth-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="pth"
+pkgver="&pth-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+source=('&pth-url;')
+md5sums=('&pth-md5;')
+
+prepare(){
+  cd "${pkgname}-${pkgver}"
+  sed -i 's#$(LOBJS): Makefile#$(LOBJS): pth_p.h Makefile#' Makefile.in
+}
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr \
+              --mandir=/usr/share/man
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make check
+}
+
+package(){
+  cd ${pkgname}-${pkgver}
+  make -j1 DESTDIR="${pkgdir}/" install
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-libgcrypt" role="wrap">
+  <?dbhtml filename="libgcrypt.html"?>
+
+  <sect1info condition="script">
+    <productname>libgcrypt</productname>
+    <productnumber>&libgcrypt-version;</productnumber>
+    <address>&libgcrypt-url;</address>
+  </sect1info>
+
+  <title>libgcrypt-&libgcrypt-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="libgcrypt"
+pkgver="&libgcrypt-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+makedepends=('unzip')
+optdepends=('libedit')
+source=('&libgcrypt-url;')
+md5sums=('&libgcrypt-md5;')
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr
+  make
+  make -C doc html
+  makeinfo --html --no-split -o doc/gcrypt_nochunks.html doc/gcrypt.texi
+  makeinfo --plaintext       -o doc/gcrypt.txt           doc/gcrypt.texi
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make check
+}
+
+package(){
+  cd ${pkgname}-${pkgver}
+  make DESTDIR="${pkgdir}/" install
+  install -vdm755 ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
+  install -vm644  README doc/{README.apichanges,fips*,libgcrypt*} \
+                  ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
+  install -vdm755 ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/html
+  install -vm644  doc/gcrypt.html/* \
+                  ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/html
+  install -vm644  doc/gcrypt_nochunks.html \
+                  ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
+  install -vm644  doc/gcrypt.{txt,texi} \
+                  ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
+}
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-libksba" role="wrap">
+  <?dbhtml filename="libksba.html"?>
+
+  <sect1info condition="script">
+    <productname>libksba</productname>
+    <productnumber>&libksba-version;</productnumber>
+    <address>&libksba-url;</address>
+  </sect1info>
+
+  <title>libksba-&libksba-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="libksba"
+pkgver="&libksba-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core'
+         'libgcrypt')
+source=('&libksba-url;')
+md5sums=('&libksba-md5;')
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make check
+}
+
+package(){
+  cd ${pkgname}-${pkgver}
+  make DESTDIR="${pkgdir}/" install
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-libtasn1" role="wrap">
+  <?dbhtml filename="libtasn1.html"?>
+
+  <sect1info condition="script">
+    <productname>libtasn1</productname>
+    <productnumber>&libtasn1-version;</productnumber>
+    <address>&libtasn1-url;</address>
+  </sect1info>
+
+  <title>libtasn1-&libtasn1-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="libtasn1"
+pkgver="&libtasn1-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core'
+         'libksba')
+source=('&libtasn1-url;')
+md5sums=('&libtasn1-md5;')
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr \
+              --disable-static
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make check
+}
+
+package(){
+  cd ${pkgname}-${pkgver}
+  make DESTDIR="${pkgdir}/" install
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-p11-kit" role="wrap">
+  <?dbhtml filename="p11-kit.html"?>
+
+  <sect1info condition="script">
+    <productname>p11-kit</productname>
+    <productnumber>&p11-kit-version;</productnumber>
+    <address>&p11-kit-url;</address>
+  </sect1info>
+
+  <title>p11-kit-&p11-kit-version;</title>
+
+  <sect2 role="installation">
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "REALEOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="p11-kit"
+pkgver="&p11-kit-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core'
+         'libtasn1')
+source=('&p11-kit-url;')
+md5sums=('&p11-kit-md5;')
+
+prepare(){
+  cd "${pkgname}-${pkgver}"
+  sed '20,$ d' -i trust/trust-extract-compat
+  cat &gt;&gt; trust/trust-extract-compat &lt;&lt; "EOF"
+# Copy existing anchor modifications to /etc/ssl/local
+/usr/libexec/make-ca/copy-trust-modifications
+
+# Update trust stores
+/usr/sbin/make-ca -r
+EOF
+mkdir p11-build
+}
+
+build(){
+  cd "${pkgname}-${pkgver}/p11-build"
+  meson --prefix=/usr       \
+        --buildtype=release \
+        -Dtrust_paths=/etc/pki/anchors
+  ninja
+}
+
+package(){
+  cd "${pkgname}-${pkgver}/p11-build"
+  DESTDIR=${pkgdir} ninja install
+  ln -sfv /usr/libexec/p11-kit/trust-extract-compat \
+          ${pkgdir}/usr/bin/update-ca-certificates
+  ln -sfv ./pkcs11/p11-kit-trust.so ${pkgdir}/usr/lib/libnssckbi.so
+}
+REALEOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-make-ca" role="wrap">
+  <?dbhtml filename="make-ca.html"?>
+
+  <sect1info condition="script">
+    <productname>make-ca</productname>
+    <productnumber>&make-ca-version;</productnumber>
+    <address>&make-ca-url;</address>
+  </sect1info>
+
+  <title>make-ca-&make-ca-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; make-ca.install &lt;&lt; "EOF"
+#make-ca.install
+
+post_install(){
+  /usr/sbin/make-ca -f -g
+}
+
+post_upgrade(){
+  post_install
+}
+
+EOF
+cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="make-ca"
+pkgver="&make-ca-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+url="http://github.com/djlucas/${pkgname}"
+depends=('core'
+         'p11-kit')
+optdepends=('nss')
+options=('emptydirs')
+install="${pkgname}.install"
+source=('&make-ca-url;')
+md5sums=('&make-ca-md5;')
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  make DESTDIR=${pkgdir} install
+  install -vdm755 ${pkgdir}/etc/ssl/local
+  if test ! -d /usr/lib/systemd; then
+    rm -rf "${pkgdir}/usr/lib/systemd"
+  fi
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-unzip" role="wrap">
+  <?dbhtml filename="unzip.html"?>
+
+  <sect1info condition="script">
+    <productname>unzip</productname>
+    <productnumber>&unzip-version;</productnumber>
+    <address>&unzip-url;</address>
+  </sect1info>
+
+  <title>unzip-&unzip-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="unzip"
+pkgver="&unzip-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+source=('&unzip-url;'
+        '&unzip-patch-url;')
+md5sums=('&unzip-md5;'
+         '&unzip-patch-md5;')
+
+prepare(){
+  cd "${pkgname}60"
+  patch -Np1 -i ${srcdir}/&unzip-patch;
+}
+
+build(){
+  cd "${pkgname}60"
+  make -f unix/Makefile generic
+}
+
+package(){
+  cd "${pkgname}60"
+  make prefix=${pkgdir}/usr MANDIR=${pkgdir}/usr/share/man/man1 \
+       -f unix/Makefile install
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-sqlite" role="wrap">
+  <?dbhtml filename="sqlite.html"?>
+
+  <sect1info condition="script">
+    <productname>sqlite</productname>
+    <productnumber>&sqlite-version;</productnumber>
+    <address>&sqlite-url;</address>
+  </sect1info>
+
+  <title>sqlite-&sqlite-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="sqlite"
+pkgver="&sqlite-version;"
+_pkgver="&sqlite-short-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+makedepends=('unzip')
+optdepends=('libedit')
+source=('&sqlite-url;'
+        '&sqlite-doc-url;')
+noextract=('sqlite-doc-${_pkgver}.zip')
+md5sums=('&sqlite-md5;'
+         '&sqlite-doc-md5;')
+
+prepare(){
+  cd "${pkgname}-autoconf-${_pkgver}"
+  unzip -q ${srcdir}/sqlite-doc-${_pkgver}.zip
+}
+  
+build(){
+  cd "${pkgname}-autoconf-${_pkgver}"
+  ./configure --prefix=/usr     \
+              --disable-static  \
+              --enable-fts5     \
+              CPPFLAGS="-DSQLITE_ENABLE_FTS3=1  \
+              -DSQLITE_ENABLE_FTS4=1            \
+              -DSQLITE_ENABLE_COLUMN_METADATA=1 \
+              -DSQLITE_ENABLE_UNLOCK_NOTIFY=1   \
+              -DSQLITE_ENABLE_DBSTAT_VTAB=1     \
+              -DSQLITE_SECURE_DELETE=1          \
+              -DSQLITE_ENABLE_FTS3_TOKENIZER=1"
+  make
+}
+
+check(){
+  cd "${pkgname}-autoconf-${_pkgver}"
+  make check
+}
+
+package(){
+  cd ${pkgname}-autoconf-${_pkgver}
+  make DESTDIR="${pkgdir}/" install
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-nettle" role="wrap">
+  <?dbhtml filename="nettle.html"?>
+
+  <sect1info condition="script">
+    <productname>nettle</productname>
+    <productnumber>&nettle-version;</productnumber>
+    <address>&nettle-url;</address>
+  </sect1info>
+
+  <title>nettle-&nettle-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="nettle"
+pkgver="&nettle-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+source=('&nettle-url;')
+md5sums=('&nettle-md5;')
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr \
+              --disable-static
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make -k check || true
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  make DESTDIR=${pkgdir} install
+  chmod -v 755 ${pkgdir}/usr/lib/lib{hogweed,nettle}.so
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-curl" role="wrap">
+  <?dbhtml filename="curl.html"?>
+
+  <sect1info condition="script">
+    <productname>curl</productname>
+    <productnumber>&curl-version;</productnumber>
+    <address>&curl-url;</address>
+  </sect1info>
+
+  <title>Curl-&curl-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="curl"
+pkgver="&curl-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+optdepends=('brotli'
+            'c-ares'
+            'gnutls'
+            'impacket'
+            'libidn2'
+            'libmetalink'
+            'libpsl'
+            'librtmp'
+            'libssh2'
+            'make-ca'
+            'mit-krb5'
+            'nghttp2'
+            'ngtcp2'
+            'openldap'
+            'quiche'
+            'samba'
+            'spngo'
+            'stunnel'
+            'valgrind')
+source=('&curl-url;')
+md5sums=('&curl-md5;')
+
+prepare(){
+  cd "${pkgname}-${pkgver}"
+  grep -rl '#!.*python$' | xargs sed -i '1s/python/&amp;3/'
+}
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  ./configure --prefix=/usr              \
+              --disable-static           \
+              --with-openssl             \
+              --enable-threaded-resolver \
+              --with-ca-path=/etc/ssl/certs
+  make
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  make test
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  make DESTDIR="${pkgdir}" install
+  rm -rf docs/examples/.deps
+  find docs \( -name Makefile\* -o -name \*.1 -o -name \*.3 \) -exec rm {} \;
+  install -vdm755 "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
+  cp -Rv docs/* "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-setuptools" role="wrap">
+  <?dbhtml filename="setuptools.html"?>
+
+  <sect1info condition="script">
+    <productname>setuptools</productname>
+    <productnumber>&setuptools-version;</productnumber>
+    <address>&setuptools-url;</address>
+  </sect1info>
+
+  <title>setuptools-&setuptools-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="setuptools"
+pkgver="&setuptools-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+source=('&setuptools-url;')
+md5sums=('&setuptools-md5;')
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  python3 setup.py build
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  python3 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 --skip-build
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-pip" role="wrap">
+  <?dbhtml filename="pip.html"?>
+
+  <sect1info condition="script">
+    <productname>pip</productname>
+    <productnumber>&pip-version;</productnumber>
+    <address>&pip-url;</address>
+  </sect1info>
+
+  <title>pip-&pip-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="pip"
+pkgver="&pip-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core')
+source=('&pip-url;')
+md5sums=('&pip-md5;')
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  python3 setup.py build
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  python3 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1
+  ln -sfv pip3.9 ${pkgdir}/usr/bin/pip3
+  ln -sfv pip3.9 ${pkgdir}/usr/bin/pip
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-pacman" role="wrap">
+  <?dbhtml filename="pacman.html"?>
+
+  <sect1info condition="script">
+    <productname>pacman</productname>
+    <productnumber>&pacman-version;</productnumber>
+    <address>&pacman-url;</address>
+  </sect1info>
+
+  <title>Pacman-&pacman-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "REALEOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="pacman"
+pkgver="&pacman-version;"
+_hooksver="&pacman-hooks-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core'
+         'curl'
+         'fakeroot'
+         'libarchive')
+optdepends=('asciidoc'
+            'doxygen'
+            'gpgme'
+            'libassuan'
+            'libgcrypt'
+            'libgpg-error'
+            'libksba'
+            'libtasn1'
+            'pth'
+            'sqlite')
+source=('&pacman-url;'
+        '&pacman-hooks-url;')
+noextract=("pacman-hooks-${_hooksver}.tar.xz")
+md5sums=('&pacman-md5;'
+         '&pacman-hooks-md5;')
+backup=('etc/pacman.conf'
+        'etc/makepkg.conf')
+
+prepare(){
+  cd "${pkgname}-${pkgver}"
+  tar -xf ${srcdir}/pacman-hooks-${_hooksver}.tar.xz
+}
+
+build(){
+  cd "${pkgname}-${pkgver}"
+  meson --prefix=/usr                   \
+        --buildtype=plain               \
+        -Ddoc=disabled                  \
+        -Ddoxygen=disabled              \
+        -Dscriptlet-shell=/usr/bin/bash \
+        -Dldconfig=/usr/bin/ldconfig    \
+        build
+  meson compile -C build
+}
+
+check(){
+  cd "${pkgname}-${pkgver}"
+  # 19 additional tests are know to fail because prior tests don't clean-up
+  meson test -C build || true
+}
+
+package(){
+  cd "${pkgname}-${pkgver}"
+  DESTDIR="${pkgdir}" meson install -C build
+  # Don't install systemd hooks on sysv (or other)
+  if [ ! -d /usr/lib/systemd ]; then
+    rm -f pacman-hooks-${_hooksver}/hooks/*systemd*
+    rm -f pacman-hooks-${_hooksver}/hooks/dbus-reload.hook
+    rm -f pacman-hooks-${_hooksver}/scripts/*systemd*
+  fi
+  sed '/^Target/s@/\*@/*.info*@' -i \
+      pacman-hooks-${_hooksver}/hooks/texinfo-install.hook
+  install -vdm755 ${pkgdir}/usr/share/libalpm/{hooks,scripts}/
+  install -vm644 pacman-hooks-${_hooksver}/hooks/* \
+                 ${pkgdir}/usr/share/libalpm/hooks/
+  install -vm755 pacman-hooks-${_hooksver}/scripts/* \
+                 ${pkgdir}/usr/share/libalpm/scripts/
+  cat &gt;&gt; ${pkgdir}/etc/makepkg.conf &lt;&lt; EOF
+PACKAGER="Linux From Scratch &lt;lfs-dev@lists.linuxfromscrtch.org&gt;"
+PKGDEST="/srv/pacman/repos/LFS"
+SRCDEST="/sources"
+LOGDEST="/srv/pacman/logs/LFS"
+EOF
+  sed -e /PKGEXT/s/gz/xz/                                \
+      -e /SRCEXT/s/gz/xz/                                \
+      -e /^INTEGRITY/s/ck/md5/                           \
+      -e '/^OPTIONS/s/\([^!]\)emptydirs/\1!emptydirs/'   \
+      -e '/^OPTIONS/s/\([^!]\)libtoo/\1!libtool/'        \
+      -e '/^OPTIONS/s/\([^!]\)staticlibs/\1!staticlibs/' \
+      -i ${pkgdir}/etc/makepkg.conf
+  cat &gt;&gt; ${pkgdir}/etc/pacman.conf &lt;&lt; "EOF"
+
+[LFS]
+SigLevel = Optional TrustAll
+Server = file:///srv/pacman/repos/LFS
+
+EOF
+}
+REALEOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-pacman-contrib" role="wrap">
+  <?dbhtml filename="pacman-contrib.html"?>
+
+  <sect1info condition="script">
+    <productname>pacman-contrib</productname>
+    <productnumber>&pacman-contrib-version;</productnumber>
+    <address>&pacman-contrib-url;</address>
+  </sect1info>
+
+  <title>pacman-contrib-&pacman-contrib-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="pacman-contrib"
+pkgver="&pacman-contrib-version;"
+pkgrel="1"
+pkgdesc="${pkgname} ${pkgver}"
+arch=()
+license=()
+groups=('core-pacman')
+depends=('core'
+         'pacman')
+source=('&pacman-contrib-url;'
+        '&pacman-contrib-patch-url;')
+md5sums=('&pacman-contrib-md5;'
+         '&pacman-contrib-patch-md5;')
+
+prepare(){
+  cd "${pkgname}-v${pkgver}"
+  patch -Np1 -i ${srcdir}/&pacman-contrib-patch;
+  chmod 755 configure
+}
+
+build(){
+  cd "${pkgname}-v${pkgver}"
+  ./configure --prefix=/usr        \
+              --sysconfdir=/etc    \
+              --localstatedir=/var \
+              --disable-doc
+  make
+}
+
+#check(){
+#  cd "${pkgname}-v${pkgver}"
+#  make -k check || true
+#}
+
+package(){
+  cd "${pkgname}-v${pkgver}"
+  make DESTDIR=${pkgdir} install
+  vimdir=$(ls -d /usr/share/vim/vim[0-9]* | tail -n 1)
+  install -vdm755 ${pkgdir}/${vimdir}
+  mv -v ${pkgdir}/usr/share/vim/vimfiles/* \
+        ${pkgdir}/${vimdir}
+  rm -rf ${pkgdir}/usr/share/vim/vimfiles
+}
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-core-pacman" role="wrap">
+  <?dbhtml filename="core-pacman.html"?>
+
+  <sect1info condition="script">
+    <productname>core-pacman</productname>
+    <productnumber>1.0</productnumber>
+    <address>&lfs-root;</address>
+  </sect1info>
+
+  <title>core-1.0</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">pacman -Qg | grep core-pacman | cut -d " " -f 2 | \
+    sed 's@^@          @' &gt; pkglist
+cat &gt; PKGBUILD &lt;&lt; "EOF"
+# Maintainer: Linux From Scratch &lt;lfs-dev@lists.linuxfromscratch.org&gt;
+
+pkgname="core-pacman"
+pkgver="1.0"
+pkgrel="1"
+pkgdesc="core-pacman meta-package"
+url="https://www.linuxfromscratch.org/"
+arch=('any')
+license=('CC-BY-SA-2.0')
+depends=(
+EOF
+cat pkglist >> PKBUILD
+echo "         )" >> PKGBUILD</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
 </article>
diff --git a/pkgmngt/packageManager.xml.rpm b/pkgmngt/packageManager.xml.rpm
new file mode 100644
index 0000000..81f9b46
--- /dev/null
+++ b/pkgmngt/packageManager.xml.rpm
@@ -0,0 +1,2403 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--  Above is a mandatory header for xml files. It must be the first
+line in the file. Change encoding to the one you use on your computer -->
+<!-- $Id$ -->
+<!-- Mandatory DOCTYPE declaration. Fill free to add entities,
+but no external entities in local files, since they would not
+be accessible from JHALFSDIR. Change the document type `article' to
+book if you prefer. That slightly changes the aspect if you render
+it in html -->
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY cpio-version         "2.13">
+<!ENTITY elfutils-version     "0.185">
+<!ENTITY libarchive-version   "3.5.1">
+<!ENTITY libassuan-version    "2.5.5">
+<!ENTITY libgpg-error-version "1.42">
+<!ENTITY libgcrypt-version    "1.9.3">
+<!ENTITY libxml2-version      "2.9.12">
+<!ENTITY libxml2-testsuite-version "20130923">
+<!ENTITY lua-version          "5.4.3">
+<!ENTITY lua-minor            "5.4">
+<!ENTITY nettle-version       "3.7.3">
+<!ENTITY pip-version          "21.1.3">
+<!ENTITY popt-version         "1.18">
+<!ENTITY pth-version          "2.0.7">
+<!ENTITY rpm-version          "4.16.1.3">
+<!ENTITY setuptools-version   "56.0.0">
+<!ENTITY sqlite-version       "3.36.0">
+<!ENTITY sqlite-short-version "3360000">
+<!ENTITY unzip-version        "6.0">
+<!ENTITY cpio-url           "https://ftp.gnu.org/gnu/cpio/cpio-&cpio-version;.tar.bz2">
+<!ENTITY elfutils-url       "https://sourceware.org/ftp/elfutils/&elfutils-version;/elfutils-&elfutils-version;.tar.bz2">
+<!ENTITY libarchive-url     "https://github.com/libarchive/libarchive/releases/download/&libarchive-version;/libarchive-&libarchive-version;.tar.xz">
+<!ENTITY libassuan-url      "https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-&libassuan-version;.tar.bz2">
+<!ENTITY libgpg-error-url   "https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-&libgpg-error-version;.tar.bz2">
+<!ENTITY libgcrypt-url      "https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-&libgcrypt-version;.tar.bz2">
+<!ENTITY libxml2-url        "http://xmlsoft.org/sources/libxml2-&libxml2-version;.tar.gz">
+<!ENTITY libxml2-testsuite  "xmlts&libxml2-testsuite-version;.tar.gz">
+<!ENTITY libxml2-testsuite-url "https://www.w3.org/XML/Test/&libxml2-testsuite;">
+<!ENTITY lua-url            "https://www.lua.org/ftp/lua-&lua-version;.tar.gz">
+<!ENTITY lua-patch          "lua-&lua-version;-shared_library-1.patch">
+<!ENTITY lua-patch-url      "https://www.linuxfromscratch.org/patches/blfs/svn/&lua-patch;">
+<!ENTITY nettle-url         "https://ftp.gnu.org/gnu/nettle/nettle-&nettle-version;.tar.gz">
+<!ENTITY pip-url            "https://files.pythonhosted.org/packages/4d/0c/3b63fe024414a8a48661cf04f0993d4b2b8ef92daed45636474c018cd5b7/pip-&pip-version;.tar.gz">
+<!ENTITY popt-url           "https://ftp.osuosl.org/pub/rpm/popt/releases/popt-1.x/popt-&popt-version;.tar.gz">
+<!ENTITY pth-url            "https://ftp.gnu.org/gnu/pth/pth-&pth-version;.tar.gz">
+<!ENTITY rpm-url            "https://ftp.osuosl.org/pub/rpm/releases/rpm-4.16.x/rpm-&rpm-version;.tar.bz2">
+<!ENTITY setuptools-url     "https://files.pythonhosted.org/packages/f6/e9/19af16328705915233299f6f1f02db95899fb00c75ac9da4757aa1e5d1de/setuptools-&setuptools-version;.tar.gz">
+<!ENTITY sqlite-url         "https://sqlite.org/2021/sqlite-autoconf-&sqlite-short-version;.tar.gz">
+<!ENTITY sqlite-doc-url     "https://sqlite.org/2021/sqlite-doc-&sqlite-short-version;.zip">
+<!ENTITY unzip-url          "https://downloads.sourceforge.net/infozip/unzip60.tar.gz">
+<!ENTITY unzip-patch        "unzip-6.0-consolidated_fixes-1.patch">
+<!ENTITY unzip-patch-url    "https://www.linuxfromscratch.org/patches/blfs/svn/&unzip-patch;">
+<!ENTITY cpio-md5           "f3438e672e3fa273a7dc26339dd1eed6">
+<!ENTITY elfutils-md5       "2b6e94c2eebc1f2194173e31bca9396e">
+<!ENTITY libarchive-md5     "1f8c29149832baff8bae232fd2f9b0ec">
+<!ENTITY libassuan-md5      "7194453152bb67e3d45da698762b5d6f">
+<!ENTITY libgpg-error-md5   "133fed221ba8f63f5842858a1ff67cb3">
+<!ENTITY libgcrypt-md5      "3fcb490b9b7347344708eeb7b4a95464">
+<!ENTITY libxml2-md5        "f433a39be087a9f0b197eb2307ad9f75">
+<!ENTITY libxml2-testsuite-md5 "ef8fbe0c92efd9a60d7f320e211d10b2">
+<!ENTITY lua-md5            "ef63ed2ecfb713646a7fcc583cf5f352">
+<!ENTITY lua-patch-md5      "2d7ce798932bd2570c356222b0f5d9ba">
+<!ENTITY nettle-md5         "a60273d0fab9c808646fcf5e9edc2e8f">
+<!ENTITY pip-md5            "e459d41a10ce33688b5d389216a8876f">
+<!ENTITY popt-md5           "450f2f636e6a3aa527de803d0ae76c5a">
+<!ENTITY pth-md5            "9cb4a25331a4c4db866a31cbe507c793">
+<!ENTITY rpm-md5            "576277fafa5d0681a8a92c8716aca5f0">
+<!ENTITY setuptools-md5     "d9715b19a0d894539285655fd5c69109">
+<!ENTITY sqlite-md5         "f5752052fc5b8e1b539af86a3671eac7">
+<!ENTITY sqlite-doc-md5     "9abe65c7295fd0a2462f7c61f95400fd">
+<!ENTITY unzip-md5          "62b490407489521db863b523a7f86375">
+<!ENTITY unzip-patch-md5    "14c119ef7019f769497363e5cec306e0">
+<!ENTITY % general-entities SYSTEM "BOOK/general.ent">
+%general-entities;
+]>
+
+
+<!-- The first markup should be the one defined in the DOCTYPE DECLARATION -->
+<article>
+
+<!-- First section for the tarball download address.
+Only the next four lines are mandatory, but you can add anything
+to make the text look more like the LFS book.
+Do not change  anything, except the url and the md5 checksum. -->
+<sect1 id="package">
+  <?dbhtml filename="package.html"?>
+
+  <title>All Packages</title>
+        <para>Download: <ulink url="&cpio-url;"/></para>
+        <para>MD5 sum: <literal>&cpio-md5;</literal></para>
+        <para>Download: <ulink url="&libarchive-url;"/></para>
+        <para>MD5 sum: <literal>&libarchive-md5;</literal></para>
+        <para>Download: <ulink url="&libassuan-url;"/></para>
+        <para>MD5 sum: <literal>&libassuan-md5;</literal></para>
+        <para>Download: <ulink url="&libgcrypt-url;"/></para>
+        <para>MD5 sum: <literal>&libgcrypt-md5;</literal></para>
+        <para>Download: <ulink url="&libgpg-error-url;"/></para>
+        <para>MD5 sum: <literal>&libgpg-error-md5;</literal></para>
+        <para>Download: <ulink url="&libxml2-url;"/></para>
+        <para>MD5 sum: <literal>&libxml2-md5;</literal></para>
+        <para>Download: <ulink url="&libxml2-testsuite-url;"/></para>
+        <para>MD5 sum: <literal>&libxml2-testsuite-md5;</literal></para>
+        <para>Download: <ulink url="&lua-url;"/></para>
+        <para>MD5 sum: <literal>&lua-md5;</literal></para>
+        <para>Download: <ulink url="&nettle-url;"/></para>
+        <para>MD5 sum: <literal>&nettle-md5;</literal></para>
+        <para>Download: <ulink url="&pip-url;"/></para>
+        <para>MD5 sum: <literal>&pip-md5;</literal></para>
+        <para>Download: <ulink url="&popt-url;"/></para>
+        <para>MD5 sum: <literal>&popt-md5;</literal></para>
+        <para>Download: <ulink url="&pth-url;"/></para>
+        <para>MD5 sum: <literal>&pth-md5;</literal></para>
+        <para>Download: <ulink url="&rpm-url;"/></para>
+        <para>MD5 sum: <literal>&rpm-md5;</literal></para>
+        <para>Download: <ulink url="&setuptools-url;"/></para>
+        <para>MD5 sum: <literal>&setuptools-md5;</literal></para>
+        <para>Download: <ulink url="&sqlite-url;"/></para>
+        <para>MD5 sum: <literal>&sqlite-md5;</literal></para>
+        <para>Download: <ulink url="&sqlite-doc-url;"/></para>
+        <para>MD5 sum: <literal>&sqlite-doc-md5;</literal></para>
+        <para>Download: <ulink url="&unzip-url;"/></para>
+        <para>MD5 sum: <literal>&unzip-md5;</literal></para>
+</sect1>
+
+<sect1 id="patches">
+        <para>Download: <ulink url="&lua-patch-url;"/></para>
+        <para>MD5 sum: <literal>&lua-patch-md5;</literal></para>
+        <para>Download: <ulink url="&unzip-patch-url;"/></para>
+        <para>MD5 sum: <literal>&unzip-patch-md5;</literal></para>
+</sect1>
+
+<!-- Removed ch-tools as newer book is required anyway -->
+
+<!-- version for new book: needs ninja and meson, which needs
+     Python rebuilt with libffi and zlib. Needs also pkg-config -->
+<sect1 id="ch-chroot-bzip2" role="wrap">
+  <?dbhtml filename="bzip2.html"?>
+
+  <sect1info condition="script">
+    <productname>bzip2</productname>
+    <productnumber>&bzip2-version;</productnumber>
+    <address>&bzip2-url;</address>
+  </sect1info>
+
+  <title>Bzip2-&bzip2-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="pre">patch -Np1 -i ../bzip2-1.0.8-install_docs-1.patch
+sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
+sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile</userinput></screen>
+<screen><userinput remap="make">make -f Makefile-libbz2_so
+make clean
+make</userinput></screen>
+<screen><userinput remap="install">make PREFIX=/usr install
+cp -av libbz2.so.* /usr/lib
+cp -v bzip2-shared /usr/bin/bzip2
+rm -fv /usr/lib/libbz2.a
+ln -sv libbz2.so.1.0.8 /usr/lib/libbz2.so</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-libgpg-error" role="wrap">
+  <?dbhtml filename="libgpg-error.html"?>
+
+  <sect1info condition="script">
+    <productname>libgpg-error</productname>
+    <productnumber>&libgpg-error-version;</productnumber>
+    <address>&libgpg-error-url;</address>
+  </sect1info>
+
+  <title>libgpg-error-&libgpg-error-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-libassuan" role="wrap">
+  <?dbhtml filename="libassuan.html"?>
+
+  <sect1info condition="script">
+    <productname>libassuan</productname>
+    <productnumber>&libassuan-version;</productnumber>
+    <address>&libassuan-url;</address>
+  </sect1info>
+
+  <title>libassuan-&libassuan-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-pth" role="wrap">
+  <?dbhtml filename="pth.html"?>
+
+  <sect1info condition="script">
+    <productname>pth</productname>
+    <productnumber>&pth-version;</productnumber>
+    <address>&pth-url;</address>
+  </sect1info>
+
+  <title>pth-&pth-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="pre">sed -i 's#$(LOBJS): Makefile#$(LOBJS): pth_p.h Makefile#' Makefile.in</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr \
+           --mandir=/usr/share/man</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-libgcrypt" role="wrap">
+  <?dbhtml filename="libgcrypt.html"?>
+
+  <sect1info condition="script">
+    <productname>libgcrypt</productname>
+    <productnumber>&libgcrypt-version;</productnumber>
+    <address>&libgcrypt-url;</address>
+  </sect1info>
+
+  <title>libgcrypt-&libgcrypt-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-libffi" role="wrap">
+  <?dbhtml filename="libffi.html"?>
+
+  <sect1info condition="script">
+    <productname>libffi</productname>
+    <productnumber>&libffi-version;</productnumber>
+    <address>&libffi-url;</address>
+  </sect1info>
+
+  <title>libffi-&libffi-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr --disable-static --with-gcc-arch=native</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-zlib" role="wrap">
+  <?dbhtml filename="zlib.html"?>
+
+  <sect1info condition="script">
+    <productname>zlib</productname>
+    <productnumber>&zlib-version;</productnumber>
+    <address>&zlib-url;</address>
+  </sect1info>
+
+  <title>zlib-&zlib-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install
+rm -fv /usr/lib/libz.a</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-openssl" role="wrap">
+  <?dbhtml filename="openssl.html"?>
+
+  <sect1info condition="script">
+    <productname>openssl</productname>
+    <productnumber>&openssl-version;</productnumber>
+    <address>&openssl-url;</address>
+  </sect1info>
+
+  <title>openssl-&openssl-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./config --prefix=/usr         \
+         --openssldir=/etc/ssl \
+         --libdir=lib          \
+         shared                \
+         zlib-dynamic</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
+make MANSUFFIX=ssl install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-sqlite" role="wrap">
+  <?dbhtml filename="sqlite.html"?>
+
+  <sect1info condition="script">
+    <productname>sqlite</productname>
+    <productnumber>&sqlite-short-version;</productnumber>
+    <address>&sqlite-url;</address>
+  </sect1info>
+
+  <title>sqlite-&sqlite-short-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr     \
+            --disable-static  \
+            --enable-fts5     \
+            CPPFLAGS="-DSQLITE_ENABLE_FTS3=1  \
+            -DSQLITE_ENABLE_FTS4=1            \
+            -DSQLITE_ENABLE_COLUMN_METADATA=1 \
+            -DSQLITE_ENABLE_UNLOCK_NOTIFY=1   \
+            -DSQLITE_ENABLE_DBSTAT_VTAB=1     \
+            -DSQLITE_SECURE_DELETE=1          \
+            -DSQLITE_ENABLE_FTS3_TOKENIZER=1"</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-gmp" role="wrap">
+  <?dbhtml filename="gmp.html"?>
+
+  <sect1info condition="script">
+    <productname>gmp</productname>
+    <productnumber>&gmp-version;</productnumber>
+    <address>&gmp-url;</address>
+  </sect1info>
+
+  <title>gmp-&gmp-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="pre">cp -v configfsf.guess config.guess
+cp -v configfsf.sub   config.sub</userinput></screen>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --enable-cxx     \
+            --disable-static \
+            --docdir=/usr/share/doc/gmp-6.2.1</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-nettle" role="wrap">
+  <?dbhtml filename="nettle.html"?>
+
+  <sect1info condition="script">
+    <productname>nettle</productname>
+    <productnumber>&nettle-version;</productnumber>
+    <address>&nettle-url;</address>
+  </sect1info>
+
+  <title>nettle-&nettle-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr --disable-static</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install
+chmod -v 755 /usr/lib/lib{hogweed,nettle}.so</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-libarchive" role="wrap">
+  <?dbhtml filename="libarchive.html"?>
+
+  <sect1info condition="script">
+    <productname>libarchive</productname>
+    <productnumber>&libarchive-version;</productnumber>
+    <address>&libarchive-url;</address>
+  </sect1info>
+
+  <title>Libarchive-&libarchive-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr \
+            --disable-static</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-expat" role="wrap">
+  <?dbhtml filename="expat.html"?>
+
+  <sect1info condition="script">
+    <productname>expat</productname>
+    <productnumber>&expat-version;</productnumber>
+    <address>&expat-url;</address>
+  </sect1info>
+
+  <title>expat-&expat-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr    \
+            --disable-static \
+            --docdir=/usr/share/doc/expat-&expat-version;</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-pkg-config" role="wrap">
+  <?dbhtml filename="pkg-config.html"?>
+
+  <sect1info condition="script">
+    <productname>pkg-config</productname>
+    <productnumber>&pkgconfig-version;</productnumber>
+    <address>&pkgconfig-url;</address>
+  </sect1info>
+
+  <title>pkgconfig-&pkgconfig-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr              \
+            --with-internal-glib       \
+            --disable-host-tool        \
+            --docdir=/usr/share/doc/pkg-config-&pkgconfig-version;</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-python" role="wrap">
+  <?dbhtml filename="python.html"?>
+
+  <sect1info condition="script">
+    <productname>python</productname>
+    <productnumber>&python-version;</productnumber>
+    <address>&python-url;</address>
+  </sect1info>
+
+  <title>Python-&python-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr        \
+            --enable-shared      \
+            --with-system-expat  \
+            --with-system-ffi    \
+            --with-ensurepip=yes \
+            --enable-optimizations</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-setuptools" role="wrap">
+  <?dbhtml filename="setuptools.html"?>
+
+  <sect1info condition="script">
+    <productname>setuptools</productname>
+    <productnumber>&setuptools-version;</productnumber>
+    <address>&setuptools-url;</address>
+  </sect1info>
+
+  <title>setuptools-&setuptools-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="make">python3 setup.py build</userinput></screen>
+<screen><userinput remap="install">python3 setup.py install --optimize=1 --skip-build</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-pip" role="wrap">
+  <?dbhtml filename="pip.html"?>
+
+  <sect1info condition="script">
+    <productname>pip</productname>
+    <productnumber>&pip-version;</productnumber>
+    <address>&pip-url;</address>
+  </sect1info>
+
+  <title>pip-&pip-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="make">python3 setup.py build</userinput></screen>
+<screen><userinput remap="install">python3 setup.py install --prefix=/usr --optimize=1
+ln -sfv pip3.9 /usr/bin/pip3
+ln -sfv pip3.9 /usr/bin/pip</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-libcap" role="wrap">
+  <?dbhtml filename="libcap.html"?>
+
+  <sect1info condition="script">
+    <productname>libcap</productname>
+    <productnumber>&libcap-version;</productnumber>
+    <address>&libcap-url;</address>
+  </sect1info>
+
+  <title>libcap-&libcap-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="make">make prefix=/usr lib=lib</userinput></screen>
+<screen><userinput remap="install">make prefix=/usr lib=lib install
+chmod -v 755 /lib/lib{cap,psx}.so.&libcap-version;
+rm -f /usr/lib/lib{cap,psx}.a</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-elfutils" role="wrap">
+  <?dbhtml filename="elfutils.html"?>
+
+  <sect1info condition="script">
+    <productname>elfutils</productname>
+    <productversion>&elfutils-version;</productversion>
+    <address>&elfutils-url;</address>
+  </sect1info>
+
+  <title>elfutils-&elfutils-version;</title>
+
+  <sect2 role="installation">>
+    <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr                \
+            --disable-debuginfod         \
+            --enable-libdebuginfod=dummy</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+</sect1>
+
+<sect1 id="ch-chroot-popt" role="wrap">
+  <?dbhtml filename="popt.html"?>
+
+  <sect1info condition="script">
+    <productname>popt</productname>
+    <productversion>&popt-version;</productversion>
+    <address>&popt-url;</address>
+  </sect1info>
+
+  <title>popt-&popt-version;</title>
+
+  <sect2 role="installation">
+  <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr --disable-static</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install</userinput></screen>
+  </sect2>
+</sect1>
+
+<sect1 id="ch-chroot-lua" role="wrap">
+  <?dbhtml filename="lua.html"?>
+
+  <sect1info condition="script">
+    <productname>lua</productname>
+    <productversion>&lua-version;</productversion>
+    <address>&lua-url;</address>
+  </sect1info>
+
+  <title>lua-&lua-version;</title>
+
+  <sect2 role="installation">
+  <title/>
+<screen><userinput remap="pre">cat &gt; lua.pc &lt;&lt; "EOF"
+V=5.4
+R=5.4.3
+
+prefix=/usr
+INSTALL_BIN=${prefix}/bin
+INSTALL_INC=${prefix}/include
+INSTALL_LIB=${prefix}/lib
+INSTALL_MAN=${prefix}/share/man/man1
+INSTALL_LMOD=${prefix}/share/lua/${V}
+INSTALL_CMOD=${prefix}/lib/lua/${V}
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: Lua
+Description: An Extensible Extension Language
+Version: ${R}
+Requires:
+Libs: -L${libdir} -llua -lm -ldl
+Cflags: -I${includedir}
+EOF
+patch -Np1 -i ../lua-5.4.3-shared_library-1.patch</userinput></screen>
+<screen><userinput remap="make">make linux</userinput></screen>
+<screen><userinput remap="install">make INSTALL_TOP=/usr                \
+     INSTALL_DATA="cp -d"            \
+     INSTALL_MAN=/usr/share/man/man1 \
+     TO_LIB="liblua.so liblua.so.5.4 liblua.so.5.4.3" \
+     install
+install -v -m644 -D lua.pc /usr/lib/pkgconfig/lua.pc</userinput></screen>
+  </sect2>
+</sect1>
+
+<sect1 id="ch-chroot-rpm" role="wrap">
+  <?dbhtml filename="rpm.html"?>
+
+  <sect1info condition="script">
+    <productname>rpm</productname>
+    <productversion>&rpm-version;</productversion>
+    <address>&rpm-url;</address>
+  </sect1info>
+
+  <title>rpm-&rpm-version;</title>
+
+  <sect2 role="installation">
+  <title/>
+<screen><userinput remap="configure">./configure --prefix=/usr        \
+            --sysconfdir=/etc    \
+            --localstatedir=/var \
+            --disable-bdb</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make install
+sed /_db_backend/s/bdb/sqlite/ -i /usr/lib/rpm/macros</userinput></screen>
+  </sect2>
+</sect1>
+
+<sect1 id="ch-chroot-shadow" role="wrap">
+  <?dbhtml filename="shadow.html"?>
+
+  <sect1info condition="script">
+    <productname>shadow</productname>
+    <productnumber>&shadow-version;</productnumber>
+    <address>&shadow-url;</address>
+  </sect1info>
+
+  <title>shadow-&shadow-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="pre">sed -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD SHA512:' \
+    -e 's:/var/spool/mail:/var/mail:'                 \
+    -e '/PATH=/{s@/sbin:@@;s@/bin:@@}'                \
+    -i etc/login.defs
+sed -e "224s/rounds/min_rounds/" -i libmisc/salt.c</userinput></screen>
+<screen><userinput remap="configure">touch /usr/bin/passwd
+./configure --sysconfdir=/etc \
+            --with-group-name-max-length=32</userinput></screen>
+<screen><userinput remap="make">make</userinput></screen>
+<screen><userinput remap="install">make exec_prefix=/usr install
+mkdir -p /etc/default
+useradd -D --gid 999</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<!-- It is not ideal to do build the next two packages here ( without officially
+     being in chapter08), but it gets the order correct, and we already do this
+     in LFS with the linux-api-headers package, it must be done here as well-->
+
+<sect1 id="ch-chroot-rootfs" role="wrap">
+  <?dbhtml filename="rootfs.html"?>
+
+  <sect1info condition="script">
+    <productname>rootfs</productname>
+    <productnumber>1.0</productnumber>
+    <address>https://www.linuxfromscratch.org/</address>
+  </sect1info>
+
+  <title>rootfs-1.0</title>
+
+  <sect2 role="installation">
+    <title/>
+
+<screen><userinput remap="install"># Not actually part of the package, but this needs to be done now...
+# Delete all man/info pages, documentation, and libtool archives
+rm -rf /usr/share/man/*
+rm -f /usr/share/info/*
+rm -rf /usr/share/doc/*
+find /usr/{lib,libexec} -name \*.la -delete
+rpm --initdb --root=/
+mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS,BUILDROOT}
+
+# Here we create our first pacakge
+# Note: this combines many sections from LFS and configuration files that
+# will be overwritten as jhalfs progresses
+mkdir -p rootfs
+cd rootfs
+cat &gt; rootfs.spec &lt;&lt; "REALEOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: rootfs
+Version: 1.0
+Release: 1
+Summary: Basic root filesystem
+License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0
+Group: base
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+
+%description
+Contains the basic root filesystem layout and initial configuration files
+
+%prep
+# Nothing to do
+
+%build
+# Nothing to do
+
+%install
+# LFS Section 4.2
+install -vdm755 %{buildroot}/{etc,lib64,usr/{bin,lib,sbin},var}
+for i in bin lib sbin; do
+  ln -sv usr/$i %{buildroot}/$i
+done
+
+# LFS Section 7.3
+install -vdm755 %{buildroot}/{dev,proc,run,sys}
+
+# LFS Section 7.3.1
+mknod -m 666 %{buildroot}/dev/console c 5 1
+mknod -m 666 %{buildroot}/dev/null c 1 3
+
+# LFS Section 7.5
+install -vdm755 %{buildroot}/{boot,home,mnt,opt,srv}
+install -vdm755 %{buildroot}/etc/{opt,sysconfig}
+install -vdm755 %{buildroot}/usr/lib/firmware
+install -vdm755 %{buildroot}/media/{floppy,cdrom}
+install -vdm755 %{buildroot}/usr/{,local/}{bin,include,lib,sbin,src}
+install -vdm755 %{buildroot}/usr/{,local/}share/{color,dict,doc,info,locale,man}
+install -vdm755 %{buildroot}/usr/{,local/}share/{misc,terminfo,zoneinfo}
+install -vdm755 %{buildroot}/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
+install -vdm755 %{buildroot}/var/{cache,local,log,mail,opt,spool}
+install -vdm755 %{buildroot}/var/lib/{color,misc,locate}
+install -vdm750 %{buildroot}/root
+install -vdm1777 %{buildroot}{,/var}/tmp
+ln -sfv /run %{buildroot}/var/run
+ln -sfv /run/lock %{buildroot}/var/lock
+
+# LFS Section 7.6
+ln -sv /proc/self/mounts %{buildroot}/etc/mtab
+cat &gt; %{buildroot}/etc/passwd &lt;&lt; "EOF"
+root:x:0:0:root:/root:/bin/bash
+bin:x:1:1:bin:/dev/null:/bin/false
+daemon:x:6:6:Daemon User:/dev/null:/bin/false
+messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/bin/false
+uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/bin/false
+nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
+tester:x:1001:101::/home/tester:/bin/bash
+EOF
+cat &gt; %{buildroot}/etc/group &lt;&lt; "EOF"
+root:x:0:
+bin:x:1:daemon
+sys:x:2:
+kmem:x:3:
+tape:x:4:
+tty:x:5:
+daemon:x:6:
+floppy:x:7:
+disk:x:8:
+lp:x:9:
+dialout:x:10:
+audio:x:11:
+video:x:12:
+utmp:x:13:
+usb:x:14:
+cdrom:x:15:
+adm:x:16:
+messagebus:x:18:
+input:x:24:
+mail:x:34:
+kvm:x:61:
+uuidd:x:80:
+wheel:x:97:
+nogroup:x:99:
+users:x:999:
+tester:x:101:
+EOF
+
+touch %{buildroot}/var/log/{btmp,lastlog,faillog,wtmp}
+chgrp -v utmp %{buildroot}/var/log/lastlog
+chmod -v 664  %{buildroot}/var/log/lastlog
+chmod -v 600  %{buildroot}/var/log/btmp
+
+# LFS Sections 7.6 and 9.5.4
+cat &gt; %{buildroot}/etc/hosts &lt;&lt; "EOF"
+# Begin /etc/hosts
+
+# IPv4
+127.0.0.1 localhost.localdomain localhost
+# Populate the follwoing lines after installation
+#127.0.1.1 &lt;FQDN&gt; &lt;HOSTNAME&gt;
+#&lt;192.168.1.1&gt; &lt;FQDN&gt; &lt;HOSTNAME&gt; [alias1] [alias2 ...]
+
+# IPv6
+::1       localhost ip6-localhost ip6-loopback
+ff02::1   ip6-allnodes
+ff02::2   ip6-allrouters
+
+# End /etc/hosts
+EOF
+
+# LFS Section 8.5.2.3
+install -vdm755 %{buildroot}/etc/ld.so.conf.d/
+cat &gt; %{buildroot}/etc/ld.so.conf &lt;&lt; "EOF"
+# Begin /etc/ld.so.conf
+
+/usr/local/lib
+/opt/lib
+
+# Add an include directory
+include /etc/ld.so.conf.d/*.conf
+
+# End /etc/ld.so.conf
+EOF
+
+# LFS Section 9.5.2
+cat &gt; %{buildroot}/etc/resolv.conf &lt;&lt; "EOF"
+# Begin /etc/resolv.conf
+
+domain localdomain
+nameserver 8.8.8.8
+nameserver 8.8.4.4
+
+# End /etc/resolv.conf
+EOF
+
+# LFS Section 9.5.3
+echo "lfs" &gt; %{buildroot}/etc/hostname
+
+# LFS Section 9.8
+cat &gt; %{buildroot}/etc/inputrc &lt;&lt; "EOF"
+# Begin /etc/inputrc
+# Modified by Chris Lynn &lt;roryo@roryo.dynup.net&gt;
+
+# Allow the command prompt to wrap to the next line
+set horizontal-scroll-mode Off
+
+# Enable 8bit input
+set meta-flag On
+set input-meta On
+
+# Turns off 8th bit stripping
+set convert-meta Off
+
+# Keep the 8th bit for display
+set output-meta On
+
+# none, visible or audible
+set bell-style none
+
+# All of the following map the escape sequence of the value
+# contained in the 1st argument to the readline specific functions
+"\eOd": backward-word
+"\eOc": forward-word
+
+# for linux console
+"\e[1~": beginning-of-line
+"\e[4~": end-of-line
+"\e[5~": beginning-of-history
+"\e[6~": end-of-history
+"\e[3~": delete-char
+"\e[2~": quoted-insert
+
+# for xterm
+"\eOH": beginning-of-line
+"\eOF": end-of-line
+
+# for Konsole
+"\e[H": beginning-of-line
+"\e[F": end-of-line
+
+# End /etc/inputrc
+EOF
+
+  # LFS Section 9.9
+  cat &gt; %{buildroot}/etc/shells &lt;&lt; "EOF"
+# Begin /etc/shells
+
+/bin/sh
+/bin/bash
+
+# End /etc/shells
+EOF
+
+# LFS Section 10.2
+cat &gt; %{buildroot}/etc/fstab &lt;&lt; "EOF"
+# Begin /etc/fstab
+
+# file system  mount-point  type     options             dump  fsck
+#                                                              order
+/dev/&lt;xxx&gt;     /            &lt;fff&gt;    defaults            1     1
+/dev/&lt;yyy&gt;     swap         swap     pri=1               0     0
+proc           /proc        proc     nosuid,noexec,nodev 0     0
+sysfs          /sys         sysfs    nosuid,noexec,nodev 0     0
+devpts         /dev/pts     devpts   gid=5,mode=620      0     0
+tmpfs          /run         tmpfs    defaults            0     0
+devtmpfs       /dev         devtmpfs mode=0755,nosuid    0     0
+
+# End /etc/fstab
+EOF
+
+# Post LFS fixes:
+touch %{buildroot}/usr/share/info/dir
+chmod 0644 %{buildroot}/usr/share/info/dir
+touch %{buildroot}/etc/ld.so.cache
+chmod 0644 %{buildroot}/etc/ld.so.cache
+chmod 0555 %{buildroot}/proc
+chmod 1777 %{buildroot}/run
+chmod 0555 %{buildroot}/sys
+
+#### Generic addition to install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed -i '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed -i '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+%pre
+# Nothing to do
+
+%post
+# Nothing to do
+
+%preun
+# Nothing to do
+
+%postun
+# Nothing to do
+
+REALEOF
+mv rootfs.spec /root/rpmbuild/SPECS
+rpmbuild -ba /root/rpmbuild/SPECS/rootfs.spec
+rpm --install --nodeps --justdb \
+    /root/rpmbuild/RPMS/$(uname -m)/rootfs-1.0-1.$(uname -m).rpm
+rpm --install --nodeps --replacepkgs \
+    /root/rpmbuild/RPMS/$(uname -m)/rootfs-1.0-1.$(uname -m).rpm
+rm -rf /root/rpmbuild/BUILDROOT/rootfs-1.0/</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-chroot-linux-api-headers" role="wrap">
+  <?dbhtml filename="linux-api-headers.html"?>
+
+  <sect1info condition="script">
+    <productname>linux-api-headers</productname>
+    <productnumber>&linux-version;</productnumber>
+    <address>&linux-url;</address>
+  </sect1info>
+
+  <title>linux-api-headers-&linux-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+
+<screen><userinput remap="install">mkdir linux-api-headers
+cd linux-api-headers
+cat &gt; linux-api-headers.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: linux-api-headers
+Version: &linux-version;
+Release: 1
+Summary: Linux API Headers
+License: LGPL
+Group: base
+BuildRequires: bash binutils coreutils findutils gcc glibc grep gzip make perl sed
+Requires: rootfs
+Source: linux-&linux-version;.tar.xz
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+The Linux API Headers expose the kernel's API for use by Glibc.
+
+%prep
+%setup -n linux-%{version}
+make mrproper
+
+%build
+make headers
+find usr/include -name '.*' -delete
+rm usr/include/Makefile
+
+%check
+# Nothing to do
+
+%install
+mkdir -pv %{buildroot}/usr
+cp -rv usr/include %{buildroot}/usr/
+
+#### Generic addition to install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+%pre
+# Nothing to do
+
+%post
+# Nothing to do
+
+%preun
+# Nothing to do
+
+%postun
+# Nothing to do
+
+EOF
+mv linux-api-headers.spec /root/rpmbuild/SPECS/
+cp /sources/linux-&linux-version;.tar.xz /root/rpmbuild/SOURCES/
+rpmbuild -ba --nodeps /root/rpmbuild/SPECS/linux-api-headers.spec
+rpm --install --nodeps --justdb \
+    /root/rpmbuild/RPMS/$(uname -m)/linux-api-headers-&linux-version;-1.$(uname -m).rpm
+rpm --install --nodeps --replacepkgs \
+    /root/rpmbuild/RPMS/$(uname -m)/linux-api-headers-&linux-version;-1.$(uname -m).rpm
+rm -rf /root/rpmbuild/BUILD/linux-api-headers-&linux-version;</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<!-- Mandatory section for creating dirs. These instructions are added at the
+end of the creating dirs instructions of the book. Do not change the
+following line -->
+<sect1 id="ch-pkgmngt-creatingdirs">
+
+  <title>Creating Directories</title>
+
+<screen><userinput> </userinput></screen>
+
+</sect1>
+<!-- Same for files. Do not change the following line -->
+<sect1 id="ch-pkgmngt-createfiles">
+
+  <title>Creating Essential Files</title>
+
+<screen><userinput> </userinput></screen>
+
+</sect1>
+
+<!-- Last but not least : Final instructions for installing the
+package manager at the end of chapter 6. Again, the scriptlet file name is
+taken from the dbhtml instruction, with digits added before and .html cut
+and the tarball name is formed from this name + version. So the file
+here _must_ be the same as in chapter 5. If rendering in html, both
+sets of instructions end up in the same file, which is usually not a problem.
+-->
+
+<sect1 id="ch-system-base" role="wrap">
+  <?dbhtml filename="base.html"?>
+
+  <sect1info condition="script">
+    <productname>base</productname>
+    <productnumber>1.0</productnumber>
+    <address>&lfs-root;</address>
+  </sect1info>
+
+  <title>Base metapackage</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">REQUIRES=""
+for package in $(rpm -qa | sed 's@-[0-9].*@@'); do
+  REQUIRES="${REQUIRES} ${package}"
+done
+cat &gt; base.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: base
+Version: 1.0
+Release: 1
+Summary: base 1.0
+License: CC-BY-SA
+EOF
+echo "Requires: ${REQUIRES}" &gt;&gt; base.spec
+cat &gt;&gt; base.spec &lt;&lt; "EOF"
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+A metapackage that contians all LFS base packages for easier dependency
+management.
+
+%files
+
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-libgpg-error" role="wrap">
+  <?dbhtml filename="libgpg-error.html"?>
+
+  <sect1info condition="script">
+    <productname>libgpg-error</productname>
+    <productnumber>&libgpg-error-version;</productnumber>
+    <address>&libgpg-error-url;</address>
+  </sect1info>
+
+  <title>libgpg-error-&libgpg-error-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; libgpg-error.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: libgpg-error
+Version: &libgpg-error-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Source0: libgpg-error-&libgpg-error-version;.tar.bz2
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}-%{version}
+
+%build
+./configure --prefix=/usr
+make
+
+%check
+make check
+
+%install
+make DESTDIR="%{buildroot}" install
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-libassuan" role="wrap">
+  <?dbhtml filename="libassuan.html"?>
+
+  <sect1info condition="script">
+    <productname>libassuan</productname>
+    <productnumber>&libassuan-version;</productnumber>
+    <address>&libassuan-url;</address>
+  </sect1info>
+
+  <title>libassuan-&libassuan-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; libassuan.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: libassuan
+Version: &libassuan-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base
+BuildRequires: base libgpg-error
+Requires: base libgpg-error
+Source0: libassuan-&libassuan-version;.tar.bz2
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup %{name}-%{version}
+
+%build
+./configure --prefix=/usr
+make
+
+%check
+make check
+
+%install
+make DESTDIR="%{buildroot}" install
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-pth" role="wrap">
+  <?dbhtml filename="pth.html"?>
+
+  <sect1info condition="script">
+    <productname>pth</productname>
+    <productnumber>&pth-version;</productnumber>
+    <address>&pth-url;</address>
+  </sect1info>
+
+  <title>pth-&pth-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; pth.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: pth
+Version: &pth-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Source0: pth-&pth-version;.tar.gz
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}-%{version}
+sed -i 's#$(LOBJS): Makefile#$(LOBJS): pth_p.h Makefile#' Makefile.in
+
+%build
+./configure --prefix=/usr \
+            --mandir=/usr/share/man
+make
+
+%check
+make check
+
+%install
+make -j1 DESTDIR="%{buildroot}" install
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-libgcrypt" role="wrap">
+  <?dbhtml filename="libgcrypt.html"?>
+
+  <sect1info condition="script">
+    <productname>libgcrypt</productname>
+    <productnumber>&libgcrypt-version;</productnumber>
+    <address>&libgcrypt-url;</address>
+  </sect1info>
+
+  <title>libgcrypt-&libgcrypt-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; libgcrypt.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: libgcrypt
+Version: &libgcrypt-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Suggests: libedit
+Source0: libgcrypt-&libgcrypt-version;.tar.bz2
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup %{name}-%{version}
+
+%build
+./configure --prefix=/usr
+make
+
+%check
+make check
+
+%install
+make DESTDIR="%{buildroot}" install
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-unzip" role="wrap">
+  <?dbhtml filename="unzip.html"?>
+
+  <sect1info condition="script">
+    <productname>unzip</productname>
+    <productnumber>&unzip-version;</productnumber>
+    <address>&unzip-url;</address>
+  </sect1info>
+
+  <title>unzip-&unzip-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; unzip.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: unzip
+Version: &unzip-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Source0: unzip60.tar.gz
+Patch0: &unzip-patch;
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&gt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}60
+%patch0 -p1
+
+%build
+make -f unix/Makefile generic
+
+%install
+make prefix=%{buildroot}/usr MANDIR=%{buildroot}/usr/share/man/man1 \
+     -f unix/Makefile install
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-sqlite" role="wrap">
+  <?dbhtml filename="sqlite.html"?>
+
+  <sect1info condition="script">
+    <productname>sqlite</productname>
+    <productnumber>&sqlite-version;</productnumber>
+    <address>&sqlite-url;</address>
+  </sect1info>
+
+  <title>sqlite-&sqlite-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; sqlite.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: sqlite
+Version: &sqlite-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Suggests: libedit
+Source0: sqlite-autoconf-&sqlite-short-version;.tar.gz
+Source1: sqlite-doc-&sqlite-short-version;.zip
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}-autoconf-&sqlite-short-version;
+unzip -q ../../SOURCES/sqlite-doc-&sqlite-short-version;.zip
+
+%build
+./configure --prefix=/usr     \
+            --disable-static  \
+            --enable-fts5     \
+            CPPFLAGS="-DSQLITE_ENABLE_FTS3=1  \
+            -DSQLITE_ENABLE_FTS4=1            \
+            -DSQLITE_ENABLE_COLUMN_METADATA=1 \
+            -DSQLITE_ENABLE_UNLOCK_NOTIFY=1   \
+            -DSQLITE_ENABLE_DBSTAT_VTAB=1     \
+            -DSQLITE_SECURE_DELETE=1          \
+            -DSQLITE_ENABLE_FTS3_TOKENIZER=1"
+make
+
+%check
+make check
+
+%install
+make DESTDIR="%{buildroot}" install
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-nettle" role="wrap">
+  <?dbhtml filename="nettle.html"?>
+
+  <sect1info condition="script">
+    <productname>nettle</productname>
+    <productnumber>&nettle-version;</productnumber>
+    <address>&nettle-url;</address>
+  </sect1info>
+
+  <title>nettle-&nettle-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; nettle.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: nettle
+Version: &nettle-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Suggests: valgrind
+Source0: nettle-&nettle-version;.tar.gz
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup %{name}-%{version}
+
+%build
+./configure --prefix=/usr --disable-static
+make
+
+%check
+make check
+
+%install
+make DESTDIR="%{buildroot}" install
+chmod -v 755    %{buildroot}/usr/lib/lib{hogweed,nettle}.so
+install -vdm755 %{buildroot}/usr/share/doc/nettle-%{version}
+install -vm644  nettle.html %{buildroot}/usr/share/doc/nettle-%{version}
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-libxml2" role="wrap">
+  <?dbhtml filename="libxml2.html"?>
+
+  <sect1info condition="script">
+    <productname>libxml2</productname>
+    <productnumber>&libxml2-version;</productnumber>
+    <address>&libxml2-url;</address>
+  </sect1info>
+
+  <title>libxml2-&libxml2-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; libxml2.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: libxml2
+Version: &libxml2-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Suggests: icu valgrind
+Source0: libxml2-&libxml2-version;.tar.gz
+Source1: &libxml2-testsuite;
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup %{name}-%{version}
+
+%build
+./configure --prefix=/usr    \
+            --disable-static \
+            --with-history   \
+            --with-python=/usr/bin/python3
+make
+
+%check
+tar -xf ../../SOURCES/&libxml2-testsuite;
+make check
+
+%install
+make DESTDIR="%{buildroot}" install
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+
+<sect1 id="ch-system-libarchive" role="wrap">
+  <?dbhtml filename="libarchive.html"?>
+
+  <sect1info condition="script">
+    <productname>libarchive</productname>
+    <productnumber>&libarchive-version;</productnumber>
+    <address>&libarchive-url;</address>
+  </sect1info>
+
+  <title>libarchive-&libarchive-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; libarchive.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: libarchive
+Version: &libarchive-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base libxml2 nettle
+Requires: base libxml2 nettle
+Suggests: lzo
+Source0: libarchive-&libarchive-version;.tar.xz
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup %{name}-%{version}
+
+%build
+./configure --prefix=/usr --disable-static
+make
+
+%check
+LC_ALL=C make check
+
+%install
+make DESTDIR="%{buildroot}" install
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-setuptools" role="wrap">
+  <?dbhtml filename="setuptools.html"?>
+
+  <sect1info condition="script">
+    <productname>setuptools</productname>
+    <productnumber>&setuptools-version;</productnumber>
+    <address>&setuptools-url;</address>
+  </sect1info>
+
+  <title>setuptools-&setuptools-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; setuptools.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: setuptools
+Version: &setuptools-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Source0: setuptools-&setuptools-version;.tar.gz
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}-%{version}
+
+%build
+python3 setup.py build
+
+%install
+python3 setup.py install --prefix=/usr --root="%{buildroot}" --optimize=1 --skip-build
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+## Special case for setuptools - it has spaces in filenames
+sed '/launcher manifest/s@^/@"/@' -i files.%{name}
+sed '/launcher manifest/s@xml@xml"@' -i files.%{name}
+sed '/script (dev)/s@^/@"/@' -i files.%{name}
+sed '/script (dev)/s@tmpl@tmpl"@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-pip" role="wrap">
+  <?dbhtml filename="pip.html"?>
+
+  <sect1info condition="script">
+    <productname>pip</productname>
+    <productnumber>&pip-version;</productnumber>
+    <address>&pip-url;</address>
+  </sect1info>
+
+  <title>pip-&pip-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; pip.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: pip
+Version: &pip-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base setuptools
+Requires: base
+Source0: pip-&pip-version;.tar.gz
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}-%{version}
+
+%build
+python3 setup.py build
+
+%install
+python3 setup.py install --prefix=/usr --root="%{buildroot}" --optimize=1
+ln -sfv pip3.9 %{buildroot}/usr/bin/pip3
+ln -sfv pip3.9 %{buildroot}/usr/bin/pip
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-popt" role="wrap">
+  <?dbhtml filename="popt.html"?>
+
+  <sect1info condition="script">
+    <productname>popt</productname>
+    <productnumber>&popt-version;</productnumber>
+    <address>&popt-url;</address>
+  </sect1info>
+
+  <title>popt-&popt-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; popt.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: popt
+Version: &popt-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Suggests: doxygen
+Source0: popt-&popt-version;.tar.gz
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}-%{version}
+
+%build
+./configure --prefix=/usr --disable-static
+make
+
+%check
+make check
+
+%install
+make DESTDIR="%{buildroot}" install
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-lua" role="wrap">
+  <?dbhtml filename="lua.html"?>
+
+  <sect1info condition="script">
+    <productname>lua</productname>
+    <productnumber>&lua-version;</productnumber>
+    <address>&lua-url;</address>
+  </sect1info>
+
+  <title>lua-&lua-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; lua.spec &lt;&lt; "REALEOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: lua
+Version: &lua-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Source0: lua-&lua-version;.tar.gz
+Patch0: &lua-patch;
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}-%{version}
+cat &gt; lua.pc &lt;&lt; "EOF"
+V=&lua-minor;
+R=&lua-version;
+
+prefix=/usr
+INSTALL_BIN=${prefix}/bin
+INSTALL_INC=${prefix}/include
+INSTALL_LIB=${prefix}/lib
+INSTALL_MAN=${prefix}/share/man/man1
+INSTALL_LMOD=${prefix}/share/lua/${V}
+INSTALL_CMOD=${prefix}/lib/lua/${V}
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: Lua
+Description: An Extensible Extension Language
+Version: ${R}
+Requires:
+Libs: -L${libdir} -llua -lm -ldl
+Cflags: -I${includedir}
+EOF
+%patch0 -p1
+
+%build
+make linux
+
+%check
+make test
+
+%install
+make INSTALL_TOP=%{buildroot}/usr                     \
+     INSTALL_DATA="cp -d"                             \
+     INSTALL_MAN=%{buildroot}/usr/share/man/man1      \
+     TO_LIB="liblua.so liblua.so.&lua-minor; liblua.so.&lua-version;" \
+     install
+install -vdm755 %{buildroot}/usr/share/doc/lua-&lua-version;
+install -vm644 doc/*.{html,css,gif,png} \
+    %{buildroot}/usr/share/doc/lua-&lua-version;
+install -vdm755 %{buildroot}/usr/lib/pkgconfig
+install -vm644 lua.pc %{buildroot}/usr/lib/pkgconfig
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+REALEOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-cpio" role="wrap">
+  <?dbhtml filename="cpio.html"?>
+
+  <sect1info condition="script">
+    <productname>cpio</productname>
+    <productnumber>&cpio-version;</productnumber>
+    <address>&cpio-url;</address>
+  </sect1info>
+
+  <title>cpio-&rpm-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; cpio.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: cpio
+Version: &cpio-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base
+Requires: base
+Suggests: tex
+Source0: cpio-&cpio-version;.tar.bz2
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}-%{version}
+sed -i '/The name/,+2 d' src/global.c
+
+%build
+./configure --prefix=/usr \
+            --enable-mt   \
+            --with-rmt=/usr/libexec/rmt
+make
+makeinfo --html            -o doc/html      doc/cpio.texi
+makeinfo --html --no-split -o doc/cpio.html doc/cpio.texi
+makeinfo --plaintext       -o doc/cpio.txt  doc/cpio.texi
+
+%check
+make check
+
+%install
+make DESTDIR="%{buildroot}" install
+install -vdm755 %{buildroot}/usr/share/doc/%{name}-%{version}/html
+install -vm644  doc/html/* \
+                %{buildroot}/usr/share/doc/%{name}-%{version}/html
+install -vm644  doc/cpio.{html,txt} \
+                %{buildroot}/usr/share/doc/%{name}-%{version}
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-rpm" role="wrap">
+  <?dbhtml filename="rpm.html"?>
+
+  <sect1info condition="script">
+    <productname>rpm</productname>
+    <productnumber>&rpm-version;</productnumber>
+    <address>&rpm-url;</address>
+  </sect1info>
+
+  <title>rpm-&rpm-version;</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; rpm.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: rpm
+Version: &rpm-version;
+Release: 1
+Summary: %{name} %{version}
+License:
+Group: base-rpm
+BuildRequires: base libarchive lua
+Requires: base libarchive lua
+Suggests: berkeley-db cpio
+Source0: rpm-&rpm-version;.tar.bz2
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+%{name} %{version}
+
+%prep
+%setup -n %{name}-%{version}
+
+%build
+./configure --prefix=/usr        \
+            --sysconfdir=/etc    \
+            --localstatedir=/var \
+            --disable-bdb
+make
+
+%check
+make check
+
+%install
+make DESTDIR="%{buildroot}" install
+sed /_db_backend/s/bdb/sqlite/ -i %{buildroot}/usr/lib/rpm/macros
+rmdir %{buildroot}/var/tmp
+
+#### Generic addition to %install for all specs to generate installed files list
+find %{buildroot} -type f -name "*.la" -delete
+rm -f %{buildroot}/usr/share/info/dir
+find %{buildroot} -not -type d > files.%{name}
+sed  's@^%{buildroot}@@' -i files.%{name}
+find %{buildroot} -type d > dirs.%{name}
+sed  's@^%{buildroot}@@' -i dirs.%{name}
+sed '/\/etc\//s@^/@%config /@' -i files.%{name}
+sed '/\/var\/log\//s@^/@%config /@' -i files.%{name}
+sed '/\/usr\/share\/info\//s@$@.gz@' -i files.%{name}
+sed '/\/usr\/share\/man\//s@$@.gz@' -i files.%{name}
+sed 's@^/@%dir /@' dirs.%{name} >> files.%{name}
+
+#### The files section is also generic for all specs
+%files -f files.%{name}
+%defattr(-,root,root)
+
+#### The Changelog is also generic for all specs
+%changelog
+* %{date} %{pname}
+  %{pmail} %{version}-%{release}
+  Initial build
+
+EOF</userinput></screen>
+  </sect2>
+
+</sect1>
+
+<sect1 id="ch-system-base-rpm" role="wrap">
+  <?dbhtml filename="base-rpm.html"?>
+
+  <sect1info condition="script">
+    <productname>base-rpm</productname>
+    <productnumber>1.0</productnumber>
+    <address>&lfs-root;</address>
+  </sect1info>
+
+  <title>Base-rpm metapackage</title>
+
+  <sect2 role="installation">
+    <title/>
+<screen><userinput remap="install">cat &gt; base-rpm.spec &lt;&lt; "EOF"
+Packager: Linux From Scratch &lt;lfs-dev@linuxfromscratch.org&gt;
+Name: base-rpm
+Version: 1.0
+Release: 1
+Summary: base-rpm 1.0
+License: CC-BY-SA
+Requires: base cpio libarchive libassuan libgcrypt libgpg-error lua nettle pip popt pth rpm setuptools sqlite unzip
+
+# Define changelog info
+%define date %(date +"%a %b %d %Y")
+%define pname "Linux From Scratch"
+%define pmail "&lt;lfs-dev@linuxfromscrtach.org&gt;"
+%define postinsttasks ""
+
+%description
+A metapackage that contians all rpm specfic additional packages for easier
+dependency management.
+
+%files
+
+EOF</userinput></screen>
+
+  </sect2>
+
+</sect1>
+
+</article>
