Skip to content

Commit 28014ad

Browse files
Merge pull request #877 from travis-ci/km-TDOC-106-V2
Added support for Android in Bionic, Jammy, and Focal
2 parents 21c6082 + 832db15 commit 28014ad

File tree

13 files changed

+375
-119
lines changed

13 files changed

+375
-119
lines changed

cookbooks/travis_ci_ubuntu_1804/attributes/default.rb

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
openjdk9
6868
openjdk10
6969
openjdk11
70+
openjdk17
7071
]
7172
override['travis_jdk']['default'] = 'openjdk11'
7273
end
@@ -184,11 +185,44 @@
184185
perl6
185186
elixir
186187
erlang
187-
188+
android
188189
]
189190
override['travis_docker']['version'] = '24.0.5'
190191
override['travis_docker']['binary']['version'] = '24.0.5'
191192
override['travis_docker']['compose']['url'] = 'https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-Linux-x86_64'
192193
override['travis_docker']['compose']['sha256sum'] = 'f45e4cb687df8b48a57f656097ce7175fa8e8bef70be407b011e29ff663f475f'
193194
override['travis_docker']['binary']['url'] = 'https://download.docker.com/linux/static/stable/x86_64/docker-24.0.5.tgz'
194195
override['travis_docker']['binary']['checksum'] = '0a5f3157ce25532c5c1261a97acf3b25065cfe25940ef491fa01d5bea18ddc86'
196+
override['android-sdk'] = {
197+
'name' => 'android-sdk',
198+
'setup_root' => '/usr/local',
199+
'download_url' => 'https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip',
200+
'checksum' => '2b3751867a4b4b70dbd8dcf6537aa888',
201+
'version' => '9477386',
202+
'owner' => 'root',
203+
'group' => 'root',
204+
'with_symlink' => true,
205+
'java_from_system' => false,
206+
'set_environment_variables' => true,
207+
'license' => {
208+
'white_list' => ['android-sdk-license'],
209+
'black_list' => [],
210+
'default_answer' => 'y'
211+
},
212+
'license_file_path' => File.expand_path('../../android-accept-licenses', __dir__),
213+
'components' => [
214+
'tools',
215+
'platform-tools',
216+
'build-tools;30.0.0',
217+
'platforms;android-30',
218+
'extras;google;google_play_services',
219+
'extras;google;m2repository',
220+
'extras;android;m2repository'
221+
],
222+
'scripts' => {
223+
'path' => '/usr/local/bin',
224+
'owner' => 'root',
225+
'group' => 'root'
226+
},
227+
'maven_rescue' => false
228+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/expect -f
2+
3+
set timeout 1800
4+
set cmd [lindex $argv 0]
5+
set licenses [lindex $argv 1]
6+
7+
spawn {*}$cmd
8+
expect {
9+
-regexp "Do you accept the license '($licenses)'.*" {
10+
exp_send "y\r"
11+
exp_continue
12+
}
13+
"Do you accept the license '*'*" {
14+
exp_send "n\r"
15+
exp_continue
16+
}
17+
eof
18+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Originally written by Ralf Kistner <[email protected]>, but placed in the public domain
4+
5+
set +e
6+
7+
bootanim=""
8+
failcounter=0
9+
timeout_in_sec=360
10+
11+
until [[ "$bootanim" =~ "stopped" ]]; do
12+
bootanim=`adb -e shell getprop init.svc.bootanim 2>&1 &`
13+
if [[ "$bootanim" =~ "device not found" || "$bootanim" =~ "device offline"
14+
|| "$bootanim" =~ "running" ]]; then
15+
let "failcounter += 1"
16+
echo "Waiting for emulator to start"
17+
if [[ $failcounter -gt timeout_in_sec ]]; then
18+
echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator"
19+
exit 1
20+
fi
21+
fi
22+
sleep 1
23+
done
24+
25+
echo "Emulator is ready"

cookbooks/travis_ci_ubuntu_1804/recipes/default.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@
4040
end
4141
include_recipe 'travis_docker::compose'
4242
include_recipe 'openssl'
43+
4344
include_recipe 'travis_jdk'
4445
include_recipe 'travis_build_environment::maven'
4546
include_recipe 'travis_build_environment::lein'
4647
include_recipe 'travis_sbt_extras'
4748
include_recipe 'travis_build_environment::gradle'
4849
include_recipe 'travis_postgresql'
49-
include_recipe 'travis_build_environment::mysql'
5050
include_recipe 'travis_perlbrew::multi'
5151
include_recipe 'travis_build_environment::redis'
5252
include_recipe 'travis_build_environment::mongodb'
5353
include_recipe 'memcached'
54+
include_recipe 'travis_build_environment::android-sdk'
5455
# TODO: Uncomment when cassandra works on Java 8 again
5556
# https://github.com/travis-ci/packer-templates/issues/589
5657
# include_recipe 'travis_build_environment::cassandra'
@@ -63,7 +64,8 @@
6364
include_recipe 'travis_build_environment::ibm_advanced_tool_chain'
6465
include_recipe 'travis_phantomjs::2'
6566
include_recipe 'travis_phpenv::libargon2'
66-
67+
include_recipe 'travis_phpenv::libargon2'
68+
include_recipe 'travis_build_environment::mysql'
6769
# HACK: ubuntu_1804-specific shims!
6870
execute 'ln -svf /usr/bin/hashdeep /usr/bin/md5deep'
6971

cookbooks/travis_ci_ubuntu_2004/attributes/default.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
openjdk9
5858
openjdk10
5959
openjdk11
60+
openjdk17
6061
]
6162

6263
override['travis_jdk']['default'] = 'openjdk11'
@@ -183,6 +184,7 @@
183184
rust
184185
elixir
185186
erlang
187+
android
186188
]
187189

