feat: package manager -> dpkg

This commit is contained in:
Euiseo Cha 2023-03-30 12:02:54 +09:00
parent f6e9ef2fac
commit 22eb3171ad
Signed by: zeroday0619
GPG Key ID: 220CC17AA79A0AEA
3 changed files with 391 additions and 3 deletions

6
.gitignore vendored
View File

@ -1,5 +1,5 @@
configuration*
# configuration*
custom/config/
menu/__pycache__/
pkgmngt/packInstall.sh
pkgmngt/packageManager.xml
# pkgmngt/packInstall.sh
# pkgmngt/packageManager.xml

39
pkgmngt/packInstall.sh Normal file
View File

@ -0,0 +1,39 @@
# function for packing and installing a tree. We only have access
# to variables PKGDIR and PKG_DEST
packInstall() {
local PCKGVRS=$(basename $PKGDIR)
local TGTPKG=$(basename $PKG_DEST)
local PACKAGE=$(echo ${TGTPKG} | sed 's/^[0-9]\{3,4\}-//' |
sed 's/^[0-9]\{2\}-//')
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 dpkg does not want a '_' in version.
esac
local ARCHIVE_NAME=$(dirname ${PKGDIR})/${PACKAGE}_${VERSION}.deb
case $(uname -m) in
x86_64) local ARCH=amd64 ;;
*) local ARCH=i386 ;;
esac
pushd $PKG_DEST
rm -fv ./usr/share/info/dir
mkdir DEBIAN
cat > DEBIAN/control <<EOF
Package: $PACKAGE
Version: $VERSION
Maintainer: Pierre Labastie <lnimbus@club-internet.fr>
Description: $PACKAGE
Architecture: $ARCH
EOF
dpkg-deb -z9 -b . $ARCHIVE_NAME
dpkg -i $ARCHIVE_NAME
mv -v $ARCHIVE_NAME /var/lib/packages
popd
}

349
pkgmngt/packageManager.xml Normal file
View File

