From patchwork Fri Aug 14 20:21:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Spooren X-Patchwork-Id: 1345195 X-Patchwork-Delegate: jow@openwrt.org 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=ycPtjWHn; 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 4BSvzg6G9mz9sR4 for ; Sat, 15 Aug 2020 06:24:14 +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=PMW7o0Ht83qG8uQx8bF3uYyXy9g7BNWcziuvRqimSp8=; b=ycPtjWHnZWcdU4utlCyi2Xkm1 3zU8VRL7QLuX4BZtVhtZsYs5TZeoAVvfNiHb3tqa2fMn0HRqiC2LqHAxU10Kedjf8tPFDaEqdyeQo VHaN/L1ig185ZF49hw+WJuLsgC7PAJLlbsN7iUNmsgEcC1WI5uMKweloZXVd73AfD00wCV/kqPxd0 NpO43GME8LbPAaVVOX4Rooj9cw71wU9Wzv9cxp1sK5z3RHbwcRVOBLlVDtMvdE/UWOEpj4/zwWFYH vcAL9Jt5GxgyRCqE7+/N3+OOvrlXbGW3A1AQW2rPOmheMgP8HEYD51y/XAim+ijJpVaKDXv/vvRHE +JYi8Sw8A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6gDT-0000Qw-Ni; Fri, 14 Aug 2020 20:22:19 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6gDQ-0000Q1-BL for openwrt-devel@lists.openwrt.org; Fri, 14 Aug 2020 20:22:17 +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 relay5-d.mail.gandi.net (Postfix) with ESMTPA id C09941C0008; Fri, 14 Aug 2020 20:22:13 +0000 (UTC) From: Paul Spooren To: openwrt-devel@lists.openwrt.org Subject: [PATCH v2 2/4] build: get_source_date_epoch allow external repos Date: Fri, 14 Aug 2020 10:21:56 -1000 Message-Id: <20200814202158.3270944-3-mail@aparcar.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200814202158.3270944-1-mail@aparcar.org> References: <20200814202158.3270944-1-mail@aparcar.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_162216_527472_C7CEB3EF X-CRM114-Status: GOOD ( 13.23 ) 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_H2 RBL: Average reputation (+2) [217.70.183.197 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [217.70.183.197 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 T_PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: version.date (date)] 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 bd3384a761..fa80a4691e 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" ] }