summaryrefslogtreecommitdiff
path: root/lib/rpmte.c
diff options
context:
space:
mode:
authorSteve Lawrence <slawrence@tresys.com>2010-06-21 17:04:37 -0400
committerPanu Matilainen <pmatilai@redhat.com>2010-06-22 11:12:43 +0300
commit85d89bafdca5ec04866f9a7ecabb735d292c5a25 (patch)
tree31157801f8330c5571cfe6193036fd51178a51ef /lib/rpmte.c
parent04bdec775ac56c7673f87257306b23536a954474 (diff)
downloadlibrpm-tizen-85d89bafdca5ec04866f9a7ecabb735d292c5a25.tar.gz
librpm-tizen-85d89bafdca5ec04866f9a7ecabb735d292c5a25.tar.bz2
librpm-tizen-85d89bafdca5ec04866f9a7ecabb735d292c5a25.zip
Determine when to perform Collection actions
There are three times during a transaction when Collection actions can be performed: 1) After the last time a member of a collection is either installed or removed 2) After the last time a member of a collection is installed only 3) Before the first time a member of a collection is removed only This patch adds three lists to the rpmte structure to mark which transaction elements fall into each of these groups, and the collections that caused that. A new function is added to the TSM to scan through all the transaction elements and update these lists. When a collection is added to one of these lists, it signifies that when that transaction element is installed, the appropriate action should be performed for that collection.
Diffstat (limited to 'lib/rpmte.c')
-rw-r--r--lib/rpmte.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/rpmte.c b/lib/rpmte.c
index e622558ed..2c3360558 100644
--- a/lib/rpmte.c
+++ b/lib/rpmte.c
@@ -63,6 +63,11 @@ struct rpmte_s {
int failed; /*!< (parent) install/erase failed */
rpmfs fs;
+
+ ARGV_t lastInCollectionsAny; /*!< list of collections this te is the last to be installed or removed */
+ ARGV_t lastInCollectionsAdd; /*!< list of collections this te is the last to be only installed */
+ ARGV_t firstInCollectionsRemove; /*!< list of collections this te is the first to be only removed */
+ ARGV_t collections; /*!< list of collections */
};
/* forward declarations */
@@ -185,6 +190,8 @@ static void buildRelocs(rpmte p, Header h, rpmRelocation *relocs)
*/
static void addTE(rpmte p, Header h, fnpyKey key, rpmRelocation * relocs)
{
+ struct rpmtd_s colls;
+
p->name = headerGetAsString(h, RPMTAG_NAME);
p->version = headerGetAsString(h, RPMTAG_VERSION);
p->release = headerGetAsString(h, RPMTAG_RELEASE);
@@ -228,6 +235,19 @@ static void addTE(rpmte p, Header h, fnpyKey key, rpmRelocation * relocs)
headerIsEntry(h, RPMTAG_POSTTRANSPROG)) ?
RPMTE_HAVE_POSTTRANS : 0;
+ p->lastInCollectionsAny = NULL;
+ p->lastInCollectionsAdd = NULL;
+ p->firstInCollectionsRemove = NULL;
+ p->collections = NULL;
+ if (headerGet(h, RPMTAG_COLLECTIONS, &colls, HEADERGET_MINMEM)) {
+ const char *collname;
+ while ((collname = rpmtdNextString(&colls))) {
+ argvAdd(&p->collections, collname);
+ }
+ argvSort(p->collections, NULL);
+ rpmtdFreeData(&colls);
+ }
+
rpmteColorDS(p, RPMTAG_PROVIDENAME);
rpmteColorDS(p, RPMTAG_REQUIRENAME);
return;
@@ -261,6 +281,11 @@ rpmte rpmteFree(rpmte te)
rpmteCleanDS(te);
rpmtsUnlink(te->ts);
+ argvFree(te->collections);
+ argvFree(te->lastInCollectionsAny);
+ argvFree(te->lastInCollectionsAdd);
+ argvFree(te->firstInCollectionsRemove);
+
memset(te, 0, sizeof(*te)); /* XXX trash and burn */
free(te);
}
@@ -368,6 +393,46 @@ rpm_color_t rpmteSetColor(rpmte te, rpm_color_t color)
return ocolor;
}
+ARGV_const_t rpmteCollections(rpmte te)
+{
+ return (te != NULL) ? te->collections : NULL;
+}
+
+int rpmteHasCollection(rpmte te, const char *collname)
+{
+ return (argvSearch(rpmteCollections(te), collname, NULL) != NULL);
+}
+
+int rpmteAddToLastInCollectionAdd(rpmte te, const char *collname)
+{
+ if (te != NULL) {
+ argvAdd(&te->lastInCollectionsAdd, collname);
+ argvSort(te->lastInCollectionsAdd, NULL);
+ return 0;
+ }
+ return -1;
+}
+
+int rpmteAddToLastInCollectionAny(rpmte te, const char *collname)
+{
+ if (te != NULL) {
+ argvAdd(&te->lastInCollectionsAny, collname);
+ argvSort(te->lastInCollectionsAny, NULL);
+ return 0;
+ }
+ return -1;
+}
+
+int rpmteAddToFirstInCollectionRemove(rpmte te, const char *collname)
+{
+ if (te != NULL) {
+ argvAdd(&te->firstInCollectionsRemove, collname);
+ argvSort(te->firstInCollectionsRemove, NULL);
+ return 0;
+ }
+ return -1;
+}
+
rpm_loff_t rpmtePkgFileSize(rpmte te)
{
return (te != NULL ? te->pkgFileSize : 0);