1 |
commit: 83510840c1dfde65e806e405c64abec44b9095f4 |
2 |
Author: Ulrich Müller <ulm <AT> kph <DOT> uni-mainz <DOT> de> |
3 |
AuthorDate: Mon May 20 08:53:39 2019 +0000 |
4 |
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon May 20 21:31:15 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=83510840 |
7 |
|
8 |
sys-kernel/linux-firmware: Speed up src_prepare code. |
9 |
|
10 |
Building the list of files to remove could take up to one minute |
11 |
on recent hardware, because it used a quadratic algorithm in bash. |
12 |
Call grep instead, which is way faster. |
13 |
|
14 |
Acked-by: Chí-Thanh Christopher Nguyễn <chithanh <AT> gentoo.org> |
15 |
Closes: https://bugs.gentoo.org/686376 |
16 |
Package-Manager: Portage-2.3.66, Repoman-2.3.12 |
17 |
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> |
18 |
|
19 |
.../linux-firmware/linux-firmware-99999999.ebuild | 33 ++++++++-------------- |
20 |
1 file changed, 11 insertions(+), 22 deletions(-) |
21 |
|
22 |
diff --git a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild |
23 |
index 398592afd42..f439b40eab4 100644 |
24 |
--- a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild |
25 |
+++ b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild |
26 |
@@ -226,6 +226,7 @@ src_prepare() { |
27 |
|
28 |
# remove sources and documentation (wildcards are expanded) |
29 |
rm -r ${source_files[@]} || die |
30 |
+ rm -rf .git |
31 |
|
32 |
if use !unknown-license; then |
33 |
# remove files in unknown_license |
34 |
@@ -236,12 +237,11 @@ src_prepare() { |
35 |
# remove files _not_ in the free_software or unknown_license lists |
36 |
# everything else is confirmed (or assumed) to be redistributable |
37 |
# based on upstream acceptance policy |
38 |
- local file remove=() |
39 |
- while IFS= read -d "" -r file; do |
40 |
- has "${file#./}" "${free_software[@]}" "${unknown_license[@]}" \ |
41 |
- || remove+=("${file}") |
42 |
- done < <(find * ! -type d -print0 || die) |
43 |
- printf "%s\0" "${remove[@]}" | xargs -0 rm || die |
44 |
+ local IFS=$'\n' |
45 |
+ find ! -type d -printf "%P\n" \ |
46 |
+ | grep -Fvx -e "${free_software[*]}" -e "${unknown_license[*]}" \ |
47 |
+ | xargs -d '\n' rm || die |
48 |
+ IFS=$' \t\n' |
49 |
fi |
50 |
|
51 |
echo "# Remove files that shall not be installed from this list." > ${PN}.conf |
52 |
@@ -250,23 +250,12 @@ src_prepare() { |
53 |
if use savedconfig; then |
54 |
restore_config ${PN}.conf |
55 |
|
56 |
- local file preserved_files=() remove=() |
57 |
- |
58 |
ebegin "Removing all files not listed in config" |
59 |
- while IFS= read -r file; do |
60 |
- # Ignore comments. |
61 |
- if [[ ${file} != "#"* ]]; then |
62 |
- preserved_files+=("${file}") |
63 |
- fi |
64 |
- done < ${PN}.conf || die |
65 |
- |
66 |
- while IFS= read -d "" -r file; do |
67 |
- has "${file}" "${preserved_files[@]}" || remove+=("${file}") |
68 |
- done < <(find * ! -type d ! -name ${PN}.conf -print0 || die) |
69 |
- if [[ ${#remove[@]} -gt 0 ]]; then |
70 |
- printf "%s\0" "${remove[@]}" | xargs -0 rm || die |
71 |
- fi |
72 |
- eend 0 |
73 |
+ find ! -type d ! -name ${PN}.conf -printf "%P\n" \ |
74 |
+ | grep -Fvx -f <(grep -v '^#' ${PN}.conf \ |
75 |
+ || die "grep failed, empty config file?") \ |
76 |
+ | xargs -d '\n' --no-run-if-empty rm |
77 |
+ eend $? || die |
78 |
fi |
79 |
|
80 |
# remove empty directories, bug #396073 |