• Bug#872381: dpkg-dev: optimize Makefile snippets for debian/rules (5/6)

    From Nicolas Boulenguez@1:229/2 to All on Mon Mar 4 16:50:01 2024
    [continued from previous message]

    + # Only parse the changelog if a variable is actually used,
    + # but then replace each recursive definition with a non-recursive one
    + # (and of course return the asked value).
    + DEB_SOURCE = $(dpkg-parsechangelog_run)$(DEB_SOURCE)
    + DEB_VERSION = $(dpkg-parsechangelog_run)$(DEB_VERSION)
    + DEB_VERSION_EPOCH_UPSTREAM = \
    + $(dpkg-parsechangelog_run)$(DEB_VERSION_EPOCH_UPSTREAM)
    + DEB_VERSION_UPSTREAM_REVISION = \
    + $(dpkg-parsechangelog_run)$(DEB_VERSION_UPSTREAM_REVISION)
    + DEB_VERSION_UPSTREAM = \
    + $(dpkg-parsechangelog_run)$(DEB_VERSION_UPSTREAM)
    + DEB_DISTRIBUTION = $(dpkg-parsechangelog_run)$(DEB_DISTRIBUTION)
    +else
    + # We must run a subshell in order to compute SOURCE_DATE_EPOCH,
    + # so we may as well set all variables.
    + dpkg-parsechangelog_sed += \
    + ;s/^Timestamp: \(.*\)/$$(eval SOURCE_DATE_EPOCH:=\1)/p
    + $(dpkg-parsechangelog_run)
    +endif

    export SOURCE_DATE_EPOCH

    --
    2.39.2


    From 94fb896c431e96db1f489e1a344e48a0a7d11209 Mon Sep 17 00:00:00 2001
    From: Nicolas Boulenguez <[email protected]>
    Date: Wed, 10 Jan 2024 20:10:10 +0100
    Subject: [PATCH 08/10] scripts/buildapi.mk: reduce the number of subprocesses

    Ensure that dpkg-buildapi is only called at most once.

    If so, call it once and cache the result for future expansions.
    ---
    scripts/mk/buildapi.mk | 6 +++++-
    1 file changed, 5 insertions(+), 1 deletion(-)

    diff --git a/scripts/mk/buildapi.mk b/scripts/mk/buildapi.mk
    index ba6b43543..8ceb13cab 100644
    --- a/scripts/mk/buildapi.mk
    +++ b/scripts/mk/buildapi.mk
    @@ -4,7 +4,11 @@ ifndef dpkg_buildapi.mk_included
    dpkg_buildapi.mk_included :=

    # Default API level when not set.
    -DPKG_BUILD_API ?= $(shell dpkg-buildapi)
    +# Run dpkg-buildapi if the variable is actually expanded,
    +# but then replace the recursive definition with a non-recursive one
    +# (and of course return the asked value).
    +DPKG_BUILD_API ?= \
    + $$(eval DPKG_BUILD_API := $$(shell dpkg-buildapi))$$(DPKG_BUILD_API)

    # We could use only built-in GNU make functions, but that seems too much
    # complexity given no integer operators, given that we currently have to
    --
    2.39.2


    From 0ef38e6dbee661921d9fad371734e7bfa5160fae Mon Sep 17 00:00:00 2001
    From: Nicolas Boulenguez <[email protected]>
    Date: Sun, 13 Feb 2022 13:41:26 +0100
    Subject: [PATCH