mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-09 06:04:12 +00:00
New flag -no-remove for aptly snapshot pull.
This commit is contained in:
+10
-6
@@ -18,6 +18,7 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
|
||||
noDeps := cmd.Flag.Lookup("no-deps").Value.Get().(bool)
|
||||
noRemove := cmd.Flag.Lookup("no-remove").Value.Get().(bool)
|
||||
|
||||
snapshotCollection := debian.NewSnapshotCollection(context.database)
|
||||
packageCollection := debian.NewPackageCollection(context.database)
|
||||
@@ -107,12 +108,14 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error {
|
||||
continue
|
||||
}
|
||||
|
||||
// Remove all packages with the same name and architecture
|
||||
for p := packageList.Search(debian.Dependency{Architecture: pkg.Architecture, Pkg: pkg.Name}); p != nil; {
|
||||
packageList.Remove(p)
|
||||
color.Printf("@r[-]@| %s removed", p)
|
||||
fmt.Printf("\n")
|
||||
p = packageList.Search(debian.Dependency{Architecture: pkg.Architecture, Pkg: pkg.Name})
|
||||
if !noRemove {
|
||||
// Remove all packages with the same name and architecture
|
||||
for p := packageList.Search(debian.Dependency{Architecture: pkg.Architecture, Pkg: pkg.Name}); p != nil; {
|
||||
packageList.Remove(p)
|
||||
color.Printf("@r[-]@| %s removed", p)
|
||||
fmt.Printf("\n")
|
||||
p = packageList.Search(debian.Dependency{Architecture: pkg.Architecture, Pkg: pkg.Name})
|
||||
}
|
||||
}
|
||||
|
||||
// Add new discovered package
|
||||
@@ -187,6 +190,7 @@ ex.
|
||||
|
||||
cmd.Flag.Bool("dry-run", false, "don't create destination snapshot, just show what would be pulled")
|
||||
cmd.Flag.Bool("no-deps", false, "don't process dependencies, just pull listed packages")
|
||||
cmd.Flag.Bool("no-remove", false, "don't remove other package versions when pulling package")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
Dependencies would be pulled into snapshot:
|
||||
[snap1]: Snapshot from mirror [wheezy-main]: http://mirror.yandex.ru/debian/ wheezy
|
||||
from snapshot:
|
||||
[snap2]: Snapshot from mirror [wheezy-backports]: http://mirror.yandex.ru/debian/ wheezy-backports
|
||||
and result would be saved as new snapshot snap3.
|
||||
Loading packages (59249)...
|
||||
Building indexes...
|
||||
[0;32;49m[+][0;39;49m rsyslog_7.4.4-1~bpo70+1_amd64 added[0m
|
||||
[0;32;49m[+][0;39;49m libestr0_0.1.9-1~bpo70+1_amd64 added[0m
|
||||
[0;32;49m[+][0;39;49m init-system-helpers_1.11~bpo70.1_all added[0m
|
||||
[0;32;49m[+][0;39;49m rsyslog_7.4.4-1~bpo70+1_i386 added[0m
|
||||
[0;32;49m[+][0;39;49m libestr0_0.1.9-1~bpo70+1_i386 added[0m
|
||||
|
||||
Snapshot snap3 successfully created.
|
||||
You can run 'aptly publish snapshot snap3' to publish snapshot as Debian repository.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -175,3 +175,23 @@ class PullSnapshot10Test(BaseTest):
|
||||
|
||||
self.check_output()
|
||||
self.check_cmd_output("aptly snapshot show --with-packages snap3", "snapshot_show", match_prepare=remove_created_at)
|
||||
|
||||
|
||||
class PullSnapshot11Test(BaseTest):
|
||||
"""
|
||||
pull snapshot: -no-remove
|
||||
"""
|
||||
fixtureDB = True
|
||||
fixtureCmds = [
|
||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
||||
"aptly snapshot create snap2 from mirror wheezy-backports",
|
||||
]
|
||||
runCmd = "aptly snapshot pull -no-remove snap1 snap2 snap3 'rsyslog (>= 7.4.4)'"
|
||||
outputMatchPrepare = lambda _, output: "\n".join(sorted(output.split("\n")))
|
||||
|
||||
def check(self):
|
||||
def remove_created_at(s):
|
||||
return re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s)
|
||||
|
||||
self.check_output()
|
||||
self.check_cmd_output("aptly snapshot show -with-packages snap3", "snapshot_show", match_prepare=remove_created_at)
|
||||
|
||||
Reference in New Issue
Block a user