20
edits
Changes
Upgrade to recent FF release :-)
== Firefox 10+ and Extension Installation Files ==
Since FF 4, it is no longer required, even recommanded, to unzip xpi files. Thus the former cmd batch must be slightly adapted to provide full support of global extension installation. At the time, this part is written, it lacks the uninstall file test. So, to keep a sort of wpkg control, a simple hack is included (see inline explanations below).
===packages/mozilla/install-extensions.cmd===
<source lang="dos">
:: 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 copy=copy /Y
:: set xpidir=C:\NETINST
set xpidir=%SOFTWARE%\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
set extnroot=%CommonProgramFiles%\Mozilla Shared\Extensions
set extntemp=%temp%\
if not exist "%extnroot%" mkdir "%extnroot%"
if errorlevel 1 %return%
::set extndir=%extnroot%\%2
set extndir=%extntemp%\%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%"
if exist "%extndir%" %rmdir% "%extndir%"
set key=HKLM\Software\Mozilla\%1\Extensions
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 "%extnroot%\%id%.xpi" /f
:: Now we mustn't unzip xpi files to install them, only copy them to the id.xpi filenames :)
%copy% "%xpidir%\%2.xpi" "%extnroot%\%id%.xpi"
:: quick and dirty hack : we create an empty text file, which name will be used in the
:: wpkg xml file to check the success of the installation
@echo "%2" >"%extnroot%\%2.txt"
%return%
</source>
===packages/mozilla/remove-extensions.cmd===
To be provided
===templates/ff-extension.xml===
<source lang="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;-'/>
<!-- the old fashion check won't do the job anymore with xpi not unzipped unless we do some quick&dirty "hack" -->
<check type="logical" condition="or">
<check type="file" condition="exists" path="%CommonProgramFiles%\Mozilla Shared\Extensions\%FXEXT%.txt" />
<check type="file" condition="exists" path="%CommonProgramFiles(x86)%\Mozilla Shared\Extensions\%FXEXT%.txt" />
</check>
<depends package-id="firefox-check" />
<install cmd='"%SOFTWARE%\mozilla\install-extensions.cmd" Firefox %FXEXT% >%TEMP%\%FXEXT%-install.log'/>
<upgrade cmd='"%SOFTWARE%\mozilla\remove-extensions.cmd" Firefox %FXEXT% >%TEMP%\%FXEXT%-upgrade-remove.log'/>
<upgrade cmd='"%SOFTWARE%\mozilla\install-extensions.cmd" Firefox %FXEXT% >%TEMP%\%FXEXT%-upgrade.log'/>
<downgrade cmd='"%SOFTWARE%\mozilla\install-extensions.cmd" Firefox %FXEXT% >%TEMP%\%FXEXT%-downgrade.log'/>
<remove cmd='"%SOFTWARE%\mozilla\remove-extensions.cmd" Firefox %FXEXT% >%TEMP%\%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>
</source>
== Firefox 3.6+ and Extension Installation Files ==