Skip to content

Commit

Permalink
Adjusted the plugins installation rake task
Browse files Browse the repository at this point in the history
Now an 'install' of the plugins will also clean up
spurious dead symlink. No need to full erase and recreate all!
  • Loading branch information
prioux committed Oct 1, 2024
1 parent 435a133 commit 53eb3a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
17 changes: 17 additions & 0 deletions BrainPortal/lib/tasks/cbrain_plugins.rake
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,23 @@ namespace :cbrain do
end
end

erase_dead_symlinks = lambda do |name, directory|
Dir.entries(directory)
.map { |entry| Pathname.new(directory) + entry }
.select { |subpath| subpath.symlink? }
.select { |subpath| ! subpath.exist? } # checks that the symlink points to something valid
.each do |subpath|
puts "-> Erasing symlink for #{name} '#{subpath}'." if verbose
logger.('DeadSymlink', 'None', name, subpath)
File.unlink(subpath) # remove symlink
end
end

# Setup each userfile plugin
setup.('userfiles/*', 'userfile', userfiles_plugins_dir,
condition: lambda { |f| File.directory?(f) }
)
erase_dead_symlinks.('userfile', userfiles_plugins_dir)

# Setup each cbrain_task plugin
setup.('cbrain_task/*', 'task', tasks_plugins_dir,
Expand All @@ -131,6 +144,7 @@ namespace :cbrain do
File.symlink "cbrain_task_class_loader.rb", "#{symlink_location}.rb"
end
)
erase_dead_symlinks.('task', tasks_plugins_dir)

# Setup each cbrain_task descriptor plugin
setup.('cbrain_task_descriptors/*', 'descriptor', descriptors_plugins_dir,
Expand All @@ -139,16 +153,19 @@ namespace :cbrain do
File.symlink "cbrain_task_descriptor_loader.rb", "#{symlink_location.sub(/.json$/, '.rb')}"
end
)
erase_dead_symlinks.('descriptor', descriptors_plugins_dir)

# Setup each boutiques descriptor plugin (new integrator)
setup.('boutiques_descriptors/*', 'boutiques', boutiques_plugins_dir,
condition: lambda { |f| File.extname(f) == '.json' },
)
erase_dead_symlinks.('boutiques', boutiques_plugins_dir)

# Setup each ruby lib file
setup.('lib/*', 'lib', lib_plugins_dir,
condition: lambda { |f| File.extname(f) == '.rb' },
)
erase_dead_symlinks.('lib', lib_plugins_dir)

end # chdir package
end # each package
Expand Down
7 changes: 2 additions & 5 deletions script/update_cb_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ A) for both Bourreau and BrainPortal:
1 - git pull of the main CBRAIN repo
2 - git pull of each installed plugins
3 - bundle install
4 - rake cbrain:plugins:clean:all
- rake cbrain:plugins:install:all
4 - rake cbrain:plugins:install:all
B) for BrainPortal only:
Expand Down Expand Up @@ -192,9 +191,7 @@ fi
step=4
if test $step -ge $skipto -a $step -le $stopat ; then

Step $step: Re-install All Plugins
test "$base" == "BrainPortal" && runcapture "rake cbrain:plugins:clean:all"
test "$base" == "Bourreau" && runcapture "rake cbrain:plugins:clean:plugins"
Step $step: Update All Plugins Symlinks
test "$base" == "BrainPortal" && runcapture "rake cbrain:plugins:install:all"
test "$base" == "Bourreau" && runcapture "rake cbrain:plugins:install:plugins"

Expand Down

0 comments on commit 53eb3a3

Please sign in to comment.