Bump version to 6.4-15
[LibreOffice.git] / setup_native / scripts / downloadscript.sh
blob7246ebcda27cfadc61997268da5a6ae4b8ed3313
1 #!/bin/sh
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 linenum=LINENUMBERPLACEHOLDER
22 UNPACKDIR=/var/tmp/unpack_PRODUCTNAMEPLACEHOLDER
23 diskSpaceRequired=DISCSPACEPLACEHOLDER
24 checksum=CHECKSUMPLACEHOLDER
26 EXTRACTONLY="no"
27 if [ "$1" = "-x" ]
28 then
29 EXTRACTONLY=yes
32 # Determining current platform
34 platform=`uname -s`
36 case $platform in
37 SunOS)
38 tail_prog="tail"
40 Linux)
41 tail_prog="tail -n"
44 tail_prog="tail"
46 esac
48 # Asking for the unpack directory
50 echo
51 echo "Select the directory in which to save the unpacked files. [$UNPACKDIR] "
52 read reply leftover
53 if [ "x$reply" != "x" ]
54 then
55 UNPACKDIR="$reply"
58 if [ -d $UNPACKDIR ]; then
59 printf "Directory $UNPACKDIR already exists.\n"
60 printf "Please select a new directory name.\n"
61 exit 1
64 # Unpacking
66 mkdir -m 700 $UNPACKDIR
68 diskSpace=`df -k $UNPACKDIR | $tail_prog -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'`
69 if [ $diskSpace -lt $diskSpaceRequired ]; then
70 printf "The selected drive does not have enough disk space available.\n"
71 printf "PRODUCTNAMEPLACEHOLDER requires at least %s kByte.\n" $diskSpaceRequired
72 exit 1
75 trap 'rm -rf $UNPACKDIR; exit 1' HUP INT QUIT TERM
77 if [ -x /usr/bin/sum ] ; then
78 echo "File is being checked for errors ..."
80 sum=`$tail_prog +$linenum $0 | /usr/bin/sum`
81 sum=`echo $sum | awk '{ print $1 }'`
83 if [ $sum != $checksum ]; then
84 echo "The download file appears to be corrupted. Please download PRODUCTNAMEPLACEHOLDER again."
85 exit 1
89 echo "Unpacking ..."
91 $tail_prog +$linenum $0 | (cd $UNPACKDIR; tar xf -)
93 echo "All files have been successfully unpacked."
95 if [ "$EXTRACTONLY" != "yes" ]
96 then
97 if [ -f $UNPACKDIR/setup ]
98 then
99 chmod 775 $UNPACKDIR/setup
100 $UNPACKDIR/setup
104 exit 0