forked from desura/Desurium
/
getceflibs.sh
executable file
·87 lines (76 loc) · 2.36 KB
/
getceflibs.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
#!/bin/sh
# -------
# Copyright (c) 2012 Jookia
#
# Usage of the works is permitted provided that this instrument is retained with
# the works, so that any entity that uses the works is notified of this
# instrument.
#
# DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
# we need mcf_extract, if we don't have it, compile...
if [ ! -e ./build/src/tools/mcf_extract/mcf_extract ] ; then
echo "mcf_extract not found."
echo "Compiling..."
./build_desura.sh
fi
COPYPATH="`pwd`/ceflibs/"
ARGUMENTS="$1" # if ARGUMENTS != nil, we assume a script is accesses getceflibs.sh
if [ -z ${ARGUMENTS} ] ; then
INSTALLDIR="install"
fi
# To get these, download the official Desura client, run it, and steal it from
# the XML file it downloads.
if [[ "`uname -m`" = "x86_64" ]]; then
URL="http://app.desura.com/120/2011/1535.mcf"
elif [[ "`uname -m`" = "i686" ]]; then
URL="http://app.desura.com/110/2011/1534.mcf"
else
echo "Sorry, official Desura only supports x86_64 and i686. This won't work."
exit 1
fi
if [ ! -d "${COPYPATH}" ] ; then
mkdir $COPYPATH
fi
echo "Downloading libs..."
wget $URL -O desura.mcf
if [ -z ${ARGUMENTS} ] ; then
export LD_LIBRARY_PATH="`pwd`/install/lib"
else
export LD_LIBRARY_PATH="`pwd`/${INSTALLDIR}/lib"
fi
echo "Extracting libs..."
./build/src/tools/mcf_extract/mcf_extract desura.mcf tmp_desura
cd tmp_desura
mv lib_extra/* lib
# copyDeps recursively copies libraries. Could come in useful somewhere else.
# $1: The library to copy, and to have its deps copied.
# $COPYPATH: The path to copy $1 to.
# $LIBSPATH: The path to search for deps of $1 in.
function copyDeps
{
cp $1 $COPYPATH
AWKLIBSPATH="`echo \"$LIBSPATH\" | sed 's|\/|\\\/|g'`"
for dep in $(ldd 2>/dev/null $1 | awk "/^.*$AWKLIBSPATH.*$/{print \$1}")
do
DEPLIBSPATH="$LIBSPATH/$dep"
DEPCOPYPATH="$COPYPATH/$dep"
if [[ ! -f $DEPCOPYPATH ]]; then
copyDeps $DEPLIBSPATH
fi
done
}
if [ -z ${ARGUMENTS} ] ; then # no argument is given, we most likely just
# run the script manually
LIBSPATH="`pwd`/lib"
export LD_LIBRARY_PATH="/lib:/usr/lib:$LIBSPATH"
else # an argument is given, we most likely access
# getceflibs.sh using a script
LIBSPATH="${INSTALLDIR}/lib"
export LD_LIBRARY_PATH="/opt/desura/lib"
fi
echo "Copying libs to destinations..."
copyDeps "$LIBSPATH/libcef_desura.so"
echo "Removing unwanted files..."
cd ..
rm -r ./tmp_desura/ desura.mcf
echo "Done"