Skip to content

Instantly share code, notes, and snippets.

@machta
Last active October 6, 2019 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save machta/cf4b384c6a3785fc771f6802505b2435 to your computer and use it in GitHub Desktop.
Save machta/cf4b384c6a3785fc771f6802505b2435 to your computer and use it in GitHub Desktop.
Recursively searches for bitbake recipes and updates SRCREVs to the tops of selected branches.
#!/bin/bash
#
# Recursively searches for bitbake recipes and updates SRCREVs to the tops of
# selected branches.
if [ $# -ne 1 ] ; then
echo "Usage: ./update-srcrev.sh ROOT_SEARCH_DIR"
exit 1
fi
recipes=`find $1 -type f -name \*.bb`
for r in $recipes ; do
echo "Processing $r"
# Check that SRC_URI is in the right format
grep 'SRC_URI.*git@.*git;branch=' $r >/dev/null &&
# Extract URI of the remote and branch name from SRC_URI
URI="ssh://"`grep SRC_URI $r | sed -r 's|.*(git@.*\git);.*|\1|'` &&
BRANCH=`grep SRC_URI $r | sed -r 's|.*branch=(.*);.*|\1|'` &&
# Get the lates commit hash for the branch from the server
SRCREV=`git ls-remote $URI $BRANCH | awk '{print $1}'` &&
# Replace the old hash with the new one in the recipe file
sed -i "s|SRCREV.*\".*\"|SRCREV = \"$SRCREV\"|" $r
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment