[darwinbuild-changes] [899] trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 27 15:25:56 PDT 2010
Revision: 899
http://trac.macosforge.org/projects/darwinbuild/changeset/899
Author: wsiegrist at apple.com
Date: 2010-10-27 15:25:54 -0700 (Wed, 27 Oct 2010)
Log Message:
-----------
Merge PR-8488185
Modified Paths:
--------------
trunk/darwinup/Depot.cpp
trunk/darwinup/Depot.h
trunk/darwinup/darwinup.1
trunk/darwinup/main.cpp
trunk/testing/darwinup/run-tests.sh
Added Paths:
-----------
trunk/testing/darwinup/corrupt.tgz
trunk/testing/darwinup/depotroot.tar.gz
Property Changed:
----------------
trunk/
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-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
/branches/PR-7872907:830-840
/branches/PR-7935095:819-821
/branches/PR-8116613:849
/branches/PR-8279204:854-862
/branches/PR-8416637:870-880
/branches/PR-8486662:885-889
+ /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
/branches/PR-7872907:830-840
/branches/PR-7935095:819-821
/branches/PR-8116613:849
/branches/PR-8279204:854-862
/branches/PR-8416637:870-880
/branches/PR-8486662:885-889
/branches/PR-8488185:894-898
Modified: trunk/darwinup/Depot.cpp
===================================================================
--- trunk/darwinup/Depot.cpp 2010-10-26 20:52:23 UTC (rev 898)
+++ trunk/darwinup/Depot.cpp 2010-10-27 22:25:54 UTC (rev 899)
@@ -426,6 +426,12 @@
IF_DEBUG("[analyze] %s\n", file->path());
+ if (strcasestr(file->path(), ".DarwinDepot")) {
+ fprintf(stderr, "Error: Root contains a .DarwinDepot, "
+ "aborting to avoid damaging darwinup metadata.\n");
+ return DEPOT_ERROR;
+ }
+
// Perform a three-way-diff between the file to be installed (file),
// the file we last installed in this location (preceding),
// and the file that actually exists in this location (actual).
@@ -688,8 +694,9 @@
fprintf(stdout, "%s\n", uuid);
} else {
fprintf(stderr, "Error: Install failed.\n");
- if (res != DEPOT_OBJ_CHANGE) {
+ if (res != DEPOT_OBJ_CHANGE && res != DEPOT_PREINSTALL_ERR) {
// object change errors come from analyze stage,
+ // and pre-install errors happen early,
// so there is no installation to roll back
fprintf(stderr, "Rolling back installation.\n");
res = this->uninstall(archive);
@@ -763,6 +770,10 @@
remove_directory(rollback_path);
free(rollback_path);
free(archive_path);
+ if (!dryrun && res) {
+ this->rollback_transaction();
+ return DEPOT_PREINSTALL_ERR;
+ }
return res;
}
Modified: trunk/darwinup/Depot.h
===================================================================
--- trunk/darwinup/Depot.h 2010-10-26 20:52:23 UTC (rev 898)
+++ trunk/darwinup/Depot.h 2010-10-27 22:25:54 UTC (rev 899)
@@ -46,6 +46,7 @@
#define DEPOT_OBJ_CHANGE -4
#define DEPOT_BUILD_MISMATCH -5
#define DEPOT_USAGE_ERROR -6
+#define DEPOT_PREINSTALL_ERR -7
struct Archive;
Modified: trunk/darwinup/darwinup.1
===================================================================
--- trunk/darwinup/darwinup.1 2010-10-26 20:52:23 UTC (rev 898)
+++ trunk/darwinup/darwinup.1 2010-10-27 22:25:54 UTC (rev 899)
@@ -134,19 +134,19 @@
.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 at 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
+.It /path/to/file-or-directory
+You can install archive files or directories by specifying a relative or
+absolute path. If the path is a directory, all files below it will be
+installed as a single root. If the path points to a file, it must be one of
+the suported archive file types as described in the usage statement.
+.It user at host:/path/to/file-or-directory
+You can install files or directories from another host via rsync/ssh.
+The files/directories will be downloaded to your machine and then installed
+like any other root.
+.It http[s]://host/path/to/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
+archive file will be downloaded using curl to your machine and then
+installed like any other archive file. You can not point darwinup at a
directory hosted via HTTP or HTTPS, only archive files such as tarballs.
.El
.Sh ARCHIVE SPECIFICATIONS
Modified: trunk/darwinup/main.cpp
===================================================================
--- trunk/darwinup/main.cpp 2010-10-26 20:52:23 UTC (rev 898)
+++ trunk/darwinup/main.cpp 2010-10-27 22:25:54 UTC (rev 899)
@@ -211,7 +211,23 @@
for (int i = 1; i < argc && res == 0; i++) {
if (strcmp(argv[0], "install") == 0) {
if (i==1 && depot->initialize(true)) exit(13);
- res = depot->install(argv[i]);
+ // gaurd against installing paths ontop of themselves
+ if (strncmp(path, argv[i], strlen(argv[i])) == 0
+ && (strlen(path) == strlen(argv[i])
+ || strlen(path) - 1 == strlen(argv[i]))) {
+ if (strncmp(path, "/", 1) == 0 && strlen(path) == 1) {
+ fprintf(stderr, "Error: You provided '/' as a path to a root. "
+ "If you meant to specify a destination of '/', then you "
+ "just need to remove the '/' argument as the destination "
+ "defaults to '/'. Use the -p option to specify another "
+ "destination.\n");
+ } else {
+ fprintf(stderr, "Error: You cannot install the root at '%s' onto"
+ " itself.\n", path);
+ }
+ res = DEPOT_ERROR;
+ }
+ if (res == 0) res = depot->install(argv[i]);
} else if (strcmp(argv[0], "upgrade") == 0) {
if (i==1 && depot->initialize(true)) exit(14);
// find most recent matching archive by name
Copied: trunk/testing/darwinup/corrupt.tgz (from rev 898, branches/PR-8488185/testing/darwinup/corrupt.tgz)
===================================================================
--- trunk/testing/darwinup/corrupt.tgz (rev 0)
+++ trunk/testing/darwinup/corrupt.tgz 2010-10-27 22:25:54 UTC (rev 899)
@@ -0,0 +1,2 @@
+This is a text file. Darwinup will see the .tgz extension and try to use tar on it.
+This will fail, which allows us to test early failures from external tools (like ditto and tar).
Copied: trunk/testing/darwinup/depotroot.tar.gz (from rev 898, branches/PR-8488185/testing/darwinup/depotroot.tar.gz)
===================================================================
(Binary files differ)
Modified: trunk/testing/darwinup/run-tests.sh
===================================================================
--- trunk/testing/darwinup/run-tests.sh 2010-10-26 20:52:23 UTC (rev 898)
+++ trunk/testing/darwinup/run-tests.sh 2010-10-27 22:25:54 UTC (rev 899)
@@ -62,6 +62,9 @@
cp $R $PREFIX/
done;
+cp corrupt.tgz $PREFIX/
+cp depotroot.tar.gz $PREFIX/
+
mkdir -p $ORIG
cp -R $DEST/* $ORIG/
@@ -426,6 +429,33 @@
echo "========== Expected Failures =========="
set +e
+echo "========== TEST: testing early ditto failure ==========";
+
+$DARWINUP install $PREFIX/corrupt.tgz | tee $PREFIX/corrupt.log
+C=$(grep -c 'Rolling back' $PREFIX/corrupt.log)
+test $C -eq 0
+if [ $? -ne 0 ]; then exit 1; fi
+echo "DIFF: diffing original test files to dest (should be no diffs) ..."
+$DIFF $ORIG $DEST 2>&1
+if [ $? -ne 0 ]; then exit 1; fi
+
+echo "========== TEST: testing recursive install guards ==========";
+$DARWINUP install $PREFIX/depotroot.tar.gz
+if [ $? -ne 255 ]; then exit 1; fi
+echo "DIFF: diffing original test files to dest (should be no diffs) ..."
+$DIFF $ORIG $DEST 2>&1
+if [ $? -ne 0 ]; then exit 1; fi
+$DARWINUP install $DEST
+if [ $? -ne 255 ]; then exit 1; fi
+echo "DIFF: diffing original test files to dest (should be no diffs) ..."
+$DIFF $ORIG $DEST 2>&1
+if [ $? -ne 0 ]; then exit 1; fi
+darwinup $1 install /
+if [ $? -ne 255 ]; then exit 1; fi
+echo "DIFF: diffing original test files to dest (should be no diffs) ..."
+$DIFF $ORIG $DEST 2>&1
+if [ $? -ne 0 ]; then exit 1; fi
+
echo "========== TEST: Try replacing File with Directory =========="
$DARWINUP install $PREFIX/rep_file_dir
if [ $? -ne 255 ]; then exit 1; fi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20101027/8e7dd9d2/attachment-0001.html>
More information about the darwinbuild-changes
mailing list