[darwinbuild-changes] [757] branches/PR-7593824/darwinup
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 10 13:07:35 PST 2010
Revision: 757
http://trac.macosforge.org/projects/darwinbuild/changeset/757
Author: wsiegrist at apple.com
Date: 2010-03-10 13:07:33 -0800 (Wed, 10 Mar 2010)
Log Message:
-----------
Update dyld shared cache after installing or uninstalling a root
Modified Paths:
--------------
branches/PR-7593824/darwinup/Utils.cpp
branches/PR-7593824/darwinup/Utils.h
branches/PR-7593824/darwinup/main.cpp
Modified: branches/PR-7593824/darwinup/Utils.cpp
===================================================================
--- branches/PR-7593824/darwinup/Utils.cpp 2010-03-10 17:14:31 UTC (rev 756)
+++ branches/PR-7593824/darwinup/Utils.cpp 2010-03-10 21:07:33 UTC (rev 757)
@@ -274,8 +274,8 @@
return NULL;
}
-int build_number_for_path(char** build, const char* path) {
- // find /System
+int find_base_system_path(char** output, const char* path) {
+ // find the first /System as we walk up path
char system[PATH_MAX];
char parent[PATH_MAX];
strlcpy(parent, path, PATH_MAX);
@@ -293,12 +293,56 @@
if (res) snprintf(parent, PATH_MAX, "%s", dirname(parent));
}
if (res) {
- fprintf(stderr, "Error: (%d) unable to find /System when looking for build version.\n", res);
+ fprintf(stderr, "Error: (%d) unable to find base system path.\n", res);
return res;
}
+ asprintf(output, "%s", parent);
+ return 0;
+}
+
+int update_dyld_shared_cache(const char* path) {
+ extern uint32_t verbosity;
+ int res;
+ char* base;
+ res = find_base_system_path(&base, path);
+ if (res) return res;
+
+ if (verbosity) {
+ fprintf(stdout, "Updating dyld shared cache for %s ... ", base);
+ fflush(stdout);
+ }
+
+ // exec the tool from our target system
+ char* toolpath;
+ join_path(&toolpath, base, "/usr/bin/update_dyld_shared_cache");
+
+ const char* args[] = {
+ toolpath,
+ "-root", base,
+ NULL
+ };
+ res = exec_with_args(args);
+
+ if (verbosity) fprintf(stdout, "Done updating dyld shared cache\n");
+
+ free(toolpath);
+ free(base);
+ return res;
+}
+
+int build_number_for_path(char** build, const char* path) {
+ int res = 0;
+ char system[PATH_MAX];
+ char* base;
+
+ // find the version plist for our target path
+ find_base_system_path(&base, path);
+ if (!base) return 1;
+ snprintf(system, PATH_MAX, "%s/System/Library/CoreServices/SystemVersion.plist", base);
+ free(base);
+
// read version plist to get build number
- snprintf(system, PATH_MAX, "%s/System/Library/CoreServices/SystemVersion.plist", parent);
const char* args[] = {
"/usr/libexec/PlistBuddy",
"-c", "Print ProductBuildVersion",
@@ -311,7 +355,6 @@
fprintf(stderr, "Error: (%d) failed to create pipe.\n", res);
return res;
}
-
exec_with_args_pipe(args, pfd[1]);
// read from the pipe
@@ -356,3 +399,4 @@
fprintf(stdout, "=============================================="
"=======================================\n");
}
+
Modified: branches/PR-7593824/darwinup/Utils.h
===================================================================
--- branches/PR-7593824/darwinup/Utils.h 2010-03-10 17:14:31 UTC (rev 756)
+++ branches/PR-7593824/darwinup/Utils.h 2010-03-10 21:07:33 UTC (rev 757)
@@ -76,6 +76,8 @@
char* fetch_url(const char* srcpath, const char* dstpath);
char* fetch_userhost(const char* srcpath, const char* dstpath);
+int find_base_system_path(char** output, const char* path);
+int update_dyld_shared_cache(const char* path);
int build_number_for_path(char** build, const char* path);
void __data_hex(FILE* f, uint8_t* data, uint32_t size);
Modified: branches/PR-7593824/darwinup/main.cpp
===================================================================
--- branches/PR-7593824/darwinup/main.cpp 2010-03-10 17:14:31 UTC (rev 756)
+++ branches/PR-7593824/darwinup/main.cpp 2010-03-10 21:07:33 UTC (rev 757)
@@ -156,6 +156,7 @@
if (strcmp(argv[0], "install") == 0) {
if (i==1 && depot->initialize(true)) exit(13);
res = depot->install(argv[i]);
+ if (res == 0) res = update_dyld_shared_cache(path);
} else if (strcmp(argv[0], "upgrade") == 0) {
if (i==1 && depot->initialize(true)) exit(14);
// find most recent matching archive by name
@@ -168,12 +169,14 @@
if (res == 0) res = depot->install(argv[i]);
// uninstall old archive
if (res == 0) res = depot->uninstall(old);
+ if (res == 0) res = update_dyld_shared_cache(path);
} else if (strcmp(argv[0], "files") == 0) {
if (i==1 && depot->initialize(false)) exit(12);
res = depot->process_archive(argv[0], argv[i]);
} else if (strcmp(argv[0], "uninstall") == 0) {
if (i==1 && depot->initialize(true)) exit(15);
res = depot->process_archive(argv[0], argv[i]);
+ if (res == 0) res = update_dyld_shared_cache(path);
} else if (strcmp(argv[0], "verify") == 0) {
if (i==1 && depot->initialize(true)) exit(16);
res = depot->process_archive(argv[0], argv[i]);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100310/5fb497bb/attachment-0001.html>
More information about the darwinbuild-changes
mailing list