/usr/bin/openturns-module is in libopenturns-dev 0.15-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | #! /bin/sh
# -*- Shell-script -*-
#
# openturns-module-build.in / openturns-module-build / openturns-module
#
# (C) Copyright 2005-2011 EDF
#
# Permission to copy, use, modify, sell and distribute this software
# is granted provided this copyright notice appears in all copies.
# This software is provided "as is" without express or implied
# warranty, and with no claim as to its suitability for any purpose.
#
#
# Author : $LastChangedBy: dutka $
# Date : $LastChangedDate: 2008-10-31 16:07:46 +0100 (Fri, 31 Oct 2008) $
# Id : $Id: openturns-config.in 996 2008-10-31 15:07:46Z dutka $
#
# This script installs or removes extra modules
#
print_usage()
{
cat <<EOT
Usage: openturns-module [--silent] {--install=<module> | --remove=<module>} [--prefix=PFX] [extra_configure_args]
openturns-module [--silent] {--install <module> | --remove <module>} [--prefix PFX] [extra_configure_args]
openturns-module [--silent] {--module=<module> | --module <module>} [options]
Note:
For installation, 'module' can be either a path to a directory
or a path to a archive file (compressed or not).
For removal, 'module' is the module name.
The extra configure args are passed as is to the module configure
script.
Example:
(install)
openturns-module --install=mymodule/
openturns-module --install=/path/to/mymodule/
openturns-module --install=mymodule.tar
openturns-module --install=mymodule.tar.gz
openturns-module --install=mymodule.tgz
openturns-module --install=mymodule.tar.bz2
openturns-module --install=mymodule.tbz
openturns-module --install=URL
You can provide a prefix to choose where the module will be installed.
PFX can take one of the following values:
* openturns : the module will be installed in the Open TURNS installation tree
* user : the module will be installed in the Open TURNS user directory ($HOME/openturns)
* <dir> : the module will be installed in <dir>. You should append <dir> to the
OPENTURNS_MODULE_PATH envvar to tell Open TURNS where to find the module
(remove)
openturns-module --remove=mymodule
(mixed form)
openturns-module --remove=myoldmodule1 --install=mynewmodule1 --install=mymodule2
(module)
openturns-module --module=mymodule
Options:
--silent Do not output any message
EOT
exit 1
}
build_tempdir()
{
test $# = 0 || { $silent || echo "internal error: wrong number of args for build_tempdir(): $# (0 expected)" ; return 1 ; }
tempdir=/tmp/openturns-module.$$
mkdir -p $tempdir || return 1
echo $tempdir
return 0
}
delete_tempdir()
{
test $# = 1 || { $silent || echo "internal error: wrong number of args for delete_tempdir(): $# (1 expected)" ; return 1 ; }
tempdir=$1
test -d $tempdir && rm -rf $tempdir || return 1
return 0
}
# this function checks the type of the module and returns a string
# describing this type :
# dir -> the module is a directory
# tar -> the module is an uncompressed archive
# tgz -> the module is a gzip compressed archive
# tbz -> the module is a bzip2 compressed archive
# tZ -> the module is a compressed archive
# otherwise it aborts the global process
get_module_type()
{
test $# = 1 || { $silent || echo "internal error: wrong number of args for get_module_type(): $# (1 expected)" ; return 1 ; }
module=$1
if test -d $module
then
echo "dir"
elif test -f $module
then
if echo $module | egrep -q -e '(\.tar\.gz|\.tgz)$'
then
echo "tgz"
elif echo $module | egrep -q -e '(\.tar\.bz2|\.tbz)$'
then
echo "tbz"
elif echo $module | egrep -q -e '\.tar\.Z$'
then
echo "tZ"
elif echo $module | egrep -q -e '\.tar$'
then
echo "tar"
else
echo "none"
fi
elif echo $module | grep -q -e '^http://'
then
echo "http"
else
echo "none"
fi
return 0
}
# this function uncompress the archive into the temporary directory
# in the case of a directory, just use it
prepare_module_in_tempdir()
{
test $# = 3 || { $silent || echo "internal error: wrong number of args for prepare_module_in_tempdir(): $# (3 expected)" ; return 1 ; }
module=$1
tempdir=$2
type=$3
case $type in
"dir")
modulename=`echo $module | sed -e 's,/$,,' | sed -e 's,^.*/,,'`
if echo $module | egrep -q -e '^/'
then
cp -rf $module $tempdir/$modulename
else
cp -rf `pwd`/$module $tempdir/$modulename
fi
echo $tempdir/$modulename
;;
"tar")
modulename=`echo $module | sed -e 's,^.*/,,' -e 's,\.tar$,,'`
if echo $module | egrep -q -e '^/'
then
absmodule=$module
else
absmodule=`pwd`/$module
fi
( cd $tempdir && tar -xf $absmodule )
echo $tempdir/$modulename
;;
"tgz")
modulename=`echo $module | sed -e 's,^.*/,,' -e 's,\.tar\..*$,,'`
if echo $module | egrep -q -e '^/'
then
absmodule=$module
else
absmodule=`pwd`/$module
fi
( cd $tempdir && tar -xzf $absmodule )
echo $tempdir/$modulename
;;
"tbz")
modulename=`echo $module | sed -e 's,^.*/,,' -e 's,\.tar\..*$,,'`
if echo $module | egrep -q -e '^/'
then
absmodule=$module
else
absmodule=`pwd`/$module
fi
( cd $tempdir && tar -xjf $absmodule )
echo $tempdir/$modulename
;;
"tZ")
modulename=`echo $module | sed -e 's,^.*/,,' -e 's,\.tar\..*$,,'`
if echo $module | egrep -q -e '^/'
then
absmodule=$module
else
absmodule=`pwd`/$module
fi
( cd $tempdir && { uncompress -c $absmodule | tar -xjf - ; } )
echo $tempdir/$modulename
;;
"http")
modulename=`echo $module | sed -e 's,^.*/,,'`
if ( false $module >> openturns-module.log 2>&1 )
then
t=`get_module_type $modulename`
newmodule=`prepare_module_in_tempdir $modulename $tempdir $t`
elif ( false $module -O -f --silent >> openturns-module.log 2>&1 )
then
t=`get_module_type $modulename`
newmodule=`prepare_module_in_tempdir $modulename $tempdir $t`
else
$silent || echo "Can't get $module."
return 1
fi
echo $newmodule
;;
*)
$silent || echo "internal error: wrong type in prepare_module_in_tempdir(): $type"
return 1
;;
esac
return 0
}
# run the bootstrap script
run_bootstrap()
{
rc=0
if test -x bootstrap
then
./bootstrap
rc=$?
else
sh bootstrap
rc=$?
fi
return $rc
}
# configure the prepared module into its destination
configure_module()
{
test $# = 1 || { $silent || echo "internal error: wrong number of args for configure_module(): $# (1 expected)" ; return 1 ; }
extra_configure_args=$1
if test ! -x configure
then
if test -f bootstrap
then
echo "No configure script found but there seems to be a bootstrap. Try running bootstrap ..."
if run_bootstrap
then
test ! -x configure && { echo "bootstrap did not build a configure script. Abort." ; return 1 ; }
else
echo "Bootstrap failed. No configure script available. Abort."
return 1
fi
else
echo "Neither configure script nor bootstrap available. Trying autoreconf."
autoreconf
return $?
fi
fi
for cmd in "sh configure --disable-option-checking --prefix=$destdir --with-openturns=/usr $extra_configure_args"
do
echo "========================================"
echo "Running command : $cmd"
echo "========================================"
eval $cmd || return 1
done
return 0
}
# compile the prepared module into its destination
compile_module()
{
test $# = 0 || { $silent || echo "internal error: wrong number of args for compile_module(): $# (0 expected)" ; return 1 ; }
for cmd in "make" "make check"
do
echo "========================================"
echo "Running command : $cmd"
echo "========================================"
eval $cmd || return 1
done
return 0
}
# install the prepared module into its destination
install_module()
{
test $# = 1 || { $silent || echo "internal error: wrong number of args for install_module(): $# (1 expected)" ; return 1 ; }
modulename=$1
for cmd in "make install DESTDIR=`pwd`/_install" \
": > $modulename.tmp" \
"cat $modlocation/CONF >> $modulename.tmp || true" \
"cat FLAGS >> $modulename.tmp || true" \
"( cd `pwd`/_install && ( find ./$destdir -depth | sed -e 's/^\.\//file: /' ) ) >> $modulename.tmp" \
"mkdir `pwd`/_install/$destdir/conf" \
"mv $modulename.tmp `pwd`/_install/$destdir/conf/$modulename" \
"cp -dr `pwd`/_install/* /" \
"make installcheck"
do
echo "========================================"
echo "Running command : $cmd"
echo "========================================"
eval $cmd || return 1
done
return 0
}
# find a module by name in the standard directories
find_module()
{
test $# = 1 || { $silent || echo "internal error: wrong number of args for find_module(): $# (1 expected)" ; return 1 ; }
module=$1
echo $OPENTURNS_MODULE_PATH $HOME/openturns/lib/openturns/module ${exec_prefix}/lib/openturns/module | tr ":" "/n" | tr " " "\n" | while read dir
do
if test -f $dir/conf/$module
then
echo $dir
fi
done
}
# get the list of all available modules
all_modules()
{
test $# = 0 || { $silent || echo "internal error: wrong number of args for all_modules(): $# (0 expected)" ; return 1 ; }
mods=
for dir in `echo $OPENTURNS_MODULE_PATH $HOME/openturns/lib/openturns/module ${exec_prefix}/lib/openturns/module | tr ":" "/n" | tr " " "\n"`
do
for conffile in `ls $dir/conf/* 2>/dev/null`
do
modulename=`grep -e "^name: *" $conffile | sed -e "s/^name: *//"`
mods="$mods $modulename"
done
done
echo $mods
}
# get the list of missing prerequisite modules
check_prerequisite()
{
test $# = 1 || { $silent || echo "internal error: wrong number of args for check_prerequisite(): $# (1 expected)" ; return 1 ; }
modlocation=$1
prereq=
if test -f $modlocation/CONF
then
for mod in `grep -e "^needs: *" $modlocation/CONF | sed -e "s/^needs: *//"`
do
loc=`find_module $mod`
test -z "$loc" && prereq="$prereq $mod"
done
echo $prereq
fi
return 0
}
########################################
test $# -lt 1 && print_usage
action=
module=
worklist=
extra_args=
modulename=
silent=false
postmsg=no
prefix=/usr
exec_prefix=${prefix}
prefixarg=openturns
# Argument parsing
while test $# != 0
do
arg=$1
shift
case $arg in
--silent)
silent=true
;;
--install | --remove)
action=`echo $arg | sed -e 's/^--//'`
module=$1
worklist="$worklist $action:$module"
shift
;;
--install=* | --remove=*)
action=`echo $arg | sed -e 's/^--//' -e 's/=.*//'`
module=`echo $arg | sed -e "s/^--$action=//"`
worklist="$worklist $action:$module"
;;
--prefix)
prefixarg=$1
shift
;;
--prefix=*)
prefixarg=`echo $arg | sed -e 's/^--prefix=//'`
;;
--module)
action=query
module=$1
worklist="$worklist $action:$module"
shift
;;
--module=*)
action=query
module=`echo $arg | sed -e "s/^--module=//"`
worklist="$worklist $action:$module"
;;
*)
extra_args="$extra_args $arg"
;;
esac
done
# Prefix keyword / destination directory mapping
case $prefixarg in
openturns)
destdir=${exec_prefix}/lib/openturns/module
;;
user)
destdir=$HOME/openturns/lib/openturns/module
;;
*)
destdir=$prefixarg
postmsg=yes
;;
esac
# Process each module in turn
rc=0
for work in $worklist
do
action=`echo $work | sed -e 's/:.*$//'`
module=`echo $work | sed -e 's/^[^:]*://'`
case $action in
install)
$silent || echo "Trying to install module '$module' ..."
: > openturns-module.log
type=`get_module_type $module`
#echo "module type is '$type'"
test $type = none && print_usage
tempdir=`build_tempdir`
#echo "tempdir=$tempdir"
modlocation=`prepare_module_in_tempdir $module $tempdir $type`
#echo "modlocation=$modlocation"
( cd $modlocation && configure_module "$extra_args" ) >> openturns-module.log 2>&1
rc=$?
if test $rc = 0
then
if test -f $modlocation/CONF
then
modulename=`grep -e "^name: *" $modlocation/CONF | head -1 | sed -e "s/^name: *//"`
( cd $modlocation && compile_module ) >> openturns-module.log 2>&1
rc=$?
if test $rc = 0
then
loc=`find_module $modulename`
if test -z "$loc"
then
prereq=`check_prerequisite $modlocation`
#echo "prereq='$prereq'"
if test -z "$prereq"
then
( cd $modlocation && install_module $modulename ) >> openturns-module.log 2>&1
rc=$?
if test $rc = 0
then
$silent || echo "Module '$modulename' successfully installed"
rm openturns-module.log
test $postmsg = yes && cat <<EOF
Module installed in $destdir which is non standard for Open TURNS.
You should inform Open TURNS of this directory in order to use
the module. You may either append the directory to the
OPENTURNS_MODULE_PATH envvar or use the PYTHONPATH envvar.
EOF
else
$silent || echo "Module '$modulename' installation failed. Check log 'openturns-module.log'"
fi
else
$silent || echo "Module '$modulename' needs: $prereq"
rc=1
fi
else
$silent || echo "Module '$modulename' is already installed"
rc=1
fi
else
$silent || echo "Module '$modulename' compilation failed. Check log 'openturns-module.log'" ;
fi
else
$silent || echo "Module '$module' has no CONF file"
rc=1
fi
else
$silent || echo "Module '$module' configuration failed. Check log 'openturns-module.log'" ;
fi
delete_tempdir $tempdir
;;
remove)
modulename=$module
$silent || echo "Trying to remove module '$module' ..."
destdir=`find_module $modulename`
test -n $destdir || { $silent || echo "No module '$module' found." ; exit 1 ; }
mods=`all_modules` || { $silent || echo "Can't retrieve all modules." ; exit 1 ; }
usedby=
for mod in $mods
do
loc=`find_module $mod`
grep -e "^needs: *$modulename" $loc/conf/$mod && usedby="$usedby $mod"
done
if test -z "$usedby"
then
cp $destdir/conf/$modulename /tmp/openturns-module.$$
rm $destdir/conf/$modulename 2>/dev/null
rmdir $destdir/conf 2>/dev/null
grep -e "^file: *" /tmp/openturns-module.$$ | sed -e "s/^file: *//" | while read file
do
test -d $file && rmdir $file 2>/dev/null || rm $file 2>/dev/null
done
rm /tmp/openturns-module.$$
$silent || echo "Module '$module' successfully removed"
else
$silent || echo "Can't remove module '$modulename' used by: $usedby"
rc=1
fi
;;
query)
modulename=$module
$silent || echo "Trying to find module '$module' ..."
destdir=`find_module $modulename`
test -n $destdir || { $silent || echo "No module '$module' found." ; exit 1 ; }
$silent || echo "Module '$module' located at '$destdir'."
flags=
for arg in $extra_args
do
case $arg in
--swigflags)
flags="$flags `grep -e "^swigflags: " $destdir/conf/$modulename | sed -e 's/^swigflags: //g'`"
;;
--cppflags)
flags="$flags `grep -e "^cppflags: " $destdir/conf/$modulename | sed -e 's/^cppflags: //g'`"
;;
--ldflags)
flags="$flags `grep -e "^ldflags: " $destdir/conf/$modulename | sed -e 's/^ldflags: //g'`"
;;
--libs)
flags="$flags `grep -e "^libs: " $destdir/conf/$modulename | sed -e 's/^libs: //g'`"
;;
esac
done
echo $flags
;;
*)
$silent || echo "Error: unknown action '$action'"
$silent || print_usage
rc=1
;;
esac
test $rc = 0 || break
done
exit $rc
|