Skip to main content
This revision made March 24, 2013 19:27, by Alan Coopersmith
« earlier revision revert to this « later revision

Building Oracle Solaris Desktop (OSD) Packages


Note: This documentation is currently a little out of date, as it doesn't cover things like building IPS packages or installing the CBE tools from the IPS repository. A slightly more up to date set of instructions can be found in How To: Build JDS (GNOME) on OpenSolaris.


1. Compilers


We recommend to build the OSD with Oracle Solaris Studio compilers. Building with gcc is also possible, but may require a little extra work during the build. We would much welcome patches to fix this so that both compilers can be used out of the box. The rest of this document assumes you are building the OSD sources with Solaris Studio.

2. Package Requirements


Some of the OSD components require other packages to be available on your system in order for you to build.

SUNWgpch SUNWgtar SUNWwgetu

You can find these packages on your Solaris install media. The cbe-install script will assist with installing them.

3. OSD Common Build Environment


The OSD Common Build Environment (CBE) is a set of build tools required to build GNOME, Mozilla and Evolution on Solaris. It includes the following tools -

Apache ant GNU autoconf GNU automake
GNU bison CVS GNU diffutils
GNU fileutils GNU flex GNU gettext
GNU libtool GNU m4 GNU make
pkgbuild rsync * subversion
 *=optional

Download the latest tarball from the Solaris Desktop download center.

The latest version of CBE builds packages by default in ~/packages, while installing the tools in /opt/jdsbld. Installing the CBE for your architecture gives you the opportunity of easily installing packages, rather than having to build the tools yourself.

You don't need root access for installing the CBE or building GNOME, but the build user needs to have the 'Software Installation' profile for installing the packages that the CBE creates. In a typical case, you need to add the following profile to /etc/user_attr -


       osduser::::profiles=Software Installation

Then run the cbe-install script as follows -


osduser@osdbuild:~> ./cbe-install 
Checking for required packages...
Installing the OSD Common Build Environment (CBE) version 1.6.1
The recommended C compiler(s) for this version of the OSD CBE is/are:
        Sun Studio 11 (Venus) (cc: Sun C 5.8 Patch 121016-02 2006/03/31)
        Sun Studio 10 (Vulcan) (cc: Sun C 5.7 Patch 117837-04 2005/05/11)
Enter the path to the C compiler [/opt/SUNWspro/bin/cc]: 
This version of the CBE comes with some optional utilities.
These are not required for building the OSD code, nevertheless
they are useful to have on your system.
Please see the README file for the list of optional utilities.
Would you like to install the optional packages? [yes]: 
Installing package SFpkgbuild

Installation of  was successful.
Installing package CBEmake
....
....
+ cd /home/osduser/packages/BUILD
+ rm -rf /var/tmp/pkgbuild-osduser/CBEenv-1.6.1-build
+ exit 0
Installing package CBEenv

Installation of  was successful.
CBE setup complete
Run
  . /opt/jdsbld/bin/env.sh
or
  source /opt/jdsbld/bin/env.csh
depending on your shell, to use this build environment.
Installation log saved in /tmp/jds-cbe-1.6.1.install.log.4030

You may want to put the following in your profile, adjusting to your shell of preference -


JDS_CBE_ENV_QUIET=1 . /opt/jdsbld/bin/env.sh

Note: if you already have a previous version of the OSD CBE installed, the cbe-install script will upgrade it to the new version.

The OSD CBE sets up the following default directory structure for you to build packages -

Location Description
$HOME/packages/BUILD/ Sources are unpacked, patched and built
$HOME/packages/PKGMAPS/ Information for contents of Solaris packages and any pr|- e/post install scripts
$HOME/packages/PKGS/ Binary packages are produced
$HOME/packages/SOURCES/ Source code, patches and other miscellaneous files used in the build
$HOME/packages/SPECS/ Spec files
$HOME/packages/SPKGS/ Source packages are produced

4. OSD Build Sources


Once you have installed the OSD CBE, you are now ready to fetch the build sources. You can get the latest set of OSD sources from the SVN repository with anonymous access -


osduser@osdbuild:~/> hg clone https://hg.java.net/hg/solaris-desktop~spec-files

Once you have downloaded the sources, take some time to take a source code tour to get a feel of the build structure. The current OSD source code on 'trunk' is based on GNOME 2.30, along with a number of other components. Other branches are available by doing the following -


