[Android] compile.sh: check libvlc custom patches apply

Simon Latapie git at videolan.org
Fri Jul 26 17:16:10 CEST 2019


vlc-android | branch: master | Simon Latapie <garf at videolan.org> | Fri Jul 26 14:17:13 2019 +0200| [d948cb1a4e838030a7dfa47560bc85295586175e] | committer: Simon Latapie

compile.sh: check libvlc custom patches apply

Use the Message-Id header in patch files to check whether they have
already been applied to vlc sources.
To perform that:
- patch files are generated with the '--thread' option to generate the
  Message-Id header
- patch files are applied with 'git am --message-id ...' to keep the
  Message-Id in the commit description

> https://code.videolan.org/videolan/vlc-android/commit/d948cb1a4e838030a7dfa47560bc85295586175e
---

 compile.sh                                         | 35 ++++++++++++++++++++--
 .../patches/vlc3/0001-access-add-smb2-module.patch |  5 ++--
 ...-compat-Workaround-sendmsg-bug-on-android.patch |  7 +++--
 ...03-libvlc-events-Add-callbacks-for-record.patch |  5 +++-
 ...work-tls-Handle-errors-from-older-kernels.patch |  5 +++-
 ...tput-file-Add-error-dialog-for-write-open.patch |  5 +++-
 ...006-libvlc-media_player-Add-record-method.patch |  5 +++-
 7 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/compile.sh b/compile.sh
index 0664fdc4e..e337bd719 100755
--- a/compile.sh
+++ b/compile.sh
@@ -18,6 +18,31 @@ checkfail()
     fi
 }
 
+# Try to check whether a patch file has already been applied to the current directory tree
+# Warning: this function assumes:
+# - The patch file contains a Message-Id header. This can be generated with `git format-patch --thread ...` option
+# - The patch has been applied with `git am --message-id ...` option to keep the Message-Id in the commit description
+check_patch_is_applied()
+{
+    patch_file=$1
+    diagnostic "Checking presence of patch $1"
+    message_id=$(grep -E '^Message-Id: [^ ]+' "$patch_file" | sed 's/^Message-Id: \([^\ ]+\)/\1/')
+    if [ -z "$message_id" ]; then
+        diagnostic "Error: patch $patch_file does not contain a Message-Id."
+        diagnostic "Please consider generating your patch files with the 'git format-patch --thread ...' option."
+        diagnostic ""
+        exit 1
+    fi
+    if [ -z "$(git log --grep="$message_id")" ]; then
+        diagnostic "Cannot find patch $patch_file in tree, aborting."
+        diagnostic "There can be two reasons for that:"
+        diagnostic "- you forgot to apply the patch on this tree, or"
+        diagnostic "- you applied the patch without the 'git am --message-id ...' option."
+        diagnostic ""
+        exit 1
+    fi
+}
+
 # Read the Android Wiki http://wiki.videolan.org/AndroidCompile
 # Setup all that stuff correctly.
 # Get the latest Android SDK Platform or modify numbers in configure.sh and libvlc/default.properties.
@@ -246,20 +271,26 @@ if [ ! -d "vlc" ]; then
     diagnostic "VLC sources: not found, cloning"
     git clone https://git.videolan.org/git/vlc/vlc-3.0.git vlc
     checkfail "VLC sources: git clone failed"
+    cd vlc
     diagnostic "VLC sources: resetting to the TESTED_HASH commit (${TESTED_HASH})"
     git reset --hard ${TESTED_HASH}
     checkfail "VLC sources: TESTED_HASH ${TESTED_HASH} not found"
     diagnostic "VLC sources: applying custom patches"
