Go to main content

Creating Package Repositories in Oracle® Solaris 11.4

Exit Print View

Updated: November 2018
 
 

Using an Oracle Solaris 10 or Linux System to Serve Repository Content

In addition to accessing your repository through an Oracle Solaris 11 system, you can access your IPS package repository through an Oracle Solaris 10 system or a Linux system.

The repository must be created on an Oracle Solaris 11 system. The repository can remain on the Oracle Solaris 11 system and be accessed from an Oracle Solaris 10 or Linux system, or you can copy the repository directory to the Oracle Solaris 10 or Linux system.

A file system repository can be hosted on almost any operating system and then shared over NFS, SMB, or any other remote file system mechanism that Oracle Solaris supports.

The following procedure shows how to provide HTTP access to an IPS repository from an Oracle Solaris 10 or Linux system. In addition to Oracle Solaris 10 and Linux repository hosts, you could use this partial configuration as an Apache configuration for Oracle Solaris 11 11/11, Oracle Solaris 11.1, Oracle Solaris 11.2, Oracle Solaris 11.3, or Oracle Solaris 11.4 repository hosts. You might want to do this, for example, if you have an existing web server and do not want to run a separate web server instance as part of the svc:/application/pkg/depot service.

How to Provide HTTP Access to an IPS Repository From an Oracle Solaris 10 or Linux System

When HTTP access to a repository is provided from a system that is not an Oracle Solaris 11 system, pkg search and BUI support are not available. Users can install and update packages and get information about packages through the pkg list, pkg info, and pkg contents commands.

Before You Begin

This procedure uses the pkg.depot-config command, which is available only in Oracle Solaris 11.2 or later. You must install the package/pkg/depot package to get the pkg.depot-config command.

  1. Create a partial web server configuration file.

    Use the pkg.depot-config command to create the configuration to enable a web server on the Oracle Solaris 10 or Linux system to serve basic pkg installation operations for systems using an existing web service.

    /usr/lib/pkg.depot-config -F -d prefix=repository_dir -r runtime_dir

    The prefix is a prefix into the depot-config web server namespace where the repository_dir repository can be accessed. The runtime_dir is created if it does not already exist. See the pkg.depot-config(8) man page for more information about how to use the pkg.depot-config command.

    This command creates the following output in the runtime_dir directory, as shown in Example 3, Serving Package Content From a Linux System Using an HTTP Interface:

    • A filed named depot.conf that contains rewrite rules.

    • An htdocs directory.

  2. Install the partial web server configuration file.

    Copy the partial configuration that is output by the pkg.depot-config command to the Apache configuration directory. On an Oracle Solaris 10 repository host, copy the depot.conf configuration fragment file to /etc/apache2/2.2/conf.d, for example. For a Linux repository host, consult your OS documentation to determine how to use this partial configuration file. The htdocs files must be accessible from the DocumentRoot of the repository host.

  3. Set the publisher origin.

    On each Oracle Solaris system that needs to access the repository, set the publisher origin to the http address of the repository host system, as shown in the following example. Use pkg list or pkg info to test your access to the repository.

Example 3  Serving Package Content From a Linux System Using an HTTP Interface

In this example, the repository is in /var/share/pkgrepos on an Oracle Solaris 11.4 system. This repository contains one package from the mypub publisher.

$ pkgrepo -s /var/share/pkgrepos/myrepo info
PUBLISHER PACKAGES STATUS           UPDATED
mypub     1        online           2018-06-08T05:23:00.489687Z

The following command creates the configuration.

$ /usr/lib/pkg.depot-config -F -d customconfig=/var/share/pkgrepos/myrepo \
-r /tmp/runtime
Created /tmp/runtime/depot.conf

The -F option produces a partial Apache configuration file that can be installed on the Linux system to enable access to the IPS package repository from the Linux system. This configuration information is only a partial configuration, designed to be included from an existing Apache configuration file. For a complete httpd.conf configuration, you need many additional Apache settings that are not included in this partial configuration.

The -d option specifies the path to the repository. This repository directory will be included in the depot server configuration. The customconfig portion of the argument is used as a prefix into the depot-config web server namespace where this repository can be accessed.

The -r option specifies the output directory for the configuration files.

The pkg.depot-config command created the following configuration files:

/tmp/runtime/depot.conf
/tmp/runtime/htdocs
/tmp/runtime/htdocs/customconfig
/tmp/runtime/htdocs/customconfig/mypub
/tmp/runtime/htdocs/customconfig/mypub/publisher
/tmp/runtime/htdocs/customconfig/mypub/publisher/1
/tmp/runtime/htdocs/customconfig/mypub/publisher/1/index.html
/tmp/runtime/htdocs/customconfig/publisher
/tmp/runtime/htdocs/customconfig/publisher/1
/tmp/runtime/htdocs/customconfig/publisher/1/index.html
/tmp/runtime/htdocs/customconfig/status
/tmp/runtime/htdocs/customconfig/status/0
/tmp/runtime/htdocs/customconfig/status/0/index.html
/tmp/runtime/htdocs/versions
/tmp/runtime/htdocs/versions/0
/tmp/runtime/htdocs/versions/0/index.html

