From Fedora Project Wiki
No edit summary
(added rpm macros)
Line 8: Line 8:


Rationale:
Rationale:
== RPM macros ==
XXX: the verbatim rpm macros are here just for demonstration purposes and should be removed in the final text.
<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
%_firefox_extdir        %{_mozilla_extdir}/%{firefox_app_id}
%_thunderbird_extdir    %{_mozilla_extdir}/%{thunderbird_app_id}
%_seamonkey_extdir      %{_mozilla_extdir}/%{seamonkey_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>


== Installation Directories ==
== Installation Directories ==

Revision as of 12:26, 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.

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.

Rationale:

RPM macros

XXX: the verbatim rpm macros are here just for demonstration purposes and should be removed in the final text.

%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
%_firefox_extdir        %{_mozilla_extdir}/%{firefox_app_id}
%_thunderbird_extdir    %{_mozilla_extdir}/%{thunderbird_app_id}
%_seamonkey_extdir      %{_mozilla_extdir}/%{seamonkey_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}

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.

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.

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

# Firefox
mkdir -p $RPM_BUILD_ROOT%{_firefox_extdir}
ln -s %{_moz_ext_commondir}/{extension_name} $RPM_BUILD_ROOT%{_firefox_extdir}/{extension_id}
# Thunderbird
mkdir -p $RPM_BUILD_ROOT%{_thunderbird_extdir}
ln -s %{_moz_ext_commondir}/{extension_name} $RPM_BUILD_ROOT%{_thunderbird_extdir}/{extension_id}

Rationale:

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
_moz_ext_commondir 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
_spicebird_extdir Spicebird 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