diff --git a/elements/source-repositories/extra-data.d/98-source-repositories b/elements/source-repositories/extra-data.d/98-source-repositories index 86b1275a..7b9d0eb2 100755 --- a/elements/source-repositories/extra-data.d/98-source-repositories +++ b/elements/source-repositories/extra-data.d/98-source-repositories @@ -88,7 +88,12 @@ function get_repos_for_element(){ pushd $REPO_DEST sudo git fetch $CACHE_PATH $REPOREF sudo git reset --hard FETCH_HEAD + # Get the reference in use + git_ref=$(git rev-parse FETCH_HEAD) popd + + # Write the reference being used into the source-repositories manifest + echo "$REPONAME git $REPOPATH $REPOLOCATION $git_ref" >> $GIT_MANIFEST ;; tar) # The top level directory of the tarball mightn't have a fixed name i.e. @@ -168,8 +173,19 @@ if [ -e "$OLD_CACHE_BASE" ] ; then fi fi mkdir -p $CACHE_BASE +# Use the IMAGE_NAME from the calling script, and make it unique with the temporary path +GIT_MANIFEST_NAME=dib-git-manifest-$(basename ${IMAGE_NAME}) +GIT_MANIFEST_CACHE_NAME=${GIT_MANIFEST_NAME}_$(dirname ${TMP_MOUNT_PATH##*.}) +GIT_MANIFEST=$CACHE_BASE/${GIT_MANIFEST_CACHE_NAME} +rm -f $GIT_MANIFEST # Get source repositories for the target for _SOURCEREPO in $(find $TMP_HOOKS_PATH -maxdepth 1 -name "source-repository-*" -not -name '*~'); do get_repos_for_element $_SOURCEREPO done + +# Copy the manifest into the image if it exists (there may be no git repositories used) +if [ -e "$GIT_MANIFEST" ] ; then + sudo cp $GIT_MANIFEST $TMP_MOUNT_PATH/etc/$GIT_MANIFEST_NAME + sudo mv $GIT_MANIFEST $(dirname ${IMAGE_NAME})/$GIT_MANIFEST_NAME +fi