Difference between revisions of "Firefox ext install downloads"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
(template file ff-extension.cmd including clean-extensions.cmd)
m (Firefox 3.6+ and Extension Installation Files)
Line 1: Line 1:
 
== Firefox 3.6+ and Extension Installation Files ==
 
== Firefox 3.6+ and Extension Installation Files ==
  
Here are the command and xml files listed for use by [[Firefox#Firefox_3.6_Series_Extension_Templates]]. The idea comes from [[http://forums.mozillazine.org/viewtopic.php?f=7&t=1724155] Mozilla Forum Discussion] and the files are adapted from [[http://flabdablet.nfshost.com/windows-scripts/install-extensions.cmd] install_extensions.cmd].
+
Here are the command and xml files listed for use by [[Firefox#Firefox_3.6_Series_Extension_Templates]]. The idea comes from [[http://forums.mozillazine.org/viewtopic.php?f=7&t=1724155] Mozilla Forum Discussion] and the files are adapted from [[http://flabdablet.nfshost.com/windows-scripts/install-extensions.cmd] install_extensions.cmd]. New: clean-extensions.cmd is needed for removing older versions of the same extension, too.
  
 
Be sure to
 
Be sure to

Revision as of 17:35, 6 December 2011

Firefox 3.6+ and Extension Installation Files

Here are the command and xml files listed for use by Firefox#Firefox_3.6_Series_Extension_Templates. The idea comes from [[1] Mozilla Forum Discussion] and the files are adapted from [[2] install_extensions.cmd]. New: clean-extensions.cmd is needed for removing older versions of the same extension, too.

Be sure to

* put 7zip into packages\mozilla\7-Zip\
* adjust the local path (here: C:\NETINST) if needed
* have the right directory tree

My structure for mozilla installations:

packages
packages/mozilla/
packages/mozilla/fx_extensions
packages/mozilla/fx_profile
packages/mozilla/tb_extensions
packages/mozilla/7-zip

packages/mozilla/install-extensions.cmd

:: Mozilla extension installation demo script for Firefox and Thunderbird versions
:: based on Gecko 1.9+ from which the -install-global-extension command line option
:: has been removed. This script must be run from a Windows account with local
:: administrative rights. The extensions it installs can be run immediately by
:: limited users.
::
:: Stephen Thomas <flabdablet (at) gmail.com> 31-Jan-2010
::
:: This is free software. Do whatever you want with it except hold me accountable
:: for the grief it will undoubtedly cause you. If you improve it, I'd like to hear
:: from you.


set mozextn=call :mozextn
set return=goto :eof
set rmdir=rmdir /s /q
:: set xpidir=C:\NETINST
set xpidir=%SOFTWARE%\packages\mozilla\fx_extensions
:: set zip="%ProgramFiles%\7-Zip\7z.exe"
set zip="%SOFTWARE%\packages\mozilla\7-Zip\7z.exe"

:: :: give args on command line
:: Firefox myextension
:: Thunderbird myextension
::    (myextension without .xpi)
%mozextn% %1 %2
%return%



:: Install a Mozilla extension XPI package into a system-wide folder, and add
:: the registry key required to tell the Mozilla app it's there.
::
:: Uses the same root folder for all packages regardless of whether they are
:: intended for Firefox or Thunderbird; this allows both apps to share disk space
:: for any extensions they have in common.
::
:: If there's already a folder in "%ProgramFiles%\Mozilla %appname%\extensions"
:: named for the ID of the extension being installed, or if the registry key
:: already exists and points to a different folder from the new one, the old
:: folders are deleted before the registry key is updated.
::
:: Parameters:
::
:: %1:	app name (Firefox or Thunderbird)
:: %2:	XPI package name, without trailing .xpi; also used to name the
::	installation folder.
::
:: Returns errorlevel 0 if installation worked, 1 if not.
::
:: Uses a totally unsound hack to extract the package ID from its install.rdf
:: file; will break horribly if the first <em:id> XML tag encountered does not
:: belong to the package ID, or if <em:id>package-id</em:id> is not all on
:: one line. If you'd rather use a proper XML parser instead, be my guest. If
:: it's really easy to do, let me know.

:mozextn
if exist "%ProgramFiles%\Mozilla Firefox\firefox.exe" goto :nurXP
if not exist "%ProgramFiles(x86)%\Mozilla Firefox\firefox.exe" %return%
:nur32
set extnroot=%CommonProgramFiles(x86)%\Mozilla Shared\Extensions
if not exist "%extnroot%" mkdir "%extnroot%"
if errorlevel 1 %return%
set key=HKLM\Software\Wow6432Node\Mozilla\%1\Extensions

goto nextall
:nurXP
set extnroot=%CommonProgramFiles%\Mozilla Shared\Extensions
if not exist "%extnroot%" mkdir "%extnroot%"
if errorlevel 1 %return%
set key=HKLM\Software\Mozilla\%1\Extensions
:nextall
set extndir=%extnroot%\%2
if exist "%extndir%" %rmdir% "%extndir%"
%zip% x -yo"%extndir%" "%xpidir%\%2.xpi"
if errorlevel 1 %return%

for /f "skip=2 tokens=*" %%L in ('find "<em:id>" "%extndir%\install.rdf"') do @(
	set line="%%L"
	goto :mozextn1
)

:mozextn1
set id=%line:~8,-9%
if "%id%"=="" (
	%rmdir% "%extndir%"
	verify error 2>nul
	%return%
)

set olddir=%ProgramFiles%\Mozilla %1\extensions\%id%
if exist "%olddir%" %rmdir% "%olddir%"

for /f "skip=4 tokens=2*" %%A in ('reg query "%key%" /v "%id%"') do set olddir=%%B
if not "%olddir%"=="%extndir%" if exist "%olddir%" %rmdir% "%olddir%"

reg add "%key%" /v "%id%" /d "%extndir%" /f
%return%

packages/mozilla/remove-extensions.cmd

:: Mozilla extension installation demo script for Firefox and Thunderbird versions
:: based on Gecko 1.9+ from which the -install-global-extension command line option
:: has been removed. This script must be run from a Windows account with local
:: administrative rights. The extensions it installs can be run immediately by
:: limited users.
::
:: Falko Trojahn <falko (at) trojahn (dot) de> 01-May-2010
:: adapted from
:: Stephen Thomas <flabdablet (at) gmail.com> 31-Jan-2010
::
:: This is free software. Do whatever you want with it except hold me accountable
:: for the grief it will undoubtedly cause you. If you improve it, I'd like to hear
:: from you.


set mozextn=call :mozextn
set return=goto :eof
set rmdir=rmdir /s /q
set xpidir=c:\netinst
set zip="%ProgramFiles%\7-Zip\7z.exe"

:: :: give args on command line
:: Firefox myextension
:: Thunderbird myextension
::    (myextension without .xpi)
%mozextn% %1 %2
%return%



:: REMOVE a Mozilla extension XPI package from a system-wide folder, and delete
:: the registry key required to tell the Mozilla app it's there.
::
:: Uses the same root folder for all packages regardless of whether they are
:: intended for Firefox or Thunderbird; this allows both apps to share disk space
:: for any extensions they have in common.
::
:: If there's already a folder in "%ProgramFiles%\Mozilla %appname%\extensions"
:: named for the ID of the extension being installed, or if the registry key
:: already exists and points to a different folder from the new one, the old
:: folders are deleted before the registry key is updated.
::
:: Parameters:
::
:: %1:	app name (Firefox or Thunderbird)
:: %2:	XPI package name, without trailing .xpi; also used to name the
::	installation folder.
::
:: Returns errorlevel 0 if installation worked, 1 if not.
::
:: Uses a totally unsound hack to extract the package ID from its install.rdf
:: file; will break horribly if the first <em:id> XML tag encountered does not
:: belong to the package ID, or if <em:id>package-id</em:id> is not all on
:: one line. If you'd rather use a proper XML parser instead, be my guest. If
:: it's really easy to do, let me know.

:mozextn
if exist "%ProgramFiles%\Mozilla Firefox\firefox.exe" goto :nurXP
if not exist "%ProgramFiles(x86)%\Mozilla Firefox\firefox.exe" %return%
:nur32
set extnroot=%CommonProgramFiles(x86)%\Mozilla Shared\Extensions
if not exist "%extnroot%" mkdir "%extnroot%"
if errorlevel 1 %return%
set key=HKLM\Software\Wow6432Node\Mozilla\%1\Extensions


goto nextall
:nurXP
set extnroot=%CommonProgramFiles%\Mozilla Shared\Extensions
if not exist "%extnroot%" mkdir "%extnroot%"
if errorlevel 1 %return%
set key=HKLM\Software\Mozilla\%1\Extensions

:nextall

set extndir=%extnroot%\%2

for /f "skip=2 tokens=*" %%L in ('find "<em:id>" "%extndir%\install.rdf"') do @(
	set line="%%L"
	goto :mozextn1
)


:mozextn1
set id=%line:~8,-9%
if "%id%"=="" (
	verify error 2>nul
	%return%
)


for /f "skip=4 tokens=2*" %%A in ('reg query "%key%" /v "%id%"') do set olddir=%%B
if "%olddir%"=="%extndir%" if exist "%olddir%" %rmdir% "%olddir%"

reg delete "%key%" /v "%id%" /f
%return%

packages/mozilla/clean-extensions.cmd

:: Mozilla extension installation demo script for Firefox and Thunderbird versions
:: based on Gecko 1.9+ from which the -install-global-extension command line option
:: has been removed. This script must be run from a Windows account with local
:: administrative rights. The extensions it installs can be run immediately by
:: limited users.
::
:: Falko Trojahn <falko (at) trojahn (dot) de> 01-May-2010
:: adapted from
:: Stephen Thomas <flabdablet (at) gmail.com> 31-Jan-2010
::
:: This is free software. Do whatever you want with it except hold me accountable
:: for the grief it will undoubtedly cause you. If you improve it, I'd like to hear
:: from you.


set mozextn=call :mozextn
set return=goto :eof
set rmdir=rmdir /s /q
set xpidir=c:\netinst
set zip="%ProgramFiles%\7-Zip\7z.exe"

:: :: give args on command line
:: Firefox myextension myextname
:: Thunderbird myextension myextname
::    (myextension without .xpi)
::    (myextname without VERSION and .xpi)
%mozextn% %1 %2 %3
%return%



:: REMOVE a Mozilla extension XPI package from a system-wide folder, and delete
:: the registry key required to tell the Mozilla app it's there.
::
:: Uses the same root folder for all packages regardless of whether they are
:: intended for Firefox or Thunderbird; this allows both apps to share disk space
:: for any extensions they have in common.
::
:: If there's already a folder in "%ProgramFiles%\Mozilla %appname%\extensions"
:: named for the ID of the extension being installed, or if the registry key
:: already exists and points to a different folder from the new one, the old
:: folders are deleted before the registry key is updated.
::
:: Parameters:
::
:: %1:	app name (Firefox or Thunderbird)
:: %2:	XPI package name, without trailing .xpi; also used to name the
::	installation folder.
::
:: Returns errorlevel 0 if installation worked, 1 if not.
::
:: Uses a totally unsound hack to extract the package ID from its install.rdf
:: file; will break horribly if the first <em:id> XML tag encountered does not
:: belong to the package ID, or if <em:id>package-id</em:id> is not all on
:: one line. If you'd rather use a proper XML parser instead, be my guest. If
:: it's really easy to do, let me know.

:mozextn
if exist "%ProgramFiles%\Mozilla Firefox\firefox.exe" goto :nurXP
if not exist "%ProgramFiles(x86)%\Mozilla Firefox\firefox.exe" %return%
:nur32
set extnroot=%CommonProgramFiles(x86)%\Mozilla Shared\Extensions
if not exist "%extnroot%" mkdir "%extnroot%"
if errorlevel 1 %return%
set key=HKLM\Software\Wow6432Node\Mozilla\%1\Extensions


goto nextall
:nurXP
set extnroot=%CommonProgramFiles%\Mozilla Shared\Extensions
if not exist "%extnroot%" mkdir "%extnroot%"
if errorlevel 1 %return%
set key=HKLM\Software\Mozilla\%1\Extensions

:nextall

set extndir=%extnroot%\%2

for /f "skip=2 tokens=*" %%L in ('find "<em:id>" "%extndir%\install.rdf"') do @(
	set line="%%L"
	goto :mozextn1
)


:mozextn1
set id=%line:~8,-9%
if "%id%"=="" (
	verify error 2>nul
	goto : clean
)


for /f "skip=4 tokens=2*" %%A in ('reg query "%key%" /v "%id%"') do set olddir=%%B
if "%olddir%"=="%extndir%" if exist "%olddir%" %rmdir% "%olddir%"

reg delete "%key%" /v "%id%" /f

:clean
for /f "tokens=*" %%i in ('dir /ad /b "%extnroot%\%3*"') do rmdir "%extnroot%\%%i" /s /q

%return%

profiles/firefox36.xml

To have all needed things at hand, here is a profile file firefox36.xml:

<?xml version="1.0" encoding="UTF-8"?>

<profiles>

    <profile id="firefox36">
        <package package-id="firefox36" />
	<package package-id="firefox-ext-adblock_plus" />
        <package package-id="firefox-ext-bookmarkdd" />
        <package package-id="firefox-ext-dict_de-de_hunspell" /> 
        <package package-id="firefox-ext-downthemall" />
        <package package-id="firefox-ext-ie_view" /> 
        <package package-id="firefox-ext-screengrab" />
        <package package-id="firefox-ext-selection_links" /> 
    </profile>

    <profile id="firefox36-dev">
        <depends profile-id="firefox36" />
        <package package-id="firefox-ext-aardvark" />
        <package package-id="firefox-ext-firebug" /> 
	<package package-id="firefox-ext-fireftp" />  
	<package package-id="firefox-ext-colorzilla" />
	<package package-id="firefox-ext-quick_locale_switcher" />
	<package package-id="firefox-ext-split_browser" />  
        <package package-id="firefox-ext-web_developer" /> 
    </profile>

</profiles>

templates/ff-extension.xml

<package id='firefox-ext-&ext-name;' name='Firefox Extension &ext-name;' revision='&ext-key;' priority='15'>
    <variable name='fxext' value='&ext-name;-&ext-key;'/>
    <variable name='fxname' value='&ext-name;-'/>
  <check type="logical" condition="or">
    <check type="file" condition="exists" path="%CommonProgramFiles%\Mozilla Shared\Extensions\%FXEXT%\install.rdf" />
    <check type="file" condition="exists" path="%CommonProgramFiles(x86)%\Mozilla Shared\Extensions\%FXEXT%\install.rdf" />
  </check>
    <depends package-id="firefox-check" />
    <install cmd='"%SOFTWARE%\packages\mozilla\install-extensions.cmd" Firefox %FXEXT% >c:\netinst\logs\%FXEXT%-install.log'/>
    <upgrade cmd='%SOFTWARE%\tools\pskill.exe firefox.exe'> <exit code="-1" /> </upgrade>
    <upgrade cmd='"%SOFTWARE%\packages\mozilla\clean-extensions.cmd" Firefox %FXEXT% %FXNAME%>c:\netinst\logs\%FXNAME%-upgrade.log'/>
    <upgrade cmd='"%SOFTWARE%\packages\mozilla\install-extensions.cmd" Firefox %FXEXT% >c:\netinst\logs\%FXEXT%-upgrade.log'/>
    <downgrade cmd='%SOFTWARE%\tools\pskill.exe firefox.exe'> <exit code="-1" /> </downgrade>
    <downgrade cmd='"%SOFTWARE%\packages\mozilla\clean-extensions.cmd" Firefox %FXEXT% %FXNAME%>c:\netinst\logs\%FXNAME%-downgrade.log'/>
    <downgrade cmd='"%SOFTWARE%\packages\mozilla\install-extensions.cmd" Firefox %FXEXT% >c:\netinst\logs\%FXEXT%-downgrade.log'/>
    <remove cmd='"%SOFTWARE%\packages\mozilla\remove-extensions.cmd" Firefox %FXEXT% >c:\netinst\logs\%FXEXT%-remove.log'/>
    <remove cmd='cmd /c if exist "%CommonProgramFiles%\Mozilla Shared\Extensions\%FXEXT%\" rmdir /s /q "%CommonProgramFiles%\Mozilla Shared\Extensions\%FXEXT%\"' />
    <remove cmd='cmd /c if exist "%CommonProgramFiles(x86)%\Mozilla Shared\Extensions\%FXEXT%\" rmdir /s /q "%CommonProgramFiles(x86)%\Mozilla Shared\Extensions\%FXEXT%\"' />
</package>

packages/firefox-ext-skel.xml

Skeleton file for adding new extension by copying "firefox-ext-skel.xml to "firefox-ext-(name).xml".

<!DOCTYPE firefoxextension [ <!ENTITY ext-name "XX"> <!ENTITY ext-key "XX-00"> <!ENTITY ff-extension SYSTEM "../templates/ff-extension.xml"> ]>
<packages>&ff-extension;</packages>

Change "XX" to name of extension, "XX-00" to extension key of the file.

Example: screengrab-0.96.3-fx.xpi

* XX    -> screengrab  
* XX-00 -> 0.96.3-fx

packages/firefox36.xml

An additional "firefox check" package is used as dependancy in the extension template, as extensions do not depend from a certain firefox version and therefor need not to be removed when doing a upgrade later to the next firefox generation.

<?xml version="1.0" encoding="UTF-8"?>

<packages>
<package
		id="firefox-check"
		name="Mozilla Firefox 3 installed"
		revision="1"
		reboot="false"
		priority="20">
 
		<check type="file" condition="versiongreaterorequal" path="%programfiles%\mozilla firefox\firefox.exe" value="1.9.1.3642" /> 
	</package>

<package
		id="firefox36"
		name="Mozilla Firefox 3"
		revision="30612"
		reboot="false"
		priority="99">
 
		<check type="file" condition="versiongreaterorequal" path="%programfiles%\mozilla firefox\firefox.exe" value="1.9.2.3951" /> 
	    <install cmd='%SOFTWARE%\tools\pskill.exe firefox.exe'>
            <exit code="-1" />
        </install>
           <install cmd='cmd /c if exist "%programfiles%\mozilla firefox\firefox.exe" move /y "%programfiles%\mozilla firefox" "%programfiles%\mozilla firefox.bak"' >
             <exit code="1" />
           </install>
	   <install cmd='"%SOFTWARE%\packages\mozilla\firefox-30612-deu.exe" -ms' />
           <install cmd='cmd /c if exist "%programfiles%\mozilla firefox.bak\searchplugins" copy /y "%programfiles%\mozilla firefox.bak\searchplugins\*" "%programfiles%\mozilla firefox\searchplugins\"' >
             <exit code="1" />
             <exit code="0" />
           </install>
           <install cmd='"%PROGRAMFILES%\Mozilla Firefox\firefox.exe" -CreateProfile default '>
             <exit code="0" />
     	</install>

	    <upgrade cmd='%SOFTWARE%\tools\pskill.exe firefox.exe'>
            <exit code="-1" />
        </upgrade>
	<upgrade cmd='"%SOFTWARE%\packages\mozilla\firefox-30612-deu.exe" -ms' />
	    <remove cmd='%SOFTWARE%\tools\pskill.exe firefox.exe'>
            <exit code="-1" />
        </remove>
		<remove cmd="%PROGRAMFILES%\Mozilla Firefox\uninstall\helper.exe /s" />
	</package>

</packages>

packages/firefox.xml

<?xml version="1.0" encoding="UTF-8"?>

<packages>
  <package
		id="firefox-check"
		name="Mozilla Firefox installed"
		revision="1"
		reboot="false"
		priority="20">
		<check type="logical" condition="or">
			<check type="file" condition="versiongreaterorequal" path="%programfiles%\mozilla firefox\firefox.exe" value="2.0.0.4094" /> 
			<check type="file" condition="versiongreaterorequal" path="%programfiles(x86)%\mozilla firefox\firefox.exe" value="2.0.0.4094" /> 
		</check>
  </package>

  <package
		id="firefox"
		name="Mozilla Firefox 8"
		revision="%version%"
		reboot="false"
		priority="99">
		<variable name="version" value="80001" />
 
		<check type="logical" condition="or">
			<check type="file" condition="versiongreaterorequal" path="%programfiles%\mozilla firefox\firefox.exe" value="8.0.1.4341" /> 
			<check type="file" condition="versiongreaterorequal" path="%programfiles(x86)%\mozilla firefox\firefox.exe" value="8.0.1.4341" /> 
		</check>
	    <install cmd='%SOFTWARE%\tools\pskill.exe firefox.exe'>
            <exit code="-1" />
        </install>
           <install cmd='%COMSPEC% /c if exist "%programfiles%\mozilla firefox\firefox.exe" move /y "%programfiles%\mozilla firefox" "%programfiles%\mozilla firefox.bak"' >
             <exit code="1" />
           </install>
	   <install cmd='%SOFTWARE%\packages\mozilla\firefox-%version%-deu.exe -ms' />
           <install cmd='%COMSPEC% /c if exist "%programfiles%\mozilla firefox.bak\searchplugins" copy /y "%programfiles%\mozilla firefox.bak\searchplugins\*" "%programfiles%\mozilla firefox\searchplugins\"' >
             <exit code="1" />
             <exit code="0" />
           </install>
           <install cmd='%COMSPEC% /c if exist "%programfiles(x86)%\mozilla firefox.bak\searchplugins" copy /y "%programfiles(x86)%\mozilla firefox.bak\searchplugins\*" "%programfiles%\mozilla firefox\searchplugins\"' >
             <exit code="1" />
             <exit code="0" />
           </install>
           <install cmd='%COMSPEC% /c if exist "%programfiles%\mozilla firefox" xcopy /v /s /i /e /h /c /y /q "%SOFTWARE%\packages\mozilla\fx_profile\*" "%programfiles%\mozilla firefox\"' >
             <exit code="1" />
           </install>
           <install cmd='%COMSPEC% /c if exist "%programfiles(x86)%\mozilla firefox" xcopy /v /s /i /e /h /c /y /q "%SOFTWARE%\packages\mozilla\fx_profile\*" "%programfiles(x86)%\mozilla firefox\"' >
             <exit code="1" />
           </install>
           <install cmd='%COMSPEC% /c if exist "%PROGRAMFILES%\Mozilla Firefox\firefox.exe" "%PROGRAMFILES%\Mozilla Firefox\firefox.exe" -CreateProfile default '>
             <exit code="1" />
             <exit code="0" />
     	</install>
           <install cmd='%COMSPEC% /c if exist "%PROGRAMFILES(x86)%\Mozilla Firefox\firefox.exe" "%PROGRAMFILES(x86)%\Mozilla Firefox\firefox.exe" -CreateProfile default '>
             <exit code="1" />
             <exit code="0" />
     	</install>

	    <upgrade cmd='%SOFTWARE%\tools\pskill.exe firefox.exe'>
            <exit code="-1" />
        </upgrade>
	<upgrade cmd='"%SOFTWARE%\packages\mozilla\firefox-%version%-deu.exe" -ms' />
        <upgrade cmd='%COMSPEC% /c if exist "%programfiles(x86)%\mozilla firefox" xcopy /v /s /i /e /h /c /y /q "%SOFTWARE%\packages\mozilla\fx_profile\*" "%programfiles(x86)%\mozilla firefox\"' >
            <exit code="1" />
        </upgrade>
        <upgrade cmd='%COMSPEC% /c if exist "%programfiles%\mozilla firefox" xcopy /v /s /i /e /h /c /y /q "%SOFTWARE%\packages\mozilla\fx_profile\*" "%programfiles%\mozilla firefox\"' >
            <exit code="1" />
        </upgrade>
	    <remove cmd='%SOFTWARE%\tools\pskill.exe firefox.exe'>
            <exit code="-1" />
        </remove>
		<remove cmd="%PROGRAMFILES%\Mozilla Firefox\uninstall\helper.exe /s" />
	</package>

  </packages>

Remarks

There are reported problems (bugs ?) using quoted strings within cmd files. Egfor %zip% . You may have to replace

set zip="%SOFTWARE%\packages\mozilla\7-Zip\7z.exe"
with
set zip=%SOFTWARE%\packages\mozilla\7-Zip\7z.exe
in both install-extensions.cmd and remove-extensions.cmd.

For Windows non-specialists, it's possible to hunt bugs/problems redirecting cmd file output to a log file. Replace >NUL in the template file to some >> %SYSTEMDRIVE%\myplace\myfile.txt (for example).