Remember buildroot directory in rpmfc struct
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 1 Dec 2010 09:09:02 +0000 (11:09 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 1 Dec 2010 09:09:02 +0000 (11:09 +0200)
- New constructor rpmfcCreate() which takes buildroot as an argument,
  and "flags" argument for future use. Calculate brlen at initialization
  now that we can.
- Preserve rpmfcNew() as a compatibility wrapper as it's something
  somebody could, in theory, have used legitimately.

build/rpmfc.c
build/rpmfc.h

index 39b64f4..e3ea588 100644 (file)
@@ -36,7 +36,8 @@ struct rpmfc_s {
     int skipProv;      /*!< Don't auto-generate Provides:? */
     int skipReq;       /*!< Don't auto-generate Requires:? */
     int tracked;       /*!< Versioned Provides: tracking dependency added? */
-    size_t brlen;      /*!< strlen(spec->buildRoot) */
+    char *buildRoot;   /*!< (Build) root dir */
+    size_t brlen;      /*!< rootDir length */
 
     rpmfcAttr *atypes; /*!< known file attribute types */
 
@@ -706,6 +707,7 @@ rpmfc rpmfcFree(rpmfc fc)
        for (rpmfcAttr *attr = fc->atypes; attr && *attr; attr++)
            rpmfcAttrFree(*attr);
        rfree(fc->atypes);
+       rfree(fc->buildRoot);
        fc->fn = argvFree(fc->fn);
        for (int i = 0; i < fc->nfiles; i++)
            argvFree(fc->fattrs[i]);
@@ -725,12 +727,21 @@ rpmfc rpmfcFree(rpmfc fc)
     return NULL;
 }
 
-rpmfc rpmfcNew(void)
+rpmfc rpmfcCreate(const char *buildRoot, rpmFlags flags)
 {
     rpmfc fc = xcalloc(1, sizeof(*fc));
+    if (buildRoot) {
+       fc->buildRoot = xstrdup(buildRoot);
+       fc->brlen = strlen(buildRoot);
+    }
     return fc;
 }
 
+rpmfc rpmfcNew(void)
+{
+    return rpmfcCreate(NULL, 0);
+}
+
 rpmds rpmfcProvides(rpmfc fc)
 {
     return (fc != NULL ? fc->provides : NULL);
@@ -1202,11 +1213,10 @@ rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg)
     }
     av[ac] = NULL;
 
-    fc = rpmfcNew();
+    fc = rpmfcCreate(spec->buildRoot, 0);
     fc->skipProv = !pkg->autoProv;
     fc->skipReq = !pkg->autoReq;
     fc->tracked = 0;
-    fc->brlen = (spec->buildRoot ? strlen(spec->buildRoot) : 0);
 
     /* Copy (and delete) manually generated dependencies to dictionary. */
     if (!fc->skipProv) {
index ab32568..f3d3e66 100644 (file)
@@ -61,10 +61,21 @@ rpmfc rpmfcFree(rpmfc fc);
 
 /** \ingroup rpmfc
  * Create a file classifier.
+ * @param rootDir      (build) root directory
+ * @param flags                (unused)
  * @return             new file classifier
  */
+rpmfc rpmfcCreate(const char *rootDir, rpmFlags flags);
+
+/** \ingroup rpmfc
+ * @deprecated
+ * Create a file classifier.
+ * @return             new file classifier
+ */
+RPM_GNUC_DEPRECATED
 rpmfc rpmfcNew(void);
 
+
 /** \ingroup rpmfc
  * Build file class dictionary and mappings.
  * @param fc           file classifier