feat: add altlinux prefix for repo
This commit is contained in:
parent
e4f9743dea
commit
0d56779189
4 changed files with 23 additions and 8 deletions
|
@ -2,5 +2,5 @@
|
|||
<rect width="1100" height="20" fill="#555"/>
|
||||
<rect x="60" width="50" height="20" fill="#4c1"/>
|
||||
<text x="5" y="14" fill="#fff" font-family="Verdana" font-size="11">coverage</text>
|
||||
<text x="70" y="14" fill="#fff" font-family="Verdana" font-size="11">58.4%</text>
|
||||
<text x="70" y="14" fill="#fff" font-family="Verdana" font-size="11">59.3%</text>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 341 B |
|
@ -74,6 +74,7 @@ func (s *Service) cleanUpAfterUpdate() {
|
|||
|
||||
func (s *Service) Update(force bool) error {
|
||||
const REPO_NAME = "aides"
|
||||
const DISTRO_ID = "altlinux"
|
||||
|
||||
architectures := []string{
|
||||
"x86_64",
|
||||
|
@ -141,6 +142,7 @@ func (s *Service) Update(force bool) error {
|
|||
|
||||
futureRepoPath := path.Join(
|
||||
s.futureRepoPathPrefix(),
|
||||
DISTRO_ID,
|
||||
altRepo.Name,
|
||||
)
|
||||
|
||||
|
@ -170,7 +172,7 @@ func (s *Service) Update(force bool) error {
|
|||
"RPMS.aides",
|
||||
fileInfo.Filename,
|
||||
)
|
||||
targetPath := path.Join("../../../../tasks/", localFilePath)
|
||||
targetPath := path.Join("../../../../../tasks/", localFilePath)
|
||||
err := createSymlink(targetPath, symLink)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -196,11 +198,13 @@ func (s *Service) Update(force bool) error {
|
|||
|
||||
currentRepoPath := path.Join(
|
||||
s.currentRepoPathPrefix(),
|
||||
DISTRO_ID,
|
||||
altRepo.Name,
|
||||
)
|
||||
|
||||
oldRepoPath := path.Join(
|
||||
s.oldRepoPathPrefix(),
|
||||
DISTRO_ID,
|
||||
altRepo.Name,
|
||||
)
|
||||
|
||||
|
@ -211,7 +215,7 @@ func (s *Service) Update(force bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := os.Rename(
|
||||
if err := renameIfExists(
|
||||
futureRepoPath,
|
||||
currentRepoPath,
|
||||
); err != nil {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"code.aides.space/aides-infra/aides-repo-api/internal/logger"
|
||||
)
|
||||
|
@ -82,7 +83,17 @@ func createSymlink(target, link string) error {
|
|||
}
|
||||
|
||||
func renameIfExists(oldPath, newPath string) error {
|
||||
log := logger.GetLogger()
|
||||
log.Debug(filepath.Dir(newPath))
|
||||
|
||||
if _, err := os.Stat(oldPath); err == nil {
|
||||
log.Debug(filepath.Dir(newPath))
|
||||
if err = os.MkdirAll(
|
||||
filepath.Dir(newPath),
|
||||
os.ModePerm,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Rename(oldPath, newPath)
|
||||
} else if !os.IsNotExist(err) {
|
||||
return err
|
||||
|
|
|
@ -88,7 +88,7 @@ func TestRepoService_ForceUpdate(t *testing.T) {
|
|||
// CHECK
|
||||
assert.NoError(t, err)
|
||||
// TODO: check db
|
||||
repoBasePath := path.Join(config.GetUploadDir(), "repo", "Sisyphus")
|
||||
repoBasePath := path.Join(config.GetUploadDir(), "repo", "altlinux", "Sisyphus")
|
||||
x86_64BasePath := path.Join(repoBasePath, "x86_64", "base")
|
||||
x86_64RPMSPath := path.Join(repoBasePath, "x86_64", "RPMS.aides")
|
||||
noarchBasePath := path.Join(repoBasePath, "noarch", "base")
|
||||
|
@ -115,7 +115,7 @@ func TestRepoService_ForceUpdate(t *testing.T) {
|
|||
rpmPath := path.Join(x86_64RPMSPath, fileName)
|
||||
linkDest, err := os.Readlink(rpmPath)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, path.Join("../../../../tasks/1", fileName), linkDest)
|
||||
assert.Equal(t, path.Join("../../../../../tasks/1", fileName), linkDest)
|
||||
})
|
||||
|
||||
t.Run("Correct update (update)", func(t *testing.T) {
|
||||
|
@ -181,7 +181,7 @@ func TestRepoService_ForceUpdate(t *testing.T) {
|
|||
// CHECK
|
||||
assert.NoError(t, err)
|
||||
// TODO: check db
|
||||
repoBasePath := path.Join(config.GetUploadDir(), "repo", "Sisyphus")
|
||||
repoBasePath := path.Join(config.GetUploadDir(), "repo", "altlinux", "Sisyphus")
|
||||
x86_64BasePath := path.Join(repoBasePath, "x86_64", "base")
|
||||
x86_64RPMSPath := path.Join(repoBasePath, "x86_64", "RPMS.aides")
|
||||
noarchBasePath := path.Join(repoBasePath, "noarch", "base")
|
||||
|
@ -208,7 +208,7 @@ func TestRepoService_ForceUpdate(t *testing.T) {
|
|||
rpmPath := path.Join(x86_64RPMSPath, fileName)
|
||||
linkDest, err := os.Readlink(rpmPath)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, path.Join("../../../../tasks/1", fileName), linkDest)
|
||||
assert.Equal(t, path.Join("../../../../../tasks/1", fileName), linkDest)
|
||||
})
|
||||
|
||||
t.Run("Do not do anything if no updates", func(t *testing.T) {
|
||||
|
@ -275,7 +275,7 @@ func TestRepoService_ForceUpdate(t *testing.T) {
|
|||
|
||||
// СHECK
|
||||
assert.NoError(t, err)
|
||||
repoBasePath := path.Join(config.GetUploadDir(), "repo", "Sisyphus")
|
||||
repoBasePath := path.Join(config.GetUploadDir(), "repo", "altlinux", "Sisyphus")
|
||||
_, err = os.Stat(repoBasePath)
|
||||
assert.True(t, os.IsNotExist(err))
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue