smc-get 0.1.0 → 0.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,119 @@
|
|
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 UpdateCommand < Command
|
26
|
+
|
27
|
+
def self.help
|
28
|
+
<<EOF
|
29
|
+
USAGE: #{File.basename($0)} update [PACKAGES...]
|
30
|
+
|
31
|
+
Checks for updates in the repository and tries to update the local
|
32
|
+
packages. If you modified a package, you will be prompted to
|
33
|
+
decide how to proceed.
|
34
|
+
|
35
|
+
OPTIONS:
|
36
|
+
-y\t--yes\tAssume yes on all queries
|
37
|
+
EOF
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.summary
|
41
|
+
"update\tUpdate packages."
|
42
|
+
end
|
43
|
+
|
44
|
+
def parse(args)
|
45
|
+
CUI.debug("Parsing #{args.count} args for update.")
|
46
|
+
@packages = []
|
47
|
+
while(arg = args.shift)
|
48
|
+
case arg
|
49
|
+
when "-y", "--yes" then @assume_yes = true
|
50
|
+
else
|
51
|
+
@packages << arg
|
52
|
+
end
|
53
|
+
end
|
54
|
+
#Warn on package names starting with a hyphen, may be a mistyped option
|
55
|
+
@packages.each{|pkg| $stderr.puts("Warning: Treating #{pkg} as a package") if pkg.start_with?("-")}
|
56
|
+
end
|
57
|
+
|
58
|
+
def execute(config)
|
59
|
+
CUI.debug("Executing update")
|
60
|
+
|
61
|
+
#Get the packages we want to update
|
62
|
+
if @packages.empty? #None given, default to all
|
63
|
+
packages = @cui.local_repository.package_specs.map(&:name)
|
64
|
+
else
|
65
|
+
packages = @packages
|
66
|
+
end
|
67
|
+
puts "Going to check #{packages.count} packages for updates."
|
68
|
+
|
69
|
+
packages.each do |pkgname|
|
70
|
+
spec_name = "#{pkgname}.yml"
|
71
|
+
local_spec = PackageSpecification.from_file(@cui.local_repository.fetch_spec(spec_name))
|
72
|
+
remote_spec = PackageSpecification.from_file(@cui.remote_repository.fetch_spec(spec_name))
|
73
|
+
|
74
|
+
#Execute update if remote is newer than local
|
75
|
+
if remote_spec.last_update > local_spec.last_update
|
76
|
+
|
77
|
+
puts "Updating #{pkgname}."
|
78
|
+
begin
|
79
|
+
path = download_package(pkgname)
|
80
|
+
|
81
|
+
#First uninstall the old version--this is necessary, b/c a new
|
82
|
+
#version of a package may have files removed that wouldn’t be
|
83
|
+
#deleted by a simple overwrite operation.
|
84
|
+
print "Uninstalling obsolete version of #{pkgname}... "
|
85
|
+
@cui.local_repository.uninstall(pkgname) do |conflict_file|
|
86
|
+
puts "CONFLICT: The file #{conflict_file} has been modified. What now?"
|
87
|
+
puts "1) Ignore and delete anyway"
|
88
|
+
puts "2) Copy file and include MODIFIED in the name."
|
89
|
+
print "Enter a number[1]: "
|
90
|
+
$stdin.gets.chomp.to_i == 2 #True means copying
|
91
|
+
end
|
92
|
+
puts "Done."
|
93
|
+
|
94
|
+
#Then install the new version.
|
95
|
+
pkg = Package.from_file(path)
|
96
|
+
puts pkg.spec.install_message if pkg.spec.install_message
|
97
|
+
print "Installing #{pkgname}... "
|
98
|
+
@cui.local_repository.install(pkg)
|
99
|
+
puts "Done."
|
100
|
+
rescue => e
|
101
|
+
$stderr.puts(e.message)
|
102
|
+
$stderr.puts("Ignoring the problem and continuing with the next package, if any.")
|
103
|
+
if CUI.debug_mode?
|
104
|
+
$stderr.puts("Class: #{e.class}")
|
105
|
+
$stderr.puts("Message: #{e.message}")
|
106
|
+
$stderr.puts("Backtrace:")
|
107
|
+
$stderr.puts(e.backtrace.join("\n\t"))
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
# vim:set ts=8 sts=2 sw=2 et: #
|
@@ -1,57 +1,58 @@
|
|
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 VersionCommand < Command
|
26
|
-
|
27
|
-
def self.help
|
28
|
-
<<EOF
|
29
|
-
USAGE: #{File.basename($0)} version
|
30
|
-
|
31
|
-
Shows the version of #{File.basename($0)} and the copyright statement.
|
32
|
-
EOF
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.summary
|
36
|
-
"version\tShows smc-get's version and copyright."
|
37
|
-
end
|
38
|
-
|
39
|
-
def parse(args)
|
40
|
-
raise(InvalidCommandline, "Too many arguments.") unless args.empty?
|
41
|
-
end
|
42
|
-
|
43
|
-
def execute(config)
|
44
|
-
puts "This is #{File.basename($0)}, version #{
|
45
|
-
puts
|
46
|
-
puts "#{File.basename($0)}
|
47
|
-
puts "#{File.basename($0)}
|
48
|
-
puts "This program comes with ABSOLUTELY NO WARRANTY."
|
49
|
-
puts "This is free software, and you are welcome to redistribute it"
|
50
|
-
puts "under certain conditions; see the COPYING file for information."
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
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 VersionCommand < Command
|
26
|
+
|
27
|
+
def self.help
|
28
|
+
<<EOF
|
29
|
+
USAGE: #{File.basename($0)} version
|
30
|
+
|
31
|
+
Shows the version of #{File.basename($0)} and the copyright statement.
|
32
|
+
EOF
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.summary
|
36
|
+
"version\tShows smc-get's version and copyright."
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse(args)
|
40
|
+
raise(InvalidCommandline, "Too many arguments.") unless args.empty?
|
41
|
+
end
|
42
|
+
|
43
|
+
def execute(config)
|
44
|
+
puts "This is #{File.basename($0)}, version #{SmcGet.version}."
|
45
|
+
puts
|
46
|
+
puts "#{File.basename($0)} Copyright (C) 2010-2011 Luiji Maryo"
|
47
|
+
puts "#{File.basename($0)} Copyright (C) 2011 Marvin Gülker"
|
48
|
+
puts "This program comes with ABSOLUTELY NO WARRANTY."
|
49
|
+
puts "This is free software, and you are welcome to redistribute it"
|
50
|
+
puts "under certain conditions; see the COPYING file for information."
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
# vim:set ts=8 sts=2 sw=2 et: #
|
data/lib/smc_get/errors.rb
CHANGED
@@ -1,113 +1,140 @@
|
|
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
|
-
#This module contains all errors messages that are specific to smc-get.
|
24
|
-
module Errors
|
25
|
-
|
26
|
-
#Superclass for all errors in this library.
|
27
|
-
class SmcGetError < StandardError
|
28
|
-
end
|
29
|
-
|
30
|
-
#Raises when you did not call SmcGet.setup.
|
31
|
-
class LibraryNotInitialized < SmcGetError
|
32
|
-
|
33
|
-
#Throws an exception of this class with an appropriate error
|
34
|
-
#message if smc-get has not been initialized correctly.
|
35
|
-
def self.throw_if_needed!
|
36
|
-
if SmcGet.datadir.nil? or SmcGet.repo_url.nil?
|
37
|
-
raise(self, "You have to setup smc-get first!")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
# Raised when the class is initialized with a non-existant settings file.
|
44
|
-
class CannotFindSettings < SmcGetError
|
45
|
-
# The path to the settings file that was specified.
|
46
|
-
attr_reader :settings_path
|
47
|
-
|
48
|
-
# Create a new instance of the exception with the settings path.
|
49
|
-
def initialize(settings_path)
|
50
|
-
@settings_path = settings_path
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Raised when a package call is made but the specified package cannot be
|
55
|
-
# found.
|
56
|
-
class NoSuchPackageError < SmcGetError
|
57
|
-
# The name of the package that could not be found.
|
58
|
-
attr_reader :package_name
|
59
|
-
|
60
|
-
# Create a new instance of the exception with the specified package name.
|
61
|
-
def initialize(name)
|
62
|
-
@package_name = name
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Raised when a package call is made but one of the resources of the
|
67
|
-
# specified package is missing.
|
68
|
-
class NoSuchResourceError < SmcGetError
|
69
|
-
# The type of resource (should be either :music, :graphic, or :
|
70
|
-
attr_reader :resource_type
|
71
|
-
# The name of the resource (i.e. mylevel.lvl or Stuff/Cheeseburger.png).
|
72
|
-
attr_reader :resource_name
|
73
|
-
|
74
|
-
# Create a new instance of the exception with the specified resource type
|
75
|
-
# and name. Type should either be :music, :graphic, or :level.
|
76
|
-
def initialize(type, name)
|
77
|
-
@resource_type = type
|
78
|
-
@resource_name = name
|
79
|
-
end
|
80
|
-
|
81
|
-
# Returns true if the resource type is :music. False otherwise.
|
82
|
-
def is_music?
|
83
|
-
@resource_type == :music
|
84
|
-
end
|
85
|
-
|
86
|
-
# Returns true if the resource type is :graphic. False otherwise.
|
87
|
-
def is_graphic?
|
88
|
-
@resource_type == :graphic
|
89
|
-
end
|
90
|
-
|
91
|
-
# Returns true if the resource type is :level. False otherwise.
|
92
|
-
def is_level?
|
93
|
-
@resource_type == :level
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
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
|
+
#This module contains all errors messages that are specific to smc-get.
|
24
|
+
module Errors
|
25
|
+
|
26
|
+
#Superclass for all errors in this library.
|
27
|
+
class SmcGetError < StandardError
|
28
|
+
end
|
29
|
+
|
30
|
+
#Raises when you did not call SmcGet.setup.
|
31
|
+
class LibraryNotInitialized < SmcGetError
|
32
|
+
|
33
|
+
#Throws an exception of this class with an appropriate error
|
34
|
+
#message if smc-get has not been initialized correctly.
|
35
|
+
def self.throw_if_needed!
|
36
|
+
if SmcGet.datadir.nil? or SmcGet.repo_url.nil?
|
37
|
+
raise(self, "You have to setup smc-get first!")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
# Raised when the class is initialized with a non-existant settings file.
|
44
|
+
class CannotFindSettings < SmcGetError
|
45
|
+
# The path to the settings file that was specified.
|
46
|
+
attr_reader :settings_path
|
47
|
+
|
48
|
+
# Create a new instance of the exception with the settings path.
|
49
|
+
def initialize(settings_path)
|
50
|
+
@settings_path = settings_path
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Raised when a package call is made but the specified package cannot be
|
55
|
+
# found.
|
56
|
+
class NoSuchPackageError < SmcGetError
|
57
|
+
# The name of the package that could not be found.
|
58
|
+
attr_reader :package_name
|
59
|
+
|
60
|
+
# Create a new instance of the exception with the specified package name.
|
61
|
+
def initialize(name)
|
62
|
+
@package_name = name
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Raised when a package call is made but one of the resources of the
|
67
|
+
# specified package is missing.
|
68
|
+
class NoSuchResourceError < SmcGetError
|
69
|
+
# The type of resource (should be either :music, :graphic, :level or :spec).
|
70
|
+
attr_reader :resource_type
|
71
|
+
# The name of the resource (i.e. mylevel.lvl or Stuff/Cheeseburger.png).
|
72
|
+
attr_reader :resource_name
|
73
|
+
|
74
|
+
# Create a new instance of the exception with the specified resource type
|
75
|
+
# and name. Type should either be :music, :graphic, or :level.
|
76
|
+
def initialize(type, name)
|
77
|
+
@resource_type = type
|
78
|
+
@resource_name = name
|
79
|
+
end
|
80
|
+
|
81
|
+
# Returns true if the resource type is :music. False otherwise.
|
82
|
+
def is_music?
|
83
|
+
@resource_type == :music
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns true if the resource type is :graphic. False otherwise.
|
87
|
+
def is_graphic?
|
88
|
+
@resource_type == :graphic
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns true if the resource type is :level. False otherwise.
|
92
|
+
def is_level?
|
93
|
+
@resource_type == :level
|
94
|
+
end
|
95
|
+
|
96
|
+
# Returns true if the resource type is :spec. False otherwise.
|
97
|
+
def is_spec?
|
98
|
+
@resource_type == :spec
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
# Raised when a call to download() fails.
|
104
|
+
class DownloadFailedError < SmcGetError
|
105
|
+
# The URL that failed to download (including everything after /raw/master
|
106
|
+
# only).
|
107
|
+
attr_reader :download_url
|
108
|
+
|
109
|
+
def initialize(url)
|
110
|
+
@download_url = url
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
#Raised when SmcGet.download timed out.
|
115
|
+
class ConnectionTimedOutError < DownloadFailedError
|
116
|
+
end
|
117
|
+
|
118
|
+
#Raised if a package is damaged or malformed.
|
119
|
+
class BrokenPackageError < SmcGetError
|
120
|
+
end
|
121
|
+
|
122
|
+
#Raised if a package specification file contains rubbish.
|
123
|
+
class InvalidSpecification < BrokenPackageError
|
124
|
+
end
|
125
|
+
|
126
|
+
#Raised when a repository wasn’t found or contains structure errors.
|
127
|
+
class InvalidRepository < SmcGetError
|
128
|
+
|
129
|
+
#The URL of the repository.
|
130
|
+
attr_reader :repository_uri
|
131
|
+
|
132
|
+
def initialize(repository_uri)
|
133
|
+
@repository_uri = repository_uri
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
# vim:set ts=8 sts=2 sw=2 et: #
|