CPack.STGZ_Header.sh.in 3.93 KB
Newer Older
1 2 3 4 5 6 7 8 9
#!/bin/sh

# Display usage
cpack_usage()
{
  cat <<EOF
Usage: $0 [options]
Options: [defaults in brackets after descriptions]
  --help            print this message
10
  --version         print cmake installer version
11 12 13
  --prefix=dir      directory in which to install
  --include-subdir  include the @CPACK_PACKAGE_FILE_NAME@ subdirectory
  --exclude-subdir  exclude the @CPACK_PACKAGE_FILE_NAME@ subdirectory
14
  --skip-license    accept license
15 16 17 18
EOF
  exit 1
}

Andy Cedilnik's avatar
Andy Cedilnik committed
19 20 21 22 23 24
cpack_echo_exit()
{
  echo $1
  exit 1
}

25 26 27 28 29 30 31 32 33 34 35 36
# Display version
cpack_version()
{
  echo "@CPACK_PACKAGE_NAME@ Installer Version: @CPACK_PACKAGE_VERSION@, Copyright (c) @CPACK_PACKAGE_VENDOR@"
}

# Helper function to fix windows paths.
cpack_fix_slashes ()
{
  echo "$1" | sed 's/\\/\//g'
}

37 38 39
interactive=TRUE
cpack_skip_license=FALSE
cpack_include_subdir=""
40 41 42 43 44 45
for a in "$@CPACK_AT_SIGN@"; do
  if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
    cpack_prefix_dir=`echo $a | sed "s/^--prefix=//"`
    cpack_prefix_dir=`cpack_fix_slashes "${cpack_prefix_dir}"`
  fi
  if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
46
    cpack_usage
47 48
  fi
  if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
49
    cpack_version
50 51 52 53 54 55 56 57
    exit 2
  fi
  if echo $a | grep "^--include-subdir" > /dev/null 2> /dev/null; then
    cpack_include_subdir=TRUE
  fi
  if echo $a | grep "^--exclude-subdir" > /dev/null 2> /dev/null; then
    cpack_include_subdir=FALSE
  fi
58 59 60
  if echo $a | grep "^--skip-license" > /dev/null 2> /dev/null; then
    cpack_skip_license=TRUE
  fi
61 62
done

Andy Cedilnik's avatar
Andy Cedilnik committed
63
if [ "x${cpack_include_subdir}x" != "xx" -o "x${cpack_skip_license}x" = "xTRUEx" ]
64 65 66 67
then
  interactive=FALSE
fi

68 69 70 71 72 73 74 75 76 77
cpack_version
echo "This is a self-extracting archive."
toplevel="`pwd`"
if [ "x${cpack_prefix_dir}x" != "xx" ]
then
  toplevel="${cpack_prefix_dir}"
fi

echo "The archive will be extracted to: ${toplevel}"

Andy Cedilnik's avatar
Andy Cedilnik committed
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 87 88
@CPACK_RESOURCE_FILE_LICENSE_CONTENT@
____cpack__here_doc____
    echo
89
    echo "Do you accept the license? [yN]: "
90 91 92 93 94 95 96 97 98 99
    read line leftover
    case ${line} in
      y* | Y*)
        cpack_license_accepted=TRUE;;
      *)
        echo "License not accepted. Exiting ..."
        exit 1;;
    esac
  fi

Andy Cedilnik's avatar
Andy Cedilnik committed
100
  if [ "x${cpack_include_subdir}x" = "xx" ]
101 102
  then
    echo "By default the @CPACK_PACKAGE_NAME@ will be installed in:"
Andy Cedilnik's avatar
Andy Cedilnik committed
103
    echo "  \"${toplevel}/@CPACK_PACKAGE_FILE_NAME@\""
104
    echo "Do you want to include the subdirectory @CPACK_PACKAGE_FILE_NAME@?"
Andy Cedilnik's avatar
Andy Cedilnik committed
105
    echo "Saying no will install in: \"${toplevel}\" [Yn]: "
106
    read line leftover
Andy Cedilnik's avatar
Andy Cedilnik committed
107
    cpack_include_subdir=TRUE
108
    case ${line} in
Andy Cedilnik's avatar
Andy Cedilnik committed
109 110
      n* | N*)
        cpack_include_subdir=FALSE
111
    esac
112 113 114
  fi
fi

Andy Cedilnik's avatar
Andy Cedilnik committed
115
if [ "x${cpack_include_subdir}x" = "xTRUEx" ]
116 117 118 119
then
  toplevel="${toplevel}/@CPACK_PACKAGE_FILE_NAME@"
  mkdir -p "${toplevel}"
fi
120 121 122
echo
echo "Using target directory: ${toplevel}"
echo "Extracting, please wait..."
123 124 125 126 127
echo ""

# take the archive portion of this file and pipe it to tar
# the NUMERIC parameter in this command should be one more
# than the number of lines in this header file
Alexander Neundorf's avatar
 
Alexander Neundorf committed
128 129 130 131 132 133 134
# there are tails which don't understand the "-n" argument, e.g. on SunOS
# OTOH there are tails which complain when not using the "-n" argument (e.g. GNU)
# so at first try to tail some file to see if tail fails if used with "-n"
# if so, don't use "-n"
use_new_tail_syntax="-n"
tail $use_new_tail_syntax +1 "$0" > /dev/null 2> /dev/null || use_new_tail_syntax=""

135 136 137 138
extractor="pax -r"
command -v pax > /dev/null 2> /dev/null || extractor="tar xf -"

tail $use_new_tail_syntax +###CPACK_HEADER_LENGTH### "$0" | gunzip | (cd "${toplevel}" && ${extractor}) || cpack_echo_exit "Problem unpacking the @CPACK_PACKAGE_FILE_NAME@"
Andy Cedilnik's avatar
Andy Cedilnik committed
139 140

echo "Unpacking finished successfully"
141 142 143 144 145

exit 0
#-----------------------------------------------------------
#      Start of TAR.GZ file
#-----------------------------------------------------------;