summarylogtreecommitdiffstats
path: root/generate.sh
blob: ffbe99ed8c5e9470ae90adf970c8ff840847fa0d (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
26
#!/bin/sh

REPO="tuProlog/2p-kt"

function get_latest_release() {
  curl --silent "https://api.github.com/repos/$REPO/releases/latest" | 
    grep '"tag_name":' |
    sed -E 's/.*"([^"]+)".*/\1/'
}

function escape4sed() {
    printf '%s\n' "$1" | sed -e 's/[\/&]/\\&/g'
}

LATEST_VERSION=`get_latest_release`
URL="https://github.com/$REPO"
VERSION=${1:-$LATEST_VERSION}

wget -q $URL/releases/download/$VERSION/2p-repl-$VERSION-redist.jar

DIGEST=$(cat 2p-repl-$VERSION-redist.jar | sha256sum - | cut -d' ' -f 1)

cat .PKGBUILD.template  | 
    sed -e "s/__VERSION__/$VERSION/g" |
    sed -e "s/__URL__/$(escape4sed $URL)/g" |
    sed -e "s/__DIGEST__/$(escape4sed $DIGEST)/g"