From patchwork Fri Aug 14 00:17:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Spooren X-Patchwork-Id: 1344581 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=CA6xJrEq; 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 4BSPFc19D2z9sTQ for ; Fri, 14 Aug 2020 10:19:32 +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:References:In-Reply-To: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:List-Owner; bh=imVJn/3tx8XJ2n3vvSO3582LogQHxDB3XgRKOxS3/4A=; b=CA6xJrEqAeUf4HIDxhqGrxp6Q Mt8AwmzrPCB4RLMyOKAv5Fg9LAE1EJleihr1da9rs5q2EVfHOZH/f7Nw9uceza9CGwbbdSMWM5f0E 6ELmWbEmczuiNoyphR9+iRAsIKYMb7CqNHDBGtK8Gmx1iQhI01SWdhb52uEfKfQD69NHQppWWjiiw YpUS+uAl8SVZxGRhpChSOFRulbktFyV6YdrJ54nRYD3PBXWJhHpF1T2N2yOYVzorhuLbxV7KMyW5P JXGFo+Xo9SVLsXWJhr/YHfArzUOrIMwGGl2wyfAIphGki1RJkpIEwW2WIcQNpxHDOvt4Y1xZexH2D 18t7RD8NA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6NQ0-0006nk-Pr; Fri, 14 Aug 2020 00:18:00 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6NPx-0006n3-MP for openwrt-devel@lists.openwrt.org; Fri, 14 Aug 2020 00:17:58 +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 relay1-d.mail.gandi.net (Postfix) with ESMTPA id DC9EB240004; Fri, 14 Aug 2020 00:17:54 +0000 (UTC) From: Paul Spooren To: openwrt-devel@lists.openwrt.org Subject: [PATCH 2/4] build: get_source_date_epoch allow external repos Date: Thu, 13 Aug 2020 14:17:23 -1000 Message-Id: <20200814001724.2539178-3-mail@aparcar.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200814001724.2539178-1-mail@aparcar.org> References: <20200814001724.2539178-1-mail@aparcar.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200813_201757_853929_5373C72D X-CRM114-Status: GOOD ( 13.34 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [217.70.183.193 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [217.70.183.193 listed in list.dnswl.org] 0.0 T_PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: version.date (date)] 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: jo@mein.io, Paul Spooren Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The SOURCE_DATE_EPOCH variable is used to make builds reproducible even if rebuild at different times. Instead of using the current timestamp, the time of the last source change is used. Created packages are `touch`ed with a specific timestamp so resulting packages have the same checksums. The `get_source_date_epoch.sh` script tries multiple ways (file, git, hg) to determine the correct timestamp. Until now the script would only consider the $TOPDIR instead of package specific changes. Resulting in packages with same versions but different timestamps, as $TOPDIR (openwrt.git) received changes not affecting package versions. This results in warning/erros in `opkg` as the package versions stay the same but checksums changed. This commit adds an optional argument to get the `SOURCE_DATE_EPOCH` of a specific path (e.g. package SOURCE) rather than the $TOPDIR. As a consequence this allows granular but still reproducible timestamps. As packages might be distributed over multiple repositories the check for `.git/` becomes unfeasible. Instead tell `git` and `hg` to change their working directories and automatically traverse the repo folder. Signed-off-by: Paul Spooren --- scripts/get_source_date_epoch.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/get_source_date_epoch.sh b/scripts/get_source_date_epoch.sh index 3e277d3a94..1d06dbd413 100755 --- a/scripts/get_source_date_epoch.sh +++ b/scripts/get_source_date_epoch.sh @@ -3,21 +3,21 @@ export LANG=C export LC_ALL=C [ -n "$TOPDIR" ] && cd "$TOPDIR" || exit 1 +SOURCE="${1:-.}" + try_version() { - [ -f version.date ] || return 1 - SOURCE_DATE_EPOCH="$(cat version.date)" + [ -f "$SOURCE/version.date" ] || return 1 + SOURCE_DATE_EPOCH=$(cat "$SOURCE/version.date") [ -n "$SOURCE_DATE_EPOCH" ] } try_git() { - [ -e .git ] || return 1 - SOURCE_DATE_EPOCH="$(git log -1 --format=format:%ct)" + SOURCE_DATE_EPOCH=$(git -C "$SOURCE" log -1 --format=format:%ct "$SOURCE" 2>/dev/null) [ -n "$SOURCE_DATE_EPOCH" ] } try_hg() { - [ -d .hg ] || return 1 - SOURCE_DATE_EPOCH="$(hg log --template '{date}' -l 1 | cut -d. -f1)" + SOURCE_DATE_EPOCH=$(hg --cwd "$SOURCE" log --template '{date}' -l 1 "$SOURCE" 2>/dev/null | cut -d. -f1) [ -n "$SOURCE_DATE_EPOCH" ] }