port_upgrade 0.0.4 → 0.0.5

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/History.txt CHANGED
@@ -1,8 +1,18 @@
1
- == 0.4.0 2009-01-02
1
+ == 0.0.5 2009-01-06
2
+ * Bugs
3
+ * port install needs -x to actually give useful return codes
4
+ * Fixed issue with database inserts when there are more than one version of something to uninstall
5
+ * Added summary to Rakefile so it will show up on gem search
6
+ * Yet another rewrite of version compare routine. Handles version string that differ in length now
7
+ * Better debugging output
8
+ * Added new config file action final_install. For items that need to happen after a port is installed, but is best at the very end of all the installs.
9
+
10
+ == 0.0.4 2009-01-02
2
11
  * Add flag to call port outdated instead of using internal routine
3
12
  * Complete rewrite of version comparison routine
4
13
  * Bugs
5
14
  * Fix computing depth of receipts when using a custom path
15
+
6
16
  == 0.0.3 2008-12-23
7
17
 
8
18
  * Bug Fix Release:
data/Rakefile CHANGED
@@ -6,6 +6,7 @@ GEM_DIR = File.join(GEM_HOME,RbConfig::CONFIG["ruby_version"],"gems")
6
6
  $hoe = Hoe.new('port_upgrade',Ports::VERSION) do |p|
7
7
  p.developer('Tony Doan', 'tdoan@tdoan.com')