osduser@osdbuild:~/> hg branches
gnome-2-30-s11update       22138:18326cc71ee2
gnome-2-30-s12             22135:44cb22ad8c30
gnome-2-30-s11u1-sru       22134:4ba33f8ba76d
gnome-2-30-s11rr-sru       22060:20b965d9af9d
default                    22050:f7758f374dde
gnome-2-30-s12preview      22011:50154828b79a
gnome-2-12                 21810:b59a653a3329
gnome-2-14                 21798:352a4716f1f3
gnome-2-16                 21673:f2bdac07fd5f
[...]
osduser@osdbuild:~/> hg checkout gnome-2-16

As part of our policy for developing on OSD, we only apply and manage patches on top of a pre existing community released tarball. Not only does this allow us to separate out our work into atomic changes, it also maximizes the chances of getting these changes upstream in the original community. Along with the build sources that you just downloaded, you will also need to download the original community tarball - this can be done manually, or automatically using pkgtool.

Solaris specific manual pages are found in tarballs named SUNWgnome-something-manpages-version.tar.bz2. These tarballs are generated from the manual page files found in spec-files/manpages. To generate the tarballs, use the following commands:


osduser@osdbuild:~> cd spec-files/manpages
osduser@osdbuild:~> make

The manpage tarballs will be placed in the spec-files/sun-manpage-tarballs directory.

Solaris specific changes to translations are found in tarballs named module-po-sun-version.tar.bz2. These tarballs are generated from the .po files found in spec-files/po-sun. To generate the tarballs, use the following commands:


osduser@osdbuild:~> cd spec-files/po-sun
osduser@osdbuild:~> make

The manpage tarballs will be placed in the spec-files/po-sun/po-sun-tarballs directory.

5. Quickstart to building OSD


First, set up the environment for building OSD -


osduser@osdbuild:~> . /opt/jdsbld/bin/env.sh

Uninstall the existing OSD packages using pkgtool -


osduser@osdbuild:~> cd spec-files
osduser@osdbuild:~> pkgtool uninstall-pkgs *.spec

This command extracts the package names from the spec files and then uninstalls them using the pkgrm command. Packages are uninstalled even if other installed packages require them. It is advised that you are not logged into GNOME during this step as it uninstalls all GNOME packages. Use a remote login or a failsafe session instead.

Now build the entire stack -


osduser@osdbuild:~> pkgtool --download build -v *.spec

pkgtool will read all spec files to determine the build order, then builds and installs them one by one. For more details on building OSD manually, see the following sections.

Build log files for individual packages are placed in /tmp by default. You can change this using the --logdir option or specifying logdir in ~/.pkgtoolrc:


osduser@osdbuild:~> echo 'logdir: /path/to/my/logdir' >> ~/.pkgtoolrc

6. Building Solaris Packages


At the heart of the OSD build environment is pkgbuild, a perl script for building Solaris SVr4 packages from an RPM spec file. It is intended to be a plug-in replacement of the rpmbuild command on many Linux distributions. pkgbuild allows you to build a single package at a time.

Building a package goes through 4 stages -

Stage Description
Preparation Sources are unpacked, and patched.
Compilation Sources are compiled locally.
Installation The compiled binaries and data are installed into a temporary directory.
Package The compiled binaries and data in the temporary directory are put into a package.

A command summary of pkgbuild is as follows -


osduser@osdbuild:~> pkgbuild --help
pkgbuild version 1.3.2
Copyright 2003-2008 - Sun Microsystems, Inc.
This may be freely redistributed under the terms of the GNU GPL

* = the option is implemented

 Usage:
*  --help                  - print this message
*  --version               - print the version of rpm being used
*  --interactive           - start a shell in the build directory if fails
                             and allow to continue after the shell terminates
   all modes support the following arguments:
      --rcfile <file>      - use <file> instead of /etc/rpmrc and $HOME/.rpmrc
     -v                    - be a little more verbose
     -vv                   - be incredibly verbose (for debugging)
*   -b<stage> <spec>
    -t<stage> <tarball>    - build package, where <stage> is one of:
*         p                - prep (unpack sources and apply patches)
          l                - list check (do some cursory checks on %files)
*         c                - compile (prep and compile)
*         i                - install (prep, compile, install)
*         b                - binary package (prep, compile, install, package)
*         a                - bin/src package (prep, compile, install, package)
*     --short-circuit      - skip straight to specified stage (only for c,i)
      --clean              - remove build tree when done
      --rmsource           - remove sources and spec file when done
      --sign               - generate PGP/GPG signature
      --buildroot <dir>    - use <dir> as the build root
      --target=<platform>+ - build the packages for the build targets
                             platform1...platformN.
      --nobuild            - do not execute any stages
      --timecheck <secs>   - set the time check to <secs> seconds (0 disables)
*     --define "<name> <value>"
                           - define <name> as <value> as if you had
                             "%define <name> <value>" in the spec file

*   --rebuild <src_pkg>    - install source package, build binary package and
                             remove spec file, sources, patches, and icons.
    --rmsource <spec>      - remove sources and spec file
    --recompile <src_pkg>  - like --rebuild, but don't build any package

7. Manually building your first package with pkgbuild


As an example package to build, take SUNWspeex. Speex is an open source and patent-free speech multimedia codec. As mentioned in the source code tour, the Solaris SUNWspeex package is built from a RPM spec file. Looking at the SUNWspeex.spec file within the spec-files directory of the OSD build sources, you will notice the lines -


%include Solaris.inc
%use speex = speex.spec

The SUNWspeex.spec file includes much of the core information already detailed in the speex.spec "base" spec file, which is in the spec-files/base-specs. As such, the SUNWspeex.spec file is an extension, detailing how the Solaris package is created. You will need both of these files to successfully build the package - copy them to ~/packages/SPECS. Along with that, you'll notice it includes some default settings as detailed in Solaris.inc. This, and other include files are in the spec-files/include directory. Copy this file, along with default-depend.inc into ~/packages/SPECS. Also, copy the default-copyright.txt file, (which is available in the ext-sources top-level directory) into ~/packages/SOURCES.

Within the speex.spec file you will notice the block of lines -


Name:              speex
License:           Xiph
Group:             Application/Devel
Version:           1.0.5
Distribution:      Java Desktop System
Vendor:            Sun Microsystems, Inc.
Summary:           An open-source, patent-free speech codec
Source:            http://www.speex.org/download/%{name}-%{version}.tar.gz
URL:               http://www.speex.org/

This describes much of the core information about the package - what version and license it uses, along with details of where to download it. While we have automated much of the process of downloading the sources from their original community as you will see a little later, for now, proceed to download speex-1.0.5.tar.gz. Copy the downloaded file to /jds/packages/SOURCES.

Now you are ready to build your first package. All the spec files and the sources are in the correct directory locations under ~/packages/, as follows -

Location Contents
$HOME/packages/SOURCES/ speex-1.0.5.tar.gz, default-copyright.txt
$HOME/packages/SPECS/ speex.spec, SUNWspeex.spec, Solaris.inc, default-depend.inc

We want to create a full binary and source SUNWspeex package, so we will use the -ba option with pkgbuild -


