[96466] branches/release_2_1/base

cal at macports.org cal at macports.org
Fri Aug 10 13:10:42 PDT 2012


Revision: 96466
          https://trac.macports.org/changeset/96466
Author:   cal at macports.org
Date:     2012-08-10 13:10:40 -0700 (Fri, 10 Aug 2012)
Log Message:
-----------
merge from trunk: 96136, 96137, 96399, 96400, 96401, #29223

Modified Paths:
--------------
    branches/release_2_1/base/ChangeLog
    branches/release_2_1/base/doc/port.1
    branches/release_2_1/base/src/port/port.tcl
    branches/release_2_1/base/src/port1.0/portutil.tcl
    branches/release_2_1/base/tests/Makefile

Added Paths:
-----------
    branches/release_2_1/base/tests/test/statefile-unknown-version/
    branches/release_2_1/base/tests/test/statefile-version1/
    branches/release_2_1/base/tests/test/statefile-version1-outdated/
    branches/release_2_1/base/tests/test/statefile-version2/
    branches/release_2_1/base/tests/test/statefile-version2-invalid/
    branches/release_2_1/base/tests/test/statefile-version2-outdated/

Property Changed:
----------------
    branches/release_2_1/base/
    branches/release_2_1/base/ChangeLog


Property changes on: branches/release_2_1/base
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/gsoc11-rev-upgrade/base:78828-88375
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:91825,91829,91834,92072,92342,92404,92546,92730,92785,92881,92903,92976,93062,93129,93153,93197,93250,93256,93258-93259,93261,93268,93274,93303,93339,93511-93512,93816,93962,95382,95438-95439,95480,95552,95616,95620,95873
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692
   + /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/gsoc11-rev-upgrade/base:78828-88375
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:91825,91829,91834,92072,92342,92404,92546,92730,92785,92881,92903,92976,93062,93129,93153,93197,93250,93256,93258-93259,93261,93268,93274,93303,93339,93511-93512,93816,93962,95382,95438-95439,95480,95552,95616,95620,95873,96136-96137,96399-96401
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692

Modified: branches/release_2_1/base/ChangeLog
===================================================================
--- branches/release_2_1/base/ChangeLog	2012-08-10 19:54:31 UTC (rev 96465)
+++ branches/release_2_1/base/ChangeLog	2012-08-10 20:10:40 UTC (rev 96466)
@@ -3,6 +3,12 @@
 # $Id$
 ###
 
