File: macx_pkgsetup.in

package info (click to toggle)
otb 7.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,005,476 kB
  • sloc: cpp: 270,143; xml: 128,722; ansic: 4,367; sh: 1,768; python: 1,084; perl: 92; makefile: 72
file content (118 lines) | stat: -rwxr-xr-x 4,949 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh
#
# Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
#     https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e

# verify basic tools are here (install_name_tool is specific macOS)
which sh >/dev/null 2>&1 || ret=$?
if [ ! -z "$ret" ] ; then echo "ERROR: Missing tool 'which'"; exit 1 ; fi
for tool in dirname find file grep cut sed chmod cat readlink install_name_tool ; do
  if [ -z "$(which $tool)" ] ; then
    echo "ERROR: Missing tool '${tool}'"
    echo "Please install it and make sure it can be found from PATH"
    exit 1;
  fi
done

DIRNAME_0=$(dirname "$0")
cd  "$DIRNAME_0" || exit 1

# NOTE: $OUT_DIR is also used in make_sylinks script (see below)
# Avoid any pre-mature optimization on variable names here.

OUT_DIR=$(pwd)

#do not move below 3 lines. it must be before "unset LD_LIBRARY_PATH" code
if [ -f "$OUT_DIR/lib/python/_otbApplication.so" ] ; then
  chmod +x "$OUT_DIR/setup_python.sh"
  ./setup_python.sh || setup_python_ret=$?
fi

# no interference with DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH
unset DYLD_LIBRARY_PATH
unset DYLD_FALLBACK_LIBRARY_PATH

echo "Configuring..."

LIB_FILES=$(find "./lib" "./plugins" -type f -exec file {} \; | grep -i ": Mach-O "|cut -d ':' -f1)
BIN_FILES=$(find "./bin" -type f -exec file {} \; | grep -i ": Mach-O .*executable"|cut -d ':' -f1)
# run install_name_tool
for input_file in $LIB_FILES $BIN_FILES; do
    #echo "adding rpath to $OUT_DIR/$lib_file"
    input_file_old_rpaths=$(otool -l "$input_file" | grep -A 3 "LC_RPATH" | grep -oE 'path .* \(offset' | cut -d ' ' -f 2)
    for rpath_old in $input_file_old_rpaths; do
      install_name_tool "-delete_rpath" "$rpath_old" "$input_file"
    done
    install_name_tool "-add_rpath" "$OUT_DIR/lib" "$input_file"
done

#install uninstall_otb script
echo "Installing uninstall script for OTB 'tools/uninstall_otb.sh'"
sed -i "" "s,mapla.sh,Mapla.app -r,g" "$OUT_DIR/tools/uninstall_otb.sh"
sed -i "" "s,monteverdi.sh,Monteverdi.app -r,g" "$OUT_DIR/tools/uninstall_otb.sh"
sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/tools/uninstall_otb.sh"
chmod +x "$OUT_DIR/tools/uninstall_otb.sh"

mkdir "$OUT_DIR/template.app/Contents/MacOS"
mkdir "$OUT_DIR/template.app/Contents/Resources"
cp -r "$OUT_DIR/template.app" "$OUT_DIR/Mapla.app"
cp -r "$OUT_DIR/template.app" "$OUT_DIR/Monteverdi.app"
mv "$OUT_DIR/mapla.sh" "Mapla.app/Contents/MacOS/Mapla"
mv "$OUT_DIR/monteverdi.sh" "Monteverdi.app/Contents/MacOS/Monteverdi"
rm -fr "template.app"
LONG_VERSION_STRING=@Monteverdi_VERSION_MAJOR@.@Monteverdi_VERSION_MINOR@.@Monteverdi_VERSION_PATCH@
SHORT_VERSION_STRING=@Monteverdi_VERSION_MAJOR@.@Monteverdi_VERSION_MINOR@
#sed qt.conf
sed -i "" "s,Prefix=..,Prefix=$OUT_DIR,g" "$OUT_DIR/bin/qt.conf"

cp "$OUT_DIR/bin/qt.conf" "$OUT_DIR/Mapla.app/Contents/Resources/qt.conf"
cp "$OUT_DIR/Monteverdi.icns" "Mapla.app/Contents/Resources/"
sed -i "" "s,STARTUP_FILE,Mapla,g" "Mapla.app/Contents/Info.plist"
sed -i "" "s,LONG_VERSION,$LONG_VERSION_STRING,g" "Mapla.app/Contents/Info.plist"
sed -i "" "s,SHORT_VERSION,$SHORT_VERSION_STRING,g" "Mapla.app/Contents/Info.plist"
sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/Mapla.app/Contents/MacOS/Mapla"
chmod +x "$OUT_DIR/Mapla.app/Contents/MacOS/Mapla"

cp "$OUT_DIR/bin/qt.conf" "$OUT_DIR/Monteverdi.app/Contents/Resources/qt.conf"
cp "$OUT_DIR/Monteverdi.icns" "Monteverdi.app/Contents/Resources/"
sed -i "" "s,STARTUP_FILE,Monteverdi,g" "Monteverdi.app/Contents/Info.plist"
sed -i "" "s,LONG_VERSION,$LONG_VERSION_STRING,g" "Monteverdi.app/Contents/Info.plist"
sed -i "" "s,SHORT_VERSION,$SHORT_VERSION_STRING,g" "Monteverdi.app/Contents/Info.plist"
sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/Monteverdi.app/Contents/MacOS/Monteverdi"
chmod +x "$OUT_DIR/Monteverdi.app/Contents/MacOS/Monteverdi"

sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/otbenv.profile"
chmod +x "$OUT_DIR/otbenv.profile"

printf %s\\n ""
printf %s\\n "source './otbenv.profile' file to set required environment variables"
printf %s\\n "eg: '. $OUT_DIR/otbenv.profile'"
printf %s\\n "You can also copy above line to  ~/.profile to keep changes permanently!"
printf %s\\n "More documentation can be found in $OUT_DIR/README"


# echo "Creating symbolic links..."
. "./make_symlinks"
rm -f "$OUT_DIR/make_symlinks"
rm -f "$OUT_DIR/setup_python.sh"
rm -f "$OUT_DIR/Monteverdi.icns"
rm -f "$OUT_DIR/pkgsetup"

#open "$OUT_DIR"