mirror of https://github.com/BOINC/boinc.git
Mac installer: fix crash bug, improve translations.
This commit is contained in:
parent
dd8b87c734
commit
532f9f53d8
|
@ -45,7 +45,6 @@ Boolean IsRestartNeeded();
|
|||
static void GetPreferredLanguages(char * pkgPath);
|
||||
static void LoadPreferredLanguages();
|
||||
static void ShowMessage(const char *format, ...);
|
||||
OSErr FindProcess (OSType typeToFind, OSType creatorToFind, ProcessSerialNumberPtr processSN);
|
||||
static OSErr QuitAppleEventHandler(const AppleEvent *appleEvt, AppleEvent* reply, UInt32 refcon);
|
||||
void print_to_log_file(const char *format, ...);
|
||||
void strip_cr(char *buf);
|
||||
|
@ -72,10 +71,9 @@ int main(int argc, char *argv[])
|
|||
char MetaPkgPath[MAXPATHLEN], MetaPkgRestartPath[MAXPATHLEN];
|
||||
char brand[64], s[256];
|
||||
char *p;
|
||||
ProcessSerialNumber ourPSN, installerPSN;
|
||||
ProcessSerialNumber ourPSN;
|
||||
FSRef ourFSRef;
|
||||
long response;
|
||||
pid_t installerPID = 0;
|
||||
OSStatus err = noErr;
|
||||
struct stat stat_buf;
|
||||
Boolean restartNeeded = true;
|
||||
|
@ -133,43 +131,39 @@ int main(int argc, char *argv[])
|
|||
*p = '\0';
|
||||
ShowMessage((char *)_("Sorry, this version of %s requires system 10.4 or higher."), brand);
|
||||
|
||||
err = FindProcess ('APPL', 'xins', &installerPSN);
|
||||
err = GetProcessPID(&installerPSN , &installerPID);
|
||||
} else {
|
||||
|
||||
if (err == noErr)
|
||||
err = kill(installerPID, SIGKILL);
|
||||
// Remove previous installer package receipt so we can run installer again
|
||||
// (affects only older versions of OS X and fixes a bug in those versions)
|
||||
// "rm -rf /Library/Receipts/GridRepublic.pkg"
|
||||
sprintf(s, "rm -rf \"/Library/Receipts/%s.pkg\"", brand);
|
||||
system (s);
|
||||
|
||||
ExitToShell();
|
||||
}
|
||||
restartNeeded = IsRestartNeeded();
|
||||
|
||||
// Remove previous installer package receipt so we can run installer again
|
||||
// (affects only older versions of OS X and fixes a bug in those versions)
|
||||
// "rm -rf /Library/Receipts/GridRepublic.pkg"
|
||||
sprintf(s, "rm -rf \"/Library/Receipts/%s.pkg\"", brand);
|
||||
system (s);
|
||||
|
||||
restartNeeded = IsRestartNeeded();
|
||||
|
||||
// Write a temp file to tell our PostInstall.app whether restart is needed
|
||||
restartNeededFile = fopen("/tmp/BOINC_restart_flag", "w");
|
||||
if (restartNeededFile) {
|
||||
fputs(restartNeeded ? "1\n" : "0\n", restartNeededFile);
|
||||
fclose(restartNeededFile);
|
||||
}
|
||||
|
||||
err = Gestalt(gestaltSystemVersion, &response);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
if (err == noErr) {
|
||||
if ((response < 0x1050) || stat(MetaPkgPath, &stat_buf)) { // stat() returns zero on success
|
||||
sprintf(infoPlistPath, "open \"%s\" &", restartNeeded ? pkgRestartPath : pkgPath);
|
||||
} else {
|
||||
sprintf(infoPlistPath, "open \"%s\" &", restartNeeded ? MetaPkgRestartPath : MetaPkgPath);
|
||||
// Write a temp file to tell our PostInstall.app whether restart is needed
|
||||
restartNeededFile = fopen("/tmp/BOINC_restart_flag", "w");
|
||||
if (restartNeededFile) {
|
||||
fputs(restartNeeded ? "1\n" : "0\n", restartNeededFile);
|
||||
fclose(restartNeededFile);
|
||||
}
|
||||
|
||||
err = Gestalt(gestaltSystemVersion, &response);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
if (err == noErr) {
|
||||
if ((response < 0x1050) || stat(MetaPkgPath, &stat_buf)) { // stat() returns zero on success
|
||||
sprintf(infoPlistPath, "open \"%s\" &", restartNeeded ? pkgRestartPath : pkgPath);
|
||||
} else {
|
||||
sprintf(infoPlistPath, "open \"%s\" &", restartNeeded ? MetaPkgRestartPath : MetaPkgPath);
|
||||
}
|
||||
system(infoPlistPath);
|
||||
}
|
||||
system(infoPlistPath);
|
||||
}
|
||||
|
||||
system("rm -dfR /tmp/BOINC_PAX");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -393,8 +387,6 @@ cleanup:
|
|||
CFArrayRemoveAllValues(supportedLanguages);
|
||||
CFRelease(supportedLanguages);
|
||||
supportedLanguages = NULL;
|
||||
|
||||
system("rm -dfR /tmp/BOINC_PAX");
|
||||
}
|
||||
|
||||
|
||||
|
@ -406,7 +398,7 @@ static void LoadPreferredLanguages(){
|
|||
|
||||
BOINCTranslationInit();
|
||||
|
||||
// Install.app wrote a list of our preferred languages to a temp file
|
||||
// GetPreferredLanguages() wrote a list of our preferred languages to a temp file
|
||||
f = fopen("/tmp/BOINC_preferred_languages", "r");
|
||||
if (!f) return;
|
||||
|
||||
|
@ -460,37 +452,6 @@ static void ShowMessage(const char *format, ...) {
|
|||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/* This runs through the process list looking for the indicated application */
|
||||
/* Searches for process by file type and signature (creator code) */
|
||||
// ---------------------------------------------------------------------------
|
||||
OSErr FindProcess (OSType typeToFind, OSType creatorToFind, ProcessSerialNumberPtr processSN)
|
||||
{
|
||||
ProcessInfoRec tempInfo;
|
||||
FSSpec procSpec;
|
||||
Str31 processName;
|
||||
OSErr myErr = noErr;
|
||||
/* null out the PSN so we're starting at the beginning of the list */
|
||||
processSN->lowLongOfPSN = kNoProcess;
|
||||
processSN->highLongOfPSN = kNoProcess;
|
||||
/* initialize the process information record */
|
||||
tempInfo.processInfoLength = sizeof(ProcessInfoRec);
|
||||
tempInfo.processName = processName;
|
||||
tempInfo.processAppSpec = &procSpec;
|
||||
/* loop through all the processes until we */
|
||||
/* 1) find the process we want */
|
||||
/* 2) error out because of some reason (usually, no more processes) */
|
||||
do {
|
||||
myErr = GetNextProcess(processSN);
|
||||
if (myErr == noErr)
|
||||
GetProcessInformation(processSN, &tempInfo);
|
||||
}
|
||||
while ((tempInfo.processSignature != creatorToFind || tempInfo.processType != typeToFind) &&
|
||||
myErr == noErr);
|
||||
return(myErr);
|
||||
}
|
||||
|
||||
|
||||
static OSErr QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEvent* reply, UInt32 refcon )
|
||||
{
|
||||
gQuitFlag = true;
|
||||
|
|
|
@ -1132,6 +1132,11 @@ static char * PersistentFGets(char *buf, size_t buflen, FILE *f) {
|
|||
// user, before the Apple Installer switches us to root.
|
||||
// So we get the preferred languages in our Installer.app which
|
||||
// writes them to a temporary file which we retrieve here.
|
||||
// We must do it this way because, for unknown reasons, the
|
||||
// CFBundleCopyLocalizationsForPreferences() API does not work
|
||||
// correctly if we seteuid and setuid to the logged in user by
|
||||
// calling SetEUIDBackToUser() after running as root.
|
||||
//
|
||||
static void LoadPreferredLanguages(){
|
||||
FILE *f;
|
||||
int i;
|
||||
|
|
|
@ -1375,6 +1375,11 @@ static void SleepTicks(UInt32 ticksToSleep) {
|
|||
// user, before we switch to root in our second pass.
|
||||
// So we get the preferred languages here and write them to a
|
||||
// temporary file to be retrieved by our second pass.
|
||||
// We must do it this way because, for unknown reasons, the
|
||||
// CFBundleCopyLocalizationsForPreferences() API does not work
|
||||
// correctly if we seteuid and setuid to the logged in user
|
||||
// after running as root.
|
||||
|
||||
static void GetPreferredLanguages() {
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
|
|
Loading…
Reference in New Issue