By Chris W Beal-Oracle on Oct 04, 2011
It's been ages since I blogged, so apologies for that. I'm at Oracle Openworld 2011 this week, and I was helping out on the Solaris booths in the DemoGrounds. One of the people I talked to asked a question, which I've heard internally at Oracle a few times recently. That is "How can I package up my own app as an IPS package?" I've answered it a few times, and so suddenly it struck me as a good subject for a blog.
Most of this information is available either in the documentation, or other blogs, but this is also for me to reference back to (rather than my notes)
With IPS, packages are published to a repository (or repo). This can either be a
special pkg web server or simply a directory. For simplicity I've used
$ export PKGREPO=/path/to/repo $ pkgrepo create $PKGREPO
This populates the $PKGREPO with the required repository structure, you only need to do this once.
Packages are described by manifests. You need one per package. If you have existing System V packages, you can allow the tools to generate it all for you, but simply passing the SystemV package file in the a tool called pkgsend
$ pkgsend generate sysvpkg > sysvpkg.mf
However, often my own tools are just added manually by hand or archived together with tar. So if I want to turn those in to an IPS package, I need to create my own manifest. Again fortunately pkgsend can help, but you'll need to add some details.
So let's assume I've put all my tools in /opt/mytools
$ export ROOT=/opt/mytools
$ pkgsend generate $ROOT > mytools.mf
This manifest needs a line adding to it to describe the package
set name=pkg.fmri \
This states the publisher (tools), package name (mytools) and the version
So once you have the working manifest - and there's a lot more detail we can add to these, they can be published. (to the $PKGREPO directory we created earlier)
$ pkgsend publish -s $PKGREPO -d $ROOT mypkg.mf
Note for each successfully published you get a "Published" message,
but silent failure (exit code is 1 though so it can be detected in a script)
You can then add the repo you've just populated to your test machine. You'll need to do this a as a privileged user, such as root
# pkg set-publisher -O $PKGREPO tools
and add a package
# pkg install mytools Packages to install: 1
Create boot environment: No
DOWNLOAD PKGS FILES XFER (MB)
Completed 1/1 716/716 2.4/2.4
Install Phase 746/746
Package State Update Phase 1/1
Image State Update Phase 2/2
Reading Existing Index 8/8
Indexing Packages 1/1
So this is now installed on my system. There are so many interesting things you can add to the manifest, that if you're interested, I'll try to blog about in the future. However one thing I've glossed over here is the package version. It's surprisingly important that you understand what you set that to, so I'll make that the subject of a future blog.