summaryrefslogtreecommitdiffstats
path: root/src/ob-applypatches.sh
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-03-17 18:24:16 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-03-17 18:24:16 (EDT)
commitb5187d21a50c91fa37d3a54a8e4e9eecb5970286 (patch)
tree365254e473841f6d44e22d25384e956dd64161c1 /src/ob-applypatches.sh
parented16df9880ac1a92149242f14562da4282114fed (diff)
ob-applypatches: Track and skip applied patches
Diffstat (limited to 'src/ob-applypatches.sh')
-rw-r--r--src/ob-applypatches.sh13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ob-applypatches.sh b/src/ob-applypatches.sh
index 999b0cd..28d667c 100644
--- a/src/ob-applypatches.sh
+++ b/src/ob-applypatches.sh
@@ -1,6 +1,6 @@
# Apply patches to source code
#
-# Copyright (C) 2012 Patrick McDermott
+# Copyright (C) 2012, 2019 Patrick McDermott
#
# This file is part of opkbuild.
#
@@ -28,6 +28,10 @@ apply_patches()
applied='false'
if [ -d '../patches' ] && [ -d 'src' ]; then
+ mkdir -p '.opkbuild'
+ patches="${OB_LF}$(cat '.opkbuild/patches' 2>/dev/null || \
+ :)${OB_LF}"
+ exec 3>>'.opkbuild/patches'
cd 'src/'
# Iterate over patches ordered alphabetically by name.
# POSIX.1-2008 says that the results of a pathname expansion
@@ -40,16 +44,23 @@ apply_patches()
[ -f "${patch}" ] || continue
LANG="${orig_lang}"
patch="${patch#../../patches/}"
+ case "${patches}" in *"${OB_LF}${patch}${OB_LF}"*)
+ ob_info "$(ob_get_msg 'skipping_patch')" \
+ "${patch}"
+ continue
+ esac
ob_info "$(ob_get_msg 'applying_patch')" "${patch}"
if ! patch -N -p 1 -u -i "../../patches/${patch}"; then
ob_error "$(ob_get_msg 'cant_apply_patch')" \
"${patch}"
return 1
fi
+ printf '%s\n' "${patch}" >&3
applied='true'
done
LANG="${orig_lang}"
cd '../'
+ exec 3>&-
fi
${applied} || ob_info "$(ob_get_msg 'no_patches')"