CPack.STGZ_Header.sh.in 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #!/bin/sh
  2. # Display usage
  3. cpack_usage()
  4. {
  5. cat <<EOF
  6. Usage: $0 [options]
  7. Options: [defaults in brackets after descriptions]
  8. --help print this message
  9. --version print cmake installer version
  10. --prefix=dir directory in which to install
  11. --include-subdir include the @CPACK_PACKAGE_FILE_NAME@ subdirectory
  12. --exclude-subdir exclude the @CPACK_PACKAGE_FILE_NAME@ subdirectory
  13. --skip-license accept license
  14. EOF
  15. exit 1
  16. }
  17. cpack_echo_exit()
  18. {
  19. echo $1
  20. exit 1
  21. }
  22. # Display version
  23. cpack_version()
  24. {
  25. echo "@CPACK_PACKAGE_NAME@ Installer Version: @CPACK_PACKAGE_VERSION@, Copyright (c) @CPACK_PACKAGE_VENDOR@"
  26. }
  27. # Helper function to fix windows paths.
  28. cpack_fix_slashes ()
  29. {
  30. echo "$1" | sed 's/\\/\//g'
  31. }
  32. interactive=TRUE
  33. cpack_skip_license=FALSE
  34. cpack_include_subdir=""
  35. for a in "$@CPACK_AT_SIGN@"; do
  36. if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
  37. cpack_prefix_dir=`echo $a | sed "s/^--prefix=//"`
  38. cpack_prefix_dir=`cpack_fix_slashes "${cpack_prefix_dir}"`
  39. fi
  40. if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
  41. cpack_usage
  42. fi
  43. if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
  44. cpack_version
  45. exit 2
  46. fi
  47. if echo $a | grep "^--include-subdir" > /dev/null 2> /dev/null; then
  48. cpack_include_subdir=TRUE
  49. fi
  50. if echo $a | grep "^--exclude-subdir" > /dev/null 2> /dev/null; then
  51. cpack_include_subdir=FALSE
  52. fi
  53. if echo $a | grep "^--skip-license" > /dev/null 2> /dev/null; then
  54. cpack_skip_license=TRUE
  55. fi
  56. done
  57. if [ "x${cpack_include_subdir}x" != "xx" -o "x${cpack_skip_license}x" = "xTRUEx" ]
  58. then
  59. interactive=FALSE
  60. fi
  61. cpack_version
  62. echo "This is a self-extracting archive."
  63. toplevel="`pwd`"
  64. if [ "x${cpack_prefix_dir}x" != "xx" ]
  65. then
  66. toplevel="${cpack_prefix_dir}"
  67. fi
  68. echo "The archive will be extracted to: ${toplevel}"
  69. if [ "x${interactive}x" = "xTRUEx" ]
  70. then
  71. echo ""
  72. echo "If you want to stop extracting, please press <ctrl-C>."
  73. if [ "x${cpack_skip_license}x" != "xTRUEx" ]
  74. then
  75. more << '____cpack__here_doc____'
  76. @CPACK_RESOURCE_FILE_LICENSE_CONTENT@
  77. ____cpack__here_doc____
  78. echo
  79. echo "Do you accept the license? [yN]: "
  80. read line leftover
  81. case ${line} in
  82. y* | Y*)
  83. cpack_license_accepted=TRUE;;
  84. *)
  85. echo "License not accepted. Exiting ..."
  86. exit 1;;
  87. esac
  88. fi
  89. if [ "x${cpack_include_subdir}x" = "xx" ]
  90. then
  91. echo "By default the @CPACK_PACKAGE_NAME@ will be installed in:"
  92. echo " \"${toplevel}/@CPACK_PACKAGE_FILE_NAME@\""
  93. echo "Do you want to include the subdirectory @CPACK_PACKAGE_FILE_NAME@?"
  94. echo "Saying no will install in: \"${toplevel}\" [Yn]: "
  95. read line leftover
  96. cpack_include_subdir=TRUE
  97. case ${line} in
  98. n* | N*)
  99. cpack_include_subdir=FALSE
  100. esac
  101. fi
  102. fi
  103. if [ "x${cpack_include_subdir}x" = "xTRUEx" ]
  104. then
  105. toplevel="${toplevel}/@CPACK_PACKAGE_FILE_NAME@"
  106. mkdir -p "${toplevel}"
  107. fi
  108. echo
  109. echo "Using target directory: ${toplevel}"
  110. echo "Extracting, please wait..."
  111. echo ""
  112. # take the archive portion of this file and pipe it to tar
  113. # the NUMERIC parameter in this command should be one more
  114. # than the number of lines in this header file
  115. # there are tails which don't understand the "-n" argument, e.g. on SunOS
  116. # OTOH there are tails which complain when not using the "-n" argument (e.g. GNU)
  117. # so at first try to tail some file to see if tail fails if used with "-n"
  118. # if so, don't use "-n"
  119. use_new_tail_syntax="-n"
  120. tail $use_new_tail_syntax +1 "$0" > /dev/null 2> /dev/null || use_new_tail_syntax=""
  121. extractor="pax -r"
  122. command -v pax > /dev/null 2> /dev/null || extractor="tar xf -"
  123. tail $use_new_tail_syntax +###CPACK_HEADER_LENGTH### "$0" | gunzip | (cd "${toplevel}" && ${extractor}) || cpack_echo_exit "Problem unpacking the @CPACK_PACKAGE_FILE_NAME@"
  124. echo "Unpacking finished successfully"
  125. exit 0
  126. #-----------------------------------------------------------
  127. # Start of TAR.GZ file
  128. #-----------------------------------------------------------;