diff options
author | Patrick 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) |
commit | b5187d21a50c91fa37d3a54a8e4e9eecb5970286 (patch) | |
tree | 365254e473841f6d44e22d25384e956dd64161c1 | |
parent | ed16df9880ac1a92149242f14562da4282114fed (diff) |
ob-applypatches: Track and skip applied patches
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | locale/en_US/opkbuild.sh | 1 | ||||
-rw-r--r-- | src/ob-applypatches.sh | 13 | ||||
-rwxr-xr-x | tests/exe/ob-applypatches.sh | 2 |
5 files changed, 16 insertions, 4 deletions
@@ -19,6 +19,8 @@ Utilities: * ob-unpacksource now supports decompression of xz-compressed upstream archives. + * ob-applypatches now tracks and skips applied patches, instead of + re-running the patch command and throwing an error. * Manual pages for all utilities have been updated/written and are now built and installed for the first time since opkhelper 1.0.0. * Utilities can now be run in-place without installation by setting @@ -12,8 +12,6 @@ Functional Changes ------------------ * ob-installdocs: Handle non-directory non-regular files? - * ob-applypatches: Track and skip applied patches in `.opkbuild/patches` file: - - `ob-applypatches: Skipping applied patch "01_foo.patch"...` * Read `tmp/<binpkg>.substvars` files and use them when generating each specific binary package's `control` file. This is needed for automatic shared library dependencies. diff --git a/locale/en_US/opkbuild.sh b/locale/en_US/opkbuild.sh index 4da8922..c39c5bf 100644 --- a/locale/en_US/opkbuild.sh +++ b/locale/en_US/opkbuild.sh @@ -86,6 +86,7 @@ msg_opkbuild_cant_unpack_upstream='Can'\''t extract upstream source archive' msg_opkbuild_cant_move_native='Can'\''t move extracted upstream source directory' # src/ob-applypatches.sh +msg_opkbuild_skipping_patch='Skipping applied patch "%s"...' msg_opkbuild_applying_patch='Applying patch "%s"...' msg_opkbuild_cant_apply_patch='Can'\''t apply patch "%s"' msg_opkbuild_no_patches='No patches to be applied' 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')" diff --git a/tests/exe/ob-applypatches.sh b/tests/exe/ob-applypatches.sh index c652275..1fc1ab1 100755 --- a/tests/exe/ob-applypatches.sh +++ b/tests/exe/ob-applypatches.sh @@ -35,7 +35,7 @@ cmd_is 'patch applied' cat 'src/src/foo.sh' <<-EOF ${FOO_SH_PATCHED} EOF -command_ok_ 'ob-applypatches second run exit status' -D TODO -- ob-applypatches +command_ok_ 'ob-applypatches second run exit status' -- ob-applypatches cmd_is 'patch still applied' cat 'src/src/foo.sh' <<-EOF ${FOO_SH_PATCHED} EOF |