void-packages/common/environment/setup/git.sh
Đoàn Trần Công Danh 2cd2b99e41 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: <path>` 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).
2020-05-23 06:59:24 +00:00

20 lines
760 B
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
# only run this, if SOURCE_DATE_EPOCH isn't set.
if [ -z "$XBPS_GIT_CMD" ]; then
msg_error "BUG: environment/setup: XBPS_GIT_CMD is not set\n"
fi
if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
unset SOURCE_DATE_EPOCH
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 [ -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)"
fi
fi