Allow repeated patch applys

The patches were not idempotent, as in after the first attempt to
build locally using the ci scripts, subsequent builds would fail
in the apply patch step.

This patch checks for the presence of the patch by attempting to apply the inverse of the patch. If that works, then the patch was already applied.

Change-Id: I9ba4267f6a0a567ae13dcaf2c98a7dff204347ce
diff --git a/script/build_package.sh b/script/build_package.sh
index 0738b4f..3377065 100755
--- a/script/build_package.sh
+++ b/script/build_package.sh
@@ -1057,6 +1057,11 @@
 		echo "Applying ${1:?}..."
 	fi
 
+	if git apply --reverse --check < "$ci_root/patch/$1"; then
+		echo "Skipping already applied ${1:?}"
+		return 0
+	fi
+
 	if git apply < "$ci_root/patch/$1"; then
 		echo "$1" >> "${patch_record:?}"
 	else