188190
override['travis_docker']['version'] = '26.1.3'
@@ -191,3 +193,38 @@
191193
override['travis_docker']['compose']['sha256sum'] = 'ddc876fe2a89d5b7ea455146b0975bfe52904eecba9b192193377d6f99d69ad9'
192194
override['travis_docker']['binary']['url'] = 'https://download.docker.com/linux/static/stable/x86_64/docker-26.1.3.tgz'
193195
override['travis_docker']['binary']['checksum'] = 'a50076d372d3bbe955664707af1a4ce4f5df6b2d896e68b12ecc74e724d1db31'
196+
197+
198+
override['android-sdk'] = {
199+
'name' => 'android-sdk',
200+
'setup_root' => '/usr/local',
201+
'download_url' => 'https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip',
202+
'checksum' => '2b3751867a4b4b70dbd8dcf6537aa888',
203+
'version' => '9477386',
204+
'owner' => 'root',
205+
'group' => 'root',
206+
'with_symlink' => true,
207+
'java_from_system' => false,
208+
'set_environment_variables' => true,
209+
'license' => {
210+
'white_list' => ['android-sdk-license'],
211+
'black_list' => [],
212+
'default_answer' => 'y'
213+
},
214+
'license_file_path' => File.expand_path('../../android-accept-licenses', __dir__),
215+
'components' => [
216+
'tools',
217+
'platform-tools',
218+
'build-tools;30.0.0',
219+
'platforms;android-30',
220+
'extras;google;google_play_services',
221+
'extras;google;m2repository',
222+
'extras;android;m2repository'
223+
],
224+
'scripts' => {
225+
'path' => '/usr/local/bin',
226+
'owner' => 'root',
227+
'group' => 'root'
228+
},
229+
'maven_rescue' => false
230+
}

cookbooks/travis_ci_ubuntu_2004/recipes/default.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
include_recipe 'travis_perlbrew::multi'
4949
include_recipe 'travis_build_environment::redis'
5050
# include_recipe 'travis_build_environment::mongodb'
51-
include_recipe '::erlang'
51+
#include_recipe '::erlang'
5252
include_recipe 'memcached'
5353
# TODO: Uncomment when cassandra works on Java 8 again
5454
# https://github.com/travis-ci/packer-templates/issues/589
@@ -84,3 +84,4 @@
8484
# HACK: force removal of ~/.pearrc until a decision is reached on if they are
8585
# good or bad
8686
execute 'rm -f /home/travis/.pearrc'
87+
include_recipe 'travis_build_environment::android-sdk'
Lines changed: 111 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,126 @@
1+
module ErlangHelper
2+
require 'chef/mixin/shell_out'
3+
include Chef::Mixin::ShellOut
4+
extend self
15

2-
# frozen_string_literal: true
6+
def direct_download_erlang
7+
if shell_out("which erl").exitstatus != 0
8+
Chef::Log.info("Trying direct download approach for Erlang...")
9+
shell_out!("mkdir -p /tmp/erlang_install")
10+
shell_out!(%{
11+
cd /tmp/erlang_install && \
12+
wget https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_25.0.3-1~ubuntu~focal_amd64.deb -O erlang.deb || \
13+
wget http://archive.ubuntu.com/ubuntu/pool/main/e/erlang/erlang-base_23.0.2+dfsg-1ubuntu1_amd64.deb -O erlang.deb
14+
})
15+
shell_out!("dpkg -i /tmp/erlang_install/erlang.deb || true")
16+
shell_out!("apt-get -f -y install")
17+
shell_out!("rm -rf /tmp/erlang_install")
18+
end
19+
end
320

