Skip to content

Commit

Permalink
Merge pull request #391 from koreader/chrox-master
Browse files Browse the repository at this point in the history
zsync binary for Android that will be used by OTA
  • Loading branch information
houqp committed Mar 8, 2016
2 parents 6d2c11b + ecb76ed commit 21066ec
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Makefile
Expand Up @@ -19,14 +19,14 @@ all: $(OUTPUT_DIR)/libs $(if $(ANDROID),,$(LUAJIT)) \
$(LUA_SPORE_ROCK) \
$(if $(ANDROID),$(LPEG_DYNLIB) $(LPEG_RE),) \
$(if $(WIN32),,$(OUTPUT_DIR)/sdcv) \
$(if $(or $(ANDROID),$(WIN32)),,$(OUTPUT_DIR)/tar) \
$(if $(or $(ANDROID),$(WIN32)),,$(OUTPUT_DIR)/zsync) \
$(if $(WIN32),,$(OUTPUT_DIR)/tar) \
$(if $(WIN32),,$(OUTPUT_DIR)/zsync) \
$(if $(WIN32), ,$(ZMQ_LIB) $(CZMQ_LIB) $(FILEMQ_LIB) $(ZYRE_LIB))
ifndef EMULATE_READER
STRIP_FILES="\
$(if $(WIN32),,$(OUTPUT_DIR)/sdcv) \
$(if $(or $(ANDROID),$(WIN32)),,$(OUTPUT_DIR)/tar) \
$(if $(or $(ANDROID),$(WIN32)),,$(OUTPUT_DIR)/zsync) \
$(if $(WIN32),,$(OUTPUT_DIR)/tar) \
$(if $(WIN32),,$(OUTPUT_DIR)/zsync) \
$(if $(ANDROID),,$(LUAJIT)) \
$(OUTPUT_DIR)/libs/$(if $(WIN32),*.dll,*.so*)" ;\
$(STRIP) --strip-unneeded $${STRIP_FILES} ;\
Expand Down Expand Up @@ -109,7 +109,7 @@ ffi/lodepng_h.lua: ffi-cdecl/lodepng_decl.c $(LODEPNG_DIR)
CPPFLAGS="$(CFLAGS) -I. -I$(LODEPNG_DIR)" $(FFI_CDECL) gcc ffi-cdecl/lodepng_decl.c $@

# include all third party libs
include third.Makefile
include Makefile.third

