mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-27 13:57:46 +00:00
Add -force-replace flag to repo aptly add to replace conflicting packages. #83
This commit is contained in:
@@ -40,6 +40,8 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to load packages: %s", err)
|
return fmt.Errorf("unable to load packages: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
forceReplace := context.flags.Lookup("force-replace").Value.Get().(bool)
|
||||||
|
|
||||||
packageFiles := []string{}
|
packageFiles := []string{}
|
||||||
failedFiles := []string{}
|
failedFiles := []string{}
|
||||||
|
|
||||||
@@ -79,6 +81,10 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
|
|||||||
processedFiles := []string{}
|
processedFiles := []string{}
|
||||||
sort.Strings(packageFiles)
|
sort.Strings(packageFiles)
|
||||||
|
|
||||||
|
if forceReplace {
|
||||||
|
list.PrepareIndex()
|
||||||
|
}
|
||||||
|
|
||||||
for _, file := range packageFiles {
|
for _, file := range packageFiles {
|
||||||
var (
|
var (
|
||||||
stanza deb.Stanza
|
stanza deb.Stanza
|
||||||
@@ -155,6 +161,14 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if forceReplace {
|
||||||
|
conflictingPackages := list.Search(deb.Dependency{Pkg: p.Name, Version: p.Version, Architecture: p.Architecture}, true)
|
||||||
|
for _, cp := range conflictingPackages {
|
||||||
|
context.Progress().ColoredPrintf("@r[-]@| %s removed due to conflict with package being added", cp)
|
||||||
|
list.Remove(cp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = list.Add(p)
|
err = list.Add(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
context.Progress().ColoredPrintf("@y[!]@| @!Unable to add package to repo %s: %s@|", p, err)
|
context.Progress().ColoredPrintf("@y[!]@| @!Unable to add package to repo %s: %s@|", p, err)
|
||||||
@@ -216,6 +230,7 @@ Example:
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flag.Bool("remove-files", false, "remove files that have been imported successfully into repository")
|
cmd.Flag.Bool("remove-files", false, "remove files that have been imported successfully into repository")
|
||||||
|
cmd.Flag.Bool("force-replace", false, "when adding package that conflicts with existing package, remove existing package")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -476,6 +476,10 @@ $ aptly repo add testing myapp\-0\.1\.2\.deb incoming/
|
|||||||
Options:
|
Options:
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
\-\fBforce\-replace\fR=false
|
||||||
|
when adding package that conflicts with existing package, remove existing package
|
||||||
|
.
|
||||||
|
.TP
|
||||||
\-\fBremove\-files\fR=false
|
\-\fBremove\-files\fR=false
|
||||||
remove files that have been imported successfully into repository
|
remove files that have been imported successfully into repository
|
||||||
.
|
.
|
||||||
|
|||||||
+1
-1
@@ -203,8 +203,8 @@ class BaseTest(object):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def check_cmd_output(self, command, gold_name, match_prepare=None, expected_code=0):
|
def check_cmd_output(self, command, gold_name, match_prepare=None, expected_code=0):
|
||||||
|
output = self.run_cmd(command, expected_code=expected_code)
|
||||||
try:
|
try:
|
||||||
output = self.run_cmd(command, expected_code=expected_code)
|
|
||||||
self.verify_match(self.get_gold(gold_name), output, match_prepare)
|
self.verify_match(self.get_gold(gold_name), output, match_prepare)
|
||||||
except:
|
except:
|
||||||
if self.captureResults:
|
if self.captureResults:
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
Format: 1.0
|
||||||
|
Source: pyspi
|
||||||
|
Binary: python-at-spi
|
||||||
|
Architecture: any
|
||||||
|
Version: 0.6.1-1.3
|
||||||
|
Maintainer: Jose Carlos Garcia Sogo <jsogo@debian.org>
|
||||||
|
Homepage: http://people.redhat.com/zcerza/dogtail
|
||||||
|
Standards-Version: 3.7.3
|
||||||
|
Vcs-Svn: svn://svn.tribulaciones.org/srv/svn/pyspi/trunk
|
||||||
|
Build-Depends: debhelper (>= 5), cdbs, libatspi-dev, python-pyrex, python-support (>= 0.4), python-all-dev, libx11-dev
|
||||||
|
Files:
|
||||||
|
d41d8cd98f00b204e9800998ecf8427e 0 pyspi_0.6.1.orig.tar.gz
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Loading packages...
|
||||||
|
[-] pyspi_0.6.1-1.3_source removed due to conflict with package being added
|
||||||
|
[+] pyspi_0.6.1-1.3_source added
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Name: repo11
|
||||||
|
Comment: Repo11
|
||||||
|
Default Distribution: squeeze
|
||||||
|
Default Component: main
|
||||||
|
Number of packages: 1
|
||||||
|
Packages:
|
||||||
|
pyspi_0.6.1-1.3_source
|
||||||
@@ -216,3 +216,19 @@ class AddRepo10Test(BaseTest):
|
|||||||
def check(self):
|
def check(self):
|
||||||
self.check_output()
|
self.check_output()
|
||||||
self.check_cmd_output("aptly repo show -with-packages repo10", "repo_show")
|
self.check_cmd_output("aptly repo show -with-packages repo10", "repo_show")
|
||||||
|
|
||||||
|
|
||||||
|
class AddRepo11Test(BaseTest):
|
||||||
|
"""
|
||||||
|
add package to local repo: conflict in packages + -force-replace
|
||||||
|
"""
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly repo create -comment=Repo11 -distribution=squeeze repo11",
|
||||||
|
"aptly repo add repo11 ${files}/pyspi_0.6.1-1.3.dsc",
|
||||||
|
]
|
||||||
|
runCmd = "aptly repo add -force-replace repo11 ${testfiles}/pyspi_0.6.1-1.3.conflict.dsc"
|
||||||
|
outputMatchPrepare = lambda self, s: s.replace(os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), "").replace(os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), "")
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
self.check_output()
|
||||||
|
self.check_cmd_output("aptly repo show -with-packages repo11", "repo_show")
|
||||||
|
|||||||
Reference in New Issue
Block a user