xbps-src: abstract away non-portable stat(1)

This implements semi-portable abstractions for both GNU and BSD
flavors of stat.
This commit is contained in:
q66 2023-09-11 04:30:55 +02:00 committed by Đoàn Trần Công Danh
parent 4349108b68
commit 937272e967
6 changed files with 43 additions and 7 deletions

View file

@ -15,7 +15,7 @@ elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
fi
# check if the template is under version control:
if [ -n "$basepkg" -a -z "$($XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
export SOURCE_DATE_EPOCH="$(stat -c %Y ${XBPS_SRCPKGDIR}/${basepkg}/template)"
export SOURCE_DATE_EPOCH="$(stat_mtime ${XBPS_SRCPKGDIR}/${basepkg}/template)"
else
export SOURCE_DATE_EPOCH=$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} cat-file commit HEAD |
sed -n '/^committer /{s/.*> \([0-9][0-9]*\) [-+][0-9].*/\1/p;q;}')