<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[918] branches/PR-8817822</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/darwinbuild/changeset/918">918</a></dd>
<dt>Author</dt> <dd>wsiegrist@apple.com</dd>
<dt>Date</dt> <dd>2011-02-04 15:53:53 -0800 (Fri, 04 Feb 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Stop forcing all uninstall ops since this disabled the build check safety. Instead, we pass down the reverse_files flag to denote uninstall operations which allow type changes to happen. Add tests for the build check.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesPR8817822darwinupDepotcpp">branches/PR-8817822/darwinup/Depot.cpp</a></li>
<li><a href="#branchesPR8817822darwinupFilecpp">branches/PR-8817822/darwinup/File.cpp</a></li>
<li><a href="#branchesPR8817822darwinupFileh">branches/PR-8817822/darwinup/File.h</a></li>
<li><a href="#branchesPR8817822darwinupmaincpp">branches/PR-8817822/darwinup/main.cpp</a></li>
<li><a href="#branchesPR8817822testingdarwinupruntestssh">branches/PR-8817822/testing/darwinup/run-tests.sh</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesPR8817822darwinupDepotcpp"></a>
<div class="modfile"><h4>Modified: branches/PR-8817822/darwinup/Depot.cpp (917 => 918)</h4>
<pre class="diff"><span>
<span class="info">--- branches/PR-8817822/darwinup/Depot.cpp   2011-02-04 22:37:04 UTC (rev 917)
+++ branches/PR-8817822/darwinup/Depot.cpp      2011-02-04 23:53:53 UTC (rev 918)
</span><span class="lines">@@ -695,7 +695,9 @@
</span><span class="cx">  if (INFO_TEST(file->info(), FILE_INFO_INSTALL_DATA)) {
</span><span class="cx">          ++context->files_modified;
</span><span class="cx"> 
</span><del>-               res = file->install(context->depot->m_archives_path, context->depot->m_prefix);
</del><ins>+                res = file->install(context->depot->m_archives_path,
+                        context->depot->m_prefix,
+                        context->reverse_files);
</ins><span class="cx">   } else {
</span><span class="cx">          res = file->install_info(context->depot->m_prefix);
</span><span class="cx">  }
</span><span class="lines">@@ -947,11 +949,13 @@
</span><span class="cx">                                                  S_ISDIR(preceding->mode())) {
</span><span class="cx">                                                  // use rename instead of mkdir so children are restored
</span><span class="cx">                                                  res = preceding->dirrename(context->depot->m_archives_path, 
</span><del>-                                                                                                          context->depot->m_prefix);                                                     
</del><ins>+                                                                                                                       context->depot->m_prefix,
+                                         context->reverse_files);                                                   
</ins><span class="cx"> 
</span><span class="cx">                                          } else {
</span><span class="cx">                                                  res = preceding->install(context->depot->m_archives_path, 
</span><del>-                                                                                                        context->depot->m_prefix);                                                       
</del><ins>+                                                                                                                     context->depot->m_prefix,
+                                       context->reverse_files);
</ins><span class="cx">                                           }
</span><span class="cx">                                  }
</span><span class="cx">                          } else if (INFO_TEST(flags, FILE_INFO_MODE_DIFFERS) ||
</span></span></pre></div>
<a id="branchesPR8817822darwinupFilecpp"></a>
<div class="modfile"><h4>Modified: branches/PR-8817822/darwinup/File.cpp (917 => 918)</h4>
<pre class="diff"><span>
<span class="info">--- branches/PR-8817822/darwinup/File.cpp    2011-02-04 22:37:04 UTC (rev 917)
+++ branches/PR-8817822/darwinup/File.cpp       2011-02-04 23:53:53 UTC (rev 918)
</span><span class="lines">@@ -147,7 +147,7 @@
</span><span class="cx">  free(dig);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int File::install(const char* prefix, const char* dest) {
</del><ins>+int File::install(const char* prefix, const char* dest, bool uninstall) {
</ins><span class="cx">   extern uint32_t force;
</span><span class="cx">  int res = 0;
</span><span class="cx">  Archive* archive = this->archive();
</span><span class="lines">@@ -160,6 +160,10 @@
</span><span class="cx">  char* dstpath;
</span><span class="cx">  join_path(&dstpath, dest, path);
</span><span class="cx"> 
</span><ins>+  // object changes are expected for some uninstall operations,
+  // otherwise require force flag
+  bool allow_change = (uninstall || force);
+
</ins><span class="cx">   if (dirpath) {
</span><span class="cx">          ssize_t len = snprintf(srcpath, sizeof(srcpath), "%s/%s", dirpath, path);
</span><span class="cx">          if ((size_t)len > sizeof(srcpath)) {
</span><span class="lines">@@ -176,7 +180,7 @@
</span><span class="cx">                          if (is_directory(dirpath) == 0) {
</span><span class="cx">                                  IF_DEBUG("[install] File::install on-demand archive expansion\n");
</span><span class="cx">                                  res = archive->expand_directory(prefix);
</span><del>-                                       if (res == 0) res = this->install(prefix, dest);
</del><ins>+                                        if (res == 0) res = this->install(prefix, dest, uninstall);
</ins><span class="cx">                           } else {
</span><span class="cx">                                  // archive was already expanded, so
</span><span class="cx">                                  // the file is truly missing (worry).
</span><span class="lines">@@ -184,13 +188,13 @@
</span><span class="cx">                                  fprintf(stderr, "%s:%d: %s: %s (%d)\n", 
</span><span class="cx">                                                  __FILE__, __LINE__, srcpath, strerror(errno), errno);
</span><span class="cx">                          }
</span><del>-                       } else if (force && errno == ENOTDIR) {
</del><ins>+                        } else if (allow_change && errno == ENOTDIR) {
</ins><span class="cx">                           // a) some part of destination path does not exist
</span><span class="cx">                          // b) from is a directory, but to is not
</span><span class="cx">                          IF_DEBUG("[install] File::install ENOTDIR\n");
</span><span class="cx">                          fprintf(stderr, "%s:%d: %s: %s (%d)\n", 
</span><span class="cx">                                          __FILE__, __LINE__, dstpath, strerror(errno), errno);
</span><del>-                       } else if (force && errno == EISDIR) {
</del><ins>+                        } else if (allow_change && errno == EISDIR) {
</ins><span class="cx">                           // to is a directory, but from is not
</span><span class="cx">                          IF_DEBUG("[install] replacing directory with a file\n");
</span><span class="cx">                          IF_DEBUG("[install] removefile(%s)\n", dstpath);
</span><span class="lines">@@ -206,7 +210,7 @@
</span><span class="cx">                          if (res == -1) fprintf(stderr, "%s:%d: %s: %s (%d)\n",
</span><span class="cx">                                                                     __FILE__, __LINE__, dstpath, strerror(errno), 
</span><span class="cx">                                                                     errno);
</span><del>-                       } else if (force && errno == ENOTEMPTY) {
</del><ins>+                        } else if (allow_change && errno == ENOTEMPTY) {
</ins><span class="cx">                           // to is a directory and is not empty
</span><span class="cx">                          IF_DEBUG("[install] File::install ENOTEMPTY\n");
</span><span class="cx">                          fprintf(stderr, "%s:%d: %s: %s (%d)\n", 
</span><span class="lines">@@ -228,7 +232,7 @@
</span><span class="cx">  return res;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int File::dirrename(const char* prefix, const char* dest) {
</del><ins>+int File::dirrename(const char* prefix, const char* dest, bool uninstall) {
</ins><span class="cx">   // only used for directories
</span><span class="cx">  assert(0);
</span><span class="cx"> }
</span><span class="lines">@@ -345,15 +349,15 @@
</span><span class="cx">                                   Digest* digest) 
</span><span class="cx"> : File(serial, archive, info, path, mode, uid, gid, size, digest) {};
</span><span class="cx"> 
</span><del>-int Directory::install(const char* prefix, const char* dest) {
-       return this->_install(prefix, dest, false);
</del><ins>+int Directory::install(const char* prefix, const char* dest, bool uninstall) {
+       return this->_install(prefix, dest, uninstall, false);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int Directory::dirrename(const char* prefix, const char* dest) {
-       return this->_install(prefix, dest, true);   
</del><ins>+int Directory::dirrename(const char* prefix, const char* dest, bool uninstall) {
+       return this->_install(prefix, dest, uninstall, true);        
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int Directory::_install(const char* prefix, const char* dest, bool use_rename) {
</del><ins>+int Directory::_install(const char* prefix, const char* dest, bool uninstall, bool use_rename) {
</ins><span class="cx">   // We create a new directory instead of renaming the
</span><span class="cx">  // existing one, since that would move the entire
</span><span class="cx">  // sub-tree, and lead to a lot of ENOENT errors.
</span><span class="lines">@@ -362,6 +366,10 @@
</span><span class="cx">  char* dstpath;
</span><span class="cx">  join_path(&dstpath, dest, this->path());
</span><span class="cx">  
</span><ins>+  // object changes are expected for some uninstall operations,
+  // otherwise require force flag
+  bool allow_change = (uninstall || force);
+
</ins><span class="cx">   mode_t mode = this->mode() & ALLPERMS;
</span><span class="cx">  uid_t uid = this->uid();
</span><span class="cx">  gid_t gid = this->gid();
</span><span class="lines">@@ -403,7 +411,7 @@
</span><span class="cx">                  if (res == -1) fprintf(stderr, "%s:%d: %s: %s (%d)\n", 
</span><span class="cx">                                                             __FILE__, __LINE__, dstpath, strerror(errno), 
</span><span class="cx">                                                             errno);
</span><del>-               } else if (force) {
</del><ins>+                } else if (allow_change) {
</ins><span class="cx">                   // this could be bad, so require the force option
</span><span class="cx">                  IF_DEBUG("[install] original node is a file, we need to replace " \
</span><span class="cx">                                   "with a directory \n");
</span><span class="lines">@@ -415,7 +423,7 @@
</span><span class="cx">                                                             __FILE__, __LINE__, dstpath, strerror(errno), 
</span><span class="cx">                                                             errno);
</span><span class="cx">          }
</span><del>-       } else if (force && res == -1 && errno == ENOTDIR) {
</del><ins>+        } else if (allow_change && res == -1 && errno == ENOTDIR) {
</ins><span class="cx">           // some part of destination path is not a directory
</span><span class="cx">          IF_DEBUG("[install] Directory::install ENOTDIR \n");
</span><span class="cx">  } else if (res == -1) {
</span></span></pre></div>
<a id="branchesPR8817822darwinupFileh"></a>
<div class="modfile"><h4>Modified: branches/PR-8817822/darwinup/File.h (917 => 918)</h4>
<pre class="diff"><span>
<span class="info">--- branches/PR-8817822/darwinup/File.h      2011-02-04 22:37:04 UTC (rev 917)
+++ branches/PR-8817822/darwinup/File.h 2011-02-04 23:53:53 UTC (rev 918)
</span><span class="lines">@@ -172,9 +172,9 @@
</span><span class="cx">  // Installs the file from the archive into the prefix
</span><span class="cx">  // i.e., for regular files:
</span><span class="cx">  // rename(prefix + this->archive()->uuid() + this->path(), dest + this->path());
</span><del>-       virtual int install(const char* prefix, const char* dest);
</del><ins>+        virtual int install(const char* prefix, const char* dest, bool uninstall);
</ins><span class="cx">   // only used for directories
</span><del>-       virtual int dirrename(const char* prefix, const char* dest);
</del><ins>+        virtual int dirrename(const char* prefix, const char* dest, bool uninstall);
</ins><span class="cx">   
</span><span class="cx">  // Sets the mode, uid, and gid of the file in the dest path
</span><span class="cx">  // XXX: rename as repair()?
</span><span class="lines">@@ -243,9 +243,9 @@
</span><span class="cx"> struct Directory : File {
</span><span class="cx">  Directory(Archive* archive, FTSENT* ent);
</span><span class="cx">  Directory(uint64_t serial, Archive* archive, uint32_t info, const char* path, mode_t mode, uid_t uid, gid_t gid, off_t size, Digest* digest);
</span><del>-       virtual int install(const char* prefix, const char* dest);
-       virtual int dirrename(const char* prefix, const char* dest);
-       int _install(const char* prefix, const char* dest, bool use_rename);
</del><ins>+        virtual int install(const char* prefix, const char* dest, bool uninstall);
+       virtual int dirrename(const char* prefix, const char* dest, bool uninstall);
+       int _install(const char* prefix, const char* dest, bool uninstall, bool use_rename);
</ins><span class="cx">   virtual int remove();
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesPR8817822darwinupmaincpp"></a>
<div class="modfile"><h4>Modified: branches/PR-8817822/darwinup/main.cpp (917 => 918)</h4>
<pre class="diff"><span>
<span class="info">--- branches/PR-8817822/darwinup/main.cpp    2011-02-04 22:37:04 UTC (rev 917)
+++ branches/PR-8817822/darwinup/main.cpp       2011-02-04 23:53:53 UTC (rev 918)
</span><span class="lines">@@ -245,10 +245,6 @@
</span><span class="cx">                          res = depot->process_archive(argv[0], argv[i]);
</span><span class="cx">                  } else if (strcmp(argv[0], "uninstall") == 0) {
</span><span class="cx">                          if (i==1 && depot->initialize(true)) exit(15);
</span><del>-                               // uninstall is always in force mode so it can
-                               // uninstall archives that were installed under
-                               // force mode
-                               force = 1;
</del><span class="cx">                           res = depot->process_archive(argv[0], argv[i]);
</span><span class="cx">                  } else if (strcmp(argv[0], "verify") == 0) {
</span><span class="cx">                          if (i==1 && depot->initialize(true)) exit(16);
</span></span></pre></div>
<a id="branchesPR8817822testingdarwinupruntestssh"></a>
<div class="modfile"><h4>Modified: branches/PR-8817822/testing/darwinup/run-tests.sh (917 => 918)</h4>
<pre class="diff"><span>
<span class="info">--- branches/PR-8817822/testing/darwinup/run-tests.sh        2011-02-04 22:37:04 UTC (rev 917)
+++ branches/PR-8817822/testing/darwinup/run-tests.sh   2011-02-04 23:53:53 UTC (rev 918)
</span><span class="lines">@@ -97,6 +97,18 @@
</span><span class="cx">  done
</span><span class="cx"> fi
</span><span class="cx"> 
</span><ins>+echo "========== TEST: Test uninstall build check safety =========="
+$DARWINUP install $PREFIX/root2
+sqlite3 $DEST/.DarwinDepot/Database-V100 "UPDATE archives SET osbuild = '$(sw_vers -buildVersion)X'"
+set +e
+$DARWINUP uninstall root2
+if [ $? -eq 0 ]; then exit 1; fi
+set -e
+$DARWINUP -f uninstall root2
+echo "DIFF: diffing original test files to dest (should be no diffs) ..."
+$DIFF $ORIG $DEST 2>&1
+
+
</ins><span class="cx"> echo "========== TEST: Try installing a symlink-to-directory =========="
</span><span class="cx"> ln -s root2 $PREFIX/root_link
</span><span class="cx"> # test without trailing slash
</span></span></pre>
</div>
</div>

</body>
</html>