smc-get 0.1.0 → 0.2.0.beta1
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.
- data/COPYING +674 -674
- data/HISTORY.rdoc +31 -0
- data/README.rdoc +163 -148
- data/VERSION.txt +1 -1
- data/bin/smc-checksum +44 -0
- data/bin/smc-get +31 -31
- data/config/smc-get.yml +32 -32
- data/lib/smc_get.rb +23 -21
- data/lib/smc_get/cui.rb +325 -289
- data/lib/smc_get/cui_commands/build.rb +329 -0
- data/lib/smc_get/cui_commands/command.rb +117 -81
- data/lib/smc_get/cui_commands/getinfo.rb +92 -91
- data/lib/smc_get/cui_commands/help.rb +65 -64
- data/lib/smc_get/cui_commands/install.rb +101 -91
- data/lib/smc_get/cui_commands/list.rb +101 -80
- data/lib/smc_get/cui_commands/search.rb +106 -109
- data/lib/smc_get/cui_commands/uninstall.rb +80 -78
- data/lib/smc_get/cui_commands/update.rb +119 -0
- data/lib/smc_get/cui_commands/version.rb +58 -57
- data/lib/smc_get/errors.rb +140 -113
- data/lib/smc_get/gui.rb +20 -19
- data/lib/smc_get/local_repository.rb +277 -0
- data/lib/smc_get/package.rb +260 -279
- data/lib/smc_get/package_archive.rb +80 -0
- data/lib/smc_get/package_specification.rb +253 -0
- data/lib/smc_get/remote_repository.rb +272 -0
- data/lib/smc_get/repository.rb +10 -0
- data/lib/smc_get/smc_get.rb +117 -139
- data/smcpak.rdoc +332 -0
- data/test/test_smc-get-cui.rb +123 -121
- data/test/test_smc-get-lib.rb +172 -170
- metadata +71 -36
@@ -1,91 +1,92 @@
|
|
1
|
-
#Encoding: UTF-8
|
2
|
-
################################################################################
|
3
|
-
# This file is part of smc-get.
|
4
|
-
# Copyright (C) 2010-2011 Entertaining Software, Inc.
|
5
|
-
# Copyright (C) 2011 Marvin Gülker
|
6
|
-
#
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, either version 3 of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
################################################################################
|
20
|
-
|
21
|
-
module SmcGet
|
22
|
-
|
23
|
-
module CUICommands
|
24
|
-
|
25
|
-
class GetinfoCommand < Command
|
26
|
-
|
27
|
-
def self.help
|
28
|
-
<<HELP
|
29
|
-
USAGE: #{File.basename($0)} getinfo [-r] PACKAGE
|
30
|
-
|
31
|
-
Retrieves information about PACKAGE.
|
32
|
-
|
33
|
-
OPTIONS:
|
34
|
-
\r-r\t--remote\tForces getinfo to do a remote lookup.
|
35
|
-
|
36
|
-
The default behaviour is to do a local lookup if the
|
37
|
-
package is already installed.
|
38
|
-
HELP
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.summary
|
42
|
-
"getinfo\tGet information on a package."
|
43
|
-
end
|
44
|
-
|
45
|
-
def parse(args)
|
46
|
-
|
47
|
-
raise(InvalidCommandline, "No package given.") if args.empty?
|
48
|
-
@force_remote = false
|
49
|
-
|
50
|
-
while args.count > 1
|
51
|
-
arg = args.shift
|
52
|
-
case arg
|
53
|
-
when "-r", "--remote" then @force_remote = true
|
54
|
-
else
|
55
|
-
raise(InvalidCommandline, "Invalid argument #{arg}.")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
#The last command-line arg is the package
|
59
|
-
@pkg_name = args.shift
|
60
|
-
end
|
61
|
-
|
62
|
-
def execute(config)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
1
|
+
#Encoding: UTF-8
|
2
|
+
################################################################################
|
3
|
+
# This file is part of smc-get.
|
4
|
+
# Copyright (C) 2010-2011 Entertaining Software, Inc.
|
5
|
+
# Copyright (C) 2011 Marvin Gülker
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
################################################################################
|
20
|
+
|
21
|
+
module SmcGet
|
22
|
+
|
23
|
+
module CUICommands
|
24
|
+
|
25
|
+
class GetinfoCommand < Command
|
26
|
+
|
27
|
+
def self.help
|
28
|
+
<<HELP
|
29
|
+
USAGE: #{File.basename($0)} getinfo [-r] PACKAGE
|
30
|
+
|
31
|
+
Retrieves information about PACKAGE.
|
32
|
+
|
33
|
+
OPTIONS:
|
34
|
+
\r-r\t--remote\tForces getinfo to do a remote lookup.
|
35
|
+
|
36
|
+
The default behaviour is to do a local lookup if the
|
37
|
+
package is already installed.
|
38
|
+
HELP
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.summary
|
42
|
+
"getinfo\tGet information on a package."
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse(args)
|
46
|
+
CUI.debug("Parsing #{args.count} args for getinfo.")
|
47
|
+
raise(InvalidCommandline, "No package given.") if args.empty?
|
48
|
+
@force_remote = false
|
49
|
+
|
50
|
+
while args.count > 1
|
51
|
+
arg = args.shift
|
52
|
+
case arg
|
53
|
+
when "-r", "--remote" then @force_remote = true
|
54
|
+
else
|
55
|
+
raise(InvalidCommandline, "Invalid argument #{arg}.")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
#The last command-line arg is the package
|
59
|
+
@pkg_name = args.shift
|
60
|
+
end
|
61
|
+
|
62
|
+
def execute(config)
|
63
|
+
CUI.debug("Executing getinfo.")
|
64
|
+
Dir.mktmpdir do |tmpdir|
|
65
|
+
repo = if @cui.local_repository.contains?(@pkg_name) and !@force_remote
|
66
|
+
puts "[LOCAL PACKAGE]"
|
67
|
+
@cui.local_repository
|
68
|
+
else
|
69
|
+
puts "[REMOTE PACKAGE]"
|
70
|
+
@cui.remote_repository
|
71
|
+
end
|
72
|
+
info = YAML.load_file(repo.fetch_spec(@pkg_name + ".yml", tmpdir).to_s)
|
73
|
+
|
74
|
+
puts "Title: #{info['title']}"
|
75
|
+
if info['authors'].count == 1
|
76
|
+
puts "Author: #{info['authors'][0]}"
|
77
|
+
else
|
78
|
+
puts 'Authors:'
|
79
|
+
info['authors'].each{|author| puts " - #{author}"}
|
80
|
+
end
|
81
|
+
puts "Difficulty: #{info['difficulty']}"
|
82
|
+
puts "Description: #{info['description']}"
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
# vim:set ts=8 sts=2 sw=2 et: #
|
@@ -1,64 +1,65 @@
|
|
1
|
-
#Encoding: UTF-8
|
2
|
-
################################################################################
|
3
|
-
# This file is part of smc-get.
|
4
|
-
# Copyright (C) 2010-2011 Entertaining Software, Inc.
|
5
|
-
# Copyright (C) 2011 Marvin Gülker
|
6
|
-
#
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, either version 3 of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
################################################################################
|
20
|
-
|
21
|
-
module SmcGet
|
22
|
-
|
23
|
-
module CUICommands
|
24
|
-
|
25
|
-
class HelpCommand < Command
|
26
|
-
|
27
|
-
def self.help
|
28
|
-
<<EOF
|
29
|
-
USAGE: #{File.basename($0)} help [SUBCOMMAND]
|
30
|
-
|
31
|
-
Shows help for a special SUBCOMMAND or for #{File.basename($0)} in general.
|
32
|
-
EOF
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.summary
|
36
|
-
"help\t\tGet help on a specific command."
|
37
|
-
end
|
38
|
-
|
39
|
-
def parse(args)
|
40
|
-
CUI.debug("Parsing #{args.count} args for help.")
|
41
|
-
raise(InvalidCommandline, "Too many arguments.") if args.count > 1
|
42
|
-
@command = args.shift #nil if not given
|
43
|
-
end
|
44
|
-
|
45
|
-
def execute(config)
|
46
|
-
CUI.debug("Executing help.")
|
47
|
-
if @command
|
48
|
-
sym = :"#{@command.capitalize}Command"
|
49
|
-
if CUICommands.const_defined?(sym)
|
50
|
-
puts CUICommands.const_get(sym).help
|
51
|
-
else
|
52
|
-
puts "#{@command} is not a valid command."
|
53
|
-
return 2
|
54
|
-
end
|
55
|
-
else
|
56
|
-
puts CUI::GENERAL_HELP
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
1
|
+
#Encoding: UTF-8
|
2
|
+
################################################################################
|
3
|
+
# This file is part of smc-get.
|
4
|
+
# Copyright (C) 2010-2011 Entertaining Software, Inc.
|
5
|
+
# Copyright (C) 2011 Marvin Gülker
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
################################################################################
|
20
|
+
|
21
|
+
module SmcGet
|
22
|
+
|
23
|
+
module CUICommands
|
24
|
+
|
25
|
+
class HelpCommand < Command
|
26
|
+
|
27
|
+
def self.help
|
28
|
+
<<EOF
|
29
|
+
USAGE: #{File.basename($0)} help [SUBCOMMAND]
|
30
|
+
|
31
|
+
Shows help for a special SUBCOMMAND or for #{File.basename($0)} in general.
|
32
|
+
EOF
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.summary
|
36
|
+
"help\t\tGet help on a specific command."
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse(args)
|
40
|
+
CUI.debug("Parsing #{args.count} args for help.")
|
41
|
+
raise(InvalidCommandline, "Too many arguments.") if args.count > 1
|
42
|
+
@command = args.shift #nil if not given
|
43
|
+
end
|
44
|
+
|
45
|
+
def execute(config)
|
46
|
+
CUI.debug("Executing help.")
|
47
|
+
if @command
|
48
|
+
sym = :"#{@command.capitalize}Command"
|
49
|
+
if CUICommands.const_defined?(sym)
|
50
|
+
puts CUICommands.const_get(sym).help
|
51
|
+
else
|
52
|
+
puts "#{@command} is not a valid command."
|
53
|
+
return 2
|
54
|
+
end
|
55
|
+
else
|
56
|
+
puts CUI::GENERAL_HELP
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
# vim:set ts=8 sts=2 sw=2 et: #
|
@@ -1,91 +1,101 @@
|
|
1
|
-
#Encoding: UTF-8
|
2
|
-
################################################################################
|
3
|
-
# This file is part of smc-get.
|
4
|
-
# Copyright (C) 2010-2011 Entertaining Software, Inc.
|
5
|
-
# Copyright (C) 2011 Marvin Gülker
|
6
|
-
#
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, either version 3 of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
################################################################################
|
20
|
-
|
21
|
-
module SmcGet
|
22
|
-
|
23
|
-
module CUICommands
|
24
|
-
|
25
|
-
class InstallCommand < Command
|
26
|
-
|
27
|
-
def self.help
|
28
|
-
<<HELP
|
29
|
-
USAGE: #{File.basename($0)} install [-r] PACKAGES
|
30
|
-
|
31
|
-
Installs one or more packages.
|
32
|
-
|
33
|
-
OPTIONS:
|
34
|
-
-r\t--reinstall\tForces a reinstallation of the package.
|
35
|
-
HELP
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.summary
|
39
|
-
"install\tInstall one or more packages."
|
40
|
-
end
|
41
|
-
|
42
|
-
def parse(args)
|
43
|
-
|
44
|
-
raise(InvalidCommandline, "No package given.") if args.empty?
|
45
|
-
@reinstall = false
|
46
|
-
@pkg_names = []
|
47
|
-
|
48
|
-
until args.empty?
|
49
|
-
arg = args.shift
|
50
|
-
case arg
|
51
|
-
when "--reinstall", "-r" then @reinstall = true
|
52
|
-
else
|
53
|
-
@pkg_names << arg
|
54
|
-
$stderr.puts("Unknown argument #{arg}. Treating it as a package.") if arg.start_with?("-")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def execute(config)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
if
|
64
|
-
if @reinstall
|
65
|
-
puts "Reinstalling #{
|
66
|
-
else
|
67
|
-
puts "#{
|
68
|
-
next
|
69
|
-
end
|
70
|
-
end
|
71
|
-
puts "Installing #{
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
1
|
+
#Encoding: UTF-8
|
2
|
+
################################################################################
|
3
|
+
# This file is part of smc-get.
|
4
|
+
# Copyright (C) 2010-2011 Entertaining Software, Inc.
|
5
|
+
# Copyright (C) 2011 Marvin Gülker
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
################################################################################
|
20
|
+
|
21
|
+
module SmcGet
|
22
|
+
|
23
|
+
module CUICommands
|
24
|
+
|
25
|
+
class InstallCommand < Command
|
26
|
+
|
27
|
+
def self.help
|
28
|
+
<<HELP
|
29
|
+
USAGE: #{File.basename($0)} install [-r] PACKAGES
|
30
|
+
|
31
|
+
Installs one or more packages.
|
32
|
+
|
33
|
+
OPTIONS:
|
34
|
+
-r\t--reinstall\tForces a reinstallation of the package.
|
35
|
+
HELP
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.summary
|
39
|
+
"install\tInstall one or more packages."
|
40
|
+
end
|
41
|
+
|
42
|
+
def parse(args)
|
43
|
+
CUI.debug("Parsing #{args.count} args for install.")
|
44
|
+
raise(InvalidCommandline, "No package given.") if args.empty?
|
45
|
+
@reinstall = false
|
46
|
+
@pkg_names = []
|
47
|
+
|
48
|
+
until args.empty?
|
49
|
+
arg = args.shift
|
50
|
+
case arg
|
51
|
+
when "--reinstall", "-r" then @reinstall = true
|
52
|
+
else
|
53
|
+
@pkg_names << arg
|
54
|
+
$stderr.puts("Unknown argument #{arg}. Treating it as a package.") if arg.start_with?("-")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def execute(config)
|
60
|
+
CUI.debug("Executing install.")
|
61
|
+
|
62
|
+
@pkg_names.each do |pkg_name|
|
63
|
+
if @cui.local_repository.contains?(pkg_name)
|
64
|
+
if @reinstall
|
65
|
+
puts "Reinstalling #{pkg_name}."
|
66
|
+
else
|
67
|
+
puts "#{pkg_name} is already installed. Maybe you want --reinstall?."
|
68
|
+
next
|
69
|
+
end
|
70
|
+
end
|
71
|
+
puts "Installing #{pkg_name}."
|
72
|
+
spec_file = pkg_name + ".yml"
|
73
|
+
pkg_file = pkg_name + ".smcpak"
|
74
|
+
|
75
|
+
begin
|
76
|
+
path = download_package(pkg_name)
|
77
|
+
pkg = Package.from_file(path)
|
78
|
+
puts pkg.spec.install_message if pkg.spec.install_message
|
79
|
+
print "Decompressing... "
|
80
|
+
@cui.local_repository.install(pkg)
|
81
|
+
puts "Done."
|
82
|
+
rescue => e
|
83
|
+
$stderr.puts(e.message)
|
84
|
+
$stderr.puts("Ignoring the problem, continueing with the next package, if any.")
|
85
|
+
if CUI.debug_mode?
|
86
|
+
$stderr.puts("Class: #{e.class}")
|
87
|
+
$stderr.puts("Message: #{e.message}")
|
88
|
+
$stderr.puts("Backtrace:")
|
89
|
+
$stderr.puts(e.backtrace.join("\n\t"))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end #each
|
93
|
+
end #execute
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
# vim:set ts=8 sts=2 sw=2 et: #
|