common/hooks: new post-install hook to generate pkg gitrevs file.
This commit is contained in:
parent
f6bbf499cc
commit
030f58909f
2 changed files with 43 additions and 1 deletions
39
common/hooks/post-install/05-generate-gitrevs.sh
Normal file
39
common/hooks/post-install/05-generate-gitrevs.sh
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# This hook generates a file in ${wrksrc}/.xbps_git_revs with the last
|
||||||
|
# commit sha1 (in short mode) for all files of a source pkg.
|
||||||
|
|
||||||
|
hook() {
|
||||||
|
local GITREVS_FILE=${wrksrc}/.xbps_${sourcepkg}_git_revs
|
||||||
|
local _revs= _out= f= _filerev= _files=
|
||||||
|
|
||||||
|
# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
|
||||||
|
if [ -z $XBPS_USE_GIT_REVS ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# If the file exists don't regenerate it again.
|
||||||
|
if [ -s ${GITREVS_FILE} ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# Get the git revisions from this source pkg.
|
||||||
|
cd ${XBPS_SRCPKGDIR}
|
||||||
|
_files=$(git ls-files ${sourcepkg})
|
||||||
|
[ -z "${_files}" ] && return
|
||||||
|
|
||||||
|
for f in ${_files}; do
|
||||||
|
_filerev=$(git rev-list --abbrev-commit HEAD $f | head -n1)
|
||||||
|
[ -z "${_filerev}" ] && continue
|
||||||
|
_out="${f} ${_filerev}"
|
||||||
|
if [ -z "${_revs}" ]; then
|
||||||
|
_revs="${_out}"
|
||||||
|
else
|
||||||
|
_revs="${_revs} ${_out}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
set -- ${_revs}
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
local _file=$1; local _rev=$2
|
||||||
|
echo "${_file}: ${_rev}"
|
||||||
|
echo "${_file}: ${_rev}" >> ${GITREVS_FILE}
|
||||||
|
shift 2
|
||||||
|
done
|
||||||
|
}
|
|
@ -40,6 +40,9 @@ genpkg() {
|
||||||
if [ -s ${PKGDESTDIR}/shlib-requires ]; then
|
if [ -s ${PKGDESTDIR}/shlib-requires ]; then
|
||||||
_shrequires="$(cat ${PKGDESTDIR}/shlib-requires)"
|
_shrequires="$(cat ${PKGDESTDIR}/shlib-requires)"
|
||||||
fi
|
fi
|
||||||
|
if [ -s ${wrksrc}/.xbps_${sourcepkg}_git_revs ]; then
|
||||||
|
_gitrevs="$(cat ${wrksrc}/.xbps_${sourcepkg}_git_revs)"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$provides" ]; then
|
if [ -n "$provides" ]; then
|
||||||
local _provides=
|
local _provides=
|
||||||
|
@ -92,7 +95,7 @@ genpkg() {
|
||||||
--built-with "xbps-src-${XBPS_SRC_VERSION}" \
|
--built-with "xbps-src-${XBPS_SRC_VERSION}" \
|
||||||
--build-options "${PKG_BUILD_OPTIONS}" \
|
--build-options "${PKG_BUILD_OPTIONS}" \
|
||||||
--pkgver "${pkgver}" --quiet \
|
--pkgver "${pkgver}" --quiet \
|
||||||
--source-revisions "$(cat ${PKG_GITREVS_FILE:-/dev/null} 2>/dev/null)" \
|
--source-revisions "${_gitrevs}" \
|
||||||
--shlib-provides "${_shprovides}" \
|
--shlib-provides "${_shprovides}" \
|
||||||
--shlib-requires "${_shrequires}" \
|
--shlib-requires "${_shrequires}" \
|
||||||
${_preserve} ${_sourcerevs} ${PKGDESTDIR}
|
${_preserve} ${_sourcerevs} ${PKGDESTDIR}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue