Bug 747597 - Part 2: Remove --install-app from XULRunner. r+sr=bsmedberg
authorAlex Vincent <ajvincent@gmail.com>
Sat, 21 Apr 2012 22:22:46 -0700
changeset 167007 7bcfaf8f42e8ed9a8c45de6debd74c27afb24c44
parent 167006 5997e5766e988d522732c12b2c85fa9af27b4d27
child 167008 d2b783a561140ee91df29321efdf934f6461704a
push idunknown
push userunknown
push dateunknown
bugs747597
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 747597 - Part 2: Remove --install-app from XULRunner. r+sr=bsmedberg
xulrunner/app/nsXULRunnerApp.cpp
xulrunner/moz.build
xulrunner/setup/moz.build
xulrunner/setup/nsIXULAppInstall.idl
xulrunner/setup/nsXULAppInstall.js
xulrunner/setup/nsXULAppInstall.manifest
--- a/xulrunner/app/nsXULRunnerApp.cpp
+++ b/xulrunner/app/nsXULRunnerApp.cpp
@@ -9,17 +9,16 @@
 #ifdef XP_WIN
 #include <windows.h>
 #define snprintf _snprintf
 #define strcasecmp _stricmp
 #endif
 
 #include "nsAppRunner.h"
 #include "nsIFile.h"
-#include "nsIXULAppInstall.h"
 #include "nsCOMPtr.h"
 #include "nsMemory.h"
 #include "nsCRTGlue.h"
 #include "nsStringAPI.h"
 #include "nsServiceManagerUtils.h"
 #include "plstr.h"
 #include "prprf.h"
 #include "prenv.h"
@@ -133,18 +132,16 @@ static void Usage(const char *argv0)
            "Usage: " XULRUNNER_PROGNAME " [OPTIONS]\n"
            "       " XULRUNNER_PROGNAME " APP-FILE [APP-OPTIONS...]\n"
            "\n"
            "OPTIONS\n"
            "      --app                  specify APP-FILE (optional)\n"
            "  -h, --help                 show this message\n"
            "  -v, --version              show version\n"
            "  --gre-version              print the GRE version string on stdout\n"
-           "  --install-app <application> [<destination> [<directoryname>]]\n"
-           "                             Install a XUL application.\n"
            "\n"
            "APP-FILE\n"
            "  Application initialization file.\n"
            "\n"
            "APP-OPTIONS\n"
            "  Application specific options.\n",
            milestone.get());
 }
@@ -157,83 +154,16 @@ XRE_mainType XRE_main;
 static const nsDynamicFunctionLoad kXULFuncs[] = {
     { "XRE_GetFileFromPath", (NSFuncPtr*) &XRE_GetFileFromPath },
     { "XRE_CreateAppData", (NSFuncPtr*) &XRE_CreateAppData },
     { "XRE_FreeAppData", (NSFuncPtr*) &XRE_FreeAppData },
     { "XRE_main", (NSFuncPtr*) &XRE_main },
     { nullptr, nullptr }
 };
 