4-
execute 'debug_wget_erlang_key' do
5-
command 'wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | tee /tmp/erlang_solutions.asc.debug'
6-
not_if { ::File.exist?('/etc/apt/trusted.gpg.d/erlang_solutions.gpg') }
21+
def install_erlang_from_source
22+
if shell_out("which erl").exitstatus != 0
23+
Chef::Log.info("Attempting to install Erlang from source...")
24+
shell_out!("apt-get install -y build-essential libncurses5-dev libssl-dev")
25+
shell_out!(%{
26+
cd /tmp && \
27+
wget https://github.com/erlang/otp/archive/OTP-24.0.tar.gz && \
28+
tar -xzf OTP-24.0.tar.gz && \
29+
cd otp-OTP-24.0 && \
30+
./configure --prefix=/usr/local --without-javac && \
31+
make -j$(nproc) && \
32+
make install
33+
})
34+
end
35+
end
736
end
837

9-
execute 'add_erlang_gpg_key' do
10-
command 'wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add - 2>&1 | tee /tmp/erlang_gpg_add.log'
11-
not_if { ::File.exist?('/etc/apt/trusted.gpg.d/erlang_solutions.gpg') }
38+
execute 'diagnose_filesystem_issues' do
39+
command <<-EOH
40+
echo "=== Filesystem Status ==="
41+
df -h
42+
echo "=== APT Cache Directory Permissions ==="
43+
ls -la /var/cache/apt/
44+
ls -la /var/cache/apt/archives/
45+
echo "=== Checking for stale apt/dpkg locks ==="
46+
lsof /var/lib/dpkg/lock* || echo "No locks found"
47+
lsof /var/lib/apt/lists/lock || echo "No lists lock found"
48+
lsof /var/cache/apt/archives/lock || echo "No archives lock found"
49+
50+
rm -f /var/lib/dpkg/lock*
51+
rm -f /var/lib/apt/lists/lock
52+
rm -f /var/cache/apt/archives/lock
53+
54+
rm -rf /var/cache/apt/archives/*
55+
mkdir -p /var/cache/apt/archives/partial
56+
chmod 755 /var/cache/apt/archives
57+
chmod 755 /var/cache/apt/archives/partial
58+
chown _apt:root /var/cache/apt/archives/partial
59+
EOH
60+
action :run
1261
end
1362

14-
execute 'debug_erlang_repo' do
15-
command 'echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | tee /tmp/erlang_repo.list.debug'
16-
not_if { ::File.exist?('/etc/apt/sources.list.d/rabbitmq.list') }
17-
end
63+
ruby_block 'cleanup_old_erlang_repos' do
64+
block do
65+
[
66+
'/etc/apt/sources.list.d/erlang.list',
67+
'/etc/apt/sources.list.d/erlang-solutions.list'
68+
].each do |file|
69+
File.delete(file) if File.exist?(file)
70+
end
1871

19-
execute 'add_erlang_repository' do
20-
command 'echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/rabbitmq.list 2>&1 | tee /tmp/erlang_repo_add.log'
21-
not_if { ::File.exist?('/etc/apt/sources.list.d/rabbitmq.list') }
72+
[
73+
'/usr/share/keyrings/erlang-solutions.gpg',
74+
'/usr/share/keyrings/erlang.gpg'
75+
].each do |key_file|
76+
File.delete(key_file) if File.exist?(key_file)
77+
end
78+
end
79+
action :run
2280
end
2381

24-
apt_update 'update_packages' do
25-
action :update
82+
execute 'switch_to_ubuntu_repos' do
83+
command <<-EOH
84+
apt-get clean
85+
apt-get update -q || true
86+
apt-get install -y erlang-base erlang-dev || true
87+
EOH
88+
action :run
2689
ignore_failure true
2790
end
2891

29-
package 'erlang' do
30-
action :install
31-
notifies :write, 'log[erlang_installed]', :immediately
92+
ruby_block 'direct_download_erlang' do
93+
block do
94+
ErlangHelper.direct_download_erlang
95+
end
96+
action :run
97+
end
98+
99+
ruby_block 'install_erlang_from_source' do
100+
block do
101+
ErlangHelper.install_erlang_from_source
102+
end
103+
action :run
104+
ignore_failure true
32105
end
33106

34-
log 'erlang_installed' do
35-
message 'Erlang package has been successfully installed.'
36-
level :info
37-
action :nothing
107+
execute 'verify_erlang_installation' do
108+
command <<-EOH
109+
if which erl > /dev/null 2>&1; then
110+
echo "Erlang was successfully installed:"
111+
erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
112+
else
113+
echo "Attempting one final approach - installing just the minimal set of packages"
114+
apt-get update -q
115+
apt-get install -y --no-install-recommends erlang-base erlang-crypto erlang-syntax-tools erlang-inets erlang-mnesia
116+
117+
if which erl > /dev/null 2>&1; then
118+
echo "Minimal Erlang installation successful"
119+
else
120+
echo "All installation attempts failed. Manual intervention needed."
121+
exit 1
122+
fi
123+
fi
124+
EOH
125+
action :run
38126
end

0 commit comments

Comments
 (0)