1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1997-01-18 00:20:18 +08:00
|
|
|
|
1998-07-25 04:30:55 +08:00
|
|
|
#ifndef PATH_MAX
|
|
|
|
# define PATH_MAX 255
|
|
|
|
#endif
|
|
|
|
|
1999-09-21 11:22:53 +08:00
|
|
|
#include "rpmbuild.h"
|
1999-07-14 05:37:57 +08:00
|
|
|
#include <rpmurl.h>
|
1995-12-28 04:08:35 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
/* ======================================================================== */
|
|
|
|
static char * permsString(int mode)
|
|
|
|
{
|
1999-09-21 11:22:53 +08:00
|
|
|
char *perms = xstrdup("----------");
|
1999-07-18 03:00:45 +08:00
|
|
|
|
|
|
|
if (S_ISDIR(mode))
|
|
|
|
perms[0] = 'd';
|
|
|
|
else if (S_ISLNK(mode))
|
|
|
|
perms[0] = 'l';
|
|
|
|
else if (S_ISFIFO(mode))
|
|
|
|
perms[0] = 'p';
|
|
|
|
else if (S_ISSOCK(mode))
|
|
|
|
perms[0] = 's';
|
|
|
|
else if (S_ISCHR(mode))
|
|
|
|
perms[0] = 'c';
|
|
|
|
else if (S_ISBLK(mode))
|
|
|
|
perms[0] = 'b';
|
1996-01-06 02:12:17 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
if (mode & S_IRUSR) perms[1] = 'r';
|
|
|
|
if (mode & S_IWUSR) perms[2] = 'w';
|
|
|
|
if (mode & S_IXUSR) perms[3] = 'x';
|
|
|
|
|
|
|
|
if (mode & S_IRGRP) perms[4] = 'r';
|
|
|
|
if (mode & S_IWGRP) perms[5] = 'w';
|
|
|
|
if (mode & S_IXGRP) perms[6] = 'x';
|
1998-10-27 13:41:02 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
if (mode & S_IROTH) perms[7] = 'r';
|
|
|
|
if (mode & S_IWOTH) perms[8] = 'w';
|
|
|
|
if (mode & S_IXOTH) perms[9] = 'x';
|
1999-05-08 02:33:35 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
if (mode & S_ISUID)
|
|
|
|
perms[3] = ((mode & S_IXUSR) ? 's' : 'S');
|
1999-05-08 02:33:35 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
if (mode & S_ISGID)
|
|
|
|
perms[6] = ((mode & S_IXGRP) ? 's' : 'S');
|
|
|
|
|
|
|
|
if (mode & S_ISVTX)
|
|
|
|
perms[9] = ((mode & S_IXOTH) ? 't' : 'T');
|
|
|
|
|
|
|
|
return perms;
|
1999-05-08 02:33:35 +08:00
|
|
|
}
|
1998-10-27 13:41:02 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
static void printFileInfo(FILE *fp, const char * name,
|
|
|
|
unsigned int size, unsigned short mode,
|
|
|
|
unsigned int mtime, unsigned short rdev,
|
|
|
|
const char * owner, const char * group,
|
|
|
|
int uid, int gid, const char * linkto)
|
|
|
|
{
|
|
|
|
char sizefield[15];
|
|
|
|
char ownerfield[9], groupfield[9];
|
|
|
|
char timefield[100] = "";
|
|
|
|
time_t when = mtime; /* important if sizeof(int_32) ! sizeof(time_t) */
|
|
|
|
struct tm * tm;
|
|
|
|
static time_t now;
|
|
|
|
static struct tm nowtm;
|
|
|
|
const char * namefield = name;
|
|
|
|
char * perms;
|
1998-10-27 13:41:02 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
/* On first call, grab snapshot of now */
|
|
|
|
if (now == 0) {
|
|
|
|
now = time(NULL);
|
|
|
|
tm = localtime(&now);
|
|
|
|
nowtm = *tm; /* structure assignment */
|
|
|
|
}
|
1998-10-27 13:41:02 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
perms = permsString(mode);
|
1998-10-27 13:41:02 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
if (owner)
|
|
|
|
strncpy(ownerfield, owner, 8);
|
|
|
|
else
|
|
|
|
sprintf(ownerfield, "%-8d", uid);
|
|
|
|
ownerfield[8] = '\0';
|
|
|
|
|
|
|
|
if (group)
|
|
|
|
strncpy(groupfield, group, 8);
|
|
|
|
else
|
|
|
|
sprintf(groupfield, "%-8d", gid);
|
|
|
|
groupfield[8] = '\0';
|
|
|
|
|
|
|
|
/* this is normally right */
|
|
|
|
sprintf(sizefield, "%12u", size);
|
|
|
|
|
|
|
|
/* this knows too much about dev_t */
|
|
|
|
|
|
|
|
if (S_ISLNK(mode)) {
|
|
|
|
char *nf = alloca(strlen(name) + sizeof(" -> ") + strlen(linkto));
|
|
|
|
sprintf(nf, "%s -> %s", name, linkto);
|
|
|
|
namefield = nf;
|
|
|
|
} else if (S_ISCHR(mode)) {
|
|
|
|
perms[0] = 'c';
|
|
|
|
sprintf(sizefield, "%3u, %3u", (rdev >> 8) & 0xff, rdev & 0xFF);
|
|
|
|
} else if (S_ISBLK(mode)) {
|
|
|
|
perms[0] = 'b';
|
|
|
|
sprintf(sizefield, "%3u, %3u", (rdev >> 8) & 0xff, rdev & 0xFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert file mtime to display format */
|
|
|
|
tm = localtime(&when);
|
|
|
|
{ const char *fmt;
|
|
|
|
if (now > when + 6L * 30L * 24L * 60L * 60L || /* Old. */
|
|
|
|
now < when - 60L * 60L) /* In the future. */
|
|
|
|
{
|
|
|
|
/* The file is fairly old or in the future.
|
|
|
|
* POSIX says the cutoff is 6 months old;
|
|
|
|
* approximate this by 6*30 days.
|
|
|
|
* Allow a 1 hour slop factor for what is considered "the future",
|
|
|
|
* to allow for NFS server/client clock disagreement.
|
|
|
|
* Show the year instead of the time of day.
|
|
|
|
*/
|
|
|
|
fmt = "%b %e %Y";
|
1998-10-27 13:41:02 +08:00
|
|
|
} else {
|
1999-07-18 03:00:45 +08:00
|
|
|
fmt = "%b %e %H:%M";
|
1998-10-27 13:41:02 +08:00
|
|
|
}
|
1999-07-18 03:00:45 +08:00
|
|
|
(void)strftime(timefield, sizeof(timefield) - 1, fmt, tm);
|
1998-10-27 13:41:02 +08:00
|
|
|
}
|
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
fprintf(fp, "%s %8s %8s %10s %s %s\n", perms, ownerfield, groupfield,
|
|
|
|
sizefield, timefield, namefield);
|
|
|
|
if (perms) free(perms);
|
|
|
|
}
|
1999-05-08 02:33:35 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
static int queryHeader(FILE *fp, Header h, const char * chptr)
|
|
|
|
{
|
1997-05-30 04:09:45 +08:00
|
|
|
char * str;
|
1999-09-18 04:40:41 +08:00
|
|
|
const char * error;
|
1996-06-28 04:47:54 +08:00
|
|
|
|
1997-05-30 04:09:45 +08:00
|
|
|
str = headerSprintf(h, chptr, rpmTagTable, rpmHeaderFormats, &error);
|
|
|
|
if (!str) {
|
1998-01-10 02:45:41 +08:00
|
|
|
fprintf(stderr, _("error in format: %s\n"), error);
|
1997-05-30 04:09:45 +08:00
|
|
|
return 1;
|
1996-04-02 11:36:00 +08:00
|
|
|
}
|
1996-06-09 01:27:10 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
fputs(str, fp);
|
1996-06-28 04:47:54 +08:00
|
|
|
|
|
|
|
return 0;
|
1996-04-02 11:36:00 +08:00
|
|
|
}
|
|
|
|
|
1999-09-18 04:40:41 +08:00
|
|
|
int showQueryPackage(QVA_t *qva, /*@unused@*/rpmdb db, Header h)
|
1999-05-11 07:41:04 +08:00
|
|
|
{
|
1999-07-18 03:00:45 +08:00
|
|
|
FILE *fp = stdout; /* XXX FIXME: pass as arg */
|
1999-05-11 07:41:04 +08:00
|
|
|
int queryFlags = qva->qva_flags;
|
|
|
|
const char *queryFormat = qva->qva_queryFormat;
|
|
|
|
|
1999-08-07 06:52:49 +08:00
|
|
|
const char * name, * version, * release;
|
1995-12-28 04:08:35 +08:00
|
|
|
int_32 count, type;
|
|
|
|
char * prefix = NULL;
|
1999-11-27 05:58:42 +08:00
|
|
|
const char ** dirNames, ** baseNames;
|
1999-09-18 04:40:41 +08:00
|
|
|
const char ** fileMD5List;
|
|
|
|
const char * fileStatesList;
|
|
|
|
const char ** fileOwnerList = NULL;
|
|
|
|
const char ** fileGroupList = NULL;
|
|
|
|
const char ** fileLinktoList;
|
1996-02-19 12:50:33 +08:00
|
|
|
int_32 * fileFlagsList, * fileMTimeList, * fileSizeList;
|
1999-09-18 04:40:41 +08:00
|
|
|
int_32 * fileUIDList = NULL;
|
|
|
|
int_32 * fileGIDList = NULL;
|
1996-06-21 06:28:02 +08:00
|
|
|
uint_16 * fileModeList;
|
|
|
|
uint_16 * fileRdevList;
|
1999-11-27 05:58:42 +08:00
|
|
|
int_32 * dirIndexes;
|
1995-12-28 04:08:35 +08:00
|
|
|
int i;
|
|
|
|
|
1999-08-07 06:52:49 +08:00
|
|
|
headerNVR(h, &name, &version, &release);
|
1995-12-28 04:08:35 +08:00
|
|
|
|
1997-02-18 04:18:54 +08:00
|
|
|
if (!queryFormat && !queryFlags) {
|
1999-07-18 03:00:45 +08:00
|
|
|
fprintf(fp, "%s-%s-%s\n", name, version, release);
|
1995-12-28 04:08:35 +08:00
|
|
|
} else {
|
1997-02-18 04:18:54 +08:00
|
|
|
if (queryFormat)
|
1999-07-18 03:00:45 +08:00
|
|
|
queryHeader(fp, h, queryFormat);
|
1995-12-28 04:08:35 +08:00
|
|
|
|
|
|
|
if (queryFlags & QUERY_FOR_LIST) {
|
1999-12-09 03:04:50 +08:00
|
|
|
if (!headerGetEntry(h, RPMTAG_BASENAMES, &type,
|
1999-11-27 05:58:42 +08:00
|
|
|
(void **) &baseNames, &count)) {
|
1999-07-18 03:00:45 +08:00
|
|
|
fputs(_("(contains no files)"), fp);
|
|
|
|
fputs("\n", fp);
|
1996-01-06 02:12:17 +08:00
|
|
|
} else {
|
1996-11-19 02:02:36 +08:00
|
|
|
if (!headerGetEntry(h, RPMTAG_FILESTATES, &type,
|
1996-03-30 03:24:52 +08:00
|
|
|
(void **) &fileStatesList, &count)) {
|
|
|
|
fileStatesList = NULL;
|
|
|
|
}
|
1999-12-09 03:04:50 +08:00
|
|
|
headerGetEntry(h, RPMTAG_DIRNAMES, NULL,
|
1999-11-27 05:58:42 +08:00
|
|
|
(void **) &dirNames, NULL);
|
1999-12-09 03:04:50 +08:00
|
|
|
headerGetEntry(h, RPMTAG_DIRINDEXES, NULL,
|
1999-11-27 05:58:42 +08:00
|
|
|
(void **) &dirIndexes, NULL);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_FILEFLAGS, &type,
|
1996-01-06 02:12:17 +08:00
|
|
|
(void **) &fileFlagsList, &count);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_FILESIZES, &type,
|
1996-02-19 12:50:33 +08:00
|
|
|
(void **) &fileSizeList, &count);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_FILEMODES, &type,
|
1996-02-19 12:50:33 +08:00
|
|
|
(void **) &fileModeList, &count);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_FILEMTIMES, &type,
|
1996-02-19 12:50:33 +08:00
|
|
|
(void **) &fileMTimeList, &count);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_FILERDEVS, &type,
|
1996-02-19 12:50:33 +08:00
|
|
|
(void **) &fileRdevList, &count);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_FILELINKTOS, &type,
|
1996-02-19 23:17:56 +08:00
|
|
|
(void **) &fileLinktoList, &count);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerGetEntry(h, RPMTAG_FILEMD5S, &type,
|
1996-06-21 06:28:02 +08:00
|
|
|
(void **) &fileMD5List, &count);
|
1996-01-06 02:12:17 +08:00
|
|
|
|
1997-02-18 04:18:54 +08:00
|
|
|
if (!headerGetEntry(h, RPMTAG_FILEUIDS, &type,
|
|
|
|
(void **) &fileUIDList, &count)) {
|
|
|
|
fileUIDList = NULL;
|
1999-09-18 04:40:41 +08:00
|
|
|
} else if (!headerGetEntry(h, RPMTAG_FILEGIDS, &type,
|
|
|
|
(void **) &fileGIDList, &count)) {
|
|
|
|
fileGIDList = NULL;
|
1997-02-18 04:18:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!headerGetEntry(h, RPMTAG_FILEUSERNAME, &type,
|
|
|
|
(void **) &fileOwnerList, &count)) {
|
|
|
|
fileOwnerList = NULL;
|
1999-09-18 04:40:41 +08:00
|
|
|
} else if (!headerGetEntry(h, RPMTAG_FILEGROUPNAME, &type,
|
|
|
|
(void **) &fileGroupList, &count)) {
|
|
|
|
fileGroupList = NULL;
|
1997-02-18 04:18:54 +08:00
|
|
|
}
|
|
|
|
|
1996-01-06 02:12:17 +08:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
if (!((queryFlags & QUERY_FOR_DOCS) ||
|
|
|
|
(queryFlags & QUERY_FOR_CONFIG))
|
|
|
|
|| ((queryFlags & QUERY_FOR_DOCS) &&
|
|
|
|
(fileFlagsList[i] & RPMFILE_DOC))
|
|
|
|
|| ((queryFlags & QUERY_FOR_CONFIG) &&
|
|
|
|
(fileFlagsList[i] & RPMFILE_CONFIG))) {
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
if (!rpmIsVerbose())
|
1999-07-18 03:00:45 +08:00
|
|
|
prefix ? fputs(prefix, fp) : 0;
|
1996-06-21 06:28:02 +08:00
|
|
|
|
|
|
|
if (queryFlags & QUERY_FOR_STATE) {
|
|
|
|
if (fileStatesList) {
|
|
|
|
switch (fileStatesList[i]) {
|
|
|
|
case RPMFILE_STATE_NORMAL:
|
1999-07-18 03:00:45 +08:00
|
|
|
fputs(_("normal "), fp); break;
|
1996-06-21 06:28:02 +08:00
|
|
|
case RPMFILE_STATE_REPLACED:
|
1999-07-18 03:00:45 +08:00
|
|
|
fputs(_("replaced "), fp); break;
|
1996-06-21 06:28:02 +08:00
|
|
|
case RPMFILE_STATE_NOTINSTALLED:
|
1999-07-18 03:00:45 +08:00
|
|
|
fputs(_("not installed "), fp); break;
|
1999-08-16 03:11:40 +08:00
|
|
|
case RPMFILE_STATE_NETSHARED:
|
|
|
|
fputs(_("net shared "), fp); break;
|
1996-06-21 06:28:02 +08:00
|
|
|
default:
|
1999-07-18 03:00:45 +08:00
|
|
|
fprintf(fp, _("(unknown %3d) "),
|
1999-09-18 04:40:41 +08:00
|
|
|
(int)fileStatesList[i]);
|
1996-02-19 12:50:33 +08:00
|
|
|
}
|
1996-06-21 06:28:02 +08:00
|
|
|
} else {
|
1999-07-18 03:00:45 +08:00
|
|
|
fputs( _("(no state) "), fp);
|
1996-01-06 02:12:17 +08:00
|
|
|
}
|
1996-06-21 06:28:02 +08:00
|
|
|
}
|
1999-10-06 23:51:14 +08:00
|
|
|
|
1996-06-21 06:28:02 +08:00
|
|
|
if (queryFlags & QUERY_FOR_DUMPFILES) {
|
1999-10-06 23:51:14 +08:00
|
|
|
fprintf(fp, "%s%s %d %d %s 0%o ",
|
1999-11-27 05:58:42 +08:00
|
|
|
dirNames[dirIndexes[i]], baseNames[i],
|
1996-06-21 06:28:02 +08:00
|
|
|
fileSizeList[i], fileMTimeList[i],
|
|
|
|
fileMD5List[i], fileModeList[i]);
|
|
|
|
|
1999-09-18 04:40:41 +08:00
|
|
|
if (fileOwnerList && fileGroupList)
|
1999-07-18 03:00:45 +08:00
|
|
|
fprintf(fp, "%s %s", fileOwnerList[i],
|
1996-06-21 06:28:02 +08:00
|
|
|
fileGroupList[i]);
|
1999-09-18 04:40:41 +08:00
|
|
|
else if (fileUIDList && fileGIDList)
|
1999-07-18 03:00:45 +08:00
|
|
|
fprintf(fp, "%d %d", fileUIDList[i],
|
1996-06-21 06:28:02 +08:00
|
|
|
fileGIDList[i]);
|
1997-02-18 04:18:54 +08:00
|
|
|
else {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_INTERNAL, _("package has "
|
|
|
|
"neither file owner or id lists"));
|
1997-02-18 04:18:54 +08:00
|
|
|
}
|
1996-06-21 06:28:02 +08:00
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
fprintf(fp, " %s %s %u ",
|
1996-06-21 06:28:02 +08:00
|
|
|
fileFlagsList[i] & RPMFILE_CONFIG ? "1" : "0",
|
|
|
|
fileFlagsList[i] & RPMFILE_DOC ? "1" : "0",
|
1998-11-17 05:40:28 +08:00
|
|
|
(unsigned)fileRdevList[i]);
|
1996-06-21 06:28:02 +08:00
|
|
|
|
|
|
|
if (strlen(fileLinktoList[i]))
|
1999-07-18 03:00:45 +08:00
|
|
|
fprintf(fp, "%s\n", fileLinktoList[i]);
|
1996-06-21 06:28:02 +08:00
|
|
|
else
|
1999-07-18 03:00:45 +08:00
|
|
|
fprintf(fp, "X\n");
|
1996-06-21 06:28:02 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
} else if (!rpmIsVerbose()) {
|
1999-11-27 05:58:42 +08:00
|
|
|
fputs(dirNames[dirIndexes[i]], fp);
|
|
|
|
fputs(baseNames[i], fp);
|
1999-07-18 03:00:45 +08:00
|
|
|
fputs("\n", fp);
|
1997-02-18 04:18:54 +08:00
|
|
|
} else {
|
1999-10-06 23:51:14 +08:00
|
|
|
char * filespec;
|
|
|
|
|
1999-11-27 05:58:42 +08:00
|
|
|
filespec = xmalloc(strlen(dirNames[dirIndexes[i]])
|
|
|
|
+ strlen(baseNames[i]) + 1);
|
|
|
|
strcpy(filespec, dirNames[dirIndexes[i]]);
|
|
|
|
strcat(filespec, baseNames[i]);
|
1999-10-06 23:51:14 +08:00
|
|
|
|
|
|
|
if (fileOwnerList && fileGroupList) {
|
|
|
|
printFileInfo(fp, filespec, fileSizeList[i],
|
|
|
|
fileModeList[i], fileMTimeList[i],
|
|
|
|
fileRdevList[i],
|
|
|
|
fileOwnerList[i],
|
|
|
|
fileGroupList[i], -1,
|
|
|
|
-1, fileLinktoList[i]);
|
|
|
|
} else if (fileUIDList && fileGIDList) {
|
|
|
|
printFileInfo(fp, filespec, fileSizeList[i],
|
|
|
|
fileModeList[i], fileMTimeList[i],
|
|
|
|
fileRdevList[i], NULL,
|
|
|
|
NULL, fileUIDList[i],
|
|
|
|
fileGIDList[i],
|
|
|
|
fileLinktoList[i]);
|
|
|
|
} else {
|
|
|
|
rpmError(RPMERR_INTERNAL, _("package has "
|
|
|
|
"neither file owner or id lists"));
|
|
|
|
}
|
|
|
|
|
|
|
|
free(filespec);
|
1997-02-18 04:18:54 +08:00
|
|
|
}
|
1995-12-28 04:08:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-27 05:58:42 +08:00
|
|
|
free(dirNames);
|
|
|
|
free(baseNames);
|
1996-02-19 23:17:56 +08:00
|
|
|
free(fileLinktoList);
|
1996-06-21 06:28:02 +08:00
|
|
|
free(fileMD5List);
|
1996-02-19 12:50:33 +08:00
|
|
|
if (fileOwnerList) free(fileOwnerList);
|
|
|
|
if (fileGroupList) free(fileGroupList);
|
1996-01-06 02:12:17 +08:00
|
|
|
}
|
1995-12-28 04:08:35 +08:00
|
|
|
}
|
1996-04-16 06:21:30 +08:00
|
|
|
}
|
1999-05-11 07:41:04 +08:00
|
|
|
return 0; /* XXX FIXME: need real return code */
|
1996-04-16 06:21:30 +08:00
|
|
|
}
|
|
|
|
|
1999-02-23 01:44:57 +08:00
|
|
|
static void
|
|
|
|
printNewSpecfile(Spec spec)
|
|
|
|
{
|
|
|
|
struct speclines *sl = spec->sl;
|
|
|
|
struct spectags *st = spec->st;
|
|
|
|
char buf[8192];
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
if (sl == NULL || st == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < st->st_ntags; i++) {
|
|
|
|
char *msgstr;
|
|
|
|
struct spectag *t;
|
|
|
|
t = st->st_t + i;
|
|
|
|
|
|
|
|
/* XXX Summary tag often precedes name, so build msgid now. */
|
|
|
|
if (t->t_msgid == NULL) {
|
|
|
|
char *n;
|
|
|
|
headerGetEntry(spec->packages->header, RPMTAG_NAME, NULL,
|
1999-04-14 20:35:08 +08:00
|
|
|
(void **) &n, NULL);
|
1999-02-23 01:44:57 +08:00
|
|
|
sprintf(buf, "%s(%s)", n, tagName(t->t_tag));
|
1999-09-21 11:22:53 +08:00
|
|
|
t->t_msgid = xstrdup(buf);
|
1999-02-23 01:44:57 +08:00
|
|
|
}
|
1999-09-23 02:17:41 +08:00
|
|
|
msgstr = xstrdup(/*@-unrecog@*/ dgettext(specedit, t->t_msgid) /*@=unrecog@*/);
|
1999-02-23 01:44:57 +08:00
|
|
|
|
|
|
|
switch(t->t_tag) {
|
|
|
|
case RPMTAG_SUMMARY:
|
|
|
|
case RPMTAG_GROUP:
|
1999-09-18 04:40:41 +08:00
|
|
|
free(sl->sl_lines[t->t_startx]);
|
|
|
|
sl->sl_lines[t->t_startx] = NULL;
|
1999-02-23 01:44:57 +08:00
|
|
|
if (t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG))
|
|
|
|
continue;
|
|
|
|
sprintf(buf, "%s: %s\n",
|
|
|
|
((t->t_tag == RPMTAG_GROUP) ? "Group" : "Summary"),
|
|
|
|
msgstr);
|
1999-09-21 11:22:53 +08:00
|
|
|
sl->sl_lines[t->t_startx] = xstrdup(buf);
|
1999-02-23 01:44:57 +08:00
|
|
|
break;
|
|
|
|
case RPMTAG_DESCRIPTION:
|
1999-09-18 04:40:41 +08:00
|
|
|
for (j = 1; j < t->t_nlines; j++) {
|
|
|
|
free(sl->sl_lines[t->t_startx + j]);
|
|
|
|
sl->sl_lines[t->t_startx + j] = NULL;
|
|
|
|
}
|
1999-02-23 01:44:57 +08:00
|
|
|
if (t->t_lang && strcmp(t->t_lang, RPMBUILD_DEFAULT_LANG)) {
|
1999-09-18 04:40:41 +08:00
|
|
|
free(sl->sl_lines[t->t_startx]);
|
|
|
|
sl->sl_lines[t->t_startx] = NULL;
|
1999-02-23 01:44:57 +08:00
|
|
|
continue;
|
|
|
|
}
|
1999-09-21 11:22:53 +08:00
|
|
|
sl->sl_lines[t->t_startx + 1] = xstrdup(msgstr);
|
1999-02-23 01:44:57 +08:00
|
|
|
if (t->t_nlines > 2)
|
1999-09-21 11:22:53 +08:00
|
|
|
sl->sl_lines[t->t_startx + 2] = xstrdup("\n\n");
|
1999-02-23 01:44:57 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < sl->sl_nlines; i++) {
|
|
|
|
if (sl->sl_lines[i] == NULL)
|
|
|
|
continue;
|
|
|
|
printf("%s", sl->sl_lines[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-11 07:41:04 +08:00
|
|
|
void rpmDisplayQueryTags(FILE * f) {
|
|
|
|
const struct headerTagTableEntry * t;
|
|
|
|
int i;
|
|
|
|
const struct headerSprintfExtension * ext = rpmHeaderFormats;
|
|
|
|
|
|
|
|
for (i = 0, t = rpmTagTable; i < rpmTagTableSize; i++, t++) {
|
|
|
|
fprintf(f, "%s\n", t->name + 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (ext->name) {
|
|
|
|
if (ext->type == HEADER_EXT_TAG)
|
|
|
|
fprintf(f, "%s\n", ext->name + 7), ext++;
|
|
|
|
else if (ext->type == HEADER_EXT_MORE)
|
|
|
|
ext = ext->u.more;
|
|
|
|
else
|
|
|
|
ext++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int showMatches(QVA_t *qva, rpmdb db, dbiIndexSet matches, QVF_t showPackage)
|
|
|
|
{
|
|
|
|
Header h;
|
|
|
|
int ec = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < dbiIndexSetCount(matches); i++) {
|
|
|
|
int rc;
|
|
|
|
unsigned int recOffset = dbiIndexRecordOffset(matches, i);
|
|
|
|
if (recOffset == 0)
|
|
|
|
continue;
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("record number %u\n"), recOffset);
|
|
|
|
|
|
|
|
h = rpmdbGetRecord(db, recOffset);
|
|
|
|
if (h == NULL) {
|
|
|
|
fprintf(stderr, _("error: could not read database record\n"));
|
|
|
|
ec = 1;
|
|
|
|
} else {
|
|
|
|
if ((rc = showPackage(qva, db, h)) != 0)
|
|
|
|
ec = rc;
|
|
|
|
headerFree(h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ec;
|
|
|
|
}
|
|
|
|
|
1999-07-01 05:18:43 +08:00
|
|
|
/*
|
|
|
|
* XXX Eliminate linkage loop into librpmbuild.a
|
|
|
|
*/
|
1999-11-01 05:38:21 +08:00
|
|
|
int (*parseSpecVec) (Spec *specp, const char *specFile, const char *rootdir,
|
|
|
|
const char *buildRoot, int inBuildArch, const char *passPhrase,
|
|
|
|
char *cookie, int anyarch, int force) = NULL;
|
1999-07-01 05:18:43 +08:00
|
|
|
void (*freeSpecVec) (Spec spec) = NULL;
|
|
|
|
char *specedit = NULL;
|
|
|
|
|
1999-05-11 07:41:04 +08:00
|
|
|
int rpmQueryVerify(QVA_t *qva, enum rpmQVSources source, const char * arg,
|
|
|
|
rpmdb db, QVF_t showPackage)
|
|
|
|
{
|
|
|
|
dbiIndexSet matches;
|
1995-12-28 04:08:35 +08:00
|
|
|
Header h;
|
|
|
|
int offset;
|
1996-01-06 02:12:17 +08:00
|
|
|
int rc;
|
|
|
|
int isSource;
|
1996-03-01 11:29:18 +08:00
|
|
|
int recNumber;
|
1996-04-03 11:45:27 +08:00
|
|
|
int retcode = 0;
|
1996-06-21 06:28:02 +08:00
|
|
|
char *end = NULL;
|
1995-12-28 04:08:35 +08:00
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
switch (source) {
|
|
|
|
case RPMQV_RPM:
|
1999-12-12 09:46:13 +08:00
|
|
|
{ int argc = 0;
|
|
|
|
const char ** argv = NULL;
|
|
|
|
int i;
|
1998-12-01 08:10:18 +08:00
|
|
|
|
1999-12-12 09:46:13 +08:00
|
|
|
rc = remoteGlob(arg, &argc, &argv);
|
|
|
|
if (rc)
|
|
|
|
return 1;
|
|
|
|
for (i = 0; i < argc; i++) {
|
|
|
|
FD_t fd;
|
|
|
|
fd = Fopen(argv[i], "r.ufdio");
|
1999-10-31 00:43:29 +08:00
|
|
|
if (Ferror(fd)) {
|
|
|
|
/* XXX Fstrerror */
|
1999-12-12 09:46:13 +08:00
|
|
|
fprintf(stderr, _("open of %s failed: %s\n"), argv[i],
|
1999-11-11 06:09:49 +08:00
|
|
|
#ifndef NOTYET
|
1999-12-12 09:46:13 +08:00
|
|
|
urlStrerror(argv[i]));
|
1999-11-11 06:09:49 +08:00
|
|
|
#else
|
|
|
|
Fstrerror(fd));
|
|
|
|
#endif
|
1999-11-30 22:49:45 +08:00
|
|
|
if (fd)
|
|
|
|
Fclose(fd);
|
1998-12-01 08:10:18 +08:00
|
|
|
retcode = 1;
|
|
|
|
break;
|
1996-10-15 11:14:50 +08:00
|
|
|
}
|
|
|
|
|
1999-05-11 07:41:04 +08:00
|
|
|
retcode = rpmReadPackageHeader(fd, &h, &isSource, NULL, NULL);
|
1996-10-15 11:14:50 +08:00
|
|
|
|
1999-10-31 00:43:29 +08:00
|
|
|
Fclose(fd);
|
1996-10-15 11:14:50 +08:00
|
|
|
|
1999-05-11 07:41:04 +08:00
|
|
|
switch (retcode) {
|
1998-12-01 08:10:18 +08:00
|
|
|
case 0:
|
|
|
|
if (h == NULL) {
|
|
|
|
fprintf(stderr, _("old format source packages cannot "
|
|
|
|
"be queried\n"));
|
1999-05-11 07:41:04 +08:00
|
|
|
retcode = 1;
|
|
|
|
break;
|
1996-01-06 02:12:17 +08:00
|
|
|
}
|
1999-05-11 07:41:04 +08:00
|
|
|
retcode = showPackage(qva, db, h);
|
|
|
|
headerFree(h);
|
1998-12-01 08:10:18 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
1999-12-12 09:46:13 +08:00
|
|
|
fprintf(stderr, _("%s does not appear to be a RPM package\n"), argv[i]);
|
1999-09-18 04:40:41 +08:00
|
|
|
/*@fallthrough@*/
|
1998-12-01 08:10:18 +08:00
|
|
|
case 2:
|
1999-12-12 09:46:13 +08:00
|
|
|
fprintf(stderr, _("query of %s failed\n"), argv[i]);
|
1998-12-01 08:10:18 +08:00
|
|
|
retcode = 1;
|
|
|
|
break;
|
1996-01-06 02:12:17 +08:00
|
|
|
}
|
1999-11-10 04:57:38 +08:00
|
|
|
}
|
1999-12-12 09:46:13 +08:00
|
|
|
if (argv) {
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
xfree(argv[i]);
|
|
|
|
xfree(argv);
|
|
|
|
}
|
1999-11-10 04:57:38 +08:00
|
|
|
} break;
|
1995-12-28 04:08:35 +08:00
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
case RPMQV_SPECFILE:
|
1999-05-11 07:41:04 +08:00
|
|
|
if (showPackage != showQueryPackage)
|
|
|
|
return 1;
|
1999-07-01 05:18:43 +08:00
|
|
|
|
|
|
|
/* XXX Eliminate linkage dependency loop */
|
|
|
|
if (parseSpecVec == NULL || freeSpecVec == NULL)
|
|
|
|
return 1;
|
|
|
|
|
1998-11-20 08:29:46 +08:00
|
|
|
{ Spec spec = NULL;
|
|
|
|
Package pkg;
|
|
|
|
char * buildRoot = NULL;
|
|
|
|
int inBuildArch = 0;
|
|
|
|
char * passPhrase = "";
|
|
|
|
char *cookie = NULL;
|
|
|
|
int anyarch = 1;
|
|
|
|
int force = 1;
|
1999-07-01 05:18:43 +08:00
|
|
|
|
1999-11-01 05:38:21 +08:00
|
|
|
rc = parseSpecVec(&spec, arg, "/", buildRoot, inBuildArch, passPhrase,
|
1999-07-01 05:18:43 +08:00
|
|
|
cookie, anyarch, force);
|
1998-11-20 08:29:46 +08:00
|
|
|
if (rc || spec == NULL) {
|
|
|
|
|
|
|
|
fprintf(stderr, _("query of specfile %s failed, can't parse\n"), arg);
|
1999-07-01 05:24:06 +08:00
|
|
|
if (spec != NULL) freeSpecVec(spec);
|
1998-11-20 08:29:46 +08:00
|
|
|
retcode = 1;
|
|
|
|
break;
|
|
|
|
}
|
1999-02-23 01:44:57 +08:00
|
|
|
|
1999-05-07 07:21:08 +08:00
|
|
|
if (specedit != NULL) {
|
1999-02-23 01:44:57 +08:00
|
|
|
printNewSpecfile(spec);
|
1999-07-01 05:24:06 +08:00
|
|
|
freeSpecVec(spec);
|
1999-02-23 01:44:57 +08:00
|
|
|
retcode = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-11-20 08:29:46 +08:00
|
|
|
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
|
1999-05-11 07:41:04 +08:00
|
|
|
showPackage(qva, NULL, pkg->header);
|
1998-11-20 08:29:46 +08:00
|
|
|
}
|
1999-07-01 05:24:06 +08:00
|
|
|
freeSpecVec(spec);
|
1998-11-20 08:29:46 +08:00
|
|
|
} break;
|
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
case RPMQV_ALL:
|
1999-05-11 07:41:04 +08:00
|
|
|
for (offset = rpmdbFirstRecNum(db);
|
|
|
|
offset != 0;
|
|
|
|
offset = rpmdbNextRecNum(db, offset)) {
|
|
|
|
h = rpmdbGetRecord(db, offset);
|
|
|
|
if (h == NULL) {
|
|
|
|
fprintf(stderr, _("could not read database record!\n"));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if ((rc = showPackage(qva, db, h)) != 0)
|
|
|
|
retcode = rc;
|
|
|
|
headerFree(h);
|
1995-12-28 04:08:35 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
case RPMQV_GROUP:
|
1996-01-06 02:12:17 +08:00
|
|
|
if (rpmdbFindByGroup(db, arg, &matches)) {
|
1997-04-29 10:45:19 +08:00
|
|
|
fprintf(stderr, _("group %s does not contain any packages\n"), arg);
|
1996-04-03 11:45:27 +08:00
|
|
|
retcode = 1;
|
1996-01-06 02:12:17 +08:00
|
|
|
} else {
|
1999-05-11 07:41:04 +08:00
|
|
|
retcode = showMatches(qva, db, matches, showPackage);
|
1996-11-19 02:02:36 +08:00
|
|
|
dbiFreeIndexRecord(matches);
|
1996-01-06 02:12:17 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
case RPMQV_TRIGGEREDBY:
|
1998-03-28 00:46:39 +08:00
|
|
|
if (rpmdbFindByTriggeredBy(db, arg, &matches)) {
|
|
|
|
fprintf(stderr, _("no package triggers %s\n"), arg);
|
|
|
|
retcode = 1;
|
|
|
|
} else {
|
1999-05-11 07:41:04 +08:00
|
|
|
retcode = showMatches(qva, db, matches, showPackage);
|
1998-03-28 00:46:39 +08:00
|
|
|
dbiFreeIndexRecord(matches);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
case RPMQV_WHATREQUIRES:
|
1996-06-10 05:47:42 +08:00
|
|
|
if (rpmdbFindByRequiredBy(db, arg, &matches)) {
|
1997-04-29 10:45:19 +08:00
|
|
|
fprintf(stderr, _("no package requires %s\n"), arg);
|
1996-06-10 05:47:42 +08:00
|
|
|
retcode = 1;
|
|
|
|
} else {
|
1999-05-11 07:41:04 +08:00
|
|
|
retcode = showMatches(qva, db, matches, showPackage);
|
1996-11-19 02:02:36 +08:00
|
|
|
dbiFreeIndexRecord(matches);
|
1996-06-10 05:47:42 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-03 00:31:35 +08:00
|
|
|
case RPMQV_WHATPROVIDES:
|
|
|
|
if (arg[0] != '/') {
|
|
|
|
if (rpmdbFindByProvides(db, arg, &matches)) {
|
|
|
|
fprintf(stderr, _("no package provides %s\n"), arg);
|
|
|
|
retcode = 1;
|
|
|
|
} else {
|
|
|
|
retcode = showMatches(qva, db, matches, showPackage);
|
|
|
|
dbiFreeIndexRecord(matches);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*@fallthrough@*/
|
1999-11-10 04:57:38 +08:00
|
|
|
case RPMQV_PATH:
|
1995-12-28 04:08:35 +08:00
|
|
|
if (rpmdbFindByFile(db, arg, &matches)) {
|
1998-07-25 04:30:55 +08:00
|
|
|
int myerrno = 0;
|
|
|
|
if (access(arg, F_OK) != 0)
|
|
|
|
myerrno = errno;
|
|
|
|
switch (myerrno) {
|
|
|
|
default:
|
|
|
|
fprintf(stderr, _("file %s: %s\n"), arg, strerror(myerrno));
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
fprintf(stderr, _("file %s is not owned by any package\n"), arg);
|
|
|
|
break;
|
|
|
|
}
|
1996-04-03 11:45:27 +08:00
|
|
|
retcode = 1;
|
1995-12-28 04:08:35 +08:00
|
|
|
} else {
|
1999-05-11 07:41:04 +08:00
|
|
|
retcode = showMatches(qva, db, matches, showPackage);
|
1996-11-19 02:02:36 +08:00
|
|
|
dbiFreeIndexRecord(matches);
|
1995-12-28 04:08:35 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
case RPMQV_DBOFFSET:
|
1996-06-21 06:28:02 +08:00
|
|
|
recNumber = strtoul(arg, &end, 10);
|
|
|
|
if ((*end) || (end == arg) || (recNumber == ULONG_MAX)) {
|
1997-04-29 10:45:19 +08:00
|
|
|
fprintf(stderr, _("invalid package number: %s\n"), arg);
|
1996-06-21 06:28:02 +08:00
|
|
|
return 1;
|
|
|
|
}
|
1999-05-11 07:41:04 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("package record number: %d\n"), recNumber);
|
1996-06-21 06:28:02 +08:00
|
|
|
h = rpmdbGetRecord(db, recNumber);
|
1998-11-17 05:40:28 +08:00
|
|
|
if (h == NULL) {
|
1997-04-29 10:45:19 +08:00
|
|
|
fprintf(stderr, _("record %d could not be read\n"), recNumber);
|
1996-06-21 06:28:02 +08:00
|
|
|
retcode = 1;
|
1996-01-06 02:12:17 +08:00
|
|
|
} else {
|
1999-05-11 07:41:04 +08:00
|
|
|
retcode = showPackage(qva, db, h);
|
1996-11-19 02:02:36 +08:00
|
|
|
headerFree(h);
|
1996-06-21 06:28:02 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
case RPMQV_PACKAGE:
|
1997-05-31 05:14:34 +08:00
|
|
|
rc = rpmdbFindByLabel(db, arg, &matches);
|
1996-06-21 06:28:02 +08:00
|
|
|
if (rc == 1) {
|
|
|
|
retcode = 1;
|
1997-04-29 10:45:19 +08:00
|
|
|
fprintf(stderr, _("package %s is not installed\n"), arg);
|
1996-06-21 06:28:02 +08:00
|
|
|
} else if (rc == 2) {
|
|
|
|
retcode = 1;
|
1997-04-29 10:45:19 +08:00
|
|
|
fprintf(stderr, _("error looking for package %s\n"), arg);
|
1996-06-21 06:28:02 +08:00
|
|
|
} else {
|
1999-05-11 07:41:04 +08:00
|
|
|
retcode = showMatches(qva, db, matches, showPackage);
|
1996-11-19 02:02:36 +08:00
|
|
|
dbiFreeIndexRecord(matches);
|
1996-01-06 02:12:17 +08:00
|
|
|
}
|
1995-12-28 04:08:35 +08:00
|
|
|
break;
|
1999-11-10 04:57:38 +08:00
|
|
|
}
|
1995-12-28 04:08:35 +08:00
|
|
|
|
1999-05-11 07:41:04 +08:00
|
|
|
return retcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rpmQuery(QVA_t *qva, enum rpmQVSources source, const char * arg)
|
|
|
|
{
|
|
|
|
rpmdb db = NULL;
|
|
|
|
int rc;
|
|
|
|
|
1998-11-20 08:29:46 +08:00
|
|
|
switch (source) {
|
1999-05-08 02:33:35 +08:00
|
|
|
case RPMQV_RPM:
|
|
|
|
case RPMQV_SPECFILE:
|
1998-11-20 08:29:46 +08:00
|
|
|
break;
|
1999-05-11 07:41:04 +08:00
|
|
|
default:
|
|
|
|
if (rpmdbOpen(qva->qva_prefix, &db, O_RDONLY, 0644)) {
|
|
|
|
fprintf(stderr, _("rpmQuery: rpmdbOpen() failed\n"));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
1996-01-09 03:44:29 +08:00
|
|
|
}
|
1996-04-03 11:45:27 +08:00
|
|
|
|
1999-05-11 07:41:04 +08:00
|
|
|
rc = rpmQueryVerify(qva, source, arg, db, showQueryPackage);
|
1996-02-15 04:56:22 +08:00
|
|
|
|
1999-05-11 07:41:04 +08:00
|
|
|
if (db)
|
|
|
|
rpmdbClose(db);
|
1998-08-16 22:06:19 +08:00
|
|
|
|
1999-05-11 07:41:04 +08:00
|
|
|
return rc;
|
1996-04-03 11:45:27 +08:00
|
|
|
}
|
1999-07-18 03:00:45 +08:00
|
|
|
|
|
|
|
/* ======================================================================== */
|
|
|
|
#define POPT_QUERYFORMAT 1000
|
|
|
|
#define POPT_WHATREQUIRES 1001
|
|
|
|
#define POPT_WHATPROVIDES 1002
|
|
|
|
#define POPT_QUERYBYNUMBER 1003
|
|
|
|
#define POPT_TRIGGEREDBY 1004
|
|
|
|
#define POPT_DUMP 1005
|
|
|
|
#define POPT_SPECFILE 1006
|
|
|
|
|
|
|
|
/* ========== Query/Verify source popt args */
|
1999-10-05 04:18:48 +08:00
|
|
|
static void rpmQVSourceArgCallback( /*@unused@*/ poptContext con,
|
|
|
|
/*@unused@*/ enum poptCallbackReason reason,
|
|
|
|
const struct poptOption * opt, /*@unused@*/ const char * arg,
|
|
|
|
const void * data)
|
1999-07-18 03:00:45 +08:00
|
|
|
{
|
1999-10-01 00:56:05 +08:00
|
|
|
QVA_t *qva = (QVA_t *) data;
|
1999-07-18 03:00:45 +08:00
|
|
|
|
|
|
|
switch (opt->val) {
|
|
|
|
case 'a': qva->qva_source |= RPMQV_ALL; qva->qva_sourceCount++; break;
|
|
|
|
case 'f': qva->qva_source |= RPMQV_PATH; qva->qva_sourceCount++; break;
|
|
|
|
case 'g': qva->qva_source |= RPMQV_GROUP; qva->qva_sourceCount++; break;
|
|
|
|
case 'p': qva->qva_source |= RPMQV_RPM; qva->qva_sourceCount++; break;
|
|
|
|
case POPT_WHATPROVIDES: qva->qva_source |= RPMQV_WHATPROVIDES;
|
|
|
|
qva->qva_sourceCount++; break;
|
|
|
|
case POPT_WHATREQUIRES: qva->qva_source |= RPMQV_WHATREQUIRES;
|
|
|
|
qva->qva_sourceCount++; break;
|
|
|
|
case POPT_TRIGGEREDBY: qva->qva_source |= RPMQV_TRIGGEREDBY;
|
|
|
|
qva->qva_sourceCount++; break;
|
|
|
|
|
|
|
|
/* XXX SPECFILE is not verify sources */
|
|
|
|
case POPT_SPECFILE:
|
|
|
|
qva->qva_source |= RPMQV_SPECFILE;
|
|
|
|
qva->qva_sourceCount++;
|
|
|
|
break;
|
|
|
|
case POPT_QUERYBYNUMBER:
|
|
|
|
qva->qva_source |= RPMQV_DBOFFSET;
|
|
|
|
qva->qva_sourceCount++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct poptOption rpmQVSourcePoptTable[] = {
|
|
|
|
{ NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
|
|
|
|
rpmQVSourceArgCallback, 0, NULL, NULL },
|
|
|
|
{ "file", 'f', 0, 0, 'f',
|
|
|
|
N_("query package owning file"), "FILE" },
|
|
|
|
{ "group", 'g', 0, 0, 'g',
|
|
|
|
N_("query packages in group"), "GROUP" },
|
|
|
|
{ "package", 'p', 0, 0, 'p',
|
|
|
|
N_("query a package file"), NULL },
|
|
|
|
{ "querybynumber", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0,
|
|
|
|
POPT_QUERYBYNUMBER, NULL, NULL },
|
|
|
|
{ "specfile", '\0', 0, 0, POPT_SPECFILE,
|
|
|
|
N_("query a spec file"), NULL },
|
|
|
|
{ "triggeredby", '\0', 0, 0, POPT_TRIGGEREDBY,
|
|
|
|
N_("query the pacakges triggered by the package"), "PACKAGE" },
|
|
|
|
{ "whatrequires", '\0', 0, 0, POPT_WHATREQUIRES,
|
|
|
|
N_("query the packages which require a capability"), "CAPABILITY" },
|
|
|
|
{ "whatprovides", '\0', 0, 0, POPT_WHATPROVIDES,
|
|
|
|
N_("query the packages which provide a capability"), "CAPABILITY" },
|
|
|
|
{ 0, 0, 0, 0, 0, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ========== Query specific popt args */
|
|
|
|
|
1999-09-18 04:40:41 +08:00
|
|
|
static void queryArgCallback(/*@unused@*/poptContext con, /*@unused@*/enum poptCallbackReason reason,
|
1999-07-18 03:00:45 +08:00
|
|
|
const struct poptOption * opt, const char * arg,
|
1999-10-01 00:56:05 +08:00
|
|
|
const void * data)
|
1999-07-18 03:00:45 +08:00
|
|
|
{
|
1999-10-01 00:56:05 +08:00
|
|
|
QVA_t *qva = (QVA_t *) data;
|
|
|
|
|
1999-07-18 03:00:45 +08:00
|
|
|
switch (opt->val) {
|
|
|
|
case 'c': qva->qva_flags |= QUERY_FOR_CONFIG | QUERY_FOR_LIST; break;
|
|
|
|
case 'd': qva->qva_flags |= QUERY_FOR_DOCS | QUERY_FOR_LIST; break;
|
|
|
|
case 'l': qva->qva_flags |= QUERY_FOR_LIST; break;
|
|
|
|
case 's': qva->qva_flags |= QUERY_FOR_STATE | QUERY_FOR_LIST; break;
|
|
|
|
case POPT_DUMP: qva->qva_flags |= QUERY_FOR_DUMPFILES | QUERY_FOR_LIST; break;
|
|
|
|
case 'v': rpmIncreaseVerbosity(); break;
|
|
|
|
|
|
|
|
case POPT_QUERYFORMAT:
|
|
|
|
{ char *qf = (char *)qva->qva_queryFormat;
|
|
|
|
if (qf) {
|
|
|
|
int len = strlen(qf) + strlen(arg) + 1;
|
1999-09-21 11:22:53 +08:00
|
|
|
qf = xrealloc(qf, len);
|
1999-07-18 03:00:45 +08:00
|
|
|
strcat(qf, arg);
|
|
|
|
} else {
|
1999-09-21 11:22:53 +08:00
|
|
|
qf = xmalloc(strlen(arg) + 1);
|
1999-07-18 03:00:45 +08:00
|
|
|
strcpy(qf, arg);
|
|
|
|
}
|
|
|
|
qva->qva_queryFormat = qf;
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct poptOption rpmQueryPoptTable[] = {
|
|
|
|
{ NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
|
|
|
|
queryArgCallback, 0, NULL, NULL },
|
|
|
|
{ "configfiles", 'c', 0, 0, 'c',
|
|
|
|
N_("list all configuration files"), NULL },
|
|
|
|
{ "docfiles", 'd', 0, 0, 'd',
|
|
|
|
N_("list all documentation files"), NULL },
|
|
|
|
{ "dump", '\0', 0, 0, POPT_DUMP,
|
|
|
|
N_("dump basic file information"), NULL },
|
|
|
|
{ "list", 'l', 0, 0, 'l',
|
|
|
|
N_("list files in package"), NULL },
|
|
|
|
{ "qf", '\0', POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN, 0,
|
|
|
|
POPT_QUERYFORMAT, NULL, NULL },
|
|
|
|
{ "queryformat", '\0', POPT_ARG_STRING, 0, POPT_QUERYFORMAT,
|
|
|
|
N_("use the following query format"), "QUERYFORMAT" },
|
|
|
|
{ "specedit", '\0', POPT_ARG_STRING, &specedit, 0,
|
|
|
|
N_("substitute i18n sections from the following catalogue"),
|
|
|
|
"METACATALOGUE" },
|
|
|
|
{ "state", 's', 0, 0, 's',
|
|
|
|
N_("display the states of the listed files"), NULL },
|
|
|
|
{ "verbose", 'v', 0, 0, 'v',
|
|
|
|
N_("display a verbose file listing"), NULL },
|
|
|
|
{ 0, 0, 0, 0, 0, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ======================================================================== */
|