-static nsresult
-GetXULRunnerDir(const char *argv0, nsIFile* *aResult)
-{
-  nsresult rv;
-
-  nsCOMPtr<nsIFile> appFile;
-  rv = BinaryPath::GetFile(argv0, getter_AddRefs(appFile));
-  if (NS_FAILED(rv)) {
-    Output(true, "Could not find XULRunner application path.\n");
-    return rv;
-  }
-
-  rv = appFile->GetParent(aResult);
-  if (NS_FAILED(rv)) {
-    Output(true, "Could not find XULRunner installation dir.\n");
-  }
-  return rv;
-}
-
-static int
-InstallXULApp(nsIFile* aXULRunnerDir,
-              const char *aAppLocation,
-              const char *aInstallTo,
-              const char *aLeafName)
-{
-  nsCOMPtr<nsIFile> appLocation;
-  nsCOMPtr<nsIFile> installTo;
-  nsString 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_CStringToUTF16(nsDependentCString(aLeafName),
-                      NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, leafName);
-
-  rv = NS_InitXPCOM2(nullptr, aXULRunnerDir, nullptr);
-  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(nullptr);
-
-  if (NS_FAILED(rv))
-    return 3;
-
-  return 0;
-}
-
 class AutoAppData
 {
 public:
   AutoAppData(nsIFile* aINIFile) : mAppData(nullptr) {
     nsresult rv = XRE_CreateAppData(aINIFile, &mAppData);
     if (NS_FAILED(rv))
       mAppData = nullptr;
   }
@@ -306,43 +236,18 @@ int main(int argc, char* argv[])
         return 1;
       }
 
       printf("%s\n", milestone.get());
       return 0;
     }
 
     if (IsArg(argv[1], "install-app")) {
-      if (argc < 3 || argc > 5) {
-        Usage(argv[0]);
-        return 1;
-      }
-
-      char *appLocation = argv[2];
-
-      char *installTo = nullptr;
-      if (argc > 3) {
-        installTo = argv[3];
-        if (!*installTo) // left blank?
-          installTo = nullptr;
-      }
-
-      char *leafName = nullptr;
-      if (argc > 4) {
-        leafName = argv[4];
-        if (!*leafName)
-          leafName = nullptr;
-      }
-
-      nsCOMPtr<nsIFile> regDir;
-      rv = GetXULRunnerDir(argv[0], getter_AddRefs(regDir));
-      if (NS_FAILED(rv))
-        return 2;
-
-      return InstallXULApp(regDir, appLocation, installTo, leafName);
+      Output(true, "--install-app support has been removed.  Use 'python install-app.py' instead.\n");
+      return 1;
     }
   }
 
   const char *appDataFile = getenv("XUL_APP_FILE");
 
   if (!(appDataFile && *appDataFile)) {
     if (argc < 2) {
       Usage(argv[0]);
--- a/xulrunner/moz.build
+++ b/xulrunner/moz.build
@@ -3,17 +3,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 CONFIGURE_SUBST_FILES += ['installer/Makefile']
 
 PARALLEL_DIRS += [
     'app',
-    'setup',
     'stub',
     'examples',
 ]
 
 if CONFIG['MAKENSISU']:
     DIRS += ['installer/windows']
 
 if CONFIG['OS_ARCH'] == 'WINNT':
deleted file mode 100644
--- a/xulrunner/setup/moz.build
+++ /dev/null
@@ -1,21 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-XPIDL_SOURCES += [
-    'nsIXULAppInstall.idl',
-]
-
-XPIDL_MODULE = 'xulapp_setup'
-
-EXTRA_COMPONENTS += [
-    'nsXULAppInstall.manifest',
-]
-
-EXTRA_PP_COMPONENTS += [
-    'nsXULAppInstall.js',
-]
-
-DEFINES['BIN_SUFFIX'] = CONFIG['BIN_SUFFIX']
deleted file mode 100644
--- a/xulrunner/setup/nsIXULAppInstall.idl
+++ /dev/null
@@ -1,35 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-interface nsIFile;
-
-/**
- * Installation and management of XUL applications.
- *
- * @status IN_FLUX   This interface is not stable and will change in the
- *                   future.
- */
-[scriptable, uuid(800ace15-6b38-48c4-b057-7928378f6cd2)]
-interface nsIXULAppInstall : nsISupports
-{
-  /**
-   * Install a XUL application into a form that can be run by the native
-   * operating system.
-   *
-   * @param aAppFile   Directory or a zip file containing a 
-   *                   XULRunner package (with the required application.ini
-   *                   file in the root).
-   * @param aDirectory Path specifying the location to install the
-   *                   application. If null, an appropriate default install
-   *                   location will be used. e.g. "C:\Program Files\<Vendor>"
-   *                   on Windows.
-   * @param aLeafName  The leaf name of the application directory. If empty
-   *                   an appropriate default will be chosen. e.g. "Simple.app"
-   *                   on Mac.
-   */
-  void installApplication(in nsIFile aAppFile, in nsIFile aDirectory,
-                          in AString aLeafName);
-};
deleted file mode 100644
--- a/xulrunner/setup/nsXULAppInstall.js
+++ /dev/null
@@ -1,318 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-#filter substitution
-#if 0
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#endif
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-const nsIFile             = Components.interfaces.nsIFile;
-const nsIINIParser        = Components.interfaces.nsIINIParser;
-const nsIINIParserFactory = Components.interfaces.nsIINIParserFactory;
-const nsILocalFile        = Components.interfaces.nsILocalFile;
-const nsISupports         = Components.interfaces.nsISupports;
-const nsIXULAppInstall    = Components.interfaces.nsIXULAppInstall;
-const nsIZipReader        = Components.interfaces.nsIZipReader;
-
-function getDirectoryKey(aKey) {
-  try {
-    return Components.classes["@mozilla.org/file/directory_service;1"].
-      getService(Components.interfaces.nsIProperties).
-      get(aKey, nsIFile);
-  }
-  catch (e) {
-    throw "Couln't get directory service key: " + aKey;
-  }
-}
-
-function createINIParser(aFile) {
-  return Components.manager.
-    getClassObjectByContractID("@mozilla.org/xpcom/ini-parser-factory;1",
-                               nsIINIParserFactory).
-    createINIParser(aFile);
-}
-
-function copy_recurse(aSource, aDest) {
-  var e = aSource.directoryEntries;
-
-  while (e.hasMoreElements()) {
-    var f = e.getNext().QueryInterface(nsIFile);
-    var leaf = f.leafName;
-
-    var ddest = aDest.clone();
-    ddest.append(leaf);
-
-    if (f.isDirectory()) {
-      copy_recurse(f, ddest);
-    }
-    else {
-      if (ddest.exists())
-        ddest.remove(false);
-
-      f.copyTo(aDest, leaf);
-    }
-  }
-}
-
-const PR_WRONLY = 0x02;
-const PR_CREATE_FILE = 0x08;
-const PR_TRUNCATE = 0x20;
-
-function openFileOutputStream(aFile) {
-  var s = Components.classes["@mozilla.org/network/file-output-stream;1"].
-    createInstance(Components.interfaces.nsIFileOutputStream);
-  s.init(aFile, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0644, 0);
-  return s;
-}
-
-/**
- * An extractor implements the following prototype:
- * readonly attribute nsIINIPaser iniParser;
- * void copyTo(in nsILocalFile root);
- */
-
-function directoryExtractor(aFile) {
-  this.mDirectory = aFile;
-}
-
-directoryExtractor.prototype = {
-  mINIParser : null,
-
-  get iniParser() {
-    if (!this.mINIParser) {
-      var iniFile = this.mDirectory.clone();
-      iniFile.append("application.ini");
-
-      this.mINIParser = createINIParser(iniFile);
-    }
-    return this.mINIParser;
-  },
-
-  copyTo : function de_copyTo(aDest) {
-    // Assume the root already exists
-    copy_recurse(this.mDirectory, aDest);
-  }
-};
-
-function zipExtractor(aFile) {
-  this.mZipReader = Components.classes["@mozilla.org/libjar/zip-reader;1"].
-    createInstance(nsIZipReader);
-  this.mZipReader.open(aFile);
-  this.mZipReader.test(null);
-}
-
-zipExtractor.prototype = {
-  mINIParser : null,
-
-  get iniParser() {
-    if (!this.mINIParser) {
-      // XXXbsmedberg: this is not very unique, guessing could be a problem
-      var f = getDirectoryKey("TmpD");
-      f.append("application.ini");
-      f.createUnique(nsIFile.NORMAL_FILE_TYPE, 0600);
-
-      try {
-        this.mZipReader.extract("application.ini", f);
-        this.mINIParser = createINIParser(f);
-      }
-      catch (e) {
-        try {
-          f.remove();
-        }
-        catch (ee) { }
-
-        throw e;
-      }
-      try {
-        f.remove();
-      }
-      catch (e) { }
-    }
-    return this.mINIParser;
-  },
-
-  copyTo : function ze_CopyTo(aDest) {
-    var entries = this.mZipReader.findEntries(null);
-    while (entries.hasMore()) {
-      var entryName = entries.getNext();
-
-      this._installZipEntry(this.mZipReader, entryName, aDest);
-    }
-  },
-
-  _installZipEntry : function ze_installZipEntry(aZipReader, aZipEntry,
-                                                 aDestination) {
-    var file = aDestination.clone();
-
-    var dirs = aZipEntry.split(/\//);
-    var isDirectory = /\/$/.test(aZipEntry);
-
-    var end = dirs.length;
-    if (!isDirectory)
-      --end;
-
-    for (var i = 0; i < end; ++i) {
-      file.append(dirs[i]);
-      if (!file.exists()) {
-        file.create(nsIFile.DIRECTORY_TYPE, 0755);
-      }
-    }
-
-    if (!isDirectory) {
-      file.append(dirs[end]);
-      aZipReader.extract(aZipEntry, file);
-    }
-  }
-};
-
-function createExtractor(aFile) {
-  if (aFile.isDirectory())
-    return new directoryExtractor(aFile);
-
-  return new zipExtractor(aFile);
-}
-
-function AppInstall() {
-}
-
-AppInstall.prototype = {
-  classID: Components.ID("{00790a19-27e2-4d9a-bef0-244080feabfd}"),
-
-  /* nsISupports */
-  QueryInterface : XPCOMUtils.generateQI([nsIXULAppInstall]),
-
-  /* nsIXULAppInstall */
-  installApplication : function ai_IA(aAppFile, aDirectory, aLeafName) {
-    var extractor = createExtractor(aAppFile);
-    var iniParser = extractor.iniParser;
-
-    var appName = iniParser.getString("App", "Name");
-
-    // vendor is optional
-    var vendor;
-    try {
-      vendor = iniParser.getString("App", "Vendor");
-    }
-    catch (e) { }
-
-    if (aDirectory == null) {
-#ifdef XP_WIN
-      aDirectory = getDirectoryKey("ProgF");
-      if (vendor)
-        aDirectory.append(vendor);
-#else
-#ifdef XP_MACOSX
-      aDirectory = getDirectoryKey("LocApp");
-      if (vendor)
-        aDirectory.append(vendor);
-#else
-      aDirectory = Components.classes["@mozilla.org/file/local;1"].
-        createInstance(nsILocalFile);
-      aDirectory.initWithPath("/usr/local/lib");
-      if (vendor)
-        aDirectory.append(vendor.toLowerCase());
-#endif
-#endif
-    }
-    else {
-      aDirectory = aDirectory.clone();
-    }
-
-    if (!aDirectory.exists()) {
-      aDirectory.create(nsIFile.DIRECTORY_TYPE, 0755);
-    }
-
-    if (aLeafName == "") {
-#ifdef XP_MACOSX
-      aLeafName = appName + ".app";
-#else
-#ifdef XP_WIN
-      aLeafName = appName;
-#else
-      aLeafName = appName.toLowerCase();
-#endif
-#endif
-    }
-
-    aDirectory.append(aLeafName);
-    if (!aDirectory.exists()) {
-      aDirectory.create(nsIFile.DIRECTORY_TYPE, 0755);
-    }
-
-#ifdef XP_MACOSX
-    aDirectory.append("Contents");
-    if (!aDirectory.exists()) {
-      aDirectory.create(nsIFile.DIRECTORY_TYPE, 0755);
-    }
- 
-    var version = iniParser.getString("App", "Version");
-    var buildID = iniParser.getString("App", "BuildID");
-
-    var infoString = "";
-    if (vendor) {
-      infoString = vendor + " ";
-    }
-    infoString += appName + " " + version;
-
-    var plistFile = aDirectory.clone();
-    plistFile.append("Info.plist");
-    var ostream = openFileOutputStream(plistFile);
-
-    var contents =
-    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-    "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" +
-    "<plist version=\"1.0\">\n" +
-    "<dict>\n" +
-    "<key>CFBundleInfoDictionaryVersion</key>\n" +
-    "<string>6.0</string>\n" +
-    "<key>CFBundlePackageType</key>\n" +
-    "<string>APPL</string>\n" +
-    "<key>CFBundleExecutable</key>\n" +
-    "<string>xulrunner</string>\n" +
-    "<key>NSAppleScriptEnabled</key>\n" +
-    "<true/>\n" +
-    "<key>CFBundleGetInfoString</key>\n" +
-    "<string>" + infoString + "</string>\n" +
-    "<key>CFBundleName</key>\n" +
-    "<string>" + appName + "</string>\n" +
-    "<key>CFBundleShortVersionString</key>\n" +
-    "<string>" + version + "</string>\n" +
-    "<key>CFBundleVersion</key>\n" +
-    "<string>" + version + "." + buildID + "</string>\n" +
-    "</dict>\n" +
-    "</plist>";
-
-    // "<key>CFBundleIdentifier</key>\n" +
-    // "<string>org.%s.%s</string>\n" +
-    // "<key>CFBundleSignature</key>\n" +
-    // "<string>MOZB</string>\n" +
-    // "<key>CFBundleIconFile</key>\n" +
-    // "<string>document.icns</string>\n" +
-
-    ostream.write(contents, contents.length);
-    ostream.close();
-
-    var contentsDir = aDirectory.clone();
-    contentsDir.append("MacOS");
-
-    var xulrunnerBinary = getDirectoryKey("GreD");
-    xulrunnerBinary.append("xulrunner");
-
-    xulrunnerBinary.copyTo(contentsDir, "xulrunner");
-
-    aDirectory.append("Resources");
-    extractor.copyTo(aDirectory);
-#else
-    extractor.copyTo(aDirectory);
-
-    var xulrunnerBinary = getDirectoryKey("GreD");
-    xulrunnerBinary.append("xulrunner-stub@BIN_SUFFIX@");
-
-    xulrunnerBinary.copyTo(aDirectory, appName.toLowerCase() + "@BIN_SUFFIX@");
-#endif
-  }
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AppInstall]);
deleted file mode 100644
--- a/xulrunner/setup/nsXULAppInstall.manifest
+++ /dev/null
@@ -1,2 +0,0 @@
-component {00790a19-27e2-4d9a-bef0-244080feabfd} nsXULAppInstall.js
-contract @mozilla.org/xulrunner/app-install-service;1 {00790a19-27e2-4d9a-bef0-244080feabfd}