tutorial | local repository on OpenIndiana/Solaris 11

Synopsis

The tutorial describes three different ways to setup a local Image Packaging System (IPS) software package repository, retrieving the packages and serve them from a file based repository or a local package repository server. The local server can run multiple instances of the daemon on different ports and on an Apache webserver with specific URLs.

System requirement

The system can be either an OpenIndiana, Solaris 11 Express or Oracle Solaris 11 system.

Introduction

OpenIndiana and Solaris use the IPS (Image Packing Systems) as the way to manage the software patches and packages, It is being developed by the OpenSolaris project team. IPS make it easy to manage package and patches. It deliver patches and packages stored in IPS package repositories, which are populated by IPS publishers. It is tightly integrated with the ZFS file system to create images and boot environments for installing different versions of software and safe rollbacks.
IPS tools enable you easily to create your own repository and copy packages from an existing repository in to it and supports filesystem-based repository access too.

Why to configure Local IPS?
1. Performance (more speed from local network)
2. Security (no connection to internet)
3. Replication and Automatic Installation (for identical installations)
4. Customizing packages (replace packages with your own one, mogrify packages)

You can use the repository file from media or you can retrieve an entire repository from the Internet. In either case, you can serve the packages from a local web server or from a local directory.
The basic steps are
1. Preparing: Creating a a new ZFS-file system
2. Populating: Getting the packages
3. Publishing: Making the repositories accessible
4. Configuring: Multiple Repositories using multiple depot server instances

1. Preparation: Creating a new ZFS-file systems

If one system hosts more than one IPS repository, make each repository a separate ZFS file system so that you can snapshot, rollback and recover each repository separately. It’s also allows to tweak them for compression and performance independently.
Assume the root role, create a new ZFS file system for the package repository in the root pool and check and tweak:

su -
zfs create -o compression=on rpool/export/repo2010_11
zfs create -o compression=on rpool/export/repoSolaris11
zfs create -o compression=on rpool/export/repoOI151a
zfs list
zfs set atime=off rpool/export/repo2010_11
zfs set atime=off rpool/export/repoSolaris11
zfs set atime=off rpool/export/repoOI151a

2.1. Getting the Packages from a File
Get the Package Repository File

The repository comes normally in two compressed iso-images. Move them to the the right folder, uncompress and concatenate the files into one file

mv /your download path/sol-11-exp-201011-repo-full*.zip /export/repo2010_11
unzip sol-11-1111-repo-full.iso-a.zip
unzip sol-11-1111-repo-full.iso-b.zip
cat sol-11-1111-repo-full.iso-a sol-11-1111-repo-full.iso-b > sol-11-1111-repo-full.iso

Make the Contents of the Repository File Available

Mount the iso-file and check:

mount -F hsfs /export/repo2010-11/sol-11-1111-repo-full.iso /mnt
ls /mnt
pkg list -g /mnt/repo

Copy the Repository Files

For increased performance of accesses and to avoid the need to remount the .iso image after restart, copy the repository files from /mnt/repo/ to a ZFS file system. You can do this copy with rsync or with tar. Check and unmount the image.

rsync -aP /mnt/repo /export/repoSolaris11
pkg list -g /export/repoSolaris11
umount /mnt/

Clean up

Remove unnecessary files

rm *.iso
rm *.zip

2.2. Get the Packages From a Package Server
Create the Infrastructure for the Local Repository

The following command creates a repository, with a single file (pkg5.repository):

pkgrepo create /export/repoOI151a

By default, version 4 repositories are created, supporting storage of packages for multiple publishers.

Copy the Repository

Retrieve the latest versions of all packages with pkgrecv from the existing repository and republish the retrieved packages to the local repository. By default, packages are retrieved in package repository format suitable for use with a local repository server.

pkgrecv -s http://pkg.openindiana.org/dev/ -d /export/repoOI151a '*'

2.3. Get the Packages for a Specific Build From a Package Server

Build the repository as described before:

pkgrepo create /export/repo2010_11

As pkgrecv always try to retrieve the newest version of a package. The download of packages from a specific (and not newest) build use the entire package. This package contains a series of constraint relationships that pkg(5) uses to make sure mutually compatible packages are installed on your system.

Finding the relevant entire package

At the http://pgk.oracle.com website go to the advanced search, mark the checkbox for show all version and search for entire or issue the command

pkg search -r -s http://pkg.oracle.com/solaris/release entire

and look for entire@0.5.11,5.11-0.151.0.1:20101105T054056Z
where 5.11-0.151.0.1 indicates the build and brunch of Solaris 11 Express.

Copy the Repository

Receive the package and all of its dependencies from the package server system to the local repository

pkgrecv -s http://pkg.oracle.com/solaris/release -d /export/repo2010_11 -r entire@0.5.11,5.11-0.151.0.1:20101105T054056Z

3. Publishing: Making the repositories accessible

The repository is accessible as file-based repository or over the pkg-server. Search operations performed using a file-based repository can use substantially more memory by the client when a repository contains a large number of packages and the client will not cache data from a repository.
For more reliable connections, caching and faster searching a http-based access to the repository via pkg.depotd(1m) is used instead.

File Based Repository Access

Accessing and removing all existing origins and mirrors for the publisher solaris, solaris-express, openindiana.org

pkg set-publisher -G '*' -M '*' -g file:/export/repo2010_11/ solaris-express
pkg set-publisher -G '*' -M '*' -g file:/export/repoSolaris11/ solaris
pkg set-publisher -G '*' -M '*' -g file:/export/repoOI151a/ openindiana.org

Repository Server Service Based Access

Build the index

pkgrepo -s /export/repo2010_11/repo refresh
pkgrepo -s /export/repoSolaris11/repo refresh
pkgrepo -s /export/repoOI151a/repo refresh

Use Service Management Facility (SMF) commands to configure the repository server service and check.

svccfg -s application/pkg/server setprop pkg/inst_root=/export/repo2010_11/repo
svccfg -s application/pkg/server setprop pkg/readonly=true
svccfg -s application/pkg/server setprop pkg/port=81
svcprop -p pkg/inst_root application/pkg/server

Restart the service and check

svcadm refresh application/pkg/server
svcadm enable application/pkg/server
svcs *pkg*

or by open a browser window on the http://localhost:81/

set the publisher URI


set-publisher -G '*' -M '*' -g http://yourserver:81/

Snapshots

The ZFS file system allows you to create snapshots of each file systems, which makes it very easy to roll back a file system at a later date, if needed, or to copy a file system quickly. For convenience, we will create a snapshot of our repository now using the zfs snapshot command.

# zfs snapshot rpool/export/repo2010_11@initial

Configuring: Multiple Repositories using multiple depot server instances
Adding the other repositories
Apache configuration

Adjust the Apache server’s configuration to connect different instances of the daemon with different URLs.

The entire process was tested on OpenIndiana 151a on an x86-based system.

Credits:

Oracle Documentation: Copying and Creating Oracle Solaris 11 Package Repositories
Brian Leonard on The Observatory for all his help and hints using OpenSolaris and Solaris
Shawn Walker’for all his help and hints using pkg and file based repositories

One thought on “tutorial | local repository on OpenIndiana/Solaris 11

Leave a Reply

Your email address will not be published. Required fields are marked *