From 69148551aa38a787a0045333cc8bccd1662804e3 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Sun, 26 May 2019 15:48:21 +0300 Subject: [PATCH] qemu-common: adapt build scripts for both android-5 and android-7 --- .../android-5/0001-implement-lockf.patch | 95 +++++++++++++++++++ x11-packages/qemu-common/build.sh | 15 ++- 2 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 x11-packages/qemu-common/android-5/0001-implement-lockf.patch diff --git a/x11-packages/qemu-common/android-5/0001-implement-lockf.patch b/x11-packages/qemu-common/android-5/0001-implement-lockf.patch new file mode 100644 index 000000000..8d8eea8e0 --- /dev/null +++ b/x11-packages/qemu-common/android-5/0001-implement-lockf.patch @@ -0,0 +1,95 @@ +diff -uNr qemu-3.1.0/lockf_implementation.h qemu-3.1.0.mod/lockf_implementation.h +--- qemu-3.1.0/lockf_implementation.h 1970-01-01 03:00:00.000000000 +0300 ++++ qemu-3.1.0.mod/lockf_implementation.h 2019-02-14 00:17:12.137667319 +0200 +@@ -0,0 +1,56 @@ ++#ifndef LOCKF_IMPLEMENTATION_H ++#define LOCKF_IMPLEMENTATION_H ++ ++// ++// lockf() implementation from GNU Libc ++// ++ ++static int lockf (int fd, int cmd, off_t len) ++{ ++ struct flock fl; ++ ++ memset ((char *) &fl, '\0', sizeof (fl)); ++ ++ /* lockf is always relative to the current file position. */ ++ fl.l_whence = SEEK_CUR; ++ fl.l_start = 0; ++ fl.l_len = len; ++ ++ switch (cmd) ++ { ++ case F_TEST: ++ /* Test the lock: return 0 if FD is unlocked or locked by this process; ++ return -1, set errno to EACCES, if another process holds the lock. */ ++ fl.l_type = F_RDLCK; ++ if (fcntl (fd, F_GETLK, &fl) < 0) ++ return -1; ++ if (fl.l_type == F_UNLCK || fl.l_pid == getpid ()) ++ return 0; ++ errno = EACCES; ++ return -1; ++ ++ case F_ULOCK: ++ fl.l_type = F_UNLCK; ++ cmd = F_SETLK; ++ break; ++ case F_LOCK: ++ fl.l_type = F_WRLCK; ++ cmd = F_SETLKW; ++ break; ++ case F_TLOCK: ++ fl.l_type = F_WRLCK; ++ cmd = F_SETLK; ++ break; ++ ++ default: ++ errno = EINVAL; ++ return -1; ++ } ++ ++ /* lockf() is a cancellation point but so is fcntl() if F_SETLKW is ++ used. Therefore we don't have to care about cancellation here, ++ the fcntl() function will take care of it. */ ++ return fcntl (fd, cmd, &fl); ++} ++ ++#endif +diff -uNr qemu-3.1.0/os-posix.c qemu-3.1.0.mod/os-posix.c +--- qemu-3.1.0/os-posix.c 2018-12-11 19:44:34.000000000 +0200 ++++ qemu-3.1.0.mod/os-posix.c 2019-02-14 00:17:05.354295183 +0200 +@@ -36,6 +36,7 @@ + #include "qemu/error-report.h" + #include "qemu/log.h" + #include "qemu/cutils.h" ++#include "lockf_implementation.h" + + #ifdef CONFIG_LINUX + #include +diff -uNr qemu-3.1.0/qga/main.c qemu-3.1.0.mod/qga/main.c +--- qemu-3.1.0/qga/main.c 2018-12-11 19:44:34.000000000 +0200 ++++ qemu-3.1.0.mod/qga/main.c 2019-02-14 00:17:18.731038388 +0200 +@@ -45,6 +45,8 @@ + #endif + #endif + ++#include "lockf_implementation.h" ++ + #ifndef _WIN32 + #define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0" + #define QGA_STATE_RELATIVE_DIR "run" +diff -uNr qemu-3.1.0/scsi/qemu-pr-helper.c qemu-3.1.0.mod/scsi/qemu-pr-helper.c +--- qemu-3.1.0/scsi/qemu-pr-helper.c 2018-12-11 19:44:34.000000000 +0200 ++++ qemu-3.1.0.mod/scsi/qemu-pr-helper.c 2019-02-14 00:17:24.634405524 +0200 +@@ -24,6 +24,8 @@ + #include + #include + ++#include "lockf_implementation.h" ++ + #ifdef CONFIG_LIBCAP + #include + #endif diff --git a/x11-packages/qemu-common/build.sh b/x11-packages/qemu-common/build.sh index 104e4db2c..47d65818c 100644 --- a/x11-packages/qemu-common/build.sh +++ b/x11-packages/qemu-common/build.sh @@ -3,13 +3,24 @@ TERMUX_PKG_DESCRIPTION="A set common files for the QEMU emulators" TERMUX_PKG_LICENSE="LGPL-2.1" TERMUX_PKG_MAINTAINER="Leonid Plyushch " TERMUX_PKG_VERSION=3.1.0 -TERMUX_PKG_REVISION=7 +TERMUX_PKG_REVISION=8 TERMUX_PKG_SRCURL=https://download.qemu.org/qemu-$TERMUX_PKG_VERSION.tar.xz TERMUX_PKG_SHA256=6a0508df079a0a33c2487ca936a56c12122f105b8a96a44374704bef6c69abfc -#TERMUX_PKG_DEPENDS="capstone, glib, libandroid-shmem, libc++, libcap, libgnutls, libnettle" TERMUX_PKG_DEPENDS="capstone, dtc, glib, libandroid-shmem, libbz2, libc++, libcap, libcurl, libffi, libgnutls, libjpeg-turbo, liblzo, libnettle, libnfs, libpixman, libpng, libsasl, libssh2, libxml2, ncurses, openssl, pcre, sdl2, zlib" TERMUX_PKG_BUILD_IN_SRC=true +termux_step_pre_configure() { + if [ $TERMUX_PKG_API_LEVEL -lt 24 ]; then + patch -p1 -i "$TERMUX_PKG_BUILDER_DIR"/android-5/0001-implement-lockf.patch + TERMUX_PKG_DEPENDS="$TERMUX_PKG_DEPENDS, libutil" + + # Build dependency 'libutil' manually since buildorder.py cannot + # process shell script structures. + (cd "$TERMUX_SCRIPTDIR" + TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -a "$TERMUX_ARCH" libutil) + fi +} + termux_step_configure() { local ENABLED_TARGETS