From patchwork Tue Jan 14 17:45:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Maciej Nowak X-Patchwork-Id: 1222959 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=o2.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=pWixXGTa; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=o2.pl header.i=@o2.pl header.a=rsa-sha256 header.s=1024a header.b=m7yddHMN; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47xyYg6NgFz9s29 for ; Wed, 15 Jan 2020 04:46:15 +1100 (AEDT) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version: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=WB9cR3nK8ews2jJ7hkaVjBQLuXkMW7lTvW5cusrw93I=; b=pWixXGTaf2NfUgXVPl0DTkfraP ORxoAJaIm7vEpQeTHbfpkOXAhFEKTXEllBFn1TTJLwf1lj+eQcgpHSE0Abd6TwGkwaNPBM9vZ8DWS 3mZj7b0xrulgWUwKLDP3cCj3fxGndh6rV2kzFbAvlgdy/57/7Za9B2hHAJBD9FXjRSvqI34jiHCSw PozUxNzZO7jl8XYh7EnorjH8GHidZhLceVCtP2Xh03yj5DsHeuQH4A5iLXhpVjiab3YdkUgZBz1Qo BXcYe7jmk0YUrhHEccCBzDUnIwTelSJUx3sz43RAcK05LGnC3SFfd00UyE3o2DldVCmJM3U0mWJRW wPOY0nMw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irQGc-0006ED-DF; Tue, 14 Jan 2020 17:46:14 +0000 Received: from mx-out.tlen.pl ([193.222.135.140]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irQGN-00062K-1Q for openwrt-devel@lists.openwrt.org; Tue, 14 Jan 2020 17:46:04 +0000 Received: (wp-smtpd smtp.tlen.pl 9959 invoked from network); 14 Jan 2020 18:45:54 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1579023954; bh=SYSW8lMBQEMkIK7NSIwuUpi5W6tkKvh+K6WqjJmeo+Y=; h=From:To:Subject; b=m7yddHMNqMKJIkpRytayxFB5j1ZkFg7BsB6qnRyKkz521vdG+ab8c0XyR0r8T5YCL Cwog+FLIJMEvtknClbipEC9ISRbAZ9YgmUdaBygvr7uD/YKXvwLDJg22BJyviKSqEO JkJMFVfsM6MLuK9igd8Xbk1rhVQ4fZfOuzRNhsW8= Received: from 131.ip-164-132-48.eu (HELO localhost.localdomain) (tomek_n@o2.pl@[164.132.48.131]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 14 Jan 2020 18:45:54 +0100 From: Tomasz Maciej Nowak To: openwrt-devel@lists.openwrt.org Date: Tue, 14 Jan 2020 18:45:43 +0100 Message-Id: <20200114174545.1514-2-tomek_n@o2.pl> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114174545.1514-1-tomek_n@o2.pl> References: <20200114174545.1514-1-tomek_n@o2.pl> MIME-Version: 1.0 X-WP-MailID: 770f379f3e3c088fcfde68397f96d833 X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 0000000 [wZME] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_094559_616006_9830CFA9 X-CRM114-Status: UNSURE ( 5.88 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tomek_n[at]o2.pl) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [OpenWrt-Devel] [PATCH v3 1/3] x86: image: cleanup before creating image X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org There can be some leftovers from other image recipes, if the same directory names are used and multiply image types are selected. Therefore remove directories used in the recipe, before contents for the image are prepared. Signed-off-by: Tomasz Maciej Nowak --- target/linux/x86/image/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile index eb0db417a3..2838b3139c 100644 --- a/target/linux/x86/image/Makefile +++ b/target/linux/x86/image/Makefile @@ -60,6 +60,7 @@ ifneq ($(CONFIG_GRUB_IMAGES),) define Image/Build/grub2 # left here because the image builder doesnt need these + rm -fR $(KDIR)/root.grub $(KDIR)/grub2 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz grub-mkimage \ @@ -93,6 +94,7 @@ ifneq ($(CONFIG_GRUB_IMAGES),) endif define Image/Build/iso + rm -fR $(KDIR)/root.grub $(KDIR)/grub2 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz grub-mkimage \ From patchwork Tue Jan 14 17:45:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Maciej Nowak X-Patchwork-Id: 1222960 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=o2.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=Y9guj/6q; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=o2.pl header.i=@o2.pl header.a=rsa-sha256 header.s=1024a header.b=hIHbgYO3; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47xyYy0Jljz9s29 for ; Wed, 15 Jan 2020 04:46:30 +1100 (AEDT) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version: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=k9RVh/11RqhXKTzgITj/ZJN74u929itj0ldO4XCpVlk=; b=Y9guj/6qS+iYJDWg1Ua7VP07VW SVQ5RMCpJEAFxaYXtitCXdVXULXV0mMsnoIrHOs6IE6D3+jdVXzR/TJdpASopLESocnuuk+K132AL Qkrw80NviimVGpRs3Vli5tgLX6B132RjEkAwYfyguFxMzZ2gFJ3Ey3wO2Hg+EbpQsOBFlcu90X5iv 27NZTm4+sg3sJsDlL1jlfk3TmmcrXMMaLHQrq1AFlfpZrmpIi2h6rXGof6d5yde1rXVF/G+1lEQmR hKNUKtyAKgtQpO1YXm9YNzWcwqSAo/IIXT6aFMoGXbw4NE9WvvHQPZSggK/GadslswjCEIE13Pni1 DE9yloew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irQGq-0006TH-Ag; Tue, 14 Jan 2020 17:46:28 +0000 Received: from mx-out.tlen.pl ([193.222.135.140]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irQGP-00062k-0w for openwrt-devel@lists.openwrt.org; Tue, 14 Jan 2020 17:46:06 +0000 Received: (wp-smtpd smtp.tlen.pl 15951 invoked from network); 14 Jan 2020 18:45:57 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1579023957; bh=8y/nzgJTmef4MOXcBVxFf7KLJOHdmFMpZzokkPaIh5o=; h=From:To:Subject; b=hIHbgYO3PM8eVDVz9octXTKGt81GpQiQJVo1b6rg79TDQ1DOzvme+gAZeba7eYF8l 9WeO5Z//ghiYzlaZKkZ5PorodMN65WeJCj+OMhviypwyqzO++N54jWnNTD0O6UhnPy imIB2TlNUH8zVPIp+YTPubqjo0f4pbIDQAKny0PM= Received: from 131.ip-164-132-48.eu (HELO localhost.localdomain) (tomek_n@o2.pl@[164.132.48.131]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 14 Jan 2020 18:45:57 +0100 From: Tomasz Maciej Nowak To: openwrt-devel@lists.openwrt.org Date: Tue, 14 Jan 2020 18:45:44 +0100 Message-Id: <20200114174545.1514-3-tomek_n@o2.pl> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114174545.1514-1-tomek_n@o2.pl> References: <20200114174545.1514-1-tomek_n@o2.pl> MIME-Version: 1.0 X-WP-MailID: 2b3f0338c2febc5ed9ee3cc69536cbf5 X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 0000000 [0TN0] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_094601_222008_3027272A X-CRM114-Status: UNSURE ( 9.48 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tomek_n[at]o2.pl) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [OpenWrt-Devel] [PATCH v3 2/3] x86: add bootloader upgrade on sysupgrade X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Currently bootloader always stays on the same version as when first written to boot medium (not true if partition layout changed, which will trigger sysupgrade process to write full disk image). That creates inconveniences as it always stays with same features or/and bugs. Users wishing to add support to additional modules or new version, would need to write the whole image, potentially destroying previous system configuration. To fix these, this commit adds additional routine to sysupgrade which upgrades unconditionally the bootloader to the latest state provided by OpenWrt. Signed-off-by: Tomasz Maciej Nowak --- package/boot/grub2/Makefile | 5 ++++ .../x86/base-files/lib/upgrade/platform.sh | 24 +++++++++++++++++++ target/linux/x86/image/Makefile | 7 +++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/package/boot/grub2/Makefile b/package/boot/grub2/Makefile index 1f92ba9250..b26ef64ca4 100644 --- a/package/boot/grub2/Makefile +++ b/package/boot/grub2/Makefile @@ -82,6 +82,11 @@ define Host/Configure $(Host/Configure/Default) endef +define Package/grub2/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/grub-bios-setup $(1)/usr/sbin/ +endef + define Package/grub2-editenv/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/grub-editenv $(1)/usr/sbin/ diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh index 3b6c25877f..8be96dfcd4 100644 --- a/target/linux/x86/base-files/lib/upgrade/platform.sh +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh @@ -1,3 +1,5 @@ +RAMFS_COPY_BIN='grub-bios-setup' + platform_check_image() { local diskdev partdev diff [ "$#" -gt 1 ] && return 1 @@ -44,6 +46,26 @@ platform_copy_config() { fi } +platform_do_bootloader_upgrade() { + local bootpart + local diskdev="$1" + + if export_partdevice bootpart 1; then + mkdir -p /tmp/boot + mount -o rw,noatime "/dev/$bootpart" /tmp/boot + echo "(hd0) /dev/$diskdev" > /tmp/device.map + + echo "Upgrading bootloader on /dev/$diskdev..." + grub-bios-setup \ + -m "/tmp/device.map" \ + -d "/tmp/boot/boot/grub" \ + -r "hd0,msdos1" \ + "/dev/$diskdev" + + umount /tmp/boot + fi +} + platform_do_upgrade() { local diskdev partdev diff @@ -92,4 +114,6 @@ platform_do_upgrade() { #copy partition uuid echo "Writing new UUID to /dev/$diskdev..." get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync + + platform_do_bootloader_upgrade "$diskdev" } diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile index 2838b3139c..373f2396b7 100644 --- a/target/linux/x86/image/Makefile +++ b/target/linux/x86/image/Makefile @@ -66,11 +66,11 @@ ifneq ($(CONFIG_GRUB_IMAGES),) grub-mkimage \ -p /boot/grub \ -d $(STAGING_DIR_HOST)/lib/grub/i386-pc \ - -o $(KDIR)/grub2/core.img \ + -o $(KDIR)/root.grub/boot/grub/core.img \ -O i386-pc \ -c ./grub-early.cfg \ $(GRUB2_MODULES) - $(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/grub2/ + $(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/root.grub/boot/grub/ echo '(hd0) $(BIN_DIR)/$(IMG_COMBINED)-$(1).img' > $(KDIR)/grub2/device.map sed \ -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \ @@ -80,6 +80,7 @@ ifneq ($(CONFIG_GRUB_IMAGES),) -e 's#@TITLE@#$(GRUB_TITLE)#g' \ ./grub.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg -$(CP) $(STAGING_DIR_ROOT)/boot/. $(KDIR)/root.grub/boot/ + grub-bios-setup -V | cut -d' ' -f3 > $(KDIR)/root.grub/boot/grub/version PADDING="1" SIGNATURE="$(IMG_PART_SIGNATURE)" PATH="$(TARGET_PATH)" $(SCRIPT_DIR)/gen_image_generic.sh \ $(BIN_DIR)/$(IMG_COMBINED)-$(1).img \ $(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.grub \ @@ -87,7 +88,7 @@ ifneq ($(CONFIG_GRUB_IMAGES),) 256 grub-bios-setup \ --device-map="$(KDIR)/grub2/device.map" \ - -d "$(KDIR)/grub2" \ + -d "$(KDIR)/root.grub/boot/grub" \ -r "hd0,msdos1" \ "$(BIN_DIR)/$(IMG_COMBINED)-$(1).img" endef From patchwork Tue Jan 14 17:45:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Maciej Nowak X-Patchwork-Id: 1222961 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=o2.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=qPptbvI/; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=o2.pl header.i=@o2.pl header.a=rsa-sha256 header.s=1024a header.b=WmhuFhuN; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47xyZG6q6yz9s29 for ; Wed, 15 Jan 2020 04:46:46 +1100 (AEDT) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version: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=dHuqtY7nUpurcnZyLzayZaJt72Ch7O3Xl6okDrAecC4=; b=qPptbvI/t1p7xK1arfjOTC0LiM R2z57TI37/3vK9/eActyBnUcOlrHLuLpVlevJ+k6//9X4rvY5R/OMh+GJ3TPI2mU948sFpBbYRV5L wYzWSiDBtkMoMAH4ggyNqxUT3/3rFjSAk26UetkwgT2oiyX6MGJXRQ9MtU0BvjJQmILm2h14yBzwS yiv/ObiRRvOYXdf11qmmdC7ukd22gz4/O02mqD79zXW8YVVfUqhQUpFM8lFhCDKJYD3s7UIL1mGR7 ITn+zlUmrEl+g+MHWIGDeYOwONFhaZOBt0lzhgHT0gQ1rhdd5ebDlaCkbKl+WvAcNL4aoqRLJt2ij CeSWgCyw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irQH7-0006kJ-Gz; Tue, 14 Jan 2020 17:46:45 +0000 Received: from mx-out.tlen.pl ([193.222.135.140]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irQGR-00063C-O6 for openwrt-devel@lists.openwrt.org; Tue, 14 Jan 2020 17:46:08 +0000 Received: (wp-smtpd smtp.tlen.pl 20265 invoked from network); 14 Jan 2020 18:45:59 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1579023959; bh=N7j7921f4RqRncoyF1YddpRylPY3NAg3MU2zMgxk9HY=; h=From:To:Subject; b=WmhuFhuNnKHMV7Z2k8CLPpZTBeA4zJQd/MhC4e/e8KJ5NgSF7X8sNfy2SxqGLrA80 oWGvMZBaqHUxlr5FJx2hcomcP0OImvyv+fiXuj3BeMtOiqpYvQdMfVVm5afWOWHRSR CRByNdbDJ0oXsp+UMvTIdqBMPS55LzWB7+B39XBU= Received: from 131.ip-164-132-48.eu (HELO localhost.localdomain) (tomek_n@o2.pl@[164.132.48.131]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 14 Jan 2020 18:45:59 +0100 From: Tomasz Maciej Nowak To: openwrt-devel@lists.openwrt.org Date: Tue, 14 Jan 2020 18:45:45 +0100 Message-Id: <20200114174545.1514-4-tomek_n@o2.pl> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114174545.1514-1-tomek_n@o2.pl> References: <20200114174545.1514-1-tomek_n@o2.pl> MIME-Version: 1.0 X-WP-MailID: 7ea7a2543854f08d9424521901f9ec79 X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 0000000 [gYPE] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_094603_940677_ABE1846E X-CRM114-Status: GOOD ( 10.08 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tomek_n[at]o2.pl) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [OpenWrt-Devel] [PATCH v3 3/3] x86: add preinit hook for bootloader upgrade X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This commit fills the void for current OpenWrt installations which will be still on old bootloader version even after "x86: add bootloader upgrade on sysupgrade", since it performs bootloader upgrade only on sysupgrade. To keep all OpenWrt deploynents on the same GRUB version, add preinit hook, which will perform upgrade of the bootloader on first boot after sysupgrade. It's temporary solution and should be deleted, when the first release including this hook will no longer be supported by OpenWrt team. We can assume that all installations should be on current bootolader version and from there sysupgrade routine will be sufficient. Signed-off-by: Tomasz Maciej Nowak --- .../lib/preinit/81_upgrade_bootloader | 19 +++++++++++++++++++ .../x86/base-files/lib/upgrade/platform.sh | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader diff --git a/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader b/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader new file mode 100644 index 0000000000..3a4e756b1e --- /dev/null +++ b/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader @@ -0,0 +1,19 @@ +#!/bin/sh + +upgrade_bootloader() { + local diskdev + + . /lib/upgrade/common.sh + + if [ ! -f /boot/grub/upgraded ] && export_bootdevice && export_partdevice diskdev 0; then + echo "(hd0) /dev/$diskdev" > /tmp/device.map + /usr/sbin/grub-bios-setup \ + -m "/tmp/device.map" \ + -d "/boot/grub" \ + -r "hd0,msdos1" \ + "/dev/$diskdev" \ + && touch /boot/grub/upgraded + fi +} + +[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main upgrade_bootloader diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh index 8be96dfcd4..53c751861c 100644 --- a/target/linux/x86/base-files/lib/upgrade/platform.sh +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh @@ -60,7 +60,8 @@ platform_do_bootloader_upgrade() { -m "/tmp/device.map" \ -d "/tmp/boot/boot/grub" \ -r "hd0,msdos1" \ - "/dev/$diskdev" + "/dev/$diskdev" \ + && touch /boot/grub/upgraded umount /tmp/boot fi