ACSMDownloader

ACSMDownloader Commit Details

Date:2021-04-30 17:39:28 (2 months 27 days ago)
Author:Grégory Soutadé
Commit:903ea27e823c0fd588e0019cd7260818ab7c1573
Parents: cf52f44fcacc01a5bb3ebc7a0412ed92542278e2
Message:Add new build scripts

Changes:
Ascripts/acsmdownloader.sh (full)
Ascripts/find_libs.sh (full)
Ascripts/setup.sh (full)
MMakefile (1 diff)
Minclude/rmsdk_wrapper.h (2 diffs)

File differences

Makefile
22
33
44
5
6
7
8
9
10
511
612
713
814
915
10
11
16
17
18
19
20
1221
13
22
23
24
1425
1526
1627
1728
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
1844
1945
2046
21
22
47
48
RMSDK_C_VERSION ?= 10_0
CROSS ?= arm-linux-gnueabihf-
CXX = $(CROSS)g++
CC = $(CROSS)gcc
DEBUG ?= 1
NO_BUILD_OPENSSL ?= 0
INSTALL_DIR ?= $(PWD)/deploy
RMSDK_LIBDIR=$(PWD)/lib/rmsdk/$(RMSDK_VERSION)
OUTPUT ?= output/$(RMSDK_VERSION)
TARGET=$(OUTPUT)/acsmdownloader
SRCS=src/main.cpp
CXXFLAGS += -I./include/rmsdk/ `pkg-config --cflags Qt5Core Qt5Network` -fPIC -ggdb -DRMSDK_$(RMSDK_C_VERSION) -I./include
LDFLAGS=-L. -L./lib/rmsdk/$(RMSDK_VERSION) -L./lib -lrmsdk -L./lib/local -lQt5Core -lQt5Network -lpthread
CXXFLAGS += -I./include -I./include/rmsdk/ `pkg-config --cflags Qt5Core Qt5Network` -fPIC -DRMSDK_$(RMSDK_C_VERSION) -Wall
ifeq ($(DEBUG),1)
CXXFLAGS += -ggdb
endif
all: $(OUTPUT) $(TARGET)
LDFLAGS=-L. -L$(RMSDK_LIBDIR) -L./lib -lrmsdk -lQt5Core -lQt5Network -lpthread
all: $(TARGET)
clean:
rm -rf $(TARGET)
ultraclean:
rm -rf $(TARGET) lib
prepare: $(RMSDK_LIBDIR)
install: $(TARGET)
rm -rf $(INSTALL_DIR)
mkdir -p $(INSTALL_DIR)
cp -r $(RMSDK_LIBDIR) $(INSTALL_DIR)/lib
cp $(TARGET) $(INSTALL_DIR)
cp scripts/acsmdownloader.sh $(INSTALL_DIR)
$(RMSDK_LIBDIR):
CC=$(CC) NO_BUILD_OPENSSL=$(NO_BUILD_OPENSSL) RMSDK_VERSION=$(RMSDK_VERSION) $(PWD)/scripts/setup.sh
$(OUTPUT):
mkdir -p $@
$(TARGET): $(SRCS)
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
$(TARGET): $(RMSDK_LIBDIR) $(OUTPUT) $(SRCS)
$(CXX) $(CXXFLAGS) $(SRCS) $(LDFLAGS) -o $@
include/rmsdk_wrapper.h
277277
278278
279279
280
280
281281
282282
283283
......
371371
372372
373373
374
374
375375
376376
377377
class MockDevice : public dpdev::Device, public mdom::DocumentHandler
{
public:
MockDevice(dpdrm::DRMProcessorClient* processorClient, char* deviceFile, char* activationFile, char* devkeyFile) :deviceProvider(0), processorClient(processorClient)
MockDevice(dpdrm::DRMProcessorClient* processorClient, const char* deviceFile, const char* activationFile, const char* devkeyFile) :deviceProvider(0), processorClient(processorClient)
{
partition = new MockPartition(this, 0, "root", "Fixed", "/tmp", "/tmp", "/tmp");
}
virtual bool startEntity(uft::Value const&) {return true;}
static int readFile(char* filePath, unsigned char** res, int* length = 0, bool addFinalZero=false)
static int readFile(const char* filePath, unsigned char** res, int* length = 0, bool addFinalZero=false)
{
int _length, fd;
QFile file(filePath);
scripts/acsmdownloader.sh
1
2
3
4
#!/bin/bash
export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH
./acsmdownloader $@
scripts/find_libs.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
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
#!/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}
scripts/setup.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
#!/bin/bash
ROOT=${PWD}
TARGET_DIR="${ROOT}/lib/rmsdk/${RMSDK_VERSION}"
echo "ROOT is ${ROOT}"
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}

Archive Download the corresponding diff file

Branches