+Release 2.1.3 (unreleased)
+    - Fixed a bug where a certain order of starting and aborting a build,
+      running selfupdate and continuing a build would resume building although
+      it should start from the beginning.
+      (#29223, cal in r96136, r96399, r96400)
+
 Release 2.1.2 (2012-07-26 by jmr):
     - Fixed autodetection of developer_dir with Xcode 4.4
       (#35150, mfeiri in r95552)


Property changes on: branches/release_2_1/base/ChangeLog
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/ChangeLog:37343-46937
/branches/gsoc09-logging/base/ChangeLog:51231-60371
/branches/gsoc11-rev-upgrade/base/ChangeLog:78828-88375
/branches/universal-sanity/base/ChangeLog:51872-52323
/branches/variant-descs-14482/base/ChangeLog:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base/ChangeLog:91825,91829,91834,92072,92342,92404,92546,92730,92785,92881,92903,93062,93129,93153,93197,93225,93250,93256,93268,93274,95439,95620,95873
/users/perry/base-bugs_and_notes/ChangeLog:45682-46060
/users/perry/base-select/ChangeLog:44044-44692
   + /branches/gsoc08-privileges/base/ChangeLog:37343-46937
/branches/gsoc09-logging/base/ChangeLog:51231-60371
/branches/gsoc11-rev-upgrade/base/ChangeLog:78828-88375
/branches/universal-sanity/base/ChangeLog:51872-52323
/branches/variant-descs-14482/base/ChangeLog:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base/ChangeLog:91825,91829,91834,92072,92342,92404,92546,92730,92785,92881,92903,93062,93129,93153,93197,93225,93250,93256,93268,93274,95439,95620,95873,96137,96399-96401
/users/perry/base-bugs_and_notes/ChangeLog:45682-46060
/users/perry/base-select/ChangeLog:44044-44692

Modified: branches/release_2_1/base/doc/port.1
===================================================================
--- branches/release_2_1/base/doc/port.1	2012-08-10 19:54:31 UTC (rev 96465)
+++ branches/release_2_1/base/doc/port.1	2012-08-10 20:10:40 UTC (rev 96466)
@@ -252,7 +252,7 @@
 .It Fl f
 force mode (ignore state file)
 .It Fl o
-honor state files older than Portfile
+honor state files even if the Portfile has been modified since (called -o because it used to mean "older")
 .It Fl s
 source-only mode (build and install from source, do not attempt to fetch binary archives)
 .It Fl b

Modified: branches/release_2_1/base/src/port/port.tcl
===================================================================
--- branches/release_2_1/base/src/port/port.tcl	2012-08-10 19:54:31 UTC (rev 96465)
+++ branches/release_2_1/base/src/port/port.tcl	2012-08-10 20:10:40 UTC (rev 96466)
@@ -4315,7 +4315,7 @@
                         set global_options(ports_force) yes
                     }
                     o {
-                        set global_options(ports_ignore_older) yes
+                        set global_options(ports_ignore_different) yes
                     }
                     n {
                         set global_options(ports_nodeps) yes

Modified: branches/release_2_1/base/src/port1.0/portutil.tcl
===================================================================
--- branches/release_2_1/base/src/port1.0/portutil.tcl	2012-08-10 19:54:31 UTC (rev 96465)
+++ branches/release_2_1/base/src/port1.0/portutil.tcl	2012-08-10 20:10:40 UTC (rev 96466)
@@ -1637,7 +1637,7 @@
 # open_statefile
 # open file to store name of completed targets
 proc open_statefile {args} {
-    global workpath worksymlink place_worksymlink subport portpath ports_ignore_older ports_dryrun \
+    global workpath worksymlink place_worksymlink subport portpath ports_ignore_different ports_dryrun \
            usealtworkpath altprefix env applications_dir subbuildpath
 
     if {$usealtworkpath} {
@@ -1680,22 +1680,75 @@
 
     # flock Portfile
     set statefile [file join $workpath .macports.${subport}.state]
+    set fresh_build yes
+    set checksum_portfile [sha256 file ${portpath}/Portfile]
     if {[file exists $statefile]} {
+        set fresh_build no
         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]} {
             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]} {
-            if {![tbool ports_dryrun]} {
-                ui_notice "Portfile changed since last build; discarding previous state."
-                chownAsRoot $subbuildpath
-                delete $workpath
-                file mkdir $workpath
-            } else {
-                ui_notice "Portfile changed since last build but not discarding previous state (dry run)"
+        if {![tbool ports_ignore_different]} {
+            # start by assuming the statefile is current
+            set portfile_changed no
+
+            # open the statefile, determine the statefile version
+            set readfd [open $statefile r]
+            set statefile_version 1
+            if {[get_statefile_value "version" $readfd result] != 0} {
+                set statefile_version $result
             }
+
+            # check for outdated statefiles depending on what version the
+            # statefile is; we explicitly support older statefiles here, because
+            # all previously built archives would be invalidated (e.g., when
+            # using mpkg) if we didn't
+            switch $statefile_version {
+                1 {
+                    # statefile version 1
+                    # this statefile doesn't have a checksum, fall back to
+                    # comparing the Portfile modification date with the
+                    # statefile modification date
+                    if {[file mtime $statefile] < [file mtime ${portpath}/Portfile]} {
+                        ui_debug "Statefile has version 1 and is older than Portfile"
+                        set portfile_changed yes
+                    }
+                }
+                2 {
+                    # statefile version 2
+                    # this statefile has a sha256 checksum of the Portfile in
+                    # the "checksum" key
+                    set checksum_statefile ""
+                    if {[get_statefile_value "checksum" $readfd checksum_statefile] == 0} {
+                        ui_warn "Statefile has version 2 but didn't contain a checksum"
+                        set portfile_changed yes
+                    } else {
+                        if {$checksum_portfile != $checksum_statefile} {
+                            ui_debug "Checksum recorded in statefile '$checksum_statefile' \
+                                differs from Portfile checksum '$checksum_portfile'"
+                            set portfile_changed yes
+                        }
+                    }
+                }
+                default {
+                    ui_warn "Unsupported statefile version '$statefile_version'"
+                    ui_warn "Please run 'port selfupdate' to update to the latest version of MacPorts"
+                }
+            }
+            if {[tbool portfile_changed]} {
+                if {![tbool ports_dryrun]} {
+                    ui_notice "Portfile changed since last build; discarding previous state."
+                    chownAsRoot $subbuildpath
+                    delete $workpath
+                    file mkdir $workpath
+                    set fresh_build yes
+                } else {
+                    ui_notice "Portfile changed since last build but not discarding previous state (dry run)"
+                }
+            }
+            close $readfd
         }
     } elseif {[tbool ports_dryrun]} {
         set statefile /dev/null
@@ -1715,9 +1768,28 @@
             }
         }
     }
+    if {[tbool fresh_build]} {
+        write_statefile "version" 2 $fd
+        write_statefile "checksum" $checksum_portfile $fd
+    }
     return $fd
 }
 
