devinstall 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51f4ddcf8ee4cb1806c0ee407aa1c6e582c7088c
4
- data.tar.gz: 7317bd32282391c568339f534e23bd485bbf02b4
3
+ metadata.gz: 787f87b759b55152d2289690d13d252750959d10
4
+ data.tar.gz: 2c7c82ab18b1a35b10e8ab1ad0843621c0e6b1ba
5
5
  SHA512:
6
- metadata.gz: 8ac955e8f47abcfcf93f2ad3351ef78125d8d7e68b898ff4ff5812473fcf2fd3c159a35d4e576d04336b54630c52166b92efe7904fc9855f3884869753756b06
7
- data.tar.gz: ae05a8d213cf8570eeb9c7a4016de3dbe31f39da88e1db182d6a187b339e81c8cb4699577983ea3c77348adef9944a35ef5a2d8018764c0a5861a3b7b7182b06
6
+ metadata.gz: 3da99d23d6bb38aac0a04839082e771df2aa69c819d4bd067ce32a9b6827c08a9dd796c3f677b1af7d4f07fbf2864808b9a63334d05422bc64bce4f0be3a89ae
7
+ data.tar.gz: f4f01fb943d21cbe1e15b28c97fec5bafa5b38ecc44b35af6145a61cb4e5ceeeb3e0c36ca29d5c1e9d1d82308fe6ec0ca437ca4cdadb07a25d26a6adce216daa
data/bin/pkg-tool CHANGED
@@ -6,7 +6,8 @@ command = ARGV.shift
6
6
 
7
7
  unless %w"build install upload help version test".include? command
8
8
  puts "Unknown command #{command}"
9
- exit 1
9
+ exit! 1
10
10
  end
11
- cli=Cli.new
11
+ cli=Devinstall::Cli.new
12
12
  cli.send(command.to_sym)
13
+
@@ -20,13 +20,18 @@ module Devinstall
20
20
  ['--package', '-p', Getopt::REQUIRED],
21
21
  ['--config', '-c', Getopt::REQUIRED],
22
22
  ['--type', '-t', Getopt::REQUIRED],
23
- ['--env', '-e', Getopt::REQUIRED],
23
+ ['--env','-e', Getopt::REQUIRED],
24
+ ['--verbose', '-v'],
25
+ ['--dry-run', '-d'],
24
26
  )
25
27
  rescue
26
28
  puts 'Invalid option in command line'
27
29
  help
28
30
  exit! 1
29
31
  end
32
+ #verbose and dry-run
33
+ $verbose ||= @opt['verbose']
34
+ $dry ||= @opt['dry-run']
30
35
  # get config file
31
36
  unless get_config(["./devinstall.yml"])
32
37
  puts 'You must specify the config file'
@@ -50,7 +55,7 @@ module Devinstall
50
55
  def version
51
56
  puts "devinstall version #{Devinstall::VERSION}"
52
57
  puts "pkg-tool version #{Devinstall::VERSION}"
53
- exit(0)
58
+ exit! 0
54
59
  end
55
60
 
56
61
  def help
@@ -65,18 +70,18 @@ module Devinstall
65
70
  end
66
71
 
67
72
  def install
68
- package.build(@opt['type'].to_sym)
69
- package.install(@opt['env'].to_sym)
73
+ @package.build(@opt['type'].to_sym)
74
+ @package.install(@opt['env'].to_sym)
70
75
  end
71
76
 
72
77
  def upload
73
- package.build(@opt['type'].to_sym)
74
- package.run_tests(@opt['env'].to_sym)
75
- package.upload(@opt['env'].to_sym)
78
+ @package.build(@opt['type'].to_sym)
79
+ @package.run_tests(@opt['env'].to_sym)
80
+ @package.upload(@opt['env'].to_sym)
76
81
  end
77
82
 
78
83
  def test
79
- package.run_tests(@opt['env'].to_sym)
84
+ @package.run_tests(@opt['env'].to_sym)
80
85
  end
81
86
 
82
87
  end
@@ -0,0 +1,23 @@
1
+ module Utils
2
+
3
+ def command(cmd)
4
+ puts cmd if $verbose
5
+ ret=''
6
+ unless $dry
7
+ ret = `#{cmd}` unless $dry
8
+ if $?.exitstatus != 0 ## return failure
9
+ puts "While executing:"
10
+ puts cmd
11
+ puts "The command failed with exitstatus $?.exitstatus"
12
+ puts "Full output of command follows"
13
+ puts "="*40
14
+ puts ret
15
+ puts "Nothing to do. Aborting!"
16
+ exit! 1
17
+ end
18
+ end
19
+ ret
20
+ end
21
+
22
+
23
+ end #module
@@ -1,3 +1,3 @@
1
1
  module Devinstall
2
- VERSION = '0.2.3' # first test
2
+ VERSION = '0.2.5' # Small bugfixes
3
3
  end
data/lib/devinstall.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'devinstall/version'
2
2
  require 'devinstall/deep_symbolize'
3
+ require 'devinstall/utils'
3
4
  require 'devinstall/settings' ## in near future we will have to abandon Settings
4
5
  # for something more complex because we will need to
5
6
  # define things (repos/install-hosts) for different
@@ -10,6 +11,8 @@ module Devinstall
10
11
 
11
12
  class Pkg
12
13
 
14
+ include Utils
15
+
13
16
  # @param [Symbol] type
14
17
  def get_version(type)
15
18
  if type == :deb
@@ -43,13 +46,18 @@ module Devinstall
43
46
  def upload (env)
44
47
  scp = Settings.base[:scp]
45
48
  repo = {}
46
- type = Settings.repos[:environments][env][:type]
49
+ type = Settings.repos[:environments][env][:type].to_sym
47
50
  [:user, :host, :folder].each do |k|
48
- fail("Unexistent key repos:#{environment}:#{k}") unless Settings.repos[:environments][env].has_key?(k)
51
+ unless Settings.repos[:environments][env].has_key?(k)
52
+ puts "Unexistent key #{k} in repos:environments:#{env}"
53
+ puts "Aborting"
54
+ exit! 1
55
+ end
49
56
  repo[k] = Settings.repos[:environments][env][k]
50
57
  end
51
- @package_files[type].each do |p|
52
- system("#{scp} #{Settings.local[:temp]}/#{p} #{repo[:user]}@#{repo[:host]}:#{repo[:folder]}")
58
+ @package_files[type].each do |p,f|
59
+ puts "Uploading #{f}\t\t[#{p}] to $#{repo[:host]}"
60
+ command("#{scp} #{Settings.local[:temp]}/#{f} #{repo[:user]}@#{repo[:host]}:#{repo[:folder]}")
53
61
  end
54
62
  end
55
63
 
@@ -65,6 +73,7 @@ module Devinstall
65
73
  [:user, :host, :folder, :target].each do |k|
66
74
  unless Settings.build.has_key? k
67
75
  puts "Undefined key 'build:#{k.to_s}:'"
76
+ puts "Aborting!"
68
77
  exit! 1
69
78
  end
70
79
  build[k] = Settings.build[k]
@@ -82,20 +91,10 @@ module Devinstall
82
91
  gsub('%T', type.to_s)
83
92
 
84
93
  upload_sources("#{local_folder}/", "#{build[:user]}@#{build[:host]}:#{build[:folder]}")
85
- res = system("#{ssh} #{build[:user]}@#{build[:host]} \"#{build_command}\"")
86
- unless res
87
- puts 'Build error'
88
- puts 'Aborting!'
89
- exit! 1
90
- end
94
+ command("#{ssh} #{build[:user]}@#{build[:host]} \"#{build_command}\"")
91
95
  @package_files[type].each do |p, t|
92
96
  puts "Receiving target #{p.to_s} for #{t.to_s}"
93
- res = system("#{rsync} -az #{build[:user]}@#{build[:host]}:#{build[:target]}/#{t} #{local_temp}")
94
- unless res
95
- puts 'File downloading error'
96
- puts 'Aborting!'
97
- exit! 1
98
- end
97
+ command("#{rsync} -az #{build[:user]}@#{build[:host]}:#{build[:target]}/#{t} #{local_temp}")
99
98
  end
100
99
  end
101
100
 
@@ -104,7 +103,7 @@ module Devinstall
104
103
  test = {}
105
104
  [:user, :machine, :command, :folder].each do |k|
106
105
  unless Settings.tests[env].has_key? k
107
- puts("Undefined key 'tests:#{environment}:#{k.to_s}:'")
106
+ puts("Undefined key 'tests:#{env}:#{k.to_s}:'")
108
107
  exit! 1
109
108
  end
110
109
  test[k] = Settings.tests[env][k]
@@ -119,13 +118,9 @@ module Devinstall
119
118
 
120
119
  upload_sources("#{local_folder}/", "#{test[:user]}@#{test[:machine]}:#{test[:folder]}") # upload them to the test machine
121
120
 
122
- puts "Running all tests for the #{environment} environment"
123
- puts "This will take some time"
124
- ret = system("#{ssh} #{test[:user]}@#{test[:machine]} \"#{test[:command]}\"")
125
- if ret
126
- puts "Errors during test. Aborting current procedure"
127
- exit! 1
128
- end
121
+ puts "Running all tests for the #{env} environment"
122
+ puts "This will take some time and you have no output"
123
+ command("#{ssh} #{test[:user]}@#{test[:machine]} \"#{test[:command]}\"")
129
124
  rescue => ee
130
125
  puts "Unknown exception during parsing config file"
131
126
  puts "Aborting (#{ee})"
@@ -148,8 +143,8 @@ module Devinstall
148
143
  end
