From 4b847c9099076c38ae6e87677a74f6644f07c63d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 6 Mar 2019 09:35:57 +0100 Subject: archPackagesUpdate: patch PKGBUILD directly instead of invoking eval inside package() --- archPackagesUpdate | 71 ++++++++++++++++++------------------------------------ 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/archPackagesUpdate b/archPackagesUpdate index b1c91ba8..706a4105 100755 --- a/archPackagesUpdate +++ b/archPackagesUpdate @@ -546,55 +546,30 @@ if ${aufRechenknecht}; then rm -rf --one-file-system src pkg # add PKGBUILD-patches to the PKGBUILD - { - if grep -q '^\s*pkgbase=' PKGBUILD; then - ( - eval "$( - sed -n '/^\s*pkgname=(/,/)/ p' PKGBUILD - )" - printf 'package_%s\n' "${pkgname[@]}" - ) - else - printf 'package\n' - fi \ - | while read -r function; do - printf '%s\n' \ - 'eval "$(' \ - ' declare -f '"${function}"' | \' \ - ' sed '"'"'$d'"'" - for patch in "${tmpDir}/"*".PKGBUILDpatch"; do - patch_name="${patch##*/}" - patch_name="${patch_name%.*}" - if grep -qF "skip ${patch_name}" PKGBUILD; then - continue - fi - printf ' cat "%s"\n' \ - "${patch##*/}" - done - printf ')\n}"\n' - done - printf 'source+=(\n' - for patch in "${tmpDir}/"*".PKGBUILDpatch"; do - printf '"%s"\n' \ - "${patch##*/}" - cp "${patch}" . + if grep -q '^\s*pkgbase=' PKGBUILD; then + ( + eval "$( + sed -n '/^\s*pkgname=(/,/)/ p' PKGBUILD + )" + printf 'package_%s\n' "${pkgname[@]}" + ) + else + printf 'package\n' + fi \ + | sponge \ + | while read -r function; do + sed -i ' + /^'"${function}"'() {$/,/^}$/ { + /^}$/ {'"$( + ls -1 "${tmpDir}/"*".PKGBUILDpatch" | \ + sed 's/^/r /' + )"' + a } + d + } + } + ' PKGBUILD done - printf ')\n' - sed ' - s/^\s*\([^=[:space:]]\+sums\)=.*$/\1/ - t - d - ' PKGBUILD \ - | while read -r sum_type; do - printf '%s+=(' \ - "${sum_type}" - "${sum_type%s}" "${tmpDir}/"*".PKGBUILDpatch" \ - | awk '{print $1}' - printf ')\n' - done - } > PKGBUILD.append - cat PKGBUILD.append >> PKGBUILD - rm PKGBUILD.append if [ "${arch}" = 'i686' ]; then # 32-bit is built in chroot /opt/arch32 -- cgit v1.2.3-70-g09d2