From fe8fffe8c9023161153feb0ed3992e3ed274652f Mon Sep 17 00:00:00 2001 From: langfingaz Date: Sun, 25 Apr 2021 16:29:06 +0200 Subject: [PATCH] fix --- pkg/de-p1st-repo/PKGBUILD | 2 +- pkg/de-p1st-repo/arch-repo-receive-new.sh | 31 ++++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pkg/de-p1st-repo/PKGBUILD b/pkg/de-p1st-repo/PKGBUILD index e8732ea..53bec83 100644 --- a/pkg/de-p1st-repo/PKGBUILD +++ b/pkg/de-p1st-repo/PKGBUILD @@ -2,7 +2,7 @@ _pkgname=repo _reponame=arch-pkg pkgname="de-p1st-$_pkgname" -pkgver=0.0.10 +pkgver=0.0.11 pkgrel=1 pkgdesc="Bash script to manage remote Arch Linux repository" arch=('any') diff --git a/pkg/de-p1st-repo/arch-repo-receive-new.sh b/pkg/de-p1st-repo/arch-repo-receive-new.sh index ec05d56..69d8fd8 100644 --- a/pkg/de-p1st-repo/arch-repo-receive-new.sh +++ b/pkg/de-p1st-repo/arch-repo-receive-new.sh @@ -56,8 +56,8 @@ function sort_pkgname_pkgver(){ for PKG in ./*.pkg.tar.{xz,zst}; do get_pkginfo "$PKG" || { echo "get_pkginfo failed"; return 1; } - get_pkgname "$PKGINFO" || { echo "get_pkgname failed"; return 1; } - get_pkgver "$PKGINFO" || { echo "get_pkgver failed"; return 1; } + get_pkgname "$PKGINFO" || { echo "get_pkgname failed"; echo "Content of PKGINFO: ${PKGINFO}"; return 1; } + get_pkgver "$PKGINFO" || { echo "get_pkgver failed"; echo "Content of PKGINFO: ${PKGINFO}"; return 1; } echo "Creating file ./db/${PKGNAME} with content ${PKG} ..." mkdir -p "db/${PKGNAME}" || return $? @@ -73,15 +73,27 @@ function get_pkginfo(){ # return: 0 on success if endswith "$1" ".pkg.tar.xz"; then - PKGINFO=$(tar -xvf "$1" -O .PKGINFO) || { echo "tar failed"; return 1; } + PKGINFO=$(tar -xf "$1" -O .PKGINFO) || { echo "tar failed"; return 1; } elif endswith "$1" ".pkg.tar.zst"; then - PKGINFO=$(tar -I zstd -xvf "$1" -O .PKGINFO) || { echo "tar failed"; return 1; } + PKGINFO=$(tar -I zstd -xf "$1" -O .PKGINFO) || { echo "tar failed"; return 1; } else echo "$1 does not seem to be a package!" return 1 fi } + +# +# get pkgname from $PKGINFO +# +function get_pkgname(){ + # return: 0 on success + + # remove "pkgname = " as well as tailing whitespace characters + local tmp + tmp=$(echo "$PKGINFO" | grep '^pkname') || return $? + PKGVER=$(echo "$tmp" | sed 's|^pkgname\s*=\s*||; s|\s*$||') || return $? +} # # get pkgver from $PKGINFO # @@ -93,17 +105,6 @@ function get_pkgver(){ tmp=$(echo "$PKGINFO" | grep '^pkgver') || return $? PKGVER=$(echo "$tmp" | sed 's|^pkgver\s*=\s*||; s|\s*$||') || return $? } -# -# get pkgname from &PKGINFO -# -function get_pkgname(){ - # return: 0 on success - - # remove "pkgname = " as well as tailing whitespace characters - local tmp - tmp=$(echo "$PKGINFO" | grep '^pkname') || return $? - PKGVER=$(echo "$tmp" | sed 's|^pkgname\s*=\s*||; s|\s*$||') || return $? -} # Inspired by: https://stackoverflow.com/questions/2172352/in-bash-how-can-i-check-if-a-string-begins-with-some-value/18558871#18558871