Skip to content

Commit

Permalink
Manually unbreak if 0, EXTRA_DIST = (and dist_xxx_MANS =) being ignored
Browse files Browse the repository at this point in the history
Workaround-for: https://bugs.debian.org/1011024
Closes: openzfs#13459
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
  • Loading branch information
nabijaczleweli authored and adamdmoss committed May 15, 2022
1 parent de82164 commit 7116b1e
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 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 @@ -60,3 +61,63 @@ automake --version | awk '{print $NF; exit}' | (
}

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
}

0 comments on commit 7116b1e

Please sign in to comment.