[darwinbuild-changes] [166] trunk/darwinxref/plugins/loadDeps.c
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 4 01:53:07 PDT 2006
Revision: 166
http://trac.macosforge.org/projects/darwinbuild/changeset/166
Author: ssen
Date: 2006-10-04 01:53:07 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
Stop using canonicalize_path(). Resolving paths like
"/usr/bin/foo" against the true root filesystem is not correct,
since a default install will not have many things like
/usr/local/lib/system/libc.a. Additionally, it leads to interesting
false dependencies since the dependency "/usr/bin/gcc" may resolve
to gcc-3.3 inside the chroot but gcc-4.0 outside the chroot, so
projects would end up with a "gcc" project dep incorrectly.
In order to support this, the "loadDeps" plugin takes the path
to the BuildRoot/ so that it can lstat paths.
Modified Paths:
--------------
trunk/darwinxref/plugins/loadDeps.c
Modified: trunk/darwinxref/plugins/loadDeps.c
===================================================================
--- trunk/darwinxref/plugins/loadDeps.c 2005-08-09 05:58:43 UTC (rev 165)
+++ trunk/darwinxref/plugins/loadDeps.c 2006-10-04 08:53:07 UTC (rev 166)
@@ -33,22 +33,25 @@
#include "DBPlugin.h"
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/param.h>
-int loadDeps(const char* build, const char* project);
+int loadDeps(const char* build, const char* project, const char *root);
static int run(CFArrayRef argv) {
int res = 0;
CFIndex count = CFArrayGetCount(argv);
- if (count != 1) return -1;
+ if (count != 2) return -1;
char* project = strdup_cfstr(CFArrayGetValueAtIndex(argv, 0));
+ char* root = strdup_cfstr(CFArrayGetValueAtIndex(argv, 1));
+
char* build = strdup_cfstr(DBGetCurrentBuild());
- loadDeps(build, project);
+ loadDeps(build, project, root);
free(project);
return res;
}
static CFStringRef usage() {
- return CFRetain(CFSTR("<project>"));
+ return CFRetain(CFSTR("<project> <buildroot>"));
}
int initialize(int version) {
@@ -70,70 +73,8 @@
return found ? (strcmp(found, little) == 0) : 0;
}
-static char* canonicalize_path(const char* path) {
-#if 1 // USE_REALPATH
- char* result = malloc(PATH_MAX);
- realpath(path, result);
- return result;
-#else
- char* result = malloc(strlen(path) + 1);
- const char* src = path;
- char* dst = result;
-
- while (*src != 0) {
- // Backtrack to previous /
- if (strncmp(src, "/../", 4) == 0) {
- src += 3; // skip to last /, so we can evaluate that below
- if (dst == result) {
- *dst = '/';
- dst += 1;
- } else {
- do {
- dst -= 1;
- } while (dst != result && *dst != '/');
- }
- // Trim /..
- } else if (strcmp(src, "/..") == 0) {
- src += 3;
- if (dst == result) {
- *dst = '/';
- dst += 1;
- } else {
- do {
- dst -= 1;
- } while (dst != result && *dst != '/');
- }
- // Compress /./ to /
- } else if (strncmp(src, "/./", 3) == 0) {
- src += 2; // skip to last /, so we can evaluate that below
- // Trim /.
- } else if (strcmp(src, "/.") == 0) {
- *dst = 0;
- break;
- // compress slashes, trim trailing slash
- } else if (*src == '/') {
- if ((dst == result || dst[-1] != '/') && src[1] != 0) {
- *dst = '/';
- dst += 1;
- src += 1;
- } else {
- src += 1;
- }
- // default to copying over a single char
- } else {
- *dst = *src;
- dst += 1;
- src += 1;
- }
- }
-
- *dst = 0; // NUL terminate
-
- return result;
-#endif
-}
-int loadDeps(const char* build, const char* project) {
+int loadDeps(const char* build, const char* project, const char *root) {
size_t size;
char* line;
int count = 0;
@@ -150,7 +91,9 @@
if (line[size-1] == '\n') line[size-1] = 0; // chomp newline
char* tab = memchr(line, '\t', size);
if (tab) {
+ char fullpath[MAXPATHLEN];
char *type, *file;
+ struct stat sb;
int typesize = (intptr_t)tab - (intptr_t)line;
asprintf(&type, "%.*s", typesize, line);
asprintf(&file, "%.*s", size - typesize - 1, tab+1);
@@ -168,16 +111,14 @@
free(type);
type = "build";
}
- char* canonicalized = canonicalize_path(file);
- struct stat sb;
- int res = lstat(canonicalized, &sb);
+ sprintf(fullpath, "%s/%s", root, file);
+ int res = lstat(fullpath, &sb);
// for now, skip if the path points to a directory
if (res == 0 && !S_ISDIR(sb.st_mode)) {
SQL("INSERT INTO unresolved_dependencies (build,project,type,dependency) VALUES (%Q,%Q,%Q,%Q)",
- build, project, type, canonicalized);
+ build, project, type, file);
}
- free(canonicalized);
free(file);
} else {
fprintf(stderr, "Error: syntax error in input. no tab delimiter found.\n");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/ddabb7a7/attachment-0001.html
More information about the darwinbuild-changes
mailing list