File: install.sh

package info (click to toggle)
astyle 3.6.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,412 kB
  • sloc: cpp: 16,670; makefile: 713; sh: 202
file content (96 lines) | stat: -rw-r--r-- 2,167 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Install the AStyle documentation.
# For testing change the "prefix" variable and "sudo" is not needed.
# NOTE: Use ~, not $HOME.  HOME is not defined in SciTE.

# prefix may be changed for testing
prefix=/usr/local
#prefix=/private/tmp/AStyle.dst/usr

NORMAL=""
# CYAN, BOLD: information
CYAN=""
# YELLOW; system message
YELLOW=""
# WHITE, BOLD; error message
WHITE=""
# RED, BOLD: failure message
RED=""

ipath=$prefix/bin
SYSCONF_PATH=$prefix/share/doc/astyle
# the path was changed in release 2.01
# SYSCONF_PATH_OLD may be removed at the appropriate time
SYSCONF_PATH_OLD=$prefix/share/astyle
# $USER will be root when sudo is used
INSTALL="install -o $USER -g wheel"

# define $result variable here
result=:
unset result

# error handler function
check_error () {
	if [ $result -ne 0 ] ; then
		echo -n $WHITE
		echo "Error $result returned from function"
		echo "Did you use 'sudo'?"
		echo $RED
		echo "** INSTALL FAILED **"
		echo $NORMAL
		exit 1
	fi
	unset result
}


# must install from this path
if [ ! -f install.sh ]; then
	echo -n $WHITE
	echo "Cannot install from this path"
	echo "Change to the directory containing install.sh"
	echo; echo -n $NORMAL
	exit 1
fi

# remove previous documentation
echo $CYAN
echo "Installing documentation to $SYSCONF_PATH"
echo -n $YELLOW
if [ -d $SYSCONF_PATH/html ]; then
	rm -rf  $SYSCONF_PATH/html
	result=$?;	check_error
fi
# create documentation install directory
if [ ! -d $SYSCONF_PATH/html ]; then
	$INSTALL -m 755 -d $SYSCONF_PATH/html
	result=$?;	check_error
fi
# copy documentation
for files in astyle.html \
             install.html \
             news.html \
             notes.html \
             styles.css
do
	$INSTALL  -m 644  "../../doc/$files"  $SYSCONF_PATH/html
	result=$?;	check_error
done

# remove old documentation
if [ -d $SYSCONF_PATH_OLD ];  then
	rm -rf $SYSCONF_PATH_OLD
	result=$?;	check_error
fi

echo $WHITE
echo "** INSTALL SUCCEEDED **"

# has astyle been installed?
if [ ! -f $ipath/astyle ]; then
	echo $WHITE
	echo "The astyle executable has not been installed"
	echo "Use xcodebuild to install astyle"
fi

echo; echo -n $NORMAL