CPack: Refactor API in order to handle multi-file packages

The multi-argument CompressFiles(...) method has been replace by the
no-argument PackageFiles() method and 3 more member variables.  This
will enable implemention of multi-package generators.  Now each specific
generator (which overloads PackageFiles()) may decide to change the name
and/or the number of generated package files.
This commit is contained in:
Eric NOULARD 2010-08-11 19:48:39 +02:00 committed by Brad King
parent 7c20f7b244
commit cd7b8a03f5
24 changed files with 173 additions and 118 deletions

View File

@ -166,8 +166,7 @@ int cmCPackArchiveGenerator::InitializeInternal()
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
} }
int cmCPackArchiveGenerator::CompressFiles(const char* outFileName, int cmCPackArchiveGenerator::PackageFiles()
const char* toplevel, const std::vector<std::string>& files)
{ {
int res = ARCHIVE_OK; int res = ARCHIVE_OK;
#define CHECK_ARCHIVE_ERROR(res, msg) \ #define CHECK_ARCHIVE_ERROR(res, msg) \
@ -180,14 +179,15 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName,
<< "\n"); \ << "\n"); \
} }
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
<< (toplevel ? toplevel : "(NULL)") << std::endl); << toplevel << std::endl);
// create a new archive // create a new archive
struct archive* a = archive_write_new(); struct archive* a = archive_write_new();
// Set the compress and archive types for the archive // Set the compress and archive types for the archive
SetArchiveType(a, this->Compress, this->Archive); SetArchiveType(a, this->Compress, this->Archive);
// Open binary stream // Open binary stream
cmGeneratedFileStream* gf = new cmGeneratedFileStream; cmGeneratedFileStream* gf = new cmGeneratedFileStream;
gf->Open(outFileName, false, true); gf->Open(packageFileNames[0].c_str(), false, true);
StreamData data(gf, this); StreamData data(gf, this);
// pass callbacks to archive_write_open to handle stream // pass callbacks to archive_write_open to handle stream
res = archive_write_open(a, res = archive_write_open(a,
@ -204,13 +204,13 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName,
CHECK_ARCHIVE_ERROR(res, "archive_read_disk_set_standard_lookup:"); CHECK_ARCHIVE_ERROR(res, "archive_read_disk_set_standard_lookup:");
std::vector<std::string>::const_iterator fileIt; std::vector<std::string>::const_iterator fileIt;
std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(toplevel); cmSystemTools::ChangeDirectory(toplevel.c_str());
for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
{ {
// create a new entry for each file // create a new entry for each file
struct archive_entry *entry = archive_entry_new(); struct archive_entry *entry = archive_entry_new();
// Get the relative path to the file // Get the relative path to the file
std::string rp = cmSystemTools::RelativePath(toplevel, fileIt->c_str()); std::string rp = cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str());
// Set the name of the entry to the file name // Set the name of the entry to the file name
archive_entry_set_pathname(entry, rp.c_str()); archive_entry_set_pathname(entry, rp.c_str());
res = archive_read_disk_entry_from_file(disk, entry, -1, 0); res = archive_read_disk_entry_from_file(disk, entry, -1, 0);

View File

@ -37,8 +37,7 @@ public:
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
int CompressFiles(const char* outFileName, const char* toplevel, int PackageFiles();
const std::vector<std::string>& files);
virtual const char* GetOutputExtension() = 0; virtual const char* GetOutputExtension() = 0;
CompressType Compress; CompressType Compress;
ArchiveType Archive; ArchiveType Archive;

View File

@ -53,10 +53,8 @@ const char* cmCPackBundleGenerator::GetPackagingInstallPrefix()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackBundleGenerator::CompressFiles(const char* outFileName, int cmCPackBundleGenerator::PackageFiles()
const char* toplevel, const std::vector<std::string>& files)
{ {
(void) files;
// Get required arguments ... // Get required arguments ...
const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME") const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME")
@ -167,5 +165,5 @@ int cmCPackBundleGenerator::CompressFiles(const char* outFileName,
cmSystemTools::SetPermissions(command_target.str().c_str(), 0777); cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
} }
return this->CreateDMG(toplevel, outFileName); return this->CreateDMG(toplevel.c_str(), packageFileNames[0].c_str());
} }

View File

@ -31,8 +31,7 @@ public:
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
virtual const char* GetPackagingInstallPrefix(); virtual const char* GetPackagingInstallPrefix();
int CompressFiles(const char* outFileName, const char* toplevel, int PackageFiles();
const std::vector<std::string>& files);
std::string InstallPrefix; std::string InstallPrefix;
}; };

View File

@ -41,8 +41,7 @@ int cmCPackCygwinBinaryGenerator::InitializeInternal()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName, int cmCPackCygwinBinaryGenerator::PackageFiles()
const char* toplevel, const std::vector<std::string>& files)
{ {
std::string packageName = this->GetOption("CPACK_PACKAGE_NAME"); std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
packageName += "-"; packageName += "-";
@ -70,12 +69,10 @@ int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName,
ofs << manifest << "\n"; ofs << manifest << "\n";
} }
// add the manifest file to the list of all files // add the manifest file to the list of all files
std::vector<std::string> filesWithManifest = files; files.push_back(manifestFile);
filesWithManifest.push_back(manifestFile);
// create the bzip2 tar file // create the bzip2 tar file
return this->Superclass::CompressFiles(outFileName, toplevel, return this->Superclass::PackageFiles();
filesWithManifest);
} }
const char* cmCPackCygwinBinaryGenerator::GetOutputExtension() const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()

View File

@ -30,8 +30,7 @@ public:
virtual ~cmCPackCygwinBinaryGenerator(); virtual ~cmCPackCygwinBinaryGenerator();
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
int CompressFiles(const char* outFileName, const char* toplevel, int PackageFiles();
const std::vector<std::string>& files);
virtual const char* GetOutputExtension(); virtual const char* GetOutputExtension();
std::string OutputExtension; std::string OutputExtension;
}; };

View File

@ -48,21 +48,19 @@ int cmCPackCygwinSourceGenerator::InitializeInternal()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName, int cmCPackCygwinSourceGenerator::PackageFiles()
const char* toplevel, const std::vector<std::string>& files)
{ {
// Create a tar file of the sources // Create a tar file of the sources
std::string packageDirFileName std::string packageDirFileName
= this->GetOption("CPACK_TEMPORARY_DIRECTORY"); = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packageDirFileName += ".tar.bz2"; packageDirFileName += ".tar.bz2";
packageFileNames[0] = packageDirFileName;
std::string output; std::string output;
// skip one parent up to the cmCPackTarBZip2Generator // skip one parent up to the cmCPackTarBZip2Generator
// to create tar.bz2 file with the list of source // to create tar.bz2 file with the list of source
// files // files
this->Compress = BZIP2; this->Compress = BZIP2;
if ( !this->cmCPackTarBZip2Generator:: if ( !this->cmCPackTarBZip2Generator::PackageFiles() )
CompressFiles(packageDirFileName.c_str(),
toplevel, files) )
{ {
return 0; return 0;
} }
@ -135,21 +133,25 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
patchFile += "/"; patchFile += "/";
patchFile += cmSystemTools::GetFilenameName( patchFile += cmSystemTools::GetFilenameName(
this->GetOption("CPACK_CYGWIN_PATCH_FILE")); this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
std::vector<std::string> outerFiles;
std::string file = cmSystemTools::GetFilenameName(compressOutFile); std::string file = cmSystemTools::GetFilenameName(compressOutFile);
std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile); std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile);
sourceTar += "/"; sourceTar += "/";
sourceTar += file; sourceTar += file;
/* reset list of file to be packaged */
files.clear();
// a source release in cygwin should have the build script used // a source release in cygwin should have the build script used
// to build the package, the patch file that is different from the // to build the package, the patch file that is different from the
// regular upstream version of the sources, and a bziped tar file // regular upstream version of the sources, and a bziped tar file
// of the original sources // of the original sources
outerFiles.push_back(buildScript); files.push_back(buildScript);
outerFiles.push_back(patchFile); files.push_back(patchFile);
outerFiles.push_back(sourceTar); files.push_back(sourceTar);
if ( !this->cmCPackTarBZip2Generator:: /* update the name of the produced package */
CompressFiles(outerTarFile.c_str(), packageFileNames[0] = outerTarFile;
tmpDir.c_str(), outerFiles) ) /* update the toplevel dir */
toplevel = tmpDir;
if ( !this->cmCPackTarBZip2Generator::PackageFiles() )
{ {
return 0; return 0;
} }

View File

@ -31,8 +31,7 @@ public:
protected: protected:
const char* GetPackagingInstallPrefix(); const char* GetPackagingInstallPrefix();
virtual int InitializeInternal(); virtual int InitializeInternal();
int CompressFiles(const char* outFileName, const char* toplevel, int PackageFiles();
const std::vector<std::string>& files);
virtual const char* GetOutputExtension(); virtual const char* GetOutputExtension();
std::string InstallPrefix; std::string InstallPrefix;
std::string OutputExtension; std::string OutputExtension;

View File

@ -48,9 +48,7 @@ int cmCPackDebGenerator::InitializeInternal()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackDebGenerator::CompressFiles(const char* outFileName, int cmCPackDebGenerator::PackageFiles()
const char* toplevel,
const std::vector<std::string>& files)
{ {
this->ReadListFile("CPackDeb.cmake"); this->ReadListFile("CPackDeb.cmake");
const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND"); const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND");
@ -141,7 +139,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
// now add all directories which have to be compressed // now add all directories which have to be compressed
// collect all top level install dirs for that // 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 // e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would give /usr and /opt
size_t topLevelLength = strlen(toplevel); size_t topLevelLength = toplevel.length();
std::set<std::string> installDirs; std::set<std::string> installDirs;
for (std::vector<std::string>::const_iterator fileIt = files.begin(); for (std::vector<std::string>::const_iterator fileIt = files.begin();
fileIt != files.end(); ++ fileIt ) fileIt != files.end(); ++ fileIt )
@ -160,7 +158,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
std::string output; std::string output;
int retVal = -1; int retVal = -1;
int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0); &retVal, toplevel.c_str(), this->GeneratorVerbose, 0);
if ( !res || retVal ) if ( !res || retVal )
{ {
@ -196,7 +194,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
//std::string output; //std::string output;
//int retVal = -1; //int retVal = -1;
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0); &retVal, toplevel.c_str(), this->GeneratorVerbose, 0);
// debian md5sums entries are like this: // debian md5sums entries are like this:
// 014f3604694729f3bf19263bac599765 usr/bin/ccmake // 014f3604694729f3bf19263bac599765 usr/bin/ccmake
// thus strip the full path (with the trailing slash) // thus strip the full path (with the trailing slash)
@ -237,7 +235,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
} }
} }
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0); &retVal, toplevel.c_str(), this->GeneratorVerbose, 0);
if ( !res || retVal ) if ( !res || retVal )
{ {
@ -263,7 +261,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
arFiles.push_back(topLevelString + "debian-binary"); arFiles.push_back(topLevelString + "debian-binary");
arFiles.push_back(topLevelString + "control.tar.gz"); arFiles.push_back(topLevelString + "control.tar.gz");
arFiles.push_back(topLevelString + "data.tar.gz"); arFiles.push_back(topLevelString + "data.tar.gz");
res = ar_append(outFileName, arFiles); res = ar_append(packageFileNames[0].c_str(), arFiles);
if ( res!=0 ) if ( res!=0 )
{ {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");

View File

@ -33,8 +33,7 @@ public:
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
virtual int CompressFiles(const char* outFileName, const char* toplevel, virtual int PackageFiles();
const std::vector<std::string>& files);
virtual const char* GetOutputExtension() { return ".deb"; } virtual const char* GetOutputExtension() { return ".deb"; }
}; };

View File

@ -104,12 +104,10 @@ const char* cmCPackDragNDropGenerator::GetOutputExtension()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackDragNDropGenerator::CompressFiles(const char* outFileName, int cmCPackDragNDropGenerator::PackageFiles()
const char* toplevel, const std::vector<std::string>& files)
{ {
(void) files;
return this->CreateDMG(toplevel, outFileName); return this->CreateDMG(toplevel, packageFileNames[0]);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -29,8 +29,7 @@ public:
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
virtual const char* GetOutputExtension(); virtual const char* GetOutputExtension();
int CompressFiles(const char* outFileName, const char* toplevel, int PackageFiles();
const std::vector<std::string>& files);
bool CopyFile(cmOStringStream& source, cmOStringStream& target); bool CopyFile(cmOStringStream& source, cmOStringStream& target);
bool RunCommand(cmOStringStream& command, std::string* output = 0); bool RunCommand(cmOStringStream& command, std::string* output = 0);

View File

@ -100,6 +100,7 @@ int cmCPackGenerator::PrepareNames()
} }
std::string destFile = pdir; std::string destFile = pdir;
this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PREFIX", destFile.c_str());
destFile += "/" + outName; destFile += "/" + outName;
std::string outFile = topDirectory + "/" + outName; std::string outFile = topDirectory + "/" + outName;
this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str()); this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str());
@ -843,7 +844,7 @@ int cmCPackGenerator::DoPackage()
} }
// The files to be installed // The files to be installed
std::vector<std::string> files = gl.GetFiles(); files = gl.GetFiles();
// For component installations, determine which files go into which // For component installations, determine which files go into which
// components. // components.
@ -866,16 +867,40 @@ int cmCPackGenerator::DoPackage()
} }
} }
if ( !this->CompressFiles(tempPackageFileName,
tempDirectory, files) || cmSystemTools::GetErrorOccuredFlag()) packageFileNames.clear();
/* Put at least one file name into the list of
* wanted packageFileNames. The specific generator
* may update this during PackageFiles.
* (either putting several names or updating the provided one)
*/
packageFileNames.push_back(tempPackageFileName);
toplevel = tempDirectory;
if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag())
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory" cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory"
<< std::endl); << std::endl);
return 0; return 0;
} }
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Finalize package" << std::endl); /*
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copy final package: " * Copy the generated packages to final destination
* - there may be several of them
* - the initially provided name may have changed
* (because the specific generator did 'normalize' it)
*/
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) ["
<<packageFileNames.size()
<<"]:"<<std::endl);
std::vector<std::string>::iterator it;
/* now copy package one by one */
for (it=packageFileNames.begin();it!=packageFileNames.end();++it)
{
std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
tempPackageFileName = it->c_str();
tmpPF += "/"+cmSystemTools::GetFilenameName(*it);
packageFileName = tmpPF.c_str();
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): "
<< (tempPackageFileName ? tempPackageFileName : "(NULL)" ) << (tempPackageFileName ? tempPackageFileName : "(NULL)" )
<< " to " << " to "
<< (packageFileName ? packageFileName : "(NULL)") << (packageFileName ? packageFileName : "(NULL)")
@ -890,10 +915,11 @@ int cmCPackGenerator::DoPackage()
<< std::endl); << std::endl);
return 0; return 0;
} }
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: "
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Package " << packageFileName
<< (packageFileName ? packageFileName : "(NULL)")
<< " generated." << std::endl); << " generated." << std::endl);
}
return 1; return 1;
} }
@ -984,12 +1010,8 @@ int cmCPackGenerator::SetCMakeRoot()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackGenerator::CompressFiles(const char* outFileName, int cmCPackGenerator::PackageFiles()
const char* toplevel, const std::vector<std::string>& files)
{ {
(void)outFileName;
(void)toplevel;
(void)files;
return 0; return 0;
} }

View File

@ -55,13 +55,22 @@ class cmCPackGenerator : public cmObject
public: public:
cmTypeMacro(cmCPackGenerator, cmObject); cmTypeMacro(cmCPackGenerator, cmObject);
/** /**
* If verbose then more informaiton is printed out * If verbose then more information is printed out
*/ */
void SetVerbose(bool val) { this->GeneratorVerbose = val; } void SetVerbose(bool val) { this->GeneratorVerbose = val; }
/** /**
* Do the actual processing. Subclass has to override it. * Do the actual whole package processing.
* Return 0 if error. * Subclass may redefine it but its usually enough
* to redefine @ref PackageFiles, because in fact
* this method do call:
* - PrepareName
* - clean-up temp dirs
* - InstallProject (with the appropriate method)
* - prepare list of files and/or components to be package
* - PackageFiles
* - Copy produced packages at the expected place
* @return 0 if error.
*/ */
virtual int DoPackage(); virtual int DoPackage();
@ -94,13 +103,32 @@ public:
bool ReadListFile(const char* moduleName); bool ReadListFile(const char* moduleName);
protected: protected:
/**
* Prepare common used names by inspecting
* several CPACK_xxx var values.
*/
int PrepareNames(); int PrepareNames();
/**
* Install the project using appropriate method.
*/
int InstallProject(); int InstallProject();
int CleanTemporaryDirectory(); int CleanTemporaryDirectory();
virtual const char* GetOutputExtension() { return ".cpack"; } virtual const char* GetOutputExtension() { return ".cpack"; }
virtual const char* GetOutputPostfix() { return 0; } virtual const char* GetOutputPostfix() { return 0; }
virtual int CompressFiles(const char* outFileName, const char* toplevel,
const std::vector<std::string>& files); /**
* Package the list of files and/or components which
* has been prepared by the beginning of DoPackage.
* @pre @ref toplevel has been filled-in
* @pre the list of file @ref files has been populated
* @pre packageFileNames contains at least 1 entry
* @post packageFileNames may have been updated and contains
* the list of packages generated by the specific generator.
*/
virtual int PackageFiles();
virtual const char* GetInstallPath(); virtual const char* GetInstallPath();
virtual const char* GetPackagingInstallPrefix(); virtual const char* GetPackagingInstallPrefix();
@ -134,11 +162,42 @@ protected:
std::string InstallPath; std::string InstallPath;
/**
* The list of package file names.
* At beginning of DoPackage the (generic) generator will populate
* the list of desired package file names then it will
* call the redefined method PackageFiles which is may
* either use this set of names (usually on entry there should be
* only a single name) or update the vector with the list
* of created package file names.
*/
std::vector<std::string> packageFileNames;
/**
* The directory where all the files to be packaged reside.
* If the installer support components there will be one
* sub-directory for each component. In those directories
* one will find the file belonging to the specified component.
*/
std::string toplevel;
/**
* The complete list of files to be packaged.
* This list will be populated by DoPackage before
* PackageFiles is called.
*/
std::vector<std::string> files;
std::string CPackSelf; std::string CPackSelf;
std::string CMakeSelf; std::string CMakeSelf;
std::string CMakeRoot; std::string CMakeRoot;
std::map<std::string, cmCPackInstallationType> InstallationTypes; std::map<std::string, cmCPackInstallationType> InstallationTypes;
/**
* The set of components.
* If component installation is supported then this map
* contains the component specified in CPACK_COMPONENTS_ALL
*/
std::map<std::string, cmCPackComponent> Components; std::map<std::string, cmCPackComponent> Components;
std::map<std::string, cmCPackComponentGroup> ComponentGroups; std::map<std::string, cmCPackComponentGroup> ComponentGroups;

View File

@ -43,11 +43,10 @@ cmCPackNSISGenerator::~cmCPackNSISGenerator()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackNSISGenerator::CompressFiles(const char* outFileName, int cmCPackNSISGenerator::PackageFiles()
const char* toplevel, const std::vector<std::string>& files)
{ {
(void)outFileName; // TODO: Fix nsis to force out file name // TODO: Fix nsis to force out file name
(void)toplevel;
std::string nsisInFileName = this->FindTemplate("NSIS.template.in"); std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
if ( nsisInFileName.size() == 0 ) if ( nsisInFileName.size() == 0 )
{ {
@ -74,7 +73,7 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName,
std::vector<std::string>::const_iterator it; std::vector<std::string>::const_iterator it;
for ( it = files.begin(); it != files.end(); ++ it ) for ( it = files.begin(); it != files.end(); ++ it )
{ {
std::string fileN = cmSystemTools::RelativePath(toplevel, std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(),
it->c_str()); it->c_str());
if (!this->Components.empty()) if (!this->Components.empty())
{ {
@ -88,13 +87,13 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName,
<< str.str().c_str() << std::endl); << str.str().c_str() << std::endl);
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str()); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str());
std::vector<std::string> dirs; std::vector<std::string> dirs;
this->GetListOfSubdirectories(toplevel, dirs); this->GetListOfSubdirectories(toplevel.c_str(), dirs);
std::vector<std::string>::const_iterator sit; std::vector<std::string>::const_iterator sit;
cmOStringStream dstr; cmOStringStream dstr;
for ( sit = dirs.begin(); sit != dirs.end(); ++ sit ) for ( sit = dirs.begin(); sit != dirs.end(); ++ sit )
{ {
std::string componentName; std::string componentName;
std::string fileN = cmSystemTools::RelativePath(toplevel, sit->c_str()); std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(), sit->c_str());
if ( fileN.empty() ) if ( fileN.empty() )
{ {
continue; continue;

View File

@ -37,8 +37,7 @@ protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
void CreateMenuLinks( cmOStringStream& str, void CreateMenuLinks( cmOStringStream& str,
cmOStringStream& deleteStr); cmOStringStream& deleteStr);
int CompressFiles(const char* outFileName, const char* toplevel, int PackageFiles();
const std::vector<std::string>& files);
virtual const char* GetOutputExtension() { return ".exe"; } virtual const char* GetOutputExtension() { return ".exe"; }
virtual const char* GetOutputPostfix() { return "win32"; } virtual const char* GetOutputPostfix() { return "win32"; }

View File

@ -33,12 +33,10 @@ cmCPackOSXX11Generator::~cmCPackOSXX11Generator()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, int cmCPackOSXX11Generator::PackageFiles()
const char* toplevel,
const std::vector<std::string>& files)
{ {
(void) files; // TODO: Fix api to not need files. // TODO: Use toplevel ?
(void) toplevel; // TODO: Use toplevel // It is used! Is this an obsolete comment?
const char* cpackPackageExecutables const char* cpackPackageExecutables
= this->GetOption("CPACK_PACKAGE_EXECUTABLES"); = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
@ -144,7 +142,7 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName,
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
<< "\" create -ov -format UDZO -srcfolder \"" << "\" create -ov -format UDZO -srcfolder \""
<< diskImageDirectory.c_str() << diskImageDirectory.c_str()
<< "\" \"" << outFileName << "\""; << "\" \"" << packageFileNames[0] << "\"";
int retVal = 1; int retVal = 1;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Compress disk image using command: " "Compress disk image using command: "

View File

@ -33,8 +33,7 @@ public:
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
int CompressFiles(const char* outFileName, const char* toplevel, int PackageFiles();
const std::vector<std::string>& files);
virtual const char* GetPackagingInstallPrefix(); virtual const char* GetPackagingInstallPrefix();
virtual const char* GetOutputExtension() { return ".dmg"; } virtual const char* GetOutputExtension() { return ".dmg"; }

View File

@ -59,12 +59,10 @@ int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir,
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, int cmCPackPackageMakerGenerator::PackageFiles()
const char* toplevel,
const std::vector<std::string>& files)
{ {
(void) files; // TODO: Fix api to not need files. // TODO: Use toplevel
(void) toplevel; // TODO: Use toplevel // It is used! Is this an obsolete comment?
std::string resDir; // Where this package's resources will go. std::string resDir; // Where this package's resources will go.
std::string packageDirFileName std::string packageDirFileName
@ -318,7 +316,7 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName,
cmOStringStream dmgCmd; cmOStringStream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
<< "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
<< "\" \"" << outFileName << "\""; << "\" \"" << packageFileNames[0] << "\"";
std::string output; std::string output;
int retVal = 1; int retVal = 1;
int numTries = 4; int numTries = 4;

View File

@ -42,8 +42,7 @@ protected:
const char* script, const char* script,
const char* name); const char* name);
virtual int InitializeInternal(); virtual int InitializeInternal();
int CompressFiles(const char* outFileName, const char* toplevel, int PackageFiles();
const std::vector<std::string>& files);
virtual const char* GetOutputExtension() { return ".dmg"; } virtual const char* GetOutputExtension() { return ".dmg"; }
virtual const char* GetOutputPostfix() { return "darwin"; } virtual const char* GetOutputPostfix() { return "darwin"; }

View File

@ -31,9 +31,7 @@ int cmCPackRPMGenerator::InitializeInternal()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackRPMGenerator::CompressFiles(const char* /*outFileName*/, int cmCPackRPMGenerator::PackageFiles()
const char* /*toplevel*/,
const std::vector<std::string>& /*files*/)
{ {
this->ReadListFile("CPackRPM.cmake"); this->ReadListFile("CPackRPM.cmake");
if (!this->IsSet("RPMBUILD_EXECUTABLE")) if (!this->IsSet("RPMBUILD_EXECUTABLE"))

View File

@ -37,8 +37,7 @@ public:
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
virtual int CompressFiles(const char* outFileName, const char* toplevel, virtual int PackageFiles();
const std::vector<std::string>& files);
virtual const char* GetOutputExtension() { return ".rpm"; } virtual const char* GetOutputExtension() { return ".rpm"; }
}; };

View File

@ -52,14 +52,13 @@ int cmCPackSTGZGenerator::InitializeInternal()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCPackSTGZGenerator::CompressFiles(const char* outFileName, int cmCPackSTGZGenerator::PackageFiles()
const char* toplevel, const std::vector<std::string>& files)
{ {
if ( !this->Superclass::CompressFiles(outFileName, toplevel, files) ) if ( !this->Superclass::PackageFiles() )
{ {
return 0; return 0;
} }
return cmSystemTools::SetPermissions(outFileName, return cmSystemTools::SetPermissions(packageFileNames[0].c_str(),
#if defined( _MSC_VER ) || defined( __MINGW32__ ) #if defined( _MSC_VER ) || defined( __MINGW32__ )
S_IREAD | S_IWRITE | S_IEXEC S_IREAD | S_IWRITE | S_IEXEC
#elif defined( __BORLANDC__ ) #elif defined( __BORLANDC__ )

View File

@ -32,8 +32,7 @@ public:
virtual ~cmCPackSTGZGenerator(); virtual ~cmCPackSTGZGenerator();
protected: protected:
int CompressFiles(const char* outFileName, const char* toplevel, int PackageFiles();
const std::vector<std::string>& files);
virtual int InitializeInternal(); virtual int InitializeInternal();
int GenerateHeader(std::ostream* os); int GenerateHeader(std::ostream* os);
virtual const char* GetOutputExtension() { return ".sh"; } virtual const char* GetOutputExtension() { return ".sh"; }