summaryrefslogtreecommitdiff
path: root/lib/rpminstall.c
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2023-08-28 14:57:22 +0900
committerbiao716.wang <biao716.wang@samsung.com>2023-08-28 14:57:22 +0900
commit0fb104edc1e949fd224866aa900463aa2d6588d0 (patch)
treecdc9ddc3123edd5741e5151f3076c9bfc9535916 /lib/rpminstall.c
parenta0dea826f88a4c5c9ceb722592cceedeb75a32fe (diff)
downloadlibrpm-tizen-0fb104edc1e949fd224866aa900463aa2d6588d0.tar.gz
librpm-tizen-0fb104edc1e949fd224866aa900463aa2d6588d0.tar.bz2
librpm-tizen-0fb104edc1e949fd224866aa900463aa2d6588d0.zip
Upgrade version to 4.14sandbox/wangbiao/rpm414_tizen
Change-Id: Ifd629ba679a11ede4d831195c6aea2245efc3300 Signed-off-by: biao716.wang <biao716.wang@samsung.com>
Diffstat (limited to 'lib/rpminstall.c')
-rw-r--r--lib/rpminstall.c76
1 files changed, 56 insertions, 20 deletions
diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index a3623fd3a..e10392e0f 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -10,6 +10,7 @@
#include <rpm/rpmdb.h>
#include <rpm/rpmds.h>
#include <rpm/rpmts.h>
+#include <rpm/rpmsq.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
@@ -22,6 +23,7 @@ static int rpmcliHashesCurrent = 0;
static int rpmcliHashesTotal = 0;
static int rpmcliProgressCurrent = 0;
static int rpmcliProgressTotal = 0;
+static int rpmcliProgressState = 0;
/**
* Print a CLI progress bar.
@@ -103,7 +105,6 @@ void * rpmShowProgress(const void * arg,
void * rc = NULL;
const char * filename = (const char *)key;
static FD_t fd = NULL;
- static int state = -1;
switch (what) {
case RPMCALLBACK_INST_OPEN_FILE:
@@ -134,8 +135,8 @@ void * rpmShowProgress(const void * arg,
case RPMCALLBACK_INST_START:
case RPMCALLBACK_UNINST_START:
- if (state != what) {
- state = what;
+ if (rpmcliProgressState != what) {
+ rpmcliProgressState = what;
if (flags & INSTALL_HASH) {
if (what == RPMCALLBACK_INST_START) {
fprintf(stdout, _("Updating / installing...\n"));
@@ -185,7 +186,7 @@ void * rpmShowProgress(const void * arg,
rpmcliProgressTotal = 1;
rpmcliProgressCurrent = 0;
rpmcliPackagesTotal = total;
- state = what;
+ rpmcliProgressState = what;
if (!(flags & INSTALL_LABEL))
break;
if (flags & INSTALL_HASH)
@@ -290,8 +291,8 @@ static int rpmcliTransaction(rpmts ts, struct rpmInstallArguments_s * ia,
ps = rpmtsProblems(ts);
- if ((rpmpsNumProblems(ps) > 0) && (eflags? 1 : (rc > 0)))
- rpmpsPrint((eflags? NULL : stderr), ps);
+ if (rpmpsNumProblems(ps) > 0 && (eflags || rc > 0))
+ rpmpsPrint(NULL, ps);
ps = rpmpsFree(ps);
}
@@ -311,7 +312,8 @@ static int tryReadManifest(struct rpmEIU * eiu)
Fclose(fd);
fd = NULL;
}
- eiu->numFailed++; *eiu->fnp = NULL;
+ eiu->numFailed++;
+ *eiu->fnp = NULL;
return RPMRC_FAIL;
}
@@ -323,8 +325,10 @@ static int tryReadManifest(struct rpmEIU * eiu)
Fclose(fd);
fd = NULL;
- if (rc != RPMRC_OK)
- eiu->numFailed++; *eiu->fnp = NULL;
+ if (rc != RPMRC_OK) {
+ eiu->numFailed++;
+ *eiu->fnp = NULL;
+ }
return rc;
}
@@ -340,7 +344,8 @@ static int tryReadHeader(rpmts ts, struct rpmEIU * eiu, Header * hdrp)
Fclose(fd);
fd = NULL;
}
- eiu->numFailed++; *eiu->fnp = NULL;
+ eiu->numFailed++;
+ *eiu->fnp = NULL;
return RPMRC_FAIL;
}
@@ -353,9 +358,10 @@ static int tryReadHeader(rpmts ts, struct rpmEIU * eiu, Header * hdrp)
if (eiu->rpmrc == RPMRC_NOTFOUND && (giFlags & RPMGI_NOMANIFEST))
eiu->rpmrc = RPMRC_FAIL;
- if(eiu->rpmrc == RPMRC_FAIL) {
+ if (eiu->rpmrc == RPMRC_FAIL) {
rpmlog(RPMLOG_ERR, _("%s cannot be installed\n"), *eiu->fnp);
- eiu->numFailed++; *eiu->fnp = NULL;
+ eiu->numFailed++;
+ *eiu->fnp = NULL;
}
return RPMRC_OK;
@@ -385,6 +391,19 @@ static int checkFreshenStatus(rpmts ts, Header h)
return (oldH != NULL);
}
+static int rpmNoGlob(const char *fn, int *argcPtr, ARGV_t * argvPtr)
+{
+ struct stat sb;
+ int rc = stat(fn, &sb);
+ if (rc == 0) {
+ argvAdd(argvPtr, fn);
+ *argcPtr = 1;
+ } else {
+ *argcPtr = 0;
+ }
+ return rc;
+}
+
/** @todo Generalize --freshen policies. */
int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv)
{
@@ -417,13 +436,20 @@ int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv)
for (eiu->fnp = fileArgv; *eiu->fnp != NULL; eiu->fnp++) {
ARGV_t av = NULL;
int ac = 0;
- char * fn;
- fn = rpmEscapeSpaces(*eiu->fnp);
- rc = rpmGlob(fn, &ac, &av);
- fn = _free(fn);
+ if (giFlags & RPMGI_NOGLOB) {
+ rc = rpmNoGlob(*eiu->fnp, &ac, &av);
+ } else {
+ char * fn = rpmEscapeSpaces(*eiu->fnp);
+ rc = rpmGlob(fn, &ac, &av);
+ fn = _free(fn);
+ }
if (rc || ac == 0) {
- rpmlog(RPMLOG_ERR, _("File not found by glob: %s\n"), *eiu->fnp);
+ if (giFlags & RPMGI_NOGLOB) {
+ rpmlog(RPMLOG_ERR, _("File not found: %s\n"), *eiu->fnp);
+ } else {
+ rpmlog(RPMLOG_ERR, _("File not found by glob: %s\n"), *eiu->fnp);
+ }
eiu->numFailed++;
continue;
}
@@ -520,6 +546,10 @@ restart:
}
if (headerIsSource(h)) {
+ if (ia->installInterfaceFlags & INSTALL_FRESHEN) {
+ headerFree(h);
+ continue;
+ }
rpmlog(RPMLOG_DEBUG, "\tadded source package [%d]\n",
eiu->numSRPMS);
eiu->sourceURL = xrealloc(eiu->sourceURL,
@@ -552,7 +582,10 @@ restart:
continue;
}
- rc = rpmtsAddInstallElement(ts, h, (fnpyKey)fileName,
+ if (ia->installInterfaceFlags & INSTALL_REINSTALL)
+ rc = rpmtsAddReinstallElement(ts, h, (fnpyKey)fileName);
+ else
+ rc = rpmtsAddInstallElement(ts, h, (fnpyKey)fileName,
(ia->installInterfaceFlags & INSTALL_UPGRADE) != 0,
relocations);
@@ -560,7 +593,7 @@ restart:
if (eiu->relocations)
eiu->relocations->oldPath = _free(eiu->relocations->oldPath);
- switch(rc) {
+ switch (rc) {
case 0:
rpmlog(RPMLOG_DEBUG, "\tadded binary package [%d]\n",
eiu->numRPMS);
@@ -594,8 +627,11 @@ restart:
}
if (eiu->numSRPMS && (eiu->sourceURL != NULL)) {
+ rpmcliProgressState = 0;
+ rpmcliProgressTotal = 0;
+ rpmcliProgressCurrent = 0;
for (i = 0; i < eiu->numSRPMS; i++) {
- rpmdbCheckSignals();
+ rpmsqPoll();
if (eiu->sourceURL[i] != NULL) {
rc = RPMRC_OK;
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST))