From Fedora Project Wiki
No edit summary
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 3: Line 3:
== Draft for Packaging Mozilla Extensions ==
== Draft for Packaging Mozilla Extensions ==
This is a draft for packaging extensions for Mozilla applications: Firefox, Thunderbird, Seamonkey, and others.
This is a draft for packaging extensions for Mozilla applications: Firefox, Thunderbird, Seamonkey, and others.
XXX: The lines marked with XXX throughout the text are comments for the draft and to be removed in the final version.


== Naming ==
== Naming ==
Packages of Mozilla extensions should take into account the upstream name of the extension. All Mozilla extensions MUST follow the scheme of mozilla-<extension>, where <extension> is the name of the extension. Examples include mozilla-adblockplus, mozilla-noscript.
Packages of Mozilla extensions should take into account the upstream name of the extension. All Mozilla extensions MUST follow the scheme of mozilla-<extension>, where <extension> is the name of the extension. Examples include mozilla-adblockplus, mozilla-noscript.
XXX: Debian uses xul-ext-<extension> and openSUSE has an add-on repo with packages following mozilla-ext-<extension> naming. In Fedora, however, the existing packages have so far used mozilla-<extension>, and changing it now would create too much additional work.


Rationale:
Rationale:
Following a common naming scheme makes it easier for users to locate the extensions. mozilla- prefix creates a visually separate group in package lists and makes it easier to browse through available extension packages. Using e.g. firefox- or thunderbird- prefix for some packages would create visual clutter in package lists and is therefore not recommended.


== Installation Directories ==
== Installation Directories ==
Packages for Mozilla extensions should place unpacked files in %{_datadir}/mozilla/extensions/common/<extension>/ directory, where <extension> is the name of the package without the mozilla- prefix. Packages that contain architecture specific files should instead use %{_libdir}/mozilla/extensions/<extension>/ directory.
Packages for Mozilla extensions should place unpacked files in %{_datadir}/mozilla/extensions/common/<package_name>/ directory. This is just a directory for keeping the files in and it's worth pointing out that Mozilla apps don't look in there on their own. The convenience macro <code>%{_mozilla_common_extdir}</code> expands to either %{_datadir}/mozilla/extensions/common or %{_libdir}/mozilla/extensions/common, depending on whether the package is noarch.
 
The macro <code>%xpi_unpack -f <filename.xpi></code> takes care of unpacking the .xpi in the correct directory.
 
To register the extension for Mozilla applications, the extension packages use symlinks which point back to the directory in <code>%{_mozilla_common_extdir}</code>. The symlinks need to be dropped to %{_datadir}/mozilla/extensions/<app_guid>/ directory.


To register an extension for a Mozilla application, the package should drop into the application's extension directory symlinks which point to the actual files in the %{_datadir}/mozilla/extensions/common/<extension>/ directory.
The macro <code>%xpi_symlink -a <app_guid></code> takes care of creating the symlinks and registering the extension.


For an  example, to register the extension for Mozilla and Thunderbird, the package should:
For an  example, to register the extension for Mozilla and Thunderbird, the package should:
<pre>
<pre>
# Firefox
# The identifier for this extension, taken from install.rdf;
mkdir -p $RPM_BUILD_ROOT%{_firefox_extdir}
# used by the rpm macros for registering the extension.
ln -s %{_moz_ext_commondir}/{extension_name} $RPM_BUILD_ROOT%{_firefox_extdir}/{extension_id}
%global _mozilla_extension_id \{12345678-9876-5432-abcd-123456789012\}
# Thunderbird
 
mkdir -p $RPM_BUILD_ROOT%{_thunderbird_extdir}
# Unpack the .xpi in _mozilla_common_extdir:
ln -s %{_moz_ext_commondir}/{extension_name} $RPM_BUILD_ROOT%{_thunderbird_extdir}/{extension_id}
%xpi_unpack -f myextension.xpi
 
# Register for Firefox
%xpi_symlink -a %{firefox_app_id}
 
# Register for Thunderbird
%xpi_symlink -a %{thunderbird_app_id}
</pre>
</pre>
Rationale:


== Directory Ownership ==
== Directory Ownership ==
Line 47: Line 60:
!Macro!!Usage
!Macro!!Usage
|-
|-
|_moz_ext_commondir||Directory where extension packages should install actual files.
|_mozilla_common_extdir||Directory where extension packages should install actual files.
|-
|-
|_chatzilla_extdir||Chatzilla extension directory for dropping symlinks in
|_chatzilla_extdir||Chatzilla extension directory for dropping symlinks in
Line 54: Line 67:
|-
|-
|_seamonkey_extdir||Seamonkey extension directory for dropping symlinks in
|_seamonkey_extdir||Seamonkey extension directory for dropping symlinks in
|-
|_spicebird_extdir||Spicebird extension directory for dropping symlinks in
|-
|-
|_sunbird_extdir||Sunbird extension directory for dropping symlinks in
|_sunbird_extdir||Sunbird extension directory for dropping symlinks in
Line 65: Line 76:
== Sample Spec File ==
== Sample Spec File ==
<pre>
<pre>
# The identifier for this extension, taken from install.rdf;
# used by the rpm macros later on.
%global _mozilla_extension_id \{12345678-9876-5432-abcd-123456789012\}
Name:          mozilla-awesomeextension
Version:        0.1
Release:        1%{?dist}
Summary:        Awesome extension for Mozilla browsers
License:        ...
URL:            ...
Source0:        ...
# XXX: do we want the rpm macros in mozilla-filesystem or somewhere else?
BuildRequires:  mozilla-filesystem
Requires:      mozilla-filesystem
BuildArch:      noarch
%description
Awesome extension for Mozilla browsers.
%prep
%setup -q -n awesomeextension-%{version}
%build
%configure
make %{?_smp_mflags}
%install
# Install the Mozilla extension
%xpi_unpack -f myawesomeextension-*.xpi
# Register the extension for the apps
%xpi_symlink -a %{firefox_app_id}
%xpi_symlink -a %{seamonkey_app_id}
%xpi_symlink -a %{thunderbird_app_id}
%files
%doc COPYING
%{_mozilla_common_extdir}/%{name}/
%{_firefox_extdir}/
%{_seamoney_extdir}/
%{_thunderbird_extdir}/
%changelog
* Wed Aug 10 2011 Kalev Lember <kalevlember@gmail.com> - 0.1-1
- Initial RPM release
</pre>
== Appendix A: RPM macros ==
XXX: the macros are here just for demonstration purposes and are to be removed in the final text. The macros are most likely to end up in mozilla-filesystem or redhat-rpm-config package.
<pre>
%chatzilla_app_id  \{59c81df5-4b7a-477b-912d-4e0fdf64e5f2\}
%firefox_app_id    \{ec8030f7-c20a-464f-9b0e-13a3a9e97384\}
%seamonkey_app_id  \{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a\}
%sunbird_app_id    \{718e30fb-e89b-41dd-9da7-e25a45638b28\}
%thunderbird_app_id \{3550f703-e582-4d05-9a08-453d09bdfdc6\}
# If the package is noarch, put the files in /usr/share, otherwise use the libdir.
%_mozilla_extdir %( \
    if [ x"%{_target_cpu}" = x"noarch" ] || [ -n "%{?_mozilla_extension_force_noarch}" ]; then \
        echo "%{_datadir}/mozilla/extensions"; \
    else \
        echo "%{_libdir}/mozilla/extensions"; \
    fi \
)
%_mozilla_common_extdir %{_mozilla_extdir}/common
%_chatzilla_extdir      %{_mozilla_extdir}/%{chatzilla_app_id}
%_firefox_extdir        %{_mozilla_extdir}/%{firefox_app_id}
%_seamonkey_extdir      %{_mozilla_extdir}/%{seamonkey_app_id}
%_sunbird_extdir        %{_mozilla_extdir}/%{sunbird_app_id}
%_thunderbird_extdir    %{_mozilla_extdir}/%{thunderbird_app_id}
%xpi_unpack(f:n:) \
    %{!-f: %{error:Missing parameter -f <file> for macro xpi_unpack} exit 1} \
\
    %define xpi %{-f*} \
    %define extension_name %{-n*}%{!-n:%{name}} \
\
    mkdir -p "$RPM_BUILD_ROOT%{_mozilla_common_extdir}/%{extension_name}" \
    unzip "%xpi" -d "$RPM_BUILD_ROOT%{_mozilla_common_extdir}/%{extension_name}" \
%{nil}
%xpi_symlink(a:n:) \
    %{!-a: %{error:Missing parameter -a <app_id> for macro xpi_symlink} exit 1} \
    %{!?_mozilla_extension_id: %{error:Define _mozilla_extension_id before invoking macro xpi_symlink} exit 1 } \
