From 870eae26dc5c6a18b08d9a6f4dfa92907517aa6c Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Tue, 10 Dec 2024 18:20:15 +1000 Subject: [PATCH] makepkg: move SOURCE_DATE_EPOCH handling to libmakepkg Signed-off-by: Allan McRae --- scripts/libmakepkg/reproducible/meson.build | 1 + .../reproducible/source_date_epoch.sh.in | 33 +++++++++++++++++++ scripts/makepkg.sh.in | 7 ---- 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 scripts/libmakepkg/reproducible/source_date_epoch.sh.in diff --git a/scripts/libmakepkg/reproducible/meson.build b/scripts/libmakepkg/reproducible/meson.build index 0738fe9c..995b8797 100644 --- a/scripts/libmakepkg/reproducible/meson.build +++ b/scripts/libmakepkg/reproducible/meson.build @@ -2,6 +2,7 @@ libmakepkg_module = 'reproducible' sources = [ 'python.sh.in', + 'source_date_epoch.sh.in', ] foreach src : sources diff --git a/scripts/libmakepkg/reproducible/source_date_epoch.sh.in b/scripts/libmakepkg/reproducible/source_date_epoch.sh.in new file mode 100644 index 00000000..190e6011 --- /dev/null +++ b/scripts/libmakepkg/reproducible/source_date_epoch.sh.in @@ -0,0 +1,33 @@ +#!/bin/bash +# +# source_date_epoch.sh - handle SOURCE_DATE_EPOCH variable for reproducibility +# +# Copyright (c) 2017-2024 Pacman Development Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +[[ -n "$LIBMAKEPKG_REPRODUCIBLE_SOURCE_DATE_EPOCH_SH" ]] && return +LIBMAKEPKG_REPRODUCIBLE_SOURCE_DATE_EPOCH_SH=1 + + +MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'} + + +if [[ -n $SOURCE_DATE_EPOCH ]]; then + REPRODUCIBLE=1 +else + SOURCE_DATE_EPOCH=$(date +%s) +fi +export SOURCE_DATE_EPOCH diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 75df3650..b7edb712 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -80,13 +80,6 @@ SPLITPKG=0 SOURCEONLY=0 VERIFYSOURCE=0 -if [[ -n $SOURCE_DATE_EPOCH ]]; then - REPRODUCIBLE=1 -else - SOURCE_DATE_EPOCH=$(date +%s) -fi -export SOURCE_DATE_EPOCH - MAKEPKG_LINT_PKGBUILD=${MAKEPKG_LINT_PKGBUILD:-1} PACMAN_OPTS=()