site  contact  subhomenews

Xdelta3 compiled statically in Pi3

December 04, 2016 — BarryK
Yesterday I tried to compile Xdelta3 statically against dietlibc, running Quirky on my Raspberry Pi3. Gave up.

Quirky, and the pup before, uses an old version of xdelta, "30p". This, and later versions, are described on the developer's website:
http://xdelta.org/

There is a "30q" which has fixes for Windows, then there was a major version jump. The old 30p works fine, so I will stay with it. It also looks simpler to compile.

Previously, I have compiled it in a Landley x86 and x86_64 uClibc chrootable filesystems, so I know that it does link against uClibc OK.

Well, I have buildroot. using uClibc, where I have already been compiling packages statically, so far, busybox, e2fsprogs and coreutils. The problem is, buildroot does not have xdelta3.

Fortunately, I found someone else has added xdelta3, version 30q, to buildroot:
https://github.com/wagle/addnas_source/tree/master/1470_Firmware_Source/buildroot-patches/packages/xdelta3

I modified that a bit, and put it into buildroot. I created folder package/xdelta3, with three files 'Config.in', 'xdelta3.hash' and 'xdelta3.mk'.

Config.in
config BR2_PACKAGE_XDELTA3

bool "xdelta3 binary file difference"
default y
depends on BR2_PACKAGE_UCLIBC
help
The xdelta3 patch tool. Allows incremental update of binary files.

http://xdelta.org/
<

Note that the indents are tab character for first indent, second indent is two space characters.

xdelta3.hash
sha1 988f8d8f884aee31b5a0de0a4067575cb452543f xdelta30p.tar.bz2
<

xdelta3.mk
#############################################################

#
# xdelta3
#
#############################################################
XDELTA3_VER:=0p
XDELTA3_SOURCE:=xdelta3$(XDELTA3_VER).tar.bz2
XDELTA3_SRC=xdelta3.c
XDELTA3_SITE:=http://distro.ibiblio.org/quirky/quirky6/sources/t2/april/
XDELTA3_DIR:=$(BUILD_DIR)/xdelta3$(XDELTA3_VER)
XDELTA3_CAT:=bzcat
XDELTA3_BINARY:=xdelta3
XDELTA3_TARGET_BINARY:=usr/sbin/xdelta3
XDELTA3_CC_OPTS:=-DXD3_DEBUG=0 \
-DXD3_USE_LARGEFILE64=1 \
-DREGRESSION_TEST=0 \
-DSECONDARY_DJW=1 \
-DSECONDARY_FGK=1 \
-DXD3_MAIN=1 \
-DXD3_POSIX=1


$(DL_DIR)/$(XDELTA3_SOURCE):
$(WGET) -P $(DL_DIR) $(XDELTA3_SITE)/$(XDELTA3_SOURCE)

xdelta3-source: $(DL_DIR)/$(XDELTA3_SOURCE)

#############################################################
#
# build xdelta3 for use on the target system
#
#############################################################
$(XDELTA3_DIR)/.unpacked: $(DL_DIR)/$(XDELTA3_SOURCE)
$(XDELTA3_CAT) $(DL_DIR)/$(XDELTA3_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
touch $(XDELTA3_DIR)/.unpacked

$(XDELTA3_DIR)/.configured: $(XDELTA3_DIR)/.unpacked
touch $(XDELTA3_DIR)/.configured

$(XDELTA3_DIR)/$(XDELTA3_BINARY): $(XDELTA3_DIR)/.configured
${TARGET_CC} $(TARGET_CFLAGS) $(XDELTA3_CC_OPTS)\
${XDELTA3_DIR}/${XDELTA3_SRC} -o ${XDELTA3_DIR}/${XDELTA3_BINARY}

$(TARGET_DIR)/$(XDELTA3_TARGET_BINARY): $(XDELTA3_DIR)/$(XDELTA3_BINARY)
cp $(XDELTA3_DIR)/$(XDELTA3_BINARY) $(TARGET_DIR)/$(XDELTA3_TARGET_BINARY)


xdelta3: uclibc $(TARGET_DIR)/$(XDELTA3_TARGET_BINARY)

xdelta3-clean:
$(MAKE) -C $(XDELTA3_DIR) clean

xdelta3-dirclean:
rm -rf $(XDELTA3_DIR)

#############################################################
#
# Toplevel Makefile options
#
#############################################################
ifeq ($(strip $(BR2_PACKAGE_XDELTA3)),y)
TARGETS+=xdelta3
endif
<

Then, and entry has to be made in package/Config.in

Finally, compile it:
# make xdelta3
<

Comments

Well, no, first have to select the package:
# make menuconfig

# make xdelta3
<

You can make an entry anywhere appropriate in file package/Config.in

I inserted this line into the "Miscellaneous" category:
	source "package/xdelta3/Config.in"
<

http://distro.ibiblio.org/quirky/quirky6/armv7/packages/pet_packages-xerus/xdelta3_static-30p-xerus-armv7.pet

Very interesting, the stripped size of 'xdelta3' is only 82KB.

The earlier dynaically-linked with glibc xdelta3 is 102KB.

Out of interest, I also compiled statically against glibc, and it was about 450KB.

Also interesting, my x86_64 shared-lib compile against glibc is 140KB.

All of these binaries are stripped.

Tags: linux