qemu-common: adapt build scripts for both android-5 and android-7

This commit is contained in:
Leonid Pliushch 2019-05-26 15:48:21 +03:00 committed by Yaksh Bariya
parent 02c1275050
commit 69148551aa
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
2 changed files with 108 additions and 2 deletions

View File

@ -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 <sys/prctl.h>
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 <linux/dm-ioctl.h>
#include <scsi/sg.h>
+#include "lockf_implementation.h"
+
#ifdef CONFIG_LIBCAP
#include <cap-ng.h>
#endif

View File

@ -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 <leonid.plyushch@gmail.com>"
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