Add "AUR-only" flag for "Prepare build" action

This might be useful to avoid accidentally rebuilding a package with a
local/custom override withiout actually updating the custom PKGBUILD.
This commit is contained in:
Martchus 2024-02-09 23:09:02 +01:00
parent 9150d90233
commit 56ee1325f0
4 changed files with 19 additions and 2 deletions

View File

@ -197,6 +197,12 @@ BuildActionMetaInfo::BuildActionMetaInfo()
.desc = "Uses `makecontainerpkg` instead of using `makepkg` when printing source info; eliminates the need to having pacman on the host by using docker/podman instead",
.param = "use-container",
},
BuildActionFlagMetaInfo{
.id = static_cast<BuildActionFlagType>(PrepareBuildFlags::AurOnly),
.name = "AUR-only",
.desc = "Consider it an error when a PKGBUILD was found locally and thus was not downloaded from the AUR",
.param = "aur-only",
},
},
.settings = {
BuildActionSettingMetaInfo{

View File

@ -88,6 +88,7 @@ enum class PrepareBuildFlags : BuildActionFlagType {
PullingInFurtherDependenciesUnexpected = (1 << 5),
FetchOfficialPackageSources = (1 << 6),
UseContainer = (1 << 7),
AurOnly = (1 << 8),
};
enum class ConductBuildFlags : BuildActionFlagType {
None,

View File

@ -520,6 +520,7 @@ private:
bool m_pulledInFurtherDependencies = false;
bool m_fetchOfficialSources = false;
bool m_useContainer = false;
bool m_aurOnly = false;
};
struct LIBREPOMGR_EXPORT BatchProcessingSession : public MultiSession<std::string> {

View File

@ -78,6 +78,7 @@ void PrepareBuild::run()
m_pullingInFurtherDependenciesUnexpected = flags & PrepareBuildFlags::PullingInFurtherDependenciesUnexpected;
m_fetchOfficialSources = flags & PrepareBuildFlags::FetchOfficialPackageSources;
m_useContainer = flags & PrepareBuildFlags::UseContainer;
m_aurOnly = flags & PrepareBuildFlags::AurOnly;
if (m_forceBumpPackageVersion && m_keepPkgRelAndEpoch) {
reportError("Can not force-bump pkgrel and keeping it at the same time.");
return;
@ -890,14 +891,22 @@ void PrepareBuild::computeDependencies(WebClient::AurSnapshotQuerySession::Conta
}
// check for errors
set<string> failedPackages;
auto failedPackages = std::set<std::string>();
auto localPackages = std::set<std::string>();
auto errorMessage = std::string();
for (const auto &buildData : m_buildDataByPackage) {
if (!buildData.second.error.empty()) {
failedPackages.emplace(buildData.first);
} else if (m_aurOnly && !buildData.second.originalSourceDirectory.empty()) {
localPackages.emplace(buildData.first);
}
}
if (!failedPackages.empty()) {
auto errorMessage = "Unable to retrieve the following packages (see result data for details): " + joinStrings(failedPackages, " ");
errorMessage = "Unable to retrieve the following packages (see result data for details): " + joinStrings(failedPackages, " ");
} else if (!localPackages.empty()) {
errorMessage = "The following packages have a local override but the AUR-only flag was set: " + joinStrings(localPackages, " ");
}
if (!errorMessage.empty()) {
m_buildAction->appendOutput(Phrases::ErrorMessage, errorMessage, '\n');
auto resultData = makeResultData(std::move(errorMessage));
auto buildActionWriteLock = m_setup.building.lockToWrite();