mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-09 06:04:12 +00:00
When doing db cleanup, consider package references stored in PublishedRepos
of local repo publishes. #146
This commit is contained in:
+19
-1
@@ -20,7 +20,7 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
|
||||
// collect information about references packages...
|
||||
existingPackageRefs := deb.NewPackageRefList()
|
||||
|
||||
context.Progress().Printf("Loading mirrors, local repos and snapshots...\n")
|
||||
context.Progress().Printf("Loading mirrors, local repos, snapshots and published repos...\n")
|
||||
err = context.CollectionFactory().RemoteRepoCollection().ForEach(func(repo *deb.RemoteRepo) error {
|
||||
err := context.CollectionFactory().RemoteRepoCollection().LoadComplete(repo)
|
||||
if err != nil {
|
||||
@@ -61,6 +61,24 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = context.CollectionFactory().PublishedRepoCollection().ForEach(func(published *deb.PublishedRepo) error {
|
||||
if published.SourceKind != "local" {
|
||||
return nil
|
||||
}
|
||||
err := context.CollectionFactory().PublishedRepoCollection().LoadComplete(published, context.CollectionFactory())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, component := range published.Components() {
|
||||
existingPackageRefs = existingPackageRefs.Merge(published.RefList(component), false)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// ... and compare it to the list of all packages
|
||||
context.Progress().Printf("Loading list of all packages...\n")
|
||||
allPackageRefs := context.CollectionFactory().PackageCollection().AllPackageRefs()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Loading mirrors, local repos and snapshots...
|
||||
Loading mirrors, local repos, snapshots and published repos...
|
||||
Loading list of all packages...
|
||||
Deleting unreferenced packages (0)...
|
||||
Building list of files referenced by packages...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Loading mirrors, local repos and snapshots...
|
||||
Loading mirrors, local repos, snapshots and published repos...
|
||||
Loading list of all packages...
|
||||
Deleting unreferenced packages (73270)...
|
||||
Building list of files referenced by packages...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Loading mirrors, local repos and snapshots...
|
||||
Loading mirrors, local repos, snapshots and published repos...
|
||||
Loading list of all packages...
|
||||
Deleting unreferenced packages (7)...
|
||||
Building list of files referenced by packages...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Loading mirrors, local repos and snapshots...
|
||||
Loading mirrors, local repos, snapshots and published repos...
|
||||
Loading list of all packages...
|
||||
Deleting unreferenced packages (0)...
|
||||
Building list of files referenced by packages...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Loading mirrors, local repos and snapshots...
|
||||
Loading mirrors, local repos, snapshots and published repos...
|
||||
Loading list of all packages...
|
||||
Deleting unreferenced packages (7)...
|
||||
Building list of files referenced by packages...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Loading mirrors, local repos and snapshots...
|
||||
Loading mirrors, local repos, snapshots and published repos...
|
||||
Loading list of all packages...
|
||||
Deleting unreferenced packages (0)...
|
||||
Building list of files referenced by packages...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Loading mirrors, local repos and snapshots...
|
||||
Loading mirrors, local repos, snapshots and published repos...
|
||||
Loading list of all packages...
|
||||
Deleting unreferenced packages (0)...
|
||||
Building list of files referenced by packages...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Loading mirrors, local repos and snapshots...
|
||||
Loading mirrors, local repos, snapshots and published repos...
|
||||
Loading list of all packages...
|
||||
Deleting unreferenced packages (3)...
|
||||
Building list of files referenced by packages...
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
Loading mirrors, local repos, snapshots and published repos...
|
||||
Loading list of all packages...
|
||||
Deleting unreferenced packages (0)...
|
||||
Building list of files referenced by packages...
|
||||
Building list of files in package pool...
|
||||
Deleting unreferenced files (0)...
|
||||
Compacting database...
|
||||
@@ -0,0 +1,4 @@
|
||||
Removing /Users/smira/.aptly/public/dists/def...
|
||||
Cleaning up prefix "." components main...
|
||||
|
||||
Published repository has been removed successfully.
|
||||
@@ -92,3 +92,22 @@ class CleanupDB8Test(BaseTest):
|
||||
"aptly repo drop local-repo",
|
||||
]
|
||||
runCmd = "aptly db cleanup"
|
||||
|
||||
|
||||
class CleanupDB9Test(BaseTest):
|
||||
"""
|
||||
cleanup db: publish local repo, remove packages from repo, db cleanup
|
||||
"""
|
||||
fixtureCmds = [
|
||||
"aptly repo create -distribution=abc local-repo",
|
||||
"aptly repo create -distribution=def local-repo2",
|
||||
"aptly repo add local-repo ${files}",
|
||||
"aptly publish repo local-repo",
|
||||
"aptly publish repo -architectures=i386 local-repo2",
|
||||
"aptly repo remove local-repo Name",
|
||||
]
|
||||
runCmd = "aptly db cleanup"
|
||||
|
||||
def check(self):
|
||||
self.check_output()
|
||||
self.check_cmd_output("aptly publish drop def", "publish_drop")
|
||||
|
||||
Reference in New Issue
Block a user