Last active
October 6, 2019 11:40
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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