port_upgrade 0.1.1 → 0.1.2
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/Manifest.txt +1 -0
- data/README.rdoc +18 -3
- data/Rakefile +1 -0
- data/bin/port_upgrade +1 -0
- data/lib/port_purge/cli.rb +2 -3
- data/lib/port_upgrade.rb +24 -40
- data/lib/port_upgrade/cli.rb +6 -1
- data/lib/port_upgrade/port.rb +12 -4
- data/lib/port_upgrade/port_upgrade_config.rb +51 -0
- data/test/test_helper.rb +1 -1
- data/test/test_port.rb +1 -0
- data/test/test_port_purge_cli.rb +5 -5
- data/test/test_version.rb +1 -1
- metadata +49 -27
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
port_upgrade
|
2
2
|
2008-07-14
|
3
3
|
|
4
|
-
Copyright (C)
|
4
|
+
Copyright (C) 2009 Tony Doan (tdoan@tdoan.com)
|
5
5
|
|
6
6
|
= port_upgrade
|
7
7
|
|
8
|
-
* http://portupgrade.rubyforge.org
|
8
|
+
* {RubyForge homepage}[http://portupgrade.rubyforge.org]
|
9
|
+
* FAQ[http://wiki.github.com/tdoan/port_upgrade/faq]
|
9
10
|
|
10
11
|
== DESCRIPTION:
|
11
12
|
|
@@ -21,7 +22,7 @@ Updates your MacPorts while also removing old dependent versions of libraries an
|
|
21
22
|
* Update your ports database from macports.org
|
22
23
|
* sudo port selfupdate (or sync)
|
23
24
|
* Run port_upgrade to generate a shell script
|
24
|
-
* port_upgrade -
|
25
|
+
* port_upgrade -o upgrade.sh
|
25
26
|
* Run the shell script to update your ports tree
|
26
27
|
* sudo ./upgrade.sh
|
27
28
|
* There is no step 4
|
@@ -35,6 +36,20 @@ Updates your MacPorts while also removing old dependent versions of libraries an
|
|
35
36
|
|
36
37
|
* sudo gem install port_upgrade
|
37
38
|
|
39
|
+
== Additional Usage Scenerios
|
40
|
+
|
41
|
+
1) Uninstall a port on which other ports depend. Example with libiconv
|
42
|
+
|
43
|
+
<tt>port_upgrade --outdated=libiconv -o iconv_uninstall.sh</tt>
|
44
|
+
|
45
|
+
<tt>./iconv_uninstall.sh uninstall</tt>
|
46
|
+
|
47
|
+
2)
|
48
|
+
|
49
|
+
== Known Bugs
|
50
|
+
|
51
|
+
* Does not check epoch dates in Portfiles
|
52
|
+
|
38
53
|
== LICENSE:
|
39
54
|
|
40
55
|
Copyright (c) 2008 Tony Doan <tdoan@tdoan.com>
|
data/Rakefile
CHANGED
data/bin/port_upgrade
CHANGED
data/lib/port_purge/cli.rb
CHANGED
@@ -42,10 +42,9 @@ module PortPurge
|
|
42
42
|
when /^(yes|y)$/i
|
43
43
|
@to_remove << leaf
|
44
44
|
when /^(quit|q)$/i
|
45
|
-
exit
|
45
|
+
exit(-1)
|
46
46
|
when /^(skip|s)$/i
|
47
47
|
break
|
48
|
-
$stderr.puts
|
49
48
|
else
|
50
49
|
@keep << leaf
|
51
50
|
end
|
@@ -64,7 +63,7 @@ module PortPurge
|
|
64
63
|
end
|
65
64
|
else
|
66
65
|
$stderr.puts "Exiting"
|
67
|
-
exit
|
66
|
+
exit(-1)
|
68
67
|
end
|
69
68
|
end
|
70
69
|
end
|
data/lib/port_upgrade.rb
CHANGED
@@ -16,6 +16,7 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
16
16
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
17
17
|
require 'port_upgrade/port'
|
18
18
|
require 'port_upgrade/version'
|
19
|
+
require 'port_upgrade/port_upgrade_config'
|
19
20
|
require 'yaml'
|
20
21
|
require 'bz2'
|
21
22
|
require 'find'
|
@@ -29,10 +30,9 @@ class String
|
|
29
30
|
end
|
30
31
|
|
31
32
|
module Ports
|
32
|
-
VERSION = '0.1.
|
33
|
+
VERSION = '0.1.2'
|
33
34
|
RECEIPT_PATH = '/opt/local/var/macports/receipts'
|
34
35
|
MACPORTS_DB='/opt/local/var/macports/sources/rsync.macports.org/release/ports'
|
35
|
-
CONFIG_FILE = 'port_upgrade.conf'
|
36
36
|
SH_ERB_PATH = File.join(File.dirname(__FILE__),"port_upgrade","port_upgrade_sh.erb")
|
37
37
|
Struct.new('Edge',:port,:dep,:level)
|
38
38
|
class Struct::Edge
|
@@ -205,40 +205,20 @@ module Ports
|
|
205
205
|
|
206
206
|
class PortsDB
|
207
207
|
def initialize(path=nil,outdated=nil)
|
208
|
+
mp_version_path = "/opt/local/var/macports/sources/rsync.macports.org/release/base//config/mp_version"
|
209
|
+
@mp_version = File.read("/opt/local/var/macports/sources/rsync.macports.org/release/base//config/mp_version").to_f
|
210
|
+
@needs_dash_x = @mp_version < 1.8
|
211
|
+
@dash_x = @needs_dash_x ? "-x" : ""
|
208
212
|
@path=path
|
209
213
|
@db = SQLite3::Database.new(':memory:')#('port_tree.db')
|
210
214
|
@pt = PortTree.new(self,path)
|
211
215
|
@installed = @pt.installed
|
212
216
|
set_outdated(outdated)
|
213
217
|
@to_remove = nil
|
214
|
-
|
215
|
-
|
216
|
-
begin
|
217
|
-
@config = YAML::load(File.open(config_file))
|
218
|
-
@config = {} if @config == false
|
219
|
-
rescue Errno::ENOENT
|
220
|
-
$stderr.puts("No configuration loaded.")
|
221
|
-
rescue ArgumentError
|
222
|
-
$stderr.puts("Badly formed config file.")
|
223
|
-
exit(-1)
|
224
|
-
end
|
225
|
-
else
|
226
|
-
$stderr.puts("No configuration loaded.")
|
227
|
-
end
|
218
|
+
@config = PortUpgradeConfig.instance.config
|
219
|
+
|
228
220
|
end
|
229
221
|
|
230
|
-
def locate_config_file
|
231
|
-
to_search = []
|
232
|
-
local_dir = File.dirname($0).sub(/bin$/,"")
|
233
|
-
local_dir = local_dir == "" ? "." : local_dir
|
234
|
-
to_search << File.join(local_dir,"etc",Ports::CONFIG_FILE)
|
235
|
-
to_search << File.join(ENV['HOME'],"."+Ports::CONFIG_FILE)
|
236
|
-
to_search.each do |path|
|
237
|
-
return path if File.readable?(path)
|
238
|
-
end
|
239
|
-
return nil
|
240
|
-
end
|
241
|
-
|
242
222
|
def installed
|
243
223
|
@installed
|
244
224
|
end
|
@@ -310,16 +290,16 @@ module Ports
|
|
310
290
|
cats << (md[2].nil? ? md[1] : md[2].split.first)
|
311
291
|
end
|
312
292
|
end
|
313
|
-
portfile_path = File.join(
|
293
|
+
portfile_path = File.join(get_macports_db_path,cats.flatten,port,'Portfile')
|
314
294
|
unless File.exist?(portfile_path)
|
315
295
|
$stderr.puts "Searching for #{port}'s Portfile"
|
316
|
-
Dir.entries(
|
317
|
-
if File.directory?(File.join(
|
318
|
-
testpath = File.join(
|
296
|
+
Dir.entries(get_macports_db_path).each do |d|
|
297
|
+
if File.directory?(File.join(get_macports_db_path,d)) && d != '.' && d != '..'
|
298
|
+
testpath = File.join(get_macports_db_path,d,port,'Portfile')
|
319
299
|
if File.exist?(testpath)
|
320
|
-
|
321
|
-
|
322
|
-
|
300
|
+
portfile_path = testpath
|
301
|
+
break
|
302
|
+
end
|
323
303
|
end
|
324
304
|
end
|
325
305
|
end
|
@@ -331,10 +311,10 @@ module Ports
|
|
331
311
|
if cmp.nil?
|
332
312
|
$stderr.puts "Unable to compare versions: #{[port]}"
|
333
313
|
else
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
314
|
+
if cmp < 0
|
315
|
+
@outdated << port
|
316
|
+
end
|
317
|
+
end
|
338
318
|
else
|
339
319
|
$stderr.puts "Unable to process Portfile (File Not Found) for #{port}"
|
340
320
|
end
|
@@ -383,7 +363,7 @@ module Ports
|
|
383
363
|
end
|
384
364
|
bi = get_before_install(port)
|
385
365
|
uninstall_data << bi unless bi.nil?
|
386
|
-
install_data << "port #{get_force(port)}
|
366
|
+
install_data << "port #{get_force(port)} #{@dash_x} install #{port} #{remvariants[port][variantindex]} || exit -1"
|
387
367
|
ai = get_after_install(port)
|
388
368
|
fi = get_final_install(port)
|
389
369
|
final << fi unless fi.nil?
|
@@ -426,6 +406,10 @@ module Ports
|
|
426
406
|
get_port_action(portname,:final_install)
|
427
407
|
end
|
428
408
|
|
409
|
+
def get_macports_db_path
|
410
|
+
PortUpgradeConfig.instance.get_macports_db_path
|
411
|
+
end
|
412
|
+
|
429
413
|
def [](portname)
|
430
414
|
Port.new(portname,@path)
|
431
415
|
end
|
data/lib/port_upgrade/cli.rb
CHANGED
@@ -32,6 +32,9 @@ module PortUpgrade
|
|
32
32
|
options.checkoutdated = co
|
33
33
|
$stderr.puts "CHECKOUTDATED: #{co}"
|
34
34
|
end
|
35
|
+
opts.on("-p",'Add pid to the end of the outputfile') do
|
36
|
+
options.pid = "." + Process.pid.to_s
|
37
|
+
end
|
35
38
|
opts.on_tail("-V", "--version","Show version") do
|
36
39
|
$stderr.puts "port_upgrade #{Ports::VERSION}"
|
37
40
|
exit
|
@@ -42,6 +45,7 @@ module PortUpgrade
|
|
42
45
|
end
|
43
46
|
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
44
47
|
$stderr.puts "VERBOSE: #{v}"
|
48
|
+
$stderr.puts Ports::PortUpgradeConfig.instance.get_macports_db_path
|
45
49
|
options.verbose = v
|
46
50
|
end
|
47
51
|
end
|
@@ -50,7 +54,8 @@ module PortUpgrade
|
|
50
54
|
puts opts
|
51
55
|
exit 1
|
52
56
|
end
|
53
|
-
$verbose = true
|
57
|
+
$verbose = true if options.verbose
|
58
|
+
options.output += options.pid if options.pid
|
54
59
|
if options.portoutdated
|
55
60
|
$stderr.print "Running port outdated..."
|
56
61
|
outdated = `port outdated`.find_all{|l| (l =~ /(The following|No installed ports are outdated)/).nil? }.collect{|l| l.split[0]}
|
data/lib/port_upgrade/port.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
require 'port_upgrade/port_upgrade_config'
|
1
2
|
module Ports
|
2
3
|
class Port
|
3
4
|
attr_reader :name,:versions,:portfile_path
|
4
|
-
|
5
|
+
@config = PortUpgradeConfig.instance.config
|
6
|
+
|
5
7
|
def initialize(portname,receipt_path=nil)
|
6
8
|
receipt_path ||= RECEIPT_PATH
|
7
9
|
tmpp = File.join(receipt_path,portname)
|
8
10
|
@name = portname
|
9
11
|
@versions = []
|
12
|
+
@portfile_path = nil
|
10
13
|
if File.exist?(tmpp) and File.readable?(tmpp)
|
11
14
|
@rp = tmpp
|
12
15
|
Find.find(@rp) do |d|
|
@@ -18,9 +21,9 @@ module Ports
|
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
21
|
-
Dir.entries(
|
22
|
-
if File.directory?(File.join(
|
23
|
-
testpath = File.join(
|
24
|
+
Dir.entries(get_macports_db_path).each do |d|
|
25
|
+
if File.directory?(File.join(get_macports_db_path,d)) && d != '.' && d != '..'
|
26
|
+
testpath = File.join(get_macports_db_path,d,@name,'Portfile')
|
24
27
|
if File.exist?(testpath)
|
25
28
|
@portfile_path = testpath
|
26
29
|
break
|
@@ -61,5 +64,10 @@ module Ports
|
|
61
64
|
end
|
62
65
|
result
|
63
66
|
end
|
67
|
+
|
68
|
+
def get_macports_db_path
|
69
|
+
PortUpgradeConfig.instance.get_macports_db_path
|
70
|
+
end
|
71
|
+
|
64
72
|
end
|
65
73
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Ports
|
5
|
+
CONFIG_FILE = 'port_upgrade.conf'
|
6
|
+
class PortUpgradeConfig
|
7
|
+
include Singleton
|
8
|
+
@@config=nil
|
9
|
+
def locate_config_file
|
10
|
+
to_search = []
|
11
|
+
local_dir = File.dirname($0).sub(/bin$/,"")
|
12
|
+
local_dir = local_dir == "" ? "." : local_dir
|
13
|
+
to_search << File.join(local_dir,"etc",Ports::CONFIG_FILE)
|
14
|
+
to_search << File.join(ENV['HOME'],"."+Ports::CONFIG_FILE)
|
15
|
+
to_search.each do |path|
|
16
|
+
return path if File.readable?(path)
|
17
|
+
end
|
18
|
+
return nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_macports_db_path
|
22
|
+
unless config.nil?
|
23
|
+
if config.has_key?(:macports_db_path)
|
24
|
+
config[:macports_db_path]
|
25
|
+
else
|
26
|
+
MACPORTS_DB
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def config
|
32
|
+
return @@config unless @@config.nil?
|
33
|
+
|
34
|
+
config_file = locate_config_file
|
35
|
+
unless config_file.nil?
|
36
|
+
begin
|
37
|
+
@@config = YAML::load(File.open(config_file))
|
38
|
+
@@config = {} if @@config == false
|
39
|
+
return @@config
|
40
|
+
rescue Errno::ENOENT
|
41
|
+
throw "No configuration loaded."
|
42
|
+
rescue ArgumentError
|
43
|
+
throw "Badly formed config file."
|
44
|
+
end
|
45
|
+
else
|
46
|
+
#throw "No configuration loaded."
|
47
|
+
return nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/test/test_helper.rb
CHANGED
data/test/test_port.rb
CHANGED
data/test/test_port_purge_cli.rb
CHANGED
@@ -3,14 +3,14 @@ require 'test/unit'
|
|
3
3
|
require 'stringio'
|
4
4
|
require 'port_purge/cli'
|
5
5
|
|
6
|
-
class TestPortPurgeCli < Test::Unit::TestCase
|
6
|
+
#class TestPortPurgeCli < Test::Unit::TestCase
|
7
7
|
#def setup
|
8
8
|
# PortPurge::CLI.execute(@stdout_io = StringIO.new, [])
|
9
9
|
# @stdout_io.rewind
|
10
10
|
# @stdout = @stdout_io.read
|
11
11
|
#end
|
12
12
|
|
13
|
-
def test_not_print_default_output
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
13
|
+
#def test_not_print_default_output
|
14
|
+
# assert_no_match(/To update this executable/, @stdout)
|
15
|
+
#end
|
16
|
+
#end
|
data/test/test_version.rb
CHANGED
@@ -34,7 +34,7 @@ class TestVersion < Test::Unit::TestCase
|
|
34
34
|
xorg-util-macros 1.2.0_0 < 1.2.1_0
|
35
35
|
xrender 0.9.4_1 < 0.9.4_4
|
36
36
|
}
|
37
|
-
@tests = raw_tests.collect{|l| parts = l.split(" "); [parts[1],parts[3]] }
|
37
|
+
@tests = raw_tests.split("\n").collect{|l| parts = l.split(" "); [parts[1],parts[3]] }
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_1
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: port_upgrade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Tony Doan
|
@@ -9,50 +14,65 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-04-18 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: sqlite3-ruby
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 0
|
23
31
|
version: 1.2.0
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: bz2
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 2
|
33
44
|
version: "0.2"
|
34
|
-
|
45
|
+
type: :runtime
|
46
|
+
version_requirements: *id002
|
35
47
|
- !ruby/object:Gem::Dependency
|
36
48
|
name: newgem
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
51
|
requirements:
|
41
52
|
- - ">="
|
42
53
|
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
54
|
+
segments:
|
55
|
+
- 1
|
56
|
+
- 5
|
57
|
+
- 3
|
58
|
+
version: 1.5.3
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id003
|
45
61
|
- !ruby/object:Gem::Dependency
|
46
62
|
name: hoe
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
65
|
requirements:
|
51
66
|
- - ">="
|
52
67
|
- !ruby/object:Gem::Version
|
53
|
-
|
54
|
-
|
55
|
-
|
68
|
+
segments:
|
69
|
+
- 2
|
70
|
+
- 6
|
71
|
+
- 0
|
72
|
+
version: 2.6.0
|
73
|
+
type: :development
|
74
|
+
version_requirements: *id004
|
75
|
+
description: ""
|
56
76
|
email:
|
57
77
|
- tdoan@tdoan.com
|
58
78
|
executables:
|
@@ -63,7 +83,6 @@ extensions: []
|
|
63
83
|
extra_rdoc_files:
|
64
84
|
- History.txt
|
65
85
|
- Manifest.txt
|
66
|
-
- README.rdoc
|
67
86
|
files:
|
68
87
|
- History.txt
|
69
88
|
- Manifest.txt
|
@@ -75,35 +94,38 @@ files:
|
|
75
94
|
- lib/port_upgrade/port.rb
|
76
95
|
- lib/port_upgrade/port_upgrade_sh.erb
|
77
96
|
- lib/port_upgrade/version.rb
|
97
|
+
- lib/port_upgrade/port_upgrade_config.rb
|
78
98
|
- bin/port_upgrade
|
79
99
|
- bin/port_purge
|
80
100
|
- etc/port_upgrade.conf.sample
|
81
101
|
has_rdoc: true
|
82
|
-
homepage:
|
102
|
+
homepage:
|
83
103
|
licenses: []
|
84
104
|
|
85
105
|
post_install_message:
|
86
106
|
rdoc_options:
|
87
107
|
- --main
|
88
|
-
- README.
|
108
|
+
- README.txt
|
89
109
|
require_paths:
|
90
110
|
- lib
|
91
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
112
|
requirements:
|
93
113
|
- - ">="
|
94
114
|
- !ruby/object:Gem::Version
|
115
|
+
segments:
|
116
|
+
- 0
|
95
117
|
version: "0"
|
96
|
-
version:
|
97
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
119
|
requirements:
|
99
120
|
- - ">="
|
100
121
|
- !ruby/object:Gem::Version
|
122
|
+
segments:
|
123
|
+
- 0
|
101
124
|
version: "0"
|
102
|
-
version:
|
103
125
|
requirements: []
|
104
126
|
|
105
127
|
rubyforge_project: portupgrade
|
106
|
-
rubygems_version: 1.3.
|
128
|
+
rubygems_version: 1.3.6
|
107
129
|
signing_key:
|
108
130
|
specification_version: 3
|
109
131
|
summary: Cleanly upgrade your MacPorts.
|