Last active
August 13, 2020 05:38
-
-
Save nobodywasishere/38ad7814f5e0fbf4ef18b2860b058a90 to your computer and use it in GitHub Desktop.
Update fpga-toolchain-bin on the AUR
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 | |
# Copyright 2020 Michael Riegert | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
UPSTREAM=https://api.github.com/repos/open-tool-forge/fpga-toolchain/releases/latest | |
FPGADIR= # location of the PKGBUILD aur git repo | |
NOTIFYOPTS="-u normal -i network-server" | |
cd ${FPGADIR} | |
# pull list of latest builds | |
curl -s ${UPSTREAM} > upstream.txt | |
# check latest builds for linux build, sometimes not included | |
if cat upstream.txt | grep -q 'fpga-toolchain-linux_x86_64-nightly-'; then | |
# pull the latest PKGBUILD from the aur | |
if !(git fetch && git reset --hard HEAD && git merge '@{u}' > /dev/null); then | |
notify-send "fpga-toolchain-update-bin: | |
Failed to pull latest PKGBUILD $( echo ${pkgtxt} | sed 's/.*=//' )" $NOTIFYOPTS | |
echo "fpga-toolchain-update-bin: Failed to pull latest PKGBUILD $( echo ${pkgtxt} | sed 's/.*=//' )" | |
exit 1 | |
fi | |
# get the old and new versions of the binaries | |
pkgtxt=$(echo "pkgver=" $(cat upstream.txt | grep -o -P 'nightly-.{0,8}' | head -1 | sed 's/.*-//') | sed 's/ //') | |
pkgtxt_old=$(grep -o -P 'pkgver=.{0,8}' PKGBUILD | head -1 | sed 's/ //') | |
# echo ${pkgtxt} # Debug | |
# echo ${pkgtxt_old} # Debug | |
# if the versions are different, need to update the AUR | |
if [ $pkgtxt != $pkgtxt_old ]; then | |
sed -i 's/pkgver=.*/'"${pkgtxt}"'/' PKGBUILD | |
# check to see if the updated PKGBUILD successfully compiles | |
# skipping checksums as they're for the old version | |
if makepkg -f --skipinteg > /dev/null; then | |
# update checksums | |
updpkgsums | |
# AUR stuff | |
makepkg --printsrcinfo > .SRCINFO | |
git add PKGBUILD .SRCINFO | |
git commit -m "Update nightly build" | |
git push | |
# notify me of success or failure | |
notify-send "fpga-toolchain-update-bin: | |
Updated PKGBUILD with newest version $( echo ${pkgtxt} | sed 's/.*=//' )" $NOTIFYOPTS | |
echo "fpga-toolchain-update-bin: Updated PKGBUILD with newest version $( echo ${pkgtxt} | sed 's/.*=//' )" | |
else | |
notify-send "fpga-toolchain-update-bin: | |
Failed to update PKGBUILD with newest version $( echo ${pkgtxt} | sed 's/.*=//' )" $NOTIFYOPTS | |
echo "fpga-toolchain-update-bin: Failed to update PKGBUILD with newest version $( echo ${pkgtxt} | sed 's/.*=//' )" | |
fi | |
else | |
notify-send "fpga-toolchain-update-bin: | |
No update needed" $NOTIFYOPTS | |
echo "fpga-toolchain-update-bin: No update needed" | |
fi | |
else | |
notify-send "fpga-toolchain-update-bin: | |
No Linux build included" $NOTIFYOPTS | |
echo "fpga-toolchain-update-bin: No Linux build included" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment