From patchwork Wed Apr 4 23:28:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 895211 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=arrakis.dune.hu (client-ip=78.24.191.176; helo=arrakis.dune.hu; envelope-from=openwrt-devel-bounces@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tSx0Ntq9"; dkim-atps=neutral Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40GhxW6v6qz9ry1 for ; Thu, 5 Apr 2018 09:29:19 +1000 (AEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 8F459B91446; Thu, 5 Apr 2018 01:28:46 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Thu, 5 Apr 2018 01:28:46 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 1F891B91460 for ; Thu, 5 Apr 2018 01:28:41 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -7 Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 5 Apr 2018 01:28:41 +0200 (CEST) Received: by mail-qk0-f195.google.com with SMTP id o205so24461541qke.3 for ; Wed, 04 Apr 2018 16:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rFusgNfTIEUMj2zlZB8qk0i1/WBV8GPdMFtd71dtU9Q=; b=tSx0Ntq9HzyPMxwnj0RrTUni3I/rcBGAF5H3jdM7rEHdK+zpsAImTM5HGxsMsNl7Ab sc84Tt/DjBmdbuS0t7PwdOxiR16r+vn+oVaj4wHpjtoNTuPD+Blpa4352NIdqJlZprFg X54v2B5jEqKWiabpfxLwQWBDlXUgAGzf4MsnXfP8R+FGsQc6C2nG2C8WX/EL7+tLOf/N eo8g8ss6WUwZfsz9CBB45B72YaTnmc7giuqo6nAg7+Wmd+ovLVgZ3yA20QgcDlJDrt48 oEGKhj7tH2APQ2ImeQqwkMIG6KgWMDzJ6Zk0NHClzpmuZwHbh7iYbhmh+reyDdANm40d QW3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rFusgNfTIEUMj2zlZB8qk0i1/WBV8GPdMFtd71dtU9Q=; b=YIDNJNFQFPtgAS5Ifq5VJ3Q7gQVA8PtPMJgH65HS7KvrLlckEoavytNv3FICy866Wx LSncSWLcnnUjR5kg/73bP4Tq+z101GBqBRe2D6y1rn/yAT4mqzNoos3jH6AJWw6JjbyQ AtVNyQSIVO/jZXmxJfhdHW/3f1tRSfx2JQd2HBUdx194UWxd3srPN3oA0hhkv/TEe204 FCoBW1yYa83wUWBq0dTBLKyRse9O3FNtCds9+5czK8Jwe5kTNPvNYUrLmXebi+XwTf9e ln1GKuyWdV9fymZfuFBVhRj01c5MyvNASndZWP9/6aCFa+znmCqbr6C4bX6MLKupfvMN Ut+A== X-Gm-Message-State: ALQs6tDe4oo5/eoaPMaP7B90gl7CUkiIOyR5ayS8PurzC2bZ9tIK/rvI aQzMwCI2WF57caOS2TEUZU2i5g== X-Google-Smtp-Source: AIpwx4+J+YebuBEzR/uschas8nHMEV/zwGuQ98n39m1tgkN3u8Nmpe3kzKTMLzpQILeOtdox/OBTxQ== X-Received: by 10.55.217.77 with SMTP id u74mr26971054qki.148.1522884519791; Wed, 04 Apr 2018 16:28:39 -0700 (PDT) Received: from tresc043793.redetresc.tre-sc.gov.br ([201.55.123.206]) by smtp.gmail.com with ESMTPSA id z7sm5149132qke.19.2018.04.04.16.28.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Apr 2018 16:28:39 -0700 (PDT) From: Luiz Angelo Daros de Luca To: openwrt-devel@lists.openwrt.org, lede-dev@lists.infradead.org Date: Wed, 4 Apr 2018 20:28:24 -0300 Message-Id: <20180404232826.10815-3-luizluca@gmail.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180404232826.10815-1-luizluca@gmail.com> References: <20171117004110.23143-1-luizluca@gmail.com> <20180404232826.10815-1-luizluca@gmail.com> Subject: [OpenWrt-Devel] [PATCH v2 2/4] base-files: add sysupgrade -u to skip unchanged files X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" With '-u', for a file /aaa/bbb/ccc enlisted for backup, it will only get into backup if /rom/aaa/bbb/ccc does not exist or /aaa/bbb/ccc is different from /rom/aaa/bbb/ccc. It also works with '-c', but only effective for files touched but not modified. Signed-off-by: Luiz Angelo Daros de Luca --- package/base-files/files/sbin/sysupgrade | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index 46e46c3342..4d221ef5d6 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -10,6 +10,7 @@ export VERBOSE=1 export SAVE_CONFIG=1 export SAVE_OVERLAY=0 export SAVE_PARTITIONS=1 +export SKIP_UNCHANGED=0 export CONF_IMAGE= export CONF_BACKUP_LIST=0 export CONF_BACKUP= @@ -28,6 +29,7 @@ while [ -n "$1" ]; do -n) export SAVE_CONFIG=0;; -c) export SAVE_OVERLAY=1;; -p) export SAVE_PARTITIONS=0;; + -u) export SKIP_UNCHANGED=1;; -b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;; -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;; -l|--list-backup) export CONF_BACKUP_LIST=1;; @@ -52,12 +54,13 @@ IMAGE="$1" [ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 -o $HELP -gt 0 ] && { cat <...] - $0 [-q] [-i] [-c] + $0 [-q] [-i] [-c] [-u] upgrade-option: -f restore configuration from .tar.gz (file or url) -i interactive mode -c attempt to preserve all changed files in /etc/ + -u skip from backup files that are equals to those in /rom -n do not save configuration over reflash -p do not attempt to restore the partition table after flash. -T | --test @@ -119,20 +122,19 @@ add_conffiles() { local file="$1" ( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \ /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \ - -type f -o -type l 2>/dev/null; + \( -type f -o -type l \) $find_filter 2>/dev/null; list_changed_conffiles ) | sort -u > "$file" return 0 } add_overlayfiles() { local file="$1" - find /overlay/upper/etc/ -type f -o -type l | sed \ - -e 's,^/overlay\/upper/,/,' \ - -e '\,/META_[a-zA-Z0-9]*$,d' \ - -e '\,/functions.sh$,d' \ + ( cd /overlay/upper/; find ./etc \( -type f -o -type l \) $find_filter | sed \ + -e 's,^\.,,' \ + -e '\,^/etc/board.json$,d' \ -e '\,/[^/]*-opkg$,d' \ - -e '\,/etc/urandom.seed$,d' \ - > "$file" + -e '\,^/etc/urandom.seed$,d' \ + )> "$file" return 0 } @@ -150,6 +152,15 @@ else sysupgrade_init_conffiles="add_conffiles" fi +find_filter="" +if [ $SKIP_UNCHANGED = 1 ]; then + [ ! -d /rom/ ] && { + echo "'/rom/' is required by '-u'" + exit 1 + } + find_filter='( ( -exec test -e /rom/{} ; -exec cmp -s /{} /rom/{} ; ) -o -print )' +fi + include /lib/upgrade do_save_conffiles() {