osduser@osdbuild:~> . /opt/jdsbld/bin/env.sh
osduser@osdbuild:~> cd ~/packages/SPECS
osduser@osdbuild:~> pkgbuild -ba SUNWspeex.spec
Executing(%prep): /bin/bash /var/tmp/pkgbuild-tmp-1.11242
+ umask 022
+ uname -a
SunOS zenity 5.10 Generic i86pc i386 i86pc
+ cd /home/osduser/packages/BUILD
+ rm -rf SUNWspeex-2.12.0
+ mkdir SUNWspeex-2.12.0
+ cd /home/osduser/packages/BUILD
+ cd /home/osduser/packages/BUILD/SUNWspeex-2.12.0
+ rm -rf speex-1.0.5
+ /usr/bin/gzip -dc /home/osduser/packages/SOURCES/speex-1.0.5.tar.gz
+ /bin/tar xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd speex-1.0.5
+ ++ /usr/xpg4/bin/id -u
+ '[' 100 = 0 ']'
+ ++ /usr/xpg4/bin/id -u
+ '[' 100 = 0 ']'
+ /bin/chmod -Rf a+rX,g-w,o-w .
+ cd ..
+ exit 0
Executing(%build): /bin/bash /var/tmp/pkgbuild-tmp-2.11242
+ umask 022
+ uname -a
SunOS zenity 5.10 Generic i86pc i386 i86pc
+ cd /home/osduser/packages/BUILD
+ cd SUNWspeex-2.12.0
+ cd /home/osduser/packages/BUILD/SUNWspeex-2.12.0
+ cd speex-1.0.5
++ /usr/sbin/psrinfo
++ grep on-line
++ wc -l
++ tr -d ' '
+ CPUS=1
+ test x1 = x -o 1 = 0
+ CFLAGS='-i -x04 -xspace -xstrconst -xpentium -mr'
+ ./configure --enable-shared --enable-static --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man
.....
.....
## Packaging one part.
/home/osduser/packages/SPKGS/SUNWspeex-src/pkgmap
/home/osduser/packages/SPKGS/SUNWspeex-src/pkginfo
/home/osduser/packages/SPKGS/SUNWspeex-src/install/copyright
/home/osduser/packages/SPKGS/SUNWspeex-src/reloc/share/src/SUNWspeex-2.12.0/SOURCES/default-copyright.txt
/home/osduser/packages/SPKGS/SUNWspeex-src/reloc/share/src/SUNWspeex-2.12.0/SOURCES/speex-1.0.5.tar.gz
/home/osduser/packages/SPKGS/SUNWspeex-src/reloc/share/src/SUNWspeex-2.12.0/SPECS/..pkgbuild
/home/osduser/packages/SPKGS/SUNWspeex-src/reloc/share/src/SUNWspeex-2.12.0/SPECS/SUNWspeex.spec
/home/osduser/packages/SPKGS/SUNWspeex-src/reloc/share/src/SUNWspeex-2.12.0/SPECS/Solaris.inc
/home/osduser/packages/SPKGS/SUNWspeex-src/reloc/share/src/SUNWspeex-2.12.0/SPECS/default-depend.inc
/home/osduser/packages/SPKGS/SUNWspeex-src/reloc/share/src/SUNWspeex-2.12.0/SPECS/speex.spec
## Validating control scripts.
## Packaging complete.
Executing(%clean): /bin/bash /var/tmp/pkgbuild-tmp-15.11388
+ umask 022
+ uname -a
SunOS zenity 5.10 Generic i86pc i386 i86pc
+ cd /home/osduser/packages/BUILD
+ cd SUNWspeex-2.12.0
+ rm -rf /var/tmp/SUNWspeex-2.12.0-build
+ exit 0

8. Automatically building packages with pkgtool


While using pkgbuild allows you to build Solaris packages easily, it doesn't allow for automatic dependency checking, and very much relies on the spec files and the sources to be in the correct place. pkgtool is a wrapper script around pkgbuild that helps to solve this problem. pkgtool will also allow you to download the original source community tarballs. Not only is pkgtool very useful in this respect, it also acts as a tinderbox script allowing you log your builds and report any errors that might have occurred. A command summary of pkgtool is as follows -


osduser@osdbuild:~> pkgtool --help
pkgtool [options] [command] specs...

