[CalendarServer-changes] [9504] CalendarServer/trunk/contrib/migration

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 27 12:38:13 PDT 2012


Revision: 9504
          http://trac.macosforge.org/projects/calendarserver/changeset/9504
Author:   sagen at apple.com
Date:     2012-07-27 12:38:10 -0700 (Fri, 27 Jul 2012)
Log Message:
-----------
Handle Lion -> MtnLion migration with non-standard ServerRoot location on the boot volume in order to resolve https://discussions.apple.com/message/19020164#19020164

Modified Paths:
--------------
    CalendarServer/trunk/contrib/migration/calendarmigrator.py
    CalendarServer/trunk/contrib/migration/test/test_migrator.py

Modified: CalendarServer/trunk/contrib/migration/calendarmigrator.py
===================================================================
--- CalendarServer/trunk/contrib/migration/calendarmigrator.py	2012-07-27 00:55:51 UTC (rev 9503)
+++ CalendarServer/trunk/contrib/migration/calendarmigrator.py	2012-07-27 19:38:10 UTC (rev 9504)
@@ -104,9 +104,9 @@
         help='path to the root of the new system',
         default='/')
 
-    optionParser.add_option('--language', choices=('en', 'fr', 'de', 'ja'),
-        metavar='[en|fr|de|ja]',
-        help='language identifier (IGNORED)')
+    optionParser.add_option('--language',
+        help='language identifier (IGNORED)',
+        default="en")
 
     (options, args) = optionParser.parse_args()
     log("Options: %s" % (options,))
@@ -590,7 +590,7 @@
         # /Library/Server/Calendar and Contacts will be new ServerRoot no matter what.
 
         if oldCalDocumentRootValueProcessed:
-            if diskAccessor.exists(oldCalDocumentRootValueProcessed): # external volume
+            if oldCalDocumentRootValueProcessed.startswith("/Volumes/"): # external volume
                 # The old external calendar DocumentRoot becomes the new DataRoot
                 newDataRoot = newDataRootValue = os.path.join(os.path.dirname(oldCalDocumentRootValue.rstrip("/")), "Calendar and Contacts Data")
                 newDocumentRoot = os.path.join(newDataRoot, newDocumentRootValue)
@@ -629,8 +629,7 @@
         # Old AddressBook DocumentRoot
         if oldABDocumentRootValue:
             newAddressBooks = os.path.join(newDocumentRoot, "addressbooks")
-            if diskAccessor.exists(oldABDocumentRootValue):
-                # Must be on an external volume if we see it existing at the point
+            if oldABDocumentRootValue.startswith("/Volumes/"): # external volume
                 diskAccessor.ditto(
                     os.path.join(oldABDocumentRootValue, "addressbooks"),
                     newAddressBooks
@@ -651,7 +650,7 @@
         # Before 10.8, DocumentRoot and DataRoot were relative to ServerRoot
 
         if oldServerRootValue:
-            if oldServerRootValue.rstrip("/") != NEW_SERVER_ROOT: # external volume
+            if oldServerRootValue.rstrip("/").startswith("/Volumes/"): # external volume
                 log("Using external calendar server root: %s" % (oldServerRootValue,))
                 # ServerRoot needs to be /Library/Server/Calendar and Contacts
                 # Since DocumentRoot is now relative to DataRoot, move DocumentRoot into DataRoot
@@ -699,7 +698,7 @@
     else: # 10.8 -> 10.8
 
         if oldServerRootValue:
-            if oldServerRootValue.rstrip("/") != NEW_SERVER_ROOT: # external volume
+            if oldServerRootValue.rstrip("/").startswith("/Volumes/"): # external volume
                 log("Using external calendar server root: %s" % (oldServerRootValue,))
             elif diskAccessor.exists(absolutePathWithRoot(sourceRoot, oldServerRootValue)):
                 log("Copying calendar server root: %s" % (newServerRoot,))

Modified: CalendarServer/trunk/contrib/migration/test/test_migrator.py
===================================================================
--- CalendarServer/trunk/contrib/migration/test/test_migrator.py	2012-07-27 00:55:51 UTC (rev 9503)
+++ CalendarServer/trunk/contrib/migration/test/test_migrator.py	2012-07-27 19:38:10 UTC (rev 9504)
@@ -1415,6 +1415,53 @@
         ),
 
         (
+            "Lion -> Mountain Lion Migration, ServerRoot is non-standard but also not on an external volume, e.g. /Library/CalendarServer/Documents",
+            {
+                "/Library/Server/Previous/private/etc/caldavd/caldavd.plist" : """
+                    <plist version="1.0">
+                    <dict>
+                        <key>ServerRoot</key>
+                        <string>/Library/CalendarServer/Documents</string>
+                        <key>DocumentRoot</key>
+                        <string>Documents</string>
+                        <key>DataRoot</key>
+                        <string>Data</string>
+                        <key>UserName</key>
+                        <string>calendar</string>
+                        <key>GroupName</key>
+                        <string>calendar</string>
+                    </dict>
+                    </plist>
+                """,
+
+                "/Library/Server/Previous/Library/CalendarServer/Documents/" : True,
+                "/Library/Server/Previous/Library/CalendarServer/Documents/Documents/" : True,
+                "/Library/Server/Previous/Library/CalendarServer/Documents/Data/" : True,
+            },
+            (   # args
+                "/Library/Server/Previous", # sourceRoot
+                "/Volumes/new", # targetRoot
+                "10.7.4", # sourceVersion
+                "/Library/CalendarServer/Documents", # oldServerRootValue
+                "Documents", # oldCalDocumentRootValue
+                "Data", # oldCalDataRootValue
+                None, # oldABDocumentRootValue
+                FakeUser.pw_uid, FakeGroup.gr_gid, # user id, group id
+            ),
+            (   # expected return values
+                "/Volumes/new/Library/Server/Calendar and Contacts",
+                "/Library/Server/Calendar and Contacts",
+                "Data",
+            ),
+            [
+                ('ditto', '/Library/Server/Previous/Library/CalendarServer/Documents', '/Volumes/new/Library/Server/Calendar and Contacts'),
+                ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts/Data'),
+                ('mkdir', '/Volumes/new/Library/Server/Calendar and Contacts/Data/Documents'),
+                ('chown-recursive', '/Volumes/new/Library/Server/Calendar and Contacts', FakeUser.pw_uid, FakeGroup.gr_gid),
+            ]
+        ),
+
+        (
             "Mountain Lion -> Mountain Lion Migration, all in default locations",
             {
                 "/Library/Server/Previous/private/etc/caldavd/caldavd.plist" : """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120727/717b6d68/attachment.html>


More information about the calendarserver-changes mailing list