]> code.ossystems Code Review - openembedded-core.git/commitdiff
pseudo: Enhancements
authorJoshua Lock <josh@linux.intel.com>
Fri, 23 Jul 2010 17:18:51 +0000 (18:18 +0100)
committerRichard Purdie <rpurdie@linux.intel.com>
Fri, 23 Jul 2010 23:39:58 +0000 (00:39 +0100)
Enable changing the data directory on the fly from the environment and then use
this feature within poky to confine pseudo usage to each WORKDIR.

This fixes issues that could be seen under heavy inode reusage e.g.
with rm_work.

Work based mainly off a patch from Joshua Lock but finished by Richard
Purdie.

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
meta/classes/base.bbclass
meta/conf/bitbake.conf
meta/packages/pseudo/pseudo/data-as-env.patch [new file with mode: 0644]
meta/packages/pseudo/pseudo_git.bb

index a67555dc68e3e3ed72a9fcf52bcb3ba530e63f72..bcde3122209db21dc56ec61d8144d324449cf5e4 100644 (file)
@@ -148,6 +148,7 @@ python base_do_setscene () {
                bb.build.make_stamp("do_setscene", d)
 }
 do_setscene[selfstamp] = "1"
+do_setscene[dirs] = "${PSEUDO_DATADIR}"
 addtask setscene before do_fetch
 
 addtask fetch
index 67dd84095903598dc5b8fbea9ef4e3713ddc1716..057a213c96ee5066850a24c68b547c0a3df8092a 100644 (file)
@@ -528,7 +528,9 @@ SRC_URI = "file://${FILE}"
 
 # We can choose which provider of fake root privileges to use
 # default is fakeroot but in Poky we use pseudo
-FAKEROOT = "PSEUDO_PREFIX=${STAGING_DIR_NATIVE}${prefix_native} pseudo"
+# this is hopefully only temporary, to work around the database becoming corrupt
+PSEUDO_DATADIR ?= "${WORKDIR}/pseudo/"
+FAKEROOT = "PSEUDO_DATADIR=${PSEUDO_DATADIR} PSEUDO_PREFIX=${STAGING_DIR_NATIVE}${prefix_native} pseudo"
 PREFERRED_PROVIDER_virtual/fakeroot-native ?= "pseudo-native"
 
 
diff --git a/meta/packages/pseudo/pseudo/data-as-env.patch b/meta/packages/pseudo/pseudo/data-as-env.patch
new file mode 100644 (file)
index 0000000..4b2b5d0
--- /dev/null
@@ -0,0 +1,114 @@
+We observed the pseudo database becoming large and corrupted when undergoing
+significant use (generating multiple output package types).
+
+This patch checks for the existence of an PSEUDO_DATADIR environment variable
+and, when it exists, uses the directory specified there to store the pseudo
+database. This should enable us to use a different database for each run of
+pseudo.
+
+JL (23/07/10)
+Index: git/pseudo.h
+===================================================================
+--- git.orig/pseudo.h  2010-07-23 12:12:21.000000000 +0100
++++ git/pseudo.h       2010-07-23 13:35:29.044856965 +0100
+@@ -123,6 +123,7 @@
+ extern char *pseudo_fix_path(const char *, const char *, size_t, size_t, size_t *, int);
+ extern char **pseudo_dropenv(char * const *);
+ extern char **pseudo_setupenv(char * const *, char *);
++extern char *pseudo_data_path(char *);
+ extern char *pseudo_prefix_path(char *);
+ extern char *pseudo_get_prefix(char *);
+ extern int pseudo_logfile(char *defname);
+Index: git/pseudo_db.c
+===================================================================
+--- git.orig/pseudo_db.c       2010-07-23 12:12:21.000000000 +0100
++++ git/pseudo_db.c    2010-07-23 13:40:21.614745308 +0100
+@@ -465,17 +465,18 @@
+       char *errmsg;
+       static int registered_cleanup = 0;
+       char *dbfile;
++      char *data_dir;
+       if (!db)
+               return 1;
+       if (*db)
+               return 0;
+       if (db == &file_db) {
+-              dbfile = strdup(PSEUDO_DATA "/files.db");
++              dbfile = pseudo_data_path("files.db");
+               rc = sqlite3_open(dbfile, db);
+               free(dbfile);
+       } else {
+-              dbfile = strdup(PSEUDO_DATA "/logs.db");
++              dbfile = pseudo_data_path("logs.db");
+               rc = sqlite3_open(dbfile, db);
+               free(dbfile);
+       }
+Index: git/pseudo_server.c
+===================================================================
+--- git.orig/pseudo_server.c   2010-07-23 12:12:21.000000000 +0100
++++ git/pseudo_server.c        2010-07-23 13:36:09.340857158 +0100
+@@ -107,7 +107,7 @@
+       }
+       /* cd to the data directory */
+-      pseudo_path = strdup(PSEUDO_DATA);
++      pseudo_path = pseudo_data_path(NULL);
+       if (!pseudo_path) {
+               pseudo_diag("can't find %s directory.\n", PSEUDO_DATA);
+               return 1;
+Index: git/pseudo_util.c
+===================================================================
+--- git.orig/pseudo_util.c     2010-07-23 12:12:21.000000000 +0100
++++ git/pseudo_util.c  2010-07-23 13:41:11.062734484 +0100
+@@ -593,6 +593,50 @@
+       return new_environ;
+ }
++/* get the full path to the datadir for this run of pseudo
++ * file parameter is optional and returns the datadir path
++ * with the file name appended.
++ */
++char *
++pseudo_data_path(char *file) {
++      static char *datadir = NULL;
++      static size_t datadir_len;
++      char *path;
++
++      if (!datadir) {
++              datadir = getenv("PSEUDO_DATADIR");
++              if (!datadir) {
++                      datadir = strdup(PSEUDO_DATA);
++              }
++              datadir_len = strlen(datadir);
++      }
++
++      if (!file) {
++              return strdup(datadir);
++      } else {
++              size_t len = datadir_len + strlen(file) + 2;
++              path = malloc(len);
++              if (path) {
++                      char *endptr;
++                      int  rc;
++      
++                      rc = snprintf(path, len, "%s", datadir);
++                      /* this certainly SHOULD be impossible */
++                      if ((size_t) rc >= len)
++                              rc = len - 1;
++                      endptr = path + rc;
++                      /* strip extra slashes.
++                       * This probably has no real effect, but I don't like
++                       * seeing "     //" in paths.
++                       */
++                      while ((endptr > path) && (endptr[-1] == '/'))
++                              --endptr;
++                      snprintf(endptr, len - (endptr - path), "/%s", file);
++              }
++              return path;
++      }
++}
++
+ /* get the full path to a file under $PSEUDO_PREFIX.  Other ways of
+  * setting the prefix all set it in the environment.
+  */
index 88c7ee2c5ac77242043a0027869f98e2fb906ba4..e675cbcade020a8ce0493345ebee69aa94aefde5 100644 (file)
@@ -6,14 +6,15 @@ LICENSE = "LGPL2.1"
 DEPENDS = "sqlite3"
 
 PV = "0.0+git${SRCPV}"
-PR = "r5"
+PR = "r6"
 
 SRC_URI = "git://github.com/wrpseudo/pseudo.git;protocol=git \
            file://tweakflags.patch \
            file://path-munge.patch \
            file://ld_sacredness.patch \
            file://make_parallel.patch \
-           file://static_sqlite.patch"
+           file://static_sqlite.patch \
+          file://data-as-env.patch"
 
 FILES_${PN} = "${libdir}/libpseudo.so ${bindir}/* ${localstatedir}/pseudo"
 PROVIDES += "virtual/fakeroot"