Package
An interface to a software package.
Overview
Package:
An interface to a software package.
Intent
- Define an object that encapsulates the lifecycle of a software package.
- Abstract the parameters common to packages of different formats.
Problem
We want to create and install packages of various formats but these packages have varying degrees of capability and require thier own tool sets to produce them. Lacking a standard way of creating, distributing and installing packages undermines the goal of a generic deployment procedure.
Discussion
Depending on their architecture and platform, applications are released using a wide variety of formats. The components of a Java based applications may be deployed as .jar, .war, and .ear files, while platform software may be deployed as .rpm, .deb, and .pkg files. Windows based applications have their own range of deployable artifacts and installers: .dll, .exe, .setup, .zip. Indeed, many software components are distributed as they are, devoid of any formalized packaged delivery.
When one considers the common details and requirements for software packages they can be organized into different categories:
- parameters: these are key attributes that describe the package.
- lifecycle: these are the set of procedures needed to create and manage the package.
- dependencies: these are the requirements needed both to build the package and the assumptions about the dependencies that will be met when the package is installed.
Due to this diversity of software delivery, one is often faced with using a myriad of tools and a recipe of procedures to prepare, deliver and install software components. This requires that the person undertaking the deployment must be well versed in the use of these tools and may also require that a developer maintain specialized locally developed code to produce the artifacts.

Having to install packages of differing formats to support a multi-component application undermines the desirable goal to employ a single common mechanism. A preferred scenario of course, would be to have a homogeneous package format so that there could be a standard method to create and manage all packages.
Another approach would be to define a package concept that sufficiently describes the characteristics, both essential attributes and dependencies, as well as, encapsulate the lifecycle methods for the package.
This package abstraction offers the benefit of homogeneity by way of its standardized behavior and characteristics yet allows for the underlying differences of the heterogeneous formats and tools needed to support different application components. As new package formats are introduced, their differences can be accommodated by defining a new derived class.

The package abstraction organizes the details of the package life cycle into several categories: configuration, procedures, context and content.
Package configuration encompasses essential installation, version, dependency, storage and deployment attributes. This configuration data is used to drive the package life cycle procedures.
Life cycle procedures fall into two general categories: creation and installation. Creation methods take as input package content and output a package artifact using the format specific to that package type. Additionally, the creation method can store the package artifact into a release repository for later distribution. Installation methods pull the package from the repository, extract it to the host and perform optional pre- and post-installation.
Occassionally, environment specific information is required by the life cycle methods (though one should strive to avoid this), therefore the package abstraction provides the means to override configuration parameters with needed values.
While the package abstraction can be implemented to contain the content of the package archive itself, it is preferable to decouple the content file itself from the code that creates and installs it. With this arrangement the package archive file (e.g, the .rpm file) resides in a repository, while an instance of a package type, provides the configuration and environment context and procedures to install the package.
Structure
There are two primary collaborations of the package abstraction one for building the package and the other for deploying the package.
The Builder uses the Package type to construct, register and store the package. The Deployment object uses the Package to deliver and install the package.

The essential package properties are defined as the following parameters:
| Name | Description |
|---|---|
| arch | Host architecture type. |
| base | The package base name. This often is the name of the package minus the file extension. |
| buildtime | Timestamp specifying when the content of the package was built. |
| install-rank | A value representing installation order. |
| release | The version release identifier. |
| restart | Boolean flag specifying that a service restart is required after installation. |
| release-tag | A logical release identification tag. |
| filetype | Package format type |
| install-root | Directory path where package should be extracted. |
| vendor | Organization responsible for creating the package |
| repo-url | URL used to access the package artifact from the repository. |
| version | Package version |
| filename | The name of the package file. |
Example
The Package type defines an object that provides methods to create and install a package and maintain key properties that describe the package. Packaging and deploying the Apache httpd server is a good example to demonstrate the use of the Package type.
The graphic below describes the two phases of the build and installation cycle for a package. In the build phase, a Builder object takes source files and a build configuration and compiles and uses the Package's create, upload and register commands to store it in the repo. In the installation phase, a Deployment object uses the Package's install command which implicitly uses the prepare, get, extract and finish commands to acquire and install the package, providing optional environment context during the process.

Check List
Building
- Choose the package format type required. This may be from existing package types like: zip, jar, rpm, etc.). If a new format is desired then derive a new subtype from Package and implement the necessary installation lifecycle methods.
- Identify the set of files that will be archived using the above package format. Then run the create command specifying necessary parameters.
- Store the package artifact in the repository and register it as a resource that can be used as Deployment dependency.
Installation
- Identify Deployment types that require this package type. Possibly, modify the dependency constraints for the Deployment type to allow the new dependency type.
- Choose the Deployment object and Package object and assign the dependency.
- Install the package by running the Deployment object's Packages-Install command.
Rules of Thumb
Since package formats and the tools that produce and manage them are not equal, one must establish a middle ground.
Design
- Super Type
- Managed-Entity
| Role | Concrete. (Objects can be created.) |
| Instance Names | Unique |
| Notification | false |
| Template Directory | |
| Data View | Children, proximity: 1 |
| Logger Name | Package |
Commands
create
creates a package archive
- Usage
- create [-filename <>] [-installroot <>]
Options
| Option | Description |
|---|---|
| filename | file to write archive |
| installroot | root where source files reside |
extract
extracts the package
- Usage
- extract [-base <>] [-filename <>] [-installroot <>]
Options
| Option | Description |
|---|---|
| base | package base name |
| filename | file to extract |
| installroot | destination directory |
finish
finishes the package installation
- Usage
- finish [-filename <>] [-filtersfile <>] [-installroot <>]
Options
| Option | Description |
|---|---|
| filename | path to package file |
| filtersfile | property file |
| installroot | installation root dir |
get
gets the package from the repostiory
- Usage
- get [-filename <>] [-installroot <>] [-url <>]
Options
| Option | Description |
|---|---|
| filename | the filename |
| installroot | the installation root |
| url | the url to the package |
install
runs the package installation process
- Usage
- install [-filename <>] [-filtersfile <>] [-installroot <>] [-url <>]
Options
| Option | Description |
|---|---|
| filename | the filename |
| filtersfile | filtersfile |
| installroot | the install root |
| url | the repo url |
prepare
prepares the package for installation
- Usage
- prepare
purge
removes the file from the repository
- Usage
- purge -url <>
Options
| Option | Description |
|---|---|
| url | URL of the file |
register
registers the object
- Usage
- register [-arch <>] [-base <>] [-buildtime <>] [-depot <>] [-description <>] [-filename <>] [-filetype <>] [-installrank <>] [-installroot <>] [-name <>] [-release <>] [-releasetag <>] [-restart] [-type <>] [-url <>] [-vendor <>] [-version <>]
Options
| Option | Description |
|---|---|
| arch | host architecture |
| base | the package base name |
| buildtime | time package was built |
| depot | project depot name |
| description | description of the object |
| filename | the file name |
| filetype | the package file type |
| installrank | install rank |
| installroot | the installation root |
| name | the object name |
| release | the package release |
| releasetag | release tag |
| restart | requires restart |
| type | the object type |
| url | the repo url |
| vendor | the package producer |
| version | the package version |
remove
removes the installed package
- Usage
- remove [-installroot <>]
Options
| Option | Description |
|---|---|
| installroot | directory to remove |
upload
uploads the file to the repository
- Usage
- upload [-filename <>] [-url <>]
Options
| Option | Description |
|---|---|
| filename | file to upload |
| url | repository url |
verify
verifies the package
- Usage
- verify


