This commit is contained in:
Daniel Langbein 2021-04-25 16:29:06 +02:00
parent 27875f6030
commit fe8fffe8c9
2 changed files with 17 additions and 16 deletions

View File

@ -2,7 +2,7 @@
_pkgname=repo _pkgname=repo
_reponame=arch-pkg _reponame=arch-pkg
pkgname="de-p1st-$_pkgname" pkgname="de-p1st-$_pkgname"
pkgver=0.0.10 pkgver=0.0.11
pkgrel=1 pkgrel=1
pkgdesc="Bash script to manage remote Arch Linux repository" pkgdesc="Bash script to manage remote Arch Linux repository"
arch=('any') arch=('any')

View File

@ -56,8 +56,8 @@ function sort_pkgname_pkgver(){
for PKG in ./*.pkg.tar.{xz,zst}; do for PKG in ./*.pkg.tar.{xz,zst}; do
get_pkginfo "$PKG" || { echo "get_pkginfo failed"; return 1; } get_pkginfo "$PKG" || { echo "get_pkginfo failed"; return 1; }
get_pkgname "$PKGINFO" || { echo "get_pkgname failed"; return 1; } get_pkgname "$PKGINFO" || { echo "get_pkgname failed"; echo "Content of PKGINFO: ${PKGINFO}"; return 1; }
get_pkgver "$PKGINFO" || { echo "get_pkgver failed"; return 1; } get_pkgver "$PKGINFO" || { echo "get_pkgver failed"; echo "Content of PKGINFO: ${PKGINFO}"; return 1; }
echo "Creating file ./db/${PKGNAME} with content ${PKG} ..." echo "Creating file ./db/${PKGNAME} with content ${PKG} ..."
mkdir -p "db/${PKGNAME}" || return $? mkdir -p "db/${PKGNAME}" || return $?
@ -73,15 +73,27 @@ function get_pkginfo(){
# return: 0 on success # return: 0 on success
if endswith "$1" ".pkg.tar.xz"; then 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 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 else
echo "$1 does not seem to be a package!" echo "$1 does not seem to be a package!"
return 1 return 1
fi 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 # get pkgver from $PKGINFO
# #
@ -93,17 +105,6 @@ function get_pkgver(){
tmp=$(echo "$PKGINFO" | grep '^pkgver') || return $? tmp=$(echo "$PKGINFO" | grep '^pkgver') || return $?
PKGVER=$(echo "$tmp" | sed 's|^pkgver\s*=\s*||; s|\s*$||') || 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 # Inspired by: https://stackoverflow.com/questions/2172352/in-bash-how-can-i-check-if-a-string-begins-with-some-value/18558871#18558871