News, tips, partners, and perspectives for the Oracle Solaris operating system

Quick Local Repository

Solaris 11 Express makes it pretty easy to set up a local copy of the repository. However, the full repository is several gigabytes large, so that in itself can be a deterrent, especially if you're just looking to install a couple of packages.

A common reason folks need access to a local repository is because their system is not connected to the Internet. In this example I will show you how to create a local repository, receive files into it, copy that repository to another machine, install it as a publisher and finally install the software. My real world use case for this blog was my need to install software from an internal Oracle repository to an machine not connected to the Oracle network. However, for this example I'll use the public repository as my example and the Tomcat web server as the software I want to make available to the remote machine.

Step 1: Create a Repository

The first step is to create the repository to host the packages. This repository will then be copied to the remote machine. This is easily accomplished with the pkgrepo command. Here I'm creating a repository off of my home directory:

bleonard@solaris:~$ pkgrepo create ~/repo

This basically creates a directory, repo, with a single file, pkg5.repository:

bleonard@solaris:~$ cat repo/pkg5.repository 
prefix =
version = 4
version = 4

Note, there's no command to delete the repository. As it's a file based repository, just delete the directory:

bleonard@solaris:~$ rm -r repo

Step 2: Receive the Packages into the Repository

The next step is to receive the packages into the new repository. For this I will use the pkgrecv command. If the repository you want to receive the packages from is not configured as a publisher, you can also specify that on the command line. In addition, you can use the -r option to recursively grab all of the package's dependencies. Beware, however, that depending on the package, this may end up downloading most of the repository. For this example I'm going to grab the Apache Tomcat server, sans dependencies:

bleonard@solaris:~$ pkgrecv -s http://pkg.oracle.com/solaris/release -d ~/repo web/java-servlet/tomcat web/java-servlet/tomcat/tomcat-examples
Processing packages for publisher solaris ...
Retrieving and evaluating 2 package(s)...
Completed 2/2 10.4/10.4 13.5/13.5

Step 3: Copy the Repository to the Remote Machine

You could use your favorite approach for copying files. In this example, I'm going to use scp:

oracle@solaris:~$ scp -r bleonard@ repo
The authenticity of host ' (' can't be established.
RSA key fingerprint is f7:1d:2c:d7:24:e3:1c:57:53:0f:59:75:31:4a:0f:7d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
ndd: No such file or directory
pkg5.repository 100% |*****************************| 78 00:00
19bd9e48c1f7ce9a2bb6 100% |*****************************| 541 00:00
catalog.dependency.C 100% |*****************************| 1055 00:00
6.0.28%2C5.11-0.151. 100% |*****************************| 45641 00:00
6.0.28%2C5.11-0.151. 100% |*****************************| 71145 00:00
6.0.20%2C5.11-0.133% 100% |*****************************| 419 00:00

You can check the status of the new repo:

oracle@solaris:~$ pkgrepo info -s ~/repo
solaris 3 online 2011-06-07T20:38:51.166088Z

Note, searches against the repository will initially fail:

oracle@solaris:~$ pkg search -s file:///home/oracle/repo tomcat
pkg: Some repositories failed to respond appropriately:
file protocol error: code: 11 reason: Search temporarily unavailable.
Repository URL: 'file:///home/oracle/repo'. (happened 4 times

This can be corrected by refreshing the index:

oracle@solaris:~$ pkgrepo refresh -s ~/repo
Repository refresh initiated.
oracle@solaris:~$ pkg search -s file:///home/oracle/repo tomcat
description set Tomcat Servlet/JSP Container pkg:/web/java-servlet/tomcat@6.0.28-
description set Tomcat Servlet/JSP Container - example applications pkg:/web/java-servlet/tomcat/tomcat-examples@6.0.28-
pkg.description set Tomcat Servlet/JSP Container pkg:/web/java-servlet/tomcat@6.0.28-
pkg.description set Tomcat Servlet/JSP Container - example applications pkg:/web/java-servlet/tomcat/tomcat-examples@6.0.28-
pkg.summary set Tomcat Servlet/JSP Container pkg:/web/java-servlet/tomcat@6.0.28-
pkg.summary set Tomcat Servlet/JSP Container - example applications pkg:/web/java-servlet/tomcat/tomcat-examples@6.0.28-
pkg.fmri set solaris/web/java-servlet/tomcat pkg:/web/java-servlet/tomcat@6.0.28-

To see all the packages in the repository:

oracle@solaris:~$ pkg search -p -s file:///home/oracle/repo '*'
pkg:/SUNWtcat-examples@6.0.20-0.133 solaris
pkg:/web/java-servlet/tomcat/tomcat-examples@6.0.28- solaris
pkg:/web/java-servlet/tomcat@6.0.28- solaris

Step 4: Add the Repository as a Publisher

Since the packages are from the default 'solaris' repository, we're just going to add a new origin to the existing configured repository. We'll then remove the default origin of http://pkg.oracle.com/solaris/release (since theoretically we can't connect to it anyway). If the packages were from a new or unconfigured repository, you would use the -p option instead:

oracle@solaris:~$ sudo pkg set-publisher -g file:///home/oracle/repo solaris
oracle@solaris:~$ sudo pkg set-publisher -G http://pkg.oracle.com/solaris/release/ solaris
oracle@solaris:~$ pkg publisher
solaris (preferred) origin online file:///home/oracle/repo/

Step 5: Install Software

oracle@solaris:~$ sudo pkg install tomcat tomcat-examples
Packages to install: 2
Create boot environment: No
Services to restart: 1
Completed 2/2 475/475 5.8/5.8
Install Phase 610/610
Package State Update Phase 2/2
Image State Update Phase 2/2

In this particular case, we'll start the Tomcat server:

oracle@solaris:~$ sudo svcadm enable tomcat6

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.