Revision: 814 http://trac.macosforge.org/projects/darwinbuild/changeset/814 Author: wsiegrist@apple.com Date: 2010-04-20 14:19:34 -0700 (Tue, 20 Apr 2010) Log Message: ----------- Merge PR-6973110 Modified Paths: -------------- trunk/darwinbuild.xcodeproj/project.pbxproj trunk/darwinup/Archive.cpp trunk/darwinup/Database.cpp trunk/darwinup/Database.h trunk/darwinup/Depot.cpp trunk/darwinup/Utils.cpp Added Paths: ----------- trunk/darwinup/darwinup.1 Property Changed: ---------------- trunk/ trunk/darwinbuild/darwinbuild.in trunk/darwinbuild/darwinmaster.in trunk/darwinbuild/installXcode.in trunk/darwinbuild/packageRoots.in trunk/darwinbuild/thinPackages.in Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/PR-4841388:399-419 /branches/PR-6358021:442-443 /branches/PR-6392966:423-427 /branches/PR-6398060:433-434 /branches/PR-6493844:460-461 /branches/PR-6497694:466-468,471 /branches/PR-6634286:632-650 /branches/PR-6688645:479-490 /branches/PR-6722857:495-499 /branches/PR-6729491:655-664 /branches/PR-7250612:635-650 /branches/PR-7341154:682-694 /branches/PR-7431723:660-664 /branches/PR-7461534:650-664 /branches/PR-7482850:670-671 /branches/PR-7489777:676-731 /branches/PR-7529688:692-694 /branches/PR-7593824:739-772 /branches/PR-7598640:703-731 /branches/PR-7748469:777-785 /branches/PR-7765119:790-791 /branches/PR-7798586:796-799 + /branches/PR-4841388:399-419 /branches/PR-6358021:442-443 /branches/PR-6392966:423-427 /branches/PR-6398060:433-434 /branches/PR-6493844:460-461 /branches/PR-6497694:466-468,471 /branches/PR-6634286:632-650 /branches/PR-6688645:479-490 /branches/PR-6722857:495-499 /branches/PR-6729491:655-664 /branches/PR-6973110:804-813 /branches/PR-7250612:635-650 /branches/PR-7341154:682-694 /branches/PR-7431723:660-664 /branches/PR-7461534:650-664 /branches/PR-7482850:670-671 /branches/PR-7489777:676-731 /branches/PR-7529688:692-694 /branches/PR-7593824:739-772 /branches/PR-7598640:703-731 /branches/PR-7748469:777-785 /branches/PR-7765119:790-791 /branches/PR-7798586:796-799 Property changes on: trunk/darwinbuild/darwinbuild.in ___________________________________________________________________ Modified: svn:mergeinfo - /branches/PR-4841388/darwinbuild/darwinbuild:399-419 /branches/PR-6358021/darwinbuild/darwinbuild:442-443 /branches/PR-6392966/darwinbuild/darwinbuild:423-427 /branches/PR-6398060/darwinbuild/darwinbuild:433-434 /branches/PR-6493844/darwinbuild/darwinbuild.in:460-461 /branches/PR-6497694/darwinbuild/darwinbuild.in:466-468,471 /branches/PR-6634286/darwinbuild/darwinbuild.in:632-650 /branches/PR-6688645/darwinbuild/darwinbuild.in:479-490 /branches/PR-6722857/darwinbuild/darwinbuild.in:495-499 /branches/PR-6729491/darwinbuild/darwinbuild.in:655-664 /branches/PR-7250612/darwinbuild/darwinbuild.in:635-650 /branches/PR-7341154/darwinbuild/darwinbuild.in:682-694 /branches/PR-7431723/darwinbuild/darwinbuild.in:660-664 /branches/PR-7461534/darwinbuild/darwinbuild.in:650-664 /branches/PR-7489777/darwinbuild/darwinbuild.in:676-731 /branches/PR-7529688/darwinbuild/darwinbuild.in:692-694 /branches/PR-7593824/darwinbuild/darwinbuild.in:739-772 /branches/PR-7598640/darwinbuild/darwinbuild.in:703-731 /branches/PR-7748469/darwinbuild/darwinbuild.in:777-785 /branches/PR-7765119/darwinbuild/darwinbuild.in:790-791 /branches/PR-7798586/darwinbuild/darwinbuild.in:796-799 + /branches/PR-4841388/darwinbuild/darwinbuild:399-419 /branches/PR-6358021/darwinbuild/darwinbuild:442-443 /branches/PR-6392966/darwinbuild/darwinbuild:423-427 /branches/PR-6398060/darwinbuild/darwinbuild:433-434 /branches/PR-6493844/darwinbuild/darwinbuild.in:460-461 /branches/PR-6497694/darwinbuild/darwinbuild.in:466-468,471 /branches/PR-6634286/darwinbuild/darwinbuild.in:632-650 /branches/PR-6688645/darwinbuild/darwinbuild.in:479-490 /branches/PR-6722857/darwinbuild/darwinbuild.in:495-499 /branches/PR-6729491/darwinbuild/darwinbuild.in:655-664 /branches/PR-6973110/darwinbuild/darwinbuild.in:804-813 /branches/PR-7250612/darwinbuild/darwinbuild.in:635-650 /branches/PR-7341154/darwinbuild/darwinbuild.in:682-694 /branches/PR-7431723/darwinbuild/darwinbuild.in:660-664 /branches/PR-7461534/darwinbuild/darwinbuild.in:650-664 /branches/PR-7489777/darwinbuild/darwinbuild.in:676-731 /branches/PR-7529688/darwinbuild/darwinbuild.in:692-694 /branches/PR-7593824/darwinbuild/darwinbuild.in:739-772 /branches/PR-7598640/darwinbuild/darwinbuild.in:703-731 /branches/PR-7748469/darwinbuild/darwinbuild.in:777-785 /branches/PR-7765119/darwinbuild/darwinbuild.in:790-791 /branches/PR-7798586/darwinbuild/darwinbuild.in:796-799 Property changes on: trunk/darwinbuild/darwinmaster.in ___________________________________________________________________ Modified: svn:mergeinfo - /branches/PR-4841388/darwinbuild/darwinmaster.sh:399-419 /branches/PR-6358021/darwinbuild/darwinmaster.sh:442-443 /branches/PR-6392966/darwinbuild/darwinmaster.sh:423-427 /branches/PR-6398060/darwinbuild/darwinmaster.sh:433-434 /branches/PR-6493844/darwinbuild/darwinmaster.sh.in:460-461 /branches/PR-6497694/darwinbuild/darwinmaster.sh.in:466-468,471 /branches/PR-6634286/darwinbuild/darwinmaster.in:632-650 /branches/PR-6688645/darwinbuild/darwinmaster.sh.in:479-490 /branches/PR-6722857/darwinbuild/darwinmaster.sh.in:495-499 /branches/PR-6729491/darwinbuild/darwinmaster.in:655-664 /branches/PR-7250612/darwinbuild/darwinmaster.in:635-650 /branches/PR-7341154/darwinbuild/darwinmaster.in:682-694 /branches/PR-7431723/darwinbuild/darwinmaster.in:660-664 /branches/PR-7461534/darwinbuild/darwinmaster.in:650-664 /branches/PR-7489777/darwinbuild/darwinmaster.in:676-731 /branches/PR-7529688/darwinbuild/darwinmaster.in:692-694 /branches/PR-7593824/darwinbuild/darwinmaster.in:739-772 /branches/PR-7598640/darwinbuild/darwinmaster.in:703-731 /branches/PR-7748469/darwinbuild/darwinmaster.in:777-785 /branches/PR-7765119/darwinbuild/darwinmaster.in:790-791 /branches/PR-7798586/darwinbuild/darwinmaster.in:796-799 + /branches/PR-4841388/darwinbuild/darwinmaster.sh:399-419 /branches/PR-6358021/darwinbuild/darwinmaster.sh:442-443 /branches/PR-6392966/darwinbuild/darwinmaster.sh:423-427 /branches/PR-6398060/darwinbuild/darwinmaster.sh:433-434 /branches/PR-6493844/darwinbuild/darwinmaster.sh.in:460-461 /branches/PR-6497694/darwinbuild/darwinmaster.sh.in:466-468,471 /branches/PR-6634286/darwinbuild/darwinmaster.in:632-650 /branches/PR-6688645/darwinbuild/darwinmaster.sh.in:479-490 /branches/PR-6722857/darwinbuild/darwinmaster.sh.in:495-499 /branches/PR-6729491/darwinbuild/darwinmaster.in:655-664 /branches/PR-6973110/darwinbuild/darwinmaster.in:804-813 /branches/PR-7250612/darwinbuild/darwinmaster.in:635-650 /branches/PR-7341154/darwinbuild/darwinmaster.in:682-694 /branches/PR-7431723/darwinbuild/darwinmaster.in:660-664 /branches/PR-7461534/darwinbuild/darwinmaster.in:650-664 /branches/PR-7489777/darwinbuild/darwinmaster.in:676-731 /branches/PR-7529688/darwinbuild/darwinmaster.in:692-694 /branches/PR-7593824/darwinbuild/darwinmaster.in:739-772 /branches/PR-7598640/darwinbuild/darwinmaster.in:703-731 /branches/PR-7748469/darwinbuild/darwinmaster.in:777-785 /branches/PR-7765119/darwinbuild/darwinmaster.in:790-791 /branches/PR-7798586/darwinbuild/darwinmaster.in:796-799 Property changes on: trunk/darwinbuild/installXcode.in ___________________________________________________________________ Modified: svn:mergeinfo - /branches/PR-4841388/darwinbuild/installXcode:399-419 /branches/PR-6358021/darwinbuild/installXcode:442-443 /branches/PR-6392966/darwinbuild/installXcode:423-427 /branches/PR-6398060/darwinbuild/installXcode:433-434 /branches/PR-6493844/darwinbuild/installXcode.in:460-461 /branches/PR-6497694/darwinbuild/installXcode.in:466-468,471 /branches/PR-6634286/darwinbuild/installXcode.in:632-650 /branches/PR-6688645/darwinbuild/installXcode.in:479-490 /branches/PR-6722857/darwinbuild/installXcode.in:495-499 /branches/PR-6729491/darwinbuild/installXcode.in:655-664 /branches/PR-7250612/darwinbuild/installXcode.in:635-650 /branches/PR-7341154/darwinbuild/installXcode.in:682-694 /branches/PR-7431723/darwinbuild/installXcode.in:660-664 /branches/PR-7461534/darwinbuild/installXcode.in:650-664 /branches/PR-7489777/darwinbuild/installXcode.in:676-731 /branches/PR-7529688/darwinbuild/installXcode.in:692-694 /branches/PR-7593824/darwinbuild/installXcode.in:739-772 /branches/PR-7598640/darwinbuild/installXcode.in:703-731 /branches/PR-7748469/darwinbuild/installXcode.in:777-785 /branches/PR-7765119/darwinbuild/installXcode.in:790-791 /branches/PR-7798586/darwinbuild/installXcode.in:796-799 + /branches/PR-4841388/darwinbuild/installXcode:399-419 /branches/PR-6358021/darwinbuild/installXcode:442-443 /branches/PR-6392966/darwinbuild/installXcode:423-427 /branches/PR-6398060/darwinbuild/installXcode:433-434 /branches/PR-6493844/darwinbuild/installXcode.in:460-461 /branches/PR-6497694/darwinbuild/installXcode.in:466-468,471 /branches/PR-6634286/darwinbuild/installXcode.in:632-650 /branches/PR-6688645/darwinbuild/installXcode.in:479-490 /branches/PR-6722857/darwinbuild/installXcode.in:495-499 /branches/PR-6729491/darwinbuild/installXcode.in:655-664 /branches/PR-6973110/darwinbuild/installXcode.in:804-813 /branches/PR-7250612/darwinbuild/installXcode.in:635-650 /branches/PR-7341154/darwinbuild/installXcode.in:682-694 /branches/PR-7431723/darwinbuild/installXcode.in:660-664 /branches/PR-7461534/darwinbuild/installXcode.in:650-664 /branches/PR-7489777/darwinbuild/installXcode.in:676-731 /branches/PR-7529688/darwinbuild/installXcode.in:692-694 /branches/PR-7593824/darwinbuild/installXcode.in:739-772 /branches/PR-7598640/darwinbuild/installXcode.in:703-731 /branches/PR-7748469/darwinbuild/installXcode.in:777-785 /branches/PR-7765119/darwinbuild/installXcode.in:790-791 /branches/PR-7798586/darwinbuild/installXcode.in:796-799 Property changes on: trunk/darwinbuild/packageRoots.in ___________________________________________________________________ Modified: svn:mergeinfo - /branches/PR-4841388/darwinbuild/packageRoots.sh:399-419 /branches/PR-6358021/darwinbuild/packageRoots.sh:442-443 /branches/PR-6392966/darwinbuild/packageRoots.sh:423-427 /branches/PR-6398060/darwinbuild/packageRoots.sh:433-434 /branches/PR-6493844/darwinbuild/packageRoots.sh.in:460-461 /branches/PR-6497694/darwinbuild/packageRoots.sh.in:466-468,471 /branches/PR-6634286/darwinbuild/packageRoots.in:632-650 /branches/PR-6688645/darwinbuild/packageRoots.sh.in:479-490 /branches/PR-6722857/darwinbuild/packageRoots.sh.in:495-499 /branches/PR-6729491/darwinbuild/packageRoots.in:655-664 /branches/PR-7250612/darwinbuild/packageRoots.in:635-650 /branches/PR-7341154/darwinbuild/packageRoots.in:682-694 /branches/PR-7431723/darwinbuild/packageRoots.in:660-664 /branches/PR-7461534/darwinbuild/packageRoots.in:650-664 /branches/PR-7489777/darwinbuild/packageRoots.in:676-731 /branches/PR-7529688/darwinbuild/packageRoots.in:692-694 /branches/PR-7593824/darwinbuild/packageRoots.in:739-772 /branches/PR-7598640/darwinbuild/packageRoots.in:703-731 /branches/PR-7748469/darwinbuild/packageRoots.in:777-785 /branches/PR-7765119/darwinbuild/packageRoots.in:790-791 /branches/PR-7798586/darwinbuild/packageRoots.in:796-799 + /branches/PR-4841388/darwinbuild/packageRoots.sh:399-419 /branches/PR-6358021/darwinbuild/packageRoots.sh:442-443 /branches/PR-6392966/darwinbuild/packageRoots.sh:423-427 /branches/PR-6398060/darwinbuild/packageRoots.sh:433-434 /branches/PR-6493844/darwinbuild/packageRoots.sh.in:460-461 /branches/PR-6497694/darwinbuild/packageRoots.sh.in:466-468,471 /branches/PR-6634286/darwinbuild/packageRoots.in:632-650 /branches/PR-6688645/darwinbuild/packageRoots.sh.in:479-490 /branches/PR-6722857/darwinbuild/packageRoots.sh.in:495-499 /branches/PR-6729491/darwinbuild/packageRoots.in:655-664 /branches/PR-6973110/darwinbuild/packageRoots.in:804-813 /branches/PR-7250612/darwinbuild/packageRoots.in:635-650 /branches/PR-7341154/darwinbuild/packageRoots.in:682-694 /branches/PR-7431723/darwinbuild/packageRoots.in:660-664 /branches/PR-7461534/darwinbuild/packageRoots.in:650-664 /branches/PR-7489777/darwinbuild/packageRoots.in:676-731 /branches/PR-7529688/darwinbuild/packageRoots.in:692-694 /branches/PR-7593824/darwinbuild/packageRoots.in:739-772 /branches/PR-7598640/darwinbuild/packageRoots.in:703-731 /branches/PR-7748469/darwinbuild/packageRoots.in:777-785 /branches/PR-7765119/darwinbuild/packageRoots.in:790-791 /branches/PR-7798586/darwinbuild/packageRoots.in:796-799 Property changes on: trunk/darwinbuild/thinPackages.in ___________________________________________________________________ Modified: svn:mergeinfo - /branches/PR-4841388/darwinbuild/thinPackages.sh:399-419 /branches/PR-6358021/darwinbuild/thinPackages.sh:442-443 /branches/PR-6392966/darwinbuild/thinPackages.sh:423-427 /branches/PR-6398060/darwinbuild/thinPackages.sh:433-434 /branches/PR-6493844/darwinbuild/thinPackages.sh.in:460-461 /branches/PR-6497694/darwinbuild/thinPackages.sh.in:466-468,471 /branches/PR-6634286/darwinbuild/thinPackages.in:632-650 /branches/PR-6688645/darwinbuild/thinPackages.sh.in:479-490 /branches/PR-6722857/darwinbuild/thinPackages.sh.in:495-499 /branches/PR-6729491/darwinbuild/thinPackages.in:655-664 /branches/PR-7250612/darwinbuild/thinPackages.in:635-650 /branches/PR-7341154/darwinbuild/thinPackages.in:682-694 /branches/PR-7431723/darwinbuild/thinPackages.in:660-664 /branches/PR-7461534/darwinbuild/thinPackages.in:650-664 /branches/PR-7489777/darwinbuild/thinPackages.in:676-731 /branches/PR-7529688/darwinbuild/thinPackages.in:692-694 /branches/PR-7593824/darwinbuild/thinPackages.in:739-772 /branches/PR-7598640/darwinbuild/thinPackages.in:703-731 /branches/PR-7748469/darwinbuild/thinPackages.in:777-785 /branches/PR-7765119/darwinbuild/thinPackages.in:790-791 /branches/PR-7798586/darwinbuild/thinPackages.in:796-799 + /branches/PR-4841388/darwinbuild/thinPackages.sh:399-419 /branches/PR-6358021/darwinbuild/thinPackages.sh:442-443 /branches/PR-6392966/darwinbuild/thinPackages.sh:423-427 /branches/PR-6398060/darwinbuild/thinPackages.sh:433-434 /branches/PR-6493844/darwinbuild/thinPackages.sh.in:460-461 /branches/PR-6497694/darwinbuild/thinPackages.sh.in:466-468,471 /branches/PR-6634286/darwinbuild/thinPackages.in:632-650 /branches/PR-6688645/darwinbuild/thinPackages.sh.in:479-490 /branches/PR-6722857/darwinbuild/thinPackages.sh.in:495-499 /branches/PR-6729491/darwinbuild/thinPackages.in:655-664 /branches/PR-6973110/darwinbuild/thinPackages.in:804-813 /branches/PR-7250612/darwinbuild/thinPackages.in:635-650 /branches/PR-7341154/darwinbuild/thinPackages.in:682-694 /branches/PR-7431723/darwinbuild/thinPackages.in:660-664 /branches/PR-7461534/darwinbuild/thinPackages.in:650-664 /branches/PR-7489777/darwinbuild/thinPackages.in:676-731 /branches/PR-7529688/darwinbuild/thinPackages.in:692-694 /branches/PR-7593824/darwinbuild/thinPackages.in:739-772 /branches/PR-7598640/darwinbuild/thinPackages.in:703-731 /branches/PR-7748469/darwinbuild/thinPackages.in:777-785 /branches/PR-7765119/darwinbuild/thinPackages.in:790-791 /branches/PR-7798586/darwinbuild/thinPackages.in:796-799 Modified: trunk/darwinbuild.xcodeproj/project.pbxproj =================================================================== --- trunk/darwinbuild.xcodeproj/project.pbxproj 2010-04-19 23:32:00 UTC (rev 813) +++ trunk/darwinbuild.xcodeproj/project.pbxproj 2010-04-20 21:19:34 UTC (rev 814) @@ -167,6 +167,7 @@ DFC9772D11138F9400CAE084 /* Column.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFC9772711138F9400CAE084 /* Column.cpp */; }; DFC9772E11138F9400CAE084 /* Database.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFC9772911138F9400CAE084 /* Database.cpp */; }; DFC9772F11138F9400CAE084 /* Table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFC9772B11138F9400CAE084 /* Table.cpp */; }; + DFCAA3C61178E1A1008DCF37 /* darwinup.1 in Install Manpage */ = {isa = PBXBuildFile; fileRef = DFCAA39C1178E05B008DCF37 /* darwinup.1 */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -629,6 +630,17 @@ ); runOnlyForDeploymentPostprocessing = 1; }; + DFCAA3C51178E10E008DCF37 /* Install Manpage */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = "$(DATDIR)/man/man1"; + dstSubfolderSpec = 0; + files = ( + DFCAA3C61178E1A1008DCF37 /* darwinup.1 in Install Manpage */, + ); + name = "Install Manpage"; + runOnlyForDeploymentPostprocessing = 1; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -753,6 +765,7 @@ DFC9772A11138F9400CAE084 /* Database.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Database.h; path = darwinup/Database.h; sourceTree = "<group>"; }; DFC9772B11138F9400CAE084 /* Table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Table.cpp; path = darwinup/Table.cpp; sourceTree = "<group>"; }; DFC9772C11138F9400CAE084 /* Table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Table.h; path = darwinup/Table.h; sourceTree = "<group>"; }; + DFCAA39C1178E05B008DCF37 /* darwinup.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; name = darwinup.1; path = darwinup/darwinup.1; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1018,6 +1031,7 @@ 72C86BD710965DD800C66E90 /* darwinup */ = { isa = PBXGroup; children = ( + DFCAA39C1178E05B008DCF37 /* darwinup.1 */, DFC9772711138F9400CAE084 /* Column.cpp */, DFC9772811138F9400CAE084 /* Column.h */, DFC9772911138F9400CAE084 /* Database.cpp */, @@ -1679,6 +1693,7 @@ buildPhases = ( 72C86C451096609500C66E90 /* Sources */, 72C86C461096609500C66E90 /* Frameworks */, + DFCAA3C51178E10E008DCF37 /* Install Manpage */, ); buildRules = ( ); Modified: trunk/darwinup/Archive.cpp =================================================================== --- trunk/darwinup/Archive.cpp 2010-04-19 23:32:00 UTC (rev 813) +++ trunk/darwinup/Archive.cpp 2010-04-20 21:19:34 UTC (rev 814) @@ -281,16 +281,26 @@ return NULL; } } else if (is_userhost_path(path)) { - actpath = fetch_userhost(path, tmppath); + char* cleanpath; + // join with / to ensure all single slashes and a single trailing slash + int res = join_path(&cleanpath, path, "/"); + assert(res==0); + size_t pathlen = strlen(cleanpath); + // remove trailing slash so rsync behavior is predictable + cleanpath[pathlen - 1] = '\0'; + + IF_DEBUG("fetching userhost path from: %s to: %s \n", cleanpath, tmppath); + actpath = fetch_userhost(cleanpath, tmppath); + IF_DEBUG("fetched %s \n", actpath); if (!actpath) { fprintf(stderr, "Error: could not fetch remote file from: %s \n", path); return NULL; } + free(cleanpath); } else { actpath = (char *)path; } - // make sure the archive exists struct stat sb; int res = stat(actpath, &sb); @@ -328,7 +338,7 @@ } else { fprintf(stderr, "Error: unknown archive type: %s\n", path); } - + if (actpath && actpath != path) free(actpath); return archive; } Modified: trunk/darwinup/Database.cpp =================================================================== --- trunk/darwinup/Database.cpp 2010-04-19 23:32:00 UTC (rev 813) +++ trunk/darwinup/Database.cpp 2010-04-20 21:19:34 UTC (rev 814) @@ -121,8 +121,22 @@ fprintf(stderr, "Error: pre-connection failed.\n"); return res; } - + + // test our access level int exists = is_regular_file(m_path); + bool readonly = false; + if (!exists && access(dirname(m_path), W_OK | X_OK)) { + // does not exist and we cannot write to the directory + fprintf(stderr, + "Error: Unable to create new darwinup database. " + "Try running as root."); + return DB_ERROR; + } + if (exists && access(m_path, W_OK)) { + // db exists already but we cannot write to it + readonly = true; + } + res = sqlite3_open(m_path, &m_db); if (res) { sqlite3_close(m_db); @@ -137,7 +151,7 @@ fprintf(stderr, "Error: post-connection failed.\n"); return res; } - + if (!exists) { // create schema since it is empty assert(this->create_tables() == 0); @@ -150,12 +164,23 @@ } if (version < this->m_schema_version) { + if (readonly) { + fprintf(stderr, + "Error: the darwinup database needs to be upgraded " + "but darwinup cannot write to database. " + "Try running as root.\n"); + sqlite3_close(m_db); + m_db = NULL; + return DB_ERROR; + } IF_DEBUG("Upgrading schema from %u to %u \n", version, this->m_schema_version); assert(this->upgrade_schema(version) == 0); assert(this->set_schema_version(this->m_schema_version) == 0); } if (version > this->m_schema_version) { fprintf(stderr, "Error: this client is too old!\n"); + sqlite3_close(m_db); + m_db = NULL; return DB_ERROR; } } @@ -203,6 +228,10 @@ return this->connect(); } +bool Database::is_connected() { + return m_db != NULL; +} + int Database::begin_transaction() { return this->execute(m_begin_transaction); } Modified: trunk/darwinup/Database.h =================================================================== --- trunk/darwinup/Database.h 2010-04-19 23:32:00 UTC (rev 813) +++ trunk/darwinup/Database.h 2010-04-20 21:19:34 UTC (rev 814) @@ -136,6 +136,7 @@ const char* error(); int connect(); int connect(const char* path); + bool is_connected(); int begin_transaction(); int rollback_transaction(); Modified: trunk/darwinup/Depot.cpp =================================================================== --- trunk/darwinup/Depot.cpp 2010-04-19 23:32:00 UTC (rev 813) +++ trunk/darwinup/Depot.cpp 2010-04-20 21:19:34 UTC (rev 814) @@ -98,8 +98,8 @@ int Depot::connect() { m_db = new DarwinupDatabase(m_database_path); - if (!m_db) { - fprintf(stderr, "Error: unable to connect to database in Depot::connect().\n"); + if (!m_db || !m_db->is_connected()) { + fprintf(stderr, "Error: unable to connect to database.\n"); return 1; } return 0; Modified: trunk/darwinup/Utils.cpp =================================================================== --- trunk/darwinup/Utils.cpp 2010-04-19 23:32:00 UTC (rev 813) +++ trunk/darwinup/Utils.cpp 2010-04-20 21:19:34 UTC (rev 814) @@ -257,18 +257,28 @@ char* fetch_userhost(const char* srcpath, const char* dstpath) { extern uint32_t verbosity; + char* localfile; int res = join_path(&localfile, dstpath, basename((char*)srcpath)); if (!localfile) return NULL; + + // make sure dstpath has a trailing slash + char* cleanpath; + res = join_path(&cleanpath, dstpath, "/"); + if (!cleanpath) return NULL; + IF_DEBUG("rsync %s %s %s \n", (verbosity ? "-v" : "-q"), srcpath, cleanpath); + const char* args[] = { "/usr/bin/rsync", (verbosity ? "-v" : "-q"), - "-a", srcpath, - localfile, + "-a", "--delete", + srcpath, + cleanpath, NULL }; + free(cleanpath); if (res == 0) res = exec_with_args(args); if (res == 0) return localfile; return NULL; Copied: trunk/darwinup/darwinup.1 (from rev 813, branches/PR-6973110/darwinup/darwinup.1) =================================================================== --- trunk/darwinup/darwinup.1 (rev 0) +++ trunk/darwinup/darwinup.1 2010-04-20 21:19:34 UTC (rev 814) @@ -0,0 +1,232 @@ +.ig +Copyright (c) 2010 Apple Inc. All rights reserved. +@APPLE_BSD_LICENSE_HEADER_START@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +@APPLE_BSD_LICENSE_HEADER_END@ +.. +.Dd 16 Apr, 2010 +.Dt darwinup 1 +.Os Darwin +.Sh NAME +.Nm darwinup +.Nd Install, uninstall, and manage roots +.Sh SYNOPSIS +.Nm +.Op Fl dfnv +.Op Fl p Ar path +.Ar subcommand +.Op Ar arguments ... +.Sh DESCRIPTION +.Nm +allows you to manage roots, or +archives, of files that replace parts of your system. This is useful +for installing a new version of a library or tool on your system while +allowing you to uninstall the files and revert back to the originals +safely and easily. +.Sh OPTIONS +.Bl -tag -width -indent +.It \-d +Do not update dyld cache. Darwinup normally runs update_dyld_shared_cache +if the operation actually changes files on disk. To ensure this does not +happen, you can provide this option. +.It \-f +Force. Some operations will fail gracefully due to potentially unsafe +situations, such as a root that installs a file where a directory is. +In order to have darwinup continue through such a situation, you can +pass the -f option. +.It \-n +Dry run. Darwinup will go through an operation, including analyzing +the root(s) and printing the state/change symbol, but no files will +be modified on your system and no records will be added to the depot. +.It \-p Op Ar path +Prefix path. Normally, darwinup will operate on the boot partition. You +can use the -p option to have darwinup work on another partition. You +can provide any arbitrary path, it does not need to be a mount point. +.It \-v +Verbose. This option causes darwinup to print extra information. You can +pass 2 or 3 v's for even more information, but that is usually only needed +for development and debugging of darwinup itself. +.El +.Sh SUBCOMMANDS +Note that the +.Ar path +and +.Ar archive +options listed below support globbing and multiple items. See the EXAMPLES +section below for more details. +.Bl -tag -width -indent +.It Ar files Ar archives +List the files and directories in the +.Ar archive . +.It Ar install Ar path +Install the root at +.Ar path . +.It Ar list Op Ar archive +List archives that are installed. You may optionally provide an +archive specification to limit which archives get listed. +.It Ar uninstall Ar archives +Uninstall the specified archive. +.It Ar upgrade Ar path +Find the last archive that was installed with the same name (basename of +path), and replace it with the root at +.Ar path . +.It Ar verify Ar archive +List all of the information about +.Ar archive . +This includes status letters +detailing how the archive differs from whats on disk +.El +.Sh STATE/CHANGE SYMBOLS +.Bl -tag -width -indent +.It ? +Unknown state. Probably a bug. +.It ! +Missing file during uninstall. Darwinup expected a file or directory to +exist, but it did not. This could be a bug in darwinup, but most likely +another tool or software update removed a file that darwinup had been +tracking. It can also be caused by an installation failing due to an +object changing type (see FORCING OPERATIONS below), and the subsequent +rollback finding the root only partially installed. Since these all +happen during uninstall, they are typically safe to ignore, since darwinup +was going to delete the object anyway. +.It A +Added. No previous file or directory existed so the file or directory was +added to your system. +.It E +External change. The file you are installing is different than the +last file you installed, but it is identical to what was actually found +on disk. This probably means something manually installed a root or software +update without darwinup knowing about it. This is usually harmless. +.It M +Mode change. Only changes to permission or ownership were needed to +uninstall the file or directory. +.It R +Removed. No previous file or directory existed, so the uninstall process +removed the file. +.It U +Updated. During installation, the file or directory replaces an existing +object at the same path. During uninstallation, the previous version of +the file was restored. +.El +.Sh SUPPORTED PATHS +.Bl -tag -width -indent +.It /path/to/local/file-or-directory +You can install files from one of your locally mounted filesystems. The path +can be a directory, in which case all files below it will be installed, or +it can be a archive file. The supported file formats are listed in the usage +statement, but typical formats are .tgz, .tbz2, or .zip. +.It user@host:/path/to/remote/file-or-directory +You can install files from a remote machine via rsync/ssh. The remote files +will be copied to your local depot and then installed like any other local +root. +.It http[s]://host/path/to/remote/file +You can install files from an archive hosted on an HTTP/HTTPS server. The +archive file will be downloaded using curl to your local depot and then +installed like any other local archive. You can not point darwinup at a +directory hosted via HTTP or HTTPS, only archive files such as tarballs. +.El +.Sh ARCHIVE SPECIFICATIONS +When running a subcommand which takes an +.Ar archive +argument, you can use one or more of the following items to specify which +archive to operate on. You can mix and match any of them as needed. +You can use the list subcommand with these specifications to see what will +match. +.Bl -tag -width -indent +.It Ar serial +You can specify an archive with its serial number, which can be found using +the list subcommand. +.It Ar uuid +You can specify an archive with its UUID, which can be found using the +list subcommand. +.It Ar name +You can specify an archive with its name, which can be found using the +list subcommand. +.It newest +The newest keyword will match the one archive which was most recently +installed. This should always be the first archive listed. +.It oldest +The oldest keyword will match the one archive which was installed the +longest time ago. This should always be the last archive listed. +.It superseded +The superseded keyword will match zero or more archives. An archive is +superseded if every file it contains is contained in an archive that was +(and still is) installed after it. A file in an archive can also be superseded +by external changes, such as operating system updates. When uninstalling a +superseded archive, you should never see any status symbols, since being +superseded means there is a newer file on disk. +.It all +The all keyword will match all archives. If you specify extra verbosity +with -vv, then rollback archives will also be matched by the all keyword. This +means that +.Nm darwinup -vv uninstall all +will attempt to uninstall rollback archives, which will print a message +about not being able to uninstall rollback archives. This is normal and +not a problem. +.El +.Sh FORCING OPERATIONS +There are 2 cases where darwinup will require you to pass the force (-f) +option before proceeding with an operation. +.Bl -tag -width -indent +.It Object Type Change +If you install an archive which contains a file with the same path as a +directory on your system, or vice versa, darwinup will give you a error +about not doing that unless you really want to force it. If you do force +the operation, darwinup will delete the existing object and replace it with +the object from the root. This can happen when a directory full of files +gets packaged up in some opaque file, like xibs/nibs. If you expect this +"type change", then it is probably safe to force the operation. +.It Uninstall a root from an older base system +Darwinup remembers the version (build) of the operating system when a root +is installed. The reason for this is darwinup saves the old (replaced) +files during the installation procedure. Those backups may have come from +the older operating system, and thus are not necessarily compatible with +the current build of the operating system. So if you try to uninstall an +archive that had been installed on a different version of the operating +system, darwinup will stop and provide a message asking you to force the +operation if you really want to. If the files you are uninstalling are all +superseded, then you should not get this error as the backup copies will +not be used anyway. +.El +.Sh EXAMPLES +.Bl -tag -width -indent +.It Install files from a tarball +$ darwinup install library-1.2.3.tar.gz +.It Install several directories from /tmp/ +$ darwinup install /tmp/*/*~dst/ +.It Uninstall everything +$ darwinup uninstall all +.It See what archives have been superseded and then uninstall them +$ darwinup list superseded +$ darwinup uninstall superseded +.It Uninstall several archives by serial, the oldest one, and one named myroot +$ darwinup uninstall 9 16 myroot oldest +.It Install a root from src.macosforge.org +$ darwinup install http://src.macosforge.org/Roots/10D573/zlib.root.tar.gz +.El +.Sh SEE ALSO +.Xr rsync 1 , +.Xr curl 1 , +.Xr tar 1 , +.Xr gzip 1 , +.Xr ditto 1 \ No newline at end of file
participants (1)
-
source_changes@macosforge.org