mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-12 18:20:11 +01:00
Merge branch 'gradle-versioning'
This commit is contained in:
commit
09328806ce
@ -19,26 +19,6 @@ if node['kernel']['machine'] == "x86_64"
|
||||
end
|
||||
end
|
||||
|
||||
script "install-gradle" do
|
||||
cwd "/tmp"
|
||||
interpreter "bash"
|
||||
code "
|
||||
unzip /vagrant/cache/gradle-1.9-bin.zip
|
||||
mv gradle-1.9 /opt/gradle
|
||||
"
|
||||
not_if "test -d /opt/gradle"
|
||||
end
|
||||
|
||||
execute "add-gradle-home" do
|
||||
user user
|
||||
command "echo \"export GRADLE_HOME=/opt/gradle\" >> /home/#{user}/.bsenv"
|
||||
not_if "grep GRADLE_HOME /home/#{user}/.bsenv"
|
||||
end
|
||||
execute "add-gradle-bin" do
|
||||
user user
|
||||
command "echo \"export PATH=\\$PATH:/opt/gradle/bin\" >> /home/#{user}/.bsenv"
|
||||
not_if "grep gradle/bin /home/#{user}/.bsenv"
|
||||
end
|
||||
execute "add-bsenv" do
|
||||
user user
|
||||
command "echo \". ./.bsenv \" >> /home/#{user}/.bashrc"
|
||||
|
48
buildserver/cookbooks/gradle/recipes/default.rb
Normal file
48
buildserver/cookbooks/gradle/recipes/default.rb
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
user = node[:settings][:user]
|
||||
|
||||
gradle_script = IO.read(File.join(
|
||||
File.expand_path(File.dirname(__FILE__)), "gradle"))
|
||||
|
||||
script "add-gradle-bindir" do
|
||||
cwd "/tmp"
|
||||
interpreter "bash"
|
||||
code "mkdir -p /opt/gradle/bin"
|
||||
not_if "test -d /opt/gradle/bin"
|
||||
end
|
||||
|
||||
script "add-gradle-verdir" do
|
||||
cwd "/tmp"
|
||||
interpreter "bash"
|
||||
code "mkdir -p /opt/gradle/versions"
|
||||
not_if "test -d /opt/gradle/versions"
|
||||
end
|
||||
|
||||
%w{1.4 1.6 1.7 1.8 1.9}.each do |ver|
|
||||
script "install-gradle-#{ver}" do
|
||||
cwd "/tmp"
|
||||
interpreter "bash"
|
||||
code "
|
||||
unzip /vagrant/cache/gradle-#{ver}-bin.zip
|
||||
mv gradle-#{ver} /opt/gradle/versions/#{ver}
|
||||
"
|
||||
not_if "test -d /opt/gradle/versions/#{ver}"
|
||||
end
|
||||
end
|
||||
|
||||
script "add-gradle-wrapper" do
|
||||
cwd "/tmp"
|
||||
interpreter "bash"
|
||||
code "
|
||||
cat << \"EOF\" > /opt/gradle/bin/gradle
|
||||
#{gradle_script}
|
||||
EOF
|
||||
chmod a+x /opt/gradle/bin/gradle
|
||||
"
|
||||
end
|
||||
|
||||
execute "add-android-ndk-path" do
|
||||
user user
|
||||
command "echo \"export PATH=\\$PATH:/opt/gradle/bin #PATH-GRADLE\" >> /home/#{user}/.bsenv"
|
||||
not_if "grep PATH-GRADLE /home/#{user}/.bsenv"
|
||||
end
|
68
buildserver/cookbooks/gradle/recipes/gradle
Executable file
68
buildserver/cookbooks/gradle/recipes/gradle
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
bindir="$(dirname $0)"
|
||||
basedir="$(dirname $bindir)"
|
||||
verdir="${basedir}/versions"
|
||||
args=("$@")
|
||||
pushd "${verdir}" &>/dev/null
|
||||
|
||||
v_all=(*/)
|
||||
v_all=(${v_all[@]%/})
|
||||
|
||||
v_def=${v_all[-1]}
|
||||
echo "Available gradle versions: ${v_all[@]}"
|
||||
|
||||
popd &>/dev/null
|
||||
|
||||
run_gradle() {
|
||||
${verdir}/${v_found}/bin/gradle "${args[@]}"
|
||||
exit $?
|
||||
}
|
||||
|
||||
# key-value pairs of what gradle version each gradle plugin version
|
||||
# should accept
|
||||
d_plugin_k=(0.7 0.6 0.5 0.4 0.3 0.2)
|
||||
d_plugin_v=(1.9 1.8 1.6 1.6 1.4 1.4)
|
||||
|
||||
# Latest takes priority
|
||||
files=(build.gradle)
|
||||
|
||||
for f in ${files[@]}; do
|
||||
[[ -f $f ]] || continue
|
||||
while read l; do
|
||||
if [[ $l == *'com.android.tools.build:gradle:'* ]]; then
|
||||
plugin_pver=$(echo -n "$l" | sed "s/.*com.android.tools.build:gradle:\\([0-9\\.\\+]\\+\\).*/\\1/")
|
||||
elif [[ $l == *'gradleVersion'* ]]; then
|
||||
wrapper_ver=$(echo -n "$l" | sed "s/.*gradleVersion[ ]*=[ ]*[\"']\\([0-9\\.]\\+\\)[\"'].*/\\1/")
|
||||
fi
|
||||
done < $f
|
||||
done
|
||||
|
||||
if [[ -n $wrapper_ver ]]; then
|
||||
v_found=$wrapper_ver
|
||||
echo Found $v_found via gradleVersion
|
||||
run_gradle
|
||||
fi
|
||||
|
||||
if [[ -n $plugin_pver ]]; then
|
||||
i=0
|
||||
match=false
|
||||
for k in ${d_plugin_k[@]}; do
|
||||
if [[ $plugin_pver == ${k}* ]]; then
|
||||
plugin_ver=${d_plugin_v[$i]}
|
||||
match=true
|
||||
break
|
||||
fi
|
||||
let i++
|
||||
done
|
||||
if $match; then
|
||||
v_found=$plugin_ver
|
||||
echo Found $v_found via gradle plugin version $k
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ -n $v_found ]] && run_gradle
|
||||
|
||||
echo No suitable gradle version found - defaulting to $v_def
|
||||
v_found=$v_def
|
||||
run_gradle
|
@ -4,6 +4,7 @@ import os
|
||||
import sys
|
||||
import subprocess
|
||||
import time
|
||||
import hashlib
|
||||
from optparse import OptionParser
|
||||
|
||||
def vagrant(params, cwd=None, printout=False):
|
||||
@ -62,6 +63,18 @@ cachefiles = [
|
||||
('android-sdk_r22.3-linux.tgz',
|
||||
'http://dl.google.com/android/android-sdk_r22.3-linux.tgz',
|
||||
'4077575c98075480e0156c10e48a1521e31c7952768271a206870e6813057f4f'),
|
||||
('gradle-1.4-bin.zip',
|
||||
'http://services.gradle.org/distributions/gradle-1.4-bin.zip',
|
||||
'cd99e85fbcd0ae8b99e81c9992a2f10cceb7b5f009c3720ef3a0078f4f92e94e'),
|
||||
('gradle-1.6-bin.zip',
|
||||
'http://services.gradle.org/distributions/gradle-1.6-bin.zip',
|
||||
'de3e89d2113923dcc2e0def62d69be0947ceac910abd38b75ec333230183fac4'),
|
||||
('gradle-1.7-bin.zip',
|
||||
'http://services.gradle.org/distributions/gradle-1.7-bin.zip',
|
||||
'360c97d51621b5a1ecf66748c718594e5f790ae4fbc1499543e0c006033c9d30'),
|
||||
('gradle-1.8-bin.zip',
|
||||
'http://services.gradle.org/distributions/gradle-1.8-bin.zip',
|
||||
'a342bbfa15fd18e2482287da4959588f45a41b60910970a16e6d97959aea5703'),
|
||||
('gradle-1.9-bin.zip',
|
||||
'http://services.gradle.org/distributions/gradle-1.9-bin.zip',
|
||||
'097ddc2bcbc9da2bb08cbf6bf8079585e35ad088bafd42e8716bc96405db98e9'),
|
||||
@ -86,16 +99,26 @@ else:
|
||||
'http://dl.google.com/android/ndk/android-ndk-r9b-linux-x86-legacy-toolchains.tar.bz2',
|
||||
'606aadf815ae28cc7b0154996247c70d609f111b14e44bcbcd6cad4c87fefb6f')])
|
||||
wanted = []
|
||||
|
||||
def sha256_for_file(path):
|
||||
with open(path, 'r') as f:
|
||||
s = hashlib.sha256()
|
||||
while True:
|
||||
data = f.read(4096)
|
||||
if not data:
|
||||
break
|
||||
s.update(data)
|
||||
return s.hexdigest()
|
||||
|
||||
for f, src, shasum in cachefiles:
|
||||
if not os.path.exists(os.path.join(cachedir, f)):
|
||||
relpath = os.path.join(cachedir, f)
|
||||
if not os.path.exists(relpath):
|
||||
print "Downloading " + f + " to cache"
|
||||
if subprocess.call(['wget', src], cwd=cachedir) != 0:
|
||||
print "...download of " + f + " failed."
|
||||
sys.exit(1)
|
||||
if shasum:
|
||||
p = subprocess.Popen(['shasum', '-a', '256', os.path.join(cachedir, f)],
|
||||
stdout=subprocess.PIPE)
|
||||
v = p.communicate()[0].split(' ')[0]
|
||||
v = sha256_for_file(relpath)
|
||||
if v != shasum:
|
||||
print "Invalid shasum of '" + v + "' detected for " + f
|
||||
sys.exit(1)
|
||||
@ -135,6 +158,7 @@ vagrantfile += """
|
||||
chef.add_recipe "fdroidbuild-general"
|
||||
chef.add_recipe "android-sdk"
|
||||
chef.add_recipe "android-ndk"
|
||||
chef.add_recipe "gradle"
|
||||
chef.add_recipe "kivy"
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user