Difference between revisions of "Sugar Network/Recipe Specification"

From Sugar Labs
Jump to navigation Jump to search
 
(160 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<noinclude>
+
== Summary ==
{{TOCright}}
 
[[Category:Zero Sugar]]
 
</noinclude>
 
  
== 0sugar.info file ==
+
The document describes software specification files format which is a superset on top of the Sugar [[Development_Team/Almanac/Activity_Bundles|activity bundles]] specification. This format is backwards compatible with [[Development_Team/Almanac/Activity_Bundles#.info_file_format|activity.info]] files to make sure that software starts well from the regular Sugar Shell. But the major purpose of introducing new format is supporting software hosted on the [[Sugar Network]]. In particular, new format assumes the following functionality:
  
The 0sugar.info specification file is an analog of scenario files in regular GNU/Linux distributions, like .spec files in RPM. It is the cornerstone of Zero Sugar workflows, everything depends on the 0sugar.info spec file.
+
* Support binary based software;
 +
* Provide information about software dependencies;
 +
* Introduce stability levels to make it possible (for interested in people) to run development versions using the same, like for stable releases, distribution channel;
 +
* Distribute not only Sugar activities, e.g., software libraries;
 +
* Include all required information to make it possible to reuse the same spec file on different software evolution phases, like, making sources tarball, building binaries on Sugar Labs [[Platform_Team/Open_Build_Service|instance]] of the [http://openbuildservice.org/ Open Build Service], executing.
  
For activities, ''activity.info'', a deprecated spec file name, is supported.
+
The format is partially based on the [http://0install.net/ Zero Install] [http://0install.net/interface-spec.html specification] since implementation code reuses Zero Install library in order to launch software on users side.
  
=== [DEFAULT] ===
+
== Spec file locations ==
  
Common options. Options from this section will be accessible from all other sections. It may be useful to store options that are common for all sections.
+
There are two possible spec file locations (staring from the top directory of a distribution bundle):
  
'''import''' = <filename> [; ...]
+
* {{Code|/activity/activity.info}}<br>for Sugar activities to make them capable to be launched from the regular Sugar Shell;
 +
* {{Code|/sweets.recipe}}<br>in the rest of cases.
  
Import another spec file. Makes sense only within the [DEFAULT] section itself.
+
== Configuration sections ==
  
'''repos''' = <name> <feeds-prefix> [downloads-prefix] [; ...]
+
As ''activity.info'' files, new format is based on [[wikipedia:INI_file|INI files]] and should contain at least one of the following sections.
 
 
Add new or reset existing [[#Package_names|repositories]]. Attribute ''feeds-prefix'' defines a Web url prefix for 0install feeds, ''downloads-prefix'', for downloads that feeds contain (equals to ''feeds-prefix'' by default).
 
  
 
=== Common options ===
 
=== Common options ===
  
Options that are common for all sections except [DEFAULT].
+
Regardless of the software type, a recipe section (or one of them) should contain the following options.
 
 
'''inherit''' = <section-name> [; ...]
 
 
 
Include options from another section.
 
  
'''merge''' = <section-name> [; ...]
+
<div id="context"></div>
  
The same behaviour as ''inherit'', but merges values for list type options, i.e., the final values will consist of the base-section values with addtional child-section values. List options are:
+
'''context''' = ''GUID''
  
* category
+
Required (but see the [[#.5BActivity.5D|[Activity]]] section). The value which uniquely identifies a software project this particular version implements. This is a Sugar Network [[Platform_Team/Sugar_Network/Objects_model|Context]] GUID.
* requires
 
* binding
 
* include
 
* exclude
 
* langs
 
* packaged
 
  
=== [Package] ===
+
<div id="name"></div>
  
This is a required section (but could be replaced by [Activity]). It describes the main package.
+
'''name''' = ''NAME''
  
'''slug''' = <package-slug>
+
Optional. Free-form name. (It is equal to the ''implemented'', by default.)
  
The string used as identifier in cases like 0install feed urls or native package names. Only lower alphabetic, numeric, "+" or "-" symbols are allowed. Slug value should be at least two characters long and start with an alphanumeric character.
+
<div id="summary"></div>
  
  '''name''' = <package-name>
+
  '''summary''' = ''ONE_LINE_TEXT''
  
Package name, in free form, equals to ''slug'', by default.
+
Required. Short descriptive line.
  
'''summary''' = <one-line-description>
+
<div id="description"></div>
  
Short descriptive line.
+
'''description''' = ''MULTI_LINE_TEXT''
  
'''description''' = <multi-line-description>
+
Optional. Long descriptive text. To wrap long text, all lines starting from the second, should start with spaces. This field is equal to ''summary'' by default.
  
Long descriptive text. To wrap long text, all lines after the second, should start with spaces. This field is equal to ''summary'' by default.
+
<div id="license"></div>
  
  '''license''' = <licence-name>
+
  '''license''' = ''LICENSE'' [; ...]
  
Package license. Short licence names from [http://fedoraproject.org/wiki/Licensing Fedora naming scheme] are welcome.
+
Required. Short license names. The licenses should conform with the [[Activity Library]] licensing [[Activity_Library/Editors/Policy/Licensing|policy]].
  
'''homepage''' = <url>
+
<div id="homepage"></div>
  
Packaged project home page.
+
'''homepage''' = ''URL''
  
'''icon''' = <icon-file-name>
+
Required. Software project home page.
  
Relative (from Zero Sugar based project) path to icon file.
+
<div id="icon"></div>
  
  '''category''' = <category> [; ...]
+
  '''icon''' = ''FILENAME''
  
A classification for the package using values defined by [http://standards.freedesktop.org/menu-spec/latest/apa.html freedesktop.org menu specification].
+
Optional (but see the [[#.5BActivity.5D|[Activity]]] section). Path to the icon file starting from the path where the recipe file is located.
  
'''age''' = <age-number>
+
<div id="tags"></div>
  
Simple number that will be used as a major number for ''version'', see [[#Versioning|versioning scheme]] for details.
+
'''tags''' = ''TAG'' [; ...]
  
'''version''' = <version-number>
+
Optional. Tags give more context by which to group the software. This is done to allow users to make search more easily.
  
Current version of the package using [http://0install.net/interface-spec.html#id4016582 0install version format]. If the ''age'' option was set, versioning is a bit [[#Versioning|different]].
+
<div id="version"></div>
  
  '''stability''' = <stability-level>
+
  '''version''' = ''VERSION''
  
Stability level of current version. Values conform to [http://0install.net/interface-spec.html#id4016716 0install stability levels] and could be:
+
Required. Current version of the software using [[#Version_numbers|special notation]]. Note, to make Sugar activity bundles compatible with pristine Sugar, use a limited format subset supported by the Sugar Shell.
* insecure
 
* buggy
 
* developer
 
* testing
 
* stable
 
  
'''requires''' = <dependency> [(=|>=|<) <version>] [; ...]
+
<div id="stability"></div>
  
List of [[#Package_names|dependencies]] that should exist before using the package.
+
'''stability''' = ''LEVEL''
  
'''slots'''[<dependency>] = <first-dependency-version> [; ...], <last-dependency-verison>
+
Required. Stability level of the current version. Values conform to the [[#Software_stability_levels|below list]].
  
To specify dependency [[#Slots|slots]].
+
<div id="requires"></div>
  
  '''binding''' = [prepend|append|replace] <variable-name> [<insert-text-to-prepend-variable-value>] [; ...]
+
  '''requires''' = ''DEPENDENCY'' [; ...]
  
The environment variables 0install should export to the process that uses this package. This makes sense only for multiple-activity-serving dependencies (like libraries), not for the activity itself.
+
Optional. List of [[#Dependencies|dependencies]] that should exist at run-time before launching the release.
 
 
'''main''' = <path-to-exec-file>
 
 
 
The relative path of an executable inside the implementation that should be executed by default when the package is run.
 
 
 
'''exec''' = <shell-command>
 
 
 
Instead of using an executable program from the ''main'' option, 0sugar can bundle a script to run an arbitrary shell command.
 
 
 
If a package has neither ''main'' nor ''exec'', then it cannot be executed. This typically means that the package is for a library.
 
 
 
'''include''' = <glob-pattern> [; ...]
 
 
 
[[#Glob patterns|Glob pattern]] for files to include to package. By default, all files are assumed.
 
 
 
'''exclude''' = <glob-pattern> [; ...]
 
 
 
[[#Glob patterns|Glob pattern]] for files to exclude from package. In additional, various temporary files will be excluded like ''.bak'' or ''.pyc''.
 
 
 
'''langs''' = <lang-name> [; ...]
 
include[<lang-name>] = <glob-pattern> [; ...]
 
exclude[<lang-name>] = <glob-pattern> [; ...]
 
 
 
A special form of ''include''/''exclude'' options that are intended to create separate, per locale, (sub)packages. If language is mentioned in ''langs'' list but doesn't have ''include[]''/''exclude[]'' options, ''include''/''exclude'' will be used (in that case, using special [[#Predefined_options|LANG]] variable makes sense).
 
 
 
'''arch''' = <arch>
 
 
 
Makes sense only for binary (sub)packages, and can contain:
 
* ''all'' for noarch (by default)
 
* ''any'' for binaries to use the current architecture
 
  
 
=== [Activity] ===
 
=== [Activity] ===
  
This section should be present only for activities (or for applications that could be used also as Activities, e.g., GCompris is a regular application but could be launched in Sugar mode).  
+
This section type should be present only in Sugar activities.
  
Section uses the same options as [Package] with these additions:
+
<div id="activity_version"></div>
  
  '''activity_version'''
+
  '''activity_version''' = ''VERSION''
  
Option is deprecated, ''version'' should be used instead.
+
Required. An alias of the ''version'' option.
  
'''bundle_id''' = <bundle-id>
+
<div id="bundle_id"></div>
  
See [[Development_Team/Almanac/Activity_Bundles#.info_file_format|activity.info file specification]]. Option will be deprecated after implementing 0sugar in glucose and switching to identifying activities by urls (like 0install feeds).
+
'''bundle_id''' = ''BUNDLE_ID''
  
'''icon''' = <icon-file-name-wo-suffix>
+
Required. An alias of the ''context'' option.
  
Behaviour from activity.info is supported (value should not have ".svg" suffix, and icon file could be found only in activity subdirectory) but deprecated. Regular ''icon'' behaviour from [Package] section should be used instead.
+
<div id="icon"></div>
  
  '''exec''' = <shell-command>
+
  '''icon''' = ''FILENAME_WITHOUT_SUFFIX''
  
Sugar will pass additional [[Development_Team/Low-level_Activity_API#Command_Line_Arguments| command line arguments]] to this command.
+
Required. Behaviour from {{Code|activity.info}} is supported (value should not have a {{Code|.svg}} suffix, and the icon file can be found only in the {{Code|activity}} subdirectory) and, while deprecated, it needs to be used to not break backwards compatibility. For the remaining cases, the regular ''icon'' behaviour should be used instead.
  
'''mime_types''' = <mime-type> [; ...]
+
<div id="activity_exec"></div>
  
List of mime types supported by the activity. It's used when opening a file from the web or to present to the user a list of activities which can open a certain Journal object.
+
'''exec''' = ''SHELL_COMMAND''
  
'''tags''' = <tag> [; ...]
+
Required. Sugar will pass additional [[Development_Team/Low-level_Activity_API#Command_Line_Arguments| command line arguments]] to this command.
  
Tags give more context in which to group the activity. This is used to allow users to find activities more easily in the Journal, the Home view, etc.
+
<div id="mime_types"></div>
  
=== [Source] ===
+
'''mime_types''' = ''MIME_TYPE'' [; ...]
  
Section makes sense only while packaging 3rd-party applications.
+
Optional. List of mime types supported by the activity. It's used when opening a file from the web, or to present to the user a list of activities that can open a certain Journal object.
  
'''source''' = <url>
+
<!--
 +
=== [Application] ===
  
Url to download sources tarball.  
+
Application to run outside of Sugar Shell.
  
  '''patch''' = <path-to-patch> [patch-level] [; ...]
+
  '''exec''' = ''SHELL_COMMAND''
  
Patch downloaded tarball.
+
Required. The relative path of an executable command inside the implementation that should be executed by default when the sweet is run. Command can have optional arguments.
  
=== [Buid] ===
+
=== [Library] ===
  
How to build binaries. If package contains binary implementations, this section should be present to describe the building process.
+
'''binding''' = [prepend|append|replace] <variable-name> [<insert-text-to-prepend-variable-value>] [; ...]
  
'''NOTE''' The commands in this section will be executed, not only in the developer's environment, but also in the user's, if a proper binary wasn't found; so move all development-related commands, like autogen.sh, to the ''[Maintain]'' section.
+
Required. The environment variables 0install should export to the process that uses this sweet.
 +
-->
 +
=== [Archive] ===
  
'''requires''' = <dependency-name> [(=|>=|<) <version>] [; ...]
+
This configuration section makes sense only while building binary distribution bundles from the sources. The section is optional for spec files that describe software assumed to be launched as-is, e.g., ''.xo'' bundles.
  
What [[#Package_names|dependencies]] should be present before building the package from sources, in addition to ''requires'' values from the ''[Package]'' sections.
+
Each ''[Archive]'' section describes one particular binary bundle. There are might be several sections to define binaries for different cases:
  
'''configure''' = <shell-command>
+
* To save storage space or bandwidth when some bundles will contain any-arch data that are common for all platforms, and another bundle will contain binaries for a particular platform;
 +
* Per language bundles, e.g., for media content.
  
Shell command to configure sources before building, e.g, invoking the ''configure'' script in auto-tools-based projects. It is important to use [[#Predefined_options|predefined constants]], like ''PREFIX'', during configuration to prepare valid Zero packages. If the source code does not require a configuration stage, this option could be omited.
+
All archive sections are named:
  
  '''build''' = <shell-command>
+
  Archive[:''SUBNAME'']
  
Shell command to build binaries from sources. If the source code does not require a building stage, this option could be omited.
+
And contain the following options:
  
'''install''' = <shell-command>
+
<div id="archive-include"></div>
  
Shell command to place files that are ready for distribution into the ''%(DISTDIR)s'' directory.
+
'''include''' = ''GLOB'' [; ...]
  
=== [Maintain] ===
+
Optional. [[#Glob_patterns|Glob pattern]] for files to include in the archive. By default, all files are assumed.
  
Various options that make sense only in the package-developer's environment.
+
<div id="archive-exclude"></div>
  
  '''exec''' = <shell-command>
+
  '''exclude''' = ''GLOB'' [; ...]
  
How to bundle package. By default, 0sugar just bundles the entire root directory, excluding temporary files.
+
Optional. Like the ''include'' option, but used for excluding files from the archive. In addition, various temporary files will be excluded, like ''.bak'' or ''.pyc''.
 +
<!-- Not yet implemented
 +
'''langs''' = <lang-name> [; ...]
 +
include[<lang-name>] = <glob-pattern> [; ...]
 +
exclude[<lang-name>] = <glob-pattern> [; ...]
  
'''requires''' = <dependency> [(=|>=|<) <version>] [; ...]
+
Optional. A special form of ''include''/''exclude'' options that are intended to create separate, per locale, archives. If a language is mentioned in the ''langs'' list, but doesn't have any ''include[]''/''exclude[]'' options, ''include''/''exclude'' will be used (in that case, using the special [[#Predefined_constants|LANG]] constant makes sense).-->
  
The packages that should be present before invoking the ''exec'' command. For example, if the ''exec'' command generates .c files from .vala, the vala dependency should be mentioned in the ''requires'' option.
+
<div id="arch"></div>
  
== Package names ==
+
'''arch''' = ''ARCH''
  
Zero Sugar spec file options, like ''requires'', contain links to other packages. The following link formats are supported:
+
Optional. Makes sense only for binary archives, and can contain:
  
* current package to upload to ''target'' repository (instead of a direct slug value, to make the spec file more robust, move the ''slug'' option to the [DEFAULT] section and use {{Code|%(slug)s}} interpolation),
+
* ''all'' for noarch (by default),
<slug-option-value>[/<nowiki><sub-package></nowiki>]
+
* ''any'' for binaries to use the current architecture.
  
* package from default repository,
+
=== [Build] ===
<package-name>[/<nowiki><sub-package></nowiki>]
 
  
* package from particular repository,
+
This section is required if software needs additional work in order to prepare a ready-to-use installation. It is important to use [[#Predefined_constants|predefined constants]] for options that contain shell commands. All shell commands will be executed from the {{Code|%(BUILDDIR)s}} directory.
<repository>:<package-name>[/<nowiki><sub-package></nowiki>]
 
  
* direct 0install link.
+
'''NOTE''' The commands in this section will be executed, not only in the developer's environment, but also in the user's, if a proper binary wasn't found; so move all development-related commands, like {{Code|autogen.sh}}, to the ''[Source]'' section.
<0install-feed-url>
 
  
At the end, all links will be transfered to 0install feed urls. Repository is just a Web url prefix like http://packages.sugarlabs.org/, the final 0install url will be composed by concatenating repository prefix and package name. Repositories might be:
+
<div id="build-requires"></div>
  
* ''default'' or without mentioning repository name, the native GNU/Linux distributions packages from http://namedb.0install.net/;
+
'''requires''' = ''DEPENDENCY'' [; ...]
  
* ''target'', the repository the current package will be uploaded to, equals to ''sl'' by default;
+
Optional. This defines what [[#Dependencies|dependencies]] should be present before building the software from sources. Note that common ''requires'' option values are not auto included in the build-time dependencies.
  
* ''sl'', repository hosted by Sugar Labs on http://packages.sugarlabs.org/;
+
<div id="clean"></div>
  
Spec option ''repos'' can add new repositories or reset predefined ones.
+
'''clean''' = ''SHELL_COMMAND''
  
== Versioning ==
+
Optional. Cleanup build environment before running ''configure'' command.
  
The versioning scheme for Zero packages can be arbitrary, since the ''version'' spec option supports [http://0install.net/interface-spec.html#id4016582 0install version format]. But in some cases, e.g., libraries, stricter versioning could be useful. In that case, the ''age'' spec option should be used.
+
<div id="configure"></div>
  
The spec option ''age'' is intended to support, mostly, API breakages of library packages. But not ABI, because tracking an ABI is not trivial within the Sugar ecosystem (due to the enormous potential code base of varying quality) and of little utility, since packages may at any time rebuild from sources and multiple library versions may be installed (thanks to 0install).
+
'''configure''' = ''SHELL_COMMAND''
  
Using the ''age'' option is simple, on every API breakage for the library package, increment the ''age'' value. Final package version will be:
+
Optional. Shell command to configure sources before building, e.g., invoking the configure script in auto-tools-based projects. If the source code does not require a configuration stage, this option could be omitted.
<age-option>.<version-option>
 
  
<!-- I like composing packages that are avoiding breakages and leakages a lot -->
+
<div id="build-make"></div>
  
== Glob patterns ==
+
'''make''' = ''SHELL_COMMAND''
 
 
A pattern could be of two types:
 
 
 
* doesn't contain ''/'' or ''**'' substrings, will be applied only to file names (not names of sub-directories within parent directory)
 
* contains ''/'' or ''**'' substring, will be applied to the full file path (relative to the root), thus could affect several directory levels
 
  
Only these pattern symbols are allowed:
+
Optional. Shell command to make binaries from sources. If the source code does not require a making stage, this option could be omitted.
  
* ''*'' matches everything, except directory separator
+
<div id="install"></div>
* ''?'' matches any single character, except directory separator
 
* ''**'' matches everything, including directory separator
 
  
== Sub packages ==
+
'''install''' = ''SHELL_COMMAND''
  
By default, package is the singular and will be composed using ''[Package]'' or/and ''[Activity]'' sections. But if the package contains several logical components, it might have sub packages. In that case, the spec file should contain additional sections (per sub package) in the form:
+
Required. Shell command to place files that are ready for distribution into the {{Code|%(DESTDIR)s}} directory. If ''install'' is missing, the entire {{Code|%(BUILDDIR)s}} (excepting temporary files) will be copied.
  
  [Package/<nowiki><sub-package></nowiki>]
+
=== [Source] ===
  
Format of sub sections is identical to ''[Package]'' section. Sub packages could make sense, e.g., for packaging additional content, or to separate library and its script language binding.
+
The section makes sense only while building sources bundles and is a replacement of former ''MANIFEST'' file in Sugar activity bundles.
  
Other packages can mention sub packages by the format:
+
<div id="source-exec"></div>
  
  <package>/<nowiki><sub-package></nowiki>
+
  '''exec''' = ''SHELL_COMMAND''
  
Good practise is using the following names for sub packages:
+
Optional. Execute an external program to create sources tarball. Option might be used, e.g., to run {{Code|make dist}} command.
  
* ''python'' for Python binding.
+
<div id="source-include"></div>
  
== Recipes ==
+
'''include''' = ''GLOB'' [; ...]
 +
'''exclude''' = ''GLOB'' [; ...]
  
In some cases, e.g., to save storage space or bandwidth, it is useful to split a packaged application into several tarballs when some tarballs will contain any-arch data, that are common for all platforms, and other will contain binaries for particular platform. Thus, if an application supports several platforms and any-arch data is big (various media, text, etc. files), there will not be duplicate tarballs.
+
Optional. If the ''exec'' option was not used, all files will be bundled and these [[#Glob_patterns|glob patterns]] might be used to reify the selection.
  
The key differences between recipes and sub packages:
+
<div id="source-requires"></div>
* Sub packages are logically independent parts of the package;
 
* Each sub package is identified by unique 0install url, all recipe components are identified by recipe url;
 
* Tarballs for different sub packages will be extracted to different directories, recipe component tarballs, within the same recipe, will be extracted to the same directory.
 
  
Use the ''recipe'' option to declare a (sub)package(s) as a recipe:
+
'''requires''' = ''DEPENDENCY'' [; ...]
  
  [Package]
+
Optional. The [[#Dependencies|dependencies]] that should be present before creating sources tarball. For example, if the ''exec'' command generates .c files from .vala, the vala dependency should be mentioned in the ''requires'' option.
  recipe = <component-name> [; ...]
 
  
and declare sections that contain components:
+
=== Predefined constants ===
  
  [<component-name>]
+
Constants defined within the ''[Build]'' section:
  ...
 
  
Being a recipe, the package section cannot contain files-related options (since package itself does not contain any tarballs directly, only via recipe components), these options could be set only in components:
+
* ''BUILDDIR'' where the build happens, directory contains un-tarred sources bundle. This variable can be used in ''binding'' options as well. During the local build, it will point environment variables to the root of sources directory.
 +
* ''DESTDIR'' temporary path to place installed files before bundling them
 +
* ''PREFIX'' should be used as installation prefix path, e.g., for {{Code|./configure --prefix}}
 +
* ''CFLAGS'' default gcc CFLAGS
 +
* ''CXXFLAGS'' default gcc CXXFLAGS
  
* langs
+
In sections that contain a ''langs'' option:
* arch
 
* include
 
* exclude
 
* exec
 
* slots
 
  
The same component could be a part of different recipes. In that case, different package implementations will contain the same recipe component tarball.
+
* ''LANG'' current language while building per language implementation
  
== Slots ==
+
== Version numbers ==
  
Slots make sense only for binary services when they could be built against several compatibility ranges for their dependencies and these dependencies could be installed from native packages.
+
A version number string has the following form:
  
Assume that a service requires cairo, and that the source code uses a cairo feature that appeared only in v1.8, but the source code can fallback to previous cairo versions, as well. If cairo can be installed from 0install feeds, then there is no need for slots, since the service can declared as a "cairo >= 1.8" dependency, and so cairo will be installed from 0install feeds. But if cairo could be installed from native packages, there is no way to know in advance which cairo version will be present, and the service should have two implementations, one for cairo < 1.8 and one for cairo >= 1.8. In this case, slots will be useful.
+
Version := DottedList ("-" Modifier? DottedList?)*
 +
DottedList := (Integer ("." Integer)*)
 +
Modifier := "pre" | "rc" | "post"
  
To declare slots for a package dependency, ''slots'' and appropriate ''requires'' options should be placed in the ''[Service]'' section that uses the dependency:
+
Numerically, the modifiers come in the order "-pre" (pre-release), "-rc" (release candidate), "-" (no modifier name), "-post" (post-release or patch level). Versions are ordered like this:
  
  requires = <dependency>
+
0.1
  slots[<dependency>] = <versions-range>
+
1
 +
1.0
 +
1.2-pre
 +
1.2-pre1
 +
1.2-rc1
 +
1.2
 +
1.2-0
 +
1.2-post
 +
1.2-post1-pre
 +
1.2-post1
 +
1.2.1-pre
 +
1.2.1.4
 +
1.2.2
 +
1.2.10
 +
3
  
Option ''slots'' will declare compatibility ranges for a particular dependency. Only one, closed from both sides, range can be used. For example, in the cairo case, it could be:
+
== Software stability levels ==
  
  1.0, 1.8, 2.0
+
The spec file also gives a stability rating for each implementation. The following levels are allowed (must be lowercase in the feed files):
  
The 1.0 (it could be 0.0 as well) restricts the version range from the left and the 2.0 (most likely v2.0 will not be backwards compatible with v1.x) from the right; so only two ranges can be chosen, 1.0 >= x < 1.8, 1.8 >= x < 2.0. While building binaries for the ''0sugar build'' command, 0sugar will detect what the current cairo version is (the service that it is building/linking against), and will choose the proper slot or fail, otherwise.
+
* ''stable'',
 +
* ''testing'',
 +
* ''developer'',
 +
* ''buggy'',
 +
* ''insecure''.
  
== Predefined options ==
+
Stability ratings are expected to change over time. When any new release is made, its stability should be set to testing. Users who have selected Help test new versions will then start using it. Other users will continue with the previous stable release. After a while (days, weeks or months, depending on the project) with no serious problems found, the implementation's stability can be changed to stable so that everyone will use it.
  
* ''BUILDDIR'' where the build happens
+
If problems are found, it can instead be marked as ''buggy'', or ''insecure'' to avoid selecting these versions while launching on users side. ''developer'' is like a more extreme version of ''testing'', where the program is expected to have bugs.
* ''SRCDIR'' path to directory with sources; for a custom (via 0compile) build, ''BUILDDIR'' and ''SRCDIR'' are different, while building on OBS, they are the same
 
* ''DISTDIR'' temporary path to place installed files before bundling them
 
* ''PREFIX'' prefix path for installed files, e.g., /usr
 
* ''DATADIR'' data files directory, e.g., /usr/share
 
* ''DOCDIR'' doc files directory, e.g., /usr/share/doc
 
* ''BINDIR'' bin files directory, e.g., /usr/bin
 
* ''INCLUDEDIR'' include files directory, e.g., /usr/include
 
* ''LIBDIR'' lib files directory, e.g., /usr/lib
 
* ''PYTHON_SITEDIR'' python files directory, e.g., /usr/lib/python2.6/site-packages
 
* ''CFLAGS'' default gcc CFLAGS
 
* ''CXXFLAGS'' default gcc CXXFLAGS
 
  
In sections that contain ''langs'' option:
+
When to use ''buggy''? Don't mark old releases as buggy every time you do a new release, just because a few bugs have been fixed. People who have selected network connectivity automatically pickup the new version anyway, so marking an older version as ''buggy'' only affects people who have explicitly stated that they don't want to use the latest version, but would prefer to use an older release to save network use.
  
* ''LANG'' current language while building per language implementation
+
== Dependencies ==
  
Also, during the ''0sugar build'' command invocation, ''0sugar'' exports the environment variables that should be used in ''exec'' options, for example, to implement a conditional build.
+
Dependencies might be used to declare software that the current release depends on.
  
* ''ZSUGAR_<argument-in-upper-case>'' map ''0sugar'' long command line arguments
+
The format of a dependency string is:
* ''SECTION_<section-name-in-upper-case>'' for every spec file section that will be processed
 
  
== Examples ==
+
''DEPENDENCY'' [(<|<=|=|>=|>) ''VERSION'']
  
=== Python activity ===
+
The ''DEPENDENCY'' value is a GUID associated with dependency project, i.e., ''context'' value from dependency spec file. In general, it might be any software Sugar Network [http://node.sugarlabs.org/context Context], but current implementation assumes only GNU/Linux [http://node.sugarlabs.org/context?type=package packages].
  
Python-based activity with standard Sugar Platform dependencies.
+
== Glob patterns ==
  
[Activity]
+
The ''include'' and ''exclude'' options contain file patterns. A pattern could be of two types:
slug      = cartoon-builder
 
name      = Cartoon Builder
 
summary  = Create your own cell-animation sequences
 
license  = GPLv2+
 
homepage  = http://wiki.sugarlabs.org/go/Activities/Cartoon_Builder
 
icon      = activity/activity-cartoonbuilder.svg
 
category  = Games;Education
 
version  = 11.4.9-pre3
 
stability = testing
 
exec      = sugar-activity activity.CartoonBuilderActivity
 
  
=== Python library ===
+
* doesn't contain ''/'' or ''**'' substrings, will be applied only to file names
 +
* contains ''/'' or ''**'' substring, will be applied to the full file path (relative to the root), thus could affect several directory levels
  
Package python-based library that could be used as is, or as an activity dependency.
+
Only these pattern symbols are allowed:
  
[Package]
+
* ''*'' matches everything, except directory separator
slug      = journal
+
* ''?'' matches any single character, except directory separator
summary  = Hight level library to create your own Journal-like activity
+
* ''**'' matches everything, including directory separator
license  = GPLv3+
 
homepage  = http://wiki.sugarlabs.org/go/Activity_Team/Services/Journal
 
version  = 1
 
stability = testing
 
requires  = toolkit/python
 
binding  = PYTHONPATH
 
 
 
=== Vala library ===
 
 
 
Binary library with generating C files from Vala sources, creating library package, and devel, python binding sub-packages.
 
 
 
[DEFAULT]
 
slug      = env
 
summary  = Access to various sugar environment settings.
 
license  = LGPLv3+
 
homepage  = http://wiki.sugarlabs.org/go/Activity_Team/Services/Env
 
version  = 0.9
 
stability = testing
 
 
[Package]
 
requires  = glib; gconf; libgee >= 0.5
 
binding  = LD_LIBRARY_PATH lib
 
include  = *.so.*
 
arch      = build
 
 
[Package/devel]
 
requires  = glib/devel; gconf/devel; libgee/devel
 
            %(slug)s
 
binding  = LD_LIBRARY_PATH lib
 
            PKG_CONFIG_PATH lib/pkgconfig
 
            VAPIDIR share/vala/vapi
 
exclude  = %(PYTHON_SITEDIR)s/**
 
            *.so.*
 
arch      = build
 
 
[Package/python]
 
requires  = python; %(slug)s
 
binding  = PYTHONPATH python
 
include  = %(PYTHON_SITEDIR)s/**
 
arch      = build
 
slots[python] = 2.5; 2.6; 2.7; 3.0
 
 
[Build]
 
requires  = glib/devel; gconf/devel; libgee/devel
 
            pkgconfig; cmake; make; gcc-c
 
build    = cmake -DCMAKE_INSTALL_PREFIX=%(PREFIX)s
 
                  -DPYTHON_SITEDIR=%(PYTHON_SITEDIR)s
 
                  -DCOMPONENTS="env"
 
                  -DBINDING=python
 
                  -DCMAKE_C_FLAGS:STRING="%(CFLAGS)s"
 
                  %(SRCDIR)s &&
 
            make
 
install  = make DESTDIR=%(DISTDIR)s install
 
 
[Maintain]
 
requires  = vala
 
exec      = make dist
 

Latest revision as of 18:00, 3 July 2013

Summary

The document describes software specification files format which is a superset on top of the Sugar activity bundles specification. This format is backwards compatible with activity.info files to make sure that software starts well from the regular Sugar Shell. But the major purpose of introducing new format is supporting software hosted on the Sugar Network. In particular, new format assumes the following functionality:

  • Support binary based software;
  • Provide information about software dependencies;
  • Introduce stability levels to make it possible (for interested in people) to run development versions using the same, like for stable releases, distribution channel;
  • Distribute not only Sugar activities, e.g., software libraries;
  • Include all required information to make it possible to reuse the same spec file on different software evolution phases, like, making sources tarball, building binaries on Sugar Labs instance of the Open Build Service, executing.

The format is partially based on the Zero Install specification since implementation code reuses Zero Install library in order to launch software on users side.

Spec file locations

There are two possible spec file locations (staring from the top directory of a distribution bundle):

  • /activity/activity.info
    for Sugar activities to make them capable to be launched from the regular Sugar Shell;
  • /sweets.recipe
    in the rest of cases.

Configuration sections

As activity.info files, new format is based on INI files and should contain at least one of the following sections.

Common options

Regardless of the software type, a recipe section (or one of them) should contain the following options.

context = GUID

Required (but see the [Activity] section). The value which uniquely identifies a software project this particular version implements. This is a Sugar Network Context GUID.

name = NAME

Optional. Free-form name. (It is equal to the implemented, by default.)

summary = ONE_LINE_TEXT

Required. Short descriptive line.

description = MULTI_LINE_TEXT

Optional. Long descriptive text. To wrap long text, all lines starting from the second, should start with spaces. This field is equal to summary by default.

license = LICENSE [; ...]

Required. Short license names. The licenses should conform with the Activity Library licensing policy.

homepage = URL

Required. Software project home page.

icon = FILENAME

Optional (but see the [Activity] section). Path to the icon file starting from the path where the recipe file is located.

tags = TAG [; ...]

Optional. Tags give more context by which to group the software. This is done to allow users to make search more easily.

version = VERSION

Required. Current version of the software using special notation. Note, to make Sugar activity bundles compatible with pristine Sugar, use a limited format subset supported by the Sugar Shell.

stability = LEVEL

Required. Stability level of the current version. Values conform to the below list.

requires = DEPENDENCY [; ...]

Optional. List of dependencies that should exist at run-time before launching the release.

[Activity]

This section type should be present only in Sugar activities.

activity_version = VERSION

Required. An alias of the version option.

bundle_id = BUNDLE_ID

Required. An alias of the context option.

icon = FILENAME_WITHOUT_SUFFIX

Required. Behaviour from activity.info is supported (value should not have a .svg suffix, and the icon file can be found only in the activity subdirectory) and, while deprecated, it needs to be used to not break backwards compatibility. For the remaining cases, the regular icon behaviour should be used instead.

exec = SHELL_COMMAND

Required. Sugar will pass additional command line arguments to this command.

mime_types = MIME_TYPE [; ...]

Optional. List of mime types supported by the activity. It's used when opening a file from the web, or to present to the user a list of activities that can open a certain Journal object.

[Archive]

This configuration section makes sense only while building binary distribution bundles from the sources. The section is optional for spec files that describe software assumed to be launched as-is, e.g., .xo bundles.

Each [Archive] section describes one particular binary bundle. There are might be several sections to define binaries for different cases:

  • To save storage space or bandwidth when some bundles will contain any-arch data that are common for all platforms, and another bundle will contain binaries for a particular platform;
  • Per language bundles, e.g., for media content.

All archive sections are named:

Archive[:SUBNAME]

And contain the following options:

include = GLOB [; ...]

Optional. Glob pattern for files to include in the archive. By default, all files are assumed.

exclude = GLOB [; ...]

Optional. Like the include option, but used for excluding files from the archive. In addition, various temporary files will be excluded, like .bak or .pyc.

arch = ARCH

Optional. Makes sense only for binary archives, and can contain:

  • all for noarch (by default),
  • any for binaries to use the current architecture.

[Build]

This section is required if software needs additional work in order to prepare a ready-to-use installation. It is important to use predefined constants for options that contain shell commands. All shell commands will be executed from the %(BUILDDIR)s directory.

NOTE The commands in this section will be executed, not only in the developer's environment, but also in the user's, if a proper binary wasn't found; so move all development-related commands, like autogen.sh, to the [Source] section.

requires = DEPENDENCY [; ...]

Optional. This defines what dependencies should be present before building the software from sources. Note that common requires option values are not auto included in the build-time dependencies.

clean = SHELL_COMMAND

Optional. Cleanup build environment before running configure command.

configure = SHELL_COMMAND

Optional. Shell command to configure sources before building, e.g., invoking the configure script in auto-tools-based projects. If the source code does not require a configuration stage, this option could be omitted.

make = SHELL_COMMAND

Optional. Shell command to make binaries from sources. If the source code does not require a making stage, this option could be omitted.

install = SHELL_COMMAND

Required. Shell command to place files that are ready for distribution into the %(DESTDIR)s directory. If install is missing, the entire %(BUILDDIR)s (excepting temporary files) will be copied.

[Source]

The section makes sense only while building sources bundles and is a replacement of former MANIFEST file in Sugar activity bundles.

exec = SHELL_COMMAND

Optional. Execute an external program to create sources tarball. Option might be used, e.g., to run make dist command.

include = GLOB [; ...]
exclude = GLOB [; ...]

Optional. If the exec option was not used, all files will be bundled and these glob patterns might be used to reify the selection.

requires = DEPENDENCY [; ...]

Optional. The dependencies that should be present before creating sources tarball. For example, if the exec command generates .c files from .vala, the vala dependency should be mentioned in the requires option.

Predefined constants

Constants defined within the [Build] section:

  • BUILDDIR where the build happens, directory contains un-tarred sources bundle. This variable can be used in binding options as well. During the local build, it will point environment variables to the root of sources directory.
  • DESTDIR temporary path to place installed files before bundling them
  • PREFIX should be used as installation prefix path, e.g., for ./configure --prefix
  • CFLAGS default gcc CFLAGS
  • CXXFLAGS default gcc CXXFLAGS

In sections that contain a langs option:

  • LANG current language while building per language implementation

Version numbers

A version number string has the following form:

Version := DottedList ("-" Modifier? DottedList?)*
DottedList := (Integer ("." Integer)*)
Modifier := "pre" | "rc" | "post"

Numerically, the modifiers come in the order "-pre" (pre-release), "-rc" (release candidate), "-" (no modifier name), "-post" (post-release or patch level). Versions are ordered like this:

0.1
1
1.0
1.2-pre
1.2-pre1
1.2-rc1
1.2
1.2-0
1.2-post
1.2-post1-pre
1.2-post1
1.2.1-pre
1.2.1.4
1.2.2
1.2.10
3

Software stability levels

The spec file also gives a stability rating for each implementation. The following levels are allowed (must be lowercase in the feed files):

  • stable,
  • testing,
  • developer,
  • buggy,
  • insecure.

Stability ratings are expected to change over time. When any new release is made, its stability should be set to testing. Users who have selected Help test new versions will then start using it. Other users will continue with the previous stable release. After a while (days, weeks or months, depending on the project) with no serious problems found, the implementation's stability can be changed to stable so that everyone will use it.

If problems are found, it can instead be marked as buggy, or insecure to avoid selecting these versions while launching on users side. developer is like a more extreme version of testing, where the program is expected to have bugs.

When to use buggy? Don't mark old releases as buggy every time you do a new release, just because a few bugs have been fixed. People who have selected network connectivity automatically pickup the new version anyway, so marking an older version as buggy only affects people who have explicitly stated that they don't want to use the latest version, but would prefer to use an older release to save network use.

Dependencies

Dependencies might be used to declare software that the current release depends on.

The format of a dependency string is:

DEPENDENCY [(<|<=|=|>=|>) VERSION]

The DEPENDENCY value is a GUID associated with dependency project, i.e., context value from dependency spec file. In general, it might be any software Sugar Network Context, but current implementation assumes only GNU/Linux packages.

Glob patterns

The include and exclude options contain file patterns. A pattern could be of two types:

  • doesn't contain / or ** substrings, will be applied only to file names
  • contains / or ** substring, will be applied to the full file path (relative to the root), thus could affect several directory levels

Only these pattern symbols are allowed:

  • * matches everything, except directory separator
  • ? matches any single character, except directory separator
  • ** matches everything, including directory separator