Creating an IPS Repository & Adding Your First Package
Posted on May 21, 2010
So IPS is here to stay, most likely, and you no doubt want to get a feel for things. So lets quickly create our first repository and package.
Hold on just one second! Lets get this clear first, IPS is all about network package repositories. There is no “local package” file format. Therefore, its a little confusing to say “create a package”. So lets be crystal clear: we are going to send a bunch of files and meta-data as a package transaction to a package depot server. Fundamental concept…. moving on.
First things first, you can start an IPS Depot (“repository server”, but the daemon is actually pkg.depotd) using the pkg/server SMF service, or start it manually in a shell (so you can watch it work, useful for your first time) like so:
root@quatro ~$ /usr/lib/pkg.depotd -d /export/pkg -p 80 --set-property publisher.prefix=cuddletech [21/May/2010:00:40:19] INDEX Search Available [21/May/2010:00:40:19] ENGINE Listening for SIGHUP. [21/May/2010:00:40:19] ENGINE Listening for SIGTERM. [21/May/2010:00:40:19] ENGINE Listening for SIGUSR1. [21/May/2010:00:40:19] ENGINE Bus STARTING [21/May/2010:00:40:19] ENGINE Started monitor thread '_TimeoutMonitor'. [21/May/2010:00:40:19] ENGINE Serving on 0.0.0.0:80 [21/May/2010:00:40:19] ENGINE Bus STARTED ..
If you point your browser at http://localhost/ you’ll see a web interface that looks identical to pkg.opensolaris.org. It has 0 packages. So lets add one.
There are many ways to add a package. The most popular way is to create a SysV package and then “convert it”… however I believe that to be extremely hypocritical, given that IPS is all about putting SysV packages to death. So we’re going to avoid that method and assume that we’re going to compile something from source and then package it.
I’ve decided to create a package for rsyslog. So I download the latest source and start to build it:
benr@quatro rsyslog-5.5.5$ ./configure --prefix=/usr ... benr@quatro rsyslog-5.5.5$ gmake ... benr@quatro rsyslog-5.5.5$ mkdir -p /tmp/staging_root benr@quatro rsyslog-5.5.5$ DESTDIR=/tmp/staging_root gmake install .....
Notice here that I built it to install into /usr, but before installing it I did a little switcharoo by over-riding the DESTDIR variable. The result is that gmake install installs into /tmp/staging_root, with all the links and configs as though it was in /usr.
Now that I’ve got my faked out installation, lets use pkgsend to import that directory structure:
benr@quatro rsyslog-5.5.5$ pkgsend open email@example.com export PKG_TRANS_ID=1274430097_pkg%3A%2F%2Fcuddletech%2Frsyslog%405.5.6%2C5.11%3A20100521T082137Z benr@quatro rsyslog-5.5.5$ export PKG_TRANS_ID=1274430097_pkg%3A%2F%2Fcuddletech%2Frsyslog%405.5.6%2C5.11%3A20100521T082137Z benr@quatro rsyslog-5.5.5$ pkgsend import /tmp/staging_root benr@quatro rsyslog-5.5.5$ pkgsend close PUBLISHED pkg://firstname.lastname@example.org,5.11:20100521T082137Z
And thats it. I first used pkgsend to open a new transaction to the depot server. This starts a new package. It returns to me a transaction ID which I export as a environmental variable used by future commands. Now I import the staging_root that I installed our tool into. Once done, I just close the transaction, and its done.
If I wanted to add meta-data, I could insert the following before closing the transaction:
$ pkgsend add set name=pkg.summary value="Rsyslog is an enhanced multi-threaded syslogd with a focus on security and reliability" $ pkgsend add set name=pkg.description value="Rsyslog is an enhanced multi-threaded syslogd with a focus on security and reliability" $ pkgsend add set name=description value="Rsyslog is an enhanced multi-threaded syslogd with a focus on security and reliability" $ pkgsend add set name=packager value="Ben Rockwood (email@example.com)"
Now go look at the repo in your browser again. Sure enough its there.
To install the new package, add your local repo to your IPS repo list and then install it:
benr@quatro ~$ pfexec pkg set-publisher -g http://localhost/ cuddletech benr@quatro ~$ pkg publisher PUBLISHER TYPE STATUS URI opensolaris.org (preferred) origin online http://pkg.opensolaris.org/dev/ contrib.opensolaris.org origin online http://pkg.opensolaris.org/contrib/ cuddletech origin online http://localhost/ benr@quatro ~$ pfexec pkg install rsyslog DOWNLOAD PKGS FILES XFER (MB) Completed 1/1 33/33 0.7/0.7 PHASE ACTIONS Install Phase 41/41
Pretty easy right? Creating packages can be really hard if you add all the files manually and nit-pick it, but personally I find this “import /some/dir” to work just fine. It also works on tar files! 🙂
Good luck with IPS.