feat: migrate to system cache with changing core logic
This commit is contained in:
71
pkg/build/dirs.go
Normal file
71
pkg/build/dirs.go
Normal file
@ -0,0 +1,71 @@
|
||||
// ALR - Any Linux Repository
|
||||
// Copyright (C) 2025 Евгений Храмов
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package build
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
|
||||
)
|
||||
|
||||
type BaseDirProvider interface {
|
||||
BaseDir() string
|
||||
}
|
||||
|
||||
type SrcDirProvider interface {
|
||||
SrcDir() string
|
||||
}
|
||||
|
||||
type PkgDirProvider interface {
|
||||
PkgDir() string
|
||||
}
|
||||
|
||||
type ScriptDirProvider interface {
|
||||
ScriptDir() string
|
||||
}
|
||||
|
||||
func getDirs(
|
||||
cfg Config,
|
||||
scriptPath string,
|
||||
basePkg string,
|
||||
) (types.Directories, error) {
|
||||
pkgsDir := cfg.GetPaths().PkgsDir
|
||||
|
||||
scriptPath, err := filepath.Abs(scriptPath)
|
||||
if err != nil {
|
||||
return types.Directories{}, err
|
||||
}
|
||||
baseDir := filepath.Join(pkgsDir, basePkg)
|
||||
return types.Directories{
|
||||
BaseDir: getBaseDir(cfg, basePkg),
|
||||
SrcDir: getSrcDir(cfg, basePkg),
|
||||
PkgDir: filepath.Join(baseDir, "pkg"),
|
||||
ScriptDir: getScriptDir(scriptPath),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getBaseDir(cfg Config, basePkg string) string {
|
||||
return filepath.Join(cfg.GetPaths().PkgsDir, basePkg)
|
||||
}
|
||||
|
||||
func getSrcDir(cfg Config, basePkg string) string {
|
||||
return filepath.Join(getBaseDir(cfg, basePkg), "src")
|
||||
}
|
||||
|
||||
func getScriptDir(scriptPath string) string {
|
||||
return filepath.Dir(scriptPath)
|
||||
}
|
Reference in New Issue
Block a user