Bug 125936 - ports-mgmt/portupgrade -R fails if BUILD_DEP's are not installed.
Summary: ports-mgmt/portupgrade -R fails if BUILD_DEP's are not installed.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ruby (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-24 17:20 UTC by Michael Schout
Modified: 2011-07-25 12:30 UTC (History)
0 users

See Also:


Attachments
patch-bin-portupgrade.txt (410 bytes, patch)
2009-06-27 05:44 UTC, Bryan Drewery
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Schout 2008-07-24 17:20:03 UTC
	If any BUILD_DEP's of a package have been removed, running portupgrade -R pkgname will fail
        with an exception.  For example, if postgresql74-server is built, it has BUILD_DEP's that include
        bison and m4.  If you then remove bison and m4 (because they are not runtime dependencies), then later
        try to portupgrade -R postgresql-server, then portupgrade fails like this:

  [Gathering depends for databases/postgresql74-server ... done]
  [Exclude up-to-date packages ...... done]
  /usr/local/lib/ruby/site_ruby/1.8/pkginfo.rb:74:in `initialize': : Not in due form: <name>-<version> (ArgumentError)
        from /usr/local/sbin/portupgrade:931:in `new'
        from /usr/local/sbin/portupgrade:931:in `do_upgrade'
        from /usr/local/sbin/portupgrade:815:in `main'
        from /usr/local/sbin/portupgrade:811:in `each'
        from /usr/local/sbin/portupgrade:811:in `main'
        from /usr/local/lib/ruby/1.8/optparse.rb:785:in `initialize'
        from /usr/local/sbin/portupgrade:229:in `new'
        from /usr/local/sbin/portupgrade:229:in `main'
        from /usr/local/sbin/portupgrade:2208

  This error is raised because of this section in portupgrade:

        if $upward_recursive || $config
          dep = []
          get_all_depends(origin).each do |d|
            dep << $pkgdb.deorigin(d).to_s
          end
          depends |= dep if $upward_recursive
        end

  The problem is that $pkgdb.deorigin(d).to_s returns an empty string if the dependency is not
  installed, which means you end up with a blank entry in the "depends" array.

Fix: 

Probably add the missing build deps to the install tasks.
How-To-Repeat:   Build any port that has BUILD_DEP's, then uninstall one or more of the BUILD_DEP's,
  and do portupgrade -Rf portname
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2008-07-25 00:14:09 UTC
Responsible Changed
From-To: freebsd-ports-bugs->sem

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Michael Schout 2008-09-18 20:31:50 UTC
Thanks.  Unfortunately this patch does not work for 2 reasons.

1: I think you meant to use upgrade_tasks.compact! which is the in-place 
form of the compact() method.

However, even using the in place form fails because:

2: compact only removes nil's, not empty strings.

Here is a modified patch that works for me:

@@ -928,6 +930,9 @@
  end

  def do_upgrade(pkgname)
+  if pkgname.nil? or pkgname.empty?
+    return;
+  end
    pkg = PkgInfo.new(pkgname)

    origin = $task_options[pkgname][:origin]
Comment 3 Bryan Drewery 2009-06-27 05:44:55 UTC
I ran into this issue myself this week. I think this could even be
possible if the new version of an installed port has a new dependency.

My patch simply ignores the bad value from deorigin and has worked just
fine:

-                   dep << $pkgdb.deorigin(d).to_s
+                   dep_origin = $pkgdb.deorigin(d).to_s
+                   dep << dep_origin if dep_origin != ''


Bryan
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2009-07-25 02:48:19 UTC
Responsible Changed
From-To: sem->ruby

sem@ has turned over maintainership of portupgrade to the ruby mailing list.
Comment 5 Stanislav Sedov 2009-10-27 13:42:01 UTC
Hello, guys!

Sorry for delay in processing of this PR!
I wonder if this problem is still relevant?
I seem to unable to reproduce this issue :-(
Have you figured out any strightforward way
to repdoduce this?

Thanks!

-- 
Stanislav Sedov
ST4096-RIPE
Comment 6 Bryan Drewery 2009-10-27 14:57:21 UTC
Try force deleting a build dependency, like libtool, then portupgrading
a port which needs it.

Bryan

Stanislav Sedov wrote:
> Hello, guys!
>
> Sorry for delay in processing of this PR!
> I wonder if this problem is still relevant?
> I seem to unable to reproduce this issue :-(
> Have you figured out any strightforward way
> to repdoduce this?
>
> Thanks!
>
>
Comment 7 dfilter service freebsd_committer freebsd_triage 2009-10-27 14:59:45 UTC
stas        2009-10-27 14:59:37 UTC

  FreeBSD projects repository

  Modified files:
    pkgtools/bin         portupgrade 
  Log:
  - Do not try to update dependency if it is not installed.  Several
    people reported failures that may be related to this.
  
  PR:             ports/125936 (possibly)
  
  Revision  Changes    Path
  1.63      +4 -1      projects/pkgtools/bin/portupgrade
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 8 Stanislav Sedov 2009-10-27 15:10:42 UTC
On Tue, 27 Oct 2009 09:57:21 -0500
Bryan Drewery <bryan@shatow.net> mentioned:

> Try force deleting a build dependency, like libtool, then portupgrading
> a port which needs it.
> 

Yeah, I tried that but I can't reproduce the failure.  Anyway, I committed
the patch just now that may be able to fix this problem.  If you can reproduce
this can you, plese, test the patch attached?

Thanks!

--- bin/portupgrade     26 Oct 2009 14:47:49 -0000      1.62
+++ bin/portupgrade     27 Oct 2009 14:59:37 -0000      1.63
@@ -631,7 +631,10 @@

                if $upward_recursive || $config
                  dep = []
                  get_all_depends(origin).each do |d|
-                   dep << $pkgdb.deorigin(d).to_s
+                   newdep = $pkgdb.deorigin(d)
+                   unless newdep.nil? then
+                     dep << newdep.to_s
+                   end
                  end
                  depends |= dep if $upward_recursive
                end

-- 
Stanislav Sedov
ST4096-RIPE
Comment 9 Philip M. Gollucci freebsd_committer freebsd_triage 2010-09-10 00:10:19 UTC
Responsible Changed
From-To: ruby->pgollucci

I will take it
Comment 10 Philip M. Gollucci freebsd_committer freebsd_triage 2010-09-24 07:21:30 UTC
Responsible Changed
From-To: pgollucci->freebsd-ports-bugs

going to have enotime for the next 2 weeks, sorry
Comment 11 Steve Price freebsd_committer freebsd_triage 2011-01-03 17:15:18 UTC
Responsible Changed
From-To: freebsd-ports-bugs->ruby

Over to maintainer(s).
Comment 12 Bryan Drewery 2011-07-23 18:08:38 UTC
Looks like the latest release has fixed this in the code, so this PR can
probably be closed.

> get_all_depends(origin).each do |d|
>  newdep = $pkgdb.deorigin(d)
>  unless newdep.nil? then
>    dep << newdep.to_s
>  end
> end


Bryan Drewery
Comment 13 Tilman Keskinoz freebsd_committer freebsd_triage 2011-07-25 12:29:11 UTC
State Changed
From-To: open->closed

Bryan reports that this issue is fixed with the latest release