Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP7:Update
php7.35978
php-build-reproducible-phar.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File php-build-reproducible-phar.patch of Package php7.35978
From 485e2a4e43458a417603d4ed219af3e79854ef46 Mon Sep 17 00:00:00 2001 From: Arjen de Korte <build+github@de-korte.org> Date: Sat, 2 Jan 2021 17:57:18 +0100 Subject: [PATCH 1/1] phar: honor SOURCE_DATE_EPOCH for timestamps In order to build reproducible phars, honor SOURCE_DATE_EPOCH if set Signed-off-by: Arjen de Korte <build+github@de-korte.org> --- ext/phar/phar.c | 2 +- ext/phar/phar_internal.h | 15 +++++++++++++++ ext/phar/stream.c | 2 +- ext/phar/tar.c | 2 +- ext/phar/util.c | 2 +- ext/phar/zip.c | 2 +- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 6434a75a75..b5d28c8181 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -3002,7 +3002,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv 4: metadata-len +: metadata */ - mytime = time(NULL); + mytime = source_date_epoch_time(NULL); phar_set_32(entry_buffer, entry->uncompressed_filesize); phar_set_32(entry_buffer+4, mytime); phar_set_32(entry_buffer+8, entry->compressed_filesize); diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index f959cb29bc..de7ba32636 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -425,6 +425,21 @@ static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry) return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type; } +static inline time_t source_date_epoch_time(time_t *tloc) +{ + const char *sde; + time_t ts; + + tsrm_env_lock(); + sde = getenv("SOURCE_DATE_EPOCH"); + ts = (sde) ? strtoul(sde, NULL, 10) : time(0); + tsrm_env_unlock(); + if (tloc) { + *tloc = ts; + } + return ts; +} + static inline zend_off_t phar_get_fp_offset(phar_entry_info *entry) { if (!entry->is_persistent) { diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 91ed30cf03..15a5fa29a1 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -463,7 +463,7 @@ static int phar_stream_flush(php_stream *stream) /* {{{ */ phar_entry_data *data = (phar_entry_data *) stream->abstract; if (data->internal_file->is_modified) { - data->internal_file->timestamp = time(0); + data->internal_file->timestamp = source_date_epoch_time(0); ret = phar_flush(data->phar, 0, 0, 0, &error); if (error) { php_stream_wrapper_log_error(stream->wrapper, REPORT_ERRORS, "%s", error); diff --git a/ext/phar/tar.c b/ext/phar/tar.c index bae1a4bf7b..76773e4752 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -971,7 +971,7 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int char halt_stub[] = "__HALT_COMPILER();"; entry.flags = PHAR_ENT_PERM_DEF_FILE; - entry.timestamp = time(NULL); + entry.timestamp = source_date_epoch_time(NULL); entry.is_modified = 1; entry.is_crc_checked = 1; entry.is_tar = 1; diff --git a/ext/phar/util.c b/ext/phar/util.c index b45251d14a..0bb95ea480 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -574,7 +574,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, ch phar_add_virtual_dirs(phar, path, path_len); etemp.is_modified = 1; - etemp.timestamp = time(0); + etemp.timestamp = source_date_epoch_time(0); etemp.is_crc_checked = 1; etemp.phar = phar; etemp.filename = estrndup(path, path_len); diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 1d7c5b2217..eb515475f7 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -1185,7 +1185,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int pass.error = &temperr; entry.flags = PHAR_ENT_PERM_DEF_FILE; - entry.timestamp = time(NULL); + entry.timestamp = source_date_epoch_time(NULL); entry.is_modified = 1; entry.is_zip = 1; entry.phar = phar; -- 2.29.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor