2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2007-02-01 00:50:24 +03:00
|
|
|
#include "cmCPackCygwinSourceGenerator.h"
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCPackLog.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
2007-02-01 00:50:24 +03:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmake.h"
|
2007-02-01 00:50:24 +03:00
|
|
|
|
|
|
|
#include <cmsys/SystemTools.hxx>
|
|
|
|
|
|
|
|
// Includes needed for implementation of RenameFile. This is not in
|
|
|
|
// system tools because it is not implemented robustly enough to move
|
|
|
|
// files across directories.
|
|
|
|
#ifdef _WIN32
|
2016-05-16 17:34:04 +03:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <windows.h>
|
2007-02-01 00:50:24 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCPackCygwinSourceGenerator::~cmCPackCygwinSourceGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmCPackCygwinSourceGenerator::InitializeInternal()
|
|
|
|
{
|
|
|
|
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
|
|
|
|
return this->Superclass::InitializeInternal();
|
|
|
|
}
|
|
|
|
|
2010-08-11 21:48:39 +04:00
|
|
|
int cmCPackCygwinSourceGenerator::PackageFiles()
|
2007-02-01 00:50:24 +03:00
|
|
|
{
|
2007-02-02 22:40:26 +03:00
|
|
|
// Create a tar file of the sources
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string packageDirFileName =
|
|
|
|
this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
2009-11-03 17:40:57 +03:00
|
|
|
packageDirFileName += ".tar.bz2";
|
2010-08-11 21:48:39 +04:00
|
|
|
packageFileNames[0] = packageDirFileName;
|
2007-02-01 00:50:24 +03:00
|
|
|
std::string output;
|
2009-11-03 17:40:57 +03:00
|
|
|
// skip one parent up to the cmCPackTarBZip2Generator
|
|
|
|
// to create tar.bz2 file with the list of source
|
|
|
|
// files
|
2010-08-25 13:04:49 +04:00
|
|
|
this->Compress = cmArchiveWrite::CompressBZip2;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
|
2007-02-01 00:50:24 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-02 22:40:26 +03:00
|
|
|
// Now create a tar file that contains the above .tar.bz2 file
|
|
|
|
// and the CPACK_CYGWIN_PATCH_FILE and CPACK_TOPLEVEL_DIRECTORY
|
|
|
|
// files
|
2009-11-03 17:40:57 +03:00
|
|
|
std::string compressOutFile = packageDirFileName;
|
2012-08-13 21:42:58 +04:00
|
|
|
// at this point compressOutFile is the full path to
|
2007-02-01 00:50:24 +03:00
|
|
|
// _CPack_Package/.../package-2.5.0.tar.bz2
|
|
|
|
// we want to create a tar _CPack_Package/.../package-2.5.0-1-src.tar.bz2
|
2012-08-13 21:42:58 +04:00
|
|
|
// with these
|
|
|
|
// _CPack_Package/.../package-2.5.0-1.patch
|
2007-02-01 00:50:24 +03:00
|
|
|
// _CPack_Package/.../package-2.5.0-1.sh
|
|
|
|
// _CPack_Package/.../package-2.5.0.tar.bz2
|
|
|
|
// the -1 is CPACK_CYGWIN_PATCH_NUMBER
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2009-11-03 17:40:57 +03:00
|
|
|
// first copy the patch file and the .sh file
|
|
|
|
// to the toplevel cpack temp dir
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2007-02-02 22:40:26 +03:00
|
|
|
// copy the patch file into place
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->GetOption("CPACK_CYGWIN_PATCH_FILE")) {
|
2009-11-03 17:40:57 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"No patch file specified for cygwin sources.");
|
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cmSystemTools::CopyFileAlways(
|
|
|
|
this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
|
|
|
|
this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
|
2007-02-01 00:50:24 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: ["
|
2016-05-16 17:34:04 +03:00
|
|
|
<< this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n["
|
|
|
|
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
|
2007-02-01 00:50:24 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT")) {
|
2012-08-13 21:42:58 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2009-11-03 17:40:57 +03:00
|
|
|
"No build script specified for cygwin sources.");
|
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-02 22:40:26 +03:00
|
|
|
// copy the build script into place
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::CopyFileAlways(
|
|
|
|
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
|
|
|
|
this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
|
2007-02-01 00:50:24 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n"
|
|
|
|
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
|
2007-02-01 00:50:24 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::string outerTarFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
2007-02-01 00:50:24 +03:00
|
|
|
outerTarFile += "-";
|
2008-03-13 04:54:27 +03:00
|
|
|
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!patch) {
|
2008-03-13 04:54:27 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< " not specified, defaulting to 1\n");
|
2008-03-13 04:54:27 +03:00
|
|
|
patch = "1";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-13 04:54:27 +03:00
|
|
|
outerTarFile += patch;
|
2009-11-03 17:40:57 +03:00
|
|
|
outerTarFile += "-src.tar.bz2";
|
|
|
|
std::string tmpDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
|
|
std::string buildScript = tmpDir;
|
|
|
|
buildScript += "/";
|
|
|
|
buildScript += cmSystemTools::GetFilenameName(
|
2007-02-01 00:50:24 +03:00
|
|
|
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"));
|
2009-11-03 17:40:57 +03:00
|
|
|
std::string patchFile = tmpDir;
|
|
|
|
patchFile += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
patchFile +=
|
|
|
|
cmSystemTools::GetFilenameName(this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
|
2010-08-11 21:48:39 +04:00
|
|
|
|
2007-02-01 00:50:24 +03:00
|
|
|
std::string file = cmSystemTools::GetFilenameName(compressOutFile);
|
2009-11-03 17:40:57 +03:00
|
|
|
std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile);
|
|
|
|
sourceTar += "/";
|
|
|
|
sourceTar += file;
|
2010-08-11 21:48:39 +04:00
|
|
|
/* reset list of file to be packaged */
|
|
|
|
files.clear();
|
2007-02-01 00:50:24 +03:00
|
|
|
// a source release in cygwin should have the build script used
|
|
|
|
// to build the package, the patch file that is different from the
|
|
|
|
// regular upstream version of the sources, and a bziped tar file
|
|
|
|
// of the original sources
|
2010-08-11 21:48:39 +04:00
|
|
|
files.push_back(buildScript);
|
|
|
|
files.push_back(patchFile);
|
|
|
|
files.push_back(sourceTar);
|
|
|
|
/* update the name of the produced package */
|
|
|
|
packageFileNames[0] = outerTarFile;
|
|
|
|
/* update the toplevel dir */
|
|
|
|
toplevel = tmpDir;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
|
2007-02-01 00:50:24 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-01 00:50:24 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-10-31 15:50:17 +03:00
|
|
|
const char* cmCPackCygwinSourceGenerator::GetPackagingInstallPrefix()
|
2007-02-01 00:50:24 +03:00
|
|
|
{
|
|
|
|
this->InstallPrefix = "/";
|
|
|
|
this->InstallPrefix += this->GetOption("CPACK_PACKAGE_FILE_NAME");
|
|
|
|
return this->InstallPrefix.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
|
|
|
|
{
|
|
|
|
this->OutputExtension = "-";
|
2012-08-13 21:42:58 +04:00
|
|
|
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!patch) {
|
2008-03-13 04:54:27 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< " not specified, defaulting to 1\n");
|
2008-03-13 04:54:27 +03:00
|
|
|
patch = "1";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-13 04:54:27 +03:00
|
|
|
this->OutputExtension += patch;
|
2007-02-01 00:50:24 +03:00
|
|
|
this->OutputExtension += "-src.tar.bz2";
|
|
|
|
return this->OutputExtension.c_str();
|
|
|
|
}
|