From cad76dea393550b41b142efd73873bf4ec18c8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 15 May 2022 19:46:25 +0200 Subject: [PATCH] Manually unbreak if 0, EXTRA_DIST = (and dist_xxx_MANS =) being ignored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Workaround-for: https://bugs.debian.org/1011024 Closes: #13459 Signed-off-by: Ahelenia ZiemiaƄska --- autogen.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/autogen.sh b/autogen.sh index c817090183f1..cde98d40ca7a 100755 --- a/autogen.sh +++ b/autogen.sh @@ -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 @@ -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 @@ -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 +}