benvd / lfs-pacman

Guide to using pacman as a package manager for Linux From Scratch
Other
84 stars 15 forks source link

Just a quick update idea to this guide if you care to for future interest. #5

Open weirdbeardgame opened 2 years ago

weirdbeardgame commented 2 years ago

So, I don't know if you care enough to update this guide or not in any sense but I've sorta taken on this challenge with the more modern LFS build system and pacman package. The first biggest change. pacman has switched from configure / make to meson. This still works because meson has a Dest Dir option so you can set DESDIR=$LFS to install in the temporary toolchain. Pacman has several other depends like Doxygen now that aren't listed.

The biggest thing I've found in doing this with the updated pacman and LFS. You CANNOT build pacman in the LFS Chroot environment. Or at least I don't seem to be able to. While I was able to get it's depends installed like libxml2. Everytime you run the meson build script it'll reference a tool that get's installed with libxml2 that will always err out in the chroot environment even though it built and installed properly with the $LFS destdir.

It seems the best approach is to run with LFS up to the chroot ensuring you can actually enter and exit the functioning chroot but don't close or remove the original temp environment lfs user. Instead once the chroot is active and working and you've confirmed that. Use the host system's package depends to compile and install pacman with the DESTDIR=$LFS meson install -C build command from there. Then switch to the chroot environment and you'll hopefully have a working pacman you can continue with.

benvd commented 2 years ago

Every now and then I start working on updating this for the latest LFS version, but I generally don't manage to make it all the way through... :)

That said, I did revisit this for LFS 10 (not 11 though), with pacman 6.0.0, which uses meson. I managed to build and install pacman, and then use pacman to install at least some packages to the final system, but I never completed it, so caveat emptor.

[edit] I realize there's nothing about libxml2 in this explanation, but apparently that never posed a problem on my side...


Stage 1 - Installing pacman to your temporary toolchain

This stage begins right before section 8.3. Man-pages-5.10 of the LFS 10.1 book.

Pacman dependencies

Pacman has a fair amount of dependencies, and some of those in turn have other dependencies. When all is said and done, we'll need to install fourteen packages. Thirteen of these have instructions in either LFS or BLFS that you can follow verbatim:

I installed them in the order listed above.

The fourteenth package is fakeroot. Download its source tarball and the three patch files, then run these commands:

patch -p1 -i fakeroot-1.25.3-glibc-2.33-fix-1.patch
patch -p1 -i fakeroot-1.25.3-glibc-2.33-fix-2.patch
patch -p1 -i fakeroot-1.25.3-glibc-2.33-fix-3.patch

# Don't install docs
sed -i 's/SUBDIRS=doc \(.*\)/SUBDIRS=\1/' Makefile.am

./bootstrap

./configure --prefix=/usr \
  --libdir=/usr/lib/libfakeroot \
  --disable-static \
  --with-ipc=sysv

make
make install

install -dm0755 "/etc/ld.so.conf.d/"
echo '/usr/lib/libfakeroot' > "/etc/ld.so.conf.d/fakeroot.conf"

Installing pacman

Download and install pacman:

meson --prefix=/usr \
      --buildtype=plain \
      -Ddoc=disabled \
      -Ddoxygen=disabled \
      -Dscriptlet-shell=/usr/bin/bash \
      -Dldconfig=/usr/bin/ldconfig \
      build
meson compile -C build
meson install -C build

This will have installed, amongst others, the makepkg.conf and pacman.conf config files in /etc; you may want to edit them. For makepkg.conf, be sure that CARCH and CHOST are appropriate, e.g.:

CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"

You can set your name and email address as the PACKAGER if you want, and set MAKEFLAGS to something appropriate for your system.

It seems like pacman expects bash to be at /usr/bin/bash when launching post-install hooks. Bash is at /bin/bash in our system, so make a symlink:

ln -sv /bin/bash /usr/bin/bash
eli-schwartz commented 2 years ago

It seems like pacman expects bash to be at /usr/bin/bash when launching post-install hooks. Bash is at /bin/bash in our system, so make a symlink:

It only expects this because up above, you passed a meson option: -Dscriptlet-shell=/usr/bin/bash

Presumably if you switched that to -Dscriptlet-shell=/bin/bash you would not need the symlink (at least not for pacman! There may very well be other software packages out there that just hardcode this path rather than offer a build option to specify where it can be found.)

python (we've already installed this in chapter 7, but we need to reinstall it, this time including pip/setuptools)

I assume you want to include pip/setuptools in order to use them to install Meson. See https://mesonbuild.com/Getting-meson.html for two methods of running Meson without using setuptools/pip to install it:

I'd recommend the second method, personally.

weirdbeardgame commented 2 years ago

What I did was installed pacman with the temporary LFS user outside of the chroot environment setting the prefix to /usr and the destdir to $LFS on the install command. It seems to have resulted in a stable pacman in the chroot environment installed to the temporary toolchain. I'll test a bit by seeing if I can install it's dependencies and pacman to the final Linux environment.

It's sort of an option b since it's built with the host packages at least initially.

Edit: From a bit of probing. After that initial install it seems the above packages are still needed on the LFS side

Asome10121 commented 4 months ago

I tried this and have a working pacman 6.0.2 install on LFS 12.1 but I'm unsure how I would continue as the guide is so outdated and I'm not adept in using makepkg

Hussein-Playz commented 1 month ago

I tried this and have a working pacman 6.0.2 install on LFS 12.1 but I'm unsure how I would continue as the guide is so outdated and I'm not adept in using makepkg

its LFS your suppost to compile shit 24/7 how tf are you not adept lol