8
8
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ p.summary = "Cleanly upgrade your MacPorts."
9
10
  p.post_install_message = %Q{
10
11
 
11
12
  A sample config file can be found in:
data/bin/port_upgrade CHANGED
@@ -3,6 +3,7 @@
3
3
  # Created on 2008-12-15.
4
4
  # Copyright (c) 2008. All rights reserved.
5
5
 
6
+ require 'rubygems'
6
7
  require File.expand_path(File.dirname(__FILE__) + "/../lib/port_upgrade")
7
8
 
8
9
  require "port_upgrade/cli"
@@ -7,19 +7,32 @@ module Ports
7
7
  end
8
8
 
9
9
  def <=>(other)
10
+ $stderr.puts("self: #{@parts.inspect}") if $DEBUG
11
+ $stderr.puts("other: #{other.parts.inspect}") if $DEBUG
10
12
  cmp = 0
11
- @parts.each_with_index do |p,i|
12
- #$stderr.puts "Sizes: #{p.size} #{other.parts[i].size}"
13
- p.each_with_index do |q,j|
14
- a = q
15
- b = other.parts[i][j]
16
- a = a.to_i if a =~ /^[0-9]+$/
17
- b = b.to_i if b =~ /^[0-9]+$/
18
- #$stderr.puts "#{a} <=> #{b}"
19
- cmp = a <=> b
20
- break if cmp != 0
13
+ numparts = @parts.size>other.parts.size ? @parts.size : other.parts.size
14
+ 0.upto(numparts-1) do |i|
15
+ p = i>=@parts.size ? ["-1"] : @parts[i]
16
+ q = i>=other.parts.size ? ["-1"] : other.parts[i]
17
+ numsubparts = p.size>q.size ? p.size : q.size
18
+ 0.upto(numsubparts-1) do |j|
19
+ r = j>=p.size ? "-1" : p[j]
20
+ s = j>=q.size ? "-1" : q[j]
21
+
22
+ $stderr.puts("p of #{j}: #{r}") if $DEBUG
23
+ $stderr.puts("q of #{j}: #{s}") if $DEBUG
24
+ a = r =~ /^-?[0-9]+$/ ? r.to_i : r
25
+ b = s =~ /^-?[0-9]+$/ ? s.to_i : s
26
+ $stderr.puts "#{a.inspect} <=> #{b.inspect}" if $DEBUG
27
+ if a.instance_of?(b.class)
28
+ cmp = a <=> b
29
+ else
30
+ $stderr.puts "Can't compare different classes #{a.class.to_s} <=> #{b.class.to_s}" if $DEBUG
31
+ cmp = 0
32
+ end
33
+ return cmp if cmp != 0
21
34
  end
22
- break if cmp != 0
35
+ return cmp if cmp != 0
23
36
  end
24
37
  cmp
25
38
  end
data/lib/port_upgrade.rb CHANGED
@@ -15,6 +15,7 @@
15
15
  $:.unshift(File.dirname(__FILE__)) unless
16
16
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
17
17
 
18
+ require 'yaml'
18
19
  require 'bz2'
19
20
  require 'find'
20
21
  require 'sqlite3'
@@ -26,7 +27,7 @@ class String
26
27
  end
27
28
 
28
29
  module Ports
29
- VERSION = '0.0.4'
30
+ VERSION = '0.0.5'
30
31
  RECEIPT_PATH = '/opt/local/var/macports/receipts'
31
32
  MACPORTS_DB='/opt/local/var/macports/sources/rsync.macports.org/release/ports'
32
33
  CONFIG_FILE = 'port_upgrade.conf'
@@ -118,7 +119,7 @@ module Ports
118
119
  rescue SQLite3::SQLException => exp
119
120
  $stderr.puts "Dup insert into remports: #{exp}}" if $DEBUG
120
121
  end
121
- @pdb.db.execute("insert into remports values(\"#{a}\",\"\")")
122
+ @pdb.db.execute("insert or ignore into remports values(\"#{a}\",\"\")")
122
123
  end
123
124
  @pdb.db.execute('delete from remports where port="gimp-app" and dep="gimp"')
124
125
  #File.open("remtree.dot",'w') do |f|
@@ -314,7 +315,7 @@ module Ports
314
315
  if File.exist?(portfile_path)
315
316
  curver = Portfile.new(portfile_path).version
316
317
  #puts "%-32s%s < %s" %[port,version.split('+').first,curver] if Ports::Utilities.cmp_vers(version.split('+').first,curver) < 0
317
- $stderr.puts("#{port}: #{version.split('+').first}, #{curver}") if $verbose
318
+ $stderr.puts("#{port}: #{version.split('+').first}, #{curver}") if $DEBUG
318
319
  cmp = Ports::Utilities.cmp_vers(version.split('+').first,curver)
319
320
  if cmp.nil?
320
321
  $stderr.puts "Unable to compare versions: #{[port]}"
@@ -332,6 +333,7 @@ module Ports
332
333
  end
333
334
 
334
335
  def upgrade(path='port_upgrade.sh')
336
+ final = []
335
337
  @pt.setup_remports(outdated) if @to_remove.nil?
336
338
  remports = []
337
339
  remvariants = Hash.new {|h,k| h[k] = Array.new}
@@ -369,11 +371,15 @@ module Ports
369
371
  end
370
372
  bi = get_before_install(port)
371
373
  dotsh.puts(bi) unless bi.nil?
372
- dotsh.puts("port #{get_force(port)} install #{port} #{remvariants[port][variantindex]} || exit -1")
374
+ dotsh.puts("port #{get_force(port)} -x install #{port} #{remvariants[port][variantindex]} || exit -1")
373
375
  ai = get_after_install(port)
376
+ fi = get_final_install(port)
377
+ final << fi unless fi.nil?
374
378
  dotsh.puts(ai) unless ai.nil?
375
379
  end
376
380
  stmt.close
381
+ final.each{|l| dotsh.puts(l)}
382
+ dotsh.close
377
383
  true
378
384
  end
379
385
 
@@ -402,6 +408,10 @@ module Ports
402
408
  get_port_action(portname,:after_install)
403
409
  end
404
410
 
411
+ def get_final_install(portname)
412
+ get_port_action(portname,:final_install)
413
+ end
414
+
405
415
  private
406
416
 
407
417
  def get_port_action(portname,type)
@@ -475,7 +485,7 @@ module Ports
475
485
  v = $2 || $3 if v.nil?
476
486
  break
477
487
  when /(\S+)\s+([^$]+)$/
478
- vars[$1] = $2
488
+ vars[$1] = $2.strip
479
489
  end
480
490
  end
481
491
  rev = "0" if rev.nil?
data/test/test_version.rb CHANGED
@@ -6,6 +6,7 @@ class TestVersion < Test::Unit::TestCase
6
6
  def setup
7
7
  raw_tests = %q{ImageMagick 6.4.6-7_0 < 6.4.8-1_0
8
8
  binutils 2.17_0 < 2.19_0
9
+ bison 2.4_1 < 2.4.1_0
9
10
  boost 1.35.0_2 < 1.37.0_0
10
11
  cairo 1.8.4_0 < 1.8.6_1
11
12
  dbus 1.2.4_2 < 1.2.10_0
@@ -53,6 +54,18 @@ class TestVersion < Test::Unit::TestCase
53
54
  assert_equal(v1 <=> v2, 1)
54
55
  end
55
56
 
57
+ def test_4
58
+ v1 = Version.new("2.24a.1")
59
+ v2 = Version.new("2.24b.1")
60
+ assert_equal(v1 <=> v2, -1)
61
+ end
62
+
63
+ def test_5
64
+ v1 = Version.new("5.820_0")
65
+ v2 = Version.new("5.820 LWP_0")
66
+ assert_equal(v1 <=> v2, 0)
67
+ end
68
+
56
69
  def test_current
57
70
  @tests.each do |test|
58
71
  v1 = Version.new(test[0])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: port_upgrade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Doan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-02 00:00:00 -08:00
12
+ date: 2009-01-07 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 1.2.1
53
+ version: 1.2.3
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: hoe
@@ -89,7 +89,7 @@ post_install_message: |+
89
89
 
90
90
 
91
91
  A sample config file can be found in:
92
- /opt/local/lib/ruby/gems/1.8/gems/port_upgrade-0.0.4/etc
92
+ /opt/local/lib/ruby/gems/1.8/gems/port_upgrade-0.0.5/etc
93
93
  To install copy it to ~/.port_upgrade.conf
94
94
 
95
95