IPS For Developers (Tasks)
The IPS software in the 2008.11 release of OpenSolaris enables developers to perform
a variety of tasks related to creating and publishing packages. The following tasks
are supported for the 2008.11 release.
How to Create Your Own OpenSolaris Repository Using pkg.depotd(1) Command
- Type the following command to create your repository:
$ /usr/lib/pkg.depotd -d repository_directory -p port_value
Note - If the repository_directory you have specified does not exist, it will be created
for you.
- To confirm that the repository has been created, open your browser and type
the following : https://localhost:port_v.
If the depot server is running correctly, a message will be displayed in
the browser.
- Check the contents of the repository.
$ ls repository_directory
Example 5-1 Creating Your Own Repository Using pkg.depotd
This example creates an OpenSolaris repository repository1 with a port value of 11000
and shows the content of the repository.
$ /usr/lib/pkg.depotd -d /tmp/testrepo -p 11000
[06/Nov/2008:13:43:26] INDEX Search Available
[06/Nov/2008:13:43:26] ENGINE Listening for SIGHUP.
[06/Nov/2008:13:43:26] ENGINE Listening for SIGTERM.
[06/Nov/2008:13:43:26] ENGINE Listening for SIGUSR1.
[06/Nov/2008:13:43:26] ENGINE Bus STARTING
[06/Nov/2008:13:43:26] ENGINE Started monitor thread '_TimeoutMonitor'.
[06/Nov/2008:13:43:26] ENGINE Serving on 0.0.0.0:11000
[06/Nov/2008:13:43:26] ENGINE Bus STARTED
$ ls /export/home/user1/repository1
catalog file pkg search.dir search.pag trans updatelog
How to Create Your Own OpenSolaris Repository Using Smf Commands
- Become superuser.
- Set the value of the port.
# svccfg -s application/pkg/server setprop pkg/port=port_value
- Set the value of the repository.
# svccfg -s application/pkg/server setprop pkg/inst_root=repository_directory
- Refresh the repository.
# svcadm refresh application/pkg/server
- Restart the repository.
# svcadm restart application/pkg/server
- Open your browser and type https://localhost:port_value to confirm that the repository has
been created.
- Check the contents of the repository.
# ls repository_directory
Example 5-2 Creating Your OpenSolaris Repository Using SMF Commands
This example creates an OpenSolaris repository repository2 with a port value of 8000
and shows the contents of the repository.
# svccfg -s application/pkg/server setprop pkg/port=8000
# svccfg -s application/pkg/server setprop pkg/inst_root=/export/home/user1/repository2
# svcadm refresh application/pkg/server
# svcadm restart application/pkg/server
# ls /export/home/user1/repository2
catalog file pkg search.dir search.pag trans updatelog
How to Create and Publish an IPS Package
There are different types of IPS packages that can be created. As
mentioned previously, a package is a collection of files, directories, drivers, and dependencies in
a defined format. This task shows how to create a package that consists
of a directory, a file, a dependency, and a name attribute. The package
is then published to the repository using the pkgsend(1) command.
Note - This examples publishes the packages to the default repository, https://localhost:10000. If you
are publishing a package to a repository other than the default repository, ensure
that the repository is created and use the -s option with the pkgsend(1)
command to specify the repository.
Before You Begin
Read the section Actions in IPS and become familiar with actions and the attributes of
each action.
- Create a temporary directory on your system.
$ mkdir my_tmp
- Change the directory to the temporary directory.
$ cd / my_tmp
- Create a directory called my_package.
$ mkdir my_package
- Change the directory to my_package.
$ cd my_package
- Create a text file under the directory my_package.
$ vi my_text_file
Note - The files can be of any type. This example uses a text
file.
- Export the directory my_package. Specify a version number and a sub-version number for
the package. In this example, the my_package has a version number of 1.0
and a subversion number of 1. Note the back quotes used in this command.
$ eval `pkgsend open [email protected]`
Note - Specify the package name, version number and subversion number correctly. This cannot be
changed afterwards.
- Add attributes to the package. In this task you add a directory action
with attributes of mode, owner, group, and path. Path is the key
attribute for the directory action and has to be specified.
$ pkgsend add dir mode=0555 owner=root group=bin path=/etc/my_package
- Add the file my_text_file under the my_package directory.
$ pkgsend add file my_package/my_text_file
- Add attributes to the file. In this example, you add the file action
with the attributes of mode, owner, group, and path. Path is the
key attribute for the file action and has to be specified.
$ pkgsend add file my_package/my_text_file mode=0555 owner=root group=bin path=/etc/my_package
Note - Actions can also be included in a file. This file can then
be added to the current transaction by using the pkgsend include command.
Note - The path attribute specifies the directory where the file will be created. This
path should exist on the IPS client although it can be different from
the file's location on the IPS server.
- We have now created a package my_package consisting of a directory and a
file.
- We will add a dependency for this package and set a name
attribute.
$ pkgsend add depend fmri=pkg:/[email protected] type=require
$ pkgsend add set name=description value="Example Package"
Note - If the resources have been specified in a file, use the pkgsend include resource_filename
command instead of the pkgsend add command, to add the resources to the current
transaction.
- Use the following option to close the transaction.
$ pkgsend close
Example 5-3 Creating and Publishing a Simple Package
This example uses the pkgsend(1) command to create and publish a package.
$ eval `pkgsend open [email protected]`
$ pkgsend add file my_package mode=0555 owner=root group=bin\
path=/usr/bin/my_package
$ pkgsend close
More Information
Tagging Your XML Manifest File
If you have specified the actions and resources for a package in
an xml file, also called the manifest, you can tag the manifest file to
instruct additional services either before, or after the package is installed.
For example, you can instruct a package to start an SMF service
when it is installed and stop the SMF service when the package is
uninstalled. Use the pkgsend(1) command to tag your xml manifest file in the following
way:
$ pkgsend add set restart_fmri=svc:/system/manifest-import:default xml_manifest
How to Publish SVR4 Packages to Your Repository
SVR4 packages can be installed directly on your system by using the pkgadd(1M)
and related commands. To learn more about the SVR4 packaging commands, see the
Application Packaging Programmer's Guide.
SVR4 packages can be published to the IPS repository by using the
pkgsend(1) command.
Note - This examples publishes the packages to the default repository, https://localhost:10000. If you
are publishing a package to a repository other than the default repository, ensure
that the repository is created and use the -s option with the pkgsend(1)
command to specify the repository.
Before You Begin
See The Publication Client pkgsend(1) to become familiar with the workings and limitations of the
command.
- Open the transaction.
eval `pkgsend open svr4pkg`
- Include the manifest associated with the SVR4 package.
pkgsend include ips-manifest-with-metadata
- Import the package.
pkgsend import svr4pkg
- Close the transaction.
pkgsend close