User:Matwey/Erlang guidelines draft

Jump to: navigation, search

Erlang guidelines DRAFT

DRAFT

Here is DRAFT for Erlang packaging guidelines. The discussion is going on at http://lists.opensuse.org/opensuse-packaging/2013-01/msg00012.html

About Erlang

According to Wikipedia, Erlang is a general-purpose concurrent, garbage-collected programming language and runtime system.

Naming convention

The names to the packages must be chosen with respect to Package naming guidelines. Namely, libraries must be packed as erlang-%{UPSTREAM_NAME}, for standalone applications %{UPSTREAM_NAME} is required (rabbitmq-server, ejabberd, etc).

Version

The package version must be upstream version. However, many erlang software are hosted at GitHub and don't follow any version scheme. Until the general openSUSE packaging rule for this case is established, you must follow the next scheme:

  1. Ask the upstream maintainer to use tags in order to mark version.
  2. If he/she does not have resources to carefully follow versions, then use 0.0.0+{git,hg}YYYYMMDD notation. Where YYYYMMDD is the date of the last commit in the tarball, and "git" or "hg" is selected with respect to VCS used. See also the following comments on tar_scm service.

+debug_info

Please, be sure that your BEAM-code is compiled with +debug_info. As mentioned many times, this does not affect the performance.

Notes on .app files

Every erlang library are provided with .app file, located in ebin. There are application name which is hereinafter referred to as %{APP_NAME} and "vsn" (%{APP_VSN}). If you feel divergence between %{APP_VSN} and %{UPSTREAM_VERSION}, please consult with upstream maintainer.

File locations

Erlang libraries must be installed into %{_libdir}/erlang/lib/%{APP_NAME}-%{APP_VSN}. Inside this directory there must be standard Erlang file hierarchy (ebin, priv, include, ...). Please, pack src as separate subpackage erlang-%{UPSTREAM_NAME}-src, or not pack it at all. As usual, pack documentation as appropriate separate subpackage. Also, make an effort to put one erlang library (one .app file) per one RPM package.

Erlang standalone applications should be installed in appropriate place (for instance, %{_libdir}/rabbitmq), and there must be wrappers or links in /usr/bin.

Provides/Requires

There is early development to have automatic provides/requires lookup. So, every required erlang application are to be marked with

  Requires: erlang:app(%{APP1_NAME})

and module

  Requires: erlang:mod(%{MOD_NAME})

Correspondingly:

  Provides: erlang:app(%{APP_NAME}) = %{APP_VSN}
  Provides: erlang:mod(%{MOD_NAME})

Specific RPM macroes

File /etc/rpm/macros.erlang is provided with erlang package now. So, following macroes are available:

  • %erlang_dir
  • %erlang_libdir
  • %rebar_compile
  • %erlang_app_vsn(APPFILE)
  • %erlang_app_name(APPFILE)

Two flavors of rebar

Installing erlang-rebar you get brand-new upstream rebar, but when your package is being built in obs special rebar flavor is supplied for it. It is called erlang-rebar-obs and has two features:

  1. It looks for all deps only locally
  2. It reads .rebar_vsn_obs file in the root of source directory and puts the content to your .app file, when {vsn, git} is specified here.

.spec example

#
# spec file for package %{name}
#
# Copyright (c) 2013, $YOUR_NAME <$YOUR_MAIL>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

Name:           erlang-$UPSTREAM_NAME
Version:        $UPSTREAM_VERSION
Release:        0
Summary:        $SUMMARY
License:        $LICENSE
Group:          Development/Libraries/Other
Url:            $URL
Source:         %{name}-%{version}.tar
Requires:       erlang
Provides:       erlang($APP_NAME) = $APP_VSN
BuildRequires:  erlang gcc make
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
$DESCRIPTION

%package doc
Summary:        API documentation
Group:          Documentation/Other
Requires:       %{name} = %{version}

%description doc
API, examples and documentation. 

%package src
Summary:        %{name} sources
Group:          Development/Libraries/Other
Requires:       %{name} = %{version}

%description src
Sources for Erlang %{name}.
 
%prep
%setup

%build
make %{?_smp_mflags}

%install
make install DESTDIR=$RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
# files goes here

%files doc
%defattr(-,root,root,-)
# files goes here

%files src
%defattr(-,root,root,-)
# files goes here

%changelog

Further information

You may use Fedora's guidelines as additional informational background: