Mac installer: check whether the project server provided the installer_filename.txt file by putting it in the same parent directory as our installer bundle (the bundle's default name is "BOINC Installer.app"). If yes, copy the provided file into the BOINC Data directory. Otherwise create the installer_filename.txt file and write the name of our installer bundle in it.

This commit is contained in:
Charlie Fenton 2017-11-12 03:37:52 -08:00
parent c324052576
commit 048e9e4800
1 changed files with 28 additions and 8 deletions

View File

@ -77,7 +77,7 @@ int main(int argc, char *argv[])
{
char pkgPath[MAXPATHLEN];
char postInstallAppPath[MAXPATHLEN];
char temp[MAXPATHLEN];
char temp[MAXPATHLEN], temp2[MAXPATHLEN];
char brand[64], s[256];
char *p;
OSStatus err = noErr;
@ -117,15 +117,35 @@ int main(int argc, char *argv[])
strlcat(postInstallAppPath, "PostInstall.app", sizeof(postInstallAppPath));
p = strrchr(temp, '/'); // Point to name of this application (e.g., "BOINC Installer.app")
if (p == NULL)
if (p == NULL) {
p = temp - 1;
} else {
*p = '\0';
}
// write installer filename to a temp file
// PostInstall.app will copy it into the BOINC Data directory
snprintf(temp, sizeof(temp), "tmp/%s/%s", tempDirName, INSTALLER_FILENAME_FILENAME);
FILE* f = fopen(temp, "w");
// Delete any old project auto-attach key file from our temp directory
snprintf(temp2, sizeof(temp2), "rm -dfR \"/tmp/%s/%s\"", tempDirName, INSTALLER_FILENAME_FILENAME);
err = callPosixSpawn(temp2);
REPORT_ERROR(err);
// Write a file containing the project auto-attach key into our temp
// directory because the BOINC Data directory may not yet exist.
// PostInstall.app will copy it into the BOINC Data directory laer
snprintf(temp2, sizeof(temp2), "%s/%s", temp, INSTALLER_FILENAME_FILENAME);
if (boinc_file_exists(temp2)) {
// If the project server put installer_filename.txt file in the same
// parent directory as this installer, copy it into our temp directory
snprintf(temp2, sizeof(temp2), "cp \"%s/%s\" \"/tmp/%s/%s\"", temp, INSTALLER_FILENAME_FILENAME, tempDirName, INSTALLER_FILENAME_FILENAME);
err = callPosixSpawn(temp2);
REPORT_ERROR(err);
} else {
// Create an installer_filename.txt file containing our
// installer's filename and put it in our temp directory
snprintf(temp2, sizeof(temp2), "/tmp/%s/%s", tempDirName, INSTALLER_FILENAME_FILENAME);
FILE* f = fopen(temp2, "w");
fputs(p+1, f);
fclose(f);
}
// To allow for branding, assume name of installer package inside bundle corresponds to name of this application
strlcpy(brand, p+1, sizeof(brand));