Browse Source

Another success!

master
mid-kid 4 months ago
parent
commit
094cbaa681
  1. 119
      gentoo-2024.8/gentoo.txt

119
gentoo-2024.8/gentoo.txt

@ -9,6 +9,8 @@ umount target/dev/shm target/sys target/proc target/tmp
# Optional: back up the system
env -i chroot target tar --exclude='/external' --sort=name -cf /target.tar /
env -i chroot target bzip2 -9v /target.tar
mv target/external/repo .
mv target/target.tar.bz2 .
# Goal:
# install cross compiler in /cross
@ -19,8 +21,13 @@ mount -t proc proc proc
mount -t sysfs sysfs sys
mount -t devtmpfs devtmpfs dev
mount -t devpts devpts dev/pts
env -i TERM="$TERM" chroot .
env -i TERM="$TERM" chroot . /bin/bash -l
source /steps/env
mkdir -p /var/cache/distfiles; cd /var/cache/distfiles
curl -LO http://gitweb.gentoo.org/proj/portage.git/snapshot/portage-3.0.65.tar.bz2
curl -LO http://distfiles.gentoo.org/snapshots/squashfs/gentoo-20240801.xz.sqfs
curl -LO https://github.com/plougher/squashfs-tools/archive/refs/tags/4.6.1/squashfs-tools-4.6.1.tar.gz
cd /tmp
cat > portage.patch << 'EOF'
@ -51,11 +58,7 @@ cat > portage.patch << 'EOF'
}
EOF
curl -LO http://gitweb.gentoo.org/proj/portage.git/snapshot/portage-3.0.65.tar.bz2
curl -LO https://github.com/plougher/squashfs-tools/archive/refs/tags/4.6.1/squashfs-tools-4.6.1.tar.gz
curl -LO http://distfiles.gentoo.org/snapshots/squashfs/gentoo-20240801.xz.sqfs
tar xf squashfs-tools-4.6.1.tar.gz
tar xf /var/cache/distfiles/squashfs-tools-4.6.1.tar.gz
cd squashfs-tools-4.6.1
make -C squashfs-tools install \
INSTALL_PREFIX=/usr \
@ -63,12 +66,15 @@ make -C squashfs-tools install \
cd ..
rm -rf squashfs-tools-4.6.1
unsquashfs gentoo-20240801.xz.sqfs
unsquashfs /var/cache/distfiles/gentoo-20240801.xz.sqfs
mkdir -p /var/db/repos
rm -rf /var/db/repos/gentoo
mv squashfs-root /var/db/repos/gentoo
tar xf portage-3.0.65.tar.bz2
tar xf /var/cache/distfiles/portage-3.0.65.tar.bz2
cd portage-3.0.65
patch -p1 -i ../portage.patch
cd ..
ln -sf portage-3.0.65 portage
# Configure portage
@ -100,10 +106,10 @@ FETCHCOMMAND="$FETCHCOMMAND" MAKEOPTS=-j1 ./portage/bin/emerge -O1 dev-build/mak
FETCHCOMMAND="$FETCHCOMMAND" ./portage/bin/emerge -O1 net-misc/wget
# Upgrade python so we can use it to cross-compile later on
./portage/bin/emerge -O1 dev-build/autoconf
./portage/bin/emerge -O1 dev-build/autoconf-wrapper
./portage/bin/emerge -O1 dev-build/automake
./portage/bin/emerge -O1 dev-build/autoconf
./portage/bin/emerge -O1 dev-build/automake-wrapper
./portage/bin/emerge -O1 dev-build/automake
./portage/bin/emerge -O1 sys-apps/gentoo-functions
./portage/bin/emerge -O1 app-portage/elt-patches
./portage/bin/emerge -O1 dev-libs/mpdecimal
@ -128,13 +134,13 @@ ln -s bzip2-reference /bin/bzip2
./portage/bin/emerge -O1 dev-python/wheel
./portage/bin/emerge -O1 dev-python/setuptools
./portage/bin/emerge -O1 dev-build/meson
./portage/bin/emerge -O1 dev-build/meson-format-array
./portage/bin/emerge -O1 dev-build/ninja
# Finally install portage itself
./portage/bin/emerge -O1 sys-apps/portage
# Install pax-utils to allow stripping binaries
emerge -O1 dev-build/meson-format-array
# Install pax-utils to allow stripping binaries (requires meson...)
emerge -O1 app-misc/pax-utils
# Fix "find" warnings in emerge
@ -168,14 +174,14 @@ sys-devel/gcc -sanitize -fortran
EOF
mkdir -p /cross/etc/portage/env/sys-devel
cat > /cross/etc/portage/env/sys-devel/gcc << 'EOF'
EXTRA_ECONF='--with-sysroot=$EPREFIX/usr/$CTARGET'
EXTRA_ECONF='--with-sysroot=$EPREFIX/usr/$CTARGET --enable-threads'
EOF
# TODO: Build sys-libs/glibc in /gentoo instead, to avoid extra rebuilding
PORTAGE_CONFIGROOT=/cross EPREFIX=/cross emerge -O1 sys-devel/binutils
PORTAGE_CONFIGROOT=/cross EPREFIX=/cross USE='headers-only' emerge -O1 sys-kernel/linux-headers
PORTAGE_CONFIGROOT=/cross EPREFIX=/cross USE='headers-only -multilib' emerge -O1 sys-libs/glibc
PORTAGE_CONFIGROOT=/cross EPREFIX=/cross USE='-cxx -openmp' emerge -O1 sys-devel/gcc
PORTAGE_CONFIGROOT=/cross EPREFIX=/cross USE='-cxx' emerge -O1 sys-devel/gcc
PORTAGE_CONFIGROOT=/cross EPREFIX=/cross emerge -O1 sys-kernel/linux-headers
PORTAGE_CONFIGROOT=/cross EPREFIX=/cross emerge -O1 sys-libs/glibc
PORTAGE_CONFIGROOT=/cross EPREFIX=/cross emerge -O1 sys-devel/gcc
@ -213,7 +219,7 @@ BINPKG_COMPRESS="bzip2"
CBUILD="i386-unknown-linux-musl"
CHOST="x86_64-bootstrap-linux-gnu"
CFLAGS_x86="$CFLAGS_x86 -msse" # bug 937637
USE="-* build openmp python_targets_python3_12"
USE="-* build $BOOTSTRAP_USE -zstd"
CONFIG_SITE="$PORTAGE_CONFIGROOT/etc/portage/config.site"
EOF
cat > /gentoo.cfg/etc/portage/config.site << 'EOF'
@ -224,6 +230,7 @@ ac_cv_file__dev_ptc=no
fi
EOF
py=$(PORTAGE_CONFIGROOT=/gentoo.cfg portageq envvar PYTHON_SINGLE_TARGET | sed 's/^python//;s/_/./g')
PORTAGE_CONFIGROOT=/gentoo.cfg ROOT=/gentoo SYSROOT=/gentoo emerge -O1n \
sys-apps/baselayout \
sys-kernel/linux-headers \
@ -242,7 +249,7 @@ PORTAGE_CONFIGROOT=/gentoo.cfg ROOT=/gentoo SYSROOT=/gentoo emerge -O1n \
dev-libs/mpdecimal \
sys-apps/util-linux \
sys-libs/libxcrypt \
dev-lang/python:3.12 \
dev-lang/python:$py \
\
dev-lang/python-exec \
sys-apps/portage \
@ -259,53 +266,53 @@ PORTAGE_CONFIGROOT=/gentoo.cfg ROOT=/gentoo SYSROOT=/gentoo emerge -O1n \
sys-devel/patch \
app-arch/tar \
app-arch/gzip \
dev-build/make
# TODO: Un-hardcode python 3.12
# TODO: Avoid gzip?
dev-build/make \
\
dev-libs/openssl \
net-misc/wget \
app-misc/ca-certificates
# Set up final system
mkdir -p /gentoo/etc/portage
ln -sf ../../var/db/repos/gentoo/profiles/default/linux/amd64/23.0 /gentoo/etc/portage/make.profile
rsync -aP /var/db/repos/ /gentoo/var/db/repos
echo 'nameserver 1.1.1.1' > /gentoo/etc/resolv.conf
echo 'C.UTF8 UTF-8' > /gentoo/etc/locale.gen
# Fetch some extra source code
DISTDIR=/gentoo/var/cache/distfiles \
PORTAGE_CONFIGROOT=/gentoo ROOT=/gentoo SYSROOT=/gentoo emerge -O1f \
dev-util/pkgconf \
dev-lang/perl \
dev-libs/openssl \
net-misc/wget \
app-misc/ca-certificates
# Copy repo
rsync -aP /var/db/repos/ /gentoo/var/db/repos
# From here you just chroot into /gentoo, clean /etc/portage (leaving only make.profile), install wget, and run "emerge -DN @world", untangling dependencies until it works
# From here you just chroot into /gentoo, and run "emerge -e @world", untangling dependencies until it works
# This is an example:
# TODO: Avoid weird gcc rebuild...
# This part can be improved a lot by cross-compiling more stuff
emerge -O1 dev-util/pkgconf
USE=-gdbm emerge -O1 dev-lang/perl
emerge -O1 dev-libs/openssl
MAKEINFO=true emerge -O1 net-misc/wget
emerge -O1 app-misc/ca-certificates
emerge -O1 dev-build/ninja
emerge -O1 app-alternatives/ninja
emerge -O1 sys-apps/gentoo-functions
emerge -O1 app-portage/elt-patches
emerge -O1 sys-devel/m4
MAKEINFO=true emerge -O1 sys-devel/flex
emerge -O1 sys-apps/diffutils
emerge -O1 sys-devel/gcc-config
USE='-* openmp' EXTRA_ECONF=--disable-bootstrap emerge -O1 sys-devel/gcc
emerge -O1 dev-build/ninja # avoid segfault
emerge -O1 sys-devel/bison
USE='-* cet' emerge -O1 sys-libs/glibc
emerge -O1 app-alternatives/yacc
emerge -O1 app-alternatives/lex
rm -f /var/run/bootstrap-progress && USE=-nls /var/db/repos/gentoo/scripts/bootstrap.sh
USE='-* openmp' EXTRA_ECONF=--disable-bootstrap emerge -O1 sys-devel/gcc # enable openmp again...
USE='-nls -pam -su -http2' emerge -1 net-misc/rsync
USE='-nls -pam -su -http2' emerge -e @system
emerge -DN @system
# TODO: How does catalyst stage1 resolve these?
emerge -O1n \
app-alternatives/awk \
app-alternatives/bzip2 \
app-alternatives/gzip \
app-alternatives/lex \
app-alternatives/ninja \
app-alternatives/tar \
app-alternatives/yacc
USE="-* build $(portageq envvar BOOTSTRAP_USE)" emerge -O1n \
sys-apps/gentoo-functions \
app-portage/elt-patches \
app-crypt/libmd \
dev-libs/libbsd \
dev-util/pkgconf \
sys-apps/shadow
# Finish installing stage1 dependencies
pkgs_build="$(python3 -c 'import portage
print(*portage.util.stack_lists([portage.util.grabfile_package("%s/packages.build" % x) for x in portage.settings.profiles], incremental=1))')"
USE="-* build $(portageq envvar BOOTSTRAP_USE)" CHOST="$(gcc -dumpmachine)" \
emerge -1Dn --with-bdeps=n $pkgs_build
# Change CHOST and build OpenMP support
emerge -O1 sys-devel/binutils
EXTRA_ECONF=--disable-bootstrap emerge -O1 sys-devel/gcc
emerge -O1 $(portageq expand_virtual / virtual/libc)
# Rebuild everything
USE='-filecaps -http2' emerge -e @system
emerge -c

Loading…
Cancel
Save