зеркало из https://github.com/mozilla/pjs.git
Bug 300139 - nsXULAppInstall fixup and xulrunner command-line flag. r=robstrong
This commit is contained in:
Родитель
c42832559f
Коммит
22f36b709f
|
@ -68,6 +68,7 @@ REQUIRES = \
|
||||||
string \
|
string \
|
||||||
appshell \
|
appshell \
|
||||||
xulapp \
|
xulapp \
|
||||||
|
xulrunner \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
CPPSRCS = nsXULRunnerApp.cpp
|
CPPSRCS = nsXULRunnerApp.cpp
|
||||||
|
|
|
@ -47,8 +47,10 @@
|
||||||
#include "nsAppRunner.h"
|
#include "nsAppRunner.h"
|
||||||
#include "nsINIParser.h"
|
#include "nsINIParser.h"
|
||||||
#include "nsILocalFile.h"
|
#include "nsILocalFile.h"
|
||||||
|
#include "nsIXULAppInstall.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsMemory.h"
|
#include "nsMemory.h"
|
||||||
|
#include "nsNativeCharsetUtils.h"
|
||||||
#include "nsBuildID.h"
|
#include "nsBuildID.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
#include "prprf.h"
|
#include "prprf.h"
|
||||||
|
@ -270,6 +272,8 @@ static void Usage()
|
||||||
" --register-user\n"
|
" --register-user\n"
|
||||||
" --find-gre <version> Find a GRE with version <version> and print\n"
|
" --find-gre <version> Find a GRE with version <version> and print\n"
|
||||||
" the path on stdout\n"
|
" the path on stdout\n"
|
||||||
|
" --install-app <application> [<destination> [<directoryname>]]\n"
|
||||||
|
" Install a XUL application.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"APP-FILE\n"
|
"APP-FILE\n"
|
||||||
" Application initialization file.\n"
|
" Application initialization file.\n"
|
||||||
|
@ -298,6 +302,53 @@ GetXULRunnerDir(const char *argv0, nsIFile* *aResult)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
InstallXULApp(nsIFile* aXULRunnerDir,
|
||||||
|
const char *aAppLocation,
|
||||||
|
const char *aInstallTo,
|
||||||
|
const char *aLeafName)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsILocalFile> appLocation;
|
||||||
|
nsCOMPtr<nsILocalFile> installTo;
|
||||||
|
nsAutoString leafName;
|
||||||
|
|
||||||
|
nsresult rv = XRE_GetFileFromPath(aAppLocation, getter_AddRefs(appLocation));
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
if (aInstallTo) {
|
||||||
|
rv = XRE_GetFileFromPath(aInstallTo, getter_AddRefs(installTo));
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aLeafName)
|
||||||
|
NS_CopyNativeToUnicode(nsDependentCString(aLeafName), leafName);
|
||||||
|
|
||||||
|
rv = NS_InitXPCOM2(nsnull, aXULRunnerDir, nsnull);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
{
|
||||||
|
// Scope our COMPtr to avoid holding XPCOM refs beyond xpcom shutdown
|
||||||
|
nsCOMPtr<nsIXULAppInstall> install
|
||||||
|
(do_GetService("@mozilla.org/xulrunner/app-install-service;1"));
|
||||||
|
if (!install) {
|
||||||
|
rv = NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv = install->InstallApplication(appLocation, installTo, leafName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_ShutdownXPCOM(nsnull);
|
||||||
|
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (argc > 1 && (IsArg(argv[1], "h") ||
|
if (argc > 1 && (IsArg(argv[1], "h") ||
|
||||||
|
@ -376,6 +427,36 @@ int main(int argc, char* argv[])
|
||||||
printf("%s\n", GRE_BUILD_ID);
|
printf("%s\n", GRE_BUILD_ID);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsArg(argv[1], "install-app")) {
|
||||||
|
if (argc < 3 || argc > 5) {
|
||||||
|
Usage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *appLocation = argv[2];
|
||||||
|
|
||||||
|
char *installTo = nsnull;
|
||||||
|
if (argc > 3) {
|
||||||
|
installTo = argv[3];
|
||||||
|
if (!*installTo) // left blank?
|
||||||
|
installTo = nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *leafName = nsnull;
|
||||||
|
if (argc > 4) {
|
||||||
|
leafName = argv[4];
|
||||||
|
if (!*leafName)
|
||||||
|
leafName = nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIFile> regDir;
|
||||||
|
nsresult rv = GetXULRunnerDir(argv[0], getter_AddRefs(regDir));
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
return InstallXULApp(regDir, appLocation, installTo, leafName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
geckoVersion = ParseVersion(GRE_BUILD_ID);
|
geckoVersion = ParseVersion(GRE_BUILD_ID);
|
||||||
|
|
|
@ -42,7 +42,8 @@ VPATH = @srcdir@
|
||||||
|
|
||||||
include $(DEPTH)/config/autoconf.mk
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
MODULE = xulapp_setup
|
MODULE = xulrunner
|
||||||
|
XPIDL_MODULE = xulapp_setup
|
||||||
|
|
||||||
XPIDLSRCS = \
|
XPIDLSRCS = \
|
||||||
nsIXULAppInstall.idl \
|
nsIXULAppInstall.idl \
|
||||||
|
|
|
@ -46,10 +46,15 @@ const nsIZipEntry = Components.interfaces.nsIZipEntry;
|
||||||
const nsIZipReader = Components.interfaces.nsIZipReader;
|
const nsIZipReader = Components.interfaces.nsIZipReader;
|
||||||
|
|
||||||
function getDirectoryKey(aKey) {
|
function getDirectoryKey(aKey) {
|
||||||
|
try {
|
||||||
return Components.classes["@mozilla.org/file/directory_service;1"].
|
return Components.classes["@mozilla.org/file/directory_service;1"].
|
||||||
getService(Components.interfaces.nsIProperties).
|
getService(Components.interfaces.nsIProperties).
|
||||||
get(aKey, nsIFile);
|
get(aKey, nsIFile);
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw "Couln't get directory service key: " + aKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createINIParser(aFile) {
|
function createINIParser(aFile) {
|
||||||
return Components.manager.
|
return Components.manager.
|
||||||
|
@ -87,7 +92,7 @@ const PR_TRUNCATE = 0x20;
|
||||||
function openFileOutputStream(aFile) {
|
function openFileOutputStream(aFile) {
|
||||||
var s = Components.classes["@mozilla.org/network/file-output-stream;1"].
|
var s = Components.classes["@mozilla.org/network/file-output-stream;1"].
|
||||||
createInstance(Components.interfaces.nsIFileOutputStream);
|
createInstance(Components.interfaces.nsIFileOutputStream);
|
||||||
s.init(aFile, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE);
|
s.init(aFile, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0644, 0);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +232,7 @@ const AppInstall = {
|
||||||
|
|
||||||
if (aDirectory == null) {
|
if (aDirectory == null) {
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
aDirectory = getDirectoryKey("Progs");
|
aDirectory = getDirectoryKey("ProgF");
|
||||||
if (vendor)
|
if (vendor)
|
||||||
aDirectory.append(vendor);
|
aDirectory.append(vendor);
|
||||||
#else
|
#else
|
||||||
|
@ -277,6 +282,12 @@ const AppInstall = {
|
||||||
var version = iniParser.getString("App", "Version");
|
var version = iniParser.getString("App", "Version");
|
||||||
var buildID = iniParser.getString("App", "BuildID");
|
var buildID = iniParser.getString("App", "BuildID");
|
||||||
|
|
||||||
|
var infoString = "";
|
||||||
|
if (vendor) {
|
||||||
|
infoString = vendor + " ";
|
||||||
|
}
|
||||||
|
infoString += appName + " " + version;
|
||||||
|
|
||||||
var plistFile = aDirectory.clone();
|
var plistFile = aDirectory.clone();
|
||||||
plistFile.append("Info.plist");
|
plistFile.append("Info.plist");
|
||||||
var ostream = openFileOutputStream(plistFile);
|
var ostream = openFileOutputStream(plistFile);
|
||||||
|
@ -289,13 +300,13 @@ const AppInstall = {
|
||||||
"<key>CFBundleInfoDictionaryVersion</key>\n" +
|
"<key>CFBundleInfoDictionaryVersion</key>\n" +
|
||||||
"<string>6.0</string>\n" +
|
"<string>6.0</string>\n" +
|
||||||
"<key>CFBundlePackageType</key>\n" +
|
"<key>CFBundlePackageType</key>\n" +
|
||||||
"<string>APPL</string>" +
|
"<string>APPL</string>\n" +
|
||||||
"<key>CFBundleExecutable</key>\n" +
|
"<key>CFBundleExecutable</key>\n" +
|
||||||
"<string>xulrunner</string>\n" +
|
"<string>xulrunner</string>\n" +
|
||||||
"<key>NSAppleScriptEnabled</key>\n" +
|
"<key>NSAppleScriptEnabled</key>\n" +
|
||||||
"<true/>\n" +
|
"<true/>\n" +
|
||||||
"<key>CFBundleGetInfoString</key>\n" +
|
"<key>CFBundleGetInfoString</key>\n" +
|
||||||
"<string>" + vendor ? (vendor + " ") : "" + appName + " " + version + "</string>\n" +
|
"<string>" + infoString + "</string>\n" +
|
||||||
"<key>CFBundleName</key>\n" +
|
"<key>CFBundleName</key>\n" +
|
||||||
"<string>" + appName + "</string>\n" +
|
"<string>" + appName + "</string>\n" +
|
||||||
"<key>CFBundleShortVersionString</key>\n" +
|
"<key>CFBundleShortVersionString</key>\n" +
|
||||||
|
|
|
@ -70,7 +70,7 @@ main(int argc, char **argv)
|
||||||
absResourcesURL,
|
absResourcesURL,
|
||||||
CFSTR("application.ini"),
|
CFSTR("application.ini"),
|
||||||
false);
|
false);
|
||||||
CFRelease(resourcesURL);
|
CFRelease(absResourcesURL);
|
||||||
|
|
||||||
if (!iniFileURL)
|
if (!iniFileURL)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -131,6 +131,11 @@ main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *lastSlash = strrchr(greDir, '/');
|
||||||
|
if (lastSlash) {
|
||||||
|
*lastSlash = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
char **argv2 = (char**) alloca(sizeof(char*) * (argc + 2));
|
char **argv2 = (char**) alloca(sizeof(char*) * (argc + 2));
|
||||||
|
|
||||||
char xulBin[PATH_MAX];
|
char xulBin[PATH_MAX];
|
||||||
|
|
Загрузка…
Ссылка в новой задаче