CPack.STGZ_Header.sh.in 3.8 KB

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