This repository was archived by the owner on Feb 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +34
-21
lines changed Expand file tree Collapse file tree 4 files changed +34
-21
lines changed Original file line number Diff line number Diff line change 53
53
}
54
54
}
55
55
56
- case $::kernel {
57
- ' Darwin' : {}
58
- default: {
59
- ensure_packages([' expect' ])
60
- Package[' expect' ] -> Exec[" update-android-package-${title} " ]
61
- }
62
- }
63
-
64
56
file { "${android::installdir}/expect-install-${title}" :
65
57
content => template (" android/expect-script.erb" ),
58
+ mode => ' 0755' ,
66
59
} ->
67
60
exec { "update-android-package-${title}" :
68
- command => " /usr/bin/expect -f ${android::installdir} /expect-install-${title} " ,
61
+ command => " ${android::installdir} /expect-install-${title} " ,
69
62
creates => $creates ,
70
63
timeout => 0,
71
64
require => [Class[' android::sdk' ]],
Original file line number Diff line number Diff line change 20
20
it { should contain_file ( "#{ dir } /expect-install-platform-tools" )
21
21
. with_content ( /android update sdk -u --all -t platform-tools/ ) }
22
22
it { should contain_exec ( 'update-android-package-platform-tools' )
23
- . with_command ( "/usr/bin/expect -f #{ dir } /expect-install-platform-tools" ) }
23
+ . with_command ( "#{ dir } /expect-install-platform-tools" ) }
24
24
25
25
it { should contain_file ( dir ) . with ( { :owner => 'root' , :group => 'root' } ) }
26
26
it { should contain_exec ( 'unpack-androidsdk' ) . with ( { :cwd => dir , :user => 'root' } ) }
47
47
it { should contain_file ( "#{ dir } /expect-install-platform-tools" )
48
48
. with_content ( /android update sdk -u --all -t platform-tools --proxy-host myhost --proxy-port 1234/ ) }
49
49
it { should contain_exec ( 'update-android-package-platform-tools' )
50
- . with_command ( "/usr/bin/expect -f #{ dir } /expect-install-platform-tools" ) }
50
+ . with_command ( "#{ dir } /expect-install-platform-tools" ) }
51
51
end
52
52
53
53
context 'with installdir' , :compile do
100
100
it { should contain_file ( "#{ dir } /expect-install-platform-tools" )
101
101
. with_content ( /android update sdk -u --all -t platform-tools --proxy-host myhost --proxy-port 1234/ ) }
102
102
it { should contain_exec ( 'update-android-package-platform-tools' )
103
- . with_command ( "/usr/bin/expect -f #{ dir } /expect-install-platform-tools" ) }
103
+ . with_command ( "#{ dir } /expect-install-platform-tools" ) }
104
104
105
105
it { should contain_file ( dir ) . with ( { :owner => 'root' , :group => 'admin' } ) }
106
106
it { should contain_exec ( 'unpack-androidsdk' ) . with ( { :cwd => dir , :user => 'root' } ) }
Original file line number Diff line number Diff line change 10
10
it { should contain_file ( "#{ dir } /expect-install-android-15" )
11
11
. with_content ( /android update sdk -u --all -t android-15/ ) }
12
12
it { should contain_exec ( 'update-android-package-android-15' ) . with ( {
13
- :command => "/usr/bin/expect -f #{ dir } /expect-install-android-15" ,
13
+ :command => "#{ dir } /expect-install-android-15" ,
14
14
:creates => "#{ dir } /android-sdk-linux/platforms/android-15" ,
15
15
} ) }
16
16
end
34
34
let ( :params ) { { :type => 'platform' } }
35
35
it { should contain_file ( "#{ dir } /expect-install-android-15" ) . with_content ( /android update sdk -u --all -t android-15/ ) }
36
36
it { should contain_exec ( 'update-android-package-android-15' ) . with ( {
37
- :command => "/usr/bin/expect -f #{ dir } /expect-install-android-15" ,
37
+ :command => "#{ dir } /expect-install-android-15" ,
38
38
:creates => "#{ dir } /android-sdk-macosx/platforms/android-15" ,
39
39
} ) }
40
40
end
Original file line number Diff line number Diff line change 1
- set timeout -1;
2
- spawn <%= scope.lookupvar('android::paths::sdk_home') %> /tools/android update sdk -u --all -t <%= @title %> <%= @proxy_host %> <%= @proxy_port %> ;
3
- expect {
4
- "Do you accept the license" { exp_send "y\r" ; exp_continue }
5
- "Error: Ignoring unknown package" { exit 1 }
6
- eof
7
- }
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pty'
4
+ require 'expect'
5
+
6
+ command = "<%= scope.lookupvar('android::paths::sdk_home') %>/tools/android update sdk -u --all -t <%= @title %> <%= @proxy_host %> <%= @proxy_port %>"
7
+ match = %r/^\s *Do you accept the license .* \[ y\/ n\] :\s */
8
+ response = "y"
9
+
10
+ puts command
11
+
12
+ PTY . spawn ( command ) do |r , w , p |
13
+
14
+ w . sync = true
15
+
16
+ begin
17
+ while true do
18
+ r . expect ( match )
19
+ sleep ( 0.1 )
20
+ w . puts ( response )
21
+ end
22
+ rescue Errno ::EIO , PTY ::ChildExited
23
+ end
24
+ end
25
+
26
+ exit
27
+ # vim: set ts=2 sw=2 tw=0 et:
You can’t perform that action at this time.
0 commit comments