portupgrade small hacks

Hello everyone.
First, sorry for my bad english.
I use FreeBSD as desktop more than 3 years. Also, i need to use Gentoo Linux sometimes.
I find some of gentoo's portage some features that interesting and think it's would be great to see similar in FreeBSD ports.

1. Print information about currently upgrading port in title of terminal. I upgrading my ports with portupgrade -a, and i think it's would be great to see status of overall upgrade (ex. 14/17 - "upgrading 14th port of 17 that's needs upgrade) and name of currently upgrading port. I don't know ruby (portupgrade is writing on it), so currently i only write package name in title. But i think it's need some corrections (normalize title after break upgrade and ended upgrade). This is my small patch for installed portupgrade:​

Code:
      --- orig_portupgrade	2009-10-14 12:50:42.000000000 +0400
      +++ portupgrade	2009-10-14 12:56:27.000000000 +0400
      @@ -524,6 +524,11 @@
       
           $interrupt_proc = result_proc
       
      +    $isterm = false
      +    if `echo $TERM`.chomp.eql? "xterm"
      +	$isterm = true
      +    end
      +
           begin
             init_global
             init_pkgtools_global
      @@ -798,20 +803,20 @@
             exit 64
           end
       
      -    ntasks = upgrade_tasks.size + install_tasks.size
      -    ctask = 0
      +    $ntasks = upgrade_tasks.size + install_tasks.size
      +    $ctask = 0
       
           $current_pkgname = ''
           install_tasks.each do |origin| 
      -      ctask += 1
      -      setproctitle('[%d/%d] %s', ctask, ntasks, origin)
      +      $ctask += 1
      +      setproctitle('[%d/%d] %s', $ctask, $ntasks, origin)
             do_install(origin)
             progress_message "** Install tasks #{install_tasks.length}: #{$results.summary}" if $emit_summaries || $verbose
           end
       
           upgrade_tasks.each do |pkgname|
      -      ctask += 1
      -      setproctitle('[%d/%d] %s', ctask, ntasks, pkgname)
      +      $ctask += 1
      +      setproctitle('[%d/%d] %s', $ctask, $ntasks, pkgname)
             $current_pkgname = pkgname
             do_upgrade(pkgname)
             progress_message "** Upgrade tasks #{upgrade_tasks.length}: #{$results.summary}" if $emit_summaries || $verbose
      @@ -823,6 +828,29 @@
         stty_sane unless $results.empty?
       
         timer_end("Session")
      +  settermtitle(-1,nil,nil,nil,nil,nil)
      +end
      +
      +def settermtitle(t,cur,tot,old,new,orig)
      +	if $isterm 
      +		case t
      +			when -1
      +				msg = "ended"
      +			when 1
      +				msg = "[ #{cur} / #{tot} ]: Fetching the distfile(s) for '#{new}' (#{orig})"
      +			when 2
      +				msg = "[ #{cur} / #{tot} ]: Upgrading '#{old}' to '#{new}' (#{orig})"
      +			when 3
      +				msg = "[ #{cur} / #{tot} ]: Downgrading '#{old}' to '#{new}' (#{orig})"
      +			when 4
      +				msg = "[ #{cur} / #{tot} ]: Reinstalling '#{old}' (#{orig})"
      +			when 5
      +				msg = "[ #{cur} / #{tot} ]: Installing '#{new}' from a package"
      +			when 6
      +				msg = "[ #{cur} / #{tot} ]: Installing '#{new}' from a port (#{orig})"
      +		end
      +		print "\033]0;portupgrade" + msg + "\007"
      +	end
       end
       
       # Returns:
      @@ -1349,17 +1377,21 @@
         if $fetch_only
           timer_start(time_key = "Fetch for #{origin}")
           progress_message "Fetching the distfile(s) for '#{newpkgname}' (#{origin})"
      +	settermtitle(1,$ctask,$ntasks,nil,newpkgname,origin)
         else
           case service
           when :upgrade
             time_key = "Upgrade of #{origin}"
             msg = "Upgrading '#{oldpkgname}' to '#{newpkgname}' (#{origin})"
      +	  settermtitle(2,$ctask,$ntasks,oldpkgname,newpkgname,origin)
           when :downgrade
             time_key = "Downgrade of #{origin}"
             msg = "Downgrading '#{oldpkgname}' to '#{newpkgname}' (#{origin})"
      +	  settermtitle(3,$ctask,$ntasks,oldpkgname,newpkgname,origin)
           when :reinstall
             time_key = "Reinstallation of #{origin}"
             msg = "Reinstalling '#{oldpkgname}' (#{origin})"
      +	  settermtitle(4,$ctask,$ntasks,oldpkgname,nil,origin)
           end
       
           if have_package
      @@ -1611,8 +1643,10 @@
       
         if have_package
           progress_message "Installing '#{newpkgname}' from a package"
      +	settermtitle(5,$ctask,$ntasks,nil,newpkgname,nil)
         else
           progress_message "Installing '#{newpkgname}' from a port (#{origin})"
      +	settermtitle(6,$ctask,$ntasks,nil,newpkgname,origin)
         end
       
         if $noexecute

2. Similar as in "1", but for all ports system, for new installing ports with all depends via [cmd=]cd /usr/ports/blah && make install clean[/cmd]​

3. Downloading distfiles in background. For example, portupgrade -a - first port rebuilding and the second fetch distfiles in same time. Or similar with depends for new port installing.​

If you are finding it's interesting and would like to talk about it's realisation, please write here (in this topic) or contact me dirrectly via:
jabber: xa (at) nobody.su
mail: same as jabber id

Or if you think these ideas are insane and unnecessary - please write why you think so. Thank you.
 
Back
Top