summarylogtreecommitdiffstats
path: root/update.sh
blob: bb5845e5159d3200560a969ceeab17716ec06f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash

ORIGINAL_REPO=$(grep "^source" PKGBUILD |grep "git+https"|sed -e "s|.*com/\(.*\)\#commit.*|\1|" -e "s|.git$||")
LATEST_COMMIT=$(curl -s https://api.github.com/repos/$ORIGINAL_REPO/commits/HEAD|jq -r ".sha")
echo $ORIGINAL_REPO
echo "Latest :" $LATEST_COMMIT

# PKGBUILD
COMMIT=$(grep "^_commit" PKGBUILD|cut -f2 -d"=")
echo "Current:" $COMMIT

if [[ "$COMMIT" != "$LATEST_COMMIT" ]]; then
    echo "change detected."
    #git checkout master
    sed -i 's|^_commit=.*$|_commit='"${LATEST_COMMIT}"'|' PKGBUILD
    updpkgsums
    makepkg -do --noprepare
    makepkg --printsrcinfo > .SRCINFO
    git diff
    git commit -a -m "Update: _commit=${LATEST_COMMIT}"
    #git push
    #git checkout makepkg
else
    echo "No change detected."
fi