Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / CPack / cmCPackCygwinBinaryGenerator.cxx
blobac0aae86b42ce6c5003ee8e5413287f530043c1a
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCPackCygwinBinaryGenerator.cxx,v $
5 Language: C++
6 Date: $Date: 2008-03-07 16:06:44 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
18 #include "cmCPackCygwinBinaryGenerator.h"
20 #include "cmake.h"
21 #include "cmGlobalGenerator.h"
22 #include "cmLocalGenerator.h"
23 #include "cmSystemTools.h"
24 #include "cmMakefile.h"
25 #include "cmGeneratedFileStream.h"
26 #include "cmCPackLog.h"
28 #include <cmsys/SystemTools.hxx>
30 //----------------------------------------------------------------------
31 cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator()
33 this->Compress = false;
36 //----------------------------------------------------------------------
37 cmCPackCygwinBinaryGenerator::~cmCPackCygwinBinaryGenerator()
41 //----------------------------------------------------------------------
42 int cmCPackCygwinBinaryGenerator::InitializeInternal()
44 this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
45 this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
46 std::vector<std::string> path;
47 std::string pkgPath = cmSystemTools::FindProgram("bzip2", path, false);
48 if ( pkgPath.empty() )
50 cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find BZip2" << std::endl);
51 return 0;
53 this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
54 cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found Compress program: "
55 << pkgPath.c_str()
56 << std::endl);
58 return this->Superclass::InitializeInternal();
61 //----------------------------------------------------------------------
62 int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName,
63 const char* toplevel, const std::vector<std::string>& files)
65 std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
66 packageName += "-";
67 packageName += this->GetOption("CPACK_PACKAGE_VERSION");
68 packageName = cmsys::SystemTools::LowerCase(packageName);
69 std::string manifest = "/usr/share/doc/";
70 manifest += packageName;
71 manifest += "/MANIFEST";
72 std::string manifestFile
73 = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
74 // Create a MANIFEST file that contains all of the files in
75 // the tar file
76 std::string tempdir = manifestFile;
77 manifestFile += manifest;
78 // create an extra scope to force the stream
79 // to create the file before the super class is called
81 cmGeneratedFileStream ofs(manifestFile.c_str());
82 for(std::vector<std::string>::const_iterator i = files.begin();
83 i != files.end(); ++i)
85 // remove the temp dir and replace with /usr
86 ofs << (*i).substr(tempdir.size()) << "\n";
88 ofs << manifest << "\n";
90 // add the manifest file to the list of all files
91 std::vector<std::string> filesWithManifest = files;
92 filesWithManifest.push_back(manifestFile);
93 // create the bzip2 tar file
94 return this->Superclass::CompressFiles(outFileName, toplevel,
95 filesWithManifest);
98 const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
100 this->OutputExtension = "-";
101 const char* patchNumber =this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
102 if(!patchNumber)
104 patchNumber = "1";
105 cmCPackLogger(cmCPackLog::LOG_WARNING,
106 "CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
107 << std::endl);
109 this->OutputExtension +=
110 this->OutputExtension += ".tar.bz2";
111 return this->OutputExtension.c_str();