aboutsummarylogtreecommitdiffstats
path: root/auto_update.sh
blob: 9eb2ba9a2a538231f45a6296a80985699789e9f7 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! /bin/bash

service_url="https://cef-builds.spotifycdn.com"

versions=$(curl -s "$service_url/index.json")

stripQuotes() {
  sed -e 's/^"//' -e 's/"$//' <<<$1
}

replace_line() {
  sed -i "$2s#.*#$1#" $3
}

update_version() {
  local arch=$1;

  stable=$(echo $versions | jq ".$arch.versions | .[1]");

  # versions
  version_arr=$(echo $stable | jq '.cef_version | split("+")');

  version=$(stripQuotes $(echo $version_arr | jq '.[0]'));
  build_hash=$(stripQuotes $(echo $version_arr | jq '.[1]'));
  chromium_version=$(stripQuotes $(echo $version_arr | jq '.[2] | split("-") | .[1]'));

  minimal=$(echo $stable | jq '.files | map(select(.type == "standard" )) | .[0]');

  filename=$(stripQuotes $(echo $minimal | jq '.name' ))
  sha_hash=$(stripQuotes $(echo $minimal | jq '.sha1' ))

  file_url=$service_url/$filename

  # update PKGBUILD
  replace_line "pkgver=\"$version\"" 5 PKGBUILD
  replace_line "_chromiumver=\"$chromium_version\"" 7 PKGBUILD
  replace_line "_pkgcommit=\"$build_hash\"" 6 PKGBUILD

  # update .SRCINFO
  replace_line "	pkgver = $version" 3 .SRCINFO

  if [ $arch = "linux64" ]; then
    replace_line "sha1sums_x86_64=(\"$sha_hash\")" 29 PKGBUILD

    replace_line "  source_x86_64 = $file_url" 29 .SRCINFO
    replace_line "  sha1sums_x86_64 = $sha_hash" 30 .SRCINFO
  else
    replace_line "sha1sums_i686=(\"$sha_hash\")" 28 PKGBUILD

    replace_line "  source_i686 = $file_url" 27 .SRCINFO
	  replace_line "  sha1sums_i686 = $sha_hash" 28 .SRCINFO
  fi
}

echo "UPDATING "
git pull > /dev/null

echo "- Patching x86_64..."
update_version linux64

echo "- Patching i686..."
update_version linux32

echo $version
echo "- Rebuilding(makepkg)..."
makepkg > /dev/null

if [ -z ${SKIP_PUSH+x} ]; then
  echo "- Uploading to AUR"
  git add .SRCINFO PKGBUILD > /dev/null
  git commit  -m "[AUTO] Version $version" > /dev/null
  git push > /dev/null
fi

echo "Cleanup"
rm -r src/* > /dev/null
rm -r pkg/* > /dev/null

echo "DONE"