[872] branches/PR-8416637/darwinup
Revision: 872 http://trac.macosforge.org/projects/darwinbuild/changeset/872 Author: wsiegrist@apple.com Date: 2010-09-14 16:26:57 -0700 (Tue, 14 Sep 2010) Log Message: ----------- Move object type checking to analyze stage. Modified Paths: -------------- branches/PR-8416637/darwinup/Depot.cpp branches/PR-8416637/darwinup/File.cpp branches/PR-8416637/darwinup/File.h Modified: branches/PR-8416637/darwinup/Depot.cpp =================================================================== --- branches/PR-8416637/darwinup/Depot.cpp 2010-09-13 19:57:26 UTC (rev 871) +++ branches/PR-8416637/darwinup/Depot.cpp 2010-09-14 23:26:57 UTC (rev 872) @@ -402,9 +402,9 @@ return res; } - int Depot::analyze_stage(const char* path, Archive* archive, Archive* rollback, int* rollback_files) { + extern uint32_t force; extern uint32_t dryrun; int res = 0; assert(archive != NULL); @@ -475,9 +475,22 @@ if (INFO_TEST(actual->info(), FILE_INFO_NO_ENTRY)) { state = 'A'; } else { + if (INFO_TEST(actual_flags, FILE_INFO_TYPE_DIFFERS) && !force) { + // the existing file on disk is a different type than what + // we are trying to install, so require the force option, + // otherwise print an error and bail + mode_t file_type = file->mode() & S_IFMT; + mode_t actual_type = actual->mode() & S_IFMT; + fprintf(stderr, FILE_OBJ_CHANGE_ERROR, path, + FILE_TYPE_STRING(file_type), + FILE_TYPE_STRING(actual_type)); + return -2; + } state = 'U'; } + + if (INFO_TEST(actual_flags, FILE_INFO_TYPE_DIFFERS) || INFO_TEST(actual_flags, FILE_INFO_DATA_DIFFERS)) { IF_DEBUG("[analyze] needs installation\n"); @@ -739,8 +752,8 @@ int rollback_files = 0; if (res == 0) res = this->analyze_stage(archive_path, archive, rollback, &rollback_files); - // we can stop now if this is a dry run - if (dryrun) { + // we can stop now if analyze failed or this is a dry run + if (res || dryrun) { remove_directory(archive_path); remove_directory(rollback_path); free(rollback_path); Modified: branches/PR-8416637/darwinup/File.cpp =================================================================== --- branches/PR-8416637/darwinup/File.cpp 2010-09-13 19:57:26 UTC (rev 871) +++ branches/PR-8416637/darwinup/File.cpp 2010-09-14 23:26:57 UTC (rev 872) @@ -213,8 +213,8 @@ __FILE__, __LINE__, dstpath, strerror(errno), errno); } else { if (!force) { - fprintf(stderr, FILE_OBJ_CHANGE_ERROR("file", "directory")); - } + assert(0); + } fprintf(stderr, "%s:%d: %s: %s (%d)\n", __FILE__, __LINE__, dstpath, strerror(errno), errno); fprintf(stderr, "ERROR: fatal error during File::install. " \ Modified: branches/PR-8416637/darwinup/File.h =================================================================== --- branches/PR-8416637/darwinup/File.h 2010-09-13 19:57:26 UTC (rev 871) +++ branches/PR-8416637/darwinup/File.h 2010-09-14 23:26:57 UTC (rev 872) @@ -39,15 +39,28 @@ #include <sys/stat.h> #include <fts.h> -#define FILE_OBJ_CHANGE_ERROR(_old_, _new_) \ +#define FILE_OBJ_CHANGE_ERROR \ "-----------------------------------------------------------------------------\n" \ "Darwinup has encountered a potentially unsafe mismatch between the root and \n" \ -"destination. You seem to be trying to install a " _new_ " over a " _old_". \n" \ +"destination: %s\n" \ +"You seem to be trying to install a %s over a %s. \n" \ "Darwinup will not install this root by default since it could cause damage \n" \ "to your system. You can use the force (-f) option to allow darwinup to \n" \ "attempt the install anyway. \n" \ "-----------------------------------------------------------------------------\n" +#define FILE_TYPE_STRING(type) \ +(type == S_IFIFO ? "named pipe" : \ +(type == S_IFCHR ? "character special" : \ +(type == S_IFDIR ? "directory" : \ +(type == S_IFBLK ? "block special" : \ +(type == S_IFREG ? "file" : \ +(type == S_IFLNK ? "symbolic link" : \ +(type == S_IFSOCK ? "socket" : \ +(type == S_IFWHT ? "whiteout" : \ +"unknown")))))))) + + enum file_starseded_t { FILE_SUPERSEDED, FILE_PRECEDED
participants (1)
-
source_changes@macosforge.org