\
    %define app_id %{-a*} \
    %define extension_name %{-n*}%{!-n:%{name}} \
\
    mkdir -p "$RPM_BUILD_ROOT%{_mozilla_extdir}/%{app_id}" \
    pushd "$RPM_BUILD_ROOT%{_mozilla_extdir}/%{app_id}" \
        ln -s "%{_mozilla_common_extdir}/%{extension_name}" "%{_mozilla_extension_id}" \
    popd \
%{nil}
</pre>
</pre>

Latest revision as of 13:21, 11 August 2011

This page is a draft only
It is still under construction and content may change. Do not rely on the information on this page.

Draft for Packaging Mozilla Extensions

This is a draft for packaging extensions for Mozilla applications: Firefox, Thunderbird, Seamonkey, and others.

XXX: The lines marked with XXX throughout the text are comments for the draft and to be removed in the final version.

Naming

Packages of Mozilla extensions should take into account the upstream name of the extension. All Mozilla extensions MUST follow the scheme of mozilla-<extension>, where <extension> is the name of the extension. Examples include mozilla-adblockplus, mozilla-noscript.

XXX: Debian uses xul-ext-<extension> and openSUSE has an add-on repo with packages following mozilla-ext-<extension> naming. In Fedora, however, the existing packages have so far used mozilla-<extension>, and changing it now would create too much additional work.

Rationale: Following a common naming scheme makes it easier for users to locate the extensions. mozilla- prefix creates a visually separate group in package lists and makes it easier to browse through available extension packages. Using e.g. firefox- or thunderbird- prefix for some packages would create visual clutter in package lists and is therefore not recommended.

Installation Directories

Packages for Mozilla extensions should place unpacked files in %{_datadir}/mozilla/extensions/common/<package_name>/ directory. This is just a directory for keeping the files in and it's worth pointing out that Mozilla apps don't look in there on their own. The convenience macro %{_mozilla_common_extdir} expands to either %{_datadir}/mozilla/extensions/common or %{_libdir}/mozilla/extensions/common, depending on whether the package is noarch.

The macro %xpi_unpack -f <filename.xpi> takes care of unpacking the .xpi in the correct directory.

To register the extension for Mozilla applications, the extension packages use symlinks which point back to the directory in %{_mozilla_common_extdir}. The symlinks need to be dropped to %{_datadir}/mozilla/extensions/<app_guid>/ directory.

The macro %xpi_symlink -a <app_guid> takes care of creating the symlinks and registering the extension.

For an example, to register the extension for Mozilla and Thunderbird, the package should:

# The identifier for this extension, taken from install.rdf;
# used by the rpm macros for registering the extension.
%global _mozilla_extension_id \{12345678-9876-5432-abcd-123456789012\}

# Unpack the .xpi in _mozilla_common_extdir:
%xpi_unpack -f myextension.xpi

# Register for Firefox
%xpi_symlink -a %{firefox_app_id}

# Register for Thunderbird
%xpi_symlink -a %{thunderbird_app_id}

Directory Ownership

Mozilla extension packages should Require mozilla-filesystem for common directories, but avoid depending on specific Mozilla applications. Each of the %{_<appname>_extdir} directory where the extension package drops symlinks in, should also be owned by the same extension package.

XXX: What to do with %{_mozilla_common_extdir}? Is mozilla-filesystem going to own it or should the extension packages own it?

Sample %files section:

%files
%{_mozilla_common_extdir}/%{name}/
%{_firefox_extdir}/
%{_seamonkey_extdir}/
%{_thunderbird_extdir}/

Rationale: RPM needs to keep track of the installed directories, so that it could remove them on uninstall. When installing extensions, we drop symlinks to multiple application directories and want to avoid depending on these apps just to satisfy directory ownership requirements. Because of that, Mozilla extension packages need to own all the %{_<appname>_extdir} directories they drop symlinks in, so rpm could track these directories and remove them when the extension package is uninstalled.

Macros

Macro Usage
_mozilla_common_extdir Directory where extension packages should install actual files.
_chatzilla_extdir Chatzilla extension directory for dropping symlinks in
_firefox_extdir Firefox extension directory for dropping symlinks in
_seamonkey_extdir Seamonkey extension directory for dropping symlinks in
_sunbird_extdir Sunbird extension directory for dropping symlinks in
_thunderbird_extdir Thunderbird extension directory for dropping symlinks in

