API

This part of the documentation covers the application programming interface of Parcel.

Deployment

The majority of work done by Parcel is using the Deployment object.

class parcel.deploy.Deployment(app_name, build_deps=None, run_deps=None, path='.', base=None, arch=<parcel.distro.Debian object at 0x23965d0>, version=None, venv_dirname='vp')

The core Deployment object. All Fabric tasks built with Parcel will probably use this an instance of this class.

add_data_to_root_fs(data, remotepath)

Copies data in file on remotepath (relative to final root)

add_postinst(lines)

Add lines to the postinst file

add_postrm(lines)

Add lines to the postrm file

add_preinst(lines)

Add lines to the preinst file

add_prerm(lines)

Add lines to the prerm file

add_to_root_fs(localfile, remotepath)

Add a local file to the root package path. If remote path ends in /, the filename is copied into that directory. If the remote path doesn’t end in /, it represents the final filename.

app_name = None

The name of the resulting package.

arch = None

The architecture of the build host. This should be a Distro object.

base_path = None

Location of files during build on build host. Default is user’s home directory. If path is relative, it’s relative to the remote user’s home directory. If the path is absolute, it’s used as is.

build_deps = None

A list of packages that need to be installed to build the software.

build_package(templates=True)

Takes the whole app including the virtualenv, packages it using fpm and downloads it to the local host. The version of the package is the build number - which is just the latest package version in our Ubuntu repositories plus one.

path = None

The directory that will be used as the base level directory.

prepare_app(branch=None, requirements='requirements.txt')

Creates the necessary directories on the build server, checks out the desired branch (None means current), creates a virtualenv and populates it with dependencies from requirements.txt.

Parameters:requirements – The name of the requirements.txt file relative to the path setting used in the constructor.
run_deps = None

A list of packages that must be installed to run the resulting package.

write_postinst_template(template)

Take a template postinst script and format it with appname and postinst_lines If you call this function you must supply a template string that includes {app_name} and {lines}.

write_postrm_template(template)

Take a template postrm script and format it with appname and postrm_lines If you call this function you must supply a template string that includes {app_name} and {lines}.

write_preinst_template(template)

Take a template preinst script and format it with appname and preinst_lines If you call this function you must supply a template string that includes {app_name} and {lines}.

write_prerm_template(template)

Take a template prerm script and format it with appname and prerm_lines If you call this function you must supply a template string that includes {app_name} and {lines}.

Hg

Access your Mercurial revision control information with the Hg objects.

class parcel.revisions.Hg(path)

An interface to Mercurial source repositories.

branch()

A property that is the present checked out branch

clone(repo)

hg clone a repo or path to the present repo location. The Hg path and object this is called on should be clean. In other words you should call clone() immedately after construction of the Hg object and make sure that the Hg object is constructed on an empty path.

eg.

