Do not let 'rpm -q foo-' find package 'foo'. (RhBug:488567)

- Includes a test suite for the case.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
This commit is contained in:
Ales Kozumplik 2011-11-08 09:01:59 +01:00 committed by Panu Matilainen
parent 1581f4e5c0
commit 1c8e56729d
2 changed files with 43 additions and 4 deletions

View File

@ -1142,9 +1142,9 @@ static rpmRC dbiFindByLabel(rpmdb db, dbiIndex dbi, const char * arg,
if (c != '[') brackets = 0;
break;
}
c = *s;
if (!brackets && *s == '-')
if (!brackets && c && *s == '-')
break;
c = *s;
}
/* FIX: *matches may be NULL. */
@ -1175,9 +1175,9 @@ static rpmRC dbiFindByLabel(rpmdb db, dbiIndex dbi, const char * arg,
if (c != '[') brackets = 0;
break;
}
c = *s;
if (!brackets && *s == '-')
if (!brackets && c && *s == '-')
break;
c = *s;
}
if (s == localarg) {

View File

@ -44,6 +44,45 @@ runroot rpm \
[0])
AT_CLEANUP
# ------------------------------
# Run rpm -q <package> where <package> exists in the db.
AT_SETUP([rpm -q foo])
AT_KEYWORDS([rpmdb query])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT
runroot rpm -i \
/data/RPMS/foo-1.0-1.noarch.rpm
runroot rpm -q foo
],
[0],
[foo-1.0-1.noarch
],
[])
AT_CLEANUP
# ------------------------------
# Run rpm -q <package>- where <package> exists in the db.
AT_SETUP([rpm -q foo-])
AT_KEYWORDS([rpmdb query])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT
runroot rpm -i \
/data/RPMS/foo-1.0-1.noarch.rpm
runroot rpm -q foo-
],
[1],
[package foo- is not installed
],
[])
AT_CLEANUP
# ------------------------------
# install a noarch package into a local rpmdb without --relocate and --nodeps