Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:wip/mattst88 commit in: targets/support/
Date: Thu, 29 Oct 2020 21:00:48
Message-Id: 1603236395.97060f608afd21e1463115f46cf2fbc3cee73b5c.mattst88@gentoo
1 commit: 97060f608afd21e1463115f46cf2fbc3cee73b5c
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Tue Oct 20 02:38:39 2020 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 20 23:26:35 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=97060f60
7
8 targets: Reimplement kerncache support
9
10 I cannot see how the code added in commit fed3b45b could have possibly
11 worked, and in practice it did not.
12
13 An earlier commit (beb92087) deleted most or all of the uses of the
14 *_MATCH variables but left the code that set them in place.
15
16 Fixes: beb92087 ("Added patches from Joshua Kinard <kumba <AT> gentoo.org>")
17 Fixes: fed3b45b ("Fix and improve kernel build when kerncache is enabled.")
18 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
19
20 targets/support/kmerge.sh | 147 +++++++++++++++-------------------------------
21 1 file changed, 47 insertions(+), 100 deletions(-)
22
23 diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh
24 index 6a0137d7..972feb99 100755
25 --- a/targets/support/kmerge.sh
26 +++ b/targets/support/kmerge.sh
27 @@ -85,11 +85,6 @@ genkernel_compile() {
28 else
29 genkernel "${GK_ARGS[@]}" || exit 1
30 fi
31 - if [ -n "${clst_KERNCACHE}" -a -e /var/tmp/${kname}.config ]
32 - then
33 - md5sum /var/tmp/${kname}.config | awk '{print $1}' > \
34 - /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.CONFIG
35 - fi
36 }
37
38 [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript
39 @@ -106,117 +101,69 @@ eval eval kernel_gk_kernargs=( \$clst_boot_kernel_${kname}_gk_kernargs )
40 eval "ksource=\$clst_boot_kernel_${kname}_sources"
41 [[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-sources"
42
43 -# Check if we have a match in kerncach
44 -
45 -if [ -n "${clst_KERNCACHE}" ]
46 -then
47 - USE_MATCH=0
48 - if [ -e /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.USE ]
49 - then
50 - STR1=$(for i in `cat /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.USE`; do echo $i; done|sort)
51 - STR2=$(for i in ${kernel_use}; do echo $i; done|sort)
52 - if [ "${STR1}" = "${STR2}" ]
53 - then
54 - USE_MATCH=1
55 - else
56 - [ -e /tmp/kerncache/${kname}/usr/src/linux/.config ] && \
57 - rm /tmp/kerncache/${kname}/usr/src/linux/.config
58 - fi
59 - fi
60 -
61 - EXTRAVERSION_MATCH=0
62 - if [ -e /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.EXTRAVERSION ]
63 - then
64 - STR1=`cat /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.EXTRAVERSION`
65 - STR2=${clst_kextraversion}
66 - if [ "${STR1}" = "${STR2}" ]
67 - then
68 - EXTRAVERSION_MATCH=1
69 - fi
70 - fi
71 -
72 - CONFIG_MATCH=0
73 - if [ -e /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.CONFIG ]
74 - then
75 - if [ ! -e /var/tmp/${kname}.config ]
76 - then
77 - CONFIG_MATCH=1
78 - else
79 - STR1=`cat /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.CONFIG`
80 - STR2=`md5sum /var/tmp/${kname}.config|awk '{print $1}'`
81 - if [ "${STR1}" = "${STR2}" ]
82 - then
83 - CONFIG_MATCH=1
84 - fi
85 - fi
86 - fi
87 +kernel_version=$(portageq best_visible / "${ksource}")
88
89 - # install dependencies of kernel sources ahead of time in case
90 - # package.provided generated below causes them not to be (re)installed
91 - run_merge --onlydeps "${ksource}"
92 +if [[ -n ${clst_KERNCACHE} ]]; then
93 + mkdir -p "/tmp/kerncache/${kname}"
94 + pushd "/tmp/kerncache/${kname}" >/dev/null
95
96 - # Create the kerncache directory if it doesn't exists
97 - mkdir -p /tmp/kerncache/${kname}
98 + echo "${kernel_use}" > /tmp/USE
99 + echo "${kernel_version}" > /tmp/VERSION
100 + echo "${clst_kextraversion}" > /tmp/EXTRAVERSION
101
102 - if [ -e /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.KERNELVERSION ]
103 - then
104 - KERNELVERSION=$(</tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.KERNELVERSION)
105 - mkdir -p ${clst_port_conf}/profile
106 - echo "${KERNELVERSION}" > ${clst_port_conf}/profile/package.provided
107 - else
108 - rm -f ${clst_port_conf}/profile/package.provided
109 + if cmp -s {/tmp/,}USE && \
110 + cmp -s {/tmp/,}VERSION && \
111 + cmp -s {/tmp/,}EXTRAVERSION && \
112 + cmp -s /var/tmp/${kname}.config CONFIG; then
113 + cached_kernel_found="true"
114 fi
115
116 - # Don't use package.provided if there's a pending up/downgrade
117 - if [[ "$(portageq best_visible / ${ksource})" == "${KERNELVERSION}" ]]; then
118 - echo "No pending updates for ${ksource}"
119 - else
120 - echo "Pending updates for ${ksource}, removing package.provided"
121 - rm -f ${clst_port_conf}/profile/package.provided
122 - fi
123 + rm -f /tmp/{USE,VERSION,EXTRAVERSION}
124 + popd >/dev/null
125 +fi
126
127 +if [[ ! ${cached_kernel_found} ]]; then
128 USE=symlink run_merge --update "${ksource}"
129 +fi
130
131 +if [[ -n ${clst_KERNCACHE} ]]; then
132 SOURCESDIR="/tmp/kerncache/${kname}/sources"
133 - if [ -L /usr/src/linux ]
134 - then
135 - # A kernel was merged, move it to $SOURCESDIR
136 - [ -e ${SOURCESDIR} ] && rm -Rf ${SOURCESDIR}
137 -
138 - KERNELVERSION=`portageq best_visible / "${ksource}"`
139 - echo "${KERNELVERSION}" > /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.KERNELVERSION
140 -
141 + if [[ ! ${cached_kernel_found} ]]; then
142 echo "Moving kernel sources to ${SOURCESDIR} ..."
143 - mv `readlink -f /usr/src/linux` ${SOURCESDIR}
144 - fi
145 - ln -sf ${SOURCESDIR} /usr/src/linux
146
147 - # If catalyst has set to a empty string, extraversion wasn't specified so we
148 - # skip this part
149 - if [ "${EXTRAVERSION_MATCH}" = "0" ]
150 - then
151 - if [ ! "${clst_kextraversion}" = "" ]
152 - then
153 - echo "Setting extraversion to ${clst_kextraversion}"
154 - sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile
155 - echo ${clst_kextraversion} > /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.EXTRAVERSION
156 - else
157 - touch /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.EXTRAVERSION
158 - fi
159 + rm -rf "${SOURCESDIR}"
160 + mv $(readlink -f /usr/src/linux) "${SOURCESDIR}"
161 fi
162 -else
163 - USE=symlink run_merge --update "${ksource}"
164 + ln -snf "${SOURCESDIR}" /usr/src/linux
165 +fi
166
167 - if [ ! "${clst_kextraversion}" = "" ]
168 - then
169 - echo "Setting extraversion to ${clst_kextraversion}"
170 - sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile
171 +if [[ -n ${clst_kextraversion} ]]; then
172 + echo "Setting EXTRAVERSION to ${clst_kextraversion}"
173 +
174 + if [[ -e /usr/src/linux/Makefile.bak ]]; then
175 + cp /usr/src/linux/Makefile{.bak,}
176 + else
177 + cp /usr/src/linux/Makefile{,.bak}
178 fi
179 + sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" \
180 + /usr/src/linux/Makefile
181 fi
182
183 genkernel_compile
184
185 -if [ -n "${clst_KERNCACHE}" ]
186 -then
187 - echo ${kernel_use} > /tmp/kerncache/${kname}/${kname}-${clst_version_stamp}.USE
188 +# Write out CONFIG, USE, VERSION, and EXTRAVERSION files
189 +if [[ -n ${clst_KERNCACHE} && ! ${cached_kernel_found} ]]; then
190 + pushd "/tmp/kerncache/${kname}" >/dev/null
191 +
192 + cp /var/tmp/${kname}.config CONFIG
193 + echo "${kernel_use}" > USE
194 + echo "${kernel_version}" > VERSION
195 + echo "${clst_kextraversion}" > EXTRAVERSION
196 +
197 + popd >/dev/null
198 +fi
199 +
200 +if [[ ! ${cached_kernel_found} ]]; then
201 + run_merge -C "${ksource}"
202 + rm /usr/src/linux
203 fi