hooks/pre-pkg: fixed mtime support for packages.
overwrites the mtime of all files in a package with the commit-date of the package.
This commit is contained in:
parent
bb03d78ad0
commit
16050ad3f2
3 changed files with 34 additions and 1 deletions
26
common/hooks/pre-pkg/90-set-timestamps.sh
Normal file
26
common/hooks/pre-pkg/90-set-timestamps.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
# This hook executes the following tasks:
|
||||
# - sets the timestamps in a package to the commit date
|
||||
|
||||
hook() {
|
||||
local GIT_CMD date basepkg
|
||||
|
||||
# If XBPS_USE_GIT_COMMIT_DATE is disabled in conf file don't continue.
|
||||
if [ -z $XBPS_USE_GIT_COMMIT_DATE ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if command -v chroot-git &>/dev/null; then
|
||||
GIT_CMD=$(command -v chroot-git)
|
||||
elif command -v git &>/dev/null; then
|
||||
GIT_CMD=$(command -v git)
|
||||
else
|
||||
msg_error "$pkgver: cannot find chroot-git or git utility, exiting...\n"
|
||||
fi
|
||||
basepkg=$pkgname
|
||||
if [ -L "${XBPS_SRCPKGDIR}/$basepkg" ]; then
|
||||
basepkg=$(readlink "${XBPS_SRCPKGDIR}/$basepkg")
|
||||
fi
|
||||
date=$($GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} log --pretty='%ci' --date=iso -n1 .)
|
||||
msg_normal "$pkgver: setting mtimes to %s\n" "$(date --date "$date")"
|
||||
find $PKGDESTDIR -print0 | xargs -0 touch --date "$date"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue