From b5187d21a50c91fa37d3a54a8e4e9eecb5970286 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 17 Mar 2019 18:24:16 -0400 Subject: ob-applypatches: Track and skip applied patches --- (limited to 'src/ob-applypatches.sh') 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')" -- cgit v0.9.1