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.
@@ -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
- EOF
33
- end
34
-
35
- def self.summary
36
- "uninstall\tUninstalls one or more packages."
37
- end
38
-
39
- def parse(args)
40
- CUI.debug("Parsing #{args.count} args for uninstall.")
41
- raise(InvalidCommandline, "No package given.") if args.empty?
42
- @pkg_names = []
43
- until args.empty?
44
- arg = args.shift
45
- #case arg
46
- #when "-c", "--my-arg" then ...
47
- #else
48
- @pkg_names << arg
49
- $stderr.puts("Unkown argument #{arg}. Treating it as a package.") if arg.start_with?("-")
50
- #end
51
- end
52
- end
53
-
54
- def execute(config)
55
- CUI.debug("Executing uninstall.")
56
- @pkg_names.each do |pkg_name|
57
- if @cui.local_repository.contains?(pkg_name)
58
- spec = PackageSpecification.from_file(@cui.local_repository.fetch_spec("#{pkg_name}.yml", SmcGet.temp_dir))
59
- puts spec.remove_message if spec.remove_message
60
- print "Removing #{pkg_name}... "
61
- @cui.local_repository.uninstall(pkg_name) do |conflict_file|
62
- puts "CONFLICT: The file #{conflict_file} has been modified. What now?"
63
- puts "1) Ignore and delete anyway"
64
- puts "2) Copy file and include MODIFIED in the name."
65
- print "Enter a number[1]: "
66
- $stdin.gets.chomp.to_i == 2 #True means copying
67
- end
68
- puts "Done."
69
- else
70
- $stderr.puts "#{pkg_name} is not installed. Skipping."
71
- end
72
- end
73
- end
74
-
75
- end
76
-
77
- end
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
- 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
+ #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: #