Skip to content

Commit

Permalink
rename addon files to skel files
Browse files Browse the repository at this point in the history
  • Loading branch information
reglim authored and neolynx committed Apr 24, 2024
1 parent c89593f commit 2a5db9f
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 26 deletions.
5 changes: 2 additions & 3 deletions api/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
return &task.ProcessReturnValue{Code: http.StatusBadRequest, Value: nil}, fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate)
}

err := published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), publishOutput, b.ForceOverwrite)
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), publishOutput, b.ForceOverwrite)
if err != nil {
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to publish: %s", err)
}
Expand Down Expand Up @@ -341,8 +341,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
resources = append(resources, string(published.Key()))
taskName := fmt.Sprintf("Update published %s (%s): %s", published.SourceKind, strings.Join(updatedComponents, " "), strings.Join(updatedSnapshots, ", "))
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) {
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, out, b.ForceOverwrite)
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), out, b.ForceOverwrite)
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), out, b.ForceOverwrite)
if err != nil {
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/publish_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
context.Progress().ColoredPrintf("@rWARNING@|: force overwrite mode enabled, aptly might corrupt other published repositories sharing the same package pool.\n")
}

err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), context.Progress(), forceOverwrite)
err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), context.Progress(), forceOverwrite)
if err != nil {
return fmt.Errorf("unable to publish: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/publish_switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
published.SkipBz2 = context.Flags().Lookup("skip-bz2").Value.Get().(bool)
}

err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), context.Progress(), forceOverwrite)
err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), context.Progress(), forceOverwrite)
if err != nil {
return fmt.Errorf("unable to publish: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/publish_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
published.SkipBz2 = context.Flags().Lookup("skip-bz2").Value.Get().(bool)
}

err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.AddonPath(), context.Progress(), forceOverwrite)
err = published.Publish(context.PackagePool(), context, collectionFactory, signer, context.SkelPath(), context.Progress(), forceOverwrite)
if err != nil {
return fmt.Errorf("unable to publish: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,9 @@ func (context *AptlyContext) GetVerifier() pgp.Verifier {
return pgp.NewGpgVerifier(context.getGPGFinder())
}

// AddonPath builds the local addon folder
func (context *AptlyContext) AddonPath() string {
return filepath.Join(context.config().RootDir, "addon")
// SkelPath builds the local skeleton folder
func (context *AptlyContext) SkelPath() string {
return filepath.Join(context.config().RootDir, "skel")
}

// UpdateFlags sets internal copy of flags in the context
Expand Down
4 changes: 2 additions & 2 deletions deb/index_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ func (files *indexFiles) LegacyContentsIndex(arch string, udeb bool) *indexFile
return file
}

func (files *indexFiles) AddonIndex(component, path string) *indexFile {
key := fmt.Sprintf("ai-%s-%s", component, path)
func (files *indexFiles) SkelIndex(component, path string) *indexFile {
key := fmt.Sprintf("si-%s-%s", component, path)
file, ok := files.indexes[key]

if !ok {
Expand Down
24 changes: 12 additions & 12 deletions deb/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,16 +542,16 @@ func (p *PublishedRepo) GetCodename() string {
return p.Codename
}

// GetAddonFiles returns a map of files to be added to a repo. Key being the relative
// GetSkelFiles returns a map of files to be added to a repo. Key being the relative
// path from component folder, and value being the full local FS path.
func (p *PublishedRepo) GetAddonFiles(addonDir string, component string) (map[string]string, error) {
func (p *PublishedRepo) GetSkelFiles(skelDir string, component string) (map[string]string, error) {
files := make(map[string]string)

if addonDir == "" {
if skelDir == "" {
return files, nil
}

fsPath := filepath.Join(addonDir, p.Prefix, "dists", p.Distribution, component)
fsPath := filepath.Join(skelDir, p.Prefix, "dists", p.Distribution, component)
if err := filepath.Walk(fsPath, func(path string, info os.FileInfo, err error) error {

Check warning on line 555 in deb/publish.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'info' seems to be unused, consider removing or renaming it as _ (revive)
if err != nil {
return err
Expand Down Expand Up @@ -582,7 +582,7 @@ func (p *PublishedRepo) GetAddonFiles(addonDir string, component string) (map[st

// Publish publishes snapshot (repository) contents, links package files, generates Packages & Release files, signs them
func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageProvider aptly.PublishedStorageProvider,
collectionFactory *CollectionFactory, signer pgp.Signer, addonDirectory string, progress aptly.Progress, forceOverwrite bool) error {
collectionFactory *CollectionFactory, signer pgp.Signer, skelDir string, progress aptly.Progress, forceOverwrite bool) error {
publishedStorage := publishedStorageProvider.GetPublishedStorage(p.Storage)

err := publishedStorage.MkDir(filepath.Join(p.Prefix, "pool"))
Expand Down Expand Up @@ -787,25 +787,25 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
}

for component := range p.sourceItems {
addonFiles, err := p.GetAddonFiles(addonDirectory, component)
skelFiles, err := p.GetSkelFiles(skelDir, component)
if err != nil {
return fmt.Errorf("unable to get addon files: %v", err)
return fmt.Errorf("unable to get skeleton files: %v", err)
}

for relPath, absPath := range addonFiles {
bufWriter, err := indexes.AddonIndex(component, relPath).BufWriter()
for relPath, absPath := range skelFiles {
bufWriter, err := indexes.SkelIndex(component, relPath).BufWriter()
if err != nil {
return fmt.Errorf("unable to generate addon index: %v", err)
return fmt.Errorf("unable to generate skeleton index: %v", err)
}

file, err := os.Open(absPath)
if err != nil {
return fmt.Errorf("unable to read addon file: %v", err)
return fmt.Errorf("unable to read skeleton file: %v", err)
}

_, err = bufio.NewReader(file).WriteTo(bufWriter)
if err != nil {
return fmt.Errorf("unable to write addon file: %v", err)
return fmt.Errorf("unable to write skeleton file: %v", err)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion man/aptly.1.ronn.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Options:

* `rootDir`:
is root of directory storage to store database (`rootDir`/db), downloaded packages (`rootDir`/pool),
the default for published repositories (`rootDir`/public) and addon files (`rootDir`/addon)
the default for published repositories (`rootDir`/public) and skeleton files (`rootDir`/skel)

* `downloadConcurrency`:
is a number of parallel download threads to use when downloading packages
Expand Down
4 changes: 2 additions & 2 deletions system/t06_publish/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def check(self):

class PublishRepo34Test(BaseTest):
"""
publish repo: addon files
publish repo: skeleton files
"""
fixtureCmds = [
"aptly repo create local-repo",
Expand All @@ -904,7 +904,7 @@ class PublishRepo34Test(BaseTest):
def prepare_fixture(self):
super(PublishRepo34Test, self).prepare_fixture()

self.write_file(os.path.join('addon', 'dists', 'maverick', 'main', 'dep11', 'README'), 'README test file')
self.write_file(os.path.join('skel', 'dists', 'maverick', 'main', 'dep11', 'README'), 'README test file')

def check(self):
super(PublishRepo34Test, self).check()
Expand Down

0 comments on commit 2a5db9f

Please sign in to comment.