diff --git a/cmd/mirror_list.go b/cmd/mirror_list.go index d3a6daaf..1c554a61 100644 --- a/cmd/mirror_list.go +++ b/cmd/mirror_list.go @@ -1,6 +1,7 @@ package cmd import ( + "encoding/json" "fmt" "sort" @@ -9,12 +10,23 @@ import ( ) func aptlyMirrorList(cmd *commander.Command, args []string) error { - var err error if len(args) != 0 { cmd.Usage() return commander.ErrCommandError } + jsonFlag := cmd.Flag.Lookup("json").Value.Get().(bool) + + if jsonFlag { + return aptlyMirrorListJson(cmd, args) + } + + return aptlyMirrorListTxt(cmd, args) +} + +func aptlyMirrorListTxt(cmd *commander.Command, args []string) error { + var err error + raw := cmd.Flag.Lookup("raw").Value.Get().(bool) repos := make([]string, context.CollectionFactory().RemoteRepoCollection().Len()) @@ -31,7 +43,9 @@ func aptlyMirrorList(cmd *commander.Command, args []string) error { context.CloseDatabase() - sort.Strings(repos) + if len(repos) > 0 { + sort.Strings(repos) + } if raw { for _, repo := range repos { @@ -52,6 +66,32 @@ func aptlyMirrorList(cmd *commander.Command, args []string) error { return err } +func aptlyMirrorListJson(cmd *commander.Command, args []string) error { + var err error + + repos := make([]*deb.RemoteRepo, context.CollectionFactory().RemoteRepoCollection().Len()) + i := 0 + context.CollectionFactory().RemoteRepoCollection().ForEach(func(repo *deb.RemoteRepo) error { + repos[i] = repo + i++ + return nil + }) + + context.CloseDatabase() + + sort.Slice(repos, func(i, j int) bool { + return repos[i].Name < repos[j].Name + }) + + if output, e := json.MarshalIndent(repos, "", " "); e == nil { + fmt.Println(string(output)) + } else { + err = e + } + + return err +} + func makeCmdMirrorList() *commander.Command { cmd := &commander.Command{ Run: aptlyMirrorList, @@ -66,6 +106,7 @@ Example: `, } + cmd.Flag.Bool("json", false, "display list in JSON format") cmd.Flag.Bool("raw", false, "display list in machine-readable format") return cmd diff --git a/cmd/mirror_show.go b/cmd/mirror_show.go index 31b2b636..a1b466a7 100644 --- a/cmd/mirror_show.go +++ b/cmd/mirror_show.go @@ -1,7 +1,9 @@ package cmd import ( + "encoding/json" "fmt" + "sort" "strings" "github.com/aptly-dev/aptly/deb" @@ -11,12 +13,23 @@ import ( ) func aptlyMirrorShow(cmd *commander.Command, args []string) error { - var err error if len(args) != 1 { cmd.Usage() return commander.ErrCommandError } + jsonFlag := cmd.Flag.Lookup("json").Value.Get().(bool) + + if jsonFlag { + return aptlyMirrorShowJson(cmd, args) + } + + return aptlyMirrorShowTxt(cmd, args) +} + +func aptlyMirrorShowTxt(cmd *commander.Command, args []string) error { + var err error + name := args[0] repo, err := context.CollectionFactory().RemoteRepoCollection().ByName(name) @@ -79,6 +92,94 @@ func aptlyMirrorShow(cmd *commander.Command, args []string) error { return err } +func aptlyMirrorShowJson(cmd *commander.Command, args []string) error { + var err error + + name := args[0] + + withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool) + + repo, err := context.CollectionFactory().RemoteRepoCollection().ByName(name) + if err != nil { + return fmt.Errorf("unable to show: %s", err) + } + + err = context.CollectionFactory().RemoteRepoCollection().LoadComplete(repo) + if err != nil { + return fmt.Errorf("unable to show: %s", err) + } + + // fmt.Printf("Name: %s\n", repo.Name) + // if repo.Status == deb.MirrorUpdating { + // fmt.Printf("Status: In Update (PID %d)\n", repo.WorkerPID) + // } + // fmt.Printf("Archive Root URL: %s\n", repo.ArchiveRoot) + // fmt.Printf("Distribution: %s\n", repo.Distribution) + // fmt.Printf("Components: %s\n", strings.Join(repo.Components, ", ")) + // fmt.Printf("Architectures: %s\n", strings.Join(repo.Architectures, ", ")) + // downloadSources := No + // if repo.DownloadSources { + // downloadSources = Yes + // } + // fmt.Printf("Download Sources: %s\n", downloadSources) + // downloadUdebs := No + // if repo.DownloadUdebs { + // downloadUdebs = Yes + // } + // fmt.Printf("Download .udebs: %s\n", downloadUdebs) + // if repo.Filter != "" { + // fmt.Printf("Filter: %s\n", repo.Filter) + // filterWithDeps := No + // if repo.FilterWithDeps { + // filterWithDeps = Yes + // } + // fmt.Printf("Filter With Deps: %s\n", filterWithDeps) + // } + // if repo.LastDownloadDate.IsZero() { + // fmt.Printf("Last update: never\n") + // } else { + // fmt.Printf("Last update: %s\n", repo.LastDownloadDate.Format("2006-01-02 15:04:05 MST")) + // fmt.Printf("Number of packages: %d\n", repo.NumPackages()) + // } + + // fmt.Printf("\nInformation from release file:\n") + // for _, k := range utils.StrMapSortedKeys(repo.Meta) { + // fmt.Printf("%s: %s\n", k, repo.Meta[k]) + // } + + // if withPackages { + // if repo.LastDownloadDate.IsZero() { + // fmt.Printf("Unable to show package list, mirror hasn't been downloaded yet.\n") + // } else { + // ListPackagesRefList(repo.RefList()) + // } + // } + + // include packages if requested + if withPackages { + if repo.RefList() != nil { + var list *deb.PackageList + list, err = deb.NewPackageListFromRefList(repo.RefList(), context.CollectionFactory().PackageCollection(), context.Progress()) + + list.PrepareIndex() + list.ForEachIndexed(func(p *deb.Package) error { + repo.Packages = append(repo.Packages, p.GetFullName()) + return nil + }) + + sort.Strings(repo.Packages) + } + } + + // merge the repo object with the package list + var output []byte + if output, err = json.MarshalIndent(repo, "", " "); err == nil { + fmt.Println(string(output)) + } + + return err +} + func makeCmdMirrorShow() *commander.Command { cmd := &commander.Command{ Run: aptlyMirrorShow, @@ -94,6 +195,7 @@ Example: Flag: *flag.NewFlagSet("aptly-mirror-show", flag.ExitOnError), } + cmd.Flag.Bool("json", false, "display record in JSON format") cmd.Flag.Bool("with-packages", false, "show detailed list of packages and versions stored in the mirror") return cmd diff --git a/cmd/snapshot_show.go b/cmd/snapshot_show.go index 45c134a3..d2a7a8ba 100644 --- a/cmd/snapshot_show.go +++ b/cmd/snapshot_show.go @@ -125,7 +125,6 @@ func aptlySnapshotShowJson(cmd *commander.Command, args []string) error { if err != nil { continue } - source.ReleaseFiles = nil // do not include the release file info snapshot.RemoteRepos = append(snapshot.RemoteRepos, source) } } diff --git a/deb/package.go b/deb/package.go index a32b7265..ce16adf2 100644 --- a/deb/package.go +++ b/deb/package.go @@ -52,10 +52,10 @@ const ( PackageTypeInstaller = "installer" ) -// Special arhictectures +// Special architectures const ( ArchitectureAll = "all" - ArhictectureAny = "any" + ArchitectureAny = "any" ArchitectureSource = "source" ) diff --git a/deb/remote.go b/deb/remote.go index 775ec871..d34b384d 100644 --- a/deb/remote.go +++ b/deb/remote.go @@ -52,7 +52,7 @@ type RemoteRepo struct { // Last update date LastDownloadDate time.Time // Checksums for release files - ReleaseFiles map[string]utils.ChecksumInfo + ReleaseFiles map[string]utils.ChecksumInfo `json:"-"` // exclude from json output // Filter for packages Filter string // Status marks state of repository (being updated, no action) @@ -71,6 +71,8 @@ type RemoteRepo struct { DownloadUdebs bool // Should we download installer files? DownloadInstaller bool + // Packages for json output + Packages []string `codec:"-" json:",omitempty"` // "Snapshot" of current list of packages packageRefs *PackageRefList // Parsed archived root diff --git a/system/t04_mirror/ListMirror5Test_gold b/system/t04_mirror/ListMirror5Test_gold new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/system/t04_mirror/ListMirror5Test_gold @@ -0,0 +1 @@ +[] diff --git a/system/t04_mirror/ListMirror6Test_gold b/system/t04_mirror/ListMirror6Test_gold new file mode 100644 index 00000000..cf8b565e --- /dev/null +++ b/system/t04_mirror/ListMirror6Test_gold @@ -0,0 +1,150 @@ +[ + { + "Name": "mirror1", + "ArchiveRoot": "http://cdn-fastly.deb.debian.org/debian/", + "Distribution": "stretch", + "Components": [ + "main", + "contrib", + "non-free" + ], + "Architectures": [ + "amd64", + "arm64", + "armel", + "armhf", + "i386", + "mips", + "mips64el", + "mipsel", + "ppc64el", + "s390x" + ], + "Meta": { + "Acquire-By-Hash": "yes", + "Architectures": "amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x", + "Changelogs": "http://metadata.ftp-master.debian.org/changelogs/@CHANGEPATH@_changelog", + "Codename": "stretch", + "Components": "main contrib non-free", + "Date": "Sat, 14 Aug 2021 07:42:00 UTC", + "Description": " Debian 9.13 Released 18 July 2020\n", + "Label": "Debian", + "Origin": "Debian", + "Suite": "oldoldstable", + "Version": "9.13" + }, + "LastDownloadDate": "0001-01-01T00:00:00Z", + "Filter": "", + "Status": 0, + "WorkerPID": 0, + "FilterWithDeps": false, + "SkipComponentCheck": false, + "SkipArchitectureCheck": false, + "DownloadSources": false, + "DownloadUdebs": false, + "DownloadInstaller": false + }, + { + "Name": "mirror2", + "ArchiveRoot": "http://cdn-fastly.deb.debian.org/debian/", + "Distribution": "stretch", + "Components": [ + "contrib" + ], + "Architectures": [ + "amd64", + "arm64", + "armel", + "armhf", + "i386", + "mips", + "mips64el", + "mipsel", + "ppc64el", + "s390x" + ], + "Meta": { + "Acquire-By-Hash": "yes", + "Architectures": "amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x", + "Changelogs": "http://metadata.ftp-master.debian.org/changelogs/@CHANGEPATH@_changelog", + "Codename": "stretch", + "Components": "main contrib non-free", + "Date": "Sat, 14 Aug 2021 07:42:00 UTC", + "Description": " Debian 9.13 Released 18 July 2020\n", + "Label": "Debian", + "Origin": "Debian", + "Suite": "oldoldstable", + "Version": "9.13" + }, + "LastDownloadDate": "0001-01-01T00:00:00Z", + "Filter": "", + "Status": 0, + "WorkerPID": 0, + "FilterWithDeps": false, + "SkipComponentCheck": false, + "SkipArchitectureCheck": false, + "DownloadSources": true, + "DownloadUdebs": false, + "DownloadInstaller": false + }, + { + "Name": "mirror3", + "ArchiveRoot": "http://cdn-fastly.deb.debian.org/debian/", + "Distribution": "stretch", + "Components": [ + "non-free" + ], + "Architectures": [ + "i386" + ], + "Meta": { + "Acquire-By-Hash": "yes", + "Architectures": "amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x", + "Changelogs": "http://metadata.ftp-master.debian.org/changelogs/@CHANGEPATH@_changelog", + "Codename": "stretch", + "Components": "main contrib non-free", + "Date": "Sat, 14 Aug 2021 07:42:00 UTC", + "Description": " Debian 9.13 Released 18 July 2020\n", + "Label": "Debian", + "Origin": "Debian", + "Suite": "oldoldstable", + "Version": "9.13" + }, + "LastDownloadDate": "0001-01-01T00:00:00Z", + "Filter": "", + "Status": 0, + "WorkerPID": 0, + "FilterWithDeps": false, + "SkipComponentCheck": false, + "SkipArchitectureCheck": false, + "DownloadSources": false, + "DownloadUdebs": false, + "DownloadInstaller": false + }, + { + "Name": "mirror4", + "ArchiveRoot": "http://download.opensuse.org/repositories/Apache:/MirrorBrain/Debian_9.0/", + "Distribution": "./", + "Components": null, + "Architectures": null, + "Meta": { + "Architectures": "i386 amd64", + "Archive": "Debian_9.0", + "Codename": "Debian_9.0", + "Date": "Thu Jan 14 15:16:28 2021", + "Description": " MirrorBrain (Debian_9.0)\n", + "Label": "Apache:MirrorBrain", + "Origin": "obs://build.opensuse.org/Apache:MirrorBrain/Debian_9.0" + }, + "LastDownloadDate": "0001-01-01T00:00:00Z", + "Filter": "", + "Status": 0, + "WorkerPID": 0, + "FilterWithDeps": false, + "SkipComponentCheck": false, + "SkipArchitectureCheck": false, + "DownloadSources": false, + "DownloadUdebs": false, + "DownloadInstaller": false + } +] diff --git a/system/t04_mirror/ShowMirror1Test_gold b/system/t04_mirror/ShowMirror1Test_gold index cd554eac..44e12aec 100644 --- a/system/t04_mirror/ShowMirror1Test_gold +++ b/system/t04_mirror/ShowMirror1Test_gold @@ -13,10 +13,10 @@ Architectures: amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x Changelogs: http://metadata.ftp-master.debian.org/changelogs/@CHANGEPATH@_changelog Codename: stretch Components: main contrib non-free -Date: Sat, 18 Jul 2020 10:50:51 UTC +Date: Sat, 14 Aug 2021 07:42:00 UTC Description: Debian 9.13 Released 18 July 2020 Label: Debian Origin: Debian -Suite: oldstable +Suite: oldoldstable Version: 9.13 diff --git a/system/t04_mirror/ShowMirror4Test_gold b/system/t04_mirror/ShowMirror4Test_gold index 471bec70..c531b649 100644 --- a/system/t04_mirror/ShowMirror4Test_gold +++ b/system/t04_mirror/ShowMirror4Test_gold @@ -18,5 +18,5 @@ Description: Debian 9 Security Updates Label: Debian-Security Origin: Debian -Suite: oldstable +Suite: oldoldstable Version: 9 diff --git a/system/t04_mirror/ShowMirror5Test_gold b/system/t04_mirror/ShowMirror5Test_gold new file mode 100644 index 00000000..5e5aaa63 --- /dev/null +++ b/system/t04_mirror/ShowMirror5Test_gold @@ -0,0 +1,46 @@ +{ + "UUID": "82ca6517-ab0b-4be9-81bd-e884a07167f2", + "Name": "mirror1", + "ArchiveRoot": "http://cdn-fastly.deb.debian.org/debian/", + "Distribution": "stretch", + "Components": [ + "main", + "contrib", + "non-free" + ], + "Architectures": [ + "amd64", + "arm64", + "armel", + "armhf", + "i386", + "mips", + "mips64el", + "mipsel", + "ppc64el", + "s390x" + ], + "Meta": { + "Acquire-By-Hash": "yes", + "Architectures": "amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x", + "Changelogs": "http://metadata.ftp-master.debian.org/changelogs/@CHANGEPATH@_changelog", + "Codename": "stretch", + "Components": "main contrib non-free", + "Date": "Sat, 14 Aug 2021 07:42:00 UTC", + "Description": " Debian 9.13 Released 18 July 2020\n", + "Label": "Debian", + "Origin": "Debian", + "Suite": "oldoldstable", + "Version": "9.13" + }, + "LastDownloadDate": "0001-01-01T00:00:00Z", + "Filter": "", + "Status": 0, + "WorkerPID": 0, + "FilterWithDeps": false, + "SkipComponentCheck": false, + "SkipArchitectureCheck": false, + "DownloadSources": false, + "DownloadUdebs": false, + "DownloadInstaller": false +} diff --git a/system/t04_mirror/ShowMirror6Test_gold b/system/t04_mirror/ShowMirror6Test_gold new file mode 100644 index 00000000..5b1f2811 --- /dev/null +++ b/system/t04_mirror/ShowMirror6Test_gold @@ -0,0 +1 @@ +ERROR: unable to show: mirror with name mirror-xx not found diff --git a/system/t04_mirror/ShowMirror7Test_gold b/system/t04_mirror/ShowMirror7Test_gold new file mode 100644 index 00000000..d454a959 --- /dev/null +++ b/system/t04_mirror/ShowMirror7Test_gold @@ -0,0 +1,361 @@ +{ + "UUID": "2ee0f8e4-5884-4eba-8987-cfe02c01630d", + "Name": "wheezy-contrib", + "ArchiveRoot": "http://mirror.yandex.ru/debian/", + "Distribution": "wheezy", + "Components": [ + "contrib" + ], + "Architectures": [ + "i386", + "amd64" + ], + "Meta": { + "Architectures": "amd64 armel armhf i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc", + "Codename": "wheezy", + "Components": "main contrib non-free", + "Date": "Sat, 26 Apr 2014 09:27:11 UTC", + "Description": " Debian 7.5 Released 26 April 2014\n", + "Label": "Debian", + "Origin": "Debian", + "Suite": "stable", + "Version": "7.5" + }, + "LastDownloadDate": "2014-06-28T01:23:26.097358548+04:00", + "Filter": "", + "Status": 0, + "WorkerPID": 0, + "FilterWithDeps": false, + "SkipComponentCheck": false, + "SkipArchitectureCheck": false, + "DownloadSources": false, + "DownloadUdebs": false, + "DownloadInstaller": false, + "Packages": [ + "alien-arena-server_7.53+dfsg-3_amd64", + "alien-arena-server_7.53+dfsg-3_i386", + "alien-arena_7.53+dfsg-3_amd64", + "alien-arena_7.53+dfsg-3_i386", + "alsa-firmware-loaders_1.0.25-2_amd64", + "alsa-firmware-loaders_1.0.25-2_i386", + "amoeba_1.1-26_amd64", + "amoeba_1.1-26_i386", + "assaultcube_1.1.0.4+dfsg2-1_amd64", + "assaultcube_1.1.0.4+dfsg2-1_i386", + "atari800_2.2.1-2_amd64", + "atari800_2.2.1-2_i386", + "b43-fwcutter_1:015-14.1_amd64", + "b43-fwcutter_1:015-14.1_i386", + "basilisk2_0.9.20120331-2_amd64", + "basilisk2_0.9.20120331-2_i386", + "bgoffice-dict-downloader_0.09_all", + "biomaj-watcher_1.2.1-1_all", + "boinc-nvidia-cuda_7.0.27+dfsg-5_amd64", + "boinc-nvidia-cuda_7.0.27+dfsg-5_i386", + "cbedic_4.0-3_amd64", + "cbedic_4.0-3_i386", + "chocolate-doom_1.7.0-3+b1_amd64", + "chocolate-doom_1.7.0-3_i386", + "cicero_0.7.2-2_all", + "cl-sql-oracle_6.2.0-1_all", + "cl-umlisp-orf_3.3.2-3_all", + "cl-umlisp_1:2007ac.2-6_all", + "cltl_1.0.26_all", + "conky-all_1.9.0-2_amd64", + "conky-all_1.9.0-2_i386", + "cpp-doc_5:4_amd64", + "cpp-doc_5:4_i386", + "crafty-bitmaps_1.0-1_all", + "crafty-books-medium_1.0.debian1-2_all", + "crafty-books-medtosmall_1.0.debian1-2_all", + "crafty-books-small_1.0.debian1-2_all", + "cytadela-data_1.0.1-2_all", + "cytadela-dbg_1.0.1-2_amd64", + "cytadela-dbg_1.0.1-2_i386", + "cytadela_1.0.1-2_amd64", + "cytadela_1.0.1-2_i386", + "dosemu_1.4.0+svn.2080-1_amd64", + "dosemu_1.4.0+svn.2080-1_i386", + "dynagen_0.11.0-6_all", + "dynare-matlab_4.3.0-2_all", + "e-uae-dbg_0.8.29-WIP4-10_amd64", + "e-uae-dbg_0.8.29-WIP4-10_i386", + "e-uae_0.8.29-WIP4-10_amd64", + "e-uae_0.8.29-WIP4-10_i386", + "easyspice_0.6.8-2_amd64", + "easyspice_0.6.8-2_i386", + "esix_1-2_all", + "exult-studio_1.2-15.2_amd64", + "exult-studio_1.2-15.2_i386", + "exult_1.2-15.2_amd64", + "exult_1.2-15.2_i386", + "festvox-don_1.4.0-4_all", + "festvox-en1_1.95-1_all", + "festvox-rablpc16k_1.4.0-2_all", + "festvox-rablpc8k_1.4.0-2_all", + "festvox-us1_1.95-1_all", + "festvox-us2_1.95-1_all", + "festvox-us3_1.95-1_all", + "firmware-b43-installer_1:015-14.1_all", + "firmware-b43-lpphy-installer_1:015-14.1_all", + "firmware-b43legacy-installer_1:015-14.1_all", + "flashplugin-nonfree-extrasound_0.0.svn2431-3_i386", + "flashplugin-nonfree_1:3.2_amd64", + "flashplugin-nonfree_1:3.2_i386", + "frogatto_1.2+dfsg-1+b1_amd64", + "frogatto_1.2+dfsg-1_i386", + "game-data-packager_30_all", + "gcc-doc_5:4_amd64", + "gcc-doc_5:4_i386", + "gcj-doc_5:4_amd64", + "gcj-doc_5:4_i386", + "geoip-database-contrib_1.8_all", + "gfortran-doc_5:4_amd64", + "gfortran-doc_5:4_i386", + "glx-alternative-fglrx_0.2.2_amd64", + "glx-alternative-fglrx_0.2.2_i386", + "glx-alternative-mesa_0.2.2_amd64", + "glx-alternative-mesa_0.2.2_i386", + "glx-alternative-nvidia_0.2.2_amd64", + "glx-alternative-nvidia_0.2.2_i386", + "glx-diversions_0.2.2_amd64", + "glx-diversions_0.2.2_i386", + "gnat-doc_5:4_amd64", + "gnat-doc_5:4_i386", + "gnome-speech-dectalk_1:0.4.25-5_i386", + "gnome-speech-ibmtts_1:0.4.25-5_i386", + "gnome-speech-swift_1:0.4.25-5_amd64", + "gnome-speech-swift_1:0.4.25-5_i386", + "gnome-video-arcade_0.8.3-1_amd64", + "gnome-video-arcade_0.8.3-1_i386", + "gns3_0.7.4-1_all", + "gnuboy-sdl_1.0.3-6.1_amd64", + "gnuboy-sdl_1.0.3-6.1_i386", + "gnuboy-svga_1.0.3-6.1_amd64", + "gnuboy-svga_1.0.3-6.1_i386", + "gnuboy-x_1.0.3-6.1_amd64", + "gnuboy-x_1.0.3-6.1_i386", + "gnuvd-gnome_1.0.11-1_all", + "gnuvd_1.0.11-1_amd64", + "gnuvd_1.0.11-1_i386", + "gobi-loader_0.6-1_amd64", + "gobi-loader_0.6-1_i386", + "googleearth-package_0.7.0_all", + "gtktrain_0.9b-13_amd64", + "gtktrain_0.9b-13_i386", + "hannah-foo2zjs_1:1_amd64", + "hannah-foo2zjs_1:1_i386", + "horae_071~svn536-1_all", + "hts-voice-nitech-jp-atr503-m001_1.04-1_all", + "hyperspec_1.30+nmu2_all", + "ifeffit-doc_2:1.2.11d-8_all", + "ifeffit_2:1.2.11d-8_amd64", + "ifeffit_2:1.2.11d-8_i386", + "imgtex_0.20050123-8_all", + "isdnactivecards_1:3.9.20060704-11_amd64", + "isdnactivecards_1:3.9.20060704-11_i386", + "isight-firmware-tools_1.6-1_amd64", + "isight-firmware-tools_1.6-1_i386", + "iucode-tool_0.8.3-1_amd64", + "iucode-tool_0.8.3-1_i386", + "ivtv-utils_1.4.1-2_amd64", + "ivtv-utils_1.4.1-2_i386", + "java-package_0.50+nmu2_all", + "kcemu-common_0.5.1+dfsg-5_all", + "kcemu_0.5.1+dfsg-5_amd64", + "kcemu_0.5.1+dfsg-5_i386", + "libcplgasgano20_6.1.1-2_amd64", + "libcplgasgano20_6.1.1-2_i386", + "libdbd-oracle-perl_1.44-1_amd64", + "libdbd-oracle-perl_1.44-1_i386", + "libgooglecharts-ruby1.8_1.6.8-2_all", + "libgooglecharts-ruby_1.6.8-2_all", + "libifeffit-perl_2:1.2.11d-8_amd64", + "libifeffit-perl_2:1.2.11d-8_i386", + "libjlapack-java_0.8~dfsg-1_all", + "libmtj-java-doc_0.9.14~dfsg-2_all", + "libmtj-java_0.9.14~dfsg-2_all", + "libnetlib-java_0.9.3-1_all", + "libpgplot-perl_1:2.21-3_amd64", + "libpgplot-perl_1:2.21-3_i386", + "libsocl-contrib-1.0_1.0.1+dfsg-1_amd64", + "libsocl-contrib-1.0_1.0.1+dfsg-1_i386", + "libstarpu-contrib-1.0_1.0.1+dfsg-1_amd64", + "libstarpu-contrib-1.0_1.0.1+dfsg-1_i386", + "libstarpu-contrib-dev_1.0.1+dfsg-1_amd64", + "libstarpu-contrib-dev_1.0.1+dfsg-1_i386", + "libstarpu-contribfft-1.0_1.0.1+dfsg-1_amd64", + "libstarpu-contribfft-1.0_1.0.1+dfsg-1_i386", + "libstarpu-contribmpi-1.0_1.0.1+dfsg-1_amd64", + "libstarpu-contribmpi-1.0_1.0.1+dfsg-1_i386", + "libsuitesparse-metis-3.1.0_3.1.0-2_amd64", + "libsuitesparse-metis-3.1.0_3.1.0-2_i386", + "libsuitesparse-metis-dbg_3.1.0-2_amd64", + "libsuitesparse-metis-dbg_3.1.0-2_i386", + "libsuitesparse-metis-dev_3.1.0-2_amd64", + "libsuitesparse-metis-dev_3.1.0-2_i386", + "libtrain-bin_0.9b-11_amd64", + "libtrain-bin_0.9b-11_i386", + "libtrain-dev_0.9b-11_amd64", + "libtrain-dev_0.9b-11_i386", + "libtrain1_0.9b-11_amd64", + "libtrain1_0.9b-11_i386", + "libviennacl-dev_1.2.0-2_all", + "libviennacl-doc_1.2.0-2_all", + "libxnvctrl-dev_304.88-1_amd64", + "libxnvctrl-dev_304.88-1_i386", + "libxnvctrl0_304.88-1_amd64", + "libxnvctrl0_304.88-1_i386", + "libydpdict2-dev_1.0.2-1_amd64", + "libydpdict2-dev_1.0.2-1_i386", + "libydpdict2_1.0.2-1_amd64", + "libydpdict2_1.0.2-1_i386", + "linux-wlan-ng-firmware_0.2.9+dfsg-5_all", + "lugaru_0~20110520.1+hge4354+dfsg-3_amd64", + "lugaru_0~20110520.1+hge4354+dfsg-3_i386", + "mathematica-fonts_16_all", + "matlab-gdf_0.1.2-2_all", + "matlab-support_0.0.18_all", + "mess-desktop-entries_0.2-2_all", + "microcode.ctl_1.18~0+nmu2_amd64", + "microcode.ctl_1.18~0+nmu2_i386", + "netdisco-mibs-installer_1.7.1_all", + "nvidia-installer-cleanup_20120630+3_amd64", + "nvidia-installer-cleanup_20120630+3_i386", + "nvidia-kernel-common_20120630+3_amd64", + "nvidia-kernel-common_20120630+3_i386", + "nvidia-settings-legacy-173xx_173.14.35-2_amd64", + "nvidia-settings-legacy-173xx_173.14.35-2_i386", + "nvidia-settings_304.88-1_amd64", + "nvidia-settings_304.88-1_i386", + "nvidia-support_20120630+3_amd64", + "nvidia-support_20120630+3_i386", + "nvidia-xconfig_304.48-1_amd64", + "nvidia-xconfig_304.48-1_i386", + "opendict-plugins-lingvosoft_0.8-2_all", + "ora2pg_8.11-1_all", + "phoronix-test-suite_3.8.0-1_all", + "pidgin-skype-dbg_20110407+svn628+dfsg-1_amd64", + "pidgin-skype-dbg_20110407+svn628+dfsg-1_i386", + "pidgin-skype_20110407+svn628+dfsg-1_amd64", + "pidgin-skype_20110407+svn628+dfsg-1_i386", + "playonlinux_4.1.1-1_all", + "premail_0.46-9_all", + "prism2-usb-firmware-installer_0.2.9+dfsg-5_amd64", + "prism2-usb-firmware-installer_0.2.9+dfsg-5_i386", + "pvpgn_1.8.1-2.1+b1_amd64", + "pvpgn_1.8.1-2.1+b1_i386", + "python-ifeffit_2:1.2.11d-8_amd64", + "python-ifeffit_2:1.2.11d-8_i386", + "python-ldap-doc_2.3-2.2_all", + "python-pycuda-doc_2012.1-1_all", + "python-pycuda-headers_2012.1-1_all", + "python-pycuda_2012.1-1_amd64", + "python-pycuda_2012.1-1_i386", + "python-pyopencl-doc_2012.1.dfsg-1_all", + "python-pyopencl-headers_2012.1.dfsg-1_all", + "python-pyopencl_2012.1.dfsg-1_amd64", + "python-pyopencl_2012.1.dfsg-1_i386", + "python3-pyopencl_2012.1.dfsg-1_amd64", + "python3-pyopencl_2012.1.dfsg-1_i386", + "q-tools_0.4-1_i386", + "qmhandle_1.3.2-1_all", + "quake-server_2_all", + "quake3-server_1.4_all", + "quake3_1.4_all", + "quake_2_all", + "r-cran-surveillance_1.2-1-3_amd64", + "r-cran-surveillance_1.2-1-3_i386", + "raccoon_1.0-1_all", + "redeclipse-dbg_1.2-3_amd64", + "redeclipse-dbg_1.2-3_i386", + "redeclipse-server-dbg_1.2-3_amd64", + "redeclipse-server-dbg_1.2-3_i386", + "redeclipse-server_1.2-3_amd64", + "redeclipse-server_1.2-3_i386", + "redeclipse_1.2-3_amd64", + "redeclipse_1.2-3_i386", + "reminiscence_0.2.1-1_amd64", + "reminiscence_0.2.1-1_i386", + "rocksndiamonds_3.3.0.1+dfsg1-2.2_amd64", + "rocksndiamonds_3.3.0.1+dfsg1-2.2_i386", + "rott_1.1.2-1_amd64", + "rott_1.1.2-1_i386", + "ruby-googlecharts_1.6.8-2_all", + "ruby-pgplot-dbg_0.1.3-6_amd64", + "ruby-pgplot_0.1.3-6_amd64", + "sabnzbdplus-theme-classic_0.6.15-1_all", + "sabnzbdplus-theme-iphone_0.6.15-1_all", + "sabnzbdplus-theme-mobile_0.6.15-1_all", + "sabnzbdplus-theme-plush_0.6.15-1_all", + "sabnzbdplus-theme-smpl_0.6.15-1_all", + "sabnzbdplus_0.6.15-1_all", + "sandboxgamemaker_2.7.1+dfsg-2_amd64", + "sandboxgamemaker_2.7.1+dfsg-2_i386", + "sapgui-package_0.0.10_all", + "sauerbraten-dbg_0.0.20100728.dfsg+repack-3_amd64", + "sauerbraten-dbg_0.0.20100728.dfsg+repack-3_i386", + "sauerbraten-server_0.0.20100728.dfsg+repack-3_amd64", + "sauerbraten-server_0.0.20100728.dfsg+repack-3_i386", + "sauerbraten-wake6_1.0-1.1_all", + "sauerbraten_0.0.20100728.dfsg+repack-3_amd64", + "sauerbraten_0.0.20100728.dfsg+repack-3_i386", + "sdic-edict_2.1.3-22_all", + "sdic-eijiro_2.1.3-22_all", + "sdic-gene95_2.1.3-22_all", + "sdic_2.1.3-22_all", + "series60-remote_0.4.0+dfsg.1-1_all", + "sixpack_1:0.68-1_all", + "spectemu-common_0.94a-15_amd64", + "spectemu-common_0.94a-15_i386", + "spectemu-svga_0.94a-15_amd64", + "spectemu-svga_0.94a-15_i386", + "spectemu-x11_0.94a-15_amd64", + "spectemu-x11_0.94a-15_i386", + "sqldeveloper-package_0.2.4_all", + "starpu-contrib-examples_1.0.1+dfsg-1_amd64", + "starpu-contrib-examples_1.0.1+dfsg-1_i386", + "starpu-contrib-tools_1.0.1+dfsg-1_amd64", + "starpu-contrib-tools_1.0.1+dfsg-1_i386", + "sugar-etoys-activity_116-3_all", + "susv2_1.1_all", + "susv3_6.1_all", + "tightvnc-java_1.2.7-8_all", + "ttf-mathematica4.1_16_all", + "ttf-mscorefonts-installer_3.4+nmu1_all", + "ttf-root-installer_5.34.00-2_all", + "uae-dbg_0.8.29-7_amd64", + "uae-dbg_0.8.29-7_i386", + "uae_0.8.29-7_amd64", + "uae_0.8.29-7_i386", + "uqm-russian_1.0.2-5_all", + "uqm_0.6.2.dfsg-9_amd64", + "uqm_0.6.2.dfsg-9_i386", + "vice_2.3.dfsg-4_amd64", + "vice_2.3.dfsg-4_i386", + "vmware-manager_0.2.0-3_all", + "vmware-view-open-client_4.5.0-297975+dfsg-4+b1_amd64", + "vmware-view-open-client_4.5.0-297975+dfsg-4+b1_i386", + "vnc-java_3.3.3r2-8_all", + "vor_0.5.5-2_amd64", + "vor_0.5.5-2_i386", + "vusb-analyzer_1.1-3_all", + "wdq2wav_0.8.3-2_amd64", + "wdq2wav_0.8.3-2_i386", + "winetricks_0.0+20121030+svn918-1_all", + "wnn7egg_1.02-8_all", + "wolf4sdl_1.7+svn262+dfsg1-1_amd64", + "wolf4sdl_1.7+svn262+dfsg1-1_i386", + "x-pgp-sig-el_1.3.5.1-4.1_all", + "xserver-xorg-video-ivtv-dbg_1.1.2-1+b3_amd64", + "xserver-xorg-video-ivtv-dbg_1.1.2-1+b3_i386", + "xserver-xorg-video-ivtv_1.1.2-1+b3_amd64", + "xserver-xorg-video-ivtv_1.1.2-1+b3_i386", + "xtrs_4.9c-3.4_amd64", + "xtrs_4.9c-3.4_i386", + "xvba-va-driver_0.8.0-5_amd64", + "xvba-va-driver_0.8.0-5_i386", + "ydpdict_1.0.0-2_amd64", + "ydpdict_1.0.0-2_i386" + ] +} diff --git a/system/t04_mirror/ShowMirror8Test_gold b/system/t04_mirror/ShowMirror8Test_gold new file mode 100644 index 00000000..0a27c32d --- /dev/null +++ b/system/t04_mirror/ShowMirror8Test_gold @@ -0,0 +1,39 @@ +{ + "UUID": "548dbdb6-75d6-42ac-80de-d6aff8012f83", + "Name": "mirror4", + "ArchiveRoot": "http://security.debian.org/", + "Distribution": "stretch/updates", + "Components": [ + "main" + ], + "Architectures": [ + "amd64", + "arm64", + "armel", + "armhf", + "i386" + ], + "Meta": { + "Acquire-By-Hash": "yes", + "Architectures": "amd64 arm64 armel armhf i386", + "Codename": "stretch", + "Components": "updates/main updates/contrib updates/non-free", + "Date": "Tue, 21 Sep 2021 13:02:10 UTC", + "Description": " Debian 9 Security Updates\n", + "Label": "Debian-Security", + "Origin": "Debian", + "Suite": "oldoldstable", + "Valid-Until": "Fri, 01 Oct 2021 13:02:10 UTC", + "Version": "9" + }, + "LastDownloadDate": "0001-01-01T00:00:00Z", + "Filter": "nginx | Priority (required)", + "Status": 0, + "WorkerPID": 0, + "FilterWithDeps": true, + "SkipComponentCheck": false, + "SkipArchitectureCheck": false, + "DownloadSources": false, + "DownloadUdebs": false, + "DownloadInstaller": false +} diff --git a/system/t04_mirror/list.py b/system/t04_mirror/list.py index 75697972..7b02e288 100644 --- a/system/t04_mirror/list.py +++ b/system/t04_mirror/list.py @@ -1,4 +1,5 @@ from lib import BaseTest +import re class ListMirror1Test(BaseTest): @@ -34,3 +35,26 @@ class ListMirror4Test(BaseTest): list mirrors: raw empty list """ runCmd = "aptly -raw mirror list" + + +class ListMirror5Test(BaseTest): + """ + list mirrors: json empty list + """ + runCmd = "aptly mirror list -json" + + +class ListMirror6Test(BaseTest): + """ + list mirrors: regular list + """ + fixtureCmds = [ + "aptly mirror create --ignore-signatures mirror1 http://cdn-fastly.deb.debian.org/debian/ stretch", + "aptly mirror create -with-sources --ignore-signatures mirror2 http://cdn-fastly.deb.debian.org/debian/ stretch contrib", + "aptly -architectures=i386 mirror create --ignore-signatures mirror3 http://cdn-fastly.deb.debian.org/debian/ stretch non-free", + "aptly mirror create -ignore-signatures mirror4 http://download.opensuse.org/repositories/Apache:/MirrorBrain/Debian_9.0/ ./", + ] + runCmd = "aptly mirror list -json" + + def outputMatchPrepare(_, s): + return re.sub(r'[ ]*"UUID": "[\w-]+",?\n', '', s) diff --git a/system/t04_mirror/show.py b/system/t04_mirror/show.py index 34aa3404..21325c36 100644 --- a/system/t04_mirror/show.py +++ b/system/t04_mirror/show.py @@ -40,3 +40,43 @@ class ShowMirror4Test(BaseTest): def outputMatchPrepare(self, s): return re.sub(r"(Date|Valid-Until): [,0-9:+A-Za-z -]+\n", "", s) + + +class ShowMirror5Test(BaseTest): + """ + show mirror: regular mirror + """ + fixtureCmds = ["aptly mirror create --ignore-signatures mirror1 http://cdn-fastly.deb.debian.org/debian/ stretch"] + runCmd = "aptly mirror show -json mirror1" + + def outputMatchPrepare(_, s): + return re.sub(r'[ ]*"UUID": "[\w-]+",?\n', '', s) + + +class ShowMirror6Test(BaseTest): + """ + show mirror: missing mirror + """ + runCmd = "aptly mirror show -json mirror-xx" + expectedCode = 1 + + +class ShowMirror7Test(BaseTest): + """ + show mirror: regular mirror with packages + """ + fixtureDB = True + runCmd = "aptly mirror show -json --with-packages wheezy-contrib" + + +class ShowMirror8Test(BaseTest): + """ + show mirror: mirror with filter + """ + fixtureCmds = [ + "aptly mirror create -ignore-signatures -filter='nginx | Priority (required)' -filter-with-deps=true mirror4 http://security.debian.org/ stretch/updates main" + ] + runCmd = "aptly mirror show -json mirror4" + + def outputMatchPrepare(self, s): + return re.sub(r'[ ]*"UUID": "[\w-]+",?\n', '', s) diff --git a/system/t05_snapshot/ShowSnapshot4Test_gold b/system/t05_snapshot/ShowSnapshot4Test_gold index 7336941b..11ea4f87 100644 --- a/system/t05_snapshot/ShowSnapshot4Test_gold +++ b/system/t05_snapshot/ShowSnapshot4Test_gold @@ -26,7 +26,6 @@ "Version": "7.5" }, "LastDownloadDate": "2014-06-28T01:23:26.597799094+04:00", - "ReleaseFiles": null, "Filter": "", "Status": 0, "WorkerPID": 0, diff --git a/system/t05_snapshot/ShowSnapshot5Test_gold b/system/t05_snapshot/ShowSnapshot5Test_gold index f886b112..6d6a42c4 100644 --- a/system/t05_snapshot/ShowSnapshot5Test_gold +++ b/system/t05_snapshot/ShowSnapshot5Test_gold @@ -28,7 +28,6 @@ "Version": "10.10" }, "LastDownloadDate": "2014-06-28T01:24:09.760026156+04:00", - "ReleaseFiles": null, "Filter": "", "Status": 0, "WorkerPID": 0,