Creating Packages
Overview
This document describes how to store packages in the ControlTier repository. ControlTier provides a set of package control modules, any of which can be used to manage the creation and installation life cycle for your packaging artifacts:
- bin: A self extracting shar package
- ear: An EAR package
- jar: An JAR package
- pkg: A SVR4 package
- rpm: An RPM package
- tgz: A GZip compressed TAR package
- war: A WAR package
- zip: A Zip package
Each of these control modules can create and extract the packaged files of its archive format. You can also override the behavior of any of the life cycle steps through subtyping. If you have an archive format or set of life cycle steps that is not covered by one of these, then subtype the Package control module but be sure to implement the create and extract commands.
Uploading an existing file as a package
You can store an existing file as a package in the repository. This is done in two steps:
1. Define the package metdata file
Create an XML file using the one below as an example. This example represents the zip distribution of Apache Tomcat 5.5 downloaded from here: http://tomcat.apache.org/download-55.cgi. For this example, imagine the file was downloaded as /tmp/apache-tomcat-5.5.26.zip and an XML file called /tmp/package.xml contains the package metadata:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project PUBLIC "-//ControlTier Software Inc.//DTD Project Document 1.0//EN"
"project.dtd">
<project>
<package
arch="noarch"
base="apache-tomcat-5.5.26"
buildtime="2008061570109"
description="The Tomcat application server."
filename="apache-tomcat-5.5.26.zip"
filetype="zip"
installroot="/demo/apache-tomcat-5.5.26"
installrank=""
name="apache-tomcat-5.5.26.zip"
release=""
releasetag=""
repoUrl="${framework.pkgRepo.upload-url}/default/zip/zips/apache-tomcat-5.5.26.zip"
restart="false"
type="zip"
vendor=""
version="5.5.26"
/>
</project>
Of course, for your metadata file you will change the details from the one in the example. The table below gives a brief description for each of the attributes in the package metdata file. The ones with an asterisk are required during the deployment cycle.
| attribute | description |
|---|---|
| arch | Hardware architecture. |
| base* | Package base. |
| buildtime | Build identifier |
| description | Description of the package. |
| filename* | Name of the file. |
| filetype | Archive format.. |
| installroot* | Directory where archive will be extracted. |
| installrank* | Relative ordering. |
| name* | Name of the package. Usually, the same as filename |
| release | Version release. |
| releasetag | Release identifier. |
| repoUrl* | URL to the file in the repository. |
| restart | Signifies if the service should restart after installation. |
| type | Name of control module |
| vendor | Organization that created the package |
| version* | Package version |
2. Upload the file to the repository
The next step is to upload the file to the repository using the metadata defined in the xml file above.
ctl -p default -m zip -c upload -- \
-xml /tmp/package.xml
-filename /tmp/apache-tomcat-5.5.26.zip
Output from the upload should resemble the text below:
Uploading to: http://strongbad:8080/webdav/pkgs/default/zip/zips/apache-tomcat-5.5.26.zip
Uploading: apache-tomcat-5.5.26.zip
Puted 1 file to http://strongbad:8080/webdav/pkgs/default/zip/zips/apache-tomcat-5.5.26.zip
Loading metadata from XML file: '/tmp/package.xml' ...
Loading "/tmp/package.xml" ...
1 file(s) have been successfully validated.
Mapping XML to properties ...
Collecting object attributes ...
Batching object attribute updates ...
Batching resource and referrer updates ...
Executing batch update ...
After the package has been registered you can query the repository and now see it listed:
$ ctl -p default -m ProjectBuilder -c find-objects -- -type zip
|
|--(zip) apache-tomcat-5.5.26.zip
Alternatively, you can go to the PackageManager in Workbench and view it there. Go to Workbench → PackageManager → Package List. You will see it listed as a zip package.
Creating a zip package from a directory
1. Prepare reference directory
A reference directory is a directory that contains the files and directories as you want them on the target hosts relative to its installation root directory.
For this example, imagine we have a reference directory named "foo-agent" that contains an executable called foo.agent, and a configuration subdirectory. The steps below simulate the creation of the foo-agent reference directory.
First create the installation root directory:
mkdir /tmp/foo-agent
Populate the directory with the agent files:
cp foo.agent /tmp/foo-agent cp -r conf /tmp/foo-agent
Of course, these examples assume these hypothetical foo.agent and conf files exist in the current directory.
2. Create the package and upload it to the repository
With the files prepared in the reference installation root directory you are ready to create the package. This is done via the create command.
The create command takes several options. The -installroot option references your reference directory. The -filename option specifies the package file that will be the archive of the installroot. The -upload flag specifies that after the archive is created, it should be uploaded to the repository and registered as a new package.
The example below shows how to run create for our hypothetical "foo-agent":
ctl -p default -m zip -c create -- -installroot /tmp/foo-agent -filename foo-agent-1.zip -upload
Packaging files in directory: /tmp/foo-agent ...
Building zip: /tmp/foo-agent-1.zip
Copying 1 file to /tmp
Generated package metadata file: /tmp/foo-agent/../object.xml
Uploading to: http://strongbad:8080/webdav/pkgs/default/zip/zips/foo-agent-1.zip
Uploading: foo-agent-1.zip
Puted 1 file to http://strongbad:8080/webdav/pkgs/default/zip/zips/foo-agent-1.zip
Loading metadata from XML file: '/tmp/foo-agent/../object.xml' ...
Loading "/tmp/foo-agent/../object.xml" ...
1 file(s) have been successfully validated.
Processing /tmp/object.xml to /home/ctier/ctier/ctl/var/tmp/projectxml-1366622780.xml
Loading stylesheet /home/ctier/ctier/ctl/depots/default/modules/ProjectBuilder/lib/load-objects/projectxml/project.xsl
Mapping XML to properties ...
Collecting object attributes ...
Batching object attribute updates ...
Batching resource and referrer updates ...
Executing batch update ...
Done.
As you can tell by reading through the output, the files were packaged up into a new archive called "foo-agent-1.zip" and uploaded to the repository. At the end the archive was registered as a package using metadata generated by the create command.
After the package has been registered you can query the repository and now see it listed:
$ ctl -p default -m ProjectBuilder -c find-objects -- -type zip
|
|--(zip) apache-tomcat-5.5.26.zip
|
|--(zip) foo-agent-1.zip


