mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-14 11:00:10 +01:00
714b3b9ff6
It will make it a lot easier to manage the cache if we use the original file names, which often include the file version. This also changes the download process to be resumable if there is a partial file in the cache, and switches from calling wget on the command line to using the python libs 'requests' and 'clint' to provide a similar experience. While its not so important for this particular bit of code to use those libraries, I think those two will allow us to provide a better user experience throughout the whole of fdroidserver. In this case, it is already doing special tricks fetching the file size from the server before trying to download it. I suppose this code could instead check if the file exists, and if so, check the hash sum. I think that would be slower for most people since checking the hash on large files takes a noticeable about of time, while a HTTP HEAD request is pretty tiny.
94 lines
2.0 KiB
Ruby
94 lines
2.0 KiB
Ruby
|
|
sdk_loc = node[:settings][:sdk_loc]
|
|
user = node[:settings][:user]
|
|
|
|
script "setup-android-sdk" do
|
|
timeout 14400
|
|
interpreter "bash"
|
|
user user
|
|
cwd "/tmp"
|
|
code "
|
|
tools=`ls -1 /vagrant/cache/tools_*.zip | sort -n | tail -1`
|
|
unzip $tools
|
|
mkdir #{sdk_loc}
|
|
mkdir #{sdk_loc}/platforms
|
|
mkdir #{sdk_loc}/build-tools
|
|
mv tools #{sdk_loc}/
|
|
"
|
|
not_if "test -d #{sdk_loc}"
|
|
end
|
|
|
|
script "setup-sdk-dirs" do
|
|
interpreter "bash"
|
|
user user
|
|
code "
|
|
mkdir -p #{sdk_loc}/build-tools
|
|
"
|
|
end
|
|
|
|
execute "add-android-sdk-path" do
|
|
user user
|
|
path = "#{sdk_loc}/tools:#{sdk_loc}/platform-tools"
|
|
command "echo \"export PATH=\\$PATH:#{path} #PATH-SDK\" >> /home/#{user}/.bsenv"
|
|
not_if "grep PATH-SDK /home/#{user}/.bsenv"
|
|
end
|
|
|
|
%w{
|
|
platform-tools
|
|
extra-android-m2repository
|
|
}.each do |pkg|
|
|
script "add_pkg_#{pkg}" do
|
|
interpreter "bash"
|
|
user user
|
|
code "
|
|
#{sdk_loc}/tools/android update sdk --no-ui -a -t #{pkg} <<X
|
|
y
|
|
|
|
X
|
|
"
|
|
end
|
|
end
|
|
|
|
script "add-platforms" do
|
|
interpreter "bash"
|
|
user user
|
|
cwd "/tmp"
|
|
code "
|
|
rm -rf current-platform
|
|
mkdir current-platform
|
|
cd current-platform
|
|
for f in `ls -1 /vagrant/cache/android-[0-9]*.zip /vagrant/cache/platform-[0-9]*.zip`; do
|
|
unzip $f
|
|
sdk=`sed -n 's,^ro.build.version.sdk=,,p' */build.prop`
|
|
rm -rf #{sdk_loc}/platforms/android-$sdk
|
|
mv * #{sdk_loc}/platforms/android-$sdk
|
|
done
|
|
"
|
|
end
|
|
|
|
%w{17 18.0.1 18.1 18.1.1 19 19.0.1 19.0.2 19.0.3 19.1 20 21 21.0.1 21.0.2 21.1
|
|
21.1.1 21.1.2 22 22.0.1 23 23.0.1 23.0.2 23.0.3
|
|
}.each do |ver|
|
|
script "add_btools_#{ver}" do
|
|
interpreter "bash"
|
|
user user
|
|
cwd "/tmp"
|
|
code "
|
|
unzip /vagrant/cache/build-tools_r#{ver}-linux.zip
|
|
case `echo #{ver} | wc -c` in
|
|
3)
|
|
dirver=#{ver}.0.0
|
|
;;
|
|
5)
|
|
dirver=#{ver}.0
|
|
;;
|
|
7)
|
|
dirver=#{ver}
|
|
;;
|
|
esac
|
|
rm -rf #{sdk_loc}/build-tools/${dirver}
|
|
mv android-*/ #{sdk_loc}/build-tools/${dirver}
|
|
"
|
|
end
|
|
end
|