Difference between revisions of "Platform Team/Guide/Sweets Packaging"

From Sugar Labs
Jump to navigation Jump to search
Line 61: Line 61:
  
 
The ''base'' project is also useful for [[Platform_Team/Sweets/Glossary#Associated_interfaces|associated]] interfaces set in ''associate'' recipe option. For example, if your sweet needs ''pygame=2'' dependency that is not yet widespread, create ''~user/pygame'' temporary sweet with ''2'' version only, and use ''~user/pygame'' as a dependency in your sweet. If ''base/pygame'' will be added as associated interface to the ''~user/pygame'', users that have ''>=2'' version in native packages will reuse them instead of ''~user/pygame'''s one.
 
The ''base'' project is also useful for [[Platform_Team/Sweets/Glossary#Associated_interfaces|associated]] interfaces set in ''associate'' recipe option. For example, if your sweet needs ''pygame=2'' dependency that is not yet widespread, create ''~user/pygame'' temporary sweet with ''2'' version only, and use ''~user/pygame'' as a dependency in your sweet. If ''base/pygame'' will be added as associated interface to the ''~user/pygame'', users that have ''>=2'' version in native packages will reuse them instead of ''~user/pygame'''s one.
 +
 +
=== Stability status ===
 +
 +
Sweets should have stability status:
 +
 +
* ''stable'', final stable release,
 +
* ''testing'', let people interested in testing try latest changes that are not yet stable,
 +
* ''developer'', just a more extreme version of ''testing'',
 +
 +
This is a useful Zero Install feature that let developers share not yet stable version among the community. Since by default, only stable versions are being used, people, who are interested in helping developers in polishing not yet stable versions, need to explicitly choose not stable versions.
 +
 +
=== 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
  
 
=== Examples ===
 
=== Examples ===
Line 141: Line 164:
 
  make      = make
 
  make      = make
 
  install  = make DESTDIR=%(DESTDIR)s install
 
  install  = make DESTDIR=%(DESTDIR)s install
 +
 +
== Releasing ==
  
 
== Development with Sweets ==
 
== Development with Sweets ==
Line 150: Line 175:
  
 
Checking out will register a ''sweet'' in the local ''Sweets'' instance as a single ''implementation'' for the ''interfaces'' it ''implements''. This feature is especially useful for libraries, for example, if the sugar-toolkit sources, which implement the {{Code|sdk/sugar-toolkit}} ''interface'', were cloned to the {{Code|~/src/sugar-toolkit}} directory, then, while running a {{Code|sdk/sugar}} ''sweet'', it would become possible to reuse local sugar-toolkit sources as a regular ''implementation'' of the {{Code|sdk/sugar-toolkit}} dependency of {{Code|sdk/sugar}}.
 
Checking out will register a ''sweet'' in the local ''Sweets'' instance as a single ''implementation'' for the ''interfaces'' it ''implements''. This feature is especially useful for libraries, for example, if the sugar-toolkit sources, which implement the {{Code|sdk/sugar-toolkit}} ''interface'', were cloned to the {{Code|~/src/sugar-toolkit}} directory, then, while running a {{Code|sdk/sugar}} ''sweet'', it would become possible to reuse local sugar-toolkit sources as a regular ''implementation'' of the {{Code|sdk/sugar-toolkit}} dependency of {{Code|sdk/sugar}}.
 
== Feedback ==
 
 
* [http://bugs.sugarlabs.org/newticket?component=sweets Submit] your bug report.
 
* Ask your question on IRC channels, [irc://irc.freenode.net/sugar #sugar] (not logged) or [irc://irc.freenode.net/sugar-newbies #sugar-newbies] (logged).
 
 
<!--
 
 
The only thing that is required from sources is having a [[Platform Team/Recipe Specification|sweets.recipe]] spec file for non-activity projects or an {{Code|activity/activity.info}} file (that conforms to the same spec) for activities. All sweets for Glucose components are located in the http://git.sugarlabs.org/sdk project.
 
 
Once checked out, these sources might be launched using {{Code|<nowiki>http://</nowiki>sweets.sugarlabs.org/''sweet-value-from-sweets.recipe''}} or just mentioning a sweet value:
 
 
sweets ''sweet''
 
 
For glucose projects, you can find ready-to-use and always-rebased-to-upstream projects in the [http://git.sugarlabs.org/sdk SDK] http://git.sugarlabs.org project. For now, there are two branches: {{Code|master}} for recent trunk, and {{Code|master-0.88}} for 0.88 code based on Dextrose-2 patches.
 
 
Checked-out projects will be built according to the {{Code|[Build]}} section commands in the {{Code|sweets.recipe}} files. In general, for autotools-based projects, there is no further need for the {{Code|sweets}} command; just run {{Code|make install}} to build current sources and install  them to the directory that was specified by {{Code|sweets}} in the configure stage. For glucose projects, there is no need even in calling the {{Code|make}} command (python code will be reused from its original location, see {{Code|binding}} options in [[Platform Team/Recipe Specification|sweets.recipe]] files), just change the code and restart sugar.
 
 
 
== Writing recipe files ==
 
 
See also [[Platform_Team/Recipe_Specification|recipe specification]].
 
 
=== Package names ===
 
 
Within recipe files, Zero packages might be identified by several methods:
 
 
* current package (instead of a direct slug value, to make the recipe file more robust, move the ''slug'' option to the [DEFAULT] section and use {{Code|%(slug)s}} interpolation),
 
<current-slug>[/<nowiki><sub-package></nowiki>]
 
 
* other packages from Bazaar that are accessible in the current project,
 
<other-package-slug>[/<nowiki><sub-package></nowiki>]
 
 
* direct 0install link.
 
<0install-feed-url>
 
 
At the end, all links will be transfered to 0install feed urls. The final 0install url will be in the following format:
 
 
<nowiki>http</nowiki>://sweets.sugarlabs.org/<Bazaar-project>/<slug>
 
 
=== Versioning ===
 
 
The versioning scheme for Zero packages can be arbitrary, since the ''version'' recipe 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'' recipe option should be used.
 
 
The recipe 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, and since packages may at any time be rebuilt from sources and multiple library versions may be installed (thanks to 0install).
 
 
Using the ''age'' option is simple, on every API breakage for the library package, increment the ''age'' value. The final package version will be:
 
<age-option>.<version-option>
 
 
=== Glob 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
 
  
 
== Pitfalls ==
 
== Pitfalls ==
Line 216: Line 180:
 
=== Devel packages ===
 
=== Devel packages ===
  
It is common practice in binary-based GNU/Linux distributions to use satellite devel packages to collect various build-time files like C headers or pkg-config files. In the 0install environment, this doesn't work, because every package is stored in a separate directory hierarchy, e.g., *.so symlinks, from devel package, will point to nothing, since all *.so.* files from the library package live in a separate directory.
+
It is common practice in binary-based GNU/Linux distributions to use satellite devel packages to collect various build-time files like C headers or pkg-config files. In the Zero Install environment, this doesn't work, because every package is stored in a separate directory hierarchy, e.g., *.so symlinks, from devel package, will point to nothing, since all *.so.* files from the library package live in a separate directory.
  
Keep all build-time files in the runtime package.
+
Keep all build-time files in the sweet as runtime files.
  
 +
== Feedback ==
  
 
+
* [http://bugs.sugarlabs.org/newticket?component=sweets Submit] your bug report.
 
+
* Ask your question on IRC channels, [irc://irc.freenode.net/sugar #sugar] (not logged) or [irc://irc.freenode.net/sugar-newbies #sugar-newbies] (logged).
 
 
 
 
== Introduction ==
 
 
 
The purpose of this Guide is to describe how to deploy your code via [[Activity_Team/Services|Sugar Services]] and let other people [[Documentation_Team/Services/Activity_Developers_Guide|use]] it in simple and convenient way.
 
 
 
If you are looking for a method to install some software from native packages, see [[Documentation_Team/Services/Wrap native packages HOWTO| native packages HOWTO]].
 
 
 
If the service is not just a [[Documentation_Team/Services/Native_packages_usage|wrapper]] for an upstream project, please consider the possibility of creating a service page using [[Activity Team/Services/Template|template]].
 
 
 
== Detailed description ==
 
 
 
The resulting service development process will consist of regular 0install files that are placed in a subdirectory on http://services.sugarlabs.org/ with a name that is the identity for the service in the rest of the 0sugar infrastructure. The Service's subdirectory will contain:
 
 
 
* Several .xml files that are regular 0install feeds. service.xml is the main feed for the service, other feed files are optional and represent sub services, e.g., [http://download.sugarlabs.org/services/toolkit/].
 
 
 
* A bunch of tarballs with sources and binaries. Feed files contain links to these files.
 
 
 
See the 0install [http://0install.net/interface-spec.html documentation] to learn more about feeds.
 
 
 
Services could be identified using two methods:
 
 
 
* by name in the 0sugar environment
 
<service>
 
<service>/<subservice>
 
 
 
* as regular 0install identifiers in the 0install environment
 
http://services.sugarlabs.org/<service>
 
http://services.sugarlabs.org/<service>/<subservice>.xml
 
 
 
To start the Sugar Services developing process:
 
* Install the [[Documentation_Team/Services/0sugar|0sugar]] tool.
 
* Read ''service.info'' file.
 
[[Documentation_Team/Services/Service.info_Specification|specification]]
 
and follow the rest of this document instruction about development details.
 
 
 
== Stability status ==
 
 
 
One of the core differences from the Sucrose development process is having not stable "releases" (here, release is a result of ``0sugar push`` command). So, services need stability status. Internally, each service release will have one of 0install's stability [http://0install.net/interface-spec.html#id4091477 statuses]:
 
 
 
* ''stable'', final stable release,
 
* ''testing'', let people interested in testing try latest changes that are not yet stable,
 
* ''developer'', just a more extreme version of ''testing'',
 
* ''buggy'', already-released versions (of any status) could be [[#Bugfix_releases|marked]] as buggy after a while to force people to upgrade to a new bugfix version,
 
* ''insecure'', an extreme version of ''buggy''.
 
 
 
''0sugar push'' w/o arguments will push local changes as is. If you want to push with a particular stability status, use ''0sugar push <status>''.
 
 
 
By default, all users will use only ''stable'' versions and won't upgrade to new versions, even if there are stable ones. To force people to upgrade from buggy versions, see the [[#Bugfix_releases|bugfix releases]] workflow.
 
 
 
== Development workflows ==
 
 
 
A Service developer can follow one of several step-by-step scenarios:
 
 
 
* [[Documentation Team/Services/Activity specific Services HOWTO|Activity specific Services HOWTO]] - if your activity uses its own binaries,
 
* [[Documentation Team/Services/Binary-less Services HOWTO|Binary-less Services HOWTO]] - to make any architecture service, e.g., python based,
 
* [[Documentation Team/Services/Binary Services HOWTO|Binary Services HOWTO]] - for services that contain binaries,
 
* [[Documentation Team/Services/Upstream Services HOWTO|Upstream Services HOWTO]] - if your activity or service uses a project which is not part of Sugar Platform, follow this howto to create a wrapper around the upstream project, and just add its name to the ''requires'' section of .info file,
 
* [[Documentation Team/Services/Wrap native packages HOWTO|Wrap native packages HOWTO]] - this is a special one, if some project is already well packaged in various GNU/Linux distributions, but is not a Sugar Platform component, just create a "fake" service.
 
 
 
== Release workflows ==
 
 
 
'''Having only stable releases'''
 
 
 
All releases of your services will have ''stable'' stability status.
 
 
 
* when your code is ready to release,
 
* ''0sugar dist*'' to make bundles,
 
* ''0sugar push stable'' to rsync bundles to the server,
 
* if it was the wrong time to release and you want to re-release it, repeat the previous steps to rewrite the wrong release.
 
 
 
'''Bugfix releases'''
 
 
 
Services assume a simple versioning scheme, if you found bugs in the stable version,
 
 
 
* either ''0sugar push stable'' the release once more (users will not mess this new copy of release with previous ones),
 
* or ''0sugar push stable'' the release with incremented ''version'' field.
 
* If bugs are critical, mark the previous release as ''buggy'' or ''insecure'' to force users to upgrade their old releases. If you re-pushed release w/o incrementing ''version'' number, you should use revision number.
 
 
 
0sugar push {buggy|insecure} {version[-revision]}
 
 
 
''' Development releases '''
 
 
 
If you want to test your new version among interested people,
 
 
 
* do all the steps mentioned in the previous workflows,
 
* but use either the ''testing'' or ''developer'' status for the ''push'' command.
 
* Users interested in testing (with testing mode enabled) will get your new development version.
 
* You don't have to change the ''version'' every time for micro releases, ''0sugar'' will implicitly change the revision of new pushes, and users will download the latest changes.
 
 
 
== Tips ==
 
 
 
* Via ''binding'' variables, a service's root directory will be accessible for service users, so for python services (for example), it is better to use a subdirectory for a service's import modules, like [http://git.sugarlabs.org/projects/toolkit/repos/mainline/trees/master Toolkit] does - there is a ''toolkit'' subdirectory in Toolkit's root.
 
 
 
* Be careful with machine architecture, especially in making binaries in VMs, e.g., the XO-1 arch is i586, but built-in XO VM, binaries could have i686 and thus, won't start (0install won't allow) on XO-1. Use --arch 0sugar's argument to set targeted architecture explicitly.
 
 
 
== Documentation ==
 
 
 
* [http://0install.net/injector-packagers.html Packaging guide] for 0install packages
 
* [http://0install.net/interface-spec.html Feed file format specification]
 
* [http://0install.net/0compile.html 0compile] [http://0install.net/0compile-dev.html guide]
 
 
 
== The workflow of regular Sugar doer will look like: ==
 
 
 
# Having a directory with Sugar project to develop.
 
#* Directory should be placed to one of default paths.
 
#* The only important element is a [[Platform Team/Sugar_Doers_Kit/Implementation#Recipes|recipe file]], i.e., an analog of {{Code|activity.info}} file for activities.
 
# To make it useful, just run it.
 
#* For activities, just click on activity icon in Sugar Shell.
 
#* Otherwise, run application using its unique Web url.
 
# Everything which is related to the process of project running, will be handled automatically.
 
#* There is always a way to fallback to the particular running step.
 
#* If project has dependencies, they will be installed or passed though the same running procedure (for under development dependencies).
 
#* If project needs to be build, it will happen automatically (including installing buildtime dependencies).
 
# Make Sugar project accessible for others.
 
#* Only one command call or one click in Sugar Shell is needed.
 
#* The only requirement, being registered in the system (particular implementations might be different, from [https://cas.sugarlabs.org/ Sugar Labs Central Login] to local school server).
 
#* Anyone can run recent version of your project just be mentioning its Web url.
 
# Sharing information about Sugar project.
 
#* Information about newly released project might be automatically published on [[Activity Library]].
 
 
 
-->
 

Revision as of 18:19, 30 September 2011

Summary

This guide describes how to prepare software projects to be distributed via Sugar Labs' Packaging Management System, Sweets.

Make sure that you read the introduction page and Usage guide. To understand conceptual ideas, read the Glossary.

Prepare the environment

Using the Usage guide's instructions, install the Sweets. In addition, Sweets might be used from sources:

git clone git://git.sugarlabs.org/sdk/sweets.git
cd sweets
git submodule init
git submodule update
./sweets upgrade

The command ./sweets upgrade might require relogin from the X session to take into account the new PATH value.

Recipe files

The recipe specification file is an analog of scenario files in regular GNU/Linux distributions, like .spec files in RPM. It is the cornerstone of Sweets, everything on the sweet project level depends on the recipe file. For activities, activity/activity.info, an inherited recipe file name, is supported.

On a logical level, the entire Sweets infrastructure might be treated as a set of distribution bundles with sources that contain recipe files. Software projects are identified as Zero Install interfaces that contain information about which distribution bundle needs to be downloaded in order to launch a particular software version. That's not the full picture (there are binary bundles created based on sources), but it is useful for this topic's purpose. Read the Development with Sweets section to learn about the available usage scenarios.

A recipe file is an ini format configuration file that might consist of several sections:

These files need to be placed in the root sources directory with names sweets.recipe or activity/activity.info for Sugar activities.

Writing recipes

In sources directory, create a recipe file, e.g., using sweets init command. Recipe file should contain at least one use case section. There are several types of use case sections:

  • Activity for Sugar activities,
  • Application for stand alone applications,
  • Library for libraries.

Make sure that all required options were set. The implement option has a special meaning, it is an identifier of the sweet.

By default, the entirely sources directory will be packaged into sources tarball. In case if sources list needs to be restricted, add Source section with appropriate include and/or exclude options.

If the sweet needs to be built, add Build section.

If built files are platform dependent, add Archive section with arch=any option.

Interfaces

The implement, associate and requires (optionally) options contain short interfaces. These values have two meanings:

In the 2nd case, the last slash separated part is a package, and the rest is a project, e.g., for sdk/sugar, sdk is a project and sugar is a package in the sdk project. It is possible to have interface values without slashes, in that case, project and package names are the same.

In the OBS, there is a special project named base. This project contains sweets that all time will be represented only by native packages. In other words, if you need to make sure that your sweet needs to depend only on native packages, use dependencies from the base project.

The base project is also useful for associated interfaces set in associate recipe option. For example, if your sweet needs pygame=2 dependency that is not yet widespread, create ~user/pygame temporary sweet with 2 version only, and use ~user/pygame as a dependency in your sweet. If base/pygame will be added as associated interface to the ~user/pygame, users that have >=2 version in native packages will reuse them instead of ~user/pygame's one.

Stability status

Sweets should have stability status:

  • stable, final stable release,
  • testing, let people interested in testing try latest changes that are not yet stable,
  • developer, just a more extreme version of testing,

This is a useful Zero Install feature that let developers share not yet stable version among the community. Since by default, only stable versions are being used, people, who are interested in helping developers in polishing not yet stable versions, need to explicitly choose not stable versions.

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

Examples

A list of recipe examples.

Python activity

Python-based activity with standard Sugar Platform dependencies.

[Activity]
implement = cartoon-builder
name      = Cartoon Builder
summary   = Create your own cell-animation sequences
license   = GPLv2+
homepage  = http://wiki.sugarlabs.org/go/Activities/Cartoon_Builder

version   = %(activity_version)s
stability = stable

icon      = activity-cartoonbuilder
exec      = sugar-activity activity.CartoonBuilderActivity

# Backwards compatibility of original activity.info options
bundle_id = com.ywwg.CartoonBuilderActivity
activity_version = 7

Python library

A python-based library that could be used as is, or as an activity dependency.

[Library]
implement = libjournal
name      = libjournal
summary   = Hight level library to create your own Journal-like activity
license   = GPLv3+
homepage  = http://wiki.sugarlabs.org/go/Activity_Team/Services/Journal
version   = 1
stability = testing
requires  = toolkit
binding   = PYTHONPATH

C-based library

[DEFAULT]
depends   = base/glib; base/gconf; base/libgee >= 0.5; base/gtk+ >= 2.12
            base/pango >= 1.20; base/librsvg

[Library]
implement = polyol
name      = polyol
summary   = Intermediate level GObject based libraries for Sugar
description = Polyol is a set of libraries that are written in Vala.
            Libraries are intended to provide high-level C API to basic Sugar
            features including Gtk based user interface. Applications that are
            linked against Polyol, interact with sugar processes
            (like shell, datastore, etc.) via DBus.
license   = LGPLv3+
homepage  = http://wiki.sugarlabs.org/go/Activity_Team/Polyol

version   = 1
stability = developer

binding   = LD_LIBRARY_PATH lib
            PKG_CONFIG_PATH lib/pkgconfig
            VAPIDIR share/vala/vapi
requires  = %(depends)s

[Archive]
arch      = any

[Build]
requires  = %(depends)s; pkg-config; cmake; make; gcc-c
configure = cmake -D CMAKE_INSTALL_PREFIX=%(PREFIX)s
                  -D PYTHON_SITEDIR=%(PREFIX)s/python
                  -D COMPONENTS="collab;ds;env;gui;shell;toolkit"
                  -D BINDING=python
                  -D CMAKE_C_FLAGS:STRING="%(CFLAGS)s"
                  .
make      = make
install   = make DESTDIR=%(DESTDIR)s install

Releasing

Development with Sweets

Source bundles might be used on a client side not only indirectly, via sweets command for example, but also explicitly. Sources might be bundled, emailed, etc. In this case, it is no different from .xo files. To make sources useful within Sweets, the local directory with sources might be used in several ways:

  • Applications might be launched from sources, sweets <path-to-sources>;
  • To reuse sources as dependencies for other sweets, source directory needs to be registered in Sweets, sweets checkout <path-to-sources>; applications might be checked out as well.

Checking out will register a sweet in the local Sweets instance as a single implementation for the interfaces it implements. This feature is especially useful for libraries, for example, if the sugar-toolkit sources, which implement the sdk/sugar-toolkit interface, were cloned to the ~/src/sugar-toolkit directory, then, while running a sdk/sugar sweet, it would become possible to reuse local sugar-toolkit sources as a regular implementation of the sdk/sugar-toolkit dependency of sdk/sugar.

Pitfalls

Devel packages

It is common practice in binary-based GNU/Linux distributions to use satellite devel packages to collect various build-time files like C headers or pkg-config files. In the Zero Install environment, this doesn't work, because every package is stored in a separate directory hierarchy, e.g., *.so symlinks, from devel package, will point to nothing, since all *.so.* files from the library package live in a separate directory.

Keep all build-time files in the sweet as runtime files.

Feedback