cmake/Source/CPack/cmCPackDebGenerator.cxx

918 lines
32 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackDebGenerator.h"
2021-09-14 00:13:48 +02:00
#include <cstdlib>
2020-02-01 23:06:01 +01:00
#include <cstring>
#include <map>
#include <ostream>
#include <set>
#include <utility>
#include "cmsys/Glob.hxx"
#include "cm_sys_stat.h"
2015-11-17 17:22:37 +01:00
#include "cmArchiveWrite.h"
2016-10-30 18:24:19 +01:00
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
2016-07-09 11:21:54 +02:00
#include "cmCPackLog.h"
2018-01-26 17:06:56 +01:00
#include "cmCryptoHash.h"
2016-07-09 11:21:54 +02:00
#include "cmGeneratedFileStream.h"
2020-02-01 23:06:01 +01:00
#include "cmStringAlgorithms.h"
2016-07-09 11:21:54 +02:00
#include "cmSystemTools.h"
2018-10-28 12:09:07 +01:00
namespace {
class DebGenerator
{
public:
2019-11-11 23:01:05 +01:00
DebGenerator(cmCPackLog* logger, std::string outputName, std::string workDir,
std::string topLevelDir, std::string temporaryDir,
2021-09-14 00:13:48 +02:00
const char* debianCompressionType, const char* numThreads,
2018-10-28 12:09:07 +01:00
const char* debianArchiveType,
2019-11-11 23:01:05 +01:00
std::map<std::string, std::string> controlValues,
bool genShLibs, std::string shLibsFilename, bool genPostInst,
std::string postInst, bool genPostRm, std::string postRm,
const char* controlExtra, bool permissionStrctPolicy,
std::vector<std::string> packageFiles);
2018-10-28 12:09:07 +01:00
bool generate() const;
private:
void generateDebianBinaryFile() const;
void generateControlFile() const;
bool generateDataTar() const;
std::string generateMD5File() const;
bool generateControlTar(std::string const& md5Filename) const;
bool generateDeb() const;
cmCPackLog* Logger;
const std::string OutputName;
const std::string WorkDir;
std::string CompressionSuffix;
const std::string TopLevelDir;
const std::string TemporaryDir;
const char* DebianArchiveType;
2021-09-14 00:13:48 +02:00
int NumThreads;
2018-10-28 12:09:07 +01:00
const std::map<std::string, std::string> ControlValues;
const bool GenShLibs;
const std::string ShLibsFilename;
const bool GenPostInst;
const std::string PostInst;
const bool GenPostRm;
const std::string PostRm;
const char* ControlExtra;
const bool PermissionStrictPolicy;
const std::vector<std::string> PackageFiles;
cmArchiveWrite::Compress TarCompressionType;
};
DebGenerator::DebGenerator(
2019-11-11 23:01:05 +01:00
cmCPackLog* logger, std::string outputName, std::string workDir,
std::string topLevelDir, std::string temporaryDir,
2021-09-14 00:13:48 +02:00
const char* debianCompressionType, const char* numThreads,
const char* debianArchiveType,
2019-11-11 23:01:05 +01:00
std::map<std::string, std::string> controlValues, bool genShLibs,
std::string shLibsFilename, bool genPostInst, std::string postInst,
bool genPostRm, std::string postRm, const char* controlExtra,
bool permissionStrictPolicy, std::vector<std::string> packageFiles)
2018-10-28 12:09:07 +01:00
: Logger(logger)
2019-11-11 23:01:05 +01:00
, OutputName(std::move(outputName))
, WorkDir(std::move(workDir))
, TopLevelDir(std::move(topLevelDir))
, TemporaryDir(std::move(temporaryDir))
, DebianArchiveType(debianArchiveType ? debianArchiveType : "gnutar")
, ControlValues(std::move(controlValues))
2018-10-28 12:09:07 +01:00
, GenShLibs(genShLibs)
2019-11-11 23:01:05 +01:00
, ShLibsFilename(std::move(shLibsFilename))
2018-10-28 12:09:07 +01:00
, GenPostInst(genPostInst)
2019-11-11 23:01:05 +01:00
, PostInst(std::move(postInst))
2018-10-28 12:09:07 +01:00
, GenPostRm(genPostRm)
2019-11-11 23:01:05 +01:00
, PostRm(std::move(postRm))
2018-10-28 12:09:07 +01:00
, ControlExtra(controlExtra)
, PermissionStrictPolicy(permissionStrictPolicy)
2019-11-11 23:01:05 +01:00
, PackageFiles(std::move(packageFiles))
2018-10-28 12:09:07 +01:00
{
if (!debianCompressionType) {
debianCompressionType = "gzip";
}
if (!strcmp(debianCompressionType, "lzma")) {
2021-09-14 00:13:48 +02:00
this->CompressionSuffix = ".lzma";
this->TarCompressionType = cmArchiveWrite::CompressLZMA;
2018-10-28 12:09:07 +01:00
} else if (!strcmp(debianCompressionType, "xz")) {
2021-09-14 00:13:48 +02:00
this->CompressionSuffix = ".xz";
this->TarCompressionType = cmArchiveWrite::CompressXZ;
2018-10-28 12:09:07 +01:00
} else if (!strcmp(debianCompressionType, "bzip2")) {
2021-09-14 00:13:48 +02:00
this->CompressionSuffix = ".bz2";
this->TarCompressionType = cmArchiveWrite::CompressBZip2;
2018-10-28 12:09:07 +01:00
} else if (!strcmp(debianCompressionType, "gzip")) {
2021-09-14 00:13:48 +02:00
this->CompressionSuffix = ".gz";
this->TarCompressionType = cmArchiveWrite::CompressGZip;
2018-10-28 12:09:07 +01:00
} else if (!strcmp(debianCompressionType, "none")) {
2021-09-14 00:13:48 +02:00
this->CompressionSuffix.clear();
this->TarCompressionType = cmArchiveWrite::CompressNone;
2018-10-28 12:09:07 +01:00
} else {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error unrecognized compression type: "
<< debianCompressionType << std::endl);
}
2021-09-14 00:13:48 +02:00
if (numThreads == nullptr) {
numThreads = "1";
}
char* endptr;
this->NumThreads = static_cast<int>(strtol(numThreads, &endptr, 10));
if (numThreads != endptr && *endptr != '\0') {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Unrecognized number of threads: " << numThreads
<< std::endl);
}
2018-10-28 12:09:07 +01:00
}
bool DebGenerator::generate() const
{
2021-09-14 00:13:48 +02:00
this->generateDebianBinaryFile();
this->generateControlFile();
if (!this->generateDataTar()) {
2018-10-28 12:09:07 +01:00
return false;
}
2021-09-14 00:13:48 +02:00
std::string md5Filename = this->generateMD5File();
if (!this->generateControlTar(md5Filename)) {
2018-10-28 12:09:07 +01:00
return false;
}
2021-09-14 00:13:48 +02:00
return this->generateDeb();
2018-10-28 12:09:07 +01:00
}
void DebGenerator::generateDebianBinaryFile() const
{
// debian-binary file
2021-09-14 00:13:48 +02:00
const std::string dbfilename = this->WorkDir + "/debian-binary";
2020-08-30 11:54:41 +02:00
cmGeneratedFileStream out;
out.Open(dbfilename, false, true);
out << "2.0\n"; // required for valid debian package
2018-10-28 12:09:07 +01:00
}
void DebGenerator::generateControlFile() const
{
2021-09-14 00:13:48 +02:00
std::string ctlfilename = this->WorkDir + "/control";
2018-10-28 12:09:07 +01:00
2020-08-30 11:54:41 +02:00
cmGeneratedFileStream out;
out.Open(ctlfilename, false, true);
2021-09-14 00:13:48 +02:00
for (auto const& kv : this->ControlValues) {
2018-10-28 12:09:07 +01:00
out << kv.first << ": " << kv.second << "\n";
}
unsigned long totalSize = 0;
{
2021-09-14 00:13:48 +02:00
for (std::string const& file : this->PackageFiles) {
2018-10-28 12:09:07 +01:00
totalSize += cmSystemTools::FileLength(file);
}
}
2020-08-30 11:54:41 +02:00
out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n\n";
2018-10-28 12:09:07 +01:00
}
bool DebGenerator::generateDataTar() const
{
2021-09-14 00:13:48 +02:00
std::string filename_data_tar =
this->WorkDir + "/data.tar" + this->CompressionSuffix;
2018-10-28 12:09:07 +01:00
cmGeneratedFileStream fileStream_data_tar;
fileStream_data_tar.Open(filename_data_tar, false, true);
if (!fileStream_data_tar) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error opening the file \""
<< filename_data_tar << "\" for writing" << std::endl);
return false;
}
2021-09-14 00:13:48 +02:00
cmArchiveWrite data_tar(fileStream_data_tar, this->TarCompressionType,
this->DebianArchiveType, 0, this->NumThreads);
2020-08-30 11:54:41 +02:00
data_tar.Open();
2018-10-28 12:09:07 +01:00
// uid/gid should be the one of the root user, and this root user has
// always uid/gid equal to 0.
data_tar.SetUIDAndGID(0u, 0u);
data_tar.SetUNAMEAndGNAME("root", "root");
// now add all directories which have to be compressed
// collect all top level install dirs for that
// e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would
// give /usr and /opt
2021-09-14 00:13:48 +02:00
size_t topLevelLength = this->WorkDir.length();
2018-10-28 12:09:07 +01:00
cmCPackLogger(cmCPackLog::LOG_DEBUG,
2021-09-14 00:13:48 +02:00
"WDIR: \"" << this->WorkDir
<< "\", length = " << topLevelLength << std::endl);
2018-10-28 12:09:07 +01:00
std::set<std::string> orderedFiles;
// we have to reconstruct the parent folders as well
2021-09-14 00:13:48 +02:00
for (std::string currentPath : this->PackageFiles) {
while (currentPath != this->WorkDir) {
2018-10-28 12:09:07 +01:00
// the last one IS WorkDir, but we do not want this one:
// XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application
// should not add XXX/application
orderedFiles.insert(currentPath);
2019-11-11 23:01:05 +01:00
currentPath = cmSystemTools::CollapseFullPath("..", currentPath);
2018-10-28 12:09:07 +01:00
}
}
for (std::string const& file : orderedFiles) {
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"FILEIT: \"" << file << "\"" << std::endl);
std::string::size_type slashPos = file.find('/', topLevelLength + 1);
std::string relativeDir =
file.substr(topLevelLength, slashPos - topLevelLength);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"RELATIVEDIR: \"" << relativeDir << "\"" << std::endl);
#ifdef WIN32
std::string mode_t_adt_filename = file + ":cmake_mode_t";
cmsys::ifstream permissionStream(mode_t_adt_filename.c_str());
mode_t permissions = 0;
if (permissionStream) {
permissionStream >> std::oct >> permissions;
}
if (permissions != 0) {
data_tar.SetPermissions(permissions);
} else if (cmSystemTools::FileIsDirectory(file)) {
data_tar.SetPermissions(0755);
} else {
data_tar.ClearPermissions();
}
#endif
// do not recurse because the loop will do it
if (!data_tar.Add(file, topLevelLength, ".", false)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem adding file to tar:"
<< std::endl
2021-09-14 00:13:48 +02:00
<< "#top level directory: " << this->WorkDir << std::endl
2018-10-28 12:09:07 +01:00
<< "#file: " << file << std::endl
<< "#error:" << data_tar.GetError() << std::endl);
return false;
}
}
return true;
}
std::string DebGenerator::generateMD5File() const
{
2021-09-14 00:13:48 +02:00
std::string md5filename = this->WorkDir + "/md5sums";
2018-10-28 12:09:07 +01:00
2020-08-30 11:54:41 +02:00
cmGeneratedFileStream out;
out.Open(md5filename, false, true);
2018-10-28 12:09:07 +01:00
2021-09-14 00:13:48 +02:00
std::string topLevelWithTrailingSlash = cmStrCat(this->TemporaryDir, '/');
for (std::string const& file : this->PackageFiles) {
2018-10-28 12:09:07 +01:00
// hash only regular files
if (cmSystemTools::FileIsDirectory(file) ||
cmSystemTools::FileIsSymlink(file)) {
continue;
}
std::string output =
cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5);
if (output.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem computing the md5 of " << file << std::endl);
}
output += " " + file + "\n";
// debian md5sums entries are like this:
// 014f3604694729f3bf19263bac599765 usr/bin/ccmake
// thus strip the full path (with the trailing slash)
cmSystemTools::ReplaceString(output, topLevelWithTrailingSlash.c_str(),
"");
out << output;
}
// each line contains a eol.
// Do not end the md5sum file with yet another (invalid)
return md5filename;
}
bool DebGenerator::generateControlTar(std::string const& md5Filename) const
{
2021-09-14 00:13:48 +02:00
std::string filename_control_tar = this->WorkDir + "/control.tar.gz";
2018-10-28 12:09:07 +01:00
cmGeneratedFileStream fileStream_control_tar;
fileStream_control_tar.Open(filename_control_tar, false, true);
if (!fileStream_control_tar) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error opening the file \""
<< filename_control_tar << "\" for writing" << std::endl);
return false;
}
cmArchiveWrite control_tar(fileStream_control_tar,
2021-09-14 00:13:48 +02:00
cmArchiveWrite::CompressGZip,
this->DebianArchiveType);
2020-08-30 11:54:41 +02:00
control_tar.Open();
2018-10-28 12:09:07 +01:00
// sets permissions and uid/gid for the files
control_tar.SetUIDAndGID(0u, 0u);
control_tar.SetUNAMEAndGNAME("root", "root");
/* permissions are set according to
https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
and
https://lintian.debian.org/tags/control-file-has-bad-permissions.html
*/
const mode_t permission644 = 0644;
const mode_t permissionExecute = 0111;
const mode_t permission755 = permission644 | permissionExecute;
// for md5sum and control (that we have generated here), we use 644
// (RW-R--R--)
// so that deb lintian doesn't warn about it
control_tar.SetPermissions(permission644);
// adds control and md5sums
2021-09-14 00:13:48 +02:00
if (!control_tar.Add(md5Filename, this->WorkDir.length(), ".") ||
!control_tar.Add(this->WorkDir + "/control", this->WorkDir.length(),
".")) {
2018-10-28 12:09:07 +01:00
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error adding file to tar:"
<< std::endl
2021-09-14 00:13:48 +02:00
<< "#top level directory: " << this->WorkDir << std::endl
2018-10-28 12:09:07 +01:00
<< "#file: \"control\" or \"md5sums\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl);
return false;
}
// adds generated shlibs file
2021-09-14 00:13:48 +02:00
if (this->GenShLibs) {
if (!control_tar.Add(this->ShLibsFilename, this->WorkDir.length(), ".")) {
2018-10-28 12:09:07 +01:00
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error adding file to tar:"
<< std::endl
2021-09-14 00:13:48 +02:00
<< "#top level directory: " << this->WorkDir << std::endl
2018-10-28 12:09:07 +01:00
<< "#file: \"shlibs\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl);
return false;
}
}
// adds LDCONFIG related files
2021-09-14 00:13:48 +02:00
if (this->GenPostInst) {
2018-10-28 12:09:07 +01:00
control_tar.SetPermissions(permission755);
2021-09-14 00:13:48 +02:00
if (!control_tar.Add(this->PostInst, this->WorkDir.length(), ".")) {
2018-10-28 12:09:07 +01:00
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error adding file to tar:"
<< std::endl
2021-09-14 00:13:48 +02:00
<< "#top level directory: " << this->WorkDir << std::endl
2018-10-28 12:09:07 +01:00
<< "#file: \"postinst\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl);
return false;
}
control_tar.SetPermissions(permission644);
}
2021-09-14 00:13:48 +02:00
if (this->GenPostRm) {
2018-10-28 12:09:07 +01:00
control_tar.SetPermissions(permission755);
2021-09-14 00:13:48 +02:00
if (!control_tar.Add(this->PostRm, this->WorkDir.length(), ".")) {
2018-10-28 12:09:07 +01:00
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error adding file to tar:"
<< std::endl
2021-09-14 00:13:48 +02:00
<< "#top level directory: " << this->WorkDir << std::endl
2018-10-28 12:09:07 +01:00
<< "#file: \"postinst\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl);
return false;
}
control_tar.SetPermissions(permission644);
}
// for the other files, we use
// -either the original permission on the files
// -either a permission strictly defined by the Debian policies
2021-09-14 00:13:48 +02:00
if (this->ControlExtra) {
2018-10-28 12:09:07 +01:00
// permissions are now controlled by the original file permissions
static const char* strictFiles[] = { "config", "postinst", "postrm",
"preinst", "prerm" };
std::set<std::string> setStrictFiles(
strictFiles, strictFiles + sizeof(strictFiles) / sizeof(strictFiles[0]));
// default
control_tar.ClearPermissions();
2021-09-14 00:13:48 +02:00
std::vector<std::string> controlExtraList =
cmExpandedList(this->ControlExtra);
2018-10-28 12:09:07 +01:00
for (std::string const& i : controlExtraList) {
std::string filenamename = cmsys::SystemTools::GetFilenameName(i);
2021-09-14 00:13:48 +02:00
std::string localcopy = this->WorkDir + "/" + filenamename;
2018-10-28 12:09:07 +01:00
2021-09-14 00:13:48 +02:00
if (this->PermissionStrictPolicy) {
2018-10-28 12:09:07 +01:00
control_tar.SetPermissions(
setStrictFiles.count(filenamename) ? permission755 : permission644);
}
// if we can copy the file, it means it does exist, let's add it:
2021-09-14 00:13:48 +02:00
if (!cmsys::SystemTools::FileExists(i)) {
cmCPackLogger(cmCPackLog::LOG_WARNING,
"Adding file to tar:" << std::endl
<< "#top level directory: "
<< this->WorkDir << std::endl
<< "#missing file: " << i
<< std::endl);
}
2018-10-28 12:09:07 +01:00
if (cmsys::SystemTools::CopyFileIfDifferent(i, localcopy)) {
2021-09-14 00:13:48 +02:00
control_tar.Add(localcopy, this->WorkDir.length(), ".");
2018-10-28 12:09:07 +01:00
}
}
}
return true;
}
bool DebGenerator::generateDeb() const
{
// ar -r your-package-name.deb debian-binary control.tar.* data.tar.*
// A debian package .deb is simply an 'ar' archive. The only subtle
// difference is that debian uses the BSD ar style archive whereas most
// Linux distro have a GNU ar.
// See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info
2021-09-14 00:13:48 +02:00
std::string const outputPath = this->TopLevelDir + "/" + this->OutputName;
std::string const tlDir = this->WorkDir + "/";
2018-10-28 12:09:07 +01:00
cmGeneratedFileStream debStream;
debStream.Open(outputPath, false, true);
cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd");
2020-08-30 11:54:41 +02:00
deb.Open();
2018-10-28 12:09:07 +01:00
// uid/gid should be the one of the root user, and this root user has
// always uid/gid equal to 0.
deb.SetUIDAndGID(0u, 0u);
deb.SetUNAMEAndGNAME("root", "root");
if (!deb.Add(tlDir + "debian-binary", tlDir.length()) ||
!deb.Add(tlDir + "control.tar.gz", tlDir.length()) ||
2021-09-14 00:13:48 +02:00
!deb.Add(tlDir + "data.tar" + this->CompressionSuffix, tlDir.length())) {
2018-10-28 12:09:07 +01:00
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error creating debian package:"
<< std::endl
2021-09-14 00:13:48 +02:00
<< "#top level directory: " << this->TopLevelDir
<< std::endl
<< "#file: " << this->OutputName << std::endl
2018-10-28 12:09:07 +01:00
<< "#error:" << deb.GetError() << std::endl);
return false;
}
return true;
}
} // end anonymous namespace
2019-11-11 23:01:05 +01:00
cmCPackDebGenerator::cmCPackDebGenerator() = default;
2019-11-11 23:01:05 +01:00
cmCPackDebGenerator::~cmCPackDebGenerator() = default;
int cmCPackDebGenerator::InitializeInternal()
{
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
2020-02-01 23:06:01 +01:00
if (cmIsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
2010-11-13 01:00:53 +02:00
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
2016-07-09 11:21:54 +02:00
}
return this->Superclass::InitializeInternal();
}
2016-07-09 11:21:54 +02:00
int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel,
std::string const& packageName)
{
2011-06-19 15:41:06 +03:00
int retval = 1;
// Begin the archive for this pack
std::string localToplevel(initialTopLevel);
2021-09-14 00:13:48 +02:00
std::string packageFileName(
cmSystemTools::GetParentDirectory(this->toplevel));
2016-10-30 18:24:19 +01:00
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + "-" +
packageName + this->GetOutputExtension());
2016-07-09 11:21:54 +02:00
localToplevel += "/" + packageName;
2011-06-19 15:41:06 +03:00
/* replace the TEMP DIRECTORY with the component one */
2016-07-09 11:21:54 +02:00
this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
packageFileName += "/" + outputFileName;
2011-06-19 15:41:06 +03:00
/* replace proposed CPACK_OUTPUT_FILE_NAME */
2016-07-09 11:21:54 +02:00
this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
2011-06-19 15:41:06 +03:00
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
2016-07-09 11:21:54 +02:00
packageFileName.c_str());
2011-06-19 15:41:06 +03:00
// Tell CPackDeb.cmake the name of the component GROUP.
2016-07-09 11:21:54 +02:00
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT", packageName.c_str());
2013-03-16 19:13:01 +02:00
// Tell CPackDeb.cmake the path where the component is.
2020-02-01 23:06:01 +01:00
std::string component_path = cmStrCat('/', packageName);
2013-03-16 19:13:01 +02:00
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
2018-10-28 12:09:07 +01:00
if (!this->ReadListFile("Internal/CPack/CPackDeb.cmake")) {
2018-08-09 18:06:22 +02:00
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while execution CPackDeb.cmake" << std::endl);
2011-06-19 15:41:06 +03:00
retval = 0;
return retval;
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
2018-10-28 12:09:07 +01:00
{ // Isolate globbing of binaries vs. dbgsyms
cmsys::Glob gl;
std::string findExpr(this->GetOption("GEN_WDIR"));
findExpr += "/*";
gl.RecurseOn();
gl.SetRecurseListDirs(true);
2020-08-30 11:54:41 +02:00
gl.SetRecurseThroughSymlinks(false);
2018-10-28 12:09:07 +01:00
if (!gl.FindFiles(findExpr)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find any files in the installed directory"
<< std::endl);
return 0;
}
2021-09-14 00:13:48 +02:00
this->packageFiles = gl.GetFiles();
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
2021-09-14 00:13:48 +02:00
int res = this->createDeb();
2016-07-09 11:21:54 +02:00
if (res != 1) {
2011-06-19 15:41:06 +03:00
retval = 0;
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
// add the generated package to package file names list
2020-02-01 23:06:01 +01:00
packageFileName = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"));
2021-09-14 00:13:48 +02:00
this->packageFileNames.push_back(std::move(packageFileName));
2018-10-28 12:09:07 +01:00
2021-09-14 00:13:48 +02:00
if (this->IsOn("GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE") &&
this->GetOption("GEN_DBGSYMDIR")) {
2018-10-28 12:09:07 +01:00
cmsys::Glob gl;
std::string findExpr(this->GetOption("GEN_DBGSYMDIR"));
findExpr += "/*";
gl.RecurseOn();
gl.SetRecurseListDirs(true);
2020-08-30 11:54:41 +02:00
gl.SetRecurseThroughSymlinks(false);
2018-10-28 12:09:07 +01:00
if (!gl.FindFiles(findExpr)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find any files in the installed directory"
<< std::endl);
return 0;
}
2021-09-14 00:13:48 +02:00
this->packageFiles = gl.GetFiles();
2018-10-28 12:09:07 +01:00
2021-09-14 00:13:48 +02:00
res = this->createDbgsymDDeb();
2018-10-28 12:09:07 +01:00
if (res != 1) {
retval = 0;
}
// add the generated package to package file names list
2020-02-01 23:06:01 +01:00
packageFileName =
cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME"));
2021-09-14 00:13:48 +02:00
this->packageFileNames.push_back(std::move(packageFileName));
2018-10-28 12:09:07 +01:00
}
2011-06-19 15:41:06 +03:00
return retval;
}
int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
{
int retval = 1;
/* Reset package file name list it will be populated during the
* component packaging run*/
2021-09-14 00:13:48 +02:00
this->packageFileNames.clear();
2011-06-19 15:41:06 +03:00
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
2016-07-09 11:21:54 +02:00
if (!ignoreGroup) {
2018-01-26 17:06:56 +01:00
for (auto const& compG : this->ComponentGroups) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging component group: " << compG.first << std::endl);
2011-06-19 15:41:06 +03:00
// Begin the archive for this group
2021-09-14 00:13:48 +02:00
retval &= this->PackageOnePack(initialTopLevel, compG.first);
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
// Handle Orphan components (components not belonging to any groups)
2018-01-26 17:06:56 +01:00
for (auto const& comp : this->Components) {
2011-06-19 15:41:06 +03:00
// Does the component belong to a group?
2018-01-26 17:06:56 +01:00
if (comp.second.Group == nullptr) {
2016-07-09 11:21:54 +02:00
cmCPackLogger(
2018-08-09 18:06:22 +02:00
cmCPackLog::LOG_VERBOSE,
"Component <"
2018-01-26 17:06:56 +01:00
<< comp.second.Name
2011-06-19 15:41:06 +03:00
<< "> does not belong to any group, package it separately."
<< std::endl);
// Begin the archive for this orphan component
2021-09-14 00:13:48 +02:00
retval &= this->PackageOnePack(initialTopLevel, comp.first);
2011-06-19 15:41:06 +03:00
}
}
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
2016-07-09 11:21:54 +02:00
else {
2018-01-26 17:06:56 +01:00
for (auto const& comp : this->Components) {
2021-09-14 00:13:48 +02:00
retval &= this->PackageOnePack(initialTopLevel, comp.first);
2011-06-19 15:41:06 +03:00
}
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
return retval;
}
//----------------------------------------------------------------------
2016-07-09 11:21:54 +02:00
int cmCPackDebGenerator::PackageComponentsAllInOne(
const std::string& compInstDirName)
2011-06-19 15:41:06 +03:00
{
int retval = 1;
/* Reset package file name list it will be populated during the
* component packaging run*/
2021-09-14 00:13:48 +02:00
this->packageFileNames.clear();
2011-06-19 15:41:06 +03:00
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
2016-07-09 11:21:54 +02:00
<< std::endl);
2011-06-19 15:41:06 +03:00
// The ALL GROUPS in ONE package case
std::string localToplevel(initialTopLevel);
2021-09-14 00:13:48 +02:00
std::string packageFileName(
cmSystemTools::GetParentDirectory(this->toplevel));
2016-10-30 18:24:19 +01:00
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
this->GetOutputExtension());
2011-06-19 15:41:06 +03:00
// all GROUP in one vs all COMPONENT in one
2017-04-14 19:02:05 +02:00
// if must be here otherwise non component paths have a trailing / while
// components don't
if (!compInstDirName.empty()) {
localToplevel += "/" + compInstDirName;
}
2011-06-19 15:41:06 +03:00
/* replace the TEMP DIRECTORY with the component one */
2016-07-09 11:21:54 +02:00
this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
packageFileName += "/" + outputFileName;
2011-06-19 15:41:06 +03:00
/* replace proposed CPACK_OUTPUT_FILE_NAME */
2016-07-09 11:21:54 +02:00
this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
2011-06-19 15:41:06 +03:00
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
2016-07-09 11:21:54 +02:00
packageFileName.c_str());
if (!compInstDirName.empty()) {
// Tell CPackDeb.cmake the path where the component is.
2020-02-01 23:06:01 +01:00
std::string component_path = cmStrCat('/', compInstDirName);
2016-07-09 11:21:54 +02:00
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
}
2018-10-28 12:09:07 +01:00
if (!this->ReadListFile("Internal/CPack/CPackDeb.cmake")) {
2018-08-09 18:06:22 +02:00
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while execution CPackDeb.cmake" << std::endl);
2011-06-19 15:41:06 +03:00
retval = 0;
return retval;
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
cmsys::Glob gl;
2015-08-17 11:37:30 +02:00
std::string findExpr(this->GetOption("GEN_WDIR"));
2011-06-19 15:41:06 +03:00
findExpr += "/*";
gl.RecurseOn();
2015-11-17 17:22:37 +01:00
gl.SetRecurseListDirs(true);
2020-08-30 11:54:41 +02:00
gl.SetRecurseThroughSymlinks(false);
2016-07-09 11:21:54 +02:00
if (!gl.FindFiles(findExpr)) {
2011-06-19 15:41:06 +03:00
cmCPackLogger(cmCPackLog::LOG_ERROR,
2016-07-09 11:21:54 +02:00
"Cannot find any files in the installed directory"
<< std::endl);
2011-06-19 15:41:06 +03:00
return 0;
2016-07-09 11:21:54 +02:00
}
2021-09-14 00:13:48 +02:00
this->packageFiles = gl.GetFiles();
2011-06-19 15:41:06 +03:00
2021-09-14 00:13:48 +02:00
int res = this->createDeb();
2016-07-09 11:21:54 +02:00
if (res != 1) {
2011-06-19 15:41:06 +03:00
retval = 0;
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
// add the generated package to package file names list
2020-02-01 23:06:01 +01:00
packageFileName = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"));
2021-09-14 00:13:48 +02:00
this->packageFileNames.push_back(std::move(packageFileName));
2011-06-19 15:41:06 +03:00
return retval;
}
2010-11-13 01:00:53 +02:00
int cmCPackDebGenerator::PackageFiles()
{
2011-06-19 15:41:06 +03:00
/* Are we in the component packaging case */
2021-09-14 00:13:48 +02:00
if (this->WantsComponentInstallation()) {
2011-06-19 15:41:06 +03:00
// CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL GROUPS or ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here.
2021-09-14 00:13:48 +02:00
if (this->componentPackageMethod == ONE_PACKAGE) {
return this->PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group
// however one may require to ignore component group and
// in this case you'll get 1 package for each component.
2021-09-14 00:13:48 +02:00
return this->PackageComponents(this->componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
2011-06-19 15:41:06 +03:00
}
// CASE 3 : NON COMPONENT package.
2021-09-14 00:13:48 +02:00
return this->PackageComponentsAllInOne("");
2011-06-19 15:41:06 +03:00
}
int cmCPackDebGenerator::createDeb()
{
2018-10-28 12:09:07 +01:00
std::map<std::string, std::string> controlValues;
// debian policy enforce lower case for package name
2018-10-28 12:09:07 +01:00
controlValues["Package"] = cmsys::SystemTools::LowerCase(
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"));
2018-10-28 12:09:07 +01:00
controlValues["Version"] =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
2018-10-28 12:09:07 +01:00
controlValues["Section"] =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION");
2018-10-28 12:09:07 +01:00
controlValues["Priority"] =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY");
2018-10-28 12:09:07 +01:00
controlValues["Architecture"] =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
2018-10-28 12:09:07 +01:00
controlValues["Maintainer"] =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
2018-10-28 12:09:07 +01:00
controlValues["Description"] =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
2018-10-28 12:09:07 +01:00
const char* debian_pkg_source =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_source)) {
2018-10-28 12:09:07 +01:00
controlValues["Source"] = debian_pkg_source;
}
2015-08-17 11:37:30 +02:00
const char* debian_pkg_dep =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_dep)) {
2018-10-28 12:09:07 +01:00
controlValues["Depends"] = debian_pkg_dep;
}
2010-11-13 01:00:53 +02:00
const char* debian_pkg_rec =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_rec)) {
2018-10-28 12:09:07 +01:00
controlValues["Recommends"] = debian_pkg_rec;
}
2010-11-13 01:00:53 +02:00
const char* debian_pkg_sug =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_sug)) {
2018-10-28 12:09:07 +01:00
controlValues["Suggests"] = debian_pkg_sug;
}
2010-11-13 01:00:53 +02:00
const char* debian_pkg_url =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_url)) {
2018-10-28 12:09:07 +01:00
controlValues["Homepage"] = debian_pkg_url;
}
2010-11-13 01:00:53 +02:00
const char* debian_pkg_predep =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_predep)) {
2018-10-28 12:09:07 +01:00
controlValues["Pre-Depends"] = debian_pkg_predep;
}
2010-11-13 01:00:53 +02:00
const char* debian_pkg_enhances =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_enhances)) {
2018-10-28 12:09:07 +01:00
controlValues["Enhances"] = debian_pkg_enhances;
}
2010-11-13 01:00:53 +02:00
const char* debian_pkg_breaks =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_breaks)) {
2018-10-28 12:09:07 +01:00
controlValues["Breaks"] = debian_pkg_breaks;
}
2010-11-13 01:00:53 +02:00
const char* debian_pkg_conflicts =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_conflicts)) {
2018-10-28 12:09:07 +01:00
controlValues["Conflicts"] = debian_pkg_conflicts;
}
2010-11-13 01:00:53 +02:00
const char* debian_pkg_provides =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_provides)) {
2018-10-28 12:09:07 +01:00
controlValues["Provides"] = debian_pkg_provides;
}
2010-11-13 01:00:53 +02:00
const char* debian_pkg_replaces =
2016-07-09 11:21:54 +02:00
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_replaces)) {
2018-10-28 12:09:07 +01:00
controlValues["Replaces"] = debian_pkg_replaces;
2016-07-09 11:21:54 +02:00
}
2018-10-28 12:09:07 +01:00
const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
2016-07-09 11:21:54 +02:00
const std::string shlibsfilename = strGenWDIR + "/shlibs";
const char* debian_pkg_shlibs =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SHLIBS");
const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") &&
2021-09-14 00:13:48 +02:00
cmNonempty(debian_pkg_shlibs);
2016-07-09 11:21:54 +02:00
if (gen_shibs) {
2020-08-30 11:54:41 +02:00
cmGeneratedFileStream out;
out.Open(shlibsfilename, false, true);
2016-07-09 11:21:54 +02:00
out << debian_pkg_shlibs;
2020-08-30 11:54:41 +02:00
out << '\n';
2016-07-09 11:21:54 +02:00
}
const std::string postinst = strGenWDIR + "/postinst";
const std::string postrm = strGenWDIR + "/postrm";
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
2020-08-30 11:54:41 +02:00
cmGeneratedFileStream out;
out.Open(postinst, false, true);
2016-07-09 11:21:54 +02:00
out << "#!/bin/sh\n\n"
"set -e\n\n"
"if [ \"$1\" = \"configure\" ]; then\n"
"\tldconfig\n"
"fi\n";
}
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
2020-08-30 11:54:41 +02:00
cmGeneratedFileStream out;
out.Open(postrm, false, true);
2016-07-09 11:21:54 +02:00
out << "#!/bin/sh\n\n"
"set -e\n\n"
"if [ \"$1\" = \"remove\" ]; then\n"
"\tldconfig\n"
"fi\n";
}
2015-04-27 22:25:09 +02:00
2018-10-28 12:09:07 +01:00
DebGenerator gen(
2021-09-14 00:13:48 +02:00
this->Logger, this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"), strGenWDIR,
2018-10-28 12:09:07 +01:00
this->GetOption("CPACK_TOPLEVEL_DIRECTORY"),
this->GetOption("CPACK_TEMPORARY_DIRECTORY"),
this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE"),
2021-09-14 00:13:48 +02:00
this->GetOption("CPACK_THREADS"),
2018-10-28 12:09:07 +01:00
this->GetOption("GEN_CPACK_DEBIAN_ARCHIVE_TYPE"), controlValues, gen_shibs,
shlibsfilename, this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST"), postinst,
this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM"), postrm,
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"),
this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION"),
2021-09-14 00:13:48 +02:00
this->packageFiles);
2018-10-28 12:09:07 +01:00
if (!gen.generate()) {
return 0;
2016-10-30 18:24:19 +01:00
}
2018-10-28 12:09:07 +01:00
return 1;
}
2016-10-30 18:24:19 +01:00
2018-10-28 12:09:07 +01:00
int cmCPackDebGenerator::createDbgsymDDeb()
{
// Packages containing debug symbols follow the same structure as .debs
// but have different metadata and content.
2018-10-28 12:09:07 +01:00
std::map<std::string, std::string> controlValues;
// debian policy enforce lower case for package name
std::string packageNameLower = cmsys::SystemTools::LowerCase(
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"));
const char* debian_pkg_version =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
2015-11-17 17:22:37 +01:00
2018-10-28 12:09:07 +01:00
controlValues["Package"] = packageNameLower + "-dbgsym";
controlValues["Package-Type"] = "ddeb";
controlValues["Version"] = debian_pkg_version;
controlValues["Auto-Built-Package"] = "debug-symbols";
controlValues["Depends"] = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME") +
std::string(" (= ") + debian_pkg_version + ")";
controlValues["Section"] = "debug";
controlValues["Priority"] = "optional";
controlValues["Architecture"] =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
controlValues["Maintainer"] =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
controlValues["Description"] =
std::string("debug symbols for ") + packageNameLower;
2015-11-17 17:22:37 +01:00
2018-10-28 12:09:07 +01:00
const char* debian_pkg_source =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_pkg_source)) {
2018-10-28 12:09:07 +01:00
controlValues["Source"] = debian_pkg_source;
2015-11-17 17:22:37 +01:00
}
2018-10-28 12:09:07 +01:00
const char* debian_build_ids = this->GetOption("GEN_BUILD_IDS");
2021-09-14 00:13:48 +02:00
if (cmNonempty(debian_build_ids)) {
2018-10-28 12:09:07 +01:00
controlValues["Build-Ids"] = debian_build_ids;
2015-11-17 17:22:37 +01:00
}
2018-10-28 12:09:07 +01:00
DebGenerator gen(
2021-09-14 00:13:48 +02:00
this->Logger, this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME"),
2018-10-28 12:09:07 +01:00
this->GetOption("GEN_DBGSYMDIR"),
2018-08-09 18:06:22 +02:00
2018-10-28 12:09:07 +01:00
this->GetOption("CPACK_TOPLEVEL_DIRECTORY"),
this->GetOption("CPACK_TEMPORARY_DIRECTORY"),
this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE"),
2021-09-14 00:13:48 +02:00
this->GetOption("CPACK_THREADS"),
2018-10-28 12:09:07 +01:00
this->GetOption("GEN_CPACK_DEBIAN_ARCHIVE_TYPE"), controlValues, false, "",
false, "", false, "", nullptr,
this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION"),
2021-09-14 00:13:48 +02:00
this->packageFiles);
2018-08-09 18:06:22 +02:00
2018-10-28 12:09:07 +01:00
if (!gen.generate()) {
return 0;
2016-07-09 11:21:54 +02:00
}
return 1;
}
2011-06-19 15:41:06 +03:00
bool cmCPackDebGenerator::SupportsComponentInstallation() const
2016-07-09 11:21:54 +02:00
{
2021-09-14 00:13:48 +02:00
return this->IsOn("CPACK_DEB_COMPONENT_INSTALL");
2016-07-09 11:21:54 +02:00
}
2011-06-19 15:41:06 +03:00
std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
2016-07-09 11:21:54 +02:00
const std::string& componentName)
{
2021-09-14 00:13:48 +02:00
if (this->componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) {
2011-06-19 15:41:06 +03:00
return componentName;
}
2021-09-14 00:13:48 +02:00
if (this->componentPackageMethod == ONE_PACKAGE) {
2011-06-19 15:41:06 +03:00
return std::string("ALL_COMPONENTS_IN_ONE");
}
// We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to.
2016-07-09 11:21:54 +02:00
std::string groupVar =
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
2021-09-14 00:13:48 +02:00
if (nullptr != this->GetOption(groupVar)) {
return std::string(this->GetOption(groupVar));
2011-06-19 15:41:06 +03:00
}
2016-10-30 18:24:19 +01:00
return componentName;
2016-07-09 11:21:54 +02:00
}