Pkgbuild on OpenSolaris
From pkgbuild
Contents |
pkgbuild on OpenSolaris, Oracle Solaris 11 Express, and OpenIndiana
Want to package or install additional software on OpenSolaris, Oracle Solaris 11 Express, or OpenIndiana? Here's how to do it with pkgbuild.
pkgbuild is used by the following projects:
- Desktop (JDS), the core desktop software for Solaris 11
- spec-files-extra, a project to create package recipes for software not yet included in Solaris 11 or OpenIndiana
- Source Juicer, the system for submitting community-maintained packages to the OpenSolaris /contrib repository
- KDE Solaris, the project supporting the K Desktop Environment on Solaris and derivatives
- BeleniX, an independent distribution based on OpenSolaris
Quick Setup
This may not work in all cases.
Thomas Wagner has written an automated installer for pkgbuild and spec-files-extra.
If you check the license and download the SolarisStudio compiler as tarfile from http://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/index-jsp-141149.html and place the resulting file SolarisStudio12.3-solaris-x86-bin.tar.bz2 into the current working directory, then the bootstrap script below automaticly finds the file and extracts it to install the compiler. You may want to create a zfs filesystem before and mount it to /opt/solarisstudio12.3
To try it out, run (as the user you wish to build packages with):
#OpenSolaris up to including build 134, 2009.06 or earlier - skip to the next section for OpenIndiana, Oracle Solaris 11 Express, internal builds > 134 wget http://tinyurl.com/bootstrap-sfe-latest-os20nn chmod +x bootstrap-sfe-latest-os20nn ./bootstrap-sfe-latest-os20nn $USER
If it is successful, you can skip to the "Building Packages" section. Otherwise, keep reading.
For more recent builds (e.g. Solaris 11 Express or OpenIndiana) there is an experimental script version:
usage: Login as regular userid. This is important. Test the sudo mechanism for working successfully with this userid:
Running "sudo id" and at the prompt enter user's password (not root's!). This will return something like "uid=0(root) gid=0(root)". You *need* sudo.
#OpenIndiana, Solaris 11 Express, other internal builds > 134 pfexec pkg install sudo wget http://bit.ly/bootstrap-sfe-testing-os20nn chmod +x bootstrap-sfe-testing-os20nn ./bootstrap-sfe-testing-os20nn $USER
Please drop Tom a note if you encounter problems or have comments. You may wish to drop a 'Success Report' as well (that's what every programmer need to re-fuel). The Email address is displayed at the end of the script.
You are done with the quick setup now. If you *read* the last few pages and/or save them into a text file for later use then you should be save!
There is no need to do the next steps on this page, they are only for installing the build-environment manually.
Configuring the Build Environment
Installing Compilers
First, you should install C and C++ compilers, as the majority of available software is written in these languages.
Sun Studio compilers are recommended for most software, including the JDS spec files. To install Sun Studio, run:
sudo pkg install ss-dev
Some software in spec-files-extra may require the GCC compilers. To install GCC, run:
sudo pkg install gcc-dev
Configuring Your User Account
You can skip this section if you are going to be using the user account you created when you first installed the system.
To have pkgbuild automatically install packages, your user account needs to include at least the "Software Installation" profile.
To check the profiles for a user, run:
profiles <username>
If the list does not include either "Primary Administrator" or "Software Installation", modify the profiles:
sudo usermod -P "Software Installation,All" <username>
This replaces the existing list of profiles for the user, so don't do this if this is only user with "Primary Administrator".
Installing the Desktop Common Build Environment
The Desktop Common Build Environment (formerly known as the JDS CBE) is a set of software that includes pkgbuild as well as other tools which are necessary to build packages.
To download the latest version the Desktop CBE to the directory "jds-cbe", run:
svn co svn+ssh://anon@svn.opensolaris.org/svn/jds/jds-cbe/trunk jds-cbe
If this is your first time connecting to svn.opensolaris.org, accept the host key when prompted by typing 'yes'.
Wait for the files to finish downloading, then install the Desktop CBE by running:
cd jds-cbe ./cbe-install
If the installer asks to install required packages, type 'yes' or just press Enter to continue.
The later instructions assume you chose the default base directory (/opt/dtbld).
When prompted for base directory and compiler settings and whether to install additional tools, you may accept the defaults by pressing Enter.
Once the installation completes, you are ready to pkgbuild.
Building Packages
Environment
Before using pkgbuild or other CBE tools, source or run the "env.sh" script to set up the correct environment.
Note that you will need to repeat the following command each time you start a new shell. You can place this command in your shell's profile to avoid having to type it.
For JDS CBE 1.6.2:
. /opt/jdsbld/bin/env.sh
If you're using Desktop CBE 1.7.0 or later:
. /opt/dtbld/bin/env.sh
Packaging Systems
There are two packaging systems supported by pkgbuild, each with its own advantages.
Image Packaging System
OpenSolaris and it successors use the Image Packaging System, also known as pkg(5). Currently, IPS is completely network-based, and if you choose to create packages in this format, they need to be published to a pkg(5) server.
Your system comes with a local pkg(5) server which you can enable with the following commands:
# Create the repository sudo pkgsend -s file:///var/pkg/repo create-repository --set-property publisher.prefix=localhost # Change the server port to avoid conflict (default is port 80) sudo svccfg -s pkg/server setprop pkg/port=10000 # Enable write access to the repository sudo svccfg -s pkg/server setprop pkg/readonly = false # Update the service instance sudo svcadm refresh pkg/server # Enable the server sudo svcadm enable pkg/server # Add server as a publisher for this system sudo pkg set-publisher -O http://localhost:10000 localhost
You do not have to use /var/pkg/repo as the location of your repository. That is just the default. Thus, you could do
sudo pkgsend -s file:///export/pkg create-repository --set-property publisher.prefix=my_publisher sudo svccfg -s pkg/server setprop pkg/inst_root = /export/pkg
Here, my_publisher can be any string consisting of letters, hyphens, and periods; a good choice is the name of your machine on your network. It is a good idea to make your repository reside in its own zfs filesystem; thus, before doing the above, you would do
sudo zfs create -o mountpoint=/export/pkg rpool/export/pkg
The pkg(1) command is used to manage pkg(5) packages. To make pkg faster, it is recommended that you make pkg access your repository through the file system rather than over http. (This only works with OpenIndiana snv_147 or more recent Solaris releases.) Thus, continuing the above example, you would do
sudo pkg set-publisher -g file:///export/pkg/ my_publisher
SVR4 Packages
Solaris 10 and prior releases use SVR4 packages (originally from Unix System V), and OpenSolaris and its successors continue to support them with some limitations.
SVR4 packages currently have the advantage of being installable from a single file (a "datastream") while pkg(5) packages must be installed from a package server. SVR4 packages can list pkg(5) packages as dependencies, but not vice versa.
The pkg(1) command is not aware of SVR4 packages. Instead, SVR4 packages are managed by its own set of commands, including pkgadd, pkgrm, and pkginfo.
The pkgtrans command converts SVR4 packages between "file system" and "datastream" formats.
From Source Juicer
Source Juicer (jucr) is an automated build system based on pkgbuild that allows community members to maintain binary packages in the OpenSolaris /contrib repository, the official repository for contributed software. jucr publishes built packages to the /pending repository. Following review, they are made available on the OpenSolaris /contrib repository.
Spec files (package recipes) submitted to Source Juicer are stored in jucr's own repository, and a copy of the repository can be used for staging new or updated packages. To check out the current repository:
If you used the automated bootstrap script above, you can skip this step.
svn co svn+ssh://anon@svn.opensolaris.org/svn/sourcejuicer/spec-files-jucr/trunk spec-files-jucr
This creates a working copy of the repository in the directory 'spec-files-jucr'.
cd spec-files-jucr
Now, locate the spec file for the package(s) you wish to install. Packages with legal restrictions (e.g. patent or copyright problems) are located in the "encumbered" directory.
The build process for jucr packages is similar to that of spec-files-extra, as described below. Keep in mind jucr only creates IPS packages.
If you are considering submitting new packages to jucr, please check if spec-files-extra has an existing port of said software and contact the authors of that spec to avoid duplication or conflicts. Many of the spec files in spec-files-extra may eventually be submitted to jucr.
Source Juicer Help has for more information.
From spec-files-extra
spec-files-extra (SFE) is a repository of contributed spec files (package recipes) for lots of free software that isn't yet officially part of Solaris 11 or OpenIndiana.
If you wish to install packages from SFE, check out the current repository first:
If you used the automated bootstrap script above, you can skip this step.
svn co https://pkgbuild.svn.sourceforge.net/svnroot/pkgbuild/spec-files-extra/trunk spec-files-extra
This creates a working copy of the repository in the directory 'spec-files-extra'.
cd spec-files-extra
Now, locate the spec file for the package(s) you wish to install. Packages with legal restrictions (e.g. patent or copyright problems) are located in the "encumbered" directory.
Example for IPS Packages
This example generates a package for the native Image Packaging System (IPS) in OpenSolaris and its successors. It assumes a local package server is enabled.
In this example, we will build and install the GStreamer "bad" plugins (gst-plugins-bad). The spec file "SFEgst-plugins-bad.spec" is used to build the software, which will be placed in a package named SFEgst-plugins-bad.
We will use the pkgtool command instead of running pkgbuild directly:
pkgtool build --download --interactive SFEgst-plugins-bad.spec
A quick explanation of the options used for pkgtool:
- build - Build and install packages from the specified spec files
- --download - Automatically download sources
- --interactive - Display the build output and allows you to intervene if a packaging step fails.
If the build process succeeds, the SFEgst-plugins-bad package will be published to the local package server automatically. You can then install the package by running:
sudo pkg install SFEgst-plugins-bad
Example for SVR4 Packages
This example generates a package in the SVR4 format used by previous Solaris releases. These packages can be used on OpenSolaris and its successors, but they can only be managed with the legacy commands (pkgadd, pkgrm, etc.). They will not be visible to the pkg(1) command.
In this example, we will build and install the GStreamer "bad" plugins (gst-plugins-bad). The spec file "SFEgst-plugins-bad.spec" is used to build the software, which will be placed in a package named SFEgst-plugins-bad.
We will use the pkgtool command instead of running pkgbuild directly:
pkgtool build --svr4 --download --autodeps --interactive SFEgst-plugins-bad.spec
A quick explanation of the options used for pkgtool:
- build - Build and install packages from the specified spec files
- --svr4 - Create a package in the legacy SVR4 format
- --download - Automatically download sources
- --autodeps - Automatically locate and build dependencies
- --interactive - Display the build output and allows you to intervene if a packaging step fails.
If the build process succeeds, the SFEgst-plugins-bad package will be installed automatically. If you do not wish to install packages automatically, use the "build-only" command instead of "build".
With the default pkgtool settings, a copy of the package will be kept in "packages/BUILD/PKGS" under your home directory.
