-
Notifications
You must be signed in to change notification settings - Fork 0
/
genroot
executable file
·65 lines (54 loc) · 1.89 KB
/
genroot
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
#!/bin/sh
set -eu
opt_build="${build:-n}"
unset build
opt_final="${final:-n}"
unset final
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
# Creates an ROOT using portage based on a package list
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, install just enough to avoid circular dependencies
extrapkg=""
test $opt_build = y && extrapkg="
dev-lang/go
dev-lang/rust
"
# TODO: Use `qlist -ICF '=%{CATEGORY}/%{PF}' --root "$BROOT"` to install all packages instead
# Install rest of the system
emerge --ask=n -KDU \
--with-bdeps=$opt_build \
--quickpkg-direct=$(test $opt_final = y && echo n || echo y) \
@world $extrapkg
# 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