static void finalizeDeps(Package pkg) { /* check if the package has a dependency with a '~' */ if (haveTildeDep(pkg)) (void) rpmlibNeedsFeature(pkg, "TildeInVersions", "4.10.0-1"); /* check if the package has a rich dependency */ if (haveRichDep(pkg)) (void) rpmlibNeedsFeature(pkg, "RichDependencies", "4.12.0-1"); /* All dependencies added finally, write them into the header */ for (int i = 0; i < PACKAGE_NUM_DEPS; i++) { /* Nuke any previously added dependencies from the header */ headerDel(pkg->header, rpmdsTagN(pkg->dependencies[i])); headerDel(pkg->header, rpmdsTagEVR(pkg->dependencies[i])); headerDel(pkg->header, rpmdsTagF(pkg->dependencies[i])); headerDel(pkg->header, rpmdsTagTi(pkg->dependencies[i])); /* ...and add again, now with automatic dependencies included */ rpmdsPutToHeader(pkg->dependencies[i], pkg->header); } }
int rpmdsPutToHeader(rpmds ds, Header h) { rpmTagVal tagN = rpmdsTagN(ds); rpmTagVal tagEVR = rpmdsTagEVR(ds); rpmTagVal tagF = rpmdsTagF(ds); rpmTagVal tagTi = rpmdsTagTi(ds); if (!tagN) return -1; rpmds pi = rpmdsInit(ds); while (rpmdsNext(pi) >= 0) { rpmsenseFlags flags = rpmdsFlags(pi); uint32_t index = rpmdsTi(pi); headerPutString(h, tagN, rpmdsN(pi)); headerPutString(h, tagEVR, rpmdsEVR(pi)); headerPutUint32(h, tagF, &flags, 1); if (tagTi != RPMTAG_NOT_FOUND) { headerPutUint32(h, tagTi, &index, 1); } } return 0; }