System test for repo adding .udebs. #108

This commit is contained in:
Andrey Smirnov
2014-09-30 21:26:28 +04:00
parent 6514b87e3e
commit 2c84faaf8d
9 changed files with 74 additions and 5 deletions

View File

@@ -61,14 +61,16 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
return nil return nil
} }
if strings.HasSuffix(info.Name(), ".deb") || strings.HasSuffix(info.Name(), ".dsc") { if strings.HasSuffix(info.Name(), ".deb") || strings.HasSuffix(info.Name(), ".udeb") ||
strings.HasSuffix(info.Name(), ".dsc") {
packageFiles = append(packageFiles, path) packageFiles = append(packageFiles, path)
} }
return nil return nil
}) })
} else { } else {
if strings.HasSuffix(info.Name(), ".deb") || strings.HasSuffix(info.Name(), ".dsc") { if strings.HasSuffix(info.Name(), ".deb") || strings.HasSuffix(info.Name(), ".udeb") ||
strings.HasSuffix(info.Name(), ".dsc") {
packageFiles = append(packageFiles, location) packageFiles = append(packageFiles, location)
} else { } else {
context.Progress().ColoredPrintf("@y[!]@| @!Unknwon file extenstion: %s@|", location) context.Progress().ColoredPrintf("@y[!]@| @!Unknwon file extenstion: %s@|", location)
@@ -93,6 +95,7 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
candidateProcessedFiles := []string{} candidateProcessedFiles := []string{}
isSourcePackage := strings.HasSuffix(file, ".dsc") isSourcePackage := strings.HasSuffix(file, ".dsc")
isUdebPackage := strings.HasSuffix(file, ".udeb")
if isSourcePackage { if isSourcePackage {
stanza, err = deb.GetControlFileFromDsc(file, verifier) stanza, err = deb.GetControlFileFromDsc(file, verifier)
@@ -105,7 +108,11 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
} }
} else { } else {
stanza, err = deb.GetControlFileFromDeb(file) stanza, err = deb.GetControlFileFromDeb(file)
p = deb.NewPackageFromControlFile(stanza) if isUdebPackage {
p = deb.NewUdebPackageFromControlFile(stanza)
} else {
p = deb.NewPackageFromControlFile(stanza)
}
} }
if err != nil { if err != nil {
context.Progress().ColoredPrintf("@y[!]@| @!Unable to read file %s: %s@|", file, err) context.Progress().ColoredPrintf("@y[!]@| @!Unable to read file %s: %s@|", file, err)
@@ -216,8 +223,8 @@ func makeCmdRepoAdd() *commander.Command {
UsageLine: "add <name> <package file.deb>|<directory> ...", UsageLine: "add <name> <package file.deb>|<directory> ...",
Short: "add packages to local repository", Short: "add packages to local repository",
Long: ` Long: `
Command adds packages to local repository from .deb (binary packages) and .dsc (source packages) files. Command adds packages to local repository from .deb, .udeb (binary packages) and .dsc (source packages) files.
When importing from directory aptly would do recursive scan looking for all files matching *.deb or *.dsc When importing from directory aptly would do recursive scan looking for all files matching *.[u]deb or *.dsc
patterns. Every file discovered would be analyzed to extract metadata, package would then be created and added patterns. Every file discovered would be analyzed to extract metadata, package would then be created and added
to the database. Files would be imported to internal package pool. For source packages, all required files are to the database. Files would be imported to internal package pool. For source packages, all required files are
added automatically as well. Extra files for source package should be in the same directory as *.dsc file. added automatically as well. Extra files for source package should be in the same directory as *.dsc file.

View File

@@ -155,6 +155,7 @@ class BaseTest(object):
if not hasattr(command, "__iter__"): if not hasattr(command, "__iter__"):
params = { params = {
'files': os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"), 'files': os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files"),
'udebs': os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "udebs"),
'testfiles': os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__), 'testfiles': os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__),
} }
if self.fixtureWebServer: if self.fixtureWebServer:

View File

@@ -0,0 +1,2 @@
Loading packages...
[+] dmraid-udeb_1.0.0.rc16-4.1_amd64 added

View File

@@ -0,0 +1,7 @@
Name: repo12
Comment: Repo12
Default Distribution: squeeze
Default Component: main
Number of packages: 1
Packages:
dmraid-udeb_1.0.0.rc16-4.1_amd64

View File

@@ -0,0 +1,6 @@
Loading packages...
[+] libboost-program-options-dev_1.49.0.1_i386 added
[+] pyspi_0.6.1-1.4_source added
[+] pyspi_0.6.1-1.3_source added
[+] dmraid-udeb_1.0.0.rc16-4.1_amd64 added
[+] dmraid-udeb_1.0.0.rc16-4.1_i386 added

View File

@@ -0,0 +1,11 @@
Name: repo13
Comment: Repo13
Default Distribution: squeeze
Default Component: main
Number of packages: 5
Packages:
dmraid-udeb_1.0.0.rc16-4.1_amd64
dmraid-udeb_1.0.0.rc16-4.1_i386
libboost-program-options-dev_1.49.0.1_i386
pyspi_0.6.1-1.3_source
pyspi_0.6.1-1.4_source

View File

@@ -232,3 +232,38 @@ class AddRepo11Test(BaseTest):
def check(self): def check(self):
self.check_output() self.check_output()
self.check_cmd_output("aptly repo show -with-packages repo11", "repo_show") self.check_cmd_output("aptly repo show -with-packages repo11", "repo_show")
class AddRepo12Test(BaseTest):
"""
add package to local repo: .udeb file
"""
fixtureCmds = [
"aptly repo create -comment=Repo12 -distribution=squeeze repo12",
]
runCmd = "aptly repo add repo12 ${udebs}/dmraid-udeb_1.0.0.rc16-4.1_amd64.udeb"
def check(self):
self.check_output()
self.check_cmd_output("aptly repo show -with-packages repo12", "repo_show")
# check pool
self.check_exists('pool/72/16/dmraid-udeb_1.0.0.rc16-4.1_amd64.udeb')
class AddRepo13Test(BaseTest):
"""
add package to local repo: .udeb and .deb files
"""
fixtureCmds = [
"aptly repo create -comment=Repo13 -distribution=squeeze repo13",
]
runCmd = "aptly repo add repo13 ${udebs} ${files}"
def check(self):
self.check_output()
self.check_cmd_output("aptly repo show -with-packages repo13", "repo_show")
# check pool
self.check_exists('pool/72/16/dmraid-udeb_1.0.0.rc16-4.1_amd64.udeb')
self.check_exists('pool/b7/2c/pyspi_0.6.1-1.3.dsc')

Binary file not shown.

Binary file not shown.