Allow using `makecontainerpkg` in prepare action

This commit is contained in:
Martchus 2023-11-08 15:09:42 +01:00
parent 434e1a8f0c
commit 1a4b9282d2
4 changed files with 17 additions and 2 deletions

View File

@ -178,6 +178,12 @@ BuildActionMetaInfo::BuildActionMetaInfo()
.desc = "Whether PKGBUILDs from official Arch Linux Git repositories should be downloaded (if not present, the AUR will still be checked; local PKGBUILDs still have precedence)",
.param = "fetch-official-pkgbuilds",
},
BuildActionFlagMetaInfo{
.id = static_cast<BuildActionFlagType>(ConductBuildFlags::UseContainer),
.name = "Use container",
.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",
},
},
.settings = {
BuildActionSettingMetaInfo{

View File

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

View File

@ -496,6 +496,7 @@ private:
std::mutex m_mutex;
std::string m_workingDirectory;
boost::filesystem::path m_makePkgPath;
boost::filesystem::path m_makeContainerPkgPath;
std::vector<std::string> m_pkgbuildsDirs;
std::regex m_ignoreLocalPkgbuildsRegex;
std::unordered_map<std::string, PackageBuildData> m_buildDataByPackage;
@ -516,6 +517,7 @@ private:
bool m_pullingInFurtherDependenciesUnexpected = false;
bool m_pulledInFurtherDependencies = false;
bool m_fetchOfficialSources = false;
bool m_useContainer;
};
struct LIBREPOMGR_EXPORT BatchProcessingSession : public MultiSession<std::string> {

View File

@ -77,6 +77,7 @@ void PrepareBuild::run()
m_resetChrootSettings = flags & PrepareBuildFlags::ResetChrootSettings;
m_pullingInFurtherDependenciesUnexpected = flags & PrepareBuildFlags::PullingInFurtherDependenciesUnexpected;
m_fetchOfficialSources = flags & PrepareBuildFlags::FetchOfficialPackageSources;
m_useContainer = flags & PrepareBuildFlags::UseContainer;
if (m_forceBumpPackageVersion && m_keepPkgRelAndEpoch) {
reportError("Can not force-bump pkgrel and keeping it at the same time.");
return;
@ -92,7 +93,11 @@ void PrepareBuild::run()
// read values from global config
auto setupReadLock = m_setup.lockToRead();
m_makePkgPath = findExecutable(m_setup.building.makePkgPath);
if (m_useContainer) {
m_makeContainerPkgPath = findExecutable(m_setup.building.makeContainerPkgPath);
} else {
m_makePkgPath = findExecutable(m_setup.building.makePkgPath);
}
copySecondVectorIntoFirstVector(m_pkgbuildsDirs, m_setup.building.pkgbuildsDirs);
m_ignoreLocalPkgbuildsRegex = m_setup.building.ignoreLocalPkgbuildsRegex;
m_workingDirectory = determineWorkingDirectory(buildDataWorkingDirectory);
@ -316,7 +321,8 @@ void PrepareBuild::makeSrcInfo(
m_setup.building.ioContext, [multiSession, &sourceDirectory, &packageName](boost::process::child &&child, ProcessResult &&result) {
processSrcInfo(*multiSession, sourceDirectory, packageName, std::move(child), std::move(result));
});
processSession->launch(boost::process::start_dir(sourceDirectory), m_makePkgPath.string(), "--printsrcinfo");
processSession->launch(
boost::process::start_dir(sourceDirectory), (m_useContainer ? m_makeContainerPkgPath : m_makePkgPath).string(), "--printsrcinfo");
}
void PrepareBuild::processSrcInfo(WebClient::AurSnapshotQuerySession &multiSession, const std::string &sourceDirectory,