From patchwork Sat May 13 19:56:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 762081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wQHl86FmFz9s7g for ; Sun, 14 May 2017 06:00:36 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O0GaX2ZD"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=tFBpex3el2AVQlyuVQ/h/g7KEKWPuW44mZdpeXUILjQ=; b=O0GaX2ZD3Zdy7D+FFsIzhAbBF8 x32BGvipOgLcNnlXt34+U9SYyJA6zrBlYGD+wN9CMCAE9ixBTAYQSP4rlwV14MOT6sfXgr5oFFVCm CE13u0HFeg78jYwKCak/cCBjzKPdhAwx/418/MxVAwY5X7ehxJxUNa0HqX1FBLMU/0DbDyMY4iQUC Rx4URxdv1Eyo6kIZK8kvMXJ5O2HPWAJk3x4rdi6JENTi6fVYDiZ17lKDoOtUhwjxpVltUp+Lcp3tS dswsC06irWmTL68C1pe2ACzKD8/5FP088v9a4C3/hRbucpViQYkEF20aSiAcWNRQyPYn6JDHBPQC7 9PdUMhDw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d9dDM-0000Yz-Uo; Sat, 13 May 2017 20:00:32 +0000 Received: from chaos.universe-factory.net ([37.72.148.22]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d9dB3-0004Ow-Hc for lede-dev@lists.infradead.org; Sat, 13 May 2017 19:58:23 +0000 Received: from localhost.localdomain (unknown [IPv6:fd1b:c28a:2fd6::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by chaos.universe-factory.net (Postfix) with ESMTPSA id 143C8186C9E for ; Sat, 13 May 2017 21:56:58 +0200 (CEST) From: Matthias Schiffer To: lede-dev@lists.infradead.org Date: Sat, 13 May 2017 21:56:45 +0200 Message-Id: <25a9482c084c6d60bb7272706b7c2bae49beffb6.1494704975.git.mschiffer@universe-factory.net> X-Mailer: git-send-email 2.13.0 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170513_125810_184417_82716CD4 X-CRM114-Status: UNSURE ( 7.65 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH v2 15/19] x86: sysupgrade: move partition table change check to platform_check_image X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The staged sysupgrade will prevent us from using ask_bool in platform_do_upgrade; therefore, the check is moved to platform_check_image. Signed-off-by: Matthias Schiffer --- .../linux/x86/base-files/lib/upgrade/platform.sh | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh index d3e9f360aa..81b349a818 100644 --- a/target/linux/x86/base-files/lib/upgrade/platform.sh +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh @@ -1,13 +1,37 @@ platform_check_image() { + local diskdev partdev diff [ "$#" -gt 1 ] && return 1 case "$(get_magic_word "$1")" in - eb48|eb63) return 0;; + eb48|eb63) ;; *) echo "Invalid image type" return 1 ;; esac + + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null + + get_partitions /tmp/image.bs image + + #compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + + rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image + + if [ -n "$diff" ]; then + echo "Partition layout has changed. Full image will be written." + ask_bool 0 "Abort" && exit 1 + return 0 + fi } platform_copy_config() { @@ -36,9 +60,6 @@ platform_do_upgrade() { #compare tables diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" if [ -n "$diff" ]; then - echo "Partition layout is changed. Full image will be written." - ask_bool 0 "Abort" && exit - get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync return 0 fi