The pkg.depot-config command created the following /tmp/runtime/depot.conf file:

RewriteEngine on
RewriteLog "/var/log/pkg/depot/rewrite.log"
RewriteLogLevel 0

# Allow these because they are encoded in the package/manifest names
# when looking up v4 repositories.
AllowEncodedSlashes On
# The default of 500 MaxKeepAliveRequests is too low to be useful.
MaxKeepAliveRequests 10000

# Per-repository versions, publishers, and status responses.
RewriteRule ^/customconfig/versions/0 /versions/0/index.html [PT,NE]
RewriteRule ^/customconfig/publisher/0 /customconfig/publisher/1/index.html [PT,NE]
RewriteRule ^/customconfig/status/0 /customconfig/status/0/index.html [PT,NE]

# Rules to handle responses for default publishers.

RewriteRule ^/mypub/manifest/0/.*$ %{THE_REQUEST} [NE,C]
RewriteRule ^GET\ /mypub/manifest/0/([^@]+)@([^\ ]+)(\ HTTP/1.1)$ /customconfig/mypub/publisher/mypub/pkg/$1/$2 [NE,PT,C]
RewriteRule ^/customconfig/mypub/(.*)$ %{DOCUMENT_ROOT}/customconfig/mypub/$1 [NE,L]
RewriteRule ^/mypub/file/(.*$) /customconfig/mypub/file/$1 [NE]
RewriteRule ^/customconfig/catalog/1/(.*$) /customconfig/mypub/publisher/mypub/catalog/$1 [NE,PT]

# Write per-publisher rules for publisher, version, file, and manifest responses.

# Serve the static versions and publisher responses.
RewriteRule ^/customconfig/mypub/versions/0 %{DOCUMENT_ROOT}/versions/0/index.html [L,NE]
RewriteRule ^/customconfig/mypub/publisher/0 %{DOCUMENT_ROOT}/customconfig/mypub/publisher/1/index.html [L,NE]

RewriteRule ^/customconfig/mypub/catalog/1/(.*)$ /customconfig/mypub/publisher/mypub/catalog/$1 [NE,PT]
RewriteRule ^/customconfig/mypub/file/1/(..)(.*)$ /customconfig/mypub/publisher/mypub/file/$1/$1$2 [NE,PT]
RewriteRule ^/customconfig/mypub/manifest/0/.*$ %{THE_REQUEST} [NE,C]
RewriteRule ^GET\ /customconfig/mypub/manifest/0/([^@]+)@([^\ ]+)(\ HTTP/1.1)$ /customconfig/mypub/publisher/mypub/pkg/$1/$2 [NE,PT,C]
RewriteRule ^/customconfig/mypub/(.*)$ %{DOCUMENT_ROOT}/customconfig/mypub/$1 [NE,L]

# Create an alias to serve /var/share/pkgrepos/myrepo content.
# Map the web server URI namespace to a location on the file system.
Alias /customconfig/mypub /var/share/pkgrepos/myrepo
# Enable the web server to see that file system location.
<Directory "/var/share/pkgrepos/myrepo">
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

# Versions response.
RewriteRule ^/.*[/]?versions/0/?$ %{DOCUMENT_ROOT}/versions/0/index.html [L]
# Allow for 'OPTIONS * HTTP/1.0' requests.
RewriteCond %{REQUEST_METHOD} OPTIONS [NC]
RewriteRule \* - [L]

# Location matches based on the final Rewrite paths for file,
# manifest, catalog, and publisher responses.
<LocationMatch ".*/file/../[a-zA-Z0-9]+$">
        Header set Cache-Control "must-revalidate, no-transform, max-age=31536000"
        Header set Content-Type application/data
</LocationMatch>
<LocationMatch ".*/publisher/.*/pkg/.*">
        Header set Cache-Control "must-revalidate, no-transform, max-age=31536000"
        Header set Content-Type text/plain;charset=utf-8
</LocationMatch>
<LocationMatch ".*/catalog/catalog.*.C">
        Header set Cache-Control "must-revalidate, no-transform, max-age=86400"
        Header set Content-Type text/plain;charset=utf-8
</LocationMatch>
<LocationMatch ".*/catalog.attrs">
        Header set Cache-Control no-cache
</LocationMatch>
<LocationMatch ".*/publisher/\d/.*">
        Header set Cache-Control "must-revalidate, no-transform, max-age=31536000"
        Header set Content-Type application/vnd.pkg5.info
</LocationMatch>

Copy /tmp/runtime to the Linux system. The depot.conf configuration fragment file must be added to the Apache configuration on the Linux system, and the htdocs files must be accessible from the DocumentRoot of the Linux system.

On Oracle Solaris systems that need to access this repository, set the origin of the mypub publisher to the http address of the Linux system.

$ pkg set-publisher -g http://linux-system-name:8080/mypub mypub

You could have used the -P option to the pkg.depot-config command to root the repository further down the URI namespace. For example, the following pkg.depot-config command enables you to have a mypub origin of http://linux-system-name:8080/ips-repos/mypub:

$ /usr/lib/pkg.depot-config -F -P ips-repos -d customconfig=/var/share/pkgrepos/myrepo -r /tmp/runtime