+# get_statefile_value
+# Check for a given $class in the statefile $fd and write the first match to
+# $result, if any. Returns 1 if a line matched, 0 otherwise
+proc get_statefile_value {class fd result} {
+    upvar $result upresult
+    seek $fd 0
+    while {[gets $fd line] >= 0} {
+        if {[regexp "$class: (.*)" $line match value]} {
+            set upresult $value
+            return 1
+        }
+    }
+    return 0
+}
+
 # check_statefile
 # Check completed/selected state of target/variant $name
 proc check_statefile {class name fd} {
@@ -1754,19 +1826,20 @@
 
     array set upoldvariations {}
 
-    seek $fd 0 end
-    if {[tell $fd] == 0} {
-        # Statefile is empty, skipping further tests
-        return 0
-    }
-
+    set variants_found no
     seek $fd 0
     while {[gets $fd line] >= 0} {
         if {[regexp "variant: (.*)" $line match name]} {
             set upoldvariations([string range $name 1 end]) [string range $name 0 0]
+            set variants_found yes
         }
     }
 
+    if {![tbool variants_found]} {
+        # Statefile is "empty", skipping further tests
+        return 0
+    }
+
     set mismatch 0
     if {[array size upoldvariations] != [array size upvariations]} {
         set mismatch 1

Modified: branches/release_2_1/base/tests/Makefile
===================================================================
--- branches/release_2_1/base/tests/Makefile	2012-08-10 19:54:31 UTC (rev 96465)
+++ branches/release_2_1/base/tests/Makefile	2012-08-10 20:10:40 UTC (rev 96466)
@@ -1,6 +1,6 @@
 include ../Mk/macports.autoconf.mk
 
-TESTS?=checksums-1 svn-and-patchsites envvariables site-tags trace universal universal-2 xcodeversion dependencies-c dependencies-d dependencies-e case-insensitive-deactivate variants
+TESTS?=checksums-1 svn-and-patchsites envvariables site-tags trace universal universal-2 xcodeversion dependencies-c dependencies-d dependencies-e case-insensitive-deactivate variants statefile-version1 statefile-version1-outdated statefile-version2 statefile-version2-outdated statefile-version2-invalid statefile-unknown-version
 
 PWD=$(shell pwd)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120810/196c8cbb/attachment.html>


More information about the macports-changes mailing list