Currently solbuild can cache C, C++, and Rust builds. However, in the future, it's likely we'll need to cache more things. For example, the cargo registry (takes 1~2 minutes to pull the index), Go build cache, etc.
Therefore, I propose the ability for packagers to specify additional cache entries using /etc/solbuild/<profile>.conf. The structure can look like this:
# By default, sccache and ccache are provided.
[cache]
caches = ["ccache", "sccache", "cargo"]
[cache.cargo]
# Relative to the $BUILDUSER's $HOME directory, which should be enough for most conditions.
# This can be further discussed.
internalDir = ".cargo"
# For legacy builds. Require a full path.
legacyInternalDir = "/root/.cargo"
The benefits of this approach are that it does not affect existing cache (e.g. for the build server that doesn't want any caching), and it is very simple (we don't need to patch YPKG).
To achieve this, the cache directories' layout needs to be changed. Currently, we have /var/lib/solbuild/ccache and /var/lib/solbuild/sccache. For easier cache management, all build cache will be stored in /var/lib/solbuild/cache/<cache-name>. For example, the ccache directory will go to /var/lib/solbuild/ccache, and the cargo registry directory (in the example above) will go to /var/lib/solbuild/cargo. When deleting cache (solbuild dc), we can simply delete /var/lib/solbuild/cache.
If this is not possible, I suggest at least refactor the code so that in the future, we can add additional caches as easy as constructing a new struct (Cache) and add it to a global variable called caches, instead of writing 10 new methods by hand. I already implemented this locally and have been using it for a week, so I can verify this will not break anything. Unfortunately, I recently wiped my PC without pushing my commits to the remote, so I don't have them ready right now, but I am happy to rewrite them since they're still refresh in my head.
Currently
solbuildcan cache C, C++, and Rust builds. However, in the future, it's likely we'll need to cache more things. For example, the cargo registry (takes 1~2 minutes to pull the index), Go build cache, etc.Therefore, I propose the ability for packagers to specify additional cache entries using
/etc/solbuild/<profile>.conf. The structure can look like this:The benefits of this approach are that it does not affect existing cache (e.g. for the build server that doesn't want any caching), and it is very simple (we don't need to patch YPKG).
To achieve this, the cache directories' layout needs to be changed. Currently, we have
/var/lib/solbuild/ccacheand/var/lib/solbuild/sccache. For easier cache management, all build cache will be stored in/var/lib/solbuild/cache/<cache-name>. For example, theccachedirectory will go to/var/lib/solbuild/ccache, and thecargoregistry directory (in the example above) will go to/var/lib/solbuild/cargo. When deleting cache (solbuild dc), we can simply delete/var/lib/solbuild/cache.If this is not possible, I suggest at least refactor the code so that in the future, we can add additional caches as easy as constructing a new struct (
Cache) and add it to a global variable calledcaches, instead of writing 10 new methods by hand. I already implemented this locally and have been using it for a week, so I can verify this will not break anything. Unfortunately, I recently wiped my PC without pushing my commits to the remote, so I don't have them ready right now, but I am happy to rewrite them since they're still refresh in my head.