setup_externals.sh 4.1 KB
Newer Older
Tobias WEBER's avatar
Tobias WEBER committed
1
2
#!/bin/bash
#
3
# downloads external libraries
Tobias WEBER's avatar
Tobias WEBER committed
4
5
# @author Tobias Weber <tweber@ill.fr>
# @date 6-apr-18
Tobias WEBER's avatar
Tobias WEBER committed
6
# @license GPLv3, see 'LICENSE' file
Tobias WEBER's avatar
Tobias WEBER committed
7
#
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# ----------------------------------------------------------------------------
# mag-core (part of the Takin software suite)
# Copyright (C) 2018-2021  Tobias WEBER (Institut Laue-Langevin (ILL),
#                          Grenoble, France).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------------
#
Tobias WEBER's avatar
Tobias WEBER committed
26
27
28
29

# -----------------------------------------------------------------------------
# tools
WGET=wget
Tobias WEBER's avatar
Tobias WEBER committed
30
TAR=tar
Tobias WEBER's avatar
Tobias WEBER committed
31
UZIP=unzip
Tobias WEBER's avatar
Tobias WEBER committed
32
33
34
35
36
37
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# URLs for external libs
TLIBS=https://forge.frm2.tum.de/cgit/cgit.cgi/frm2/mira/tlibs.git/snapshot/tlibs-master.tar.bz2
Tobias WEBER's avatar
Tobias WEBER committed
38
QCP=https://www.qcustomplot.com/release/2.0.1/QCustomPlot-source.tar.gz
Tobias WEBER's avatar
Tobias WEBER committed
39
GEMMI=https://github.com/project-gemmi/gemmi/archive/master.zip
40
MAGDATA=https://stokes.byu.edu/iso/magnetic_data.txt
Tobias WEBER's avatar
Tobias WEBER committed
41
42
43
44

# local file names
TLIBS_LOCAL=${TLIBS##*[/\\]}
QCP_LOCAL=${QCP##*[/\\]}
Tobias WEBER's avatar
Tobias WEBER committed
45
GEMMI_LOCAL=${GEMMI##*[/\\]}
46
MAGDATA_LOCAL=${MAGDATA##*[/\\]}
Tobias WEBER's avatar
Tobias WEBER committed
47
48
49
50
51
52
53
54
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# cleans externals
function clean_dirs()
{
	rm -rf qcp
Tobias WEBER's avatar
Tobias WEBER committed
55
	rm -rf gemmi
Tobias WEBER's avatar
Tobias WEBER committed
56
57
58
59
60
}

function clean_files()
{
	rm -f ${QCP_LOCAL}
Tobias WEBER's avatar
Tobias WEBER committed
61
	rm -f ${GEMMI_LOCAL}
Tobias WEBER's avatar
Tobias WEBER committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
}
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
function dl_qcp()
{
	if ! ${WGET} ${QCP}
	then
		echo -e "Error downloading qcp.";
		exit -1;
	fi


Tobias WEBER's avatar
Tobias WEBER committed
76
	if ! ${TAR} xzvf ${QCP_LOCAL}
Tobias WEBER's avatar
Tobias WEBER committed
77
78
79
80
81
82
83
	then
		echo -e "Error extracting qcp.";
		exit -1;
	fi

	mv qcustomplot-source qcp
}
Tobias WEBER's avatar
Tobias WEBER committed
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102


function dl_gemmi()
{
	if ! ${WGET} ${GEMMI}
	then
		echo -e "Error downloading gemmi.";
		exit -1;
	fi


	if ! ${UZIP} ${GEMMI_LOCAL}
	then
		echo -e "Error extracting gemmi.";
		exit -1;
	fi

	mv gemmi-master gemmi
}
103
104
105
106
107
108
109
110
111
112
113
114


function dl_magdata()
{
	if ! ${WGET} ${MAGDATA}
	then
		echo -e "Error downloading magnetic space group data.";
		exit -1;
	fi

	mv ${MAGDATA_LOCAL} magsg.dat
}
Tobias WEBER's avatar
Tobias WEBER committed
115
116
117
# -----------------------------------------------------------------------------


118
119
mkdir -pv data
mkdir -pv ext
Tobias WEBER's avatar
Tobias WEBER committed
120
121
122
123
124
125
126
127
cd ext

echo -e "\n--------------------------------------------------------------------------------"
echo -e "Removing old libs...\n"
clean_dirs
clean_files
echo -e "--------------------------------------------------------------------------------\n"

128
#echo -e "\n--------------------------------------------------------------------------------"
129
130
#echo -e "Installing external qcustomplot library...\n"
#dl_qcp
131
#echo -e "--------------------------------------------------------------------------------\n"
Tobias WEBER's avatar
Tobias WEBER committed
132

Tobias WEBER's avatar
Tobias WEBER committed
133
134
135
136
137
echo -e "\n--------------------------------------------------------------------------------"
echo -e "Installing external Gemmi library...\n"
dl_gemmi
echo -e "--------------------------------------------------------------------------------\n"

138
139
140
141
#echo -e "\n--------------------------------------------------------------------------------"
#echo -e "Downloading magnetic space group data...\n"
#dl_magdata
#echo -e "--------------------------------------------------------------------------------\n"
142

Tobias WEBER's avatar
Tobias WEBER committed
143
144
145
146
echo -e "\n--------------------------------------------------------------------------------"
echo -e "Removing temporary files...\n"
clean_files
echo -e "--------------------------------------------------------------------------------\n"