From patchwork Tue Sep 8 23:11:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Spooren X-Patchwork-Id: 1360227 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=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aparcar.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=bvje93ei; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4BmLXr0Rsyz9sTN for ; Wed, 9 Sep 2020 09:12:59 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=04Vuzh5WcJPd07nVXNV+7lZfRkg3Bbu6e/+eP+p+R24=; b=bvje93eivPK7sygSqePHEMov4X Ct5fCtg7/gXqSCi/UDBqQovt3n43nlN6y3iYu+dSftF9PDWtKbXFlMriX6fgCpGokA1WrUQ03p61E Ffy8EY+RY8shFjEusZkKEiQDvaqcilUul/vLPj6idTygrLVMYla8JR6nrdNcN1hfKpOe6ug/KkWd+ Ta2Ad3JD8lDzp6GCIszQNTbrAsDxP4bv2QiIRZydV6JP2Pz4a9bRJXdOViEydZPn4FxRzpz73k+Gl cLWzeiBNlp/dy8xCTmdIGNYWnlyt3EdI/v/sxrVGFxNim9w461RjTgOL5A+S2Yo6YTlP7xyQck3x9 8oMnpxqQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFmlz-00077K-0E; Tue, 08 Sep 2020 23:11:35 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFmlv-00076o-Lj for openwrt-devel@lists.openwrt.org; Tue, 08 Sep 2020 23:11:32 +0000 X-Originating-IP: 72.234.141.215 Received: from dawn.lan (udp224251uds.hawaiiantel.net [72.234.141.215]) (Authenticated sender: mail@aparcar.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPA id B6EA1E000A; Tue, 8 Sep 2020 23:11:26 +0000 (UTC) From: Paul Spooren To: openwrt-devel@lists.openwrt.org Subject: [PATCH] build: fix missing file handling for file_modes Date: Tue, 8 Sep 2020 13:11:22 -1000 Message-Id: <20200908231122.35729-1-mail@aparcar.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200908_191131_819467_02E23B02 X-CRM114-Status: GOOD ( 11.57 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [217.70.183.196 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [217.70.183.196 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Spooren Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The `ipkg-build` script uses `file_modes` (-m) to set file modes during package creation. If a single OpenWrt package results in multiple `ipk` packages, the `PKG_FILE_MODES` are applied to every single one of them. This can cause in errors files can be missing between e.g. a *full* and a *mini* variant. This commit checks if the file/folder exists, if not a warning is printed but no longer a positive exit code produced. Also clean up indention of surrounding lines. Signed-off-by: Paul Spooren --- scripts/ipkg-build | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/ipkg-build b/scripts/ipkg-build index e3a9a882cf..62b72ada88 100755 --- a/scripts/ipkg-build +++ b/scripts/ipkg-build @@ -134,19 +134,24 @@ cd $pkg_dir for file_mode in $file_modes; do case $file_mode in /*:*:*:*) - ;; + ;; *) - echo "ERROR: file modes must use absolute path and contain user:group:mode" - echo "$file_mode" - exit 1 - ;; + echo "ERROR: file modes must use absolute path and contain user:group:mode" + echo "$file_mode" + exit 1 + ;; esac - path=$(echo "$file_mode" | cut -d ':' -f 1) - user_group=$(echo "$file_mode" | cut -d ':' -f 2-3) - mode=$(echo "$file_mode" | cut -d ':' -f 4) - chown "$user_group" "$pkg_dir/$path" - chmod "$mode" "$pkg_dir/$path" + path=$(echo "$file_mode" | cut -d ':' -f 1) + if [ -e "$pkg_dir/$path" ]; then + user_group=$(echo "$file_mode" | cut -d ':' -f 2-3) + mode=$(echo "$file_mode" | cut -d ':' -f 4) + + chown "$user_group" "$pkg_dir/$path" + chmod "$mode" "$pkg_dir/$path" + else + echo "WARNING: skip mod change for non existing $path" + fi done $TAR -X $tmp_dir/tarX --format=gnu --sort=name -cpf - --mtime="$TIMESTAMP" . | $GZIP -n - > $tmp_dir/data.tar.gz