From 5ecfc84bc620859a57c8364bda636cbca14c46e6 Mon Sep 17 00:00:00 2001 From: Max Rees Date: Tue, 19 Jun 2018 00:46:45 -0400 Subject: Initial removal of bashisms --- abuild.in | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'abuild.in') diff --git a/abuild.in b/abuild.in index d1456c9..07b872c 100644 --- a/abuild.in +++ b/abuild.in @@ -269,7 +269,8 @@ sumcheck() { fetch || return 1 msg "Checking ${algo}sums..." cd "$srcdir" || return 1 - IFS=$'\n' + IFS=" +" endreturnval=0 for src in $sums; do origin=$1; shift @@ -277,7 +278,7 @@ sumcheck() { endreturnval=1 is_remote $origin || continue - local csum="${src:0:8}" + local csum="$(printf '%s' "$src" | awk '{ print substr($0, 1, 8) }' )" local file="$SRCDEST/$(filename_from_uri $origin)" echo "Because the remote file above failed the ${algo}sum check it will be renamed." @@ -514,7 +515,8 @@ cleanpkg() { rm -f "$REPODEST/$repo/src/$pkgname-$pkgver-r$pkgrel.src.tar.gz" for i in $allpackages; do subpkg_set "$i" - rm -f "$REPODEST/$repo/${subpkgarch/noarch/$CARCH}/$subpkgname-$pkgver-r$pkgrel.apk" + [ "$subpkgarch" = "noarch" ] && subpkgarch="$CARCH" + rm -f "$REPODEST/$repo/$subpkgarch/$subpkgname-$pkgver-r$pkgrel.apk" done subpkg_unset @@ -870,9 +872,9 @@ check_secfixes_comment() { fi # check if there are tabs - if echo "$invalid" | grep -q $'\t'; then + if echo "$invalid" | grep -q "$(printf '\t')"; then error "secfixes comment must not have tabs:" - echo "$c" | grep $'\t' >&2 + echo "$c" | grep "$(printf '\t')" >&2 return 1 fi @@ -998,7 +1000,8 @@ prepare_metafiles() { local f=${i%=*} local dirs=${i#*=} [ "${f%.trigger}" != "$name" ] && continue - echo "triggers = ${dirs//:/ }" >> "$pkginfo" + dirs="$(printf '%s' "$dirs" | sed 's/:/ /g')" + echo "triggers = $dirs" >> "$pkginfo" done if [ -n "$install_if" ]; then echo "install_if = $(echo $install_if)" >> "$pkginfo" @@ -1392,7 +1395,7 @@ scan_shared_objects() { # path (2nd arg). normalize_target_path() { local path=$1 - [ "${path:0:1}" = / ] || path=$(dirname "$2")/$path + (printf '%s' "$path" | grep -q '^/') || path=$(dirname "$2")/$path local oifs="$IFS" pathstr= i= IFS='/' @@ -1510,8 +1513,9 @@ create_apks() { abuild-sign -q control.tar.gz || exit 1 msg "Create $apk" - mkdir -p "$REPODEST"/$repo/${subpkgarch/noarch/$CARCH} - cat control.tar.gz data.tar.gz > "$REPODEST"/$repo/${subpkgarch/noarch/$CARCH}/$apk + [ "$subpkgarch" = "noarch" ] && subpkgarch="$CARCH" + mkdir -p "$REPODEST"/$repo/$subpkgarch + cat control.tar.gz data.tar.gz > "$REPODEST"/$repo/$subpkgarch/$apk ) done } @@ -1840,7 +1844,8 @@ apk_up2date() { local i s for i in $allpackages; do subpkg_set "$i" - if [ ! -f "$REPODEST/$repo/${subpkgarch/noarch/$CARCH}/$subpkgname-$pkgver-r$pkgrel.apk" ]; then + [ "$subpkgarch" = "noarch" ] && subpkgarch="$CARCH" + if [ ! -f "$REPODEST/$repo/$subpkgarch/$subpkgname-$pkgver-r$pkgrel.apk" ]; then subpkg_unset return 1 fi @@ -1855,7 +1860,8 @@ apk_up2date() { else s="$startdir/${i##*/}" fi - if [ "$s" -nt "$REPODEST/$repo/${pkgarch/noarch/$CARCH}/$pkgname-$pkgver-r$pkgrel.apk" ]; then + [ "$pkgarch" = "noarch" ] && pkgarch="$CARCH" + if [ "$s" -nt "$REPODEST/$repo/$pkgarch/$pkgname-$pkgver-r$pkgrel.apk" ]; then return 1 fi done @@ -1868,7 +1874,8 @@ abuildindex_up2date() { for i in $allpackages; do subpkg_set "$i" - local dir="$REPODEST"/$repo/${subpkgarch/noarch/$CARCH} + [ "$subpkgarch" = "noarch" ] && subpkgarch="$CARCH" + local dir="$REPODEST"/$repo/$subpkgarch local idx="$dir"/APKINDEX.tar.gz local file="$dir"/$subpkgname-$pkgver-r$pkgrel.apk @@ -2187,7 +2194,7 @@ rootbld() { local version="edge" buildhost="edge" gitref if gitref="$(expr "$(git symbolic-ref --short HEAD)" : '\([0-9]\+\(\.[0-9]\+\)*\)-')"; then version=v${gitref} - buildhost=${gitref/./-} + buildhost="$(printf '%s' "$gitref" | sed 's/[.]/-/')" fi local repo_template=$aportsgit/$repo/.rootbld-repositories -- cgit v1.2.3-70-g09d2