-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix, build] Don't fail quietly on patching failure #895
Conversation
@NiLuJe Hm, apparently I was wrongish. I'll look into it a little deeper in any case, because this
|
Hide it away in a utility function in our cmake bag of tricks? Would have to take a list for projects with multiple patches and we'd just have to feed the filename? (Similar to how Gentoo ebuilds use a PATCHES bash array). |
It looks like it might be really easy to handle. The error code for previously applied is 1, and for actual errors it's greater than 1. |
Oh, wait, that wouldn't solve the "silent failure" issue, though -_-". EDIT: Ha, too slow ;). |
I think there's an easier solution: |
Not supported on macOS ;).
|
@NiLuJe Could you check the error codes? |
In which instances? (Right now, it return 2 for unsupported option ;)). |
Like I said above, |
Yep, that holds true on macOS, too. |
Alright, in that case I'll write a simple wrapper script. |
It's GNU Patch only. ;-; This reverts commit 93abe3e.
@NiLuJe Something like this work on Mac OS? #!/bin/sh
# depends on input from stdin
patch -p1 -N --dry-run --silent 2>/dev/null
exit_status=$?
if [ $exit_status -eq 0 ]; then
echo "Applying patch."
patch -p1 -N
exit $?
elif [ $exit_status -eq 1 ]; then
echo "Previously applied patch, ignoring."
exit 0
fi
exit $? diff --git a/thirdparty/cmake_modules/koreader_thirdparty_common.cmake b/thirdparty/cmake_modules/koreader_thirdparty_common.cmake
index fff09c2..1be801a 100644
--- a/thirdparty/cmake_modules/koreader_thirdparty_common.cmake
+++ b/thirdparty/cmake_modules/koreader_thirdparty_common.cmake
@@ -24,6 +24,8 @@ else()
set(KO_MAKE_RECURSIVE make)
endif()
+set(KO_PATCH "sh ${CMAKE_MODULE_PATH}/patch-wrapper.sh")
+
macro(assert_var_defined varName)
if(NOT DEFINED ${varName})
message(FATAL_ERROR "${varName} variable not defined!") |
That looks sane, but I'll double-check when I'm back on the laptop later ;) |
I'll update the PR to include that. The basic strategy seems right even if some minor details in the script itself could need tweaking for Mac OS. This way it seems more elegant to me, but the same thing can always be done without the dry-run part. PS I think sdcv is working out because it's handled completely by CMake, and the conflicts arise because for whatever reason the patching process is a bit weird for ExternalProject. The CMake source just says that it can be hard to write a good patch command, roflmao. |
CMake being helpful, as always :D. |
|
@NiLuJe Not 100 % sure, but I think the problem may be localized to |
@NiLuJe In other news, introducing a failure (on purpose here for testing) still returns an exit status of 0 for the OpenSSL configure script? O_o
|
Darn, you also get an exit code of 1 for hunks failed to apply. @NiLuJe Does Mac OS have the NB Only returning false success in some instances is still better than always returning success. |
@NiLuJe I think this updated script is pretty fool-proof. #!/bin/sh
if [ $# -eq 0 ]; then
echo "Patch file required as argument."
exit 1
fi
PATCH_FILE=$1
# Reverse patch will succeed if the patch is already applied.
# In case of failure, it means we should try to apply the patch.
if ! patch -R -p1 -N --dry-run <"${PATCH_FILE}" >/dev/null 2>&1; then
# Now patch for real.
patch -p1 -N <"${PATCH_FILE}"
exit $?
fi So if the reverse patch doesn't succeed, try to patch, and return the exit status. If the reverse patch succeeds, it means the patch was already successfully applied previously. |
koreader/koreader-base#896 * Bump HarfBuzz to 2.4.0 * Bump K2pdfopt to pickup the CJK thingy * Bump libpng to 1.6.37 * Bump FBInk to 1.15.0 [fix, build] Don't fail quietly on patching failure koreader/koreader-base#895
Yeah, the reverse test should do the job.
I'd check what happens with patches that add completely new files though,
because I have a vague memory of trying something like that somewhere
and this specific case being weird...
…On Sat, Apr 20, 2019, 14:31 Frans de Jonge ***@***.***> wrote:
Merged #895 <#895> into
master.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#895 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAA3KZQC5PYWZEYFRTVI6SDPRMEI7ANCNFSM4HHEK5EQ>
.
|
koreader/koreader-base#896 * Bump HarfBuzz to 2.4.0 * Bump K2pdfopt to pickup the CJK thingy * Bump libpng to 1.6.37 * Bump FBInk to 1.15.0 [fix, build] Don't fail quietly on patching failure koreader/koreader-base#895
nice work on the patch wrapper 👍 |
koreader/koreader-base#896 * Bump HarfBuzz to 2.4.0 * Bump K2pdfopt to pickup the CJK thingy * Bump libpng to 1.6.37 * Bump FBInk to 1.15.0 [fix, build] Don't fail quietly on patching failure koreader/koreader-base#895
It's a vestigial property from before we switched to CMake.
See #892 (comment) for discussion.