Add pacman as package manager.

This commit is contained in:
Pierre Labastie 2015-01-18 16:58:24 +00:00
parent 4195a401a6
commit bd0095150a
6 changed files with 281 additions and 49 deletions

View file

@ -17,59 +17,43 @@ BY : Pierre Labastie (work in progress)
2. OVERVIEW OF THE SYSTEM:
For now, package management is only available for LFS. I plan to
upgrade BLFS tools, but nothing usable right now. The other flavours of
LFS do not seem very active, so there is no point in updating jhalfs
for them.
The first thing to do is to modify the install instructions of the
chapter 6, 7 and 8 of the book so that the installed files end up in a
directory other than `/'. We choose to call this directory by the name
of the executed script, and to put the path to this directory in the
PKG_DEST variable which is made available to the scriplets.
Almost all the packages have a way to redirect the destination of
the files they install at the `make install' stage with the variable
DESTDIR. Furthermore, the authors of the book have been kind enough to
flag the installation instructions with `remap=install'. This allows an
xsl stylesheet to find those instructions. Then, places where `make '
occurs (make followed by a space) are replaced by `make DESTDIR=$PKG_DEST '.
Places where the book instructions move files into their destination
are harder to deal with: it is possible to change all occurences of ` /' or
`>/' (beginning of absolute paths) to `$PKG_DEST', but you end up moving
upgrade BLFS tools, but nothing usable right now. I have not attempted
to adapt this tool for the other flavours of LFS.
This system performs basically 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 XSL stylesheet used for generating the scriptlets, automatically
adds DESTDIR install instructions when "package management" is selected.
Also all the paths beginning with " /" or ">/" (absolute paths) are prepended
with $PKG_DEST. This has the default that you might want to move
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 I am conservative and
create a reasonable subset of the FHS hierarchy into the destination
directory. Empty directories should then be removed before packing the
(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.
Supposing now that the scriptlets have been adequately modified, the
package manager installation instructions have to be added at the end of
chapter 5 and chapter 6. Furthermore, the administrative files and
directories have to be created during the `Creating Directories' and
`Creating Essential Files' stage. For all this, the user has to supply a
file in docbook format, with the necessary instructions and enough
information to download the tarball. A template is provided in the pkgmngt
subdirectory.
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 two XML files for
dpkg and pacman, respectively `packageManager.xml.dpkg' and
`packageManager.xml.pacman', that you can copy to `packageManager.xml'.
They are not updated often, so the versions used can be rather old.
The last thing to do is to tell how to use the package manager. When
the binary package is ready, the scriptlets call a shell function named
`packInstall', which should pack the binary package and install it on the
system. Note that nothing has been done to manage configuration files,
which are ususally treated specially by package managers. Depending on
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. The user has to provide his own function. A template is provided
in the pkgmngt subdirectory.
3. DETAILED INSTRUCTIONS:
Before beginning, you should know which package manager you want, where
to get the sources, and how to use it for:
a) Making a package from a directory tree. Usually, there is some control
file containing the version, pacakager, build system (32 or 64 bits at
least) or other more or less usefull but mandatory bits of information
which you should understand.
b) Unpack the package.
Second, you ought to have a basic knowledge of bash scripting and
docbook-xml writing, because you have to write a bash function for packing
and unpacking the package, and a set of instructions to install the PM.
upgrade. The user has to write his own `packInstall' function. The shell
function should be defined in a file named `packInstall.sh', residing in
the `pkgmngt' directory. A template is provided, as well as two example
scripts for dpkg and pacman.

View file

@ -0,0 +1,59 @@
# $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() {
# 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\}-//' |
sed 's/^[0-9]\{1\}-//')
# 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]*//') ;;
vim*|unzip*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*\([0-9]\)\([0-9]\)/\1.\2/') ;;
tidy*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*\([0-9]*\)/\1cvs/') ;;
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
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
mv * ../$PACKAGE/src
cat > PKGBUILD <<EOF
pkgname=( '$PACKAGE' )
pkgver=$VERSION
pkgrel=1
pkgdesc=$PACKAGE
arch=( '$ARCH' )
package() {
mv * \$pkgdir
}
EOF
# Building the binary package
makepkg --asroot -c --skipinteg
# Installing it on LFS
if ! pacman -U --noconfirm $ARCHIVE_NAME; then
pacman -U --noconfirm --force $ARCHIVE_NAME
fi
popd # Since the $PKG_DEST directory is destroyed
# immediately after the return of the function,
# getting back to $PKGDIR is important...
}

