mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-12 10:10:30 +03:00
buildserver: use android update sdk to install Android SDK
`android update sdk --no-ui` is the standard command line tool for installing the Android SDK. By symlinking into the $ANDROID_HOME/temp dir, the cached files can still be used. This converts the chef recipe to a vagrant shell provisioning script since it was all bash anyway. Some file names no longer officially have a -linux in them, so those were changed to keep the cache working with the default filename.
This commit is contained in:
parent
e449d2f583
commit
e47396b403
3 changed files with 65 additions and 88 deletions
|
|
@ -1,79 +0,0 @@
|
|||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
script "add_android_packages" do
|
||||
interpreter "bash"
|
||||
user user
|
||||
code "
|
||||
#{sdk_loc}/tools/android update sdk --no-ui --all --filter platform-tools,extra-android-m2repository <<X
|
||||
y
|
||||
|
||||
X
|
||||
"
|
||||
end
|
||||
|
||||
script "add-platforms" do
|
||||
interpreter "bash"
|
||||
user user
|
||||
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
|
||||
|
||||
script "add_build_tools" do
|
||||
interpreter "bash"
|
||||
user user
|
||||
code "
|
||||
rm -rf current-build-tools
|
||||
mkdir current-build-tools
|
||||
cd current-build-tools
|
||||
for ver in 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; do
|
||||
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}
|
||||
done
|
||||
"
|
||||
end
|
||||
53
buildserver/provision-android-sdk
Normal file
53
buildserver/provision-android-sdk
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z $ANDROID_HOME ]; then
|
||||
echo "ANDROID_HOME env var must be set!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# TODO remove the rm, this should work with an existing ANDROID_HOME
|
||||
if [ ! -x $ANDROID_HOME/tools/android ]; then
|
||||
rm -rf $ANDROID_HOME
|
||||
mkdir ${ANDROID_HOME}
|
||||
mkdir ${ANDROID_HOME}/temp
|
||||
mkdir ${ANDROID_HOME}/platforms
|
||||
mkdir ${ANDROID_HOME}/build-tools
|
||||
cd $ANDROID_HOME
|
||||
|
||||
tools=`ls -1 /vagrant/cache/tools_*.zip | sort -n | tail -1`
|
||||
unzip -qq $tools
|
||||
fi
|
||||
|
||||
cd /vagrant/cache
|
||||
|
||||
# make hard links for `android update sdk` to use and delete
|
||||
for f in android_*.zip android-[0-9]*.zip platform-[0-9]*.zip build-tools_r*-linux.zip; do
|
||||
rm -f ${ANDROID_HOME}/temp/$f
|
||||
ln -s /vagrant/cache/$f ${ANDROID_HOME}/temp/
|
||||
done
|
||||
|
||||
# install all cached platforms
|
||||
cached=""
|
||||
for f in `ls -1 android-[0-9]*.zip platform-[0-9]*.zip`; do
|
||||
sdk=`unzip -c $f "*/build.prop" | sed -n 's,^ro.build.version.sdk=,,p'`
|
||||
cached=,android-${sdk}${cached}
|
||||
done
|
||||
|
||||
# install all cached build-tools
|
||||
for f in `ls -1 build-tools*.zip`; do
|
||||
ver=`unzip -c $f "*/source.properties" | sed -n 's,^Pkg.Revision=,,p'`
|
||||
cached=,build-tools-${ver}${cached}
|
||||
done
|
||||
|
||||
${ANDROID_HOME}/tools/android --silent update sdk --no-ui --all \
|
||||
--filter platform-tools,extra-android-m2repository${cached} <<EOH
|
||||
y
|
||||
|
||||
EOH
|
||||
|
||||
|
||||
chmod -R a+rX $ANDROID_HOME/
|
||||
find $ANDROID_HOME/ -type f -executable -print0 | xargs -0 chmod a+x
|
||||
Loading…
Add table
Add a link
Reference in a new issue