瀏覽代碼

ENH: add support for cygwin source and binary packaging

Bill Hoffman 19 年之前
父節點
當前提交
4925e64b97

+ 35 - 0
CMakeLists.txt

@@ -388,9 +388,44 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
     SET(CPACK_SOURCE_STRIP_FILES "")
     SET(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake")
   ENDIF(WIN32 AND NOT UNIX)
+# cygwin specific packaging stuff
+  IF(CYGWIN)
+    SET(CPACK_PACKAGE_NAME cmake)
+    # setup the name of the package for cygwin cmake-2.4.3
+    SET(CPACK_PACKAGE_FILE_NAME
+      "${CPACK_PACKAGE_NAME}-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
+    # the source has the same name as the binary
+    SET(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
+    # Create a cygwin version number in case there are changes for cygwin
+    # that are not reflected upstream in CMake
+    SET(CPACK_CYGWIN_PATCH_NUMBER 1)
+    # if we are on cygwin and have cpack, then force the 
+    # doc, data and man dirs to conform to cygwin style directories
+    SET(CMAKE_DOC_DIR "/share/doc/${CPACK_PACKAGE_FILE_NAME}")
+    SET(CMAKE_DATA_DIR "/share/${CPACK_PACKAGE_FILE_NAME}")
+    SET(CMAKE_MAN_DIR "/share/man")
+    # let the user know we just forced these values
+    MESSAGE(STATUS "Setup for Cygwin packaging")
+    MESSAGE(STATUS "Override cache CMAKE_DOC_DIR = ${CMAKE_DOC_DIR}")
+    MESSAGE(STATUS "Override cache CMAKE_DATA_DIR = ${CMAKE_DATA_DIR}")
+    MESSAGE(STATUS "Override cache CMAKE_MAN_DIR = ${CMAKE_MAN_DIR}")
+    # These files are required by the cmCPackCygwinSourceGenerator and the files
+    # put into the release tar files.
+    SET(CPACK_CYGWIN_BUILD_SCRIPT 
+      "${CMake_BINARY_DIR}/@CPACK_PACKAGE_FILE_NAME@-@[email protected]")
+    SET(CPACK_CYGWIN_PATCH_FILE 
+      "${CMake_BINARY_DIR}/@CPACK_PACKAGE_FILE_NAME@-@[email protected]")
+    # include the sub directory for cygwin releases
+    SUBDIRS(Utilities/Release/Cygwin)
+    # when packaging source make sure the .build directory is not included
+    SET(CPACK_SOURCE_IGNORE_FILES
+      "/CVS/" "/\\\\.build/" "/\\\\.svn/" "\\\\.swp$" "\\\\.#" "/#" "~$")
+  ENDIF(CYGWIN)
+  # include CPack model once all variables are set
   INCLUDE(CPack)
 ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
 
+# configure the CTestScript.cmake file into the binary directory
 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in"
   "${CMAKE_CURRENT_BINARY_DIR}/CTestScript.cmake"
   @ONLY IMMEDIATE)

+ 4 - 0
Modules/CPack.cmake

@@ -99,6 +99,10 @@ IF(NOT CPACK_GENERATOR)
       SET(CPACK_GENERATOR "STGZ;TGZ;TZ")
     ENDIF(APPLE)
     SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")
+    IF(CYGWIN)
+      SET(CPACK_SOURCE_GENERATOR "CygwinSource")
+      SET(CPACK_GENERATOR "CygwinBinary")
+    ENDIF(CYGWIN)
   ELSE(UNIX)
     SET(CPACK_GENERATOR "NSIS;ZIP")
     SET(CPACK_SOURCE_GENERATOR "ZIP")

+ 2 - 0
Source/CMakeLists.txt

@@ -295,6 +295,8 @@ SET(CPACK_SRCS
   CPack/cmCPackTarBZip2Generator.cxx
   CPack/cmCPackTarCompressGenerator.cxx
   CPack/cmCPackZIPGenerator.cxx
+  CPack/cmCPackCygwinBinaryGenerator.cxx
+  CPack/cmCPackCygwinSourceGenerator.cxx
   )
 # Build CPackLib
 ADD_LIBRARY(CPackLib ${CPACK_SRCS})

+ 2 - 0
Source/CPack/bills-comments.txt

@@ -6,6 +6,7 @@ cmCPackGenerators  -- creates cmCPackGenericGenerator's via NewGenerator
 
 cmCPackGenericGenerator::Initialize
    this->InitializeInternal
+     CPACK_INCLUDE_TOPLEVEL_DIRECTORY = 0 turns off 
 
 
 // binary package run
@@ -64,3 +65,4 @@ break up cmCPackGenerator::InstallProject so it calls the following:
 // run the cmake install scripts if provided
   cmCPackGenerator::RunCMakeInstallScripts()  
 
+-

+ 16 - 8
Source/CPack/cmCPackCygwinBinaryGenerator.cxx

@@ -41,7 +41,7 @@ cmCPackCygwinBinaryGenerator::~cmCPackCygwinBinaryGenerator()
 //----------------------------------------------------------------------
 int cmCPackCygwinBinaryGenerator::InitializeInternal()
 {
-  this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1");
+  this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
   std::vector<std::string> path;
   std::string pkgPath = cmSystemTools::FindProgram("bzip2", path, false);
   if ( pkgPath.empty() )
@@ -62,13 +62,16 @@ int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName,
   const char* toplevel, const std::vector<std::string>& files)
 {
   std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
+  packageName += "-";
   packageName += this->GetOption("CPACK_PACKAGE_VERSION");
   packageName = cmsys::SystemTools::LowerCase(packageName);
-  std::string manifest = "/share/doc/";
+  std::string manifest = "/usr/share/doc/";
   manifest += packageName;
   manifest += "/MANIFEST";
   std::string manifestFile 
     = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+  // Create a MANIFEST file that contains all of the files in
+  // the tar file
   std::string tempdir = manifestFile;
   manifestFile += manifest;
   // create an extra scope to force the stream
@@ -78,18 +81,23 @@ int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName,
   for(std::vector<std::string>::const_iterator i = files.begin();
       i != files.end(); ++i)
     {
-#undef cerr
     // remove the temp dir and replace with /usr
-    ofs << "/usr" << (*i).substr(tempdir.size()) << "\n";
-    std::cerr << "/usr" << (*i).substr(tempdir.size()) << "\n";
-    
+    ofs << (*i).substr(tempdir.size()) << "\n";
     }
-  ofs << "/usr" << manifest << "\n";
+  ofs << manifest << "\n";
   }
-  // Now compress up everything
+  // add the manifest file to the list of all files
   std::vector<std::string> filesWithManifest = files;
   filesWithManifest.push_back(manifestFile);
+  // create the bzip2 tar file 
   return this->Superclass::CompressFiles(outFileName, toplevel, 
                                          filesWithManifest);
 }
 
+const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
+{
+  this->OutputExtension = "-";
+  this->OutputExtension += this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
+  this->OutputExtension += ".tar.bz2";
+  return this->OutputExtension.c_str();
+}

+ 3 - 2
Source/CPack/cmCPackCygwinBinaryGenerator.h

@@ -33,12 +33,13 @@ public:
    */
   cmCPackCygwinBinaryGenerator();
   virtual ~cmCPackCygwinBinaryGenerator();
-
 protected:
+  virtual const char* GetInstallPrefix() { return "/usr"; }
   virtual int InitializeInternal();
   int CompressFiles(const char* outFileName, const char* toplevel,
     const std::vector<std::string>& files);
-
+  virtual const char* GetOutputExtension();
+  std::string OutputExtension;
 };
 
 #endif

