origen_updater 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22a2000f0e9389ed2f408708e5ad0f72cfa6186c
4
- data.tar.gz: 6d2f0410c262f3fdfc58f3201b885592b5ad782e
3
+ metadata.gz: f207701accc963a830a6e1434b4cce3f127819bc
4
+ data.tar.gz: 58de6275daf1f7d8e470c4ddb1ea3bc9f5a6ed65
5
5
  SHA512:
6
- metadata.gz: 906ddd63491534139aa3d32349af5d10db238ba4f1ebbaf2a31718bf67a431eed536c872db2ddbd318cffd626aa9ac0337ef38f551776c6a358113c6274da36e
7
- data.tar.gz: 321db3e7048916b77ca8fcef3213ff1bbffc5b4dfd96b77f0be8bac2a0da7c7b7d6412dd92b00e8b6e1accc703666907b78d7acd884d07026636787b09a0cdd6
6
+ metadata.gz: b5aa8946acd330747e3cb9e394fecc8ae3eda974c14e174d1c9a581b667730e65e8bafdcbd4f6f6002e83b6dc86b3a73a5ea10a82f7f3d86496a50fa2144e9e5
7
+ data.tar.gz: 6a36803945b5ae7e08f649aa89ab4a3fbb3dc6cc001517cb522a59c7d5b9ffc6029b3eb9e164e88ed364d159dac081dc347f06d938780a6f86292123a3f9f980
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env ruby
2
+ $VERBOSE = nil # Don't care about world writable dir warnings and the like
3
+
4
+ if $_fix_my_workspace_version_check
5
+ $_fix_my_workspace_version = '0.3.0'
6
+ else
7
+ require 'origen'
8
+
9
+ if !Origen.site_config.gem_manage_bundler
10
+ puts 'Sorry but you have opted to manage Bundler yourself via your Origen site config, and this means'
11
+ puts 'that I cannot make certain assumptions about how your workspace is configured.'
12
+ puts 'You will need to either resolve this problem yourself, or else change the value of'
13
+ puts 'gem_mange_bundler to true.'
14
+ puts 'See here for more details on how to do that: http://origen-sdk.org/origen/guides/starting/company/'
15
+
16
+ else
17
+ ENV['BUNDLE_GEMFILE'] = File.join(Origen.root, 'Gemfile')
18
+ ENV['BUNDLE_PATH'] = File.expand_path(Origen.site_config.gem_install_dir)
19
+ ENV['BUNDLE_BIN'] = File.join(Origen.root, 'lbin')
20
+
21
+ # Force copy system gems to local gems
22
+ if Origen.site_config.gem_use_from_system
23
+ local_gem_dir = "#{ENV['BUNDLE_PATH']}/ruby/#{Pathname.new(Gem.dir).basename}"
24
+ gem_dir = Pathname.new(Gem.dir)
25
+
26
+ Origen.site_config.gem_use_from_system.each do |gem, version|
27
+ begin
28
+ # This will raise an error if the system doesn't have this gem installed, that
29
+ # will be rescued below
30
+ spec = Gem::Specification.find_by_name(gem, version)
31
+
32
+ local_dir = File.join(local_gem_dir, Pathname.new(spec.gem_dir).relative_path_from(gem_dir))
33
+ FileUtils.mkdir_p local_dir
34
+ FileUtils.cp_r(spec.gem_dir, local_dir)
35
+
36
+ local_file = Pathname.new(File.join(local_gem_dir, Pathname.new(spec.cache_file).relative_path_from(gem_dir)))
37
+ FileUtils.mkdir_p local_file.dirname
38
+ FileUtils.cp(spec.cache_file, local_file)
39
+
40
+ if spec.extension_dir && File.exist?(spec.extension_dir)
41
+ local_dir = File.join(local_gem_dir, Pathname.new(spec.extension_dir).relative_path_from(gem_dir))
42
+ FileUtils.mkdir_p local_dir
43
+ FileUtils.cp_r(spec.extension_dir, local_dir)
44
+ end
45
+
46
+ local_file = Pathname.new(File.join(local_gem_dir, Pathname.new(spec.spec_file).relative_path_from(gem_dir)))
47
+ FileUtils.mkdir_p local_file.dirname
48
+ FileUtils.cp(spec.spec_file, local_file)
49
+
50
+ rescue Gem::LoadError
51
+ # This just means that one of the gems that should be copied from the system
52
+ # was not actually installed in the system, so nothing we can do about that here
53
+ end
54
+ end
55
+ end
56
+
57
+ # Delete lbin
58
+ FileUtils.rm_rf(ENV['BUNDLE_BIN']) if File.exist?(ENV['BUNDLE_BIN'])
59
+
60
+ # Run bundler with correct switches
61
+ cmd = "bundle install --gemfile #{ENV['BUNDLE_GEMFILE']} --binstubs #{ENV['BUNDLE_BIN']} --path #{ENV['BUNDLE_PATH']}"
62
+ `chmod o-w #{Origen.root}` # Stops some annoying world writable warnings during install
63
+ `chmod o-w #{Origen.root}/bin` if File.exist?("#{Origen.root}/bin")
64
+ `chmod o-w #{Origen.root}/.bin` if File.exist?("#{Origen.root}/.bin")
65
+
66
+ # Try again, this time updating the bundle
67
+ if system(cmd)
68
+ fixed = true
69
+ elsif system 'bundle update'
70
+ fixed = true
71
+ end
72
+
73
+ `chmod o-w #{ENV['BUNDLE_BIN']}` if File.exist?(ENV['BUNDLE_BIN'])
74
+
75
+ system 'origen -v' if fixed
76
+
77
+ end
78
+ end
@@ -1,94 +1,101 @@
1
1
  require 'origen'