149
144
  case type
150
145
  when :deb
151
- system("#{scp} #{local_temp}/#{@package_files[type][:deb]} #{install[:user]}@#{install[:host]}:#{install[:folder]}")
152
- system("#{sudo} #{Settings.build[:user]}@#{Settings.build[:host]} /usr/bin/dpkg -i '#{install[:folder]}/#{@package_files[type][:deb]}'")
146
+ command("#{scp} #{local_temp}/#{@package_files[type][:deb]} #{install[:user]}@#{install[:host]}:#{install[:folder]}")
147
+ command("#{sudo} #{install[:user]}@#{install[:host]} /usr/bin/dpkg -i #{install[:folder]}/#{@package_files[type][:deb]}")
153
148
  else
154
149
  puts "unknown package type '#{type.to_s}'"
155
150
  exit! 1
@@ -158,13 +153,7 @@ module Devinstall
158
153
 
159
154
  def upload_sources (source, dest)
160
155
  rsync = Settings.base[:rsync]
161
- res = system("#{rsync} -az #{source} #{dest}")
162
- unless res
163
- puts "Rsync error"
164
- puts "Aborting!"
165
- exit! 1
166
- end
167
- res
156
+ command("#{rsync} -az #{source} #{dest}")
168
157
  end
169
158
  end
170
159
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devinstall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dragos Boca
@@ -61,16 +61,6 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - .gitignore
64
- - .idea/codeStyleSettings.xml
65
- - .idea/devinstall.iml
66
- - .idea/dictionaries/dragos.xml
67
- - .idea/encodings.xml
68
- - .idea/inspectionProfiles/Project_Default.xml
69
- - .idea/inspectionProfiles/profiles_settings.xml
70
- - .idea/misc.xml
71
- - .idea/modules.xml
72
- - .idea/scopes/scope_settings.xml
73
- - .idea/vcs.xml
74
64
  - Gemfile
75
65
  - LICENSE.txt
76
66
  - README
@@ -83,6 +73,7 @@ files:
83
73
  - lib/devinstall/cli.rb
84
74
  - lib/devinstall/deep_symbolize.rb
85
75
  - lib/devinstall/settings.rb
76
+ - lib/devinstall/utils.rb
86
77
  - lib/devinstall/version.rb
87
78
  homepage: http://github.com/dboca/devinstall
88
79
  licenses:
@@ -1,13 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectCodeStyleSettingsManager">
4
- <option name="PER_PROJECT_SETTINGS">
5
- <value>
6
- <XML>
7
- <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
8
- </XML>
9
- </value>
10
- </option>
11
- </component>
12
- </project>
13
-
data/.idea/devinstall.iml DELETED
@@ -1,23 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="FacetManager">
4
- <facet type="gem" name="Gem">
5
- <configuration>
6
- <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
- <option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
8
- <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
- </configuration>
10
- </facet>
11
- </component>
12
- <component name="NewModuleRootManager">
13
- <content url="file://$MODULE_DIR$">
14
- <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
15
- </content>
16
- <orderEntry type="inheritedJdk" />
17
- <orderEntry type="sourceFolder" forTests="false" />
18
- <orderEntry type="library" scope="PROVIDED" name="bundler (v1.3.4, RVM: ruby-2.0.0-p0) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="getopt (v1.4.1, RVM: ruby-2.0.0-p0) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="rake (v10.0.3, RVM: ruby-2.0.0-p0) [gem]" level="application" />
21
- </component>
22
- </module>
23
-
@@ -1,3 +0,0 @@
1
- <component name="ProjectDictionaryState">
2
- <dictionary name="dragos" />
3
- </component>
data/.idea/encodings.xml DELETED
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
- </project>
5
-
@@ -1,11 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0" is_locked="false">
3
- <option name="myName" value="Project Default" />
4
- <option name="myLocal" value="false" />
5
- <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
6
- <option name="processCode" value="true" />
7
- <option name="processLiterals" value="true" />
8
- <option name="processComments" value="true" />
9
- </inspection_tool>
10
- </profile>
11
- </component>
@@ -1,7 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <settings>
3
- <option name="PROJECT_PROFILE" value="Project Default" />
4
- <option name="USE_PROJECT_PROFILE" value="true" />
5
- <version value="1.0" />
6
- </settings>
7
- </component>
data/.idea/misc.xml DELETED
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.0.0-p0" project-jdk-type="RUBY_SDK" />
4
- </project>
5
-
data/.idea/modules.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/devinstall.iml" filepath="$PROJECT_DIR$/.idea/devinstall.iml" />
6
- </modules>
7
- </component>
8
- </project>
9
-
@@ -1,5 +0,0 @@
1
- <component name="DependencyValidationManager">
2
- <state>
3
- <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
- </state>
5
- </component>
data/.idea/vcs.xml DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
7
-