Options:

  General:

    -v|--verbose:
                  Increase verbosity: the more -v's the more diag messages.

    -q|--quiet:
                  Silent operation.

    --halt-on-errors:
                  Halt on the first build error, do not attempt to continue.

    --rcfile=file
                  Read default configuration from file.
                  Default: ./.pkgtoolrc, ~/.pkgtoolrc

    --norc
                  Ignore the default rc files.

    --dumprc
                  Print the current configuration in a format suitable
                  for an rc file, then exit.

    --download

                  Automatically download sources if not found in the local
                  search paths (requires wget)  Specify your proxy servers
                  using the http_proxy and ftp_proxy environment variables.

    --download-to=dir

                  Save downloaded files in dir.  By default, files are
                  downloaded to /usr/src/packages/SOURCES.  Implies --download.

    --interactive  [EXPERIMENTAL]

                  Interactive mode: pkgbuild/rpm output is displayed on
                  the standard output; pkgbuild is executed in interactive
                  mode which makes it start a subshell if the build fails

  Directories and search paths:

    --specdirs=path, --spec=path:
                  Specify a colon separated list of directories to search
                  for spec files in

    --tarballdirs=path, --tarballs=path, --tar=path:
                  Specify a colon separated list of directories to search
                  for tarballs in

    --sourcedirs=path, --src=path:
                  Specify a colon separated list of directories to search
                  for additional source files in

    --patchdirs=path, --patches=path, --patch=path
                  Specify a colon separated list of directories to search
                  for patches (source diffs) in

    --topdir=dir
                  Use dir as the rpm base directory (aka %topdir, where the
                  SPECS, SOURCES, RPMS, SRPMS, BUILD directories are found).
                  Default: /usr/src/packages

    --logdir=dir, --log=dir:
                  Write build logs to dir.

  Options controlling the build:

    --nodeps, --deps:
                  Ignore/verify dependencies before building a component.
                  Default: --deps

    --with foo, --without foo
                  This option is passed on to rpm/pkgbuild as is.  Use it
                  for enabling/disabling conditional build options.

    --target=arch
                  This option is passed on to rpm/pkgbuild as is.

    --pkgformat={filesystem|fs|datastream|ds}
                  Create Solaris packages in filesystem or datastream format.
                  This option is ignored when running on Linux.
                  Default: filesystem

    --nightly, --nonightly:
                  Suffix/Don't suffix the rpm Release with the current date.
                  Default: --nonightly;  See also: --date-format

    --date-format=format, --date=format:
                  Use "date +format" to generate the date suffix for
                  the nightly builds.  Default: %y%m%d

  Reporting:

    --mail-errors-to=address

                  Send the last few lines of the build log to address
                  if the build fails

    --report=file

                  Write a build report to file (in HTML format)

    --prodname=string

                  The name of the product as appears in the build report

    --full-path:
                  Print the full path to the package when running install-order

Commands:

    build-install  Build and install the specs listed on the command line.
                   The build order is determined by the dependencies
                   defined in the spec files.

    build          Same as build-install

    build-only     Build the specs listed on the command line, don't install
                   them.

    prep           run the %prep section of the spec files listed on the
                   command line

    spkg           create source package(s) only (no build done)

    build-order    Print the build order of the specs listed on the
                   command line.

    install-order  Print the rpms in the order they should be installed

    install-pkgs   (not implemented yet): install the packages defined
                   by the spec files listed on the command line from
                   the PKGS directory.  No build is done.  Useful to
                   install packages previously built using the build-only
                   command.

    uninstall-pkgs Uninstall all packages defined in the spec files listed
                   on the command line. (runs rpm --erase --nodeps on
                   Linux, pkgrm on Solaris)

    download       Download the source files from the URLs specified in
                   the spec files listed on the command line.  Source
                   files found in the local search paths will not be
                   downloaded.  (See --tarballdirs, --sourcedirs,
                   --download-to)

specs...

    List of spec files to build. Either full path names or names of spec
    files in the spec directory search path.

Build examples with pkgtool


Print out the build order of the packages -


osduser@osdbuild:Solaris> pkgtool -q build-order *.spec
/export/home/osduser/osd-spec-files/SUNWPython.spec
/export/home/osduser/osd-spec-files/SUNWTiff.spec
/export/home/osduser/osd-spec-files/SUNWaspell.spec
....

Download all the community source tarballs needed to build the SUNWgnome-panel package -


osduser@osdbuild:~> pkgtool download SUNWgnome-panel.spec

Download, build, and install all the packages in the correct order. You will need to set the environmental variables http_proxy and ftp_proxy if necessary -


osduser@osdbuild:~> pkgtool --download build-install *.spec

Uninstall packages SUNWgnome-utils and SUNWgnome-config-editor -


osduser@osdbuild:~> pkgtool uninstall-pkgs SUNWgnome-utils.spec SUNWgnome-config-editor.spec

Build the SUNWgnome-img-viewer package, but don't install it -


osduser@osdbuild:~> pkgtool build-only SUNWgnome-img-viewer.spec

Difference compared to previous revision
= Building Oracle Solaris Desktop (OSD) Packages '''Note:''' This documentation is currently a little out of date, as it doesn't cover things like building IPS packages or installing the CBE tools from the IPS repository. A slightly more up to date set of instructions can be found in ''[https://blogs.oracle.com/mattman/entry/how_to_build_jds_on How To: Build JDS (GNOME) on OpenSolaris]''. __TOC__ == 1. Compilers
 
 
Close
loading
Please Confirm
Close