2
2
  class OrigenUpdaterApplication < Origen::Application
3
-
4
3
  # See http://origen-sdk.org/origen/api/Origen/Application/Configuration.html
5
4
  # for a full list of the configuration options available
6
5
 
7
6
  # These attributes should never be changed, the duplication here will be resolved in future
8
7
  # by condensing these attributes that do similar things
9
- self.name = "origen_updater"
10
- self.namespace = "OrigenUpdater"
11
- config.name = "origen_updater"
12
- config.initials = "OrigenUpdater"
13
- config.rc_url = "git@github.com:Origen-SDK/origen_updater.git"
8
+ self.name = 'origen_updater'
9
+ self.namespace = 'OrigenUpdater'
10
+ config.name = 'origen_updater'
11
+ config.initials = 'OrigenUpdater'
12
+ config.rc_url = 'git@github.com:Origen-SDK/origen_updater.git'
14
13
  config.release_externally = true
15
14
 
16
15
  # To enable deployment of your documentation to a web server (via the 'origen web'
17
16
  # command) fill in these attributes.
18
- #config.web_directory = "git@github.com:Origen-SDK/Origen-SDK.github.io.git/origen_updater"
19
- #config.web_domain = "http://origen-sdk.org/origen_updater"
17
+ # config.web_directory = "git@github.com:Origen-SDK/Origen-SDK.github.io.git/origen_updater"
18
+ # config.web_domain = "http://origen-sdk.org/origen_updater"
20
19
 
21
20
  # When false Origen will be less strict about checking for some common coding errors,
22
21
  # it is recommended that you leave this to true for better feedback and easier debug.
23
22
  # This will be the default setting in Origen v3.
24
23
  config.strict_errors = true
25
24
 
26
- config.shared = {
27
- command_launcher: "config/shared_commands.rb"
28
- }
29
-
30
25
  # See: http://origen-sdk.org/origen/latest/guides/utilities/lint/
31
26
  config.lint_test = {
32
27
  # Require the lint tests to pass before allowing a release to proceed
33
- run_on_tag: true,
28
+ run_on_tag: true,
34
29
  # Auto correct violations where possible whenever 'origen lint' is run
35
- auto_correct: true,
30
+ auto_correct: true,
36
31
  # Limit the testing for large legacy applications
37
- #level: :easy,
32
+ # level: :easy,
38
33
  # Run on these directories/files by default
39
- #files: ["lib", "config/application.rb"],
34
+ files: ['lib', 'config/application.rb', 'bin']
40
35
  }
41
36
 
42
37
  config.semantically_version = true
43
38
 
39
+ def before_release_tag(identifier, note, type, selector, options)
40
+ v = Origen::VersionString.new(identifier)
41
+ # Update the version in the command files
42
+ f = "#{Origen.root}/bin/fix_my_workspace"
43
+ data = File.read(f)
44
+ filtered_data = data.sub(/\$_fix_my_workspace_version = '\d+\.\d+\.\d+'/, "$_fix_my_workspace_version = '#{v}'")
45
+ File.open(f, 'w') do |f|
46
+ f.write(filtered_data)
47
+ end
48
+ Origen.app.rc.checkin f, comment: 'Wrote new version in command code'
49
+ end
50
+
44
51
  # An example of how to set application specific LSF parameters
45
- #config.lsf.project = "msg.te"
46
-
52
+ # config.lsf.project = "msg.te"
53
+
47
54
  # An example of how to specify a prefix to add to all generated patterns
