[71225] branches/gsoc10-configfiles

and.damore at macports.org and.damore at macports.org
Sun Sep 5 05:32:39 PDT 2010


Revision: 71225
          http://trac.macports.org/changeset/71225
Author:   and.damore at macports.org
Date:     2010-09-05 05:32:36 -0700 (Sun, 05 Sep 2010)
Log Message:
-----------
tarballs for GSoC10 code submit

Added Paths:
-----------
    branches/gsoc10-configfiles/code-submit/
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r68019.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69583.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69584.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69585.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69606.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69607.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69680.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69681.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69682.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69731.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69756.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70378.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70386.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70398.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70399.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70400.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70404.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70412.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70418.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70423.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70427.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70448.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70472.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70473.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70488.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70500.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70508.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70509.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70510.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70518.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70543.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70544.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70545.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70566.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70585.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70586.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70587.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70592.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70610.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70611.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70613.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70614.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70632.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70633.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70637.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70638.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70639.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70656.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70664.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70665.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70666.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70668.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70669.diff
    branches/gsoc10-configfiles/code-submit/Andrea_D'Amore.tar.bz2

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r68019.diff
===================================================================
Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69583.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69583.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69583.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,29 @@
+Index: src/macports1.0/macports.tcl
+===================================================================
+--- src/macports1.0/macports.tcl	(revision 69582)
++++ src/macports1.0/macports.tcl	(revision 69583)
+@@ -40,6 +40,7 @@
+ namespace eval macports {
+     namespace export bootstrap_options user_options portinterp_options open_mports ui_priorities port_phases 
+     variable bootstrap_options "\
++        config_paths config_files\
+         portdbpath libpath binpath auto_path extra_env sources_conf prefix portdbformat \
+         portinstalltype portarchivemode portarchivepath portarchivetype portautoclean \
+         porttrace portverbose keeplogs destroot_umask variants_conf rsync_server rsync_options \
+@@ -49,6 +50,7 @@
+         macportsuser proxy_override_env proxy_http proxy_https proxy_ftp proxy_rsync proxy_skip"
+     variable user_options "submitter_name submitter_email submitter_key"
+     variable portinterp_options "\
++        config_paths config_files\
+         portdbpath porturl portpath portbuildpath auto_path prefix prefix_frozen portsharepath \
+         registry.path registry.format registry.installtype portarchivemode portarchivepath \
+         portarchivetype portautoclean porttrace keeplogs portverbose destroot_umask rsync_server \
+@@ -425,6 +427,8 @@
+     }
+ 
+     global auto_path env tcl_platform
++    global macports::config_paths
++    global macports::config_files
+     global macports::autoconf::macports_conf_path
+     global macports::macports_user_dir
+     global macports::bootstrap_options

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69584.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69584.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69584.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,29 @@
+Index: src/macports1.0/macports.tcl
+===================================================================
+--- src/macports1.0/macports.tcl	(revision 69583)
++++ src/macports1.0/macports.tcl	(revision 69584)
+@@ -40,7 +40,6 @@
+ namespace eval macports {
+     namespace export bootstrap_options user_options portinterp_options open_mports ui_priorities port_phases 
+     variable bootstrap_options "\
+-        config_paths config_files\
+         portdbpath libpath binpath auto_path extra_env sources_conf prefix portdbformat \
+         portinstalltype portarchivemode portarchivepath portarchivetype portautoclean \
+         porttrace portverbose keeplogs destroot_umask variants_conf rsync_server rsync_options \
+@@ -50,7 +49,6 @@
+         macportsuser proxy_override_env proxy_http proxy_https proxy_ftp proxy_rsync proxy_skip"
+     variable user_options "submitter_name submitter_email submitter_key"
+     variable portinterp_options "\
+-        config_paths config_files\
+         portdbpath porturl portpath portbuildpath auto_path prefix prefix_frozen portsharepath \
+         registry.path registry.format registry.installtype portarchivemode portarchivepath \
+         portarchivetype portautoclean porttrace keeplogs portverbose destroot_umask rsync_server \
+@@ -427,8 +425,6 @@
+     }
+ 
+     global auto_path env tcl_platform
+-    global macports::config_paths
+-    global macports::config_files
+     global macports::autoconf::macports_conf_path
+     global macports::macports_user_dir
+     global macports::bootstrap_options

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69585.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69585.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69585.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,29 @@
+Index: src/macports1.0/macports.tcl
+===================================================================
+--- src/macports1.0/macports.tcl	(revision 69584)
++++ src/macports1.0/macports.tcl	(revision 69585)
+@@ -40,6 +40,7 @@
+ namespace eval macports {
+     namespace export bootstrap_options user_options portinterp_options open_mports ui_priorities port_phases 
+     variable bootstrap_options "\
++        config_paths config_files\
+         portdbpath libpath binpath auto_path extra_env sources_conf prefix portdbformat \
+         portinstalltype portarchivemode portarchivepath portarchivetype portautoclean \
+         porttrace portverbose keeplogs destroot_umask variants_conf rsync_server rsync_options \
+@@ -49,6 +50,7 @@
+         macportsuser proxy_override_env proxy_http proxy_https proxy_ftp proxy_rsync proxy_skip"
+     variable user_options "submitter_name submitter_email submitter_key"
+     variable portinterp_options "\
++        config_paths config_files\
+         portdbpath porturl portpath portbuildpath auto_path prefix prefix_frozen portsharepath \
+         registry.path registry.format registry.installtype portarchivemode portarchivepath \
+         portarchivetype portautoclean porttrace keeplogs portverbose destroot_umask rsync_server \
+@@ -425,6 +427,8 @@
+     }
+ 
+     global auto_path env tcl_platform
++    global macports::config_paths
++    global macports::config_files
+     global macports::autoconf::macports_conf_path
+     global macports::macports_user_dir
+     global macports::bootstrap_options

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69606.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69606.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69606.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,21 @@
+Index: src/port1.0/portmain.tcl
+===================================================================
+--- src/port1.0/portmain.tcl	(revision 69605)
++++ src/port1.0/portmain.tcl	(revision 69606)
+@@ -51,6 +51,7 @@
+ options supported_archs depends_skip_archcheck
+ options copy_log_files
+ options compiler.cpath compiler.library_path
++options config_path config_files
+ 
+ # Order of option_proc and option_export matters. Filter before exporting.
+ 
+@@ -79,6 +80,8 @@
+ default worksrcdir {$distname}
+ default filespath {[file join $portpath $filesdir]}
+ default worksrcpath {[file join $workpath $worksrcdir]}
++default config_path {${prefix}/etc}
++default config_files {}
+ # empty list means all archs are supported
+ default supported_archs {}
+ default depends_skip_archcheck {}

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69607.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69607.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69607.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,29 @@
+Index: src/macports1.0/macports.tcl
+===================================================================
+--- src/macports1.0/macports.tcl	(revision 69606)
++++ src/macports1.0/macports.tcl	(revision 69607)
+@@ -40,7 +40,6 @@
+ namespace eval macports {
+     namespace export bootstrap_options user_options portinterp_options open_mports ui_priorities port_phases 
+     variable bootstrap_options "\
+-        config_paths config_files\
+         portdbpath libpath binpath auto_path extra_env sources_conf prefix portdbformat \
+         portinstalltype portarchivemode portarchivepath portarchivetype portautoclean \
+         porttrace portverbose keeplogs destroot_umask variants_conf rsync_server rsync_options \
+@@ -50,7 +49,6 @@
+         macportsuser proxy_override_env proxy_http proxy_https proxy_ftp proxy_rsync proxy_skip"
+     variable user_options "submitter_name submitter_email submitter_key"
+     variable portinterp_options "\
+-        config_paths config_files\
+         portdbpath porturl portpath portbuildpath auto_path prefix prefix_frozen portsharepath \
+         registry.path registry.format registry.installtype portarchivemode portarchivepath \
+         portarchivetype portautoclean porttrace keeplogs portverbose destroot_umask rsync_server \
+@@ -427,8 +425,6 @@
+     }
+ 
+     global auto_path env tcl_platform
+-    global macports::config_paths
+-    global macports::config_files
+     global macports::autoconf::macports_conf_path
+     global macports::macports_user_dir
+     global macports::bootstrap_options

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69680.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69680.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69680.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,45 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 69679)
++++ src/registry2.0/portimage.tcl	(revision 69680)
+@@ -449,12 +449,15 @@
+                     }
+ 
+                     set owner [registry::entry owner $file]
++                    ui_msg "GSOC: $file owner is \"$owner\""
+ 
+                     if {$owner != {} && $owner != $port} {
+                         # deactivate conflicting port if it is replaced_by this one
+                         set result [mportlookup [$owner name]]
+                         array unset portinfo
+                         array set portinfo [lindex $result 1]
++                        #GSoC10
++                        #here we'll check if you should replace a config file testing a --drop-config option from CLI
+                         if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^[$port name]\$"] != -1} {
+                             # we'll deactivate the owner later, but before activating our files
+                             set todeactivate($owner) yes
+@@ -522,7 +525,7 @@
+             # debug output of activate make more sense.
+             set theList [lsort -increasing -unique $files]
+             set rollback_filelist {}
+-
++            ui_msg "GSOC DBG: let's activate actual files"
+             registry::write {
+                 # Activate it, and catch errors so we can roll-back
+                 try {
+@@ -539,6 +542,7 @@
+                 }
+             }
+         } catch {*} {
++            ui_msg "GSOC DBG: rollback"
+             # roll back activation of this port
+             if {[info exists deactivate_this]} {
+                 _deactivate_contents $port $rollback_filelist yes yes
+@@ -664,6 +668,7 @@
+             return -code error $result
+         }
+     }
++    ui_msg "GSOC DBG: end of _activate_contents"
+ }
+ 
+ proc _deactivate_file {dstfile} {

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69681.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69681.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69681.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,14 @@
+
+Property changes on: src
+___________________________________________________________________
+Modified: svn:ignore
+   - config.h
+Makefile
+pkg_mkindex.sh
+
+   + config.h
+Makefile
+pkg_mkindex.sh
+thread2.6
+
+

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69682.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69682.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69682.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,4324 @@
+Index: configure
+===================================================================
+--- configure	(revision 69681)
++++ configure	(revision 69682)
+@@ -1,13 +1,13 @@
+ #! /bin/sh
+ # Guess values for system-dependent variables and create Makefiles.
+-# Generated by GNU Autoconf 2.65 for MacPorts 1.9.99.
++# Generated by GNU Autoconf 2.66 for MacPorts 1.9.99.
+ #
+ # Report bugs to <macports-dev at lists.macosforge.org>.
+ #
+ #
+ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+-# Inc.
++# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
++# Foundation, Inc.
+ #
+ #
+ # This configure script is free software; the Free Software Foundation
+@@ -319,7 +319,7 @@
+       test -d "$as_dir" && break
+     done
+     test -z "$as_dirs" || eval "mkdir $as_dirs"
+-  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
++  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+ 
+ 
+ } # as_fn_mkdir_p
+@@ -359,19 +359,19 @@
+ fi # as_fn_arith
+ 
+ 
+-# as_fn_error ERROR [LINENO LOG_FD]
+-# ---------------------------------
++# as_fn_error STATUS ERROR [LINENO LOG_FD]
++# ----------------------------------------
+ # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+ # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+-# script with status $?, using 1 if that was 0.
++# script with STATUS, using 1 if that was 0.
+ as_fn_error ()
+ {
+-  as_status=$?; test $as_status -eq 0 && as_status=1
+-  if test "$3"; then
+-    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
++  as_status=$1; test $as_status -eq 0 && as_status=1
++  if test "$4"; then
++    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
++    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+   fi
+-  $as_echo "$as_me: error: $1" >&2
++  $as_echo "$as_me: error: $2" >&2
+   as_fn_exit $as_status
+ } # as_fn_error
+ 
+@@ -533,7 +533,7 @@
+ exec 6>&1
+ 
+ # Name of the host.
+-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
++# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+ # so uname gets run too.
+ ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+ 
+@@ -688,6 +688,7 @@
+ UNZIP
+ TAR
+ SED
++OPENSSL
+ RSYNC
+ RMDIR
+ PATCH
+@@ -816,6 +817,7 @@
+ MTREE
+ CVS
+ SVN
++OPENSSL
+ RSYNC
+ SED
+ TAR
+@@ -936,7 +938,7 @@
+     ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+     # Reject names that are not valid shell variable names.
+     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+-      as_fn_error "invalid feature name: $ac_useropt"
++      as_fn_error $? "invalid feature name: $ac_useropt"
+     ac_useropt_orig=$ac_useropt
+     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+     case $ac_user_opts in
+@@ -962,7 +964,7 @@
+     ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+     # Reject names that are not valid shell variable names.
+     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+-      as_fn_error "invalid feature name: $ac_useropt"
++      as_fn_error $? "invalid feature name: $ac_useropt"
+     ac_useropt_orig=$ac_useropt
+     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+     case $ac_user_opts in
+@@ -1166,7 +1168,7 @@
+     ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+     # Reject names that are not valid shell variable names.
+     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+-      as_fn_error "invalid package name: $ac_useropt"
++      as_fn_error $? "invalid package name: $ac_useropt"
+     ac_useropt_orig=$ac_useropt
+     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+     case $ac_user_opts in
+@@ -1182,7 +1184,7 @@
+     ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+     # Reject names that are not valid shell variable names.
+     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+-      as_fn_error "invalid package name: $ac_useropt"
++      as_fn_error $? "invalid package name: $ac_useropt"
+     ac_useropt_orig=$ac_useropt
+     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+     case $ac_user_opts in
+@@ -1212,8 +1214,8 @@
+   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+     x_libraries=$ac_optarg ;;
+ 
+-  -*) as_fn_error "unrecognized option: \`$ac_option'
+-Try \`$0 --help' for more information."
++  -*) as_fn_error $? "unrecognized option: \`$ac_option'
++Try \`$0 --help' for more information"
+     ;;
+ 
+   *=*)
+@@ -1221,7 +1223,7 @@
+     # Reject names that are not valid shell variable names.
+     case $ac_envvar in #(
+       '' | [0-9]* | *[!_$as_cr_alnum]* )
+-      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
++      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+     esac
+     eval $ac_envvar=\$ac_optarg
+     export $ac_envvar ;;
+@@ -1239,13 +1241,13 @@
+ 
+ if test -n "$ac_prev"; then
+   ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+-  as_fn_error "missing argument to $ac_option"
++  as_fn_error $? "missing argument to $ac_option"
+ fi
+ 
+ if test -n "$ac_unrecognized_opts"; then
+   case $enable_option_checking in
+     no) ;;
+-    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
++    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+     *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+   esac
+ fi
+@@ -1268,7 +1270,7 @@
+     [\\/$]* | ?:[\\/]* )  continue;;
+     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+   esac
+-  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
++  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+ done
+ 
+ # There might be people who depend on the old broken behavior: `$host'
+@@ -1282,8 +1284,8 @@
+ if test "x$host_alias" != x; then
+   if test "x$build_alias" = x; then
+     cross_compiling=maybe
+-    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+-    If a cross compiler is detected then cross compile mode will be used." >&2
++    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
++    If a cross compiler is detected then cross compile mode will be used" >&2
+   elif test "x$build_alias" != "x$host_alias"; then
+     cross_compiling=yes
+   fi
+@@ -1298,9 +1300,9 @@
+ ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ ac_ls_di=`ls -di .` &&
+ ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+-  as_fn_error "working directory cannot be determined"
++  as_fn_error $? "working directory cannot be determined"
+ test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+-  as_fn_error "pwd does not report name of working directory"
++  as_fn_error $? "pwd does not report name of working directory"
+ 
+ 
+ # Find the source files, if location was not specified.
+@@ -1339,11 +1341,11 @@
+ fi
+ if test ! -r "$srcdir/$ac_unique_file"; then
+   test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+-  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
++  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+ fi
+ ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ ac_abs_confdir=`(
+-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
++	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+ 	pwd)`
+ # When building in place, set srcdir=.
+ if test "$ac_abs_confdir" = "$ac_pwd"; then
+@@ -1383,7 +1385,7 @@
+       --help=short        display options specific to this package
+       --help=recursive    display the short help of all the included packages
+   -V, --version           display version information and exit
+-  -q, --quiet, --silent   do not print \`checking...' messages
++  -q, --quiet, --silent   do not print \`checking ...' messages
+       --cache-file=FILE   cache test results in FILE [disabled]
+   -C, --config-cache      alias for \`--cache-file=config.cache'
+   -n, --no-create         do not create output files
+@@ -1495,6 +1497,7 @@
+   MTREE       path to mtree command
+   CVS         path to cvs command
+   SVN         path to svn command
++  OPENSSL     path to openssl command
+   RSYNC       path to rsync command
+   SED         path to sed command
+   TAR         path to tar command
+@@ -1575,9 +1578,9 @@
+ if $ac_init_version; then
+   cat <<\_ACEOF
+ MacPorts configure 1.9.99
+-generated by GNU Autoconf 2.65
++generated by GNU Autoconf 2.66
+ 
+-Copyright (C) 2009 Free Software Foundation, Inc.
++Copyright (C) 2010 Free Software Foundation, Inc.
+ This configure script is free software; the Free Software Foundation
+ gives unlimited permission to copy, distribute and modify it.
+ _ACEOF
+@@ -1755,10 +1758,10 @@
+ ac_fn_objc_check_header_mongrel ()
+ {
+   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+-  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++  if eval "test \"\${$3+set}\"" = set; then :
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval "test \"\${$3+set}\"" = set; then :
+   $as_echo_n "(cached) " >&6
+ fi
+ eval ac_res=\$$3
+@@ -1817,17 +1820,15 @@
+ $as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+-( cat <<\_ASBOX
+-## ------------------------------------------------ ##
++( $as_echo "## ------------------------------------------------ ##
+ ## Report this to macports-dev at lists.macosforge.org ##
+-## ------------------------------------------------ ##
+-_ASBOX
++## ------------------------------------------------ ##"
+      ) | sed "s/^/$as_me: WARNING:     /" >&2
+     ;;
+ esac
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval "test \"\${$3+set}\"" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   eval "$3=\$ac_header_compiler"
+@@ -1891,7 +1892,7 @@
+   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval "test \"\${$3+set}\"" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -2046,10 +2047,10 @@
+ ac_fn_c_check_header_mongrel ()
+ {
+   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+-  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++  if eval "test \"\${$3+set}\"" = set; then :
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval "test \"\${$3+set}\"" = set; then :
+   $as_echo_n "(cached) " >&6
+ fi
+ eval ac_res=\$$3
+@@ -2108,17 +2109,15 @@
+ $as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+-( cat <<\_ASBOX
+-## ------------------------------------------------ ##
++( $as_echo "## ------------------------------------------------ ##
+ ## Report this to macports-dev at lists.macosforge.org ##
+-## ------------------------------------------------ ##
+-_ASBOX
++## ------------------------------------------------ ##"
+      ) | sed "s/^/$as_me: WARNING:     /" >&2
+     ;;
+ esac
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval "test \"\${$3+set}\"" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   eval "$3=\$ac_header_compiler"
+@@ -2139,7 +2138,7 @@
+   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval "test \"\${$3+set}\"" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -2198,15 +2197,18 @@
+ 
+ } # ac_fn_c_check_func
+ 
+-# ac_fn_c_check_decl LINENO SYMBOL VAR
+-# ------------------------------------
+-# Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
++# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
++# ---------------------------------------------
++# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
++# accordingly.
+ ac_fn_c_check_decl ()
+ {
+   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5
+-$as_echo_n "checking whether $2 is declared... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++  as_decl_name=`echo $2|sed 's/ *(.*//'`
++  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
++  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
++$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
++if eval "test \"\${$3+set}\"" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -2215,9 +2217,13 @@
+ int
+ main ()
+ {
+-#ifndef $2
+-  (void) $2;
++#ifndef $as_decl_name
++#ifdef __cplusplus
++  (void) $as_decl_use;
++#else
++  (void) $as_decl_name;
+ #endif
++#endif
+ 
+   ;
+   return 0;
+@@ -2241,7 +2247,7 @@
+ running configure, to aid debugging if configure makes a mistake.
+ 
+ It was created by MacPorts $as_me 1.9.99, which was
+-generated by GNU Autoconf 2.65.  Invocation command line was
++generated by GNU Autoconf 2.66.  Invocation command line was
+ 
+   $ $0 $@
+ 
+@@ -2351,11 +2357,9 @@
+   {
+     echo
+ 
+-    cat <<\_ASBOX
+-## ---------------- ##
++    $as_echo "## ---------------- ##
+ ## Cache variables. ##
+-## ---------------- ##
+-_ASBOX
++## ---------------- ##"
+     echo
+     # The following way of writing the cache mishandles newlines in values,
+ (
+@@ -2389,11 +2393,9 @@
+ )
+     echo
+ 
+-    cat <<\_ASBOX
+-## ----------------- ##
++    $as_echo "## ----------------- ##
+ ## Output variables. ##
+-## ----------------- ##
+-_ASBOX
++## ----------------- ##"
+     echo
+     for ac_var in $ac_subst_vars
+     do
+@@ -2406,11 +2408,9 @@
+     echo
+ 
+     if test -n "$ac_subst_files"; then
+-      cat <<\_ASBOX
+-## ------------------- ##
++      $as_echo "## ------------------- ##
+ ## File substitutions. ##
+-## ------------------- ##
+-_ASBOX
++## ------------------- ##"
+       echo
+       for ac_var in $ac_subst_files
+       do
+@@ -2424,11 +2424,9 @@
+     fi
+ 
+     if test -s confdefs.h; then
+-      cat <<\_ASBOX
+-## ----------- ##
++      $as_echo "## ----------- ##
+ ## confdefs.h. ##
+-## ----------- ##
+-_ASBOX
++## ----------- ##"
+       echo
+       cat confdefs.h
+       echo
+@@ -2483,7 +2481,12 @@
+ ac_site_file1=NONE
+ ac_site_file2=NONE
+ if test -n "$CONFIG_SITE"; then
+-  ac_site_file1=$CONFIG_SITE
++  # We do not want a PATH search for config.site.
++  case $CONFIG_SITE in #((
++    -*)  ac_site_file1=./$CONFIG_SITE;;
++    */*) ac_site_file1=$CONFIG_SITE;;
++    *)   ac_site_file1=./$CONFIG_SITE;;
++  esac
+ elif test "x$prefix" != xNONE; then
+   ac_site_file1=$prefix/share/config.site
+   ac_site_file2=$prefix/etc/config.site
+@@ -2498,7 +2501,11 @@
+     { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+ $as_echo "$as_me: loading site script $ac_site_file" >&6;}
+     sed 's/^/| /' "$ac_site_file" >&5
+-    . "$ac_site_file"
++    . "$ac_site_file" \
++      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "failed to load site script $ac_site_file
++See \`config.log' for more details" "$LINENO" 5; }
+   fi
+ done
+ 
+@@ -2574,7 +2581,7 @@
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+   { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+ $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+-  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
++  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+ fi
+ ## -------------------- ##
+ ## Main body of script. ##
+@@ -2593,16 +2600,22 @@
+ 
+ ac_aux_dir=
+ for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+-  for ac_t in install-sh install.sh shtool; do
+-    if test -f "$ac_dir/$ac_t"; then
+-      ac_aux_dir=$ac_dir
+-      ac_install_sh="$ac_aux_dir/$ac_t -c"
+-      break 2
+-    fi
+-  done
++  if test -f "$ac_dir/install-sh"; then
++    ac_aux_dir=$ac_dir
++    ac_install_sh="$ac_aux_dir/install-sh -c"
++    break
++  elif test -f "$ac_dir/install.sh"; then
++    ac_aux_dir=$ac_dir
++    ac_install_sh="$ac_aux_dir/install.sh -c"
++    break
++  elif test -f "$ac_dir/shtool"; then
++    ac_aux_dir=$ac_dir
++    ac_install_sh="$ac_aux_dir/shtool install -c"
++    break
++  fi
+ done
+ if test -z "$ac_aux_dir"; then
+-  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
++  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+ fi
+ 
+ # These three variables are undocumented and unsupported,
+@@ -2616,7 +2629,7 @@
+ 
+ # Make sure we can run config.sub.
+ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+-  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
++  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+ 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+ $as_echo_n "checking build system type... " >&6; }
+@@ -2627,16 +2640,16 @@
+ test "x$ac_build_alias" = x &&
+   ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+ test "x$ac_build_alias" = x &&
+-  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
++  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+-  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
++  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+ 
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+ $as_echo "$ac_cv_build" >&6; }
+ case $ac_cv_build in
+ *-*-*) ;;
+-*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
++*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+ esac
+ build=$ac_cv_build
+ ac_save_IFS=$IFS; IFS='-'
+@@ -2661,7 +2674,7 @@
+   ac_cv_host=$ac_cv_build
+ else
+   ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+-    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
++    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+ fi
+ 
+ fi
+@@ -2669,7 +2682,7 @@
+ $as_echo "$ac_cv_host" >&6; }
+ case $ac_cv_host in
+ *-*-*) ;;
+-*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
++*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+ esac
+ host=$ac_cv_host
+ ac_save_IFS=$IFS; IFS='-'
+@@ -2694,7 +2707,7 @@
+   ac_cv_target=$ac_cv_host
+ else
+   ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
+-    as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
++    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
+ fi
+ 
+ fi
+@@ -2702,7 +2715,7 @@
+ $as_echo "$ac_cv_target" >&6; }
+ case $ac_cv_target in
+ *-*-*) ;;
+-*) as_fn_error "invalid value of canonical target" "$LINENO" 5;;
++*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
+ esac
+ target=$ac_cv_target
+ ac_save_IFS=$IFS; IFS='-'
+@@ -2891,7 +2904,7 @@
+ 
+ case "$MACOSX_VERSION" in
+   10.0*|10.1*|10.2*|10.3*)
+-    as_fn_error "This version of Mac OS X is not supported
++    as_fn_error $? "This version of Mac OS X is not supported
+                   Please upgrade at http://store.apple.com/" "$LINENO" 5
+     ;;
+   10.4.[0-9]|10.4.10|10.5.[0-7]|10.6.[0-1])
+@@ -3251,8 +3264,8 @@
+ 
+ test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "no acceptable C compiler found in \$PATH
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "no acceptable C compiler found in \$PATH
++See \`config.log' for more details" "$LINENO" 5; }
+ 
+ # Provide some information about the compiler.
+ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+@@ -3366,9 +3379,8 @@
+ 
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-{ as_fn_set_status 77
+-as_fn_error "C compiler cannot create executables
+-See \`config.log' for more details." "$LINENO" 5; }; }
++as_fn_error 77 "C compiler cannot create executables
++See \`config.log' for more details" "$LINENO" 5; }
+ else
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ $as_echo "yes" >&6; }
+@@ -3410,8 +3422,8 @@
+ else
+   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "cannot compute suffix of executables: cannot compile and link
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "cannot compute suffix of executables: cannot compile and link
++See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ rm -f conftest conftest$ac_cv_exeext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+@@ -3468,9 +3480,9 @@
+     else
+ 	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "cannot run C compiled programs.
++as_fn_error $? "cannot run C compiled programs.
+ If you meant to cross compile, use \`--host'.
+-See \`config.log' for more details." "$LINENO" 5; }
++See \`config.log' for more details" "$LINENO" 5; }
+     fi
+   fi
+ fi
+@@ -3521,8 +3533,8 @@
+ 
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "cannot compute suffix of object files: cannot compile
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "cannot compute suffix of object files: cannot compile
++See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ rm -f conftest.$ac_cv_objext conftest.$ac_ext
+ fi
+@@ -4090,7 +4102,7 @@
+ $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+ set x ${MAKE-make}
+ ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+-if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   cat >conftest.make <<\_ACEOF
+@@ -4098,7 +4110,7 @@
+ all:
+ 	@echo '@@@%%%=$(MAKE)=@@@%%%'
+ _ACEOF
+-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
++# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+ case `${MAKE-make} -f conftest.make 2>/dev/null` in
+   *@@@%%%=?*=@@@%%%*)
+     eval ac_cv_prog_make_${ac_make}_set=yes;;
+@@ -4810,6 +4822,46 @@
+ fi
+ 
+ 
++# Extract the first word of "openssl", so it can be a program name with args.
++set dummy openssl; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if test "${ac_cv_path_OPENSSL+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  case $OPENSSL in
++  [\\/]* | ?:[\\/]*)
++  ac_cv_path_OPENSSL="$OPENSSL" # Let the user override the test with a path.
++  ;;
++  *)
++  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++  IFS=$as_save_IFS
++  test -z "$as_dir" && as_dir=.
++    for ac_exec_ext in '' $ac_executable_extensions; do
++  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++    ac_cv_path_OPENSSL="$as_dir/$ac_word$ac_exec_ext"
++    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++    break 2
++  fi
++done
++  done
++IFS=$as_save_IFS
++
++  ;;
++esac
++fi
++OPENSSL=$ac_cv_path_OPENSSL
++if test -n "$OPENSSL"; then
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENSSL" >&5
++$as_echo "$OPENSSL" >&6; }
++else
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++
+ # Extract the first word of "sed", so it can be a program name with args.
+ set dummy sed; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+@@ -5607,6 +5659,7 @@
+ 
+ 
+ 
++
+ 	# Extract the first word of "sed", so it can be a program name with args.
+ set dummy sed; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+@@ -5649,7 +5702,7 @@
+ 
+ 
+ 	if test "x$SED" = "x"; then
+-		as_fn_error "cannot find sed. Is sed installed?" "$LINENO" 5
++		as_fn_error $? "cannot find sed. Is sed installed?" "$LINENO" 5
+ 	fi
+ 
+ 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which sed flag to use for extended regexp" >&5
+@@ -6398,8 +6451,8 @@
+ else
+   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "Objective C preprocessor \"$OBJCPP\" fails sanity check
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "Objective C preprocessor \"$OBJCPP\" fails sanity check
++See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ 
+ ac_ext=m
+@@ -6460,7 +6513,7 @@
+   done
+ IFS=$as_save_IFS
+   if test -z "$ac_cv_path_GREP"; then
+-    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
++    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+   fi
+ else
+   ac_cv_path_GREP=$GREP
+@@ -6526,7 +6579,7 @@
+   done
+ IFS=$as_save_IFS
+   if test -z "$ac_cv_path_EGREP"; then
+-    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
++    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+   fi
+ else
+   ac_cv_path_EGREP=$EGREP
+@@ -6658,8 +6711,7 @@
+   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_objc_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+ "
+-eval as_val=\$$as_ac_Header
+-   if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+   cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+ _ACEOF
+@@ -6687,7 +6739,7 @@
+ 			no)
+ 				;;
+ 			*)
+-				as_fn_error "${with_objc_runtime} is not a valid argument to --with-objc-runtime. Please specify either \"GNU\" or \"apple\"" "$LINENO" 5
++				as_fn_error $? "${with_objc_runtime} is not a valid argument to --with-objc-runtime. Please specify either \"GNU\" or \"apple\"" "$LINENO" 5
+ 				;;
+ 		esac
+ 	fi
+@@ -6711,7 +6763,7 @@
+ _ACEOF
+ 
+ else
+-  as_fn_error "Can't locate Objective C runtime headers" "$LINENO" 5
++  as_fn_error $? "Can't locate Objective C runtime headers" "$LINENO" 5
+ fi
+ 
+ done
+@@ -6956,8 +7008,8 @@
+ 	else
+ 			{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "Could not locate a working Objective-C runtime.
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "Could not locate a working Objective-C runtime.
++See \`config.log' for more details" "$LINENO" 5; }
+ 	fi
+ 
+ 	# Restore LIBS & OBJCFLAGS
+@@ -6999,7 +7051,7 @@
+ 			no)
+ 				;;
+ 			*)
+-				as_fn_error "${with_objc_foundation} is not a valid argument to --with-objc-foundation. Please specify either \"GNU\" or \"apple\"" "$LINENO" 5
++				as_fn_error $? "${with_objc_foundation} is not a valid argument to --with-objc-foundation. Please specify either \"GNU\" or \"apple\"" "$LINENO" 5
+ 				;;
+ 		esac
+ 	fi
+@@ -7080,7 +7132,7 @@
+ 		GNUSTEP_CONFIG=/usr/bin/gnustep-config
+ 		if test ! -x "${GNUSTEP_CONFIG}" -a x"${GNUSTEP_SYSTEM_ROOT}" == x; then
+ 			if test x"${with_objc_foundation}" == x"GNUstep"; then
+-				as_fn_error "GNUSTEP_SYSTEM_ROOT is not defined in your environment, preventing the use of GNUstep's Foundation library" "$LINENO" 5
++				as_fn_error $? "GNUSTEP_SYSTEM_ROOT is not defined in your environment, preventing the use of GNUstep's Foundation library" "$LINENO" 5
+ 			else
+ 				{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: GNUSTEP_SYSTEM_ROOT is not defined in your environment, preventing the use of GNUstep's Foundation library" >&5
+ $as_echo "$as_me: WARNING: GNUSTEP_SYSTEM_ROOT is not defined in your environment, preventing the use of GNUstep's Foundation library" >&2;}
+@@ -7186,7 +7238,7 @@
+ 		{ $as_echo "$as_me:${as_lineno-$LINENO}: Not using Foundation implementation" >&5
+ $as_echo "$as_me: Not using Foundation implementation" >&6;}
+ 	else
+-		as_fn_error "Could not find a working Foundation implementation" "$LINENO" 5
++		as_fn_error $? "Could not find a working Foundation implementation" "$LINENO" 5
+ 	fi
+ 
+ 
+@@ -7476,7 +7528,7 @@
+ # Check for paths
+ 
+ if test x$prefix = x/usr/local; then
+-    as_fn_error "Installing MacPorts into /usr/local is not supported" "$LINENO" 5
++    as_fn_error $? "Installing MacPorts into /usr/local is not supported" "$LINENO" 5
+ fi
+ 
+ 
+@@ -7495,7 +7547,7 @@
+  	  if test -d "$portsdir" -a -e "$portsdir/PortIndex" ; then
+  		:
+  	  else
+- 		as_fn_error "$portsdir not a valid ports tree" "$LINENO" 5
++ 		as_fn_error $? "$portsdir not a valid ports tree" "$LINENO" 5
+  	  fi
+  	else
+  		 		if test "x$PORTS_DIR_DEFAULT" != "x" ; then
+@@ -7568,7 +7620,7 @@
+ 	    TCL_PACKAGE_DIR=${PACKAGE_DIR_NATIVE}
+ 
+ 		if test x"${ac_cv_c_tclpkgd}" = x ; then
+-			as_fn_error "Tcl package directory not found.  Please specify its location with --with-tclpackage" "$LINENO" 5
++			as_fn_error $? "Tcl package directory not found.  Please specify its location with --with-tclpackage" "$LINENO" 5
+ 	    else
+ 			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_cv_c_tclpkgd}" >&5
+ $as_echo "${ac_cv_c_tclpkgd}" >&6; }
+@@ -7908,8 +7960,8 @@
+ else
+   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "C preprocessor \"$CPP\" fails sanity check
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
++See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ 
+ ac_ext=c
+@@ -8036,7 +8088,7 @@
+   as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
+ $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
+-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval "test \"\${$as_ac_Header+set}\"" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -8063,8 +8115,7 @@
+ eval ac_res=\$$as_ac_Header
+ 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+ $as_echo "$ac_res" >&6; }
+-eval as_val=\$$as_ac_Header
+-   if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+   cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+ _ACEOF
+@@ -8236,8 +8287,7 @@
+ do :
+   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+-eval as_val=\$$as_ac_Header
+-   if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+   cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+ _ACEOF
+@@ -8254,8 +8304,7 @@
+ do :
+   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+-eval as_val=\$$as_ac_var
+-   if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+   cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+ _ACEOF
+@@ -8383,7 +8432,7 @@
+ $as_echo "$as_me: Please install the libmd developer headers for your platform." >&6;}
+ 					;;
+ 			esac
+-			as_fn_error "libmd was found, but md5.h is missing." "$LINENO" 5
++			as_fn_error $? "libmd was found, but md5.h is missing." "$LINENO" 5
+ 
+ fi
+ 
+@@ -8397,7 +8446,7 @@
+ fi
+ 
+ 	if test "x$MD5_LIBS" = "x"; then
+-		as_fn_error "Neither CommonCrypto nor libmd were found. A working md5 implementation is required." "$LINENO" 5
++		as_fn_error $? "Neither CommonCrypto nor libmd were found. A working md5 implementation is required." "$LINENO" 5
+ 	fi
+ 
+ 
+@@ -8593,7 +8642,7 @@
+ 		if test -f "${with_tclconfig}/tclConfig.sh" ; then
+ 		    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
+ 		else
+-		    as_fn_error "${with_tclconfig} directory doesn't contain tclConfig.sh" "$LINENO" 5
++		    as_fn_error $? "${with_tclconfig} directory doesn't contain tclConfig.sh" "$LINENO" 5
+ 		fi
+ 	    fi
+ 
+@@ -8649,7 +8698,7 @@
+ 
+ 	if test x"${ac_cv_c_tclconfig}" = x ; then
+ 	    TCL_BIN_DIR="# no Tcl configs found"
+-	    as_fn_error "Can't find Tcl configuration definitions" "$LINENO" 5
++	    as_fn_error $? "Can't find Tcl configuration definitions" "$LINENO" 5
+ 	else
+ 	    no_tcl=
+ 	    TCL_BIN_DIR=${ac_cv_c_tclconfig}
+@@ -8728,7 +8777,7 @@
+ 	if test -f "${with_tclinclude}/tcl.h" ; then
+ 	    ac_cv_c_tclh=${with_tclinclude}
+ 	else
+-	    as_fn_error "${with_tclinclude} directory does not contain Tcl public header file tcl.h" "$LINENO" 5
++	    as_fn_error $? "${with_tclinclude} directory does not contain Tcl public header file tcl.h" "$LINENO" 5
+ 	fi
+     else
+ 	if test "${ac_cv_c_tclh+set}" = set; then :
+@@ -8761,7 +8810,7 @@
+     # Print a message based on how we determined the include path
+ 
+     if test x"${ac_cv_c_tclh}" = x ; then
+-	as_fn_error "tcl.h not found.  Please specify its location with --with-tclinclude" "$LINENO" 5
++	as_fn_error $? "tcl.h not found.  Please specify its location with --with-tclinclude" "$LINENO" 5
+     else
+ 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_cv_c_tclh}" >&5
+ $as_echo "${ac_cv_c_tclh}" >&6; }
+@@ -8871,7 +8920,7 @@
+ 			;;
+ 	esac
+ 	if test "x$TCLSH" = "x" ; then
+-		as_fn_error "Could not find tclsh" "$LINENO" 5
++		as_fn_error $? "Could not find tclsh" "$LINENO" 5
+ 	fi
+ 
+ 
+@@ -8942,7 +8991,7 @@
+     fi
+ 
+     if test x"${ac_cv_c_tclpkgd}" = x ; then
+-	as_fn_error "Tcl package directory not found.  Please specify its location with --with-tclpackage" "$LINENO" 5
++	as_fn_error $? "Tcl package directory not found.  Please specify its location with --with-tclpackage" "$LINENO" 5
+     else
+ 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_cv_c_tclpkgd}" >&5
+ $as_echo "${ac_cv_c_tclpkgd}" >&6; }
+@@ -8968,7 +9017,7 @@
+ 	else
+ 		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ $as_echo "no" >&6; }
+-		as_fn_error "tcl wasn't compiled with threads enabled" "$LINENO" 5
++		as_fn_error $? "tcl wasn't compiled with threads enabled" "$LINENO" 5
+ 	fi
+ 
+ 
+@@ -9066,7 +9115,7 @@
+ 	fi
+ 
+ 	if test "x$CURL_CONFIG" = "x"; then
+-		as_fn_error "cannot find curl-config. Is libcurl installed?" "$LINENO" 5
++		as_fn_error $? "cannot find curl-config. Is libcurl installed?" "$LINENO" 5
+ 	fi
+ 
+ 	CFLAGS_LIBCURL=$($CURL_CONFIG --cflags)
+@@ -9141,7 +9190,7 @@
+ if test "x$ac_cv_header_sqlite3_h" = x""yes; then :
+ 
+ else
+-  as_fn_error "cannot find sqlite3 header" "$LINENO" 5
++  as_fn_error $? "cannot find sqlite3 header" "$LINENO" 5
+ fi
+ 
+ 
+@@ -9340,7 +9389,7 @@
+ 
+ 	eval dpversionfile="${sysconfdir}/ports/dp_version"
+ 	if test -f $dpversionfile; then
+-		as_fn_error "Existing MacPorts or DarwinPorts install is too old to be upgraded. Install MacPorts 1.7.1 first." "$LINENO" 5
++		as_fn_error $? "Existing MacPorts or DarwinPorts install is too old to be upgraded. Install MacPorts 1.7.1 first." "$LINENO" 5
+ 	else
+ 		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ $as_echo "yes" >&6; }
+@@ -9365,7 +9414,7 @@
+ 
+ 
+ # Output
+-ac_config_files="$ac_config_files Doxyfile Makefile Mk/macports.autoconf.mk doc/prefix.mtree doc/macosx.mtree doc/macports.conf portmgr/freebsd/Makefile src/Makefile src/macports1.0/macports_autoconf.tcl src/port1.0/port_autoconf.tcl src/registry2.0/registry_autoconf.tcl src/programs/Makefile src/macports1.0/macports_fastload.tcl setupenv.bash"
++ac_config_files="$ac_config_files Doxyfile Makefile Mk/macports.autoconf.mk doc/prefix.mtree doc/macosx.mtree doc/macports.conf doc/pubkeys.conf portmgr/freebsd/Makefile src/Makefile src/macports1.0/macports_autoconf.tcl src/port1.0/port_autoconf.tcl src/registry2.0/registry_autoconf.tcl src/programs/Makefile src/macports1.0/macports_fastload.tcl setupenv.bash"
+ 
+ 
+ ac_config_files="$ac_config_files src/pkg_mkindex.sh"
+@@ -9454,6 +9503,7 @@
+ 
+ ac_libobjs=
+ ac_ltlibobjs=
++U=
+ for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+   # 1. Remove the extension, and $U if already installed.
+   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+@@ -9615,19 +9665,19 @@
+ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+ 
+ 
+-# as_fn_error ERROR [LINENO LOG_FD]
+-# ---------------------------------
++# as_fn_error STATUS ERROR [LINENO LOG_FD]
++# ----------------------------------------
+ # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+ # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+-# script with status $?, using 1 if that was 0.
++# script with STATUS, using 1 if that was 0.
+ as_fn_error ()
+ {
+-  as_status=$?; test $as_status -eq 0 && as_status=1
+-  if test "$3"; then
+-    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
++  as_status=$1; test $as_status -eq 0 && as_status=1
++  if test "$4"; then
++    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
++    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+   fi
+-  $as_echo "$as_me: error: $1" >&2
++  $as_echo "$as_me: error: $2" >&2
+   as_fn_exit $as_status
+ } # as_fn_error
+ 
+@@ -9823,7 +9873,7 @@
+       test -d "$as_dir" && break
+     done
+     test -z "$as_dirs" || eval "mkdir $as_dirs"
+-  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
++  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+ 
+ 
+ } # as_fn_mkdir_p
+@@ -9877,7 +9927,7 @@
+ # values after options handling.
+ ac_log="
+ This file was extended by MacPorts $as_me 1.9.99, which was
+-generated by GNU Autoconf 2.65.  Invocation command line was
++generated by GNU Autoconf 2.66.  Invocation command line was
+ 
+   CONFIG_FILES    = $CONFIG_FILES
+   CONFIG_HEADERS  = $CONFIG_HEADERS
+@@ -9939,10 +9989,10 @@
+ ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ ac_cs_version="\\
+ MacPorts config.status 1.9.99
+-configured by $0, generated by GNU Autoconf 2.65,
++configured by $0, generated by GNU Autoconf 2.66,
+   with options \\"\$ac_cs_config\\"
+ 
+-Copyright (C) 2009 Free Software Foundation, Inc.
++Copyright (C) 2010 Free Software Foundation, Inc.
+ This config.status script is free software; the Free Software Foundation
+ gives unlimited permission to copy, distribute and modify it."
+ 
+@@ -9996,7 +10046,7 @@
+     ac_need_defaults=false;;
+   --he | --h)
+     # Conflict between --help and --header
+-    as_fn_error "ambiguous option: \`$1'
++    as_fn_error $? "ambiguous option: \`$1'
+ Try \`$0 --help' for more information.";;
+   --help | --hel | -h )
+     $as_echo "$ac_cs_usage"; exit ;;
+@@ -10005,7 +10055,7 @@
+     ac_cs_silent=: ;;
+ 
+   # This is an error.
+-  -*) as_fn_error "unrecognized option: \`$1'
++  -*) as_fn_error $? "unrecognized option: \`$1'
+ Try \`$0 --help' for more information." ;;
+ 
+   *) as_fn_append ac_config_targets " $1"
+@@ -10062,6 +10112,7 @@
+     "doc/prefix.mtree") CONFIG_FILES="$CONFIG_FILES doc/prefix.mtree" ;;
+     "doc/macosx.mtree") CONFIG_FILES="$CONFIG_FILES doc/macosx.mtree" ;;
+     "doc/macports.conf") CONFIG_FILES="$CONFIG_FILES doc/macports.conf" ;;
++    "doc/pubkeys.conf") CONFIG_FILES="$CONFIG_FILES doc/pubkeys.conf" ;;
+     "portmgr/freebsd/Makefile") CONFIG_FILES="$CONFIG_FILES portmgr/freebsd/Makefile" ;;
+     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
+     "src/macports1.0/macports_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/macports1.0/macports_autoconf.tcl" ;;
+@@ -10072,7 +10123,7 @@
+     "setupenv.bash") CONFIG_FILES="$CONFIG_FILES setupenv.bash" ;;
+     "src/pkg_mkindex.sh") CONFIG_FILES="$CONFIG_FILES src/pkg_mkindex.sh" ;;
+ 
+-  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
++  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+   esac
+ done
+ 
+@@ -10109,7 +10160,7 @@
+ {
+   tmp=./conf$$-$RANDOM
+   (umask 077 && mkdir "$tmp")
+-} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
++} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ 
+ # Set up the scripts for CONFIG_FILES section.
+ # No need to generate them if there are no CONFIG_FILES.
+@@ -10126,7 +10177,7 @@
+ fi
+ ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+ if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+-  ac_cs_awk_cr='\r'
++  ac_cs_awk_cr='\\r'
+ else
+   ac_cs_awk_cr=$ac_cr
+ fi
+@@ -10140,18 +10191,18 @@
+   echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+   echo "_ACEOF"
+ } >conf$$subs.sh ||
+-  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+-ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
++  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
++ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ ac_delim='%!_!# '
+ for ac_last_try in false false false false false :; do
+   . ./conf$$subs.sh ||
+-    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
++    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ 
+   ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+   if test $ac_delim_n = $ac_delim_num; then
+     break
+   elif $ac_last_try; then
+-    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
++    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+   else
+     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+   fi
+@@ -10240,20 +10291,28 @@
+ else
+   cat
+ fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+-  || as_fn_error "could not setup config files machinery" "$LINENO" 5
++  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+ _ACEOF
+ 
+-# VPATH may cause trouble with some makes, so we remove $(srcdir),
+-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
++# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
++# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+ # trailing colons and then remove the whole line if VPATH becomes empty
+ # (actually we leave an empty line to preserve line numbers).
+ if test "x$srcdir" = x.; then
+-  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
+-s/:*\$(srcdir):*/:/
+-s/:*\${srcdir}:*/:/
+-s/:*@srcdir@:*/:/
+-s/^\([^=]*=[	 ]*\):*/\1/
++  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
++h
++s///
++s/^/:/
++s/[	 ]*$/:/
++s/:\$(srcdir):/:/g
++s/:\${srcdir}:/:/g
++s/:@srcdir@:/:/g
++s/^:*//
+ s/:*$//
++x
++s/\(=[	 ]*\).*/\1/
++G
++s/\n//
+ s/^[^=]*=[	 ]*$//
+ }'
+ fi
+@@ -10281,7 +10340,7 @@
+   if test -z "$ac_t"; then
+     break
+   elif $ac_last_try; then
+-    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
++    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+   else
+     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+   fi
+@@ -10366,7 +10425,7 @@
+ _ACAWK
+ _ACEOF
+ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+-  as_fn_error "could not setup config headers machinery" "$LINENO" 5
++  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+ fi # test -n "$CONFIG_HEADERS"
+ 
+ 
+@@ -10379,7 +10438,7 @@
+   esac
+   case $ac_mode$ac_tag in
+   :[FHL]*:*);;
+-  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
++  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+   :[FH]-) ac_tag=-:-;;
+   :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+   esac
+@@ -10407,7 +10466,7 @@
+ 	   [\\/$]*) false;;
+ 	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ 	   esac ||
+-	   as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
++	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+       esac
+       case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+       as_fn_append ac_file_inputs " '$ac_f'"
+@@ -10434,7 +10493,7 @@
+ 
+     case $ac_tag in
+     *:-:* | *:-) cat >"$tmp/stdin" \
+-      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
++      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+     esac
+     ;;
+   esac
+@@ -10565,22 +10624,22 @@
+ $ac_datarootdir_hack
+ "
+ eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+-  || as_fn_error "could not create $ac_file" "$LINENO" 5
++  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ 
+ test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+   { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+   { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+-which seems to be undefined.  Please make sure it is defined." >&5
++which seems to be undefined.  Please make sure it is defined" >&5
+ $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+-which seems to be undefined.  Please make sure it is defined." >&2;}
++which seems to be undefined.  Please make sure it is defined" >&2;}
+ 
+   rm -f "$tmp/stdin"
+   case $ac_file in
+   -) cat "$tmp/out" && rm -f "$tmp/out";;
+   *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+   esac \
+-  || as_fn_error "could not create $ac_file" "$LINENO" 5
++  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+  ;;
+   :H)
+   #
+@@ -10591,19 +10650,19 @@
+       $as_echo "/* $configure_input  */" \
+       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+     } >"$tmp/config.h" \
+-      || as_fn_error "could not create $ac_file" "$LINENO" 5
++      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+     if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+       { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+ $as_echo "$as_me: $ac_file is unchanged" >&6;}
+     else
+       rm -f "$ac_file"
+       mv "$tmp/config.h" "$ac_file" \
+-	|| as_fn_error "could not create $ac_file" "$LINENO" 5
++	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
+     fi
+   else
+     $as_echo "/* $configure_input  */" \
+       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+-      || as_fn_error "could not create -" "$LINENO" 5
++      || as_fn_error $? "could not create -" "$LINENO" 5
+   fi
+  ;;
+ 
+@@ -10623,7 +10682,7 @@
+ ac_clean_files=$ac_clean_files_save
+ 
+ test $ac_write_fail = 0 ||
+-  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
++  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+ 
+ 
+ # configure is writing to config.log, and then calls config.status.
+@@ -10644,7 +10703,7 @@
+   exec 5>>config.log
+   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+   # would make configure fail if this is the last instruction.
+-  $ac_cs_success || as_fn_exit $?
++  $ac_cs_success || as_fn_exit 1
+ fi
+ 
+ #
+@@ -10785,7 +10844,7 @@
+       # The eval makes quoting arguments work.
+       eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
+ 	   --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
+-	as_fn_error "$ac_sub_configure failed for $ac_dir" "$LINENO" 5
++	as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5
+     fi
+ 
+     cd "$ac_popdir"
+Index: Makefile.in
+===================================================================
+--- Makefile.in	(revision 69681)
++++ Makefile.in	(revision 69682)
+@@ -34,6 +34,7 @@
+ install::
+ 	[ ! -f $(DESTDIR)${sysconfdir}/macports/mp_version ] || rm -vf $(DESTDIR)${sysconfdir}/macports/mp_version
+ 	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 setupenv.bash  $(DESTDIR)${datadir}/macports/
++	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 macports-pubkey.pem  $(DESTDIR)${datadir}/macports/
+ # Only run these scripts when not building in a destroot
+ ifeq ($(DESTDIR),)
+ # Add [default] tag to the central MacPorts repository, if it isn't already
+Index: src/port/port.tcl
+===================================================================
+--- src/port/port.tcl	(revision 69681)
++++ src/port/port.tcl	(revision 69682)
+@@ -267,9 +267,9 @@
+             set ivariants [lindex $i 3]
+             set iactive [lindex $i 4]
+             if { $iactive == 0 } {
+-                puts "  $iname ${iversion}_${irevision}${ivariants}"
++                puts "  $iname @${iversion}_${irevision}${ivariants}"
+             } elseif { $iactive == 1 } {
+-                puts "  $iname ${iversion}_${irevision}${ivariants} (active)"
++                puts "  $iname @${iversion}_${irevision}${ivariants} (active)"
+             }
+         }
+         return -code error "Registry error: Please specify the full version as recorded in the port registry."
+@@ -858,6 +858,7 @@
+             fatal "port installed failed: $result"
+         }
+     }
++    registry::open_dep_map
+     set results {}
+     foreach i $ilist {
+         set iname [lindex $i 0]
+@@ -2225,7 +2226,7 @@
+ 
+             set i [lindex $ilist 0]
+             set regref [registry::entry open $portname [lindex $i 1] [lindex $i 2] [lindex $i 3] [lindex $i 5]]
+-            if {[registry::run_target $regref activate [array get options]]} {
++            if {[$regref installtype] == "image" && [registry::run_target $regref activate [array get options]]} {
+                 continue
+             }
+         }
+@@ -2262,7 +2263,7 @@
+             set ivariants [lindex $i 3]
+             if {$composite_version == "" || $composite_version == "${iversion}_${irevision}${ivariants}"} {
+                 set regref [registry::entry open $portname $iversion $irevision $ivariants [lindex $i 5]]
+-                if {[registry::run_target $regref deactivate [array get options]]} {
++                if {[$regref installtype] == "image" && [registry::run_target $regref deactivate [array get options]]} {
+                     continue
+                 }
+             }
+@@ -2406,6 +2407,7 @@
+ 
+ 
+ proc action_setrequested { action portlist opts } {
++    global macports::registry.format
+     set status 0
+     if {[require_portlist portlist]} {
+         return 1
+@@ -2414,11 +2416,14 @@
+     set val [string equal $action setrequested]
+     foreachport $portlist {
+         set composite_version [composite_version $portversion [array get variations]]
+-        if {![catch {set ilist [registry::installed $portname $composite_version]}]} {
++        if {![catch {set ilist [registry::installed $portname $composite_version]} result]} {
+             ui_info "Setting requested flag for $portname to $val"
+             foreach i $ilist {
+-                set regref [registry::entry open $portname [lindex $i 1] [lindex $i 2] [lindex $i 3] [lindex $i 5]]
++                set regref [registry::open_entry $portname [lindex $i 1] [lindex $i 2] [lindex $i 3] [lindex $i 5]]
+                 registry::property_store $regref requested $val
++                if {${macports::registry.format} != "receipt_sqlite"} {
++                    registry::write_entry $regref
++                }
+             }
+         } else {
+             global errorInfo
+@@ -2584,6 +2589,7 @@
+     if {[require_portlist portlist]} {
+         return 1
+     }
++    set separator ""
+ 
+     foreachport $portlist {
+         if {[info exists options(ports_${action}_no-build)] && [string is true -strict $options(ports_${action}_no-build)]} {
+@@ -2647,8 +2653,10 @@
+             ui_warn "port ${action} --index does not work with the 'current' pseudo-port"
+             continue
+         }
++        set portname $portinfo(name)
+ 
+         set deplist {}
++        set deps_output {}
+         set ndeps 0
+         array set labeldict {depends_fetch Fetch depends_extract Extract depends_build Build depends_lib Library depends_run Runtime}
+         # get list of direct deps
+@@ -2665,7 +2673,7 @@
+                 }
+                 if {$action == "deps"} {
+                     set label "$labeldict($type) Dependencies"
+-                    puts [wraplabel $label [join $deplist ", "] 0 [string repeat " " 22]]
++                    lappend deps_output [wraplabel $label [join $deplist ", "] 0 [string repeat " " 22]]
+                     incr ndeps [llength $deplist]
+                     set deplist {}
+                 }
+@@ -2680,11 +2688,16 @@
+             set variants {}
+         }
+ 
++        puts -nonewline $separator
+         if {$action == "deps"} {
+             if {$ndeps == 0} {
+                 ui_notice "$portname @${version}_${revision}${variants} has no dependencies."
++            } else {
++                ui_notice "Full Name: $portname @${version}_${revision}${variants}"
++                puts [join $deps_output "\n"]
+             }
+-            return $status
++            set separator "--\n"
++            continue
+         }
+ 
+         set toplist $deplist
+@@ -2779,6 +2792,7 @@
+             incr cur_pos
+             set pos_stack [lreplace $pos_stack end end $cur_pos]
+         }
++        set separator "--\n"
+     }
+     return $status
+ }
+@@ -2934,7 +2948,7 @@
+ 
+     set num_outdated 0
+     if { [llength $ilist] > 0 } {
+-        foreach i $ilist {
++        foreach i [portlist_sortint $ilist] {
+         
+             # Get information about the installed port
+             set portname [lindex $i 0]
+@@ -2986,10 +3000,12 @@
+                 set comp_result [rpm-vercomp $installed_revision $latest_revision]
+             }
+             set reason ""
+-            if {$comp_result == 0 && $epoch_comp_result != 0} {
+-                set reason { (epoch $installed_epoch $relation $latest_epoch)}
++            if {$epoch_comp_result != 0} {
++                if {($comp_result >= 0 && $epoch_comp_result < 0) || ($comp_result <= 0 && $epoch_comp_result > 0)} {
++                    set reason { (epoch $installed_epoch $relation $latest_epoch)}
++                }
+                 set comp_result $epoch_comp_result
+-            } elseif {$comp_result == 0 && $epoch_comp_result == 0} {
++            } elseif {$comp_result == 0} {
+                 set regref [registry::open_entry $portname $installed_version $installed_revision [lindex $i 3] $installed_epoch]
+                 set os_platform_installed [registry::property_retrieve $regref os_platform]
+                 set os_major_installed [registry::property_retrieve $regref os_major]
+@@ -3449,7 +3465,11 @@
+                     # We need it to evaluate the editor, and the editor
+                     # may want stuff from it as well, like TERM.
+                     array unset env_save; array set env_save [array get env]
+-                    array unset env *; unsetenv *; array set env [array get boot_env]
++                    array unset env *
++                    if {${macports::macosx_version} == "10.5"} {
++                        unsetenv *
++                    }
++                    array set env [array get boot_env]
+                     
+                     # Find an editor to edit the portfile
+                     set editor ""
+@@ -3475,7 +3495,11 @@
+                     }
+                     
+                     # Restore internal MacPorts environment
+-                    array unset env *; unsetenv *; array set env [array get env_save]
++                    array unset env *
++                    if {${macports::macosx_version} == "10.5"} {
++                        unsetenv *
++                    }
++                    array set env [array get env_save]
+                 }
+ 
+                 dir {
+@@ -3566,7 +3590,6 @@
+     if {[require_portlist portlist]} {
+         return 1
+     }
+-    set target $action
+     foreachport $portlist {
+         # If we have a url, use that, since it's most specific
+         # otherwise try to map the portname to a url
+@@ -3611,8 +3634,12 @@
+             set options(ports_version_glob) $portversion
+         }
+         # if installing, mark the port as explicitly requested
+-        if {$target == "install"} {
++        if {$action == "install"} {
+             set options(ports_requested) 1
++            # we actually activate as well
++            set target activate
++        } else {
++            set target $action
+         }
+         if {[catch {set workername [mportopen $porturl [array get options] [array get requested_variations]]} result]} {
+             global errorInfo
+@@ -3759,7 +3786,6 @@
+     test        [list action_target         [ACTION_ARGS_PORTS]] \
+     lint        [list action_target         [ACTION_ARGS_PORTS]] \
+     submit      [list action_target         [ACTION_ARGS_PORTS]] \
+-    trace       [list action_target         [ACTION_ARGS_PORTS]] \
+     livecheck   [list action_target         [ACTION_ARGS_PORTS]] \
+     distcheck   [list action_target         [ACTION_ARGS_PORTS]] \
+     mirror      [list action_target         [ACTION_ARGS_PORTS]] \
+Index: src/port/portindex.tcl
+===================================================================
+--- src/port/portindex.tcl	(revision 69681)
++++ src/port/portindex.tcl	(revision 69682)
+@@ -38,14 +38,14 @@
+ }
+ 
+ proc pindex {portdir} {
+-    global target oldfd oldmtime qindex fd directory archive outdir stats full_reindex \
++    global target oldfd oldmtime newest qindex fd directory archive outdir stats full_reindex \
+            ui_options port_options save_prefix keepkeys
+ 
+     # try to reuse the existing entry if it's still valid
+     if {$full_reindex != "1" && $archive != "1" && [info exists qindex([string tolower [file tail $portdir]])]} {
+         try {
+             set mtime [file mtime [file join $directory $portdir Portfile]]
+-            if {$oldmtime > $mtime} {
++            if {$oldmtime >= $mtime} {
+                 set offset $qindex([string tolower [file tail $portdir]])
+                 seek $oldfd $offset
+                 gets $oldfd line
+@@ -109,6 +109,10 @@
+         set len [expr [string length $output] + 1]
+         puts $fd [list $portinfo(name) $len]
+         puts $fd $output
++        set mtime [file mtime [file join $directory $portdir Portfile]]
++        if {$mtime > $newest} {
++            set newest $mtime
++        }
+     }
+ }
+ 
+@@ -188,6 +192,7 @@
+ # open old index for comparison
+ if {[file isfile $outpath] && [file isfile ${outpath}.quick]} {
+     set oldmtime [file mtime $outpath]
++    set newest $oldmtime
+     if {![catch {set oldfd [open $outpath r]}] && ![catch {set quickfd [open ${outpath}.quick r]}]} {
+         if {![catch {set quicklist [read $quickfd]}]} {
+             foreach entry [split $quicklist "\n"] {
+@@ -196,6 +201,8 @@
+         }
+         close $quickfd
+     }
++} else {
++    set newest 0
+ }
+ 
+ set tempportindex [mktemp "/tmp/mports.portindex.XXXXXXXX"]
+@@ -213,6 +220,7 @@
+ }
+ close $fd
+ file rename -force $tempportindex $outpath
++file mtime $outpath $newest
+ mports_generate_quickindex $outpath
+ puts "\nTotal number of ports parsed:\t$stats(total)\
+       \nPorts successfully parsed:\t[expr $stats(total) - $stats(failed)]\
+Index: src/pextlib1.0/xinstall.c
+===================================================================
+--- src/pextlib1.0/xinstall.c	(revision 69681)
++++ src/pextlib1.0/xinstall.c	(revision 69682)
+@@ -146,7 +146,7 @@
+ {
+ 	struct stat from_sb, to_sb;
+ 	mode_t *set;
+-	u_long fset;
++	u_long fset = 0;
+ 	int no_target, rval;
+ 	u_int iflags;
+ 	char *flags, *curdir;
+@@ -1026,6 +1026,7 @@
+ 		if (wait(&status) == -1 || status) {
+ 			serrno = errno;
+ 			(void)unlink(to_name);
++			errno = serrno;
+ 			return;
+ 		}
+ 	}
+Index: src/pextlib1.0/strsed.c
+===================================================================
+--- src/pextlib1.0/strsed.c	(revision 69681)
++++ src/pextlib1.0/strsed.c	(revision 69682)
+@@ -592,6 +592,12 @@
+      */
+ 
+     do {
++#ifdef HS_REGEX
++	    /* XXX Not even trying to use custom memory routines */
++	    if (!(exp_regs = calloc(str_len, sizeof(regmatch_t)))) {
++		return 0;
++	    }
++#endif
+ 	if (match_all){
+ 	    /* Fake a match instead of calling re_search() or regexec(). */
+ 	    match = 1;
+@@ -605,10 +611,6 @@
+ 	    match = re_search(&re_comp_buf, str, str_len, 0, str_len, &regs);
+ #endif
+ #ifdef HS_REGEX
+-	    /* XXX Not even trying to use custom memory routines */
+-	    if (!(exp_regs = calloc(str_len, sizeof(regmatch_t)))) {
+-		return 0;
+-	    }
+ 	    match = regexec(&exp, str, str_len, exp_regs, 0) ? NO_MATCH : 1;
+ #endif
+ 	}
+Index: src/pextlib1.0/curl.c
+===================================================================
+--- src/pextlib1.0/curl.c	(revision 69681)
++++ src/pextlib1.0/curl.c	(revision 69682)
+@@ -398,7 +398,7 @@
+ 
+ 		if (remotetime) {
+ 			theCurlCode = curl_easy_getinfo(theHandle, CURLINFO_FILETIME, &theFileTime);
+-			if (theFileTime > 0) {
++			if (theCurlCode == CURLE_OK && theFileTime > 0) {
+ 				struct utimbuf times;
+ 				times.actime = (time_t)theFileTime;
+ 				times.modtime = (time_t)theFileTime;
+Index: src/pextlib1.0/Pextlib.c
+===================================================================
+--- src/pextlib1.0/Pextlib.c	(revision 69681)
++++ src/pextlib1.0/Pextlib.c	(revision 69682)
+@@ -94,10 +94,10 @@
+ {
+ 	char *d, *dest;
+ 	const char *s;
+-	int slen, dlen;
++	size_t dlen;
+ 
+ 	s = source;
+-	slen = dlen = strlen(source) * 2 + 1;
++	dlen = strlen(source) * 2 + 1;
+ 	d = dest = malloc(dlen);
+ 	if (dest == NULL) {
+ 		return NULL;
+@@ -132,8 +132,9 @@
+ {
+ 	const char ui_proc_start[] = "ui_info [subst -nocommands -novariables {";
+ 	const char ui_proc_end[] = "}]";
+-	char *script, *string, *p;
+-	int scriptlen, len, rval;
++	char *script, *string;
++	size_t scriptlen, len, remaining;
++	int rval;
+ 
+ 	string = ui_escape(mesg);
+ 	if (string == NULL)
+@@ -144,14 +145,14 @@
+ 	script = malloc(scriptlen);
+ 	if (script == NULL)
+ 		return TCL_ERROR;
+-	else
+-		p = script;
+ 
+ 	memcpy(script, ui_proc_start, sizeof(ui_proc_start));
+-	strcat(script, string);
+-	strcat(script, ui_proc_end);
++	remaining = scriptlen - sizeof(ui_proc_start);
++	strncat(script, string, remaining);
++	remaining -= len;
++	strncat(script, ui_proc_end, remaining);
+ 	free(string);
+-	rval = Tcl_EvalEx(interp, script, scriptlen - 1, 0);
++	rval = Tcl_EvalEx(interp, script, -1, 0);
+ 	free(script);
+ 	return rval;
+ }
+@@ -274,7 +275,7 @@
+ {
+ 	Tcl_Obj *tcl_result;
+ 	char *tcl_mask, *p;
+-	const size_t stringlen = 4; /* 3 digits & \0 */
++	const size_t stringlen = 5; /* 4 digits & \0 */
+ 	int i;
+ 	mode_t *set;
+ 	mode_t newmode;
+@@ -296,23 +297,18 @@
+ 
+ 	oldmode = umask(newmode);
+ 
+-	tcl_mask = malloc(stringlen); /* 3 digits & \0 */
++	tcl_mask = calloc(1, stringlen); /* 4 digits & \0 */
+ 	if (!tcl_mask) {
+ 		return TCL_ERROR;
+ 	}
+ 
+ 	/* Totally gross and cool */
+-	p = tcl_mask + stringlen;
+-	*p = '\0';
++	p = tcl_mask + stringlen - 1;
+ 	for (i = stringlen - 1; i > 0; i--) {
+ 		p--;
+ 		*p = (oldmode & 7) + '0';
+ 		oldmode >>= 3;
+ 	}
+-	if (*p != '0') {
+-		p--;
+-		*p = '0';
+-	}
+ 
+ 	tcl_result = Tcl_NewStringObj(p, -1);
+ 	free(tcl_mask);
+Index: src/registry2.0/portuninstall.tcl
+===================================================================
+--- src/registry2.0/portuninstall.tcl	(revision 69681)
++++ src/registry2.0/portuninstall.tcl	(revision 69682)
+@@ -108,18 +108,18 @@
+     } elseif { [llength $ilist] == 1 } {
+         if {$use_reg2} {
+             set port [lindex $ilist 0]
+-            if {$v == ""} {
+-                set v "[$port version]_[$port revision][$port variants]"
+-            }
++            set version [$port version]
++            set revision [$port revision]
++            set variants [$port variants]
+         } else {
+             set version [lindex [lindex $ilist 0] 1]
+             set revision [lindex [lindex $ilist 0] 2]
+             set variants [lindex [lindex $ilist 0] 3]
+             set active [lindex [lindex $ilist 0] 4]
+-            if {$v == ""} {
+-                set v "${version}_${revision}${variants}"
+-            }
+         }
++        if {$v == ""} {
++            set v "${version}_${revision}${variants}"
++        }
+     } else {
+         throw registry::invalid "Registry error: $portname not registered as installed"
+     }
+@@ -147,7 +147,9 @@
+                 ui_msg "For $portname @${v}: skipping deactivate (dry run)"
+             } else {
+                 if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $port deactivate $optionslist]} {
+-                    portimage::deactivate $portname $v [array get options]
++                    if {[$port installtype] == "image"} {
++                        portimage::deactivate $portname $v [array get options]
++                    }
+                 }
+             }
+         }
+@@ -338,17 +340,17 @@
+                     catch {file copy $fname "${fname}${bak_suffix}"}
+                 }
+             }
+-            
+-            set theFile [file normalize $fname]
+-            if { [file exists $theFile] || (![catch {file type $theFile}] && [file type $theFile] == "link") } {
++
++            if { [file exists $fname] || (![catch {file type $fname}] && [file type $fname] == "link") } {
+                 # Normalize the file path to avoid removing the intermediate
+                 # symlinks (remove the empty directories instead)
+-                lappend files $theFile
++                # The custom realpath proc is necessary because file normalize
++                # does not resolve symlinks on OS X < 10.6
++                set directory [realpath [file dirname $fname]]
++                lappend files [file join $directory [file tail $fname]]
+     
+                 # Split out the filename's subpaths and add them to the
+-                # list as well. The realpath call is necessary because file normalize
+-                # does not resolve symlinks on OS X < 10.6
+-                set directory [realpath [file dirname $theFile]]
++                # list as well.
+                 while { [lsearch -exact $files $directory] == -1 } { 
+                     lappend files $directory
+                     set directory [file dirname $directory]
+@@ -359,10 +361,10 @@
+         # Sort the list in reverse order, removing duplicates.
+         # Since the list is sorted in reverse order, we're sure that directories
+         # are after their elements.
+-        set theList [lsort -decreasing -unique $files]
++        set files [lsort -decreasing -unique $files]
+     
+         # Remove all elements.
+-        _uninstall_list $theList
++        _uninstall_list $files
+     
+         if {$use_reg2} {
+             registry::entry delete $port
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 69681)
++++ src/registry2.0/portimage.tcl	(revision 69682)
+@@ -381,11 +381,13 @@
+ ##
+ ## @param [in] srcfile path to file in image
+ ## @param [in] dstfile path to activate file to
++## @return 1 if file needs to be explicitly deleted if we have to roll back, 0 otherwise
+ proc _activate_file {srcfile dstfile} {
+     switch [file type $srcfile] {
+         link {
+             ui_debug "activating link: $dstfile"
+             file copy -force -- $srcfile $dstfile
++            return 1
+         }
+         directory {
+             # Don't recursively copy directories
+@@ -398,6 +400,7 @@
+                 # set mtime on installed element
+                 file mtime $dstfile [file mtime $srcfile]
+             }
++            return 0
+         }
+         default {
+             ui_debug "activating file: $dstfile"
+@@ -406,6 +409,7 @@
+                 ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"
+                 file link -symbolic $dstfile $srcfile
+             }
++            return 1
+         }
+     }
+ }
+@@ -486,7 +490,7 @@
+                             # the registry
+                             if { $owner != {} && $owner != $port } {
+                                 throw registry::image-error "Image error: $file is being used by the active [$owner name] port.  Please deactivate this port first, or use 'port -f activate [$port name]' to force the activation."
+-                            } elseif { $owner == {} && ![catch {[file type $file]}] } {
++                            } elseif { $owner == {} && ![catch {file type $file}] } {
+                                 throw registry::image-error "Image error: $file already exists and does not belong to a registered port.  Unable to activate port [$port name]. Use 'port -f activate [$port name]' to force the activation."
+                             }
+                         }
+@@ -523,16 +527,17 @@
+             # directories are before their elements.
+             # We don't have to do this as mentioned above, but it makes the
+             # debug output of activate make more sense.
+-            set theList [lsort -increasing -unique $files]
++            set files [lsort -increasing -unique $files]
+             set rollback_filelist {}
+             ui_msg "GSOC DBG: let's activate actual files"
+             registry::write {
+                 # Activate it, and catch errors so we can roll-back
+                 try {
+                     $port activate $imagefiles
+-                    foreach file $theList {
+-                        _activate_file "${imagedir}${file}" $file
+-                        lappend rollback_filelist $file
++                    foreach file $files {
++                        if {[_activate_file "${imagedir}${file}" $file] == 1} {
++                            lappend rollback_filelist $file
++                        }
+                     }
+                 } catch {*} {
+                     ui_debug "Activation failed, rolling back."
+@@ -637,13 +642,14 @@
+         # are before their elements.
+         # We don't have to do this as mentioned above, but it makes the
+         # debug output of activate make more sense.
+-        set theList [lsort -increasing -unique $files]
++        set files [lsort -increasing -unique $files]
+         set rollback_filelist {}
+ 
+         # Activate it, and catch errors so we can roll-back
+-        if { [catch { foreach file $theList {
+-                        _activate_file "${imagedir}${file}" $file
+-                        lappend rollback_filelist $file
++        if { [catch { foreach file $files {
++                        if {[_activate_file "${imagedir}${file}" $file] == 1} {
++                            lappend rollback_filelist $file
++                        }
+                     }} result]} {
+             ui_debug "Activation failed, rolling back."
+             _deactivate_contents $name $rollback_filelist yes yes
+@@ -703,14 +709,14 @@
+             # instead of the paths we currently have, users' registry won't
+             # match and activate will say that some file exists but doesn't
+             # belong to any port.
+-            set theFile [file normalize $file]
+-            lappend files $theFile
++            # The custom realpath proc is necessary because file normalize
++            # does not resolve symlinks on OS X < 10.6
++            set directory [realpath [file dirname $file]]
++            lappend files [file join $directory [file tail $file]]
+ 
+-            # Split out the filename's subpaths and add them to the image list as
+-            # well. The realpath call is necessary because file normalize
+-            # does not resolve symlinks on OS X < 10.6
+-            set directory [realpath [file dirname $theFile]]
+-            while { [lsearch -exact $files $directory] == -1 } { 
++            # Split out the filename's subpaths and add them to the image list
++            # as well.
++            while { [lsearch -exact $files $directory] == -1 } {
+                 lappend files $directory
+                 set directory [file dirname $directory]
+             }
+@@ -722,18 +728,18 @@
+     # Sort the list in reverse order, removing duplicates.
+     # Since the list is sorted in reverse order, we're sure that directories
+     # are after their elements.
+-    set theList [lsort -decreasing -unique $files]
++    set files [lsort -decreasing -unique $files]
+ 
+     # Remove all elements.
+     if {$use_reg2 && !$rollback} {
+         registry::write {
+             $port deactivate $imagefiles
+-            foreach file $theList {
++            foreach file $files {
+                 _deactivate_file $file
+             }
+         }
+     } else {
+-        foreach file $theList {
++        foreach file $files {
+             _deactivate_file $file
+         }
+     }
+Index: src/port1.0/portfetch.tcl
+===================================================================
+--- src/port1.0/portfetch.tcl	(revision 69681)
++++ src/port1.0/portfetch.tcl	(revision 69682)
+@@ -471,14 +471,14 @@
+             }
+             if {![info exists urlmap($url_var)]} {
+                 ui_error [format [msgcat::mc "No defined site for tag: %s, using master_sites"] $url_var]
+-                set urlmap($url_var) $master_sites
++                set urlmap($url_var) $urlmap(master_sites)
+             }
+             unset -nocomplain fetched
+             foreach site $urlmap($url_var) {
+                 ui_msg "$UI_PREFIX [format [msgcat::mc "Attempting to fetch %s from %s"] $distfile $site]"
+                 set file_url [portfetch::assemble_url $site $distfile]
+                 set effectiveURL ""
+-                if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} ${distpath}/${distfile}.TMP} result] &&
++                if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} {"${distpath}/${distfile}.TMP"}} result] &&
+                     ![catch {file rename -force "${distpath}/${distfile}.TMP" "${distpath}/${distfile}"} result]} {
+ 
+                     # Special hack to check for sourceforge mirrors, which don't return a proper error code on failure
+Index: src/port1.0/fetch_common.tcl
+===================================================================
+--- src/port1.0/fetch_common.tcl	(revision 69681)
++++ src/port1.0/fetch_common.tcl	(revision 69682)
+@@ -218,7 +218,7 @@
+         if {![info exists urlmap($url_var)]} {
+             if {$url_var != $default_listvar} {
+                 ui_error [format [msgcat::mc "No defined site for tag: %s, using $default_listvar"] $url_var]
+-                set urlmap($url_var) [set $default_listvar]
++                set urlmap($url_var) $urlmap($default_listvar)
+             } else {
+                 set urlmap($url_var) {}
+             }
+@@ -232,6 +232,14 @@
+             continue
+         }
+ 
++        # can't do the ping with dropped privileges (though it works fine if we didn't start as root)
++        if {[getuid] == 0 && [geteuid] != 0} {
++            set oldeuid [geteuid]
++            set oldegid [getegid]
++            seteuid 0
++            setegid 0
++        }
++
+         foreach site $urllist {
+             regexp $hostregex $site -> host
+ 
+@@ -269,6 +277,11 @@
+             ui_debug "$host ping time is $pingtimes($host)"
+         }
+ 
++        if {[info exists oldeuid]} {
++            setegid $oldegid
++            seteuid $oldeuid
++        }
++
+         set pinglist {}
+         foreach site $urllist {
+             regexp $hostregex $site -> host
+@@ -294,7 +307,7 @@
+     foreach {url_var distfile} $fetch_urls {
+         if {![info exists urlmap($url_var)]} {
+             ui_error [format [msgcat::mc "No defined site for tag: %s, using master_sites"] $url_var]
+-            set urlmap($url_var) $master_sites
++            set urlmap($url_var) $urlmap(master_sites)
+         }
+         foreach site $urlmap($url_var) {
+             lappend urls $site
+Index: src/port1.0/porttrace.tcl
+===================================================================
+--- src/port1.0/porttrace.tcl	(revision 69681)
++++ src/port1.0/porttrace.tcl	(revision 69682)
+@@ -101,10 +101,12 @@
+ # Disable the fence.
+ # Unused yet.
+ proc porttrace::trace_disable_fence {} {
+-    global env
++    global env macosx_version
+     if [info exists env(DARWINTRACE_SANDBOX_BOUNDS)] {
+         unset env(DARWINTRACE_SANDBOX_BOUNDS)
+-        unsetenv DARWINTRACE_SANDBOX_BOUNDS
++        if {$macosx_version == "10.5"} {
++            unsetenv DARWINTRACE_SANDBOX_BOUNDS
++        }
+     }
+ }
+ 
+@@ -147,10 +149,12 @@
+ proc porttrace::trace_stop {} {
+     global os.platform
+     if {${os.platform} == "darwin"} {
+-        global env trace_fifo
++        global env trace_fifo macosx_version
+         foreach var {DYLD_INSERT_LIBRARIES DYLD_FORCE_FLAT_NAMESPACE DARWINTRACE_LOG DARWINTRACE_SANDBOX_BOUNDS} {
+             array unset env $var
+-            unsetenv $var
++            if {$macosx_version == "10.5"} {
++                unsetenv $var
++            }
+         }
+ 
+         #kill socket
+Index: src/port1.0/portpatch.tcl
+===================================================================
+--- src/port1.0/portpatch.tcl	(revision 69681)
++++ src/port1.0/portpatch.tcl	(revision 69682)
+@@ -68,7 +68,7 @@
+ }
+ 
+ proc portpatch::patch_main {args} {
+-    global UI_PREFIX
++    global UI_PREFIX usealtworkpath altprefix
+ 
+     # First make sure that patchfiles exists and isn't stubbed out.
+     if {![exists patchfiles] || [option patchfiles] == ""} {
+@@ -83,6 +83,8 @@
+             lappend patchlist [option filespath]/$patch_file
+         } elseif {[file exists [option distpath]/$patch_file]} {
+             lappend patchlist [option distpath]/$patch_file
++        } elseif {!$usealtworkpath && [file exists "${altprefix}[option distpath]/$patch_file"]} {
++            lappend patchlist "${altprefix}[option distpath]/$patch_file"
+         } else {
+             return -code error [format [msgcat::mc "Patch file %s is missing"] $patch]
+         }
+Index: src/port1.0/portactivate.tcl
+===================================================================
+--- src/port1.0/portactivate.tcl	(revision 69681)
++++ src/port1.0/portactivate.tcl	(revision 69682)
+@@ -54,17 +54,21 @@
+ default activate.asroot no
+ 
+ proc portactivate::activate_start {args} {
+-    global prefix
+-    if { ![file writable $prefix] } {
++    global prefix registry.installtype
++    if { ![file writable $prefix] && ${registry.installtype} == "image"} {
+         # if install location is not writable, need root privileges
+         elevateToRoot "activate"
+     }
+ }
+ 
+ proc portactivate::activate_main {args} {
+-    global env name version revision portvariants user_options PortInfo
+-    registry_activate $name "${version}_${revision}${portvariants}" [array get user_options]
++    global env name version revision portvariants user_options PortInfo registry.installtype
+ 
++    # skip the actual activation in direct mode (we still want the notes and the pre/post procs)
++    if {${registry.installtype} == "image"} {
++        registry_activate $name "${version}_${revision}${portvariants}" [array get user_options]
++    }
++
+     # Display notes at the end of the activation phase.
+     if {[info exists PortInfo(notes)] && $PortInfo(notes) ne {}} {
+         ui_msg ""
+Index: src/port1.0/portchecksum.tcl
+===================================================================
+--- src/port1.0/portchecksum.tcl	(revision 69681)
++++ src/port1.0/portchecksum.tcl	(revision 69682)
+@@ -52,11 +52,14 @@
+ set_ui_prefix
+ 
+ # The list of the types of checksums we know.
+-set checksum_types "md5 sha1 rmd160"
++set checksum_types "md5 sha1 rmd160 sha256"
+ 
+ # The number of types we know.
+ set checksum_types_count [llength $checksum_types]
+ 
++# types to recommend if none are specified in the portfile
++set default_checksum_types {sha1 rmd160}
++
+ # Using global all_dist_files, parse the checksums and store them into the
+ # global array checksums_array.
+ #
+@@ -172,6 +175,15 @@
+     return [rmd160 file $file]
+ }
+ 
++# calc_sha256
++#
++# Calculate the sha256 checksum for the given file.
++# Return the checksum.
++#
++proc portchecksum::calc_sha256 {file} {
++    return [sha256 file $file]
++}
++
+ # checksum_start
+ #
+ # Target prerun procedure; simply prints a message about what we're doing.
+@@ -188,7 +200,7 @@
+ #
+ proc portchecksum::checksum_main {args} {
+     global UI_PREFIX all_dist_files checksum_types checksums_array portverbose checksum.skip
+-    global usealtworkpath altprefix
++    global usealtworkpath altprefix default_checksum_types
+ 
+     # If no files have been downloaded, there is nothing to checksum.
+     if {![info exists all_dist_files]} {
+@@ -227,11 +239,8 @@
+             }
+ 
+             # check that there is at least one checksum for the distfile.
+-            if {![info exists checksums_array($distfile)]} {
++            if {![info exists checksums_array($distfile)] || [llength $checksums_array($distfile)] < 1} {
+                 ui_error "[format [msgcat::mc "No checksum set for %s"] $distfile]"
+-                foreach type $checksum_types {
+-                    ui_info "[format [msgcat::mc "Distfile checksum: %s $type %s"] $distfile [calc_$type $fullpath]]"
+-                }
+                 set fail yes
+             } else {
+                 # retrieve the list of types/values from the array.
+@@ -272,8 +281,16 @@
+             if {![file isfile $fullpath] && (!$usealtworkpath && [file isfile "${altprefix}${fullpath}"])} {
+                 set fullpath "${altprefix}${fullpath}"
+             }
+-            foreach type $checksum_types {
+-                lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
++            if {![info exists checksums_array($distfile)] || [llength $checksums_array($distfile)] < 1} {
++                # no checksums specified; output the default set
++                foreach type $default_checksum_types {
++                    lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
++                }
++            } else {
++                # output just the types that were already used
++                foreach {type sum} $checksums_array($distfile) {
++                    lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
++                }
+             }
+         }
+         ui_info "The correct checksum line may be:"
+Index: src/port1.0/portinstall.tcl
+===================================================================
+--- src/port1.0/portinstall.tcl	(revision 69681)
++++ src/port1.0/portinstall.tcl	(revision 69682)
+@@ -62,8 +62,10 @@
+     ui_msg "$UI_PREFIX [format [msgcat::mc "Installing %s @%s_%s%s"] $name $version $revision $portvariants]"
+     
+     # start gsoc08-privileges
+-    if { ![file writable $prefix] } {
++    if {![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)} {
+         # if install location is not writable, need root privileges to install
++        # Also elevate if started as root, since 'file writable' doesn't seem
++        # to take euid into account.
+         elevateToRoot "install"
+     }
+     # end gsoc08-privileges
+Index: src/port1.0/portdeactivate.tcl
+===================================================================
+--- src/port1.0/portdeactivate.tcl	(revision 69681)
++++ src/port1.0/portdeactivate.tcl	(revision 69682)
+@@ -49,15 +49,18 @@
+ default deactivate.asroot no
+ 
+ proc portdeactivate::deactivate_start {args} {
+-    global prefix
+-    if { ![file writable $prefix] } {
++    global prefix registry.installtype
++    if { ![file writable $prefix] && ${registry.installtype} == "image"} {
+         # if install location is not writable, need root privileges
+         elevateToRoot "deactivate"
+     }
+ }
+ 
+ proc portdeactivate::deactivate_main {args} {
+-    global name version revision portvariants user_options
+-    registry_deactivate $name "${version}_${revision}${portvariants}" [array get user_options]
++    global name version revision portvariants user_options registry.installtype
++    # we still want to be able to run this target in direct mode for the pre/post procs
++    if {${registry.installtype} == "image"} {
++        registry_deactivate $name "${version}_${revision}${portvariants}" [array get user_options]
++    }
+     return 0
+ }
+Index: src/port1.0/portextract.tcl
+===================================================================
+--- src/port1.0/portextract.tcl	(revision 69681)
++++ src/port1.0/portextract.tcl	(revision 69682)
+@@ -35,7 +35,6 @@
+ package require portutil 1.0
+ 
+ set org.macports.extract [target_new org.macports.extract portextract::extract_main]
+-target_init ${org.macports.extract} portextract::extract_init
+ target_provides ${org.macports.extract} extract
+ target_requires ${org.macports.extract} fetch checksum
+ target_prerun ${org.macports.extract} portextract::extract_start
+@@ -73,9 +72,11 @@
+     return $val
+ }
+ 
+-proc portextract::extract_init {args} {
+-    global extract.only extract.dir extract.cmd extract.pre_args extract.post_args extract.mkdir use_bzip2 use_lzma use_xz use_zip use_7z use_dmg
++proc portextract::extract_start {args} {
++    global UI_PREFIX extract.dir extract.mkdir use_bzip2 use_lzma use_xz use_zip use_7z use_dmg
+ 
++    ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] [option name]]"
++
+     # should the distfiles be extracted to worksrcpath instead?
+     if {[tbool extract.mkdir]} {
+         global worksrcpath
+@@ -83,7 +84,6 @@
+         file mkdir ${worksrcpath}
+         set extract.dir ${worksrcpath}
+     }
+-
+     if {[tbool use_bzip2]} {
+         option extract.cmd [findBinary bzip2 ${portutil::autoconf::bzip2_path}]
+     } elseif {[tbool use_lzma]} {
+@@ -93,13 +93,13 @@
+     } elseif {[tbool use_zip]} {
+         option extract.cmd [findBinary unzip ${portutil::autoconf::unzip_path}]
+         option extract.pre_args -q
+-        option extract.post_args "-d [option extract.dir]"
++        option extract.post_args "-d ${extract.dir}"
+     } elseif {[tbool use_7z]} {
+         option extract.cmd [binaryInPath "7za"]
+         option extract.pre_args x
+         option extract.post_args ""
+     } elseif {[tbool use_dmg]} {
+-        global distname
++        global distname extract.cmd
+         set dmg_mount [mkdtemp "/tmp/mports.XXXXXXXX"]
+         option extract.cmd [findBinary hdiutil ${portutil::autoconf::hdiutil_path}]
+         option extract.pre_args attach
+@@ -107,12 +107,6 @@
+     }
+ }
+ 
+-proc portextract::extract_start {args} {
+-    global UI_PREFIX
+-
+-    ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] [option name]]"
+-}
+-
+ proc portextract::extract_main {args} {
+     global UI_PREFIX filespath worksrcpath extract.dir usealtworkpath altprefix
+ 
+@@ -124,11 +118,11 @@
+     foreach distfile [option extract.only] {
+         ui_info "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $distfile]"
+         if {[file exists $filespath/$distfile]} {
+-            option extract.args "$filespath/$distfile"
++            option extract.args "'$filespath/$distfile'"
+         } elseif {![file exists "[option distpath]/$distfile"] && !$usealtworkpath && [file exists "${altprefix}[option distpath]/$distfile"]} {
+-            option extract.args "${altprefix}[option distpath]/$distfile"
++            option extract.args "'${altprefix}[option distpath]/$distfile'"
+         } else {
+-            option extract.args "[option distpath]/$distfile"
++            option extract.args "'[option distpath]/$distfile'"
+         }
+         if {[catch {command_exec extract} result]} {
+             return -code error "$result"
+Index: src/port1.0/portutil.tcl
+===================================================================
+--- src/port1.0/portutil.tcl	(revision 69681)
++++ src/port1.0/portutil.tcl	(revision 69682)
+@@ -328,7 +328,7 @@
+ # command_prefix    additional command prefix (typically pipe command)
+ # command_suffix    additional command suffix (typically redirection)
+ proc command_exec {command args} {
+-    global ${command}.env ${command}.env_array ${command}.nice env
++    global ${command}.env ${command}.env_array ${command}.nice env macosx_version
+     set notty ""
+     set command_prefix ""
+     set command_suffix ""
+@@ -394,7 +394,9 @@
+ 
+     # Restore the environment.
+     array unset env *
+-    unsetenv *
++    if {$macosx_version == "10.5"} {
++        unsetenv *
++    }
+     array set env [array get saved_env]
+ 
+     # Return as if system had been called directly.
+@@ -1134,32 +1136,6 @@
+     return
+ }
+ 
+-# filefindbypath
+-# Provides searching of the standard path for included files
+-proc filefindbypath {fname} {
+-    global distpath filesdir worksrcdir portpath
+-
+-    if {[file readable $portpath/$fname]} {
+-        return $portpath/$fname
+-    } elseif {[file readable $portpath/$filesdir/$fname]} {
+-        return $portpath/$filesdir/$fname
+-    } elseif {[file readable $distpath/$fname]} {
+-        return $distpath/$fname
+-    }
+-    return ""
+-}
+-
+-# include
+-# Source a file, looking for it along a standard search path.
+-proc include {fname} {
+-    set tgt [filefindbypath $fname]
+-    if {[string length $tgt]} {
+-        uplevel "source $tgt"
+-    } else {
+-        return -code error "Unable to find include file $fname"
+-    }
+-}
+-
+ # makeuserproc
+ # This procedure re-writes the user-defined custom target to include
+ # all the globals in its scope.  This is undeniably ugly, but I haven't
+@@ -1490,7 +1466,11 @@
+                 return 0
+             } else {
+                 # run the activate target but ignore its (completed) dependencies
+-                return [target_run [lindex [dlist_search $dlist provides $target] 0]]
++                set result [target_run [lindex [dlist_search $dlist provides $target] 0]]
++                if {[getuid] == 0 && [geteuid] != 0} {
++                    setegid 0; seteuid 0
++                }
++                return $result
+             }
+         }
+     }
+@@ -1510,6 +1490,10 @@
+ 
+     set dlist [dlist_eval $dlist "" target_run]
+ 
++    if {[getuid] == 0 && [geteuid] != 0} {
++        setegid 0; seteuid 0
++    }
++
+     if {[llength $dlist] > 0} {
+         # somebody broke!
+         set errstring "Warning: the following items did not execute (for $name):"
+@@ -1531,9 +1515,6 @@
+     global workpath worksymlink place_worksymlink name portpath ports_ignore_older ports_dryrun
+     global usealtworkpath altprefix env applications_dir portbuildpath
+ 
+-    # de-escalate privileges if MacPorts was started with sudo
+-    dropPrivileges
+-
+     if {$usealtworkpath} {
+          ui_warn_once "privileges" "MacPorts running without privileges.\
+                 You may be unable to complete certain actions (e.g. install)."
+@@ -1567,6 +1548,9 @@
+         }
+     }
+ 
++    # de-escalate privileges if MacPorts was started with sudo
++    dropPrivileges
++
+     # flock Portfile
+     set statefile [file join $workpath .macports.${name}.state]
+     if {[file exists $statefile]} {
+@@ -1579,6 +1563,7 @@
+         if {!([info exists ports_ignore_older] && $ports_ignore_older == "yes") && [file mtime $statefile] < [file mtime ${portpath}/Portfile]} {
+             if {![tbool ports_dryrun]} {
+                 ui_msg "Portfile changed since last build; discarding previous state."
++                chownAsRoot $portbuildpath
+                 delete $workpath
+                 file mkdir $workpath
+             } else {
+@@ -2361,15 +2346,17 @@
+ #
+ # @param path the file/directory to be chowned
+ proc chownAsRoot {path} {
+-    global euid macportsuser
++    global euid egid macportsuser
+ 
+     if { [getuid] == 0 } {
+         if {[geteuid] != 0} {
+             # if started with sudo but have dropped the privileges
++            setegid $egid
+             seteuid $euid
+             ui_debug "euid changed to: [geteuid]"
+             chown  ${path} ${macportsuser}
+             ui_debug "chowned $path to $macportsuser"
++            setegid [uname_to_gid "$macportsuser"]
+             seteuid [name_to_uid "$macportsuser"]
+             ui_debug "euid changed to: [geteuid]"
+         } else {
+@@ -2385,14 +2372,16 @@
+ # @param file the file in question
+ # @param attributes the attributes for the file
+ proc fileAttrsAsRoot {file attributes} {
+-    global euid macportsuser
++    global euid egid macportsuser
+     if {[getuid] == 0} {
+         if {[geteuid] != 0} {
+             # Started as root, but not root now
++            setegid $egid
+             seteuid $euid
+             ui_debug "euid changed to: [geteuid]"
+             ui_debug "setting attributes on $file"
+             eval file attributes {$file} $attributes
++            setegid [uname_to_gid "$macportsuser"]
+             seteuid [name_to_uid "$macportsuser"]
+             ui_debug "euid changed to: [geteuid]"
+         } else {
+@@ -2583,6 +2572,25 @@
+     }
+ }
+ 
++# check that the selected archs are supported
++proc check_supported_archs {} {
++    global supported_archs build_arch universal_archs configure.build_arch configure.universal_archs name
++    if {$supported_archs == "noarch"} {
++        return 0
++    } elseif {[variant_exists universal] && [variant_isset universal]} {
++        if {[llength ${configure.universal_archs}] > 1 || $universal_archs == ${configure.universal_archs}} {
++            return 0
++        } else {
++            ui_error "$name cannot be installed for the configured universal_archs '$universal_archs' because it only supports the arch(s) '$supported_archs'."
++            return 1
++        }
++    } elseif {$build_arch == "" || ${configure.build_arch} != ""} {
++        return 0
++    }
++    ui_error "$name cannot be installed for the configured build_arch '$build_arch' because it only supports the arch(s) '$supported_archs'."
++    return 1
++}
++
+ # check if the installed xcode version is new enough
+ proc _check_xcode_version {} {
+     global os.subplatform macosx_version xcodeversion
+@@ -2616,3 +2624,33 @@
+     }
+     return 0
+ }
++
++# check if we can unarchive this port
++proc _archive_available {} {
++    global name version revision portvariants ports_source_only
++    global unarchive.srcpath workpath
++
++    if {[option portarchivemode] != "yes" || [tbool ports_source_only]} {
++        return 0
++    }
++
++    # Define archive directory, file, and path
++    if {![string equal ${unarchive.srcpath} ${workpath}] && ![string equal ${unarchive.srcpath} ""]} {
++        set unarchive.fullsrcpath [file join ${unarchive.srcpath} [option archive.subdir]]
++    } else {
++        set unarchive.fullsrcpath ${unarchive.srcpath}
++    }
++
++    set found 0
++    foreach unarchive.type [option portarchivetype] {
++        if {[catch {archiveTypeIsSupported ${unarchive.type}} errmsg] == 0} {
++            set archstring [join [get_canonical_archs] -]
++            set unarchive.file "${name}-${version}_${revision}${portvariants}.${archstring}.${unarchive.type}"
++            if {[file isfile [file join ${unarchive.fullsrcpath} ${unarchive.file}]]} {
++                set found 1
++                break
++            }
++        }
++    }
++    return $found
++}
+Index: src/port1.0/portconfigure.tcl
+===================================================================
+--- src/port1.0/portconfigure.tcl	(revision 69681)
++++ src/port1.0/portconfigure.tcl	(revision 69682)
+@@ -226,12 +226,17 @@
+     set ret {}
+     foreach arch $archs {
+         if {[lsearch -exact $supported_archs $arch] != -1} {
+-            lappend ret $arch
+-        } elseif {$arch == "x86_64" && [lsearch -exact $supported_archs "i386"] != -1 && [lsearch -exact $ret "i386"] == -1} {
+-            lappend ret "i386"
+-        } elseif {$arch == "ppc64" && [lsearch -exact $supported_archs "ppc"] != -1 && [lsearch -exact $ret "ppc"] == -1} {
+-            lappend ret "ppc"
++            set add_arch $arch
++        } elseif {$arch == "x86_64" && [lsearch -exact $supported_archs "i386"] != -1} {
++            set add_arch "i386"
++        } elseif {$arch == "ppc64" && [lsearch -exact $supported_archs "ppc"] != -1} {
++            set add_arch "ppc"
++        } else {
++            continue
+         }
++        if {[lsearch -exact $ret $add_arch] == -1} {
++            lappend ret $add_arch
++        }
+     }
+     return $ret
+ }
+Index: src/port1.0/portclean.tcl
+===================================================================
+--- src/port1.0/portclean.tcl	(revision 69681)
++++ src/port1.0/portclean.tcl	(revision 69682)
+@@ -69,8 +69,9 @@
+         ui_info "$UI_PREFIX [format [msgcat::mc "Removing distfiles for %s"] [option name]]"
+         clean_dist
+     }
+-    if {[info exists ports_clean_all] && $ports_clean_all == "yes" || \
+-        [info exists ports_clean_archive] && $ports_clean_archive == "yes"} {
++    if {([info exists ports_clean_all] && $ports_clean_all == "yes" || \
++        [info exists ports_clean_archive] && $ports_clean_archive == "yes")
++        && !$usealtworkpath} {
+         ui_info "$UI_PREFIX [format [msgcat::mc "Removing archives for %s"] [option name]]"
+         clean_archive
+     }
+@@ -80,7 +81,8 @@
+          ui_info "$UI_PREFIX [format [msgcat::mc "Removing build directory for %s"] [option name]]"
+          clean_work
+     }
+-    if {([info exists ports_clean_logs] && $ports_clean_logs == "yes") || ($keeplogs == "no")} {
++    if {(([info exists ports_clean_logs] && $ports_clean_logs == "yes") || ($keeplogs == "no"))
++        && !$usealtworkpath} {
+         clean_logs
+     }
+ 
+@@ -92,12 +94,14 @@
+ # This is crude, but works.
+ #
+ proc portclean::clean_dist {args} {
+-    global ports_force name distpath dist_subdir distfiles usealtworkpath portdbpath altprefix
++    global ports_force name distpath dist_subdir distfiles patchfiles usealtworkpath portdbpath altprefix
+ 
+     # remove known distfiles for sure (if they exist)
+     set count 0
+     foreach file $distfiles {
+-        set distfile [file join $distpath $file]
++        set distfile [getdistname $file]
++        ui_debug "Looking for $distfile"
++        set distfile [file join $distpath $distfile]
+         if {[file isfile $distfile]} {
+             ui_debug "Removing file: $distfile"
+             if {[catch {delete $distfile} result]} {
+@@ -121,6 +125,37 @@
+         ui_debug "No distfiles found to remove at $distpath"
+     }
+ 
++    set count 0
++    if {![info exists patchfiles]} {
++        set patchfiles ""
++    }
++    foreach file $patchfiles {
++        set patchfile [getdistname $file]
++        ui_debug "Looking for $patchfile"
++        set patchfile [file join $distpath $patchfile]
++        if {[file isfile $patchfile]} {
++            ui_debug "Removing file: $patchfile"
++            if {[catch {delete $patchfile} result]} {
++                ui_debug "$::errorInfo"
++                ui_error "$result"
++            }
++            incr count
++        }
++        if {!$usealtworkpath && [file isfile ${altprefix}${patchfile}]} {
++            ui_debug "Removing file: ${altprefix}${patchfile}"
++            if {[catch {delete ${altprefix}${patchfile}} result]} {
++                ui_debug "$::errorInfo"
++                ui_error "$result"
++            }
++            incr count
++        }
++    }
++    if {$count > 0} {
++        ui_debug "$count patchfile(s) removed."
++    } else {
++        ui_debug "No patchfiles found to remove at $distpath"
++    }
++
+     # next remove dist_subdir if only needed for this port,
+     # or if user forces us to
+     set dirlist [list]
+@@ -139,7 +174,11 @@
+     # loop through directories
+     set count 0
+     foreach dir $dirlist {
+-        set distdir [file join ${portdbpath} distfiles $dir]
++        if {$usealtworkpath} {
++            set distdir [file join ${altprefix}${portdbpath} distfiles $dir]
++        } else {
++            set distdir [file join ${portdbpath} distfiles $dir]
++        }
+         if {[file isdirectory $distdir]} {
+             ui_debug "Removing directory: ${distdir}"
+             if {[catch {delete $distdir} result]} {
+@@ -222,7 +261,7 @@
+ 
+     # Define archive destination directory, target filename, regex for archive name
+     if {$portarchivepath ne $workpath && $portarchivepath ne ""} {
+-        set archivepath [file join $portarchivepath [option os.platform]]
++        set archivepath [file join $portarchivepath [option os.platform]_[option os.major]]
+         set regexstring "^$name-\[\\-_a-zA-Z0-9\\.\]+_\[0-9\]*\[+\\-_a-zA-Z0-9\]*\[\\.\].*\[\\.\]\[a-z2\]+\$"
+     }
+ 
+@@ -243,7 +282,7 @@
+ 
+     # Remove the archive files
+     set count 0
+-    if {![catch {set archivelist [glob [file join $archivepath * $fileglob]]} result]} {
++    if {![catch {set archivelist [glob [file join $archivepath * $name $fileglob]]} result]} {
+         foreach path $archivelist {
+             set file [file tail $path]
+             # Make sure file is truly a port archive file, and not
+Index: src/port1.0/port_autoconf.tcl.in
+===================================================================
+--- src/port1.0/port_autoconf.tcl.in	(revision 69681)
++++ src/port1.0/port_autoconf.tcl.in	(revision 69682)
+@@ -44,6 +44,7 @@
+ 	variable hg_path "@HG@"
+ 	variable gzip_path "@GZIP@"
+ 	variable lipo_path "@LIPO@"
++	variable openssl_path "@OPENSSL@"
+ 	variable patch_path "@PATCH@"
+ 	variable gnupatch_path "@GNUPATCH@"
+ 	variable rmdir_path "@RMDIR@"
+Index: src/port1.0/portdistfiles.tcl
+===================================================================
+--- src/port1.0/portdistfiles.tcl	(revision 69681)
++++ src/port1.0/portdistfiles.tcl	(revision 69682)
+@@ -82,7 +82,7 @@
+ 
+         # determine sites to download from
+         if {![info exists urlmap($url_var)]} {
+-            set urlmap($url_var) $master_sites
++            set urlmap($url_var) $urlmap(master_sites)
+         }
+         
+         # determine URLs to download
+Index: src/macports1.0/macports.tcl
+===================================================================
+--- src/macports1.0/macports.tcl	(revision 69681)
++++ src/macports1.0/macports.tcl	(revision 69682)
+@@ -51,8 +51,8 @@
+     variable portinterp_options "\
+         portdbpath porturl portpath portbuildpath auto_path prefix prefix_frozen portsharepath \
+         registry.path registry.format registry.installtype portarchivemode portarchivepath \
+-        portarchivetype portautoclean porttrace keeplogs portverbose destroot_umask rsync_server \
+-        rsync_options rsync_dir startupitem_type place_worksymlink macportsuser \
++        portarchivetype archivefetch_pubkeys portautoclean porttrace keeplogs portverbose destroot_umask \
++        rsync_server rsync_options rsync_dir startupitem_type place_worksymlink macportsuser \
+         mp_remote_url mp_remote_submit_url configureccache configuredistcc configurepipe buildnicevalue buildmakejobs \
+         applications_dir current_phase frameworks_dir developer_dir universal_archs build_arch \
+         os_arch os_endian os_version os_major os_platform macosx_version macosx_deployment_target $user_options"
+@@ -113,7 +113,7 @@
+     global macports::channels macports::portdbpath
+ 
+     if {[getuid] == 0 && [geteuid] != 0} {
+-        seteuid 0
++        seteuid 0; setegid 0
+     }
+     if {[catch {macports::ch_logging $mport} err]} {
+         ui_debug "Logging disabled, error opening log file: $err"
+@@ -155,6 +155,9 @@
+         }
+     }
+     if {$::logenabled} {
++        if {[getuid] == 0 && [geteuid] != 0} {
++            seteuid 0; setegid 0
++        }
+         if {[catch {macports::ch_logging $mport} err]} {
+             ui_debug "Logging disabled, error opening log file: $err"
+             return
+@@ -385,6 +388,9 @@
+                         set macports::xcodeversion "2.1"
+                     }
+                 }
++            } else {
++                ui_warn "xcodebuild exists but failed to execute"
++                set macports::xcodeversion "none"
+             }
+         }
+         if {![info exists xcodebuildcmd]} {
+@@ -464,6 +470,7 @@
+     global macports::os_platform
+     global macports::macosx_version
+     global macports::macosx_deployment_target
++    global macports::archivefetch_pubkeys
+ 
+     # Set the system encoding to utf-8
+     encoding system utf-8
+@@ -602,6 +609,21 @@
+     global macports::global_variations
+     array set macports::global_variations [array get variations]
+ 
++    # pubkeys.conf
++    set macports::archivefetch_pubkeys {}
++    if {[file isfile [file join ${macports_conf_path} pubkeys.conf]]} {
++        set fd [open [file join ${macports_conf_path} pubkeys.conf] r]
++        while {[gets $fd line] >= 0} {
++            set line [string trim $line]
++            if {![regexp {^[\ \t]*#.*$|^$} $line]} {
++                lappend macports::archivefetch_pubkeys $line
++            }
++        }
++        close $fd
++    } else {
++        ui_debug "pubkeys.conf does not exist."
++    }
++
+     if {![info exists portdbpath]} {
+         return -code error "portdbpath must be set in ${macports_conf_path}/macports.conf or in your ${macports_user_dir}/macports.conf"
+     }
+@@ -834,9 +856,10 @@
+         set keepenvkeys [concat ${keepenvkeys} ${extra_env}]
+     }
+ 
+-    foreach envkey [array names env] {
+-        if {[lsearch $keepenvkeys $envkey] == -1} {
+-            array unset env $envkey
++    set env_names [array names env]
++    foreach envkey $env_names {
++        if {[lsearch -exact $keepenvkeys $envkey] == -1} {
++            unset env($envkey)
+         }
+     }
+ 
+@@ -870,9 +893,11 @@
+     }
+ 
+     # unset environment an extra time, to work around bugs in Leopard Tcl
+-    foreach envkey [array names env] {
+-        if {[lsearch $keepenvkeys $envkey] == -1} {
+-            unsetenv $envkey
++    if {$macosx_version == "10.5"} {
++        foreach envkey $env_names {
++            if {[lsearch -exact $keepenvkeys $envkey] == -1} {
++                unsetenv $envkey
++            }
+         }
+     }
+ 
+@@ -1512,6 +1537,7 @@
+     # xxx: set the work path?
+     set workername [ditem_key $mport workername]
+     if {![catch {$workername eval check_variants $target} result] && $result == 0 &&
++        ![catch {$workername eval check_supported_archs} result] && $result == 0 &&
+         ![catch {$workername eval eval_targets $target} result] && $result == 0} {
+         # If auto-clean mode, clean-up after dependency install
+         if {[string equal ${macports::portautoclean} "yes"]} {
+@@ -1556,29 +1582,26 @@
+     }
+ 
+     # Before we build the port, we must build its dependencies.
+-    # XXX: need a more general way of comparing against targets
+     set dlist {}
+-    if {   $target == "fetch" || $target == "checksum"
+-        || $target == "extract" || $target == "patch"
+-        || $target == "configure" || $target == "build"
+-        || $target == "test"
+-        || $target == "destroot" || $target == "install"
+-        || $target == "archive"
+-        || $target == "dmg" || $target == "mdmg"
+-        || $target == "pkg" || $target == "mpkg"
+-        || $target == "rpm" || $target == "dpkg"
+-        || $target == "srpm"|| $target == "portpkg" } {
++    if {[macports::_target_needs_deps $target]} {
+ 
+-        # possibly warn or error out depending on how old xcode is
+-        if {[$workername eval _check_xcode_version] != 0} {
+-            return 1
++        # see if we actually need to build this port
++        if {![$workername eval registry_exists \$name \$version \$revision \$portvariants]} {
++            # possibly warn or error out depending on how old xcode is
++            if {[$workername eval _check_xcode_version] != 0} {
++                return 1
++            }
++            # error out if selected arch(s) not supported by this port
++            if {[$workername eval check_supported_archs] != 0} {
++                return 1
++            }
++    
++            # upgrade dependencies that are already installed
++            if {![macports::global_option_isset ports_nodeps]} {
++                macports::_upgrade_mport_deps $mport $target
++            }
+         }
+ 
+-        # upgrade dependencies that are already installed
+-        if {![macports::global_option_isset ports_nodeps]} {
+-            macports::_upgrade_mport_deps $mport $target
+-        }
+-
+         ui_msg -nonewline "--->  Computing dependencies for [_mportkey $mport name]"
+         if {[macports::ui_isset ports_debug]} {
+             # play nice with debug messages
+@@ -1612,7 +1635,7 @@
+         if { [string equal ${macports::registry.installtype} "image"] } {
+             set result [dlist_eval $dlist _mportactive [list _mportexec "activate"]]
+         } else {
+-            set result [dlist_eval $dlist _mportinstalled [list _mportexec "install"]]
++            set result [dlist_eval $dlist _mportinstalled [list _mportexec "activate"]]
+         }
+ 
+         if {$result != {}} {
+@@ -1634,11 +1657,6 @@
+     }
+ 
+     set clean 0
+-    if {[string equal $target "install"] && [string equal ${macports::registry.installtype} "image"]} {
+-        # If we're doing image installs, then we should activate after install
+-        # xxx: This isn't pretty
+-        set target activate
+-    }
+     if {[string equal ${macports::portautoclean} "yes"] && ([string equal $target "install"] || [string equal $target "activate"])} {
+         # If we're doing an install, check if we should clean after
+         set clean 1
+@@ -1670,7 +1688,7 @@
+ proc macports::_upgrade_mport_deps {mport target} {
+     set options [ditem_key $mport options]
+     set workername [ditem_key $mport workername]
+-    set deptypes [macports::_deptypes_for_target $target]
++    set deptypes [macports::_deptypes_for_target $target $workername]
+     array set portinfo [mportinfo $mport]
+     array set depscache {}
+ 
+@@ -1910,6 +1928,8 @@
+                     ui_debug $rsync_commandline
+                     if {[catch {system $rsync_commandline}]} {
+                         ui_debug "Synchronization of the PortIndex failed doing rsync"
++                    } else {
++                        mports_generate_quickindex $indexfile
+                     }
+                 }
+                 if {[catch {system "chmod -R a+r \"$destdir\""}]} {
+@@ -1937,7 +1957,7 @@
+                         continue
+                     }
+ 
+-                    file mkdir [file dirname $indexfile]
++                    file mkdir $destdir
+ 
+                     set verboseflag {}
+                     if {$macports::portverbose == "yes"} {
+@@ -1971,6 +1991,11 @@
+                         ui_warn "Setting world read permissions on parts of the ports tree failed, need root?"
+                     }
+ 
++                    set platindex "PortIndex_${macports::os_platform}_${macports::os_major}_${macports::os_arch}/PortIndex"
++                    if {[file isfile ${destdir}/${platindex}] && [file isfile ${destdir}/${platindex}.quick]} {
++                        file rename -force "${destdir}/${platindex}" "${destdir}/${platindex}.quick" $destdir
++                    }
++
+                     file delete $tarpath
+                     
+                     set needs_portindex 1
+@@ -2401,18 +2426,22 @@
+         flush stdout
+     }
+     
+-    if {[info exists portinfo(conflicts)] && ($target == "" || $target == "install")} {
++    if {[info exists portinfo(conflicts)] && ($target == "" || $target == "install" || $target == "activate")} {
+         set conflictports [_mportconflictsinstalled $mport $portinfo(conflicts)]
+         if {[llength ${conflictports}] != 0} {
+             if {[macports::global_option_isset ports_force]} {
+                 ui_warn "Force option set; installing $portinfo(name) despite conflicts with: ${conflictports}"
+             } else {
++                if {![macports::ui_isset ports_debug]} {
++                    ui_msg ""
++                }
+                 return -code error "Can't install $portinfo(name) because conflicting ports are installed: ${conflictports}"
+             }
+         }
+     }
+ 
+-    set deptypes [macports::_deptypes_for_target $target]
++    set workername [ditem_key $mport workername]
++    set deptypes [macports::_deptypes_for_target $target $workername]
+ 
+     set subPorts {}
+     if {[llength $deptypes] > 0} {
+@@ -2421,7 +2450,6 @@
+         set optionsarray(ports_requested) 0
+         set options [array get optionsarray]
+         set variations [ditem_key $mport variations]
+-        set workername [ditem_key $mport workername]
+         set required_archs [$workername eval get_canonical_archs]
+         set depends_skip_archcheck [_mportkey $mport depends_skip_archcheck]
+     }
+@@ -2605,32 +2633,69 @@
+     ui_error "and does not have a universal variant."
+ }
+ 
++# check if the given target needs dependencies installed first
++proc macports::_target_needs_deps {target} {
++    # XXX: need a better way than checking this hardcoded list
++    switch -- $target {
++        fetch -
++        checksum -
++        extract -
++        patch -
++        configure -
++        build -
++        test -
++        destroot -
++        install -
++        archive -
++        activate -
++        dmg -
++        mdmg -
++        pkg -
++        mpkg -
++        rpm -
++        dpkg -
++        srpm { return 1 }
++        default { return 0 }
++    }
++}
++
+ # Determine dependency types required for target
+-proc macports::_deptypes_for_target {target} {
++proc macports::_deptypes_for_target {target workername} {
+     switch $target {
+         fetch       -
+-        checksum    { set deptypes "depends_fetch" }
++        checksum    { return "depends_fetch" }
+         extract     -
+-        patch       { set deptypes "depends_fetch depends_extract" }
++        patch       { return "depends_fetch depends_extract" }
+         configure   -
+-        build       { set deptypes "depends_fetch depends_extract depends_build depends_lib" }
+-
++        build       { return "depends_fetch depends_extract depends_build depends_lib" }
+         test        -
+-        destroot    -
+-        install     -
+-        activate    -
++        srpm        -
++        destroot    { return "depends_fetch depends_extract depends_build depends_lib depends_run" }
+         archive     -
+         dmg         -
+         pkg         -
+-        portpkg     -
+         mdmg        -
+         mpkg        -
+         rpm         -
+-        srpm        -
+-        dpkg        -
+-        ""          { set deptypes "depends_fetch depends_extract depends_build depends_lib depends_run" }
++        dpkg        {
++            if {[$workername eval _archive_available]} {
++                return "depends_lib depends_run"
++            } else {
++                return "depends_fetch depends_extract depends_build depends_lib depends_run"
++            }
++        }
++        install     -
++        activate    -
++        ""          {
++            if {[$workername eval registry_exists \$name \$version \$revision \$portvariants]
++                || [$workername eval _archive_available]} {
++                return "depends_lib depends_run"
++            } else {
++                return "depends_fetch depends_extract depends_build depends_lib depends_run"
++            }
++        }
+     }
+-    return $deptypes
++    return ""
+ }
+ 
+ # selfupdate procedure
+@@ -2861,7 +2926,7 @@
+                     return $status
+                 }
+                 # now install it
+-                if {[catch {set result [mportexec $workername install]} result]} {
++                if {[catch {set result [mportexec $workername activate]} result]} {
+                     global errorInfo
+                     ui_debug "$errorInfo"
+                     ui_error "Unable to exec port: $result"
+@@ -3170,7 +3235,8 @@
+             # we have to force the uninstall in case of dependents
+             set force_cur [info exists options(ports_force)]
+             set options(ports_force) yes
+-            set newregref [registry::open_entry $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants) $epoch_in_tree]
++            set existing_epoch [lindex [lindex [registry::installed $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants)] 0] 5]
++            set newregref [registry::open_entry $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants) $existing_epoch]
+             if {$is_dryrun eq "yes"} {
+                 ui_msg "Skipping uninstall $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
+             } elseif {!(${registry.format} == "receipt_sqlite" && [registry::run_target $newregref uninstall [array get options]])
+@@ -3189,7 +3255,28 @@
+                 set anyactive no
+             }
+         }
+-        if {[info exists options(port_uninstall_old)]} {
++        if {$anyactive && $portname != $newname} {
++            # replaced_by in effect, deactivate the old port
++            # we have to force the deactivate in case of dependents
++            set force_cur [info exists options(ports_force)]
++            set options(ports_force) yes
++            if {$is_dryrun eq "yes"} {
++                ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}${variant_active} (dry run)"
++            } elseif {![catch {registry::active $portname}] &&
++                      !(${registry.format} == "receipt_sqlite" && [registry::run_target $regref deactivate [array get options]])
++                      && [catch {portimage::deactivate $portname ${version_active}_${revision_active}${variant_active} [array get options]} result]} {
++                global errorInfo
++                ui_debug "$errorInfo"
++                ui_error "Deactivating $portname @${version_active}_${revision_active}${variant_active} failed: $result"
++                catch {mportclose $workername}
++                return 1
++            }
++            if {!$force_cur} {
++                unset options(ports_force)
++            }
++            set anyactive no
++        }
++        if {[info exists options(port_uninstall_old)] && $portname == $newname} {
+             # uninstalling now could fail due to dependents when not forced,
+             # because the new version is not installed
+             set uninstall_later yes
+@@ -3201,7 +3288,7 @@
+             ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}${variant_active} (dry run)"
+         }
+         ui_msg "Skipping activate $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
+-    } elseif {[catch {set result [mportexec $workername install]} result]} {
++    } elseif {[catch {set result [mportexec $workername activate]} result]} {
+         global errorInfo
+         ui_debug "$errorInfo"
+         ui_error "Couldn't activate $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants): $result"
+Index: src/package1.0/portarchivefetch.tcl
+===================================================================
+--- src/package1.0/portarchivefetch.tcl	(revision 69681)
++++ src/package1.0/portarchivefetch.tcl	(revision 69682)
+@@ -47,7 +47,8 @@
+ 
+ options archive_sites archivefetch.user archivefetch.password \
+     archivefetch.use_epsv archivefetch.ignore_sslcert \
+-    archive_sites.mirror_subdir
++    archive_sites.mirror_subdir archivefetch.pubkeys \
++    archive.subdir
+ 
+ # user name & password
+ default archivefetch.user ""
+@@ -56,13 +57,24 @@
+ default archivefetch.use_epsv no
+ # Ignore SSL certificate
+ default archivefetch.ignore_sslcert no
++default archivefetch.pubkeys {$archivefetch_pubkeys}
+ 
+ default archive_sites macports_archives
+ default archive_sites.listfile {"archive_sites.tcl"}
+ default archive_sites.listpath {"port1.0/fetch"}
++default archive.subdir {[portarchivefetch::get_archive_subdir]}
+ 
+ set_ui_prefix
+ 
++proc portarchivefetch::get_archive_subdir {} {
++    set archs [get_canonical_archs]
++    if {[llength $archs] > 1} {
++        return [file join [option os.platform]_[option os.major] "universal" [option name]]
++    } else {
++        return [file join [option os.platform]_[option os.major] $archs [option name]]
++    }
++}
++
+ # Checks possible archive files to assemble url lists for later fetching
+ proc portarchivefetch::checkarchivefiles {urls} {
+     global all_archive_files archivefetch.fulldestpath \
+@@ -70,11 +82,7 @@
+     upvar $urls fetch_urls
+ 
+     # Define archive directory, file, and path
+-    if {[llength [get_canonical_archs]] > 1} {
+-        set archivefetch.fulldestpath [file join ${portarchivepath} [option os.platform] "universal"]
+-    } else {
+-        set archivefetch.fulldestpath [file join ${portarchivepath} [option os.platform] [get_canonical_archs]]
+-    }
++    set archivefetch.fulldestpath [file join ${portarchivepath} [option archive.subdir]]
+ 
+     set unsupported 0
+     set found 0
+@@ -125,7 +133,7 @@
+ # Perform a standard fetch, assembling fetch urls from
+ # the listed url variable and associated archive file
+ proc portarchivefetch::fetchfiles {args} {
+-    global archivefetch.fulldestpath UI_PREFIX
++    global portarchivepath archivefetch.fulldestpath UI_PREFIX
+     global archivefetch.user archivefetch.password archivefetch.use_epsv \
+            archivefetch.ignore_sslcert
+     global portverbose ports_binary_only
+@@ -141,7 +149,18 @@
+             }
+         }
+     }
++    set incoming_path [file join ${portarchivepath} incoming]
++    if {![file isdirectory $incoming_path]} {
++        if {[catch {file mkdir $incoming_path} result]} {
++            elevateToRoot "archivefetch"
++            set elevated yes
++            if {[catch {file mkdir $incoming_path} result]} {
++                return -code error [format [msgcat::mc "Unable to create archive fetch path: %s"] $result]
++            }
++        }
++    }
+     chownAsRoot ${archivefetch.fulldestpath}
++    chownAsRoot $incoming_path
+     if {[info exists elevated] && $elevated == yes} {
+         dropPrivileges
+     }
+@@ -168,30 +187,64 @@
+             if {![file writable ${archivefetch.fulldestpath}]} {
+                 return -code error [format [msgcat::mc "%s must be writable"] ${archivefetch.fulldestpath}]
+             }
++            if {![file writable $incoming_path]} {
++                return -code error [format [msgcat::mc "%s must be writable"] $incoming_path]
++            }
+             if {!$sorted} {
+                 portfetch::sortsites archivefetch_urls {} archive_sites
+                 set sorted yes
+             }
+             if {![info exists urlmap($url_var)]} {
+                 ui_error [format [msgcat::mc "No defined site for tag: %s, using archive_sites"] $url_var]
+-                set urlmap($url_var) $archive_sites
++                set urlmap($url_var) $urlmap(archive_sites)
+             }
+             unset -nocomplain fetched
+             foreach site $urlmap($url_var) {
+-                ui_msg "$UI_PREFIX [format [msgcat::mc "Attempting to fetch %s from %s"] $archive $site]"
++                if {[string index $site end] != "/"} {
++                    append site "/[option archive.subdir]"
++                } else {
++                    append site [option archive.subdir]
++                }
++                ui_msg "$UI_PREFIX [format [msgcat::mc "Attempting to fetch %s from %s"] $archive ${site}]"
+                 set file_url [portfetch::assemble_url $site $archive]
+                 set effectiveURL ""
+-                if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} ${archivefetch.fulldestpath}/${archive}.TMP} result] &&
+-                    ![catch {file rename -force "${archivefetch.fulldestpath}/${archive}.TMP" "${archivefetch.fulldestpath}/${archive}"} result]} {
++                if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} {"${incoming_path}/${archive}.TMP"}} result]} {
+                     # Successful fetch
+                     set fetched 1
+                     break
+                 } else {
+                     ui_debug "[msgcat::mc "Fetching archive failed:"]: $result"
+-                    file delete -force "${archivefetch.fulldestpath}/${archive}.TMP"
++                    file delete -force "${incoming_path}/${archive}.TMP"
+                 }
+             }
+             if {[info exists fetched]} {
++                # there should be an rmd160 digest of the archive signed with one of the trusted keys
++                set signature "${incoming_path}/${archive}.rmd160"
++                ui_msg "$UI_PREFIX [format [msgcat::mc "Attempting to fetch %s from %s"] ${archive}.rmd160 $site]"
++                # reusing $file_url from the last iteration of the loop above
++                if {[catch {eval curl fetch --effective-url effectiveURL $fetch_options {${file_url}.rmd160} {$signature}} result]} {
++                    ui_debug "$::errorInfo"
++                    return -code error "Failed to fetch signature for archive: $result"
++                }
++                set verified 0
++                foreach pubkey [option archivefetch.pubkeys] {
++                    set openssl [findBinary openssl $portutil::autoconf::openssl_path]
++                    if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature "${incoming_path}/${archive}.TMP"} result]} {
++                        set verified 1
++                        break
++                    } else {
++                        ui_debug "failed verification with key $pubkey"
++                        ui_debug "openssl output: $result"
++                    }
++                }
++                if {!$verified} {
++                    return -code error "Failed to verify signature for archive!"
++                }
++                if {[catch {file rename -force "${incoming_path}/${archive}.TMP" "${archivefetch.fulldestpath}/${archive}"} result]} {
++                    ui_debug "$::errorInfo"
++                    return -code error "Failed to move downloaded archive into place: $result"
++                }
++                file delete -force $signature
+                 return 0
+             }
+         } else {
+@@ -207,19 +260,20 @@
+ 
+ # Initialize archivefetch target and call checkfiles.
+ proc portarchivefetch::archivefetch_init {args} {
+-    variable archivefetch_urls
+-
+     if {[option portarchivemode] != "yes"} {
+         return -code error "Archive mode is not enabled!"
+     }
+-
+-    portarchivefetch::checkfiles archivefetch_urls
+ }
+ 
+ proc portarchivefetch::archivefetch_start {args} {
+-    global UI_PREFIX name
+-
+-    ui_msg "$UI_PREFIX [format [msgcat::mc "Fetching archive for %s"] $name]"
++    variable archivefetch_urls
++    global UI_PREFIX name all_archive_files ports_source_only
++    if {![tbool ports_source_only]} {
++        portarchivefetch::checkfiles archivefetch_urls
++    }
++    if {[info exists all_archive_files] && [llength $all_archive_files] > 0} {
++        ui_msg "$UI_PREFIX [format [msgcat::mc "Fetching archive for %s"] $name]"
++    }
+ }
+ 
+ # Main archive fetch routine
+@@ -229,5 +283,7 @@
+     if {[info exists all_archive_files] && [llength $all_archive_files] > 0} {
+         # Fetch the files
+         return [portarchivefetch::fetchfiles]
++    } else {
++        return 0
+     }
+ }
+Index: src/package1.0/portarchive.tcl
+===================================================================
+--- src/package1.0/portarchive.tcl	(revision 69681)
++++ src/package1.0/portarchive.tcl	(revision 69682)
+@@ -78,11 +78,7 @@
+ 
+     # Define archive destination directory and target filename
+     if {![string equal ${archive.destpath} ${workpath}] && ![string equal ${archive.destpath} ""]} {
+-        if {[llength [get_canonical_archs]] > 1} {
+-            set archive.fulldestpath [file join ${archive.destpath} [option os.platform] "universal"]
+-        } else {
+-            set archive.fulldestpath [file join ${archive.destpath} [option os.platform] [get_canonical_archs]]
+-        }
++        set archive.fulldestpath [file join ${archive.destpath} [option archive.subdir]]
+     } else {
+         set archive.fulldestpath ${archive.destpath}
+     }
+@@ -294,14 +290,18 @@
+     global archive.meta archive.metaname archive.metapath
+     global os.platform
+ 
++    if {[getuid] == 0 && [geteuid] != 0} {
++        elevateToRoot "archive"
++    }
++
+     # Create archive destination path (if needed)
+     if {![file isdirectory ${archive.fulldestpath}]} {
+-        system "mkdir -p ${archive.fulldestpath}"
++        file mkdir ${archive.fulldestpath}
+     }
+ 
+     # Create (if no files) destroot for archiving
+     if {![file isdirectory ${destpath}]} {
+-        system "mkdir -p ${destpath}"
++        file mkdir ${destpath}
+     }
+ 
+     # Copy state file into destroot for archiving
+Index: src/package1.0/portunarchive.tcl
+===================================================================
+--- src/package1.0/portunarchive.tcl	(revision 69681)
++++ src/package1.0/portunarchive.tcl	(revision 69682)
+@@ -73,11 +73,7 @@
+ 
+     # Define archive directory, file, and path
+     if {![string equal ${unarchive.srcpath} ${workpath}] && ![string equal ${unarchive.srcpath} ""]} {
+-        if {[llength [get_canonical_archs]] > 1} {
+-            set unarchive.fullsrcpath [file join ${unarchive.srcpath} [option os.platform] "universal"]
+-        } else {
+-            set unarchive.fullsrcpath [file join ${unarchive.srcpath} [option os.platform] [get_canonical_archs]]
+-        }
++        set unarchive.fullsrcpath [file join ${unarchive.srcpath} [option archive.subdir]]
+     } else {
+         set unarchive.fullsrcpath ${unarchive.srcpath}
+     }
+@@ -103,7 +99,7 @@
+                 set archstring [join [get_canonical_archs] -]
+                 set unarchive.file "${name}-${version}_${revision}${portvariants}.${archstring}.${unarchive.type}"
+                 set unarchive.path "[file join ${unarchive.fullsrcpath} ${unarchive.file}]"
+-                if {[file exist ${unarchive.path}]} {
++                if {[file isfile ${unarchive.path}]} {
+                     set found 1
+                     break
+                 } else {
+Index: src/cregistry/sql.c
+===================================================================
+--- src/cregistry/sql.c	(revision 69681)
++++ src/cregistry/sql.c	(revision 69682)
+@@ -51,11 +51,13 @@
+ int do_queries(sqlite3* db, char** queries, reg_error* errPtr) {
+     char** query;
+     for (query = queries; *query != NULL; query++) {
+-        sqlite3_stmt* stmt;
++        sqlite3_stmt* stmt = NULL;
+         if ((sqlite3_prepare(db, *query, -1, &stmt, NULL) != SQLITE_OK)
+                 || (sqlite3_step(stmt) != SQLITE_DONE)) {
+             reg_sqlite_error(db, errPtr, *query);
+-            sqlite3_finalize(stmt);
++            if (stmt) {
++                sqlite3_finalize(stmt);
++            }
+             return 0;
+         }
+         sqlite3_finalize(stmt);
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 69681)
++++ src/cregistry/entry.c	(revision 69682)
+@@ -78,10 +78,10 @@
+  * @param [in,out] dst_space number of characters `dst` can hold
+  * @param [in] src           string to concatenate to `dst`
+  */
+-static int reg_strcat(char** dst, int* dst_len, int* dst_space, char* src) {
+-    int src_len = strlen(src);
+-    int result_len = *dst_len + src_len;
+-    if (result_len >= *dst_space) {
++static int reg_strcat(char** dst, size_t* dst_len, size_t* dst_space, char* src) {
++    size_t src_len = strlen(src);
++    size_t result_len = *dst_len + src_len;
++    if (result_len > *dst_space) {
+         char* new_dst;
+         *dst_space *= 2;
+         if (*dst_space < result_len) {
+@@ -197,7 +197,7 @@
+  */
+ reg_entry* reg_entry_create(reg_registry* reg, char* name, char* version,
+         char* revision, char* variants, char* epoch, reg_error* errPtr) {
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     reg_entry* entry = NULL;
+     char* query = "INSERT INTO registry.ports "
+         "(name, version, revision, variants, epoch) VALUES (?, ?, ?, ?, ?)";
+@@ -239,7 +239,9 @@
+     } else {
+         reg_sqlite_error(reg->db, errPtr, query);
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     return entry;
+ }
+ 
+@@ -257,7 +259,7 @@
+  */
+ reg_entry* reg_entry_open(reg_registry* reg, char* name, char* version,
+         char* revision, char* variants, char* epoch, reg_error* errPtr) {
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     reg_entry* entry = NULL;
+     char* query = "SELECT id FROM registry.ports WHERE name=? AND version=? "
+         "AND revision=? AND variants=? AND epoch=?";
+@@ -296,7 +298,9 @@
+     } else {
+         reg_sqlite_error(reg->db, errPtr, query);
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     return entry;
+ }
+ 
+@@ -312,9 +316,9 @@
+ int reg_entry_delete(reg_entry* entry, reg_error* errPtr) {
+     reg_registry* reg = entry->reg;
+     int result = 0;
+-    sqlite3_stmt* ports;
+-    sqlite3_stmt* files;
+-    sqlite3_stmt* dependencies;
++    sqlite3_stmt* ports = NULL;
++    sqlite3_stmt* files = NULL;
++    sqlite3_stmt* dependencies = NULL;
+     char* ports_query = "DELETE FROM registry.ports WHERE id=?";
+     char* files_query = "DELETE FROM registry.files WHERE id=?";
+     char* dependencies_query = "DELETE FROM registry.dependencies WHERE id=?";
+@@ -375,9 +379,15 @@
+     } else {
+         reg_sqlite_error(reg->db, errPtr, NULL);
+     }
+-    sqlite3_finalize(ports);
+-    sqlite3_finalize(files);
+-    sqlite3_finalize(dependencies);
++    if (ports) {
++        sqlite3_finalize(ports);
++    }
++    if (files) {
++        sqlite3_finalize(files);
++    }
++    if (dependencies) {
++        sqlite3_finalize(dependencies);
++    }
+     return result;
+ }
+ 
+@@ -417,7 +427,7 @@
+     void** results = malloc(10*sizeof(void*));
+     int result_count = 0;
+     int result_space = 10;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     if (!results) {
+         return -1;
+     }
+@@ -455,7 +465,9 @@
+             }
+         }
+     } else {
+-        sqlite3_finalize(stmt);
++        if (stmt) {
++            sqlite3_finalize(stmt);
++        }
+         reg_sqlite_error(reg->db, errPtr, query);
+     }
+     free(results);
+@@ -499,8 +511,7 @@
+     int i;
+     char* kwd = " WHERE ";
+     char* query;
+-    int query_len = 29;
+-    int query_space = 29;
++    size_t query_len, query_space;
+     int result;
+     /* get the strategy */
+     char* op = reg_strategy_op(strategy, errPtr);
+@@ -512,6 +523,7 @@
+     if (!query) {
+         return -1;
+     }
++    query_len = query_space = strlen(query);
+     for (i=0; i<key_count; i++) {
+         char* cond = sqlite3_mprintf(op, keys[i], vals[i]);
+         if (!cond || !reg_strcat(&query, &query_len, &query_space, kwd)
+@@ -523,7 +535,7 @@
+         kwd = " AND ";
+     }
+     /* do the query */
+-    result = reg_all_entries(reg, query, query_len, entries, errPtr);
++    result = reg_all_entries(reg, query, -1, entries, errPtr);
+     free(query);
+     return result;
+ }
+@@ -619,7 +631,7 @@
+ int reg_entry_owner(reg_registry* reg, char* path, reg_entry** entry,
+         reg_error* errPtr) {
+     int result = 0;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     char* query = "SELECT id FROM registry.files WHERE actual_path=? AND active";
+     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+             && (sqlite3_bind_text(stmt, 1, path, -1, SQLITE_STATIC)
+@@ -646,7 +658,9 @@
+     } else {
+         reg_sqlite_error(reg->db, errPtr, query);
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     return result;
+ }
+ 
+@@ -663,7 +677,7 @@
+  * @return          id of owner, or 0 for none
+  */
+ sqlite_int64 reg_entry_owner_id(reg_registry* reg, char* path) {
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     sqlite_int64 result = 0;
+     char* query = "SELECT id FROM registry.files WHERE actual_path=? AND active";
+     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+@@ -677,7 +691,9 @@
+             }
+         } while (r == SQLITE_BUSY);
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     return result;
+ }
+ 
+@@ -696,7 +712,7 @@
+         reg_error* errPtr) {
+     reg_registry* reg = entry->reg;
+     int result = 0;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     char* query;
+     const char *text;
+     query = sqlite3_mprintf("SELECT %q FROM registry.ports WHERE id=%lld", key,
+@@ -730,7 +746,9 @@
+     } else {
+         reg_sqlite_error(reg->db, errPtr, query);
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     sqlite3_free(query);
+     return result;
+ }
+@@ -753,7 +771,7 @@
+         reg_error* errPtr) {
+     reg_registry* reg = entry->reg;
+     int result = 0;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     char* query;
+     query = sqlite3_mprintf("UPDATE registry.ports SET %q = '%q' WHERE id=%lld",
+             key, value, entry->id);
+@@ -781,7 +799,9 @@
+     } else {
+         reg_sqlite_error(reg->db, errPtr, query);
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     sqlite3_free(query);
+     return result;
+ }
+@@ -800,7 +820,7 @@
+         reg_error* errPtr) {
+     reg_registry* reg = entry->reg;
+     int result = 1;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     char* insert = "INSERT INTO registry.files (id, path, mtime, active) "
+         "VALUES (?, ?, 0, 0)";
+     if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
+@@ -833,7 +853,9 @@
+         reg_sqlite_error(reg->db, errPtr, insert);
+         result = 0;
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     return result;
+ }
+ 
+@@ -851,7 +873,7 @@
+         reg_error* errPtr) {
+     reg_registry* reg = entry->reg;
+     int result = 1;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     char* query = "DELETE FROM registry.files WHERE path=? AND id=?";
+     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+             && (sqlite3_bind_int64(stmt, 2, entry->id) == SQLITE_OK)) {
+@@ -889,7 +911,9 @@
+         reg_sqlite_error(reg->db, errPtr, query);
+         result = 0;
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     return result;
+ }
+ 
+@@ -906,7 +930,7 @@
+  */
+ int reg_entry_imagefiles(reg_entry* entry, char*** files, reg_error* errPtr) {
+     reg_registry* reg = entry->reg;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     char* query = "SELECT path FROM registry.files WHERE id=? ORDER BY path";
+     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+             && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
+@@ -953,7 +977,9 @@
+         }
+     } else {
+         reg_sqlite_error(reg->db, errPtr, query);
+-        sqlite3_finalize(stmt);
++        if (stmt) {
++            sqlite3_finalize(stmt);
++        }
+         return -1;
+     }
+ }
+@@ -971,7 +997,7 @@
+  */
+ int reg_entry_files(reg_entry* entry, char*** files, reg_error* errPtr) {
+     reg_registry* reg = entry->reg;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     char* query = "SELECT actual_path FROM registry.files WHERE id=? "
+         "AND active ORDER BY actual_path";
+     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+@@ -1019,7 +1045,9 @@
+         }
+     } else {
+         reg_sqlite_error(reg->db, errPtr, query);
+-        sqlite3_finalize(stmt);
++        if (stmt) {
++            sqlite3_finalize(stmt);
++        }
+         return -1;
+     }
+ }
+@@ -1043,8 +1071,8 @@
+     reg_registry* reg = entry->reg;
+     int result = 1;
+     int i;
+-    sqlite3_stmt* select;
+-    sqlite3_stmt* update;
++    sqlite3_stmt* select = NULL;
++    sqlite3_stmt* update = NULL;
+     char* select_query = "SELECT id FROM registry.files WHERE actual_path=? "
+         "AND active";
+     char* update_query = "UPDATE registry.files SET actual_path=?, active=1 "
+@@ -1117,12 +1145,16 @@
+             reg_sqlite_error(reg->db, errPtr, update_query);
+             result = 0;
+         }
+-        sqlite3_finalize(update);
++        if (update) {
++            sqlite3_finalize(update);
++        }
+     } else {
+         reg_sqlite_error(reg->db, errPtr, select_query);
+         result = 0;
+     }
+-    sqlite3_finalize(select);
++    if (select) {
++        sqlite3_finalize(select);
++    }
+     return result;
+ }
+ 
+@@ -1141,7 +1173,7 @@
+     reg_registry* reg = entry->reg;
+     int result = 1;
+     int i;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     char* query = "UPDATE registry.files SET active=0 WHERE actual_path=? AND id=?";
+     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+             && (sqlite3_bind_int64(stmt, 2, entry->id) == SQLITE_OK)) {
+@@ -1178,7 +1210,9 @@
+         reg_sqlite_error(reg->db, errPtr, query);
+         result = 0;
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     return result;
+ }
+ 
+@@ -1240,7 +1274,7 @@
+ int reg_entry_depends(reg_entry* entry, char* name, reg_error* errPtr) {
+     reg_registry* reg = entry->reg;
+     int result = 0;
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     char* query = "INSERT INTO registry.dependencies (id, name) VALUES (?,?)";
+     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+             && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)
+@@ -1263,7 +1297,9 @@
+     } else {
+         reg_sqlite_error(reg->db, errPtr, query);
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     return result;
+ }
+ 
+Index: src/cregistry/registry.c
+===================================================================
+--- src/cregistry/registry.c	(revision 69681)
++++ src/cregistry/registry.c	(revision 69682)
+@@ -194,7 +194,7 @@
+         }
+     }
+     if (initialized || can_write) {
+-        sqlite3_stmt* stmt;
++        sqlite3_stmt* stmt = NULL;
+         char* query = sqlite3_mprintf("ATTACH DATABASE '%q' AS registry", path);
+         if (sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
+             int r;
+@@ -220,7 +220,9 @@
+         } else {
+             reg_sqlite_error(reg->db, errPtr, query);
+         }
+-        sqlite3_finalize(stmt);
++        if (stmt) {
++            sqlite3_finalize(stmt);
++        }
+         sqlite3_free(query);
+     } else {
+         reg_throw(errPtr, REG_CANNOT_INIT, "port registry doesn't exist at "
+@@ -239,7 +241,7 @@
+  * @return             true if success; false if failure
+  */
+ int reg_detach(reg_registry* reg, reg_error* errPtr) {
+-    sqlite3_stmt* stmt;
++    sqlite3_stmt* stmt = NULL;
+     int result = 0;
+     char* query = "DETACH DATABASE registry";
+     if (!(reg->status & reg_attached)) {
+@@ -279,7 +281,9 @@
+     } else {
+         reg_sqlite_error(reg->db, errPtr, query);
+     }
+-    sqlite3_finalize(stmt);
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
+     return result;
+ }
+ 
+Index: ChangeLog
+===================================================================
+--- ChangeLog	(revision 69681)
++++ ChangeLog	(revision 69682)
+@@ -2,9 +2,40 @@
+ # This is a log of major user-visible changes in each MacPorts release.
+ # $Id$
+ ###
++Release 1.9.2 (future):
++    - Fixed sha256 checksum (snc in r68955)
+ 
+-Release 1.9.0 (unreleased):
++    - Fixed premature privilege dropping (jmr in r68952)
+ 
++
++Release 1.9.1 (2010-06-18):
++    - Fixed a couple of problems with new 1.9 features when using the flat
++      registry format (jmr in r68910, r68913)
++
++    - Ports using the replaced_by option will once again be deactivated when
++      an upgrade is performed on them (#25270, jmr in r68872)
++
++    - Fixed the possibility of some empty directories being left behind when
++      a port is deactivated (#25268, jmr in r68864)
++
++    - Fixed failure to detect conflicts with files that are not provided by
++      a port before activation starts (#25255, jmr in r68849)
++
++    - Fixed problems with distfile names containing spaces (#25245, #25246;
++      jmr in r68816, r68817)
++
++    - Fixed a problem with uninstall when using direct mode, and started
++      running pre/post activate and deactivate procedures when installing and
++      uninstalling in direct mode, respectively (#11562, jmr in r68697)
++
++    - fixed a crasher that affected Tiger (#25194, jmr in r68675, r68680,
++      r68691)
++
++Release 1.9.0 (2010-06-08 by jmr):
++
++    - It is no longer possible to use include statements in Portfiles
++      (raimue in r68206)
++
+     - Command line options can be abbreviated if unambiguous
+       (raimue in r66837)
+ 
+Index: portmgr/ReleaseProcess
+===================================================================
+--- portmgr/ReleaseProcess	(revision 69681)
++++ portmgr/ReleaseProcess	(revision 69682)
+@@ -159,8 +159,8 @@
+  mv MacPorts-1.6.0.dmg MacPorts-1.6.0-10.5-Leopard.dmg
+  for dmg in MacPorts-1.6.0-*.dmg; do for type in -md5 -sha1 -ripemd160; do openssl dgst $type $dmg; done >> MacPorts-1.6.0.chk.txt; done
+ 
+-These new products, along with the new checksums, also have to be posted to the appropriate downloads
+-directory of the MacPorts svn repository. Developers are required to validate the generated installer as
++These new products, along with the new checksums, also have to be posted to the appropriate
++directory of the MacPorts distfiles server. Developers are required to validate the generated installer as
+ thoroughly as possible through extensive testing, which is mainly why this step of the release process
+ is not automated through a Makefile target or similar. A good way of validating the installer is to first
+ create the destroot of the port and examine it for:
+Index: portmgr/packaging/dpkgall.tcl
+===================================================================
+--- portmgr/packaging/dpkgall.tcl	(revision 69681)
++++ portmgr/packaging/dpkgall.tcl	(revision 69682)
+@@ -690,7 +690,7 @@
+ 	set variations ""
+ 
+ 	foreach port [get_required_ports] {
+-		if {[catch {do_portexec $port [array get options] [array get variants] install} result]} {
++		if {[catch {do_portexec $port [array get options] [array get variants] activate} result]} {
+ 			global errorInfo
+ 			ui_debug "$errorInfo"
+ 			ui_noisy_error "Fatal error: $result"
+@@ -745,7 +745,7 @@
+ 		exit 1
+ 	}
+ 
+-	if {[catch {set result [mportexec $workername install]} result] || $result == 1} {
++	if {[catch {set result [mportexec $workername $target]} result] || $result == 1} {
+ 
+ 		# Close the port
+ 		mportclose $workername
+Index: portmgr/packaging/rpmall.tcl
+===================================================================
+--- portmgr/packaging/rpmall.tcl	(revision 69681)
++++ portmgr/packaging/rpmall.tcl	(revision 69682)
+@@ -457,7 +457,7 @@
+ 				ui_error "Internal error: unable to install ${prebuild}... exiting"
+ 				exit 1
+ 			}
+-			if {[catch {set result [mportexec $workername install]} result] ||
++			if {[catch {set result [mportexec $workername activate]} result] ||
+ 				$result == 1} {
+ 				global errorInfo
+ 				ui_debug "$errorInfo"
+Index: portmgr/dmg/InstallationCheck
+===================================================================
+--- portmgr/dmg/InstallationCheck	(revision 69681)
++++ portmgr/dmg/InstallationCheck	(revision 69682)
+@@ -12,17 +12,22 @@
+     exit 112
+ fi
+ 
++if ! [[ -x /usr/bin/xcodebuild ]]; then
++    # message 17
++    exit 113
++fi
++
+ base_version=`uname -r | sed 's/\..*//'`
+ if [[ ${base_version} != __DARWINVERS__ ]]; then
+-   # This maps to message 17 in InstallationCheck.strings (Apple allows
++   # This maps to message 18 in InstallationCheck.strings (Apple allows
+    # 16-31 for custom messages); that message should also be customized
+    # like this script
+-   exit 113
++   exit 114
+ fi
+ 
+ if [[ -f __PREFIX__/etc/ports/dp_version ]]; then
+-   # message 18 in InstallationCheck.strings
+-   exit 114
++   # message 19 in InstallationCheck.strings
++   exit 115
+ fi
+ 
+ exit 0
+Index: portmgr/dmg/postflight
+===================================================================
+--- portmgr/dmg/postflight	(revision 69681)
++++ portmgr/dmg/postflight	(revision 69682)
+@@ -55,6 +55,7 @@
+ function setup_configs {
+     for f in macports.conf sources.conf variants.conf ; do
+         if [ ! -f ${CONFIGPATH}/${f} ]; then
++            echo "Copying ${f}.default to ${f}"
+             /bin/cp ${CONFIGPATH}/${f}.default ${CONFIGPATH}/${f}
+             /bin/chmod 644 ${CONFIGPATH}/${f}
+         fi
+Index: portmgr/dmg/InstallationCheck.strings
+===================================================================
+--- portmgr/dmg/InstallationCheck.strings	(revision 69681)
++++ portmgr/dmg/InstallationCheck.strings	(revision 69682)
+@@ -1,3 +1,4 @@
+ "16" = "Either uname or sed could not be found in PATH. Your system appears to be incomplete or misconfigured.";
+-"17" = "This package is meant to be installed on Mac OS X __XVERS__.";
+-"18" = "Your existing MacPorts or DarwinPorts installation is too old to be upgraded by this installer. Please install MacPorts 1.7.1 first.";
++"17" = "Xcode is not installed, or was installed with UNIX Development (10.5+) or Command Line Support (10.4) deselected.";
++"18" = "This package is meant to be installed on Mac OS X __XVERS__.";
++"19" = "Your existing MacPorts or DarwinPorts installation is too old to be upgraded by this installer. Please install MacPorts 1.7.1 first.";
+Index: portmgr/jobs/PortIndexRegen.sh
+===================================================================
+--- portmgr/jobs/PortIndexRegen.sh	(revision 69681)
++++ portmgr/jobs/PortIndexRegen.sh	(revision 69682)
+@@ -1,121 +0,0 @@
+-#!/bin/bash
+-
+-####
+-# PortIndex regen automation script.
+-# Created by Juan Manuel Palacios,
+-# e-mail: jmpp at macports.org
+-# Updated by Paul Guyot, <pguyot at kallisys.net>
+-# Updated for svn by Daniel J. Luke <dluke at geeklair.net>
+-# $Id$
+-####
+-
+-# Configuration
+-LOCKFILE=/tmp/.mp_svn_index_regen.lock
+-# ROOT directory, where everything is. This needs to exist!
+-ROOT=/Users/mp-user/mp_svn_index_regen
+-# MP user.
+-MP_USER=mp-user
+-# MP group.
+-MP_GROUP=mp-user
+-# e-mail address to spam in case of failure.
+-#SPAM_LOVERS=example at hostname.com
+-
+-# Other settings (probably don't need to be changed).
+-SVN_CONFIG_DIR=${ROOT}/svnconfig
+-REPO_BASE=http://svn.macports.org/repository/macports
+-SVN="/opt/local/bin/svn -q --non-interactive --config-dir $SVN_CONFIG_DIR"
+-# Where to checkout the source code. This needs to exist!
+-SRCTREE=${ROOT}/source
+-# Where MP will install its world. This gets created.
+-PREFIX=${ROOT}/opt/local
+-# Where MP installs macports1.0. This gets created.
+-TCLPKG=${PREFIX}/lib/tcl
+-# Path.
+-PATH=${PREFIX}/bin:/bin:/usr/bin:/usr/sbin:/opt/local/bin:/usr/X11/bin
+-# Log for the e-mail in case of failure.
+-FAILURE_LOG=${ROOT}/failure.log
+-# Commit message.
+-COMMIT_MSG=${ROOT}/commit.msg
+-# The date.
+-DATE=$(date +'%A %Y-%m-%d at %H:%M:%S')
+-
+-
+-# Function to spam people in charge if something goes wrong during indexing.
+-bail () {
+-    mail -s "PortIndex Regen failure on ${DATE}" $SPAM_LOVERS < $FAILURE_LOG
+-    cleanup; exit 1
+-}
+-
+-# Cleanup function for runtime files.
+-cleanup () {
+-    rm -f $COMMIT_MSG $FAILURE_LOG
+-    rm -f $LOCKFILE
+-}
+-
+-
+-if [ ! -e $LOCKFILE ]; then
+-    touch $LOCKFILE
+-else
+-    echo "PortIndex Regen lockfile found, is another regen job running?" > $FAILURE_LOG; bail
+-fi
+-
+-# Checkout/update the ports tree
+-if [ -d ${SRCTREE}/dports ]; then
+-    $SVN update ${SRCTREE}/dports > $FAILURE_LOG 2>&1 \
+-	|| { echo "Updating the ports tree from $REPO_BASE/trunk/dports failed." >> $FAILURE_LOG; bail ; }
+-else
+-    $SVN checkout ${REPO_BASE}/trunk/dports ${SRCTREE}/dports > $FAILURE_LOG 2>&1 \
+-	|| { echo "Checking out the ports tree from $REPO_BASE/trunk/dports failed." >> $FAILURE_LOG ; bail ; }
+-fi
+-echo `date -u +%s` > ${ROOT}/PORTS-TIMESTAMP
+-
+-# Checkout/update HEAD
+-TMPDIR=mp_trunk/base
+-if [ -d ${ROOT}/${TMPDIR} ]; then
+-    $SVN update ${ROOT}/${TMPDIR} > $FAILURE_LOG 2>&1 \
+-	|| { echo "Updating the trunk from $REPO_BASE/trunk/base failed." >> $FAILURE_LOG; bail ; }
+-else
+-    $SVN checkout ${REPO_BASE}/trunk/base ${ROOT}/${TMPDIR} > $FAILURE_LOG 2>&1 \
+-       || { echo "Checking out the trunk from $REPO_BASE/trunk/base failed." >> $FAILURE_LOG ; bail ; }
+-fi
+-
+-echo `date -u +%s` > ${ROOT}/BASE-TIMESTAMP
+-
+-# (re)configure.
+-cd ${ROOT}/${TMPDIR} && \
+-    mkdir -p ${TCLPKG} && \
+-    ./configure \
+-    --prefix=${PREFIX} \
+-    --with-tclpackage=${TCLPKG} \
+-    --with-install-user=${MP_USER} \
+-    --with-install-group=${MP_GROUP} > $FAILURE_LOG 2>&1 \
+-    || { echo "./configure script failed." >> $FAILURE_LOG ; bail ; }
+-
+-# clean
+-# (cleaning is useful because we don't want the indexing to fail because dependencies aren't properly computed).
+-{ cd ${ROOT}/${TMPDIR} && make clean > $FAILURE_LOG 2>&1 ; } \
+-    || { echo "make clean failed." >> $FAILURE_LOG ; bail ; }
+-
+-# (re)build
+-{ cd ${ROOT}/${TMPDIR} && make > $FAILURE_LOG 2>&1 ; } \
+-    || { echo "make failed." >> $FAILURE_LOG ; bail ; }
+-
+-# (re)install
+-{ cd ${ROOT}/${TMPDIR} && make install > $FAILURE_LOG 2>&1 ; } \
+-    || { echo "make install failed." >> $FAILURE_LOG ; bail ; }
+-
+-# (re)index
+-{ cd ${SRCTREE}/dports/ && ${PREFIX}/bin/portindex > $FAILURE_LOG 2>&1 ; } \
+-    || { echo "portindex failed." >> $FAILURE_LOG ; bail ; }
+-
+-# Commit the new index using the last 5 lines of the log for the commit message,
+-tail -n 5 $FAILURE_LOG > $COMMIT_MSG
+-# plus parsing failures, if any.
+-echo "" >> $COMMIT_MSG
+-grep Failed $FAILURE_LOG >> $COMMIT_MSG
+-{ cd ${SRCTREE}/dports/ && \
+-    $SVN --config-dir $SVN_CONFIG_DIR commit -F $COMMIT_MSG PortIndex PortIndex.quick > $FAILURE_LOG 2>&1 ; } \
+-    || { echo "SVN commit failed." >> $FAILURE_LOG ; bail ; }
+-
+-# At this point the index was committed successfuly, so we cleanup before we exit.
+-cleanup && exit 0
+Index: portmgr/jobs/mprsyncup
+===================================================================
+--- portmgr/jobs/mprsyncup	(revision 69681)
++++ portmgr/jobs/mprsyncup	(revision 69682)
+@@ -1,6 +1,4 @@
+ #!/bin/sh
+-
+-
+ ####
+ # Script to checkout/update base sources from both trunk (ToT) and the current
+ # release tag (as determined by the base/config/RELEASE_URL file) and a ports
+@@ -30,24 +28,39 @@
+ # $Id$
+ ####
+ 
+-
+ set -e
++set -x
+ 
+ # Commands we need:
+ SVN="/opt/local/bin/svn -q --non-interactive"
+ CLEANUP="/opt/local/bin/svn --non-interactive cleanup"
+-RSYNC="/usr/bin/rsync -q"
++RSYNC="/opt/local/bin/rsync -q"
+ RM="/bin/rm"
+ MKDIR="/bin/mkdir"
+ LN="/bin/ln"
+ 
+ # Paths we'll work on:
++ROOT=/var/tmp/macports
++TMPDIR=mp_trunk/base
++PREFIX=${ROOT}/opt/local
++TCLPKG=${PREFIX}/lib/tcl
+ SVNROOT=/var/tmp/macports
+ TBASE=${SVNROOT}/trunk/base
+ RBASE=${SVNROOT}/release/base
+ PORTS=${SVNROOT}/release/ports
+-RSYNCROOT=/Volumes/data/rsync/macports
++RSYNCROOT=/rsync/macports
++PORTINDEX=${PREFIX}/bin/portindex
+ 
++PATH=${PREFIX}/bin:/bin:/usr/bin:/usr/sbin:/opt/local/bin
++
++# platforms we generate indexes for
++PLATFORMS="8_ppc 8_i386 9_ppc 9_i386 10_i386"
++# copy new index of this platform to old index location for MP v1.8 compatability
++OLD_INDEX_PLATFORM="9_i386"
++
++MP_USER=nobody
++MP_GROUP=nobody
++
+ # Sources information:
+ SVNURL=http://svn.macports.org/repository/macports
+ RELEASE_URL_FILE=config/RELEASE_URL
+@@ -64,18 +77,11 @@
+     ${SVN} checkout ${SVNURL}/trunk/base ${TBASE}
+ fi
+ 
+-# Delete old exports if they exist
+-if [ -d ${TBASE}-export ]; then
+-    $RM -rf ${TBASE}-export;
+-fi
+-${SVN} export ${TBASE} ${TBASE}-export
+-
+ if [ ! -d ${RSYNCROOT}/trunk/base ]; then
+     ${MKDIR} -p ${RSYNCROOT}/trunk
+ fi
+-${RSYNC} -a -I --delete ${TBASE}-export/ ${RSYNCROOT}/trunk/base && ${RM} -rf ${TBASE}-export
++${RSYNC} -aIC --delete ${TBASE}/ ${RSYNCROOT}/trunk/base
+ 
+-
+ # Read what tag we're releasing from, switch to/checkout a copy, export and rsync it to ${RSYNCROOT}/release/base:
+ read RELEASE_URL < ${TBASE}/${RELEASE_URL_FILE}
+ if [ ! -n ${RELEASE_URL} ]; then
+@@ -88,16 +94,10 @@
+     ${SVN} checkout ${RELEASE_URL} ${RBASE}
+ fi
+ 
+-# Delete old exports if they exist
+-if [ -d ${RBASE}-export ]; then
+-    $RM -rf ${RBASE}-export;
+-fi
+-${SVN} export ${RBASE} ${RBASE}-export
+-
+ if [ ! -d ${RSYNCROOT}/release/base ]; then
+     ${MKDIR} -p ${RSYNCROOT}/release/base
+ fi
+-${RSYNC} -a -I --delete ${RBASE}-export/ ${RSYNCROOT}/release/base && ${RM} -rf ${RBASE}-export
++${RSYNC} -aIC --delete ${RBASE}/ ${RSYNCROOT}/release/base 
+ 
+ # clean up the working copy if it is locked
+ if [ -f ${PORTS}/.svn/lock ]; then
+@@ -111,26 +111,36 @@
+     ${SVN} checkout ${SVNURL}/trunk/dports ${PORTS}
+ fi
+ 
+-# Delete old exports if they exist
+-if [ -d ${PORTS}-export ]; then
+-    $RM -rf ${PORTS}-export;
+-fi
+-${SVN} export ${PORTS} ${PORTS}-export
++# generate platform-specific indexes
++pushd ${PORTS} >> /dev/null
++# build MP trunk in a private location for indexing
++pushd ${ROOT}/${TMPDIR} >> /dev/null
++mkdir -p ${TCLPKG} 
++./configure \
++    --prefix=${PREFIX} \
++    --with-tclpackage=${TCLPKG} \
++    --with-install-user=${MP_USER} \
++    --with-install-group=${MP_GROUP} 
++make clean 
++make
++make install 
++popd
+ 
++for PLATFORM in $PLATFORMS; do
++	$PORTINDEX -p darwin_${PLATFORM} -o PortIndex_darwin_${PLATFORM};
++done
++
++# support MP 1.8
++cp PortIndex_darwin_${OLD_INDEX_PLATFORM}/* ./
++popd
++
+ if [ ! -d ${RSYNCROOT}/release/ports ]; then
+     ${MKDIR} -p ${RSYNCROOT}/release/ports
+ fi
+-${RSYNC} -a -I --delete ${PORTS}-export/ ${RSYNCROOT}/release/ports && ${RM} -rf ${PORTS}-export
++${RSYNC} -aIC --delete ${PORTS}/ ${RSYNCROOT}/release/ports
+ 
+-
+-# Compatibility checks:
++# symlink trunk ports to release ports since we only have 1 set of ports
+ cd ${RSYNCROOT}
+-if [ ! -h dpupdate ]; then
+-    ${RM} -rf dpupdate && ${LN} -s trunk dpupdate
+-fi
+-if [ ! -h dpupdate1 ]; then
+-    ${RM} -rf dpupdate1 && ${LN} -s release dpupdate1
+-fi
+ if [ ! -h trunk/dports ]; then
+     cd trunk
+     ${RM} -rf dports && ${LN} -s ../release/ports dports
+Index: portmgr/jobs/README
+===================================================================
+--- portmgr/jobs/README	(revision 69681)
++++ portmgr/jobs/README	(revision 69682)
+@@ -4,13 +4,9 @@
+ 
+  1) mprsyncup:
+     Runs on Mac OS Forge servers every 30 minutes, on the hour and on the half hour, off launchd through the org.macports.mprsyncup.plist provided.
+-    Repopulates the rsync modules that feed the "sync" and "selfupdate" operations for both the ports tree and MacPorts sources, freshly off the svn
+-    sources.
++    Repopulates the rsync modules that feed the "sync" and "selfupdate" operations for both the ports tree and MacPorts sources, freshly off the svn sources.
++    Updates the port indexes stored on the rsync server.
+ 
+- 2) PortIndexRegen:
+-    Still running on Daniel's box, twice a day every 12 hours off cron. Scheduled for a rewrite in Tcl to employ the macports1.0 API and thus simplify
+-    some of its tasks. Once that's done it'll be moved to Mac OS Forge servers. This job regenerates the ports' index employed by operations like "port search".
+-
+  3) PortIndex2MySQL:
+     Running Mac OS Forge servers twice a day every 12 hours off launchd through the org.macports.PortIndex2MySQL.plist provided, 15 minutes after the
+     PortIndexRegen job. This jobs repopulates the database that feeds the www.macports.org/ports.php page off the regenerated PortIndex.
+@@ -22,3 +18,4 @@
+  5) Website:
+     There's actually no script for this one, as the job itself is really simple: a post-commit svn hook attached to the /trunk/www dir
+     updates the copy of our website on the Mac OS Forge web server whenever a commit to that directory occurs.
++
+Index: configure.ac
+===================================================================
+--- configure.ac	(revision 69681)
++++ configure.ac	(revision 69682)
+@@ -103,6 +103,7 @@
+ AC_PATH_PROG(PATCH, [patch], [])
+ AC_PATH_PROG(RMDIR, [rmdir], [])
+ AC_PATH_PROG(RSYNC, [rsync], [])
++AC_PATH_PROG(OPENSSL, [openssl], [])
+ AC_PATH_PROG(SED, [sed])
+ AC_PATH_PROG(TAR, [tar])
+ AC_PATH_PROG(UNZIP, [unzip])
+@@ -127,6 +128,7 @@
+ AC_ARG_VAR(MTREE, [path to mtree command])
+ AC_ARG_VAR(CVS, [path to cvs command])
+ AC_ARG_VAR(SVN, [path to svn command])
++AC_ARG_VAR(OPENSSL, [path to openssl command])
+ AC_ARG_VAR(RSYNC, [path to rsync command])
+ AC_ARG_VAR(SED, [path to sed command])
+ AC_ARG_VAR(TAR, [path to tar command])
+@@ -346,6 +348,7 @@
+ 	doc/prefix.mtree
+ 	doc/macosx.mtree
+ 	doc/macports.conf
++	doc/pubkeys.conf
+ 	portmgr/freebsd/Makefile
+ 	src/Makefile
+ 	src/macports1.0/macports_autoconf.tcl
+Index: doc/macports.conf.5
+===================================================================
+--- doc/macports.conf.5	(revision 69681)
++++ doc/macports.conf.5	(revision 69682)
+@@ -62,10 +62,11 @@
+ .Ic Default:
+ ${prefix}/var/macports
+ .It Va portdbformat
+-Storage type to use for the MacPorts registry. Currently the only supported format is "flat".
++Storage type to use for the MacPorts registry. The preferred format is "sqlite", with "flat"
++also available as a legacy format.
+ .br
+ .Ic Default:
+-flat
++sqlite
+ .It Va portinstalltype
+ Sets the mode in which ports are installed by MacPorts. Supported values are 'direct' or 'image'.
+ The 'direct' mode is often used on systems that do not support 'image' due to limitations in their
+Index: doc/pubkeys.conf.in
+===================================================================
+--- doc/pubkeys.conf.in	(revision 0)
++++ doc/pubkeys.conf.in	(revision 69682)
+@@ -0,0 +1,10 @@
++# Downloaded archives will only be used if they can be verified by a public
++# key listed here. Use full paths, one per line.
++
++ at prefix_expanded@/share/macports/macports-pubkey.pem
++
++# To distribute archives of your own, you need a key pair generated like so:
++# openssl genrsa -des3 -out privkey.pem 2048
++# openssl rsa -in privkey.pem -pubout -out pubkey.pem
++# Then sign the archives like this:
++# openssl dgst -ripemd160 -sign privkey.pem -out archive.tbz2.rmd160 archive.tbz2
+Index: doc/Makefile
+===================================================================
+--- doc/Makefile	(revision 69681)
++++ doc/Makefile	(revision 69682)
+@@ -1,6 +1,7 @@
+ MAN1=		port.1
+ MAN5=		macports.conf.5
+ MAN7=		portfile.7 portstyle.7 porthier.7 portgroup.7
++CONF=       macports.conf pubkeys.conf sources.conf variants.conf
+ INSTALLDIR=	${DESTDIR}${prefix}
+ TOPSRCDIR=	..
+ 
+@@ -16,7 +17,7 @@
+ test:
+ 
+ distclean: clean
+-	rm -f prefix.mtree macports.conf macosx.mtree
++	rm -f macports.conf macosx.mtree prefix.mtree pubkeys.conf
+ 
+ %.1.gz: %.1
+ 	gzip -c $^ > $@
+@@ -40,21 +41,13 @@
+ 		$(LN_S) share/man ${INSTALLDIR}/man; \
+ 	fi
+ 
+-	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 macports.conf ${DESTDIR}${mpconfigdir}/macports.conf.default
+-	if test ! -e ${DESTDIR}${mpconfigdir}/macports.conf ; then \
+-		set -x; \
+-		$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 644 macports.conf ${DESTDIR}${mpconfigdir}; \
+-	fi
+-	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 sources.conf ${DESTDIR}${mpconfigdir}/sources.conf.default
+-	if test ! -e ${DESTDIR}${mpconfigdir}/sources.conf ; then \
+-		set -x; \
+-		$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 644 sources.conf ${DESTDIR}${mpconfigdir}; \
+-	fi
+-	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 variants.conf ${DESTDIR}${mpconfigdir}/variants.conf.default
+-	if test ! -e ${DESTDIR}${mpconfigdir}/variants.conf ; then \
+-		set -x; \
+-		$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 644 variants.conf ${DESTDIR}${mpconfigdir}; \
+-	fi
++	for f in ${CONF}; do \
++		$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 $$f ${DESTDIR}${mpconfigdir}/$${f}.default; \
++		if test ! -e ${DESTDIR}${mpconfigdir}/$$f ; then \
++			set -x; \
++			$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 644 $$f ${DESTDIR}${mpconfigdir}; \
++		fi; \
++	done
+ 
+ 	# delete old uncompressed man pages if they exist
+ 	for m in ${MAN1}; do rm -f ${INSTALLDIR}/share/man/man1/$$m ; done
+
+Property changes on: doc
+___________________________________________________________________
+Modified: svn:ignore
+   - macports.conf
+prefix.mtree
+macosx.mtree
+*[0-9].gz
+
+   + macports.conf
+pubkeys.conf
+prefix.mtree
+macosx.mtree
+*[0-9].gz
+
+
+Index: config/RELEASE_URL
+===================================================================
+--- config/RELEASE_URL	(revision 69681)
++++ config/RELEASE_URL	(revision 69682)
+@@ -1 +1 @@
+-http://svn.macports.org/repository/macports/tags/release_1_8_2/base
++http://svn.macports.org/repository/macports/tags/release_1_9_1/base
+Index: macports-pubkey.pem
+===================================================================
+--- macports-pubkey.pem	(revision 0)
++++ macports-pubkey.pem	(revision 69682)
+@@ -0,0 +1,9 @@
++-----BEGIN PUBLIC KEY-----
++MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxPlw2FSMEavmtuHq5O+f
++XPUXndBnUyoX8iJvQ7NlsNY+hleE307kOAly79WFq2aAGIyKB/Ob8V+qCLW4FGOO
++4NfvOnte1WxQP8oVxOM9ai3CeN6AnUxDWUTYVJ1R+a5ZQVnJyGBKkV+jLlj0PD/z
++d8PCJ/j7Wzizw3d4s9uBIR1zpLY8lVgTivsj5FM3RP6hS7ww7I47goQshoL+YFVg
++NhE9I63oZXqFF130l9jJI9axHUqza7a42WCv04J8iv8SQhgv6fY9ZQnIBMQ4hPDH
++klGusdf4HlCbUViKhxmUpfj6FJabh2jV48ymaoTZB767GJyACF4mvnNDkenEXf41
++/wIDAQAB
++-----END PUBLIC KEY-----
+Index: NEWS
+===================================================================
+--- NEWS	(revision 69681)
++++ NEWS	(revision 69682)
+@@ -5,7 +5,7 @@
+ *) All output is now logged to a file, whose location will be shown if a port
+    target fails. This should be attached to bug reports. The new 'log' action
+    can also be used to view the log for a port.
+-*) Command line options can be abbreviated if unambigious.
++*) Command line options can be abbreviated if unambiguous.
+ *) New actions: rdeps, rdependents, setrequested, unsetrequested
+ *) --follow-dependencies option for uninstall (ports with the requested flag
+    set or with other dependents are skipped).
+
+Property changes on: .
+___________________________________________________________________
+Modified: svn:mergeinfo
+   Merged /trunk/base:r68019-69681
+

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69731.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69731.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69731.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,20 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 69730)
++++ src/registry2.0/portimage.tcl	(revision 69731)
+@@ -745,5 +745,15 @@
+     }
+ }
+ 
++proc gsocdebug {command-string op} {puts "GSOCBDBG: ${command-string}" }
++#the following 2 traces breaks macports at activate/deactivate phase, let's keep them commented
++#trace add execution ::portimage::activate enter gsocdebug
++#trace add execution ::portimage::deactivate enter gsocdebug
++trace add execution ::portimage::_check_registry enter gsocdebug
++trace add execution ::portimage::_check_contents enter gsocdebug
++trace add execution ::portimage::_activate_file enter gsocdebug
++trace add execution ::portimage::_activate_contents enter gsocdebug
++trace add execution ::portimage::_deactivate_file enter gsocdebug
++trace add execution ::portimage::_deactivate_contents enter gsocdebug
+ # End of portimage namespace
+ }

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69756.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69756.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r69756.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,131 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 69755)
++++ src/registry2.0/portimage.tcl	(revision 69756)
+@@ -91,6 +91,7 @@
+     }
+     set todeactivate [list]
+ 
++    # before activating new image we handle deactivation of old version
+     if {$use_reg2} {
+         registry::read {
+ 
+@@ -161,12 +162,14 @@
+         }
+     }
+ 
++    #eventually print variants
+     if {$v != ""} {
+         ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $v]"
+     } else {
+         ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s"] $name]"
+     }
+ 
++    #activate new image
+     if {$use_reg2} {
+         _activate_contents $requested
+         $requested state installed
+@@ -213,6 +216,7 @@
+         }
+     }
+ 
++    #branch on sqlite-registry-db or old–flatfile
+     if {$use_reg2} {
+         if { [string equal $name ""] } {
+             throw registry::image-error "Registry error: Please specify the name of the port."
+@@ -254,6 +258,7 @@
+         ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s"] $name]"
+     }
+ 
++    #here we go - 
+     if {$use_reg2} {
+         if { ![string equal [$requested installtype] "image"] } {
+             return -code error "Image error: ${name} @${specifier} not installed as an image."
+@@ -453,14 +458,12 @@
+                     }
+ 
+                     set owner [registry::entry owner $file]
+-                    ui_msg "GSOC: $file owner is \"$owner\""
+ 
+                     if {$owner != {} && $owner != $port} {
+                         # deactivate conflicting port if it is replaced_by this one
+                         set result [mportlookup [$owner name]]
+                         array unset portinfo
+                         array set portinfo [lindex $result 1]
+-                        #GSoC10
+                         #here we'll check if you should replace a config file testing a --drop-config option from CLI
+                         if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^[$port name]\$"] != -1} {
+                             # we'll deactivate the owner later, but before activating our files
+@@ -529,7 +532,6 @@
+             # debug output of activate make more sense.
+             set files [lsort -increasing -unique $files]
+             set rollback_filelist {}
+-            ui_msg "GSOC DBG: let's activate actual files"
+             registry::write {
+                 # Activate it, and catch errors so we can roll-back
+                 try {
+@@ -547,7 +549,6 @@
+                 }
+             }
+         } catch {*} {
+-            ui_msg "GSOC DBG: rollback"
+             # roll back activation of this port
+             if {[info exists deactivate_this]} {
+                 _deactivate_contents $port $rollback_filelist yes yes
+@@ -674,7 +675,6 @@
+             return -code error $result
+         }
+     }
+-    ui_msg "GSOC DBG: end of _activate_contents"
+ }
+ 
+ proc _deactivate_file {dstfile} {
+@@ -700,6 +700,7 @@
+     set files [list]
+ 
+     foreach file $imagefiles {
++        #GSOC10 we should avoid adding file to $files and instead handle them putting into a separate registry table  
+         if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } {
+             # Normalize the file path to avoid removing the intermediate
+             # symlinks (remove the empty directories instead)
+@@ -735,6 +736,10 @@
+         registry::write {
+             $port deactivate $imagefiles
+             foreach file $files {
++                  if {[is_config_file $file]} {
++                          puts "GSOC: $file is config file, skipping for now"
++                          continue
++                      }                  
+                 _deactivate_file $file
+             }
+         }
+@@ -745,15 +750,19 @@
+     }
+ }
+ 
+-proc gsocdebug {command-string op} {puts "GSOCBDBG: ${command-string}" }
+-#the following 2 traces breaks macports at activate/deactivate phase, let's keep them commented
+-#trace add execution ::portimage::activate enter gsocdebug
+-#trace add execution ::portimage::deactivate enter gsocdebug
+-trace add execution ::portimage::_check_registry enter gsocdebug
+-trace add execution ::portimage::_check_contents enter gsocdebug
+-trace add execution ::portimage::_activate_file enter gsocdebug
+-trace add execution ::portimage::_activate_contents enter gsocdebug
+-trace add execution ::portimage::_deactivate_file enter gsocdebug
+-trace add execution ::portimage::_deactivate_contents enter gsocdebug
++#proc gsocdebug {command-string op} {puts "GSOCDBG: ${command-string}" }
++#trace add execution ::portimage::_check_registry enter gsocdebug
++#trace add execution ::portimage::_check_contents enter gsocdebug
++#trace add execution ::portimage::_activate_file enter gsocdebug
++#trace add execution ::portimage::_activate_contents enter gsocdebug
++#trace add execution ::portimage::_deactivate_file enter gsocdebug
++#trace add execution ::portimage::_deactivate_contents enter gsocdebug
++
++
++proc is_config_file {filename} {
++    #replace hardcoded path with $config_path from portmain.tcl, what namespace does "option" add options to?
++    if {[string match ${::macports::prefix} "$filename"]} {return 1} {return 0}
++}
++
+ # End of portimage namespace
+ }

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70378.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70378.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70378.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,91 @@
+Index: src/cregistry/sql.c
+===================================================================
+--- src/cregistry/sql.c	(revision 70377)
++++ src/cregistry/sql.c	(revision 70378)
+@@ -130,7 +130,7 @@
+ 
+         /* file map */
+         "CREATE TABLE registry.files (id INTEGER, path TEXT, actual_path TEXT, "
+-            "active INT, mtime DATETIME, md5sum TEXT, editable INT, "
++            "active INT, mtime DATETIME, md5sum TEXT, editable INT, is_config INT, modified INT, "
+             "FOREIGN KEY(id) REFERENCES ports(id))",
+         "CREATE INDEX registry.file_port ON files (id)",
+         "CREATE INDEX registry.file_path ON files(path)",
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70377)
++++ src/cregistry/entry.c	(revision 70378)
+@@ -860,6 +860,60 @@
+ }
+ 
+ /**
++ * gsoc10-configfiles
++ * Maps files to the given port in the filemap. The list of files must not
++ * contain files that are already mapped to the given port.
++ *
++ * @param [in] entry      the entry to map the files to
++ * @param [in] tupels      a list of tupels to map in form {file checksum}
++ * @param [in] tupel_count the number of tupels
++ * @param [out] errPtr    on error, a description of the error that occurred
++ * @return                true if success; false if failure
++ */
++int reg_entry_map_with_md5(reg_entry* entry, char** tupels, int tupel_count,
++        reg_error* errPtr) {
++    reg_registry* reg = entry->reg;
++    int result = 1;
++    sqlite3_stmt* stmt = NULL;
++    char* insert = "INSERT INTO registry.files (id, path, mtime, active, md5sum) "
++        "VALUES (?, ?, 0, 0, ?)";
++    if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
++            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
++        int i;
++        for (i=0; i<tupel_count && result; i++) {
++            if (sqlite3_bind_text(stmt, 2, tupels[i], -1, SQLITE_STATIC)
++                    == SQLITE_OK) {
++                int r;
++                do {
++                    r = sqlite3_step(stmt);
++                    switch (r) {
++                        case SQLITE_DONE:
++                            sqlite3_reset(stmt);
++                            break;
++                        case SQLITE_BUSY:
++                            break;
++                        default:
++                            reg_sqlite_error(reg->db, errPtr, insert);
++                            result = 0;
++                            break;
++                    }
++                } while (r == SQLITE_BUSY);
++            } else {
++                reg_sqlite_error(reg->db, errPtr, insert);
++                result = 0;
++            }
++        }
++    } else {
++        reg_sqlite_error(reg->db, errPtr, insert);
++        result = 0;
++    }
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
++    return result;
++}
++
++/**
+  * Unaps files from the given port in the filemap. The files must be owned by
+  * the given entry.
+  *
+Index: src/cregistry/entry.h
+===================================================================
+--- src/cregistry/entry.h	(revision 70377)
++++ src/cregistry/entry.h	(revision 70378)
+@@ -75,6 +75,8 @@
+ int reg_entry_propset(reg_entry* entry, char* key, char* value,
+         reg_error* errPtr);
+ 
++int reg_entry_map_with_md5(reg_entry* entry, char** tupels, int tupel_count,
++        reg_error* errPtr);
+ int reg_entry_map(reg_entry* entry, char** files, int file_count,
+         reg_error* errPtr);
+ int reg_entry_unmap(reg_entry* entry, char** files, int file_count,

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70386.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70386.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70386.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,91 @@
+Index: src/cregistry/sql.c
+===================================================================
+--- src/cregistry/sql.c	(revision 70385)
++++ src/cregistry/sql.c	(revision 70386)
+@@ -130,7 +130,7 @@
+ 
+         /* file map */
+         "CREATE TABLE registry.files (id INTEGER, path TEXT, actual_path TEXT, "
+-            "active INT, mtime DATETIME, md5sum TEXT, editable INT, is_config INT, modified INT, "
++            "active INT, mtime DATETIME, md5sum TEXT, editable INT, "
+             "FOREIGN KEY(id) REFERENCES ports(id))",
+         "CREATE INDEX registry.file_port ON files (id)",
+         "CREATE INDEX registry.file_path ON files(path)",
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70385)
++++ src/cregistry/entry.c	(revision 70386)
+@@ -860,60 +860,6 @@
+ }
+ 
+ /**
+- * gsoc10-configfiles
+- * Maps files to the given port in the filemap. The list of files must not
+- * contain files that are already mapped to the given port.
+- *
+- * @param [in] entry      the entry to map the files to
+- * @param [in] tupels      a list of tupels to map in form {file checksum}
+- * @param [in] tupel_count the number of tupels
+- * @param [out] errPtr    on error, a description of the error that occurred
+- * @return                true if success; false if failure
+- */
+-int reg_entry_map_with_md5(reg_entry* entry, char** tupels, int tupel_count,
+-        reg_error* errPtr) {
+-    reg_registry* reg = entry->reg;
+-    int result = 1;
+-    sqlite3_stmt* stmt = NULL;
+-    char* insert = "INSERT INTO registry.files (id, path, mtime, active, md5sum) "
+-        "VALUES (?, ?, 0, 0, ?)";
+-    if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
+-            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
+-        int i;
+-        for (i=0; i<tupel_count && result; i++) {
+-            if (sqlite3_bind_text(stmt, 2, tupels[i], -1, SQLITE_STATIC)
+-                    == SQLITE_OK) {
+-                int r;
+-                do {
+-                    r = sqlite3_step(stmt);
+-                    switch (r) {
+-                        case SQLITE_DONE:
+-                            sqlite3_reset(stmt);
+-                            break;
+-                        case SQLITE_BUSY:
+-                            break;
+-                        default:
+-                            reg_sqlite_error(reg->db, errPtr, insert);
+-                            result = 0;
+-                            break;
+-                    }
+-                } while (r == SQLITE_BUSY);
+-            } else {
+-                reg_sqlite_error(reg->db, errPtr, insert);
+-                result = 0;
+-            }
+-        }
+-    } else {
+-        reg_sqlite_error(reg->db, errPtr, insert);
+-        result = 0;
+-    }
+-    if (stmt) {
+-        sqlite3_finalize(stmt);
+-    }
+-    return result;
+-}
+-
+-/**
+  * Unaps files from the given port in the filemap. The files must be owned by
+  * the given entry.
+  *
+Index: src/cregistry/entry.h
+===================================================================
+--- src/cregistry/entry.h	(revision 70385)
++++ src/cregistry/entry.h	(revision 70386)
+@@ -75,8 +75,6 @@
+ int reg_entry_propset(reg_entry* entry, char* key, char* value,
+         reg_error* errPtr);
+ 
+-int reg_entry_map_with_md5(reg_entry* entry, char** tupels, int tupel_count,
+-        reg_error* errPtr);
+ int reg_entry_map(reg_entry* entry, char** files, int file_count,
+         reg_error* errPtr);
+ int reg_entry_unmap(reg_entry* entry, char** files, int file_count,

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70398.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70398.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70398.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,41 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70397)
++++ src/registry2.0/portimage.tcl	(revision 70398)
+@@ -699,8 +699,7 @@
+     variable use_reg2
+     set files [list]
+ 
+-    foreach file $imagefiles {
+-        #GSOC10 we should avoid adding file to $files and instead handle them putting into a separate registry table  
++    foreach file $imagefiles {  
+         if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } {
+             # Normalize the file path to avoid removing the intermediate
+             # symlinks (remove the empty directories instead)
+@@ -737,8 +736,8 @@
+             $port deactivate $imagefiles
+             foreach file $files {
+                   if {[is_config_file $file]} {
+-                          puts "GSOC: $file is config file, skipping for now"
+-                          continue
++                          #puts "GSOC: $file is config file, skipping for now"
++                          #continue
+                       }                  
+                 _deactivate_file $file
+             }
+@@ -750,15 +749,6 @@
+     }
+ }
+ 
+-#proc gsocdebug {command-string op} {puts "GSOCDBG: ${command-string}" }
+-#trace add execution ::portimage::_check_registry enter gsocdebug
+-#trace add execution ::portimage::_check_contents enter gsocdebug
+-#trace add execution ::portimage::_activate_file enter gsocdebug
+-#trace add execution ::portimage::_activate_contents enter gsocdebug
+-#trace add execution ::portimage::_deactivate_file enter gsocdebug
+-#trace add execution ::portimage::_deactivate_contents enter gsocdebug
+-
+-
+ proc is_config_file {filename} {
+     #replace hardcoded path with $config_path from portmain.tcl, what namespace does "option" add options to?
+     if {[string match ${::macports::prefix} "$filename"]} {return 1} {return 0}

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70399.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70399.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70399.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,159 @@
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70398)
++++ src/registry2.0/entryobj.c	(revision 70399)
+@@ -155,6 +155,67 @@
+     }
+ }
+ 
++static int entry_obj_filemap_with_md5(Tcl_Interp* interp, reg_entry* entry, int objc,
++        Tcl_Obj* CONST objv[]) {
++    reg_registry* reg = registry_for(interp, reg_attached);
++    if (objc != 3) {
++        Tcl_WrongNumArgs(interp, 2, objv, "map {file md5checksum}-list");
++        return TCL_ERROR;
++    } else if (reg == NULL) {
++        return TCL_ERROR;
++    } else {
++        char** files;
++        char** md5sums;
++        reg_error error;
++        Tcl_Obj *element; 
++        Tcl_Obj** listv;
++        int listc;
++        int result = TCL_ERROR;
++        int i;
++
++        if (Tcl_ListObjGetElements(interp, objv[2], &listc, &listv) != TCL_OK) {
++            return TCL_ERROR;
++        }
++        files=malloc(listc*sizeof(char *));
++        md5sums=malloc(listc*sizeof(char*));
++        /*  remember to add check for malloc return values */
++        for (i = 0; i < listc; i++) { 
++            if (Tcl_ListObjIndex(interp, listv[i], 0, &element) != TCL_OK) {
++                free(files); free(md5sums); return TCL_ERROR; } 
++            else if(element != NULL)
++                files[i] = Tcl_GetString(element);
++            else {
++                Tcl_SetErrorCode(interp, "illegal input", NULL); return TCL_ERROR; }
++
++            if (Tcl_ListObjIndex(interp, listv[i], 1, &element) != TCL_OK) {
++                free(files); free(md5sums); return TCL_ERROR; } 
++            else if(element != NULL)
++                md5sums[i] = Tcl_GetString(element); 
++            else {
++                Tcl_SetErrorCode(interp, "illegal input", NULL); return TCL_ERROR; }
++        }
++        
++        /*  change the condition, */
++        /*  it used to be list_obj_to_string() but now we're filling arrays by hand  */
++        if ( 1 ) {
++            if (reg_entry_map_with_md5(entry, files, md5sums, listc, &error)) {
++                result = TCL_OK;
++            } else {
++                result = registry_failed(interp, &error);
++            }
++            free(files);
++            free(md5sums);
++        }
++        /*  the else branch is useless because if condition is a constant
++            cf. previous comment 
++        else {
++            result = registry_failed(interp, &error);
++        }
++        */
++        return result;
++    }
++}
++
+ static int entry_obj_files(Tcl_Interp* interp, reg_entry* entry, int objc,
+         Tcl_Obj* CONST objv[]) {
+     reg_registry* reg = registry_for(interp, reg_attached);
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70398)
++++ src/cregistry/entry.c	(revision 70399)
+@@ -860,6 +860,69 @@
+ }
+ 
+ /**
++ * Maps files to the given port in the filemap along with their md5 checksums.
++ * The list of files must not contain files that are already mapped to the
++ * given port.
++ *
++ * @param [in] entry      the entry to map the files to
++ * @param [in] files      a list of files to map
++ * @param [in] md5sums      a list of files to map
++ * @param [in] arg_count the number of files
++ * @param [out] errPtr    on error, a description of the error that occurred
++ * @return                true if success; false if failure
++ */
++int reg_entry_map_with_md5(reg_entry* entry, char** files, char** md5sums, int arg_count,
++        reg_error* errPtr) {
++    reg_registry* reg = entry->reg;
++    int result = 1;
++    sqlite3_stmt* stmt = NULL;
++    char* insert = "INSERT INTO registry.files (id, path, mtime, active, md5sum) "
++        "VALUES (?, ?, 0, 0, ?)";
++    /*  sqlite3_prepare() is documented as legacy, http://www.sqlite.org/c3ref/step.html
++        use sqlite3_prepare_v2() should be used instead */
++    if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
++            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
++        int i;
++        for (i=0; i<arg_count && result; i++) {
++            /*  cycles through files[] array of strings,
++                the if argument parse a file from the array and put in into
++                the SQL statement */
++            if (sqlite3_bind_text(stmt, 2, files[i], -1, SQLITE_STATIC)
++                    == SQLITE_OK) {
++                if (sqlite3_bind_text(stmt, 3, md5sums[i], -1, SQLITE_STATIC)
++                        == SQLITE_OK) {
++                    int r;
++                    do {
++                        r = sqlite3_step(stmt);
++                        switch (r) {
++                            case SQLITE_DONE:
++                                sqlite3_reset(stmt);
++                                break;
++                            case SQLITE_BUSY:
++                                break;
++                            default:
++                                reg_sqlite_error(reg->db, errPtr, insert);
++                                result = 0;
++                                break;
++                        }
++                    } while (r == SQLITE_BUSY);
++                }
++            } else {
++                reg_sqlite_error(reg->db, errPtr, insert);
++                result = 0;
++            }
++        }
++    } else {
++        reg_sqlite_error(reg->db, errPtr, insert);
++        result = 0;
++    }
++    if (stmt) {
++        sqlite3_finalize(stmt);
++    }
++    return result;
++}
++        
++/**
+  * Unaps files from the given port in the filemap. The files must be owned by
+  * the given entry.
+  *
+Index: src/cregistry/entry.h
+===================================================================
+--- src/cregistry/entry.h	(revision 70398)
++++ src/cregistry/entry.h	(revision 70399)
+@@ -77,6 +77,8 @@
+ 
+ int reg_entry_map(reg_entry* entry, char** files, int file_count,
+         reg_error* errPtr);
++int reg_entry_map_with_md5(reg_entry* entry, char** files, char** md5sums, int arg_count,
++        reg_error* errPtr);
+ int reg_entry_unmap(reg_entry* entry, char** files, int file_count,
+         reg_error* errPtr);
+ 

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70400.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70400.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70400.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,13 @@
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70399)
++++ src/cregistry/entry.c	(revision 70400)
+@@ -923,7 +923,7 @@
+ }
+         
+ /**
+- * Unaps files from the given port in the filemap. The files must be owned by
++ * Unmaps files from the given port in the filemap. The files must be owned by
+  * the given entry.
+  *
+  * @param [in] entry      the entry to unmap the files from

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70404.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70404.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70404.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,12 @@
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70403)
++++ src/registry2.0/entryobj.c	(revision 70404)
+@@ -443,6 +443,7 @@
+     { "requested", entry_obj_prop },
+     /* filemap */
+     { "map", entry_obj_filemap },
++    { "map_with_md5", entry_obj_filemap_with_md5 },
+     { "unmap", entry_obj_filemap },
+     { "files", entry_obj_files },
+     { "imagefiles", entry_obj_imagefiles },

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70412.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70412.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70412.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,53 @@
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70411)
++++ src/registry2.0/entryobj.c	(revision 70412)
+@@ -38,6 +38,7 @@
+ #include "entryobj.h"
+ #include "registry.h"
+ #include "util.h"
++#include <stdio.h>
+ 
+ const char* entry_props[] = {
+     "name",
+@@ -158,6 +159,7 @@
+ static int entry_obj_filemap_with_md5(Tcl_Interp* interp, reg_entry* entry, int objc,
+         Tcl_Obj* CONST objv[]) {
+     reg_registry* reg = registry_for(interp, reg_attached);
++    printf("GSOCDBG: we're into entry_obj_filemap_with_md5\n");
+     if (objc != 3) {
+         Tcl_WrongNumArgs(interp, 2, objv, "map {file md5checksum}-list");
+         return TCL_ERROR;
+Index: src/port1.0/portinstall.tcl
+===================================================================
+--- src/port1.0/portinstall.tcl	(revision 70411)
++++ src/port1.0/portinstall.tcl	(revision 70412)
+@@ -198,7 +198,7 @@
+             
+             if {[info exists installPlist]} {
+                 # register files
+-                $regref map $installPlist
++                $regref map_with_md5 $installPlist
+             }
+             
+             # store portfile
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70411)
++++ src/cregistry/entry.c	(revision 70412)
+@@ -37,6 +37,7 @@
+ #include <string.h>
+ #include <stdlib.h>
+ #include <sqlite3.h>
++#include <stdio.h>
+ 
+ /*
+  * TODO: possibly, allow reg_entry_search to take different matching strategies
+@@ -878,6 +879,7 @@
+     sqlite3_stmt* stmt = NULL;
+     char* insert = "INSERT INTO registry.files (id, path, mtime, active, md5sum) "
+         "VALUES (?, ?, 0, 0, ?)";
++    printf("GSOCDBG: we're into reg_entry_map_with_md5\n");
+     /*  sqlite3_prepare() is documented as legacy, http://www.sqlite.org/c3ref/step.html
+         use sqlite3_prepare_v2() should be used instead */
+     if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70418.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70418.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70418.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,19 @@
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70417)
++++ src/cregistry/entry.c	(revision 70418)
+@@ -879,13 +879,12 @@
+     sqlite3_stmt* stmt = NULL;
+     char* insert = "INSERT INTO registry.files (id, path, mtime, active, md5sum) "
+         "VALUES (?, ?, 0, 0, ?)";
+-    printf("GSOCDBG: we're into reg_entry_map_with_md5\n");
+     /*  sqlite3_prepare() is documented as legacy, http://www.sqlite.org/c3ref/step.html
+         use sqlite3_prepare_v2() should be used instead */
+     if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
+             && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
+         int i;
+-        for (i=0; i<arg_count && result; i++) {
++        for (i=0; i<(arg_count/2) && result; i++) {
+             /*  cycles through files[] array of strings,
+                 the if argument parse a file from the array and put in into
+                 the SQL statement */

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70423.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70423.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70423.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,169 @@
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70422)
++++ src/registry2.0/entryobj.c	(revision 70423)
+@@ -159,7 +159,7 @@
+ static int entry_obj_filemap_with_md5(Tcl_Interp* interp, reg_entry* entry, int objc,
+         Tcl_Obj* CONST objv[]) {
+     reg_registry* reg = registry_for(interp, reg_attached);
+-    printf("GSOCDBG: we're into entry_obj_filemap_with_md5\n");
++    printf("GSOCDBG: entering entry_obj_filemap_with_md5\n");
+     if (objc != 3) {
+         Tcl_WrongNumArgs(interp, 2, objv, "map {file md5checksum}-list");
+         return TCL_ERROR;
+@@ -174,33 +174,46 @@
+         int listc;
+         int result = TCL_ERROR;
+         int i;
++        int list_counter;
+ 
+         if (Tcl_ListObjGetElements(interp, objv[2], &listc, &listv) != TCL_OK) {
+             return TCL_ERROR;
+         }
+-        files=malloc(listc*sizeof(char *));
+-        md5sums=malloc(listc*sizeof(char*));
++        
++        printf("GSOCDBG: size of list %d\n", listc);
+         /*  remember to add check for malloc return values */
+-        for (i = 0; i < listc; i++) { 
++        files=malloc((listc/2)*sizeof(char *));
++        md5sums=malloc((listc/2)*sizeof(char*));
++        
++        printf("GSOCDBG: for loop\n");
++        /*  fill in files[] and md5sums[] */
++        for (i=0; i<listc; i+=2) { 
++            list_counter=i/2;
++            /*if (Tcl_ListObjLength(interp, listv[i], &length) != TCL_OK) {
++                free(files); free(md5sums); return TCL_ERROR; } */
++            printf("GSOCDBG: \titem %d\n", list_counter); 
++            element=NULL;
+             if (Tcl_ListObjIndex(interp, listv[i], 0, &element) != TCL_OK) {
+                 free(files); free(md5sums); return TCL_ERROR; } 
+-            else if(element != NULL)
+-                files[i] = Tcl_GetString(element);
++            else if (element == NULL) {
++                Tcl_SetErrorCode(interp, "illegal input", NULL); return TCL_ERROR; }
+             else {
++                files[list_counter] = Tcl_GetString(element);
++                printf("GSOCDBG: \t\tfiles[%d]=\"%s\"\n", list_counter, files[list_counter]); }
++            element=NULL;
++            if (Tcl_ListObjIndex(interp, listv[i+1], 0, &element) != TCL_OK) {
++                free(files); free(md5sums); return TCL_ERROR; } 
++            else if (element == NULL) {
+                 Tcl_SetErrorCode(interp, "illegal input", NULL); return TCL_ERROR; }
+-
+-            if (Tcl_ListObjIndex(interp, listv[i], 1, &element) != TCL_OK) {
+-                free(files); free(md5sums); return TCL_ERROR; } 
+-            else if(element != NULL)
+-                md5sums[i] = Tcl_GetString(element); 
+             else {
+-                Tcl_SetErrorCode(interp, "illegal input", NULL); return TCL_ERROR; }
++                md5sums[list_counter] = Tcl_GetString(element);
++                printf("GSOCDBG: \t\tmd5sums[%d]=\"%s\"\n", list_counter, md5sums[list_counter]); }
+         }
+         
+         /*  change the condition, */
+         /*  it used to be list_obj_to_string() but now we're filling arrays by hand  */
+         if ( 1 ) {
+-            if (reg_entry_map_with_md5(entry, files, md5sums, listc, &error)) {
++            if (reg_entry_map_with_md5(entry, files, md5sums, listc/2, &error)) {
+                 result = TCL_OK;
+             } else {
+                 result = registry_failed(interp, &error);
+@@ -214,6 +227,7 @@
+             result = registry_failed(interp, &error);
+         }
+         */
++        printf("GSOCDBG: exiting entry_obj_filemap_with_md5\n");
+         return result;
+     }
+ }
+@@ -469,6 +483,7 @@
+ int entry_obj_cmd(ClientData clientData, Tcl_Interp* interp, int objc,
+         Tcl_Obj* CONST objv[]) {
+     int cmd_index;
++    int len=0;
+     if (objc < 2) {
+         Tcl_WrongNumArgs(interp, 1, objv, "cmd ?arg ...?");
+         return TCL_ERROR;
+Index: src/port1.0/portinstall.tcl
+===================================================================
+--- src/port1.0/portinstall.tcl	(revision 70422)
++++ src/port1.0/portinstall.tcl	(revision 70423)
+@@ -198,7 +198,16 @@
+             
+             if {[info exists installPlist]} {
+                 # register files
+-                $regref map_with_md5 $installPlist
++                set installPlistWithMD5 [list]
++                foreach file $installPlist {
++                    lappend installPlistWithMD5 $file
++                    if {[catch {md5 file "$imagedir$file"} md5sum] == 0} {
++                        lappend installPlistWithMD5 $md5sum
++                    }
++                }    
++                #puts "installPlist:$installPlist"
++                puts "installPlistWithMD5:$installPlistWithMD5"
++                $regref map_with_md5 "$installPlistWithMD5"
+             }
+             
+             # store portfile
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70422)
++++ src/cregistry/entry.c	(revision 70423)
+@@ -872,26 +872,39 @@
+  * @param [out] errPtr    on error, a description of the error that occurred
+  * @return                true if success; false if failure
+  */
+-int reg_entry_map_with_md5(reg_entry* entry, char** files, char** md5sums, int arg_count,
+-        reg_error* errPtr) {
++int reg_entry_map_with_md5(reg_entry* entry, char** files, char** md5sums,
++        int arg_count, reg_error* errPtr) {
+     reg_registry* reg = entry->reg;
+     int result = 1;
+     sqlite3_stmt* stmt = NULL;
+-    char* insert = "INSERT INTO registry.files (id, path, mtime, active, md5sum) "
+-        "VALUES (?, ?, 0, 0, ?)";
+-    /*  sqlite3_prepare() is documented as legacy, http://www.sqlite.org/c3ref/step.html
+-        use sqlite3_prepare_v2() should be used instead */
++    char* insert = "INSERT INTO registry.files "
++        "(id, path, mtime, active, md5sum) VALUES (?, ?, 0, 0, ?)";
++        
++    printf("GSOCDBG: \tentered reg_entry_map_with_md5\n");
++    printf("GSOCDBG: \t\targ_count:%d\n",arg_count);
++    /*  sqlite3_prepare() is documented as legacy, 
++        cf. http://www.sqlite.org/c3ref/step.html
++        sqlite3_prepare_v2() should be used instead */
+     if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
+             && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
+         int i;
+-        for (i=0; i<(arg_count/2) && result; i++) {
++        printf("GSOCDBG: \tlet's print files[] and md5sums[]\n");
++        for (i=0; i<arg_count; i++) {
++            printf("GSOCDBG: \t\tfiles[%d]:\"%s\"\n",i,files[i]);
++            printf("GSOCDBG: \t\tmd5sums[%d]:\"%s\"\n",i,md5sums[i]);
++        }
++        printf("GSOCDBG: \t\tentering the for loop\n");
++            for (i=0; (i<arg_count) && result; i++) {
++            printf("GSOCDBG: \t\tloop iteration:%d\n",i);
+             /*  cycles through files[] array of strings,
+                 the if argument parse a file from the array and put in into
+                 the SQL statement */
+             if (sqlite3_bind_text(stmt, 2, files[i], -1, SQLITE_STATIC)
+                     == SQLITE_OK) {
++                printf("GSOCDBG: \t\t\tinside first if branch\n");
+                 if (sqlite3_bind_text(stmt, 3, md5sums[i], -1, SQLITE_STATIC)
+                         == SQLITE_OK) {
++                    printf("GSOCDBG: \t\t\tinside second if branch\n");
+                     int r;
+                     do {
+                         r = sqlite3_step(stmt);
+@@ -917,6 +930,7 @@
+         reg_sqlite_error(reg->db, errPtr, insert);
+         result = 0;
+     }
++    printf("GSOCDBG: \texiting reg_entry_map_with_md5\n");
+     if (stmt) {
+         sqlite3_finalize(stmt);
+     }

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70427.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70427.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70427.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,13 @@
+Index: src/port1.0/portinstall.tcl
+===================================================================
+--- src/port1.0/portinstall.tcl	(revision 70426)
++++ src/port1.0/portinstall.tcl	(revision 70427)
+@@ -203,7 +203,7 @@
+                     lappend installPlistWithMD5 $file
+                     if {[catch {md5 file "$imagedir$file"} md5sum] == 0} {
+                         lappend installPlistWithMD5 $md5sum
+-                    }
++                    } else { lappend installPlistWithMD5 _not_present}
+                 }    
+                 #puts "installPlist:$installPlist"
+                 puts "installPlistWithMD5:$installPlistWithMD5"

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70448.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70448.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70448.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,330 @@
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70447)
++++ src/registry2.0/entryobj.c	(revision 70448)
+@@ -266,6 +266,43 @@
+     }
+ }
+ 
++static int entry_obj_files_with_md5(Tcl_Interp* interp, reg_entry* entry, int objc,
++        Tcl_Obj* CONST objv[]) {
++    reg_registry* reg = registry_for(interp, reg_attached);
++    if (objc != 2) {
++        Tcl_WrongNumArgs(interp, 1, objv, "files_with_md5");
++        return TCL_ERROR;
++    } else if (reg == NULL) {
++        return TCL_ERROR;
++    } else {
++        char** files;
++        char** md5sums;
++        reg_error error;
++        /*  call to entry.c function */
++        int file_count = reg_entry_files_with_md5(entry, &files, &md5sums, &error);
++        int i;
++        if (file_count >= 0) {
++            Tcl_Obj** objs;
++            int retval = TCL_ERROR;
++            if (list_string_to_obj(&objs, files, file_count, &error)) {
++                Tcl_Obj* result = Tcl_NewListObj(file_count, objs);
++                /*  sending the result to Tcl, an object in this case */
++                Tcl_SetObjResult(interp, result);
++                free(objs);
++                retval = TCL_OK;
++            } else {
++                retval = registry_failed(interp, &error);
++            }
++            for (i=0; i<file_count; i++) {
++                free(files[i]);
++            }
++            free(files);
++            return retval;
++        }
++        return registry_failed(interp, &error);
++    }
++}
++
+ static int entry_obj_imagefiles(Tcl_Interp* interp, reg_entry* entry, int objc,
+         Tcl_Obj* CONST objv[]) {
+     reg_registry* reg = registry_for(interp, reg_attached);
+@@ -300,6 +337,41 @@
+     }
+ }
+ 
++static int entry_obj_imagefiles_with_md5(Tcl_Interp* interp, reg_entry* entry, int objc,
++        Tcl_Obj* CONST objv[]) {
++    reg_registry* reg = registry_for(interp, reg_attached);
++    if (objc != 2) {
++        Tcl_WrongNumArgs(interp, 1, objv, "imagefiles_with_md5");
++        return TCL_ERROR;
++    } else if (reg == NULL) {
++        return TCL_ERROR;
++    } else {
++        char** files;
++        char** md5sums;
++        reg_error error;
++        int file_count = reg_entry_imagefiles_with_md5(entry, &files, &md5sums, &error);
++        int i;
++        if (file_count >= 0) {
++            Tcl_Obj** objs;
++            int retval = TCL_ERROR;
++            if (list_string_to_obj(&objs, files, file_count, &error)) {
++                Tcl_Obj* result = Tcl_NewListObj(file_count, objs);
++                Tcl_SetObjResult(interp, result);
++                free(objs);
++                retval = TCL_OK;
++            } else {
++                retval = registry_failed(interp, &error);
++            }
++            for (i=0; i<file_count; i++) {
++                free(files[i]);
++            }
++            free(files);
++            return retval;
++        }
++        return registry_failed(interp, &error);
++    }
++}
++
+ static int entry_obj_activate(Tcl_Interp* interp, reg_entry* entry, int objc,
+         Tcl_Obj* CONST objv[]) {
+     reg_registry* reg = registry_for(interp, reg_attached);
+@@ -462,7 +534,9 @@
+     { "map_with_md5", entry_obj_filemap_with_md5 },
+     { "unmap", entry_obj_filemap },
+     { "files", entry_obj_files },
++    { "files_with_md5", entry_obj_files_with_md5 },
+     { "imagefiles", entry_obj_imagefiles },
++    { "imagefiles_with_md5", entry_obj_imagefiles_with_md5 },
+     { "activate", entry_obj_activate },
+     { "deactivate", entry_obj_filemap },
+     /* dep map */
+@@ -483,7 +557,6 @@
+ int entry_obj_cmd(ClientData clientData, Tcl_Interp* interp, int objc,
+         Tcl_Obj* CONST objv[]) {
+     int cmd_index;
+-    int len=0;
+     if (objc < 2) {
+         Tcl_WrongNumArgs(interp, 1, objv, "cmd ?arg ...?");
+         return TCL_ERROR;
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70447)
++++ src/cregistry/entry.c	(revision 70448)
+@@ -904,8 +904,8 @@
+                 printf("GSOCDBG: \t\t\tinside first if branch\n");
+                 if (sqlite3_bind_text(stmt, 3, md5sums[i], -1, SQLITE_STATIC)
+                         == SQLITE_OK) {
++                    int r;
+                     printf("GSOCDBG: \t\t\tinside second if branch\n");
+-                    int r;
+                     do {
+                         r = sqlite3_step(stmt);
+                         switch (r) {
+@@ -1063,6 +1063,94 @@
+ }
+ 
+ /**
++ * Gets a list of files provided by the given port. These files are in the port
++ * image and do not necessarily correspond to active files on the filesystem.
++ *
++ * TODO: check that the port's installtype is image
++ *
++ * @param [in] entry   entry to get the list for
++ * @param [out] files  a list of files provided by the port
++ * @param [out] md5sums  a list of files provided by the port
++ * @param [out] errPtr on error, a description of the error that occurred
++ * @return             the number of files if success; negative if failure
++ */
++int reg_entry_imagefiles_with_md5(reg_entry* entry, char*** files,
++        char*** md5sums, reg_error* errPtr) {
++    reg_registry* reg = entry->reg;
++    sqlite3_stmt* stmt = NULL;
++    char* query = "SELECT path,md5sum FROM registry.files WHERE id=? ORDER BY path";
++    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
++            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
++        char** result_files = malloc(10*sizeof(char*));
++        int result_count_files = 0;
++        int result_space_files = 10;
++        char** result_md5sums = malloc(10*sizeof(char*));
++        int result_count_md5sums = 0;
++        int result_space_md5sums = 10;
++        int r;
++        const char *text_file;
++        const char *text_md5sum;
++        char* element;
++        
++        if (!result_files || !result_md5sums) {
++            return -1;
++        }
++        do {
++            r = sqlite3_step(stmt);
++            switch (r) {
++                case SQLITE_ROW:
++                    /* here we're accessing the SQL statement data */
++                    text_file = (const char*)sqlite3_column_text(stmt, 0);
++                    if (text_file) {
++                        element = strdup(text_file);
++                        if (!element || !reg_listcat((void***)&result_files, &result_count_files, &result_space_files, element)) {
++                            r = SQLITE_ERROR;
++                        }
++                    }
++                    text_md5sum = (const char*)sqlite3_column_text(stmt, 1);
++                    if (text_md5sum) {
++                        element = strdup(text_md5sum);
++                        if (!element || !reg_listcat((void***)&result_md5sums, &result_count_md5sums, &result_space_md5sums, element)) {
++                            r = SQLITE_ERROR;
++                        }
++                    }
++                    break;
++                case SQLITE_DONE:
++                case SQLITE_BUSY:
++                    break;
++                default:
++                    reg_sqlite_error(reg->db, errPtr, query);
++                    break;
++            }
++        } while (r == SQLITE_ROW || r == SQLITE_BUSY);
++        sqlite3_finalize(stmt);
++        if (r == SQLITE_DONE) {
++            *files = result_files;
++            *md5sums = result_md5sums;
++            /*  this is lacking result_count_md5sums, shouldn't be necessary */
++            return result_count_files;
++        } else {
++            int i;
++            for (i=0; i<result_count_files; i++) {
++                free(result_files[i]);
++            }
++            for (i=0; i<result_count_md5sums; i++) {
++                free(result_md5sums[i]);
++            }
++            free(result_files);
++            free(result_md5sums);
++            return -1;
++        }
++    } else {
++        reg_sqlite_error(reg->db, errPtr, query);
++        if (stmt) {
++            sqlite3_finalize(stmt);
++        }
++        return -1;
++    }
++}
++
++/**
+  * Gets a list of files owned by the given port. These files are active in the
+  * filesystem and could be different from the port's imagefiles.
+  *
+@@ -1131,6 +1219,95 @@
+ }
+ 
+ /**
++ * Gets a list of files owned by the given port. These files are active in the
++ * filesystem and could be different from the port's imagefiles.
++ *
++ * TODO: check that the port is active
++ *
++ * @param [in] entry   entry to get the list for
++ * @param [out] files  a list of files owned by the port
++ * @param [out] md5sums  a list of files provided by the port
++ * @param [out] errPtr on error, a description of the error that occurred
++ * @return             the number of files if success; negative if failure
++ */
++int reg_entry_files_with_md5(reg_entry* entry, char*** files, char*** md5sums,
++        reg_error* errPtr) {
++    reg_registry* reg = entry->reg;
++    sqlite3_stmt* stmt = NULL;
++    char* query = "SELECT actual_path,md5sum FROM registry.files WHERE id=? "
++        "AND active ORDER BY actual_path";
++    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
++            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
++        char** result_files = malloc(10*sizeof(char*));
++        int result_count_files = 0;
++        int result_space_files = 10;
++        char** result_md5sums = malloc(10*sizeof(char*));
++        int result_count_md5sums = 0;
++        int result_space_md5sums = 10;
++        int r;
++        const char *text_file;
++        const char *text_md5sum;
++        char* element;
++        
++        if (!result_files || !result_md5sums) {
++            return -1;
++        }
++        do {
++            r = sqlite3_step(stmt);
++            switch (r) {
++                case SQLITE_ROW:
++                    /* here we're accessing the SQL statement data */
++                    text_file = (const char*)sqlite3_column_text(stmt, 0);
++                    if (text_file) {
++                        element = strdup(text_file);
++                        if (!element || !reg_listcat((void***)&result_files, &result_count_files, &result_space_files, element)) {
++                            r = SQLITE_ERROR;
++                        }
++                    }
++                    text_md5sum = (const char*)sqlite3_column_text(stmt, 1);
++                    if (text_md5sum) {
++                        element = strdup(text_md5sum);
++                        if (!element || !reg_listcat((void***)&result_md5sums, &result_count_md5sums, &result_space_md5sums, element)) {
++                            r = SQLITE_ERROR;
++                        }
++                    }
++                    break;
++                case SQLITE_DONE:
++                case SQLITE_BUSY:
++                    break;
++                default:
++                    reg_sqlite_error(reg->db, errPtr, query);
++                    break;
++            }
++        } while (r == SQLITE_ROW || r == SQLITE_BUSY);
++        sqlite3_finalize(stmt);
++        if (r == SQLITE_DONE) {
++            *files = result_files;
++            *md5sums = result_md5sums;
++            /*  this is lacking result_count_md5sums, shouldn't be necessary */
++            return result_count_files;
++        } else {
++            int i;
++            for (i=0; i<result_count_files; i++) {
++                free(result_files[i]);
++            }
++            for (i=0; i<result_count_md5sums; i++) {
++                free(result_md5sums[i]);
++            }
++            free(result_files);
++            free(result_md5sums);
++            return -1;
++        }
++    } else {
++        reg_sqlite_error(reg->db, errPtr, query);
++        if (stmt) {
++            sqlite3_finalize(stmt);
++        }
++        return -1;
++    }
++}
++
++/**
+  * Sets an entry's files as being active in the filesystem. This entry will be
+  * subsequently returned by `reg_entry_owner` on those files' path. If all files
+  * are being activated as the names they are in the registry, then `as_files`
+Index: src/cregistry/entry.h
+===================================================================
+--- src/cregistry/entry.h	(revision 70447)
++++ src/cregistry/entry.h	(revision 70448)
+@@ -84,7 +84,11 @@
+ 
+ int reg_entry_files(reg_entry* entry, char*** files, reg_error* errPtr);
+ int reg_entry_imagefiles(reg_entry* entry, char*** files, reg_error* errPtr);
+-
++int reg_entry_files_with_md5(
++        reg_entry* entry, char*** files, char*** md5sums, reg_error* errPtr);       
++int reg_entry_imagefiles_with_md5(
++        reg_entry* entry, char*** files, char*** md5sums, reg_error* errPtr);
++        
+ int reg_entry_activate(reg_entry* entry, char** files, char** as_files,
+         int file_count, reg_error* errPtr);
+ int reg_entry_deactivate(reg_entry* entry, char** files, int file_count,

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70472.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70472.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70472.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,83 @@
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70471)
++++ src/registry2.0/entryobj.c	(revision 70472)
+@@ -277,16 +277,24 @@
+     } else {
+         char** files;
+         char** md5sums;
++        char** mixed;
+         reg_error error;
+-        /*  call to entry.c function */
+         int file_count = reg_entry_files_with_md5(entry, &files, &md5sums, &error);
+         int i;
+         if (file_count >= 0) {
+             Tcl_Obj** objs;
+             int retval = TCL_ERROR;
+-            if (list_string_to_obj(&objs, files, file_count, &error)) {
+-                Tcl_Obj* result = Tcl_NewListObj(file_count, objs);
+-                /*  sending the result to Tcl, an object in this case */
++            
++            mixed=malloc(2*file_count*sizeof(char *));
++            for (i=0; i<2*file_count; i+=2) {
++                /*  could Tcl_* functions instead, Tcl_NewListObj and then
++                Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
++                    */
++                mixed[i+0]=files[i];
++                mixed[i+1]=md5sums[i];
++            }
++            if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
++                Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
+                 Tcl_SetObjResult(interp, result);
+                 free(objs);
+                 retval = TCL_OK;
+@@ -295,8 +303,11 @@
+             }
+             for (i=0; i<file_count; i++) {
+                 free(files[i]);
++                free(md5sums[i]);
+             }
+             free(files);
++            free(md5sums);
++            free(mixed);
+             return retval;
+         }
+         return registry_failed(interp, &error);
+@@ -348,14 +359,23 @@
+     } else {
+         char** files;
+         char** md5sums;
++        char** mixed;
+         reg_error error;
+         int file_count = reg_entry_imagefiles_with_md5(entry, &files, &md5sums, &error);
+         int i;
+         if (file_count >= 0) {
+             Tcl_Obj** objs;
+             int retval = TCL_ERROR;
+-            if (list_string_to_obj(&objs, files, file_count, &error)) {
+-                Tcl_Obj* result = Tcl_NewListObj(file_count, objs);
++            mixed=malloc(2*file_count*sizeof(char *));
++            for (i=0; i<2*file_count; i+=2) {
++                /*  could Tcl_* functions instead, Tcl_NewListObj and then
++                Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
++                    */
++                mixed[i+0]=files[i];
++                mixed[i+1]=md5sums[i];
++            }
++            if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
++                Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
+                 Tcl_SetObjResult(interp, result);
+                 free(objs);
+                 retval = TCL_OK;
+@@ -364,8 +384,11 @@
+             }
+             for (i=0; i<file_count; i++) {
+                 free(files[i]);
++                free(md5sums[i]);
+             }
+             free(files);
++            free(md5sums);
++            free(mixed);
+             return retval;
+         }
+         return registry_failed(interp, &error);

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70473.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70473.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70473.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,161 @@
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70472)
++++ src/registry2.0/entryobj.c	(revision 70473)
+@@ -277,38 +277,42 @@
+     } else {
+         char** files;
+         char** md5sums;
+-        char** mixed;
++        char** mixed=NULL;
+         reg_error error;
+         int file_count = reg_entry_files_with_md5(entry, &files, &md5sums, &error);
+-        int i;
++        int i,k;
+         if (file_count >= 0) {
+             Tcl_Obj** objs;
+             int retval = TCL_ERROR;
+-            
+             mixed=malloc(2*file_count*sizeof(char *));
+-            for (i=0; i<2*file_count; i+=2) {
+-                /*  could Tcl_* functions instead, Tcl_NewListObj and then
+-                Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
+-                    */
+-                mixed[i+0]=files[i];
+-                mixed[i+1]=md5sums[i];
+-            }
+-            if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
+-                Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
+-                Tcl_SetObjResult(interp, result);
+-                free(objs);
+-                retval = TCL_OK;
++            if (!mixed) { 
++                /*  any meaningful return code here? */
++                return -1;
+             } else {
+-                retval = registry_failed(interp, &error);
++                for (i=0; k=2*i,i<file_count; i++) {
++                    /*  could Tcl_* functions instead, Tcl_NewListObj and then
++                    Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
++                        */
++                    mixed[k+0]=files[i];
++                    mixed[k+1]=md5sums[i];
++                }
++                if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
++                    Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
++                    Tcl_SetObjResult(interp, result);
++                    free(objs);
++                    retval = TCL_OK;
++                } else {
++                    retval = registry_failed(interp, &error);
++                }
++                for (i=0; i<file_count; i++) {
++                    free(files[i]);
++                    free(md5sums[i]);
++                }
++                free(files);
++                free(md5sums);
++                free(mixed);
++                return retval;
+             }
+-            for (i=0; i<file_count; i++) {
+-                free(files[i]);
+-                free(md5sums[i]);
+-            }
+-            free(files);
+-            free(md5sums);
+-            free(mixed);
+-            return retval;
+         }
+         return registry_failed(interp, &error);
+     }
+@@ -359,37 +363,42 @@
+     } else {
+         char** files;
+         char** md5sums;
+-        char** mixed;
++        char** mixed=NULL;
+         reg_error error;
+         int file_count = reg_entry_imagefiles_with_md5(entry, &files, &md5sums, &error);
+-        int i;
++        int i,k;
+         if (file_count >= 0) {
+             Tcl_Obj** objs;
+             int retval = TCL_ERROR;
+             mixed=malloc(2*file_count*sizeof(char *));
+-            for (i=0; i<2*file_count; i+=2) {
+-                /*  could Tcl_* functions instead, Tcl_NewListObj and then
+-                Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
+-                    */
+-                mixed[i+0]=files[i];
+-                mixed[i+1]=md5sums[i];
+-            }
+-            if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
+-                Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
+-                Tcl_SetObjResult(interp, result);
+-                free(objs);
+-                retval = TCL_OK;
++            if (!mixed) { 
++                /*  any meaningful return code here? */
++                return -1;
+             } else {
+-                retval = registry_failed(interp, &error);
++                for (i=0; k=2*i,i<file_count; i++) {
++                    /*  could Tcl_* functions instead, Tcl_NewListObj and then
++                    Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
++                        */
++                    mixed[k+0]=files[i];
++                    mixed[k+1]=md5sums[i];
++                }
++                if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
++                    Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
++                    Tcl_SetObjResult(interp, result);
++                    free(objs);
++                    retval = TCL_OK;
++                } else {
++                    retval = registry_failed(interp, &error);
++                }
++                for (i=0; i<file_count; i++) {
++                    free(files[i]);
++                    free(md5sums[i]);
++                }
++                free(files);
++                free(md5sums);
++                free(mixed);
++                return retval;
+             }
+-            for (i=0; i<file_count; i++) {
+-                free(files[i]);
+-                free(md5sums[i]);
+-            }
+-            free(files);
+-            free(md5sums);
+-            free(mixed);
+-            return retval;
+         }
+         return registry_failed(interp, &error);
+     }
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70472)
++++ src/cregistry/entry.c	(revision 70473)
+@@ -1127,7 +1127,8 @@
+         if (r == SQLITE_DONE) {
+             *files = result_files;
+             *md5sums = result_md5sums;
+-            /*  this is lacking result_count_md5sums, shouldn't be necessary */
++            /*  this is lacking result_count_md5sums, shouldn't be necessary as 
++                both counts will always be the same */
+             return result_count_files;
+         } else {
+             int i;
+@@ -1284,7 +1285,8 @@
+         if (r == SQLITE_DONE) {
+             *files = result_files;
+             *md5sums = result_md5sums;
+-            /*  this is lacking result_count_md5sums, shouldn't be necessary */
++            /*  this is lacking result_count_md5sums, shouldn't be necessary as 
++                both counts will always be the same */
+             return result_count_files;
+         } else {
+             int i;

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70488.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70488.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70488.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,198 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70487)
++++ src/registry2.0/portimage.tcl	(revision 70488)
+@@ -216,7 +216,6 @@
+         }
+     }
+ 
+-    #branch on sqlite-registry-db or old–flatfile
+     if {$use_reg2} {
+         if { [string equal $name ""] } {
+             throw registry::image-error "Registry error: Please specify the name of the port."
+@@ -258,7 +257,6 @@
+         ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s"] $name]"
+     }
+ 
+-    #here we go - 
+     if {$use_reg2} {
+         if { ![string equal [$requested installtype] "image"] } {
+             return -code error "Image error: ${name} @${specifier} not installed as an image."
+@@ -699,7 +697,7 @@
+     variable use_reg2
+     set files [list]
+ 
+-    foreach file $imagefiles {  
++    foreach file $imagefiles {
+         if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } {
+             # Normalize the file path to avoid removing the intermediate
+             # symlinks (remove the empty directories instead)
+@@ -736,7 +734,7 @@
+             $port deactivate $imagefiles
+             foreach file $files {
+                   if {[is_config_file $file]} {
+-                          #puts "GSOC: $file is config file, skipping for now"
++                          puts "GSOC: $file is config file"
+                           #continue
+                       }                  
+                 _deactivate_file $file
+@@ -751,7 +749,7 @@
+ 
+ proc is_config_file {filename} {
+     #replace hardcoded path with $config_path from portmain.tcl, what namespace does "option" add options to?
+-    if {[string match ${::macports::prefix} "$filename"]} {return 1} {return 0}
++    if {[string match ${::macports::prefix}/etc "$filename"]} {return 1} {return 0}
+ }
+ 
+ # End of portimage namespace
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70487)
++++ src/registry2.0/entryobj.c	(revision 70488)
+@@ -404,6 +404,40 @@
+     }
+ }
+ 
++static int entry_obj_md5sums(Tcl_Interp* interp, reg_entry* entry, int objc,
++        Tcl_Obj* CONST objv[]) {
++    reg_registry* reg = registry_for(interp, reg_attached);
++    if (objc != 2) {
++        Tcl_WrongNumArgs(interp, 1, objv, "md5sums");
++        return TCL_ERROR;
++    } else if (reg == NULL) {
++        return TCL_ERROR;
++    } else {
++        char** md5sums;
++        reg_error error;
++        int file_count = reg_entry_md5sums(entry, &md5sums, &error);
++        int i;
++        if (file_count >= 0) {
++            Tcl_Obj** objs;
++            int retval = TCL_ERROR;
++            if (list_string_to_obj(&objs, md5sums, file_count, &error)) {
++                Tcl_Obj* result = Tcl_NewListObj(file_count, objs);
++                Tcl_SetObjResult(interp, result);
++                free(objs);
++                retval = TCL_OK;
++            } else {
++                retval = registry_failed(interp, &error);
++            }
++            for (i=0; i<file_count; i++) {
++                free(md5sums[i]);
++            }
++            free(md5sums);
++            return retval;
++        }
++        return registry_failed(interp, &error);
++    }
++}
++
+ static int entry_obj_activate(Tcl_Interp* interp, reg_entry* entry, int objc,
+         Tcl_Obj* CONST objv[]) {
+     reg_registry* reg = registry_for(interp, reg_attached);
+@@ -569,6 +603,7 @@
+     { "files_with_md5", entry_obj_files_with_md5 },
+     { "imagefiles", entry_obj_imagefiles },
+     { "imagefiles_with_md5", entry_obj_imagefiles_with_md5 },
++    { "md5sums", entry_obj_md5sums },
+     { "activate", entry_obj_activate },
+     { "deactivate", entry_obj_filemap },
+     /* dep map */
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70487)
++++ src/cregistry/entry.c	(revision 70488)
+@@ -1310,6 +1310,73 @@
+ }
+ 
+ /**
++ * Gets a list of md5sums owned by the given port.
++ *
++ * TODO: check that the port is active
++ *
++ * @param [in] entry    entry to get the list for
++ * @param [out] md5sums a list of md5sums owned by the port
++ * @param [out] errPtr  on error, a description of the error that occurred
++ * @return              the number of md5sums if success; negative if failure
++ */
++int reg_entry_md5sums(reg_entry* entry, char*** md5sums, reg_error* errPtr) {
++    reg_registry* reg = entry->reg;
++    sqlite3_stmt* stmt = NULL;
++    char* query = "SELECT md5sum FROM registry.files WHERE id=? "
++        "AND active ORDER BY actual_path";
++    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
++            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
++        char** result = malloc(10*sizeof(char*));
++        int result_count = 0;
++        int result_space = 10;
++        int r;
++        const char *text;
++        char* element;
++        if (!result) {
++            return -1;
++        }
++        do {
++            r = sqlite3_step(stmt);
++            switch (r) {
++                case SQLITE_ROW:
++                    text = (const char*)sqlite3_column_text(stmt, 0);
++                    if (text) {
++                        element = strdup(text);
++                        if (!element || !reg_listcat((void***)&result, &result_count, &result_space, element)) {
++                            r = SQLITE_ERROR;
++                        }
++                    }
++                    break;
++                case SQLITE_DONE:
++                case SQLITE_BUSY:
++                    break;
++                default:
++                    reg_sqlite_error(reg->db, errPtr, query);
++                    break;
++            }
++        } while (r == SQLITE_ROW || r == SQLITE_BUSY);
++        sqlite3_finalize(stmt);
++        if (r == SQLITE_DONE) {
++            *md5sums = result;
++            return result_count;
++        } else {
++            int i;
++            for (i=0; i<result_count; i++) {
++                free(result[i]);
++            }
++            free(result);
++            return -1;
++        }
++    } else {
++        reg_sqlite_error(reg->db, errPtr, query);
++        if (stmt) {
++            sqlite3_finalize(stmt);
++        }
++        return -1;
++    }
++}
++
++/**
+  * Sets an entry's files as being active in the filesystem. This entry will be
+  * subsequently returned by `reg_entry_owner` on those files' path. If all files
+  * are being activated as the names they are in the registry, then `as_files`
+Index: src/cregistry/entry.h
+===================================================================
+--- src/cregistry/entry.h	(revision 70487)
++++ src/cregistry/entry.h	(revision 70488)
+@@ -84,11 +84,14 @@
+ 
+ int reg_entry_files(reg_entry* entry, char*** files, reg_error* errPtr);
+ int reg_entry_imagefiles(reg_entry* entry, char*** files, reg_error* errPtr);
++
+ int reg_entry_files_with_md5(
+         reg_entry* entry, char*** files, char*** md5sums, reg_error* errPtr);       
+ int reg_entry_imagefiles_with_md5(
+         reg_entry* entry, char*** files, char*** md5sums, reg_error* errPtr);
+-        
++
++int reg_entry_md5sums(reg_entry* entry, char*** md5sums, reg_error* errPtr);
++
+ int reg_entry_activate(reg_entry* entry, char** files, char** as_files,
+         int file_count, reg_error* errPtr);
+ int reg_entry_deactivate(reg_entry* entry, char** files, int file_count,

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70500.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70500.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70500.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,101 @@
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70499)
++++ src/registry2.0/entryobj.c	(revision 70500)
+@@ -159,7 +159,6 @@
+ static int entry_obj_filemap_with_md5(Tcl_Interp* interp, reg_entry* entry, int objc,
+         Tcl_Obj* CONST objv[]) {
+     reg_registry* reg = registry_for(interp, reg_attached);
+-    printf("GSOCDBG: entering entry_obj_filemap_with_md5\n");
+     if (objc != 3) {
+         Tcl_WrongNumArgs(interp, 2, objv, "map {file md5checksum}-list");
+         return TCL_ERROR;
+@@ -180,18 +179,13 @@
+             return TCL_ERROR;
+         }
+         
+-        printf("GSOCDBG: size of list %d\n", listc);
+         /*  remember to add check for malloc return values */
+         files=malloc((listc/2)*sizeof(char *));
+         md5sums=malloc((listc/2)*sizeof(char*));
+         
+-        printf("GSOCDBG: for loop\n");
+         /*  fill in files[] and md5sums[] */
+         for (i=0; i<listc; i+=2) { 
+             list_counter=i/2;
+-            /*if (Tcl_ListObjLength(interp, listv[i], &length) != TCL_OK) {
+-                free(files); free(md5sums); return TCL_ERROR; } */
+-            printf("GSOCDBG: \titem %d\n", list_counter); 
+             element=NULL;
+             if (Tcl_ListObjIndex(interp, listv[i], 0, &element) != TCL_OK) {
+                 free(files); free(md5sums); return TCL_ERROR; } 
+@@ -199,7 +193,6 @@
+                 Tcl_SetErrorCode(interp, "illegal input", NULL); return TCL_ERROR; }
+             else {
+                 files[list_counter] = Tcl_GetString(element);
+-                printf("GSOCDBG: \t\tfiles[%d]=\"%s\"\n", list_counter, files[list_counter]); }
+             element=NULL;
+             if (Tcl_ListObjIndex(interp, listv[i+1], 0, &element) != TCL_OK) {
+                 free(files); free(md5sums); return TCL_ERROR; } 
+@@ -207,7 +200,6 @@
+                 Tcl_SetErrorCode(interp, "illegal input", NULL); return TCL_ERROR; }
+             else {
+                 md5sums[list_counter] = Tcl_GetString(element);
+-                printf("GSOCDBG: \t\tmd5sums[%d]=\"%s\"\n", list_counter, md5sums[list_counter]); }
+         }
+         
+         /*  change the condition, */
+@@ -227,7 +219,6 @@
+             result = registry_failed(interp, &error);
+         }
+         */
+-        printf("GSOCDBG: exiting entry_obj_filemap_with_md5\n");
+         return result;
+     }
+ }
+Index: src/cregistry/entry.c
+===================================================================
+--- src/cregistry/entry.c	(revision 70499)
++++ src/cregistry/entry.c	(revision 70500)
+@@ -880,32 +880,21 @@
+     char* insert = "INSERT INTO registry.files "
+         "(id, path, mtime, active, md5sum) VALUES (?, ?, 0, 0, ?)";
+         
+-    printf("GSOCDBG: \tentered reg_entry_map_with_md5\n");
+-    printf("GSOCDBG: \t\targ_count:%d\n",arg_count);
+     /*  sqlite3_prepare() is documented as legacy, 
+         cf. http://www.sqlite.org/c3ref/step.html
+         sqlite3_prepare_v2() should be used instead */
+     if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
+             && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
+-        int i;
+-        printf("GSOCDBG: \tlet's print files[] and md5sums[]\n");
+-        for (i=0; i<arg_count; i++) {
+-            printf("GSOCDBG: \t\tfiles[%d]:\"%s\"\n",i,files[i]);
+-            printf("GSOCDBG: \t\tmd5sums[%d]:\"%s\"\n",i,md5sums[i]);
+-        }
+-        printf("GSOCDBG: \t\tentering the for loop\n");
++            int i;
+             for (i=0; (i<arg_count) && result; i++) {
+-            printf("GSOCDBG: \t\tloop iteration:%d\n",i);
+             /*  cycles through files[] array of strings,
+                 the if argument parse a file from the array and put in into
+                 the SQL statement */
+             if (sqlite3_bind_text(stmt, 2, files[i], -1, SQLITE_STATIC)
+                     == SQLITE_OK) {
+-                printf("GSOCDBG: \t\t\tinside first if branch\n");
+                 if (sqlite3_bind_text(stmt, 3, md5sums[i], -1, SQLITE_STATIC)
+                         == SQLITE_OK) {
+                     int r;
+-                    printf("GSOCDBG: \t\t\tinside second if branch\n");
+                     do {
+                         r = sqlite3_step(stmt);
+                         switch (r) {
+@@ -930,7 +919,6 @@
+         reg_sqlite_error(reg->db, errPtr, insert);
+         result = 0;
+     }
+-    printf("GSOCDBG: \texiting reg_entry_map_with_md5\n");
+     if (stmt) {
+         sqlite3_finalize(stmt);
+     }

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70508.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70508.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70508.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,21 @@
+Index: src/registry2.0/entryobj.c
+===================================================================
+--- src/registry2.0/entryobj.c	(revision 70507)
++++ src/registry2.0/entryobj.c	(revision 70508)
+@@ -192,14 +192,14 @@
+             else if (element == NULL) {
+                 Tcl_SetErrorCode(interp, "illegal input", NULL); return TCL_ERROR; }
+             else {
+-                files[list_counter] = Tcl_GetString(element);
++                files[list_counter] = Tcl_GetString(element); }
+             element=NULL;
+             if (Tcl_ListObjIndex(interp, listv[i+1], 0, &element) != TCL_OK) {
+                 free(files); free(md5sums); return TCL_ERROR; } 
+             else if (element == NULL) {
+                 Tcl_SetErrorCode(interp, "illegal input", NULL); return TCL_ERROR; }
+             else {
+-                md5sums[list_counter] = Tcl_GetString(element);
++                md5sums[list_counter] = Tcl_GetString(element); }
+         }
+         
+         /*  change the condition, */

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70509.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70509.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70509.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,13 @@
+Index: src/port1.0/portinstall.tcl
+===================================================================
+--- src/port1.0/portinstall.tcl	(revision 70508)
++++ src/port1.0/portinstall.tcl	(revision 70509)
+@@ -205,8 +205,6 @@
+                         lappend installPlistWithMD5 $md5sum
+                     } else { lappend installPlistWithMD5 _not_present}
+                 }    
+-                #puts "installPlist:$installPlist"
+-                puts "installPlistWithMD5:$installPlistWithMD5"
+                 $regref map_with_md5 "$installPlistWithMD5"
+             }
+             

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70510.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70510.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70510.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,13 @@
+Index: src/port1.0/portinstall.tcl
+===================================================================
+--- src/port1.0/portinstall.tcl	(revision 70509)
++++ src/port1.0/portinstall.tcl	(revision 70510)
+@@ -204,7 +204,7 @@
+                     if {[catch {md5 file "$imagedir$file"} md5sum] == 0} {
+                         lappend installPlistWithMD5 $md5sum
+                     } else { lappend installPlistWithMD5 _not_present}
+-                }    
++                }
+                 $regref map_with_md5 "$installPlistWithMD5"
+             }
+             

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70518.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70518.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70518.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,90 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70517)
++++ src/registry2.0/portimage.tcl	(revision 70518)
+@@ -270,7 +270,8 @@
+             registry::check_dependents $requested $force
+         }
+ 
+-        _deactivate_contents $requested [$requested files] $force
++        _deactivate_contents $requested [$requested files] [$requested files_with_md5] $force
++
+         $requested state imaged
+     } else {
+         set ref [registry::open_entry $name $version $revision $variants]
+@@ -549,7 +550,7 @@
+         } catch {*} {
+             # roll back activation of this port
+             if {[info exists deactivate_this]} {
+-                _deactivate_contents $port $rollback_filelist yes yes
++                _deactivate_contents $port $rollback_filelist {} yes yes
+             }
+             # if any errors occurred, move backed-up files back to their original
+             # locations, then rethrow the error. Transaction rollback will take care
+@@ -651,7 +652,7 @@
+                         }
+                     }} result]} {
+             ui_debug "Activation failed, rolling back."
+-            _deactivate_contents $name $rollback_filelist yes yes
++            _deactivate_contents $name $rollback_filelist {} yes yes
+             # return backed up files to their old locations
+             foreach f $backups {
+                 set bakfile "${f}${baksuffix}"
+@@ -693,11 +694,15 @@
+     }
+ }
+ 
+-proc _deactivate_contents {port imagefiles {force 0} {rollback 0}} {
++proc _deactivate_contents {port imagefiles {imagefiles_with_md5 {}} {force 0} {rollback 0}} {
+     variable use_reg2
+     set files [list]
+ 
++    puts "GSOCDBG: \tdeactivate_contents"
+     foreach file $imagefiles {
++        puts "GSOCDBG:\tfile:$file:\tmd5sum:[dict get $imagefiles_with_md5 $file]:"
++    }
++    foreach file $imagefiles {
+         if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } {
+             # Normalize the file path to avoid removing the intermediate
+             # symlinks (remove the empty directories instead)
+@@ -729,14 +734,27 @@
+     set files [lsort -decreasing -unique $files]
+ 
+     # Remove all elements.
++    puts "GSOCDBG:\tremoving all elements"
+     if {$use_reg2 && !$rollback} {
+         registry::write {
+             $port deactivate $imagefiles
+             foreach file $files {
+-                  if {[is_config_file $file]} {
+-                          puts "GSOC: $file is config file"
+-                          #continue
+-                      }                  
++                if { [file isfile $file] && [is_config_file $file]} {
++                        puts "GSOCDBG:\t$file is config file"
++                        if {[catch {md5 file "$file"} actual_md5] == 0} {
++                            set stored_md5 [dict get $imagefiles_with_md5 $file]
++                            puts "GSOCDBG:\t\tactual_md5:$actual_md5\tstored_md5:$stored_md5"
++                            if {![string compare -nocase \
++                                    $actual_md5 $stored_md5]} {
++                                puts "GSOCDBG:\t\tnot modified file:$file"
++                            } else {
++                                puts "GSOCDBG:\t\tmodified file:$file - PLEASE RUN port upgrade config-upgrade"
++                            }
++                            continue
++                        } else {
++                            puts "could'nt catch md5"
++                        }
++                }
+                 _deactivate_file $file
+             }
+         }
+@@ -749,7 +767,7 @@
+ 
+ proc is_config_file {filename} {
+     #replace hardcoded path with $config_path from portmain.tcl, what namespace does "option" add options to?
+-    if {[string match ${::macports::prefix}/etc "$filename"]} {return 1} {return 0}
++    if {[string match ${::macports::prefix}/etc* "$filename"]} {return 1} {return 0}
+ }
+ 
+ # End of portimage namespace

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70543.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70543.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70543.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,50 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70542)
++++ src/registry2.0/portimage.tcl	(revision 70543)
+@@ -406,12 +406,20 @@
+             }
+             return 0
+         }
+-        default {
+-            ui_debug "activating file: $dstfile"
+-            # Try a hard link first and if that fails, a symlink
+-            if {[catch {file link -hard $dstfile $srcfile}]} {
+-                ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"
+-                file link -symbolic $dstfile $srcfile
++        default {        
++            ui_debug "activating file: $dstfile"           
++            # copy config files rather than hardlink them
++            if { [is_config_file $dstfile]} {
++                puts "GSOCDBG:\tcopying $srcfile to $dstfile as it is a config file"
++                ui_debug "copying $srcfile to $dstfile as it is a config file"
++                file copy $srcfile $dstfile
++            } else {
++                puts "GSOCDBG:\tlinking $srcfile to $dstfile as it is a config file"
++                # Try a hard link first and if that fails, a symlink
++                if {[catch {file link -hard $dstfile $srcfile}]} {
++                    ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"
++                    file link -symbolic $dstfile $srcfile
++                }
+             }
+             return 1
+         }
+@@ -744,15 +752,15 @@
+                         if {[catch {md5 file "$file"} actual_md5] == 0} {
+                             set stored_md5 [dict get $imagefiles_with_md5 $file]
+                             puts "GSOCDBG:\t\tactual_md5:$actual_md5\tstored_md5:$stored_md5"
+-                            if {![string compare -nocase \
++                            if {[string equal -nocase \
+                                     $actual_md5 $stored_md5]} {
+                                 puts "GSOCDBG:\t\tnot modified file:$file"
+                             } else {
+                                 puts "GSOCDBG:\t\tmodified file:$file - PLEASE RUN port upgrade config-upgrade"
++                                continue
+                             }
+-                            continue
+                         } else {
+-                            puts "could'nt catch md5"
++                            puts "couldn't catch md5"
+                         }
+                 }
+                 _deactivate_file $file

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70544.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70544.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70544.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,13 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70543)
++++ src/registry2.0/portimage.tcl	(revision 70544)
+@@ -406,7 +406,7 @@
+             }
+             return 0
+         }
+-        default {        
++        default {
+             ui_debug "activating file: $dstfile"           
+             # copy config files rather than hardlink them
+             if { [is_config_file $dstfile]} {

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70545.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70545.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70545.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,33 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70544)
++++ src/registry2.0/portimage.tcl	(revision 70545)
+@@ -706,11 +706,7 @@
+     variable use_reg2
+     set files [list]
+ 
+-    puts "GSOCDBG: \tdeactivate_contents"
+     foreach file $imagefiles {
+-        puts "GSOCDBG:\tfile:$file:\tmd5sum:[dict get $imagefiles_with_md5 $file]:"
+-    }
+-    foreach file $imagefiles {
+         if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } {
+             # Normalize the file path to avoid removing the intermediate
+             # symlinks (remove the empty directories instead)
+@@ -742,16 +738,13 @@
+     set files [lsort -decreasing -unique $files]
+ 
+     # Remove all elements.
+-    puts "GSOCDBG:\tremoving all elements"
+     if {$use_reg2 && !$rollback} {
+         registry::write {
+             $port deactivate $imagefiles
+             foreach file $files {
+                 if { [file isfile $file] && [is_config_file $file]} {
+-                        puts "GSOCDBG:\t$file is config file"
+                         if {[catch {md5 file "$file"} actual_md5] == 0} {
+                             set stored_md5 [dict get $imagefiles_with_md5 $file]
+-                            puts "GSOCDBG:\t\tactual_md5:$actual_md5\tstored_md5:$stored_md5"
+                             if {[string equal -nocase \
+                                     $actual_md5 $stored_md5]} {
+                                 puts "GSOCDBG:\t\tnot modified file:$file"

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70566.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70566.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70566.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,49 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70565)
++++ src/registry2.0/portimage.tcl	(revision 70566)
+@@ -67,6 +67,9 @@
+ variable force 0
+ variable use_reg2 0
+ variable noexec 0
++# This actually means that we're deactivate an installed port to activate \
++    another version of the same port
++variable is_upgrade 0
+ 
+ # Activate a "Port Image"
+ proc activate {name v optionslist} {
+@@ -75,6 +78,7 @@
+     variable force
+     variable use_reg2
+     variable noexec
++    variable is_upgrade
+ 
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         set force 1
+@@ -120,6 +124,7 @@
+                 return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
+             }
+         }
++        if {$todeactivate ne ""} {set is_upgrade 1}
+         foreach a $todeactivate {
+             if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+                 deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
+@@ -199,7 +204,9 @@
+     global UI_PREFIX macports::registry.format macports::registry.path registry_open
+     array set options $optionslist
+     variable use_reg2
++    variable is_upgrade
+ 
++    puts "GSOCDBG:\tdeactivate\tis_upgrade:$is_upgrade"
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         # this not using the namespace variable is correct, since activate
+         # needs to be able to force deactivate independently of whether
+@@ -414,7 +421,7 @@
+                 ui_debug "copying $srcfile to $dstfile as it is a config file"
+                 file copy $srcfile $dstfile
+             } else {
+-                puts "GSOCDBG:\tlinking $srcfile to $dstfile as it is a config file"
++                puts "GSOCDBG:\tlinking $srcfile to $dstfile"
+                 # Try a hard link first and if that fails, a symlink
+                 if {[catch {file link -hard $dstfile $srcfile}]} {
+                     ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70585.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70585.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70585.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,83 @@
+Index: src/registry2.0/registry_util.tcl
+===================================================================
+--- src/registry2.0/registry_util.tcl	(revision 70584)
++++ src/registry2.0/registry_util.tcl	(revision 70585)
+@@ -82,6 +82,9 @@
+ ## runs the given target of the given port using its stored portfile
+ ## @return   true if successful, false otherwise
+ proc run_target {port target options} {
++    if {$target eq "deactivate"} {
++        puts "GSOCDBG:\t\tactivate called deactivate via registry::"
++    }
+     set portspec "[$port name] @[$port version]_[$port revision][$port variants]"
+     if {[$port portfile] == ""} {
+         ui_debug "no portfile in registry for $portspec"
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70584)
++++ src/registry2.0/portimage.tcl	(revision 70585)
+@@ -80,6 +80,7 @@
+     variable noexec
+     variable is_upgrade
+ 
++    puts "GSOCDBG:\tactivate is_upgrade:$is_upgrade"
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         set force 1
+     }
+@@ -127,6 +128,7 @@
+         if {$todeactivate ne ""} {set is_upgrade 1}
+         foreach a $todeactivate {
+             if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
++                puts "GSOCDBG:\t\tactivate called deactivate via direct call"
+                 deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
+             }
+         }
+@@ -206,7 +208,7 @@
+     variable use_reg2
+     variable is_upgrade
+ 
+-    puts "GSOCDBG:\tdeactivate\tis_upgrade:$is_upgrade"
++    puts "GSOCDBG:\tdeactivate is_upgrade:$is_upgrade"
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         # this not using the namespace variable is correct, since activate
+         # needs to be able to force deactivate independently of whether
+@@ -277,6 +279,10 @@
+             registry::check_dependents $requested $force
+         }
+ 
++        #   put check for config-upgrade here, with AND on $is_upgrade, \
++            this way the actual _deactivate_contents won't start until there's \
++            some config file to upgrade, unless a forcing options has been \
++            provided on CLI
+         _deactivate_contents $requested [$requested files] [$requested files_with_md5] $force
+ 
+         $requested state imaged
+@@ -417,7 +423,7 @@
+             ui_debug "activating file: $dstfile"           
+             # copy config files rather than hardlink them
+             if { [is_config_file $dstfile]} {
+-                puts "GSOCDBG:\tcopying $srcfile to $dstfile as it is a config file"
++                puts "GSOCDBG:\t\tcopying $srcfile to $dstfile as it is a config file"
+                 ui_debug "copying $srcfile to $dstfile as it is a config file"
+                 file copy $srcfile $dstfile
+             } else {
+@@ -438,8 +444,10 @@
+     variable force
+     variable use_reg2
+     variable noexec
++    variable is_upgrade
+     global macports::prefix
+ 
++    puts "GSOCDBG:\t\t_activate_contents is_upgrade:$is_upgrade"
+     set files [list]
+     set baksuffix .mp_[clock seconds]
+     if {$use_reg2} {
+@@ -754,7 +762,7 @@
+                             set stored_md5 [dict get $imagefiles_with_md5 $file]
+                             if {[string equal -nocase \
+                                     $actual_md5 $stored_md5]} {
+-                                puts "GSOCDBG:\t\tnot modified file:$file"
++                                puts "GSOCDBG:\t\tnot modified file:$file - deactivating it"
+                             } else {
+                                 puts "GSOCDBG:\t\tmodified file:$file - PLEASE RUN port upgrade config-upgrade"
+                                 continue

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70586.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70586.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70586.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,83 @@
+Index: src/registry2.0/registry_util.tcl
+===================================================================
+--- src/registry2.0/registry_util.tcl	(revision 70585)
++++ src/registry2.0/registry_util.tcl	(revision 70586)
+@@ -82,9 +82,6 @@
+ ## runs the given target of the given port using its stored portfile
+ ## @return   true if successful, false otherwise
+ proc run_target {port target options} {
+-    if {$target eq "deactivate"} {
+-        puts "GSOCDBG:\t\tactivate called deactivate via registry::"
+-    }
+     set portspec "[$port name] @[$port version]_[$port revision][$port variants]"
+     if {[$port portfile] == ""} {
+         ui_debug "no portfile in registry for $portspec"
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70585)
++++ src/registry2.0/portimage.tcl	(revision 70586)
+@@ -80,7 +80,6 @@
+     variable noexec
+     variable is_upgrade
+ 
+-    puts "GSOCDBG:\tactivate is_upgrade:$is_upgrade"
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         set force 1
+     }
+@@ -128,7 +127,6 @@
+         if {$todeactivate ne ""} {set is_upgrade 1}
+         foreach a $todeactivate {
+             if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+-                puts "GSOCDBG:\t\tactivate called deactivate via direct call"
+                 deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
+             }
+         }
+@@ -208,7 +206,7 @@
+     variable use_reg2
+     variable is_upgrade
+ 
+-    puts "GSOCDBG:\tdeactivate is_upgrade:$is_upgrade"
++    puts "GSOCDBG:\tdeactivate\tis_upgrade:$is_upgrade"
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         # this not using the namespace variable is correct, since activate
+         # needs to be able to force deactivate independently of whether
+@@ -279,10 +277,6 @@
+             registry::check_dependents $requested $force
+         }
+ 
+-        #   put check for config-upgrade here, with AND on $is_upgrade, \
+-            this way the actual _deactivate_contents won't start until there's \
+-            some config file to upgrade, unless a forcing options has been \
+-            provided on CLI
+         _deactivate_contents $requested [$requested files] [$requested files_with_md5] $force
+ 
+         $requested state imaged
+@@ -423,7 +417,7 @@
+             ui_debug "activating file: $dstfile"           
+             # copy config files rather than hardlink them
+             if { [is_config_file $dstfile]} {
+-                puts "GSOCDBG:\t\tcopying $srcfile to $dstfile as it is a config file"
++                puts "GSOCDBG:\tcopying $srcfile to $dstfile as it is a config file"
+                 ui_debug "copying $srcfile to $dstfile as it is a config file"
+                 file copy $srcfile $dstfile
+             } else {
+@@ -444,10 +438,8 @@
+     variable force
+     variable use_reg2
+     variable noexec
+-    variable is_upgrade
+     global macports::prefix
+ 
+-    puts "GSOCDBG:\t\t_activate_contents is_upgrade:$is_upgrade"
+     set files [list]
+     set baksuffix .mp_[clock seconds]
+     if {$use_reg2} {
+@@ -762,7 +754,7 @@
+                             set stored_md5 [dict get $imagefiles_with_md5 $file]
+                             if {[string equal -nocase \
+                                     $actual_md5 $stored_md5]} {
+-                                puts "GSOCDBG:\t\tnot modified file:$file - deactivating it"
++                                puts "GSOCDBG:\t\tnot modified file:$file"
+                             } else {
+                                 puts "GSOCDBG:\t\tmodified file:$file - PLEASE RUN port upgrade config-upgrade"
+                                 continue

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70587.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70587.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70587.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,72 @@
+Index: src/registry2.0/registry_util.tcl
+===================================================================
+--- src/registry2.0/registry_util.tcl	(revision 70586)
++++ src/registry2.0/registry_util.tcl	(revision 70587)
+@@ -82,6 +82,9 @@
+ ## runs the given target of the given port using its stored portfile
+ ## @return   true if successful, false otherwise
+ proc run_target {port target options} {
++    if {$target eq "deactivate"} {
++        puts "GSOCDBG:\t\tactivate called deactivate via registry::"
++    }
+     set portspec "[$port name] @[$port version]_[$port revision][$port variants]"
+     if {[$port portfile] == ""} {
+         ui_debug "no portfile in registry for $portspec"
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70586)
++++ src/registry2.0/portimage.tcl	(revision 70587)
+@@ -80,6 +80,7 @@
+     variable noexec
+     variable is_upgrade
+ 
++    puts "GSOCDBG:\tactivate is_upgrade:$is_upgrade"
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         set force 1
+     }
+@@ -127,6 +128,7 @@
+         if {$todeactivate ne ""} {set is_upgrade 1}
+         foreach a $todeactivate {
+             if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
++                puts "GSOCDBG:\t\tactivate called deactivate via direct call"
+                 deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
+             }
+         }
+@@ -206,7 +208,7 @@
+     variable use_reg2
+     variable is_upgrade
+ 
+-    puts "GSOCDBG:\tdeactivate\tis_upgrade:$is_upgrade"
++    puts "GSOCDBG:\tdeactivate is_upgrade:$is_upgrade"
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         # this not using the namespace variable is correct, since activate
+         # needs to be able to force deactivate independently of whether
+@@ -277,6 +279,10 @@
+             registry::check_dependents $requested $force
+         }
+ 
++        #   put check for config-upgrade here, with AND on $is_upgrade, \
++            this way the actual _deactivate_contents won't start until there's \
++            some config file to upgrade, unless a forcing options has been \
++            provided on CLI
+         _deactivate_contents $requested [$requested files] [$requested files_with_md5] $force
+ 
+         $requested state imaged
+@@ -417,7 +423,7 @@
+             ui_debug "activating file: $dstfile"           
+             # copy config files rather than hardlink them
+             if { [is_config_file $dstfile]} {
+-                puts "GSOCDBG:\tcopying $srcfile to $dstfile as it is a config file"
++                puts "GSOCDBG:\t\tcopying $srcfile to $dstfile as it is a config file"
+                 ui_debug "copying $srcfile to $dstfile as it is a config file"
+                 file copy $srcfile $dstfile
+             } else {
+@@ -754,7 +760,7 @@
+                             set stored_md5 [dict get $imagefiles_with_md5 $file]
+                             if {[string equal -nocase \
+                                     $actual_md5 $stored_md5]} {
+-                                puts "GSOCDBG:\t\tnot modified file:$file"
++                                puts "GSOCDBG:\t\tnot modified file:$file - deactivating it"
+                             } else {
+                                 puts "GSOCDBG:\t\tmodified file:$file - PLEASE RUN port upgrade config-upgrade"
+                                 continue

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70592.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70592.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70592.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,68 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70591)
++++ src/registry2.0/portimage.tcl	(revision 70592)
+@@ -127,6 +127,21 @@
+         }
+         if {$todeactivate ne ""} {set is_upgrade 1}
+         foreach a $todeactivate {
++
++## Moving _check_config_files here, this render "is_upgrade" variable useless
++##
++## We need to move the check up here as we have to keep track of both
++## installed version and the version that is going to be installed
++##
++## At this point:
++## $requested is registry::entry for the port to be installed
++## $todeactivate is active version for same port
++            if {[_check_config_files_changed $requested [$requested files]]} {
++                return -code error "Image error: Please run upgrade -config-upgrade"
++                #throw registry::image-error "Image error: Please run upgrade -config-upgrade"           
++            } else {
++                puts "GSOCDBG:\tOn error we shouldn't see this"
++            }
+             if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+                 puts "GSOCDBG:\t\tactivate called deactivate via direct call"
+                 deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
+@@ -279,10 +294,6 @@
+             registry::check_dependents $requested $force
+         }
+ 
+-        #   put check for config-upgrade here, with AND on $is_upgrade, \
+-            this way the actual _deactivate_contents won't start until there's \
+-            some config file to upgrade, unless a forcing options has been \
+-            provided on CLI
+         _deactivate_contents $requested [$requested files] [$requested files_with_md5] $force
+ 
+         $requested state imaged
+@@ -393,6 +404,30 @@
+     return $imagefiles
+ }
+ 
++## Checks all files in config files for changes comparing actual checksum with 
++## checksum in registry.
++##
++## @param [in] port     portfile upgrading
++## @return 1 if the port doesn't have config files changed, 0 otherwise
++proc _check_config_files_changed {port files} {
++    return 1
++#    foreach file $files {
++#        if { [file isfile $file] && [is_config_file $file]} {
++#            if {[catch {md5 file "$file"} actual_md5] == 0} {
++#                set stored_md5 [dict get $imagefiles_with_md5 $file]
++#                if {[string equal -nocase $actual_md5 $stored_md5]} {
++#                    puts "GSOCDBG:\t\tnot modified file:$file - deactivating it"
++#                } else {
++#                    puts "GSOCDBG:\t\tmodified file:$file - PLEASE RUN port upgrade config-upgrade"
++#                    continue
++#                }
++#            } else {
++#            puts "couldn't catch md5"
++#            }
++#        }
++#    }
++}
++
+ ## Activates a file from an image into the filesystem. Deals with symlinks,
+ ## directories and files.
+ ##

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70610.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70610.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70610.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,97 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70609)
++++ src/registry2.0/portimage.tcl	(revision 70610)
+@@ -127,25 +127,21 @@
+         }
+         if {$todeactivate ne ""} {set is_upgrade 1}
+         foreach a $todeactivate {
+-
+-## Moving _check_config_files here, this render "is_upgrade" variable useless
+-##
+-## We need to move the check up here as we have to keep track of both
+-## installed version and the version that is going to be installed
+-##
+-## At this point:
+-## $requested is registry::entry for the port to be installed
+-## $todeactivate is active version for same port
+-            if {[_check_config_files_changed $requested [$requested files]]} {
+-                return -code error "Image error: Please run upgrade -config-upgrade"
+-                #throw registry::image-error "Image error: Please run upgrade -config-upgrade"           
+-            } else {
+-                puts "GSOCDBG:\tOn error we shouldn't see this"
+-            }
+-            if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+-                puts "GSOCDBG:\t\tactivate called deactivate via direct call"
+-                deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
+-            }
++            ## Moving _check_config_files here, this render "is_upgrade"
++            ## variable useless
++            ##
++            ## We need to move the check up here as we have to keep track of
++            ## both installed version and the version that is going to be
++            ## installed
++            ##
++            ## At this point: $requested is registry::entry for the port to be
++            ## installed $todeactivate is active version for same port
++            
++            puts "GSOCDBG:\t_check_config_files_changed:[_check_config_files_changed $requested [$requested files] [$requested imagefiles_with_md5]]"
++#            if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
++#                puts "GSOCDBG:\t\tactivate called deactivate via direct call"
++#                deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
++#            }
+         }
+     } else {
+         # registry1.0
+@@ -408,24 +404,33 @@
+ ## checksum in registry.
+ ##
+ ## @param [in] port     portfile upgrading
+-## @return 1 if the port doesn't have config files changed, 0 otherwise
+-proc _check_config_files_changed {port files} {
+-    return 1
+-#    foreach file $files {
+-#        if { [file isfile $file] && [is_config_file $file]} {
+-#            if {[catch {md5 file "$file"} actual_md5] == 0} {
+-#                set stored_md5 [dict get $imagefiles_with_md5 $file]
+-#                if {[string equal -nocase $actual_md5 $stored_md5]} {
+-#                    puts "GSOCDBG:\t\tnot modified file:$file - deactivating it"
+-#                } else {
+-#                    puts "GSOCDBG:\t\tmodified file:$file - PLEASE RUN port upgrade config-upgrade"
+-#                    continue
+-#                }
+-#            } else {
+-#            puts "couldn't catch md5"
+-#            }
+-#        }
+-#    }
++## @return  1 if config files of port changed, 0 otherwise
++proc _check_config_files_changed {port files files_with_md5} {
++    set return_value 0
++    puts "GSOCDBG:\tentering _check_config_files_changed"
++    foreach file $files {
++        if { [file isfile $file] && [is_config_file $file]} {
++            puts "GSOCDBG:\tfirst if"
++            if {[catch {md5 file "$file"} actual_md5] == 0} {
++                puts "GSOCDBG:\tsecond if"
++                set stored_md5 [dict get $files_with_md5 $file]                
++                if {[string equal -nocase $actual_md5 $stored_md5]} {
++                    puts "GSOCDBG:\tthird if"
++                    puts "GSOCDBG:\t\tnot modified file:$file"
++                } else {
++                    puts "GSOCDBG:\tthird if - else"
++                    puts "GSOCDBG:\t\tmodified file:$file"
++                    set return_value 1
++                }
++            } else {
++            puts "couldn't catch md5"
++            }
++        } else {
++            puts "GSOCDBG:\t\telement:$file is not of type file"
++        }
++    }
++    puts "GSOCDBG:\texiting _check_config_files_changed\t return_value:$return_value"
++    return $return_value
+ }
+ 
+ ## Activates a file from an image into the filesystem. Deals with symlinks,

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70611.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70611.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70611.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,25 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70610)
++++ src/registry2.0/portimage.tcl	(revision 70611)
+@@ -795,20 +795,6 @@
+         registry::write {
+             $port deactivate $imagefiles
+             foreach file $files {
+-                if { [file isfile $file] && [is_config_file $file]} {
+-                        if {[catch {md5 file "$file"} actual_md5] == 0} {
+-                            set stored_md5 [dict get $imagefiles_with_md5 $file]
+-                            if {[string equal -nocase \
+-                                    $actual_md5 $stored_md5]} {
+-                                puts "GSOCDBG:\t\tnot modified file:$file - deactivating it"
+-                            } else {
+-                                puts "GSOCDBG:\t\tmodified file:$file - PLEASE RUN port upgrade config-upgrade"
+-                                continue
+-                            }
+-                        } else {
+-                            puts "couldn't catch md5"
+-                        }
+-                }
+                 _deactivate_file $file
+             }
+         }

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70613.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70613.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70613.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,13 @@
+Index: src/port1.0/portutil.tcl
+===================================================================
+--- src/port1.0/portutil.tcl	(revision 70612)
++++ src/port1.0/portutil.tcl	(revision 70613)
+@@ -1557,7 +1557,7 @@
+         if {![file writable $statefile] && ![tbool ports_dryrun]} {
+             return -code error "$statefile is not writable - check permission on port directory"
+         }
+-        if {[file mtime ${portpath}/Portfile] >= [clock seconds]} {
++        if {[file mtime ${portpath}/Portfile] > [clock seconds]} {
+             return -code error "Portfile is from the future - check date and time of your system"
+         }
+         if {!([info exists ports_ignore_older] && $ports_ignore_older == "yes") && [file mtime $statefile] < [file mtime ${portpath}/Portfile]} {

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70614.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70614.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70614.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,56 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70613)
++++ src/registry2.0/portimage.tcl	(revision 70614)
+@@ -137,11 +137,15 @@
+             ## At this point: $requested is registry::entry for the port to be
+             ## installed $todeactivate is active version for same port
+             
+-            puts "GSOCDBG:\t_check_config_files_changed:[_check_config_files_changed $requested [$requested files] [$requested imagefiles_with_md5]]"
+-#            if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+-#                puts "GSOCDBG:\t\tactivate called deactivate via direct call"
+-#                deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
+-#            }
++            set changed_files [_check_config_files_changed $requested [$requested imagefiles] [$requested imagefiles_with_md5]]
++            if {$changed_files ne ""} {
++                puts "GSOCDBG:\t_check_config_files_changed: - SKIPPING DEACTIVATE"
++            } else {
++                if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
++                    puts "GSOCDBG:\t\tactivate called deactivate via direct call"
++                    deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
++                }
++            }
+         }
+     } else {
+         # registry1.0
+@@ -406,8 +410,9 @@
+ ## @param [in] port     portfile upgrading
+ ## @return  1 if config files of port changed, 0 otherwise
+ proc _check_config_files_changed {port files files_with_md5} {
+-    set return_value 0
++    set changed_files [list]
+     puts "GSOCDBG:\tentering _check_config_files_changed"
++    puts "GSOCDBG:\t\tfiles:$files"
+     foreach file $files {
+         if { [file isfile $file] && [is_config_file $file]} {
+             puts "GSOCDBG:\tfirst if"
+@@ -420,7 +425,7 @@
+                 } else {
+                     puts "GSOCDBG:\tthird if - else"
+                     puts "GSOCDBG:\t\tmodified file:$file"
+-                    set return_value 1
++                    lappend changed_files  $file
+                 }
+             } else {
+             puts "couldn't catch md5"
+@@ -429,8 +434,8 @@
+             puts "GSOCDBG:\t\telement:$file is not of type file"
+         }
+     }
+-    puts "GSOCDBG:\texiting _check_config_files_changed\t return_value:$return_value"
+-    return $return_value
++    puts "GSOCDBG:\texiting _check_config_files_changed\t changed_files:$changed_files"
++    return $changed_files
+ }
+ 
+ ## Activates a file from an image into the filesystem. Deals with symlinks,

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70632.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70632.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70632.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,68 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70631)
++++ src/registry2.0/portimage.tcl	(revision 70632)
+@@ -80,7 +80,6 @@
+     variable noexec
+     variable is_upgrade
+ 
+-    puts "GSOCDBG:\tactivate is_upgrade:$is_upgrade"
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         set force 1
+     }
+@@ -140,6 +139,7 @@
+             set changed_files [_check_config_files_changed $requested [$requested imagefiles] [$requested imagefiles_with_md5]]
+             if {$changed_files ne ""} {
+                 puts "GSOCDBG:\t_check_config_files_changed: - SKIPPING DEACTIVATE"
++                return -code error "Image error: run port upgrade -config-upgrade ${name}"
+             } else {
+                 if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+                     puts "GSOCDBG:\t\tactivate called deactivate via direct call"
+@@ -223,7 +223,6 @@
+     variable use_reg2
+     variable is_upgrade
+ 
+-    puts "GSOCDBG:\tdeactivate is_upgrade:$is_upgrade"
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         # this not using the namespace variable is correct, since activate
+         # needs to be able to force deactivate independently of whether
+@@ -411,19 +410,13 @@
+ ## @return  1 if config files of port changed, 0 otherwise
+ proc _check_config_files_changed {port files files_with_md5} {
+     set changed_files [list]
+-    puts "GSOCDBG:\tentering _check_config_files_changed"
+-    puts "GSOCDBG:\t\tfiles:$files"
+     foreach file $files {
+         if { [file isfile $file] && [is_config_file $file]} {
+-            puts "GSOCDBG:\tfirst if"
+             if {[catch {md5 file "$file"} actual_md5] == 0} {
+-                puts "GSOCDBG:\tsecond if"
+                 set stored_md5 [dict get $files_with_md5 $file]                
+                 if {[string equal -nocase $actual_md5 $stored_md5]} {
+-                    puts "GSOCDBG:\tthird if"
+                     puts "GSOCDBG:\t\tnot modified file:$file"
+                 } else {
+-                    puts "GSOCDBG:\tthird if - else"
+                     puts "GSOCDBG:\t\tmodified file:$file"
+                     lappend changed_files  $file
+                 }
+@@ -434,7 +427,6 @@
+             puts "GSOCDBG:\t\telement:$file is not of type file"
+         }
+     }
+-    puts "GSOCDBG:\texiting _check_config_files_changed\t changed_files:$changed_files"
+     return $changed_files
+ }
+ 
+@@ -468,11 +460,9 @@
+             ui_debug "activating file: $dstfile"           
+             # copy config files rather than hardlink them
+             if { [is_config_file $dstfile]} {
+-                puts "GSOCDBG:\t\tcopying $srcfile to $dstfile as it is a config file"
+                 ui_debug "copying $srcfile to $dstfile as it is a config file"
+                 file copy $srcfile $dstfile
+             } else {
+-                puts "GSOCDBG:\tlinking $srcfile to $dstfile"
+                 # Try a hard link first and if that fails, a symlink
+                 if {[catch {file link -hard $dstfile $srcfile}]} {
+                     ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70633.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70633.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70633.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,13 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70632)
++++ src/registry2.0/portimage.tcl	(revision 70633)
+@@ -139,7 +139,7 @@
+             set changed_files [_check_config_files_changed $requested [$requested imagefiles] [$requested imagefiles_with_md5]]
+             if {$changed_files ne ""} {
+                 puts "GSOCDBG:\t_check_config_files_changed: - SKIPPING DEACTIVATE"
+-                return -code error "Image error: run port upgrade -config-upgrade ${name}"
++                throw registry::image-error "Image error: run port upgrade -config-upgrade ${name}"
+             } else {
+                 if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+                     puts "GSOCDBG:\t\tactivate called deactivate via direct call"

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70637.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70637.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70637.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,14 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70636)
++++ src/registry2.0/portimage.tcl	(revision 70637)
+@@ -139,7 +139,8 @@
+             set changed_files [_check_config_files_changed $requested [$requested imagefiles] [$requested imagefiles_with_md5]]
+             if {$changed_files ne ""} {
+                 puts "GSOCDBG:\t_check_config_files_changed: - SKIPPING DEACTIVATE"
+-                throw registry::image-error "Image error: run port upgrade -config-upgrade ${name}"
++                return -code error "Image error: run port upgrade -config-upgrade ${name}"
++                #throw registry::image-error "Image error: run port upgrade -config-upgrade ${name}"
+             } else {
+                 if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+                     puts "GSOCDBG:\t\tactivate called deactivate via direct call"

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70638.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70638.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70638.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,50 @@
+Index: src/port/port.tcl
+===================================================================
+--- src/port/port.tcl	(revision 70637)
++++ src/port/port.tcl	(revision 70638)
+@@ -3870,7 +3870,7 @@
+     lint        {nitpick}
+     select      {list set show}
+     log         {{phase 1} {level 1}}
+-    upgrade     {force enforce-variants no-replace}
++    upgrade     {force enforce-variants no-replace config-upgrade}
+ }
+ 
+ ##
+Index: src/port/port-help.tcl
+===================================================================
+--- src/port/port-help.tcl	(revision 70637)
++++ src/port/port-help.tcl	(revision 70638)
+@@ -339,6 +339,7 @@
+                     upgrade even if the port is not outdated.
+ --no-replace        Do not replace one port with another according to the
+                     replaced_by field
++--config-upgrade    Handles changes in config files during upgrade
+ }
+ 
+ set porthelp(url) {
+Index: src/macports1.0/macports.tcl
+===================================================================
+--- src/macports1.0/macports.tcl	(revision 70637)
++++ src/macports1.0/macports.tcl	(revision 70638)
+@@ -2831,6 +2831,8 @@
+ # upgrade API wrapper procedure
+ # return codes: 0 = success, 1 = general failure, 2 = port name not found in index
+ proc macports::upgrade {portname dspec variationslist optionslist {depscachename ""}} {
++    array set options $optionslist
++    
+     # only installed ports can be upgraded
+     if {![registry::entry_exists_for_name $portname]} {
+         ui_error "$portname is not installed"
+@@ -2848,6 +2850,11 @@
+         set orig_nodeps no
+     }
+     
++    if {[info exists options(ports_upgrade_config-upgrade)] && $options(ports_upgrade_config-upgrade) eq "yes"} {
++        puts "GSOCDBG:\tport upgrade --config-upgrade | just exiting quietly (for now)"
++        return 0
++    }
++    
+     # run the actual upgrade
+     set status [macports::_upgrade $portname $dspec $variationslist $optionslist depscache]
+     

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70639.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70639.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70639.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,16 @@
+Index: src/macports1.0/macports.tcl
+===================================================================
+--- src/macports1.0/macports.tcl	(revision 70638)
++++ src/macports1.0/macports.tcl	(revision 70639)
+@@ -3302,7 +3302,10 @@
+         catch {mportclose $workername}
+         return 1
+     }
+-
++    # To quietly exit when config files are modified we could add manual
++    # $result handling here and avoid using -code error in portimage::activate
++    
++    
+     # Check if we have to do dependents
+     if {[info exists options(ports_do_dependents)]} {
+         # We do dependents ..

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70656.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70656.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70656.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,195 @@
+Index: src/registry2.0/registry_util.tcl
+===================================================================
+--- src/registry2.0/registry_util.tcl	(revision 70655)
++++ src/registry2.0/registry_util.tcl	(revision 70656)
+@@ -82,9 +82,6 @@
+ ## runs the given target of the given port using its stored portfile
+ ## @return   true if successful, false otherwise
+ proc run_target {port target options} {
+-    if {$target eq "deactivate"} {
+-        puts "GSOCDBG:\t\tactivate called deactivate via registry::"
+-    }
+     set portspec "[$port name] @[$port version]_[$port revision][$port variants]"
+     if {[$port portfile] == ""} {
+         ui_debug "no portfile in registry for $portspec"
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70655)
++++ src/registry2.0/portimage.tcl	(revision 70656)
+@@ -67,9 +67,9 @@
+ variable force 0
+ variable use_reg2 0
+ variable noexec 0
+-# This actually means that we're deactivate an installed port to activate \
+-    another version of the same port
+ variable is_upgrade 0
++variable config_upgrade_completed no
++variable upgrade_actions_list [list]
+ 
+ # Activate a "Port Image"
+ proc activate {name v optionslist} {
+@@ -79,7 +79,9 @@
+     variable use_reg2
+     variable noexec
+     variable is_upgrade
+-
++    variable config_upgrade_completed
++    variable upgrade_actions_list
++    
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         set force 1
+     }
+@@ -126,27 +128,28 @@
+         }
+         if {$todeactivate ne ""} {set is_upgrade 1}
+         foreach a $todeactivate {
+-            ## Moving _check_config_files here, this render "is_upgrade"
+-            ## variable useless
+-            ##
+-            ## We need to move the check up here as we have to keep track of
+-            ## both installed version and the version that is going to be
+-            ## installed
+-            ##
+-            ## At this point: $requested is registry::entry for the port to be
+-            ## installed $todeactivate is active version for same port
++            ## At this point $requested is registry::entry for the port to be
++            ## installed, $todeactivate is active version for same port            
++            set config_files_changed [_check_config_files_changed $requested [$requested imagefiles] [$requested imagefiles_with_md5]]
+             
+-            set changed_files [_check_config_files_changed $requested [$requested imagefiles] [$requested imagefiles_with_md5]]
+-            if {$changed_files ne ""} {
+-                puts "GSOCDBG:\t_check_config_files_changed: - SKIPPING DEACTIVATE"
+-                return -code error "Image error: run port upgrade -config-upgrade ${name}"
+-                #throw registry::image-error "Image error: run port upgrade -config-upgrade ${name}"
++            if {$config_files_changed ne "" && [info exists options(ports_upgrade_config-upgrade)] && $options(ports_upgrade_config-upgrade) eq "yes"} {
++                puts "GSOCDBG:\there goes _pick_config_upgrade_actions"
++                set upgrade_actions_list [_pick_config_upgrade_actions $config_files_changed]
+             } else {
+-                if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+-                    puts "GSOCDBG:\t\tactivate called deactivate via direct call"
+-                    deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
+-                }
++                set config_upgrade_completed "no"
+             }
++            
++            puts "GSOCDBG:\taction_list:$upgrade_actions_list"            
++            puts "GSOCDBG:\tconfig_files_changed:$config_files_changed"            
++            puts "GSOCDBG:\tconfig_upgrade_completed:$config_upgrade_completed"
++            
++            if {$is_upgrade && $config_files_changed ne "" && $config_upgrade_completed ne "yes"} {
++                return -code error "Image error: run port upgrade -config-upgrade ${name}"
++            }
++            
++            if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
++                deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
++            }
+         }
+     } else {
+         # registry1.0
+@@ -194,8 +197,8 @@
+ 
+     #activate new image
+     if {$use_reg2} {
+-        _activate_contents $requested
+-        $requested state installed
++            _activate_contents $requested
++            $requested state installed
+     } else {
+         set imagedir [registry::property_retrieve $ref imagedir]
+ 
+@@ -223,7 +226,9 @@
+     array set options $optionslist
+     variable use_reg2
+     variable is_upgrade
+-
++    variable config_upgrade_completed
++    variable upgrade_actions_list
++    
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         # this not using the namespace variable is correct, since activate
+         # needs to be able to force deactivate independently of whether
+@@ -412,7 +417,7 @@
+ proc _check_config_files_changed {port files files_with_md5} {
+     set changed_files [list]
+     foreach file $files {
+-        if { [file isfile $file] && [is_config_file $file]} {
++        if { [file isfile $file] && [_is_config_file $file]} {
+             if {[catch {md5 file "$file"} actual_md5] == 0} {
+                 set stored_md5 [dict get $files_with_md5 $file]                
+                 if {[string equal -nocase $actual_md5 $stored_md5]} {
+@@ -425,7 +430,7 @@
+             puts "couldn't catch md5"
+             }
+         } else {
+-            puts "GSOCDBG:\t\telement:$file is not of type file"
++            #element not of type file, can safely remove this else branch
+         }
+     }
+     return $changed_files
+@@ -460,7 +465,7 @@
+         default {
+             ui_debug "activating file: $dstfile"           
+             # copy config files rather than hardlink them
+-            if { [is_config_file $dstfile]} {
++            if { [_is_config_file $dstfile]} {
+                 ui_debug "copying $srcfile to $dstfile as it is a config file"
+                 file copy $srcfile $dstfile
+             } else {
+@@ -480,6 +485,9 @@
+     variable force
+     variable use_reg2
+     variable noexec
++    variable is_upgrade
++    variable config_upgrade_completed
++    variable upgrade_actions_list
+     global macports::prefix
+ 
+     set files [list]
+@@ -801,10 +809,30 @@
+     }
+ }
+ 
+-proc is_config_file {filename} {
++proc _is_config_file {filename} {
+     #replace hardcoded path with $config_path from portmain.tcl, what namespace does "option" add options to?
+     if {[string match ${::macports::prefix}/etc* "$filename"]} {return 1} {return 0}
+ }
+ 
++proc _pick_config_upgrade_actions {changed_files} {
++    variable config_upgrade_completed
++    
++    set actions_list [list]
++    foreach file $changed_files {
++        puts "File $file changed";
++        set choice ""
++        set answered "no"
++        while {[lsearch "keep new diff" $choice] < 0} { 
++            if {$answered eq "yes"} { puts "\nWrong entry, please choose one of keep | new | diff \n" }
++            puts "Choose one of (keep) current, install (new), show (diff):"
++            gets stdin choice
++            set answered "yes"
++        }
++        lappend actions_list "$file $choice"
++    }
++    set config_upgrade_completed "yes"
++    return $actions_list
++}
++
+ # End of portimage namespace
+ }
+Index: src/macports1.0/macports.tcl
+===================================================================
+--- src/macports1.0/macports.tcl	(revision 70655)
++++ src/macports1.0/macports.tcl	(revision 70656)
+@@ -2850,11 +2850,6 @@
+         set orig_nodeps no
+     }
+     
+-    if {[info exists options(ports_upgrade_config-upgrade)] && $options(ports_upgrade_config-upgrade) eq "yes"} {
+-        puts "GSOCDBG:\tport upgrade --config-upgrade | just exiting quietly (for now)"
+-        return 0
+-    }
+-    
+     # run the actual upgrade
+     set status [macports::_upgrade $portname $dspec $variationslist $optionslist depscache]
+     

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70664.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70664.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70664.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,264 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70663)
++++ src/registry2.0/portimage.tcl	(revision 70664)
+@@ -67,9 +67,10 @@
+ variable force 0
+ variable use_reg2 0
+ variable noexec 0
+-variable is_upgrade 0
++variable is_upgrade no
+ variable config_upgrade_completed no
+ variable upgrade_actions_list [list]
++variable changed_config_files [list]
+ 
+ # Activate a "Port Image"
+ proc activate {name v optionslist} {
+@@ -81,6 +82,7 @@
+     variable is_upgrade
+     variable config_upgrade_completed
+     variable upgrade_actions_list
++    variable changed_config_files
+     
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         set force 1
+@@ -126,25 +128,24 @@
+                 return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
+             }
+         }
+-        if {$todeactivate ne ""} {set is_upgrade 1}
++        if {$todeactivate ne ""} {set is_upgrade "yes"}
+         foreach a $todeactivate {
+             ## At this point $requested is registry::entry for the port to be
+             ## installed, $todeactivate is active version for same port            
+-            set config_files_changed [_check_config_files_changed $requested [$requested imagefiles] [$requested imagefiles_with_md5]]
+-            
+-            if {$config_files_changed ne "" && [info exists options(ports_upgrade_config-upgrade)] && $options(ports_upgrade_config-upgrade) eq "yes"} {
++            set changed_config_files [_check_config_files_changed $requested [$requested imagefiles] [$requested imagefiles_with_md5]]
++            if {$changed_config_files ne "" && [info exists options(ports_upgrade_config-upgrade)] && $options(ports_upgrade_config-upgrade) eq "yes"} {
+                 puts "GSOCDBG:\there goes _pick_config_upgrade_actions"
+-                set upgrade_actions_list [_pick_config_upgrade_actions $config_files_changed]
++                set upgrade_actions_list [_pick_config_upgrade_actions $requested $a $changed_config_files]
+             } else {
+                 set config_upgrade_completed "no"
+             }
+             
+             puts "GSOCDBG:\taction_list:$upgrade_actions_list"            
+-            puts "GSOCDBG:\tconfig_files_changed:$config_files_changed"            
++            puts "GSOCDBG:\tchanged_config_files:$changed_config_files"            
+             puts "GSOCDBG:\tconfig_upgrade_completed:$config_upgrade_completed"
+             
+-            if {$is_upgrade && $config_files_changed ne "" && $config_upgrade_completed ne "yes"} {
+-                return -code error "Image error: run port upgrade -config-upgrade ${name}"
++            if {$is_upgrade && $changed_config_files ne "" && $config_upgrade_completed ne "yes"} {
++                return -code error "Image error: run     port uninstall ${name} @${version}_${revision}${variants}; port upgrade --config-upgrade ${name}"
+             }
+             
+             if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+@@ -228,6 +229,7 @@
+     variable is_upgrade
+     variable config_upgrade_completed
+     variable upgrade_actions_list
++    variable changed_config_files
+     
+     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
+         # this not using the namespace variable is correct, since activate
+@@ -443,6 +445,11 @@
+ ## @param [in] dstfile path to activate file to
+ ## @return 1 if file needs to be explicitly deleted if we have to roll back, 0 otherwise
+ proc _activate_file {srcfile dstfile} {
++    variable is_upgrade
++    variable upgrade_actions_list
++    variable changed_config_files
++    array set actions "$upgrade_actions_list"
++    
+     switch [file type $srcfile] {
+         link {
+             ui_debug "activating link: $dstfile"
+@@ -464,17 +471,24 @@
+         }
+         default {
+             ui_debug "activating file: $dstfile"           
+-            # copy config files rather than hardlink them
+-            if { [_is_config_file $dstfile]} {
+-                ui_debug "copying $srcfile to $dstfile as it is a config file"
+-                file copy $srcfile $dstfile
+-            } else {
+-                # Try a hard link first and if that fails, a symlink
+-                if {[catch {file link -hard $dstfile $srcfile}]} {
+-                    ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"
+-                    file link -symbolic $dstfile $srcfile
++            puts "GSOCDBG: _activate_file"
++            puts "GSOCDBG:\tis_upgrade:$is_upgrade"
++            puts "GSOCDBG:\t\[info exists actions($dstfile)\]:[info exists actions($dstfile)]"
++            if {[info exists actions($dstfile)]} {puts "GSOCDBG:\t\$actions(\$dstfile):$actions($dstfile) should be 'new'"}
++            #if {!$is_upgrade || [info exists action($dstfile)] && $actions($dstfile) eq "new"} {
++                puts "GSOCDBG:\t\t\tdeactivating file: $dstfile"
++                if { [_is_config_file $dstfile]} {
++                    ui_debug "copying $srcfile to $dstfile as it is a config file"
++                    # copy config files rather than hardlink them
++                    file copy $srcfile $dstfile
++                } else {
++                    # Try a hard link first and if that fails, a symlink
++                    if {[catch {file link -hard $dstfile $srcfile}]} {
++                        ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"
++                        file link -symbolic $dstfile $srcfile
++                    }
+                 }
+-            }
++            #}                        
+             return 1
+         }
+     }
+@@ -488,6 +502,8 @@
+     variable is_upgrade
+     variable config_upgrade_completed
+     variable upgrade_actions_list
++    variable changed_config_files
++    array set actions "$upgrade_actions_list"
+     global macports::prefix
+ 
+     set files [list]
+@@ -495,10 +511,22 @@
+     if {$use_reg2} {
+         set imagedir [$port location]
+         set imagefiles [$port imagefiles]
++
++        puts "GSOCDBG:imagefiles:$imagefiles"
++        foreach file $imagefiles {
++            puts "GSOCDBG:\t\t\tchecking file:$file"
++            if {$is_upgrade && [info exists actions($file)] && $actions($file) eq "keep"} {
++                puts "GSOCDBG:\t\t\tskipping check for file:$file"
++                set num [lsearch $imagefiles $file]
++                set imagefiles [lreplace $imagefiles $num $num]
++                continue
++            }
++        }
++        puts "GSOCDBG:imagefiles:$imagefiles"
+     } else {
+         set name $port
+     }
+-
++    puts "GSOCDBG:\t\t_activate_contents"
+     set backups [list]
+     # This is big and hairy and probably could be done better.
+     # First, we need to check the source file, make sure it exists
+@@ -520,7 +548,7 @@
+                     if { [catch {file lstat $srcfile dummystatvar}] } {
+                         throw registry::image-error "Image error: Source file $srcfile does not appear to exist (cannot lstat it).  Unable to activate port [$port name]."
+                     }
+-
++                    
+                     set owner [registry::entry owner $file]
+ 
+                     if {$owner != {} && $owner != $port} {
+@@ -528,7 +556,6 @@
+                         set result [mportlookup [$owner name]]
+                         array unset portinfo
+                         array set portinfo [lindex $result 1]
+-                        #here we'll check if you should replace a config file testing a --drop-config option from CLI
+                         if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^[$port name]\$"] != -1} {
+                             # we'll deactivate the owner later, but before activating our files
+                             set todeactivate($owner) yes
+@@ -742,6 +769,11 @@
+ }
+ 
+ proc _deactivate_file {dstfile} {
++    variable is_upgrade
++    variable upgrade_actions_list
++    variable changed_config_files
++    array set actions "$upgrade_actions_list"
++    
+     if { [file type $dstfile] == "link" } {
+         ui_debug "deactivating link: $dstfile"
+         file delete -- $dstfile
+@@ -754,15 +786,28 @@
+             ui_debug "$dstfile is not empty"
+         }
+     } else {
+-        ui_debug "deactivating file: $dstfile"
+-        file delete -- $dstfile
++        puts "GSOCDBG: _deactivate_file"
++        puts "GSOCDBG:\tis_upgrade:$is_upgrade"
++        puts "GSOCDBG:\t\[info exists actions($dstfile)\]:[info exists actions($dstfile)]"
++        if {[info exists actions($dstfile)]} {puts "GSOCDBG:\t\$actions(\$dstfile):$actions($dstfile) should be 'keep')"}
++       # if {!$is_upgrade && [info exists action($dstfile)] && $actions($dstfile) eq "new"} {    
++            puts "GSOCDBG:\t\t\tdeactivating file: $dstfile"
++            ui_debug "deactivating file: $dstfile"
++            file delete -- $dstfile
++        #}
+     }
+ }
+ 
+ proc _deactivate_contents {port imagefiles {imagefiles_with_md5 {}} {force 0} {rollback 0}} {
+     variable use_reg2
++    variable is_upgrade
++    variable upgrade_actions_list
++    variable changed_config_files
++    array set actions "$upgrade_actions_list"
+     set files [list]
+ 
++    puts "GSOCDBG:_deactivate_contents"
++    puts "GSOCDBG:\timagefiles:$imagefiles"
+     foreach file $imagefiles {
+         if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } {
+             # Normalize the file path to avoid removing the intermediate
+@@ -776,6 +821,15 @@
+             # The custom realpath proc is necessary because file normalize
+             # does not resolve symlinks on OS X < 10.6
+             set directory [realpath [file dirname $file]]
++
++            puts "GSOCDBG:\t\t\tchecking file:$file"
++            puts "GSOCDBG:\t\t\t\$is_upgrade:$is_upgrade"
++            puts "GSOCDBG:\t\t\t\[info exists actions($file)\]:[info exists actions($file)]"
++            if {[info exists actions($file)]} {puts "GSOCDBG:\t\t\t\$actions($file):$actions($file)"}
++            if {$is_upgrade && [info exists actions($file)] && $actions($file) eq "keep"} {
++                puts "GSOCDBG:\t\t\tskipping check for file:$file"
++                continue
++            }
+             lappend files [file join $directory [file tail $file]]
+ 
+             # Split out the filename's subpaths and add them to the image list
+@@ -788,7 +842,7 @@
+             ui_debug "$file does not exist."
+         }
+     }
+-
++    puts "GSOCDBG:\tfiles:$files"
+     # Sort the list in reverse order, removing duplicates.
+     # Since the list is sorted in reverse order, we're sure that directories
+     # are after their elements.
+@@ -814,21 +868,24 @@
+     if {[string match ${::macports::prefix}/etc* "$filename"]} {return 1} {return 0}
+ }
+ 
+-proc _pick_config_upgrade_actions {changed_files} {
++proc _pick_config_upgrade_actions {requested active changed_files} {
+     variable config_upgrade_completed
+-    
++
++    puts "GSOCDBG:\trequested:$requested";
++    puts "GSOCDBG:\trequested:$active";
+     set actions_list [list]
+     foreach file $changed_files {
+-        puts "File $file changed";
++        puts "\nFile $file changed";
+         set choice ""
+-        set answered "no"
+-        while {[lsearch "keep new diff" $choice] < 0} { 
+-            if {$answered eq "yes"} { puts "\nWrong entry, please choose one of keep | new | diff \n" }
+-            puts "Choose one of (keep) current, install (new), show (diff):"
++        while {[lsearch "keep new" $choice] < 0} { 
++            if {$choice eq "diff"} {
++                puts "GSOCDBG: showing diff"
++            }
++            puts "\nPlease choose one of (keep) current, install (new), show (diff):"
+             gets stdin choice
+-            set answered "yes"
+         }
+-        lappend actions_list "$file $choice"
++        lappend actions_list "$file" 
++        lappend actions_list "$choice"
+     }
+     set config_upgrade_completed "yes"
+     return $actions_list

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70665.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70665.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70665.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,170 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70664)
++++ src/registry2.0/portimage.tcl	(revision 70665)
+@@ -134,16 +134,11 @@
+             ## installed, $todeactivate is active version for same port            
+             set changed_config_files [_check_config_files_changed $requested [$requested imagefiles] [$requested imagefiles_with_md5]]
+             if {$changed_config_files ne "" && [info exists options(ports_upgrade_config-upgrade)] && $options(ports_upgrade_config-upgrade) eq "yes"} {
+-                puts "GSOCDBG:\there goes _pick_config_upgrade_actions"
+                 set upgrade_actions_list [_pick_config_upgrade_actions $requested $a $changed_config_files]
+             } else {
+                 set config_upgrade_completed "no"
+             }
+             
+-            puts "GSOCDBG:\taction_list:$upgrade_actions_list"            
+-            puts "GSOCDBG:\tchanged_config_files:$changed_config_files"            
+-            puts "GSOCDBG:\tconfig_upgrade_completed:$config_upgrade_completed"
+-            
+             if {$is_upgrade && $changed_config_files ne "" && $config_upgrade_completed ne "yes"} {
+                 return -code error "Image error: run     port uninstall ${name} @${version}_${revision}${variants}; port upgrade --config-upgrade ${name}"
+             }
+@@ -423,9 +418,9 @@
+             if {[catch {md5 file "$file"} actual_md5] == 0} {
+                 set stored_md5 [dict get $files_with_md5 $file]                
+                 if {[string equal -nocase $actual_md5 $stored_md5]} {
+-                    puts "GSOCDBG:\t\tnot modified file:$file"
++                    ui_debug "config file:$file not modified"
+                 } else {
+-                    puts "GSOCDBG:\t\tmodified file:$file"
++                    ui_debug "config file:$file modified"
+                     lappend changed_files  $file
+                 }
+             } else {
+@@ -471,24 +466,17 @@
+         }
+         default {
+             ui_debug "activating file: $dstfile"           
+-            puts "GSOCDBG: _activate_file"
+-            puts "GSOCDBG:\tis_upgrade:$is_upgrade"
+-            puts "GSOCDBG:\t\[info exists actions($dstfile)\]:[info exists actions($dstfile)]"
+-            if {[info exists actions($dstfile)]} {puts "GSOCDBG:\t\$actions(\$dstfile):$actions($dstfile) should be 'new'"}
+-            #if {!$is_upgrade || [info exists action($dstfile)] && $actions($dstfile) eq "new"} {
+-                puts "GSOCDBG:\t\t\tdeactivating file: $dstfile"
+-                if { [_is_config_file $dstfile]} {
+-                    ui_debug "copying $srcfile to $dstfile as it is a config file"
+-                    # copy config files rather than hardlink them
+-                    file copy $srcfile $dstfile
+-                } else {
+-                    # Try a hard link first and if that fails, a symlink
+-                    if {[catch {file link -hard $dstfile $srcfile}]} {
+-                        ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"
+-                        file link -symbolic $dstfile $srcfile
+-                    }
++            if { [_is_config_file $dstfile]} {
++                ui_debug "copying $srcfile to $dstfile as it is a config file"
++                # copy config files rather than hardlink them
++                file copy $srcfile $dstfile
++            } else {
++                # Try a hard link first and if that fails, a symlink
++                if {[catch {file link -hard $dstfile $srcfile}]} {
++                    ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"
++                    file link -symbolic $dstfile $srcfile
+                 }
+-            #}                        
++            }
+             return 1
+         }
+     }
+@@ -512,21 +500,17 @@
+         set imagedir [$port location]
+         set imagefiles [$port imagefiles]
+ 
+-        puts "GSOCDBG:imagefiles:$imagefiles"
+         foreach file $imagefiles {
+-            puts "GSOCDBG:\t\t\tchecking file:$file"
+             if {$is_upgrade && [info exists actions($file)] && $actions($file) eq "keep"} {
+-                puts "GSOCDBG:\t\t\tskipping check for file:$file"
++                ui_debug "skipping activation for config file:$file"
+                 set num [lsearch $imagefiles $file]
+                 set imagefiles [lreplace $imagefiles $num $num]
+                 continue
+             }
+         }
+-        puts "GSOCDBG:imagefiles:$imagefiles"
+     } else {
+         set name $port
+     }
+-    puts "GSOCDBG:\t\t_activate_contents"
+     set backups [list]
+     # This is big and hairy and probably could be done better.
+     # First, we need to check the source file, make sure it exists
+@@ -786,15 +770,8 @@
+             ui_debug "$dstfile is not empty"
+         }
+     } else {
+-        puts "GSOCDBG: _deactivate_file"
+-        puts "GSOCDBG:\tis_upgrade:$is_upgrade"
+-        puts "GSOCDBG:\t\[info exists actions($dstfile)\]:[info exists actions($dstfile)]"
+-        if {[info exists actions($dstfile)]} {puts "GSOCDBG:\t\$actions(\$dstfile):$actions($dstfile) should be 'keep')"}
+-       # if {!$is_upgrade && [info exists action($dstfile)] && $actions($dstfile) eq "new"} {    
+-            puts "GSOCDBG:\t\t\tdeactivating file: $dstfile"
+-            ui_debug "deactivating file: $dstfile"
+-            file delete -- $dstfile
+-        #}
++        ui_debug "deactivating file: $dstfile"
++        file delete -- $dstfile
+     }
+ }
+ 
+@@ -806,8 +783,6 @@
+     array set actions "$upgrade_actions_list"
+     set files [list]
+ 
+-    puts "GSOCDBG:_deactivate_contents"
+-    puts "GSOCDBG:\timagefiles:$imagefiles"
+     foreach file $imagefiles {
+         if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } {
+             # Normalize the file path to avoid removing the intermediate
+@@ -822,12 +797,8 @@
+             # does not resolve symlinks on OS X < 10.6
+             set directory [realpath [file dirname $file]]
+ 
+-            puts "GSOCDBG:\t\t\tchecking file:$file"
+-            puts "GSOCDBG:\t\t\t\$is_upgrade:$is_upgrade"
+-            puts "GSOCDBG:\t\t\t\[info exists actions($file)\]:[info exists actions($file)]"
+-            if {[info exists actions($file)]} {puts "GSOCDBG:\t\t\t\$actions($file):$actions($file)"}
+             if {$is_upgrade && [info exists actions($file)] && $actions($file) eq "keep"} {
+-                puts "GSOCDBG:\t\t\tskipping check for file:$file"
++                ui_debug "skipping deactivation for config file:$file"
+                 continue
+             }
+             lappend files [file join $directory [file tail $file]]
+@@ -842,7 +813,6 @@
+             ui_debug "$file does not exist."
+         }
+     }
+-    puts "GSOCDBG:\tfiles:$files"
+     # Sort the list in reverse order, removing duplicates.
+     # Since the list is sorted in reverse order, we're sure that directories
+     # are after their elements.
+@@ -871,17 +841,23 @@
+ proc _pick_config_upgrade_actions {requested active changed_files} {
+     variable config_upgrade_completed
+ 
+-    puts "GSOCDBG:\trequested:$requested";
+-    puts "GSOCDBG:\trequested:$active";
+     set actions_list [list]
+     foreach file $changed_files {
+-        puts "\nFile $file changed";
++        ui_msg "$UI_PREFIX [format [msgcat::mc "    File %s changed"] $file]"
++        #puts "\nFile $file changed";
+         set choice ""
+         while {[lsearch "keep new" $choice] < 0} { 
+-            if {$choice eq "diff"} {
+-                puts "GSOCDBG: showing diff"
++            if {$choice eq "current"} {
++                #catch {exec /usr/bin/diff -u [] []} a
++                #set result [string range $a 0 [expr [string length $a]-33]]
++                #ui_msg "$result"
++            } elseif {$choice eq "upgraded"} {
++                #catch {exec /usr/bin/diff -u [] []} a
++                #set result [string range $a 0 [expr [string length $a]-33]]
++                #ui_msg "$result"                
+             }
+-            puts "\nPlease choose one of (keep) current, install (new), show (diff):"
++            ui_msg "$UI_PREFIX [format [msgcat::mc "    \nPlease choose one of (keep) current, install (new), show diff original-(current), show diff current-(upgraded):"] ]"
++            #puts "\nPlease choose one of (keep) current, install (new), show diff original-(current), show diff current-(upgraded):"
+             gets stdin choice
+         }
+         lappend actions_list "$file" 

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70666.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70666.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70666.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,28 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70665)
++++ src/registry2.0/portimage.tcl	(revision 70666)
+@@ -839,12 +839,12 @@
+ }
+ 
+ proc _pick_config_upgrade_actions {requested active changed_files} {
++    global UI_PREFIX
+     variable config_upgrade_completed
+ 
+     set actions_list [list]
+     foreach file $changed_files {
+-        ui_msg "$UI_PREFIX [format [msgcat::mc "    File %s changed"] $file]"
+-        #puts "\nFile $file changed";
++        ui_debug "File $file has changed"
+         set choice ""
+         while {[lsearch "keep new" $choice] < 0} { 
+             if {$choice eq "current"} {
+@@ -856,7 +856,7 @@
+                 #set result [string range $a 0 [expr [string length $a]-33]]
+                 #ui_msg "$result"                
+             }
+-            ui_msg "$UI_PREFIX [format [msgcat::mc "    \nPlease choose one of (keep) current, install (new), show diff original-(current), show diff current-(upgraded):"] ]"
++            ui_msg "$UI_PREFIX [format [msgcat::mc "Please choose one of (keep) current, install (new), show diff original-(current), show diff current-(upgraded):"] ]"
+             #puts "\nPlease choose one of (keep) current, install (new), show diff original-(current), show diff current-(upgraded):"
+             gets stdin choice
+         }

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70668.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70668.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70668.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,33 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70667)
++++ src/registry2.0/portimage.tcl	(revision 70668)
+@@ -842,19 +842,21 @@
+     global UI_PREFIX
+     variable config_upgrade_completed
+ 
++    set newimagedir [$requested location]
++    set oldimagedir [$active location]
+     set actions_list [list]
+     foreach file $changed_files {
+-        ui_debug "File $file has changed"
++        ui_msg "$UI_PREFIX [format [msgcat::mc "File %s has changed"] $file]"
+         set choice ""
+         while {[lsearch "keep new" $choice] < 0} { 
+             if {$choice eq "current"} {
+-                #catch {exec /usr/bin/diff -u [] []} a
+-                #set result [string range $a 0 [expr [string length $a]-33]]
+-                #ui_msg "$result"
++                catch {exec /usr/bin/diff -u $oldimagedir$file $file} a
++                set result [string range $a 0 [expr [string length $a]-33]]
++                ui_msg "\n$result\n"
+             } elseif {$choice eq "upgraded"} {
+-                #catch {exec /usr/bin/diff -u [] []} a
+-                #set result [string range $a 0 [expr [string length $a]-33]]
+-                #ui_msg "$result"                
++                catch {exec /usr/bin/diff -u $file $newimagedir$file} a
++                set result [string range $a 0 [expr [string length $a]-33]]
++                ui_msg "\n$result\n"                
+             }
+             ui_msg "$UI_PREFIX [format [msgcat::mc "Please choose one of (keep) current, install (new), show diff original-(current), show diff current-(upgraded):"] ]"
+             #puts "\nPlease choose one of (keep) current, install (new), show diff original-(current), show diff current-(upgraded):"

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70669.diff
===================================================================
--- branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70669.diff	                        (rev 0)
+++ branches/gsoc10-configfiles/code-submit/Andrea_D'Amore/r70669.diff	2010-09-05 12:32:36 UTC (rev 71225)
@@ -0,0 +1,13 @@
+Index: src/registry2.0/portimage.tcl
+===================================================================
+--- src/registry2.0/portimage.tcl	(revision 70668)
++++ src/registry2.0/portimage.tcl	(revision 70669)
+@@ -858,7 +858,7 @@
+                 set result [string range $a 0 [expr [string length $a]-33]]
+                 ui_msg "\n$result\n"                
+             }
+-            ui_msg "$UI_PREFIX [format [msgcat::mc "Please choose one of (keep) current, install (new), show diff original-(current), show diff current-(upgraded):"] ]"
++            ui_msg "$UI_PREFIX [format [msgcat::mc "Please choose one of:\n$UI_PREFIX\t(keep) current, install (new), show diff original-(current), show diff current-(upgraded):"] ]"
+             #puts "\nPlease choose one of (keep) current, install (new), show diff original-(current), show diff current-(upgraded):"
+             gets stdin choice
+         }

Added: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore.tar.bz2
===================================================================
(Binary files differ)


Property changes on: branches/gsoc10-configfiles/code-submit/Andrea_D'Amore.tar.bz2
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100905/632d66ed/attachment-0001.html>


More information about the macports-changes mailing list