Fix cygwin package stuff to work with libarchive
This commit is contained in:
parent
1b1d954f7e
commit
78b2d5097c
@ -49,8 +49,25 @@ bool SetArchiveType(struct archive* a,
|
|||||||
cmCPackArchiveGenerator::CompressType ct,
|
cmCPackArchiveGenerator::CompressType ct,
|
||||||
cmCPackArchiveGenerator::ArchiveType at)
|
cmCPackArchiveGenerator::ArchiveType at)
|
||||||
{
|
{
|
||||||
// pick a compression type
|
|
||||||
int res;
|
int res;
|
||||||
|
// pick the archive type
|
||||||
|
switch(at)
|
||||||
|
{
|
||||||
|
case cmCPackArchiveGenerator::TAR:
|
||||||
|
// maybe this:
|
||||||
|
//res = archive_write_set_format_pax(a);
|
||||||
|
res = archive_write_set_format_ustar(a); // is this what we want?
|
||||||
|
break;
|
||||||
|
case cmCPackArchiveGenerator::ZIP:
|
||||||
|
res = archive_write_set_format_zip(a);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(res != ARCHIVE_OK)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pick a compression type
|
||||||
switch(ct)
|
switch(ct)
|
||||||
{
|
{
|
||||||
case cmCPackArchiveGenerator::GZIP:
|
case cmCPackArchiveGenerator::GZIP:
|
||||||
@ -73,22 +90,13 @@ bool SetArchiveType(struct archive* a,
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// pick the archive type
|
// do not pad the last block!!
|
||||||
switch(at)
|
res = archive_write_set_bytes_in_last_block(a, 1);
|
||||||
{
|
|
||||||
case cmCPackArchiveGenerator::TAR:
|
|
||||||
// maybe this:
|
|
||||||
// archive_write_set_format_pax(a);
|
|
||||||
res = archive_write_set_format_ustar(a); // is this what we want?
|
|
||||||
break;
|
|
||||||
case cmCPackArchiveGenerator::ZIP:
|
|
||||||
res = archive_write_set_format_zip(a);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(res != ARCHIVE_OK)
|
if(res != ARCHIVE_OK)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +209,7 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName,
|
|||||||
if(!file)
|
if(!file)
|
||||||
{
|
{
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with fopen(): "
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with fopen(): "
|
||||||
<< file
|
<< fileIt->c_str()
|
||||||
<< strerror(errno)
|
<< strerror(errno)
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator()
|
cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator()
|
||||||
{
|
{
|
||||||
this->Compress = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
@ -38,18 +37,6 @@ int cmCPackCygwinBinaryGenerator::InitializeInternal()
|
|||||||
{
|
{
|
||||||
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
||||||
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
|
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
|
||||||
std::vector<std::string> path;
|
|
||||||
std::string pkgPath = cmSystemTools::FindProgram("bzip2", path, false);
|
|
||||||
if ( pkgPath.empty() )
|
|
||||||
{
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find BZip2" << std::endl);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found Compress program: "
|
|
||||||
<< pkgPath.c_str()
|
|
||||||
<< std::endl);
|
|
||||||
|
|
||||||
return this->Superclass::InitializeInternal();
|
return this->Superclass::InitializeInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +72,7 @@ int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName,
|
|||||||
// 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;
|
std::vector<std::string> filesWithManifest = files;
|
||||||
filesWithManifest.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::CompressFiles(outFileName, toplevel,
|
||||||
filesWithManifest);
|
filesWithManifest);
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator()
|
cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator()
|
||||||
{
|
{
|
||||||
this->Compress = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
@ -45,18 +44,6 @@ cmCPackCygwinSourceGenerator::~cmCPackCygwinSourceGenerator()
|
|||||||
int cmCPackCygwinSourceGenerator::InitializeInternal()
|
int cmCPackCygwinSourceGenerator::InitializeInternal()
|
||||||
{
|
{
|
||||||
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
|
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
|
||||||
std::vector<std::string> path;
|
|
||||||
std::string pkgPath = cmSystemTools::FindProgram("bzip2", path, false);
|
|
||||||
if ( pkgPath.empty() )
|
|
||||||
{
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find BZip2" << std::endl);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found Compress program: "
|
|
||||||
<< pkgPath.c_str()
|
|
||||||
<< std::endl);
|
|
||||||
|
|
||||||
return this->Superclass::InitializeInternal();
|
return this->Superclass::InitializeInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,26 +54,22 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
|
|||||||
// 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";
|
packageDirFileName += ".tar.bz2";
|
||||||
std::string output;
|
std::string output;
|
||||||
// skip one parent up to the cmCPackTGZGenerator to create tar file
|
// skip one parent up to the cmCPackTarBZip2Generator
|
||||||
this->Compress = false; // just create tar not tar.gz
|
// to create tar.bz2 file with the list of source
|
||||||
if ( !this->cmCPackTGZGenerator::CompressFiles(packageDirFileName.c_str(),
|
// files
|
||||||
|
this->Compress = BZIP2;
|
||||||
|
if ( !this->cmCPackTarBZip2Generator::
|
||||||
|
CompressFiles(packageDirFileName.c_str(),
|
||||||
toplevel, files) )
|
toplevel, files) )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// Now bzip2 the source tar file
|
|
||||||
if(!this->BZip2File(packageDirFileName.c_str()))
|
|
||||||
{
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running BZip2 on file: "
|
|
||||||
<< packageDirFileName.c_str());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// Now create a tar file that contains the above .tar.bz2 file
|
// Now create a tar file that contains the above .tar.bz2 file
|
||||||
// and the CPACK_CYGWIN_PATCH_FILE and CPACK_TOPLEVEL_DIRECTORY
|
// and the CPACK_CYGWIN_PATCH_FILE and CPACK_TOPLEVEL_DIRECTORY
|
||||||
// files
|
// files
|
||||||
std::string compressOutFile = packageDirFileName + ".bz2";
|
std::string compressOutFile = packageDirFileName;
|
||||||
// at this point compressOutFile is the full path to
|
// at this point compressOutFile is the full path to
|
||||||
// _CPack_Package/.../package-2.5.0.tar.bz2
|
// _CPack_Package/.../package-2.5.0.tar.bz2
|
||||||
// we want to create a tar _CPack_Package/.../package-2.5.0-1-src.tar.bz2
|
// we want to create a tar _CPack_Package/.../package-2.5.0-1-src.tar.bz2
|
||||||
@ -95,7 +78,17 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
|
|||||||
// _CPack_Package/.../package-2.5.0-1.sh
|
// _CPack_Package/.../package-2.5.0-1.sh
|
||||||
// _CPack_Package/.../package-2.5.0.tar.bz2
|
// _CPack_Package/.../package-2.5.0.tar.bz2
|
||||||
// the -1 is CPACK_CYGWIN_PATCH_NUMBER
|
// the -1 is CPACK_CYGWIN_PATCH_NUMBER
|
||||||
|
|
||||||
|
// first copy the patch file and the .sh file
|
||||||
|
// to the toplevel cpack temp dir
|
||||||
|
|
||||||
// copy the patch file into place
|
// copy the patch file into place
|
||||||
|
if(!this->GetOption("CPACK_CYGWIN_PATCH_FILE"))
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
"No patch file specified for cygwin sources.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if(!cmSystemTools::CopyFileAlways(
|
if(!cmSystemTools::CopyFileAlways(
|
||||||
this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
|
this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
|
||||||
this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
|
this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
|
||||||
@ -105,6 +98,12 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
|
|||||||
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
|
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if(!this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"))
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
"No build script specified for cygwin sources.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
// copy the build script into place
|
// copy the build script into place
|
||||||
if(!cmSystemTools::CopyFileAlways(
|
if(!cmSystemTools::CopyFileAlways(
|
||||||
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
|
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
|
||||||
@ -115,7 +114,6 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
|
|||||||
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
|
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// create the tar file
|
|
||||||
std::string outerTarFile
|
std::string outerTarFile
|
||||||
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
||||||
outerTarFile += "-";
|
outerTarFile += "-";
|
||||||
@ -127,44 +125,34 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
|
|||||||
patch = "1";
|
patch = "1";
|
||||||
}
|
}
|
||||||
outerTarFile += patch;
|
outerTarFile += patch;
|
||||||
outerTarFile += "-src.tar";
|
outerTarFile += "-src.tar.bz2";
|
||||||
std::string buildScript = cmSystemTools::GetFilenameName(
|
std::string tmpDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
|
std::string buildScript = tmpDir;
|
||||||
|
buildScript += "/";
|
||||||
|
buildScript += cmSystemTools::GetFilenameName(
|
||||||
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"));
|
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"));
|
||||||
std::string patchFile = cmSystemTools::GetFilenameName(
|
std::string patchFile = tmpDir;
|
||||||
|
patchFile += "/";
|
||||||
|
patchFile += cmSystemTools::GetFilenameName(
|
||||||
this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
|
this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
|
||||||
std::vector<cmStdString> outerFiles;
|
std::vector<std::string> outerFiles;
|
||||||
std::string file = cmSystemTools::GetFilenameName(compressOutFile);
|
std::string file = cmSystemTools::GetFilenameName(compressOutFile);
|
||||||
std::string path = cmSystemTools::GetFilenamePath(compressOutFile);
|
std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile);
|
||||||
|
sourceTar += "/";
|
||||||
|
sourceTar += file;
|
||||||
// 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);
|
outerFiles.push_back(buildScript);
|
||||||
outerFiles.push_back(patchFile);
|
outerFiles.push_back(patchFile);
|
||||||
outerFiles.push_back(file);
|
outerFiles.push_back(sourceTar);
|
||||||
std::string saveDir= cmSystemTools::GetCurrentWorkingDirectory();
|
if ( !this->cmCPackTarBZip2Generator::
|
||||||
cmSystemTools::ChangeDirectory(path.c_str());
|
CompressFiles(outerTarFile.c_str(),
|
||||||
cmSystemTools::CreateTar(outerTarFile.c_str(),
|
tmpDir.c_str(), outerFiles) )
|
||||||
outerFiles, false, false);
|
|
||||||
cmSystemTools::ChangeDirectory(saveDir.c_str());
|
|
||||||
// now compress the outer tar file
|
|
||||||
if(!this->BZip2File(outerTarFile.c_str()))
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
compressOutFile = outerTarFile;
|
|
||||||
compressOutFile += ".bz2";
|
|
||||||
// now rename the file to its final name
|
|
||||||
if ( !cmSystemTools::SameFile(compressOutFile.c_str(), outFileName ) )
|
|
||||||
{
|
|
||||||
if ( !this->RenameFile(compressOutFile.c_str(), outFileName) )
|
|
||||||
{
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem renaming: \""
|
|
||||||
<< compressOutFile.c_str() << "\" to \""
|
|
||||||
<< (outFileName ? outFileName : "(NULL)") << std::endl);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user