README.rst 11 KB
Newer Older
Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
1
************************
2 3 4 5 6 7 8 9
slapos.recipe.build:cpan
************************

Downloads and installs perl modules using Comprehensive Perl Archive Network (cpan).



Examples
Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
10
********
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

Basic example
-------------

Here is example to install one or several modules::

  [buildout]
  parts = perl-modules

  [perl-modules]
  recipe = slapos.recipe.build:cpan
  modules =
    Class::Date
    Other::Module
  # Optional argument specifying perl buildout part, if existing.
  # If specified, recipe will use the perl installed by buildout.
  # If not specified, will take the globally available perl executable.
  perl = perl

Specific version
----------------

Note that cpan won't allow you to specify version and will always take latest
version available. To choose a specific version, you will need to specify
the full path in cpan like in ::


  [buildout]
  parts = perl-modules

  [perl-modules]
  recipe = slapos.recipe.build:cpan
  modules =
    D/DL/DLUX/Class-Date-1.1.10.tar.gz
  perl = perl

Notes
=====

50
Currently, the modules will be installed in site-perl directory. Location of this
51 52
directory changes depending on the perl installation.

53 54


Antoine Catton's avatar
Antoine Catton committed
55 56 57 58 59
****************************
slapos.recipe.build:gitclone
****************************

Checkout a git repository.
60 61
Supports slapos.libnetworkcache if present, and if boolean 'use-cache' option
is true.
Antoine Catton's avatar
Antoine Catton committed
62 63 64 65

Examples
********

66 67
Those examples use slapos.recipe.build repository as an example.

Antoine Catton's avatar
Antoine Catton committed
68 69 70
Simple clone
------------

71
Only `repository` parameter is required. For each buildout run,
Antoine Catton's avatar
Antoine Catton committed
72 73
the recipe will pick up the latest commit on the remote master branch::

74 75 76 77 78 79 80 81
  >>> write(sample_buildout, 'buildout.cfg',
  ... """
  ... [buildout]
  ... parts = git-clone
  ...
  ... [git-clone]
  ... recipe = slapos.recipe.build:gitclone
  ... repository = http://git.erp5.org/repos/slapos.recipe.build.git
82
  ... use-cache = true
83
  ... """)
Antoine Catton's avatar
Antoine Catton committed
84 85

This will clone the git repository in `parts/git-clone` directory.
86 87 88 89
Then let's run the buildout::

  >>> print system(buildout)
  Installing git-clone.
90
  Cloning into '/sample-buildout/parts/git-clone'...
91 92 93 94

Let's take a look at the buildout parts directory now::

  >>> ls(sample_buildout, 'parts')
95
  d buildout
96
  d git-clone
Antoine Catton's avatar
Antoine Catton committed
97

98 99 100 101 102 103 104
When updating, it will do a "git fetch; git reset @{upstream}"::

  >>> print system(buildout)
  Updating git-clone.
  Fetching origin
  HEAD is now at ...

Antoine Catton's avatar
Antoine Catton committed
105 106 107 108 109 110
Specific branch
---------------

You can specify a specific branch using `branch` option. For each
run it will take the latest commit on this remote branch::

111 112 113 114 115 116 117 118 119 120
  >>> write(sample_buildout, 'buildout.cfg',
  ... """
  ... [buildout]
  ... parts = git-clone
  ...
  ... [git-clone]
  ... recipe = slapos.recipe.build:gitclone
  ... repository = http://git.erp5.org/repos/slapos.recipe.build.git
  ... branch = build
  ... """)
Antoine Catton's avatar
Antoine Catton committed
121

122 123 124 125
Then let's run the buildout::

  >>> print system(buildout)
  Uninstalling git-clone.
126
  Running uninstall recipe.
127
  Installing git-clone.
128
  Cloning into '/sample-buildout/parts/git-clone'...
129 130 131 132

Let's take a look at the buildout parts directory now::

  >>> ls(sample_buildout, 'parts')
133
  d buildout
134 135 136 137 138
  d git-clone

And let's see that current branch is "build"::
  >>> import subprocess
  >>> cd('parts', 'git-clone')
139 140
  >>> print subprocess.check_output(['git', 'branch'])
  * build
Antoine Catton's avatar
Antoine Catton committed
141

142 143 144 145 146 147 148 149
When updating, it will do a "git fetch; git reset build"::

  >>> cd(sample_buildout)
  >>> print system(buildout)
  Updating git-clone.
  Fetching origin
  HEAD is now at ...

Antoine Catton's avatar
Antoine Catton committed
150 151 152 153
Specific revision
-----------------

You can specify a specific commit hash or tag using `revision` option.
154
This option has priority over the "branch" option::
Antoine Catton's avatar
Antoine Catton committed
155

156 157 158 159 160 161 162 163 164 165 166
  >>> cd(sample_buildout)
  >>> write(sample_buildout, 'buildout.cfg',
  ... """
  ... [buildout]
  ... parts = git-clone
  ...
  ... [git-clone]
  ... recipe = slapos.recipe.build:gitclone
  ... repository = http://git.erp5.org/repos/slapos.recipe.build.git
  ... revision = 2566127
  ... """)
Antoine Catton's avatar
Antoine Catton committed
167

168 169 170 171
Then let's run the buildout::

  >>> print system(buildout)
  Uninstalling git-clone.
172
  Running uninstall recipe.
173
  Installing git-clone.
174
  Cloning into '/sample-buildout/parts/git-clone'...
175 176 177 178

Let's take a look at the buildout parts directory now::

  >>> ls(sample_buildout, 'parts')
179
  d buildout
180 181
  d git-clone

182
And let's see that current revision is "2566127"::
183 184 185

  >>> import subprocess
  >>> cd(sample_buildout, 'parts', 'git-clone')
186 187
  >>> print subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'])
  2566127
Antoine Catton's avatar
Antoine Catton committed
188

189 190 191 192 193 194
When updating, it will do a "git fetch; git reset revision"::

  >>> cd(sample_buildout)
  >>> print system(buildout)
  Updating git-clone.
  Fetching origin
195 196
  HEAD is now at 2566127 ...

197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
Empty revision/branch
---------------------

Specifying an empty revision or an empty branch will make buildout
ignore those values as if it was not present at all (allowing to easily
extend an existing section specifying a branch)::

  >>> cd(sample_buildout)
  >>> write(sample_buildout, 'buildout.cfg',
  ... """
  ... [buildout]
  ... parts = git-clone
  ...
  ... [git-clone-with-branch]
  ... recipe = slapos.recipe.build:gitclone
  ... repository = http://git.erp5.org/repos/slapos.recipe.build.git
  ... revision = 2566127
  ...
  ... [git-clone]
  ... <= git-clone-with-branch
  ... revision =
  ... branch = master
  ... """)

  >>> print system(buildout)
  Uninstalling git-clone.
  Running uninstall recipe.
  Installing git-clone.
  Cloning into '/sample-buildout/parts/git-clone'...

  >>> cd(sample_buildout, 'parts', 'git-clone')
  >>> print system('git branch')
  * master
230

231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
Revision/branch priority
------------------------

If both revision and branch parameters are set, revision parameters is used
and branch parameter is ignored::

  >>> cd(sample_buildout)
  >>> write(sample_buildout, 'buildout.cfg',
  ... """
  ... [buildout]
  ... parts = git-clone
  ...
  ... [git-clone]
  ... recipe = slapos.recipe.build:gitclone
  ... repository = http://git.erp5.org/repos/slapos.recipe.build.git
  ... branch = mybranch
  ... revision = 2566127
  ... """)

  >>> print system(buildout)
  Uninstalling git-clone.
  Running uninstall recipe.
  Installing git-clone.
  Warning: "branch" parameter with value "mybranch" is ignored. Checking out to revision 2566127...
  Cloning into '/sample-buildout/parts/git-clone'...
  HEAD is now at 2566127 ...

  >>> cd(sample_buildout, 'parts', 'git-clone')
  >>> print system('git branch')
  * master

Antoine Catton's avatar
Antoine Catton committed
262 263 264 265 266 267 268 269 270 271 272 273
Specific git binary
-------------------

The default git command is `git`, if for a any reason you don't
have git in your path, you can specify git binary path with `git-command`
option::

  [buildout]
  parts = git-clone

  [git-clone]
  recipe = slapos.recipe.build:gitclone
274 275
  repository = http://example.net/example.git/
  git-executable = /usr/local/git/bin/git
Antoine Catton's avatar
Antoine Catton committed
276

277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
Ignore SSL certificate
----------------------

By default, when remote server use SSL protocol git checks if the SSL
certificate of the remote server is valid before executing commands.
You can force git to ignore this check using `ignore-ssl-certificate`
boolean option::

  [buildout]
  parts = git-clone

  [git-clone]
  recipe = slapos.recipe.build:gitclone
  repository = https://example.net/example.git/
  ignore-ssl-certificate = true


Antoine Catton's avatar
Antoine Catton committed
294 295 296 297 298 299 300 301 302 303 304 305 306 307
Full example
------------

::

  [buildout]
  parts = git-clone

  [git-binary]
  recipe = hexagonit.recipe.cmmi
  url = http://git-core.googlecode.com/files/git-1.7.12.tar.gz

  [git-clone]
  recipe = slapos.recipe.build:gitclone
308
  repository = http://example.net/example.git/
Antoine Catton's avatar
Antoine Catton committed
309
  git-command = ${git-binary:location}/bin/git
310
  revision = 0123456789abcdef
Antoine Catton's avatar
Antoine Catton committed
311

312

Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
313
***********************
314 315 316 317 318 319
slapos.recipe.build:npm
***********************

Downloads and installs node.js packages using Node Package Manager (NPM).

Examples
Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
320
********
321 322 323 324 325 326 327 328 329 330 331 332 333 334

Basic example
-------------

Here is example to install one or several modules::

  [buildout]
  parts = node-package

  [node-package]
  recipe = slapos.recipe.build:npm
  modules =
    colors
    express
335

336 337 338 339 340 341 342
  # Optional argument specifying perl buildout part, if existing.
  # If specified, recipe will use the perl installed by buildout.
  # If not specified, will take the globally available perl executable.
  node = node-0.6

Specific version
----------------
Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
343
::
344 345 346 347 348 349 350

  [buildout]
  parts = node-package

  [node-package]
  recipe = slapos.recipe.build:cpan
  modules =
Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
351
    express@1.0.2
352
  node = node-0.6
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473


*******************
slapos.recipe.build
*******************

.. contents::

Examples
********

Recipe to build the software.

Example buildout::

  [buildout]
  parts =
    script

  [script]
  # default way with using script
  recipe = slapos.recipe.build
  url_0 = http://host/path/file.tar.gz
  md5sum = 9631070eac74f92a812d4785a84d1b4e
  script =
    import os
    os.chdir(%(work_directory)s)
    unpack(%(url_0), strip_path=True)
    execute('make')
    execute('make install DEST=%(location)s')
  slapos_promise =
    directory:bin
    dynlib:bin/file linked:libz.so.1,libc.so.6,libmagic.so.1 rpath:${zlib:location}/lib,!/lib
    directory:include
    file:include/magic.h
    directory:lib
    statlib:lib/libmagic.a
    statlib:lib/libmagic.la
    dynlib:lib/libmagic.so linked:libz.so.1,libc.so.6 rpath:${zlib:location}/lib
    dynlib:lib/libmagic.so.1 linked:libz.so.1,libc.so.6 rpath:${zlib:location}/lib
    dynlib:lib/libmagic.so.1.0.0 linked:libz.so.1,libc.so.6 rpath:${zlib:location}/lib
    directory:share
    directory:share/man
    directory:share/man/man1
    file:share/man/man1/file.1
    directory:share/man/man3
    file:share/man/man3/libmagic.3
    directory:share/man/man4
    file:share/man/man4/magic.4
    directory:share/man/man5
    directory:share/misc
    file:share/misc/magic.mgc

  [multiarchitecture]
  recipe = slapos.recipe.build
  slapos_promise =
    ...
  x86 = http://host/path/x86.zip [md5sum]
  x86-64 =  http://host/path/x64.zip [md5sum]
  script =
    if not self.options.get('url'): self.options['url'], self.options['md5sum'] = self.options[guessPlatform()].split(' ')
    extract_dir = self.extract(self.download(self.options['url'], self.options.get('md5sum')))
    workdir = guessworkdir(extract_dir)
    self.copyTree(workdir, "%(location)s")

You can remove formatting by using option “format = no” (default is “yes”)

For example::

  [escaping]
  recipe = slapos.recipe.build
  example = foobar's one
  script =
    print '%%s' %% self.options['example']
    # will print “foobar's one”

  [no-escaping]
  recipe = slapos.recipe.build
  example = foobar's one
  foo = bar
  format = no
  script =
    print '%s' % self.options['example']
    # will print “foobar's one”
    print '%(foo)s'
    # will print “%(foo)s”


Pure download
*************

Note: deprecated entry-point.

::

  [buildout]
  parts =
    download

  [download]
  recipe = slapos.recipe.build:download
  url = https://some.url/file

Such profile will download https://some.url/file and put it in
buildout:parts-directory/download/download

filename parameter can be used to change destination named filename.

destination parameter allows to put explicit destination.

md5sum parameter allows pass md5sum.

mode (octal, so for rw-r--r-- use 0644) allows to set mode

Exposes target attribute which is path to downloaded file.

Notes
-----

This recipe suffers from buildout download utility issue, which will do not
try to redownload resource with wrong md5sum.