How to build in a Zone

Building the Xfce Desktop or JDS can cause a few problems if you happen to building a library or binary which you currently are using or need to use. What makes it almost impossible is if you follow the build instructions and do a "pkgtool uninstall *.spec". If you are using Xfce or JDS you are removing everything that is currently your desktop depends on. One way to get around this is to first switch to CDE. This maybe ok, if you can do without such things as firefox, and thunderbird for awhile. Though there is another way you can do a full build of JDS and/or Xfce, without disturbing your desktop. The method that is shown below is creating a Solaris Zone and using it as your build environment.

The first problem if you do this is that the default zone install remounts the /usr directory as read-only into the zone. The second problem is that package changes (and patches) in the global can change the zone you are building on. The solution for the first problem is to create a "whole root zone" by removing the default inherited packages. The solution to the second problem is use a brandz zone which is identical to a native zone.

What's Required

  • Recent Solaris Nevada Distribution 
  • Sun Studio 11 - Installed automatically with Solaris Express Developers Edition 
  • JDS Common Build Environment installed and configured in the global zone.
  • At least one user with the "Software Installation" profile, which is setup to use JDS CBE. This user(s) will have their home directory mounted in both the global zone and the build zone.

Getting Started

Before you start you will need to download the initial_cbe_zone script, and modify the top section to suit your needs. This script does the following -

  • Copies and modifies the configuration files from a native brandz zone to a new cbe brandz zone.
  • Creates a default zone template, which remounts selected users home directory from the global zone into build zone.
  • Creates and installs a cbe zone (called jdsclone) from which you can clone as many cbe build zones from as you like. Note: This zone is never booted....  

Once you have downloaded the script, you need to run it from the root account. As this may take some time, you can take a coffee break (or maybe lunch) while this is happening -

    root@prae> bash ./initial~_cbe~_zone
    .
    .
    .

Making a CBE Build Zone

Once the script has finished, we next need to configure a build zone from the OSOLcbe template. The following is an example to configure a zone called "jds1". You will need to adjust the name, zonepath, and network address to suit your system.

    root@prae> zonecfg -z jds1
    jdstest: No such zone configured
    Use 'create' to begin configuring a new zone.
    zonecfg:jds1> create -t OSOLcbe
    zonecfg:jds1> set zonepath=/export/zones/jds1
    zonecfg:jds1> set autoboot=true
    zonecfg:jds1> add net
    zonecfg:jds1:net> set address=192.168.1.34/24
    zonecfg:jds1:net> set physical=nge0
    zonecfg:jds1:net> end
    zonecfg:jds1> commit
    zonecfg:jds1> exit

The next step is to clone the jdsclone zone to the zone you just configured.

    root@prae> zoneadm -z jds1 clone jdsclone
    Cloning snapshot userdata/export/zones/jdsclone@SUNWzone1
    Instead of copying, a ZFS clone has been created for this zone.
    zoneadm: zone 'jds1': mount operation is invalid for branded zones.
    Could not mount zone for sys-unconfig
    zoneadm: zone 'jds1': post-clone configuration failed.

You will probably see a few error messages as I did. You can safely ignore these messages change the zone status to "installed" by editing the /etc/zone/index file. You can use your favorite editor (which should be vi), or you can do something like my magic one-liner.

    root@prae> printf "/jds1:/s/incomplete/installed/\nwq\n" | ex - /etc/zones/index

Just before you boot the system, edit the sysidcfg file, so the zone will be automatically configured. Below is an example of what this file looks like. For more information "man sysidcfg" and/or read the Solaris Containers-Resource Management and Solaris Zones manual from docs.sun.com

    root@prae> vi /export/zones/jds1/root/etc/sysidcfg
    system~_locale=en~_AU.UTF-8
    terminal=xterm
    timezone=Asia/Bangkok
    network~_interface=PRIMARY { hostname=jds1 }
    name~_service=DNS {
        domain~_name=priv
        name~_server=192.168.1.30
    }
    nfs4~_domain=dynamic
    security~_policy=none
    root~_password=LglKGo875zdew

Booting the Build Zone

Now you have got this far you can boot the jds1 zone. Using the zlogin command to connect to the jds1 console, you can watch the boot process and check for any errors. If there is an error, it will most likely be that you have an incorrect /etc/sysidcfg file. If this happens, you will need to halt and uninstall the zone, and re-clone the zone again.

    root@prae> zoneadm -z jds1 boot
    root@prae> zlogin -e "#" -C jds1
    [Connected to zone 'jds1' console]
    [NOTICE: Zone booting up]
    SunOS Release 5.11 Version snv_59 64-bit
    Copyright 1983-2006 Sun Microsystems, Inc.  All rights reserved.
    Use is subject to license terms.
    Hostname: jds1
    Loading smf(5) service descriptions: 140/140
    Creating new rsa public/private host key pair
    Creating new dsa public/private host key pair
    Configuring network interface addresses: nge0.
    
    rebooting system due to change(s) in /etc/default/init
        
    [NOTICE: Zone rebooting]
    SunOS Release 5.11 Version snv_59 64-bit
    Copyright 1983-2006 Sun Microsystems, Inc.  All rights reserved.
    Use is subject to license terms.
    Hostname: jds1
    
    jds1 console login:

Using the Build Zone

If you have got this far you should be able to login, or even better ssh into the zone from either the global zone, or a remote machine. Everything you do in this zone is isolated from all other zones including the global zone.

    doug@prae> ssh jdsbuild@jds1
    Password: blahblah
    Last login: Sun Mar 18 15:47:04 2007 from prae.priv
    Sun Microsystems Inc.   SunOS 5.11      snv_59  October 2007
    JDS/Solaris CBE version 1.5.1 built on 2007-03-08 by jdsbuild@prae
    Unsetting LC_MONETARY
    Unsetting LC_NUMERIC
    Unsetting USER
    Unsetting LC_MESSAGES
    Unsetting LC_COLLATE
    Unsetting LANG
    Unsetting LC_CTYPE
    Setting default C compiler CC=/usr/bin/cc
    Setting default C++ compiler CXX=/usr/bin/CC
    Setting 32-bit C compiler CC32=/usr/bin/cc
    Setting 32-bit C++ compiler CXX32=/usr/bin/CC
    Setting 64-bit C compiler CC64=/usr/bin/cc
    Setting 64-bit C++ compiler CXX64=/usr/bin/CC
    Setting LD=/opt/jdsbld/bin/ld-wrapper
    Setting
PATH=/opt/jdsbld/bin:/usr/ccs/bin:/usr/gnu/bin:/usr/bin:/usr/sbin:/bin:/usr/sfw/bin:/usr/bin
    jdsbuild@jds1> cd spec-files-xfce
    jdsbuild@jds1> pkgtool uninstall-pkgs *.spec
    jdsbuild@jds1> pkgtool build \-\-download *.spec

Installing the new Packages for your Desktop

Once you have built and tested the packages you want in the build zone, you can then install them in the global zone as your desktop. Since your build user's home directory is the same in both zones, this step is easy.

    doug@prae> su - jdsbuild
    Password: blahblah
    jdsbuild@prae> cd spec-files-xfce
    jdsbuild@prae> pkgtool uninstall-pkgs *.spec
    jdsbuild@prae> pkgtool install-pkgs *.spec
last modified by admin on 2009/10/26 13:19
Collectives
Project


© Sun Microsystems Inc. 2009
XWiki Enterprise 1.8.2.19075 - Documentation
Terms Of Use | Privacy | Trademarks | Copyright Policy | Site Guidelines | Site map | Help
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.