From 2cd2b99e41a2e251ee6303558e3016ec1b40a531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Tue, 21 Apr 2020 00:14:49 +0700 Subject: [PATCH] setup: export SOURCE_DATE_EPOCH from outside of chroot git-worktree(1), and Git shared repository can use a plain text file named `.git` at the root of working tree, containing `gitdir: ` to point to the real directory that has repository. See: gitrepository-layout(5). But, that directory is usually inaccessible inside chroot. In order to support git-worktree(1) and Git shared repository, compute SOURCE_DATE_EPOCH from outside of chroot, and the chroot will carry it over to inside chroot. I've only tested again xbps-uunshare(1). --- common/environment/setup/git.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh index a7395ef53f..5f9b157a89 100644 --- a/common/environment/setup/git.sh +++ b/common/environment/setup/git.sh @@ -7,9 +7,12 @@ fi if [ -n "$XBPS_USE_BUILD_MTIME" ]; then unset SOURCE_DATE_EPOCH -elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then +elif [ -z "${SOURCE_DATE_EPOCH}" ]; then + if [ -n "$IN_CHROOT" ]; then + msg_error "xbps-src's BUG: SOURCE_DATE_EPOCH is undefined\n" + fi # check if the template is under version control: - if [ -z "$($XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then + 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)" else export SOURCE_DATE_EPOCH="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"