48
- #config.pattern_prefix = "nvm"
55
+ # config.pattern_prefix = "nvm"
49
56
 
50
57
  # An example of how to add header comments to all generated patterns
51
- #config.pattern_header do
58
+ # config.pattern_header do
52
59
  # cc "This is a pattern created by the example origen application"
53
- #end
60
+ # end
54
61
 
55
62
  # By default all generated output will end up in ./output.
56
63
  # Here you can specify an alternative directory entirely, or make it dynamic such that
57
- # the output ends up in a setup specific directory.
58
- #config.output_directory do
64
+ # the output ends up in a setup specific directory.
65
+ # config.output_directory do
59
66
  # "#{Origen.root}/output/#{$dut.class}"
60
- #end
67
+ # end
61
68
 
62
69
  # Similarly for the reference files, generally you want to setup the reference directory
63
70
  # structure to mirror that of your output directory structure.
64
- #config.reference_directory do
71
+ # config.reference_directory do
65
72
  # "#{Origen.root}/.ref/#{$dut.class}"
66
- #end
67
-
73
+ # end
74
+
68
75
  # This will automatically deploy your documentation after every tag
69
- #def after_release_email(tag, note, type, selector, options)
76
+ # def after_release_email(tag, note, type, selector, options)
70
77
  # command = "origen web compile --remote --api"
71
78
  # Dir.chdir Origen.root do
72
79
  # system command
73
80
  # end
74
- #end
81
+ # end
75
82
 
76
83
  # Ensure that all tests pass before allowing a release to continue
77
- #def validate_release
84
+ # def validate_release
78
85
  # if !system("origen specs") || !system("origen examples")
79
86
  # puts "Sorry but you can't release with failing tests, please fix them and try again."
80
87
  # exit 1
81
88
  # else
82
89
  # puts "All tests passing, proceeding with release process!"
83
90
  # end
84
- #end
91
+ # end
85
92
 
86
93
  # To enabled source-less pattern generation create a class (for example PatternDispatcher)
87
94
  # to generate the pattern. This should return false if the requested pattern has been
88
95
  # dispatched, otherwise Origen will proceed with looking up a pattern source as normal.
89
- #def before_pattern_lookup(requested_pattern)
96
+ # def before_pattern_lookup(requested_pattern)
90
97
  # PatternDispatcher.new.dispatch_or_return(requested_pattern)
91
- #end
98
+ # end
92
99
 
93
100
  # If you use pattern iterators you may come across the case where you request a pattern
94
101
  # like this:
@@ -96,11 +103,10 @@ class OrigenUpdaterApplication < Origen::Application
96
103
  #
97
104
  # However it cannot be found by Origen since the pattern name is actually example_pat_bx.atp
98
105
  # In the case where the pattern cannot be found Origen will pass the name to this translator
99
- # if it exists, and here you can make any substitutions to help Origen find the file you
106
+ # if it exists, and here you can make any substitutions to help Origen find the file you
100
107
  # want. In this example any instances of _b\d, where \d means a number, are replaced by
101
108
  # _bx.
102
- #config.pattern_name_translator do |name|
109
+ # config.pattern_name_translator do |name|
103
110
  # name.gsub(/_b\d/, "_bx")
104
- #end
105
-
111
+ # end
106
112
  end
data/config/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module OrigenUpdater
2
2
  MAJOR = 0
3
- MINOR = 2
3
+ MINOR = 3
4
4
  BUGFIX = 0
5
5
  DEV = nil
6
6
 
@@ -1,6 +1,18 @@
1
1
  require 'origen'
2
2
  require_relative '../config/application.rb'
3
- module OrigenUpdater
4
- # Don't load anything from here, everything must load from the update command and with
5
- # no dependencies
3
+
4
+ # Ensure the app always has the latest version of the updater scripts
5
+ app_fix_my_workspace = "#{Origen.root}/bin/fix_my_workspace"
6
+ if File.exist?(app_fix_my_workspace)
7
+ $_fix_my_workspace_version_check = true
8
+ load app_fix_my_workspace
9
+ end
10
+
11
+ if $_fix_my_workspace_version != Origen.app!.version
12
+ master_fix_my_workspace = File.expand_path('../../bin/fix_my_workspace', __FILE__)
13
+ FileUtils.mkdir_p "#{Origen.root}/bin" unless File.exist?("#{Origen.root}/bin")
14
+ # When running standalone
15
+ unless master_fix_my_workspace == app_fix_my_workspace
16
+ FileUtils.cp master_fix_my_workspace, app_fix_my_workspace
17
+ end
6
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen_updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-23 00:00:00.000000000 Z
11
+ date: 2017-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: origen
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.1
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.1
26
+ version: '0'
27
27
  description:
