RPM4
view release on metacpan or search on metacpan
src/RPM4.xs view on Meta::CPAN
mXPUSHs(newSVpv(nvr, 0));
} else {
mXPUSHs(newSVpvf("%s.%s", nvr, get_arch(h)));
}
free(nvr);
} else if (gimme == G_ARRAY) {
EXTEND(SP, 4);
mPUSHs(newSVpv(get_name(h, RPMTAG_NAME), 0));
mPUSHs(newSVpv(get_name(h, RPMTAG_VERSION), 0));
mPUSHs(newSVpv(get_name(h, RPMTAG_RELEASE), 0));
mPUSHs(newSVpv(get_arch(h), 0));
}
}
int
Header_issrc(h)
Header h
CODE:
RETVAL = !headerIsEntry(h, RPMTAG_SOURCERPM);
OUTPUT:
RETVAL
# Dependancies versions functions
int
Header_compare(h1, h2)
Header h1
Header h2
CODE:
RETVAL = rpmVersionCompare(h1, h2);
OUTPUT:
RETVAL
void
Header_dep(header, type, scaremem = O_SCAREMEM)
Header header
SV * type
int scaremem
PREINIT:
rpmds ds;
rpmTag tag;
PPCODE:
tag = sv2deptag(type);
ds = rpmdsNew(header, tag, scaremem);
ds = rpmdsInit(ds);
if (ds != NULL)
if (rpmdsNext(ds) >= 0) {
mXPUSHs(sv_setref_pv(newSVpvs(""), bless_rpmds, ds));
#ifdef HDRPMMEM
PRINTF_NEW(bless_rpmds, ds, ds->nrefs);
#endif
}
void
Header_files(header, scaremem = O_SCAREMEM)
Header header
int scaremem
PREINIT:
rpmfi Files = NULL;
rpmts ts = NULL; /* NULL; setting this to NULL skip path relocation
* maybe a good deal is Header::Files(header, Dep = NULL) */
PPCODE:
#ifdef HDLISTDEBUG
PRINTF_CALL;
#endif
Files = rpmfiNew(ts, header, RPMTAG_BASENAMES, scaremem);
if (Files != NULL && (Files = rpmfiInit(Files, 0)) != NULL && rpmfiNext(Files) >= 0) {
SPAGAIN;
XPUSHs(sv_setref_pv(sv_newmortal(), bless_rpmfi, (void *)Files));
#ifdef HDRPMMEM
PRINTF_NEW(bless_rpmfi, Files, Files->nrefs);
#endif
}
void
Header_hchkdep(h1, h2, type)
Header h1
Header h2
SV * type
PREINIT:
rpmds ds = NULL;
rpmds pro = NULL;
rpmTag tag;
PPCODE:
tag = sv2deptag(type);
ds = rpmdsNew(h1, tag, SCAREMEM);
pro = rpmdsNew(h2, RPMTAG_PROVIDENAME, SCAREMEM);
#ifdef HDLISTDEBUG
fprintf(stderr, "HDEBUG: Header::hchkdep %d: %s vs %s %p\n", tag, hGetNEVR(h1, NULL), hGetNEVR(h2, NULL), ds);
#endif
if (ds != NULL) {
rpmdsInit(ds);
while (rpmdsNext(ds) >= 0) {
rpmdsInit(pro);
while (rpmdsNext(pro) >= 0) {
if (rpmdsCompare(ds,pro)) {
mXPUSHs(newSVpv(rpmdsDNEVR(ds), 0));
#ifdef HDLISTDEBUG
fprintf(stderr, "HDEBUG: Header::hchkdep match %s %s p in %s\n", rpmdsDNEVR(ds), rpmdsDNEVR(pro), hGetNEVR(h2, NULL));
#endif
break;
}
}
}
}
pro = rpmdsFree(pro);
ds = rpmdsFree(ds);
int
Header_matchdep(header, Dep, sv_nopromote = NULL)
Header header
SV * sv_nopromote
rpmds Dep
PREINIT:
int nopromote = 0;
CODE:
if (sv_nopromote != NULL)
nopromote = SvIV(sv_nopromote);
RETVAL = _header_vs_dep(header, Dep, nopromote);
OUTPUT:
src/RPM4.xs view on Meta::CPAN
if (sv_exclude != NULL && SvOK(sv_exclude) && SvTYPE(SvRV(sv_exclude)) == SVt_PVAV) {
av_exclude = (AV*)SvRV(sv_exclude);
exclude = malloc((av_len(av_exclude)+1) * sizeof(int));
for (i = 0; i <= av_len(av_exclude); i++) {
SV **isv = av_fetch(av_exclude, i, 0);
exclude[i] = SvUV(*isv);
}
//FIXME: rpmtsPrunedIterator() is rpmlib internal only:
//rpmtsPrunedIterator(ts, exclude, av_len(av_exclude) + 1);
}
while (rc && ((header = rpmdbNextIterator(mi)) != NULL)) {
RETVAL++;
if (callback != NULL && SvROK(callback)) {
ENTER;
SAVETMPS;
PUSHMARK(SP);
mXPUSHs(sv_setref_pv(newSVpvs(""), bless_header, headerLink(header)));
#ifdef HDRPMMEM
PRINTF_NEW(bless_header, header, header->nrefs);
#endif
mXPUSHs(newSVuv(rpmdbGetIteratorOffset(mi)));
PUTBACK;
count = call_sv(callback, G_SCALAR);
SPAGAIN;
if (tag == RPMDBI_PACKAGES && value != NULL) {
rc = 0;
} else if (count == 1) {
rc = POPi;
}
FREETMPS;
LEAVE;
}
}
if (exclude != NULL) free(exclude);
rpmdbFreeIterator(mi);
} else
RETVAL = -1;
ts = rpmtsFree(ts);
OUTPUT:
RETVAL
void
Ts_get_header(ts, off)
rpmts ts
int off
PREINIT:
rpmdbMatchIterator mi;
Header header;
PPCODE:
mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES, &off, sizeof(off));
if ((header = rpmdbNextIterator(mi)) != NULL) {
mXPUSHs(sv_setref_pv(newSVpvs(""), bless_header, headerLink(header)));
#ifdef HDRPMMEM
PRINTF_NEW(bless_header, header, header->nrefs);
#endif
}
rpmdbFreeIterator(mi);
int
Ts_transadd(ts, header, key = NULL, upgrade = 1, sv_relocation = NULL, force = 0)
rpmts ts
Header header
char * key
int upgrade
SV * sv_relocation
int force
PREINIT:
rpmRelocation * relocations = NULL;
HV * hv_relocation;
HE * he_relocation;
int i = 0;
I32 len;
CODE:
if (key != NULL)
key = strdup(key);
/* Relocation settings */
if (sv_relocation && SvOK(sv_relocation) && !force) {
/* if (! (headerGetEntry(eiu->h, RPMTAG_PREFIXES, &pft,
(void **) &paths, &c) && (c == 1))) { */
if (! headerIsEntry(header, RPMTAG_PREFIXES)) {
rpmlog(RPMLOG_ERR,
_("package %s is not relocatable\n"), "");
XPUSHi((IV)1);
XSRETURN(1);
}
if (SvTYPE(sv_relocation) == SVt_PV) {
/* String value, assume a prefix */
relocations = malloc(2 * sizeof(*relocations));
relocations[0].oldPath = NULL;
relocations[0].newPath = SvPV_nolen(sv_relocation);
relocations[1].oldPath = relocations[1].newPath = NULL;
} else if (SvTYPE(SvRV(sv_relocation)) == SVt_PVHV) {
hv_relocation = (HV*)SvRV(sv_relocation);
hv_iterinit(hv_relocation);
while ((he_relocation = hv_iternext(hv_relocation)) != NULL) {
relocations = realloc(relocations, sizeof(*relocations) * (++i));
relocations[i-1].oldPath = NULL;
relocations[i-1].newPath = NULL;
relocations[i-1].oldPath = hv_iterkey(he_relocation, &len);
relocations[i-1].newPath = SvPV_nolen(hv_iterval(hv_relocation, he_relocation));
}
/* latest relocation is identify by NULL setting */
relocations = realloc(relocations, sizeof(*relocations) * (++i));
relocations[i-1].oldPath = relocations[i-1].newPath = NULL;
} else {
croak("latest argument is set but is not an array ref or a string");
}
}
/* TODO fnpyKey: another value can be use... */
RETVAL = rpmtsAddInstallElement(ts, header, (fnpyKey) key, upgrade, relocations);
OUTPUT:
RETVAL
int
Ts_transremove(ts, recOffset, header = NULL)
rpmts ts
int recOffset
Header header
PREINIT:
rpmdbMatchIterator mi;
CODE:
RETVAL = 0;
if (header != NULL) { /* reprofit Db_traverse */
rpmtsAddEraseElement(ts, header, recOffset);
} else {
mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES, &recOffset, sizeof(recOffset));
if ((header = rpmdbNextIterator(mi)) != NULL) {
#ifdef HDLISTDEBUG
fprintf(stderr, "HDEBUG: Db::transremove(h, o) H: %p Off:%u\n", header, recOffset);
#endif
rpmtsAddEraseElement(ts, header, recOffset);
RETVAL = 1;
}
rpmdbFreeIterator(mi);
}
OUTPUT:
RETVAL
int
Ts_transremove_pkg(ts, N_evr)
rpmts ts
char * N_evr
PREINIT:
rpmdbMatchIterator mi;
Header header;
int recOffset;
CODE:
RETVAL = 0;
/* N_evr is not NEVR but N(EVR), with RPMDBI_LABEL
* I want to find another way to exactly match a header
* For more flexible function, check Db_traverse / Db_transremove */
mi = rpmtsInitIterator(ts, RPMDBI_LABEL, N_evr, 0);
while ((header = rpmdbNextIterator(mi))) {
recOffset = rpmdbGetIteratorOffset(mi);
#ifdef HDLISTDEBUG
fprintf(stderr, "HDEBUG: Db::transremove(Name) N: %s H: %p Off:%u\n", N_evr, header, recOffset);
#endif
if (recOffset != 0) {
rpmtsAddEraseElement(ts, header, recOffset);
RETVAL ++;
}
}
rpmdbFreeIterator(mi);
OUTPUT:
RETVAL
int
Ts_traverse_transaction(ts, callback, type = 0)
rpmts ts
SV * callback
( run in 0.600 second using v1.01-cache-2.11-cpan-5511b514fd6 )