OpenSolaris Local Repository Mirror

Quelle: http://blogs.sun.com/observatory/entry/local_repository_mirror

In my previous entry I wrote about creating a portable version of the repository using a USB stick. That option is great for taking the repository on the road and even sharing it with folks at conferences where the Internet connection usually sucks.

However, a more practical use of this repository image to many of you may be setting up a local mirror. In this situation, you get the best of both words – fast access to the repository with continued access to updates as they become available.

Setting Up the Local Repository

If you haven’t already, download the ISO image of the repository (about 7 GB). After the download completes, mount the ISO:

pfexec mount -F hsfs `pfexec lofiadm -a ~/Download/osol-repo-0906-full.iso` /mnt

In order for the mount to persist across reboots, we’ll move it to a new file system, which we first need to create:

pfexec zfs create -o compression=on rpool/repo

Then copy the repository to the file system (this will take a little over an hour to complete):

bleonard@opensolaris:~$ pfexec rsync -aP /mnt/repo /rpool/repo
...
repo/updatelog/2009071315
       67506 100%  150.17kB/s    0:00:00 (xfer#304859, to-check=1/609926)
repo/updatelog/2009071316
       24956 100%   55.26kB/s    0:00:00 (xfer#304860, to-check=0/609926)

sent 6669164656 bytes  received 8537336 bytes  1368521.77 bytes/sec
total size is 6630966532  speedup is 0.99

Configure the package server to use the local repository:

svccfg -s application/pkg/server pkg/inst_rool=/rpool/repo/repo
(Korrektur: svccfg -s application/pkg/server setprop pkg/inst_root=/rpool/repo/repo )
svccfg -s application/pkg/server setprop pkg/readonly=true

Edit the repo/cfg_cache file, changing the origins property from http://pkg.opensolaris.org/release to http://<domainname>, where <domainname> is network accessible. For example:

origins = http://opensolaris

You can also choose a port number different from the default of 80, which I did because I’m running apache on port 80:

svccfg -s application/pkg/server setprop pkg/port=81

Then refresh the package server service to pick up the configuration changes and start it:

svcadm refresh application/pkg/server
svcadm enable application/pkg/server

Accessing the Local Repository

Now all those wishing to use the local package server simply need to make the following change:

pfexec pkg set-publisher -m http://opensolaris:81 opensolaris.org

Which will result in the following:

bleonard@opensolaris:~$ pkg publisher
PUBLISHER                             TYPE     STATUS   URI
opensolaris.org          (preferred)  origin   online   http://pkg.opensolaris.org/release/
opensolaris.org          (preferred)  mirror   online   http://opensolaris:81/

If you only want to use the local repository, first remove the mirror:

pfexec pkg set-publisher -M opensolaris.org http://opensolaris:81

Then:

pfexec pkg set-publisher -O http://opensolaris:81 opensolaris.org

For more information see the README.