Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-single-step cleanup #13447

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
# shellcheck disable=SC2016,SC2094
[ "${0%/*}" = "$0" ] || cd "${0%/*}" || exit

# %reldir%/%canon_reldir% (%D%/%C%) only appeared in automake 1.14, but RHEL/CentOS 7 has 1.13.4
Expand Down Expand Up @@ -47,6 +48,7 @@ automake --version | awk '{print $NF; exit}' | (

roots="$(sed '/Makefile$/!d;/module/d;s:^\s*:./:;s:/Makefile::;/^\.$/d' configure.ac)"

OIFS="$IFS"
IFS="
"
for root in $roots; do
Expand All @@ -57,6 +59,67 @@ automake --version | awk '{print $NF; exit}' | (
set -f
# shellcheck disable=SC2086,SC2046
process_root . $(printf '!\n-path\n%s/*\n' $roots)
IFS="$OIFS"
}

autoreconf -fiv && rm -rf autom4te.cache

# https://github.com/openzfs/zfs/issues/13459
# https://bugs.debian.org/1011024
# When including, EXTRA_DIST in false conditionals is skipped; we need to preprocess Makefile.in to unbreak this.
# The same happens to dist_man_MANS (DISTFILES -> DIST_COMMON -> am__DIST_COMMON -> dist_man_MANS).
#
# Shortcuts taken:
# * only the root Makefile.in is processed because it's the only one that does if, include; it takes too long to process this as-is (~0.3s)
# * only one level of :suff=suff allowed
{
deverbol() {
type rollback > /dev/null 2>&1 && rollback
rm -f "$verbols"
}

trap deverbol EXIT
verbols="$(mktemp)"

parse_verbols() {
v="${v#\$\(}"
v="${v%\)}"
[ -z "$suff_bundle" ] && {
suff_bundle="${v#*:}"
[ "$suff_bundle" = "$v" ] && suff_bundle= || suff_bundle=":$suff_bundle"
}
v="${v%:*}"
}

printf "%s\n" dist_man_MANS EXTRA_DIST > "$verbols"
while read -r v suff_bundle; do
parse_verbols
# Early exit buys back 0.43s here
awk -v v="$v" '($0 ~ ("^(@[A-Z_@]*@)?" v " =")),!/\\$/ {copying=1; print} copying && !/\\$/ {exit}' Makefile.in |
grep -o '$([^ )]*)' |
sed 's/$/ '"$suff_bundle"'/'
done < "$verbols" >> "$verbols"
sort "$verbols" | uniq |
while read -r v suff_bundle; do
parse_verbols
# And another 0.34s here
awk -v v="$v" '
BEGIN {
printf "faux_" v "_faux := "
}
($0 ~ ("^@[A-Z_@]*@" v " =")),!/\\$/ {
l = $0
sub(/^@[A-Z_@]*@/, "", l)
sub("^" v " =", "", l)
sub(/\\$/, "", l)
printf "%s", l
copying = 1
}
copying && !/\\$/ {
exit
}
' Makefile.in
echo
echo "EXTRA_DIST += \$(faux_${v}_faux${suff_bundle})"
done >> Makefile.in
}
Loading