class Object
Constants
- README
Public Instance Methods
download_ssh_key()
click to toggle source
# File lib/gpack/core/ssh.rb, line 2 def download_ssh_key() key_url = $SETTINGS["ssh"]["key_url"] if key_url remote_key = Tempfile.new('gpack_ssh') # TODO make this readable only by user begin download = open(key_url) IO.copy_stream(download, remote_key.path) rescue puts "Error with URL #{key_url}\nEnsure this is a valid url and can be reached" raise end $SETTINGS["ssh"]["key"] = remote_key end end
gpack(opts)
click to toggle source
# File lib/gpack/core/gpack.rb, line 2 def gpack(opts) puts opts.inspect puts "Using Git Executable #{`which git`}" ## TODO - Check propery ruby and git versions ## Check is ruby/git module files are properly loaded #if `which git`.chomp != "/apps/git/current/bin/git" # puts "ERROR: Git and Ruby modules not properly loaded!" # puts "\tYour .cshrc should have the following lines for gpack to properly work" # puts "\t\tsetenv MODULEPATH /common/modulefiles" # puts "\t\tmodule load apps/git-default" # puts # exit #end grepos = parse_gpackrepos() download_ssh_key() set_ssh_cmd() OptionParser.new do |opts| opts.on("-n","--nogui") do $SETTINGS["gui"]["show"] = false end opts.on("-f","--force") do $SETTINGS["core"]["force"] = true end opts.on("-p","--persist") do $SETTINGS["gui"]["persist"] = true end opts.on("-i") do $SETTINGS["core"]["install"] = true end opts.on("-s","--single") do $SETTINGS["core"]["parallel"] = false end end.parse! case opts[0] when "install" grepos.clone when "update" grepos.update when "check" grepos.check when "uninstall" grepos.remove when "archive" grepos.archive when "lock" `rm -f .gpackunlock` grepos.set_writeable(false) when "unlock" `echo "UNLOCKED" >> .gpackunlock` grepos.set_writeable(true) when "rinse" grepos.rinse grepos.check # check should be clean when "reinstall" grepos.remove grepos.clone when "status" grepos.status when "list" grepos.print else "help" puts README end # Close the SSH tempfile if $SETTINGS["ssh"]["key"] $SETTINGS["ssh"]["key"].close end end
parse_gpackrepos()
click to toggle source
Parse the GpackRepose file
# File lib/gpack/core/parse_repos.rb, line 4 def parse_gpackrepos() grepos_file = $SETTINGS["core"]["repofile"] ## Options for YAML File required_keys = ["url","localdir","branch"] valid_config = ["remote_key","ssh_command"] grepos = GitCollection.new() if !File.exist?(grepos_file) raise "File does not exist #{grepos_file}" end unlocked = File.exists?(".gpackunlock") yml_file = YAML.load_file(grepos_file) yml_file.each do |key,entry| if key == "config" # Read in config settings # Check if the config option is valid entry.each do |ckey,centry| if !valid_config.index(ckey) raise "Error in file '#{grepos_file}'.\n\tError in configuration entry #{key}\n\tConfig option must be one of #{valid_config}" end case ckey when "lock" # TODO implement this when "remote_key" #SSH KEY stuff $SETTINGS["ssh"]["key_url"] = centry when "ssh_command" # Arguements to ssh $SETTINGS["ssh"]["cmd"] = centry end end else reponame = key # Check required keys exist if !required_keys.all? {|s| entry.key? s} raise "Error in file '#{grepos_file}'.\n\tEntry #{key}\n\tFor a repository these properties are required #{required_keys}" end # Optional Key Parsing if entry.key?("lock") readonly = entry["lock"] else readonly = true end new_repo = GitReference.new :url=>entry["url"], :localdir=>entry["localdir"], :branch=>entry["branch"] if unlocked new_repo.readonly = false end grepos.add_ref(new_repo) end end return grepos end
set_ssh_cmd()
click to toggle source
# File lib/gpack/core/ssh.rb, line 18 def set_ssh_cmd() remote_key = $SETTINGS["ssh"]["key"] if remote_key id_arg = " -i #{remote_key.path}" ssh_cmd=$SETTINGS["ssh"]["cmd"] if $SETTINGS["ssh"]["cmd"] ssh_cmd="#{ssh_cmd}#{id_arg}" else ssh_cmd="ssh #{id_arg}" end $SETTINGS["ssh"]["cmd"] = ssh_cmd end end