mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-11-13 14:37:18 +00:00
Display architecture variants in package output
This commit is contained in:
1 parent
6efb8e17fd
commit
b5096eaea9
5 files changed
+83
-4
No files matched your search
@@ -60,10 +60,10 @@ func aptlySnapshotDiff(cmd *commander.Command, args []string) error {
|
||||
verA = "-"
|
||||
verB = pdiff.Right.Version
|
||||
pkg = pdiff.Right.Name
|
||||
arch = pdiff.Right.Architecture
|
||||
arch = pdiff.Right.IndexArchitecture()
|
||||
} else {
|
||||
pkg = pdiff.Left.Name
|
||||
arch = pdiff.Left.Architecture
|
||||
arch = pdiff.Left.IndexArchitecture()
|
||||
verA = pdiff.Left.Version
|
||||
if pdiff.Right == nil {
|
||||
verB = "-"
|
||||
|
||||
@@ -706,3 +706,12 @@ func (s *PackageListSuite) TestArchitectureVariantIndexArchitectures(c *C) {
|
||||
sort.Strings(base)
|
||||
c.Check(base, DeepEquals, []string{"amd64", "i386"})
|
||||
}
|
||||
|
||||
func (s *PackageListSuite) TestArchitectureVariantFullNames(c *C) {
|
||||
for _, variant := range []string{"", "amd64v3"} {
|
||||
c.Assert(s.list.Add(&Package{Name: "3cpio", Version: "0.14.0-1ubuntu1", Architecture: "amd64", ArchitectureVariant: variant}), IsNil)
|
||||
}
|
||||
names := s.list.FullNames()
|
||||
sort.Strings(names)
|
||||
c.Check(names, DeepEquals, []string{"3cpio_0.14.0-1ubuntu1_amd64", "3cpio_0.14.0-1ubuntu1_amd64v3"})
|
||||
}
|
||||
+2
-2
@@ -240,7 +240,7 @@ func (p *Package) ShortKey(prefix string) []byte {
|
||||
|
||||
// String creates readable representation
|
||||
func (p *Package) String() string {
|
||||
return fmt.Sprintf("%s_%s_%s", p.Name, p.Version, p.Architecture)
|
||||
return fmt.Sprintf("%s_%s_%s", p.Name, p.Version, p.IndexArchitecture())
|
||||
}
|
||||
|
||||
// ExtendedStanza returns package stanza enhanced with aptly-specific fields
|
||||
@@ -458,7 +458,7 @@ func (p *Package) GetName() string {
|
||||
|
||||
// GetFullName returns the package full name
|
||||
func (p *Package) GetFullName() string {
|
||||
return strings.Join([]string{p.Name, p.Version, p.Architecture}, "_")
|
||||
return strings.Join([]string{p.Name, p.Version, p.IndexArchitecture()}, "_")
|
||||
}
|
||||
|
||||
// GetVersion returns package version
|
||||
|
||||
@@ -603,3 +603,16 @@ func (s *PackageSuite) TestArchitectureVariantMatchesIndexArchitecture(c *C) {
|
||||
c.Check(p.MatchesArchitecture("amd64"), Equals, true)
|
||||
c.Check(p.MatchesArchitecture("amd64v3"), Equals, false)
|
||||
}
|
||||
|
||||
func (s *PackageSuite) TestArchitectureVariantDisplayNames(c *C) {
|
||||
for _, variant := range []string{"", "amd64v3"} {
|
||||
p := &Package{Name: "3cpio", Version: "0.14.0-1ubuntu1", Architecture: "amd64", ArchitectureVariant: variant}
|
||||
expected := "3cpio_0.14.0-1ubuntu1_amd64"
|
||||
if variant != "" {
|
||||
expected = "3cpio_0.14.0-1ubuntu1_amd64v3"
|
||||
}
|
||||
c.Check(p.String(), Equals, expected)
|
||||
c.Check(p.GetFullName(), Equals, expected)
|
||||
c.Check(p.GetArchitecture(), Equals, "amd64")
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import re
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
@@ -80,3 +82,58 @@ class DiffSnapshot6Test(BaseTest):
|
||||
"aptly snapshot create snap2 from mirror wheezy-main",
|
||||
]
|
||||
runCmd = "aptly snapshot diff snap1 snap2"
|
||||
|
||||
|
||||
class DiffSnapshotArchitectureVariantTest(BaseTest):
|
||||
"""
|
||||
snapshot diff: display base and variant architectures independently
|
||||
"""
|
||||
runCmd = "aptly snapshot diff variant-empty variant-normal"
|
||||
|
||||
def prepare_fixture(self):
|
||||
super().prepare_fixture()
|
||||
self.run_cmd("aptly repo create variant-display")
|
||||
self.run_cmd("aptly snapshot create variant-empty empty")
|
||||
with tempfile.TemporaryDirectory(prefix="aptly-diff-variant-") as tmp:
|
||||
for arch in ("amd64", "amd64v3"):
|
||||
package_dir = Path(tmp) / arch
|
||||
control_dir = package_dir / "DEBIAN"
|
||||
control_dir.mkdir(parents=True)
|
||||
control = (
|
||||
"Package: 3cpio\n"
|
||||
"Version: 0.14.0-1ubuntu1\n"
|
||||
"Architecture: amd64\n"
|
||||
"Maintainer: Aptly Test <test@example.com>\n"
|
||||
"Description: Snapshot diff display fixture\n"
|
||||
)
|
||||
if arch == "amd64v3":
|
||||
control += "Architecture-Variant: amd64v3\n"
|
||||
(control_dir / "control").write_text(control)
|
||||
package_file = str(Path(tmp) / (
|
||||
"3cpio_0.14.0-1ubuntu1_" + arch + ".deb"))
|
||||
self.run_cmd(["dpkg-deb", "--build", str(package_dir), package_file])
|
||||
self.run_cmd(["aptly", "repo", "add", "variant-display", package_file])
|
||||
snapshot = "variant-normal" if arch == "amd64" else "variant-both"
|
||||
self.run_cmd([
|
||||
"aptly", "snapshot", "create", snapshot,
|
||||
"from", "repo", "variant-display",
|
||||
])
|
||||
|
||||
def check(self):
|
||||
def check_row(output, expected):
|
||||
lines = output.strip().splitlines()
|
||||
self.check_equal(len(lines), 2)
|
||||
self.check_equal(" ".join(lines[0].split()),
|
||||
"Arch | Package | Version in A | Version in B")
|
||||
self.check_equal(" ".join(lines[1].split()), expected)
|
||||
|
||||
check_row(self.output, "+ amd64 | 3cpio | - | 0.14.0-1ubuntu1")
|
||||
for left, right, expected in (
|
||||
("variant-normal", "variant-both",
|
||||
"+ amd64v3 | 3cpio | - | 0.14.0-1ubuntu1"),
|
||||
("variant-both", "variant-normal",
|
||||
"- amd64v3 | 3cpio | 0.14.0-1ubuntu1 | -"),
|
||||
("variant-normal", "variant-empty",
|
||||
"- amd64 | 3cpio | 0.14.0-1ubuntu1 | -"),
|
||||
):
|
||||
check_row(self.run_cmd(["aptly", "snapshot", "diff", left, right]), expected)
|
||||
Reference in new issue
Block a user