From Fedora Project Wiki
No edit summary
No edit summary
Line 58: Line 58:


== Templates ==
== Templates ==
=== RPM README ===
<pre>
After installation, you must enable this module from the Drupal administration
page.
If upgrading this module separately from the core Drupal package, be sure to
run the http://hostname/drupal7/upgrade.php script after this RPM is upgraded.
</pre>


=== Module ===
=== Module ===
<pre>
%{?drupal7_find_provides_and_requires}
%global module_name __MODULE__
Name:          drupal7-%{module_name}
Version:      __VERSION__
Release:      1%{?dist}
Summary:      __SUMMARY__
Group:        Applications/Publishing
License:      GPLv2+
URL:          http://drupal.org/project/%{module_name}
Source0:      http://ftp.drupal.org/files/projects/%{module_name}-7.x-%{version}.tar.gz
Source1:      %{name}-RPM-README.txt
BuildArch:    noarch
BuildRoot:    %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: drupal7-rpmbuild >= 7.22-5
%description
__DESCRIPTION__
This package provides the following Drupal module(s):
* %{module_name}
%prep
%setup -q -n %{module_name}
cp -p %{SOURCE1} .
%build
# Empty build section, nothing to build
%install
rm -rf %{buildroot}
mkdir -p -m 0755 %{buildroot}%{drupal7_modules}/%{module_name}
cp -pr * %{buildroot}%{drupal7_modules}/%{module_name}/
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%doc *.txt
%{drupal7_modules}/%{module_name}
%exclude %{drupal7_modules}/%{module_name}/*.txt
%changelog
* ddd MMM DD YYYY __NAME__ <__EMAIL__> __VERSION__-1
- Initial package
</pre>


=== Theme ===
=== Theme ===


=== Distribution/Profile ===
<pre>
%{?drupal7_find_provides_and_requires}
 
%global theme_name __THEME__
 
Name:          drupal7-%{theme_name}
Version:      __VERSION__
Release:      1%{?dist}
Summary:      __SUMMARY__
 
Group:        Applications/Publishing
License:      GPLv2+
URL:          http://drupal.org/project/%{theme_name}
Source0:      http://ftp.drupal.org/files/projects/%{theme_name}-7.x-%{version}.tar.gz
Source1:      %{name}-RPM-README.txt
 
BuildArch:    noarch
BuildRoot:    %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: drupal7-rpmbuild >= 7.22-5
 
%description
__DESCRIPTION__
 
 
%prep
%setup -q -n %{theme_name}
cp -p %{SOURCE1} .
 
 
%build
# Empty build section, nothing to build
 
 
%install
rm -rf %{buildroot}
mkdir -p -m 0755 %{buildroot}%{drupal7_themes}/%{theme_name}
cp -pr * %{buildroot}%{drupal7_themes}/%{theme_name}/
 
 
%clean
rm -rf %{buildroot}
 
 
%files
%defattr(-,root,root,-)
%doc *.txt
%{drupal7_themes}/%{theme_name}
%exclude %{drupal7_themes}/%{theme_name}/*.txt
 
 
%changelog
* ddd MMM DD YYYY __NAME__ <__EMAIL__> __VERSION__-1
- Initial package
</pre>

Revision as of 21:56, 17 June 2013

This is only a DRAFT!

Guidelines for packaging Drupal 7 modules, themes, and profiles

Different Kinds of Packages

  • Modules: Modules extend and customize Drupal functionality.
  • Themes: Themes allow users to change the look and feel of their Drupal site.

Naming Scheme

Every package MUST be named drupal7-<drupal_machine_name>. Drupal itself enforces unique machine names for each of its' projects and there is a single namespace for all modules, themes, and distributions/profiles. The <drupal_machine_name> MUST match the drupal.org project name (i.e. drupal.org/project/<drupal_machine_name>).

File Placement

  • Modules: A module package MUST be placed in the %drupal7_modules directory (base "modules/" directory)
  • Themes: A theme package MUST be placed in the %drupal7_themes directory (base "themes/" directory)
  • Libraries: A library package MUST be placed in the %drupal7_libraries directory (base "libraries/" directory)

Requires and Provides

  • Every package SHOULD require "drupal7(<drupal_machine_name>)" virtual resources instead of "drupal7-<drupal_machine_name>" packages.
  • Every package MUST include the following in its' spec:
%{?drupal7_find_provides_and_requires}

This is for compatibility with RPM < 4.9 (i.e. EPEL 5/6).

BuildRequires: drupal7-rpmbuild >= 7.22-5

The drupal7-rpmbuild package automatically requires drupal7(core) and scans files for provides (from *.info files) and automatically adds them to the package during build time as "drupal7(<drupal_machine_name>)" virtual resources. Hidden projects are ignored. The use of virtual provides and requires helps alleviate the confusion of sub-modules and which modules actually provide those sub-modules. They also help simplify spec files.

  • Every package MUST NOT:
    • explicitly require "drupal7" or "drupal7(core)" (unless a specific core version is required) because drupal7-rpmbuild auro-requires "drupal7(core)"
    • explicitly provide "drupal7(<drupal_machine_name>)" virtual resources because drupal7-rpmbuild auto-provides these

Other Packages

See PHP packaging guidelines.

PHP Extensions

See PHP packaging guidelines.

Requiring a Minimum PHP Version

See PHP packaging guidelines but note that this should not normally be required by most packages (see [1]).

This needs to be added to the drupal7-rpmbuild package so it is automatic.

Macros and Scriptlets

Macros provided by the drupal7-rpmbuild package:

Macro Value Description
%drupal7 %{_datadir}/drupal7 Drupal 7 base directory
%drupal7_modules %{drupal7}/modules Drupal 7 modules directory
%drupal7_themes %{drupal7}/themes Drupal 7 themes directory
%drupal7_libraries %{_sysconfdir}/drupal7/all/libraries Drupal 7 libraries directory

Additional Hints

Templates

RPM README

After installation, you must enable this module from the Drupal administration
page.

If upgrading this module separately from the core Drupal package, be sure to
run the http://hostname/drupal7/upgrade.php script after this RPM is upgraded.

Module

%{?drupal7_find_provides_and_requires}

%global module_name __MODULE__

Name:          drupal7-%{module_name}
Version:       __VERSION__
Release:       1%{?dist}
Summary:       __SUMMARY__

Group:         Applications/Publishing
License:       GPLv2+
URL:           http://drupal.org/project/%{module_name}
Source0:       http://ftp.drupal.org/files/projects/%{module_name}-7.x-%{version}.tar.gz
Source1:       %{name}-RPM-README.txt

BuildArch:     noarch
BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: drupal7-rpmbuild >= 7.22-5

%description
__DESCRIPTION__

This package provides the following Drupal module(s):
* %{module_name}


%prep
%setup -q -n %{module_name}
cp -p %{SOURCE1} .


%build
# Empty build section, nothing to build


%install
rm -rf %{buildroot}
mkdir -p -m 0755 %{buildroot}%{drupal7_modules}/%{module_name}
cp -pr * %{buildroot}%{drupal7_modules}/%{module_name}/


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%doc *.txt
%{drupal7_modules}/%{module_name}
%exclude %{drupal7_modules}/%{module_name}/*.txt


%changelog
* ddd MMM DD YYYY __NAME__ <__EMAIL__> __VERSION__-1
- Initial package

Theme

%{?drupal7_find_provides_and_requires}

%global theme_name __THEME__

Name:          drupal7-%{theme_name}
Version:       __VERSION__
Release:       1%{?dist}
Summary:       __SUMMARY__

Group:         Applications/Publishing
License:       GPLv2+
URL:           http://drupal.org/project/%{theme_name}
Source0:       http://ftp.drupal.org/files/projects/%{theme_name}-7.x-%{version}.tar.gz
Source1:       %{name}-RPM-README.txt

BuildArch:     noarch
BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: drupal7-rpmbuild >= 7.22-5

%description
__DESCRIPTION__


%prep
%setup -q -n %{theme_name}
cp -p %{SOURCE1} .


%build
# Empty build section, nothing to build


%install
rm -rf %{buildroot}
mkdir -p -m 0755 %{buildroot}%{drupal7_themes}/%{theme_name}
cp -pr * %{buildroot}%{drupal7_themes}/%{theme_name}/


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%doc *.txt
%{drupal7_themes}/%{theme_name}
%exclude %{drupal7_themes}/%{theme_name}/*.txt


%changelog
* ddd MMM DD YYYY __NAME__ <__EMAIL__> __VERSION__-1
- Initial package