From patchwork Wed Apr 27 23:37:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 615918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (caladan.dune.hu [78.24.191.180]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qwGc32pNpz9t3k for ; Thu, 28 Apr 2016 09:38:10 +1000 (AEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 4F2A8B91BD2; Thu, 28 Apr 2016 01:38:04 +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 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, 28 Apr 2016 01:38:04 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 49E75B91BCF for ; Thu, 28 Apr 2016 01:38:02 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -6.1 Received: from fudo.makrotopia.org (fudo.makrotopia.org [5.135.190.93]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 28 Apr 2016 01:38:00 +0200 (CEST) Received: from local by fudo.makrotopia.org with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.85) (envelope-from ) id 1avZ1s-00086L-EJ for openwrt-devel@lists.openwrt.org; Thu, 28 Apr 2016 01:38:00 +0200 Date: Thu, 28 Apr 2016 01:37:59 +0200 From: Daniel Golle To: openwrt-devel@lists.openwrt.org Message-ID: <20160427233755.GA21020@makrotopia.org> References: <20160427231500.GA20766@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160427231500.GA20766@makrotopia.org> User-Agent: Mutt/1.6.0 (2016-04-01) Subject: [OpenWrt-Devel] [PATCH v2] base-files: evalute uci-defaults on run-time installations 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: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Packages may install scripts into /etc/uci-defaults to be executed once after installation, usually at the first boot of the target. This works fine if the package was installed to the rootfs during build or using the ImageBuilder. If the package is installed using opkg during run-time uci-defaults were applied only after a reboot of the device. Avoid the need to reboot by evaluting the package's uci-defaults in default-postinst. Signed-off-by: Daniel Golle --- v2: remove superflus expansions of always-empty variable package/base-files/files/lib/functions.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index dde1ac4..7db703f 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -214,6 +214,11 @@ default_postinst() { ret=$? fi + [ -n "$root" ] || for i in $(grep -s "^/etc/uci-defaults/" "$root/usr/lib/opkg/info/${pkgname}.list"); do + ( . "$i" ) + rm "$i" + done + [ -n "$root" ] || rm -f /tmp/luci-indexcache 2>/dev/null if [ "$PKG_UPGRADE" != "1" ]; then