File: PackageMacAppBundleLibs.sh.in

package info (click to toggle)
hugin 2016.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,072 kB
  • ctags: 11,979
  • sloc: cpp: 116,753; ansic: 6,335; python: 1,517; perl: 577; sh: 168; xml: 102; makefile: 64
file content (78 lines) | stat: -rwxr-xr-x 3,229 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
#!/bin/bash

# This script attempts to copy needed 3rd party libraries and frameworks into 
# the application bundle. It will then attempt to set the 'install_name' for 
# each library so that it references either the PlugIns or Frameworks directory.
# The Script will change every library it can find. Each of these libraries 
# needs to have an absolute install path so we can copy it.

BASE_DIR="$2"
cd ${BASE_DIR}

APPLICATION_NAME="$1"
APPLICATION_APP_BUNDLE="${APPLICATION_NAME}.app"
  APPLICATION_BINDIR="${APPLICATION_APP_BUNDLE}/Contents/MacOS"
APPLICATION_APP_NAME="${APPLICATION_BINDIR}/${APPLICATION_NAME}"
   PLUGINS_PATH="${APPLICATION_APP_BUNDLE}/Contents/Libraries"
FRAMEWORKS_PATH="${APPLICATION_APP_BUNDLE}/Contents/Frameworks"
RPATH_PLUGIN_PATH="@executable_path/../Libraries"
RPATH_FRAMEWORK_PATH="@executable_path/../Frameworks"


echo "*-----------------------------------------------------------*"
echo "* Copying Support Libraries for ${APPLICATION_APP_BUNDLE}"
echo "* Located in ${BASE_DIR}"

mkdir -p "${PLUGINS_PATH}"
mkdir -p "${FRAMEWORKS_PATH}"

get_libraries() {
  local LIBRARIES=$(echo $(otool -X -L $1 | grep -v ${RPATH_PLUGIN_PATH} | grep -v \/System\/Library | grep -v \/usr\/lib | sed -e 's/(.*)//' | sort -u))
  if [ -n "$LIBRARIES" ]; then
    for library in $LIBRARIES
    do
      update_library $library $1
    done
  fi
  install_name_tool -delete_rpath "@CMAKE_SOURCE_DIR@/mac/ExternalPrograms/repository/lib" $1 2&>/dev/null
}

update_library() {
   local lib="$1"
   local lib_file=$(basename ${lib})
   local bin="$2"
   if [ ! -f "${BASE_DIR}/${PLUGINS_PATH}/${lib_file}" ] 
   then 
     echo "* Installing Library -->$1<-- into ${APPLICATION_APP_BUNDLE} " 
     cp "${lib}" "${BASE_DIR}/${PLUGINS_PATH}" || exit 1
     chmod 755 "${BASE_DIR}/${PLUGINS_PATH}/${lib_file}"
     get_libraries "${BASE_DIR}/${PLUGINS_PATH}/${lib_file}"
     install_name_tool -id "${RPATH_PLUGIN_PATH}/${lib_file}" "${BASE_DIR}/${PLUGINS_PATH}/${lib_file}"
   fi
   install_name_tool -change "${lib}" "${RPATH_PLUGIN_PATH}/${lib_file}" "${bin}"
}


# -----------------------------------------------------------------------------
# Copy libraries for all exetuables in APPLICATION_BINDIR
# -----------------------------------------------------------------------------

for _exe in ${BASE_DIR}/${APPLICATION_BINDIR}/*; do
  get_libraries $_exe
done


  # -----------------------------------------------------------------------------
  # Copy ExifTool into the stitchers
  # -----------------------------------------------------------------------------
if [ "${APPLICATION_APP_BUNDLE}" == "PTBatcherGUI.app" ] || [ "${APPLICATION_APP_BUNDLE}" == "HuginStitchProject.app" ]; then

  if [ ! -x "${APPLICATION_APP_BUNDLE}/Contents/Resources/ExifTool/exiftool" ]; then
    echo "* Installing ExifTool into ${APPLICATION_APP_BUNDLE} " 
    mkdir -p "${APPLICATION_APP_BUNDLE}/Contents/Resources/ExifTool"
    cp -v "@CMAKE_SOURCE_DIR@/mac/ExternalPrograms/repository/"Image-ExifTool-*/exiftool  "${APPLICATION_APP_BUNDLE}/Contents/Resources/ExifTool"
    cp -r "@CMAKE_SOURCE_DIR@/mac/ExternalPrograms/repository/"Image-ExifTool-*/lib       "${APPLICATION_APP_BUNDLE}/Contents/Resources/ExifTool"
  fi

fi