build: ipkg-remove: fix source name / package confusion, optimize
The script always gets passed the package name, not the source name. Optimize for the default case where the package name matches the filename prefix. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
06267823a3
commit
471fd0a502
1 changed files with 14 additions and 7 deletions
|
@ -3,17 +3,24 @@
|
||||||
sourcename="$1"; shift
|
sourcename="$1"; shift
|
||||||
|
|
||||||
for pkg in "$@"; do
|
for pkg in "$@"; do
|
||||||
tar -Ozxf "$pkg" ./control.tar.gz 2>/dev/null | tar -Ozxf - ./control 2>/dev/null | \
|
|
||||||
while read field value; do
|
|
||||||
if [ "$field" = "SourceName:" ] && [ "$value" = "$sourcename" ]; then
|
|
||||||
rm -vf "$pkg"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
case "$pkg" in
|
case "$pkg" in
|
||||||
*/"${sourcename}_"*.ipk)
|
*/"${sourcename}_"*.ipk)
|
||||||
rm -vf "$pkg"
|
rm -vf "$pkg"
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
tar -Ozxf "$pkg" ./control.tar.gz 2>/dev/null | tar -Ozxf - ./control 2>/dev/null | {
|
||||||
|
packagename=
|
||||||
|
abiversion=
|
||||||
|
while read field value; do
|
||||||
|
case "$field" in
|
||||||
|
Package:) packagename="$value";;
|
||||||
|
ABIVersion:) abiversion="$value";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
[ -n "$abiversion" ] && packagename="${packagename%%$abiversion}"
|
||||||
|
[ "$packagename" = "$sourcename" ] && rm -vf "$pkg"
|
||||||
|
}
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue