ENH: apply patch from Mathieu which creates a deb file (not finishsed yet)

Alex
This commit is contained in:
Alexander Neundorf 2007-07-25 13:08:17 -04:00
parent 8796bfcbaf
commit 9c2d6f98d7
2 changed files with 110 additions and 9 deletions

View File

@ -41,11 +41,116 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
{
const char* arExecutable = this->GetOption("AR_EXECUTABLE");
const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND");
(void) outFileName;
(void) toplevel;
(void) files;
(void) arExecutable;
(void) cmakeExecutable;
// debian-binary file
std::string dbfilename;
dbfilename = toplevel;
dbfilename += "/debian-binary";
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(dbfilename.c_str());
out << "2.0";
out << std::endl; // required for valid debian package
}
// debian policy enforce lower case for package name
// IF(NOT DEBIAN_PACKAGE_NAME)
// STRING(TOLOWER
// ${CPACK_PACKAGE_NAME}
// DEBIAN_PACKAGE_NAME
// )
// control file
std::string ctlfilename;
ctlfilename = toplevel;
ctlfilename += "/control";
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(ctlfilename.c_str());
out << "Package: ${DEBIAN_PACKAGE_NAME}\n";
out << "Version: ${CPACK_PACKAGE_VERSION}\n";
out << "Section: devel\n";
out << "Priority: optional\n";
out << "Architecture: ${DEBIAN_ARCHITECTURE}\n";
out << "Depends: ${DEBIAN_PACKAGE_DEPENDS}\n";
out << "Maintainer: ${CPACK_NSIS_CONTACT}\n";
out << "Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n";
out << "${DEBIAN_PACKAGE_NAME} was packaged by UseDebian and CMake.\n";
out << std::endl;
}
std::string output;
std::string cmd;
// cmd = this->GetOption("CPACK_DEB_COMMAND");
// cmsys::SystemTools::ReplaceString(cmd, "<ARCHIVE>", outFileName);
// cmsys::SystemTools::ReplaceString(cmd, "<FILELIST>", "deb.filelist");
cmd = cmakeExecutable;
cmd += " -E tar cfz data.tar.gz ./usr";
int retVal = -1;
int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0);
if ( !res || retVal )
{
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/Deb.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << cmd.c_str() << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
<< cmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
return 0;
}
std::string md5filename;
md5filename = toplevel;
md5filename += "/md5sums";
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(md5filename.c_str());
std::vector<std::string>::const_iterator fileIt;
for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
{
cmd = cmakeExecutable;
cmd += " -E md5sum ";
cmd += *fileIt;
//std::string output;
//int retVal = -1;
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0);
out << output;
}
out << std::endl;
}
cmd = cmakeExecutable;
cmd += " -E tar cfz control.tar.gz ./control ./md5sums";
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0);
if ( !res || retVal )
{
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/Deb.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << cmd.c_str() << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
<< cmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
return 0;
}
// ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz
cmd = arExecutable;
cmd += " -r \"";
cmd += outFileName;
cmd += "\" debian-binary control.tar.gz data.tar.gz";
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0);
return 1;
}

View File

@ -90,7 +90,6 @@ cmCPackGenerators::~cmCPackGenerators()
cmCPackGenericGenerator* cmCPackGenerators::NewGenerator(const char* name)
{
cmCPackGenericGenerator* gen = this->NewGeneratorInternal(name);
fprintf(stderr, "********* NewGen %s\n", name);
if ( !gen )
{
return 0;
@ -106,15 +105,12 @@ cmCPackGenericGenerator* cmCPackGenerators::NewGeneratorInternal(
{
if ( !name )
{
fprintf(stderr, "*** 1 name==0\n");
return 0;
}
fprintf(stderr, "*** 2 name==%s\n", name);
cmCPackGenerators::t_GeneratorCreatorsMap::iterator it
= this->GeneratorCreators.find(name);
if ( it == this->GeneratorCreators.end() )
{
fprintf(stderr, "*** 2 name==%s not found\n", name);
return 0;
}
return (it->second)();