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
|
#!/bin/sh -e
usage="
Usage: $0 [OPTIONS]
Installs OpenNI to current machine.
-i,--install
Installs OpenNI (default mode)
-u,--uninstall
Uninstalls OpenNI.
-c,--cross-compile-rootfs <path>
Used for cross-compiling. Installs OpenNI to <path> instead of '/'.
-h,--help
Shows this help screen.
"
OS_NAME=`uname -s`
case $OS_NAME in
Darwin)
MODULES="libnimMockNodes.dylib libnimCodecs.dylib libnimRecorder.dylib"
GACDIR=""
;;
*)
MODULES="libnimMockNodes.so libnimCodecs.so libnimRecorder.so"
GACDIR="-gacdir $rootfs/usr"
;;
esac
SCRIPT_DIR=`pwd`/`dirname $0`
# create file list
LIB_FILES=`ls $SCRIPT_DIR/Lib/*`
BIN_FILES=`ls $SCRIPT_DIR/Bin/ni*`
JAR_FILES=`ls $SCRIPT_DIR/Jar/*.jar`
rootfs=
# parse command line
while [ "$1" ]; do
case $1 in
-i|--install)
install=yes
;;
-u|--uninstall)
uninstall=yes
;;
-c|--cross-staging-dir)
shift
rootfs=$1
;;
-h|--help)
echo "$usage"
exit 0
;;
*)
echo "Unrecognized option $1"
exit 1
esac
shift
done
# default mode is install
if [ ! "$install" = yes ] && [ ! "$uninstall" = yes ]; then
install=yes
fi
# validity check
if [ "$install" = yes ] && [ "$uninstall" = yes ]; then
echo "-i and -u flags cannot be used together!"
exit 1
fi
INSTALL_LIB=$rootfs/usr/lib
INSTALL_BIN=$rootfs/usr/bin
INSTALL_INC=$rootfs/usr/include/ni
INSTALL_VAR=$rootfs/var/lib/ni
INSTALL_JAR=$rootfs/usr/share/java
# make all calls into OpenNI run in this filesystem
export OPEN_NI_INSTALL_PATH=$rootfs
# make sure the staging dir OpenNI is the one being run
export LD_LIBRARY_PATH=$INSTALL_LIB
if [ "$install" = yes ]; then
printf "Installing OpenNI\n"
printf "****************************\n\n"
# copy libraries
printf "copying shared libraries..."
cp $LIB_FILES $INSTALL_LIB
printf "OK\n"
# utilities
printf "copying executables..."
cp $BIN_FILES $INSTALL_BIN
printf "OK\n"
# include files
printf "copying include files..."
mkdir -p $INSTALL_INC
cp -r Include/* $INSTALL_INC
printf "OK\n"
# create database dir
printf "creating database directory..."
mkdir -p $INSTALL_VAR
printf "OK\n"
# register modules
for module in $MODULES; do
printf "registering module '$module'..."
$INSTALL_BIN/niReg -r $INSTALL_LIB/$module
printf "OK\n"
done
# mono
if [ -f $rootfs/usr/bin/gmcs -a -f Bin/OpenNI.net.dll ]; then
printf "Installing .Net wrappers...\n"
gacutil -i Bin/OpenNI.net.dll -package 2.0 $GACDIR
fi
# java wrappers
printf "creating java bindings directory..."
mkdir -p $INSTALL_JAR
printf "OK\n"
printf "Installing java bindings..."
cp $JAR_FILES $INSTALL_JAR
printf "OK\n"
printf "\n*** DONE ***\n\n"
elif [ "$uninstall" = yes ]; then
printf "Uninstalling OpenNI\n"
printf "****************************\n\n"
# unregister modules
for module in $MODULES; do
printf "unregistering module '$module'..."
if $INSTALL_BIN/niReg -u $INSTALL_LIB/$module; then
printf "OK\n"
fi
done
# include files
printf "removing include files..."
rm -rf $INSTALL_INC
printf "OK\n"
# binaries
printf "removing executables..."
for filename in $BIN_FILES; do
rm -f $INSTALL_BIN/`basename $filename`
done
printf "OK\n"
# libraries
printf "removing shared libraries..."
for filename in $LIB_FILES; do
rm -f $INSTALL_LIB/`basename $filename`
done
printf "OK\n"
# mono
if [ -f $rootfs/usr/bin/gmcs -a -f Bin/OpenNI.net.dll ]; then
printf "Removing .Net wrappers...\n"
gacutil -u OpenNI.net $GACDIR
fi
# java
printf "removing java bindings..."
for filename in $JAR_FILES; do
rm -f $INSTALL_JAR/`basename $filename`
done
printf "OK\n"
printf "\n*** DONE ***\n\n"
fi
|