From Fedora Project Wiki
No edit summary
Line 1: Line 1:
{{admon/warning|This is only a DRAFT!}}
{{admon/warning|This is only a DRAFT!}}


= Guidelines for packaging Drupal 8 modules, themes, and profiles =
= Different Kinds of Packages =
 
== Different Kinds of Packages ==
* '''[http://drupal.org/project/modules Modules]''': Modules extend and customize Drupal functionality.
* '''[http://drupal.org/project/modules Modules]''': Modules extend and customize Drupal functionality.
* '''[http://drupal.org/project/themes Themes]''': Themes allow users to change the look and feel of their Drupal site.
* '''[http://drupal.org/project/themes Themes]''': Themes allow users to change the look and feel of their Drupal site.
* '''[http://drupal.org/project/distributions Distributions/Profiles]''': Distributions/profiles provide site features and functions for a specific type of site.
* '''[http://drupal.org/project/distributions Distributions/Profiles]''': Distributions/profiles provide site features and functions for a specific type of site.


== Naming Scheme ==
= Naming Scheme =
Every package '''MUST''' be named <code>drupal8-''&lt;drupal_project''&gt;</code>.  Drupal itself enforces unique project names for each of its' projects and there is a single namespace for all modules, themes, and distributions/profiles.  The <code>''&lt;drupal_project''&gt;</code> '''MUST''' match the drupal.org project name (i.e. drupal.org/project/<code>''&lt;drupal_project''&gt;</code>).
Every package '''MUST''' be named <code>drupal8-''&lt;drupal_project''&gt;</code>.  Drupal itself enforces unique project names for each of its' projects and there is a single namespace for all modules, themes, and distributions/profiles.  The <code>''&lt;drupal_project''&gt;</code> '''MUST''' match the drupal.org project name (i.e. drupal.org/project/<code>''&lt;drupal_project''&gt;</code>).


== File Placement ==
= File Placement =
* '''Modules''': A module package '''MUST''' be placed in the <code>%drupal8_modules</code> directory
* '''Modules''': A module package '''MUST''' be placed in the <code>%drupal8_modules</code> directory
* '''Themes''': A theme package '''MUST''' be placed in the <code>%drupal8_themes</code> directory
* '''Themes''': A theme package '''MUST''' be placed in the <code>%drupal8_themes</code> directory
Line 17: Line 15:
* '''Libraries''': A library package '''MUST''' be placed in the <code>%drupal8_libraries</code> directory
* '''Libraries''': A library package '''MUST''' be placed in the <code>%drupal8_libraries</code> directory


== Requires and Provides ==
= Requires and Provides =


Every package '''MUST''' include the following in its' spec:
Every package '''MUST''' include the following in its' spec:
Line 28: Line 26:
[2] From <code>*.info</code> file "dependencies" entries
[2] From <code>*.info</code> file "dependencies" entries


=== Other Packages ===
== Other Packages ==


See [[Packaging:PHP#Other_Packages|PHP packaging guidelines]].
See [[Packaging:PHP#Other_Packages|PHP packaging guidelines]].


=== PHP Extensions ===
== PHP Extensions ==


See [[Packaging:PHP#Extensions_Requires|PHP packaging guidelines]].
See [[Packaging:PHP#Extensions_Requires|PHP packaging guidelines]].


=== Requiring a Minimum PHP Version ===
== Requiring a Minimum PHP Version ==


Since all packages require <code>drupal8(core)</code> which requires Drupal 8's minimum PHP version, most packages do not need to require a minimum PHP version.  If packages require a minimum PHP version greater than Drupal 8's minimum version, the project maintainers should have the minimum version provided in the project's main <code>*.info.yml</code> file and <code>drupal8-rpmbuild</code> will automatically find and require the minimum PHP version.
Since all packages require <code>drupal8(core)</code> which requires Drupal 8's minimum PHP version, most packages do not need to require a minimum PHP version.  If packages require a minimum PHP version greater than Drupal 8's minimum version, the project maintainers should have the minimum version provided in the project's main <code>*.info.yml</code> file and <code>drupal8-rpmbuild</code> will automatically find and require the minimum PHP version.


== Macros and Scriptlets ==
= Macros and Scriptlets =


Macros provided by the <code>drupal8-rpmbuild</code> package:
Macros provided by the <code>drupal8-rpmbuild</code> package:
Line 77: Line 75:
''** <code>rpm</code> sub-directory so RPM-installed projects are separated from manually installed projects.''
''** <code>rpm</code> sub-directory so RPM-installed projects are separated from manually installed projects.''


== Additional Hints ==
= Additional Hints =


== Template ==
= Template =


{{admon/note|Replace <code>%{__TYPE_MACRO__}</code> in the template below with the actual macro name matching the project type:
{{admon/note|Replace <code>%{__TYPE_MACRO__}</code> in the template below with the actual macro name matching the project type:
Line 137: Line 135:
- Initial package
- Initial package
</pre>
</pre>
=== Distribution/Profile ===

Revision as of 15:47, 24 January 2016

Warning.png
This is only a DRAFT!

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.
  • Distributions/Profiles: Distributions/profiles provide site features and functions for a specific type of site.

Naming Scheme

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

File Placement

  • Modules: A module package MUST be placed in the %drupal8_modules directory
  • Themes: A theme package MUST be placed in the %drupal8_themes directory
  • Distributions/Profiles: A distribution/profile package MUST be placed in the %drupal8_profiles directory
  • Libraries: A library package MUST be placed in the %drupal8_libraries directory

Requires and Provides

Every package MUST include the following in its' spec:

BuildRequires: drupal8-rpmbuild

The drupal8-rpmbuild package automatically scans files for provides [1] and requires [2] and automatically adds them to the package during build time as "drupal8(<drupal_project>)" and "php-composer(<vendor>/<project>)" virtual resources. 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.

[1] From *.info.yml and composer.json filenames
[2] From *.info file "dependencies" entries

Other Packages

See PHP packaging guidelines.

PHP Extensions

See PHP packaging guidelines.

Requiring a Minimum PHP Version

Since all packages require drupal8(core) which requires Drupal 8's minimum PHP version, most packages do not need to require a minimum PHP version. If packages require a minimum PHP version greater than Drupal 8's minimum version, the project maintainers should have the minimum version provided in the project's main *.info.yml file and drupal8-rpmbuild will automatically find and require the minimum PHP version.

Macros and Scriptlets

Macros provided by the drupal8-rpmbuild package:

Macro Value Description
%drupal8_version 8.x.y* Drupal 8 version.
%drupal8 %{_datadir}/drupal8 Drupal 8 base directory.
%drupal8_modules %{drupal8}/modules/rpm** Drupal 8 modules directory.
%drupal8_profiles %{drupal8}/profiles/rpm** Drupal 8 profiles directory.
%drupal8_themes %{drupal8}/themes/rpm** Drupal 8 themes directory.
%drupal8_libraries %{drupal8}/libraries Drupal 8 library directory.
%drupal8_var %{_localstatedir}/lib/drupal8 Drupal 8 var directory.
Note.png
  • Files are located in %{drupal8_var}/files/[public,private]/[site]
  • %{drupal8_conf}/sites/default/files symlinks to %{drupal8_var}/files/public/default

%drupal8_conf %{_sysconfdir}/drupal8 Drupal 8 conf directory.
Note.png
  • %{drupal8}/sites symlinks to %{drupal8_conf}/sites
  • Site configurations are located in %{drupal8_conf}/sites/[site]

* Value is dynamically updated by the Drupal 8 core package.

** rpm sub-directory so RPM-installed projects are separated from manually installed projects.

Additional Hints

Template

Note.png
Replace %{__TYPE_MACRO__} in the template below with the actual macro name matching the project type:
  • %{drupal8_modules} for modules
  • %{drupal8_profiles} for profiles
  • %{drupal8_themes} for themes
%global drupal_project __DRUPAL_PROJECT__

Name:          drupal8-%{drupal_project}
Version:       __VERSION__
Release:       1%{?dist}
Summary:       __SUMMARY__

Group:         Applications/Publishing
License:       GPLv2+
URL:           https://www.drupal.org/project/%{drupal_project}
Source0:       https://ftp.drupal.org/files/projects/%{drupal_project}-8.x-%{version}.tar.gz

BuildArch:     noarch
BuildRequires: drupal8-rpmbuild

%description
__DESCRIPTION__

This package provides the following Drupal project(s):
* %{drupal_project}


%prep
%setup -qn %{drupal_project}

: Licenses and docs
mkdir -p .rpm/{licenses,docs}
mv LICENSE.txt .rpm/licenses/
mv composer.json .rpm/docs/


%build
# Empty build section, nothing to build


%install
mkdir -p %{buildroot}%{__TYPE_MACRO__}/%{drupal_project}
cp -pr * %{buildroot}%{__TYPE_MACRO__}/%{drupal_project}/


%files
%license .rpm/licenses/*
%doc .rpm/docs/*
%{__TYPE_MACRO__}/%{drupal_project}


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