mid-kid
4 years ago
6 changed files with 56 additions and 341 deletions
@ -1,116 +0,0 @@ |
|||
This is done in a chroot, from a 10.0 chapter 7 system. To do this on a live |
|||
system, you'll need a kernel, initscripts, and some way to connect to the |
|||
internet, such as iproute+dhcpcd. |
|||
|
|||
Make sure you bind-mount your host's /etc/resolv.conf to the chroot, such as: |
|||
touch $LFS/etc/resolv.conf |
|||
mount -v --bind /etc/resolv.conf $LFS/etc/resolv.conf |
|||
This will allow programs to resolve DNS names, which is necessary to download things. |
|||
|
|||
Also mount /dev/shm, in addition to the mounts in chapter 7.3: |
|||
mount -t tmpfs tmpfs $LFS/dev/shm |
|||
|
|||
Run the following chapters (avoid tests and docs): |
|||
- 8.9. Zlib-1.2.11 |
|||
- 8.10. Bzip2-1.0.8 |
|||
- 8.34. Bash-5.0 |
|||
- 8.47. Libffi-3.3 |
|||
- 8.48. OpenSSL-1.1.1g |
|||
- 8.49. Python-3.8.5 (!--with-system-expat --without-ensurepip) |
|||
|
|||
Symlink python3: |
|||
ln -sf python3 /usr/bin/python |
|||
|
|||
Install ca-certificates: |
|||
make |
|||
mkdir -p /usr/share/ca-certificates |
|||
make install |
|||
( cd /usr/share/ca-certificates |
|||
find . -name '*.crt' | LC_ALL=C sort | cut -b3- |
|||
) > /etc/ca-certificates.conf |
|||
mkdir -p /etc/ssl/certs |
|||
update-ca-certificates |
|||
|
|||
Install wget: |
|||
./configure --prefix=/usr --sysconfdir=/etc --with-ssl=openssl --with-libssl-prefix=/usr |
|||
make |
|||
make install |
|||
|
|||
Install portage (https://wiki.gentoo.org/wiki/Portage#Tarball): |
|||
python setup.py install |
|||
echo "portage:x:250:250:portage:/var/tmp/portage:/bin/false" >> /etc/passwd |
|||
echo "portage::250:portage" >> /etc/group |
|||
|
|||
Install repository (https://bouncer.gentoo.org/fetch/root/all/snapshots/, grab gentoo-*.tar.xz): |
|||
rm -rf /var/db/repos |
|||
mkdir -p /var/db/repos |
|||
mv gentoo-*/ /var/db/repos/gentoo |
|||
|
|||
Configure portage: |
|||
mkdir -p /etc/portage |
|||
ln -sf ../../var/db/repos/gentoo/profiles/default/linux/amd64/17.1/ /etc/portage/make.profile |
|||
|
|||
emerge -O1 sys-apps/baselayout |
|||
. /etc/profile |
|||
cat /var/lib/gentoo/news/news-gentoo.unread >> /var/lib/gentoo/news/news-gentoo.read |
|||
rm /var/lib/gentoo/news/news-gentoo.unread |
|||
touch /var/lib/gentoo/news/news-gentoo.unread |
|||
dispatch-conf |
|||
|
|||
Bootstrap multilib compiler: |
|||
emerge -O1 sys-apps/gentoo-functions sys-devel/binutils-config sys-devel/gcc-config app-portage/elt-patches sys-devel/binutils dev-libs/gmp dev-libs/mpfr dev-libs/mpc |
|||
|
|||
emerge -Of sys-devel/gcc |
|||
tar xf /var/cache/distfiles/gcc-*.tar.* && cd gcc-*/ && mkdir build && cd build |
|||
mkdir -p /tmp/gcc/include |
|||
touch /tmp/gcc/include/limits.h |
|||
../configure --prefix=/usr --with-local-prefix=/tmp/gcc --with-newlib --without-headers --disable-shared --disable-threads --disable-bootstrap --enable-multilib --enable-languages=c,c++ |
|||
make all-gcc all-target-libgcc |
|||
make install-gcc install-target-libgcc |
|||
rm -rf /tmp/gcc |
|||
cd ../.. && rm -rf gcc-*/ |
|||
|
|||
Remove use of gcc-multilib-bootstrap, since that defeats the point of building |
|||
everything from source, and we don't need it with this hack: |
|||
cd /var/db/repos/gentoo/sys-libs/glibc |
|||
cp -u glibc-2.31-r6.ebuild{,.orig} |
|||
sed -e '/gcc-multilib-bootstrap/d' glibc-2.31-r6.ebuild.orig > glibc-2.31-r6.ebuild |
|||
ebuild glibc-2.31-r6.ebuild manifest |
|||
PYTHON_COMPAT_OVERRIDE=python3 emerge -O1 sys-libs/glibc |
|||
|
|||
...in case of downgrade, reinstall any LFS programs that broke (using the |
|||
/tools toolchain?) until portage works again, and reinstall glibc, run |
|||
ldconfig and fix all warnings. |
|||
Alternatively, build LFS with an older glibc or unmask the same glibc version |
|||
that LFS has... |
|||
|
|||
Clean up glibc modifications: |
|||
cd /var/db/repos/gentoo/sys-libs/glibc |
|||
mv glibc-2.31-r6.ebuild.orig glibc-2.31-r6.ebuild |
|||
ebuild glibc-2.31-r6.ebuild manifest |
|||
|
|||
Not sure if this is necessary if not downgrading, but for good measure: |
|||
tar xf /var/cache/distfiles/gcc-*.tar.* && cd gcc-*/ && mkdir build && cd build |
|||
../libstdc++-v3/configure --prefix=/usr --enable-multilib |
|||
make |
|||
make install |
|||
cd ../.. && rm -rf gcc-*/ |
|||
|
|||
emerge -O1 sys-devel/gcc |
|||
PYTHON_COMPAT_OVERRIDE=python3 emerge -O1 sys-libs/glibc # might be necessary to merge _after_ pax-utils? |
|||
|
|||
Bootstrap rest of system: |
|||
emerge -O1 sys-libs/libseccomp app-misc/pax-utils # required by at least ncurses and sandbox |
|||
emerge -O1 sys-apps/sandbox |
|||
USE=-acl emerge -O1 sys-devel/gettext # circular dep, bundles libxml2, abusing this fact... |
|||
USE=-acl emerge -O1 net-misc/rsync # required by linux-headers |
|||
emerge -O1 dev-util/pkgconf # required by pax-utils |
|||
cd /var/db/repos/gentoo/scripts |
|||
./bootstrap.sh |
|||
|
|||
USE=-pam emerge -O1 sys-libs/libcap # circular dep |
|||
USE='-acl -xattr -pam' emerge -O1 sys-apps/shadow # required by acct-group |
|||
emerge -abe @system |
|||
|
|||
Unpollute the system by installing it somewhere else: |
|||
ROOT=/final emerge -K @system |
@ -1,182 +0,0 @@ |
|||
Based on portage-3.0.8 and gentoo-20201029 |
|||
|
|||
The specifics of this document (software versions and whatnot) are subject to |
|||
change as gentoo evolves, but I hope the big lines of it won't change too |
|||
much. |
|||
|
|||
This guide starts off with a system built from build_cross.sh, built for |
|||
x86_64 with i686 multilib. |
|||
It might be possible to adapt both that script, and this guide for other |
|||
architectures, but this guide won't go into detail. |
|||
|
|||
You should be running a system with a x86_64 kernel (with i686 support). |
|||
Install the required sources (outlined in gentoo.wget-list) into /sources. |
|||
|
|||
To enter the bootstrap system as a chroot, use the following commands to set |
|||
up the filesystems and entering: |
|||
mkdir -p proc sys dev tmp |
|||
mount -t proc proc proc |
|||
mount -t sysfs sysfs sys |
|||
mount -t devtmpfs devtmpfs dev |
|||
mount -t devpts devpts dev/pts |
|||
mount -t tmpfs tmpfs dev/shm |
|||
mkdir -p etc |
|||
touch etc/resolv.conf |
|||
mount --bind /etc/resolv.conf etc/resolv.conf |
|||
./bootstrap/bin/chroot . /bootstrap/bin/env -i PATH=/bin:/sbin:/usr/bin:/usr/sbin:/bootstrap/bin:/bootstrap/sbin HOME=/root /bootstrap/bin/sh -l |
|||
|
|||
To install all the prerequisite tools, place the sources (listed in |
|||
gentoo.wget-list) under /sources, then run the gentoo_tools.sh script. |
|||
|
|||
Install ebuild repository: |
|||
tar xf gentoo-*.tar.xz |
|||
mkdir -p /var/db/repos/ |
|||
mv gentoo-*/ /var/db/repos/gentoo |
|||
|
|||
Configure portage: |
|||
echo "root:x:0:0:root:/root:/bin/bash" > /etc/passwd |
|||
echo "root:x:0:root" > /etc/group |
|||
echo "portage:x:250:250:portage:/var/tmp/portage:/bin/false" >> /etc/passwd |
|||
echo "portage::250:portage" >> /etc/group |
|||
mkdir -p /tmp /root |
|||
chown root.root /tmp /root |
|||
chmod 1777 /tmp |
|||
chmod 0700 /root |
|||
ln -sf ../../var/db/repos/gentoo/profiles/default/linux/amd64/17.1/ /etc/portage/make.profile |
|||
cat > /etc/portage/make.conf << 'EOF' |
|||
FEATURES=-pid-sandbox |
|||
ROOTPATH=/bootstrap/bin:/bootstrap/sbin |
|||
EOF |
|||
|
|||
Install some prerequisites: |
|||
emerge -O1 sys-apps/gentoo-functions # Used by elt-patches and a ton of other things |
|||
emerge -O1 app-portage/elt-patches # required by elibtoolize(libtool.eclass), used to install any library |
|||
|
|||
TODO: Doing this is *BAAAAD*, since we're linking the compiler and libraries |
|||
with a potentially incompatible version of glibc in /tools, and upgrading it |
|||
afterwards. Glibc should always be installed first into a new prefix! |
|||
I just can't be assed to discuss the manual upgrade of binutils+gcc and their |
|||
dependency tools. |
|||
|
|||
TODO: Consider installing sys-devel/gnuconfig for the config.sub and |
|||
config.guess scripts. |
|||
|
|||
Bootstrap GCC: |
|||
# Install linker at final location, |
|||
# so programs built with the new compiler can run... |
|||
mkdir -p /lib64 /lib |
|||
ln -sf /bootstrap/lib/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 |
|||
ln -sf /bootstrap/lib32/ld-linux.so.2 /lib/ld-linux.so.2 |
|||
# Target compiler expects target limits.h to be available in target prefix... |
|||
mkdir -p /usr/include |
|||
ln -sf /bootstrap/include/limits.h /usr/include/limits.h |
|||
# GCC errors out at the first incompatible startfile in LIBRARY_PATH, |
|||
# so multilib paths need to be fixed to match the final compiler... |
|||
mkdir -p /usr/lib64 /usr/lib |
|||
ln -sf /bootstrap/lib/crti.o /bootstrap/lib/crtn.o /bootstrap/lib/Scrt1.o /usr/lib64/ |
|||
ln -sf /bootstrap/lib32/crti.o /bootstrap/lib32/crtn.o /bootstrap/lib32/Scrt1.o /usr/lib/ |
|||
# Reconfigure GCC to match the config of the final compiler as much as possible. |
|||
cat > /etc/portage/gcc.specs << 'EOF' |
|||
*multilib: |
|||
. !m64 !m32;64:../lib64 m64 !m32;32:../lib !m64 m32; |
|||
|
|||
*startfile_prefix_spec: |
|||
/usr/lib/ |
|||
|
|||
*link: |
|||
+ %{!shared:%{!static:-dynamic-linker %{m32:/lib/ld-linux.so.2;:/lib64/ld-linux-x86-64.so.2}}} |
|||
|
|||
*cpp: |
|||
+ -isystem /usr/include |
|||
EOF |
|||
cat > /etc/portage/bashrc << 'EOF' |
|||
export C_INCLUDE_PATH=/usr/include:/bootstrap/include |
|||
export CPLUS_INCLUDE_PATH=/usr/include:/bootstrap/include |
|||
export LIBRARY_PATH=/usr/lib64:/usr/lib:/bootstrap/lib:/bootstrap/lib32 |
|||
export LD_LIBRARY_PATH=/usr/lib64:/usr/lib:/bootstrap/lib:/bootstrap/lib32 |
|||
export CC='gcc -specs=/etc/portage/gcc.specs' |
|||
export CXX='g++ -specs=/etc/portage/gcc.specs' |
|||
EOF |
|||
emerge -O1 sys-libs/zlib dev-libs/gmp dev-libs/mpfr dev-libs/mpc |
|||
emerge -O1 sys-devel/binutils-config sys-devel/binutils |
|||
emerge -O1 sys-devel/gcc-config sys-devel/gcc |
|||
/usr/bin/gcc-config 1 # Not automatic unlike binutils-config |
|||
|
|||
Make portage forget about everything it's just installed, so it's all rebuilt |
|||
first thing when running bootstrap.sh/emerge later: |
|||
rm -rf /var/db/pkg |
|||
|
|||
Install initial glibc: |
|||
CC=gcc emerge -O1 sys-kernel/linux-headers |
|||
mkdir -p /usr/bin/ |
|||
ln -sf /bootstrap/bin/python3 /usr/bin/python3tmp |
|||
PYTHON_COMPAT_OVERRIDE=python3tmp emerge -O1 sys-libs/glibc |
|||
rm -f /usr/bin/python3tmp |
|||
|
|||
This compiler and dynamic linker will now pick up everything correctly under |
|||
/usr instead of /bootstrap: |
|||
rm -f /etc/portage/bashrc /etc/portage/gcc.specs |
|||
|
|||
Build the remainder of bootstrap utilities: |
|||
cd /var/db/repos/gentoo/scripts |
|||
rm -f /etc/profile.env |
|||
mkdir -p /var/run |
|||
USE=-nls ./bootstrap.sh |
|||
|
|||
You'll get tons of LD_PRELOAD libsandbox.so errors from programs still linked |
|||
against /bootstrap. This is fine to ignore, and will gradually disappear as |
|||
programs are rebuilt. |
|||
|
|||
It'd be nice to remove the bootstrap tools now, but among wget/openssl, gawk, |
|||
gzip, grep, and other tools, they're still required for some reason. |
|||
|
|||
From this point onward, you're pretty much on your own to beat portage into |
|||
performing an `emerge -e @system` and fixing any unspecified dependencies you |
|||
encounter along the way. This can be done in a whole number of ways, and will |
|||
differ on any given day, since this is painfully unsupported by gentoo devs. |
|||
Because the order in which you install everything can differ wildly, and |
|||
consequently affect the output of your build, it is advised to do a second |
|||
`emerge -e @system` afterwards, for sanity. Below I detail my most recent |
|||
procedure, which, I can't stress enough, may or may not work at the time |
|||
you're reading this. |
|||
|
|||
Fix circular dependencies: |
|||
USE=-filecaps emerge -O1 sys-libs/pam |
|||
USE='-acl -xattr' emerge -O1 sys-apps/shadow # required by acct-group/acct-user |
|||
|
|||
Verify there's no circular deps left, for sanity: |
|||
emerge -fe @system |
|||
|
|||
Build everything: |
|||
emerge -be @system |
|||
|
|||
Clean up bootstrap tools/configs: |
|||
rm -rf /bootstrap /sources |
|||
rm -f /etc/portage/make.conf |
|||
|
|||
Reinitialize environment: |
|||
env-update |
|||
exec bash -l |
|||
|
|||
Consider rebuilding everything again without /bootstrap, as surely a lot |
|||
errors popped up during the first emerge -be @system, can't be sure enough. |
|||
|
|||
To install everything into a clean root: |
|||
ROOT=/final emerge -K @system |
|||
|
|||
Prepare files for catalyst: |
|||
mkdir -p /var/tmp/catalyst/snapshots |
|||
wget -O gentoo-latest.tar.xz http://distfiles.gentoo.org/snapshots/gentoo-latest.tar.xz |
|||
mkdir -p /var/tmp/catalyst/builds/default |
|||
cd /var/tmp/catalyst/builds/default |
|||
tar -C /final -cf stage3-amd64-latest.tar . |
|||
xz -9v stage3-amd64-latest.tar |
|||
rm -rf /final |
|||
wget -O stage1.spec "https://gitweb.gentoo.org/proj/releng.git/plain/releases/specs/amd64/stage1.spec" |
|||
wget -O stage2.spec "https://gitweb.gentoo.org/proj/releng.git/plain/releases/specs/amd64/stage2.spec" |
|||
wget -O stage3.spec "https://gitweb.gentoo.org/proj/releng.git/plain/releases/specs/amd64/stage3.spec" |
|||
sed -i -e 's/@TIMESTAMP@/latest/' -e '/^portage_confdir: /d' *.spec |
|||
|
|||
Build the stage3: |
|||
emerge catalyst |
|||
catalyst -f stage1.spec |
Loading…
Reference in new issue