summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRakesh Pandit <rakesh@fedoraproject.org>2009-03-14 16:38:10 +0530
committerPanu Matilainen <pmatilai@redhat.com>2009-04-23 12:10:22 +0300
commit7cd942db0b5c09f71caeb9b732f69acb7703f4ef (patch)
treea371272d48d1bcf7d06ab71bbf40e4f5ec987c55 /lib
parent0766138ee96fd9c0db193907a0013aba5c3d18bf (diff)
downloadlibrpm-tizen-7cd942db0b5c09f71caeb9b732f69acb7703f4ef.tar.gz
librpm-tizen-7cd942db0b5c09f71caeb9b732f69acb7703f4ef.tar.bz2
librpm-tizen-7cd942db0b5c09f71caeb9b732f69acb7703f4ef.zip
- Move header reading part from rpminstall to tryReadHeader function.
Diffstat (limited to 'lib')
-rw-r--r--lib/psm.c1
-rw-r--r--lib/rpminstall.c76
2 files changed, 39 insertions, 38 deletions
diff --git a/lib/psm.c b/lib/psm.c
index a13f43939..d67f2236f 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -24,7 +24,6 @@
#include "lib/rpmte_internal.h" /* XXX internal apis */
#include "lib/rpmlead.h" /* writeLead proto */
#include "lib/signature.h" /* signature constants */
-#include "lib/misc.h" /* XXX rpmMkdirPath */
#include "debug.h"
diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index 9fb4767f4..8e5553171 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -322,6 +322,41 @@ static int tryReadManifest(struct rpmEIU * eiu)
return rc;
}
+static int tryReadHeader(rpmts ts, struct rpmEIU * eiu, rpmVSFlags vsflags)
+{
+ rpmVSFlags tvsflags;
+
+ /* Try to read the header from a package file. */
+ eiu->fd = Fopen(*eiu->fnp, "r.ufdio");
+ if (eiu->fd == NULL || Ferror(eiu->fd)) {
+ rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), *eiu->fnp,
+ Fstrerror(eiu->fd));
+ if (eiu->fd != NULL) {
+ Fclose(eiu->fd);
+ eiu->fd = NULL;
+ }
+ eiu->numFailed++; *eiu->fnp = NULL;
+ return RPMRC_FAIL;
+ }
+
+ /* Read the header, verifying signatures (if present). */
+ tvsflags = rpmtsSetVSFlags(ts, vsflags);
+ eiu->rpmrc = rpmReadPackageFile(ts, eiu->fd, *eiu->fnp, &eiu->h);
+ tvsflags = rpmtsSetVSFlags(ts, tvsflags);
+ Fclose(eiu->fd);
+ eiu->fd = NULL;
+
+ /* Honor --nomanifest */
+ if (eiu->rpmrc == RPMRC_NOTFOUND && (giFlags & RPMGI_NOMANIFEST))
+ eiu->rpmrc = RPMRC_FAIL;
+
+ if(eiu->rpmrc == RPMRC_FAIL) {
+ rpmlog(RPMLOG_ERR, _("%s cannot be installed\n"), *eiu->fnp);
+ eiu->numFailed++; *eiu->fnp = NULL;
+ }
+
+ return RPMRC_OK;
+}
/** @todo Generalize --freshen policies. */
int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv)
@@ -329,7 +364,7 @@ int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv)
struct rpmEIU * eiu = xcalloc(1, sizeof(*eiu));
rpmRelocation * relocations;
char * fileURL = NULL;
- rpmVSFlags vsflags, ovsflags, tvsflags;
+ rpmVSFlags vsflags, ovsflags;
int rc;
int xx;
int i;
@@ -448,48 +483,15 @@ restart:
rpmlog(RPMLOG_DEBUG, "============== %s\n", *eiu->fnp);
(void) urlPath(*eiu->fnp, &fileName);
- /* Try to read the header from a package file. */
- eiu->fd = Fopen(*eiu->fnp, "r.ufdio");
- if (eiu->fd == NULL || Ferror(eiu->fd)) {
- rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), *eiu->fnp,
- Fstrerror(eiu->fd));
- if (eiu->fd != NULL) {
- xx = Fclose(eiu->fd);
- eiu->fd = NULL;
- }
- eiu->numFailed++; *eiu->fnp = NULL;
+ if (tryReadHeader(ts, eiu, vsflags) == RPMRC_FAIL)
continue;
- }
- /* Read the header, verifying signatures (if present). */
- tvsflags = rpmtsSetVSFlags(ts, vsflags);
- eiu->rpmrc = rpmReadPackageFile(ts, eiu->fd, *eiu->fnp, &eiu->h);
- tvsflags = rpmtsSetVSFlags(ts, tvsflags);
- xx = Fclose(eiu->fd);
- eiu->fd = NULL;
-
- /* Honor --nomanifest */
- if (eiu->rpmrc == RPMRC_NOTFOUND && (giFlags & RPMGI_NOMANIFEST))
- eiu->rpmrc = RPMRC_FAIL;
-
- switch (eiu->rpmrc) {
- case RPMRC_FAIL:
- rpmlog(RPMLOG_ERR, _("%s cannot be installed\n"), *eiu->fnp);
- eiu->numFailed++; *eiu->fnp = NULL;
- continue;
- break;
- case RPMRC_NOTFOUND:
+ if (eiu->rpmrc == RPMRC_NOTFOUND) {
rc = tryReadManifest(eiu);
if (rc == RPMRC_OK) {
eiu->prevx++;
- goto restart;
+ goto restart;
}
- break;
- case RPMRC_NOTTRUSTED:
- case RPMRC_NOKEY:
- case RPMRC_OK:
- default:
- break;
}
eiu->isSource = headerIsSource(eiu->h);