From 9d62eef571ffd1fd2df8b97884d3689fced27fb1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 7 Jan 2025 17:39:32 +0100 Subject: Implement architecture variants Architecture variants are children of an architecture that share the same ABI but are optimized for different ISA levels. They are available in Ubuntu 25.10 and newer, and not supported in Debian or other distributions. A deb built for a variant contains the Architecture-Variant field, and the Architecture field points to the baseline, for example: Architecture: amd64 Architecture-Variant: amd64v3 However, the apt-get indextargets command reports the variant in the Architecture: field, and most of the code in APT presents the variant as the architecture. There are two types of variants: 1. Standalone variants are recorded in the Architectures field of the Release file as if they were a real architecture: Architectures: amd64 amd64v3 Standalone architecture variants only fetch the standalone architecture variant's Packages file. To do this, this patch changes the code such that the variants indextargets "supplant" the base targets. This may have complicated outcomes on the apt-get indextargets command. 2. Other variants can only be identified by their files being recorded with hashes in the Release file. APT fetches both the base architecture's as well as the variant's Packages file. Variants are configured in the APT::Architecture-Variants list. Image builders may want to build specific variant images using APT::Architecture-Variants { "amd64v3"; } But this commit also implements an automatic discovery mechanism using the varianttable and /proc/cpuinfo. APT::Architecture-Variants "auto"; --- apt-pkg/deb/deblistparser.cc | 6 ++++++ apt-pkg/deb/deblistparser.h | 4 ++++ apt-pkg/deb/debmetaindex.cc | 5 +++++ 3 files changed, 15 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index b62c1a84f..b98198430 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -215,6 +215,9 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver) Ver->NextInSource = G->VersionsInSource; G->VersionsInSource = Ver.MapPointer(); + if (auto ArchVar = Section.Find(pkgTagSection::Key::Architecture_Variant); not ArchVar.empty()) + Ver.ArchVariant(StoreString(pkgCacheGenerator::MIXED, ArchVar)); + Ver->MultiArch = ParseMultiArch(true); // Archive Size Ver->Size = Section.FindULL(pkgTagSection::Key::Size); @@ -1017,6 +1020,9 @@ bool debListParser::SameVersion(uint32_t Hash, /*{{{*/ unsigned char MultiArch = ParseMultiArch(false); if (MultiArch != Ver->MultiArch) return false; + + if (ArchVariant() != Ver.ArchVariant()) + return false; // for all practical proposes (we can check): same version return true; } diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 2a9108775..7ab6800c6 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -99,6 +99,10 @@ class APT_HIDDEN debListParser : public pkgCacheListParser { return Section.Find(pkgTagSection::Key::SHA256); } + std::string_view ArchVariant() const + { + return Section.Find(pkgTagSection::Key::Architecture_Variant); + } #endif }; diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index c040b76b9..b85163654 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -1068,6 +1068,11 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/ auto veryforeign = _config->FindVector("APT::BarbarianArchitectures"); Values.reserve(Values.size() + veryforeign.size()); std::move(veryforeign.begin(), veryforeign.end(), std::back_inserter(Values)); + // Let's treat architecture variants as architectures for sources.list parsing + auto const &variants = APT::Configuration::getArchitectureVariants(true); + Values.reserve(Values.size() + variants.size()); + for (auto const &var : variants) + Values.push_back(var.name); } // all is a very special architecture users shouldn't be concerned with explicitly // but if the user does, do not override the choice -- cgit v1.2.3-70-g09d2