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