28
28
  email:
29
29
  - stephen.f.mcginty@gmail.com
@@ -31,14 +31,12 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - bin/fix_my_workspace
34
35
  - config/application.rb
35
36
  - config/boot.rb
36
37
  - config/commands.rb
37
- - config/shared_commands.rb
38
38
  - config/version.rb
39
39
  - lib/origen_updater.rb
40
- - lib/origen_updater/on_updated.rb
41
- - lib/origen_updater/update.rb
42
40
  - lib/tasks/origen_updater.rake
43
41
  - templates/web/index.md.erb
44
42
  - templates/web/layouts/_basic.html.erb
@@ -1,18 +0,0 @@
1
- # The requested command is passed in here as @command
2
- case @command
3
-
4
- when "update"
5
- require "#{Origen.root!}/lib/origen_updater/update"
6
- # Important to exit when a command has been fulfilled or else Origen core will try and execute it
7
- exit 0
8
-
9
- # Always leave an else clause to allow control to fall back through to the Origen command handler.
10
- # You probably want to also add the command details to the help shown via 'origen -h',
11
- # you can do this bb adding the required text to @plugin_commands before handing control back to
12
- # Origen.
13
- else
14
- @plugin_commands << <<-EOT
15
- update Update your app environment based on your Gemfile
16
- EOT
17
-
18
- end
@@ -1 +0,0 @@
1
- puts 'Updated!!'
@@ -1,62 +0,0 @@
1
- require 'fileutils'
2
- # require 'byebug' # Un-comment to debug this file
3
-
4
- if Origen.site_config.gem_manage_bundler && Origen.site_config.gem_use_from_system
5
- Origen.site_config.gem_use_from_system.each do |gem, version|
6
- begin
7
- spec = Gem::Specification.find_by_name(gem, version)
8
- begin
9
- (spec.executables || []).each do |bin|
10
- unless File.exist?("#{local_gem_dir}/bin/#{bin}")
11
- FileUtils.cp("#{spec.bin_dir}/#{bin}", "#{local_gem_dir}/bin")
12
- end
13
- end
14
- p = Pathname.new(spec.cache_file)
15
- unless File.exist?("#{local_gem_dir}/cache/#{p.basename}")
16
- FileUtils.cp(spec.cache_file, "#{local_gem_dir}/cache")
17
- end
18
- if spec.extension_dir && File.exist?(spec.extension_dir)
19
- spec.extension_dir =~ /.*extensions(.*)/
20
- sub_dir = Pathname.new(Regexp.last_match(1)).dirname.to_s
21
- local_ext_dir = "#{local_gem_dir}/extensions/#{sub_dir}"
22
- FileUtils.mkdir_p(local_ext_dir) unless File.exist?(local_ext_dir)
23
-
24
- # If the file exists in the extensions directory, skip copying it over.
25
- p = Pathname.new(spec.extension_dir)
26
- unless File.exist?("#{local_ext_dir}/#{p.basename}")
27
- FileUtils.cp_r(spec.extension_dir, local_ext_dir)
28
- end
29
- end
30
-
31
- # If the file exists in the gem directory, skip copying it over.
32
- p = Pathname.new(spec.gem_dir)
33
- unless File.exist?("#{local_gem_dir}/gems/#{p.basename}")
34
- FileUtils.cp_r(spec.gem_dir, "#{local_gem_dir}/gems")
35
- end
36
- # If the file exists in the specifications directory, skip copying it over.
37
- p = Pathname.new(spec.spec_file)
38
- unless File.exist?("#{local_gem_dir}/specifications/#{p.basename}")
39
- FileUtils.cp(spec.spec_file, "#{local_gem_dir}/specifications")
40
- end
41
- rescue
42
- puts "Had problems installing #{spec.name} from your system Ruby, proceeding with fingers crossed..."
43
- end
44
-
45
- rescue Gem::LoadError
46
- # This just means that one of the gems that should be copied from the system
47
- # was not actually installed in the system, so nothing we can do about that here
48
- end
49
- end
50
- end
51
-
52
- if ENV['BUNDLE_BIN']
53
- FileUtils.rm_rf(ENV['BUNDLE_BIN'])
54
-
55
- if ARGV.first == 'all'
56
- system 'bundle update'
57
- elsif ARGV.empty?
58
- system 'bundle'
59
- else
60
- system "bundle update #{ARGV.join(' ')}"
61
- end
62
- end