@@ -852,11 +852,23 @@ query_dirassets() {
852852 esac
853853}
854854
855+ get_commit_ts_from_obsinfo () {
856+ local line ts
857+ while read line ; do
858+ case $line in
859+ mtime:\ * [^0-9]* ) ;;
860+ mtime:\ [0-9]* ) ts=${line# mtime: } ;;
861+ esac
862+ done < " $1 "
863+ test -n " $ts " && echo $ts
864+ }
865+
855866copy_sources () {
856867 local image_mode i
857868 if test " $BUILDTYPE " = kiwi -o " $BUILDTYPE " = docker -o " $BUILDTYPE " = fissile -o " $BUILDTYPE " = podman -o " $BUILDTYPE " = productcompose ; then
858869 image_mode=true
859870 fi
871+ local set_mtime
860872 if test -n " $RUNNING_IN_VM " -o -n " $COPY_SOURCES_ASIS " -o -n " $RPM_BUILD_IN_PLACE " ; then
861873 image_mode=
862874 ( shopt -s nullglob ; cp -pRd " $1 /" .[^.]* " $1 /" ..?* " $1 " /* " $2 " )
@@ -867,6 +879,8 @@ copy_sources() {
867879 test -n " $dirassets " && dirassets=" /${dirassets// / \\ / } /"
868880 # check which directory belongs to the git repository and only copy those and the dir assets
869881 type -p git >& /dev/null || cleanup_and_exit 1 " need git to check file status"
882+ # get commit timestamp
883+ set_mtime=$( git -C " $1 " log -n1 --date=format:%Y%m%d --no-show-signature --pretty=format:%ct)
870884 for i in " $1 /" .* " $1 " /* ; do
871885 local ii=" ${i##*/ } "
872886 test " $ii " = . -o " $ii " = .. -o " $ii " = .git && continue
@@ -890,7 +904,11 @@ copy_sources() {
890904 $BUILD_DIR /export_debian_orig_from_git " $1 " " $2 /build.origtar" || cleanup_and_exit 1 " export_debian_orig_from_git failed"
891905 fi
892906 else
907+ # check if there is a _scmsync.obsinfo file and get the commit timestamp
893908 # query recipe for directories to copy
909+ if test -s " $1 /_scmsync.obsinfo" ; then
910+ set_mtime=$( get_commit_ts_from_obsinfo " $1 /_scmsync.obsinfo" )
911+ fi
894912 local dirassets
895913 dirassets=$( query_dirassets " $1 /$RECIPEFILE " )
896914 test -n " $dirassets " && dirassets=" /${dirassets// / \\ / } /"
@@ -908,6 +926,10 @@ copy_sources() {
908926 cp -p " $1 " /* " $2 "
909927 fi
910928 fi
929+ if test -n " $set_mtime " ; then
930+ echo " setting source mtime to $set_mtime "
931+ find " $2 " -depth -type d -print0 -o -links 1 -print0 | xargs -0 --no-run-if-empty touch -d " @$set_mtime "
932+ fi
911933 if test -n " $image_mode " ; then
912934 rm -rf " $2 /repos" " $2 /containers"
913935 if test -z " $REPOS_DIRECTORY " ; then
0 commit comments