From 808723b9fbd2aa05116ef4614d5f097987dc078f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Jul 2017 00:37:56 +0200 Subject: [PATCH] Backport sysupgrade patches preventing hangs on certain sysupgrade failures --- ... 0012-procd-switch-to-latest-master.patch} | 14 ++++--- ...0016-procd-remove-procd-nand-package.patch | 2 +- ...rade-argument-passed-from-preupgrade.patch | 33 +++++++++++++++ ...oop-forever-trying-to-kill-processes.patch | 42 +++++++++++++++++++ 4 files changed, 84 insertions(+), 7 deletions(-) rename patches/lede/{0012-procd-switch-to-master-branch.patch => 0012-procd-switch-to-latest-master.patch} (57%) create mode 100644 patches/lede/0031-base-files-upgrade-correctly-handle-nand_do_upgrade-argument-passed-from-preupgrade.patch create mode 100644 patches/lede/0032-base-files-upgrade-don-t-loop-forever-trying-to-kill-processes.patch diff --git a/patches/lede/0012-procd-switch-to-master-branch.patch b/patches/lede/0012-procd-switch-to-latest-master.patch similarity index 57% rename from patches/lede/0012-procd-switch-to-master-branch.patch rename to patches/lede/0012-procd-switch-to-latest-master.patch index 0a239f9e..9c53c476 100644 --- a/patches/lede/0012-procd-switch-to-master-branch.patch +++ b/patches/lede/0012-procd-switch-to-latest-master.patch @@ -1,19 +1,21 @@ From: Matthias Schiffer Date: Sat, 8 Jul 2017 14:44:00 +0200 -Subject: procd: switch to master branch +Subject: procd: switch to latest master diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile -index 70515958cd5002841fd9698b7a7f4aec01ddfb3b..cead3b9b7a5f83879a1aee08ab0463049dd228f4 100644 +index 70515958cd5002841fd9698b7a7f4aec01ddfb3b..2a1fed4e6e2388806ee4230af2872b4bcc8f1613 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile -@@ -13,8 +13,8 @@ PKG_RELEASE:=1 +@@ -12,9 +12,9 @@ PKG_RELEASE:=1 + PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(LEDE_GIT)/project/procd.git - PKG_SOURCE_DATE:=2017-06-19 +-PKG_SOURCE_DATE:=2017-06-19 -PKG_SOURCE_VERSION:=89918c8cb78e651ee0922f13a96b7f25fc2f285a -PKG_MIRROR_HASH:=fad1a37227f85070f6a49a37ea1e98c22c066c91f16ad26898152972eb0c6a91 -+PKG_SOURCE_VERSION:=453116e08e6a9349374bbff427b75f57ce5387c9 -+PKG_MIRROR_HASH:=a0d5c1ddbd2ba63d52125fa5a815d48a3bfb1b1e0a6b85f3335af8a873ed58fc ++PKG_SOURCE_DATE:=2017-07-13 ++PKG_SOURCE_VERSION:=d749b2a3507517ff0fe39f7dac69f44ce20c56a2 ++PKG_MIRROR_HASH:=388c9f8ac28c922bb8f7889d5bfe11d9afd1bee96243bb5b77897dd1a13b3a43 CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 diff --git a/patches/lede/0016-procd-remove-procd-nand-package.patch b/patches/lede/0016-procd-remove-procd-nand-package.patch index 80426eff..2fff4f39 100644 --- a/patches/lede/0016-procd-remove-procd-nand-package.patch +++ b/patches/lede/0016-procd-remove-procd-nand-package.patch @@ -435,7 +435,7 @@ index 0000000000000000000000000000000000000000..6bd2005344c081df20e5a330a69e49e3 + nand_upgrade_stage1 +} diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile -index cead3b9b7a5f83879a1aee08ab0463049dd228f4..2a42db1fc034b554860393cfd9b17ed8423d7bc4 100644 +index 2a1fed4e6e2388806ee4230af2872b4bcc8f1613..ac0e525aed8f72b52cac892b360b3be1edcd7e1d 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile @@ -22,11 +22,9 @@ PKG_LICENSE_FILES:= diff --git a/patches/lede/0031-base-files-upgrade-correctly-handle-nand_do_upgrade-argument-passed-from-preupgrade.patch b/patches/lede/0031-base-files-upgrade-correctly-handle-nand_do_upgrade-argument-passed-from-preupgrade.patch new file mode 100644 index 00000000..35b12879 --- /dev/null +++ b/patches/lede/0031-base-files-upgrade-correctly-handle-nand_do_upgrade-argument-passed-from-preupgrade.patch @@ -0,0 +1,33 @@ +From: Matthias Schiffer +Date: Mon, 10 Jul 2017 10:35:19 +0200 +Subject: base-files: upgrade: correctly handle nand_do_upgrade argument passed from preupgrade + +Fixes: 30f61a34b4cf "base-files: always use staged sysupgrade" +Signed-off-by: Matthias Schiffer + +diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh +index fc59bf2323498d332159b00eb7ab443bfe6b147e..c8b71015c2e44210696a4e28a5b7babbd0233184 100644 +--- a/package/base-files/files/lib/upgrade/common.sh ++++ b/package/base-files/files/lib/upgrade/common.sh +@@ -211,7 +211,7 @@ default_do_upgrade() { + do_upgrade_stage2() { + v "Performing system upgrade..." + if [ -n "$do_upgrade" ]; then +- $do_upgrade "$IMAGE" ++ eval "$do_upgrade" + elif type 'platform_do_upgrade' >/dev/null 2>/dev/null; then + platform_do_upgrade "$IMAGE" + else +diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh +index 1e69c8f9657b39adf2a2c33bd9bac9303bcbc3d7..72f0fe0e10312e74ce085ad53f0adceb921fd013 100644 +--- a/package/base-files/files/lib/upgrade/nand.sh ++++ b/package/base-files/files/lib/upgrade/nand.sh +@@ -289,7 +289,7 @@ nand_do_upgrade() { + # hook; this piece of code handles scripts that haven't been + # updated. All scripts should gradually move to call nand_do_upgrade + # from platform_do_upgrade instead. +- export do_upgrade=nand_do_upgrade ++ export do_upgrade="nand_do_upgrade '$1'" + return + fi + diff --git a/patches/lede/0032-base-files-upgrade-don-t-loop-forever-trying-to-kill-processes.patch b/patches/lede/0032-base-files-upgrade-don-t-loop-forever-trying-to-kill-processes.patch new file mode 100644 index 00000000..2dfe0ca6 --- /dev/null +++ b/patches/lede/0032-base-files-upgrade-don-t-loop-forever-trying-to-kill-processes.patch @@ -0,0 +1,42 @@ +From: Matthias Schiffer +Date: Thu, 13 Jul 2017 00:19:32 +0200 +Subject: base-files: upgrade: don't loop forever trying to kill processes + +When processes don't die on SIGKILL (usually because of kernel bugs), it's +better to give up instead of looping forever. + +upgraded will trigger a reboot in this case (and if this fails, a hardware +watchdog will eventually time out and reset the system, if present). + +Signed-off-by: Matthias Schiffer + +diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 +index bdbb8926643287f48a4ae62c5d1d4b4a29130859..097ad63adfecdd70019acaa5b652d2056e774c3f 100755 +--- a/package/base-files/files/lib/upgrade/stage2 ++++ b/package/base-files/files/lib/upgrade/stage2 +@@ -87,6 +87,8 @@ switch_to_ramfs() { + } + + kill_remaining() { # [ [ ] ] ++ local loop_limit=10 ++ + local sig="${1:-TERM}" + local loop="${2:-0}" + local run=true +@@ -117,8 +119,15 @@ kill_remaining() { # [ [ ] ] + + [ $loop -eq 1 ] && run=true + done ++ ++ let loop_limit-- ++ [ $loop_limit -eq 0 ] && { ++ echo ++ echo "Failed to kill all processes." ++ exit 1 ++ } + done +- echo "" ++ echo + } + +