jw-pkg: Introduce package argument to commands

Many commands can now be limited to a list of packages

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2018-11-09 11:48:50 +00:00
commit 4c54a52c66

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
myname=`basename $0`
longname=$0
@ -16,7 +16,7 @@ usage()
{
cat << EOT
$myname command [arguments]
$myname [global options] command [options] [package ...]
command is one of
@ -34,6 +34,16 @@ cat << EOT
build-date: show installed jannet packages along with build date
built-today: show installed jannet packages that were built today
global options are
-v be verbose
package
optional whitespace-separated list of package names, generally limiting the
scope of the command to the specified packages, defaults to all installed
janware packages
EOT
if [ "$1" ]; then
exit $1
@ -76,17 +86,24 @@ check_ldconfig()
echo "done."
}
list_all_packages()
list_packages()
{
rpm -qa --queryformat '%{NAME}: %{URL}\n' | \
local names="$1"
local rpm_args
if [ "$names" ]; then
rpm_args="$rpm_args $names"
else
rpm_args="$rpm_args -a"
fi
rpm -q --queryformat '%{NAME}: %{URL}\n' $rpm_args | \
grep -i '^[^ ]\+:.*\(jannet\.de\|janware\.com\)' | \
sed 's/\(^[^ ]\+\) *:.*/\1/; s/[ ]*$//' |\
sort -u
}
list_all_projects()
list_projects()
{
list_all_packages | xargs rpm -qa --queryformat '%{SOURCERPM}: %{URL}\n' | \
list_packages "$@" | xargs rpm -qa --queryformat '%{SOURCERPM}: %{URL}\n' | \
sed 's/\(^[^ ]\+\) *:.*/\1/; s/[ ]*$//; s/-[0-9]\+.*//' |\
sort -u
}
@ -95,7 +112,7 @@ cmd_rpmnew()
{
local file
list_all_packages |
list_packages "$@" |
xargs rpm -ql |
while read file; do
if [ -e "$file.rpmnew" ]; then
@ -119,7 +136,7 @@ cmd_diff()
{
local file
list_all_packages |
list_packages "$@" |
xargs rpm -qV |
sed '/^....L\|^..5/ !d; s%[^/]*/%/%' |
while read file; do
@ -140,7 +157,7 @@ cmd_diff()
cmd_build_date()
{
list_all_packages |
list_packages "$@" |
xargs rpm -q --queryformat '%{BUILDTIME} %{NAME}\n' |
sort -n |
sed 's/-run\|-devel//' |
@ -205,30 +222,30 @@ checklog)
;;
info)
if [ "$opt_verbose" = true ]; then
list_all_packages | xargs rpm -qi
list_packages "$@" | xargs rpm -qi
else
list_all_packages | xargs rpm -q
list_packages "$@" | xargs rpm -q
fi
;;
info-projects)
list_all_projects
list_projects "$@"
;;
cpp-glib)
sudo rpm -U --replacefiles --replacepkgs --oldpackage \
ftp://dspadm@ftp.jannet.de/pub/packages/linux/suse/10.1/inst-source/rpm/i586/glib2-2.8.5-19.i586.rpm
check_ldconfig
check_ldconfig "$@"
;;
rpmnew)
cmd_rpmnew $@
cmd_rpmnew "$@"
;;
diff)
cmd_diff $@
cmd_diff "$@"
;;
build-date)
cmd_build_date
cmd_build_date "$@"
;;
built-today)
cmd_built_today
cmd_built_today "$@"
;;
help)
usage 0