Last active
December 20, 2023 23:45
-
-
Save jemdiggity/339e36f396f2f43d1a040be71b726aa3 to your computer and use it in GitHub Desktop.
Script to create nrf5_sdk git repository
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
#!/usr/bin/env bash | |
set -e | |
# This script updates https://github.com/jemdiggity/nrf5_sdk/tree/vendor/sdk | |
# with new SDK packages from Nordic http://developer.nordicsemi.com/nRF5_SDK/ | |
# The script should be run from the repository directory. | |
# Usage: ./add.sh ~/Downloads/nRF5_SDK_15.0.0_a53641a.zip ~/Downloads/nRF5_SDK_15.2.0_9412b96.zip | |
# In other words, the argument is a list of SDK packages to import. | |
# Requires dos2unix and homebrew | |
if ! [ -x "$(command -v dos2unix)" ]; then | |
echo 'Install dos2unix with homebrew first.' | |
echo 'eg brew install dos2unix' | |
exit 1 | |
fi | |
# Use the vendor branch to add SDKs. Afterwards manually merge into master. | |
git checkout vendor | |
for i in "$@"; do | |
echo "Extracting $i..." | |
rm -rf sdk | |
mkdir sdk | |
pushd sdk | |
#check if the top level dir in the tar needs to be stripped | |
if [[ `tar --exclude="*/*" -tf "$i"` == "" ]]; then | |
tar -xf $i --strip-components 1 | |
else | |
tar -xf $i | |
fi | |
rm -f *.msi | |
rm -rf documentation | |
find . -type f | xargs dos2unix -q | |
find . -name ".DS_Store" | xargs rm | |
popd | |
git add --all | |
git commit -qm "Update with `basename $i`. Remove *.msi files and documentation. Fix line-endings." | |
git log --oneline --decorate | |
git tag -a "vendor-$(echo $i | awk -F"_" '{print $3}')" -m "tag" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment