1#!/bin/sh 2 3# Display usage 4cpack_usage() 5{ 6 cat <<EOF 7Usage: $0 [options] 8Options: [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 15EOF 16 exit 1 17} 18 19cpack_echo_exit() 20{ 21 echo $1 22 exit 1 23} 24 25# Display version 26cpack_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. 32cpack_fix_slashes () 33{ 34 echo "$1" | sed 's/\\/\//g' 35} 36 37interactive=TRUE 38cpack_skip_license=FALSE 39cpack_include_subdir="" 40for 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 61done 62 63if [ "x${cpack_include_subdir}x" != "xx" -o "x${cpack_skip_license}x" = "xTRUEx" ] 64then 65 interactive=FALSE 66fi 67 68cpack_version 69echo "This is a self-extracting archive." 70toplevel="`pwd`" 71if [ "x${cpack_prefix_dir}x" != "xx" ] 72then 73 toplevel="${cpack_prefix_dir}" 74fi 75 76echo "The archive will be extracted to: ${toplevel}" 77 78if [ "x${interactive}x" = "xTRUEx" ] 79then 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 117fi 118 119if [ "x${cpack_include_subdir}x" = "xTRUEx" ] 120then 121 toplevel="${toplevel}/@CPACK_PACKAGE_FILE_NAME@" 122 mkdir -p "${toplevel}" 123fi 124echo 125echo "Using target directory: ${toplevel}" 126echo "Extracting, please wait..." 127echo "" 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" 136use_new_tail_syntax="-n" 137tail $use_new_tail_syntax +1 "$0" > /dev/null 2> /dev/null || use_new_tail_syntax="" 138 139extractor="pax -r" 140command -v pax > /dev/null 2> /dev/null || extractor="tar xf -" 141 142tail $use_new_tail_syntax +###CPACK_HEADER_LENGTH### "$0" | gunzip | (cd "${toplevel}" && ${extractor}) || cpack_echo_exit "Problem unpacking the @CPACK_PACKAGE_FILE_NAME@" 143 144echo "Unpacking finished successfully" 145 146exit 0 147#----------------------------------------------------------- 148# Start of TAR.GZ file 149#-----------------------------------------------------------; 150