1
0
Fork 0
borgbackup_on_android/build.sh

95 lines
3 KiB
Bash
Raw Normal View History

2017-07-29 23:09:10 +02:00
#!/data/data/com.termux/files/usr/bin/bash
2019-03-22 00:15:40 +01:00
set -e
2017-07-29 22:44:05 +02:00
set -x
pkg install make clang openssl-dev perl tsu wget git python python-dev gnupg dirmngr curl autoconf automake sed gettext gzip pkg-config libcrypt-dev libzmq-dev
2017-07-29 22:44:05 +02:00
pip install virtualenv
virtualenv --python=python3 borg-env
source borg-env/bin/activate
git clone https://github.com/borgbackup/borg.git
cd borg
2017-11-25 19:53:26 +01:00
git branch 1.1-maint remotes/origin/1.1-maint
git checkout 1.1-maint
2017-07-29 22:44:05 +02:00
pip install -r requirements.d/development.txt
2017-11-26 00:01:17 +01:00
#find if sync_file_range is available
s=`bash ../sync_file_range_test/test.sh`
if [ "$s" = "1" ];
then
echo "patching borg to not use sync_file_range...."
git apply ../borg_sync_file_range.patch
else
echo "no need to patch borg"
fi
2017-07-29 22:44:05 +02:00
#download and build lz4
wget https://github.com/lz4/lz4/archive/v1.7.5.tar.gz -O lz4.tar.gz
tar -xf lz4.tar.gz
cd lz4-1.7.5
make
make install
cd ..
#download and build libattr
wget https://download.savannah.gnu.org/releases/attr/attr-2.4.47.src.tar.gz
tar -xf attr-2.4.47.src.tar.gz
cd attr-2.4.47
#fixing paths to sh
sed -i "s/\/bin\/sh/\/data\/data\/com.termux\/files\/usr\/bin\/sh/" configure
2017-07-29 23:31:22 +02:00
sed -i "s/\/bin\/sh/\/data\/data\/com.termux\/files\/usr\/bin\/sh/" install-sh
2017-07-29 22:44:05 +02:00
sed -i "s/\/bin\/sh/\/data\/data\/com.termux\/files\/usr\/bin\/sh/" include/install-sh
#fix for non-existent /tmp directory in set_cc_for_build of config.guess for 32-bit arm
sed -i "s/TMPDIR=\/tmp/TMPDIR=tmp/g" config.guess
mkdir tmp
2017-09-17 06:35:19 +02:00
./configure CC=clang --prefix=/data/data/com.termux/files/usr/
2017-07-29 22:44:05 +02:00
#fix for ./include/attr/xattr.h:37:58: error: expected function body after function declarator
# const void *__value, size_t __size, int __flags) __THROW;
2017-07-29 23:31:22 +02:00
sed -i "s/__THROW//g" include/xattr.h
2017-07-29 22:44:05 +02:00
make
make install install-lib install-dev
cd ..
#download and build libacl
wget https://download.savannah.gnu.org/releases/acl/acl-2.2.52.src.tar.gz
tar -xf acl-2.2.52.src.tar.gz
cd acl-2.2.52
#fixing paths to sh
sed -i "s/\/bin\/sh/\/data\/data\/com.termux\/files\/usr\/bin\/sh/" configure
2017-07-29 23:31:22 +02:00
sed -i "s/\/bin\/sh/\/data\/data\/com.termux\/files\/usr\/bin\/sh/" install-sh
2017-07-29 22:44:05 +02:00
sed -i "s/\/bin\/sh/\/data\/data\/com.termux\/files\/usr\/bin\/sh/" include/install-sh
#fix for non-existent /tmp directory in set_cc_for_build of config.guess for 32-bit arm
sed -i "s/TMPDIR=\/tmp/TMPDIR=tmp/g" config.guess
mkdir tmp
2017-09-17 06:35:19 +02:00
./configure --prefix=/data/data/com.termux/files/usr/ CC=clang
2017-07-29 22:44:05 +02:00
make
make install install-lib install-dev
cd ..
2017-11-25 20:29:18 +01:00
#patching paths
export BORG_OPENSSL_PREFIX="/data/data/com.termux/files/usr/"
export BORG_LZ4_PREFIX="/data/data/com.termux/files/usr/"
2017-07-29 22:44:05 +02:00
pip install -e .
cd ..
#need wrapper for ssh, because /system/lib64/ needs to be in LD_LIBRARY_PATH
#otherwise: Remote: CANNOT LINK EXECUTABLE "ssh": library "libandroid-support.so" not found
export BORG_RSH=borg_ssh_wrapper
cp borg_ssh_wrapper /data/data/com.termux/files/usr/bin/borg_ssh_wrapper
chmod +x /data/data/com.termux/files/usr/bin/borg_ssh_wrapper
2017-07-29 23:14:21 +02:00
#test by creating a backup of the borg directory
2017-11-25 20:37:51 +01:00
borg init -e none borg_test
2017-07-29 23:39:34 +02:00
borg create borg_test::1 borg
2017-07-29 23:14:21 +02:00
borg list borg_test
borg info borg_test::1
borg list borg_test::1
2019-03-22 02:51:40 +01:00
rm -rf borg_test