cmCPackSTGZGenerator.cxx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmCPackSTGZGenerator.h"
  14. #include "cmake.h"
  15. #include "cmGlobalGenerator.h"
  16. #include "cmLocalGenerator.h"
  17. #include "cmSystemTools.h"
  18. #include "cmMakefile.h"
  19. #include "cmCPackLog.h"
  20. //----------------------------------------------------------------------
  21. cmCPackSTGZGenerator::cmCPackSTGZGenerator()
  22. {
  23. }
  24. //----------------------------------------------------------------------
  25. cmCPackSTGZGenerator::~cmCPackSTGZGenerator()
  26. {
  27. }
  28. //----------------------------------------------------------------------
  29. int cmCPackSTGZGenerator::InitializeInternal()
  30. {
  31. this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
  32. return this->Superclass::InitializeInternal();
  33. }
  34. //----------------------------------------------------------------------
  35. int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
  36. {
  37. cmCPackLogger(cmCPackLog::LOG_DEBUG, "Writing header" << std::endl);
  38. *os
  39. << "#!/bin/sh" << std::endl
  40. << "echo \"" << this->GetOption("CPACK_PACKAGE_NAME")
  41. << " - self-extracting archive.\"" << std::endl
  42. << "echo \"If you want to stop extracting, please press <ctrl-C>.\""
  43. << std::endl
  44. << "read line" << std::endl
  45. << "echo \"Extracting... Please wait...\"" << std::endl
  46. << "echo \"\"" << std::endl
  47. << "" << std::endl
  48. << "# take the archive portion of this file and pipe it to tar"
  49. << std::endl
  50. << "# the NUMERIC parameter in this command should be one more"
  51. << std::endl
  52. << "# than the number of lines in this header file" << std::endl
  53. << "tail +18 \"$0\" | gunzip | tar xf -" << std::endl
  54. << "" << std::endl
  55. << "exit 0" << std::endl
  56. << "echo \"\"" << std::endl
  57. << "#-----------------------------------------------------------"
  58. << std::endl
  59. << "# Start of TAR.GZ file" << std::endl
  60. << "#-----------------------------------------------------------"
  61. << std::endl;
  62. return this->Superclass::GenerateHeader(os);
  63. }