My hint is attached, tested with LFS development version SVN 20090306.

DESCRIPTION:
Pacman is the advanced package manager used in distros such as Arch Linux,
Chakra, and Frugalware. It is extremely handy for LFS builders due to its
pkgbuild system, which automates compiling and package creation. To use
pacman with LFS, pacman needs to be ready before part three. This hint
explains what dependencies are necessary and how to compile them, as well as
how to continue with the LFS build process, creating pacman packages along
the way.

Thanks,
    Xander Vedejas
AUTHOR: Xander Vedejas <[email protected]>

DATE: 2008-03-22

LICENSE: GNU Free Documentation License Version 1.2

SYNOPSIS: Using the Pacman Package Manager to manage the LFS build.

DESCRIPTION:
Pacman is the advanced package manager used in distros such as Arch Linux, 
Chakra, and Frugalware. It is extremely handy for LFS builders due to its 
pkgbuild system, which automates compiling and package creation. To use pacman 
with LFS, pacman needs to be ready before part three. This hint explains what 
dependencies are necessary and how to compile them, as well as how to continue 
with the LFS build process, creating pacman packages along the way.

This hint has been tested with LFS development version SVN-20090306.

ATTACHMENTS:

PREREQUISITES:
You need to have built an LFS system up to part III before this hint is 
applicable. If you have already started part III, this hint will also not work.

HINT:
To build Pacman, these additional dependencies are required:

* attr ftp://oss.sgi.com/projects/xfs/cmd_tars/attr_2.4.43-1.tar.gz
* bzip2 http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz
* zlib http://www.zlib.net/zlib-1.2.3.tar.bz2
* libarchive 
http://people.freebsd.org/~kientzle/libarchive/src/libarchive-2.4.17.tar.gz
* libdownload http://black-flag.co.uk/files/lfs/libdownload-1.3.tar.gz
* openssl http://www.openssl.org/source/openssl-0.9.8g.tar.gz
and 
http://www.linuxfromscratch.org/patches/blfs/6.3/openssl-0.9.8g-fix_manpages-1.patch
* fakeroot 
http://ftp.de.debian.org/debian/pool/main/f/fakeroot/fakeroot_1.11.tar.gz
* And yes, pacman itself 
ftp://ftp.archlinux.org/other/pacman/pacman-3.2.2.tar.gz

We will install these to the /tools/ directory.

* Installing Attr

sed -i Makefile \
   -e '/autoconf/d' \
   -e 's...@default: $(CONFIGURE)@default:@'
sed -i "/AC_OUTPUT/i\AC_PROG_LIBTOOL" configure.in
cp -vf install-sh{,.orig}
libtoolize -f -i
cp -vf install-sh{.orig,}
aclocal -I m4
autoconf
./configure --prefix=/ --exec-prefix=/ --sbindir=/tools/sbin \
  --bindir=/tools/sbin --libdir=/tools/lib --libexecdir=/tools/lib 
--includedir=/tools/include \
  --mandir=/tools/share/man --datadir=/tools/share
make DEBUG=-DNDEBUG LIBTOOL="$PWD/libtool"
make LIBTOOL=$PWD/libtool install install-dev install-lib
chmod 755 -v /tools/lib/libattr.so.1.1.0
rm -v /tools/lib/libattr.{,l}a

* Installing Bzip2

make
make PREFIX=/tools install

* Installing Zlib

./configure --prefix=/tools --shared --libdir=/tools/lib
make
make install
rm -v /tools/lib/libz.so
ln -sfv /tools/lib/libz.so.1.2.3 /tools/lib/libz.so
make clean
./configure --prefix=/tools
make
make install
chmod -v 644 /tools/lib/libz.a

* Installing Libarchive

./configure --prefix=/tools
make
make install

* Installing Libdownload

make
make prefix=/tools install

* Installing Openssl

