static rpmpsm rpmpsmNew(rpmts ts, rpmte te) { rpmpsm psm = xcalloc(1, sizeof(*psm)); psm->ts = rpmtsLink(ts); psm->fi = rpmfiLink(rpmteFI(te)); psm->te = te; /* XXX rpmte not refcounted yet */ return psm; }
rpmtsi rpmtsiInit(rpmts ts) { rpmtsi tsi = NULL; tsi = xcalloc(1, sizeof(*tsi)); tsi->ts = rpmtsLink(ts); tsi->oc = 0; return tsi; }
static rpmpsm rpmpsmNew(rpmts ts, rpmte te, pkgGoal goal) { rpmpsm psm = xcalloc(1, sizeof(*psm)); psm->ts = rpmtsLink(ts); psm->files = rpmteFiles(te); psm->te = te; /* XXX rpmte not refcounted yet */ if (!rpmteIsSource(te)) { /* * 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. */ int npkgs_installed = rpmdbCountPackages(rpmtsGetRdb(ts), rpmteN(te)); switch (goal) { case PKG_INSTALL: case PKG_PRETRANS: psm->scriptArg = npkgs_installed + 1; psm->countCorrection = 0; break; case PKG_ERASE: psm->scriptArg = npkgs_installed - 1; psm->countCorrection = -1; break; case PKG_VERIFY: case PKG_POSTTRANS: psm->scriptArg = npkgs_installed; psm->countCorrection = 0; break; default: break; } } if (goal == PKG_INSTALL) { Header h = rpmteHeader(te); psm->total = headerGetNumber(h, RPMTAG_LONGARCHIVESIZE); headerFree(h); } else if (goal == PKG_ERASE) { psm->total = rpmfilesFC(psm->files); } /* Fake up something for packages with no files */ if (psm->total == 0) psm->total = 100; rpmlog(RPMLOG_DEBUG, "%s: %s has %d files\n", pkgGoalString(goal), rpmteNEVRA(psm->te), rpmfilesFC(psm->files)); return psm; }
rpmtxn rpmtxnBegin(rpmts ts, rpmtxnFlags flags) { static const char * const rpmlock_path_default = "%{?_rpmlock_path}"; rpmtxn txn = NULL; if (ts == NULL) return NULL; if (ts->lockPath == NULL) { const char *rootDir = rpmtsRootDir(ts); char *t; if (!rootDir || rpmChrootDone()) rootDir = "/"; t = rpmGenPath(rootDir, rpmlock_path_default, NULL); if (t == NULL || *t == '\0' || *t == '%') { free(t); t = xstrdup(RPMLOCK_PATH); } ts->lockPath = xstrdup(t); (void) rpmioMkpath(dirname(t), 0755, getuid(), getgid()); free(t); } if (ts->lock == NULL) ts->lock = rpmlockNew(ts->lockPath, _("transaction")); if (rpmlockAcquire(ts->lock)) { txn = xcalloc(1, sizeof(*txn)); txn->lock = ts->lock; txn->flags = flags; txn->ts = rpmtsLink(ts); } return txn; }
rpmgi rpmgiNew(rpmts ts, int tag, const void * keyp, size_t keylen) { rpmgi gi = rpmgiGetPool(_rpmgiPool); if (gi == NULL) /* XXX can't happen */ return NULL; /*@-assignexpose -castexpose @*/ gi->ts = rpmtsLink(ts, "rpmgiNew"); /*@=assignexpose =castexpose @*/ gi->tsOrder = rpmcliInstallOrder; gi->tag = (rpmTag) tag; /*@-assignexpose@*/ gi->keyp = keyp; /*@=assignexpose@*/ gi->keylen = keylen; gi->flags = 0; gi->active = 0; gi->i = -1; gi->hdrPath = NULL; gi->h = NULL; gi->rc = 0; gi->tsi = NULL; gi->mi = NULL; gi->fd = NULL; gi->argv = xcalloc(1, sizeof(*gi->argv)); gi->argc = 0; gi->ftsOpts = 0; gi->ftsp = NULL; gi->fts = NULL; gi->walkPathFilter = NULL; gi->stash = NULL; return rpmgiLink(gi, "rpmgiNew"); }
rpmts rpmtsCreate(void) { rpmts ts; tsMembers tsmem; ts = xcalloc(1, sizeof(*ts)); memset(&ts->ops, 0, sizeof(ts->ops)); (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_TOTAL), -1); ts->dsi = NULL; ts->solve = NULL; ts->solveData = NULL; ts->rdb = NULL; ts->dbmode = O_RDONLY; ts->scriptFd = NULL; ts->tid = (rpm_tid_t) time(NULL); ts->color = rpmExpandNumeric("%{?_transaction_color}"); ts->prefcolor = rpmExpandNumeric("%{?_prefer_color}")?:2; ts->netsharedPaths = NULL; ts->installLangs = NULL; { char *tmp = rpmExpand("%{_netsharedpath}", NULL); if (tmp && *tmp != '%') { argvSplit(&ts->netsharedPaths, tmp, ":"); } free(tmp); tmp = rpmExpand("%{_install_langs}", NULL); if (tmp && *tmp != '%') { ARGV_t langs = NULL; argvSplit(&langs, tmp, ":"); /* If we'll be installing all languages anyway, don't bother */ for (ARGV_t l = langs; *l; l++) { if (rstreq(*l, "all")) { langs = argvFree(langs); break; } } ts->installLangs = langs; } free(tmp); } tsmem = xcalloc(1, sizeof(*ts->members)); tsmem->pool = NULL; tsmem->delta = 5; tsmem->addedPackages = NULL; tsmem->removedPackages = removedHashCreate(128, uintId, uintCmp, NULL, NULL); tsmem->orderAlloced = 0; tsmem->orderCount = 0; tsmem->order = NULL; ts->members = tsmem; ts->rootDir = NULL; ts->keyring = NULL; ts->nrefs = 0; ts->plugins = NULL; return rpmtsLink(ts); }