From patchwork Sun Jan 10 09:23:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Spooren X-Patchwork-Id: 1424210 X-Patchwork-Delegate: mail@aparcar.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=fBIQR74x; 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 4DDBMK27Y9z9sWK for ; Sun, 10 Jan 2021 20:27:41 +1100 (AEDT) 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=UoMkOxZpXZtDMvT5LbUlNFWJf6PE3g4s5WVMVe205ZI=; b=fBIQR74xZNE4vWty4IHWFHM3O KxZuh8DgAj9N7LjEVsEyCQg7XSE64Bn0ww8/Fcle0G6FAzRwBtuX/sCfVO8sUD/GMYk6EY2O5fAED 3ox/ZhGA6runM9xX+VPZAi4On/fWIwGZRmyJxYJcIJT+PWnLNjl9GBYTYA4456pYi/fL7y+NXWvfL 04NKabL9hPGI2YUtjGO0b1VNMvXZkj8ZC2sbQuSPvLyGwZyeEQ6KTMpm5w43YAgJ6LJUOyTFzwluD nSmCFFayl4jU5w614+Nc94SfNlL37loTwMsJKo6z3ZzFLqs44oFEnCGzw46jkOesCOfORa7/itfdY ThCOZxQUQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kyWyl-0006Ux-If; Sun, 10 Jan 2021 09:25:43 +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 1kyWyh-0006TS-Hz for openwrt-devel@lists.openwrt.org; Sun, 10 Jan 2021 09:25:40 +0000 X-Originating-IP: 72.235.129.18 Received: from dawn.lan (udp100268uds.hawaiiantel.net [72.235.129.18]) (Authenticated sender: mail@aparcar.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPA id 94071E0004; Sun, 10 Jan 2021 09:25:33 +0000 (UTC) From: Paul Spooren To: openwrt-devel@lists.openwrt.org Subject: [PATCH v3 1/3] rules: add commitcount function Date: Sat, 9 Jan 2021 23:23:59 -1000 Message-Id: <20210110092400.144356-1-mail@aparcar.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210107195149.1425925-1-mail@aparcar.org> References: <20210107195149.1425925-1-mail@aparcar.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210110_042539_724821_617AA3DF X-CRM114-Status: UNSURE ( 9.13 ) X-CRM114-Notice: Please train this message. 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.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low 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_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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 , nbd@nbd.name Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org `commitcount` returns the number of commits affecting the current folder. The newly added function can be used for packages that do not follow a traditional versioning schema, most prominent `base-files` which requires tedious `PKG_RELEASE` bumps. Below a naming example: base-files_1399-r15385+75-c5d033a34d_x86_64.ipk In cases where no Git system is used, the timestamp of SOURCE_DATE_EPOCH is used instead, allowing reproducible builds. base-files_210107.30634-r1538581-c5d033a34d_x86_64.ipk Signed-off-by: Paul Spooren --- v2: - reproducible versions via SOURCE_DATE_EPOCH - wrap function in ifndef DUMP v3: - don't use tabs in `commitcount` to remove stripping in VERSION:= definition rules.mk | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rules.mk b/rules.mk index f79340b124..ac406983b9 100644 --- a/rules.mk +++ b/rules.mk @@ -408,6 +408,24 @@ endef # file extension ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1))) +ifndef DUMP +define commitcount +$(shell \ + if git log -1 >/dev/null 2>/dev/null; then \ + printf '%s' $$(git rev-list --count HEAD .); \ + else \ + secs="$$(($(SOURCE_DATE_EPOCH) % 86400))"; \ + date="$$(date --utc --date="@$(SOURCE_DATE_EPOCH)" "+%y%m%d")"; \ + printf '%s.%05d' "$$date" "$$secs"; \ + fi \ +) +endef +else +define commitcount +1 +endef +endif + all: FORCE: ; .PHONY: FORCE