Sample Spec File

# The identifier for this extension, taken from install.rdf;
# used by the rpm macros later on.
%global _mozilla_extension_id \{12345678-9876-5432-abcd-123456789012\}

Name:           mozilla-awesomeextension
Version:        0.1
Release:        1%{?dist}
Summary:        Awesome extension for Mozilla browsers

License:        ...
URL:            ...
Source0:        ...

# XXX: do we want the rpm macros in mozilla-filesystem or somewhere else?
BuildRequires:  mozilla-filesystem
Requires:       mozilla-filesystem
BuildArch:      noarch

%description
Awesome extension for Mozilla browsers.

%prep
%setup -q -n awesomeextension-%{version}

%build
%configure
make %{?_smp_mflags}

%install
# Install the Mozilla extension
%xpi_unpack -f myawesomeextension-*.xpi
# Register the extension for the apps
%xpi_symlink -a %{firefox_app_id}
%xpi_symlink -a %{seamonkey_app_id}
%xpi_symlink -a %{thunderbird_app_id}

%files
%doc COPYING
%{_mozilla_common_extdir}/%{name}/
%{_firefox_extdir}/
%{_seamoney_extdir}/
%{_thunderbird_extdir}/

%changelog
* Wed Aug 10 2011 Kalev Lember <kalevlember@gmail.com> - 0.1-1
- Initial RPM release


Appendix A: RPM macros

XXX: the macros are here just for demonstration purposes and are to be removed in the final text. The macros are most likely to end up in mozilla-filesystem or redhat-rpm-config package.

%chatzilla_app_id   \{59c81df5-4b7a-477b-912d-4e0fdf64e5f2\}
%firefox_app_id     \{ec8030f7-c20a-464f-9b0e-13a3a9e97384\}
%seamonkey_app_id   \{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a\}
%sunbird_app_id     \{718e30fb-e89b-41dd-9da7-e25a45638b28\}
%thunderbird_app_id \{3550f703-e582-4d05-9a08-453d09bdfdc6\}

# If the package is noarch, put the files in /usr/share, otherwise use the libdir.
%_mozilla_extdir %( \
    if [ x"%{_target_cpu}" = x"noarch" ] || [ -n "%{?_mozilla_extension_force_noarch}" ]; then \
        echo "%{_datadir}/mozilla/extensions"; \
    else \
        echo "%{_libdir}/mozilla/extensions"; \
    fi \
)

%_mozilla_common_extdir %{_mozilla_extdir}/common
%_chatzilla_extdir      %{_mozilla_extdir}/%{chatzilla_app_id}
%_firefox_extdir        %{_mozilla_extdir}/%{firefox_app_id}
%_seamonkey_extdir      %{_mozilla_extdir}/%{seamonkey_app_id}
%_sunbird_extdir        %{_mozilla_extdir}/%{sunbird_app_id}
%_thunderbird_extdir    %{_mozilla_extdir}/%{thunderbird_app_id}

%xpi_unpack(f:n:) \
    %{!-f: %{error:Missing parameter -f <file> for macro xpi_unpack} exit 1} \
\
    %define xpi %{-f*} \
    %define extension_name %{-n*}%{!-n:%{name}} \
\
    mkdir -p "$RPM_BUILD_ROOT%{_mozilla_common_extdir}/%{extension_name}" \
    unzip "%xpi" -d "$RPM_BUILD_ROOT%{_mozilla_common_extdir}/%{extension_name}" \
%{nil}

%xpi_symlink(a:n:) \
    %{!-a: %{error:Missing parameter -a <app_id> for macro xpi_symlink} exit 1} \
    %{!?_mozilla_extension_id: %{error:Define _mozilla_extension_id before invoking macro xpi_symlink} exit 1 } \
\
    %define app_id %{-a*} \
    %define extension_name %{-n*}%{!-n:%{name}} \
\
    mkdir -p "$RPM_BUILD_ROOT%{_mozilla_extdir}/%{app_id}" \
    pushd "$RPM_BUILD_ROOT%{_mozilla_extdir}/%{app_id}" \
        ln -s "%{_mozilla_common_extdir}/%{extension_name}" "%{_mozilla_extension_id}" \
    popd \
%{nil}