checkpkg: Avoid unnecessary use of sed(1) and cut(1)
We already use `pacman -Sddp` here which should always only return a single package URL for regular packages. No need to extract the first field of the last line. Also, specify "--print-format '%l'" explicitly to make this consistent even if pacman(8)'s default value changes some day. Use bash parameter expansion instead of sed(1) to extract the file name from the URL. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
This commit is contained in:
parent
ddb08cb9a1
commit
3c175e98bd
10
checkpkg
10
checkpkg
|
@ -13,10 +13,6 @@ if [[ -r ~/.makepkg.conf ]]; then
|
|||
source ~/.makepkg.conf
|
||||
fi
|
||||
|
||||
strip_url() {
|
||||
echo "$1" | sed 's|^.*://.*/||g'
|
||||
}
|
||||
|
||||
if [[ ! -f PKGBUILD ]]; then
|
||||
echo 'This must be run in the directory of a built package.'
|
||||
exit 1
|
||||
|
@ -47,16 +43,14 @@ for _pkgname in "${pkgname[@]}"; do
|
|||
exit 1
|
||||
fi
|
||||
|
||||
tmp=$(pacman -Spdd --noconfirm "$_pkgname")
|
||||
pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$_pkgname")
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Couldn't download previous package for $_pkgname."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pkgurl=$(echo $tmp | rev | cut -d ' ' -f 1 | rev)
|
||||
|
||||
oldpkg=$(strip_url "$pkgurl")
|
||||
oldpkg=${pkgurl##*://*/}
|
||||
|
||||
if [[ "$(basename $oldpkg)" = "$(basename $pkgfile)" ]]; then
|
||||
echo "The built package ($_pkgname) is the one in the repo right now!"
|
||||
|
|
Loading…
Reference in New Issue