From d382745d17ae859c0ad43d691648da576bd70907 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 18 Nov 1996 18:02:36 +0000 Subject: [PATCH] The Great Renaming CVS patchset: 1171 CVS date: 1996/11/18 18:02:36 --- build/build.c | 91 ++++++------ build/files.c | 115 ++++++++------- build/names.c | 4 +- build/pack.c | 216 ++++++++++++++-------------- build/reqprov.c | 83 ++++++----- build/spec.c | 163 +++++++++++---------- build/trigger.c | 21 ++- build/vspec.c | 23 ++- checksig.c | 69 ++++----- convertdb.c | 65 +++++---- install.c | 74 +++++----- install.h | 8 +- lib/Makefile.in | 2 - lib/dbindex.c | 40 +++--- lib/dbindex.h | 26 ++-- lib/depends.c | 110 +++++++------- lib/header.c | 227 ++++++++++++++--------------- lib/header.h | 60 ++++---- lib/install.c | 334 +++++++++++++++++++++---------------------- lib/messages.c | 31 ++-- lib/messages.h | 16 +-- lib/misc.c | 2 +- lib/oldheader.c | 3 +- lib/package.c | 86 +++++------ lib/rebuilddb.c | 27 ++-- lib/rpmdb.c | 218 ++++++++++++++-------------- lib/rpmerr.c | 16 +-- lib/rpmlead.c | 4 +- lib/rpmlead.h | 34 +---- lib/rpmlib.h | 255 ++++++++++++++++++++++++++------- lib/rpmrc.c | 107 +++++++------- lib/signature.c | 134 ++++++++--------- lib/signature.h | 45 +----- lib/test.c | 40 +++--- lib/uninstall.c | 125 ++++++++-------- lib/var.c | 8 +- lib/verify.c | 72 +++++----- oldrpmdb.c | 18 +-- query.c | 110 +++++++------- query.h | 2 +- rpm.c | 78 +++++----- rpm2cpio.c | 2 +- rpmio/messages.c | 31 ++-- rpmio/rpmerr.c | 16 +-- tools/dump.c | 8 +- tools/dumpdb.c | 6 +- tools/rpmarchive.c | 6 +- tools/rpmchecksig.c | 2 +- tools/rpmheader.c | 8 +- tools/rpmsignature.c | 4 +- url.c | 14 +- verify.c | 48 +++---- 52 files changed, 1686 insertions(+), 1621 deletions(-) diff --git a/build/build.c b/build/build.c index a60233c2b..f63ac3f67 100644 --- a/build/build.c +++ b/build/build.c @@ -16,7 +16,6 @@ #include "header.h" #include "spec.h" #include "specP.h" -#include "rpmerr.h" #include "rpmlib.h" #include "messages.h" #include "stringbuf.h" @@ -54,11 +53,11 @@ struct Script *openScript(Spec spec, int builddir, char *name) int_32 foo; if (! main_package) { - error(RPMERR_INTERNAL, "Empty main package"); + rpmError(RPMERR_INTERNAL, "Empty main package"); exit(RPMERR_INTERNAL); } - script->name = tempnam(getVar(RPMVAR_TMPPATH), "rpmbuild"); + script->name = tempnam(rpmGetVar(RPMVAR_TMPPATH), "rpmbuild"); script->file = fopen(script->name, "w"); /* Prepare the script */ @@ -66,31 +65,31 @@ struct Script *openScript(Spec spec, int builddir, char *name) "#!/bin/sh -e\n" "# Script generated by rpm\n\n"); - fprintf(script->file, "RPM_SOURCE_DIR=\"%s\"\n", getVar(RPMVAR_SOURCEDIR)); - fprintf(script->file, "RPM_BUILD_DIR=\"%s\"\n", getVar(RPMVAR_BUILDDIR)); - fprintf(script->file, "RPM_DOC_DIR=\"%s\"\n", getVar(RPMVAR_DEFAULTDOCDIR)); - fprintf(script->file, "RPM_OPT_FLAGS=\"%s\"\n", getVar(RPMVAR_OPTFLAGS)); - fprintf(script->file, "RPM_ARCH=\"%s\"\n", getArchName()); - fprintf(script->file, "RPM_OS=\"%s\"\n", getOsName()); - if (getVar(RPMVAR_ROOT)) { - fprintf(script->file, "RPM_ROOT_DIR=\"%s\"\n", getVar(RPMVAR_ROOT)); + fprintf(script->file, "RPM_SOURCE_DIR=\"%s\"\n", rpmGetVar(RPMVAR_SOURCEDIR)); + fprintf(script->file, "RPM_BUILD_DIR=\"%s\"\n", rpmGetVar(RPMVAR_BUILDDIR)); + fprintf(script->file, "RPM_DOC_DIR=\"%s\"\n", rpmGetVar(RPMVAR_DEFAULTDOCDIR)); + fprintf(script->file, "RPM_OPT_FLAGS=\"%s\"\n", rpmGetVar(RPMVAR_OPTFLAGS)); + fprintf(script->file, "RPM_ARCH=\"%s\"\n", rpmGetArchName()); + fprintf(script->file, "RPM_OS=\"%s\"\n", rpmGetOsName()); + if (rpmGetVar(RPMVAR_ROOT)) { + fprintf(script->file, "RPM_ROOT_DIR=\"%s\"\n", rpmGetVar(RPMVAR_ROOT)); } else { fprintf(script->file, "RPM_ROOT_DIR=\"\"\n"); } - if (getVar(RPMVAR_BUILDROOT)) { + if (rpmGetVar(RPMVAR_BUILDROOT)) { fprintf(script->file, "RPM_BUILD_ROOT=\"%s\"\n", - getVar(RPMVAR_BUILDROOT)); + rpmGetVar(RPMVAR_BUILDROOT)); } else { fprintf(script->file, "RPM_BUILD_ROOT=\"\"\n"); } fprintf(script->file, "RPM_PACKAGE_NAME=\"%s\"\n", spec->name); - getEntry(main_package->header, RPMTAG_VERSION, &foo, (void **)&s, &foo); + headerGetEntry(main_package->header, RPMTAG_VERSION, &foo, (void **)&s, &foo); fprintf(script->file, "RPM_PACKAGE_VERSION=\"%s\"\n", s); - getEntry(main_package->header, RPMTAG_RELEASE, &foo, (void **)&s, &foo); + headerGetEntry(main_package->header, RPMTAG_RELEASE, &foo, (void **)&s, &foo); fprintf(script->file, "RPM_PACKAGE_RELEASE=\"%s\"\n", s); - if (isVerbose()) { + if (rpmIsVerbose()) { fprintf(script->file, "set -x\n\n"); } else { fprintf(script->file, "exec > /dev/null\n\n"); @@ -100,7 +99,7 @@ struct Script *openScript(Spec spec, int builddir, char *name) fprintf(script->file, "umask 022\n"); fprintf(script->file, "\necho Executing: %s\n", name); - fprintf(script->file, "cd %s\n\n", getVar(RPMVAR_BUILDDIR)); + fprintf(script->file, "cd %s\n\n", rpmGetVar(RPMVAR_BUILDDIR)); if (builddir) { /* Need to cd to the actual build directory. */ /* Note that this means we have to parse the */ @@ -128,12 +127,12 @@ int execScript(struct Script *script) if (!(pid = fork())) { execl(script->name, script->name, NULL); - error(RPMERR_SCRIPT, "Exec failed"); + rpmError(RPMERR_SCRIPT, "Exec failed"); exit(RPMERR_SCRIPT); } wait(&status); if (! WIFEXITED(status) || WEXITSTATUS(status)) { - error(RPMERR_SCRIPT, "Bad exit status"); + rpmError(RPMERR_SCRIPT, "Bad exit status"); exit(RPMERR_SCRIPT); } return 0; @@ -153,7 +152,7 @@ int execPart(Spec s, char *sb, char *name, int builddir, int test) { struct Script *script; - message(MESS_DEBUG, "RUNNING: %s\n", name); + rpmMessage(RPMMESS_DEBUG, "RUNNING: %s\n", name); script = openScript(s, builddir, name); writeScript(script, sb); if (!test) { @@ -184,14 +183,14 @@ static int doRmSource(Spec s) struct PackageRec *package; /* spec file */ - sprintf(filename, "%s%s", getVar(RPMVAR_SPECDIR), + sprintf(filename, "%s%s", rpmGetVar(RPMVAR_SPECDIR), strrchr(s->specfile, '/')); unlink(filename); /* sources and patches */ source = s->sources; while (source) { - sprintf(filename, "%s/%s", getVar(RPMVAR_SOURCEDIR), source->source); + sprintf(filename, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), source->source); unlink(filename); source = source->next; } @@ -200,7 +199,7 @@ static int doRmSource(Spec s) package = s->packages; while (package) { if (package->icon) { - sprintf(filename, "%s/%s", getVar(RPMVAR_SOURCEDIR), + sprintf(filename, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), package->icon); unlink(filename); } @@ -233,35 +232,35 @@ static int doSetupMacro(Spec spec, StringBuf sb, char *line) /* dir name */ opt_n = strtok(NULL, " \t\n"); if (! opt_n) { - error(RPMERR_BADSPEC, "Need arg to %%setup -n"); + rpmError(RPMERR_BADSPEC, "Need arg to %%setup -n"); return(RPMERR_BADSPEC); } } else if (!strcmp(s, "-a")) { s = strtok(NULL, " \t\n"); if (! s) { - error(RPMERR_BADSPEC, "Need arg to %%setup -a"); + rpmError(RPMERR_BADSPEC, "Need arg to %%setup -a"); return(RPMERR_BADSPEC); } s1 = NULL; opt_a = strtoul(s, &s1, 10); if ((*s1) || (s1 == s) || (opt_a == ULONG_MAX)) { - error(RPMERR_BADSPEC, "Bad arg to %%setup -a: %s", s); + rpmError(RPMERR_BADSPEC, "Bad arg to %%setup -a: %s", s); return(RPMERR_BADSPEC); } } else if (!strcmp(s, "-b")) { s = strtok(NULL, " \t\n"); if (! s) { - error(RPMERR_BADSPEC, "Need arg to %%setup -b"); + rpmError(RPMERR_BADSPEC, "Need arg to %%setup -b"); return(RPMERR_BADSPEC); } s1 = NULL; opt_b = strtoul(s, &s1, 10); if ((*s1) || (s1 == s) || (opt_b == ULONG_MAX)) { - error(RPMERR_BADSPEC, "Bad arg to %%setup -b: %s", s); + rpmError(RPMERR_BADSPEC, "Bad arg to %%setup -b: %s", s); return(RPMERR_BADSPEC); } } else { - error(RPMERR_BADSPEC, "Bad arg to %%setup: %s", s); + rpmError(RPMERR_BADSPEC, "Bad arg to %%setup: %s", s); return(RPMERR_BADSPEC); } } @@ -282,13 +281,13 @@ static int doSetupMacro(Spec spec, StringBuf sb, char *line) strcpy(build_subdir, spec->name); strcat(build_subdir, "-"); /* We should already have a version field */ - getEntry(spec->packages->header, RPMTAG_VERSION, NULL, + headerGetEntry(spec->packages->header, RPMTAG_VERSION, NULL, (void *) &version, NULL); strcat(build_subdir, version); } /* cd to the build dir */ - sprintf(buf, "cd %s", getVar(RPMVAR_BUILDDIR)); + sprintf(buf, "cd %s", rpmGetVar(RPMVAR_BUILDDIR)); appendLineStringBuf(sb, buf); /* delete any old sources */ @@ -345,7 +344,7 @@ static int doSetupMacro(Spec spec, StringBuf sb, char *line) } /* clean up permissions etc */ - sprintf(buf, "cd %s/%s", getVar(RPMVAR_BUILDDIR), build_subdir); + sprintf(buf, "cd %s/%s", rpmGetVar(RPMVAR_BUILDDIR), build_subdir); appendLineStringBuf(sb, buf); if (! geteuid()) { appendLineStringBuf(sb, "chown -R root ."); @@ -396,12 +395,12 @@ static char *do_untar(Spec spec, int c) sp = sp->next; } if (! s) { - error(RPMERR_BADSPEC, "No source number %d", c); + rpmError(RPMERR_BADSPEC, "No source number %d", c); return NULL; } - sprintf(file, "%s/%s", getVar(RPMVAR_SOURCEDIR), s); - taropts = (isVerbose() ? "-xvvf" : "-xf"); + sprintf(file, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), s); + taropts = (rpmIsVerbose() ? "-xvvf" : "-xf"); if (isCompressed(file)) { sprintf(buf, @@ -436,11 +435,11 @@ static char *do_patch(Spec spec, int c, int strip, char *db, sp = sp->next; } if (! s) { - error(RPMERR_BADSPEC, "No patch number %d", c); + rpmError(RPMERR_BADSPEC, "No patch number %d", c); return NULL; } - sprintf(file, "%s/%s", getVar(RPMVAR_SOURCEDIR), s); + sprintf(file, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), s); args[0] = '\0'; if (db) { @@ -503,7 +502,7 @@ static int doPatchMacro(Spec spec, StringBuf sb, char *line) /* orig suffix */ opt_b = strtok(NULL, " \t\n"); if (! opt_b) { - error(RPMERR_BADSPEC, "Need arg to %%patch -b"); + rpmError(RPMERR_BADSPEC, "Need arg to %%patch -b"); return(RPMERR_BADSPEC); } } else if (!strncmp(s, "-p", 2)) { @@ -513,26 +512,26 @@ static int doPatchMacro(Spec spec, StringBuf sb, char *line) } else { s = strtok(NULL, " \t\n"); if (! s) { - error(RPMERR_BADSPEC, "Need arg to %%patch -p"); + rpmError(RPMERR_BADSPEC, "Need arg to %%patch -p"); return(RPMERR_BADSPEC); } } s1 = NULL; opt_p = strtoul(s, &s1, 10); if ((*s1) || (s1 == s) || (opt_p == ULONG_MAX)) { - error(RPMERR_BADSPEC, "Bad arg to %%patch -p: %s", s); + rpmError(RPMERR_BADSPEC, "Bad arg to %%patch -p: %s", s); return(RPMERR_BADSPEC); } } else { /* Must be a patch num */ if (patch_index == 1024) { - error(RPMERR_BADSPEC, "Too many patches!"); + rpmError(RPMERR_BADSPEC, "Too many patches!"); return(RPMERR_BADSPEC); } s1 = NULL; patch_nums[patch_index] = strtoul(s, &s1, 10); if ((*s1) || (s1 == s) || (patch_nums[patch_index] == ULONG_MAX)) { - error(RPMERR_BADSPEC, "Bad arg to %%patch: %s", s); + rpmError(RPMERR_BADSPEC, "Bad arg to %%patch: %s", s); return(RPMERR_BADSPEC); } patch_index++; @@ -571,9 +570,9 @@ static int checkSources(Spec s) /* Check that we can access all the sources */ source = s->sources; while (source) { - sprintf(buf, "%s/%s", getVar(RPMVAR_SOURCEDIR), source->source); + sprintf(buf, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), source->source); if (access(buf, R_OK)) { - error(RPMERR_BADSPEC, "missing source or patch: %s", buf); + rpmError(RPMERR_BADSPEC, "missing source or patch: %s", buf); return RPMERR_BADSPEC; } source = source->next; @@ -583,9 +582,9 @@ static int checkSources(Spec s) package = s->packages; while (package) { if (package->icon) { - sprintf(buf, "%s/%s", getVar(RPMVAR_SOURCEDIR), package->icon); + sprintf(buf, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), package->icon); if (access(buf, R_OK)) { - error(RPMERR_BADSPEC, "missing icon: %s", buf); + rpmError(RPMERR_BADSPEC, "missing icon: %s", buf); return RPMERR_BADSPEC; } } diff --git a/build/files.c b/build/files.c index 04a74ca85..5fbf4a591 100644 --- a/build/files.c +++ b/build/files.c @@ -20,7 +20,6 @@ #include "header.h" #include "files.h" #include "names.h" -#include "rpmerr.h" #include "rpmlead.h" #include "rpmlib.h" #include "misc.h" @@ -86,9 +85,9 @@ int process_filelist(Header header, struct PackageRec *pr, resetDocdir(); if (type == RPMLEAD_BINARY && pr->fileFile) { - sprintf(buf, "%s/%s/%s", getVar(RPMVAR_BUILDDIR), + sprintf(buf, "%s/%s/%s", rpmGetVar(RPMVAR_BUILDDIR), build_subdir, pr->fileFile); - message(MESS_DEBUG, "Reading file names from: %sXX\n", buf); + rpmMessage(RPMMESS_DEBUG, "Reading file names from: %sXX\n", buf); if ((file = fopen(buf, "r")) == NULL) { perror("open fileFile"); exit(1); @@ -121,7 +120,7 @@ int process_filelist(Header header, struct PackageRec *pr, free (currGname); currGname = NULL; } - verify_flags = VERIFY_ALL; + verify_flags = RPMVERIFY_ALL; filename = NULL; /* First preparse buf for %verify() */ @@ -149,7 +148,7 @@ int process_filelist(Header header, struct PackageRec *pr, } else { if (filename) { /* We already got a file -- error */ - error(RPMERR_BADSPEC, + rpmError(RPMERR_BADSPEC, "Two files on one line: %s", filename); return(RPMERR_BADSPEC); } @@ -158,7 +157,7 @@ int process_filelist(Header header, struct PackageRec *pr, special_doc = 1; } else { /* not in %doc, does not begin with / -- error */ - error(RPMERR_BADSPEC, + rpmError(RPMERR_BADSPEC, "File must begin with \"/\": %s", s); return(RPMERR_BADSPEC); } @@ -174,11 +173,11 @@ int process_filelist(Header header, struct PackageRec *pr, continue; } else { if (filename || isconf || isdir) { - error(RPMERR_BADSPEC, + rpmError(RPMERR_BADSPEC, "Can't mix special %%doc with other forms: %s", fp); return(RPMERR_BADSPEC); } - sprintf(buf, "%s/%s-%s-%s", getVar(RPMVAR_DEFAULTDOCDIR), + sprintf(buf, "%s/%s-%s-%s", rpmGetVar(RPMVAR_DEFAULTDOCDIR), name, version, release); filename = buf; passed_special_doc = 1; @@ -192,7 +191,7 @@ int process_filelist(Header header, struct PackageRec *pr, if (type == RPMLEAD_BINARY) { /* check that file starts with leading "/" */ if (*filename != '/') { - error(RPMERR_BADSPEC, + rpmError(RPMERR_BADSPEC, "File needs leading \"/\": %s", filename); return(RPMERR_BADSPEC); } @@ -200,24 +199,24 @@ int process_filelist(Header header, struct PackageRec *pr, if (glob_pattern_p(filename)) { char fullname[1024]; - if (getVar(RPMVAR_ROOT)) { - sprintf(fullname, "%s%s", getVar(RPMVAR_ROOT), filename); + if (rpmGetVar(RPMVAR_ROOT)) { + sprintf(fullname, "%s%s", rpmGetVar(RPMVAR_ROOT), filename); } else { strcpy(fullname, filename); } if (glob(fullname, 0, glob_error, &glob_result)) { - error(RPMERR_BADSPEC, "No matches: %s", fullname); + rpmError(RPMERR_BADSPEC, "No matches: %s", fullname); return(RPMERR_BADSPEC); } if (glob_result.gl_pathc < 1) { - error(RPMERR_BADSPEC, "No matches: %s", fullname); + rpmError(RPMERR_BADSPEC, "No matches: %s", fullname); return(RPMERR_BADSPEC); } x = 0; c = 0; while (x < glob_result.gl_pathc) { - int offset = strlen(getVar(RPMVAR_ROOT) ? : ""); + int offset = strlen(rpmGetVar(RPMVAR_ROOT) ? : ""); c += add_file(&fes, &(glob_result.gl_pathv[x][offset]), isdoc, isconf, isdir, verify_flags, currPmode, currUname, currGname, prefix); @@ -248,7 +247,7 @@ int process_filelist(Header header, struct PackageRec *pr, } if (! c) { - error(RPMERR_BADSPEC, "File not found: %s", filename); + rpmError(RPMERR_BADSPEC, "File not found: %s", filename); return(RPMERR_BADSPEC); } count += c; @@ -301,7 +300,7 @@ int process_filelist(Header header, struct PackageRec *pr, /* Do timecheck */ tc = 0; currentTime = time(NULL); - if ((tcs = getVar(RPMVAR_TIMECHECK))) { + if ((tcs = rpmGetVar(RPMVAR_TIMECHECK))) { tc = strtoul(tcs, NULL, 10); } @@ -314,7 +313,7 @@ int process_filelist(Header header, struct PackageRec *pr, fileList[c] = strrchr(fest->file, '/') + 1; } if ((c > 0) && !strcmp(fileList[c], fileList[c-1])) { - error(RPMERR_BADSPEC, "File listed twice: %s", fileList[c]); + rpmError(RPMERR_BADSPEC, "File listed twice: %s", fileList[c]); return(RPMERR_BADSPEC); } @@ -322,14 +321,14 @@ int process_filelist(Header header, struct PackageRec *pr, fileGnameList[c] = fest->gname; *size += fest->statbuf.st_size; if (S_ISREG(fest->statbuf.st_mode)) { - if (getVar(RPMVAR_ROOT)) { - sprintf(buf, "%s%s", getVar(RPMVAR_ROOT), fest->file); + if (rpmGetVar(RPMVAR_ROOT)) { + sprintf(buf, "%s%s", rpmGetVar(RPMVAR_ROOT), fest->file); } else { strcpy(buf, fest->file); } mdfile(buf, buf); fileMD5List[c] = strdup(buf); - message(MESS_DEBUG, "md5(%s) = %s\n", fest->file, buf); + rpmMessage(RPMMESS_DEBUG, "md5(%s) = %s\n", fest->file, buf); } else { /* This is stupid */ fileMD5List[c] = strdup(""); @@ -342,7 +341,7 @@ int process_filelist(Header header, struct PackageRec *pr, /* Do timecheck */ if (tc && (type == RPMLEAD_BINARY)) { if (currentTime - fest->statbuf.st_mtime > tc) { - message(MESS_WARNING, "TIMECHECK failure: %s\n", + rpmMessage(RPMMESS_WARNING, "TIMECHECK failure: %s\n", fest->file); } } @@ -362,8 +361,8 @@ int process_filelist(Header header, struct PackageRec *pr, fileVerifyFlagsList[c] = fest->verify_flags; if (S_ISLNK(fest->statbuf.st_mode)) { - if (getVar(RPMVAR_ROOT)) { - sprintf(buf, "%s%s", getVar(RPMVAR_ROOT), fest->file); + if (rpmGetVar(RPMVAR_ROOT)) { + sprintf(buf, "%s%s", rpmGetVar(RPMVAR_ROOT), fest->file); } else { strcpy(buf, fest->file); } @@ -378,22 +377,22 @@ int process_filelist(Header header, struct PackageRec *pr, /* Add the header entries */ c = count; - addEntry(header, RPMTAG_FILENAMES, STRING_ARRAY_TYPE, fileList, c); - addEntry(header, RPMTAG_FILELINKTOS, STRING_ARRAY_TYPE, + headerAddEntry(header, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE, fileList, c); + headerAddEntry(header, RPMTAG_FILELINKTOS, RPM_STRING_ARRAY_TYPE, fileLinktoList, c); - addEntry(header, RPMTAG_FILEMD5S, STRING_ARRAY_TYPE, fileMD5List, c); - addEntry(header, RPMTAG_FILESIZES, INT32_TYPE, fileSizeList, c); - addEntry(header, RPMTAG_FILEUIDS, INT32_TYPE, fileUIDList, c); - addEntry(header, RPMTAG_FILEGIDS, INT32_TYPE, fileGIDList, c); - addEntry(header, RPMTAG_FILEUSERNAME, STRING_ARRAY_TYPE, + headerAddEntry(header, RPMTAG_FILEMD5S, RPM_STRING_ARRAY_TYPE, fileMD5List, c); + headerAddEntry(header, RPMTAG_FILESIZES, RPM_INT32_TYPE, fileSizeList, c); + headerAddEntry(header, RPMTAG_FILEUIDS, RPM_INT32_TYPE, fileUIDList, c); + headerAddEntry(header, RPMTAG_FILEGIDS, RPM_INT32_TYPE, fileGIDList, c); + headerAddEntry(header, RPMTAG_FILEUSERNAME, RPM_STRING_ARRAY_TYPE, fileUnameList, c); - addEntry(header, RPMTAG_FILEGROUPNAME, STRING_ARRAY_TYPE, + headerAddEntry(header, RPMTAG_FILEGROUPNAME, RPM_STRING_ARRAY_TYPE, fileGnameList, c); - addEntry(header, RPMTAG_FILEMTIMES, INT32_TYPE, fileMtimesList, c); - addEntry(header, RPMTAG_FILEFLAGS, INT32_TYPE, fileFlagsList, c); - addEntry(header, RPMTAG_FILEMODES, INT16_TYPE, fileModesList, c); - addEntry(header, RPMTAG_FILERDEVS, INT16_TYPE, fileRDevsList, c); - addEntry(header, RPMTAG_FILEVERIFYFLAGS, INT32_TYPE, + headerAddEntry(header, RPMTAG_FILEMTIMES, RPM_INT32_TYPE, fileMtimesList, c); + headerAddEntry(header, RPMTAG_FILEFLAGS, RPM_INT32_TYPE, fileFlagsList, c); + headerAddEntry(header, RPMTAG_FILEMODES, RPM_INT16_TYPE, fileModesList, c); + headerAddEntry(header, RPMTAG_FILERDEVS, RPM_INT16_TYPE, fileRDevsList, c); + headerAddEntry(header, RPMTAG_FILEVERIFYFLAGS, RPM_INT32_TYPE, fileVerifyFlagsList, c); /* Free the allocated strings */ @@ -548,8 +547,8 @@ static int add_file(struct file_entry **festack, const char *name, p->isconf = isconf; p->isspecfile = 0; /* source packages are done by hand */ p->verify_flags = verify_flags; - if (getVar(RPMVAR_ROOT)) { - sprintf(fullname, "%s%s", getVar(RPMVAR_ROOT), name); + if (rpmGetVar(RPMVAR_ROOT)) { + sprintf(fullname, "%s%s", rpmGetVar(RPMVAR_ROOT), name); } else { strcpy(fullname, name); } @@ -566,7 +565,7 @@ static int add_file(struct file_entry **festack, const char *name, prefixTest++; } if (*prefixPtr) { - error(RPMERR_BADSPEC, "File doesn't match prefix (%s): %s", + rpmError(RPMERR_BADSPEC, "File doesn't match prefix (%s): %s", prefix, name); return 0; } @@ -615,7 +614,7 @@ static int add_file(struct file_entry **festack, const char *name, p->next = *festack; *festack = p; - message(MESS_DEBUG, "ADDING: %s\n", name); + rpmMessage(RPMMESS_DEBUG, "ADDING: %s\n", name); /* return number of entries added */ return 1; @@ -626,8 +625,8 @@ static int add_file_aux(const char *file, struct stat *sb, int flag) { const char *name = file; - if (getVar(RPMVAR_ROOT)) { - name += strlen(getVar(RPMVAR_ROOT)); + if (rpmGetVar(RPMVAR_ROOT)) { + name += strlen(rpmGetVar(RPMVAR_ROOT)); } /* The 1 will cause add_file() to *not* descend */ @@ -705,7 +704,7 @@ static int parseForAttr(char *buf, char **currPmode, } if (*p != '(') { - error(RPMERR_BADSPEC, "Bad %%attr() syntax: %s", buf); + rpmError(RPMERR_BADSPEC, "Bad %%attr() syntax: %s", buf); return 0; } p++; @@ -716,7 +715,7 @@ static int parseForAttr(char *buf, char **currPmode, } if (! *end) { - error(RPMERR_BADSPEC, "Bad %%attr() syntax: %s", buf); + rpmError(RPMERR_BADSPEC, "Bad %%attr() syntax: %s", buf); return 0; } @@ -728,7 +727,7 @@ static int parseForAttr(char *buf, char **currPmode, *currGname = strtok(NULL, ", \n\t"); if (! (*currPmode && *currUname && *currGname)) { - error(RPMERR_BADSPEC, "Bad %%attr() syntax: %s", buf); + rpmError(RPMERR_BADSPEC, "Bad %%attr() syntax: %s", buf); *currPmode = *currUname = *currGname = NULL; return 0; } @@ -737,7 +736,7 @@ static int parseForAttr(char *buf, char **currPmode, if (strcmp(*currPmode, "-")) { x = sscanf(*currPmode, "%o", &mode); if ((x == 0) || (mode >> 12)) { - error(RPMERR_BADSPEC, "Bad %%attr() mode spec: %s", buf); + rpmError(RPMERR_BADSPEC, "Bad %%attr() mode spec: %s", buf); *currPmode = *currUname = *currGname = NULL; return 0; } @@ -777,7 +776,7 @@ static int parseForVerify(char *buf, int *verify_flags) } if (*p != '(') { - error(RPMERR_BADSPEC, "Bad %%verify() syntax: %s", buf); + rpmError(RPMERR_BADSPEC, "Bad %%verify() syntax: %s", buf); return 0; } p++; @@ -788,7 +787,7 @@ static int parseForVerify(char *buf, int *verify_flags) } if (! *end) { - error(RPMERR_BADSPEC, "Bad %%verify() syntax: %s", buf); + rpmError(RPMERR_BADSPEC, "Bad %%verify() syntax: %s", buf); return 0; } @@ -800,28 +799,28 @@ static int parseForVerify(char *buf, int *verify_flags) p = strtok(ourbuf, ", \n\t"); not = 0; - *verify_flags = VERIFY_NONE; + *verify_flags = RPMVERIFY_NONE; while (p) { if (!strcmp(p, "not")) { not = 1; } else if (!strcmp(p, "md5")) { - *verify_flags |= VERIFY_MD5; + *verify_flags |= RPMVERIFY_MD5; } else if (!strcmp(p, "size")) { - *verify_flags |= VERIFY_FILESIZE; + *verify_flags |= RPMVERIFY_FILESIZE; } else if (!strcmp(p, "link")) { - *verify_flags |= VERIFY_LINKTO; + *verify_flags |= RPMVERIFY_LINKTO; } else if (!strcmp(p, "user")) { - *verify_flags |= VERIFY_USER; + *verify_flags |= RPMVERIFY_USER; } else if (!strcmp(p, "group")) { - *verify_flags |= VERIFY_GROUP; + *verify_flags |= RPMVERIFY_GROUP; } else if (!strcmp(p, "mtime")) { - *verify_flags |= VERIFY_MTIME; + *verify_flags |= RPMVERIFY_MTIME; } else if (!strcmp(p, "mode")) { - *verify_flags |= VERIFY_MODE; + *verify_flags |= RPMVERIFY_MODE; } else if (!strcmp(p, "rdev")) { - *verify_flags |= VERIFY_RDEV; + *verify_flags |= RPMVERIFY_RDEV; } else { - error(RPMERR_BADSPEC, "Invalid %%verify token: %s", p); + rpmError(RPMERR_BADSPEC, "Invalid %%verify token: %s", p); return 0; } p = strtok(NULL, ", \n\t"); diff --git a/build/names.c b/build/names.c index 65562283d..f64a1f49d 100644 --- a/build/names.c +++ b/build/names.c @@ -12,7 +12,7 @@ #include "names.h" #include "rpmlib.h" -#include "rpmerr.h" +#include "messages.h" static uid_t uids[1024]; static char *unames[1024]; @@ -183,7 +183,7 @@ char *buildHost(void) if ((hbn = gethostbyname(hostname))) { strcpy(hostname, hbn->h_name); } else { - message(MESS_WARNING, "Could not canonicalize hostname: %s\n", + rpmMessage(RPMMESS_WARNING, "Could not canonicalize hostname: %s\n", hostname); } gotit = 1; diff --git a/build/pack.c b/build/pack.c index c2ec3c8e4..bdfe7e077 100644 --- a/build/pack.c +++ b/build/pack.c @@ -16,7 +16,6 @@ #include "spec.h" #include "specP.h" #include "signature.h" -#include "rpmerr.h" #include "rpmlead.h" #include "rpmlib.h" #include "misc.h" @@ -25,6 +24,7 @@ #include "files.h" #include "reqprov.h" #include "trigger.h" +#include "messages.h" static int writeMagic(int fd, char *name, unsigned short type); static int cpio_gzip(int fd, char *tempdir, char *writePtr, @@ -55,7 +55,7 @@ static int generateRPM(char *name, /* name-version-release */ Header sig; /* Write the archive to a temp file so we can get the size */ - archiveTemp = tempnam(getVar(RPMVAR_TMPPATH), "rpmbuild"); + archiveTemp = tempnam(rpmGetVar(RPMVAR_TMPPATH), "rpmbuild"); if ((fd = open(archiveTemp, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) { fprintf(stderr, "Could not open %s\n", archiveTemp); return 1; @@ -68,16 +68,16 @@ static int generateRPM(char *name, /* name-version-release */ close(fd); /* Add the archive size to the Header */ - addEntry(header, RPMTAG_ARCHIVESIZE, INT32_TYPE, &archiveSize, 1); + headerAddEntry(header, RPMTAG_ARCHIVESIZE, RPM_INT32_TYPE, &archiveSize, 1); /* Now write the header and append the archive */ - sigtarget = tempnam(getVar(RPMVAR_TMPPATH), "rpmbuild"); + sigtarget = tempnam(rpmGetVar(RPMVAR_TMPPATH), "rpmbuild"); if ((fd = open(sigtarget, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) { fprintf(stderr, "Could not open %s\n", sigtarget); unlink(archiveTemp); return 1; } - writeHeader(fd, header, HEADER_MAGIC); + headerWrite(fd, header, HEADER_MAGIC_YES); ifd = open(archiveTemp, O_RDONLY, 0644); while ((count = read(ifd, buffer, sizeof(buffer))) > 0) { if (count == -1) { @@ -116,23 +116,23 @@ static int generateRPM(char *name, /* name-version-release */ } /* Generate the signature */ - sigtype = sigLookupType(); - message(MESS_VERBOSE, "Generating signature: %d\n", sigtype); + sigtype = rpmLookupSignatureType(); + rpmMessage(RPMMESS_VERBOSE, "Generating signature: %d\n", sigtype); fflush(stdout); - sig = newSignature(); - addSignature(sig, sigtarget, SIGTAG_SIZE, passPhrase); - addSignature(sig, sigtarget, SIGTAG_MD5, passPhrase); + sig = rpmNewSignature(); + rpmAddSignature(sig, sigtarget, RPMSIGTAG_SIZE, passPhrase); + rpmAddSignature(sig, sigtarget, RPMSIGTAG_MD5, passPhrase); if (sigtype>0) { - addSignature(sig, sigtarget, sigtype, passPhrase); + rpmAddSignature(sig, sigtarget, sigtype, passPhrase); } - if (writeSignature(fd, sig)) { + if (rpmWriteSignature(fd, sig)) { close(fd); unlink(sigtarget); unlink(filename); - freeSignature(sig); + rpmFreeSignature(sig); return 1; } - freeSignature(sig); + rpmFreeSignature(sig); /* Append the header and archive */ ifd = open(sigtarget, O_RDONLY); @@ -158,7 +158,7 @@ static int generateRPM(char *name, /* name-version-release */ close(fd); unlink(sigtarget); - message(MESS_VERBOSE, "Wrote: %s\n", filename); + rpmMessage(RPMMESS_VERBOSE, "Wrote: %s\n", filename); return 0; } @@ -172,8 +172,8 @@ static int writeMagic(int fd, char *name, lead.major = 3; lead.minor = 0; lead.type = type; - lead.archnum = getArchNum(); - lead.osnum = getOsNum(); + lead.archnum = rpmGetArchNum(); + lead.osnum = rpmGetOsNum(); lead.signature_type = RPMSIG_HEADERSIG; /* New-style signature */ strncpy(lead.name, name, sizeof(lead.name)); @@ -200,7 +200,7 @@ static int cpio_gzip(int fd, char *tempdir, char *writePtr, int status; void *oldhandler; - cpiobin = getVar(RPMVAR_CPIOBIN); + cpiobin = rpmGetVar(RPMVAR_CPIOBIN); if (!cpiobin) cpiobin = "cpio"; *archiveSize = 0; @@ -223,10 +223,10 @@ static int cpio_gzip(int fd, char *tempdir, char *writePtr, if (tempdir) { chdir(tempdir); - } else if (getVar(RPMVAR_ROOT)) { - if (chdir(getVar(RPMVAR_ROOT))) { - error(RPMERR_EXEC, "Couldn't chdir to %s", - getVar(RPMVAR_ROOT)); + } else if (rpmGetVar(RPMVAR_ROOT)) { + if (chdir(rpmGetVar(RPMVAR_ROOT))) { + rpmError(RPMERR_EXEC, "Couldn't chdir to %s", + rpmGetVar(RPMVAR_ROOT)); exit(RPMERR_EXEC); } } else { @@ -235,20 +235,20 @@ static int cpio_gzip(int fd, char *tempdir, char *writePtr, } if (prefix) { if (chdir(prefix)) { - error(RPMERR_EXEC, "Couldn't chdir to %s", prefix); + rpmError(RPMERR_EXEC, "Couldn't chdir to %s", prefix); exit(RPMERR_EXEC); } } execlp(cpiobin, cpiobin, - (isVerbose()) ? "-ov" : "-o", + (rpmIsVerbose()) ? "-ov" : "-o", (tempdir) ? "-LH" : "-H", "crc", NULL); - error(RPMERR_EXEC, "Couldn't exec cpio"); + rpmError(RPMERR_EXEC, "Couldn't exec cpio"); exit(RPMERR_EXEC); } if (cpioPID < 0) { - error(RPMERR_FORK, "Couldn't fork cpio"); + rpmError(RPMERR_FORK, "Couldn't fork cpio"); return RPMERR_FORK; } @@ -268,11 +268,11 @@ static int cpio_gzip(int fd, char *tempdir, char *writePtr, dup2(fd, 1); /* Make stdout the passed-in fd */ execlp("gzip", "gzip", "-c9fn", NULL); - error(RPMERR_EXEC, "Couldn't exec gzip"); + rpmError(RPMERR_EXEC, "Couldn't exec gzip"); exit(RPMERR_EXEC); } if (gzipPID < 0) { - error(RPMERR_FORK, "Couldn't fork gzip"); + rpmError(RPMERR_FORK, "Couldn't fork gzip"); return RPMERR_FORK; } @@ -327,7 +327,7 @@ static int cpio_gzip(int fd, char *tempdir, char *writePtr, } while (((!cpioDead) || bytes) && (!gzipDead)); if (gzipDead) { - error(RPMERR_GZIP, "gzip died"); + rpmError(RPMERR_GZIP, "gzip died"); return 1; } @@ -338,17 +338,17 @@ static int cpio_gzip(int fd, char *tempdir, char *writePtr, signal(SIGPIPE, oldhandler); if (writeBytesLeft) { - error(RPMERR_CPIO, "failed to write all data to cpio"); + rpmError(RPMERR_CPIO, "failed to write all data to cpio"); return 1; } waitpid(cpioPID, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status)) { - error(RPMERR_CPIO, "cpio failed"); + rpmError(RPMERR_CPIO, "cpio failed"); return 1; } waitpid(gzipPID, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status)) { - error(RPMERR_GZIP, "gzip failed"); + rpmError(RPMERR_GZIP, "gzip failed"); return 1; } @@ -383,18 +383,18 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) char **farray, *file; int count; - if (!getEntry(s->packages->header, RPMTAG_VERSION, NULL, + if (!headerGetEntry(s->packages->header, RPMTAG_VERSION, NULL, (void *) &version, NULL)) { - error(RPMERR_BADSPEC, "No version field"); + rpmError(RPMERR_BADSPEC, "No version field"); return RPMERR_BADSPEC; } - if (!getEntry(s->packages->header, RPMTAG_RELEASE, NULL, + if (!headerGetEntry(s->packages->header, RPMTAG_RELEASE, NULL, (void *) &release, NULL)) { - error(RPMERR_BADSPEC, "No release field"); + rpmError(RPMERR_BADSPEC, "No release field"); return RPMERR_BADSPEC; } - /* after the getEntry() these are just pointers into the */ - /* header structure, which can be moved around by addEntry */ + /* after the headerGetEntry() these are just pointers into the */ + /* header structure, which can be moved around by headerAddEntry */ version = strdup(version); release = strdup(release); @@ -402,16 +402,16 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) (s->numNoPatch + s->numNoSource) ? "no" : ""); vendor = NULL; - if (!isEntry(s->packages->header, RPMTAG_VENDOR)) { - vendor = getVar(RPMVAR_VENDOR); + if (!headerIsEntry(s->packages->header, RPMTAG_VENDOR)) { + vendor = rpmGetVar(RPMVAR_VENDOR); } dist = NULL; - if (!isEntry(s->packages->header, RPMTAG_DISTRIBUTION)) { - dist = getVar(RPMVAR_DISTRIBUTION); + if (!headerIsEntry(s->packages->header, RPMTAG_DISTRIBUTION)) { + dist = rpmGetVar(RPMVAR_DISTRIBUTION); } packager = NULL; - if (!isEntry(s->packages->header, RPMTAG_PACKAGER)) { - packager = getVar(RPMVAR_PACKAGER); + if (!headerIsEntry(s->packages->header, RPMTAG_PACKAGER)) { + packager = rpmGetVar(RPMVAR_PACKAGER); } /* Look through for each package */ @@ -424,30 +424,30 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) } /* Handle subpackage version/release overrides */ - if (!getEntry(pr->header, RPMTAG_VERSION, NULL, + if (!headerGetEntry(pr->header, RPMTAG_VERSION, NULL, (void *) &packageVersion, NULL)) { packageVersion = version; } - if (!getEntry(pr->header, RPMTAG_RELEASE, NULL, + if (!headerGetEntry(pr->header, RPMTAG_RELEASE, NULL, (void *) &packageRelease, NULL)) { packageRelease = release; } - /* after the getEntry() these are just pointers into the */ - /* header structure, which can be moved around by addEntry */ + /* after the headerGetEntry() these are just pointers into the */ + /* header structure, which can be moved around by headerAddEntry */ packageVersion = strdup(packageVersion); packageRelease = strdup(packageRelease); /* Figure out the name of this package */ - if (!getEntry(pr->header, RPMTAG_NAME, NULL, (void *)&nametmp, NULL)) { - error(RPMERR_INTERNAL, "Package has no name!"); + if (!headerGetEntry(pr->header, RPMTAG_NAME, NULL, (void *)&nametmp, NULL)) { + rpmError(RPMERR_INTERNAL, "Package has no name!"); return RPMERR_INTERNAL; } sprintf(name, "%s-%s-%s", nametmp, packageVersion, packageRelease); if (doPackage == PACK_PACKAGE) { - message(MESS_VERBOSE, "Binary Packaging: %s\n", name); + rpmMessage(RPMMESS_VERBOSE, "Binary Packaging: %s\n", name); } else { - message(MESS_VERBOSE, "File List Check: %s\n", name); + rpmMessage(RPMMESS_VERBOSE, "File List Check: %s\n", name); } /**** Generate the Header ****/ @@ -455,9 +455,9 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) /* Here's the plan: copy the package's header, */ /* then add entries from the primary header */ /* that don't already exist. */ - outHeader = copyHeader(pr->header); - headerIter = initIterator(s->packages->header); - while (nextIterator(headerIter, &tag, &type, &ptr, &c)) { + outHeader = headerCopy(pr->header); + headerIter = headerInitIterator(s->packages->header); + while (headerNextIterator(headerIter, &tag, &type, &ptr, &c)) { /* Some tags we don't copy */ switch (tag) { case RPMTAG_PREIN: @@ -468,57 +468,57 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) continue; break; /* Shouldn't need this */ default: - if (! isEntry(outHeader, tag)) { - addEntry(outHeader, tag, type, ptr, c); + if (! headerIsEntry(outHeader, tag)) { + headerAddEntry(outHeader, tag, type, ptr, c); } } } - freeIterator(headerIter); + headerFreeIterator(headerIter); /* Add some final entries to the header */ - addEntry(outHeader, RPMTAG_OS, STRING_TYPE, getOsName(), 1); - addEntry(outHeader, RPMTAG_ARCH, STRING_TYPE, getArchName(), 1); - addEntry(outHeader, RPMTAG_BUILDTIME, INT32_TYPE, getBuildTime(), 1); - addEntry(outHeader, RPMTAG_BUILDHOST, STRING_TYPE, buildHost(), 1); - addEntry(outHeader, RPMTAG_SOURCERPM, STRING_TYPE, sourcerpm, 1); - addEntry(outHeader, RPMTAG_RPMVERSION, STRING_TYPE, VERSION, 1); + headerAddEntry(outHeader, RPMTAG_OS, RPM_STRING_TYPE, rpmGetOsName(), 1); + headerAddEntry(outHeader, RPMTAG_ARCH, RPM_STRING_TYPE, rpmGetArchName(), 1); + headerAddEntry(outHeader, RPMTAG_BUILDTIME, RPM_INT32_TYPE, getBuildTime(), 1); + headerAddEntry(outHeader, RPMTAG_BUILDHOST, RPM_STRING_TYPE, buildHost(), 1); + headerAddEntry(outHeader, RPMTAG_SOURCERPM, RPM_STRING_TYPE, sourcerpm, 1); + headerAddEntry(outHeader, RPMTAG_RPMVERSION, RPM_STRING_TYPE, VERSION, 1); if (pr->icon) { - sprintf(filename, "%s/%s", getVar(RPMVAR_SOURCEDIR), pr->icon); + sprintf(filename, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), pr->icon); stat(filename, &statbuf); icon = malloc(statbuf.st_size); iconFD = open(filename, O_RDONLY, 0644); read(iconFD, icon, statbuf.st_size); close(iconFD); if (! strncmp(icon, "GIF", 3)) { - addEntry(outHeader, RPMTAG_GIF, BIN_TYPE, + headerAddEntry(outHeader, RPMTAG_GIF, RPM_BIN_TYPE, icon, statbuf.st_size); } else if (! strncmp(icon, "/* XPM", 6)) { - addEntry(outHeader, RPMTAG_XPM, BIN_TYPE, + headerAddEntry(outHeader, RPMTAG_XPM, RPM_BIN_TYPE, icon, statbuf.st_size); } else { - error(RPMERR_BADSPEC, "Unknown icon type"); + rpmError(RPMERR_BADSPEC, "Unknown icon type"); return 1; } free(icon); } if (vendor) { - addEntry(outHeader, RPMTAG_VENDOR, STRING_TYPE, vendor, 1); + headerAddEntry(outHeader, RPMTAG_VENDOR, RPM_STRING_TYPE, vendor, 1); } if (dist) { - addEntry(outHeader, RPMTAG_DISTRIBUTION, STRING_TYPE, dist, 1); + headerAddEntry(outHeader, RPMTAG_DISTRIBUTION, RPM_STRING_TYPE, dist, 1); } if (packager) { - addEntry(outHeader, RPMTAG_PACKAGER, STRING_TYPE, packager, 1); + headerAddEntry(outHeader, RPMTAG_PACKAGER, RPM_STRING_TYPE, packager, 1); } /**** Process the file list ****/ prefixSave = prefix = NULL; prefixLen = 0; - if (getEntry(outHeader, RPMTAG_DEFAULTPREFIX, + if (headerGetEntry(outHeader, RPMTAG_DEFAULTPREFIX, NULL, (void **)&prefix, NULL)) { - /* after the getEntry() this is just pointers into the */ - /* header structure, which can be moved around by addEntry */ + /* after the headerGetEntry() this is just pointers into the */ + /* header structure, which can be moved around by headerAddEntry */ prefixSave = prefix = strdup(prefix); while (*prefix && (*prefix == '/')) { prefix++; @@ -528,7 +528,7 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) prefixLen = 0; } else { prefixLen = strlen(prefix); - message(MESS_VERBOSE, "Package Prefix = %s\n", prefix); + rpmMessage(RPMMESS_VERBOSE, "Package Prefix = %s\n", prefix); } } @@ -538,7 +538,7 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) return 1; } - if (!getEntry(outHeader, RPMTAG_FILENAMES, NULL, (void **) &farray, + if (!headerGetEntry(outHeader, RPMTAG_FILENAMES, NULL, (void **) &farray, &count)) { /* count may already be 0, but this is safer */ count = 0; @@ -552,7 +552,7 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) } if (prefix) { if (strncmp(prefix, file, prefixLen)) { - error(RPMERR_BADSPEC, "File doesn't match prefix (%s): %s", + rpmError(RPMERR_BADSPEC, "File doesn't match prefix (%s): %s", prefix, file); return 1; } @@ -572,14 +572,14 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) generateTriggerEntries(outHeader, pr); /* And add the final Header entry */ - addEntry(outHeader, RPMTAG_SIZE, INT32_TYPE, &size, 1); + headerAddEntry(outHeader, RPMTAG_SIZE, RPM_INT32_TYPE, &size, 1); /**** Make the RPM ****/ /* Make the output RPM filename */ if (doPackage == PACK_PACKAGE) { - sprintf(filename, "%s/%s/%s.%s.rpm", getVar(RPMVAR_RPMDIR), - getArchName(), name, getArchName()); + sprintf(filename, "%s/%s/%s.%s.rpm", rpmGetVar(RPMVAR_RPMDIR), + rpmGetArchName(), name, rpmGetArchName()); if (generateRPM(name, filename, RPMLEAD_BINARY, outHeader, NULL, getStringBuf(cpioFileList), passPhrase, prefix)) { @@ -589,7 +589,7 @@ int packageBinaries(Spec s, char *passPhrase, int doPackage) } freeStringBuf(cpioFileList); - freeHeader(outHeader); + headerFree(outHeader); if (prefixSave) free(prefixSave); @@ -631,7 +631,7 @@ int packageSource(Spec s, char *passPhrase) /**** Create links for all the sources ****/ - tempdir = tempnam(getVar(RPMVAR_TMPPATH), "rpmbuild"); + tempdir = tempnam(rpmGetVar(RPMVAR_TMPPATH), "rpmbuild"); mkdir(tempdir, 0700); filelist = newStringBuf(); /* List in the header */ @@ -664,13 +664,13 @@ int packageSource(Spec s, char *passPhrase) } skipi--; } - sprintf(src, "%s/%s", getVar(RPMVAR_SOURCEDIR), source->source); + sprintf(src, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), source->source); sprintf(dest, "%s/%s", tempdir, source->source); if (skipi < 0) { symlink(src, dest); appendLineStringBuf(cpioFileList, source->source); } else { - message(MESS_VERBOSE, "Skipping source/patch (%d): %s\n", + rpmMessage(RPMMESS_VERBOSE, "Skipping source/patch (%d): %s\n", source->num, source->source); } appendLineStringBuf(filelist, src); @@ -685,7 +685,7 @@ int packageSource(Spec s, char *passPhrase) package = s->packages; while (package) { if (package->icon) { - sprintf(src, "%s/%s", getVar(RPMVAR_SOURCEDIR), package->icon); + sprintf(src, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), package->icon); sprintf(dest, "%s/%s", tempdir, package->icon); appendLineStringBuf(filelist, dest); appendLineStringBuf(cpioFileList, package->icon); @@ -696,43 +696,43 @@ int packageSource(Spec s, char *passPhrase) /**** Generate the Header ****/ - if (!getEntry(s->packages->header, RPMTAG_VERSION, NULL, + if (!headerGetEntry(s->packages->header, RPMTAG_VERSION, NULL, (void *) &version, NULL)) { - error(RPMERR_BADSPEC, "No version field"); + rpmError(RPMERR_BADSPEC, "No version field"); return RPMERR_BADSPEC; } - if (!getEntry(s->packages->header, RPMTAG_RELEASE, NULL, + if (!headerGetEntry(s->packages->header, RPMTAG_RELEASE, NULL, (void *) &release, NULL)) { - error(RPMERR_BADSPEC, "No release field"); + rpmError(RPMERR_BADSPEC, "No release field"); return RPMERR_BADSPEC; } - outHeader = copyHeader(s->packages->header); - addEntry(outHeader, RPMTAG_OS, STRING_TYPE, getOsName(), 1); - addEntry(outHeader, RPMTAG_ARCH, STRING_TYPE, getArchName(), 1); - addEntry(outHeader, RPMTAG_BUILDTIME, INT32_TYPE, getBuildTime(), 1); - addEntry(outHeader, RPMTAG_BUILDHOST, STRING_TYPE, buildHost(), 1); - addEntry(outHeader, RPMTAG_RPMVERSION, STRING_TYPE, VERSION, 1); + outHeader = headerCopy(s->packages->header); + headerAddEntry(outHeader, RPMTAG_OS, RPM_STRING_TYPE, rpmGetOsName(), 1); + headerAddEntry(outHeader, RPMTAG_ARCH, RPM_STRING_TYPE, rpmGetArchName(), 1); + headerAddEntry(outHeader, RPMTAG_BUILDTIME, RPM_INT32_TYPE, getBuildTime(), 1); + headerAddEntry(outHeader, RPMTAG_BUILDHOST, RPM_STRING_TYPE, buildHost(), 1); + headerAddEntry(outHeader, RPMTAG_RPMVERSION, RPM_STRING_TYPE, VERSION, 1); if (scount) - addEntry(outHeader, RPMTAG_SOURCE, STRING_ARRAY_TYPE, sources, scount); + headerAddEntry(outHeader, RPMTAG_SOURCE, RPM_STRING_ARRAY_TYPE, sources, scount); if (pcount) - addEntry(outHeader, RPMTAG_PATCH, STRING_ARRAY_TYPE, patches, pcount); + headerAddEntry(outHeader, RPMTAG_PATCH, RPM_STRING_ARRAY_TYPE, patches, pcount); if (s->numNoSource) { - addEntry(outHeader, RPMTAG_NOSOURCE, INT32_TYPE, s->noSource, + headerAddEntry(outHeader, RPMTAG_NOSOURCE, RPM_INT32_TYPE, s->noSource, s->numNoSource); } if (s->numNoPatch) { - addEntry(outHeader, RPMTAG_NOPATCH, INT32_TYPE, s->noPatch, + headerAddEntry(outHeader, RPMTAG_NOPATCH, RPM_INT32_TYPE, s->noPatch, s->numNoPatch); } - if (!isEntry(s->packages->header, RPMTAG_VENDOR)) { - if ((vendor = getVar(RPMVAR_VENDOR))) { - addEntry(outHeader, RPMTAG_VENDOR, STRING_TYPE, vendor, 1); + if (!headerIsEntry(s->packages->header, RPMTAG_VENDOR)) { + if ((vendor = rpmGetVar(RPMVAR_VENDOR))) { + headerAddEntry(outHeader, RPMTAG_VENDOR, RPM_STRING_TYPE, vendor, 1); } } - if (!isEntry(s->packages->header, RPMTAG_DISTRIBUTION)) { - if ((dist = getVar(RPMVAR_DISTRIBUTION))) { - addEntry(outHeader, RPMTAG_DISTRIBUTION, STRING_TYPE, dist, 1); + if (!headerIsEntry(s->packages->header, RPMTAG_DISTRIBUTION)) { + if ((dist = rpmGetVar(RPMVAR_DISTRIBUTION))) { + headerAddEntry(outHeader, RPMTAG_DISTRIBUTION, RPM_STRING_TYPE, dist, 1); } } @@ -744,14 +744,14 @@ int packageSource(Spec s, char *passPhrase) } /* And add the final Header entry */ - addEntry(outHeader, RPMTAG_SIZE, INT32_TYPE, &size, 1); + headerAddEntry(outHeader, RPMTAG_SIZE, RPM_INT32_TYPE, &size, 1); /**** Make the RPM ****/ sprintf(fullname, "%s-%s-%s", s->name, version, release); - sprintf(filename, "%s/%s.%ssrc.rpm", getVar(RPMVAR_SRPMDIR), fullname, + sprintf(filename, "%s/%s.%ssrc.rpm", rpmGetVar(RPMVAR_SRPMDIR), fullname, (s->numNoPatch + s->numNoSource) ? "no" : ""); - message(MESS_VERBOSE, "Source Packaging: %s\n", fullname); + rpmMessage(RPMMESS_VERBOSE, "Source Packaging: %s\n", fullname); if (generateRPM(fullname, filename, RPMLEAD_SOURCE, outHeader, tempdir, getStringBuf(cpioFileList), passPhrase, NULL)) { diff --git a/build/reqprov.c b/build/reqprov.c index 9b0091ef0..ff9fc0f80 100644 --- a/build/reqprov.c +++ b/build/reqprov.c @@ -15,7 +15,6 @@ #include "reqprov.h" #include "messages.h" #include "rpmlib.h" -#include "rpmerr.h" #include "misc.h" static StringBuf getOutputFrom(char *dir, char *argv[], @@ -57,7 +56,7 @@ int addReqProv(struct PackageRec *p, int flags, } if (rd) { /* already there */ - message(MESS_DEBUG, "Already Got: %s\n", name); + rpmMessage(RPMMESS_DEBUG, "Already Got: %s\n", name); return 0; } @@ -68,14 +67,14 @@ int addReqProv(struct PackageRec *p, int flags, rd->next = p->reqprov; p->reqprov = rd; - if (flags & REQUIRE_PROVIDES) { - message(MESS_DEBUG, "Adding provide: %s\n", name); + if (flags & RPMSENSE_PROVIDES) { + rpmMessage(RPMMESS_DEBUG, "Adding provide: %s\n", name); p->numProv++; - } else if (flags & REQUIRE_CONFLICTS) { - message(MESS_DEBUG, "Adding conflict: %s\n", name); + } else if (flags & RPMSENSE_CONFLICTS) { + rpmMessage(RPMMESS_DEBUG, "Adding conflict: %s\n", name); p->numConflict++; } else { - message(MESS_DEBUG, "Adding require: %s\n", name); + rpmMessage(RPMMESS_DEBUG, "Adding require: %s\n", name); p->numReq++; } @@ -121,11 +120,11 @@ static StringBuf getOutputFrom(char *dir, char *argv[], chdir(dir); execvp(argv[0], argv); - error(RPMERR_EXEC, "Couldn't exec %s", argv[0]); + rpmError(RPMERR_EXEC, "Couldn't exec %s", argv[0]); exit(RPMERR_EXEC); } if (progPID < 0) { - error(RPMERR_FORK, "Couldn't fork %s", argv[0]); + rpmError(RPMERR_FORK, "Couldn't fork %s", argv[0]); return NULL; } @@ -177,12 +176,12 @@ static StringBuf getOutputFrom(char *dir, char *argv[], signal(SIGPIPE, oldhandler); if (writeBytesLeft) { - error(RPMERR_EXEC, "failed to write all data to %s", argv[0]); + rpmError(RPMERR_EXEC, "failed to write all data to %s", argv[0]); return NULL; } waitpid(progPID, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status)) { - error(RPMERR_EXEC, "%s failed", argv[0]); + rpmError(RPMERR_EXEC, "%s failed", argv[0]); return NULL; } @@ -202,26 +201,26 @@ int generateAutoReqProv(Header header, struct PackageRec *p) char dir[1024]; char *argv[8]; - message(MESS_VERBOSE, "Finding dependencies...\n"); + rpmMessage(RPMMESS_VERBOSE, "Finding dependencies...\n"); /*** Get root directory ***/ - if (getVar(RPMVAR_ROOT)) { - strcpy(dir, getVar(RPMVAR_ROOT)); + if (rpmGetVar(RPMVAR_ROOT)) { + strcpy(dir, rpmGetVar(RPMVAR_ROOT)); } else { strcpy(dir, "/"); } /*** Generate File List ***/ - if (!getEntry(header, RPMTAG_FILENAMES, NULL, (void **) &f, &count)) { + if (!headerGetEntry(header, RPMTAG_FILENAMES, NULL, (void **) &f, &count)) { return 0; } if (!count) { return 0; } fsave = f; - getEntry(header, RPMTAG_FILEMODES, NULL, (void **) &modes, NULL); + headerGetEntry(header, RPMTAG_FILEMODES, NULL, (void **) &modes, NULL); writeBuff = newStringBuf(); writeBytes = 0; @@ -244,7 +243,7 @@ int generateAutoReqProv(Header header, struct PackageRec *p) argv[1] = NULL; readBuff = getOutputFrom(dir, argv, writePtr, writeBytes); if (!readBuff) { - error(RPMERR_EXEC, "Failed to find provides"); + rpmError(RPMERR_EXEC, "Failed to find provides"); exit(1); } @@ -253,7 +252,7 @@ int generateAutoReqProv(Header header, struct PackageRec *p) freeStringBuf(readBuff); while (*f) { if (**f) { - addReqProv(p, REQUIRE_PROVIDES, *f, NULL); + addReqProv(p, RPMSENSE_PROVIDES, *f, NULL); } f++; } @@ -276,7 +275,7 @@ int generateAutoReqProv(Header header, struct PackageRec *p) argv[3] = NULL; readBuff = getOutputFrom(dir, argv, writePtr, writeBytes); if (!readBuff) { - error(RPMERR_EXEC, "Failed to find requires"); + rpmError(RPMERR_EXEC, "Failed to find requires"); exit(1); } @@ -297,7 +296,7 @@ int generateAutoReqProv(Header header, struct PackageRec *p) if ((s = strrchr(tok, '/'))) { tok = s + 1; } - addReqProv(p, REQUIRE_ANY, tok, NULL); + addReqProv(p, RPMSENSE_ANY, tok, NULL); } f++; @@ -328,17 +327,17 @@ int processReqProv(Header h, struct PackageRec *p) if (p->numProv) { rd = p->reqprov; nameArray = namePtr = malloc(p->numProv * sizeof(*nameArray)); - message(MESS_VERBOSE, "Provides (%d):", p->numProv); + rpmMessage(RPMMESS_VERBOSE, "Provides (%d):", p->numProv); while (rd) { - if (rd->flags & REQUIRE_PROVIDES) { - message(MESS_VERBOSE, " %s", rd->name); + if (rd->flags & RPMSENSE_PROVIDES) { + rpmMessage(RPMMESS_VERBOSE, " %s", rd->name); *namePtr++ = rd->name; } rd = rd->next; } - message(MESS_VERBOSE, "\n"); + rpmMessage(RPMMESS_VERBOSE, "\n"); - addEntry(h, RPMTAG_PROVIDES, STRING_ARRAY_TYPE, nameArray, p->numProv); + headerAddEntry(h, RPMTAG_PROVIDES, RPM_STRING_ARRAY_TYPE, nameArray, p->numProv); free(nameArray); } @@ -348,23 +347,23 @@ int processReqProv(Header h, struct PackageRec *p) versionArray = versionPtr = malloc(p->numConflict * sizeof(*versionArray)); flagArray = flagPtr = malloc(p->numConflict * sizeof(*flagArray)); - message(MESS_VERBOSE, "Conflicts (%d):", p->numConflict); + rpmMessage(RPMMESS_VERBOSE, "Conflicts (%d):", p->numConflict); while (rd) { - if (rd->flags & REQUIRE_CONFLICTS) { - message(MESS_VERBOSE, " %s", rd->name); + if (rd->flags & RPMSENSE_CONFLICTS) { + rpmMessage(RPMMESS_VERBOSE, " %s", rd->name); *namePtr++ = rd->name; *versionPtr++ = rd->version ? rd->version : ""; - *flagPtr++ = rd->flags & REQUIRE_SENSEMASK; + *flagPtr++ = rd->flags & RPMSENSE_SENSEMASK; } rd = rd->next; } - message(MESS_VERBOSE, "\n"); + rpmMessage(RPMMESS_VERBOSE, "\n"); - addEntry(h, RPMTAG_CONFLICTNAME, STRING_ARRAY_TYPE, + headerAddEntry(h, RPMTAG_CONFLICTNAME, RPM_STRING_ARRAY_TYPE, nameArray, p->numConflict); - addEntry(h, RPMTAG_CONFLICTVERSION, STRING_ARRAY_TYPE, + headerAddEntry(h, RPMTAG_CONFLICTVERSION, RPM_STRING_ARRAY_TYPE, versionArray, p->numConflict); - addEntry(h, RPMTAG_CONFLICTFLAGS, INT32_TYPE, + headerAddEntry(h, RPMTAG_CONFLICTFLAGS, RPM_INT32_TYPE, flagArray, p->numConflict); free(nameArray); @@ -377,24 +376,24 @@ int processReqProv(Header h, struct PackageRec *p) nameArray = namePtr = malloc(p->numReq * sizeof(*nameArray)); versionArray = versionPtr = malloc(p->numReq * sizeof(*versionArray)); flagArray = flagPtr = malloc(p->numReq * sizeof(*flagArray)); - message(MESS_VERBOSE, "Requires (%d):", p->numReq); + rpmMessage(RPMMESS_VERBOSE, "Requires (%d):", p->numReq); while (rd) { - if (! ((rd->flags & REQUIRE_PROVIDES) || - (rd->flags & REQUIRE_CONFLICTS))) { - message(MESS_VERBOSE, " %s", rd->name); + if (! ((rd->flags & RPMSENSE_PROVIDES) || + (rd->flags & RPMSENSE_CONFLICTS))) { + rpmMessage(RPMMESS_VERBOSE, " %s", rd->name); *namePtr++ = rd->name; *versionPtr++ = rd->version ? rd->version : ""; - *flagPtr++ = rd->flags & REQUIRE_SENSEMASK; + *flagPtr++ = rd->flags & RPMSENSE_SENSEMASK; } rd = rd->next; } - message(MESS_VERBOSE, "\n"); + rpmMessage(RPMMESS_VERBOSE, "\n"); - addEntry(h, RPMTAG_REQUIRENAME, STRING_ARRAY_TYPE, + headerAddEntry(h, RPMTAG_REQUIRENAME, RPM_STRING_ARRAY_TYPE, nameArray, p->numReq); - addEntry(h, RPMTAG_REQUIREVERSION, STRING_ARRAY_TYPE, + headerAddEntry(h, RPMTAG_REQUIREVERSION, RPM_STRING_ARRAY_TYPE, versionArray, p->numReq); - addEntry(h, RPMTAG_REQUIREFLAGS, INT32_TYPE, + headerAddEntry(h, RPMTAG_REQUIREFLAGS, RPM_INT32_TYPE, flagArray, p->numReq); free(nameArray); diff --git a/build/spec.c b/build/spec.c index 90851f54b..623bd891a 100644 --- a/build/spec.c +++ b/build/spec.c @@ -21,7 +21,6 @@ TODO: #include "header.h" #include "spec.h" #include "specP.h" -#include "rpmerr.h" #include "messages.h" #include "rpmlib.h" #include "stringbuf.h" @@ -81,7 +80,7 @@ static int addSource(Spec spec, char *line) p->ispatch = 1; s = line + 5; } else { - error(RPMERR_BADSPEC, "Not a source/patch line: %s\n", line); + rpmError(RPMERR_BADSPEC, "Not a source/patch line: %s\n", line); return(RPMERR_BADSPEC); } @@ -90,7 +89,7 @@ static int addSource(Spec spec, char *line) if (*s != ':') { x = strspn(s, "0123456789"); if (! x) { - error(RPMERR_BADSPEC, "Bad source/patch line: %s\n", line); + rpmError(RPMERR_BADSPEC, "Bad source/patch line: %s\n", line); return(RPMERR_BADSPEC); } c = s[x]; @@ -99,7 +98,7 @@ static int addSource(Spec spec, char *line) p->num = strtoul(s, &s1, 10); if ((*s1) || (s1 == s) || (p->num == ULONG_MAX)) { s[x] = c; - error(RPMERR_BADSPEC, "Bad source/patch number: %s\n", s); + rpmError(RPMERR_BADSPEC, "Bad source/patch number: %s\n", s); return(RPMERR_BADSPEC); } s[x] = c; @@ -109,7 +108,7 @@ static int addSource(Spec spec, char *line) } if (*s != ':') { - error(RPMERR_BADSPEC, "Bad source/patch line: %s\n", line); + rpmError(RPMERR_BADSPEC, "Bad source/patch line: %s\n", line); return(RPMERR_BADSPEC); } @@ -119,7 +118,7 @@ static int addSource(Spec spec, char *line) file = strtok(s, " \t\n"); if (! file) { - error(RPMERR_BADSPEC, "Bad source/patch line: %s\n", line); + rpmError(RPMERR_BADSPEC, "Bad source/patch line: %s\n", line); return(RPMERR_BADSPEC); } p->fullSource = strdup(file); @@ -131,9 +130,9 @@ static int addSource(Spec spec, char *line) } if (p->ispatch) { - message(MESS_DEBUG, "Patch(%d) = %s\n", p->num, p->fullSource); + rpmMessage(RPMMESS_DEBUG, "Patch(%d) = %s\n", p->num, p->fullSource); } else { - message(MESS_DEBUG, "Source(%d) = %s\n", p->num, p->fullSource); + rpmMessage(RPMMESS_DEBUG, "Source(%d) = %s\n", p->num, p->fullSource); } return 0; @@ -201,7 +200,7 @@ int noSourcePatch(Spec s, char *line, int_32 tag) if (((tag == RPMTAG_NOSOURCE) && s->numNoSource) || ((tag == RPMTAG_NOPATCH) && s->numNoPatch)) { - error(RPMERR_BADSPEC, "Only one nosource/nopatch line allowed\n"); + rpmError(RPMERR_BADSPEC, "Only one nosource/nopatch line allowed\n"); return(RPMERR_BADSPEC); } @@ -209,11 +208,11 @@ int noSourcePatch(Spec s, char *line, int_32 tag) while ((t = strtok(line, ", \t"))) { num = strtoul(t, &te, 10); if ((*te) || (te == t) || (num == ULONG_MAX)) { - error(RPMERR_BADSPEC, "Bad source/patch number: %s\n", t); + rpmError(RPMERR_BADSPEC, "Bad source/patch number: %s\n", t); return(RPMERR_BADSPEC); } array[count++] = num; - message(MESS_DEBUG, "Skipping source/patch number: %d\n", num); + rpmMessage(RPMMESS_DEBUG, "Skipping source/patch number: %d\n", num); line = NULL; } @@ -252,22 +251,22 @@ static void free_reqprov(struct ReqProv *p) } struct ReqComp ReqComparisons[] = { - { "<=", REQUIRE_LESS | REQUIRE_EQUAL}, - { "<=S", REQUIRE_LESS | REQUIRE_EQUAL | REQUIRE_SERIAL}, - { "=<", REQUIRE_LESS | REQUIRE_EQUAL}, - { "==", REQUIRE_GREATER | REQUIRE_EQUAL}, - { ">=S", REQUIRE_GREATER | REQUIRE_EQUAL | REQUIRE_SERIAL}, - { "=>", REQUIRE_GREATER | REQUIRE_EQUAL}, - { "=>S", REQUIRE_GREATER | REQUIRE_EQUAL | REQUIRE_SERIAL}, - { ">", REQUIRE_GREATER}, - { ">S", REQUIRE_GREATER | REQUIRE_SERIAL}, + { ">=", RPMSENSE_GREATER | RPMSENSE_EQUAL}, + { ">=S", RPMSENSE_GREATER | RPMSENSE_EQUAL | RPMSENSE_SERIAL}, + { "=>", RPMSENSE_GREATER | RPMSENSE_EQUAL}, + { "=>S", RPMSENSE_GREATER | RPMSENSE_EQUAL | RPMSENSE_SERIAL}, + { ">", RPMSENSE_GREATER}, + { ">S", RPMSENSE_GREATER | RPMSENSE_SERIAL}, { NULL, 0 }, }; @@ -281,7 +280,7 @@ static int parseRequiresConflicts(struct PackageRec *p, char *line, while (req || (req = strtok(line, " ,\t\n"))) { flags = (flag == RPMTAG_CONFLICTFLAGS) ? - REQUIRE_CONFLICTS : REQUIRE_ANY; + RPMSENSE_CONFLICTS : RPMSENSE_ANY; if ((version = strtok(NULL, " ,\t\n"))) { rc = ReqComparisons; while (rc->token && strcmp(version, rc->token)) { @@ -293,8 +292,8 @@ static int parseRequiresConflicts(struct PackageRec *p, char *line, version = strtok(NULL, " ,\t\n"); } } - if ((flags & REQUIRE_SENSEMASK) && !version) { - error(RPMERR_BADSPEC, "Version required in require/conflict"); + if ((flags & RPMSENSE_SENSEMASK) && !version) { + rpmError(RPMERR_BADSPEC, "Version required in require/conflict"); return RPMERR_BADSPEC; } @@ -314,7 +313,7 @@ static int parseRequiresConflicts(struct PackageRec *p, char *line, static int parseProvides(struct PackageRec *p, char *line) { char *prov; - int flags = REQUIRE_PROVIDES; + int flags = RPMSENSE_PROVIDES; while ((prov = strtok(line, " ,\t\n"))) { addReqProv(p, flags, prov, NULL); @@ -336,7 +335,7 @@ static struct PackageRec *new_packagerec(void) p->subname = NULL; p->newname = NULL; p->icon = NULL; - p->header = newHeader(); + p->header = headerNew(); p->filelist = newStringBuf(); p->files = -1; /* -1 means no %files, thus no package */ p->fileFile = NULL; @@ -357,7 +356,7 @@ static struct PackageRec *new_packagerec(void) void free_packagerec(struct PackageRec *p) { - freeHeader(p->header); + headerFree(p->header); freeStringBuf(p->filelist); freeStringBuf(p->doc); FREE(p->subname); @@ -469,9 +468,9 @@ static void generateNamesAndDocScript(Spec s) char fullname[1024]; char *name, *version, *release, *packageVersion, *packageRelease, *docs; - getEntry(s->packages->header, RPMTAG_VERSION, NULL, + headerGetEntry(s->packages->header, RPMTAG_VERSION, NULL, (void *) &version, NULL); - getEntry(s->packages->header, RPMTAG_RELEASE, NULL, + headerGetEntry(s->packages->header, RPMTAG_RELEASE, NULL, (void *) &release, NULL); package = s->packages; @@ -485,14 +484,14 @@ static void generateNamesAndDocScript(Spec s) /* Must be the main package */ name = s->name; } - addEntry(package->header, RPMTAG_NAME, STRING_TYPE, name, 1); + headerAddEntry(package->header, RPMTAG_NAME, RPM_STRING_TYPE, name, 1); /* Handle subpackage version/release overrides */ - if (!getEntry(package->header, RPMTAG_VERSION, NULL, + if (!headerGetEntry(package->header, RPMTAG_VERSION, NULL, (void *) &packageVersion, NULL)) { packageVersion = version; } - if (!getEntry(package->header, RPMTAG_RELEASE, NULL, + if (!headerGetEntry(package->header, RPMTAG_RELEASE, NULL, (void *) &packageRelease, NULL)) { packageRelease = release; } @@ -522,7 +521,7 @@ static int match_arch(char *s) char *tok, *arch; int sense, match; - arch = getArchName(); + arch = rpmGetArchName(); match = 0; tok = strtok(s, " \n\t"); @@ -542,7 +541,7 @@ static int match_os(char *s) char *tok, *os; int sense, match; - os = getOsName(); + os = rpmGetOsName(); match = 0; tok = strtok(s, " \n\t"); @@ -573,7 +572,7 @@ static int read_line(FILE *f, char *line) if (! fgets(line, LINE_BUF_SIZE, f)) { /* the end */ if (read_level->next) { - error(RPMERR_UNMATCHEDIF, "Unclosed %%if"); + rpmError(RPMERR_UNMATCHEDIF, "Unclosed %%if"); return RPMERR_UNMATCHEDIF; } else { return 0; @@ -594,14 +593,14 @@ static int read_line(FILE *f, char *line) } else if (! strncmp("%else", line, 5)) { if (! read_level->next) { /* Got an else with no %if ! */ - error(RPMERR_UNMATCHEDIF, "Got a %%else with no if"); + rpmError(RPMERR_UNMATCHEDIF, "Got a %%else with no if"); return RPMERR_UNMATCHEDIF; } read_level->reading = read_level->next->reading && ! read_level->reading; } else if (! strncmp("%endif", line, 6)) { if (! read_level->next) { - error(RPMERR_UNMATCHEDIF, "Got a %%endif with no if"); + rpmError(RPMERR_UNMATCHEDIF, "Got a %%endif with no if"); return RPMERR_UNMATCHEDIF; } rl = read_level; @@ -775,7 +774,7 @@ static void addListEntry(Header h, int_32 tag, char *line) line = NULL; } if (argc) { - addEntry(h, tag, STRING_ARRAY_TYPE, argvs, argc); + headerAddEntry(h, tag, RPM_STRING_ARRAY_TYPE, argvs, argc); } free(argvs); } @@ -852,7 +851,7 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) line = buf; s = NULL; if ((tag = check_part(line, &s))) { - message(MESS_DEBUG, "Switching to part: %d\n", tag); + rpmMessage(RPMMESS_DEBUG, "Switching to part: %d\n", tag); t1 = 0; switch (cur_part) { case PREIN_PART: @@ -880,25 +879,25 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) /* %changelog is a little special. It goes in the */ /* "main" package no matter where it appears, and it */ /* ends up in all the packages. */ - addEntry(spec->packages->header, RPMTAG_CHANGELOG, STRING_TYPE, + headerAddEntry(spec->packages->header, RPMTAG_CHANGELOG, RPM_STRING_TYPE, getStringBuf(sb), 1); break; case TRIGGERON_PART: - if (addTrigger(cur_package, TRIGGER_ON, + if (addTrigger(cur_package, RPMSENSE_TRIGGER_ON, getStringBuf(sb), triggerArgs)) { return NULL; } break; case TRIGGEROFF_PART: - if (addTrigger(cur_package, TRIGGER_OFF, + if (addTrigger(cur_package, RPMSENSE_TRIGGER_OFF, getStringBuf(sb), triggerArgs)) { return NULL; } break; } if (t1) { - addEntry(cur_package->header, t1, - STRING_TYPE, getStringBuf(sb), 1); + headerAddEntry(cur_package->header, t1, + RPM_STRING_TYPE, getStringBuf(sb), 1); } cur_part = tag; truncStringBuf(sb); @@ -911,7 +910,7 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) case INSTALL_PART: case CLEAN_PART: case CHANGELOG_PART: - error(RPMERR_BADARG, "Tag takes no arguments: %s", s); + rpmError(RPMERR_BADARG, "Tag takes no arguments: %s", s); return NULL; } } @@ -950,7 +949,7 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) } } - message(MESS_DEBUG, "fileFile = %s\n", + rpmMessage(RPMMESS_DEBUG, "fileFile = %s\n", fileFile[0] ? fileFile : "(null)"); /* If trigger, pull off the args */ @@ -973,7 +972,7 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) s += 2; s += strspn(s, ": \t"); if (*s == '\0') { - error(RPMERR_BADARG, "-n takes argument"); + rpmError(RPMERR_BADARG, "-n takes argument"); return NULL; } lookupopts = LP_NEWNAME; @@ -1003,10 +1002,10 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) default: /* XXX - should be able to drop the -n in non-%package parts */ if (! lookup_package(spec, &cur_package, s, lookupopts)) { - error(RPMERR_INTERNAL, "Package lookup failed: %s", s); + rpmError(RPMERR_INTERNAL, "Package lookup failed: %s", s); return NULL; } - message(MESS_DEBUG, "Switched to package: %s\n", + rpmMessage(RPMMESS_DEBUG, "Switched to package: %s\n", s ? s : "(main)"); } @@ -1030,10 +1029,10 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) lookupopts = LP_CREATE | LP_FAIL_EXISTS; } if (! lookup_package(spec, &cur_package, NULL, lookupopts)) { - error(RPMERR_INTERNAL, "Base package lookup failed!"); + rpmError(RPMERR_INTERNAL, "Base package lookup failed!"); return NULL; } - message(MESS_DEBUG, "Switched to BASE package\n"); + rpmMessage(RPMMESS_DEBUG, "Switched to BASE package\n"); } switch (cur_part) { @@ -1042,14 +1041,14 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) switch (tag) { case RPMTAG_EXCLUDE: case RPMTAG_EXCLUSIVE: - message(MESS_WARNING, + rpmMessage(RPMMESS_WARNING, "Exclude/Exclusive are depricated.\n" "Use ExcludeArch/ExclusiveArch instead.\n"); sprintf(buf2, "%s %s", (tag == RPMTAG_EXCLUDE) ? "%ifarch" : "%ifnarch", s); if (match_arch(buf2)) { - error(RPMERR_BADARCH, "Arch mismatch!"); + rpmError(RPMERR_BADARCH, "Arch mismatch!"); return NULL; } addListEntry(cur_package->header, @@ -1062,7 +1061,7 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) sprintf(buf2, "%s %s", (tag == RPMTAG_EXCLUDEARCH) ? "%ifarch" : "%ifnarch", s); if (match_arch(buf2)) { - error(RPMERR_BADARCH, "Arch mismatch!"); + rpmError(RPMERR_BADARCH, "Arch mismatch!"); return NULL; } addListEntry(cur_package->header, tag, s); @@ -1072,7 +1071,7 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) sprintf(buf2, "%s %s", (tag == RPMTAG_EXCLUDEOS) ? "%ifos" : "%ifnos", s); if (match_os(buf2)) { - error(RPMERR_BADOS, "OS mismatch!"); + rpmError(RPMERR_BADOS, "OS mismatch!"); return NULL; } addListEntry(cur_package->header, tag, s); @@ -1099,18 +1098,18 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) case RPMTAG_PACKAGER: case RPMTAG_GROUP: case RPMTAG_URL: - addEntry(cur_package->header, tag, STRING_TYPE, s, 1); + headerAddEntry(cur_package->header, tag, RPM_STRING_TYPE, s, 1); break; case RPMTAG_BUILDROOT: gotBuildroot = 1; spec->buildroot = strdup(s); break; case RPMTAG_DEFAULTPREFIX: - addEntry(cur_package->header, tag, STRING_TYPE, s, 1); + headerAddEntry(cur_package->header, tag, RPM_STRING_TYPE, s, 1); break; case RPMTAG_SERIAL: serial = atoi(s); - addEntry(cur_package->header, tag, INT32_TYPE, &serial, 1); + headerAddEntry(cur_package->header, tag, RPM_INT32_TYPE, &serial, 1); break; case RPMTAG_DESCRIPTION: /* Special case -- need to handle backslash */ @@ -1126,15 +1125,15 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) s = buf; } appendStringBuf(sb, s); - addEntry(cur_package->header, RPMTAG_DESCRIPTION, - STRING_TYPE, getStringBuf(sb), 1); + headerAddEntry(cur_package->header, RPMTAG_DESCRIPTION, + RPM_STRING_TYPE, getStringBuf(sb), 1); break; case RPMTAG_ROOT: /* special case */ gotRoot = 1; - message(MESS_DEBUG, "Got root: %s\n", s); - message(MESS_WARNING, "The Root: tag is depricated. Use Buildroot: instead\n"); - setVar(RPMVAR_ROOT, s); + rpmMessage(RPMMESS_DEBUG, "Got root: %s\n", s); + rpmMessage(RPMMESS_WARNING, "The Root: tag is depricated. Use Buildroot: instead\n"); + rpmSetVar(RPMVAR_ROOT, s); break; case RPMTAG_ICON: cur_package->icon = strdup(s); @@ -1177,9 +1176,9 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) } break; default: - /* message(MESS_DEBUG, "Skipping: %s\n", line); */ + /* rpmMessage(RPMMESS_DEBUG, "Skipping: %s\n", line); */ /* This shouldn't happen? */ - error(RPMERR_INTERNAL, "Bogus token"); + rpmError(RPMERR_INTERNAL, "Bogus token"); return NULL; } } else { @@ -1188,8 +1187,8 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) while (*s1 && (*s1 == ' ' || *s1 == '\t')) s1++; /* Handle blanks lines and comments */ if (*s1 && (*s1 != '#')) { - /*message(MESS_WARNING, "Unknown Field: %s\n", line);*/ - error(RPMERR_BADSPEC, "Unknown Field: %s\n", line); + /*rpmMessage(RPMMESS_WARNING, "Unknown Field: %s\n", line);*/ + rpmError(RPMERR_BADSPEC, "Unknown Field: %s\n", line); return NULL; } } @@ -1230,7 +1229,7 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) } break; default: - error(RPMERR_INTERNAL, "Bad part"); + rpmError(RPMERR_INTERNAL, "Bad part"); return NULL; } /* switch */ } @@ -1240,30 +1239,30 @@ Spec parseSpec(FILE *f, char *specfile, char *buildRootOverride) if (gotRoot && gotBuildroot) { freeSpec(spec); - error(RPMERR_BADSPEC, + rpmError(RPMERR_BADSPEC, "Spec file can not have both Root: and Buildroot:"); return NULL; } if (spec->buildroot) { /* This package can do build roots */ if (buildRootOverride) { - setVar(RPMVAR_ROOT, buildRootOverride); - setVar(RPMVAR_BUILDROOT, buildRootOverride); + rpmSetVar(RPMVAR_ROOT, buildRootOverride); + rpmSetVar(RPMVAR_BUILDROOT, buildRootOverride); } else { - if ((s = getVar(RPMVAR_BUILDROOT))) { + if ((s = rpmGetVar(RPMVAR_BUILDROOT))) { /* Take build prefix from rpmrc */ - setVar(RPMVAR_ROOT, s); + rpmSetVar(RPMVAR_ROOT, s); } else { /* Use default */ - setVar(RPMVAR_ROOT, spec->buildroot); - setVar(RPMVAR_BUILDROOT, spec->buildroot); + rpmSetVar(RPMVAR_ROOT, spec->buildroot); + rpmSetVar(RPMVAR_BUILDROOT, spec->buildroot); } } } else { /* Package can not do build prefixes */ if (buildRootOverride) { freeSpec(spec); - error(RPMERR_BADARG, "Package can not do build prefixes"); + rpmError(RPMERR_BADARG, "Package can not do build prefixes"); return NULL; } } @@ -1285,7 +1284,7 @@ static void reset_spec() struct preamble_line *p = preamble_spec; struct part_rec *p1 = part_list; - setVar(RPMVAR_ROOT, NULL); + rpmSetVar(RPMVAR_ROOT, NULL); while (read_level) { rl = read_level; @@ -1353,7 +1352,7 @@ static void dumpPackage(struct PackageRec *p, FILE *f) fprintf(f, "%s", getStringBuf(p->filelist)); fprintf(f, "FILES =^\n"); fprintf(f, "HEADER =v\n"); - dumpHeader(p->header, f, 1); + headerDump(p->header, f, 1); fprintf(f, "HEADER =^\n"); } diff --git a/build/trigger.c b/build/trigger.c index 5f9242c4c..a2c117ff0 100644 --- a/build/trigger.c +++ b/build/trigger.c @@ -7,7 +7,6 @@ #include "header.h" #include "spec.h" #include "specP.h" -#include "rpmerr.h" #include "messages.h" #include "rpmlib.h" #include "stringbuf.h" @@ -36,7 +35,7 @@ int addTrigger(struct PackageRec *package, sizeof(*(package->trigger.triggerScripts))); } package->trigger.triggerScripts[i] = strdup(script); - message(MESS_DEBUG, "TRIGGER %d:\n%s", i, script); + rpmMessage(RPMMESS_DEBUG, "TRIGGER %d:\n%s", i, script); /* create the entry (or entries) */ te = NULL; @@ -56,16 +55,16 @@ int addTrigger(struct PackageRec *package, version = strtok(NULL, " ,\t\n"); } } - if ((te->flags & REQUIRE_SENSEMASK) && !version) { - error(RPMERR_BADSPEC, "Version required in trigger"); + if ((te->flags & RPMSENSE_SENSEMASK) && !version) { + rpmError(RPMERR_BADSPEC, "Version required in trigger"); return RPMERR_BADSPEC; } te->name = strdup(arg); te->version = (rc && rc->token && version) ? strdup(version) : NULL; te->index = i; - message(MESS_DEBUG, "TRIGGER(%s): %s %s %s %d\n", - (sense == TRIGGER_ON) ? "on" : "off", + rpmMessage(RPMMESS_DEBUG, "TRIGGER(%s): %s %s %s %d\n", + (sense == RPMSENSE_TRIGGER_ON) ? "on" : "off", te->name, (rc && rc->token) ? rc->token : "NONE", te->version, te->index); @@ -100,7 +99,7 @@ void generateTriggerEntries(Header h, struct PackageRec *p) /* Add the scripts */ if (p->trigger.used) { - addEntry(h, RPMTAG_TRIGGERSCRIPTS, STRING_ARRAY_TYPE, + headerAddEntry(h, RPMTAG_TRIGGERSCRIPTS, RPM_STRING_ARRAY_TYPE, p->trigger.triggerScripts, p->trigger.used); } @@ -122,10 +121,10 @@ void generateTriggerEntries(Header h, struct PackageRec *p) te = te->next; } - addEntry(h, RPMTAG_TRIGGERNAME, STRING_ARRAY_TYPE, nameArray, i); - addEntry(h, RPMTAG_TRIGGERVERSION, STRING_ARRAY_TYPE, versionArray, i); - addEntry(h, RPMTAG_TRIGGERFLAGS, INT32_TYPE, flagArray, i); - addEntry(h, RPMTAG_TRIGGERINDEX, INT32_TYPE, indexArray, i); + headerAddEntry(h, RPMTAG_TRIGGERNAME, RPM_STRING_ARRAY_TYPE, nameArray, i); + headerAddEntry(h, RPMTAG_TRIGGERVERSION, RPM_STRING_ARRAY_TYPE, versionArray, i); + headerAddEntry(h, RPMTAG_TRIGGERFLAGS, RPM_INT32_TYPE, flagArray, i); + headerAddEntry(h, RPMTAG_TRIGGERINDEX, RPM_INT32_TYPE, indexArray, i); } void freeTriggers(struct TriggerStruct t) diff --git a/build/vspec.c b/build/vspec.c index 08b50db7c..68cb5e241 100644 --- a/build/vspec.c +++ b/build/vspec.c @@ -22,7 +22,6 @@ Here's what we do #include "header.h" #include "spec.h" #include "specP.h" -#include "rpmerr.h" #include "messages.h" #include "rpmlib.h" #include "stringbuf.h" @@ -121,13 +120,13 @@ static int checkHeaderTags(Header inh, struct packageFieldsRec *pfr) struct packageFieldsRec *p; /* This actually sorts the index, so it'll be easy to catch dups */ - h = copyHeader(inh); + h = headerCopy(inh); - headerIter = initIterator(h); + headerIter = headerInitIterator(h); lastTag = 0; - while (nextIterator(headerIter, &tag, &type, &ptr, &c)) { + while (headerNextIterator(headerIter, &tag, &type, &ptr, &c)) { if (tag == lastTag) { - error(RPMERR_BADSPEC, "Duplicate fields for : %s", + rpmError(RPMERR_BADSPEC, "Duplicate fields for : %s", tagName(tag)); res = 1; } @@ -136,13 +135,13 @@ static int checkHeaderTags(Header inh, struct packageFieldsRec *pfr) p->present = 1; lastTag = tag; } - freeIterator(headerIter); - freeHeader(h); + headerFreeIterator(headerIter); + headerFree(h); p = pfr; while (p->tag) { if (p->shouldBePresent != p->present) { - error(RPMERR_BADSPEC, "Field must%s be present%s: %s", + rpmError(RPMERR_BADSPEC, "Field must%s be present%s: %s", p->present ? " NOT" : "", p->present ? "" : " ", tagName(p->tag)); res = 1; @@ -186,15 +185,15 @@ int verifySpec(Spec s) } val = NULL; - getEntry(pr->header, RPMTAG_VERSION, NULL, (void *) &val, NULL); + headerGetEntry(pr->header, RPMTAG_VERSION, NULL, (void *) &val, NULL); if (val && strchr(val, '-')) { - error(RPMERR_BADSPEC, "Illegal '-' char in version: %s\n", val); + rpmError(RPMERR_BADSPEC, "Illegal '-' char in version: %s\n", val); res = 1; } val = NULL; - getEntry(pr->header, RPMTAG_RELEASE, NULL, (void *) &val, NULL); + headerGetEntry(pr->header, RPMTAG_RELEASE, NULL, (void *) &val, NULL); if (val && strchr(val, '-')) { - error(RPMERR_BADSPEC, "Illegal '-' char in release: %s\n", val); + rpmError(RPMERR_BADSPEC, "Illegal '-' char in release: %s\n", val); res = 1; } diff --git a/checksig.c b/checksig.c index 6c0148034..2deaccb9e 100644 --- a/checksig.c +++ b/checksig.c @@ -10,6 +10,7 @@ #include "rpmlib.h" #include "rpmlead.h" #include "signature.h" +#include "messages.h" int doReSign(int add, char *passPhrase, char **argv) { @@ -40,16 +41,16 @@ int doReSign(int add, char *passPhrase, char **argv) fprintf(stderr, "%s: Can't re-sign v2.0 RPM\n", rpm); exit(1); } - if (readSignature(fd, &sig, lead.signature_type)) { - fprintf(stderr, "%s: readSignature failed\n", rpm); + if (rpmReadSignature(fd, &sig, lead.signature_type)) { + fprintf(stderr, "%s: rpmReadSignature failed\n", rpm); exit(1); } if (add != ADD_SIGNATURE) { - freeSignature(sig); + rpmFreeSignature(sig); } /* Write the rest to a temp file */ - strcpy(sigtarget, tempnam(getVar(RPMVAR_TMPPATH), "rpmsigtarget")); + strcpy(sigtarget, tempnam(rpmGetVar(RPMVAR_TMPPATH), "rpmsigtarget")); ofd = open(sigtarget, O_WRONLY|O_CREAT|O_TRUNC, 0644); while ((count = read(fd, buffer, sizeof(buffer))) > 0) { if (count == -1) { @@ -81,24 +82,24 @@ int doReSign(int add, char *passPhrase, char **argv) } /* Generate the signature */ - sigtype = sigLookupType(); - message(MESS_VERBOSE, "Generating signature: %d\n", sigtype); + sigtype = rpmLookupSignatureType(); + rpmMessage(RPMMESS_VERBOSE, "Generating signature: %d\n", sigtype); if (add != ADD_SIGNATURE) { - sig = newSignature(); - addSignature(sig, sigtarget, SIGTAG_SIZE, passPhrase); - addSignature(sig, sigtarget, SIGTAG_MD5, passPhrase); + sig = rpmNewSignature(); + rpmAddSignature(sig, sigtarget, RPMSIGTAG_SIZE, passPhrase); + rpmAddSignature(sig, sigtarget, RPMSIGTAG_MD5, passPhrase); } if (sigtype>0) { - addSignature(sig, sigtarget, sigtype, passPhrase); + rpmAddSignature(sig, sigtarget, sigtype, passPhrase); } - if (writeSignature(ofd, sig)) { + if (rpmWriteSignature(ofd, sig)) { close(ofd); unlink(sigtarget); unlink(tmprpm); - freeSignature(sig); + rpmFreeSignature(sig); exit(1); } - freeSignature(sig); + rpmFreeSignature(sig); /* Append the header and archive */ fd = open(sigtarget, O_RDONLY); @@ -162,8 +163,8 @@ int doCheckSig(int pgp, char **argv) res++; continue; } - if (readSignature(fd, &sig, lead.signature_type)) { - fprintf(stderr, "%s: readSignature failed\n", rpm); + if (rpmReadSignature(fd, &sig, lead.signature_type)) { + fprintf(stderr, "%s: rpmReadSignature failed\n", rpm); res++; continue; } @@ -173,7 +174,7 @@ int doCheckSig(int pgp, char **argv) continue; } /* Write the rest to a temp file */ - strcpy(sigtarget, tempnam(getVar(RPMVAR_TMPPATH), "rpmsigtarget")); + strcpy(sigtarget, tempnam(rpmGetVar(RPMVAR_TMPPATH), "rpmsigtarget")); ofd = open(sigtarget, O_WRONLY|O_CREAT|O_TRUNC, 0644); while ((count = read(fd, buffer, sizeof(buffer))) > 0) { if (count == -1) { @@ -193,34 +194,34 @@ int doCheckSig(int pgp, char **argv) close(fd); close(ofd); - sigIter = initIterator(sig); + sigIter = headerInitIterator(sig); res2 = 0; missingKeys = 0; - if (isVerbose()) { + if (rpmIsVerbose()) { sprintf(buffer, "%s:\n", rpm); } else { sprintf(buffer, "%s: ", rpm); } - while (nextIterator(sigIter, &tag, &type, &ptr, &count)) { - if ((tag == SIGTAG_PGP) && !pgp) { + while (headerNextIterator(sigIter, &tag, &type, &ptr, &count)) { + if ((tag == RPMSIGTAG_PGP) && !pgp) { continue; } - if ((res3 = verifySignature(sigtarget, tag, ptr, count, result))) { - if (isVerbose()) { + if ((res3 = rpmVerifySignature(sigtarget, tag, ptr, count, result))) { + if (rpmIsVerbose()) { strcat(buffer, result); res2 = 1; } else { switch (tag) { - case SIGTAG_SIZE: + case RPMSIGTAG_SIZE: strcat(buffer, "SIZE "); res2 = 1; break; - case SIGTAG_MD5: - case SIGTAG_LITTLEENDIANMD5: + case RPMSIGTAG_MD5: + case RPMSIGTAG_LITTLEENDIANMD5: strcat(buffer, "MD5 "); res2 = 1; break; - case SIGTAG_PGP: + case RPMSIGTAG_PGP: if (res3 == RPMSIG_NOKEY) { /* Do not consedier this a failure */ strcat(buffer, "(PGP) "); @@ -236,18 +237,18 @@ int doCheckSig(int pgp, char **argv) } } } else { - if (isVerbose()) { + if (rpmIsVerbose()) { strcat(buffer, result); } else { switch (tag) { - case SIGTAG_SIZE: + case RPMSIGTAG_SIZE: strcat(buffer, "size "); break; - case SIGTAG_MD5: - case SIGTAG_LITTLEENDIANMD5: + case RPMSIGTAG_MD5: + case RPMSIGTAG_LITTLEENDIANMD5: strcat(buffer, "md5 "); break; - case SIGTAG_PGP: + case RPMSIGTAG_PGP: strcat(buffer, "pgp "); break; default: @@ -256,19 +257,19 @@ int doCheckSig(int pgp, char **argv) } } } - freeIterator(sigIter); + headerFreeIterator(sigIter); res += res2; unlink(sigtarget); if (res2) { - if (isVerbose()) { + if (rpmIsVerbose()) { fprintf(stderr, "%s", buffer); } else { fprintf(stderr, "%sNOT OK%s\n", buffer, missingKeys ? " (MISSING KEYS)" : ""); } } else { - if (isVerbose()) { + if (rpmIsVerbose()) { printf("%s", buffer); } else { printf("%sOK%s\n", buffer, diff --git a/convertdb.c b/convertdb.c index c498dfefb..d51e8ce69 100644 --- a/convertdb.c +++ b/convertdb.c @@ -10,7 +10,6 @@ #include "misc.h" #include "oldrpmdb.h" #include "oldheader.h" -#include "rpmerr.h" #include "rpmlib.h" int convertDB(void); @@ -39,12 +38,12 @@ int convertDB(void) { int i, j; if (exists("/var/lib/rpm/packages.rpm")) { - error(RPMERR_NOCREATEDB, "RPM database already exists"); + rpmError(RPMERR_NOCREATEDB, "RPM database already exists"); return 0; } if (oldrpmdbOpen(&olddb)) { - error(RPMERR_OLDDBMISSING, ""); + rpmError(RPMERR_OLDDBMISSING, ""); return 0; } @@ -55,13 +54,13 @@ int convertDB(void) { unlink("/var/lib/rpm/fileindex.rpm"); if (rpmdbOpen("", &db, O_RDWR | O_EXCL | O_CREAT, 0644)) { - error(RPMERR_DBOPEN, "failed to create RPM database /var/lib/rpm"); + rpmError(RPMERR_DBOPEN, "failed to create RPM database /var/lib/rpm"); return 0; } packageLabels = oldrpmdbGetAllLabels(&olddb); if (!packageLabels) { - error(RPMERR_OLDDBCORRUPT, ""); + rpmError(RPMERR_OLDDBCORRUPT, ""); rpmdbClose(db); unlink("/var/lib/rpm/packages.rpm"); oldrpmdbClose(&olddb); @@ -78,35 +77,35 @@ int convertDB(void) { preun = oldrpmdbGetPackagePreun(&olddb, *label); postun = oldrpmdbGetPackagePostun(&olddb, *label); - dbentry = newHeader(); - addEntry(dbentry, RPMTAG_NAME, STRING_TYPE, package.name, 1); - addEntry(dbentry, RPMTAG_VERSION, STRING_TYPE, package.version, 1); - addEntry(dbentry, RPMTAG_RELEASE, STRING_TYPE, package.release, 1); - addEntry(dbentry, RPMTAG_DESCRIPTION, STRING_TYPE, + dbentry = headerNew(); + headerAddEntry(dbentry, RPMTAG_NAME, RPM_STRING_TYPE, package.name, 1); + headerAddEntry(dbentry, RPMTAG_VERSION, RPM_STRING_TYPE, package.version, 1); + headerAddEntry(dbentry, RPMTAG_RELEASE, RPM_STRING_TYPE, package.release, 1); + headerAddEntry(dbentry, RPMTAG_DESCRIPTION, RPM_STRING_TYPE, package.description, 1); - addEntry(dbentry, RPMTAG_BUILDTIME, INT32_TYPE, &package.buildTime, 1); - addEntry(dbentry, RPMTAG_BUILDHOST, STRING_TYPE, package.buildHost, 1); - addEntry(dbentry, RPMTAG_INSTALLTIME, INT32_TYPE, + headerAddEntry(dbentry, RPMTAG_BUILDTIME, RPM_INT32_TYPE, &package.buildTime, 1); + headerAddEntry(dbentry, RPMTAG_BUILDHOST, RPM_STRING_TYPE, package.buildHost, 1); + headerAddEntry(dbentry, RPMTAG_INSTALLTIME, RPM_INT32_TYPE, &package.installTime, 1); - addEntry(dbentry, RPMTAG_DISTRIBUTION, STRING_TYPE, + headerAddEntry(dbentry, RPMTAG_DISTRIBUTION, RPM_STRING_TYPE, package.distribution, 1); - addEntry(dbentry, RPMTAG_VENDOR, STRING_TYPE, package.vendor, 1); - addEntry(dbentry, RPMTAG_SIZE, INT32_TYPE, &package.size, 1); - addEntry(dbentry, RPMTAG_COPYRIGHT, STRING_TYPE, package.copyright, 1); - addEntry(dbentry, RPMTAG_GROUP, STRING_TYPE, group, 1); + headerAddEntry(dbentry, RPMTAG_VENDOR, RPM_STRING_TYPE, package.vendor, 1); + headerAddEntry(dbentry, RPMTAG_SIZE, RPM_INT32_TYPE, &package.size, 1); + headerAddEntry(dbentry, RPMTAG_COPYRIGHT, RPM_STRING_TYPE, package.copyright, 1); + headerAddEntry(dbentry, RPMTAG_GROUP, RPM_STRING_TYPE, group, 1); if (preun) { - addEntry(dbentry, RPMTAG_PREUN, STRING_TYPE, preun, 1); + headerAddEntry(dbentry, RPMTAG_PREUN, RPM_STRING_TYPE, preun, 1); free(preun); } if (postun) { - addEntry(dbentry, RPMTAG_POSTUN, STRING_TYPE, postun, 1); + headerAddEntry(dbentry, RPMTAG_POSTUN, RPM_STRING_TYPE, postun, 1); free(postun); } gif = oldrpmdbGetPackageGif(&olddb, *label, &gifSize); if (gif) { - addEntry(dbentry, RPMTAG_GIF, BIN_TYPE, gif, gifSize); + headerAddEntry(dbentry, RPMTAG_GIF, RPM_BIN_TYPE, gif, gifSize); free(gif); } @@ -150,27 +149,27 @@ int convertDB(void) { fileFlagsList[j] |= RPMFILE_CONFIG; } - addEntry(dbentry, RPMTAG_FILENAMES, STRING_ARRAY_TYPE, fileList, + headerAddEntry(dbentry, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE, fileList, package.fileCount); - addEntry(dbentry, RPMTAG_FILELINKTOS, STRING_ARRAY_TYPE, + headerAddEntry(dbentry, RPMTAG_FILELINKTOS, RPM_STRING_ARRAY_TYPE, fileLinktoList, package.fileCount); - addEntry(dbentry, RPMTAG_FILEMD5S, STRING_ARRAY_TYPE, fileMD5List, + headerAddEntry(dbentry, RPMTAG_FILEMD5S, RPM_STRING_ARRAY_TYPE, fileMD5List, package.fileCount); - addEntry(dbentry, RPMTAG_FILESIZES, INT32_TYPE, fileSizeList, + headerAddEntry(dbentry, RPMTAG_FILESIZES, RPM_INT32_TYPE, fileSizeList, package.fileCount); - addEntry(dbentry, RPMTAG_FILEUIDS, INT32_TYPE, fileUIDList, + headerAddEntry(dbentry, RPMTAG_FILEUIDS, RPM_INT32_TYPE, fileUIDList, package.fileCount); - addEntry(dbentry, RPMTAG_FILEGIDS, INT32_TYPE, fileGIDList, + headerAddEntry(dbentry, RPMTAG_FILEGIDS, RPM_INT32_TYPE, fileGIDList, package.fileCount); - addEntry(dbentry, RPMTAG_FILEMTIMES, INT32_TYPE, fileMtimesList, + headerAddEntry(dbentry, RPMTAG_FILEMTIMES, RPM_INT32_TYPE, fileMtimesList, package.fileCount); - addEntry(dbentry, RPMTAG_FILEFLAGS, INT32_TYPE, fileFlagsList, + headerAddEntry(dbentry, RPMTAG_FILEFLAGS, RPM_INT32_TYPE, fileFlagsList, package.fileCount); - addEntry(dbentry, RPMTAG_FILEMODES, INT16_TYPE, fileModesList, + headerAddEntry(dbentry, RPMTAG_FILEMODES, RPM_INT16_TYPE, fileModesList, package.fileCount); - addEntry(dbentry, RPMTAG_FILERDEVS, INT16_TYPE, fileRDevsList, + headerAddEntry(dbentry, RPMTAG_FILERDEVS, RPM_INT16_TYPE, fileRDevsList, package.fileCount); - addEntry(dbentry, RPMTAG_FILESTATES, INT8_TYPE, fileStatesList, + headerAddEntry(dbentry, RPMTAG_FILESTATES, RPM_INT8_TYPE, fileStatesList, package.fileCount); free(fileList); @@ -189,7 +188,7 @@ int convertDB(void) { rpmdbAdd(db, dbentry); free(group); - freeHeader(dbentry); + headerFree(dbentry); oldrpmdbFreePackageInfo(package); } diff --git a/install.c b/install.c index a4ea4b113..7bed746c5 100644 --- a/install.c +++ b/install.c @@ -52,17 +52,17 @@ static int installPackages(char * rootdir, char ** packages, char * location, char * printFormat = NULL; char * chptr; int rc; - notifyFunction fn; + rpmNotifyFunction fn; char * netsharedPath = NULL; - if (interfaceFlags & RPMINSTALL_PERCENT) + if (interfaceFlags & INSTALL_PERCENT) fn = printPercent; - else if (interfaceFlags & RPMINSTALL_HASH) + else if (interfaceFlags & INSTALL_HASH) fn = printHash; else fn = NULL; - netsharedPath = getVar(RPMVAR_NETSHAREDPATH); + netsharedPath = rpmGetVar(RPMVAR_NETSHAREDPATH); for (i = 0, filename = packages; i < numPackages; i++, filename++) { if (!*filename) continue; @@ -77,9 +77,9 @@ static int installPackages(char * rootdir, char ** packages, char * location, continue; } - if (interfaceFlags & RPMINSTALL_PERCENT) + if (interfaceFlags & INSTALL_PERCENT) printFormat = "%%f %s:%s:%s\n"; - else if (isVerbose() && (interfaceFlags & RPMINSTALL_HASH)) { + else if (rpmIsVerbose() && (interfaceFlags & INSTALL_HASH)) { chptr = strrchr(*filename, '/'); if (!chptr) chptr = *filename; @@ -87,15 +87,15 @@ static int installPackages(char * rootdir, char ** packages, char * location, chptr++; printFormat = "%-28s"; - } else if (isVerbose()) + } else if (rpmIsVerbose()) printf("Installing %s\n", *filename); if (db) { rc = rpmInstallPackage(rootdir, db, fd, location, installFlags, fn, printFormat, netsharedPath); } else { - if (installFlags &= INSTALL_TEST) { - message(MESS_DEBUG, "stopping source install as we're " + if (installFlags &= RPMINSTALL_TEST) { + rpmMessage(RPMMESS_DEBUG, "stopping source install as we're " "just testing\n"); rc = 0; } else { @@ -138,31 +138,31 @@ int doInstall(char * rootdir, char ** argv, char * location, int installFlags, int numConflicts; int stopInstall = 0; - if (installFlags & INSTALL_TEST) + if (installFlags & RPMINSTALL_TEST) mode = O_RDONLY; else mode = O_RDWR | O_CREAT; - message(MESS_DEBUG, "counting packages to install\n"); + rpmMessage(RPMMESS_DEBUG, "counting packages to install\n"); for (filename = argv, numPackages = 0; *filename; filename++, numPackages++) ; - message(MESS_DEBUG, "found %d packages\n", numPackages); + rpmMessage(RPMMESS_DEBUG, "found %d packages\n", numPackages); packages = alloca((numPackages + 1) * sizeof(char *)); packages[numPackages] = NULL; tmpPackages = alloca((numPackages + 1) * sizeof(char *)); binaryHeaders = alloca((numPackages + 1) * sizeof(Header)); - message(MESS_DEBUG, "looking for packages to download\n"); + rpmMessage(RPMMESS_DEBUG, "looking for packages to download\n"); for (filename = argv, i = 0; *filename; filename++) { if (urlIsURL(*filename)) { - if (isVerbose()) { + if (rpmIsVerbose()) { printf("Retrieving %s\n", *filename); } packages[i] = alloca(strlen(*filename) + 30 + strlen(rootdir)); sprintf(packages[i], "%s/var/tmp/rpm-ftp-%d-%d.tmp", rootdir, tmpnum++, (int) getpid()); - message(MESS_DEBUG, "getting %s as %s\n", *filename, packages[i]); + rpmMessage(RPMMESS_DEBUG, "getting %s as %s\n", *filename, packages[i]); fd = urlGetFile(*filename, packages[i]); if (fd < 0) { fprintf(stderr, "error: skipping %s - transfer failed - %s\n", @@ -177,9 +177,9 @@ int doInstall(char * rootdir, char ** argv, char * location, int installFlags, } } - message(MESS_DEBUG, "retrieved %d packages\n", numTmpPackages); + rpmMessage(RPMMESS_DEBUG, "retrieved %d packages\n", numTmpPackages); - message(MESS_DEBUG, "finding source and binary packages\n"); + rpmMessage(RPMMESS_DEBUG, "finding source and binary packages\n"); for (filename = packages; *filename; filename++) { fd = open(*filename, O_RDONLY); if (fd < 0) { @@ -189,7 +189,7 @@ int doInstall(char * rootdir, char ** argv, char * location, int installFlags, continue; } - rc = pkgReadHeader(fd, &binaryHeaders[numBinaryPackages], &isSource, + rc = rpmReadPackageHeader(fd, &binaryHeaders[numBinaryPackages], &isSource, NULL, NULL); close(fd); @@ -206,7 +206,7 @@ int doInstall(char * rootdir, char ** argv, char * location, int installFlags, } else if (isSource) { /* the header will be NULL if this is a v1 source package */ if (binaryHeaders[numBinaryPackages]) - freeHeader(binaryHeaders[numBinaryPackages]); + headerFree(binaryHeaders[numBinaryPackages]); numSourcePackages++; } else { @@ -214,21 +214,21 @@ int doInstall(char * rootdir, char ** argv, char * location, int installFlags, } } - message(MESS_DEBUG, "found %d source and %d binary packages\n", + rpmMessage(RPMMESS_DEBUG, "found %d source and %d binary packages\n", numSourcePackages, numBinaryPackages); if (numBinaryPackages) { - message(MESS_DEBUG, "opening database mode: 0%o\n", mode); + rpmMessage(RPMMESS_DEBUG, "opening database mode: 0%o\n", mode); if (rpmdbOpen(rootdir, &db, mode, 0644)) { fprintf(stderr, "error: cannot open %s/var/lib/rpm/packages.rpm\n", rootdir); exit(1); } - if (!(interfaceFlags & RPMINSTALL_NODEPS)) { + if (!(interfaceFlags & INSTALL_NODEPS)) { rpmdep = rpmdepDependencies(db); for (i = 0; i < numBinaryPackages; i++) - if (installFlags & INSTALL_UPGRADE) + if (installFlags & RPMINSTALL_UPGRADE) rpmdepUpgradePackage(rpmdep, binaryHeaders[i]); else rpmdepAddPackage(rpmdep, binaryHeaders[i]); @@ -253,7 +253,7 @@ int doInstall(char * rootdir, char ** argv, char * location, int installFlags, db = NULL; if (!stopInstall) { - message(MESS_DEBUG, "installing binary packages\n"); + rpmMessage(RPMMESS_DEBUG, "installing binary packages\n"); numFailed += installPackages(rootdir, packages, location, numPackages, installFlags, interfaceFlags, db); } @@ -262,7 +262,7 @@ int doInstall(char * rootdir, char ** argv, char * location, int installFlags, unlink(tmpPackages[i]); for (i = 0; i < numBinaryPackages; i++) - freeHeader(binaryHeaders[i]); + headerFree(binaryHeaders[i]); if (db) rpmdbClose(db); @@ -272,7 +272,7 @@ int doInstall(char * rootdir, char ** argv, char * location, int installFlags, int doUninstall(char * rootdir, char ** argv, int uninstallFlags, int interfaceFlags) { rpmdb db; - dbIndexSet matches; + dbiIndexSet matches; int i, j; int mode; int rc; @@ -286,14 +286,14 @@ int doUninstall(char * rootdir, char ** argv, int uninstallFlags, int numConflicts; int stopUninstall = 0; - message(MESS_DEBUG, "counting packages to uninstall\n"); + rpmMessage(RPMMESS_DEBUG, "counting packages to uninstall\n"); for (arg = argv, numPackages = 0; *arg; arg++, numPackages++) ; - message(MESS_DEBUG, "found %d packages to uninstall\n", numPackages); + rpmMessage(RPMMESS_DEBUG, "found %d packages to uninstall\n", numPackages); packageOffsets = alloca(sizeof(int *) * numPackages); - if (uninstallFlags & UNINSTALL_TEST) + if (uninstallFlags & RPMUNINSTALL_TEST) mode = O_RDONLY; else mode = O_RDWR | O_EXCL; @@ -329,12 +329,12 @@ int doUninstall(char * rootdir, char ** argv, int uninstallFlags, } } - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } } numPackages = j; - if (!(interfaceFlags & RPMUNINSTALL_NODEPS)) { + if (!(interfaceFlags & UNINSTALL_NODEPS)) { rpmdep = rpmdepDependencies(db); for (i = 0; i < numPackages; i++) rpmdepRemovePackage(rpmdep, packageOffsets[i]); @@ -358,7 +358,7 @@ int doUninstall(char * rootdir, char ** argv, int uninstallFlags, if (!stopUninstall) { for (i = 0; i < numPackages; i++) { - message(MESS_DEBUG, "uninstalling record number %d\n", + rpmMessage(RPMMESS_DEBUG, "uninstalling record number %d\n", packageOffsets[i]); rpmRemovePackage(rootdir, db, packageOffsets[i], uninstallFlags); } @@ -379,7 +379,7 @@ int doSourceInstall(char * rootdir, char * arg, char ** specFile) { return 1; } - if (isVerbose()) + if (rpmIsVerbose()) printf("Installing %s\n", arg); rc = rpmInstallSourcePackage(rootdir, fd, specFile, NULL, NULL); @@ -396,13 +396,13 @@ void printDepFlags(FILE * f, char * version, int flags) { if (flags) fprintf(f, " "); - if (flags & REQUIRE_LESS) + if (flags & RPMSENSE_LESS) fprintf(f, "<"); - if (flags & REQUIRE_GREATER) + if (flags & RPMSENSE_GREATER) fprintf(f, ">"); - if (flags & REQUIRE_EQUAL) + if (flags & RPMSENSE_EQUAL) fprintf(f, "="); - if (flags & REQUIRE_SERIAL) + if (flags & RPMSENSE_SERIAL) fprintf(f, "S"); if (flags) diff --git a/install.h b/install.h index dcc83291a..8ae6cdec8 100644 --- a/install.h +++ b/install.h @@ -3,11 +3,11 @@ #include -#define RPMINSTALL_PERCENT (1 << 0) -#define RPMINSTALL_HASH (1 << 1) -#define RPMINSTALL_NODEPS (1 << 2) +#define INSTALL_PERCENT (1 << 0) +#define INSTALL_HASH (1 << 1) +#define INSTALL_NODEPS (1 << 2) -#define RPMUNINSTALL_NODEPS (1 << 0) +#define UNINSTALL_NODEPS (1 << 0) int doInstall(char * rootdir, char ** argv, char * prefix, int installFlags, int interfaceFlags); diff --git a/lib/Makefile.in b/lib/Makefile.in index 8ffcb4dde..7f8cd7d31 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -49,8 +49,6 @@ install: $(INSTALL) -m 644 -o 0 -g 0 $(srcdir)/rpmlib.h $(INCDIR) $(INSTALL) -m 644 -o 0 -g 0 $(srcdir)/dbindex.h $(INCDIR) $(INSTALL) -m 644 -o 0 -g 0 $(srcdir)/header.h $(INCDIR) - $(INSTALL) -m 644 -o 0 -g 0 $(srcdir)/messages.h $(INCDIR) - $(INSTALL) -m 644 -o 0 -g 0 $(srcdir)/rpmerr.h $(INCDIR) $(INSTALL) -m 644 -o 0 -g 0 librpm.a $(LIBDIR) distclean: clean diff --git a/lib/dbindex.c b/lib/dbindex.c index 4b5a6bd46..b7b231c8c 100644 --- a/lib/dbindex.c +++ b/lib/dbindex.c @@ -4,10 +4,10 @@ #include #include "dbindex.h" -#include "rpmerr.h" +#include "rpmlib.h" -dbIndex * openDBIndex(char * filename, int flags, int perms) { - dbIndex * db; +dbiIndex * dbiOpenIndex(char * filename, int flags, int perms) { + dbiIndex * db; db = malloc(sizeof(*db)); db->indexname = strdup(filename); @@ -15,7 +15,7 @@ dbIndex * openDBIndex(char * filename, int flags, int perms) { if (!db->db) { free(db->indexname); free(db); - error(RPMERR_DBOPEN, "cannot open file %s: ", filename, + rpmError(RPMERR_DBOPEN, "cannot open file %s: ", filename, strerror(errno)); return NULL; } @@ -23,17 +23,17 @@ dbIndex * openDBIndex(char * filename, int flags, int perms) { return db; } -void closeDBIndex(dbIndex * dbi) { +void dbiCloseIndex(dbiIndex * dbi) { dbi->db->close(dbi->db); free(dbi->indexname); free(dbi); } -void syncDBIndex(dbIndex * dbi) { +void dbiSyncIndex(dbiIndex * dbi) { dbi->db->sync(dbi->db, 0); } -int searchDBIndex(dbIndex * dbi, char * str, dbIndexSet * set) { +int dbiSearchIndex(dbiIndex * dbi, char * str, dbiIndexSet * set) { DBT key, data; int rc; @@ -42,7 +42,7 @@ int searchDBIndex(dbIndex * dbi, char * str, dbIndexSet * set) { rc = dbi->db->get(dbi->db, &key, &data, 0); if (rc == -1) { - error(RPMERR_DBGETINDEX, "error getting record %s from %s", + rpmError(RPMERR_DBGETINDEX, "error getting record %s from %s", str, dbi->indexname); return -1; } else if (rc == 1) { @@ -51,12 +51,12 @@ int searchDBIndex(dbIndex * dbi, char * str, dbIndexSet * set) { set->recs = data.data; set->recs = malloc(data.size); memcpy(set->recs, data.data, data.size); - set->count = data.size / sizeof(dbIndexRecord); + set->count = data.size / sizeof(dbiIndexRecord); return 0; } } -int updateDBIndex(dbIndex * dbi, char * str, dbIndexSet * set) { +int dbiUpdateIndex(dbiIndex * dbi, char * str, dbiIndexSet * set) { /* 0 on success */ DBT key, data; int rc; @@ -66,18 +66,18 @@ int updateDBIndex(dbIndex * dbi, char * str, dbIndexSet * set) { if (set->count) { data.data = set->recs; - data.size = set->count * sizeof(dbIndexRecord); + data.size = set->count * sizeof(dbiIndexRecord); rc = dbi->db->put(dbi->db, &key, &data, 0); if (rc) { - error(RPMERR_DBPUTINDEX, "error storing record %s into %s", + rpmError(RPMERR_DBPUTINDEX, "error storing record %s into %s", str, dbi->indexname); return 1; } } else { rc = dbi->db->del(dbi->db, &key, 0); if (rc) { - error(RPMERR_DBPUTINDEX, "error removing record %s into %s", + rpmError(RPMERR_DBPUTINDEX, "error removing record %s into %s", str, dbi->indexname); return 1; } @@ -86,32 +86,32 @@ int updateDBIndex(dbIndex * dbi, char * str, dbIndexSet * set) { return 0; } -int appendDBIndexRecord(dbIndexSet * set, dbIndexRecord rec) { +int dbiAppendIndexRecord(dbiIndexSet * set, dbiIndexRecord rec) { set->count++; if (set->count == 1) { - set->recs = malloc(set->count * sizeof(dbIndexRecord)); + set->recs = malloc(set->count * sizeof(dbiIndexRecord)); } else { - set->recs = realloc(set->recs, set->count * sizeof(dbIndexRecord)); + set->recs = realloc(set->recs, set->count * sizeof(dbiIndexRecord)); } set->recs[set->count - 1] = rec; return 0; } -dbIndexSet createDBIndexRecord(void) { - dbIndexSet set; +dbiIndexSet dbiCreateIndexRecord(void) { + dbiIndexSet set; set.count = 0; return set; } -void freeDBIndexRecord(dbIndexSet set) { +void dbiFreeIndexRecord(dbiIndexSet set) { free(set.recs); } /* returns 1 on failure */ -int removeDBIndexRecord(dbIndexSet * set, dbIndexRecord rec) { +int dbiRemoveIndexRecord(dbiIndexSet * set, dbiIndexRecord rec) { int from; int to = 0; int num = set->count; diff --git a/lib/dbindex.h b/lib/dbindex.h index 73ff76f89..33c42f51c 100644 --- a/lib/dbindex.h +++ b/lib/dbindex.h @@ -8,30 +8,30 @@ typedef struct { unsigned int recOffset; unsigned int fileNumber; -} dbIndexRecord; +} dbiIndexRecord; typedef struct { - dbIndexRecord * recs; + dbiIndexRecord * recs; int count; -} dbIndexSet; +} dbiIndexSet; typedef struct { DB * db; char * indexname; -} dbIndex; +} dbiIndex; -dbIndex * openDBIndex(char * filename, int flags, int perms); -void closeDBIndex(dbIndex * dbi); -void syncDBIndex(dbIndex * dbi); -int searchDBIndex(dbIndex * dbi, char * str, dbIndexSet * set); +dbiIndex * dbiOpenIndex(char * filename, int flags, int perms); +void dbiCloseIndex(dbiIndex * dbi); +void dbiSyncIndex(dbiIndex * dbi); +int dbiSearchIndex(dbiIndex * dbi, char * str, dbiIndexSet * set); /* -1 error, 0 success, 1 not found */ -int updateDBIndex(dbIndex * dbi, char * str, dbIndexSet * set); +int dbiUpdateIndex(dbiIndex * dbi, char * str, dbiIndexSet * set); /* 0 on success */ -int appendDBIndexRecord(dbIndexSet * set, dbIndexRecord rec); +int dbiAppendIndexRecord(dbiIndexSet * set, dbiIndexRecord rec); /* 0 on success - should never fail */ -int removeDBIndexRecord(dbIndexSet * set, dbIndexRecord rec); +int dbiRemoveIndexRecord(dbiIndexSet * set, dbiIndexRecord rec); /* 0 on success - fails if rec is not found */ -dbIndexSet createDBIndexRecord(void); -void freeDBIndexRecord(dbIndexSet set); +dbiIndexSet dbiCreateIndexRecord(void); +void dbiFreeIndexRecord(dbiIndexSet set); #endif diff --git a/lib/depends.c b/lib/depends.c index 70f6cf4fc..f9f93b663 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -6,8 +6,8 @@ #include #include "misc.h" -#include "rpmerr.h" #include "rpmlib.h" +#include "messages.h" struct availablePackage { Header h; @@ -71,7 +71,7 @@ struct availablePackage * alSatisfiesDepend(struct availableList * al, static int checkDependentConflicts(rpmDependencies rpmdep, struct problemsSet * psp, char * package); static int checkPackageSet(rpmDependencies rpmdep, struct problemsSet * psp, - char * package, dbIndexSet * matches); + char * package, dbiIndexSet * matches); static void alCreate(struct availableList * al) { al->list = malloc(sizeof(*al->list) * 5); @@ -114,12 +114,12 @@ static void alAddPackage(struct availableList * al, Header h, void * key) { p = al->list + al->size++; p->h = h; - getEntry(p->h, RPMTAG_NAME, &type, (void **) &p->name, &i); - getEntry(p->h, RPMTAG_VERSION, &type, (void **) &p->version, &i); - getEntry(p->h, RPMTAG_RELEASE, &type, (void **) &p->release, &i); - p->hasSerial = getEntry(h, RPMTAG_SERIAL, &type, (void **) &p->serial, &i); + headerGetEntry(p->h, RPMTAG_NAME, &type, (void **) &p->name, &i); + headerGetEntry(p->h, RPMTAG_VERSION, &type, (void **) &p->version, &i); + headerGetEntry(p->h, RPMTAG_RELEASE, &type, (void **) &p->release, &i); + p->hasSerial = headerGetEntry(h, RPMTAG_SERIAL, &type, (void **) &p->serial, &i); - if (!getEntry(h, RPMTAG_PROVIDES, &type, (void **) &p->provides, + if (!headerGetEntry(h, RPMTAG_PROVIDES, &type, (void **) &p->provides, &p->providesCount)) { p->providesCount = 0; p->provides = NULL; @@ -219,7 +219,7 @@ rpmDependencies rpmdepDependencies(rpmdb db) { void rpmdepUpgradePackage(rpmDependencies rpmdep, Header h) { /* this is an install followed by uninstalls */ - dbIndexSet matches; + dbiIndexSet matches; char * name; int count, type, i; @@ -227,14 +227,14 @@ void rpmdepUpgradePackage(rpmDependencies rpmdep, Header h) { if (!rpmdep->db) return; - getEntry(h, RPMTAG_NAME, &type, (void *) &name, &count); + headerGetEntry(h, RPMTAG_NAME, &type, (void *) &name, &count); if (!rpmdbFindPackage(rpmdep->db, name, &matches)) { for (i = 0; i < matches.count; i++) { rpmdepRemovePackage(rpmdep, matches.recs[i].recOffset); } - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } } @@ -316,7 +316,7 @@ int rpmdepCheck(rpmDependencies rpmdep, return 1; } - if (getEntry(p->h, RPMTAG_PROVIDES, &type, (void **) &provides, + if (headerGetEntry(p->h, RPMTAG_PROVIDES, &type, (void **) &provides, &providesCount)) { for (j = 0; j < providesCount; j++) { if (checkDependentConflicts(rpmdep, &ps, provides[j])) { @@ -331,35 +331,35 @@ int rpmdepCheck(rpmDependencies rpmdep, for (i = 0; i < rpmdep->numRemovedPackages; i++) { h = rpmdbGetRecord(rpmdep->db, rpmdep->removedPackages[i]); if (!h) { - error(RPMERR_DBCORRUPT, "cannot read header at %d for dependency " + rpmError(RPMERR_DBCORRUPT, "cannot read header at %d for dependency " "check", rpmdep->removedPackages[i]); free(ps.problems); return 1; } - getEntry(h, RPMTAG_NAME, &type, (void **) &name, &providesCount); + headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &providesCount); if (checkDependentPackages(rpmdep, &ps, name)) { free(ps.problems); - freeHeader(h); + headerFree(h); return 1; } - if (!getEntry(h, RPMTAG_PROVIDES, &type, (void **) &provides, + if (!headerGetEntry(h, RPMTAG_PROVIDES, &type, (void **) &provides, &providesCount)) { - freeHeader(h); + headerFree(h); continue; } for (j = 0; j < providesCount; j++) { if (checkDependentPackages(rpmdep, &ps, provides[j])) { free(ps.problems); - freeHeader(h); + headerFree(h); return 1; } } - freeHeader(h); + headerFree(h); } if (!ps.num) @@ -377,10 +377,10 @@ int rpmdepCheck(rpmDependencies rpmdep, static int unsatisfiedDepend(rpmDependencies rpmdep, char * reqName, char * reqVersion, int reqFlags, struct availablePackage ** suggestion) { - dbIndexSet matches; + dbiIndexSet matches; int i; - message(MESS_DEBUG, "dependencies: looking for %s\n", reqName); + rpmMessage(RPMMESS_DEBUG, "dependencies: looking for %s\n", reqName); if (suggestion) *suggestion = NULL; @@ -398,7 +398,7 @@ static int unsatisfiedDepend(rpmDependencies rpmdep, char * reqName, break; } - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); if (i < matches.count) return 0; } @@ -415,7 +415,7 @@ static int unsatisfiedDepend(rpmDependencies rpmdep, char * reqName, } } - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); if (i < matches.count) return 0; } } @@ -428,7 +428,7 @@ static int unsatisfiedDepend(rpmDependencies rpmdep, char * reqName, } static int checkPackageSet(rpmDependencies rpmdep, struct problemsSet * psp, - char * package, dbIndexSet * matches) { + char * package, dbiIndexSet * matches) { int i; Header h; @@ -439,17 +439,17 @@ static int checkPackageSet(rpmDependencies rpmdep, struct problemsSet * psp, h = rpmdbGetRecord(rpmdep->db, matches->recs[i].recOffset); if (!h) { - error(RPMERR_DBCORRUPT, "cannot read header at %d for dependency " + rpmError(RPMERR_DBCORRUPT, "cannot read header at %d for dependency " "check", rpmdep->removedPackages[i]); return 1; } if (checkPackageDeps(rpmdep, psp, h, package)) { - freeHeader(h); + headerFree(h); return 1; } - freeHeader(h); + headerFree(h); } return 0; @@ -457,7 +457,7 @@ static int checkPackageSet(rpmDependencies rpmdep, struct problemsSet * psp, static int checkDependentPackages(rpmDependencies rpmdep, struct problemsSet * psp, char * package) { - dbIndexSet matches; + dbiIndexSet matches; int rc; if (rpmdbFindByRequiredBy(rpmdep->db, package, &matches)) { @@ -465,14 +465,14 @@ static int checkDependentPackages(rpmDependencies rpmdep, } rc = checkPackageSet(rpmdep, psp, package, &matches); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); return rc; } static int checkDependentConflicts(rpmDependencies rpmdep, struct problemsSet * psp, char * package) { - dbIndexSet matches; + dbiIndexSet matches; int rc; if (rpmdbFindByConflicts(rpmdep->db, package, &matches)) { @@ -480,7 +480,7 @@ static int checkDependentConflicts(rpmDependencies rpmdep, } rc = checkPackageSet(rpmdep, psp, package, &matches); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); return rc; } @@ -497,23 +497,23 @@ static int checkPackageDeps(rpmDependencies rpmdep, struct problemsSet * psp, int * requireFlags, * conflictsFlags; struct availablePackage * suggestion; - if (!getEntry(h, RPMTAG_REQUIRENAME, &type, (void **) &requires, + if (!headerGetEntry(h, RPMTAG_REQUIRENAME, &type, (void **) &requires, &requiresCount)) { requiresCount = 0; } else { - getEntry(h, RPMTAG_REQUIREFLAGS, &type, (void **) &requireFlags, + headerGetEntry(h, RPMTAG_REQUIREFLAGS, &type, (void **) &requireFlags, &requiresCount); - getEntry(h, RPMTAG_REQUIREVERSION, &type, (void **) &requiresVersion, + headerGetEntry(h, RPMTAG_REQUIREVERSION, &type, (void **) &requiresVersion, &requiresCount); } - if (!getEntry(h, RPMTAG_CONFLICTNAME, &type, (void **) &conflicts, + if (!headerGetEntry(h, RPMTAG_CONFLICTNAME, &type, (void **) &conflicts, &conflictsCount)) { conflictsCount = 0; } else { - getEntry(h, RPMTAG_CONFLICTFLAGS, &type, (void **) &conflictsFlags, + headerGetEntry(h, RPMTAG_CONFLICTFLAGS, &type, (void **) &conflictsFlags, &conflictsCount); - getEntry(h, RPMTAG_CONFLICTVERSION, &type,(void **) &conflictsVersion, + headerGetEntry(h, RPMTAG_CONFLICTVERSION, &type,(void **) &conflictsVersion, &conflictsCount); } @@ -523,11 +523,11 @@ static int checkPackageDeps(rpmDependencies rpmdep, struct problemsSet * psp, rc = unsatisfiedDepend(rpmdep, requires[i], requiresVersion[i], requireFlags[i], &suggestion); if (rc == 1) { - getEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); - getEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); - getEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); + headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); - message(MESS_DEBUG, "package %s require not satisfied: %s\n", + rpmMessage(RPMMESS_DEBUG, "package %s require not satisfied: %s\n", name, requires[i]); if (psp->num == psp->alloced) { @@ -563,11 +563,11 @@ static int checkPackageDeps(rpmDependencies rpmdep, struct problemsSet * psp, /* 1 == unsatisfied, 0 == satsisfied */ if (rc == 0) { - getEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); - getEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); - getEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); + headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); - message(MESS_DEBUG, "package %s conflicts: %s\n", + rpmMessage(RPMMESS_DEBUG, "package %s conflicts: %s\n", name, conflicts[i]); if (psp->num == psp->alloced) { @@ -614,21 +614,21 @@ static int headerMatchesDepFlags(Header h, char * reqInfo, int reqFlags) { int result = 0; int sense; - getEntry(h, RPMTAG_NAME, &type, (void *) &name, &count); + headerGetEntry(h, RPMTAG_NAME, &type, (void *) &name, &count); if (!reqFlags) { return 1; } - if (reqFlags & REQUIRE_SERIAL) { - if (!getEntry(h, RPMTAG_SERIAL, &type, (void *) &serial, &count)) { - freeHeader(h); + if (reqFlags & RPMSENSE_SERIAL) { + if (!headerGetEntry(h, RPMTAG_SERIAL, &type, (void *) &serial, &count)) { + headerFree(h); return 0; } sprintf(buf, "%d", serial); version = buf; } else { - getEntry(h, RPMTAG_VERSION, &type, (void *) &version, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, (void *) &version, &count); chptr = strrchr(reqInfo, '-'); if (chptr) { reqVersion = alloca(strlen(reqInfo) + 1); @@ -636,7 +636,7 @@ static int headerMatchesDepFlags(Header h, char * reqInfo, int reqFlags) { reqVersion[chptr - reqInfo] = '\0'; reqRelease = reqVersion + (chptr - reqInfo) + 1; if (*reqRelease) - getEntry(h, RPMTAG_RELEASE, &type, (void *) &release, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void *) &release, &count); else reqRelease = NULL; } @@ -648,11 +648,11 @@ static int headerMatchesDepFlags(Header h, char * reqInfo, int reqFlags) { sense = vercmp(release, reqRelease); } - if ((reqFlags & REQUIRE_LESS) && sense < 0) { + if ((reqFlags & RPMSENSE_LESS) && sense < 0) { result = 1; - } else if ((reqFlags & REQUIRE_EQUAL) && sense == 0) { + } else if ((reqFlags & RPMSENSE_EQUAL) && sense == 0) { result = 1; - } else if ((reqFlags & REQUIRE_GREATER) && sense > 0) { + } else if ((reqFlags & RPMSENSE_GREATER) && sense > 0) { result = 1; } @@ -666,13 +666,13 @@ static int dbrecMatchesDepFlags(rpmDependencies rpmdep, int recOffset, h = rpmdbGetRecord(rpmdep->db, recOffset); if (!h) { - message(MESS_DEBUG, "dbrecMatchesDepFlags() failed to read header"); + rpmMessage(RPMMESS_DEBUG, "dbrecMatchesDepFlags() failed to read header"); return 0; } rc = headerMatchesDepFlags(h, reqVersion, reqFlags); - freeHeader(h); + headerFree(h); return rc; } diff --git a/lib/header.c b/lib/header.c index 882c5e120..be24be5cd 100644 --- a/lib/header.c +++ b/lib/header.c @@ -16,6 +16,7 @@ #include "header.h" #include "rpmlib.h" /* necessary only for dumpHeader() */ +#include "messages.h" #include "tread.h" #define INDEX_MALLOC_SIZE 8 @@ -58,7 +59,7 @@ struct headerIteratorS { int next_index; }; -HeaderIterator initIterator(Header h) +HeaderIterator headerInitIterator(Header h) { HeaderIterator hi = malloc(sizeof(struct headerIteratorS)); hi->h = h; @@ -66,12 +67,12 @@ HeaderIterator initIterator(Header h) return hi; } -void freeIterator(HeaderIterator iter) +void headerFreeIterator(HeaderIterator iter) { free(iter); } -int nextIterator(HeaderIterator iter, +int headerNextIterator(HeaderIterator iter, int_32 *tag, int_32 *type, void **p, int_32 *c) { struct headerToken *h = iter->h; @@ -92,24 +93,24 @@ int nextIterator(HeaderIterator iter, /* Now look it up */ switch (*type) { - case INT64_TYPE: - case INT32_TYPE: - case INT16_TYPE: - case INT8_TYPE: - case BIN_TYPE: - case CHAR_TYPE: + case RPM_INT64_TYPE: + case RPM_INT32_TYPE: + case RPM_INT16_TYPE: + case RPM_INT8_TYPE: + case RPM_BIN_TYPE: + case RPM_CHAR_TYPE: *p = h->data + index[slot].offset; break; - case STRING_TYPE: + case RPM_STRING_TYPE: if (*c == 1) { /* Special case -- just return a pointer to the string */ *p = h->data + index[slot].offset; break; } - /* Fall through to STRING_ARRAY_TYPE */ - case STRING_ARRAY_TYPE: + /* Fall through to RPM_STRING_ARRAY_TYPE */ + case RPM_STRING_ARRAY_TYPE: /* Correction! */ - *type = STRING_ARRAY_TYPE; + *type = RPM_STRING_ARRAY_TYPE; /* Otherwise, build up an array of char* to return */ x = index[slot].count; *p = malloc(x * sizeof(char *)); @@ -145,27 +146,27 @@ static int indexSort(const void *ap, const void *bp) } } -Header copyHeader(Header h) +Header headerCopy(Header h) { int_32 tag, type, count; void *ptr; HeaderIterator headerIter; - Header res = newHeader(); + Header res = headerNew(); /* Sort the index */ qsort(h->index, h->entries_used, sizeof(struct indexEntry), indexSort); - headerIter = initIterator(h); + headerIter = headerInitIterator(h); /* The result here is that the data is also sorted */ - while (nextIterator(headerIter, &tag, &type, &ptr, &count)) { - addEntry(res, tag, type, ptr, count); + while (headerNextIterator(headerIter, &tag, &type, &ptr, &count)) { + headerAddEntry(res, tag, type, ptr, count); - if (type == STRING_ARRAY_TYPE) free(ptr); + if (type == RPM_STRING_ARRAY_TYPE) free(ptr); } res->fully_sorted = 1; - freeIterator(headerIter); + headerFreeIterator(headerIter); return res; } @@ -176,7 +177,7 @@ Header copyHeader(Header h) /* */ /********************************************************************/ -void writeHeader(int fd, Header h, int magicp) +void headerWrite(int fd, Header h, int magicp) { int_32 l; struct indexEntry *p; @@ -185,7 +186,7 @@ void writeHeader(int fd, Header h, int magicp) void *converted_data; /* This magic actually sorts the data */ - h = copyHeader(h); + h = headerCopy(h); /* We must write using network byte order! */ @@ -228,7 +229,7 @@ void writeHeader(int fd, Header h, int magicp) write(fd, converted_data, h->data_used); free(converted_data); - freeHeader(h); + headerFree(h); } static void *dataHostToNetwork(Header h) @@ -245,29 +246,29 @@ static void *dataHostToNetwork(Header h) p = data + index->offset; count = index->count; switch (index->type) { - case INT64_TYPE: + case RPM_INT64_TYPE: while (count--) { *((int_64 *)p) = htonl(*((int_64 *)p)); p += sizeof(int_64); } break; - case INT32_TYPE: + case RPM_INT32_TYPE: while (count--) { *((int_32 *)p) = htonl(*((int_32 *)p)); p += sizeof(int_32); } break; - case INT16_TYPE: + case RPM_INT16_TYPE: while (count--) { *((int_16 *)p) = htons(*((int_16 *)p)); p += sizeof(int_16); } break; - case INT8_TYPE: - case BIN_TYPE: - case CHAR_TYPE: - case STRING_TYPE: - case STRING_ARRAY_TYPE: + case RPM_INT8_TYPE: + case RPM_BIN_TYPE: + case RPM_CHAR_TYPE: + case RPM_STRING_TYPE: + case RPM_STRING_ARRAY_TYPE: /* No conversion necessary */ break; default: @@ -281,7 +282,7 @@ static void *dataHostToNetwork(Header h) return data; } -Header readHeader(int fd, int magicp) +Header headerRead(int fd, int magicp) { int_32 il, dl; unsigned char magic[4]; @@ -293,14 +294,14 @@ Header readHeader(int fd, int magicp) struct headerToken *h = (struct headerToken *) malloc(sizeof(struct headerToken)); - if (magicp == HEADER_MAGIC) { + if (magicp == HEADER_MAGIC_YES) { c = timedRead(fd, magic, sizeof(magic)); - message(MESS_DEBUG, "magic: %02x %02x %02x %02x\n", + rpmMessage(RPMMESS_DEBUG, "magic: %02x %02x %02x %02x\n", header_magic[0], header_magic[1], header_magic[2], header_magic[3]); - message(MESS_DEBUG, "got : %02x %02x %02x %02x\n", + rpmMessage(RPMMESS_DEBUG, "got : %02x %02x %02x %02x\n", magic[0], magic[1], magic[2], @@ -386,29 +387,29 @@ static void *dataNetworkToHost(Header h) p = data + index->offset; count = index->count; switch (index->type) { - case INT64_TYPE: + case RPM_INT64_TYPE: while (count--) { *((int_64 *)p) = ntohl(*((int_64 *)p)); p += sizeof(int_64); } break; - case INT32_TYPE: + case RPM_INT32_TYPE: while (count--) { *((int_32 *)p) = ntohl(*((int_32 *)p)); p += sizeof(int_32); } break; - case INT16_TYPE: + case RPM_INT16_TYPE: while (count--) { *((int_16 *)p) = ntohs(*((int_16 *)p)); p += sizeof(int_16); } break; - case INT8_TYPE: - case BIN_TYPE: - case CHAR_TYPE: - case STRING_TYPE: - case STRING_ARRAY_TYPE: + case RPM_INT8_TYPE: + case RPM_BIN_TYPE: + case RPM_CHAR_TYPE: + case RPM_STRING_TYPE: + case RPM_STRING_ARRAY_TYPE: /* No conversion necessary */ break; default: @@ -428,7 +429,7 @@ static void *dataNetworkToHost(Header h) /* */ /********************************************************************/ -Header loadHeader(void *pv) +Header headerLoad(void *pv) { int_32 il, dl; /* index length, data length */ char *p = pv; @@ -450,20 +451,20 @@ Header loadHeader(void *pv) h->data = malloc(dl); memcpy(h->data, p, dl); - /* This assumes you only loadHeader() something you unloadHeader()-ed */ + /* This assumes you only headerLoad() something you headerUnload()-ed */ h->fully_sorted = 1; return h; } -void *unloadHeader(Header h) +void *headerUnload(Header h) { void *p; int_32 *pi; char * chptr; /* This magic actually sorts the data */ - h = copyHeader(h); + h = headerCopy(h); pi = p = malloc(2 * sizeof(int_32) + h->entries_used * sizeof(struct indexEntry) + @@ -478,7 +479,7 @@ void *unloadHeader(Header h) chptr += h->entries_used * sizeof(struct indexEntry); memcpy(chptr, h->data, h->data_used); - freeHeader(h); + headerFree(h); return p; } @@ -489,7 +490,7 @@ void *unloadHeader(Header h) /* */ /********************************************************************/ -void dumpHeader(Header h, FILE * f, int flags) +void headerDump(Header h, FILE * f, int flags) { int i, c, ct; struct indexEntry *p; @@ -509,15 +510,15 @@ void dumpHeader(Header h, FILE * f, int flags) " OFSET COUNT\n"); for (i = 0; i < h->entries_used; i++) { switch (p->type) { - case NULL_TYPE: type = "NULL_TYPE"; break; - case CHAR_TYPE: type = "CHAR_TYPE"; break; - case BIN_TYPE: type = "BIN_TYPE"; break; - case INT8_TYPE: type = "INT8_TYPE"; break; - case INT16_TYPE: type = "INT16_TYPE"; break; - case INT32_TYPE: type = "INT32_TYPE"; break; - case INT64_TYPE: type = "INT64_TYPE"; break; - case STRING_TYPE: type = "STRING_TYPE"; break; - case STRING_ARRAY_TYPE: type = "STRING_ARRAY_TYPE"; break; + case RPM_NULL_TYPE: type = "NULL_TYPE"; break; + case RPM_CHAR_TYPE: type = "CHAR_TYPE"; break; + case RPM_BIN_TYPE: type = "BIN_TYPE"; break; + case RPM_INT8_TYPE: type = "INT8_TYPE"; break; + case RPM_INT16_TYPE: type = "INT16_TYPE"; break; + case RPM_INT32_TYPE: type = "INT32_TYPE"; break; + case RPM_INT64_TYPE: type = "INT64_TYPE"; break; + case RPM_STRING_TYPE: type = "STRING_TYPE"; break; + case RPM_STRING_ARRAY_TYPE: type = "STRING_ARRAY_TYPE"; break; default: type = "(unknown)"; break; } @@ -533,13 +534,13 @@ void dumpHeader(Header h, FILE * f, int flags) fprintf(f, "Entry : %.3d (%d)%-14s %-18s 0x%.8x %.8d\n", i, p->tag, tag, type, (uint_32) p->offset, (uint_32) p->count); - if (flags & DUMP_INLINE) { + if (flags & HEADER_DUMP_INLINE) { /* Print the data inline */ dp = h->data + p->offset; c = p->count; ct = 0; switch (p->type) { - case INT32_TYPE: + case RPM_INT32_TYPE: while (c--) { fprintf(f, " Data: %.3d 0x%08x (%d)\n", ct++, (uint_32) *((int_32 *) dp), @@ -548,7 +549,7 @@ void dumpHeader(Header h, FILE * f, int flags) } break; - case INT16_TYPE: + case RPM_INT16_TYPE: while (c--) { fprintf(f, " Data: %.3d 0x%04x (%d)\n", ct++, (short int) *((int_16 *) dp), @@ -556,7 +557,7 @@ void dumpHeader(Header h, FILE * f, int flags) dp += sizeof(int_16); } break; - case INT8_TYPE: + case RPM_INT8_TYPE: while (c--) { fprintf(f, " Data: %.3d 0x%02x (%d)\n", ct++, (char) *((int_8 *) dp), @@ -564,7 +565,7 @@ void dumpHeader(Header h, FILE * f, int flags) dp += sizeof(int_8); } break; - case BIN_TYPE: + case RPM_BIN_TYPE: while (c > 0) { fprintf(f, " Data: %.3d ", ct); while (c--) { @@ -578,7 +579,7 @@ void dumpHeader(Header h, FILE * f, int flags) fprintf(f, "\n"); } break; - case CHAR_TYPE: + case RPM_CHAR_TYPE: while (c--) { ch = (char) *((char *) dp); fprintf(f, " Data: %.3d 0x%2x %c (%d)\n", ct++, @@ -588,8 +589,8 @@ void dumpHeader(Header h, FILE * f, int flags) dp += sizeof(char); } break; - case STRING_TYPE: - case STRING_ARRAY_TYPE: + case RPM_STRING_TYPE: + case RPM_STRING_ARRAY_TYPE: while (c--) { fprintf(f, " Data: %.3d %s\n", ct++, (char *) dp); dp = strchr(dp, 0); @@ -638,19 +639,19 @@ static struct indexEntry *findEntry(Header h, int_32 tag) } } -int isEntry(Header h, int_32 tag) +int headerIsEntry(Header h, int_32 tag) { return (findEntry(h, tag) ? 1 : 0); } -int getEntry(Header h, int_32 tag, int_32 * type, void **p, int_32 * c) +int headerGetEntry(Header h, int_32 tag, int_32 * type, void **p, int_32 * c) { struct indexEntry *index; char **spp; char *sp; int x; - if (!p) return isEntry(h, tag); + if (!p) return headerIsEntry(h, tag); /* First find the tag */ index = findEntry(h, tag); @@ -668,25 +669,25 @@ int getEntry(Header h, int_32 tag, int_32 * type, void **p, int_32 * c) /* Now look it up */ switch (index->type) { - case INT64_TYPE: - case INT32_TYPE: - case INT16_TYPE: - case INT8_TYPE: - case BIN_TYPE: - case CHAR_TYPE: + case RPM_INT64_TYPE: + case RPM_INT32_TYPE: + case RPM_INT16_TYPE: + case RPM_INT8_TYPE: + case RPM_BIN_TYPE: + case RPM_CHAR_TYPE: *p = h->data + index->offset; break; - case STRING_TYPE: + case RPM_STRING_TYPE: if (index->count == 1) { /* Special case -- just return a pointer to the string */ *p = h->data + index->offset; break; } - /* Fall through to STRING_ARRAY_TYPE */ - case STRING_ARRAY_TYPE: + /* Fall through to RPM_STRING_ARRAY_TYPE */ + case RPM_STRING_ARRAY_TYPE: /* Correction! */ if (type) { - *type = STRING_ARRAY_TYPE; + *type = RPM_STRING_ARRAY_TYPE; } /* Otherwise, build up an array of char* to return */ x = index->count; @@ -714,7 +715,7 @@ int getEntry(Header h, int_32 tag, int_32 * type, void **p, int_32 * c) /* */ /********************************************************************/ -Header newHeader() +Header headerNew() { struct headerToken *h = (struct headerToken *) malloc(sizeof(struct headerToken)); @@ -732,19 +733,19 @@ Header newHeader() return (Header) h; } -void freeHeader(Header h) +void headerFree(Header h) { free(h->index); free(h->data); free(h); } -unsigned int sizeofHeader(Header h, int magicp) +unsigned int headerSizeof(Header h, int magicp) { unsigned int size; /* Do some real magic to determine the ON-DISK size */ - h = copyHeader(h); + h = headerCopy(h); size = sizeof(int_32); /* count of index entries */ size += sizeof(int_32); /* length of data */ @@ -754,7 +755,7 @@ unsigned int sizeofHeader(Header h, int magicp) size += 8; } - freeHeader(h); + headerFree(h); return size; } @@ -765,7 +766,7 @@ unsigned int sizeofHeader(Header h, int magicp) /* */ /********************************************************************/ -int addEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) +int headerAddEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) { struct indexEntry *entry; void *ptr; @@ -775,7 +776,7 @@ int addEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) int pad; if (c <= 0) { - fprintf(stderr, "Bad count for addEntry(): %d\n", (int) c); + fprintf(stderr, "Bad count for headerAddEntry(): %d\n", (int) c); exit(1); } @@ -796,37 +797,37 @@ int addEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) /* Compute length of data to add */ pad = 0; switch (type) { - case INT64_TYPE: + case RPM_INT64_TYPE: length = sizeof(int_64) * c; pad = 8; break; - case INT32_TYPE: + case RPM_INT32_TYPE: length = sizeof(int_32) * c; pad = 4; break; - case INT16_TYPE: + case RPM_INT16_TYPE: length = sizeof(int_16) * c; pad = 2; break; - case INT8_TYPE: + case RPM_INT8_TYPE: length = sizeof(int_8) * c; break; - case BIN_TYPE: - case CHAR_TYPE: + case RPM_BIN_TYPE: + case RPM_CHAR_TYPE: length = sizeof(char) * c; break; - case STRING_TYPE: + case RPM_STRING_TYPE: if (c == 1) { /* Special case -- p is just the string */ length = strlen(p) + 1; break; } - /* Otherwise fall through to STRING_ARRAY_TYPE */ + /* Otherwise fall through to RPM_STRING_ARRAY_TYPE */ /* This should not be allowed */ - fprintf(stderr, "addEntry() STRING_TYPE count must be 1.\n"); + fprintf(stderr, "headerAddEntry() RPM_STRING_TYPE count must be 1.\n"); exit(1); - case STRING_ARRAY_TYPE: - /* This is like STRING_TYPE, except it's *always* an array */ + case RPM_STRING_ARRAY_TYPE: + /* This is like RPM_STRING_TYPE, except it's *always* an array */ /* Compute sum of length of all strings, including null terminators */ i = c; spp = p; @@ -855,24 +856,24 @@ int addEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) entry->offset = h->data_used + pad; ptr = h->data + h->data_used + pad; switch (type) { - case INT32_TYPE: - case INT16_TYPE: - case INT8_TYPE: - case BIN_TYPE: - case CHAR_TYPE: + case RPM_INT32_TYPE: + case RPM_INT16_TYPE: + case RPM_INT8_TYPE: + case RPM_BIN_TYPE: + case RPM_CHAR_TYPE: memcpy(ptr, p, length); break; - case STRING_TYPE: + case RPM_STRING_TYPE: if (c == 1) { /* Special case -- p is just the string */ strcpy(ptr, p); break; } - /* Fall through to STRING_ARRAY_TYPE */ + /* Fall through to RPM_STRING_ARRAY_TYPE */ /* This should not be allowed */ - fprintf(stderr, "addEntry() internal error!.\n"); + fprintf(stderr, "headerAddEntry() internal error!.\n"); exit(1); - case STRING_ARRAY_TYPE: + case RPM_STRING_ARRAY_TYPE: /* Otherwise, p is char** */ i = c; spp = p; @@ -893,7 +894,7 @@ int addEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) return 1; } -int modifyEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) +int headerModifyEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) { struct indexEntry *index; @@ -916,20 +917,20 @@ int modifyEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c) } switch (index->type) { - case INT64_TYPE: + case RPM_INT64_TYPE: *((int_64 *)(h->data + index->offset)) = *((int_64 *)p); break; - case INT32_TYPE: + case RPM_INT32_TYPE: *((int_32 *)(h->data + index->offset)) = *((int_32 *)p); break; - case INT16_TYPE: + case RPM_INT16_TYPE: *((int_16 *)(h->data + index->offset)) = *((int_16 *)p); break; - case INT8_TYPE: + case RPM_INT8_TYPE: *((int_8 *)(h->data + index->offset)) = *((int_8 *)p); break; - case BIN_TYPE: - case CHAR_TYPE: + case RPM_BIN_TYPE: + case RPM_CHAR_TYPE: *((char *)(h->data + index->offset)) = *((char *)p); break; default: diff --git a/lib/header.h b/lib/header.h index 7d6d0c7b7..c320eee7d 100644 --- a/lib/header.h +++ b/lib/header.h @@ -31,49 +31,49 @@ typedef struct headerToken *Header; typedef struct headerIteratorS *HeaderIterator; /* read and write a header from a file */ -Header readHeader(int fd, int magicp); -void writeHeader(int fd, Header h, int magicp); -unsigned int sizeofHeader(Header h, int magicp); +Header headerRead(int fd, int magicp); +void headerWrite(int fd, Header h, int magicp); +unsigned int headerSizeof(Header h, int magicp); -#define NO_HEADER_MAGIC 0 -#define HEADER_MAGIC 1 +#define HEADER_MAGIC_NO 0 +#define HEADER_MAGIC_YES 1 /* load and unload a header from a chunk of memory */ -Header loadHeader(void *p); -void *unloadHeader(Header h); +Header headerLoad(void *p); +void *headerUnload(Header h); -Header newHeader(void); -void freeHeader(Header h); +Header headerNew(void); +void headerFree(Header h); /* dump a header to a file, in human readable format */ -void dumpHeader(Header h, FILE *f, int flags); +void headerDump(Header h, FILE *f, int flags); -#define DUMP_INLINE 1 -#define DUMP_SYMBOLIC 2 +#define HEADER_DUMP_INLINE 1 +#define HEADER_DUMP_SYMBOLIC 2 -int getEntry(Header h, int_32 tag, int_32 *type, void **p, int_32 *c); -int addEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c); -int modifyEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c); +int headerGetEntry(Header h, int_32 tag, int_32 *type, void **p, int_32 *c); +int headerAddEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c); +int headerModifyEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c); -int isEntry(Header h, int_32 tag); +int headerIsEntry(Header h, int_32 tag); -HeaderIterator initIterator(Header h); -int nextIterator(HeaderIterator iter, - int_32 *tag, int_32 *type, void **p, int_32 *c); -void freeIterator(HeaderIterator iter); +HeaderIterator headerInitIterator(Header h); +int headerNextIterator(HeaderIterator iter, + int_32 *tag, int_32 *type, void **p, int_32 *c); +void headerFreeIterator(HeaderIterator iter); -Header copyHeader(Header h); +Header headerCopy(Header h); /* Entry Types */ -#define NULL_TYPE 0 -#define CHAR_TYPE 1 -#define INT8_TYPE 2 -#define INT16_TYPE 3 -#define INT32_TYPE 4 -#define INT64_TYPE 5 -#define STRING_TYPE 6 -#define BIN_TYPE 7 -#define STRING_ARRAY_TYPE 8 +#define RPM_NULL_TYPE 0 +#define RPM_CHAR_TYPE 1 +#define RPM_INT8_TYPE 2 +#define RPM_INT16_TYPE 3 +#define RPM_INT32_TYPE 4 +#define RPM_INT64_TYPE 5 +#define RPM_STRING_TYPE 6 +#define RPM_BIN_TYPE 7 +#define RPM_STRING_ARRAY_TYPE 8 #endif _header_h diff --git a/lib/install.c b/lib/install.c index 87b8c1914..d7588e5a8 100644 --- a/lib/install.c +++ b/lib/install.c @@ -21,8 +21,8 @@ #include "md5.h" #include "misc.h" #include "rpmdb.h" -#include "rpmerr.h" #include "rpmlib.h" +#include "messages.h" enum instActions { CREATE, BACKUP, KEEP, SAVE, SKIP }; enum fileTypes { XDIR, BDEV, CDEV, SOCK, PIPE, REG, LINK } ; @@ -43,7 +43,7 @@ static enum instActions decideFileFate(char * filespec, short dbMode, char * dbMd5, char * dbLink, short newMode, char * newMd5, char * newLink, int brokenMd5); static int installArchive(char * prefix, int fd, struct fileToInstall * files, - int fileCount, notifyFunction notify, + int fileCount, rpmNotifyFunction notify, char ** installArchive, char * tmpPath, int archiveSize); static int packageAlreadyInstalled(rpmdb db, char * name, char * version, @@ -63,7 +63,7 @@ static int instHandleSharedFiles(rpmdb db, int ignoreOffset, char ** fileList, struct replacedFile ** repListPtr, int flags); static int fileCompare(const void * one, const void * two); static int installSources(Header h, char * rootdir, int fd, - char ** specFilePtr, notifyFunction notify, + char ** specFilePtr, rpmNotifyFunction notify, char * labelFormat); static int markReplacedFiles(rpmdb db, struct replacedFile * replList); static int relocateFilelist(Header * hp, char * defaultPrefix, @@ -78,16 +78,16 @@ static void unglobFilename(char * dptr, char * sptr); /* 1 bad magic */ /* 2 error */ int rpmInstallSourcePackage(char * rootdir, int fd, char ** specFile, - notifyFunction notify, char * labelFormat) { + rpmNotifyFunction notify, char * labelFormat) { int rc, isSource; Header h; int major, minor; - rc = pkgReadHeader(fd, &h, &isSource, &major, &minor); + rc = rpmReadPackageHeader(fd, &h, &isSource, &major, &minor); if (rc) return rc; if (!isSource) { - error(RPMERR_NOTSRPM, "source package expected, binary found"); + rpmError(RPMERR_NOTSRPM, "source package expected, binary found"); return 2; } @@ -98,7 +98,7 @@ int rpmInstallSourcePackage(char * rootdir, int fd, char ** specFile, } rc = installSources(h, rootdir, fd, specFile, notify, labelFormat); - if (h) freeHeader(h); + if (h) headerFree(h); return rc; } @@ -107,7 +107,7 @@ int rpmInstallSourcePackage(char * rootdir, int fd, char ** specFile, /* 1 bad magic */ /* 2 error */ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, - int flags, notifyFunction notify, char * labelFormat, + int flags, rpmNotifyFunction notify, char * labelFormat, char * netsharedPath) { int rc, isSource, major, minor; char * name, * version, * release; @@ -131,7 +131,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, char ** prefixedFileList = NULL; struct replacedFile * replacedList = NULL; char * defaultPrefix; - dbIndexSet matches; + dbiIndexSet matches; int * oldVersions; int * intptr; char * archivePrefix, * tmpPath; @@ -142,12 +142,12 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, oldVersions = alloca(sizeof(int)); *oldVersions = 0; - rc = pkgReadHeader(fd, &h, &isSource, &major, &minor); + rc = rpmReadPackageHeader(fd, &h, &isSource, &major, &minor); if (rc) return rc; if (isSource) { - if (flags & INSTALL_TEST) { - message(MESS_DEBUG, "stopping install as we're running --test\n"); + if (flags & RPMINSTALL_TEST) { + rpmMessage(RPMMESS_DEBUG, "stopping install as we're running --test\n"); return 0; } @@ -158,33 +158,33 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, } rc = installSources(h, rootdir, fd, NULL, notify, labelFormat); - if (h) freeHeader(h); + if (h) headerFree(h); return rc; } /* Do this now so we can give error messages, even though we'll just do it again after relocating everything */ - getEntry(h, RPMTAG_NAME, &type, (void **) &name, &fileCount); - getEntry(h, RPMTAG_VERSION, &type, (void **) &version, &fileCount); - getEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &fileCount); + headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &fileCount); + headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &fileCount); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &fileCount); - if (!getEntry(h, RPMTAG_DEFAULTPREFIX, &type, (void *) + if (!headerGetEntry(h, RPMTAG_DEFAULTPREFIX, &type, (void *) &defaultPrefix, &fileCount)) { defaultPrefix = NULL; } if (location && !defaultPrefix) { - error(RPMERR_NORELOCATE, "package %s-%s-%s is not relocatable", + rpmError(RPMERR_NORELOCATE, "package %s-%s-%s is not relocatable", name, version, release); - freeHeader(h); + headerFree(h); return 2; } else if (!location && defaultPrefix) location = defaultPrefix; if (location) { relocateFilelist(&h, defaultPrefix, location, &relocationSize); - getEntry(h, RPMTAG_DEFAULTPREFIX, &type, (void *) &defaultPrefix, + headerGetEntry(h, RPMTAG_DEFAULTPREFIX, &type, (void *) &defaultPrefix, &fileCount); archivePrefix = alloca(strlen(rootdir) + strlen(location) + 2); sprintf(archivePrefix, "%s/%s", rootdir, location); @@ -196,27 +196,27 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, /* You're probably upset because name already points to the name of this package, right? Almost... it points to the name in the original header, which could have been trahsed by relocateFileList() */ - getEntry(h, RPMTAG_NAME, &type, (void **) &name, &fileCount); - getEntry(h, RPMTAG_VERSION, &type, (void **) &version, &fileCount); - getEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &fileCount); + headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &fileCount); + headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &fileCount); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &fileCount); - if (!(flags & INSTALL_NOARCH) && !archOkay(h)) { - error(RPMERR_BADARCH, "package %s-%s-%s is for a different " + if (!(flags & RPMINSTALL_NOARCH) && !archOkay(h)) { + rpmError(RPMERR_BADARCH, "package %s-%s-%s is for a different " "architecture", name, version, release); - freeHeader(h); + headerFree(h); return 2; } - if (!(flags & INSTALL_NOOS) && !osOkay(h)) { - error(RPMERR_BADOS, "package %s-%s-%s is for a different " + if (!(flags & RPMINSTALL_NOOS) && !osOkay(h)) { + rpmError(RPMERR_BADOS, "package %s-%s-%s is for a different " "operating system", name, version, release); - freeHeader(h); + headerFree(h); return 2; } if (packageAlreadyInstalled(db, name, version, release, &otherOffset, flags)) { - freeHeader(h); + headerFree(h); return 2; } @@ -225,8 +225,8 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, fflush(stdout); } - message(MESS_DEBUG, "package: %s-%s-%s files test = %d\n", - name, version, release, flags & INSTALL_TEST); + rpmMessage(RPMMESS_DEBUG, "package: %s-%s-%s files test = %d\n", + name, version, release, flags & RPMINSTALL_TEST); rc = rpmdbFindPackage(db, name, &matches); if (rc == -1) return 2; @@ -235,7 +235,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, else scriptArg = matches.count + 1; - if (flags & INSTALL_UPGRADE) { + if (flags & RPMINSTALL_UPGRADE) { /* We need to get a list of all old version of this package. We let this install procede normally then, but: @@ -252,7 +252,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, intptr = oldVersions = alloca((matches.count + 1) * sizeof(int)); for (i = 0; i < matches.count; i++) { if (matches.recs[i].recOffset != otherOffset) { - if (!(flags & INSTALL_UPGRADETOOLD)) + if (!(flags & RPMINSTALL_UPGRADETOOLD)) if (rpmEnsureOlder(db, name, version, release, matches.recs[i].recOffset)) return 2; @@ -264,7 +264,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, } fileList = NULL; - if (getEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, + if (headerGetEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, &fileCount)) { char ** netsharedPaths; char ** nsp; @@ -279,12 +279,12 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, prefixedFileList = alloca(sizeof(char *) * fileCount); fileStatesList = alloca(sizeof(*fileStatesList) * fileCount); - getEntry(h, RPMTAG_FILEMD5S, &type, (void **) &fileMd5s, &fileCount); - getEntry(h, RPMTAG_FILEFLAGS, &type, (void **) &fileFlagsList, + headerGetEntry(h, RPMTAG_FILEMD5S, &type, (void **) &fileMd5s, &fileCount); + headerGetEntry(h, RPMTAG_FILEFLAGS, &type, (void **) &fileFlagsList, &fileCount); - getEntry(h, RPMTAG_FILEMODES, &type, (void **) &fileModesList, + headerGetEntry(h, RPMTAG_FILEMODES, &type, (void **) &fileModesList, &fileCount); - getEntry(h, RPMTAG_FILELINKTOS, &type, (void **) &fileLinkList, + headerGetEntry(h, RPMTAG_FILELINKTOS, &type, (void **) &fileLinkList, &fileCount); /* check for any config files that already exist. If they do, plan @@ -304,12 +304,12 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, if (!strncmp(prefixedFileList[i], *nsp, strlen(*nsp))) break; if (nsp && *nsp) { - message(MESS_DEBUG, "file %s in netshared path\n", + rpmMessage(RPMMESS_DEBUG, "file %s in netshared path\n", prefixedFileList[i]); instActions[i] = SKIP; fileStatesList[i] = RPMFILE_STATE_NETSHARED; } else if ((fileFlagsList[i] & RPMFILE_DOC) && - (flags & INSTALL_NODOCS)) { + (flags & RPMINSTALL_NODOCS)) { instActions[i] = SKIP; fileStatesList[i] = RPMFILE_STATE_NOTINSTALLED; } else { @@ -319,7 +319,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, if ((fileFlagsList[i] & RPMFILE_CONFIG) && !S_ISDIR(fileModesList[i])) { if (exists(prefixedFileList[i])) { - message(MESS_DEBUG, "%s exists - backing up\n", + rpmMessage(RPMMESS_DEBUG, "%s exists - backing up\n", prefixedFileList[i]); instActions[i] = BACKUP; } @@ -341,16 +341,16 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, } } - if (flags & INSTALL_TEST) { - message(MESS_DEBUG, "stopping install as we're running --test\n"); + if (flags & RPMINSTALL_TEST) { + rpmMessage(RPMMESS_DEBUG, "stopping install as we're running --test\n"); free(fileList); if (replacedList) free(replacedList); return 0; } - message(MESS_DEBUG, "running preinstall script (if any)\n"); + rpmMessage(RPMMESS_DEBUG, "running preinstall script (if any)\n"); if (runScript(rootdir, h, RPMTAG_PREIN, scriptArg, - flags & INSTALL_NOSCRIPTS)) { + flags & RPMINSTALL_NOSCRIPTS)) { free(fileList); if (replacedList) free(replacedList); return 2; @@ -358,13 +358,13 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, if (fileList) { if (createDirectories(rootdir, fileList, fileCount)) { - freeHeader(h); + headerFree(h); free(fileList); if (replacedList) free(replacedList); return 2; } - getEntry(h, RPMTAG_FILESIZES, &type, (void **) &fileSizesList, + headerGetEntry(h, RPMTAG_FILESIZES, &type, (void **) &fileSizesList, &fileCount); files = alloca(sizeof(struct fileToInstall) * fileCount); @@ -400,11 +400,11 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, newpath = malloc(strlen(prefixedFileList[i]) + 20); strcpy(newpath, prefixedFileList[i]); strcat(newpath, ext); - error(RPMMESS_BACKUP, "warning: %s saved as %s", + rpmError(RPMMESS_BACKUP, "warning: %s saved as %s", prefixedFileList[i], newpath); if (rename(prefixedFileList[i], newpath)) { - error(RPMERR_RENAME, "rename of %s to %s failed: %s", + rpmError(RPMERR_RENAME, "rename of %s to %s failed: %s", prefixedFileList[i], newpath, strerror(errno)); if (replacedList) free(replacedList); free(newpath); @@ -436,11 +436,11 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, if (rootdir) { tmpPath = alloca(strlen(rootdir) + 15); strcpy(tmpPath, rootdir); - strcat(tmpPath, getVar(RPMVAR_TMPPATH)); + strcat(tmpPath, rpmGetVar(RPMVAR_TMPPATH)); } else - tmpPath = getVar(RPMVAR_TMPPATH); + tmpPath = rpmGetVar(RPMVAR_TMPPATH); - if (!getEntry(h, RPMTAG_ARCHIVESIZE, &type, (void *) &archiveSizePtr, + if (!headerGetEntry(h, RPMTAG_ARCHIVESIZE, &type, (void *) &archiveSizePtr, &count)) archiveSizePtr = NULL; @@ -448,15 +448,15 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, if (installArchive(archivePrefix, fd, files, archiveFileCount, notify, NULL, tmpPath, archiveSizePtr ? *archiveSizePtr : 0)) { - freeHeader(h); + headerFree(h); free(fileList); if (replacedList) free(replacedList); return 2; } - if (getEntry(h, RPMTAG_FILEUSERNAME, &type, (void **) &fileOwners, + if (headerGetEntry(h, RPMTAG_FILEUSERNAME, &type, (void **) &fileOwners, &fileCount)) { - if (getEntry(h, RPMTAG_FILEGROUPNAME, &type, (void **) &fileGroups, + if (headerGetEntry(h, RPMTAG_FILEGROUPNAME, &type, (void **) &fileGroups, &fileCount)) { if (setFileOwnerships(rootdir, fileList, fileOwners, fileGroups, fileModesList, instActions, fileCount)) { @@ -473,10 +473,10 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, } free(fileList); - addEntry(h, RPMTAG_FILESTATES, CHAR_TYPE, fileStatesList, fileCount); + headerAddEntry(h, RPMTAG_FILESTATES, RPM_CHAR_TYPE, fileStatesList, fileCount); installTime = time(NULL); - addEntry(h, RPMTAG_INSTALLTIME, INT32_TYPE, &installTime, 1); + headerAddEntry(h, RPMTAG_INSTALLTIME, RPM_INT32_TYPE, &installTime, 1); } if (replacedList) { @@ -493,19 +493,19 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, } if (rpmdbAdd(db, h)) { - freeHeader(h); + headerFree(h); return 2; } - message(MESS_DEBUG, "running postinstall script (if any)\n"); + rpmMessage(RPMMESS_DEBUG, "running postinstall script (if any)\n"); if (runScript(rootdir, h, RPMTAG_POSTIN, scriptArg, - flags & INSTALL_NOSCRIPTS)) { + flags & RPMINSTALL_NOSCRIPTS)) { return 2; } - if (flags & INSTALL_UPGRADE) { - message(MESS_DEBUG, "removing old versions of package\n"); + if (flags & RPMINSTALL_UPGRADE) { + rpmMessage(RPMMESS_DEBUG, "removing old versions of package\n"); intptr = oldVersions; while (*intptr) { rpmRemovePackage(rootdir, db, *intptr, 0); @@ -513,7 +513,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, } } - freeHeader(h); + headerFree(h); return 0; } @@ -522,7 +522,7 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, /* -1 fileCount means install all files */ static int installArchive(char * prefix, int fd, struct fileToInstall * files, - int fileCount, notifyFunction notify, + int fileCount, rpmNotifyFunction notify, char ** specFile, char * tmpPath, int archiveSize) { gzFile stream; char buf[BLOCKSIZE]; @@ -556,7 +556,7 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files, /* fd should be a gzipped cpio archive */ - message(MESS_DEBUG, "installing archive into %s\n", prefix); + rpmMessage(RPMMESS_DEBUG, "installing archive into %s\n", prefix); needSecondPipe = (notify != NULL && !archiveSize) || specFile; @@ -564,7 +564,7 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files, args = alloca(sizeof(char *) * (fileCount + 10)); - args[i++] = getVar(RPMVAR_CPIOBIN); + args[i++] = rpmGetVar(RPMVAR_CPIOBIN); args[i++] = "--extract"; args[i++] = "--unconditional"; args[i++] = "--preserve-modification-time"; @@ -584,12 +584,12 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files, if (fileCount > 500) { filelist = alloca(strlen(tmpPath) + 40); - message(MESS_DEBUG, "using a %s filelist\n", tmpPath); + rpmMessage(RPMMESS_DEBUG, "using a %s filelist\n", tmpPath); sprintf(filelist, "%s/rpm-cpiofilelist.%d.tmp", tmpPath, (int) getpid()); f = fopen(filelist, "w"); if (!f) { - error(RPMERR_CREATE, "failed to create %s: %s", filelist, + rpmError(RPMERR_CREATE, "failed to create %s: %s", filelist, strerror(errno)); return 1; } @@ -598,9 +598,9 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files, if ((fputs(files[j].fileName, f) == EOF) || (fputs("\n", f) == EOF)) { if (errno == ENOSPC) { - error(RPMERR_NOSPACE, "out of space on device"); + rpmError(RPMERR_NOSPACE, "out of space on device"); } else { - error(RPMERR_CREATE, "failed to create %s: %s", filelist, + rpmError(RPMERR_CREATE, "failed to create %s: %s", filelist, strerror(errno)); } @@ -695,7 +695,7 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files, while ((chptr = (strchr(fileInstalled.fileName, '\n')))) { *chptr = '\0'; - message(MESS_DEBUG, "file \"%s\" complete\n", + rpmMessage(RPMMESS_DEBUG, "file \"%s\" complete\n", fileInstalled.fileName); if (notify && !archiveSize) { @@ -747,7 +747,7 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files, if (cpioFailed || !WIFEXITED(status) || WEXITSTATUS(status)) { /* this would probably be a good place to check if disk space was used up - if so, we should return a different error */ - error(RPMERR_CPIO, "unpacking of archive failed"); + rpmError(RPMERR_CPIO, "unpacking of archive failed"); return 1; } @@ -762,7 +762,7 @@ static int packageAlreadyInstalled(rpmdb db, char * name, char * version, char * secVersion, * secRelease; Header sech; int i; - dbIndexSet matches; + dbiIndexSet matches; int type, count; if (!rpmdbFindPackage(db, name, &matches)) { @@ -772,23 +772,23 @@ static int packageAlreadyInstalled(rpmdb db, char * name, char * version, return 1; } - getEntry(sech, RPMTAG_VERSION, &type, (void **) &secVersion, + headerGetEntry(sech, RPMTAG_VERSION, &type, (void **) &secVersion, &count); - getEntry(sech, RPMTAG_RELEASE, &type, (void **) &secRelease, + headerGetEntry(sech, RPMTAG_RELEASE, &type, (void **) &secRelease, &count); if (!strcmp(secVersion, version) && !strcmp(secRelease, release)) { *offset = matches.recs[i].recOffset; - if (!(flags & INSTALL_REPLACEPKG)) { - error(RPMERR_PKGINSTALLED, + if (!(flags & RPMINSTALL_REPLACEPKG)) { + rpmError(RPMERR_PKGINSTALLED, "package %s-%s-%s is already installed", name, version, release); - freeHeader(sech); + headerFree(sech); return 1; } } - freeHeader(sech); + headerFree(sech); } } @@ -805,14 +805,14 @@ static int setFileOwnerships(char * rootdir, char ** fileList, pid_t child; int status; - message(MESS_DEBUG, "setting file owners and groups by name (not id)\n"); + rpmMessage(RPMMESS_DEBUG, "setting file owners and groups by name (not id)\n"); chptr = rootdir; while (*chptr && *chptr == '/') chptr++; if (*chptr) { - message(MESS_DEBUG, "forking child to setid's in chroot() " + rpmMessage(RPMMESS_DEBUG, "forking child to setid's in chroot() " "environment\n"); doFork = 1; @@ -862,7 +862,7 @@ static int setFileOwner(char * file, char * owner, char * group, else { pwent = getpwnam(owner); if (!pwent) { - error(RPMERR_NOUSER, "user %s does not exist - using root", owner); + rpmError(RPMERR_NOUSER, "user %s does not exist - using root", owner); uid = 0; } else { uid = pwent->pw_uid; @@ -879,7 +879,7 @@ static int setFileOwner(char * file, char * owner, char * group, else { grent = getgrnam(group); if (!grent) { - error(RPMERR_NOGROUP, "group %s does not exist - using root", + rpmError(RPMERR_NOGROUP, "group %s does not exist - using root", group); gid = 0; } else { @@ -890,10 +890,10 @@ static int setFileOwner(char * file, char * owner, char * group, } } - message(MESS_DEBUG, "%s owned by %s (%d), group %s (%d) mode %o\n", + rpmMessage(RPMMESS_DEBUG, "%s owned by %s (%d), group %s (%d) mode %o\n", file, owner, uid, group, gid, mode & 07777); if (chown(file, uid, gid)) { - error(RPMERR_CHOWN, "cannot set owner and group for %s - %s", + rpmError(RPMERR_CHOWN, "cannot set owner and group for %s - %s", file, strerror(errno)); /* screw with the permissions so it's not SUID and 0.0 */ chmod(file, 0644); @@ -902,7 +902,7 @@ static int setFileOwner(char * file, char * owner, char * group, /* Also set the mode according to what is stored in the header */ if (! S_ISLNK(mode)) { if (chmod(file, mode & 07777)) { - error(RPMERR_CHOWN, "cannot change mode for %s - %s", + rpmError(RPMERR_CHOWN, "cannot change mode for %s - %s", file, strerror(errno)); /* screw with the permissions so it's not SUID and 0.0 */ chmod(file, 0644); @@ -1002,14 +1002,14 @@ static int mkdirIfNone(char * directory, mode_t perms) { if (exists(directory)) return 0; - message(MESS_DEBUG, "trying to make %s\n", directory); + rpmMessage(RPMMESS_DEBUG, "trying to make %s\n", directory); rc = mkdir(directory, perms); if (!rc || errno == EEXIST) return 0; chmod(directory, perms); /* this should not be modified by the umask */ - error(RPMERR_MKDIR, "failed to create %s - %s", directory, + rpmError(RPMERR_MKDIR, "failed to create %s - %s", directory, strerror(errno)); return errno; @@ -1051,18 +1051,18 @@ static enum instActions decideFileFate(char * filespec, short dbMode, newWhat = whatis(newMode); if (diskWhat != newWhat) { - message(MESS_DEBUG, " file type on disk is different then package - " + rpmMessage(RPMMESS_DEBUG, " file type on disk is different then package - " "saving\n"); return SAVE; } else if (newWhat != dbWhat && diskWhat != dbWhat) { - message(MESS_DEBUG, " file type in database is different then disk" + rpmMessage(RPMMESS_DEBUG, " file type in database is different then disk" " and package file - saving\n"); return SAVE; } else if (dbWhat != newWhat) { - message(MESS_DEBUG, " file type changed - replacing\n"); + rpmMessage(RPMMESS_DEBUG, " file type changed - replacing\n"); return CREATE; } else if (dbWhat != LINK && dbWhat != REG) { - message(MESS_DEBUG, " can't check file for changes - replacing\n"); + rpmMessage(RPMMESS_DEBUG, " can't check file for changes - replacing\n"); return CREATE; } @@ -1074,7 +1074,7 @@ static enum instActions decideFileFate(char * filespec, short dbMode, if (rc) { /* assume the file has been removed, don't freak */ - message(MESS_DEBUG, " file not present - creating"); + rpmMessage(RPMMESS_DEBUG, " file not present - creating"); return CREATE; } dbAttr = dbMd5; @@ -1084,7 +1084,7 @@ static enum instActions decideFileFate(char * filespec, short dbMode, i = readlink(filespec, buffer, sizeof(buffer) - 1); if (i == -1) { /* assume the file has been removed, don't freak */ - message(MESS_DEBUG, " file not present - creating"); + rpmMessage(RPMMESS_DEBUG, " file not present - creating"); return CREATE; } dbAttr = dbLink; @@ -1097,14 +1097,14 @@ static enum instActions decideFileFate(char * filespec, short dbMode, if (!strcmp(dbAttr, buffer)) { /* this config file has never been modified, so just replace it */ - message(MESS_DEBUG, " old == current, replacing " + rpmMessage(RPMMESS_DEBUG, " old == current, replacing " "with new version\n"); return CREATE; } if (!strcmp(dbAttr, newAttr)) { /* this file is the same in all versions of this package */ - message(MESS_DEBUG, " old == new, keeping\n"); + rpmMessage(RPMMESS_DEBUG, " old == new, keeping\n"); return KEEP; } @@ -1112,7 +1112,7 @@ static enum instActions decideFileFate(char * filespec, short dbMode, the ones in the two packages are different. It would be nice if RPM was smart enough to at least try and merge the difference ala CVS, but... */ - message(MESS_DEBUG, " files changed too much - backing up\n"); + rpmMessage(RPMMESS_DEBUG, " files changed too much - backing up\n"); return SAVE; } @@ -1158,7 +1158,7 @@ static int instHandleSharedFiles(rpmdb db, int ignoreOffset, char ** fileList, if (secOffset != sharedList[i].secRecOffset) { if (secOffset) { - freeHeader(sech); + headerFree(sech); free(secFileMd5List); free(secFileLinksList); free(secFileList); @@ -1167,47 +1167,47 @@ static int instHandleSharedFiles(rpmdb db, int ignoreOffset, char ** fileList, secOffset = sharedList[i].secRecOffset; sech = rpmdbGetRecord(db, secOffset); if (!sech) { - error(RPMERR_DBCORRUPT, "cannot read header at %d for " + rpmError(RPMERR_DBCORRUPT, "cannot read header at %d for " "uninstall", secOffset); rc = 1; break; } - getEntry(sech, RPMTAG_NAME, &type, (void **) &name, + headerGetEntry(sech, RPMTAG_NAME, &type, (void **) &name, &secFileCount); - getEntry(sech, RPMTAG_VERSION, &type, (void **) &version, + headerGetEntry(sech, RPMTAG_VERSION, &type, (void **) &version, &secFileCount); - getEntry(sech, RPMTAG_RELEASE, &type, (void **) &release, + headerGetEntry(sech, RPMTAG_RELEASE, &type, (void **) &release, &secFileCount); - message(MESS_DEBUG, "package %s-%s-%s contain shared files\n", + rpmMessage(RPMMESS_DEBUG, "package %s-%s-%s contain shared files\n", name, version, release); - if (!getEntry(sech, RPMTAG_FILENAMES, &type, + if (!headerGetEntry(sech, RPMTAG_FILENAMES, &type, (void **) &secFileList, &secFileCount)) { - error(RPMERR_DBCORRUPT, "package %s contains no files", + rpmError(RPMERR_DBCORRUPT, "package %s contains no files", name); - freeHeader(sech); + headerFree(sech); rc = 1; break; } - getEntry(sech, RPMTAG_FILESTATES, &type, + headerGetEntry(sech, RPMTAG_FILESTATES, &type, (void **) &secFileStatesList, &secFileCount); - getEntry(sech, RPMTAG_FILEMD5S, &type, + headerGetEntry(sech, RPMTAG_FILEMD5S, &type, (void **) &secFileMd5List, &secFileCount); - getEntry(sech, RPMTAG_FILEFLAGS, &type, + headerGetEntry(sech, RPMTAG_FILEFLAGS, &type, (void **) &secFileFlagsList, &secFileCount); - getEntry(sech, RPMTAG_FILELINKTOS, &type, + headerGetEntry(sech, RPMTAG_FILELINKTOS, &type, (void **) &secFileLinksList, &secFileCount); - getEntry(sech, RPMTAG_FILEMODES, &type, + headerGetEntry(sech, RPMTAG_FILEMODES, &type, (void **) &secFileModesList, &secFileCount); } secNum = sharedList[i].secFileNumber; mainNum = sharedList[i].mainFileNumber; - message(MESS_DEBUG, "file %s is shared\n", secFileList[secNum]); + rpmMessage(RPMMESS_DEBUG, "file %s is shared\n", secFileList[secNum]); intptr = notErrors; while (*intptr) { @@ -1219,18 +1219,18 @@ static int instHandleSharedFiles(rpmdb db, int ignoreOffset, char ** fileList, replaced, just forget about it */ state = secFileStatesList[sharedList[i].secFileNumber]; if (state == RPMFILE_STATE_REPLACED) { - message(MESS_DEBUG, " old version already replaced\n"); + rpmMessage(RPMMESS_DEBUG, " old version already replaced\n"); continue; } else if (state == RPMFILE_STATE_NOTINSTALLED) { - message(MESS_DEBUG, " other version never installed\n"); + rpmMessage(RPMMESS_DEBUG, " other version never installed\n"); continue; } if (filecmp(fileModesList[mainNum], fileMd5List[mainNum], fileLinkList[mainNum], secFileModesList[secNum], secFileMd5List[secNum], secFileLinksList[secNum])) { - if (!(flags & INSTALL_REPLACEFILES) && !(*intptr)) { - error(RPMERR_PKGINSTALLED, "%s conflicts with file from " + if (!(flags & RPMINSTALL_REPLACEFILES) && !(*intptr)) { + rpmError(RPMERR_PKGINSTALLED, "%s conflicts with file from " "%s-%s-%s", fileList[sharedList[i].mainFileNumber], name, version, release); rc = 1; @@ -1248,7 +1248,7 @@ static int instHandleSharedFiles(rpmdb db, int ignoreOffset, char ** fileList, sharedList[i].secFileNumber; numReplacedFiles++; - message(MESS_DEBUG, "%s from %s-%s-%s will be replaced\n", + rpmMessage(RPMMESS_DEBUG, "%s from %s-%s-%s will be replaced\n", fileList[sharedList[i].mainFileNumber], name, version, release); } @@ -1263,12 +1263,12 @@ static int instHandleSharedFiles(rpmdb db, int ignoreOffset, char ** fileList, secFileMd5List[secNum], secFileLinksList[secNum], fileModesList[mainNum], fileMd5List[mainNum], fileLinkList[mainNum], - !isEntry(sech, RPMTAG_RPMVERSION)); + !headerIsEntry(sech, RPMTAG_RPMVERSION)); } } if (secOffset) { - freeHeader(sech); + headerFree(sech); free(secFileMd5List); free(secFileLinksList); free(secFileList); @@ -1295,7 +1295,7 @@ static int fileCompare(const void * one, const void * two) { /* 1 bad magic */ /* 2 error */ static int installSources(Header h, char * rootdir, int fd, - char ** specFilePtr, notifyFunction notify, + char ** specFilePtr, rpmNotifyFunction notify, char * labelFormat) { char * specFile; char * sourceDir, * specDir; @@ -1305,18 +1305,18 @@ static int installSources(Header h, char * rootdir, int fd, uint_32 * archiveSizePtr = NULL; int type, count; - message(MESS_DEBUG, "installing a source package\n"); + rpmMessage(RPMMESS_DEBUG, "installing a source package\n"); - sourceDir = getVar(RPMVAR_SOURCEDIR); - specDir = getVar(RPMVAR_SPECDIR); + sourceDir = rpmGetVar(RPMVAR_SOURCEDIR); + specDir = rpmGetVar(RPMVAR_SPECDIR); if (access(sourceDir, W_OK)) { - error(RPMERR_CREATE, "cannot write to %s", sourceDir); + rpmError(RPMERR_CREATE, "cannot write to %s", sourceDir); return 2; } if (access(specDir, W_OK)) { - error(RPMERR_CREATE, "cannot write to %s", sourceDir); + rpmError(RPMERR_CREATE, "cannot write to %s", sourceDir); return 2; } @@ -1330,21 +1330,21 @@ static int installSources(Header h, char * rootdir, int fd, strcat(realSpecDir, "/"); strcat(realSpecDir, specDir); - message(MESS_DEBUG, "sources in: %s\n", realSourceDir); - message(MESS_DEBUG, "spec file in: %s\n", realSpecDir); + rpmMessage(RPMMESS_DEBUG, "sources in: %s\n", realSourceDir); + rpmMessage(RPMMESS_DEBUG, "spec file in: %s\n", realSpecDir); if (rootdir) { tmpPath = alloca(strlen(rootdir) + 15); strcpy(tmpPath, rootdir); - strcat(tmpPath, getVar(RPMVAR_TMPPATH)); + strcat(tmpPath, rpmGetVar(RPMVAR_TMPPATH)); } else - tmpPath = getVar(RPMVAR_TMPPATH); + tmpPath = rpmGetVar(RPMVAR_TMPPATH); if (labelFormat && h) { - getEntry(h, RPMTAG_NAME, &type, (void *) &name, &count); - getEntry(h, RPMTAG_VERSION, &type, (void *) &version, &count); - getEntry(h, RPMTAG_RELEASE, &type, (void *) &release, &count); - if (!getEntry(h, RPMTAG_ARCHIVESIZE, &type, (void *) &archiveSizePtr, + headerGetEntry(h, RPMTAG_NAME, &type, (void *) &name, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, (void *) &version, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void *) &release, &count); + if (!headerGetEntry(h, RPMTAG_ARCHIVESIZE, &type, (void *) &archiveSizePtr, &count)) archiveSizePtr = NULL; printf(labelFormat, name, version, release); @@ -1357,7 +1357,7 @@ static int installSources(Header h, char * rootdir, int fd, } if (!specFile) { - error(RPMERR_NOSPEC, "source package contains no .spec file"); + rpmError(RPMERR_NOSPEC, "source package contains no .spec file"); return 1; } @@ -1373,7 +1373,7 @@ static int installSources(Header h, char * rootdir, int fd, strcat(correctSpecFile, "/"); strcat(correctSpecFile, specFile); - message(MESS_DEBUG, "renaming %s to %s\n", instSpecFile, correctSpecFile); + rpmMessage(RPMMESS_DEBUG, "renaming %s to %s\n", instSpecFile, correctSpecFile); if (rename(instSpecFile, correctSpecFile)) { /* try copying the file */ if (moveFile(instSpecFile, correctSpecFile)) @@ -1400,7 +1400,7 @@ static int markReplacedFiles(rpmdb db, struct replacedFile * replList) { /* ignore errors here - just do the best we can */ rpmdbUpdateRecord(db, secOffset, secHeader); - freeHeader(secHeader); + headerFree(secHeader); } secOffset = fileInfo->recOffset; @@ -1408,11 +1408,11 @@ static int markReplacedFiles(rpmdb db, struct replacedFile * replList) { if (!sh) { secOffset = 0; } else { - secHeader = copyHeader(sh); /* so we can modify it */ - freeHeader(sh); + secHeader = headerCopy(sh); /* so we can modify it */ + headerFree(sh); } - getEntry(secHeader, RPMTAG_FILESTATES, &type, (void **) &secStates, + headerGetEntry(secHeader, RPMTAG_FILESTATES, &type, (void **) &secStates, &count); } @@ -1426,7 +1426,7 @@ static int markReplacedFiles(rpmdb db, struct replacedFile * replList) { /* ignore errors here - just do the best we can */ rpmdbUpdateRecord(db, secOffset, secHeader); - freeHeader(secHeader); + headerFree(secHeader); } return 0; @@ -1442,8 +1442,8 @@ int rpmEnsureOlder(rpmdb db, char * name, char * newVersion, h = rpmdbGetRecord(db, dbOffset); if (!h) return 1; - getEntry(h, RPMTAG_VERSION, &type, (void **) &oldVersion, &count); - getEntry(h, RPMTAG_RELEASE, &type, (void **) &oldRelease, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &oldVersion, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &oldRelease, &count); result = vercmp(oldVersion, newVersion); if (result < 0) @@ -1459,10 +1459,10 @@ int rpmEnsureOlder(rpmdb db, char * name, char * newVersion, } if (rc) - error(RPMERR_OLDPACKAGE, "package %s-%s-%s (which is newer) is already" + rpmError(RPMERR_OLDPACKAGE, "package %s-%s-%s (which is newer) is already" " installed", name, oldVersion, oldRelease); - freeHeader(h); + headerFree(h); return rc; } @@ -1509,11 +1509,11 @@ static int relocateFilelist(Header * hp, char * defaultPrefix, newPrefix = strcpy(alloca(strlen(newPrefix) + 1), newPrefix); stripTrailingSlashes(newPrefix); - message(MESS_DEBUG, "relocating files from %s to %s\n", defaultPrefix, + rpmMessage(RPMMESS_DEBUG, "relocating files from %s to %s\n", defaultPrefix, newPrefix); if (!strcmp(newPrefix, defaultPrefix)) { - addEntry(h, RPMTAG_INSTALLPREFIX, STRING_TYPE, defaultPrefix, 1); + headerAddEntry(h, RPMTAG_INSTALLPREFIX, RPM_STRING_TYPE, defaultPrefix, 1); *relocationLength = strlen(defaultPrefix) + 1; return 0; } @@ -1522,18 +1522,18 @@ static int relocateFilelist(Header * hp, char * defaultPrefix, newPrefixLength = strlen(newPrefix); /* packages can have empty filelists */ - if (!getEntry(h, RPMTAG_FILENAMES, &type, (void *) &fileList, &fileCount)) + if (!headerGetEntry(h, RPMTAG_FILENAMES, &type, (void *) &fileList, &fileCount)) return 0; if (!count) return 0; - newh = newHeader(); - it = initIterator(h); - while (nextIterator(it, &tag, &type, &data, &count)) + newh = headerNew(); + it = headerInitIterator(h); + while (headerNextIterator(it, &tag, &type, &data, &count)) if (tag != RPMTAG_FILENAMES) - addEntry(newh, tag, type, data, count); + headerAddEntry(newh, tag, type, data, count); - freeIterator(it); + headerFreeIterator(it); newFileList = alloca(sizeof(char *) * fileCount); for (i = 0; i < fileCount; i++) { @@ -1543,7 +1543,7 @@ static int relocateFilelist(Header * hp, char * defaultPrefix, sprintf(newFileList[i], "%s/%s", newPrefix, fileList[i] + defaultPrefixLength + 1); } else { - message(MESS_DEBUG, "BAD - unprefixed file in relocatable package"); + rpmMessage(RPMMESS_DEBUG, "BAD - unprefixed file in relocatable package"); newFileList[i] = alloca(strlen(fileList[i]) - defaultPrefixLength + 2); sprintf(newFileList[i], "/%s", fileList[i] + @@ -1551,8 +1551,8 @@ static int relocateFilelist(Header * hp, char * defaultPrefix, } } - addEntry(newh, RPMTAG_FILENAMES, STRING_ARRAY_TYPE, newFileList, fileCount); - addEntry(newh, RPMTAG_INSTALLPREFIX, STRING_TYPE, newPrefix, 1); + headerAddEntry(newh, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE, newFileList, fileCount); + headerAddEntry(newh, RPMTAG_INSTALLPREFIX, RPM_STRING_TYPE, newPrefix, 1); *relocationLength = newPrefixLength + 1; *hp = newh; @@ -1566,11 +1566,11 @@ static int archOkay(Header h) { int type, count; /* make sure we're trying to install this on the proper architecture */ - getEntry(h, RPMTAG_ARCH, &type, (void **) &pkgArch, &count); - if (type == INT8_TYPE) { + headerGetEntry(h, RPMTAG_ARCH, &type, (void **) &pkgArch, &count); + if (type == RPM_INT8_TYPE) { /* old arch handling */ pkgArchNum = pkgArch; - if (getArchNum() != *pkgArchNum) { + if (rpmGetArchNum() != *pkgArchNum) { return 0; } } else { @@ -1588,8 +1588,8 @@ static int osOkay(Header h) { int type, count; /* make sure we're trying to install this on the proper os */ - getEntry(h, RPMTAG_OS, &type, (void **) &pkgOs, &count); - if (type == INT8_TYPE) { + headerGetEntry(h, RPMTAG_OS, &type, (void **) &pkgOs, &count); + if (type == RPM_INT8_TYPE) { /* v1 packages and v2 packages both used improper OS numbers, so just deal with it hope things work */ return 1; @@ -1614,18 +1614,18 @@ static int copyFile(char * sourceName, char * destName) { int source, dest, i; char buf[16384]; - message(MESS_DEBUG, "coping %s to %s\n", sourceName, destName); + rpmMessage(RPMMESS_DEBUG, "coping %s to %s\n", sourceName, destName); source = open(sourceName, O_RDONLY); if (source < 0) { - error(RPMERR_INTERNAL, "file %s missing from source directory", + rpmError(RPMERR_INTERNAL, "file %s missing from source directory", sourceName); return 1; } dest = creat(destName, 0644); if (dest < 0) { - error(RPMERR_CREATE, "failed to create file %s", destName); + rpmError(RPMERR_CREATE, "failed to create file %s", destName); close(source); return 1; } @@ -1633,10 +1633,10 @@ static int copyFile(char * sourceName, char * destName) { while ((i = read(source, buf, sizeof(buf))) > 0) { if (write(dest, buf, i) != i) { if (errno == ENOSPC) { - error(RPMERR_NOSPACE, "out of disk space writing file %s", + rpmError(RPMERR_NOSPACE, "out of disk space writing file %s", destName); } else { - error(RPMERR_CREATE, "error writing to file %s: %s", + rpmError(RPMERR_CREATE, "error writing to file %s: %s", destName, strerror(errno)); } close(source); @@ -1647,7 +1647,7 @@ static int copyFile(char * sourceName, char * destName) { } if (i < 0) { - error(RPMERR_CREATE, "error reading from file %s: %s", + rpmError(RPMERR_CREATE, "error reading from file %s: %s", sourceName, strerror(errno)); } diff --git a/lib/messages.c b/lib/messages.c index 5f1ed3665..953db687e 100644 --- a/lib/messages.c +++ b/lib/messages.c @@ -2,59 +2,60 @@ #include #include "messages.h" +#include "rpmlib.h" -static minLevel = MESS_NORMAL; +static minLevel = RPMMESS_NORMAL; -void increaseVerbosity(void) { +void rpmIncreaseVerbosity(void) { minLevel--; } -void setVerbosity(int level) { +void rpmSetVerbosity(int level) { minLevel = level; } -int getVerbosity(void) +int rpmGetVerbosity(void) { return minLevel; } -int isDebug(void) +int rpmIsDebug(void) { - return (minLevel <= MESS_DEBUG); + return (minLevel <= RPMMESS_DEBUG); } -int isVerbose(void) +int rpmIsVerbose(void) { - return (minLevel <= MESS_VERBOSE); + return (minLevel <= RPMMESS_VERBOSE); } -void message(int level, char * format, ...) { +void rpmMessage(int level, char * format, ...) { va_list args; va_start(args, format); if (level >= minLevel) { switch (level) { - case MESS_VERBOSE: - case MESS_NORMAL: + case RPMMESS_VERBOSE: + case RPMMESS_NORMAL: vfprintf(stdout, format, args); break; - case MESS_DEBUG: + case RPMMESS_DEBUG: fprintf(stdout, "D: "); vfprintf(stdout, format, args); break; - case MESS_WARNING: + case RPMMESS_WARNING: fprintf(stderr, "warning: "); vfprintf(stderr, format, args); break; - case MESS_ERROR: + case RPMMESS_ERROR: fprintf(stderr, "error: "); vfprintf(stderr, format, args); break; - case MESS_FATALERROR: + case RPMMESS_FATALERROR: fprintf(stderr, "fatal error: "); vfprintf(stderr, format, args); exit(1); diff --git a/lib/messages.h b/lib/messages.h index e7056dbe8..b48573529 100644 --- a/lib/messages.h +++ b/lib/messages.h @@ -1,20 +1,8 @@ #ifndef H_MESSAGES #define H_MESSAGES -#define MESS_DEBUG 1 -#define MESS_VERBOSE 2 -#define MESS_NORMAL 3 -#define MESS_WARNING 4 -#define MESS_ERROR 5 -#define MESS_FATALERROR 6 +/* all the rest of what was here moved to rpmlib.h */ -#define MESS_QUIET (MESS_NORMAL + 1) - -void increaseVerbosity(void); -void setVerbosity(int level); -int getVerbosity(void); -void message(int level, char * format, ...); -int isVerbose(void); -int isDebug(void); +void rpmMessage(int level, char * format, ...); #endif diff --git a/lib/misc.c b/lib/misc.c index 6bbfcad62..04bfb81fc 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -6,7 +6,7 @@ #include #include "misc.h" -#include "rpmerr.h" +#include "rpmlib.h" #include "messages.h" char ** splitString(char * str, int length, char sep) { diff --git a/lib/oldheader.c b/lib/oldheader.c index a907cf545..77970e647 100644 --- a/lib/oldheader.c +++ b/lib/oldheader.c @@ -9,7 +9,6 @@ #include "misc.h" #include "oldheader.h" -#include "rpmerr.h" #include "rpmlib.h" #include "tread.h" @@ -295,7 +294,7 @@ void oldrpmfileFromInfoLine(char * path, char * state, char * str, else if (!strcmp(state, "replaced")) fi->state = RPMFILE_STATE_REPLACED; else - error(RPMERR_INTERNAL, "bad file state: ", state); + rpmError(RPMERR_INTERNAL, "bad file state: ", state); infoFromFields(fields, fi); diff --git a/lib/package.c b/lib/package.c index 71cc1d695..545cfff46 100644 --- a/lib/package.c +++ b/lib/package.c @@ -7,10 +7,10 @@ #include "header.h" #include "misc.h" #include "oldheader.h" -#include "rpmerr.h" #include "rpmlead.h" #include "rpmlib.h" #include "signature.h" +#include "messages.h" /* 0 = success */ /* !0 = error */ @@ -44,13 +44,13 @@ static int readPackageHeaders(int fd, struct rpmlead * leadPtr, } if (lead->major == 1) { - message(MESS_DEBUG, "package is a version one package!\n"); + rpmMessage(RPMMESS_DEBUG, "package is a version one package!\n"); if (lead->type == RPMLEAD_SOURCE) { - message(MESS_DEBUG, "old style source package -- " + rpmMessage(RPMMESS_DEBUG, "old style source package -- " "I'll do my best\n"); oldLead->archiveOffset = ntohl(oldLead->archiveOffset); - message(MESS_DEBUG, "archive offset is %d\n", + rpmMessage(RPMMESS_DEBUG, "archive offset is %d\n", oldLead->archiveOffset); lseek(fd, oldLead->archiveOffset, SEEK_SET); @@ -60,30 +60,30 @@ static int readPackageHeaders(int fd, struct rpmlead * leadPtr, *hdr = NULL; } else { - message(MESS_DEBUG, "old style binary package\n"); + rpmMessage(RPMMESS_DEBUG, "old style binary package\n"); readOldHeader(fd, hdr, &isSource); arch = lead->archnum; - addEntry(*hdr, RPMTAG_ARCH, INT8_TYPE, &arch, 1); + headerAddEntry(*hdr, RPMTAG_ARCH, RPM_INT8_TYPE, &arch, 1); arch = 1; /* old versions of RPM only supported Linux */ - addEntry(*hdr, RPMTAG_OS, INT8_TYPE, &arch, 1); + headerAddEntry(*hdr, RPMTAG_OS, RPM_INT8_TYPE, &arch, 1); } } else if (lead->major == 2 || lead->major == 3) { - if (readSignature(fd, sigs, lead->signature_type)) { + if (rpmReadSignature(fd, sigs, lead->signature_type)) { return 2; } - *hdr = readHeader(fd, (lead->major >= 3) ? - HEADER_MAGIC : NO_HEADER_MAGIC); + *hdr = headerRead(fd, (lead->major >= 3) ? + HEADER_MAGIC_YES : HEADER_MAGIC_NO); if (! *hdr) { - if (sigs) freeHeader(*sigs); + if (sigs) headerFree(*sigs); return 2; } } else { - error(RPMERR_NEWPACKAGE, "only packages with major numbers <= 3 are" + rpmError(RPMERR_NEWPACKAGE, "only packages with major numbers <= 3 are" " supported by this version of RPM"); return 2; } - if (!hdrPtr) freeHeader(*hdr); + if (!hdrPtr) headerFree(*hdr); return 0; } @@ -98,7 +98,7 @@ int rpmReadPackageInfo(int fd, Header * signatures, Header * hdr) { /* 0 = success */ /* 1 = bad magic */ /* 2 = error */ -int pkgReadHeader(int fd, Header * hdr, int * isSource, int * major, +int rpmReadPackageHeader(int fd, Header * hdr, int * isSource, int * major, int * minor) { int rc; struct rpmlead lead; @@ -140,34 +140,34 @@ static int readOldHeader(int fd, Header * hdr, int * isSource) { return 1; } - dbentry = newHeader(); - addEntry(dbentry, RPMTAG_NAME, STRING_TYPE, oldheader.name, 1); - addEntry(dbentry, RPMTAG_VERSION, STRING_TYPE, oldheader.version, 1); - addEntry(dbentry, RPMTAG_RELEASE, STRING_TYPE, oldheader.release, 1); - addEntry(dbentry, RPMTAG_DESCRIPTION, STRING_TYPE, + dbentry = headerNew(); + headerAddEntry(dbentry, RPMTAG_NAME, RPM_STRING_TYPE, oldheader.name, 1); + headerAddEntry(dbentry, RPMTAG_VERSION, RPM_STRING_TYPE, oldheader.version, 1); + headerAddEntry(dbentry, RPMTAG_RELEASE, RPM_STRING_TYPE, oldheader.release, 1); + headerAddEntry(dbentry, RPMTAG_DESCRIPTION, RPM_STRING_TYPE, spec.description, 1); - addEntry(dbentry, RPMTAG_BUILDTIME, INT32_TYPE, &spec.buildTime, 1); - addEntry(dbentry, RPMTAG_BUILDHOST, STRING_TYPE, spec.buildHost, 1); - addEntry(dbentry, RPMTAG_INSTALLTIME, INT32_TYPE, &installTime, 1); - addEntry(dbentry, RPMTAG_DISTRIBUTION, STRING_TYPE, + headerAddEntry(dbentry, RPMTAG_BUILDTIME, RPM_INT32_TYPE, &spec.buildTime, 1); + headerAddEntry(dbentry, RPMTAG_BUILDHOST, RPM_STRING_TYPE, spec.buildHost, 1); + headerAddEntry(dbentry, RPMTAG_INSTALLTIME, RPM_INT32_TYPE, &installTime, 1); + headerAddEntry(dbentry, RPMTAG_DISTRIBUTION, RPM_STRING_TYPE, spec.distribution, 1); - addEntry(dbentry, RPMTAG_VENDOR, STRING_TYPE, spec.vendor, 1); - addEntry(dbentry, RPMTAG_SIZE, INT32_TYPE, &oldheader.size, 1); - addEntry(dbentry, RPMTAG_COPYRIGHT, STRING_TYPE, spec.copyright, 1); + headerAddEntry(dbentry, RPMTAG_VENDOR, RPM_STRING_TYPE, spec.vendor, 1); + headerAddEntry(dbentry, RPMTAG_SIZE, RPM_INT32_TYPE, &oldheader.size, 1); + headerAddEntry(dbentry, RPMTAG_COPYRIGHT, RPM_STRING_TYPE, spec.copyright, 1); if (oldheader.group) - addEntry(dbentry, RPMTAG_GROUP, STRING_TYPE, oldheader.group, 1); + headerAddEntry(dbentry, RPMTAG_GROUP, RPM_STRING_TYPE, oldheader.group, 1); else - addEntry(dbentry, RPMTAG_GROUP, STRING_TYPE, "Unknown", 1); + headerAddEntry(dbentry, RPMTAG_GROUP, RPM_STRING_TYPE, "Unknown", 1); if (spec.prein) - addEntry(dbentry, RPMTAG_PREIN, STRING_TYPE, spec.prein, 1); + headerAddEntry(dbentry, RPMTAG_PREIN, RPM_STRING_TYPE, spec.prein, 1); if (spec.preun) - addEntry(dbentry, RPMTAG_PREUN, STRING_TYPE, spec.preun, 1); + headerAddEntry(dbentry, RPMTAG_PREUN, RPM_STRING_TYPE, spec.preun, 1); if (spec.postin) - addEntry(dbentry, RPMTAG_POSTIN, STRING_TYPE, spec.postin, 1); + headerAddEntry(dbentry, RPMTAG_POSTIN, RPM_STRING_TYPE, spec.postin, 1); if (spec.postun) - addEntry(dbentry, RPMTAG_POSTUN, STRING_TYPE, spec.postun, 1); + headerAddEntry(dbentry, RPMTAG_POSTUN, RPM_STRING_TYPE, spec.postun, 1); *hdr = dbentry; @@ -211,27 +211,27 @@ static int readOldHeader(int fd, Header * hdr, int * isSource) { fileFlagsList[j] |= RPMFILE_CONFIG; } - addEntry(dbentry, RPMTAG_FILENAMES, STRING_ARRAY_TYPE, fileList, + headerAddEntry(dbentry, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE, fileList, spec.fileCount); - addEntry(dbentry, RPMTAG_FILELINKTOS, STRING_ARRAY_TYPE, + headerAddEntry(dbentry, RPMTAG_FILELINKTOS, RPM_STRING_ARRAY_TYPE, fileLinktoList, spec.fileCount); - addEntry(dbentry, RPMTAG_FILEMD5S, STRING_ARRAY_TYPE, fileMD5List, + headerAddEntry(dbentry, RPMTAG_FILEMD5S, RPM_STRING_ARRAY_TYPE, fileMD5List, spec.fileCount); - addEntry(dbentry, RPMTAG_FILESIZES, INT32_TYPE, fileSizeList, + headerAddEntry(dbentry, RPMTAG_FILESIZES, RPM_INT32_TYPE, fileSizeList, spec.fileCount); - addEntry(dbentry, RPMTAG_FILEUIDS, INT32_TYPE, fileUIDList, + headerAddEntry(dbentry, RPMTAG_FILEUIDS, RPM_INT32_TYPE, fileUIDList, spec.fileCount); - addEntry(dbentry, RPMTAG_FILEGIDS, INT32_TYPE, fileGIDList, + headerAddEntry(dbentry, RPMTAG_FILEGIDS, RPM_INT32_TYPE, fileGIDList, spec.fileCount); - addEntry(dbentry, RPMTAG_FILEMTIMES, INT32_TYPE, fileMtimesList, + headerAddEntry(dbentry, RPMTAG_FILEMTIMES, RPM_INT32_TYPE, fileMtimesList, spec.fileCount); - addEntry(dbentry, RPMTAG_FILEFLAGS, INT32_TYPE, fileFlagsList, + headerAddEntry(dbentry, RPMTAG_FILEFLAGS, RPM_INT32_TYPE, fileFlagsList, spec.fileCount); - addEntry(dbentry, RPMTAG_FILEMODES, INT16_TYPE, fileModesList, + headerAddEntry(dbentry, RPMTAG_FILEMODES, RPM_INT16_TYPE, fileModesList, spec.fileCount); - addEntry(dbentry, RPMTAG_FILERDEVS, INT16_TYPE, fileRDevsList, + headerAddEntry(dbentry, RPMTAG_FILERDEVS, RPM_INT16_TYPE, fileRDevsList, spec.fileCount); - addEntry(dbentry, RPMTAG_FILESTATES, INT8_TYPE, fileStatesList, + headerAddEntry(dbentry, RPMTAG_FILESTATES, RPM_INT8_TYPE, fileStatesList, spec.fileCount); free(fileList); diff --git a/lib/rebuilddb.c b/lib/rebuilddb.c index 4bbaad0a8..933e66123 100644 --- a/lib/rebuilddb.c +++ b/lib/rebuilddb.c @@ -7,7 +7,6 @@ #include "messages.h" #include "rpmdb.h" -#include "rpmerr.h" #include "rpmlib.h" int rpmdbRebuild(char * rootdir) { @@ -17,11 +16,11 @@ int rpmdbRebuild(char * rootdir) { Header h; int failed = 0; - message(MESS_DEBUG, "rebuilding database in rootdir %s\n", rootdir); + rpmMessage(RPMMESS_DEBUG, "rebuilding database in rootdir %s\n", rootdir); - dbpath = getVar(RPMVAR_DBPATH); + dbpath = rpmGetVar(RPMVAR_DBPATH); if (!dbpath) { - message(MESS_DEBUG, "no dbpath has been set"); + rpmMessage(RPMMESS_DEBUG, "no dbpath has been set"); return 1; } @@ -29,24 +28,24 @@ int rpmdbRebuild(char * rootdir) { sprintf(newdbpath, "%s/%s/rebuilddb.%d", rootdir, dbpath, (int) getpid()); if (!access(newdbpath, F_OK)) { - error(RPMERR_MKDIR, "temporary database %s already exists", + rpmError(RPMERR_MKDIR, "temporary database %s already exists", newdbpath); } - message(MESS_DEBUG, "creating directory: %s\n", newdbpath); + rpmMessage(RPMMESS_DEBUG, "creating directory: %s\n", newdbpath); if (mkdir(newdbpath, 0755)) { - error(RPMERR_MKDIR, "error creating directory %s: %s", + rpmError(RPMERR_MKDIR, "error creating directory %s: %s", newdbpath, strerror(errno)); } sprintf(newdbpath, "%s/rebuilddb.%d", dbpath, (int) getpid()); - message(MESS_DEBUG, "opening old database\n"); + rpmMessage(RPMMESS_DEBUG, "opening old database\n"); if (openDatabase(rootdir, dbpath, &olddb, O_RDONLY, 0644, 0)) { return 1; } - message(MESS_DEBUG, "opening new database\n"); + rpmMessage(RPMMESS_DEBUG, "opening new database\n"); if (openDatabase(rootdir, newdbpath, &newdb, O_RDWR | O_CREAT, 0644, 0)) { return 1; } @@ -54,12 +53,12 @@ int rpmdbRebuild(char * rootdir) { recnum = rpmdbFirstRecNum(olddb); while (recnum) { if (!(h = rpmdbGetRecord(olddb, recnum))) { - error(RPMERR_INTERNAL, "cannot read database record at %d", recnum); + rpmError(RPMERR_INTERNAL, "cannot read database record at %d", recnum); failed = 1; break; } if (rpmdbAdd(newdb, h)) { - error(RPMERR_INTERNAL, "cannot add record originally at %d", + rpmError(RPMERR_INTERNAL, "cannot add record originally at %d", recnum); failed = 1; break; @@ -71,16 +70,16 @@ int rpmdbRebuild(char * rootdir) { rpmdbClose(newdb); if (failed) { - message(MESS_NORMAL, "failed to rebuild database; original database " + rpmMessage(RPMMESS_NORMAL, "failed to rebuild database; original database " "remains in place\n"); rpmdbRemoveDatabase(rootdir, newdbpath); return 1; } else { if (rpmdbMoveDatabase(rootdir, newdbpath, dbpath)) { - message(MESS_ERROR, "failed to replace old database with new " + rpmMessage(RPMMESS_ERROR, "failed to replace old database with new " "database!\n"); - message(MESS_ERROR, "replaces files in %s with files from %s " + rpmMessage(RPMMESS_ERROR, "replaces files in %s with files from %s " "to recover", dbpath, newdbpath); return 1; } diff --git a/lib/rpmdb.c b/lib/rpmdb.c index a51bfbef2..de9bfe527 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -15,8 +15,8 @@ #include "header.h" #include "misc.h" #include "rpmdb.h" -#include "rpmerr.h" #include "rpmlib.h" +#include "messages.h" /* XXX the signal handling in here is not thread safe */ @@ -31,13 +31,13 @@ struct rpmdb { faFile pkgs; - dbIndex * nameIndex, * fileIndex, * groupIndex, * providesIndex; - dbIndex * requiredbyIndex, * conflictsIndex; + dbiIndex * nameIndex, * fileIndex, * groupIndex, * providesIndex; + dbiIndex * requiredbyIndex, * conflictsIndex; }; -static void removeIndexEntry(dbIndex * dbi, char * name, dbIndexRecord rec, +static void removeIndexEntry(dbiIndex * dbi, char * name, dbiIndexRecord rec, int tolerant, char * idxName); -static int addIndexEntry(dbIndex * idx, char * index, unsigned int offset, +static int addIndexEntry(dbiIndex * idx, char * index, unsigned int offset, unsigned int fileNumber); static void blockSignals(void); static void unblockSignals(void); @@ -47,9 +47,9 @@ static sigset_t signalMask; int rpmdbOpen (char * prefix, rpmdb *rpmdbp, int mode, int perms) { char * dbpath; - dbpath = getVar(RPMVAR_DBPATH); + dbpath = rpmGetVar(RPMVAR_DBPATH); if (!dbpath) { - message(MESS_DEBUG, "no dbpath has been set"); + rpmMessage(RPMMESS_DEBUG, "no dbpath has been set"); return 1; } @@ -60,9 +60,9 @@ int rpmdbInit (char * prefix, int perms) { rpmdb db; char * dbpath; - dbpath = getVar(RPMVAR_DBPATH); + dbpath = rpmGetVar(RPMVAR_DBPATH); if (!dbpath) { - message(MESS_DEBUG, "no dbpath has been set"); + rpmMessage(RPMMESS_DEBUG, "no dbpath has been set"); return 1; } @@ -93,7 +93,7 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, strcpy(filename, prefix); strcat(filename, dbpath); - message(MESS_DEBUG, "opening database in %s\n", filename); + rpmMessage(RPMMESS_DEBUG, "opening database in %s\n", filename); strcat(filename, "packages.rpm"); @@ -102,7 +102,7 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, if (!justcheck || !exists(filename)) { db.pkgs = faOpen(filename, mode, 0644); if (!db.pkgs) { - error(RPMERR_DBOPEN, "failed to open %s\n", filename); + rpmError(RPMERR_DBOPEN, "failed to open %s\n", filename); return 1; } @@ -115,14 +115,14 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, if (mode & O_RDWR) { lockinfo.l_type = F_WRLCK; if (fcntl(db.pkgs->fd, F_SETLK, (void *) &lockinfo)) { - error(RPMERR_FLOCK, "cannot get %s lock on database", + rpmError(RPMERR_FLOCK, "cannot get %s lock on database", "exclusive"); return 1; } } else { lockinfo.l_type = F_RDLCK; if (fcntl(db.pkgs->fd, F_SETLK, (void *) &lockinfo)) { - error(RPMERR_FLOCK, "cannot get %s lock on database", "shared"); + rpmError(RPMERR_FLOCK, "cannot get %s lock on database", "shared"); return 1; } } @@ -133,7 +133,7 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, strcat(filename, "nameindex.rpm"); if (!justcheck || !exists(filename)) { - db.nameIndex = openDBIndex(filename, mode, 0644); + db.nameIndex = dbiOpenIndex(filename, mode, 0644); if (!db.nameIndex) { faClose(db.pkgs); return 1; @@ -145,10 +145,10 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, strcat(filename, "fileindex.rpm"); if (!justcheck || !exists(filename)) { - db.fileIndex = openDBIndex(filename, mode, 0644); + db.fileIndex = dbiOpenIndex(filename, mode, 0644); if (!db.fileIndex) { faClose(db.pkgs); - closeDBIndex(db.nameIndex); + dbiCloseIndex(db.nameIndex); return 1; } } @@ -158,11 +158,11 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, strcat(filename, "groupindex.rpm"); if (!justcheck || !exists(filename)) { - db.groupIndex = openDBIndex(filename, mode, 0644); + db.groupIndex = dbiOpenIndex(filename, mode, 0644); if (!db.groupIndex) { faClose(db.pkgs); - closeDBIndex(db.nameIndex); - closeDBIndex(db.fileIndex); + dbiCloseIndex(db.nameIndex); + dbiCloseIndex(db.fileIndex); return 1; } } @@ -172,12 +172,12 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, strcat(filename, "providesindex.rpm"); if (!justcheck || !exists(filename)) { - db.providesIndex = openDBIndex(filename, mode, 0644); + db.providesIndex = dbiOpenIndex(filename, mode, 0644); if (!db.providesIndex) { faClose(db.pkgs); - closeDBIndex(db.fileIndex); - closeDBIndex(db.nameIndex); - closeDBIndex(db.groupIndex); + dbiCloseIndex(db.fileIndex); + dbiCloseIndex(db.nameIndex); + dbiCloseIndex(db.groupIndex); return 1; } } @@ -187,13 +187,13 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, strcat(filename, "requiredby.rpm"); if (!justcheck || !exists(filename)) { - db.requiredbyIndex = openDBIndex(filename, mode, 0644); + db.requiredbyIndex = dbiOpenIndex(filename, mode, 0644); if (!db.requiredbyIndex) { faClose(db.pkgs); - closeDBIndex(db.fileIndex); - closeDBIndex(db.nameIndex); - closeDBIndex(db.groupIndex); - closeDBIndex(db.providesIndex); + dbiCloseIndex(db.fileIndex); + dbiCloseIndex(db.nameIndex); + dbiCloseIndex(db.groupIndex); + dbiCloseIndex(db.providesIndex); return 1; } } @@ -203,14 +203,14 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, strcat(filename, "conflictsindex.rpm"); if (!justcheck || !exists(filename)) { - db.conflictsIndex = openDBIndex(filename, mode, 0644); + db.conflictsIndex = dbiOpenIndex(filename, mode, 0644); if (!db.conflictsIndex) { faClose(db.pkgs); - closeDBIndex(db.fileIndex); - closeDBIndex(db.nameIndex); - closeDBIndex(db.groupIndex); - closeDBIndex(db.providesIndex); - closeDBIndex(db.requiredbyIndex); + dbiCloseIndex(db.fileIndex); + dbiCloseIndex(db.nameIndex); + dbiCloseIndex(db.groupIndex); + dbiCloseIndex(db.providesIndex); + dbiCloseIndex(db.requiredbyIndex); return 1; } } @@ -227,12 +227,12 @@ int openDatabase(char * prefix, char * dbpath, rpmdb *rpmdbp, int mode, void rpmdbClose (rpmdb db) { if (db->pkgs) faClose(db->pkgs); - if (db->fileIndex) closeDBIndex(db->fileIndex); - if (db->groupIndex) closeDBIndex(db->groupIndex); - if (db->nameIndex) closeDBIndex(db->nameIndex); - if (db->providesIndex) closeDBIndex(db->providesIndex); - if (db->requiredbyIndex) closeDBIndex(db->requiredbyIndex); - if (db->conflictsIndex) closeDBIndex(db->conflictsIndex); + if (db->fileIndex) dbiCloseIndex(db->fileIndex); + if (db->groupIndex) dbiCloseIndex(db->groupIndex); + if (db->nameIndex) dbiCloseIndex(db->nameIndex); + if (db->providesIndex) dbiCloseIndex(db->providesIndex); + if (db->requiredbyIndex) dbiCloseIndex(db->requiredbyIndex); + if (db->conflictsIndex) dbiCloseIndex(db->conflictsIndex); free(db); } @@ -248,58 +248,58 @@ unsigned int rpmdbNextRecNum(rpmdb db, unsigned int lastOffset) { Header rpmdbGetRecord(rpmdb db, unsigned int offset) { lseek(db->pkgs->fd, offset, SEEK_SET); - return readHeader(db->pkgs->fd, NO_HEADER_MAGIC); + return headerRead(db->pkgs->fd, HEADER_MAGIC_NO); } -int rpmdbFindByFile(rpmdb db, char * filespec, dbIndexSet * matches) { - return searchDBIndex(db->fileIndex, filespec, matches); +int rpmdbFindByFile(rpmdb db, char * filespec, dbiIndexSet * matches) { + return dbiSearchIndex(db->fileIndex, filespec, matches); } -int rpmdbFindByProvides(rpmdb db, char * filespec, dbIndexSet * matches) { - return searchDBIndex(db->providesIndex, filespec, matches); +int rpmdbFindByProvides(rpmdb db, char * filespec, dbiIndexSet * matches) { + return dbiSearchIndex(db->providesIndex, filespec, matches); } -int rpmdbFindByRequiredBy(rpmdb db, char * filespec, dbIndexSet * matches) { - return searchDBIndex(db->requiredbyIndex, filespec, matches); +int rpmdbFindByRequiredBy(rpmdb db, char * filespec, dbiIndexSet * matches) { + return dbiSearchIndex(db->requiredbyIndex, filespec, matches); } -int rpmdbFindByConflicts(rpmdb db, char * filespec, dbIndexSet * matches) { - return searchDBIndex(db->conflictsIndex, filespec, matches); +int rpmdbFindByConflicts(rpmdb db, char * filespec, dbiIndexSet * matches) { + return dbiSearchIndex(db->conflictsIndex, filespec, matches); } -int rpmdbFindByGroup(rpmdb db, char * group, dbIndexSet * matches) { - return searchDBIndex(db->groupIndex, group, matches); +int rpmdbFindByGroup(rpmdb db, char * group, dbiIndexSet * matches) { + return dbiSearchIndex(db->groupIndex, group, matches); } -int rpmdbFindPackage(rpmdb db, char * name, dbIndexSet * matches) { - return searchDBIndex(db->nameIndex, name, matches); +int rpmdbFindPackage(rpmdb db, char * name, dbiIndexSet * matches) { + return dbiSearchIndex(db->nameIndex, name, matches); } -static void removeIndexEntry(dbIndex * dbi, char * key, dbIndexRecord rec, +static void removeIndexEntry(dbiIndex * dbi, char * key, dbiIndexRecord rec, int tolerant, char * idxName) { int rc; - dbIndexSet matches; + dbiIndexSet matches; - rc = searchDBIndex(dbi, key, &matches); + rc = dbiSearchIndex(dbi, key, &matches); switch (rc) { case 0: - if (removeDBIndexRecord(&matches, rec) && !tolerant) { - error(RPMERR_DBCORRUPT, "package %s not listed in %s", + if (dbiRemoveIndexRecord(&matches, rec) && !tolerant) { + rpmError(RPMERR_DBCORRUPT, "package %s not listed in %s", key, idxName); } else { - updateDBIndex(dbi, key, &matches); + dbiUpdateIndex(dbi, key, &matches); /* errors from above will be reported from dbindex.c */ } break; case 1: if (!tolerant) - error(RPMERR_DBCORRUPT, "package %s not found in %s", key, idxName); + rpmError(RPMERR_DBCORRUPT, "package %s not found in %s", key, idxName); break; case 2: break; /* error message already generated from dbindex.c */ } - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) { @@ -307,7 +307,7 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) { char * name, * group; int type; unsigned int count; - dbIndexRecord rec; + dbiIndexRecord rec; char ** fileList, ** providesList, ** requiredbyList; char ** conflictList; int i; @@ -317,31 +317,31 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) { h = rpmdbGetRecord(db, offset); if (!h) { - error(RPMERR_DBCORRUPT, "cannot read header at %d for uninstall", + rpmError(RPMERR_DBCORRUPT, "cannot read header at %d for uninstall", offset); return 1; } blockSignals(); - if (!getEntry(h, RPMTAG_NAME, &type, (void **) &name, &count)) { - error(RPMERR_DBCORRUPT, "package has no name"); + if (!headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count)) { + rpmError(RPMERR_DBCORRUPT, "package has no name"); } else { - message(MESS_DEBUG, "removing name index\n"); + rpmMessage(RPMMESS_DEBUG, "removing name index\n"); removeIndexEntry(db->nameIndex, name, rec, tolerant, "name index"); } - if (!getEntry(h, RPMTAG_GROUP, &type, (void **) &group, &count)) { - message(MESS_DEBUG, "package has no group\n"); + if (!headerGetEntry(h, RPMTAG_GROUP, &type, (void **) &group, &count)) { + rpmMessage(RPMMESS_DEBUG, "package has no group\n"); } else { - message(MESS_DEBUG, "removing group index\n"); + rpmMessage(RPMMESS_DEBUG, "removing group index\n"); removeIndexEntry(db->groupIndex, group, rec, tolerant, "group index"); } - if (getEntry(h, RPMTAG_PROVIDES, &type, (void **) &providesList, + if (headerGetEntry(h, RPMTAG_PROVIDES, &type, (void **) &providesList, &count)) { for (i = 0; i < count; i++) { - message(MESS_DEBUG, "removing provides index for %s\n", + rpmMessage(RPMMESS_DEBUG, "removing provides index for %s\n", providesList[i]); removeIndexEntry(db->providesIndex, providesList[i], rec, tolerant, "providesfile index"); @@ -349,10 +349,10 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) { free(providesList); } - if (getEntry(h, RPMTAG_REQUIRENAME, &type, (void **) &requiredbyList, + if (headerGetEntry(h, RPMTAG_REQUIRENAME, &type, (void **) &requiredbyList, &count)) { for (i = 0; i < count; i++) { - message(MESS_DEBUG, "removing requiredby index for %s\n", + rpmMessage(RPMMESS_DEBUG, "removing requiredby index for %s\n", requiredbyList[i]); removeIndexEntry(db->requiredbyIndex, requiredbyList[i], rec, tolerant, "requiredby index"); @@ -360,10 +360,10 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) { free(requiredbyList); } - if (getEntry(h, RPMTAG_CONFLICTNAME, &type, (void **) &conflictList, + if (headerGetEntry(h, RPMTAG_CONFLICTNAME, &type, (void **) &conflictList, &count)) { for (i = 0; i < count; i++) { - message(MESS_DEBUG, "removing conflict index for %s\n", + rpmMessage(RPMMESS_DEBUG, "removing conflict index for %s\n", conflictList[i]); removeIndexEntry(db->conflictsIndex, conflictList[i], rec, tolerant, "conflict index"); @@ -371,51 +371,51 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) { free(conflictList); } - if (getEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, + if (headerGetEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, &count)) { for (i = 0; i < count; i++) { - message(MESS_DEBUG, "removing file index for %s\n", fileList[i]); + rpmMessage(RPMMESS_DEBUG, "removing file index for %s\n", fileList[i]); rec.fileNumber = i; removeIndexEntry(db->fileIndex, fileList[i], rec, tolerant, "file index"); } free(fileList); } else { - message(MESS_DEBUG, "package has no files\n"); + rpmMessage(RPMMESS_DEBUG, "package has no files\n"); } faFree(db->pkgs, offset); - syncDBIndex(db->nameIndex); - syncDBIndex(db->groupIndex); - syncDBIndex(db->fileIndex); + dbiSyncIndex(db->nameIndex); + dbiSyncIndex(db->groupIndex); + dbiSyncIndex(db->fileIndex); unblockSignals(); - freeHeader(h); + headerFree(h); return 0; } -static int addIndexEntry(dbIndex * idx, char * index, unsigned int offset, +static int addIndexEntry(dbiIndex * idx, char * index, unsigned int offset, unsigned int fileNumber) { - dbIndexSet set; - dbIndexRecord irec; + dbiIndexSet set; + dbiIndexRecord irec; int rc; irec.recOffset = offset; irec.fileNumber = fileNumber; - rc = searchDBIndex(idx, index, &set); + rc = dbiSearchIndex(idx, index, &set); if (rc == -1) /* error */ return 1; if (rc == 1) /* new item */ - set = createDBIndexRecord(); - appendDBIndexRecord(&set, irec); - if (updateDBIndex(idx, index, &set)) + set = dbiCreateIndexRecord(); + dbiAppendIndexRecord(&set, irec); + if (dbiUpdateIndex(idx, index, &set)) exit(1); - freeDBIndexRecord(set); + dbiFreeIndexRecord(set); return 0; } @@ -431,36 +431,36 @@ int rpmdbAdd(rpmdb db, Header dbentry) { int type; int rc = 0; - getEntry(dbentry, RPMTAG_NAME, &type, (void **) &name, &count); - getEntry(dbentry, RPMTAG_GROUP, &type, (void **) &group, &count); + headerGetEntry(dbentry, RPMTAG_NAME, &type, (void **) &name, &count); + headerGetEntry(dbentry, RPMTAG_GROUP, &type, (void **) &group, &count); if (!group) group = "Unknown"; - if (!getEntry(dbentry, RPMTAG_FILENAMES, &type, (void **) &fileList, + if (!headerGetEntry(dbentry, RPMTAG_FILENAMES, &type, (void **) &fileList, &count)) { count = 0; } - if (!getEntry(dbentry, RPMTAG_PROVIDES, &type, (void **) &providesList, + if (!headerGetEntry(dbentry, RPMTAG_PROVIDES, &type, (void **) &providesList, &providesCount)) { providesCount = 0; } - if (!getEntry(dbentry, RPMTAG_REQUIRENAME, &type, + if (!headerGetEntry(dbentry, RPMTAG_REQUIRENAME, &type, (void **) &requiredbyList, &requiredbyCount)) { requiredbyCount = 0; } - if (!getEntry(dbentry, RPMTAG_CONFLICTNAME, &type, + if (!headerGetEntry(dbentry, RPMTAG_CONFLICTNAME, &type, (void **) &conflictList, &conflictCount)) { conflictCount = 0; } blockSignals(); - dboffset = faAlloc(db->pkgs, sizeofHeader(dbentry, NO_HEADER_MAGIC)); + dboffset = faAlloc(db->pkgs, headerSizeof(dbentry, HEADER_MAGIC_NO)); if (!dboffset) { - error(RPMERR_DBCORRUPT, "cannot allocate space for database"); + rpmError(RPMERR_DBCORRUPT, "cannot allocate space for database"); unblockSignals(); if (providesCount) free(providesList); if (requiredbyCount) free(requiredbyList); @@ -469,7 +469,7 @@ int rpmdbAdd(rpmdb db, Header dbentry) { } lseek(db->pkgs->fd, dboffset, SEEK_SET); - writeHeader(db->pkgs->fd, dbentry, NO_HEADER_MAGIC); + headerWrite(db->pkgs->fd, dbentry, HEADER_MAGIC_NO); /* Now update the appropriate indexes */ if (addIndexEntry(db->nameIndex, name, dboffset, 0)) @@ -497,11 +497,11 @@ int rpmdbAdd(rpmdb db, Header dbentry) { rc = 1; } - syncDBIndex(db->nameIndex); - syncDBIndex(db->groupIndex); - syncDBIndex(db->fileIndex); - syncDBIndex(db->providesIndex); - syncDBIndex(db->requiredbyIndex); + dbiSyncIndex(db->nameIndex); + dbiSyncIndex(db->groupIndex); + dbiSyncIndex(db->fileIndex); + dbiSyncIndex(db->providesIndex); + dbiSyncIndex(db->requiredbyIndex); unblockSignals(); @@ -517,14 +517,14 @@ int rpmdbUpdateRecord(rpmdb db, int offset, Header newHeader) { oldHeader = rpmdbGetRecord(db, offset); if (!oldHeader) { - error(RPMERR_DBCORRUPT, "cannot read header at %d for update", + rpmError(RPMERR_DBCORRUPT, "cannot read header at %d for update", offset); return 1; } - if (sizeofHeader(oldHeader, NO_HEADER_MAGIC) != - sizeofHeader(newHeader, NO_HEADER_MAGIC)) { - message(MESS_DEBUG, "header changed size!"); + if (headerSizeof(oldHeader, HEADER_MAGIC_NO) != + headerSizeof(newHeader, HEADER_MAGIC_NO)) { + rpmMessage(RPMMESS_DEBUG, "header changed size!"); if (rpmdbRemove(db, offset, 1)) return 1; @@ -535,7 +535,7 @@ int rpmdbUpdateRecord(rpmdb db, int offset, Header newHeader) { lseek(db->pkgs->fd, offset, SEEK_SET); - writeHeader(db->pkgs->fd, newHeader, NO_HEADER_MAGIC); + headerWrite(db->pkgs->fd, newHeader, HEADER_MAGIC_NO); unblockSignals(); } diff --git a/lib/rpmerr.c b/lib/rpmerr.c index 38000aad6..8106f7242 100644 --- a/lib/rpmerr.c +++ b/lib/rpmerr.c @@ -1,33 +1,33 @@ #include #include -#include "rpmerr.h" +#include "rpmlib.h" static struct err { int code; char string[1024]; } errorRec; -static CallBackType errorCallback = NULL; +static rpmErrorCallBackType errorCallback = NULL; -int errCode(void) +int rpmErrorCode(void) { return errorRec.code; } -char *errCodeString(void) +char *rpmErrorCodeString(void) { return NULL; } -char *errString(void) +char *rpmErrorString(void) { return errorRec.string; } -CallBackType errSetCallback(CallBackType cb) +rpmErrorCallBackType rpmErrorSetCallback(rpmErrorCallBackType cb) { - CallBackType ocb; + rpmErrorCallBackType ocb; ocb = errorCallback; errorCallback = cb; @@ -35,7 +35,7 @@ CallBackType errSetCallback(CallBackType cb) return ocb; } -void error(int code, char *format, ...) +void rpmError(int code, char *format, ...) { va_list args; diff --git a/lib/rpmlead.c b/lib/rpmlead.c index d5b10bece..4e4bcc8e1 100644 --- a/lib/rpmlead.c +++ b/lib/rpmlead.c @@ -9,7 +9,7 @@ #include #include -#include "rpmerr.h" +#include "rpmlib.h" #include "rpmlead.h" #include "tread.h" @@ -39,7 +39,7 @@ int writeLead(int fd, struct rpmlead *lead) int readLead(int fd, struct rpmlead *lead) { if (timedRead(fd, lead, sizeof(*lead)) != sizeof(*lead)) { - error(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno), + rpmError(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno), errno); return 1; } diff --git a/lib/rpmlead.h b/lib/rpmlead.h index e6bee1b62..a8c3f7322 100644 --- a/lib/rpmlead.h +++ b/lib/rpmlead.h @@ -1,39 +1,9 @@ #ifndef _H_RPMLEAD #define _H_RPMLEAD -#define RPMLEAD_BINARY 0 -#define RPMLEAD_SOURCE 1 +#include "rpmlib.h" -#define RPMLEAD_MAGIC0 0xed -#define RPMLEAD_MAGIC1 0xab -#define RPMLEAD_MAGIC2 0xee -#define RPMLEAD_MAGIC3 0xdb - -/* The lead needs to be 8 byte aligned */ - -#define RPMLEAD_SIZE 96 - -struct rpmlead { - unsigned char magic[4]; - unsigned char major, minor; - short type; - short archnum; - char name[66]; - short osnum; - short signature_type; - char reserved[16]; /* pads to 96 bytes -- 8 byte aligned! */ -} ; - -struct oldrpmlead { /* for version 1 packages */ - unsigned char magic[4]; - unsigned char major, minor; - short type; - short archnum; - char name[66]; - unsigned int specOffset; - unsigned int specLength; - unsigned int archiveOffset; -} ; +/* Other definitions went to rpmlib.h */ int writeLead(int fd, struct rpmlead *lead); int readLead(int fd, struct rpmlead *lead); diff --git a/lib/rpmlib.h b/lib/rpmlib.h index ad629a361..2e237a7c8 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -8,7 +8,6 @@ /* it shouldn't need these :-( */ #include "dbindex.h" #include "header.h" -#include "messages.h" struct rpmTagTableEntry { char * name; @@ -16,8 +15,8 @@ struct rpmTagTableEntry { }; int rpmReadPackageInfo(int fd, Header * signatures, Header * hdr); -int pkgReadHeader(int fd, Header * hdr, int * isSource, int * major, - int * minor); +int rpmReadPackageHeader(int fd, Header * hdr, int * isSource, int * major, + int * minor); /* 0 = success */ /* 1 = bad magic */ /* 2 = error */ @@ -112,41 +111,41 @@ extern const int rpmTagTableSize; #define RPMFILE_DOC (1 << 1) #define RPMFILE_SPECFILE (1 << 2) -#define INSTALL_REPLACEPKG (1 << 0) -#define INSTALL_REPLACEFILES (1 << 1) -#define INSTALL_TEST (1 << 2) -#define INSTALL_UPGRADE (1 << 3) -#define INSTALL_UPGRADETOOLD (1 << 4) -#define INSTALL_NODOCS (1 << 5) -#define INSTALL_NOSCRIPTS (1 << 6) -#define INSTALL_NOARCH (1 << 7) -#define INSTALL_NOOS (1 << 8) +#define RPMINSTALL_REPLACEPKG (1 << 0) +#define RPMINSTALL_REPLACEFILES (1 << 1) +#define RPMINSTALL_TEST (1 << 2) +#define RPMINSTALL_UPGRADE (1 << 3) +#define RPMINSTALL_UPGRADETOOLD (1 << 4) +#define RPMINSTALL_NODOCS (1 << 5) +#define RPMINSTALL_NOSCRIPTS (1 << 6) +#define RPMINSTALL_NOARCH (1 << 7) +#define RPMINSTALL_NOOS (1 << 8) -#define UNINSTALL_TEST (1 << 0) -#define UNINSTALL_NOSCRIPTS (1 << 1) +#define RPMUNINSTALL_TEST (1 << 0) +#define RPMUNINSTALL_NOSCRIPTS (1 << 1) -#define VERIFY_NONE 0 -#define VERIFY_MD5 (1 << 0) -#define VERIFY_FILESIZE (1 << 1) -#define VERIFY_LINKTO (1 << 2) -#define VERIFY_USER (1 << 3) -#define VERIFY_GROUP (1 << 4) -#define VERIFY_MTIME (1 << 5) -#define VERIFY_MODE (1 << 6) -#define VERIFY_RDEV (1 << 7) -#define VERIFY_ALL ~(VERIFY_NONE) +#define RPMVERIFY_NONE 0 +#define RPMVERIFY_MD5 (1 << 0) +#define RPMVERIFY_FILESIZE (1 << 1) +#define RPMVERIFY_LINKTO (1 << 2) +#define RPMVERIFY_USER (1 << 3) +#define RPMVERIFY_GROUP (1 << 4) +#define RPMVERIFY_MTIME (1 << 5) +#define RPMVERIFY_MODE (1 << 6) +#define RPMVERIFY_RDEV (1 << 7) +#define RPMVERIFY_ALL ~(RPMVERIFY_NONE) -#define REQUIRE_ANY 0 -#define REQUIRE_SERIAL (1 << 0) -#define REQUIRE_LESS (1 << 1) -#define REQUIRE_GREATER (1 << 2) -#define REQUIRE_EQUAL (1 << 3) -#define REQUIRE_PROVIDES (1 << 4) /* only used internally by builds */ -#define REQUIRE_CONFLICTS (1 << 5) /* only used internally by builds */ -#define REQUIRE_SENSEMASK 15 /* Mask to get senses */ +#define RPMSENSE_ANY 0 +#define RPMSENSE_SERIAL (1 << 0) +#define RPMSENSE_LESS (1 << 1) +#define RPMSENSE_GREATER (1 << 2) +#define RPMSENSE_EQUAL (1 << 3) +#define RPMSENSE_PROVIDES (1 << 4) /* only used internally by builds */ +#define RPMSENSE_CONFLICTS (1 << 5) /* only used internally by builds */ +#define RPMSENSE_SENSEMASK 15 /* Mask to get senses */ -#define TRIGGER_ON (1 << 16) -#define TRIGGER_OFF (1 << 17) +#define RPMSENSE_TRIGGER_ON (1 << 16) +#define RPMSENSE_TRIGGER_OFF (1 << 17) /* Stuff for maintaining "variables" like SOURCEDIR, BUILDDIR, etc */ @@ -187,21 +186,26 @@ extern const int rpmTagTableSize; #define RPMVAR_DEFAULTDOCDIR 34 #define RPMVAR_LASTVAR 35 /* IMPORTANT to keep right! */ -char *getVar(int var); -int getBooleanVar(int var); -void setVar(int var, char *val); +char *rpmGetVar(int var); +int rpmGetBooleanVar(int var); +void rpmSetVar(int var, char *val); + +/** rpmrc.c **/ -/* rpmrc.c */ int rpmReadConfigFiles(char * file, char * arch, char * os, int building); -int getOsNum(void); -int getArchNum(void); -char *getOsName(void); -char *getArchName(void); +int rpmGetOsNum(void); +int rpmGetArchNum(void); +char *rpmGetOsName(void); +char *rpmGetArchName(void); int rpmShowRC(FILE *f); +int rpmArchScore(char * arch); +int rpmOsScore(char * arch); + +/** **/ typedef struct rpmdb * rpmdb; -typedef void (*notifyFunction)(const unsigned long amount, +typedef void (*rpmNotifyFunction)(const unsigned long amount, const unsigned long total); int rpmdbOpen (char * prefix, rpmdb * dbp, int mode, int perms); @@ -215,19 +219,17 @@ unsigned int rpmdbNextRecNum(rpmdb db, unsigned int lastOffset); /* 0 at end */ Header rpmdbGetRecord(rpmdb db, unsigned int offset); -int rpmdbFindByFile(rpmdb db, char * filespec, dbIndexSet * matches); -int rpmdbFindByGroup(rpmdb db, char * group, dbIndexSet * matches); -int rpmdbFindPackage(rpmdb db, char * name, dbIndexSet * matches); -int rpmdbFindByProvides(rpmdb db, char * filespec, dbIndexSet * matches); -int rpmdbFindByRequiredBy(rpmdb db, char * filespec, dbIndexSet * matches); -int rpmdbFindByConflicts(rpmdb db, char * filespec, dbIndexSet * matches); +int rpmdbFindByFile(rpmdb db, char * filespec, dbiIndexSet * matches); +int rpmdbFindByGroup(rpmdb db, char * group, dbiIndexSet * matches); +int rpmdbFindPackage(rpmdb db, char * name, dbiIndexSet * matches); +int rpmdbFindByProvides(rpmdb db, char * filespec, dbiIndexSet * matches); +int rpmdbFindByRequiredBy(rpmdb db, char * filespec, dbiIndexSet * matches); +int rpmdbFindByConflicts(rpmdb db, char * filespec, dbiIndexSet * matches); -int rpmArchScore(char * arch); -int rpmOsScore(char * arch); int rpmInstallSourcePackage(char * prefix, int fd, char ** specFile, - notifyFunction notify, char * labelFormat); + rpmNotifyFunction notify, char * labelFormat); int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * prefix, - int flags, notifyFunction notify, char * labelFormat, + int flags, rpmNotifyFunction notify, char * labelFormat, char * netsharedPath); int rpmEnsureOlder(rpmdb db, char * name, char * newVersion, char * newRelease, int dbOffset); @@ -258,6 +260,151 @@ void rpmdepDone(rpmDependencies rpmdep); void rpmdepFreeConflicts(struct rpmDependencyConflict * conflicts, int numConflicts); -int mdfile(char *fn, unsigned char *digest); +/** messages.c **/ + +#define RPMMESS_DEBUG 1 +#define RPMMESS_VERBOSE 2 +#define RPMMESS_NORMAL 3 +#define RPMMESS_WARNING 4 +#define RPMMESS_ERROR 5 +#define RPMMESS_FATALERROR 6 + +#define RPMMESS_QUIET (RPMMESS_NORMAL + 1) + +void rpmIncreaseVerbosity(void); +void rpmSetVerbosity(int level); +int rpmGetVerbosity(void); +int rpmIsVerbose(void); +int rpmIsDebug(void); + +/** rpmlead.c **/ + +#define RPMLEAD_BINARY 0 +#define RPMLEAD_SOURCE 1 + +#define RPMLEAD_MAGIC0 0xed +#define RPMLEAD_MAGIC1 0xab +#define RPMLEAD_MAGIC2 0xee +#define RPMLEAD_MAGIC3 0xdb + +/* The lead needs to be 8 byte aligned */ + +#define RPMLEAD_SIZE 96 + +struct rpmlead { + unsigned char magic[4]; + unsigned char major, minor; + short type; + short archnum; + char name[66]; + short osnum; + short signature_type; + char reserved[16]; /* pads to 96 bytes -- 8 byte aligned! */ +} ; + +struct oldrpmlead { /* for version 1 packages */ + unsigned char magic[4]; + unsigned char major, minor; + short type; + short archnum; + char name[66]; + unsigned int specOffset; + unsigned int specLength; + unsigned int archiveOffset; +} ; + +/** rpmerr.c **/ + +typedef void (*rpmErrorCallBackType)(void); + +void rpmError(int code, char * format, ...); +int rpmErrorCode(void); +char *rpmErrorString(void); +rpmErrorCallBackType rpmErrorSetCallback(rpmErrorCallBackType); + +#define RPMERR_GDBMOPEN -2 /* gdbm open failed */ +#define RPMERR_GDBMREAD -3 /* gdbm read failed */ +#define RPMERR_GDBMWRITE -4 /* gdbm write failed */ +#define RPMERR_INTERNAL -5 /* internal RPM error */ +#define RPMERR_DBCORRUPT -6 /* rpm database is corrupt */ +#define RPMERR_OLDDBCORRUPT -7 /* old style rpm database is corrupt */ +#define RPMERR_OLDDBMISSING -8 /* old style rpm database is missing */ +#define RPMERR_NOCREATEDB -9 /* cannot create new database */ +#define RPMERR_DBOPEN -10 /* database open failed */ +#define RPMERR_DBGETINDEX -11 /* database get from index failed */ +#define RPMERR_DBPUTINDEX -12 /* database get from index failed */ +#define RPMERR_NEWPACKAGE -13 /* package is too new to handle */ +#define RPMERR_BADMAGIC -14 /* bad magic for an RPM */ +#define RPMERR_RENAME -15 /* rename(2) failed */ +#define RPMERR_UNLINK -16 /* unlink(2) failed */ +#define RPMERR_RMDIR -17 /* rmdir(2) failed */ +#define RPMERR_PKGINSTALLED -18 /* package already installed */ +#define RPMERR_CHOWN -19 /* chown() call failed */ +#define RPMERR_NOUSER -20 /* user does not exist */ +#define RPMERR_NOGROUP -21 /* group does not exist */ +#define RPMERR_MKDIR -22 /* mkdir() call failed */ +#define RPMERR_FILECONFLICT -23 /* file being installed exists */ +#define RPMERR_RPMRC -24 /* bad line in rpmrc */ +#define RPMERR_NOSPEC -25 /* .spec file is missing */ +#define RPMERR_NOTSRPM -26 /* a source rpm was expected */ +#define RPMERR_FLOCK -27 /* locking the database failed */ +#define RPMERR_OLDPACKAGE -28 /* trying upgrading to old version */ +#define RPMERR_BADARCH -29 /* bad architecture or arch mismatch */ +#define RPMERR_CREATE -30 /* failed to create a file */ +#define RPMERR_NOSPACE -31 /* out of disk space */ +#define RPMERR_NORELOCATE -32 /* tried to relocate improper package */ +#define RPMERR_BADOS -33 /* bad architecture or arch mismatch */ +#define RPMMESS_BACKUP -34 /* backup made during [un]install */ + +/* spec.c build.c pack.c */ +#define RPMERR_UNMATCHEDIF -107 /* unclosed %ifarch or %ifos */ +#define RPMERR_BADARG -109 +#define RPMERR_SCRIPT -110 /* errors related to script exec */ +#define RPMERR_READERROR -111 +#define RPMERR_UNKNOWNOS -112 +#define RPMERR_UNKNOWNARCH -113 +#define RPMERR_EXEC -114 +#define RPMERR_FORK -115 +#define RPMERR_CPIO -116 +#define RPMERR_GZIP -117 +#define RPMERR_BADSPEC -118 +#define RPMERR_LDD -119 /* couldn't understand ldd output */ + +#define RPMERR_BADSIGTYPE -200 /* Unknown signature type */ +#define RPMERR_SIGGEN -201 /* Error generating signature */ + +/** signature.c **/ + +/**************************************************/ +/* */ +/* Signature Tags */ +/* */ +/* These go in the sig Header to specify */ +/* individual signature types. */ +/* */ +/**************************************************/ + +#define RPMSIGTAG_SIZE 1000 +/* the md5 sum was broken on big endian machines for a while */ +#define RPMSIGTAG_LITTLEENDIANMD5 1001 +#define RPMSIGTAG_PGP 1002 +#define RPMSIGTAG_MD5 1003 + +/**************************************************/ +/* */ +/* verifySignature() results */ +/* */ +/**************************************************/ + +/* verifySignature() results */ +#define RPMSIG_OK 0 +#define RPMSIG_UNKNOWN 1 +#define RPMSIG_BAD 2 +#define RPMSIG_NOKEY 3 /* Do not have the key to check this signature */ + +void rpmFreeSignature(Header h); + +int rpmVerifySignature(char *file, int_32 sigTag, void *sig, int count, + char *result); #endif diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 4027faaa1..57a2687ea 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -6,7 +6,6 @@ #include "messages.h" #include "misc.h" -#include "rpmerr.h" #include "rpmlib.h" /* the rpmrc is read from /etc/rpmrc or $HOME/.rpmrc - it is not affected @@ -245,10 +244,10 @@ static int archosCompatCacheAdd(char * name, char * fn, int linenum, chptr = name; while (*chptr && *chptr != ':') chptr++; if (!*chptr) { - error(RPMERR_RPMRC, "missing second ':' at %s:%d", fn, linenum); + rpmError(RPMERR_RPMRC, "missing second ':' at %s:%d", fn, linenum); return 1; } else if (chptr == name) { - error(RPMERR_RPMRC, "missing architecture name at %s:%d", fn, + rpmError(RPMERR_RPMRC, "missing architecture name at %s:%d", fn, linenum); return 1; } @@ -320,18 +319,18 @@ static int addCanon(struct canonEntry **table, int *tableLen, char *line, t->short_name = strtok(NULL, " \t"); s = strtok(NULL, " \t"); if (! (t->name && t->short_name && s)) { - error(RPMERR_RPMRC, "Incomplete data line at %s:%d", fn, lineNum); + rpmError(RPMERR_RPMRC, "Incomplete data line at %s:%d", fn, lineNum); return RPMERR_RPMRC; } if (strtok(NULL, " \t")) { - error(RPMERR_RPMRC, "Too many args in data line at %s:%d", + rpmError(RPMERR_RPMRC, "Too many args in data line at %s:%d", fn, lineNum); return RPMERR_RPMRC; } t->num = strtoul(s, &s1, 10); if ((*s1) || (s1 == s) || (t->num == ULONG_MAX)) { - error(RPMERR_RPMRC, "Bad arch/os number: %s (%s:%d)", s, + rpmError(RPMERR_RPMRC, "Bad arch/os number: %s (%s:%d)", s, fn, lineNum); return(RPMERR_RPMRC); } @@ -365,11 +364,11 @@ static int addDefault(struct defaultEntry **table, int *tableLen, char *line, t->name = strtok(line, ": \t"); t->defName = strtok(NULL, " \t"); if (! (t->name && t->defName)) { - error(RPMERR_RPMRC, "Incomplete default line at %s:%d", fn, lineNum); + rpmError(RPMERR_RPMRC, "Incomplete default line at %s:%d", fn, lineNum); return RPMERR_RPMRC; } if (strtok(NULL, " \t")) { - error(RPMERR_RPMRC, "Too many args in default line at %s:%d", + rpmError(RPMERR_RPMRC, "Too many args in default line at %s:%d", fn, lineNum); return RPMERR_RPMRC; } @@ -456,7 +455,7 @@ static int readRpmrc(FILE * f, char * fn, int readWhat) { for (chptr = start; *chptr && *chptr != ':'; chptr++); if (! *chptr) { - error(RPMERR_RPMRC, "missing ':' at %s:%d", fn, linenum); + rpmError(RPMERR_RPMRC, "missing ':' at %s:%d", fn, linenum); return 1; } @@ -465,12 +464,12 @@ static int readRpmrc(FILE * f, char * fn, int readWhat) { while (*chptr && isspace(*chptr)) chptr++; if (! *chptr) { - error(RPMERR_RPMRC, "missing argument for %s at %s:%d", + rpmError(RPMERR_RPMRC, "missing argument for %s at %s:%d", start, fn, linenum); return 1; } - message(MESS_DEBUG, "got var '%s' arg '%s'\n", start, chptr); + rpmMessage(RPMMESS_DEBUG, "got var '%s' arg '%s'\n", start, chptr); /* these are options that don't just get stuffed in a VAR somewhere */ if (!strcasecmp(start, "arch_compat")) { @@ -511,7 +510,7 @@ static int readRpmrc(FILE * f, char * fn, int readWhat) { option = bsearch(&searchOption, optionTable, optionTableSize, sizeof(struct option), optionCompare); if (!option) { - error(RPMERR_RPMRC, "bad option '%s' at %s:%d", + rpmError(RPMERR_RPMRC, "bad option '%s' at %s:%d", start, fn, linenum); continue; /* aborting here is rude */ } @@ -520,12 +519,12 @@ static int readRpmrc(FILE * f, char * fn, int readWhat) { if (option->archSpecific) { start = chptr; - /* getArchName() should be safe by now */ - if (!archName) archName = getArchName(); + /* rpmGetArchName() should be safe by now */ + if (!archName) archName = rpmGetArchName(); for (chptr = start; *chptr && !isspace(*chptr); chptr++); if (! *chptr) { - error(RPMERR_RPMRC, "missing argument for %s at %s:%d", + rpmError(RPMERR_RPMRC, "missing argument for %s at %s:%d", option->name, fn, linenum); return 1; } @@ -533,22 +532,22 @@ static int readRpmrc(FILE * f, char * fn, int readWhat) { while (*chptr && isspace(*chptr)) chptr++; if (! *chptr) { - error(RPMERR_RPMRC, "missing argument for %s at %s:%d", + rpmError(RPMERR_RPMRC, "missing argument for %s at %s:%d", option->name, fn, linenum); return 1; } if (!strcmp(archName, start)) { - message(MESS_DEBUG, "%s is arg for %s platform", chptr, + rpmMessage(RPMMESS_DEBUG, "%s is arg for %s platform", chptr, archName); - setVar(option->var, chptr); + rpmSetVar(option->var, chptr); } } else { - setVar(option->var, chptr); + rpmSetVar(option->var, chptr); } continue; } - error(RPMERR_INTERNAL, "Bad readWhat: %d", readWhat); + rpmError(RPMERR_INTERNAL, "Bad readWhat: %d", readWhat); exit(1); } @@ -556,10 +555,10 @@ static int readRpmrc(FILE * f, char * fn, int readWhat) { } static void setDefaults(void) { - setVar(RPMVAR_OPTFLAGS, "-O2"); - setVar(RPMVAR_SIGTYPE, "none"); - setVar(RPMVAR_DEFAULTDOCDIR, "/usr/doc"); - setVar(RPMVAR_TOPDIR, "/usr/src/redhat"); + rpmSetVar(RPMVAR_OPTFLAGS, "-O2"); + rpmSetVar(RPMVAR_SIGTYPE, "none"); + rpmSetVar(RPMVAR_DEFAULTDOCDIR, "/usr/doc"); + rpmSetVar(RPMVAR_TOPDIR, "/usr/src/redhat"); } static int readConfigFilesAux(char *file, int readWhat) @@ -575,7 +574,7 @@ static int readConfigFilesAux(char *file, int readWhat) fclose(f); if (rc) return rc; } else { - error(RPMERR_RPMRC, "Unable to read " LIBRPMRC_FILENAME); + rpmError(RPMERR_RPMRC, "Unable to read " LIBRPMRC_FILENAME); return RPMERR_RPMRC; } @@ -632,8 +631,8 @@ int rpmReadConfigFiles(char * file, char * arch, char * os, int building) /* set default directories */ - if (!getVar(RPMVAR_TMPPATH)) - setVar(RPMVAR_TMPPATH, "/tmp"); + if (!rpmGetVar(RPMVAR_TMPPATH)) + rpmSetVar(RPMVAR_TMPPATH, "/tmp"); setPathDefault(RPMVAR_BUILDDIR, "BUILD"); setPathDefault(RPMVAR_RPMDIR, "RPMS"); @@ -643,15 +642,15 @@ int rpmReadConfigFiles(char * file, char * arch, char * os, int building) /* setup arch equivalences */ - archosFindEquivs(&archCache, &archEquivTable, getArchName()); - archosFindEquivs(&osCache, &osEquivTable, getOsName()); + archosFindEquivs(&archCache, &archEquivTable, rpmGetArchName()); + archosFindEquivs(&osCache, &osEquivTable, rpmGetOsName()); /* Do some checking */ - if ((tcs = getVar(RPMVAR_TIMECHECK))) { + if ((tcs = rpmGetVar(RPMVAR_TIMECHECK))) { tcse = NULL; tc = strtoul(tcs, &tcse, 10); if ((*tcse) || (tcse == tcs) || (tc == ULONG_MAX)) { - error(RPMERR_RPMRC, "Bad arg to timecheck: %s", tcs); + rpmError(RPMERR_RPMRC, "Bad arg to timecheck: %s", tcs); return(RPMERR_RPMRC); } } @@ -663,10 +662,10 @@ static void setPathDefault(int var, char * s) { char * topdir; char * fn; - if (getVar(var)) return; + if (rpmGetVar(var)) return; - topdir = getVar(RPMVAR_TOPDIR); - if (!topdir) topdir = getVar(RPMVAR_TMPPATH); + topdir = rpmGetVar(RPMVAR_TOPDIR); + if (!topdir) topdir = rpmGetVar(RPMVAR_TMPPATH); fn = alloca(strlen(topdir) + strlen(s) + 2); strcpy(fn, topdir); @@ -674,7 +673,7 @@ static void setPathDefault(int var, char * s) { strcat(fn, "/"); strcat(fn, s); - setVar(var, fn); + rpmSetVar(var, fn); } static int osnum; @@ -689,8 +688,8 @@ static void setArchOs(char *arch, char *os, int build) struct canonEntry *archCanon, *osCanon; if (archOsIsInit) { - error(RPMERR_INTERNAL, "Internal error: Arch/OS already initialized!"); - error(RPMERR_INTERNAL, "Arch: %d\nOS: %d", archnum, osnum); + rpmError(RPMERR_INTERNAL, "Internal error: Arch/OS already initialized!"); + rpmError(RPMERR_INTERNAL, "Arch: %d\nOS: %d", archnum, osnum); exit(1); } @@ -717,8 +716,8 @@ static void setArchOs(char *arch, char *os, int build) } else { archnum = 255; archname = strdup(arch); - message(MESS_WARNING, "Unknown architecture: %s\n", arch); - message(MESS_WARNING, "Please contact rpm-list@redhat.com\n"); + rpmMessage(RPMMESS_WARNING, "Unknown architecture: %s\n", arch); + rpmMessage(RPMMESS_WARNING, "Please contact rpm-list@redhat.com\n"); } if (osCanon) { osnum = osCanon->num; @@ -726,8 +725,8 @@ static void setArchOs(char *arch, char *os, int build) } else { osnum = 255; osname = strdup(os); - message(MESS_WARNING, "Unknown OS: %s\n", os); - message(MESS_WARNING, "Please contact rpm-list@redhat.com\n"); + rpmMessage(RPMMESS_WARNING, "Unknown OS: %s\n", os); + rpmMessage(RPMMESS_WARNING, "Please contact rpm-list@redhat.com\n"); } archOsIsInit = 1; @@ -736,31 +735,31 @@ static void setArchOs(char *arch, char *os, int build) #define FAIL_IF_NOT_INIT \ {\ if (! archOsIsInit) {\ - error(RPMERR_INTERNAL, "Internal error: Arch/OS not initialized!");\ - error(RPMERR_INTERNAL, "Arch: %d\nOS: %d", archnum, osnum);\ + rpmError(RPMERR_INTERNAL, "Internal error: Arch/OS not initialized!");\ + rpmError(RPMERR_INTERNAL, "Arch: %d\nOS: %d", archnum, osnum);\ exit(1);\ }\ } -int getOsNum(void) +int rpmGetOsNum(void) { FAIL_IF_NOT_INIT; return osnum; } -int getArchNum(void) +int rpmGetArchNum(void) { FAIL_IF_NOT_INIT; return archnum; } -char *getOsName(void) +char *rpmGetOsName(void) { FAIL_IF_NOT_INIT; return osname; } -char *getArchName(void) +char *rpmGetArchName(void) { FAIL_IF_NOT_INIT; return archname; @@ -774,16 +773,16 @@ int rpmShowRC(FILE *f) int i; fprintf(f, "ARCHITECTURE AND OS:\n"); - fprintf(f, "build arch : %s\n", getArchName()); - fprintf(f, "build os : %s\n", getOsName()); + fprintf(f, "build arch : %s\n", rpmGetArchName()); + fprintf(f, "build os : %s\n", rpmGetOsName()); /* This is a major hack */ archOsIsInit = 0; setArchOs(NULL, NULL, 0); - archosFindEquivs(&archCache, &archEquivTable, getArchName()); - archosFindEquivs(&osCache, &osEquivTable, getOsName()); - fprintf(f, "install arch : %s\n", getArchName()); - fprintf(f, "install os : %s\n", getOsName()); + archosFindEquivs(&archCache, &archEquivTable, rpmGetArchName()); + archosFindEquivs(&osCache, &osEquivTable, rpmGetOsName()); + fprintf(f, "install arch : %s\n", rpmGetArchName()); + fprintf(f, "install os : %s\n", rpmGetOsName()); fprintf(f, "compatible arch list :"); for (i = 0; i < archEquivTable.count; i++) fprintf(f," %s", archEquivTable.list[i].name); @@ -796,7 +795,7 @@ int rpmShowRC(FILE *f) fprintf(f, "RPMRC VALUES:\n"); opt = optionTable; while (count < optionTableSize) { - s = getVar(opt->var); + s = rpmGetVar(opt->var); fprintf(f, "%-20s : %s\n", opt->name, s ? s : "(not set)"); opt++; count++; diff --git a/lib/signature.c b/lib/signature.c index 83e2b13ad..e7d94e27e 100644 --- a/lib/signature.c +++ b/lib/signature.c @@ -22,9 +22,9 @@ #include "md5.h" #include "rpmlib.h" #include "rpmlead.h" -#include "rpmerr.h" #include "signature.h" #include "tread.h" +#include "messages.h" typedef int (*md5func)(char * fn, unsigned char * digest); @@ -38,28 +38,28 @@ static int verifyPGPSignature(char *datafile, void *sig, int count, char *result); static int checkPassPhrase(char *passPhrase); -int sigLookupType(void) +int rpmLookupSignatureType(void) { char *name; - if (! (name = getVar(RPMVAR_SIGTYPE))) { + if (! (name = rpmGetVar(RPMVAR_SIGTYPE))) { return 0; } if (!strcasecmp(name, "none")) { return 0; } else if (!strcasecmp(name, "pgp")) { - return SIGTAG_PGP; + return RPMSIGTAG_PGP; } else { return -1; } } -/* readSignature() emulates the new style signatures if it finds an */ +/* rpmReadSignature() emulates the new style signatures if it finds an */ /* old-style one. It also immediately verifies the header+archive */ /* size and returns an error if it doesn't match. */ -int readSignature(int fd, Header *header, short sig_type) +int rpmReadSignature(int fd, Header *header, short sig_type) { unsigned char buf[2048]; int sigSize, pad; @@ -73,54 +73,54 @@ int readSignature(int fd, Header *header, short sig_type) switch (sig_type) { case RPMSIG_NONE: - message(MESS_DEBUG, "No signature\n"); + rpmMessage(RPMMESS_DEBUG, "No signature\n"); break; case RPMSIG_PGP262_1024: - message(MESS_DEBUG, "Old PGP signature\n"); + rpmMessage(RPMMESS_DEBUG, "Old PGP signature\n"); /* These are always 256 bytes */ if (timedRead(fd, buf, 256) != 256) { return 1; } if (header) { - *header = newHeader(); - addEntry(*header, SIGTAG_PGP, BIN_TYPE, buf, 152); + *header = headerNew(); + headerAddEntry(*header, RPMSIGTAG_PGP, RPM_BIN_TYPE, buf, 152); } break; case RPMSIG_MD5: case RPMSIG_MD5_PGP: - error(RPMERR_BADSIGTYPE, + rpmError(RPMERR_BADSIGTYPE, "Old (internal-only) signature! How did you get that!?"); return 1; break; case RPMSIG_HEADERSIG: - message(MESS_DEBUG, "New Header signature\n"); + rpmMessage(RPMMESS_DEBUG, "New Header signature\n"); /* This is a new style signature */ - h = readHeader(fd, HEADER_MAGIC); + h = headerRead(fd, HEADER_MAGIC_YES); if (! h) { return 1; } - sigSize = sizeofHeader(h, HEADER_MAGIC); + sigSize = headerSizeof(h, HEADER_MAGIC_YES); pad = (8 - (sigSize % 8)) % 8; /* 8-byte pad */ - message(MESS_DEBUG, "Signature size: %d\n", sigSize); - message(MESS_DEBUG, "Signature pad : %d\n", pad); - if (! getEntry(h, SIGTAG_SIZE, &type, (void **)&archSize, &count)) { - freeHeader(h); + rpmMessage(RPMMESS_DEBUG, "Signature size: %d\n", sigSize); + rpmMessage(RPMMESS_DEBUG, "Signature pad : %d\n", pad); + if (! headerGetEntry(h, RPMSIGTAG_SIZE, &type, (void **)&archSize, &count)) { + headerFree(h); return 1; } if (checkSize(fd, *archSize, sigSize + pad)) { - freeHeader(h); + headerFree(h); return 1; } if (pad) { if (timedRead(fd, buf, pad) != pad) { - freeHeader(h); + headerFree(h); return 1; } } if (header) { *header = h; } else { - freeHeader(h); + headerFree(h); } break; default: @@ -130,34 +130,34 @@ int readSignature(int fd, Header *header, short sig_type) return 0; } -int writeSignature(int fd, Header header) +int rpmWriteSignature(int fd, Header header) { int sigSize, pad; unsigned char buf[8]; - writeHeader(fd, header, HEADER_MAGIC); - sigSize = sizeofHeader(header, HEADER_MAGIC); + headerWrite(fd, header, HEADER_MAGIC_YES); + sigSize = headerSizeof(header, HEADER_MAGIC_YES); pad = (8 - (sigSize % 8)) % 8; if (pad) { - message(MESS_DEBUG, "Signature size: %d\n", sigSize); - message(MESS_DEBUG, "Signature pad : %d\n", pad); + rpmMessage(RPMMESS_DEBUG, "Signature size: %d\n", sigSize); + rpmMessage(RPMMESS_DEBUG, "Signature pad : %d\n", pad); memset(buf, 0, pad); write(fd, buf, pad); } return 0; } -Header newSignature(void) +Header rpmNewSignature(void) { - return newHeader(); + return headerNew(); } -void freeSignature(Header h) +void rpmFreeSignature(Header h) { - freeHeader(h); + headerFree(h); } -int addSignature(Header header, char *file, int_32 sigTag, char *passPhrase) +int rpmAddSignature(Header header, char *file, int_32 sigTag, char *passPhrase) { struct stat statbuf; int_32 size; @@ -165,18 +165,18 @@ int addSignature(Header header, char *file, int_32 sigTag, char *passPhrase) void *sig; switch (sigTag) { - case SIGTAG_SIZE: + case RPMSIGTAG_SIZE: stat(file, &statbuf); size = statbuf.st_size; - addEntry(header, SIGTAG_SIZE, INT32_TYPE, &size, 1); + headerAddEntry(header, RPMSIGTAG_SIZE, RPM_INT32_TYPE, &size, 1); break; - case SIGTAG_MD5: + case RPMSIGTAG_MD5: mdbinfile(file, buf); - addEntry(header, sigTag, BIN_TYPE, buf, 16); + headerAddEntry(header, sigTag, RPM_BIN_TYPE, buf, 16); break; - case SIGTAG_PGP: + case RPMSIGTAG_PGP: makePGPSignature(file, &sig, &size, passPhrase); - addEntry(header, sigTag, BIN_TYPE, sig, size); + headerAddEntry(header, sigTag, RPM_BIN_TYPE, sig, size); break; } @@ -193,7 +193,7 @@ static int makePGPSignature(char *file, void **sig, int_32 *size, FILE *fpipe; struct stat statbuf; - sprintf(name, "+myname=\"%s\"", getVar(RPMVAR_PGP_NAME)); + sprintf(name, "+myname=\"%s\"", rpmGetVar(RPMVAR_PGP_NAME)); sprintf(sigfile, "%s.sig", file); @@ -204,15 +204,15 @@ static int makePGPSignature(char *file, void **sig, int_32 *size, dup2(inpipe[0], 3); close(inpipe[1]); setenv("PGPPASSFD", "3", 1); - if (getVar(RPMVAR_PGP_PATH)) { - setenv("PGPPATH", getVar(RPMVAR_PGP_PATH), 1); + if (rpmGetVar(RPMVAR_PGP_PATH)) { + setenv("PGPPATH", rpmGetVar(RPMVAR_PGP_PATH), 1); } /* setenv("PGPPASS", passPhrase, 1); */ execlp("pgp", "pgp", "+batchmode=on", "+verbose=0", "+armor=off", name, "-sb", file, sigfile, NULL); - error(RPMERR_EXEC, "Couldn't exec pgp"); + rpmError(RPMERR_EXEC, "Couldn't exec pgp"); exit(RPMERR_EXEC); } @@ -223,19 +223,19 @@ static int makePGPSignature(char *file, void **sig, int_32 *size, waitpid(pid, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status)) { - error(RPMERR_SIGGEN, "pgp failed"); + rpmError(RPMERR_SIGGEN, "pgp failed"); return 1; } if (stat(sigfile, &statbuf)) { /* PGP failed to write signature */ unlink(sigfile); /* Just in case */ - error(RPMERR_SIGGEN, "pgp failed to write signature"); + rpmError(RPMERR_SIGGEN, "pgp failed to write signature"); return 1; } *size = statbuf.st_size; - message(MESS_DEBUG, "PGP sig size: %d\n", *size); + rpmMessage(RPMMESS_DEBUG, "PGP sig size: %d\n", *size); *sig = malloc(*size); fd = open(sigfile, O_RDONLY); @@ -243,13 +243,13 @@ static int makePGPSignature(char *file, void **sig, int_32 *size, unlink(sigfile); close(fd); free(*sig); - error(RPMERR_SIGGEN, "unable to read the signature"); + rpmError(RPMERR_SIGGEN, "unable to read the signature"); return 1; } close(fd); unlink(sigfile); - message(MESS_DEBUG, "Got %d bytes of PGP sig\n", *size); + rpmMessage(RPMMESS_DEBUG, "Got %d bytes of PGP sig\n", *size); return 0; } @@ -264,37 +264,37 @@ static int checkSize(int fd, int size, int sigsize) if (S_ISREG(statbuf.st_mode)) { headerArchiveSize = statbuf.st_size - sizeof(struct rpmlead) - sigsize; - message(MESS_DEBUG, "sigsize : %d\n", sigsize); - message(MESS_DEBUG, "Header + Archive: %d\n", headerArchiveSize); - message(MESS_DEBUG, "expected size : %d\n", size); + rpmMessage(RPMMESS_DEBUG, "sigsize : %d\n", sigsize); + rpmMessage(RPMMESS_DEBUG, "Header + Archive: %d\n", headerArchiveSize); + rpmMessage(RPMMESS_DEBUG, "expected size : %d\n", size); return size - headerArchiveSize; } else { - message(MESS_DEBUG, "file is not regular -- skipping size check\n"); + rpmMessage(RPMMESS_DEBUG, "file is not regular -- skipping size check\n"); return 0; } } -int verifySignature(char *file, int_32 sigTag, void *sig, int count, +int rpmVerifySignature(char *file, int_32 sigTag, void *sig, int count, char *result) { switch (sigTag) { - case SIGTAG_SIZE: + case RPMSIGTAG_SIZE: if (verifySizeSignature(file, *(int_32 *)sig, result)) { return RPMSIG_BAD; } break; - case SIGTAG_MD5: + case RPMSIGTAG_MD5: if (verifyMD5Signature(file, sig, result, mdbinfile)) { return 1; } break; - case SIGTAG_LITTLEENDIANMD5: + case RPMSIGTAG_LITTLEENDIANMD5: if (verifyMD5Signature(file, sig, result, mdbinfileBroken)) { return 1; } break; - case SIGTAG_PGP: + case RPMSIGTAG_PGP: return verifyPGPSignature(file, sig, count, result); break; default: @@ -364,7 +364,7 @@ static int verifyPGPSignature(char *datafile, void *sig, int res = RPMSIG_OK; /* Write out the signature */ - sigfile = tempnam(getVar(RPMVAR_TMPPATH), "rpmsig"); + sigfile = tempnam(rpmGetVar(RPMVAR_TMPPATH), "rpmsig"); sfd = open(sigfile, O_WRONLY|O_CREAT|O_TRUNC, 0644); write(sfd, sig, count); close(sfd); @@ -376,15 +376,15 @@ static int verifyPGPSignature(char *datafile, void *sig, close(1); close(outpipe[0]); dup2(outpipe[1], 1); - if (getVar(RPMVAR_PGP_PATH)) { - setenv("PGPPATH", getVar(RPMVAR_PGP_PATH), 1); + if (rpmGetVar(RPMVAR_PGP_PATH)) { + setenv("PGPPATH", rpmGetVar(RPMVAR_PGP_PATH), 1); } execlp("pgp", "pgp", "+batchmode=on", "+verbose=0", sigfile, datafile, NULL); printf("exec failed!\n"); - error(RPMERR_EXEC, "Could not run pgp. Use --nopgp to skip PGP checks."); + rpmError(RPMERR_EXEC, "Could not run pgp. Use --nopgp to skip PGP checks."); exit(RPMERR_EXEC); } @@ -412,12 +412,12 @@ static int verifyPGPSignature(char *datafile, void *sig, return res; } -char *getPassPhrase(char *prompt) +char *rpmGetPassPhrase(char *prompt) { char *pass; - if (! getVar(RPMVAR_PGP_NAME)) { - error(RPMERR_SIGGEN, + if (! rpmGetVar(RPMVAR_PGP_NAME)) { + rpmError(RPMERR_SIGGEN, "You must set \"pgp_name:\" in your rpmrc file"); return NULL; } @@ -443,13 +443,13 @@ static int checkPassPhrase(char *passPhrase) int pid, status; int fd; - sprintf(name, "+myname=\"%s\"", getVar(RPMVAR_PGP_NAME)); + sprintf(name, "+myname=\"%s\"", rpmGetVar(RPMVAR_PGP_NAME)); pipe(passPhrasePipe); if (!(pid = fork())) { close(0); close(1); - if (! isVerbose()) { + if (! rpmIsVerbose()) { close(2); } if ((fd = open("/dev/null", O_RDONLY)) != 0) { @@ -460,14 +460,14 @@ static int checkPassPhrase(char *passPhrase) } dup2(passPhrasePipe[0], 3); setenv("PGPPASSFD", "3", 1); - if (getVar(RPMVAR_PGP_PATH)) { - setenv("PGPPATH", getVar(RPMVAR_PGP_PATH), 1); + if (rpmGetVar(RPMVAR_PGP_PATH)) { + setenv("PGPPATH", rpmGetVar(RPMVAR_PGP_PATH), 1); } execlp("pgp", "pgp", "+batchmode=on", "+verbose=0", name, "-sf", NULL); - error(RPMERR_EXEC, "Couldn't exec pgp"); + rpmError(RPMERR_EXEC, "Couldn't exec pgp"); exit(RPMERR_EXEC); } diff --git a/lib/signature.h b/lib/signature.h index 2d4dde398..e6cf347ea 100644 --- a/lib/signature.h +++ b/lib/signature.h @@ -24,59 +24,28 @@ #define RPMSIG_HEADERSIG 5 /* New Header style signature */ -/**************************************************/ -/* */ -/* Signature Tags */ -/* */ -/* These go in the sig Header to specify */ -/* individual signature types. */ -/* */ -/**************************************************/ - -#define SIGTAG_SIZE 1000 -/* the md5 sum was broken on big endian machines for a while */ -#define SIGTAG_LITTLEENDIANMD5 1001 -#define SIGTAG_PGP 1002 -#define SIGTAG_MD5 1003 - -/**************************************************/ -/* */ -/* verifySignature() results */ -/* */ -/**************************************************/ - -/* verifySignature() results */ -#define RPMSIG_OK 0 -#define RPMSIG_UNKNOWN 1 -#define RPMSIG_BAD 2 -#define RPMSIG_NOKEY 3 /* Do not have the key to check this signature */ - /**************************************************/ /* */ /* Prototypes */ /* */ /**************************************************/ -Header newSignature(void); +Header rpmNewSignature(void); /* If an old-style signature is found, we emulate a new style one */ -int readSignature(int fd, Header *header, short sig_type); -int writeSignature(int fd, Header header); +int rpmReadSignature(int fd, Header *header, short sig_type); +int rpmWriteSignature(int fd, Header header); /* Generate a signature of data in file, insert in header */ -int addSignature(Header header, char *file, int_32 sigTag, char *passPhrase); - -void freeSignature(Header h); +int rpmAddSignature(Header header, char *file, + int_32 sigTag, char *passPhrase); /******************************************************************/ -int verifySignature(char *file, int_32 sigTag, void *sig, int count, - char *result); - /* Return type of signature in effect for building */ -int sigLookupType(void); +int rpmLookupSignatureType(void); /* Utility to read a pass phrase from the user */ -char *getPassPhrase(char *prompt); +char *rpmGetPassPhrase(char *prompt); #endif diff --git a/lib/test.c b/lib/test.c index 8910413ac..7b0ceafc0 100644 --- a/lib/test.c +++ b/lib/test.c @@ -17,41 +17,41 @@ void main(int argc, char **argv) int_16 i16a[] = {100, 200, 300}; char ca[] = "char array"; - h = newHeader(); + h = headerNew(); - addEntry(h, RPMTAG_NAME, STRING_TYPE, "MarcEwing", 1); - addEntry(h, RPMTAG_VERSION, STRING_TYPE, "1.1", 1); - addEntry(h, RPMTAG_VERSION, STRING_ARRAY_TYPE, sa, 3); - addEntry(h, RPMTAG_SIZE, INT32_TYPE, &i32, 1); - addEntry(h, RPMTAG_SIZE, INT16_TYPE, &i16, 1); - addEntry(h, RPMTAG_SIZE, INT16_TYPE, i16a, 3); - addEntry(h, RPMTAG_VENDOR, CHAR_TYPE, ca, strlen(ca)); - addEntry(h, RPMTAG_SIZE, INT32_TYPE, i32a, 3); + headerAddEntry(h, RPMTAG_NAME, RPM_STRING_TYPE, "MarcEwing", 1); + headerAddEntry(h, RPMTAG_VERSION, RPM_STRING_TYPE, "1.1", 1); + headerAddEntry(h, RPMTAG_VERSION, RPM_STRING_ARRAY_TYPE, sa, 3); + headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE, &i32, 1); + headerAddEntry(h, RPMTAG_SIZE, RPM_INT16_TYPE, &i16, 1); + headerAddEntry(h, RPMTAG_SIZE, RPM_INT16_TYPE, i16a, 3); + headerAddEntry(h, RPMTAG_VENDOR, RPM_CHAR_TYPE, ca, strlen(ca)); + headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE, i32a, 3); - printf("Original = %d\n", sizeofHeader(h)); + printf("Original = %d\n", headerSizeof(h)); fd = open("test.out", O_WRONLY|O_CREAT); - writeHeader(fd, h); + headerWrite(fd, h); close(fd); - h2 = copyHeader(h); - printf("Copy = %d\n", sizeofHeader(h2)); + h2 = headerCopy(h); + printf("Copy = %d\n", headerSizeof(h2)); fd = open("test.out", O_RDONLY); - h3 = readHeader(fd); + h3 = headerRead(fd); close(fd); - printf("From disk = %d\n", sizeofHeader(h3)); - h4 = copyHeader(h3); - printf("Copy of disk = %d\n", sizeofHeader(h4)); + printf("From disk = %d\n", headerSizeof(h3)); + h4 = headerCopy(h3); + printf("Copy of disk = %d\n", headerSizeof(h4)); printf("=====================\n"); printf("Original\n"); - dumpHeader(h, stdout, 1); + headerDump(h, stdout, 1); printf("=====================\n"); printf("From disk\n"); - dumpHeader(h3, stdout, 1); + headerDump(h3, stdout, 1); printf("=====================\n"); printf("Copy of disk\n"); - dumpHeader(h4, stdout, 1); + headerDump(h4, stdout, 1); #if 0 convertDB(""); diff --git a/lib/uninstall.c b/lib/uninstall.c index 6eeb881f7..104411ed2 100644 --- a/lib/uninstall.c +++ b/lib/uninstall.c @@ -16,7 +16,6 @@ #include "md5.h" #include "misc.h" #include "rpmdb.h" -#include "rpmerr.h" #include "rpmlib.h" static char * SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:" @@ -49,7 +48,7 @@ int findSharedFiles(rpmdb db, int offset, char ** fileList, int fileCount, struct sharedFile * list = NULL; int itemsUsed = 0; int itemsAllocated = 0; - dbIndexSet matches; + dbiIndexSet matches; itemsAllocated = 5; list = malloc(sizeof(struct sharedFile) * itemsAllocated); @@ -70,7 +69,7 @@ int findSharedFiles(rpmdb db, int offset, char ** fileList, int fileCount, } } - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } } @@ -114,7 +113,7 @@ static int handleSharedFiles(rpmdb db, int offset, char ** fileList, for (i = 0; i < sharedCount; i++) { if (secOffset != sharedList[i].secRecOffset) { if (secOffset) { - freeHeader(sech); + headerFree(sech); free(secFileMd5List); free(secFileList); } @@ -122,58 +121,58 @@ static int handleSharedFiles(rpmdb db, int offset, char ** fileList, secOffset = sharedList[i].secRecOffset; sech = rpmdbGetRecord(db, secOffset); if (!sech) { - error(RPMERR_DBCORRUPT, "cannot read header at %d for " + rpmError(RPMERR_DBCORRUPT, "cannot read header at %d for " "uninstall", offset); rc = 1; break; } - getEntry(sech, RPMTAG_NAME, &type, (void **) &name, + headerGetEntry(sech, RPMTAG_NAME, &type, (void **) &name, &secFileCount); - getEntry(sech, RPMTAG_VERSION, &type, (void **) &version, + headerGetEntry(sech, RPMTAG_VERSION, &type, (void **) &version, &secFileCount); - getEntry(sech, RPMTAG_RELEASE, &type, (void **) &release, + headerGetEntry(sech, RPMTAG_RELEASE, &type, (void **) &release, &secFileCount); - message(MESS_DEBUG, "package %s-%s-%s contain shared files\n", + rpmMessage(RPMMESS_DEBUG, "package %s-%s-%s contain shared files\n", name, version, release); - if (!getEntry(sech, RPMTAG_FILENAMES, &type, + if (!headerGetEntry(sech, RPMTAG_FILENAMES, &type, (void **) &secFileList, &secFileCount)) { - error(RPMERR_DBCORRUPT, "package %s contains no files", + rpmError(RPMERR_DBCORRUPT, "package %s contains no files", name); - freeHeader(sech); + headerFree(sech); rc = 1; break; } - getEntry(sech, RPMTAG_FILESTATES, &type, + headerGetEntry(sech, RPMTAG_FILESTATES, &type, (void **) &secFileStatesList, &secFileCount); - getEntry(sech, RPMTAG_FILEMD5S, &type, + headerGetEntry(sech, RPMTAG_FILEMD5S, &type, (void **) &secFileMd5List, &secFileCount); } - message(MESS_DEBUG, "file %s is shared\n", + rpmMessage(RPMMESS_DEBUG, "file %s is shared\n", fileList[sharedList[i].mainFileNumber]); switch (secFileStatesList[sharedList[i].secFileNumber]) { case RPMFILE_STATE_REPLACED: - message(MESS_DEBUG, " file has already been replaced\n"); + rpmMessage(RPMMESS_DEBUG, " file has already been replaced\n"); break; case RPMFILE_STATE_NOTINSTALLED: - message(MESS_DEBUG, " file was never installed\n"); + rpmMessage(RPMMESS_DEBUG, " file was never installed\n"); break; case RPMFILE_STATE_NETSHARED: - message(MESS_DEBUG, " file is netshared (so don't touch it)\n"); + rpmMessage(RPMMESS_DEBUG, " file is netshared (so don't touch it)\n"); fileActions[sharedList[i].mainFileNumber] = KEEP; break; case RPMFILE_STATE_NORMAL: if (!strcmp(fileMd5List[sharedList[i].mainFileNumber], secFileMd5List[sharedList[i].secFileNumber])) { - message(MESS_DEBUG, " file is truely shared - saving\n"); + rpmMessage(RPMMESS_DEBUG, " file is truely shared - saving\n"); } fileActions[sharedList[i].mainFileNumber] = KEEP; break; @@ -181,7 +180,7 @@ static int handleSharedFiles(rpmdb db, int offset, char ** fileList, } if (secOffset) { - freeHeader(sech); + headerFree(sech); free(secFileMd5List); free(secFileList); } @@ -196,7 +195,7 @@ int rpmRemovePackage(char * prefix, rpmdb db, unsigned int offset, int flags) { int fileCount; char * rmmess, * name, * version, * release; char * fnbuffer = NULL; - dbIndexSet matches; + dbiIndexSet matches; int fnbuffersize = 0; int prefixLength = strlen(prefix); char ** fileList, ** fileMd5List; @@ -209,54 +208,54 @@ int rpmRemovePackage(char * prefix, rpmdb db, unsigned int offset, int flags) { h = rpmdbGetRecord(db, offset); if (!h) { - error(RPMERR_DBCORRUPT, "cannot read header at %d for uninstall", + rpmError(RPMERR_DBCORRUPT, "cannot read header at %d for uninstall", offset); return 1; } - getEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); - getEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); - getEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); + headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); /* when we run scripts, we pass an argument which is the number of versions of this package that will be installed when we are finished */ if (rpmdbFindPackage(db, name, &matches)) { - error(RPMERR_DBCORRUPT, "cannot read packages named %s for uninstall", + rpmError(RPMERR_DBCORRUPT, "cannot read packages named %s for uninstall", name); return 1; } scriptArg = matches.count - 1; - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); - if (flags & UNINSTALL_TEST) { + if (flags & RPMUNINSTALL_TEST) { rmmess = "would remove"; } else { rmmess = "removing"; } - message(MESS_DEBUG, "running preuninstall script (if any)\n"); + rpmMessage(RPMMESS_DEBUG, "running preuninstall script (if any)\n"); if (runScript(prefix, h, RPMTAG_PREUN, scriptArg, - flags & UNINSTALL_NOSCRIPTS)) { - freeHeader(h); + flags & RPMUNINSTALL_NOSCRIPTS)) { + headerFree(h); return 1; } - message(MESS_DEBUG, "%s files test = %d\n", rmmess, flags & UNINSTALL_TEST); - if (getEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, + rpmMessage(RPMMESS_DEBUG, "%s files test = %d\n", rmmess, flags & RPMUNINSTALL_TEST); + if (headerGetEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, &fileCount)) { if (prefix[0]) { fnbuffersize = 1024; fnbuffer = alloca(fnbuffersize); } - getEntry(h, RPMTAG_FILESTATES, &type, (void **) &fileStatesList, + headerGetEntry(h, RPMTAG_FILESTATES, &type, (void **) &fileStatesList, &fileCount); - getEntry(h, RPMTAG_FILEMD5S, &type, (void **) &fileMd5List, + headerGetEntry(h, RPMTAG_FILEMD5S, &type, (void **) &fileMd5List, &fileCount); - getEntry(h, RPMTAG_FILEFLAGS, &type, (void **) &fileFlagsList, + headerGetEntry(h, RPMTAG_FILEFLAGS, &type, (void **) &fileFlagsList, &fileCount); - getEntry(h, RPMTAG_FILEMODES, &type, (void **) &fileModesList, + headerGetEntry(h, RPMTAG_FILEMODES, &type, (void **) &fileModesList, &fileCount); fileActions = alloca(sizeof(*fileActions) * fileCount); @@ -286,21 +285,21 @@ int rpmRemovePackage(char * prefix, rpmdb db, unsigned int offset, int flags) { removeFile(fnbuffer, fileStatesList[i], fileFlagsList[i], fileMd5List[i], fileModesList[i], fileActions[i], - rmmess, !isEntry(h, RPMTAG_RPMVERSION), - flags & UNINSTALL_TEST); + rmmess, !headerIsEntry(h, RPMTAG_RPMVERSION), + flags & RPMUNINSTALL_TEST); } free(fileList); free(fileMd5List); } - message(MESS_DEBUG, "running postuninstall script (if any)\n"); - runScript(prefix, h, RPMTAG_POSTUN, scriptArg, flags & UNINSTALL_NOSCRIPTS); + rpmMessage(RPMMESS_DEBUG, "running postuninstall script (if any)\n"); + runScript(prefix, h, RPMTAG_POSTUN, scriptArg, flags & RPMUNINSTALL_NOSCRIPTS); - freeHeader(h); + headerFree(h); - message(MESS_DEBUG, "%s database entry\n", rmmess); - if (!(flags & UNINSTALL_TEST)) + rpmMessage(RPMMESS_DEBUG, "%s database entry\n", rmmess); + if (!(flags & RPMUNINSTALL_TEST)) rpmdbRemove(db, offset, 0); return 0; @@ -311,7 +310,7 @@ int runScript(char * prefix, Header h, int tag, int arg, int norunScripts) { char * script; char * fn; int fd; - int isdebug = isDebug(); + int isdebug = rpmIsDebug(); int child; int status; char upgradeArg[20]; @@ -322,8 +321,8 @@ int runScript(char * prefix, Header h, int tag, int arg, int norunScripts) { if (norunScripts) return 0; - if (getEntry(h, tag, &type, (void **) &script, &count)) { - if (getEntry(h, RPMTAG_INSTALLPREFIX, &type, (void **) &installPrefix, + if (headerGetEntry(h, tag, &type, (void **) &script, &count)) { + if (headerGetEntry(h, RPMTAG_INSTALLPREFIX, &type, (void **) &installPrefix, &count)) { installPrefixEnv = alloca(strlen(installPrefix) + 30); strcpy(installPrefixEnv, "RPM_INSTALL_PREFIX="); @@ -331,11 +330,11 @@ int runScript(char * prefix, Header h, int tag, int arg, int norunScripts) { } fn = tmpnam(NULL); - message(MESS_DEBUG, "script found - running from file %s\n", fn); + rpmMessage(RPMMESS_DEBUG, "script found - running from file %s\n", fn); fd = open(fn, O_CREAT | O_RDWR); unlink(fn); if (fd < 0) { - error(RPMERR_SCRIPT, "error creating file for (un)install script"); + rpmError(RPMERR_SCRIPT, "error creating file for (un)install script"); return 1; } write(fd, SCRIPT_PATH, strlen(SCRIPT_PATH)); @@ -354,7 +353,7 @@ int runScript(char * prefix, Header h, int tag, int arg, int norunScripts) { close(fd); if (strcmp(prefix, "/")) { - message(MESS_DEBUG, "performing chroot(%s)\n", prefix); + rpmMessage(RPMMESS_DEBUG, "performing chroot(%s)\n", prefix); chroot(prefix); chdir("/"); } @@ -369,7 +368,7 @@ int runScript(char * prefix, Header h, int tag, int arg, int norunScripts) { waitpid(child, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status)) { - error(RPMERR_SCRIPT, "execution of script failed"); + rpmError(RPMERR_SCRIPT, "execution of script failed"); return 1; } } @@ -386,26 +385,26 @@ static int removeFile(char * file, char state, unsigned int flags, char * md5, switch (state) { case RPMFILE_STATE_REPLACED: - message(MESS_DEBUG, "%s has already been replaced\n", file); + rpmMessage(RPMMESS_DEBUG, "%s has already been replaced\n", file); break; case RPMFILE_STATE_NORMAL: if ((action == REMOVE) && (flags & RPMFILE_CONFIG)) { /* if it's a config file, we may not want to remove it */ - message(MESS_DEBUG, "finding md5sum of %s\n", file); + rpmMessage(RPMMESS_DEBUG, "finding md5sum of %s\n", file); if (brokenMd5) rc = mdfileBroken(file, currentMd5); else rc = mdfile(file, currentMd5); if (mdfile(file, currentMd5)) - message(MESS_DEBUG, " failed - assuming file removed\n"); + rpmMessage(RPMMESS_DEBUG, " failed - assuming file removed\n"); else { if (strcmp(currentMd5, md5)) { - message(MESS_DEBUG, " file changed - will save\n"); + rpmMessage(RPMMESS_DEBUG, " file changed - will save\n"); action = BACKUP; } else { - message(MESS_DEBUG, " file unchanged - will remove\n"); + rpmMessage(RPMMESS_DEBUG, " file unchanged - will remove\n"); } } } @@ -413,17 +412,17 @@ static int removeFile(char * file, char state, unsigned int flags, char * md5, switch (action) { case KEEP: - message(MESS_DEBUG, "keeping %s\n", file); + rpmMessage(RPMMESS_DEBUG, "keeping %s\n", file); break; case BACKUP: - message(MESS_DEBUG, "saving %s as %s.rpmsave\n", file, file); + rpmMessage(RPMMESS_DEBUG, "saving %s as %s.rpmsave\n", file, file); if (!test) { newfile = alloca(strlen(file) + 20); strcpy(newfile, file); strcat(newfile, ".rpmsave"); if (rename(file, newfile)) { - error(RPMERR_RENAME, "rename of %s to %s failed: %s", + rpmError(RPMERR_RENAME, "rename of %s to %s failed: %s", file, newfile, strerror(errno)); rc = 1; } @@ -431,15 +430,15 @@ static int removeFile(char * file, char state, unsigned int flags, char * md5, break; case REMOVE: - message(MESS_DEBUG, "%s - %s\n", file, rmmess); + rpmMessage(RPMMESS_DEBUG, "%s - %s\n", file, rmmess); if (S_ISDIR(mode)) { if (!test) { if (rmdir(file)) { if (errno == ENOTEMPTY) - error(RPMERR_RMDIR, "cannot remove %s - directory " + rpmError(RPMERR_RMDIR, "cannot remove %s - directory " "not empty", file); else - error(RPMERR_RMDIR, "rmdir of %s failed: %s", + rpmError(RPMERR_RMDIR, "rmdir of %s failed: %s", file, strerror(errno)); rc = 1; } @@ -447,7 +446,7 @@ static int removeFile(char * file, char state, unsigned int flags, char * md5, } else { if (!test) { if (unlink(file)) { - error(RPMERR_UNLINK, "removal of %s failed: %s", + rpmError(RPMERR_UNLINK, "removal of %s failed: %s", file, strerror(errno)); rc = 1; } diff --git a/lib/var.c b/lib/var.c index 810b4b65c..422b6d786 100644 --- a/lib/var.c +++ b/lib/var.c @@ -7,7 +7,7 @@ static char * values[RPMVAR_LASTVAR + 1]; -char *getVar(int var) +char *rpmGetVar(int var) { if (var > RPMVAR_LASTVAR) return NULL; @@ -15,12 +15,12 @@ char *getVar(int var) return values[var]; } -int getBooleanVar(int var) { +int rpmGetBooleanVar(int var) { char * val; int num; char * chptr; - val = getVar(var); + val = rpmGetVar(var); if (!val) return 0; if (val[0] == 'y' || val[0] == 'Y') return 1; @@ -33,7 +33,7 @@ int getBooleanVar(int var) { return 0; } -void setVar(int var, char *val) +void rpmSetVar(int var, char *val) { if (var > RPMVAR_LASTVAR) return ; /* XXX should we go harey carey here? */ diff --git a/lib/verify.c b/lib/verify.c index 65531123d..601ebb2e6 100644 --- a/lib/verify.c +++ b/lib/verify.c @@ -26,21 +26,21 @@ int rpmVerifyFile(char * prefix, Header h, int filenum, int * result) { int_32 * uidList, * gidList; int useBrokenMd5; - if (getEntry(h, RPMTAG_RPMVERSION, NULL, NULL, NULL)) + if (headerGetEntry(h, RPMTAG_RPMVERSION, NULL, NULL, NULL)) useBrokenMd5 = 0; else useBrokenMd5 = 1; - getEntry(h, RPMTAG_FILEMODES, &type, (void **) &modeList, &count); + headerGetEntry(h, RPMTAG_FILEMODES, &type, (void **) &modeList, &count); - if (getEntry(h, RPMTAG_FILEVERIFYFLAGS, &type, (void **) &verifyFlags, + if (headerGetEntry(h, RPMTAG_FILEVERIFYFLAGS, &type, (void **) &verifyFlags, &count)) { flags = verifyFlags[filenum]; } else { - flags = VERIFY_ALL; + flags = RPMVERIFY_ALL; } - getEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, &count); + headerGetEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, &count); filespec = alloca(strlen(fileList[filenum]) + strlen(prefix) + 5); strcpy(filespec, prefix); strcat(filespec, "/"); @@ -51,7 +51,7 @@ int rpmVerifyFile(char * prefix, Header h, int filenum, int * result) { *result = 0; /* Check to see if the file was installed - if not pretend all is OK */ - if (getEntry(h, RPMTAG_FILESTATES, &type, + if (headerGetEntry(h, RPMTAG_FILESTATES, &type, (void **) &fileStatesList, &count) && fileStatesList) { if (fileStatesList[filenum] == RPMFILE_STATE_NOTINSTALLED) return 0; @@ -61,20 +61,20 @@ int rpmVerifyFile(char * prefix, Header h, int filenum, int * result) { return 1; if (S_ISDIR(sb.st_mode)) - flags &= ~(VERIFY_MD5 | VERIFY_FILESIZE | VERIFY_MTIME | VERIFY_LINKTO); + flags &= ~(RPMVERIFY_MD5 | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME | RPMVERIFY_LINKTO); else if (S_ISLNK(sb.st_mode)) - flags &= ~(VERIFY_MD5 | VERIFY_FILESIZE | VERIFY_MTIME); + flags &= ~(RPMVERIFY_MD5 | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME); else if (S_ISFIFO(sb.st_mode)) - flags &= ~(VERIFY_MD5 | VERIFY_FILESIZE | VERIFY_MTIME | VERIFY_LINKTO); + flags &= ~(RPMVERIFY_MD5 | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME | RPMVERIFY_LINKTO); else if (S_ISCHR(sb.st_mode)) - flags &= ~(VERIFY_MD5 | VERIFY_FILESIZE | VERIFY_MTIME | VERIFY_LINKTO); + flags &= ~(RPMVERIFY_MD5 | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME | RPMVERIFY_LINKTO); else if (S_ISBLK(sb.st_mode)) - flags &= ~(VERIFY_MD5 | VERIFY_FILESIZE | VERIFY_MTIME | VERIFY_LINKTO); + flags &= ~(RPMVERIFY_MD5 | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME | RPMVERIFY_LINKTO); else - flags &= ~(VERIFY_LINKTO); + flags &= ~(RPMVERIFY_LINKTO); - if (flags & VERIFY_MD5) { - getEntry(h, RPMTAG_FILEMD5S, &type, (void **) &md5List, &count); + if (flags & RPMVERIFY_MD5) { + headerGetEntry(h, RPMTAG_FILEMD5S, &type, (void **) &md5List, &count); if (useBrokenMd5) { rc = mdfileBroken(filespec, md5sum); } else { @@ -82,48 +82,48 @@ int rpmVerifyFile(char * prefix, Header h, int filenum, int * result) { } if (rc || strcmp(md5sum, md5List[filenum])) - *result |= VERIFY_MD5; + *result |= RPMVERIFY_MD5; free(md5List); } - if (flags & VERIFY_LINKTO) { - getEntry(h, RPMTAG_FILELINKTOS, &type, (void **) &linktoList, &count); + if (flags & RPMVERIFY_LINKTO) { + headerGetEntry(h, RPMTAG_FILELINKTOS, &type, (void **) &linktoList, &count); size = readlink(filespec, linkto, sizeof(linkto)); if (size == -1) - *result |= VERIFY_LINKTO; + *result |= RPMVERIFY_LINKTO; else linkto[size] = '\0'; if (strcmp(linkto, linktoList[filenum])) - *result |= VERIFY_LINKTO; + *result |= RPMVERIFY_LINKTO; free(linktoList); } - if (flags & VERIFY_FILESIZE) { - getEntry(h, RPMTAG_FILESIZES, &type, (void **) &sizeList, &count); + if (flags & RPMVERIFY_FILESIZE) { + headerGetEntry(h, RPMTAG_FILESIZES, &type, (void **) &sizeList, &count); if (sizeList[filenum] != sb.st_size) - *result |= VERIFY_FILESIZE; + *result |= RPMVERIFY_FILESIZE; } - if (flags & VERIFY_MODE) { + if (flags & RPMVERIFY_MODE) { if (modeList[filenum] != sb.st_mode) - *result |= VERIFY_MODE; + *result |= RPMVERIFY_MODE; } - if (flags & VERIFY_RDEV) { - getEntry(h, RPMTAG_FILERDEVS, &type, (void **) &rdevList, &count); + if (flags & RPMVERIFY_RDEV) { + headerGetEntry(h, RPMTAG_FILERDEVS, &type, (void **) &rdevList, &count); if (rdevList[filenum] != sb.st_rdev) - *result |= VERIFY_RDEV; + *result |= RPMVERIFY_RDEV; } - if (flags & VERIFY_MTIME) { - getEntry(h, RPMTAG_FILEMTIMES, &type, (void **) &mtimeList, &count); + if (flags & RPMVERIFY_MTIME) { + headerGetEntry(h, RPMTAG_FILEMTIMES, &type, (void **) &mtimeList, &count); if (mtimeList[filenum] != sb.st_mtime) - *result |= VERIFY_MTIME; + *result |= RPMVERIFY_MTIME; } - if (flags & VERIFY_USER) { - getEntry(h, RPMTAG_FILEUIDS, &type, (void **) &uidList, &count); + if (flags & RPMVERIFY_USER) { + headerGetEntry(h, RPMTAG_FILEUIDS, &type, (void **) &uidList, &count); if (uidList[filenum] != sb.st_uid) - *result |= VERIFY_USER; + *result |= RPMVERIFY_USER; } - if (flags & VERIFY_GROUP) { - getEntry(h, RPMTAG_FILEGIDS, &type, (void **) &gidList, &count); + if (flags & RPMVERIFY_GROUP) { + headerGetEntry(h, RPMTAG_FILEGIDS, &type, (void **) &gidList, &count); if (gidList[filenum] != sb.st_gid) - *result |= VERIFY_GROUP; + *result |= RPMVERIFY_GROUP; } return 0; diff --git a/oldrpmdb.c b/oldrpmdb.c index 56e076606..1e5397133 100644 --- a/oldrpmdb.c +++ b/oldrpmdb.c @@ -2,7 +2,7 @@ #include #include -#include "rpmerr.h" +#include "rpmlib.h" #include "rpm_malloc.h" #include "messages.h" #include "misc.h" @@ -149,7 +149,7 @@ int oldrpmdbOpen(struct oldrpmdb * oldrpmdb) { strcat(path, "/packages"); oldrpmdb->packages = gdbm_open(path, 1024, gdbmFlags, 0644, NULL); if (!oldrpmdb->packages) { - error(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); + rpmError(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); goterr = 1; } @@ -157,7 +157,7 @@ int oldrpmdbOpen(struct oldrpmdb * oldrpmdb) { strcat(path, "/nameidx"); oldrpmdb->nameIndex = gdbm_open(path, 1024, gdbmFlags, 0644, NULL); if (!oldrpmdb->packages) { - error(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); + rpmError(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); goterr = 1; } @@ -165,7 +165,7 @@ int oldrpmdbOpen(struct oldrpmdb * oldrpmdb) { strcat(path, "/pathidx"); oldrpmdb->pathIndex = gdbm_open(path, 1024, gdbmFlags, 0644, NULL); if (!oldrpmdb->packages) { - error(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); + rpmError(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); goterr = 1; } @@ -173,7 +173,7 @@ int oldrpmdbOpen(struct oldrpmdb * oldrpmdb) { strcat(path, "/iconidx"); oldrpmdb->iconIndex = gdbm_open(path, 1024, gdbmFlags, 0644, NULL); if (!oldrpmdb->iconIndex) { - error(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); + rpmError(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); goterr = 1; } @@ -181,7 +181,7 @@ int oldrpmdbOpen(struct oldrpmdb * oldrpmdb) { strcat(path, "/groupindex"); oldrpmdb->groupIndex = gdbm_open(path, 1024, gdbmFlags, 0644, NULL); if (!oldrpmdb->packages) { - error(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); + rpmError(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); goterr = 1; } @@ -189,7 +189,7 @@ int oldrpmdbOpen(struct oldrpmdb * oldrpmdb) { strcat(path, "/postidx"); oldrpmdb->postIndex = gdbm_open(path, 1024, gdbmFlags, 0644, NULL); if (!oldrpmdb->postIndex) { - error(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); + rpmError(RPMERR_GDBMOPEN, path, gdbm_strerror(gdbm_errno)); goterr = 1; } @@ -454,14 +454,14 @@ int oldrpmdbGetPackageInfo(struct oldrpmdb * oldrpmdb, struct oldrpmdbLabel labe labelstr = oldrpmdbLabelToLabelstr(label, 0); - message(MESS_DEBUG, "pulling %s from database\n", labelstr); + rpmMessage(RPMMESS_DEBUG, "pulling %s from database\n", labelstr); key.dptr = labelstr; key.dsize = strlen(labelstr); rec = gdbm_fetch(oldrpmdb->packages, key); if (!rec.dptr) { - error(RPMERR_OLDDBCORRUPT, "package not found in database"); + rpmError(RPMERR_OLDDBCORRUPT, "package not found in database"); return 1; } diff --git a/query.c b/query.c index 6ade08787..613ec9433 100644 --- a/query.c +++ b/query.c @@ -23,10 +23,10 @@ static int queryHeader(Header h, char * chptr); static int queryArray(Header h, char ** chptrptr); static void escapedChar(char ch); static char * handleFormat(Header h, char * chptr, int * count, int arrayNum); -static void showMatches(rpmdb db, dbIndexSet matches, int queryFlags, +static void showMatches(rpmdb db, dbiIndexSet matches, int queryFlags, char * queryFormat); static int findMatches(rpmdb db, char * name, char * version, char * release, - dbIndexSet * matches); + dbiIndexSet * matches); static void printFileInfo(char * name, unsigned int size, unsigned short mode, unsigned int mtime, unsigned short rdev, char * owner, char * group, int uid, int gid, @@ -217,43 +217,43 @@ static char * handleFormat(Header h, char * chptr, int * cntptr, return NULL; } - if (!getEntry(h, t->val, &type, &p, &count) || !p) { + if (!headerGetEntry(h, t->val, &type, &p, &count) || !p) { p = "(none)"; count = 1; - type = STRING_TYPE; + type = RPM_STRING_TYPE; } else if (notArray) { *cntptr = -1; } else if (count > 1 && (arrayNum == -1)) { p = "(array)"; count = 1; - type = STRING_TYPE; + type = RPM_STRING_TYPE; } else if ((count - 1) < arrayNum && arrayNum != -1) { p = "(past array end)"; count = 1; - type = STRING_TYPE; + type = RPM_STRING_TYPE; } else if (arrayNum != -1) *cntptr = count; if (arrayNum == -1) arrayNum = 0; switch (type) { - case STRING_ARRAY_TYPE: + case RPM_STRING_ARRAY_TYPE: strcat(format, "s"); printf(format, ((char **) p)[arrayNum]); free(p); break; - case STRING_TYPE: + case RPM_STRING_TYPE: strcat(format, "s"); printf(format, p); break; - case INT8_TYPE: + case RPM_INT8_TYPE: strcat(format, "d"); printf(format, *(((int_8 *) p) + arrayNum)); break; - case INT16_TYPE: + case RPM_INT16_TYPE: if (!strcmp(how, "perms") || !strcmp(how, "permissions")) { strcat(format, "s"); printf(format, permsString(*(((int_16 *) p) + arrayNum))); @@ -263,7 +263,7 @@ static char * handleFormat(Header h, char * chptr, int * cntptr, } break; - case INT32_TYPE: + case RPM_INT32_TYPE: if (!strcmp(how, "date")) { strcat(format, "s"); /* this is important if sizeof(int_32) ! sizeof(time_t) */ @@ -286,13 +286,13 @@ static char * handleFormat(Header h, char * chptr, int * cntptr, } else if (!strcmp(how, "depflags")) { buf[0] = '\0'; anint = *(((int_32 *) p) + arrayNum); - if (anint & REQUIRE_LESS) + if (anint & RPMSENSE_LESS) strcat(buf, "<"); - if (anint & REQUIRE_GREATER) + if (anint & RPMSENSE_GREATER) strcat(buf, ">"); - if (anint & REQUIRE_EQUAL) + if (anint & RPMSENSE_EQUAL) strcat(buf, "="); - if (anint & REQUIRE_SERIAL) + if (anint & RPMSENSE_SERIAL) strcat(buf, "S"); strcat(format, "s"); @@ -339,9 +339,9 @@ static void printHeader(Header h, int queryFlags, char * queryFormat) { uint_16 * fileRdevList; int i; - getEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); - getEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); - getEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); + headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); if (!queryFlags) { printf("%s-%s-%s\n", name, version, release); @@ -355,45 +355,45 @@ static void printHeader(Header h, int queryFlags, char * queryFormat) { } if (queryFlags & QUERY_FOR_PROVIDES) { - if (isEntry(h, RPMTAG_PROVIDES)) + if (headerIsEntry(h, RPMTAG_PROVIDES)) queryHeader(h, providesQueryFormat); } if (queryFlags & QUERY_FOR_REQUIRES) { - if (isEntry(h, RPMTAG_REQUIREFLAGS)) + if (headerIsEntry(h, RPMTAG_REQUIREFLAGS)) queryHeader(h, requiresQueryFormat); } if (queryFlags & QUERY_FOR_LIST) { - if (!getEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, + if (!headerGetEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, &count)) { puts("(contains no files)"); } else { - if (!getEntry(h, RPMTAG_FILESTATES, &type, + if (!headerGetEntry(h, RPMTAG_FILESTATES, &type, (void **) &fileStatesList, &count)) { fileStatesList = NULL; } - getEntry(h, RPMTAG_FILEFLAGS, &type, + headerGetEntry(h, RPMTAG_FILEFLAGS, &type, (void **) &fileFlagsList, &count); - getEntry(h, RPMTAG_FILESIZES, &type, + headerGetEntry(h, RPMTAG_FILESIZES, &type, (void **) &fileSizeList, &count); - getEntry(h, RPMTAG_FILEMODES, &type, + headerGetEntry(h, RPMTAG_FILEMODES, &type, (void **) &fileModeList, &count); - getEntry(h, RPMTAG_FILEMTIMES, &type, + headerGetEntry(h, RPMTAG_FILEMTIMES, &type, (void **) &fileMTimeList, &count); - getEntry(h, RPMTAG_FILERDEVS, &type, + headerGetEntry(h, RPMTAG_FILERDEVS, &type, (void **) &fileRdevList, &count); - getEntry(h, RPMTAG_FILEUIDS, &type, + headerGetEntry(h, RPMTAG_FILEUIDS, &type, (void **) &fileUIDList, &count); - getEntry(h, RPMTAG_FILEGIDS, &type, + headerGetEntry(h, RPMTAG_FILEGIDS, &type, (void **) &fileGIDList, &count); - getEntry(h, RPMTAG_FILEUSERNAME, &type, + headerGetEntry(h, RPMTAG_FILEUSERNAME, &type, (void **) &fileOwnerList, &count); - getEntry(h, RPMTAG_FILEGROUPNAME, &type, + headerGetEntry(h, RPMTAG_FILEGROUPNAME, &type, (void **) &fileGroupList, &count); - getEntry(h, RPMTAG_FILELINKTOS, &type, + headerGetEntry(h, RPMTAG_FILELINKTOS, &type, (void **) &fileLinktoList, &count); - getEntry(h, RPMTAG_FILEMD5S, &type, + headerGetEntry(h, RPMTAG_FILEMD5S, &type, (void **) &fileMD5List, &count); for (i = 0; i < count; i++) { @@ -404,7 +404,7 @@ static void printHeader(Header h, int queryFlags, char * queryFormat) { || ((queryFlags & QUERY_FOR_CONFIG) && (fileFlagsList[i] & RPMFILE_CONFIG))) { - if (!isVerbose()) + if (!rpmIsVerbose()) prefix ? fputs(prefix, stdout) : 0; if (queryFlags & QUERY_FOR_STATE) { @@ -449,7 +449,7 @@ static void printHeader(Header h, int queryFlags, char * queryFormat) { else printf("X\n"); - } else if (!isVerbose()) { + } else if (!rpmIsVerbose()) { puts(fileList[i]); } else if (fileOwnerList) printFileInfo(fileList[i], fileSizeList[i], @@ -595,14 +595,14 @@ static void printFileInfo(char * name, unsigned int size, unsigned short mode, sizefield, timefield, namefield); } -static void showMatches(rpmdb db, dbIndexSet matches, int queryFlags, +static void showMatches(rpmdb db, dbiIndexSet matches, int queryFlags, char * queryFormat) { int i; Header h; for (i = 0; i < matches.count; i++) { if (matches.recs[i].recOffset) { - message(MESS_DEBUG, "querying record number %d\n", + rpmMessage(RPMMESS_DEBUG, "querying record number %d\n", matches.recs[i].recOffset); h = rpmdbGetRecord(db, matches.recs[i].recOffset); @@ -610,7 +610,7 @@ static void showMatches(rpmdb db, dbIndexSet matches, int queryFlags, fprintf(stderr, "error: could not read database record\n"); } else { printHeader(h, queryFlags, queryFormat); - freeHeader(h); + headerFree(h); } } } @@ -624,7 +624,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, int rc; int isSource; rpmdb db; - dbIndexSet matches; + dbiIndexSet matches; int recNumber; int retcode = 0; char *end = NULL; @@ -655,7 +655,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, } if (fd >= 0) { - rc = pkgReadHeader(fd, &h, &isSource, NULL, NULL); + rc = rpmReadPackageHeader(fd, &h, &isSource, NULL, NULL); close(fd); if (isUrl) { @@ -669,7 +669,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, "queried\n"); } else { printHeader(h, queryFlags, queryFormat); - freeHeader(h); + headerFree(h); } break; case 1: @@ -694,7 +694,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, return 1; } printHeader(h, queryFlags, queryFormat); - freeHeader(h); + headerFree(h); offset = rpmdbNextRecNum(db, offset); } break; @@ -706,7 +706,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, retcode = 1; } else { showMatches(db, matches, queryFlags, queryFormat); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } break; @@ -716,7 +716,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, retcode = 1; } else { showMatches(db, matches, queryFlags, queryFormat); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } break; @@ -726,7 +726,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, retcode = 1; } else { showMatches(db, matches, queryFlags, queryFormat); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } break; @@ -742,7 +742,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, retcode = 1; } else { showMatches(db, matches, queryFlags, queryFormat); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } break; @@ -754,7 +754,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, fprintf(stderr, "invalid package number: %s\n", arg); return 1; } - message(MESS_DEBUG, "showing package: %d\n", recNumber); + rpmMessage(RPMMESS_DEBUG, "showing package: %d\n", recNumber); h = rpmdbGetRecord(db, recNumber); if (!h) { @@ -762,7 +762,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, retcode = 1; } else { printHeader(h, queryFlags, queryFormat); - freeHeader(h); + headerFree(h); } break; @@ -776,7 +776,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, fprintf(stderr, "error looking for package %s\n", arg); } else { showMatches(db, matches, queryFlags, queryFormat); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } break; } @@ -791,7 +791,7 @@ int doQuery(char * prefix, enum querysources source, int queryFlags, /* 0 found matches */ /* 1 no matches */ /* 2 error */ -int findPackageByLabel(rpmdb db, char * arg, dbIndexSet * matches) { +int findPackageByLabel(rpmdb db, char * arg, dbiIndexSet * matches) { char * localarg, * chptr; char * release; int rc; @@ -828,7 +828,7 @@ int findPackageByLabel(rpmdb db, char * arg, dbIndexSet * matches) { /* 1 no matches */ /* 2 error */ int findMatches(rpmdb db, char * name, char * version, char * release, - dbIndexSet * matches) { + dbiIndexSet * matches) { int gotMatches; int rc; int i; @@ -851,12 +851,12 @@ int findMatches(rpmdb db, char * name, char * version, char * release, h = rpmdbGetRecord(db, matches->recs[i].recOffset); if (!h) { fprintf(stderr, "error: could not read database record\n"); - freeDBIndexRecord(*matches); + dbiFreeIndexRecord(*matches); return 2; } - getEntry(h, RPMTAG_VERSION, &type, (void **) &pkgVersion, &count); - getEntry(h, RPMTAG_RELEASE, &type, (void **) &pkgRelease, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &pkgVersion, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &pkgRelease, &count); goodRelease = goodVersion = 1; @@ -871,7 +871,7 @@ int findMatches(rpmdb db, char * name, char * version, char * release, } if (!gotMatches) { - freeDBIndexRecord(*matches); + dbiFreeIndexRecord(*matches); return 1; } diff --git a/query.h b/query.h index 75471b4d2..6d8ceb9a8 100644 --- a/query.h +++ b/query.h @@ -25,6 +25,6 @@ void queryPrintTags(void); /* 0 found matches */ /* 1 no matches */ /* 2 error */ -int findPackageByLabel(rpmdb db, char * arg, dbIndexSet * matches); +int findPackageByLabel(rpmdb db, char * arg, dbiIndexSet * matches); #endif diff --git a/rpm.c b/rpm.c index 604602e41..542a323d5 100755 --- a/rpm.c +++ b/rpm.c @@ -8,7 +8,6 @@ #include #include "install.h" -#include "lib/rpmerr.h" #include "lib/messages.h" #include "lib/signature.h" #include "query.h" @@ -238,7 +237,7 @@ int build(char *arg, int buildAmount, char *passPhrase, stat(specfile, &statbuf); if (! S_ISREG(statbuf.st_mode)) { - error(RPMERR_BADSPEC, "File is not a regular file: %s\n", specfile); + rpmError(RPMERR_BADSPEC, "File is not a regular file: %s\n", specfile); return 1; } @@ -265,7 +264,7 @@ int build(char *arg, int buildAmount, char *passPhrase, } else { /* Spec parse failed -- could be Exclude: Exclusive: */ res = 1; - if (errCode() == RPMERR_BADARCH) { + if (rpmErrorCode() == RPMERR_BADARCH) { fprintf(stderr, _("%s doesn't build on this architecture\n"), arg); } else { fprintf(stderr, _("Build failed.\n")); @@ -464,9 +463,9 @@ int main(int argc, char ** argv) { if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL) argerror(_("only one major mode may be specified")); bigMode = MODE_UNINSTALL; - message(MESS_ERROR, _("-u and --uninstall are depricated and no" + rpmMessage(RPMMESS_ERROR, _("-u and --uninstall are depricated and no" " longer work.\n")); - message(MESS_ERROR, _("Use -e or --erase instead.\n")); + rpmMessage(RPMMESS_ERROR, _("Use -e or --erase instead.\n")); exit(1); case 'e': @@ -501,7 +500,7 @@ int main(int argc, char ** argv) { break; case 'v': - increaseVerbosity(); + rpmIncreaseVerbosity(); break; case 'i': @@ -524,7 +523,7 @@ int main(int argc, char ** argv) { if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL) argerror(_("only one major mode may be specified")); bigMode = MODE_INSTALL; - installFlags |= INSTALL_UPGRADE; + installFlags |= RPMINSTALL_UPGRADE; break; case 's': @@ -684,7 +683,7 @@ int main(int argc, char ** argv) { case GETOPT_DBPATH: if (optarg[0] != '/') argerror(_("arguments to --dbpath must begin with a /")); - setVar(RPMVAR_DBPATH, optarg); + rpmSetVar(RPMVAR_DBPATH, optarg); gotDbpath = 1; break; @@ -702,7 +701,7 @@ int main(int argc, char ** argv) { if ((*tce) || (tce == optarg) || (timeCheck == ULONG_MAX)) { argerror("Argument to --timecheck must be integer"); } - setVar(RPMVAR_TIMECHECK, optarg); + rpmSetVar(RPMVAR_TIMECHECK, optarg); break; case GETOPT_REBUILDDB: @@ -727,7 +726,7 @@ int main(int argc, char ** argv) { } if (quiet) - setVerbosity(MESS_QUIET); + rpmSetVerbosity(RPMMESS_QUIET); if (version) printVersion(); if (help) printHelp(); @@ -845,7 +844,7 @@ int main(int argc, char ** argv) { argerror(_("--short-circuit may only be used with -bc or -bi")); } - if (oldPackage && !(installFlags & INSTALL_UPGRADE)) + if (oldPackage && !(installFlags & RPMINSTALL_UPGRADE)) argerror(_("--oldpackage may only be used during upgrades")); if (bigMode != MODE_QUERY && dump) @@ -860,19 +859,19 @@ int main(int argc, char ** argv) { argerror(_("ftp options can only be used during package queries, " "installs, and upgrades")); - if (oldPackage || (force && (installFlags & INSTALL_UPGRADE))) - installFlags |= INSTALL_UPGRADETOOLD; + if (oldPackage || (force && (installFlags & RPMINSTALL_UPGRADE))) + installFlags |= RPMINSTALL_UPGRADETOOLD; - if (ftpProxy) setVar(RPMVAR_FTPPROXY, ftpProxy); - if (ftpPort) setVar(RPMVAR_FTPPORT, ftpPort); + if (ftpProxy) rpmSetVar(RPMVAR_FTPPROXY, ftpProxy); + if (ftpPort) rpmSetVar(RPMVAR_FTPPORT, ftpPort); if (signIt) { if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD || bigMode == MODE_RESIGN) { if (optind != argc) { - switch (sigLookupType()) { - case SIGTAG_PGP: - if (!(passPhrase = getPassPhrase("Enter pass phrase: "))) { + switch (rpmLookupSignatureType()) { + case RPMSIGTAG_PGP: + if (!(passPhrase = rpmGetPassPhrase("Enter pass phrase: "))) { fprintf(stderr, _("Pass phrase check failed\n")); exit(1); } else { @@ -892,7 +891,7 @@ int main(int argc, char ** argv) { } } else { /* Override any rpmrc setting */ - setVar(RPMVAR_SIGTYPE, "none"); + rpmSetVar(RPMVAR_SIGTYPE, "none"); } switch (bigMode) { @@ -927,8 +926,8 @@ int main(int argc, char ** argv) { case MODE_REBUILD: case MODE_RECOMPILE: - if (getVerbosity() == MESS_NORMAL) - setVerbosity(MESS_VERBOSE); + if (rpmGetVerbosity() == RPMMESS_NORMAL) + rpmSetVerbosity(RPMMESS_VERBOSE); if (optind == argc) argerror(_("no packages files given for rebuild")); @@ -950,8 +949,8 @@ int main(int argc, char ** argv) { break; case MODE_BUILD: - if (getVerbosity() == MESS_NORMAL) - setVerbosity(MESS_VERBOSE); + if (rpmGetVerbosity() == RPMMESS_NORMAL) + rpmSetVerbosity(RPMMESS_VERBOSE); switch (buildChar) { /* these fallthroughs are intentional */ @@ -996,32 +995,33 @@ int main(int argc, char ** argv) { if (optind == argc) argerror(_("no packages given for uninstall")); - if (noScripts) uninstallFlags |= UNINSTALL_NOSCRIPTS; - if (test) uninstallFlags |= UNINSTALL_TEST; - if (noDeps) interfaceFlags |= RPMUNINSTALL_NODEPS; + if (noScripts) uninstallFlags |= RPMUNINSTALL_NOSCRIPTS; + if (test) uninstallFlags |= RPMUNINSTALL_TEST; + if (noDeps) interfaceFlags |= UNINSTALL_NODEPS; ec = doUninstall(rootdir, argv + optind, uninstallFlags, interfaceFlags); break; case MODE_INSTALL: - if (force) installFlags |= (INSTALL_REPLACEPKG | INSTALL_REPLACEFILES); - if (replaceFiles) installFlags |= INSTALL_REPLACEFILES; - if (replacePackages) installFlags |= INSTALL_REPLACEPKG; - if (test) installFlags |= INSTALL_TEST; - if (noScripts) installFlags |= INSTALL_NOSCRIPTS; - if (ignoreArch) installFlags |= INSTALL_NOARCH; - if (ignoreOs) installFlags |= INSTALL_NOOS; + if (force) + installFlags |= (RPMINSTALL_REPLACEPKG | RPMINSTALL_REPLACEFILES); + if (replaceFiles) installFlags |= RPMINSTALL_REPLACEFILES; + if (replacePackages) installFlags |= RPMINSTALL_REPLACEPKG; + if (test) installFlags |= RPMINSTALL_TEST; + if (noScripts) installFlags |= RPMINSTALL_NOSCRIPTS; + if (ignoreArch) installFlags |= RPMINSTALL_NOARCH; + if (ignoreOs) installFlags |= RPMINSTALL_NOOS; - if (showPercents) interfaceFlags |= RPMINSTALL_PERCENT; - if (showHash) interfaceFlags |= RPMINSTALL_HASH; - if (noDeps) interfaceFlags |= RPMINSTALL_NODEPS; + if (showPercents) interfaceFlags |= INSTALL_PERCENT; + if (showHash) interfaceFlags |= INSTALL_HASH; + if (noDeps) interfaceFlags |= INSTALL_NODEPS; if (!incldocs) { if (excldocs) - installFlags |= INSTALL_NODOCS; - else if (getBooleanVar(RPMVAR_EXCLUDEDOCS)) - installFlags |= INSTALL_NODOCS; + installFlags |= RPMINSTALL_NODOCS; + else if (rpmGetBooleanVar(RPMVAR_EXCLUDEDOCS)) + installFlags |= RPMINSTALL_NODOCS; } if (optind == argc) diff --git a/rpm2cpio.c b/rpm2cpio.c index 2b70caa4a..3aaa4d6b5 100644 --- a/rpm2cpio.c +++ b/rpm2cpio.c @@ -36,7 +36,7 @@ int main(int argc, char **argv) exit(1); } - rc = pkgReadHeader(fd, &hd, &isSource, NULL, NULL); + rc = rpmReadPackageHeader(fd, &hd, &isSource, NULL, NULL); if (rc == 1) { fprintf(stderr, "argument is not an RPM package\n"); exit(1); diff --git a/rpmio/messages.c b/rpmio/messages.c index 5f1ed3665..953db687e 100644 --- a/rpmio/messages.c +++ b/rpmio/messages.c @@ -2,59 +2,60 @@ #include #include "messages.h" +#include "rpmlib.h" -static minLevel = MESS_NORMAL; +static minLevel = RPMMESS_NORMAL; -void increaseVerbosity(void) { +void rpmIncreaseVerbosity(void) { minLevel--; } -void setVerbosity(int level) { +void rpmSetVerbosity(int level) { minLevel = level; } -int getVerbosity(void) +int rpmGetVerbosity(void) { return minLevel; } -int isDebug(void) +int rpmIsDebug(void) { - return (minLevel <= MESS_DEBUG); + return (minLevel <= RPMMESS_DEBUG); } -int isVerbose(void) +int rpmIsVerbose(void) { - return (minLevel <= MESS_VERBOSE); + return (minLevel <= RPMMESS_VERBOSE); } -void message(int level, char * format, ...) { +void rpmMessage(int level, char * format, ...) { va_list args; va_start(args, format); if (level >= minLevel) { switch (level) { - case MESS_VERBOSE: - case MESS_NORMAL: + case RPMMESS_VERBOSE: + case RPMMESS_NORMAL: vfprintf(stdout, format, args); break; - case MESS_DEBUG: + case RPMMESS_DEBUG: fprintf(stdout, "D: "); vfprintf(stdout, format, args); break; - case MESS_WARNING: + case RPMMESS_WARNING: fprintf(stderr, "warning: "); vfprintf(stderr, format, args); break; - case MESS_ERROR: + case RPMMESS_ERROR: fprintf(stderr, "error: "); vfprintf(stderr, format, args); break; - case MESS_FATALERROR: + case RPMMESS_FATALERROR: fprintf(stderr, "fatal error: "); vfprintf(stderr, format, args); exit(1); diff --git a/rpmio/rpmerr.c b/rpmio/rpmerr.c index 38000aad6..8106f7242 100644 --- a/rpmio/rpmerr.c +++ b/rpmio/rpmerr.c @@ -1,33 +1,33 @@ #include #include -#include "rpmerr.h" +#include "rpmlib.h" static struct err { int code; char string[1024]; } errorRec; -static CallBackType errorCallback = NULL; +static rpmErrorCallBackType errorCallback = NULL; -int errCode(void) +int rpmErrorCode(void) { return errorRec.code; } -char *errCodeString(void) +char *rpmErrorCodeString(void) { return NULL; } -char *errString(void) +char *rpmErrorString(void) { return errorRec.string; } -CallBackType errSetCallback(CallBackType cb) +rpmErrorCallBackType rpmErrorSetCallback(rpmErrorCallBackType cb) { - CallBackType ocb; + rpmErrorCallBackType ocb; ocb = errorCallback; errorCallback = cb; @@ -35,7 +35,7 @@ CallBackType errSetCallback(CallBackType cb) return ocb; } -void error(int code, char *format, ...) +void rpmError(int code, char *format, ...) { va_list args; diff --git a/tools/dump.c b/tools/dump.c index b9a00efa1..b439219ba 100644 --- a/tools/dump.c +++ b/tools/dump.c @@ -22,15 +22,15 @@ void main(int argc, char ** argv) exit(1); } - h = readHeader(fd, HEADER_MAGIC); + h = headerRead(fd, HEADER_MAGIC_YES); if (!h) { - fprintf(stderr, "readHeader error: %s\n", strerror(errno)); + fprintf(stderr, "headerRead error: %s\n", strerror(errno)); exit(1); } close(fd); - dumpHeader(h, stdout, 1); - freeHeader(h); + headerDump(h, stdout, 1); + headerFree(h); } diff --git a/tools/dumpdb.c b/tools/dumpdb.c index 1abf2f423..93b13ae14 100644 --- a/tools/dumpdb.c +++ b/tools/dumpdb.c @@ -35,13 +35,13 @@ void main(int argc, char ** argv) if (!dspBlockNum || dspBlockNum == blockNum) { h = rpmdbGetRecord(db, offset); if (!h) { - fprintf(stderr, "readHeader failed\n"); + fprintf(stderr, "headerRead failed\n"); exit(1); } - dumpHeader(h, stdout, 1); + headerDump(h, stdout, 1); printf("Offset: %d\n", offset); - freeHeader(h); + headerFree(h); } if (dspBlockNum && blockNum > dspBlockNum) exit(0); diff --git a/tools/rpmarchive.c b/tools/rpmarchive.c index 254b52803..e2b0f713d 100644 --- a/tools/rpmarchive.c +++ b/tools/rpmarchive.c @@ -23,9 +23,9 @@ int main(int argc, char **argv) } readLead(fd, &lead); - readSignature(fd, NULL, lead.signature_type); - hd = readHeader(fd, (lead.major >= 3) ? - HEADER_MAGIC : NO_HEADER_MAGIC); + rpmReadSignature(fd, NULL, lead.signature_type); + hd = headerRead(fd, (lead.major >= 3) ? + HEADER_MAGIC_NO : HEADER_MAGIC_NO); while ((ct = read(fd, &buffer, 1024))) { write(1, &buffer, ct); diff --git a/tools/rpmchecksig.c b/tools/rpmchecksig.c index 21b0e4a13..896f72f76 100644 --- a/tools/rpmchecksig.c +++ b/tools/rpmchecksig.c @@ -27,7 +27,7 @@ int main(int argc, char **argv) exit(-1); readLead(fd, &lead); - readSignature(fd, lead.signature_type, (void **) &sig); + rpmReadSignature(fd, lead.signature_type, (void **) &sig); res = verifySignature(fd, lead.signature_type, sig, result, 1); printf("%s", result); if (res) { diff --git a/tools/rpmheader.c b/tools/rpmheader.c index 2b883f7a7..a838ad547 100644 --- a/tools/rpmheader.c +++ b/tools/rpmheader.c @@ -21,10 +21,10 @@ int main(int argc, char **argv) } readLead(fd, &lead); - readSignature(fd, NULL, lead.signature_type); - hd = readHeader(fd, (lead.major >= 3) ? - HEADER_MAGIC : NO_HEADER_MAGIC); - writeHeader(1, hd, HEADER_MAGIC); + rpmReadSignature(fd, NULL, lead.signature_type); + hd = headerRead(fd, (lead.major >= 3) ? + HEADER_MAGIC_YES : HEADER_MAGIC_NO); + headerWrite(1, hd, HEADER_MAGIC_YES); return 0; } diff --git a/tools/rpmsignature.c b/tools/rpmsignature.c index 6829bfd2f..0b900e87e 100644 --- a/tools/rpmsignature.c +++ b/tools/rpmsignature.c @@ -20,13 +20,13 @@ int main(int argc, char **argv) } readLead(fd, &lead); - readSignature(fd, &sig, lead.signature_type); + rpmReadSignature(fd, &sig, lead.signature_type); switch (lead.signature_type) { case RPMSIG_NONE: fprintf(stderr, "No signature available.\n"); break; default: - writeSignature(1, sig); + rpmWriteSignature(1, sig); } return 0; diff --git a/url.c b/url.c index 6f50cf082..635921b03 100644 --- a/url.c +++ b/url.c @@ -115,19 +115,19 @@ static int urlFtpLogin(char * url, char ** fileNamePtr) { int port; int ftpconn; - message(MESS_DEBUG, "getting %s via anonymous ftp\n", url); + rpmMessage(RPMMESS_DEBUG, "getting %s via anonymous ftp\n", url); buf = alloca(strlen(url) + 1); strcpy(buf, url); urlFtpSplit(buf, &userName, &password, &machineName, &fileName); - message(MESS_DEBUG, "logging into %s as %s, pw %s\n", machineName, + rpmMessage(RPMMESS_DEBUG, "logging into %s as %s, pw %s\n", machineName, userName ? userName : "ftp", password ? password : "(username)"); - proxy = getVar(RPMVAR_FTPPROXY); - portStr = getVar(RPMVAR_FTPPORT); + proxy = rpmGetVar(RPMVAR_FTPPROXY); + portStr = rpmGetVar(RPMVAR_FTPPORT); if (!portStr) { port = -1; } else { @@ -158,7 +158,7 @@ int urlGetFd(char * url, struct urlContext * context) { char * fileName; int fd; - message(MESS_DEBUG, "getting %s via anonymous ftp\n", url); + rpmMessage(RPMMESS_DEBUG, "getting %s via anonymous ftp\n", url); if ((context->ftpControl = urlFtpLogin(url, &fileName)) < 0) return context->ftpControl; @@ -184,14 +184,14 @@ int urlGetFile(char * url, char * dest) { int rc; int fd; - message(MESS_DEBUG, "getting %s via anonymous ftp\n", url); + rpmMessage(RPMMESS_DEBUG, "getting %s via anonymous ftp\n", url); if ((ftpconn = urlFtpLogin(url, &fileName)) < 0) return ftpconn; fd = creat(dest, 0600); if (fd < 0) { - message(MESS_DEBUG, "failed to create %s\n", dest); + rpmMessage(RPMMESS_DEBUG, "failed to create %s\n", dest); ftpClose(ftpconn); free(fileName); return FTPERR_UNKNOWN; diff --git a/verify.c b/verify.c index d91156cdf..4bb5eb604 100644 --- a/verify.c +++ b/verify.c @@ -11,7 +11,7 @@ #include "verify.h" static void verifyHeader(char * prefix, Header h); -static void verifyMatches(char * prefix, rpmdb db, dbIndexSet matches, +static void verifyMatches(char * prefix, rpmdb db, dbiIndexSet matches, int verifyFlags); static void verifyDependencies(rpmdb db, Header h); @@ -24,9 +24,9 @@ static void verifyHeader(char * prefix, Header h) { char * group, * user, * rdev; int_32 * fileFlagsList; - getEntry(h, RPMTAG_FILEFLAGS, &type, (void **) &fileFlagsList, &count); + headerGetEntry(h, RPMTAG_FILEFLAGS, &type, (void **) &fileFlagsList, &count); - if (getEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, &count)) { + if (headerGetEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, &count)) { for (i = 0; i < count; i++) { if (rpmVerifyFile(prefix, h, i, &verifyResult)) printf("missing %s\n", fileList[i]); @@ -36,21 +36,21 @@ static void verifyHeader(char * prefix, Header h) { if (!verifyResult) continue; - if (verifyResult & VERIFY_MD5) + if (verifyResult & RPMVERIFY_MD5) md5 = "5"; - if (verifyResult & VERIFY_FILESIZE) + if (verifyResult & RPMVERIFY_FILESIZE) size = "S"; - if (verifyResult & VERIFY_LINKTO) + if (verifyResult & RPMVERIFY_LINKTO) link = "L"; - if (verifyResult & VERIFY_MTIME) + if (verifyResult & RPMVERIFY_MTIME) mtime = "T"; - if (verifyResult & VERIFY_RDEV) + if (verifyResult & RPMVERIFY_RDEV) rdev = "D"; - if (verifyResult & VERIFY_USER) + if (verifyResult & RPMVERIFY_USER) user = "U"; - if (verifyResult & VERIFY_GROUP) + if (verifyResult & RPMVERIFY_GROUP) group = "G"; - if (verifyResult & VERIFY_MODE) + if (verifyResult & RPMVERIFY_MODE) mode = "M"; printf("%s%s%s%s%s%s%s%s %c %s\n", @@ -78,9 +78,9 @@ static void verifyDependencies(rpmdb db, Header h) { rpmdepDone(rpmdep); if (numConflicts) { - getEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); - getEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); - getEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); + headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count); + headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count); + headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count); printf("Unsatisfied dependencies for %s-%s-%s: ", name, version, release); for (i = 0; i < numConflicts; i++) { @@ -96,14 +96,14 @@ static void verifyDependencies(rpmdb db, Header h) { } } -static void verifyMatches(char * prefix, rpmdb db, dbIndexSet matches, +static void verifyMatches(char * prefix, rpmdb db, dbiIndexSet matches, int verifyFlags) { int i; Header h; for (i = 0; i < matches.count; i++) { if (matches.recs[i].recOffset) { - message(MESS_DEBUG, "verifying record number %d\n", + rpmMessage(RPMMESS_DEBUG, "verifying record number %d\n", matches.recs[i].recOffset); h = rpmdbGetRecord(db, matches.recs[i].recOffset); @@ -114,7 +114,7 @@ static void verifyMatches(char * prefix, rpmdb db, dbIndexSet matches, verifyDependencies(db, h); if (verifyFlags & VERIFY_FILES) verifyHeader(prefix, h); - freeHeader(h); + headerFree(h); } } } @@ -128,7 +128,7 @@ void doVerify(char * prefix, enum verifysources source, char ** argv, int rc; int isSource; rpmdb db; - dbIndexSet matches; + dbiIndexSet matches; char * arg; if ((source == VERIFY_SRPM || source == VERIFY_RPM) && @@ -152,7 +152,7 @@ void doVerify(char * prefix, enum verifysources source, char ** argv, verifyDependencies(db, h); if (verifyFlags & VERIFY_FILES) verifyHeader(prefix, h); - freeHeader(h); + headerFree(h); offset = rpmdbNextRecNum(db, offset); } } else { @@ -167,7 +167,7 @@ void doVerify(char * prefix, enum verifysources source, char ** argv, fprintf(stderr, "open of %s failed: %s\n", arg, strerror(errno)); } else { - rc = pkgReadHeader(fd, &h, &isSource, NULL, NULL); + rc = rpmReadPackageHeader(fd, &h, &isSource, NULL, NULL); close(fd); switch (rc) { case 0: @@ -175,7 +175,7 @@ void doVerify(char * prefix, enum verifysources source, char ** argv, verifyDependencies(db, h); if (verifyFlags & VERIFY_FILES) verifyHeader(prefix, h); - freeHeader(h); + headerFree(h); break; case 1: fprintf(stderr, "%s is not an RPM\n", arg); @@ -191,7 +191,7 @@ void doVerify(char * prefix, enum verifysources source, char ** argv, arg); } else { verifyMatches(prefix, db, matches, verifyFlags); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } break; @@ -202,7 +202,7 @@ void doVerify(char * prefix, enum verifysources source, char ** argv, arg); } else { verifyMatches(prefix, db, matches, verifyFlags); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } break; @@ -215,7 +215,7 @@ void doVerify(char * prefix, enum verifysources source, char ** argv, fprintf(stderr, "error looking for package %s\n", arg); } else { verifyMatches(prefix, db, matches, verifyFlags); - freeDBIndexRecord(matches); + dbiFreeIndexRecord(matches); } break;