smc-get 0.2.0.beta1 → 0.3.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 +53 -31
- data/README.rdoc +162 -162
- data/VERSION.txt +1 -1
- data/bin/smc-checksum +44 -44
- data/bin/smc-checksum~ +2 -0
- data/bin/smc-get +31 -31
- data/bin/smc-repo-conv +205 -0
- data/bin/smc-repo-conv~ +155 -0
- data/config/smc-get.yml +32 -32
- data/config/smc-get.yml~ +32 -0
- data/lib/smc_get.rb +22 -22
- data/lib/smc_get/cui.rb +325 -325
- data/lib/smc_get/cui_commands/build.rb +297 -329
- data/lib/smc_get/cui_commands/command.rb +181 -117
- data/lib/smc_get/cui_commands/getinfo.rb +91 -91
- data/lib/smc_get/cui_commands/help.rb +64 -64
- data/lib/smc_get/cui_commands/install.rb +101 -101
- data/lib/smc_get/cui_commands/list.rb +101 -101
- data/lib/smc_get/cui_commands/search.rb +106 -106
- data/lib/smc_get/cui_commands/server.rb +76 -0
- data/lib/smc_get/cui_commands/uninstall.rb +77 -80
- data/lib/smc_get/cui_commands/update.rb +107 -119
- data/lib/smc_get/cui_commands/version.rb +57 -57
- data/lib/smc_get/errors.rb +166 -140
- data/lib/smc_get/gui.rb +19 -19
- data/lib/smc_get/local_repository.rb +290 -277
- data/lib/smc_get/package.rb +240 -260
- data/lib/smc_get/package_archive.rb +186 -80
- data/lib/smc_get/package_specification.rb +257 -253
- data/lib/smc_get/remote_repository.rb +272 -272
- data/lib/smc_get/repository.rb +9 -9
- data/lib/smc_get/smc_get.rb +118 -117
- data/smcpak.rdoc +331 -331
- data/test/test_smc-get-cui.rb +122 -122
- data/test/test_smc-get-lib.rb +171 -171
- metadata +25 -22
@@ -1,106 +1,106 @@
|
|
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 SearchCommand < Command
|
26
|
-
|
27
|
-
def self.help
|
28
|
-
<<HELP
|
29
|
-
USAGE: #{File.basename($0)} search [-a][-d][-D][-l][-L][-p][-t] QUERY
|
30
|
-
|
31
|
-
Searches the local or remote repository for packages. QUERY is assumed
|
32
|
-
to be a regular expression (be sure to quote it in order to prevent
|
33
|
-
shell expansion!).
|
34
|
-
|
35
|
-
OPTIONS:
|
36
|
-
-a\t--authors\tSearch the author list.
|
37
|
-
-d\t--description\tSearch the package descriptions.
|
38
|
-
-D\t--difficulty\tSearch the 'difficulty' fields.
|
39
|
-
-i\t--ignore-case\tTreat QUERY as case-insensitive.
|
40
|
-
-l\t--only-local\tOnly search local packages. Default is to search remotely.
|
41
|
-
-L\t--levels\tSearch for specific level names.
|
42
|
-
-n\t--name\tSearch the package files' names.
|
43
|
-
-t\t--title\t\tSearch the packages' full titles.
|
44
|
-
|
45
|
-
|
46
|
-
If you don't specify which fields to use, --name is assumed as it doesn't have
|
47
|
-
to download all the package specifications only for searching.
|
48
|
-
HELP
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.summary
|
52
|
-
"search\tSearch for a package."
|
53
|
-
end
|
54
|
-
|
55
|
-
def parse(args)
|
56
|
-
CUI.debug("Parsing #{args.count} args for search.")
|
57
|
-
raise(InvalidCommandline, "No query given.") if args.empty?
|
58
|
-
@search_fields = []
|
59
|
-
@only_local = false
|
60
|
-
|
61
|
-
while args.count > 1
|
62
|
-
arg = args.shift
|
63
|
-
case arg
|
64
|
-
when "-l", "--only-local" then @only_local = true
|
65
|
-
when "-t", "--title" then @search_fields << :title
|
66
|
-
when "-d", "--description" then @search_fields << :description
|
67
|
-
when "-a", "--authors" then @search_fields << :authors
|
68
|
-
when "-D", "--difficulty" then @search_fields << :difficulty
|
69
|
-
when "-L", "--levels" then @search_fields << :levels
|
70
|
-
when "-n", "--name" then @search_fields << :name
|
71
|
-
when "-i", "--ignore-case" then @ignore_case = true
|
72
|
-
else
|
73
|
-
raise(InvalidCommandline, "Invalid argument #{arg}.")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
#If no search fields were specified, default to :pkgname, because
|
77
|
-
#it causes the least network traffic.
|
78
|
-
@search_fields << :name if @search_fields.empty?
|
79
|
-
#The last command-line arg is the search query
|
80
|
-
@query = @ignore_case ? Regexp.new(args.shift, Regexp::IGNORECASE) : Regexp.new(args.shift)
|
81
|
-
end
|
82
|
-
|
83
|
-
def execute(config)
|
84
|
-
CUI.debug("Executing search")
|
85
|
-
repo = @only_local ? @cui.local_repository : @cui.remote_repository
|
86
|
-
|
87
|
-
repo.search(@query, *@search_fields) do |pkgname|
|
88
|
-
if @only_local then puts "[LOCAL PACKAGE]" else puts "[REMOTE PACKAGE]" end
|
89
|
-
|
90
|
-
spec = PackageSpecification.from_file(repo.fetch_spec("#{pkgname}.yml", SmcGet.temp_dir))
|
91
|
-
puts "Package title: #{spec.title}"
|
92
|
-
puts "Real package name: #{spec.name}" #Should be the same as the pkgname variable
|
93
|
-
puts "Authors: #{spec.authors.join(', ')}"
|
94
|
-
puts "Difficulty: #{spec.difficulty}"
|
95
|
-
puts "Description:"
|
96
|
-
puts spec.description
|
97
|
-
puts #For separating the next search result
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
# vim:set ts=8 sts=2 sw=2 et: #
|
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 SearchCommand < Command
|
26
|
+
|
27
|
+
def self.help
|
28
|
+
<<HELP
|
29
|
+
USAGE: #{File.basename($0)} search [-a][-d][-D][-l][-L][-p][-t] QUERY
|
30
|
+
|
31
|
+
Searches the local or remote repository for packages. QUERY is assumed
|
32
|
+
to be a regular expression (be sure to quote it in order to prevent
|
33
|
+
shell expansion!).
|
34
|
+
|
35
|
+
OPTIONS:
|
36
|
+
-a\t--authors\tSearch the author list.
|
37
|
+
-d\t--description\tSearch the package descriptions.
|
38
|
+
-D\t--difficulty\tSearch the 'difficulty' fields.
|
39
|
+
-i\t--ignore-case\tTreat QUERY as case-insensitive.
|
40
|
+
-l\t--only-local\tOnly search local packages. Default is to search remotely.
|
41
|
+
-L\t--levels\tSearch for specific level names.
|
42
|
+
-n\t--name\tSearch the package files' names.
|
43
|
+
-t\t--title\t\tSearch the packages' full titles.
|
44
|
+
|
45
|
+
|
46
|
+
If you don't specify which fields to use, --name is assumed as it doesn't have
|
47
|
+
to download all the package specifications only for searching.
|
48
|
+
HELP
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.summary
|
52
|
+
"search\tSearch for a package."
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse(args)
|
56
|
+
CUI.debug("Parsing #{args.count} args for search.")
|
57
|
+
raise(InvalidCommandline, "No query given.") if args.empty?
|
58
|
+
@search_fields = []
|
59
|
+
@only_local = false
|
60
|
+
|
61
|
+
while args.count > 1
|
62
|
+
arg = args.shift
|
63
|
+
case arg
|
64
|
+
when "-l", "--only-local" then @only_local = true
|
65
|
+
when "-t", "--title" then @search_fields << :title
|
66
|
+
when "-d", "--description" then @search_fields << :description
|
67
|
+
when "-a", "--authors" then @search_fields << :authors
|
68
|
+
when "-D", "--difficulty" then @search_fields << :difficulty
|
69
|
+
when "-L", "--levels" then @search_fields << :levels
|
70
|
+
when "-n", "--name" then @search_fields << :name
|
71
|
+
when "-i", "--ignore-case" then @ignore_case = true
|
72
|
+
else
|
73
|
+
raise(InvalidCommandline, "Invalid argument #{arg}.")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
#If no search fields were specified, default to :pkgname, because
|
77
|
+
#it causes the least network traffic.
|
78
|
+
@search_fields << :name if @search_fields.empty?
|
79
|
+
#The last command-line arg is the search query
|
80
|
+
@query = @ignore_case ? Regexp.new(args.shift, Regexp::IGNORECASE) : Regexp.new(args.shift)
|
81
|
+
end
|
82
|
+
|
83
|
+
def execute(config)
|
84
|
+
CUI.debug("Executing search")
|
85
|
+
repo = @only_local ? @cui.local_repository : @cui.remote_repository
|
86
|
+
|
87
|
+
repo.search(@query, *@search_fields) do |pkgname|
|
88
|
+
if @only_local then puts "[LOCAL PACKAGE]" else puts "[REMOTE PACKAGE]" end
|
89
|
+
|
90
|
+
spec = PackageSpecification.from_file(repo.fetch_spec("#{pkgname}.yml", SmcGet.temp_dir))
|
91
|
+
puts "Package title: #{spec.title}"
|
92
|
+
puts "Real package name: #{spec.name}" #Should be the same as the pkgname variable
|
93
|
+
puts "Authors: #{spec.authors.join(', ')}"
|
94
|
+
puts "Difficulty: #{spec.difficulty}"
|
95
|
+
puts "Description:"
|
96
|
+
puts spec.description
|
97
|
+
puts #For separating the next search result
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
# vim:set ts=8 sts=2 sw=2 et: #
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# -*- coding: 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
|
+
class SmcGet::CUICommands::ServerCommand < SmcGet::CUICommands::Command
|
22
|
+
|
23
|
+
def self.help
|
24
|
+
<<-EOF
|
25
|
+
USAGE: #{File.basename($0)} server [-p PORT] [DIRECTORY]
|
26
|
+
|
27
|
+
Starts a simple static file server you can use to connect to
|
28
|
+
with another instance of #{File.basename($0)}. Note that it uses
|
29
|
+
Ruby's WEBrick, which is known to not be suitable for production
|
30
|
+
environments, so don't use this command for anything else than
|
31
|
+
serving small more-or-less private SMC repositories. Have a look
|
32
|
+
at robust servers like apache or nginx for making it available to
|
33
|
+
the public.
|
34
|
+
|
35
|
+
If DIRECTORY is given, uses that directory for the server root
|
36
|
+
directory. Otherwise, uses the current working directory.
|
37
|
+
|
38
|
+
OPTIONS
|
39
|
+
-p PORT\t--port PORT\tListen on this port instead of the default 3000.
|
40
|
+
EOF
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.summary
|
44
|
+
"server\tStart a repository server."
|
45
|
+
end
|
46
|
+
|
47
|
+
def parse(args)
|
48
|
+
SmcGet::CUI.debug("Parsing #{args.count} args for server.")
|
49
|
+
|
50
|
+
until args.empty?
|
51
|
+
arg = args.shift
|
52
|
+
case arg
|
53
|
+
when "--port", "-p" then @port = args.shift || raise(InvalidCommandline, "No port given.")
|
54
|
+
else
|
55
|
+
@directory = Pathname.new(arg).expand_path
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
@directory ||= Pathname.pwd
|
60
|
+
@port ||= 3000
|
61
|
+
end
|
62
|
+
|
63
|
+
def execute(config)
|
64
|
+
server = WEBrick::HTTPServer.new(Port: @port)
|
65
|
+
server[:Logger].info("Serving directory #@directory.")
|
66
|
+
server.mount("/", WEBrick::HTTPServlet::FileHandler, @directory)
|
67
|
+
|
68
|
+
Signal.trap("SIGINT") do
|
69
|
+
server[:Logger].info("Cought SIGINT, stopping...")
|
70
|
+
server.stop
|
71
|
+
end
|
72
|
+
|
73
|
+
server.start
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -1,80 +1,77 @@
|
|
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 UninstallCommand < Command
|
26
|
-
|
27
|
-
def self.help
|
28
|
-
<<EOF
|
29
|
-
#{File.basename($0)} uninstall PACKAGES
|
30
|
-
|
31
|
-
Removes PACKAGES from your set of downloaded packages.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
# vim:set ts=8 sts=2 sw=2 et: #
|
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 UninstallCommand < Command
|
26
|
+
|
27
|
+
def self.help
|
28
|
+
<<EOF
|
29
|
+
#{File.basename($0)} uninstall PACKAGES
|
30
|
+
|
31
|
+
Removes PACKAGES from your set of downloaded packages.
|
32
|
+
|
33
|
+
OPTIONS:
|
34
|
+
-y\t--yes\tAssume yes on all queries
|
35
|
+
EOF
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.summary
|
39
|
+
"uninstall\tUninstalls one or more packages."
|
40
|
+
end
|
41
|
+
|
42
|
+
def parse(args)
|
43
|
+
CUI.debug("Parsing #{args.count} args for uninstall.")
|
44
|
+
raise(InvalidCommandline, "No package given.") if args.empty?
|
45
|
+
@pkg_names = []
|
46
|
+
@assume_yes = false
|
47
|
+
until args.empty?
|
48
|
+
arg = args.shift
|
49
|
+
case arg
|
50
|
+
when "-y", "--yes" then @assume_yes = true
|
51
|
+
else
|
52
|
+
@pkg_names << arg
|
53
|
+
$stderr.puts("Unkown argument #{arg}. Treating it as a package.") if arg.start_with?("-")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def execute(config)
|
59
|
+
CUI.debug("Executing uninstall.")
|
60
|
+
@pkg_names.each do |pkg_name|
|
61
|
+
if @cui.local_repository.contains?(pkg_name)
|
62
|
+
spec = PackageSpecification.from_file(@cui.local_repository.fetch_spec("#{pkg_name}.yml", SmcGet.temp_dir))
|
63
|
+
puts spec.remove_message if spec.remove_message
|
64
|
+
puts "Removing #{pkg_name}... "
|
65
|
+
uninstall_package(pkg_name, @assume_yes, @assume_yes)
|
66
|
+
else
|
67
|
+
$stderr.puts "#{pkg_name} is not installed. Skipping."
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
# vim:set ts=8 sts=2 sw=2 et: #
|
@@ -1,119 +1,107 @@
|
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
if
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
#
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
+
#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
|
+
@assume_yes = false
|
48
|
+
while(arg = args.shift)
|
49
|
+
case arg
|
50
|
+
when "-y", "--yes" then @assume_yes = true
|
51
|
+
else
|
52
|
+
@packages << arg
|
53
|
+
end
|
54
|
+
end
|
55
|
+
#Warn on package names starting with a hyphen, may be a mistyped option
|
56
|
+
@packages.each{|pkg| $stderr.puts("Warning: Treating #{pkg} as a package") if pkg.start_with?("-")}
|
57
|
+
end
|
58
|
+
|
59
|
+
def execute(config)
|
60
|
+
CUI.debug("Executing update")
|
61
|
+
|
62
|
+
#Get the packages we want to update
|
63
|
+
if @packages.empty? #None given, default to all
|
64
|
+
packages = @cui.local_repository.package_specs.map(&:name)
|
65
|
+
else
|
66
|
+
packages = @packages
|
67
|
+
end
|
68
|
+
puts "Going to check #{packages.count} packages for updates."
|
69
|
+
|
70
|
+
packages.each do |pkgname|
|
71
|
+
spec_name = "#{pkgname}.yml"
|
72
|
+
local_spec = PackageSpecification.from_file(@cui.local_repository.fetch_spec(spec_name))
|
73
|
+
remote_spec = PackageSpecification.from_file(@cui.remote_repository.fetch_spec(spec_name))
|
74
|
+
|
75
|
+
#Execute update if remote is newer than local
|
76
|
+
if remote_spec.last_update > local_spec.last_update
|
77
|
+
|
78
|
+
puts "Updating #{pkgname}."
|
79
|
+
begin
|
80
|
+
#First uninstall the old version--this is necessary, b/c a new
|
81
|
+
#version of a package may have files removed that wouldn’t be
|
82
|
+
#deleted by a simple overwrite operation.
|
83
|
+
puts "Uninstalling obsolete version of #{pkgname}... "
|
84
|
+
uninstall_package(pkgname, true, @assume_yes) #We ignore dependencies as we immediately reinstall a package
|
85
|
+
|
86
|
+
#Then install the new version.
|
87
|
+
install_package_with_deps(pkgname, @assume_yes)
|
88
|
+
rescue => e
|
89
|
+
$stderr.puts(e.message)
|
90
|
+
$stderr.puts("Ignoring the problem and continuing with the next package, if any.")
|
91
|
+
if CUI.debug_mode?
|
92
|
+
$stderr.puts("Class: #{e.class}")
|
93
|
+
$stderr.puts("Message: #{e.message}")
|
94
|
+
$stderr.puts("Backtrace:")
|
95
|
+
$stderr.puts(e.backtrace.join("\n\t"))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
# vim:set ts=8 sts=2 sw=2 et: #
|