# ===========================================================================
# the attachment extraction tool:
Expand Down
6 changes: 6 additions & 0 deletions Makefile.defs
Expand Up @@ -196,6 +196,7 @@ else ifeq ($(TARGET), kindle-legacy)
else ifeq ($(TARGET), android)
ARM_ARCH:=$(ANDROID_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
export ac_cv_type_in_port_t=yes
else ifeq ($(TARGET), arm-generic)
# Defaults to generic crap
ARM_ARCH:=$(ARMV6_GENERIC_ARCH)
Expand Down Expand Up @@ -280,6 +281,11 @@ endif

# this will create a path named build/arm-none-linux-gnueabi or similar
MACHINE?=$(shell PATH=$(PATH) $(CC) -dumpmachine 2>/dev/null)
ifdef DEBUG
$(info ************ Building for MACHINE: "$(MACHINE)" **********)
$(info ************ PATH: "$(PATH)" **********)
$(info ************ CHOST: "$(CHOST)" **********)
endif
OUTPUT_DIR?=build/$(MACHINE)

# you can probably leave these settings alone:
Expand Down
2 changes: 1 addition & 1 deletion third.Makefile → Makefile.third
Expand Up @@ -297,7 +297,7 @@ $(OUTPUT_DIR)/sdcv: $(if $(ANDROID),$(GLIB_STATIC),$(GLIB)) $(ZLIB_STATIC) $(THI
$(OUTPUT_DIR)/tar: $(THIRDPARTY_DIR)/tar/CMakeLists.txt
install -d $(TAR_BUILD_DIR)
cd $(TAR_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DLIBS="$(if $(WIN32),,-lrt)" \
$(CMAKE) -DCC="$(CC)" -DLIBS="$(if $(or $(ANDROID),$(WIN32)),,-lrt)" \
$(if $(LEGACY),-DDISABLE_LARGEFILE:BOOL=ON -DDISABLE_FORTIFY:BOOL=ON,) \
-DCHOST="$(if $(EMULATE_READER),,$(CHOST))" \
$(CURDIR)/$(THIRDPARTY_DIR)/tar && \
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/tar/CMakeLists.txt
Expand Up @@ -10,7 +10,7 @@ assert_var_defined(LIBS)
ep_get_source_dir(SOURCE_DIR)
ep_get_binary_dir(BINARY_DIR)

set(CFG_ENV_VAR "CC=\"${CC}\"")
set(CFG_ENV_VAR "CC=\"${CC} -DHAVE_MKFIFO=1\"")
set(CFG_OPTS "-q LIBS=${LIBS} --host=\"${CHOST}\"")

if(${DISABLE_LARGEFILE})
Expand Down
5 changes: 5 additions & 0 deletions thirdparty/zsync/CMakeLists.txt
Expand Up @@ -15,6 +15,10 @@ ep_get_binary_dir(BINARY_DIR)

set(CFG_OPTS "-q --prefix=${BINARY_DIR} --host=\"${HOST}\"")
set(CFG_CMD_STR "CC=\"${CC}\" CFLAGS=\"$(CFLAGS) -I${SOURCE_DIR}/c\" ${SOURCE_DIR}/c/configure ${CFG_OPTS}")
# don't check missing definition of in_port_t in NDK <netinet/in.h>
set(PATCH_CMD1 sh -c "patch -N -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/zsync.patch || true")
# fix "rename: Invalid cross-device link" error for Android
set(PATCH_CMD2 sh -c "patch -N -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/zsync-rename.patch || true")

ko_write_gitclone_script(
GIT_CLONE_SCRIPT_FILENAME
Expand All @@ -28,6 +32,7 @@ ExternalProject_Add(
${PROJECT_NAME}
DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P ${GIT_CLONE_SCRIPT_FILENAME}
PATCH_COMMAND sh -c "cd c && autoreconf -fi"
PATCH_COMMAND COMMAND ${PATCH_CMD1} COMMAND ${PATCH_CMD2}
CONFIGURE_COMMAND sh -c ${CFG_CMD_STR}
BUILD_COMMAND $(MAKE) -j${PARALLEL_JOBS} --silent
# skip install
Expand Down
31 changes: 31 additions & 0 deletions thirdparty/zsync/zsync-rename.patch
@@ -0,0 +1,31 @@
diff --git a/c/libzsync/zsync.c b/c/libzsync/zsync.c
index 8b18d42..971d2c6 100644
--- a/c/libzsync/zsync.c
+++ b/c/libzsync/zsync.c
@@ -41,6 +41,8 @@
#include <string.h>
#include <ctype.h>
#include <time.h>
+#include <errno.h>
+#include <fcntl.h>

#include <arpa/inet.h>

@@ -533,6 +535,17 @@ int zsync_rename_file(struct zsync_state *zs, const char *f) {
free(rf);
zs->cur_filename = strdup(f);
}
+ else if (errno == EXDEV) {
+ int in_fd = open(rf, O_RDONLY);
+ int out_fd = open(f, O_WRONLY);
+ char buf[8192];
+ while(1) {
+ ssize_t result = read(in_fd, &buf[0], sizeof(buf));
+ if (!result) break;
+ write(out_fd, &buf[0], result);
+ }
+ unlink(rf);
+ }
else
perror("rename");

25 changes: 25 additions & 0 deletions thirdparty/zsync/zsync.patch
@@ -0,0 +1,25 @@
diff --git a/c/configure.ac b/c/configure.ac
index 87b0be1..6b5596f 100644
--- a/c/configure.ac
+++ b/c/configure.ac
@@ -32,7 +32,7 @@ AC_TYPE_SIZE_T
AC_CHECK_FUNCS(memcpy pwrite pread mkstemp)

X_TYPE_SOCKLEN_T
-X_TYPE_IN_PORT_T
+#X_TYPE_IN_PORT_T
X_DECL_H_ERRNO

dnl Solaris needs -lsocket - and we need this for the getaddrinfo test
diff --git a/c/libzsync/sha1.h b/c/libzsync/sha1.h
index 3946505..c898185 100644
--- a/c/libzsync/sha1.h
+++ b/c/libzsync/sha1.h
@@ -10,6 +10,7 @@
#define _SHA1_H

#include "config.h"
+#include <stdio.h>

#ifdef HAVE_INTTYPES_H
#include <inttypes.h>

0 comments on commit 21066ec

Please sign in to comment.