Repository navigation
Expand file tree
/
Copy pathgenroot
More file actions
executable file
·75 lines (61 loc) · 2.41 KB
/
Copy pathgenroot
File metadata and controls
executable file
·75 lines (61 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
set -eu
opt_build="${build:-n}"
unset build
opt_final="${final:-n}"
unset final
# Allow setting parallelization level of portage... not recommended.
NPROC="${NPROC:-1}"
BROOT="$(portageq envvar BROOT)"
export ROOT="${1:-$PWD/root}"
test $opt_build = y && ROOT="${1:-$PWD/broot}"
export EMERGE_LOG_DIR="$ROOT/var/log"
export PORTAGE_LOGDIR="$ROOT/var/log/portage"
export PORTAGE_TMPDIR="$ROOT/var/tmp"
export FEATURES='-news -parallel-fetch'
export QUICKPKG_DEFAULT_OPTS='--include-config=y' # for --quickpkg-direct=y
# silence linux-info.eclass warnings
export CHECKCONFIG_DONOTHING=y
export SKIP_KERNEL_CHECK=y
# Create ROOT directory with the correct permissions
install -dm00755 -g"$(id -g)" "$ROOT"
# Populate it with a package list from BROOT
mkdir -p "$PORTAGE_TMPDIR" "$EMERGE_LOG_DIR"
install -v -Dm644 -t "$ROOT/var/lib/portage" \
"$BROOT/var/lib/portage/world" "$BROOT/var/lib/portage/world_sets"
# Create base filesystem
test -d "$ROOT/var/db/pkg" && qlist -Ie sys-apps/baselayout > /dev/null || \
USE=build \
emerge --ask=n -nU \
sys-apps/baselayout
# HACK: Set PKGDIR to a nonsense value to avoid using local binpkgs (as it may ignore package.provided)
test $opt_final = y || export PKGDIR=/dev/null
# Install all DEPENDs in a broot
test $opt_build = y && export SYSROOT="$ROOT"
# I have no idea how to install all BDEPENDs
# So instead, pass a full list of packages...
pkg="@world"
test $opt_build = y && pkg="$(qlist -ICF '=%{CATEGORY}/%{PF}' --root "$BROOT/")"
# Sometimes, the running system might have packages that pull old deps,
# causing the installation of all packages to fail.
# Sus them out with the following command:
# emerge --root /tmp/root --quickpkg-direct=y --tree -pk $(qlist -ICF '=%{CATEGORY}/%{PF}') | tee log; less log
# Look for packages that depend on things that can't be installed as binpkg
# Rebuild those packages with:
# emerge -1 --changed-deps --binpkg-changed-deps <pkg>
# Install rest of the system
emerge --ask=n -1KDN -j "$NPROC" \
--exclude 'sys-kernel/gentoo-kernel:6.6.13' \
--quickpkg-direct=$(test $opt_final = y && echo n || echo y) \
$pkg
# Work around bad vim-related symlinks
# https://bugs.gentoo.org/922614
for x in "$ROOT/usr/share/vim"/vim*/doc/*.txt; do
test -h "$x" || continue
link="$(readlink "$x")"
case "$link" in
"$ROOT/usr/share/vim/vimfiles/doc"/*.txt)
ln -sfvrT "$link" "$x"
;;
esac
done