+ 18 - 23
Source/CPack/cmCPackCygwinSourceGenerator.cxx

@@ -69,36 +69,29 @@ int cmCPackCygwinSourceGenerator::InitializeInternal()
 int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
   const char* toplevel, const std::vector<std::string>& files)
 {
+  // Create a tar file of the sources
   std::string packageDirFileName
     = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
   packageDirFileName += ".tar";
   std::string output;
   int retVal = -1;
-  if ( !this->Superclass::CompressFiles(packageDirFileName.c_str(),
+  // skip one parent up to the cmCPackTGZGenerator to create tar file
+  this->Compress = false; // just create tar not tar.gz
+  if ( !this->cmCPackTGZGenerator::CompressFiles(packageDirFileName.c_str(),
       toplevel, files) )
     {
     return 0;
     }
-  cmOStringStream dmgCmd1;
-  dmgCmd1 << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
-    << "\" \"" << packageDirFileName
-    << "\"";
-  retVal = -1;
-  int res = cmSystemTools::RunSingleCommand(dmgCmd1.str().c_str(), &output,
-    &retVal, toplevel, this->GeneratorVerbose, 0);
-  if ( !res || retVal )
-    {
-    std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
-    tmpFile += "/CompressBZip2.log";
-    cmGeneratedFileStream ofs(tmpFile.c_str());
-    ofs << "# Run command: " << dmgCmd1.str().c_str() << std::endl
-      << "# Output:" << std::endl
-      << output.c_str() << std::endl;
-    cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running BZip2 command: "
-      << dmgCmd1.str().c_str() << std::endl
-      << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+  // 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
+  // and the CPACK_CYGWIN_PATCH_FILE and CPACK_TOPLEVEL_DIRECTORY
+  // files
   std::string compressOutFile = packageDirFileName + ".bz2";
   // at this point compressOutFile is the full path to 
   // _CPack_Package/.../package-2.5.0.tar.bz2
@@ -108,7 +101,8 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
   //   _CPack_Package/.../package-2.5.0-1.sh
   //   _CPack_Package/.../package-2.5.0.tar.bz2
   // the -1 is CPACK_CYGWIN_PATCH_NUMBER
-  if(!cmSystemTools::CopyFileIfDifferent(
+  // copy the patch file into place
+  if(!cmSystemTools::CopyFileAlways(
        this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
        this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
     {
@@ -117,7 +111,8 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
                   << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
     return 0;
     }
-  if(!cmSystemTools::CopyFileIfDifferent(
+  // copy the build script into place
+  if(!cmSystemTools::CopyFileAlways(
        this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
        this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
     {
@@ -126,7 +121,7 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
                   << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
     return 0;
     }
-                                     
+  // create the tar file 
   std::string outerTarFile
     = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
   outerTarFile += "-";
@@ -151,6 +146,7 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
   cmSystemTools::CreateTar(outerTarFile.c_str(),
                            outerFiles, false, false);
   cmSystemTools::ChangeDirectory(saveDir.c_str());
+  // now compress the outer tar file
   if(!this->BZip2File(outerTarFile.c_str()))
     {
     return 0;
@@ -168,7 +164,6 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName,
       return 0;
       }
     }
-
   return 1;
 }
 

+ 1 - 1
Source/CPack/cmCPackCygwinSourceGenerator.h

@@ -26,7 +26,7 @@
 class cmCPackCygwinSourceGenerator : public cmCPackTarBZip2Generator
 {
 public:
-  cmCPackTypeMacro(cmCPackCygwinSourceGenerator, cmCPackTGZGenerator);
+  cmCPackTypeMacro(cmCPackCygwinSourceGenerator, cmCPackTarBZip2Generator);
 
   /**
    * Construct generator

+ 12 - 0
Source/CPack/cmCPackGenerators.cxx

@@ -31,6 +31,11 @@
 #  include "cmCPackOSXX11Generator.h"
 #endif
 
+#ifdef __CYGWIN__
+#  include "cmCPackCygwinBinaryGenerator.h"
+#  include "cmCPackCygwinSourceGenerator.h"
+#endif
+
 #include "cmCPackLog.h"
 
 //----------------------------------------------------------------------
@@ -44,6 +49,13 @@ cmCPackGenerators::cmCPackGenerators()
   this->RegisterGenerator("NSIS", "Null Soft Installer",
     cmCPackNSISGenerator::CreateGenerator);
 #endif
+#ifdef __CYGWIN__
+  this->RegisterGenerator("CygwinBinary", "Cygwin Binary Installer",
+                          cmCPackCygwinBinaryGenerator::CreateGenerator);
+  this->RegisterGenerator("CygwinSource", "Cygwin Source Installer",
+                          cmCPackCygwinSourceGenerator::CreateGenerator);
+#endif
+
   this->RegisterGenerator("ZIP", "ZIP file format",
     cmCPackZIPGenerator::CreateGenerator);
   this->RegisterGenerator("TBZ2", "Tar BZip2 compression",

+ 5 - 4
Source/CPack/cmCPackGenericGenerator.cxx

@@ -74,7 +74,6 @@ int cmCPackGenericGenerator::PrepareNames()
 
   std::string outName = this->GetOption("CPACK_PACKAGE_FILE_NAME");
   tempDirectory += "/" + outName;
-  outName += ".";
   outName += this->GetOutputExtension();
 
   std::string destFile = this->GetOption("CPACK_PACKAGE_DIRECTORY");
@@ -82,7 +81,6 @@ int cmCPackGenericGenerator::PrepareNames()
 
   std::string outFile = topDirectory + "/" + outName;
   std::string installPrefix = tempDirectory + this->GetInstallPrefix();
-
   this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str());
   this->SetOptionIfNotSet("CPACK_TEMPORARY_DIRECTORY", tempDirectory.c_str());
   this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_NAME", outName.c_str());
@@ -106,7 +104,8 @@ int cmCPackGenericGenerator::PrepareNames()
     if ( !cmSystemTools::FileExists(descFileName) )
       {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Cannot find description file name: " << descFileName << std::endl);
+                    "Cannot find description file name: [" 
+                    << descFileName << "]" << std::endl);
       return 0;
       }
     std::ifstream ifs(descFileName);
@@ -235,6 +234,7 @@ int cmCPackGenericGenerator::InstallProject()
       {
       std::string fileName = tempInstallDirectory;
       fileName += "/" + *it;
+      fileName += cmSystemTools::GetExecutableExtension();
       cmCPackLogger(cmCPackLog::LOG_VERBOSE,
         "    Strip file: " << fileName.c_str()
         << std::endl);
@@ -344,7 +344,8 @@ int cmCPackGenericGenerator::InstallProjectViaInstalledDirectories(
       return 0;
       }
     std::vector<std::string>::iterator it;
-    const char* tempDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+    const char* tempDir = tempInstallDirectory;
+// this->GetOption("CPACK_TEMPORARY_DIRECTORY");
     for ( it = installDirectoriesVector.begin();
       it != installDirectoriesVector.end();
       ++it )

+ 1 - 1
Source/CPack/cmCPackGenericGenerator.h

@@ -94,7 +94,7 @@ protected:
   int PrepareNames();
   int InstallProject();
   int CleanTemporaryDirectory();
-  virtual const char* GetOutputExtension() { return "cpack"; }
+  virtual const char* GetOutputExtension() { return ".cpack"; }
   virtual const char* GetOutputPostfix() { return 0; }
   virtual int CompressFiles(const char* outFileName, const char* toplevel,
     const std::vector<std::string>& files);

+ 1 - 1
Source/CPack/cmCPackNSISGenerator.h

@@ -41,7 +41,7 @@ protected:
   virtual int InitializeInternal();
   int CompressFiles(const char* outFileName, const char* toplevel,
     const std::vector<std::string>& files);
-  virtual const char* GetOutputExtension() { return "exe"; }
+  virtual const char* GetOutputExtension() { return ".exe"; }
   virtual const char* GetOutputPostfix() { return "win32"; }
 
   bool GetListOfSubdirectories(const char* dir,

+ 1 - 1
Source/CPack/cmCPackOSXX11Generator.h

@@ -40,7 +40,7 @@ protected:
   virtual int InitializeInternal();
   int CompressFiles(const char* outFileName, const char* toplevel,
     const std::vector<std::string>& files);
-  virtual const char* GetOutputExtension() { return "dmg"; }
+  virtual const char* GetOutputExtension() { return ".dmg"; }
   virtual const char* GetInstallPrefix() { return ".app/Contents/Resources"; }
 
   //bool CopyCreateResourceFile(const char* name, const char* dir);

+ 1 - 1
Source/CPack/cmCPackPackageMakerGenerator.h

@@ -42,7 +42,7 @@ protected:
   virtual int InitializeInternal();
   int CompressFiles(const char* outFileName, const char* toplevel,
     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* GetInstallPrefix() { return "/usr"; }
 

+ 1 - 1
Source/CPack/cmCPackSTGZGenerator.h

@@ -41,7 +41,7 @@ protected:
     const std::vector<std::string>& files);
   virtual int InitializeInternal();
   int GenerateHeader(std::ostream* os);
-  virtual const char* GetOutputExtension() { return "sh"; }
+  virtual const char* GetOutputExtension() { return ".sh"; }
 };
 
 #endif

+ 1 - 1
Source/CPack/cmCPackTGZGenerator.h

@@ -44,7 +44,7 @@ protected:
   virtual int GenerateHeader(std::ostream* os);
   int CompressFiles(const char* outFileName, const char* toplevel,
     const std::vector<std::string>& files);
-  virtual const char* GetOutputExtension() { return "tar.gz"; }
+  virtual const char* GetOutputExtension() { return ".tar.gz"; }
 
   bool Compress;
 };

+ 26 - 14
Source/CPack/cmCPackTarBZip2Generator.cxx

@@ -66,27 +66,17 @@ int cmCPackTarBZip2Generator::InitializeInternal()
 }
 
 //----------------------------------------------------------------------
-int cmCPackTarBZip2Generator::CompressFiles(const char* outFileName,
-  const char* toplevel, const std::vector<std::string>& files)
+int cmCPackTarBZip2Generator::BZip2File(const char* packageDirFileName)
 {
-  std::string packageDirFileName
-    = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
-  packageDirFileName += ".tar";
-  std::string output;
-  int retVal = -1;
-  if ( !this->Superclass::CompressFiles(packageDirFileName.c_str(),
-      toplevel, files) )
-    {
-    return 0;
-    }
-
+  int retVal = 0;
   cmOStringStream dmgCmd1;
   dmgCmd1 << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
     << "\" \"" << packageDirFileName
     << "\"";
   retVal = -1;
+  std::string output;
   int res = cmSystemTools::RunSingleCommand(dmgCmd1.str().c_str(), &output,
-    &retVal, toplevel, this->GeneratorVerbose, 0);
+    &retVal, 0, this->GeneratorVerbose, 0);
   if ( !res || retVal )
     {
     std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -100,7 +90,29 @@ int cmCPackTarBZip2Generator::CompressFiles(const char* outFileName,
       << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
     return 0;
     }
+  return 1;
+}
+
+//----------------------------------------------------------------------
+int cmCPackTarBZip2Generator::CompressFiles(const char* outFileName,
+  const char* toplevel, const std::vector<std::string>& files)
+{
+  std::string packageDirFileName
+    = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+  packageDirFileName += ".tar";
+  std::string output;
+  int retVal = -1;
+  if ( !this->Superclass::CompressFiles(packageDirFileName.c_str(),
+      toplevel, files) )
+    {
+    return 0;
+    }
 
+  if(!this->BZip2File(packageDirFileName.c_str()))
+    {
+    return 0;
+    }
+  
   std::string compressOutFile = packageDirFileName + ".bz2";
   if ( !cmSystemTools::SameFile(compressOutFile.c_str(), outFileName ) )
     {

+ 2 - 2
Source/CPack/cmCPackTarBZip2Generator.h

@@ -39,8 +39,8 @@ protected:
   virtual int InitializeInternal();
   int CompressFiles(const char* outFileName, const char* toplevel,
     const std::vector<std::string>& files);
-  virtual const char* GetOutputExtension() { return "tar.bz2"; }
-
+  virtual const char* GetOutputExtension() { return ".tar.bz2"; }
+  int BZip2File(const char* filename);
   int RenameFile(const char* oldname, const char* newname);
 };
 

+ 1 - 1
Source/CPack/cmCPackTarCompressGenerator.h

@@ -39,7 +39,7 @@ protected:
   virtual int InitializeInternal();
   int CompressFiles(const char* outFileName, const char* toplevel,
     const std::vector<std::string>& files);
-  virtual const char* GetOutputExtension() { return "tar.Z"; }
+  virtual const char* GetOutputExtension() { return ".tar.Z"; }
 
   int RenameFile(const char* oldname, const char* newname);
   int GenerateHeader(std::ostream* os);

+ 1 - 1
Source/CPack/cmCPackZIPGenerator.h

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

+ 2 - 2
Source/CPack/cygwin.readme

@@ -37,8 +37,8 @@ normal binary release with use as the root of the tree:
 
 Here is the bootstrap command used:
 
-  ${SOURCE_DIR}/bootstrap --prefix=${PREFIX} --datadir=/share/${PKG}-${VER} \
-                          --docdir=/share/doc/${PKG}-${VER} --mandir=/share/man
+  ${SOURCE_DIR}/bootstrap --prefix=/usr --datadir=/share/cmake-${VER} \
+                          --docdir=/share/doc/cmake-${VER} --mandir=/share/man
 
 CMAKE_DOC_DIR    /share/doc/${PKG}-${VER}
 CMAKE_MAN_DIR    /share/man

+ 2 - 2
Utilities/Release/Cygwin/CMakeLists.txt

@@ -14,9 +14,9 @@ MESSAGE(STATUS "Using curses version: libncurses${MAX}")
 CONFIGURE_FILE("${CMake_SOURCE_DIR}/Utilities/Release/Cygwin/cygwin-setup.hint.in"
   "${CMake_BINARY_DIR}/setup.hint")
 CONFIGURE_FILE("${CMake_SOURCE_DIR}/Utilities/Release/Cygwin/README.cygwin.in"
-  "${CMake_BINARY_DIR}/Docs/@CYGWIN_PACKAGE_NAME@-@[email protected]")
+  "${CMake_BINARY_DIR}/Docs/@CPACK_PACKAGE_FILE_NAME@-@[email protected]")
 INSTALL_FILES(/share/doc/Cygwin FILES
-  ${CMake_BINARY_DIR}/Docs/@CYGWIN_PACKAGE_NAME@-@[email protected]
+  ${CMake_BINARY_DIR}/Docs/@CPACK_PACKAGE_FILE_NAME@-@[email protected]
   )
 CONFIGURE_FILE("${CMake_SOURCE_DIR}/Utilities/Release/Cygwin/cygwin-package.sh.in"
   ${CPACK_CYGWIN_BUILD_SCRIPT})

+ 6 - 6
Utilities/Release/Cygwin/README.cygwin.in

@@ -16,22 +16,22 @@ Canonical download:
 ------------------------------------
 
 Build instructions:
-  unpack @CYGWIN_SRC_PACKAGE_NAME@.tar.bz2
+  unpack @CPACK_PACKAGE_FILE_NAME@-@CPACK_CYGWIN_PATCH_NUMBER@-src.tar.bz2
     if you use setup to install this src package, it will be
          unpacked under /usr/src automatically
   cd /usr/src
-  ./@C[email protected]
+  ./@CPACK_PACKAGE_FILE_NAME@-@[email protected] all
 
 This will create:
-  /usr/src/@CYGWIN_PACKAG[email protected]
-  /usr/src/@CYGWIN_SRC_PACKAGE_NAME@.tar.bz2
+  /usr/src/@CPACK_PACKAGE_FIL[email protected]
+  /usr/src/@CPACK_PACKAGE_FILE_NAME@-@CPACK_CYGWIN_PATCH_NUMBER@-src.tar.bz2
 
 -------------------------------------------
 
 Port Notes:
 
-The directory /usr/share/@CPACK_CYGWIN_NAME@/include is purposely not
-located at /usr/include/@CPACK_CYGWIN_NAME@ or /usr/include/cmake.  The
+The directory /usr/share/@CPACK_PACKAGE_FILE_NAME@/include is purposely not
+located at /usr/include/@CPACK_PACKAGE_FILE_NAME@ or /usr/include/cmake.  The
 files it contains are not meant for inclusion in any C or C++ program.
 They are used for compiling dynamically loadable CMake commands inside
 projects that provide them.  CMake will automatically provide the

+ 90 - 13
Utilities/Release/Cygwin/cygwin-package.sh.in

@@ -1,13 +1,90 @@
-tdir=`pwd`
-tar xvfj @[email protected] &&
-cd @CYGWIN_SRC_PACKAGE_NAME@ && 
-mkdir .build &&
-cd .build &&
-../bootstrap --parallel=2 && 
-make -j2 && 
-make test && 
-./bin/cpack && 
-./bin/cpack --config  CPackSourceConfig.cmake
-
-mv @CYGWIN_SRC_PACKAGE_NAME@-@[email protected] "$tdir"
-mv @CYGWIN_PACKAGE_NAME@-@[email protected] "$tdir"
+TOP_DIR=`cd \`echo "$0" | sed -n '/\//{s/\/[^\/]*$//;p;}'\`;pwd`
+
+# create build directory
+mkdirs()
+{
+  (
+  mkdir -p "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" 
+  )
+}
+
+# cd into 
+# untar source tree and apply patch
+prep()
+{
+  (
+  cd "$TOP_DIR" &&
+  tar xvfj @[email protected]
+  patch -p0 < "@CPACK_PACKAGE_FILE_NAME@-@[email protected]" &&
+  mkdirs
+  )
+}
+
+conf()
+{
+  (
+  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" && 
+  ../bootstrap --parallel=2
+  )
+}
+
+build()
+{
+  (
+  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" &&
+  make -j2 &&
+  make test
+  )
+}
+
+clean()
+{
+  (
+  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" &&
+  make clean
+  )
+}
+
+pkg()
+{
+  (
+  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" &&
+  ./bin/cpack && 
+  mv @CPACK_PACKAGE_FILE_NAME@-@[email protected] "$TOP_DIR"     
+  )
+}
+
+spkg()
+{
+ (
+  cd "$TOP_DIR/@CPACK_PACKAGE_FILE_NAME@/.build" &&
+  ./bin/cpack --config  CPackSourceConfig.cmake &&
+  mv @CPACK_PACKAGE_FILE_NAME@-@[email protected] "$TOP_DIR" 
+  )
+}
+
+finish()
+{
+  (
+  rm -rf "@CPACK_PACKAGE_FILE_NAME@"
+  )
+}
+
+case $1 in
+  prep)         prep    ; STATUS=$? ;;
+  mkdirs)       mkdirs  ; STATUS=$? ;;
+  conf)         conf    ; STATUS=$? ;;
+  build)        build   ; STATUS=$? ;;
+  clean)        clean   ; STATUS=$? ;;
+  package)      pkg     ; STATUS=$? ;;
+  pkg)          pkg     ; STATUS=$? ;;
+  src-package)  spkg    ; STATUS=$? ;;
+  spkg)         spkg    ; STATUS=$? ;;
+  finish)       finish  ; STATUS=$? ;;
+  all) (
+       prep && conf && build && pkg && spkg && finish ;
+       STATUS=$?
+       ) ;;
+  *) echo "Error: bad argument (all or one of these: prep mkdirs conf build clean package pkg src-package spkg finish)" ; exit 1 ;;
+esac
+exit ${STATUS}

+ 1 - 0
Utilities/Release/create-cmake-release.cmake

@@ -10,6 +10,7 @@ set(RELEASE_SCRIPTS
   dashsgi1_release.cmake      # IRIX
   dashsgi1_release64.cmake    # IRIX 64
   vogon_release.cmake         # Windows
+  discworld_cygwin.cmake         # Cygwin
 #  r36n11_aix_release.cmake   # AIX 5.3
   r15n65_aix_release.cmake   # AIX 5.2
 )

+ 9 - 2
Utilities/Release/release_cmake.cmake

@@ -76,8 +76,12 @@ configure_file(${SCRIPT_PATH}/release_cmake.sh.in ${SCRIPT_FILE} @ONLY)
 
 # run the script by starting a shell on the remote machine
 # then using the script file as input to the shell
-remote_command("run release_cmake-${HOST}.sh on server"
-  "${RUN_SHELL}" ${SCRIPT_FILE})
+IF(RUN_LOCAL)
+  message(FATAL_ERROR "run this command: ${RUN_SHELL} ${SCRIPT_FILE}")
+ELSE(RUN_LOCAL)
+  remote_command("run release_cmake-${HOST}.sh on server"
+    "${RUN_SHELL}" ${SCRIPT_FILE})
+ENDIF(RUN_LOCAL)
 
 # now figure out which types of packages were created 
 set(generators ${CPACK_BINARY_GENERATORS} ${CPACK_SOURCE_GENERATORS})
@@ -95,6 +99,9 @@ foreach(gen ${generators})
   if("${gen}" STREQUAL "TBZ2")
     set(SUFFIXES ${SUFFIXES} "*.tar.bz2")
   endif("${gen}" STREQUAL "TBZ2")
+  if("${gen}" MATCHES "Cygwin")
+    set(SUFFIXES ${SUFFIXES} "*.tar.bz2")
+  endif("${gen}" STREQUAL "Cygwin")
   if("${gen}" STREQUAL "TZ")
     set(SUFFIXES ${SUFFIXES} "*.tar.Z")
   endif("${gen}" STREQUAL "TZ")