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