hg = Hg(“build/clone”) hg.clone(“hg+ssh://bitbucet.org/project”)

describe(template='{latesttag}-{latesttagdistance}-{node|short}')

Create a vesrion tag composed of the latest tag, the tag distance, and the short hash. For example:

0.5.1-23-d63d252639de

composed of the tag 0.5.1, from which we are 23 commits forwards of, with a latest changeset of hash d63d252639de

log()

A property that is the latest log entry. Returns a dictionary with the following keys: changeset: The hash number of the lastest changeset. date: The date and time of the latest changeset. user: Who committed the change summary: The commit message tag: if this commit is tagged, this is the tag.

logs()

Returns all the log entries as a list of dictionaries. Each dictionary is of the format returned by log.

path = None

The base path of the Mercurial repository.

pull()

Issue a hg pull on the repository

update()

Issue a hg update on the repository

Git

Access your Git revision control information with the Git objects.

class parcel.revisions.Git(path)

An abstraction of Git Repositories.

branch()

Return which branch the repository is checked out on.

checkout(target)

Use git checkout to bring the repository to a particular point

clone(repo)

git clone a repo or path to the present repo location. The Git path and object this is called on should be clean. In other words you should call clone() immedately after construction of the Git object and make sure that the Git object is constructed on an empty path.

eg.

git = Git(“build/clone”) git.clone(“git://github.org/project”)

describe(force_tag=False)

Use git describe to create a version tag describing the repository at this point.

log()

Return all the git logs in a list

pull()

Execute a git pull in the repository

Distro

Code specific to different distributions can be found in the Distro object.

class parcel.distro.Distro(use_sudo=False)

The base class for Distro classes. If use_sudo is true, then super user commands will be run using fabric’s sudo call. If sudo is false, super user access is gained by getting fabric to connect as root user.

build_deps(deps)

This method should install the build dependencies on the remote box.

check()

Check the remote build host to see if the relevant software to build packages is installed

install_package(pkg)

Installs package on the host using apt-get install bypassing authentication. This method should be used for testing package installation before using push_to_repo.

mkdir(remote)

Make a directory on the remote

push_files(pathlist, dst)

Push all the files in pathlist into dst directory on remote.

setup()

This method should set up a remote box for parcel package building. It should install fpm.

su(*args, **kwargs)

Method to perform a remote task as a super user. Takes same arguments as fabric.api.run or fabric.api.sudo. Can be overridden to provide your own super user execution hook.

update_packages()

This method should update the packages on the remote box.

version(package)

Look at the distro’s packaging system for the package and return a version

Debian

Code specific to the Debian distribution can be found in the Debian object.

class parcel.distro.Debian(*args, **kwargs)
build_package(deployment=None)

Runs architecture specific packaging tasks

check()

Check the remote build host to see if the relevant software to build packages is installed

install_package(pkg)

Installs package on the host using apt-get install bypassing authentication. This method should be used for testing package installation before using push_to_repo.

mkdir(remote)

Make a directory on the remote

push_files(pathlist, dst)

Push all the files in pathlist into dst directory on remote.

setup()

this method sets up a remote debian box for parcel package building. Installs fpm, easyinstall and some libraries.

su(*args, **kwargs)

Method to perform a remote task as a super user. Takes same arguments as fabric.api.run or fabric.api.sudo. Can be overridden to provide your own super user execution hook.

version(package)

Look at the debian apt package system for a package with this name and return its version. Return None if there is no such package.

Ubuntu

Code specific to the Ubuntu distribution can be found in the Ubuntu object.

class parcel.distro.Ubuntu(*args, **kwargs)
build_package(deployment=None)

Runs architecture specific packaging tasks

check()

Check the remote build host to see if the relevant software to build packages is installed

install_package(pkg)

Installs package on the host using apt-get install bypassing authentication. This method should be used for testing package installation before using push_to_repo.

mkdir(remote)

Make a directory on the remote

push_files(pathlist, dst)

Push all the files in pathlist into dst directory on remote.

setup()

this method sets up a remote ubuntu box for parcel package building. Installs fpm and also rubygems if not present.

su(*args, **kwargs)

Method to perform a remote task as a super user. Takes same arguments as fabric.api.run or fabric.api.sudo. Can be overridden to provide your own super user execution hook.

version(package)

Look at the debian apt package system for a package with this name and return its version. Return None if there is no such package.

CentOS

Code specific to the CentOS distribution can be found in the Centos object.

class parcel.distro.Centos(*args, **kwargs)
build_package(deployment=None)

Runs architecture specific packaging tasks

check()

Check the remote build host to see if the relevant software to build packages is installed

install_package(pkg)

Installs package on the host using apt-get install bypassing authentication. This method should be used for testing package installation before using push_to_repo.

mkdir(remote)

Make a directory on the remote

push_files(pathlist, dst)

Push all the files in pathlist into dst directory on remote.

setup()

this method sets up a remote centos box for parcel package building. Installs fpm and also rubygems if not present.

su(*args, **kwargs)

Method to perform a remote task as a super user. Takes same arguments as fabric.api.run or fabric.api.sudo. Can be overridden to provide your own super user execution hook.

version(package)

Look at the debian apt package system for a package with this name and return its version. Return None if there is no such package.

Helpers

Various helper functions are available in parcel.helpers

parcel.helpers.copy_ssh_key()
parcel.helpers.setup_debian()
parcel.helpers.setup_ubuntu()
parcel.helpers.setup_centos()

Probes

Functions for inspecting built packages are available in parcel.probes

parcel.probes.deb_ls()
parcel.probes.deb_install()
parcel.probes.deb_control()
parcel.probes.deb_tree()

Table Of Contents

Related Topics

This Page