scm.exlibscm.exlib is a general framework for writing exheres that check out code from a source code management system. It is designed to make the interface and feature set as uniform as reasonably possible across different SCMs, to share as much logic as possible between different backend implementations, and to easily support multiple checkouts in a single exheres.
An exheres using scm.exlib defines one or more variables defining the code that should be checked out, and then requires the exlib. While it is possible to require scm directly, it is more common to specify the backend exlib, named scm-backend - this is a shortcut that avoids the need to define the TYPE variable explicitly. Examples:
An SVN checkout; sets REPOSITORY explicitly, and TYPE implicitly:
SCM_REPOSITORY="svn://rubyforge.org/var/svn/rubygems"
require scm-svn
Same as the previous example, but without using the shortcut syntax:
SCM_REPOSITORY="svn://rubyforge.org/var/svn/rubygems"
SCM_TYPE=svn
require scm
Most commonly, an exheres will only perform a single checkout. However, sometimes it is necessary to fetch code from multiple sources. In this case, one repository is designated the “primary” repository (this term is also used for the only repository in the one-checkout case) and the rest are called “secondary” and each given their own name, listed in ${SCM_SECONDARY_REPOSITORIES}. Names must be non-empty and consist only of letters, digits and underscores. For example:
SCM_REPOSITORY="git://anongit.freedesktop.org/git/xorg/xserver"
SCM_REVISION="3336ff91de2aa35277178f39b8d025e324ae5122"
SCM_BRANCH="xgl-0-0-1"
SCM_CHECKOUT_TO="xorg-server"
SCM_mesa_REPOSITORY="git://anongit.freedesktop.org/git/mesa/mesa"
SCM_mesa_REVISION="ad6351a994fd14af9d07da4f06837a7f9b9d0de4"
SCM_mesa_BRANCH="master"
SCM_SECONDARY_REPOSITORIES="mesa"
require scm-git
Here, REPOSITORY is set for both repositories, as it must be, and REVISION, because we want to build a specific version rather than whatever happens to be the latest. BRANCH is not required here, as the default for the git backend is to fetch all branches, but it is more efficient to fetch only the one that is needed. CHECKOUT_TO is set for the primary repository so that the local git clone can be shared with the xorg-server package.
Occasionally it is useful to set the variables after requireing the exlib. For example, when defining many similar repositories in a loop, it is convenient to use the scm_set_var function, but this is not available until scm.exlib is loaded. In this case, either ensure that ${SCM_REPOSITORY} is not set when require scm is executed or set ${SCM_NO_AUTOMATIC_FINALISE} to a non-zero value before the require, and call scm_finalise after setting all the variables. Example:
require amarok scm-svn
SCM_REPOSITORY="svn://anonsvn.kde.org/home/kde/"
SCM_SUBPATH="extragear/multimedia/${PN}"
SCM_SECONDARY_REPOSITORIES="libplasma animators popupdropper"
for SCM_THIS in ${SCM_SECONDARY_REPOSITORIES}; do
scm_set_var REPOSITORY "${SCM_REPOSITORY}"
scm_set_var REVISION _
SCM_SVN_EXTERNALS+=" src/context/${SCM_THIS/lib}:${SCM_THIS}"
done
SCM_libplasma_SUBPATH="KDE/kdebase/workspace/libs/plasma"
SCM_animators_SUBPATH="KDE/kdebase/workspace/plasma/animators"
SCM_popupdropper_SUBPATH="playground/libs/popupdropper/popupdropper"
scm_finalise
This example also demonstrates the use of SUBPATH to fetch a single project from a large SVN repository, and SVN_EXTERNALS to deal with the svn:externals feature of SVN (externals are not fetched automatically, because all SCM checkouts should be controlled by scm.exlib).
Variables defined in this section are defined at most once per exheres. All are simple bash variables. Unless otherwise specified, variables default to being unset/empty.
SCM_SECONDARY_REPOSITORIESoption? ( ) conditionals, similar to those in dependencies.SCM_NO_PRIMARY_REPOSITORYTYPE variable into secondary repositories still functions). Intended for cases where all checkouts should be subject to options.SCM_NO_AUTOMATIC_FINALISEscm_finalise from being called automatically by scm.exlib, even if ${SCM_REPOSITORY} is non-empty at require-time. Intended for cases where the SCM_* variables are defined in multiple places (exheres/exlibs), and it would be difficult to ensure that ${SCM_REPOSITORY} is not set earlier than desired.Variables described in this section can be defined separately for each repository. Unless otherwise specified, variables default to being unset/empty, and secondary repositories do not automatically inherit values from the primary repository. After requireing scm.exlib, some of these may automatically be sanitised or assigned default values.
To define a variable for the primary repository, set the bash variable SCM_variable-name. Examples:
SCM_REPOSITORY="git://git.pioto.org/paludis" to set the REPOSITORY variable to upstream’s git URISCM_TAG=${PV} to set the TAG variable according to the version of the exheresTo define a variable for a secondary repository, set the bash variable SCM_repository-name_variable-name. Examples:
SCM_clang_REPOSITORY="http://llvm.org/svn/llvm-project/cfe/" to set the REPOSITORY variable for the clang repository to the appropriate SVN URISCM_perl6_spec_TYPE="svn" to specify SVN for the perl6_spec repository, when the primary repository uses git|
General definition |
Backend-specific notes |
|||||||
|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|||
|
Generic variables |
|
The name of the backend. For secondary repositories, defaults to that set for the primary repository, which is itself usually set by |
||||||
|
|
The directory into which the remote repository will be cloned/checked out/etc. Defaults to the package name for the primary repository, or the repository name for secondary repositories. If the backend doesn’t support multiple branches in a single checkout and Should always be set to a relative path in the exheres; |
A shared repository is created in this directory, then the branch is cloned to a subdirectory named by the |
||||||
|
|
The directory under Note that, although this should always be a subdirectory of |
Can be overridden automatically if the repository is mentioned in |
||||||
|
|
The address (often a URI) of the repository, in the appropriate backend-specific syntax. Must be set. |
This should specify the portion of the URI common to all branches in the “same” repository (it doesn’t matter whether or not a shared repository is actually present on the remote end) — the remainder should be placed in the
|
This should be set to the appropriate value of |
This should be the Subversion URI up to but not including the Do not include peg revisions here; use |
||||
|
|
The branch within the repository that should be fetched and copied to the build directory. |
Defaults to |
Not supported, as darcs uses a “repository = branch” model. |
Specifies which branch to fetch, and if neither Defaults to |
Specifies the branch within a particular repository. With Mercurial, it is common to use the “repository = branch” model instead, which should be handled using |
|||
|
|
The symbolic name of the revision that should be copied to the build directory. It is generally assumed that tags are fixed at creation, even if the SCM doesn’t enforce this. Please throw things at your upstream if this is not true. |
|||||||
|
|
The identifier of the revision that should be copied to the build directory, using the appropriate backend-specific syntax. In general, this must be a literal identifier, not (for SCMs that support such things) an expression that evaluates to an identifier and may even change meaning over time. |
Must be either a revision identifier or a non-dotted revision number (the latter is only supported to allow things like |
A timestamp of the form |
Not supported, as darcs does not have revision identifiers. See |
Must be lower-case and unabbreviated. |
Must be lower-case and unabbreviated. |
May be |
|
|
|
The subdirectory of the repository that should be checked out and copied to the work directory. |
Not supported. |
The CVS module that should be checked out. Defaults to the package name for the primary repository, and the repository name for secondary repositories. |
Not supported. |
Not supported. |
Not supported. |
||
|
Backend-specific variables |
|
A file containing the output of |
||||||
|
|
An array listing the names of files containing public keys that should be used to verify signed tags. If specified, the tag must be signed by one of these keys. Usually created with |
|||||||
|
|
A space-separated list of terms of the form It is an error if the repository does not match the externals definition (as defined by the values of |
|||||||
|
|
The password to pass to SVN. If empty, an explict empty password is used. Only meaningful if |
|||||||
|
|
If non-empty, the URI specified in |
|||||||
|
|
The username to pass to SVN. See also |
|||||||
scm.exlib-defined variablesscm.exlib defines more variables than are listed here, but the remainder are for internal use only.
scm.exlib-defined variablesThese are simple bash variables, and are defined after requireing scm.exlib, either directly or via a backend.
SCM_HOME${FETCHEDDIR}/scm. The default directory for storing local checkouts. Exheres will rarely need to refer to this directly.scm.exlib-defined variablesThese are mapped to bash variables in the same way as those defined by the exheres. They are generally not defined immediately; see the description of each variable to find out when it becomes available.
|
General definition |
Backend-specific notes |
|||||||
|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|||
|
Generic variables |
|
After a repository has been checked out and copied into |
This is always a globally unique revision identifier, not a revision number. |
Not supported, as CVS does not have repository-wide revision identifiers (and timestamps are not suitable due to non-atomicity). See |
Not supported, as darcs does not have revision identifiers. See |
|||
|
Backend-specific variables |
|
After the repository is checked out and copied to |
||||||
|
|
After the repository is checked out and copied to Note: currently empty if |
|||||||
These variables may be set by the user in the package manager configuration. Exheres should not modify them, and will rarely need to use them.
SCM_OFFLINESCM_MIN_UPDATE_DELAYSCM_SVN_CONFIG_DIR~/.subversion.SCM_THISscm.exlib-defined functionsscm.exlib defines more functions than are listed here, but the remainder are for internal use only.
As is usual with exlib-defined phase functions, these need only be called if the exheres or another exlib needs to define its own version of the phase function.
scm_unpack${WORK}.pkg_infoNote: most of these functions are rarely needed in exheres. In particular, scm_get_var and scm_set_var need only be used if the name of the variable or repository is not fixed at authoring time; otherwise, it is acceptable and usually preferably to reference the underlying bash variable directly. See the example for an exception.
scm_finalisescm.exlib is loaded. See the example for a situation where it needs to be called manually.scm_for_eachSCM_THIS set appropriately.scm_var_namescm_get_varscm_set_varscm_modify_varscm_get_arrayscm_set_arrayscm_trim_slashes-scheme, leading and trailing, followed by exactly one string argument. Outputs its string argument with sequences of duplicate / characters replaced by single /s. If -scheme is specified, any text up to and including the first occurrence of :// will be unchanged. If -leading is specified, also removes any / characters at the start of the string. If -trailing is specified, also removes any / characters at the end of the string.TODO
Copyright 2009 David Leverton
This work is licensed under the Creative Commons Attribution Share Alike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/; or, (b) send a letter to Creative Commons, 171 2nd Street, Suite 300, San Francisco, California, 94105, USA.