commit:     d0fc244d633375faeaf4da81350c9818a1b291f0
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Wed Dec  6 08:45:30 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Dec  6 18:05:00 2017 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d0fc244d

Allow unversioned cache directories

The generation of cachedirs up to this point includes the version_stamp
from the specfile.

If the version is being automatically incremented (eg daily builds),
then it generates unique cache directories for each build, and doesn't
reuse old cache.

Example versioned cache directories:
/release/buildroot/amd64-dev/packages/default/stage1-amd64-20171203
/release/buildroot/amd64-dev/packages/default/stage1-amd64-20171204
/release/buildroot/amd64-dev/packages/default/stage1-amd64-20171206

This should be using a common cache directory:
/release/buildroot/amd64-dev/packages/default/stage1-amd64

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 catalyst/base/stagebase.py | 23 ++++++++++++++++++-----
 catalyst/main.py           |  8 ++++++++
 doc/catalyst-config.5.txt  |  9 +++++++++
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 7a41973c..a6a32f5a 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -318,9 +318,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
                self.settings["target_profile"] = self.settings["profile"]
 
        def set_target_subpath(self):
-               self.settings["target_subpath"] = self.settings["rel_type"] + 
"/" + \
-                               self.settings["target"] + "-" + 
self.settings["subarch"] + "-" + \
-                               self.settings["version_stamp"] + '/'
+               common = self.settings["rel_type"] + "/" + \
+                               self.settings["target"] + "-" + 
self.settings["subarch"]
+               self.settings["target_subpath"] = \
+                               common + \
+                               "-" + self.settings["version_stamp"] + \
+                               "/"
+               self.settings["target_subpath_unversioned"] = \
+                               common + \
+                               "/"
 
        def set_source_subpath(self):
                if not isinstance(self.settings['source_subpath'], str):
@@ -333,19 +339,26 @@ class StageBase(TargetBase, ClearBase, GenBase):
                        if not isinstance(self.settings['pkgcache_path'], str):
                                self.settings["pkgcache_path"] = \
                                        normpath(self.settings["pkgcache_path"])
-               else:
+               elif "versioned_cache" in self.settings["options"]:
                        self.settings["pkgcache_path"] = \
                                normpath(self.settings["storedir"] + 
"/packages/" + \
                                self.settings["target_subpath"] + "/")
+               else:
+                       self.settings["pkgcache_path"] = \
+                               normpath(self.settings["storedir"] + 
"/packages/" + \
+                               self.settings["target_subpath_unversioned"] + 
"/")
 
        def set_kerncache_path(self):
                if "kerncache_path" in self.settings:
                        if not isinstance(self.settings['kerncache_path'], str):
                                self.settings["kerncache_path"] = \
                                        
normpath(self.settings["kerncache_path"])
-               else:
+               elif "versioned_cache" in self.settings["options"]:
                        self.settings["kerncache_path"] = 
normpath(self.settings["storedir"] + \
                                "/kerncache/" + self.settings["target_subpath"])
+               else:
+                       self.settings["kerncache_path"] = 
normpath(self.settings["storedir"] + \
+                               "/kerncache/" + 
self.settings["target_subpath_unversioned"])
 
        def set_target_path(self):
                self.settings["target_path"] = 
normpath(self.settings["storedir"] + \

diff --git a/catalyst/main.py b/catalyst/main.py
index b8ae662d..3a428d3a 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -190,6 +190,14 @@ $ catalyst -f stage1-specfile.spec"""
        group.add_argument('-T', '--purgetmponly',
                default=False, action='store_true',
                help='clear tmp dirs and autoresume flags and exit')
+        group.add_argument('--versioned-cachedir',
+                dest='versioned_cachedir', action='store_true',
+                help='use stage version on cache directory name')
+        group.add_argument('--unversioned-cachedir',
+                dest='versioned_cachedir', action='store_false',
+                help='do not use stage version on cache directory name')
+        group.set_defaults(versioned_cachedir=False)
+
 
        group = parser.add_argument_group('Target/config file management')
        group.add_argument('-F', '--fetchonly',

diff --git a/doc/catalyst-config.5.txt b/doc/catalyst-config.5.txt
index 5c5ad293..957ab0e6 100644
--- a/doc/catalyst-config.5.txt
+++ b/doc/catalyst-config.5.txt
@@ -145,6 +145,10 @@ Cache the snapshot so that it can be bind-mounted into the 
chroot.
 WARNING: moving parts of the portage tree from within fsscript *will*
 break your cache.  The cache is unlinked before any empty or rm
 processing.
+
+versioned_cache::
+Name the cache directories (packagecache, kerncache) based on the version of a
+spec file.
 --
 
 Repository settings
@@ -240,9 +244,14 @@ sub-slots, you may experience errors like this due to 
untracked ABI
 missmatches in binary packages.  Packages generated by catalyst builds
 are currently namespaced:
 
+If versioned_cache is set:
 ---------------------------------
 .../packages/<rel_type>/<target>-<subarch>-<version_stamp>/Packages
 ---------------------------------
+Otherwise:
+---------------------------------
+.../packages/<rel_type>/<target>-<subarch>/Packages
+---------------------------------
 
 so running into these out-of-date packages is unlikely.  You may run
 into problems if:

Reply via email to