View file

@ -86,7 +86,7 @@
<para>This is my choice of package manager. Dpkg is the basic package
manager of Debian. It can be complemented by deselect (in the same
package), apt or aptitude. We use it in a very crude way.</para>
<segmentedlist>
<segtitle>&buildtime;</segtitle>
<segtitle>&diskspace;</segtitle>
@ -253,7 +253,7 @@ touch /var/log/dpkg.log</userinput></screen>
<para>This is my choice of package manager. Dpkg is the basic package
manager of Debian. It can be complemented by deselect (in the same
package), apt or aptitude. We use it in a very crude way.</para>
<segmentedlist>
<segtitle>&buildtime;</segtitle>
<segtitle>&diskspace;</segtitle>

View file

@ -0,0 +1,189 @@
<?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" >
<!-- 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">
<para>Download: <ulink url="http://curl.haxx.se/download/curl-7.39.0.tar.lzma"/></para>
<para>MD5 sum: <literal>e9aa6dec29920eba8ef706ea5823bad7</literal></para>
<para>Download: <ulink url="http://www.libarchive.org/downloads/libarchive-3.1.2.tar.gz"/></para>
<para>MD5 sum: <literal>efad5a503f66329bb9d2f4308b5de98a</literal></para>
<para>Download: <ulink url="ftp://ftp.archlinux.org/other/pacman/pacman-4.1.2.tar.gz"/></para>
<para>MD5 sum: <literal>063c8b0ff6bdf903dc235445525627cd</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>
</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). Furthermore, the tarball name must be in the form
name_x.y.z(.extension) or name-x.y.z(.extension) if the dbhtml
instruction contains file="name.html" -->
<sect1 id="ch-tools-libarchive" role="wrap">
<?dbhtml filename="libarchive.html"?>
<sect2 role="installation">
<screen><userinput remap="configure">./configure --prefix=/tools \
--without-bz2lib \
--enable-bsdtar=static \
--enable-bsdcpio=static</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"?>
<sect2 role="installation">
<screen><userinput remap="configure">./configure --prefix=/tools \
--disable-static</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"?>
<!-- next line mandatory without change, but feel free to add any title,
other sect2 (with different role), sectinfo and so on -->
<sect2 role="installation">
<!-- 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">./configure --prefix=/tools \
PKG_CONFIG_PATH=/tools/lib/pkgconfig \
DUPATH=/tools/bin/du</userinput></screen>
<screen><userinput remap="make">make</userinput></screen>
<screen><userinput remap="install">make install</userinput></screen>
<screen><userinput>sed -e 's@/usr@/tools@g' \
-e 's/\([^!]\)strip/\1!strip/' \
-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>
</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">
<!-- Put the create dir intructions there. feel free to add
any explaining <title>Title</title> and <para>explanations</para> -->
<screen><userinput>mkdir -pv /var/{lib/{packages,pacman},cache/pkg}</userinput></screen>
</sect1>
<!-- Same for files. Do not change the following line -->
<sect1 id="ch-pkgmngt-createfiles">
<para>No file?</para>
</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"?>
<sect2 role="installation">
<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>
</sect2>
</sect1>
<sect1 id="ch-system-curl" role="wrap">
<?dbhtml filename="curl.html"?>
<sect2 role="installation">
<screen><userinput remap="configure">./configure --prefix=/usr \
--disable-static \
--enable-threaded-resolver</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-7.39.0
cp -v -R docs/* $PKG_DEST/usr/share/doc/curl-7.39.0</userinput></screen>
</sect2>
</sect1>
<sect1 id="ch-system-pkgmngt" role="wrap">
<?dbhtml filename="pacman.html"?>
<sect2 role="installation">
<screen><userinput remap="configure">./configure --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var</userinput></screen>
<screen><userinput remap="make">make</userinput></screen>
<!-- 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">make DESTDIR=$PKG_DEST install</userinput></screen>
<screen><userinput>sed -e 's/\([^!]\)strip/\1!strip/' \
-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&lt;"
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
EOF</userinput></screen>
</sect2>
</sect1>
</article>

View file

@ -100,7 +100,7 @@ touch /var/log/dpkg.log</userinput></screen>
<!-- 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
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.