Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/
Date: Wed, 28 Dec 2022 15:19:59
Message-Id: 1672240793.a627ff5554f4efb061d1ce261a248efb5e9d7e59.sam@gentoo
1 commit: a627ff5554f4efb061d1ce261a248efb5e9d7e59
2 Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 27 11:46:18 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Dec 28 15:19:53 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=a627ff55
7
8 scripts/bootstrap-prefix: Set a prefix-guest profile for RAP stage2
9
10 This is technically more correct, as stage2 uses the host's libc. It
11 also means that the Gentoo repo can check for the `prefix-guest` USE
12 flag instead of the magic `BOOTSTRAP_RAP_STAGE2` variable.
13
14 Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
15 Closes: https://github.com/gentoo/prefix/pull/15
16 Signed-off-by: Sam James <sam <AT> gentoo.org>
17
18 scripts/bootstrap-prefix.sh | 52 +++++++++++++++++++++++++++++----------------
19 1 file changed, 34 insertions(+), 18 deletions(-)
20
21 diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
22 index 4a6125b769..48f6b686cc 100755
23 --- a/scripts/bootstrap-prefix.sh
24 +++ b/scripts/bootstrap-prefix.sh
25 @@ -298,24 +298,8 @@ configure_toolchain() {
26 }
27
28 bootstrap_setup() {
29 - local profile=""
30 einfo "Setting up some guessed defaults"
31
32 - # 2.6.32.1 -> 2*256^3 + 6*256^2 + 32 * 256 + 1 = 33955841
33 - kver() { uname -r|cut -d\- -f1|awk -F. '{for (i=1; i<=NF; i++){s+=lshift($i,(4-i)*8)};print s}'; }
34 - # >=glibc-2.20 requires >=linux-2.6.32.
35 - profile-kernel() {
36 - if [[ $(kver) -ge 50462720 ]] ; then # 3.2
37 - echo kernel-3.2+
38 - elif [[ $(kver) -ge 33955840 ]] ; then # 2.6.32
39 - echo kernel-2.6.32+
40 - elif [[ $(kver) -ge 33951744 ]] ; then # 2.6.16
41 - echo kernel-2.6.16+
42 - elif [[ $(kver) -ge 33947648 ]] ; then # 2.6
43 - echo kernel-2.6+
44 - fi
45 - }
46 -
47 local FS_INSENSITIVE=0
48 touch "${ROOT}"/FOO.$$
49 [[ -e ${ROOT}/foo.$$ ]] && FS_INSENSITIVE=1
50 @@ -377,6 +361,30 @@ bootstrap_setup() {
51 fi
52 [[ -f ${ROOT}/etc/resolv.conf ]] || ln -s {,"${ROOT}"}/etc/resolv.conf
53 [[ -f ${ROOT}/etc/hosts ]] || cp {,"${ROOT}"}/etc/hosts
54 + fi
55 +
56 + bootstrap_profile
57 +}
58 +
59 +bootstrap_profile() {
60 + local profile=""
61 +
62 + # 2.6.32.1 -> 2*256^3 + 6*256^2 + 32 * 256 + 1 = 33955841
63 + kver() { uname -r|cut -d\- -f1|awk -F. '{for (i=1; i<=NF; i++){s+=lshift($i,(4-i)*8)};print s}'; }
64 + # >=glibc-2.20 requires >=linux-2.6.32.
65 + profile-kernel() {
66 + if [[ $(kver) -ge 50462720 ]] ; then # 3.2
67 + echo kernel-3.2+
68 + elif [[ $(kver) -ge 33955840 ]] ; then # 2.6.32
69 + echo kernel-2.6.32+
70 + elif [[ $(kver) -ge 33951744 ]] ; then # 2.6.16
71 + echo kernel-2.6.16+
72 + elif [[ $(kver) -ge 33947648 ]] ; then # 2.6
73 + echo kernel-2.6+
74 + fi
75 + }
76 +
77 + if is-rap ; then
78 local profile_linux=default/linux/ARCH/17.0/prefix/$(profile-kernel)
79 else
80 local profile_linux=prefix/linux/ARCH
81 @@ -1624,8 +1632,13 @@ bootstrap_stage1() {
82 [[ -e ${ROOT}/etc/portage/make.profile && \
83 -e ${MAKE_CONF_DIR}/0100_bootstrap_prefix_make.conf ]] \
84 || (bootstrap_setup) || return 1
85 +
86 + # setup a profile for stage2
87 mkdir -p "${ROOT}"/tmp/etc/. || return 1
88 - [[ -e ${ROOT}/tmp/etc/portage/make.profile ]] || "${CP}" -dpR "${ROOT}"/etc/portage "${ROOT}"/tmp/etc || return 1
89 + [[ -e ${ROOT}/tmp/etc/portage/make.profile ]] || \
90 + ( "${CP}" -dpR "${ROOT}"/etc/portage "${ROOT}"/tmp/etc && \
91 + rm -f "${ROOT}"/tmp/etc/portage/make.profile && \
92 + (ROOT="${ROOT}"/tmp PREFIX_DISABLE_RAP=yes bootstrap_profile) ) || return 1
93
94 # setup portage
95 [[ -e ${ROOT}/tmp/usr/bin/emerge ]] || (bootstrap_portage) || return 1
96 @@ -1732,7 +1745,6 @@ do_emerge_pkgs() {
97 && export CFLAGS=${OVERRIDE_CFLAGS}
98 [[ -n ${OVERRIDE_CXXFLAGS} ]] \
99 && export CXXFLAGS=${OVERRIDE_CXXFLAGS}
100 - PORTAGE_CONFIGROOT="${EPREFIX}" \
101 PORTAGE_SYNC_STALE=0 \
102 FEATURES="-news ${FEATURES}" \
103 USE="${myuse[*]}" \
104 @@ -1755,6 +1767,8 @@ do_emerge_pkgs() {
105 }
106
107 bootstrap_stage2() {
108 + export PORTAGE_CONFIGROOT="${ROOT}"/tmp
109 +
110 if ! type -P emerge > /dev/null ; then
111 eerror "emerge not found, did you bootstrap stage1?"
112 return 1
113 @@ -1937,6 +1951,8 @@ bootstrap_stage2_log() {
114 }
115
116 bootstrap_stage3() {
117 + export PORTAGE_CONFIGROOT="${ROOT}"
118 +
119 if ! type -P emerge > /dev/null ; then
120 eerror "emerge not found, did you bootstrap stage1?"
121 return 1