@ -0,0 +1,349 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY buildtime "Approximate build time">
<!ENTITY diskspace "Required disk space">
<!ENTITY dependencies "Installation depends on">
<!ENTITY testsuites "Test suite depends on">
<!ENTITY before "Must be installed before">
<!ENTITY external "Optional dependencies">
<!ENTITY debian-pool "http://ftp2.fr.debian.org/debian/pool/main/">
<!ENTITY dpkg-version "1.18.23">
<!ENTITY dpkg-size "4,411 KB">
<!ENTITY dpkg-url "&debian-pool;d/dpkg/dpkg_&dpkg-version;.tar.xz">
<!ENTITY dpkg-md5 "2195338c1792b0678575309a099d2da8">
<!ENTITY dpkg-home "http://wiki.debian.org/Teams/Dpkg">
<!ENTITY dpkg-ch5-du "56 MB">
<!ENTITY dpkg-ch5-sbu "0.2 SBU">
<!ENTITY dpkg-ch6-du "66 MB">
<!ENTITY dpkg-ch6-sbu "0.3 SBU">
]>
<article>
<sect1 id="package">
<?dbhtml filename="packages.html"?>
<title>All Packages</title>
<para>Download or otherwise obtain the following packages:</para>
<variablelist role="materials">
<varlistentry>
<term>Dpkg (&dpkg-version;) - <token>&dpkg-size;</token>:</term>
<listitem>
<para>Home page: <ulink url="&dpkg-home;"/></para>
<para>Download: <ulink url="&dpkg-url;"/></para>
<para>MD5 sum: <literal>&dpkg-md5;</literal></para>
</listitem>
</varlistentry>
</variablelist>
</sect1>
<!-- If needed, uncomment and edit this:
<sect1 id="patches">
<?dbhtml filename="patches.html"?>
<title>Needed Patches</title>
<para>In addition to the package(s), zero or more patches are also required.
These patches correct any mistakes in the packages that should be
fixed by the maintainer. The patches also make small modifications to
make the packages easier to work with. The following patches will be
needed to build an LFS system:</para>
<variablelist role="materials">
<varlistentry>
<term>Dpkg Some Patch - <token>&dpkg-somepatche-size;</token>:</term>
<listitem>
<para>Download: <ulink url="&somepatch-url;"/></para>
<para>MD5 sum: <literal>&somepatch-md5;</literal></para>
</listitem>
</varlistentry>
</variablelist>
</sect1>
-->
<sect1 id="ch-tools-pkgmngt" role="wrap">
<?dbhtml filename="dpkg.html"?>
<sect1info condition="script">
<productname>dpkg</productname>
<productnumber>&dpkg-version;</productnumber>
<address>&dpkg-url;</address>
</sect1info>
<title>Dpkg-&dpkg-version;</title>
<sect2 role="package">
<title/>
<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>
<seglistitem>
<seg>&dpkg-ch5-sbu;</seg>
<seg>&dpkg-ch5-du;</seg>
</seglistitem>
</segmentedlist>
</sect2>
<sect2 role="installation">
<title>Installation of Dpkg</title>
<para>Since Debian is shipping its own package, all patches have already
been applied.</para>
<para> Configure the package:</para>
<screen><userinput remap="configure">./configure --prefix=/tools \
--disable-nls --disable-dselect \
--disable-start-stop-daemon \
--disable-update-alternatives \
--without-zlib --with-liblzma=static --without-libselinux</userinput></screen>
<variablelist>
<title>The meaning of the configure options:</title>
<varlistentry>
<term><parameter>--disable-dselect</parameter></term>
<listitem>
<para>Avoids building <command>dselect</command>, an
awful thing!</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--disable-start-stop-daemon</parameter></term>
<listitem>
<para>The utility <command>start-stop-daemon</command>
is not needed here.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--disable-update-alternatives</parameter></term>
<listitem>
<para>Same for <command>update-alternatives</command>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--without-zlib</parameter></term>
<listitem>
<para>Use <command>gzip</command> for compression of binary
packages instead of the zlib library, which is not installed
in chapter 5.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--with-liblzma=static</parameter></term>
<listitem>
<para>Use statically linked <command>liblzma</command> for compression
of binary packages.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--without-libselinux</parameter></term>
<listitem>
<para>Disable building for <application>selinux</application>, which
is not used with LFS/BLFS.</para>
</listitem>
</varlistentry>
</variablelist>
<para>Compile the package:</para>
<screen><userinput remap="make">(cd lib &amp;&amp; make)
(cd src &amp;&amp; make)
(cd dpkg-deb &amp;&amp; make)
(cd dpkg-split &amp;&amp; make)</userinput></screen>
<para>This package does not come with a test suite.</para>
<para>Install only the needed files:</para>
<screen><userinput remap="install">cp src/dpkg src/dpkg-* /tools/bin
cp dpkg-deb/dpkg-deb /tools/bin
cp dpkg-split/dpkg-split /tools/bin
mkdir -pv /tools/etc/dpkg/{,dpkg.cfg.d}
cp debian/dpkg.cfg /tools/etc/dpkg</userinput></screen>
<para>Add a line in <filename>dpkg.cfg</filename> to
tell where to put administration files</para>
<screen><userinput>cat &gt;&gt; /tools/etc/dpkg/dpkg.cfg &lt;&lt; EOF
# admindir on LFS system
admindir /var/lib/dpkg
EOF</userinput></screen>
<para>On a Debian system, <command>dpkg</command> relies on two other
files to be present. Since we do not install them, issue:</para>
<screen><userinput>cat &gt;&gt; /tools/etc/dpkg/dpkg.cfg &lt;&lt; EOF
# disable fatal error on path checking
force-bad-path
EOF</userinput></screen>
</sect2>
</sect1>
<sect1 id="ch-pkgmngt-creatingdirs">
<?dbhtml filename="creatingdirs.html"?>
<title>Adding Directories for package management</title>
<para>Those directories should be added to the system.
<filename>/var/lib/dpkg</filename> and subdirectories are
adminitrative directories of <command>dpkg</command>.
<filename>/var/log</filename> is the log directory for
<command>dpkg</command>. <filename>/var/lib/packages</filename>
will be used to store our packages.deb files.</para>
<screen><userinput>mkdir -pv /var/{log,lib/dpkg/{info,updates}}
mkdir -pv /var/lib/packages</userinput></screen>
</sect1>
<sect1 id="ch-pkgmngt-createfiles">
<?dbhtml filename="createfiles.html"?>
<title>Adding administrative files for Dpkg</title>
<para><command>dpkg</command> needs that some files exist to run
for the first time. The log file must exist in order to be
used.</para>
<screen><userinput>touch /var/lib/dpkg/{available,status}
touch /var/log/dpkg.log</userinput></screen>
</sect1>
<sect1 id="ch-system-pkgmngt" role="wrap">
<?dbhtml filename="dpkg.html"?>
<sect1info condition="script">
<productname>dpkg</productname>
<productnumber>&dpkg-version;</productnumber>
<address>&dpkg-url;</address>
</sect1info>
<title>Dpkg-&dpkg-version;</title>
<sect2 role="package">
<title/>
<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>
<seglistitem>
<seg>&dpkg-ch6-sbu;</seg>
<seg>&dpkg-ch6-du;</seg>
</seglistitem>
</segmentedlist>
</sect2>
<sect2 role="installation">
<title>Installation of Dpkg</title>
<para>Since Debian is shipping its own package, all patches have already
been applied. We do not need more in chapter 6. Configure it:</para>
<screen><userinput remap="configure">./configure --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--disable-dselect \
--disable-start-stop-daemon \
--disable-update-alternatives \
--without-libselinux</userinput></screen>
<variablelist>
<title>The meaning of the configure options:</title>
<varlistentry>
<term><parameter>--disable-dselect</parameter></term>
<listitem>
<para>Avoids building <command>dselect</command>, an
awful thing!</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--disable-start-stop-daemon</parameter></term>
<listitem>
<para>The utility <command>start-stop-daemon</command>
is not needed here.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--disable-update-alternatives</parameter></term>
<listitem>
<para>Same for <command>update-alternatives</command>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--without-libselinux</parameter></term>
<listitem>
<para>Selinux is not used in LFS.</para>
</listitem>
</varlistentry>
</variablelist>
<para>Compile the package:</para>
<screen><userinput remap="make">make</userinput></screen>
<para>This package does not come with a test suite.</para>
<para>Install the package:</para>
<screen><userinput remap="install">mkdir -pv $PKG_DEST
make DESTDIR=$PKG_DEST install
mkdir -pv $PKG_DEST/etc/dpkg/{,dpkg.cfg.d}
cp debian/dpkg.cfg $PKG_DEST/etc/dpkg</userinput></screen>
<para>Add a line in <filename>dpkg.cfg</filename> to
tell where to put administration files</para>
<screen><userinput remap="install">cat &gt;&gt; $PKG_DEST/etc/dpkg/dpkg.cfg &lt;&lt; EOF
# admindir on LFS system
admindir /var/lib/dpkg
EOF</userinput></screen>
<!-- Is this needed in chapter 06 -->
<para>On a Debian system, <command>dpkg</command> relies on two other
files (<command>ldconfig</command> and maybe <command>update-rc.d</command>)
to be present. Since we do not install them, issue:</para>
<screen><userinput>cat &gt;&gt; /etc/dpkg/dpkg.cfg &lt;&lt; EOF
# disable fatal error on path checking
force-bad-path
EOF</userinput></screen>
</sect2>
</sect1>
</article>