patch -Np1 -i ../openssl-0.9.8g-fix_manpages-1.patch
./config --openssldir=/tools/etc/ssl --prefix=/tools shared
make MANDIR=/tools/share/man
make MANDIR=/tools/share/man install
cp -v -r certs /tools/etc/ssl
install -v -d -m755 /tools/share/doc/openssl-0.9.8g
cp -v -r doc/{HOWTO,README,*.{txt,html,gif}} \
    /tools/share/doc/openssl-0.9.8g

* Installing Fakeroot

./configure --prefix=/tools
make
make install

* Installing Pacman

./configure --prefix=/tools
make
make install

* Continuing with LFS part III

Now, when you compile each package in part III, you will want to write a 
PKGBUILD script.
Here is how you would make a PKGBUILD for the linux headers:

pkgname=linuxheaders
pkgver=2.6.28.7
pkgrel=1
pkgdesc="The Linux API Headers expose the kernel's API for use by Glibc."
arch=(`uname -m`)
url="http://www.kernel.org/";
license=('GPL')
groups=('base')
source=(http://www.kernel.org/pub/linux/kernel/v2.6/linux-$pkgver.tar.bz2)
md5sums=()
build() {
  cd $srcdir/linux-$pkgver
  make mrproper
  make headers_check
  make INSTALL_HDR_PATH=dest headers_install
  mkdir -p $pkgdir/usr/
  cp dest/include $pkgdir/usr/ -r
}

* For Glibc

pkgname=glibc
pkgver=2.9
pkgrel=1
pkgdesc="The Glibc package contains the main C library. This library provides 
the basic routines for allocating memory, searching directories, opening and 
closing files, reading and writing files, string handling, pattern matching, 
arithmetic, and so on."
arch=(`uname -m`)
url="http://www.gnu.org/";
license=('GPL')
groups=('base')
depends=(linuxheaders)
install=$pkgname.install
source=(glibc-build.tar.bz2)
md5sums=()
build() {
  cd $srcdir/glibc-build
  make install_root='$pkgdir/' install || return 1
}

* For Zlib

pkgname=zlib
pkgver=1.2.3
pkgrel=1
pkgdesc="A compression/decompression Library"
arch=(`uname -m`)
license=('custom:zlib')
url="http://www.zlib.net/";
groups=('base')
depends=('glibc')
source=("http://zlib.net/${pkgname}-${pkgver}.tar.bz2";)
md5sums=()
build() {
        cd ${srcdir}/$pkgname-$pkgver
        ./configure --prefix=/usr --shared
        make || return 1
        make install DESTDIR=${pkgdir} || return 1
        chmod 644 ${pkgdir}/usr/lib/libz.a
        grep -A 24 '^  Copyright' zlib.h > license.txt
        install -D license.txt ${pkgdir}/usr/share/licenses/zlib/license.txt
}

Normally in the build() section:
Keep the prefix the same (usually --prefix=/usr when configuring). But on the 
"make install" command, add "DESTDIR=${pkgdir}". Notice that this is not the 
case for the kernel headers or glibc, but this is the normal way to set it up 
for most packages.

To make this package, save the PKGBUILD file as PKGBUILD. Make sure you have 
the sources in the directory, and execute "makepkg -g --asroot" to obtain 
md5sum files. Once you've edited the PKGBUILD file to include the md5sums 
necessary, make the package with "makepkg --asroot". To make sure everything 
installed correctly in the package directory, you might try extracting the 
package (warning: do not extract in the root filesystem). Finally, install with 
"pacman -U /path/to/package.pkg.tar.gz".

It is advisable to make a pacman package for each package built in part III. It 
is also good practice to save all of your PKGBUILD files for later reference.

* For more Information

http://wiki.archlinux.org/index.php/Pacman
http://wiki.archlinux.org/index.php/ABS_PKGBUILD_Explained
http://wiki.archlinux.org/index.php/The_Arch_package_making_HOW-TO_-_with_guidelines

ACKNOWLEDGEMENTS:
Thanks to Judd Vinet <[email protected]>, for making the amazing pacman 
package manager.

CHANGELOG:
[2008-03-22]
  * Initial hint.

-- 
http://linuxfromscratch.org/mailman/listinfo/hints
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to