rails_pwnerer 0.6.64 → 0.6.65

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/CHANGELOG +2 -0
  2. data/LICENSE +0 -0
  3. data/Manifest +51 -49
  4. data/README +0 -0
  5. data/RUBYFORGE +0 -0
  6. data/Rakefile +7 -11
  7. data/ext/rpwn_setup_notice/extconf.rb +24 -16
  8. data/lib/{pwnage → rails_pwnerer}/app/cluster_config.rb +17 -17
  9. data/lib/{pwnage → rails_pwnerer}/app/config.rb +14 -14
  10. data/lib/{pwnage → rails_pwnerer}/app/db/mysql.rb +9 -9
  11. data/lib/{pwnage → rails_pwnerer}/app/files.rb +13 -13
  12. data/lib/{pwnage → rails_pwnerer}/app/gems.rb +3 -3
  13. data/lib/{pwnage → rails_pwnerer}/app/main.rb +4 -4
  14. data/lib/{pwnage → rails_pwnerer}/app/nginx_config.rb +7 -7
  15. data/lib/{pwnage → rails_pwnerer}/app/scripts.rb +4 -4
  16. data/lib/{pwnage → rails_pwnerer}/app/vcs/git.rb +9 -9
  17. data/lib/{pwnage → rails_pwnerer}/app/vcs/perforce.rb +11 -11
  18. data/lib/{pwnage → rails_pwnerer}/app/vcs/svn.rb +9 -9
  19. data/lib/{pwnage → rails_pwnerer}/base/atomics.rb +1 -1
  20. data/lib/{pwnage → rails_pwnerer}/base/cpus.rb +1 -1
  21. data/lib/{pwnage → rails_pwnerer}/base/dirs.rb +1 -1
  22. data/lib/{pwnage → rails_pwnerer}/base/gems.rb +2 -2
  23. data/lib/{pwnage → rails_pwnerer}/base/hostname.rb +1 -1
  24. data/lib/{pwnage → rails_pwnerer}/base/input.rb +1 -1
  25. data/lib/rails_pwnerer/base/packages.rb +272 -0
  26. data/lib/{pwnage → rails_pwnerer}/base/process.rb +1 -1
  27. data/lib/{pwnage → rails_pwnerer}/base/rails.rb +1 -1
  28. data/lib/{pwnage → rails_pwnerer}/base/startup.rb +1 -1
  29. data/lib/{pwnage → rails_pwnerer}/base.rb +1 -1
  30. data/lib/{pwnage → rails_pwnerer}/config/app.rb +1 -1
  31. data/lib/{pwnage → rails_pwnerer}/config/frontends.rb +1 -1
  32. data/lib/rails_pwnerer/config/main.rb +3 -0
  33. data/lib/{pwnage → rails_pwnerer}/config/paths.rb +1 -1
  34. data/lib/{pwnage → rails_pwnerer}/config/ports.rb +1 -1
  35. data/lib/{pwnage → rails_pwnerer}/config/repository.rb +7 -7
  36. data/lib/rails_pwnerer/ctl_executor.rb +19 -0
  37. data/lib/{pwnage → rails_pwnerer}/dev_executor.rb +2 -2
  38. data/lib/{pwnage → rails_pwnerer}/executor.rb +17 -17
  39. data/lib/{pwnage → rails_pwnerer}/scaffolds/config.rb +7 -7
  40. data/lib/{pwnage → rails_pwnerer}/scaffolds/dir_permissions.rb +4 -4
  41. data/lib/{pwnage → rails_pwnerer}/scaffolds/dirs.rb +3 -3
  42. data/lib/{pwnage → rails_pwnerer}/scaffolds/gems.rb +2 -2
  43. data/lib/{pwnage → rails_pwnerer}/scaffolds/hook_daemon.rb +2 -2
  44. data/lib/{pwnage → rails_pwnerer}/scaffolds/hook_dyndns.rb +3 -3
  45. data/lib/{pwnage → rails_pwnerer}/scaffolds/mysql_config.rb +2 -2
  46. data/lib/rails_pwnerer/scaffolds/packages.rb +118 -0
  47. data/lib/{pwnage → rails_pwnerer}/scaffolds/rubygems.rb +2 -2
  48. data/lib/{pwnage → rails_pwnerer}/scaffolds/sshd.rb +2 -2
  49. data/lib/{pwnage → rails_pwnerer}/util/kill_process_set.rb +1 -1
  50. data/lib/rails_pwnerer/util/main.rb +5 -0
  51. data/lib/rails_pwnerer.rb +52 -52
  52. data/rails_pwnerer.gemspec +17 -7
  53. data/test/base_package_test.rb +126 -0
  54. data/test/helper.rb +25 -0
  55. metadata +151 -107
  56. data/lib/pwnage/base/packages.rb +0 -159
  57. data/lib/pwnage/config/main.rb +0 -3
  58. data/lib/pwnage/ctl_executor.rb +0 -19
  59. data/lib/pwnage/scaffolds/packages.rb +0 -110
  60. data/lib/pwnage/util/main.rb +0 -5
@@ -0,0 +1,126 @@
1
+ require File.expand_path('../helper.rb', __FILE__)
2
+
3
+ class BasePackageTest < Test::Unit::TestCase
4
+ def setup
5
+ @base = BaseWrapper.new
6
+ end
7
+
8
+ def test_search_packages_with_string
9
+ packages = @base.search_packages 'ruby'
10
+ assert_operator packages, :has_key?, 'ruby1.8'
11
+ assert_operator packages, :has_key?, 'ruby-dev'
12
+ assert_match '1.8', packages['ruby1.8']
13
+ end
14
+
15
+ def test_search_packages_with_regexp
16
+ packages = @base.search_packages /ruby.*\-dev/
17
+ assert_operator packages, :has_key?, 'ruby1.8-dev'
18
+ assert_operator packages, :has_key?, 'ruby1.9-dev'
19
+ end
20
+
21
+ def test_best_package_matching
22
+ flexmock(@base).should_receive(:search_packages).with('libmagick++9-dev').
23
+ and_return({})
24
+ flexmock(@base).should_receive(:search_packages).with('libmagick9-dev').
25
+ and_return('first' => '9.1.9', 'libmagick9-dev' => '9.0.9')
26
+ patterns = ['libmagick++9-dev', 'libmagick9-dev']
27
+ golden = { :name => 'libmagick9-dev', :version => '9.0.9' }
28
+ assert_equal golden, @base.best_package_matching(patterns)
29
+ end
30
+
31
+ def test_best_package_matching_regexp
32
+ flexmock(@base).should_receive(:search_packages).with(/ruby\d+-dev/).
33
+ and_return('libruby18-dev' => '10.1.0',
34
+ 'ruby18-dev' => '1.8.6',
35
+ 'ruby187-dev' => '1.8.7')
36
+ patterns = /ruby\d+-dev/
37
+ golden = { :name => 'ruby187-dev', :version => '1.8.7' }
38
+ assert_equal golden, @base.best_package_matching(patterns)
39
+ end
40
+
41
+ def test_best_package_matching_nothing
42
+ flexmock(@base).should_receive(:search_packages).with('libmagick++9-dev').
43
+ and_return({})
44
+ flexmock(@base).should_receive(:search_packages).with('libmagick9-dev').
45
+ and_return({})
46
+ patterns = ['libmagick++9-dev', 'libmagick9-dev']
47
+ assert_nil @base.best_package_matching(patterns)
48
+ end
49
+
50
+ def test_with_package_source
51
+ package = 'nvidia-bl-dkms'
52
+ assert @base.search_packages(package).empty?,
53
+ "Found package that no test system should have (#{package})"
54
+
55
+ source = 'http://ppa.launchpad.net/mactel-support/ppa/ubuntu'
56
+ repos = ['lucid', 'main']
57
+ @base.with_package_source(source, repos) do
58
+ assert !(@base.search_packages(package).empty?),
59
+ "with_new_package_source didn't integrate the new source"
60
+ end
61
+
62
+ assert @base.search_packages(package).empty?,
63
+ "with_new_package_source didn't clean up after itself"
64
+ end
65
+
66
+ def test_update_package_metadata
67
+ command = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get update -qq -y"
68
+ flexmock(Kernel).should_receive(:system).with(command).and_return(true)
69
+ assert @base.update_package_metadata
70
+ end
71
+
72
+ def test_update_package_metadata_with_blocking_proxy
73
+ command = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get update -qq -y"
74
+ flexmock(Kernel).should_receive(:system).with(command).and_return(false)
75
+ command2 = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get update -qq -y -o Acquire::http::Proxy=false"
76
+ flexmock(Kernel).should_receive(:system).with(command2).and_return(true)
77
+ assert @base.update_package_metadata
78
+ end
79
+
80
+ def test_update_package_metadata_without_network
81
+ command = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get update -qq -y"
82
+ flexmock(Kernel).should_receive(:system).with(command).and_return(false)
83
+ command2 = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get update -qq -y -o Acquire::http::Proxy=false"
84
+ flexmock(Kernel).should_receive(:system).with(command2).and_return(false)
85
+ assert !@base.update_package_metadata
86
+ end
87
+
88
+ def test_install_package
89
+ command = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get install -qq -y hello"
90
+ flexmock(Kernel).should_receive(:system).with(command).and_return(true)
91
+ assert @base.install_package('hello')
92
+ end
93
+
94
+ def test_install_package_from_sources
95
+ c1 = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get build-dep -qq -y hello"
96
+ flexmock(Kernel).should_receive(:system).with(c1).and_return(true)
97
+ c2 = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get source -b -qq -y hello"
98
+ flexmock(Kernel).should_receive(:system).with(c2).and_return(true)
99
+ c3 = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes dpkg -i "
100
+ flexmock(Kernel).should_receive(:system).with(c3).and_return(true)
101
+ assert @base.install_package('hello', :source => true)
102
+ end
103
+
104
+ def test_remove_package
105
+ command = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get remove -qq -y hello"
106
+ flexmock(Kernel).should_receive(:system).with(command).and_return(true)
107
+ assert @base.remove_package('hello')
108
+ end
109
+
110
+ def test_install_remove_package_live
111
+ package = 'hello'
112
+ command = 'hello'
113
+
114
+ assert !Kernel.system(command), 'You have hello installed by default?!'
115
+ assert @base.install_package(package), 'Package install failed'
116
+ assert Kernel.system(command), "Package installation didn't do the job"
117
+ assert @base.remove_package(package), 'Package removal failed'
118
+ assert !Kernel.system(command), "Package removal didn't do the job"
119
+ end
120
+
121
+ def test_update_all_packages
122
+ command = "env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical DEBCONF_TERSE=yes apt-get upgrade -qq -y"
123
+ flexmock(Kernel).should_receive(:system).with(command).and_return(true)
124
+ assert @base.update_all_packages
125
+ end
126
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,25 @@
1
+ # Setup for all the tests.
2
+
3
+ require 'test/unit'
4
+ require 'rails_pwnerer'
5
+
6
+ require 'rubygems'
7
+ require 'flexmock/test_unit'
8
+
9
+
10
+ # Shell class for including RailsPwnerer::Base.
11
+ class BaseWrapper
12
+ include RailsPwnerer::Base
13
+ end
14
+
15
+
16
+ # Flexmock refuses to mock Kernel.` so we need to trick it.
17
+ module Kernel
18
+ class <<self
19
+ alias_method :backquote, "`"
20
+
21
+ def `(*args)
22
+ backquote(*args)
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_pwnerer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 135
4
+ hash: 133
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 64
10
- version: 0.6.64
9
+ - 65
10
+ version: 0.6.65
11
11
  platform: ruby
12
12
  authors:
13
13
  - Victor Costan
@@ -15,11 +15,52 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-30 00:00:00 -04:00
18
+ date: 2010-06-10 00:00:00 -04:00
19
19
  default_executable: bin/rpwn
20
- dependencies: []
21
-
22
- description: Rails deployment tool/hack.
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: echoe
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: fakefs
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: flexmock
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ version_requirements: *id003
63
+ description: Rails deployment hack.
23
64
  email: victor@costan.us
24
65
  executables:
25
66
  - rpwn
@@ -28,112 +69,114 @@ executables:
28
69
  extensions:
29
70
  - ext/rpwn_setup_notice/extconf.rb
30
71
  extra_rdoc_files:
31
- - bin/rpwn
32
- - bin/rpwnctl
33
- - bin/rpwndev
34
72
  - CHANGELOG
35
- - ext/rpwn_setup_notice/extconf.rb
36
- - lib/pwnage/app/cluster_config.rb
37
- - lib/pwnage/app/config.rb
38
- - lib/pwnage/app/db/mysql.rb
39
- - lib/pwnage/app/files.rb
40
- - lib/pwnage/app/gems.rb
41
- - lib/pwnage/app/main.rb
42
- - lib/pwnage/app/nginx_config.rb
43
- - lib/pwnage/app/scripts.rb
44
- - lib/pwnage/app/vcs/git.rb
45
- - lib/pwnage/app/vcs/perforce.rb
46
- - lib/pwnage/app/vcs/svn.rb
47
- - lib/pwnage/base/atomics.rb
48
- - lib/pwnage/base/cpus.rb
49
- - lib/pwnage/base/dirs.rb
50
- - lib/pwnage/base/gems.rb
51
- - lib/pwnage/base/hostname.rb
52
- - lib/pwnage/base/input.rb
53
- - lib/pwnage/base/packages.rb
54
- - lib/pwnage/base/process.rb
55
- - lib/pwnage/base/rails.rb
56
- - lib/pwnage/base/startup.rb
57
- - lib/pwnage/base.rb
58
- - lib/pwnage/config/app.rb
59
- - lib/pwnage/config/frontends.rb
60
- - lib/pwnage/config/main.rb
61
- - lib/pwnage/config/paths.rb
62
- - lib/pwnage/config/ports.rb
63
- - lib/pwnage/config/repository.rb
64
- - lib/pwnage/ctl_executor.rb
65
- - lib/pwnage/dev_executor.rb
66
- - lib/pwnage/executor.rb
67
- - lib/pwnage/scaffolds/config.rb
68
- - lib/pwnage/scaffolds/dir_permissions.rb
69
- - lib/pwnage/scaffolds/dirs.rb
70
- - lib/pwnage/scaffolds/gems.rb
71
- - lib/pwnage/scaffolds/hook_daemon.rb
72
- - lib/pwnage/scaffolds/hook_dyndns.rb
73
- - lib/pwnage/scaffolds/mysql_config.rb
74
- - lib/pwnage/scaffolds/packages.rb
75
- - lib/pwnage/scaffolds/rubygems.rb
76
- - lib/pwnage/scaffolds/sshd.rb
77
- - lib/pwnage/util/kill_process_set.rb
78
- - lib/pwnage/util/main.rb
79
- - lib/rails_pwnerer.rb
80
73
  - LICENSE
81
74
  - README
82
- files:
83
75
  - bin/rpwn
84
76
  - bin/rpwnctl
85
77
  - bin/rpwndev
86
- - CHANGELOG
87
78
  - ext/rpwn_setup_notice/extconf.rb
88
- - lib/pwnage/app/cluster_config.rb
89
- - lib/pwnage/app/config.rb
90
- - lib/pwnage/app/db/mysql.rb
91
- - lib/pwnage/app/files.rb
92
- - lib/pwnage/app/gems.rb
93
- - lib/pwnage/app/main.rb
94
- - lib/pwnage/app/nginx_config.rb
95
- - lib/pwnage/app/scripts.rb
96
- - lib/pwnage/app/vcs/git.rb
97
- - lib/pwnage/app/vcs/perforce.rb
98
- - lib/pwnage/app/vcs/svn.rb
99
- - lib/pwnage/base/atomics.rb
100
- - lib/pwnage/base/cpus.rb
101
- - lib/pwnage/base/dirs.rb
102
- - lib/pwnage/base/gems.rb
103
- - lib/pwnage/base/hostname.rb
104
- - lib/pwnage/base/input.rb
105
- - lib/pwnage/base/packages.rb
106
- - lib/pwnage/base/process.rb
107
- - lib/pwnage/base/rails.rb
108
- - lib/pwnage/base/startup.rb
109
- - lib/pwnage/base.rb
110
- - lib/pwnage/config/app.rb
111
- - lib/pwnage/config/frontends.rb
112
- - lib/pwnage/config/main.rb
113
- - lib/pwnage/config/paths.rb
114
- - lib/pwnage/config/ports.rb
115
- - lib/pwnage/config/repository.rb
116
- - lib/pwnage/ctl_executor.rb
117
- - lib/pwnage/dev_executor.rb
118
- - lib/pwnage/executor.rb
119
- - lib/pwnage/scaffolds/config.rb
120
- - lib/pwnage/scaffolds/dir_permissions.rb
121
- - lib/pwnage/scaffolds/dirs.rb
122
- - lib/pwnage/scaffolds/gems.rb
123
- - lib/pwnage/scaffolds/hook_daemon.rb
124
- - lib/pwnage/scaffolds/hook_dyndns.rb
125
- - lib/pwnage/scaffolds/mysql_config.rb
126
- - lib/pwnage/scaffolds/packages.rb
127
- - lib/pwnage/scaffolds/rubygems.rb
128
- - lib/pwnage/scaffolds/sshd.rb
129
- - lib/pwnage/util/kill_process_set.rb
130
- - lib/pwnage/util/main.rb
131
79
  - lib/rails_pwnerer.rb
80
+ - lib/rails_pwnerer/app/cluster_config.rb
81
+ - lib/rails_pwnerer/app/config.rb
82
+ - lib/rails_pwnerer/app/db/mysql.rb
83
+ - lib/rails_pwnerer/app/files.rb
84
+ - lib/rails_pwnerer/app/gems.rb
85
+ - lib/rails_pwnerer/app/main.rb
86
+ - lib/rails_pwnerer/app/nginx_config.rb
87
+ - lib/rails_pwnerer/app/scripts.rb
88
+ - lib/rails_pwnerer/app/vcs/git.rb
89
+ - lib/rails_pwnerer/app/vcs/perforce.rb
90
+ - lib/rails_pwnerer/app/vcs/svn.rb
91
+ - lib/rails_pwnerer/base.rb
92
+ - lib/rails_pwnerer/base/atomics.rb
93
+ - lib/rails_pwnerer/base/cpus.rb
94
+ - lib/rails_pwnerer/base/dirs.rb
95
+ - lib/rails_pwnerer/base/gems.rb
96
+ - lib/rails_pwnerer/base/hostname.rb
97
+ - lib/rails_pwnerer/base/input.rb
98
+ - lib/rails_pwnerer/base/packages.rb
99
+ - lib/rails_pwnerer/base/process.rb
100
+ - lib/rails_pwnerer/base/rails.rb
101
+ - lib/rails_pwnerer/base/startup.rb
102
+ - lib/rails_pwnerer/config/app.rb
103
+ - lib/rails_pwnerer/config/frontends.rb
104
+ - lib/rails_pwnerer/config/main.rb
105
+ - lib/rails_pwnerer/config/paths.rb
106
+ - lib/rails_pwnerer/config/ports.rb
107
+ - lib/rails_pwnerer/config/repository.rb
108
+ - lib/rails_pwnerer/ctl_executor.rb
109
+ - lib/rails_pwnerer/dev_executor.rb
110
+ - lib/rails_pwnerer/executor.rb
111
+ - lib/rails_pwnerer/scaffolds/config.rb
112
+ - lib/rails_pwnerer/scaffolds/dir_permissions.rb
113
+ - lib/rails_pwnerer/scaffolds/dirs.rb
114
+ - lib/rails_pwnerer/scaffolds/gems.rb
115
+ - lib/rails_pwnerer/scaffolds/hook_daemon.rb
116
+ - lib/rails_pwnerer/scaffolds/hook_dyndns.rb
117
+ - lib/rails_pwnerer/scaffolds/mysql_config.rb
118
+ - lib/rails_pwnerer/scaffolds/packages.rb
119
+ - lib/rails_pwnerer/scaffolds/rubygems.rb
120
+ - lib/rails_pwnerer/scaffolds/sshd.rb
121
+ - lib/rails_pwnerer/util/kill_process_set.rb
122
+ - lib/rails_pwnerer/util/main.rb
123
+ files:
124
+ - CHANGELOG
132
125
  - LICENSE
133
126
  - Manifest
134
- - Rakefile
135
127
  - README
136
128
  - RUBYFORGE
129
+ - Rakefile
130
+ - bin/rpwn
131
+ - bin/rpwnctl
132
+ - bin/rpwndev
133
+ - ext/rpwn_setup_notice/extconf.rb
134
+ - lib/rails_pwnerer.rb
135
+ - lib/rails_pwnerer/app/cluster_config.rb
136
+ - lib/rails_pwnerer/app/config.rb
137
+ - lib/rails_pwnerer/app/db/mysql.rb
138
+ - lib/rails_pwnerer/app/files.rb
139
+ - lib/rails_pwnerer/app/gems.rb
140
+ - lib/rails_pwnerer/app/main.rb
141
+ - lib/rails_pwnerer/app/nginx_config.rb
142
+ - lib/rails_pwnerer/app/scripts.rb
143
+ - lib/rails_pwnerer/app/vcs/git.rb
144
+ - lib/rails_pwnerer/app/vcs/perforce.rb
145
+ - lib/rails_pwnerer/app/vcs/svn.rb
146
+ - lib/rails_pwnerer/base.rb
147
+ - lib/rails_pwnerer/base/atomics.rb
148
+ - lib/rails_pwnerer/base/cpus.rb
149
+ - lib/rails_pwnerer/base/dirs.rb
150
+ - lib/rails_pwnerer/base/gems.rb
151
+ - lib/rails_pwnerer/base/hostname.rb
152
+ - lib/rails_pwnerer/base/input.rb
153
+ - lib/rails_pwnerer/base/packages.rb
154
+ - lib/rails_pwnerer/base/process.rb
155
+ - lib/rails_pwnerer/base/rails.rb
156
+ - lib/rails_pwnerer/base/startup.rb
157
+ - lib/rails_pwnerer/config/app.rb
158
+ - lib/rails_pwnerer/config/frontends.rb
159
+ - lib/rails_pwnerer/config/main.rb
160
+ - lib/rails_pwnerer/config/paths.rb
161
+ - lib/rails_pwnerer/config/ports.rb
162
+ - lib/rails_pwnerer/config/repository.rb
163
+ - lib/rails_pwnerer/ctl_executor.rb
164
+ - lib/rails_pwnerer/dev_executor.rb
165
+ - lib/rails_pwnerer/executor.rb
166
+ - lib/rails_pwnerer/scaffolds/config.rb
167
+ - lib/rails_pwnerer/scaffolds/dir_permissions.rb
168
+ - lib/rails_pwnerer/scaffolds/dirs.rb
169
+ - lib/rails_pwnerer/scaffolds/gems.rb
170
+ - lib/rails_pwnerer/scaffolds/hook_daemon.rb
171
+ - lib/rails_pwnerer/scaffolds/hook_dyndns.rb
172
+ - lib/rails_pwnerer/scaffolds/mysql_config.rb
173
+ - lib/rails_pwnerer/scaffolds/packages.rb
174
+ - lib/rails_pwnerer/scaffolds/rubygems.rb
175
+ - lib/rails_pwnerer/scaffolds/sshd.rb
176
+ - lib/rails_pwnerer/util/kill_process_set.rb
177
+ - lib/rails_pwnerer/util/main.rb
178
+ - test/base_package_test.rb
179
+ - test/helper.rb
137
180
  - rails_pwnerer.gemspec
138
181
  has_rdoc: true
139
182
  homepage: http://www.costan.us/rails_pwnage
@@ -164,16 +207,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
207
  requirements:
165
208
  - - ">="
166
209
  - !ruby/object:Gem::Version
167
- hash: 3
210
+ hash: 11
168
211
  segments:
169
- - 0
170
- version: "0"
212
+ - 1
213
+ - 2
214
+ version: "1.2"
171
215
  requirements: []
172
216
 
173
217
  rubyforge_project: rails-pwnage
174
218
  rubygems_version: 1.3.7
175
219
  signing_key:
176
220
  specification_version: 3
177
- summary: Rails deployment tool/hack.
178
- test_files: []
179
-
221
+ summary: Rails deployment hack.
222
+ test_files:
223
+ - test/base_package_test.rb
@@ -1,159 +0,0 @@
1
- # extends Base with OS package-related functions
2
-
3
- require 'English'
4
-
5
- module RailsPwnage::Base
6
- # TODO: this works for debian-only
7
-
8
- # Builds apt-get parameters for a set of options.
9
- def apt_params_for(options = {})
10
- # try to make debconf shut up for the general case
11
- # HACK: this getter has side-effects because it's used for
12
- # install_package_impl and update_package_impl, and they don't have
13
- # handy command-line flags for these options that we'd like
14
- ENV['DEBIAN_FRONTEND'] = 'noninteractive'
15
- ENV['DEBIAN_PRIORITY'] = 'critical'
16
- ENV['DEBCONF_TERSE'] = 'yes'
17
-
18
- params = ""
19
- params << "-o Acquire::http::Proxy=false" if options[:no_proxy]
20
- end
21
-
22
- def install_package_impl(package_name, options)
23
- apt_params = apt_params_for options
24
- if options[:source]
25
- with_temp_dir(:root => true) do
26
- Kernel.system "apt-get build-dep -y #{apt_params} #{package_name}"
27
- return false unless $CHILD_STATUS.success?
28
- Kernel.system "apt-get source -b #{apt_params} #{package_name}"
29
- return false unless $CHILD_STATUS.success?
30
- Kernel.system "dpkg -i #{Dir.glob('*.deb', File::FNM_DOTMATCH).join(' ')}"
31
- return false unless $CHILD_STATUS.success?
32
- end
33
- else
34
- Kernel.system "apt-get install -y #{apt_params} #{package_name}"
35
- return false unless $CHILD_STATUS.success?
36
- end
37
- return true
38
- end
39
-
40
- # Installs a package.
41
- # Returns true for success, false for failure.
42
- def install_package(package_name, options = {})
43
- return true if install_package_impl(package_name, options)
44
- if options[:source]
45
- if options[:no_proxy]
46
- # already bypassing proxy, fall back to binary package
47
- return install_package(package_name, options.merge(:source => false))
48
- else
49
- # try bypassing proxy
50
- return install_package(package_name, options.merge(:no_proxy => true))
51
- end
52
- else
53
- if options[:no_proxy]
54
- # out of alternatives
55
- return false
56
- else
57
- #
58
- return install_package(package_name, options.merge(:no_proxy => true))
59
- end
60
- end
61
- end
62
-
63
- def upgrade_package_impl(package_name, options)
64
- apt_params = apt_params_for options
65
- Kernel.system "apt-get upgrade -y #{apt_params} #{package_name.nil ? '' : package_name}"
66
- return $CHILD_STATUS.success?
67
- end
68
-
69
- # Upgrades a package to the latest version.
70
- def upgrade_package(package_name, options = {})
71
- return install_package(package_name, options) if options[:source]
72
- return true if upgrade_package_impl(package_name, options)
73
-
74
- if options[:no_proxy]
75
- # out of alternatives
76
- return false
77
- else
78
- #
79
- return upgrade_package(package_name, options.merge(:no_proxy => true))
80
- end
81
- end
82
-
83
- def upgrade_all_packages_impl(options)
84
- apt_params = apt_params_for options
85
- Kernel.system "apt-get upgrade -y #{apt_params} < /dev/null"
86
- return $CHILD_STATUS.success?
87
- end
88
-
89
- def upgrade_all_packages(options = {})
90
- return true if upgrade_all_packages_impl(options)
91
-
92
- if options[:no_proxy]
93
- # out of alternatives
94
- return false
95
- else
96
- #
97
- return upgrade_all_packages(options.merge(:no_proxy => true))
98
- end
99
- end
100
-
101
- def remove_package(package_name, options = {})
102
- system "apt-get remove -y #{package_name}" unless package_name.nil?
103
- end
104
-
105
- def update_package_metadata_impl(options)
106
- apt_params = apt_params_for options
107
- Kernel.system "apt-get update -y #{apt_params} < /dev/null"
108
- return $CHILD_STATUS.success?
109
- end
110
-
111
- # Updates the metadata for all the packages.
112
- # Returns true for success, false for failure.
113
- def update_package_metadata(options = {})
114
- return true if update_package_metadata_impl options
115
-
116
- if options[:no_proxy]
117
- # out of alternatives
118
- return false
119
- else
120
- # try bypassing proxy
121
- return update_package_metadata(options.merge(:no_proxy => true))
122
- end
123
- end
124
-
125
- # add a source to the package system
126
- def add_package_source(source_url, source_repos = [], options = {})
127
- source_prefix = options[:source] ? 'deb-src' : 'deb'
128
- source_patterns = [source_prefix, source_url] + source_repos
129
-
130
- # grab the sources
131
- sources = File.open('/etc/apt/sources.list', 'r') { |f| f.read }.split(/(\r|\n)+/)
132
-
133
- # see if the source we are trying to add is already there
134
- source_exists = sources.any? do |source_line|
135
- source_frags = source_line.split(' ')
136
- source_patterns.all? { |pattern| source_frags.any? { |frag| frag == pattern } }
137
- end
138
- return if source_exists
139
-
140
- # the source does exist, add it
141
- File.open('/etc/apt/sources.list', 'a') do |f|
142
- f.write "#{source_prefix} #{source_url} #{source_repos.join(' ')}\n"
143
- end
144
- end
145
- end
146
-
147
- module RailsPwnage::Base
148
- def install_packages(package_names, options = {})
149
- unroll_collection(package_names) { |n| install_package(n, options) }
150
- end
151
-
152
- def upgrade_packages(package_names, options = {})
153
- unroll_collection(package_names) { |n| upgrade_package(n, options) }
154
- end
155
-
156
- def remove_packages(package_names)
157
- unroll_collection(package_names) { |n| remove_package(n) }
158
- end
159
- end
@@ -1,3 +0,0 @@
1
- module RailsPwnage::Config
2
-
3
- end
@@ -1,19 +0,0 @@
1
- class RailsPwnage::CtlExecutor
2
- # standalone runner
3
- def run(args)
4
- case args[0]
5
- when 'start'
6
- RailsPwnage::App::ClusterConfig.new.control_all :start
7
- when 'stop'
8
- RailsPwnage::App::ClusterConfig.new.control_all :stop
9
- when 'restart'
10
- RailsPwnage::App::ClusterConfig.new.control_all :stop
11
- RailsPwnage::App::ClusterConfig.new.control_all :start
12
- when 'reload'
13
- RailsPwnage::App::ClusterConfig.new.control_all :stop
14
- RailsPwnage::App::ClusterConfig.new.control_all :start
15
- else
16
- print "Unrecognized command #{args[0]}\n"
17
- end
18
- end
19
- end