-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstallOSCAD.sh
executable file
·390 lines (340 loc) · 12 KB
/
installOSCAD.sh
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#!/bin/bash
#
# installOSCAD.sh is a part of OSCAD.
# Original Author: Yogesh Dilip Save ([email protected])
# Copyright (C) 2012 Yogesh Dilip Save, FOSS Project, IIT Bombay.
# 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; either version 2 of the
# License, or (at your option) any later version. 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, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.
echo -n "Is your internet connection behind proxy? (y/n): "
read getProxy
if [ $getProxy == "y" -o $getProxy == "Y" ]
then
echo -n 'Proxy Hostname :'
read proxyHostname
echo -n 'Proxy Port :'
read proxyPort
echo -n username@$proxyHostname:$proxyPort :
read username
echo -n 'Password :'
read -s passwd
unset http_proxy
unset https_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset ftp_proxy
unset FTP_PROXY
export http_proxy=http://$username:$passwd@$proxyHostname:$proxyPort
export https_proxy=http://$username:$passwd@$proxyHostname:$proxyPort
export https_proxy=http://$username:$passwd@$proxyHostname:$proxyPort
export HTTP_PROXY=http://$username:$passwd@$proxyHostname:$proxyPort
export HTTPS_PROXY=http://$username:$passwd@$proxyHostname:$proxyPort
export ftp_proxy=http://$username:$passwd@$proxyHostname:$proxyPort
export FTP_PROXY=http://$username:$passwd@$proxyHostname:$proxyPort
"$@"
echo
sudo apt-get install kicad ngspice python
elif [ $getProxy == "n" -o $getProxy == "N" ]
then
sudo apt-get install kicad ngspice python
if [ $? -ne 0 ]
then
echo -e "\n\n\nOSCAD ERROR: Unable to install required packages. Please check your internet connection.\n\n"
exit 0
fi
else
echo "Please select the right option"
exit 0
fi
function checkScilabVersion
{
version=`$1 -version |grep scilab |cut -d '-' -f2`
version=`echo $version | sed 's/\.//g'`
if [ "$version" -ge "540" ]
then
echo " scilab version 5.4 or above detected."
return 0
else
return 1
fi
}
function checkMetanet
{
eval $1 -nw -f checkMetanet.sci
RetVal=$?
if [ $RetVal -ne 0 ]
then
echo "No Metanet graph library found"
echo "Trying to install metanet library........"
#echo -n "Do you want to set proxy for internet connection(y/n): "
#read setProxy
#if [ $setProxy = 'y' -o $setProxy = 'Y' ]
#then
# proxy
#fi
eval $1 -nw -f installMetanet.sci
RetVal=$?
if [ $RetVal -ne 0 ]
then
echo " Unable to install Metanet "
echo " Please install metanet manually. "
echo " To install metanet use command atomInstall(\"metanet\")"
fi
fi
}
function CopyFritzing
{
echo "Installing Fritzing"
#Storing machine bit information
mc_bit_info=`uname -m`
if [ $? -eq 0 ]
then
echo $mc_bit_info
else
echo "Error in getiing machine bit information"
fi
#untar at installed location
if [ $mc_bit_info == "i686" ]
then
echo "Untar 32-bit-fritzing"
tar -xvf fritzing-0.8.5b.linux.i386.tar.bz2 -C $installDir/OSCAD --transform 's/fritzing-0.8.5b.linux.i386/fritzing-0.8.5b/'
elif [ $mc_bit_info == "x86_64" ]
then
echo "untar 64-bit-fritzing"
tar -xvf fritzing-0.8.5b.linux.AMD64.tar.bz2 -C $installDir/OSCAD --transform 's/fritzing-0.8.5b.linux.AMD64/fritzing-0.8.5b/'
else
echo "Fritzing is not installed proplerly"
fi
RetVal=$?
if [ $RetVal -eq 0 ]
then
echo "Fritzing Installed Sucessfully"
else
echo "Fritzing is not Installed"
fi
: <<'block'
echo "Copying file in .config/Fritzing"
if [ -d $HOME/.config/Fritzing ]
then
##Copying user build fritzing component to .config folder
cp My_Part/parts/user/* $HOME/.config/Fritzing/parts/user
cp My_Part/parts/svg/user/breadboard/* $HOME/.config/Fritzing/parts/svg/user/breadboard
cp My_Part/parts/svg/user/icon/* $HOME/.config/Fritzing/parts/svg/user/icon
cp My_Part/parts/svg/user/pcb/* $HOME/.config/Fritzing/parts/svg/user/pcb
cp My_Part/parts/svg/user/schematic/* $HOME/.config/Fritzing/parts/svg/user/schematic
else
cp -r My_Parts/Fritzing $HOME/.config/
fi
block
##Copying setPath.py to Fritzing Directory
cp -p $installDir/OSCAD/setPath.py $installDir/OSCAD/Fritzingtokicad/setPath.py
echo "Fritzing Installation completed"
}
echo "Checking python Modules......................"
sudo chmod 755 ./checkPythonModules.py
./checkPythonModules.py
RetVal=$?
[ $RetVal -eq 0 ] && echo "All python modules are available"
[ $RetVal -eq 1 ] && { echo "Some python modules are not available. Kindly install them and then re-run installOSCAD.sh"; exit 1; }
[ $RetVal -ne 1 ] && [ $RetVal -ne 0 ] && { echo "Unable to check modules"; exit 1; }
# added from here
echo -n "Do you have scilab 5.4 or above? (y/n) "
read Answer
case $Answer in
y|Y)
echo "Checking scilab ......................"
command -v scilab >/dev/null 2>&1
RetVal=$?
if [ $RetVal -eq 0 ]
then
scilabPATH="/usr/bin/scilab"
echo "Found scilab."
echo "Checking scilab version......................"
checkScilabVersion "$scilabPATH"
RetVal=$?
if [ $RetVal -eq 0 ]
then
echo "Checking Metanet ......................"
checkMetanet "$scilabPATH"
else
echo -e " \e[1m Require scilab version 5.4 or above \e[0m"
echo -n "Please give path of scilab installation directory (e.g., $HOME/Downloads/scilab-5.4.0):"
read scilabInstallDir
if [ -z $scilabInstallDir ]
then
scilabInstallDir=$HOME/Downloads/scilab-5.4.0
fi
echo "Checking scilab ......................"
command -v $scilabInstallDir/bin/scilab >/dev/null 2>&1
RetVal=$?
if [ $RetVal -eq 0 ]
then
echo "Found scilab."
scilabPATH="$scilabInstallDir/bin/scilab"
echo "Checking scilab version......................"
checkScilabVersion "$scilabInstallDir/bin/scilab"
RetVal=$?
if [ $RetVal -eq 0 ]
then
echo -e " Oscad installation proceeds with Scilab....\n"
echo "Checking Metanet ......................"
checkMetanet "$scilabInstallDir/bin/scilab"
else
echo -e " \e[1m Require scilab version 5.4 or above \e[0m"
if [[ $linuxVersion == "x86_64" ]]
then
echo -e " \e[1m Please download scilab 5.4.0 for 64 bits (Linux) from http://www.scilab.org/products/scilab/download \e[0m"
else
echo -e " '\e[1m' Please download scilab 5.4.0 for 32 bits (Linux) from http://www.scilab.org/products/scilab/download '\e[0m'"
fi
echo " And re-run install_OSCAD.sh "
exit 1
fi
else
echo -e " \e[1m Unable to find scilab5.4.0 or above in the specified location \e[0m"
echo " Please re-run install_OSCAD.sh and Give correct path"
exit 1
fi
fi
else
echo -e " Scilab not found.."
echo -n "Please give path of scilab installation directory (e.g., $HOME/Downloads/scilab5.4.0):"
read scilabInstallDir
if [ -z $scilabInstallDir ]
then
scilabInstallDir=$HOME/Downloads/scilab-5.4.0
fi
echo "Checking scilab ......................"
command -v $scilabInstallDir/bin/scilab >/dev/null 2>&1
RetVal=$?
if [ $RetVal -eq 0 ]
then
echo "Found scilab."
scilabPATH="$scilabInstallDir/bin/scilab"
echo "Checking scilab version......................"
checkScilabVersion "$scilabInstallDir/bin/scilab"
RetVal=$?
if [ $RetVal -eq 0 ]
then
echo -e " Oscad installation proceeds with Scilab....\n"
echo "Checking Metanet ......................"
checkMetanet "$scilabInstallDir/bin/scilab"
else
echo -e " \e[1m Require scilab version 5.4 or above \e[0m"
if [[ $linuxVersion == "x86_64" ]]
then
echo -e " \e[1m Please download scilab 5.4.0 for 64 bits (Linux) from http://www.scilab.org/products/scilab/download \e[0m"
else
echo -e " '\e[1m' Please download scilab 5.4.0 for 32 bits (Linux) from http://www.scilab.org/products/scilab/download '\e[0m'"
fi
echo " And re-run install_OSCAD.sh "
exit 1
fi
else
echo -e " \e[1m Unable to find scilab5.4.0 or above in the specified location \e[0m"
echo " Please re-run install_OSCAD.sh and Give correct path"
exit 1
fi
fi
;;
n|N) echo "Installation proceeds without Scilab....."
;;
*) echo " Please select right option"
exit 1
;;
esac
echo -n "Please select installation directory (e.g., $HOME): "
read installDir
if [ -z $installDir ]
then
installDir=$HOME
fi
if [ -d $installDir ]
then
echo 'Directory found'
else
echo 'Directory not found!'
echo -n 'Do you want to create it?(y/n)'
read response
if [ $response = 'y' -o $response = 'Y' ]
then
if [ `mkdir -p $installDir` ]
then
exit 1
fi
else
echo 'Installation aborted'
exit 1
fi
fi
echo "Installation started..............."
if [ -d $installDir/OSCAD ]
then
echo "Renaming your old OSCAD folder to OSCAD.bak"
mv -r $installDir/OSCAD $installDir/OSCAD.bak
fi
echo "Outof if loop"
#tar -zxvf OSCAD.tar.gz -C $installDir
cp -rv OSCAD $installDir
cp $installDir/OSCAD/setPathInstall.py $installDir/OSCAD/setPath.py
echo "$installDir/OSCAD/setPathInstall.py"
cat $installDir/OSCAD/setPathInstall.py
echo "$installDir/OSCAD/setPath.py"
cat $installDir/OSCAD/setPath.py
cp $installDir/OSCAD/setPathInstall.py $installDir/OSCAD/forntEnd/setPath.py
sed -i 's@set_PATH_to_OSCAD@"'$installDir'/OSCAD"@g' $installDir/OSCAD/setPath.py
sed -i 's@set_PATH_to_OSCAD@"'$installDir'/OSCAD"@g' $installDir/OSCAD/modelEditor/setPath.py
cp $installDir/OSCAD/setPath.py $installDir/OSCAD/forntEnd/setPath.py
cp $installDir/OSCAD/setPath.py $installDir/OSCAD/subcktEditor/setPath.py
cp $installDir/OSCAD/setPath.py $installDir/OSCAD/modelEditor/setPath.py
cp $installDir/OSCAD/LPCSim/LPCSim/MainInstall.sci $installDir/OSCAD/LPCSim/LPCSim/Main.sci
sed -i 's@set_PATH_to_OSCAD@"'$installDir'/OSCAD"@g' $installDir/OSCAD/LPCSim/LPCSim/Main.sci
chmod 755 $installDir/OSCAD/analysisInserter/*.py
chmod 755 $installDir/OSCAD/forntEnd/*.py
chmod 755 $installDir/OSCAD/kicadtoNgspice/*.py
chmod 755 $installDir/OSCAD/modelEditor/*.py
chmod 755 $installDir/OSCAD/subcktEditor/*.py
ln -sf $scilabPATH $installDir/OSCAD/bin/scilab54
sudo ln -sf $installDir/OSCAD/forntEnd/oscad.py /usr/bin/oscad
sudo cp -v $installDir/OSCAD/images/logo.png /usr/share/icons/oscad.png
echo "Setting up desktop icon..."
cp -v oscad.desktop $HOME/Desktop/
##Installing Fritzing
CopyFritzing
function import_kicad_lib() {
# Copy Oscad libraries to kicad lib directory
cp -r ../Oscad-installer-linux/OSCAD/library/*.lib /usr/share/kicad/library/
cp -r ../Oscad-installer-linux/OSCAD/library/*.dcm /usr/share/kicad/library/
# --------------------
# Full path of 'kicad.pro file'[Verified for Ubuntu 12.04]
KICAD_PRO="/usr/share/kicad/template/kicad.pro"
# --------------------
# Get number of libs in Oscad/Library directory
kicadlibfiles_num=$(cat ${KICAD_PRO} | awk "/\[eeschema\/libraries\]/,/\[cvpcb\]/" | grep -i "LibName" | wc -l)
# Remove string '.lib' as 'kicad.pro' does not store library name
# with '.lib' as a suffix
libfiles=$(ls -1 ../Oscad-installer-linux/OSCAD/library | grep ".lib")
# Start the counter from number of libs already available
COUNTER=${kicadlibfiles_num}
# Make a copy of original file by the extension .original
cp -rv ${KICAD_PRO}{,.original}
# Write lib in a loop
for i in ${libfiles}
do
COUNTER=$((COUNTER + 1))
FILENAME=$(echo ${i} | sed -e "s/.lib//g" | sed -e "s/^/LibName${COUNTER}=/")
#echo $FILENAME
#echo "LibName$((COUNTER - 1))"
sed -i -e '/LibName'"$((COUNTER - 1))"'/a '"${FILENAME}"'' ${KICAD_PRO}
done
}
import_kicad_lib
echo "Installation completed"