aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorAndrew Robbins <contact@andrewrobbins.info>2019-07-16 22:43:31 -0500
committerAndrew Robbins <contact@andrewrobbins.info>2019-07-16 22:45:17 -0500
commit7f8a0e4bc1e94db325cd0348c92c6005b6fd84cf (patch)
treeeebd9ba0cd4b0ad5f2ac43ba2074520fb82e7aa5 /libs
parent089265a306c58b52a0f90dde99b7cc6af3f25e11 (diff)
downloadlibrebootfr-7f8a0e4bc1e94db325cd0348c92c6005b6fd84cf.tar.gz
librebootfr-7f8a0e4bc1e94db325cd0348c92c6005b6fd84cf.zip
Add functions to safely apply patches to non-git sources
project_sources_patch() is the equivalent to git_patch() when working with non-git sources. It should not be used with sources under a version control system.
Diffstat (limited to 'libs')
-rwxr-xr-xlibs/common7
-rwxr-xr-xlibs/project13
2 files changed, 19 insertions, 1 deletions
diff --git a/libs/common b/libs/common
index 06b411e1..b1091e4f 100755
--- a/libs/common
+++ b/libs/common
@@ -117,6 +117,13 @@ diff_patch() {
patch -fd "$sources_path" -r - < "$patch_path"
}
+diff_patch_check() {
+ local sources_path=$1
+ local patch_path=$2
+
+ patch -sfd "$sources_path" --dry-run < "$patch_path" > /dev/null 2>&1
+}
+
path_wildcard_expand() {
local path=$@
diff --git a/libs/project b/libs/project
index 34b139a5..b130af17 100755
--- a/libs/project
+++ b/libs/project
@@ -584,7 +584,7 @@ project_sources_patch_recursive() {
fi
for patch in "$patches_path"/[!.]*.@(patch|diff); do
- diff_patch "$sources_path" "$patch" || return 1
+ project_sources_patch "$sources_path" "$patch" || return 1
done
if [[ -n $path && $path != . ]]; then
@@ -608,6 +608,17 @@ project_blobs() {
fi
}
+project_sources_patch() {
+ local sources_path=$1
+ local patch_path=$2
+
+ if diff_patch_check "$sources_path" "$patch_path"; then
+ diff_patch "$sources_path" "$patch_path"
+ else
+ return 1
+ fi
+}
+
project_blobs_path() {
local project=$1
shift