-    cd vlc
-    git am ../libvlc/patches/vlc3/*.patch
+    # Keep Message-Id inside commits description to track them afterwards
+    git am --message-id ../libvlc/patches/vlc3/*.patch
     checkfail "VLC sources: cannot apply custom patches"
     cd ..
 else
     diagnostic "VLC source: found sources, leaving untouched"
 fi
+diagnostic "VLC sources: Checking TESTED_HASH and patches presence"
 cd vlc
 git cat-file -e ${TESTED_HASH} 2> /dev/null
 checkfail "Error: Your vlc checkout does not contain the latest tested commit: ${TESTED_HASH}"
+for patch_file in ../libvlc/patches/vlc3/*.patch; do
+    check_patch_is_applied "$patch_file"
+done
+cd ..
 
 ############
 # Make VLC #
diff --git a/libvlc/patches/vlc3/0001-access-add-smb2-module.patch b/libvlc/patches/vlc3/0001-access-add-smb2-module.patch
index ad5499c29..529595a57 100644
--- a/libvlc/patches/vlc3/0001-access-add-smb2-module.patch
+++ b/libvlc/patches/vlc3/0001-access-add-smb2-module.patch
@@ -1,4 +1,5 @@
-From 2e675c6533bdf0a12c68e7673736c24613809665 Mon Sep 17 00:00:00 2001
+From 9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b Mon Sep 17 00:00:00 2001
+Message-Id: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
 From: Thomas Guillem <thomas at gllm.fr>
 Date: Fri, 13 Apr 2018 16:15:16 +0200
 Subject: [PATCH 1/6] access: add smb2 module
@@ -27,7 +28,7 @@ allow to use Builtin NTLMSSP authentication instead of libkrb5.
  create mode 100644 modules/access/smb2.c
 
 diff --git a/configure.ac b/configure.ac
-index 49b1166742..7bcdb44c9b 100644
+index 4909c43539..afe1ce93ae 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -1854,7 +1854,14 @@ AS_IF([test "${SYS}" = "mingw32" -a "${enable_winstore_app}" != "yes"], [ VLC_AD
diff --git a/libvlc/patches/vlc3/0002-compat-Workaround-sendmsg-bug-on-android.patch b/libvlc/patches/vlc3/0002-compat-Workaround-sendmsg-bug-on-android.patch
index 2f458cd2f..217bdc471 100644
--- a/libvlc/patches/vlc3/0002-compat-Workaround-sendmsg-bug-on-android.patch
+++ b/libvlc/patches/vlc3/0002-compat-Workaround-sendmsg-bug-on-android.patch
@@ -1,4 +1,7 @@
-From 62e61c44f3c7a35a39e718c85f06531c5a1f928f Mon Sep 17 00:00:00 2001
+From 169d059c034fbda81ed5bca4a838fa1157824c51 Mon Sep 17 00:00:00 2001
+Message-Id: <169d059c034fbda81ed5bca4a838fa1157824c51.1564134421.git.nobody at example.com>
+In-Reply-To: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
+References: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo at beauzee.fr>
 Date: Thu, 28 Mar 2019 15:23:48 +0100
 Subject: [PATCH 2/6] compat: Workaround sendmsg bug on android
@@ -46,7 +49,7 @@ index 0f42e782f8..8d69048746 100644
  #else
  #error sendmsg not implemented on your platform!
 diff --git a/configure.ac b/configure.ac
-index 7bcdb44c9b..1ad82e2d75 100644
+index afe1ce93ae..c0c0b6109a 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -365,6 +365,9 @@ AS_IF([test "$SYS" = linux],[
diff --git a/libvlc/patches/vlc3/0003-libvlc-events-Add-callbacks-for-record.patch b/libvlc/patches/vlc3/0003-libvlc-events-Add-callbacks-for-record.patch
index 7ea482f93..16e0a95c6 100644
--- a/libvlc/patches/vlc3/0003-libvlc-events-Add-callbacks-for-record.patch
+++ b/libvlc/patches/vlc3/0003-libvlc-events-Add-callbacks-for-record.patch
@@ -1,4 +1,7 @@
-From e8992a5bbc20101445819ad92d39bd97f1290da8 Mon Sep 17 00:00:00 2001
+From 75f1a7b60b8927a35788e7a8a8fd3d804e273e7f Mon Sep 17 00:00:00 2001
+Message-Id: <75f1a7b60b8927a35788e7a8a8fd3d804e273e7f.1564134421.git.nobody at example.com>
+In-Reply-To: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
+References: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
 From: Soomin Lee <bubu at mikan.io>
 Date: Thu, 27 Sep 2018 18:40:39 +0200
 Subject: [PATCH 3/6] libvlc: events: Add callbacks for record
diff --git a/libvlc/patches/vlc3/0004-network-tls-Handle-errors-from-older-kernels.patch b/libvlc/patches/vlc3/0004-network-tls-Handle-errors-from-older-kernels.patch
index 97dc1b816..77aa7ce98 100644
--- a/libvlc/patches/vlc3/0004-network-tls-Handle-errors-from-older-kernels.patch
+++ b/libvlc/patches/vlc3/0004-network-tls-Handle-errors-from-older-kernels.patch
@@ -1,4 +1,7 @@
-From 21ad8184f794553b923a15c7ebc7215f5b9ea502 Mon Sep 17 00:00:00 2001
+From ba053f9821e050bc56e04d9a94851f4a7db4fa89 Mon Sep 17 00:00:00 2001
+Message-Id: <ba053f9821e050bc56e04d9a94851f4a7db4fa89.1564134421.git.nobody at example.com>
+In-Reply-To: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
+References: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo at beauzee.fr>
 Date: Fri, 29 Mar 2019 10:56:26 +0100
 Subject: [PATCH 4/6] network: tls: Handle errors from older kernels
diff --git a/libvlc/patches/vlc3/0005-access_output-file-Add-error-dialog-for-write-open.patch b/libvlc/patches/vlc3/0005-access_output-file-Add-error-dialog-for-write-open.patch
index 574024beb..583f28be3 100644
--- a/libvlc/patches/vlc3/0005-access_output-file-Add-error-dialog-for-write-open.patch
+++ b/libvlc/patches/vlc3/0005-access_output-file-Add-error-dialog-for-write-open.patch
@@ -1,4 +1,7 @@
-From fba208edd903f9e1486cb9470f863924a174b258 Mon Sep 17 00:00:00 2001
+From 8f5d6b8889b38a6b3e1bc1ee6ce8776270542335 Mon Sep 17 00:00:00 2001
+Message-Id: <8f5d6b8889b38a6b3e1bc1ee6ce8776270542335.1564134421.git.nobody at example.com>
+In-Reply-To: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
+References: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
 From: Soomin Lee <bubu at mikan.io>
 Date: Mon, 1 Oct 2018 15:37:57 +0200
 Subject: [PATCH 5/6] access_output: file: Add error dialog for write/open
diff --git a/libvlc/patches/vlc3/0006-libvlc-media_player-Add-record-method.patch b/libvlc/patches/vlc3/0006-libvlc-media_player-Add-record-method.patch
index 1bab20715..09edd8256 100644
--- a/libvlc/patches/vlc3/0006-libvlc-media_player-Add-record-method.patch
+++ b/libvlc/patches/vlc3/0006-libvlc-media_player-Add-record-method.patch
@@ -1,4 +1,7 @@
-From 081d6e7ec842c07d3edd16ecdb65ed17fcd3a856 Mon Sep 17 00:00:00 2001
+From ddc4593d365193d19834eef88e717aded08f2f54 Mon Sep 17 00:00:00 2001
+Message-Id: <ddc4593d365193d19834eef88e717aded08f2f54.1564134421.git.nobody at example.com>
+In-Reply-To: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
+References: <9aa0e90dbc4468ddb3364cd9a7eb0bb54627ef3b.1564134421.git.nobody at example.com>
 From: Soomin Lee <bubu at mikan.io>
 Date: Wed, 31 Oct 2018 10:08:55 +0100
 Subject: [PATCH 6/6] libvlc: media_player: Add record method



More information about the Android mailing list