Skip to content

Commit

Permalink
Ensure caches are only bound for YPKG builds
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Zhao <[email protected]>
  • Loading branch information
GZGavinZhao committed Sep 20, 2023
1 parent ca352d6 commit b896959
Showing 1 changed file with 6 additions and 39 deletions.
45 changes: 6 additions & 39 deletions builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,15 @@ func (p *Package) BindSources(o *Overlay) error {

// BindCache will make all cache defined in [caches] available to the build.
func (p *Package) BindCaches(o *Overlay) error {
if p.Type == PackageTypeXML {
return fmt.Errorf("Failed to bind caches, reason: not YPKG build")
}

mountMan := disk.GetMountManager()

for _, c := range Caches {
var (
cacheSource string
cacheDir string
)

if p.Type == PackageTypeYpkg {
cacheSource = filepath.Join(CacheDirectory, c.Name, "ypkg")
cacheDir = filepath.Join(o.MountPoint, c.CacheDir[1:])
}
cacheSource := filepath.Join(CacheDirectory, c.Name, "ypkg")
cacheDir := filepath.Join(o.MountPoint, c.CacheDir[1:])

log.Debugf("Exposing %s to build %s\n", c.Name, cacheDir)

Expand Down Expand Up @@ -173,36 +170,6 @@ func (p *Package) GetSourceDirInternal() string {
return filepath.Join(BuildUserHome, "YPKG", "sources")
}

// GetCcacheDir will return the externally visible ccache directory.
func (p *Package) GetCcacheDir(o *Overlay) string {
return filepath.Join(o.MountPoint, p.GetCcacheDirInternal()[1:])
}

// GetCcacheDirInternal will return the chroot-internal ccache directory
// for the given build type.
func (p *Package) GetCcacheDirInternal() string {
if p.Type == PackageTypeXML {
return "/root/.ccache"
}

return filepath.Join(BuildUserHome, ".ccache")
}

// GetSccacheDir will return the externally visible sccache directory.
func (p *Package) GetSccacheDir(o *Overlay) string {
return filepath.Join(o.MountPoint, p.GetSccacheDirInternal()[1:])
}

// GetSccacheDirInternal will return the chroot-internal sccache
// directory for the given build type.
func (p *Package) GetSccacheDirInternal() string {
if p.Type == PackageTypeXML {
return "/root/.cache/sccache"
}

return filepath.Join(BuildUserHome, ".cache", "sccache")
}

// CopyAssets will copy all of the required assets into the builder root.
func (p *Package) CopyAssets(h *PackageHistory, o *Overlay) error {
baseDir := filepath.Dir(p.Path)
Expand Down

0 comments on commit b896959

Please sign in to comment.