Initial commit
This commit is contained in:
4
scripts/acsmdownloader.sh
Executable file
4
scripts/acsmdownloader.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH
|
||||
./acsmdownloader $@
|
||||
4
scripts/activate.sh
Executable file
4
scripts/activate.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH
|
||||
./activate $@
|
||||
178
scripts/find_libs.sh
Executable file
178
scripts/find_libs.sh
Executable file
@@ -0,0 +1,178 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright Grégory Soutadé
|
||||
|
||||
# This is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with iwla. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Find all dependant shared libraries of a target (using objdump) and copy them into a directory
|
||||
#
|
||||
|
||||
|
||||
# Options
|
||||
TARGET=""
|
||||
OUTPUT=""
|
||||
ROOT_LIB_DIRECTORY=""
|
||||
OBJDUMP=objdump
|
||||
VERBOSE=0
|
||||
EXIT_ON_ERROR=0
|
||||
QUIET_NOT_FOUND=0
|
||||
CLEAN_BEFORE_START=0
|
||||
COPY_TARGET=0
|
||||
|
||||
function debug()
|
||||
{
|
||||
if [ $VERBOSE -eq 1 ] ; then
|
||||
echo -e "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function copy()
|
||||
{
|
||||
target=$1
|
||||
symlink_name=$2
|
||||
|
||||
if [ ! -e ${target} ] ; then
|
||||
debug "${target} not found"
|
||||
return
|
||||
fi
|
||||
|
||||
debug "cp --no-dereference ${target} ${OUTPUT}"
|
||||
cp --no-dereference ${target} ${OUTPUT}
|
||||
|
||||
if [ ! $? -eq 0 ] ; then
|
||||
[ ${EXIT_ON_ERROR} -eq 1 ] && exit 1
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -z "${symlink_name}" ] ; then
|
||||
echo ln -s `basename ${target}` ${OUTPUT}/${symlink_name}
|
||||
ln -s `basename ${target}` ${OUTPUT}/${symlink_name}
|
||||
fi
|
||||
|
||||
# Symlink ? Copy target file
|
||||
if [ -L ${target} ] ; then
|
||||
copy `readlink -e ${target}`
|
||||
fi
|
||||
}
|
||||
|
||||
nb_tabs=0
|
||||
function find_lib()
|
||||
{
|
||||
target="$1"
|
||||
|
||||
if [ ! -e ${target} ] ; then
|
||||
debug "${target} not found"
|
||||
return
|
||||
fi
|
||||
|
||||
nb_tabs=$((${nb_tabs}+1))
|
||||
local tabs=""
|
||||
for i in `seq 1 ${nb_tabs}`; do
|
||||
tabs="${tabs} "
|
||||
done
|
||||
|
||||
dependencies=`${OBJDUMP} -p ${target}|grep NEEDED|sed "s/ \+/ /g"|cut -d' ' -f3`
|
||||
for dependency in ${dependencies} ; do
|
||||
symlink_name=""
|
||||
echo -e "${tabs}${dependency}"
|
||||
debug "find ${ROOT_LIB_DIRECTORY} -name ${dependency}"
|
||||
file=`find ${ROOT_LIB_DIRECTORY} -name ${dependency}|head -n 1`
|
||||
if [ -z "$file" ] ; then
|
||||
# Try lib.so*
|
||||
file=`find ${ROOT_LIB_DIRECTORY} -name ${dependency}*|head -n 1`
|
||||
if [ -z "$file" ] ; then
|
||||
[ ${QUIET_NOT_FOUND} -eq 0 ] && echo "ERROR : ${dependency} not found in ${ROOT_LIB_DIRECTORY}"
|
||||
[ ${EXIT_ON_ERROR} -eq 1 ] && exit 1
|
||||
continue
|
||||
else
|
||||
symlink_name=${dependency}
|
||||
fi
|
||||
fi
|
||||
# Already copied
|
||||
[ -e "${OUTPUT}/${dependency}" ] && continue
|
||||
copy $file ${symlink_name}
|
||||
find_lib $file
|
||||
done
|
||||
|
||||
nb_tabs=$((${nb_tabs}-1))
|
||||
}
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "Usage : ./find_libs [-O OBJDUMP] [-v] [-e] [-q] [-c] [-C] -t TARGET -o OUTPUT_DIR -l ROOT_LIBDIR"
|
||||
echo -e "\t-O OBJDUMP objdump command"
|
||||
echo -e "\t-v verbose"
|
||||
echo -e "\t-e exit on error"
|
||||
echo -e "\t-q quiet when dependency not found"
|
||||
echo -e "\t-c clean target before start"
|
||||
echo -e "\t-C Copy target in output directory"
|
||||
echo -e "\t-t TARGET first executable or library to analyze"
|
||||
echo -e "\t-o OUTPUT_DIR output directory where to place find libs"
|
||||
echo -e "\t-l ROOT_LIBDIR root directory where to search dependancy libs"
|
||||
}
|
||||
|
||||
while getopts "ht:o:l:O:veqcC" arg; do
|
||||
case $arg in
|
||||
t)
|
||||
TARGET=$OPTARG
|
||||
;;
|
||||
o)
|
||||
OUTPUT=$OPTARG
|
||||
;;
|
||||
l)
|
||||
ROOT_LIB_DIRECTORY=$OPTARG
|
||||
;;
|
||||
O)
|
||||
OBJDUMP=$OPTARG
|
||||
;;
|
||||
v)
|
||||
VERBOSE=1
|
||||
;;
|
||||
e)
|
||||
EXIT_ON_ERROR=1
|
||||
;;
|
||||
q)
|
||||
QUIET_NOT_FOUND=1
|
||||
;;
|
||||
c)
|
||||
CLEAN_BEFORE_START=1
|
||||
;;
|
||||
C)
|
||||
COPY_TARGET=1
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "${TARGET}" -o -z "${OUTPUT}" -o -z "${ROOT_LIB_DIRECTORY}" ] ; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
[ ${CLEAN_BEFORE_START} -eq 1 ] && rm -rf ${OUTPUT}
|
||||
|
||||
mkdir -p ${OUTPUT} || exit 1
|
||||
|
||||
echo ${TARGET}
|
||||
[ ${COPY_TARGET} -eq 1 ] && copy ${TARGET}
|
||||
|
||||
find_lib ${TARGET}
|
||||
74
scripts/setup.sh
Executable file
74
scripts/setup.sh
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
ROOT=${PWD}
|
||||
TARGET_DIR="${ROOT}/lib/rmsdk/${RMSDK_VERSION}"
|
||||
TMP_DIR="${ROOT}/tmp"
|
||||
# From https://wiki.mobileread.com/wiki/Kobo_Firmware_Releases#Firmware
|
||||
KOBO_FIRMWARE="http://download.kobobooks.com/firmwares/kobo4/january2016/kobo-update-3.19.5761.zip"
|
||||
# 2016 revision, same as Kobo firmware
|
||||
OPENSSL="https://www.openssl.org/source/old/1.0.1/openssl-1.0.1u.tar.gz"
|
||||
|
||||
|
||||
[ -e ${TMP_DIR} ] && rm -rf ${TMP_DIR}
|
||||
mkdir ${TMP_DIR}
|
||||
pushd ${TMP_DIR}
|
||||
|
||||
echo "Download Kobo firmware..."
|
||||
|
||||
curl ${KOBO_FIRMWARE} -o kobo_firmware.zip || exit 1
|
||||
|
||||
echo "Uncompress firmware"
|
||||
|
||||
unzip kobo_firmware.zip || exit 1
|
||||
|
||||
tar -zxvf KoboRoot.tgz
|
||||
|
||||
echo "Extract libraries"
|
||||
|
||||
${ROOT}/scripts/find_libs.sh -q -C -t "${TMP_DIR}/usr/local/Kobo/librmsdk.so" -l "${TMP_DIR}" -o "${TARGET_DIR}"
|
||||
${ROOT}/scripts/find_libs.sh -q -C -t "${TMP_DIR}/usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib/libQtCore.so.4.6.2" -l "${TMP_DIR}" -o "${TARGET_DIR}"
|
||||
${ROOT}/scripts/find_libs.sh -q -C -t "${TMP_DIR}/usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib/libQtNetwork.so.4.6.2" -l "${TMP_DIR}" -o "${TARGET_DIR}"
|
||||
|
||||
echo "Fix libraries"
|
||||
|
||||
pushd "${TARGET_DIR}"
|
||||
ln -s libQtCore.so.4.6.2 libQt5Core.so.5
|
||||
ln -s libQt5Core.so.5 libQt5Core.so
|
||||
ln -s libQtNetwork.so.4.6.2 libQt5Network.so.5
|
||||
ln -s libQt5Network.so.5 libQt5Network.so
|
||||
ln -s librmsdk.so.1.0.0 librmsdk.so.1
|
||||
rm -f libgcc* libstdc++*
|
||||
popd
|
||||
|
||||
if [ -z "${NO_BUILD_OPENSSL}" -o ${NO_BUILD_OPENSSL} -eq 0 ] ; then
|
||||
|
||||
echo "Downloading OpenSSL"
|
||||
|
||||
curl ${OPENSSL} -o openssl.tgz || exit 1
|
||||
|
||||
echo "Uncompress OpenSSL"
|
||||
|
||||
tar -zxvf openssl.tgz
|
||||
|
||||
pushd openssl-1.0.1u
|
||||
|
||||
echo "Compile OpenSSL"
|
||||
|
||||
./Configure linux-armv4 shared --prefix="${PWD}/root" || exit 1
|
||||
|
||||
make CC=${CC} -j4 build_libs || exit 1
|
||||
|
||||
echo "Install OpenSSL"
|
||||
|
||||
rm -f ${TARGET_DIR}/libcrypto* ${TARGET_DIR}/libssl*
|
||||
|
||||
cp --no-dereference libcrypto.so* libssl.so* ${TARGET_DIR}
|
||||
|
||||
popd
|
||||
fi
|
||||
|
||||
popd
|
||||
|
||||
echo "Cleaning tmp dir"
|
||||
|
||||
rm -rf ${TMP_DIR}
|
||||
Reference in New Issue
Block a user