Draft of setup the compile / build enviroment

  • Posted on: 29 January 2023
  • By: tomww

Update 20230129: there is now a package "cbe" delivering setup secripts and an ansible playbook - will be documented soon. If you want to give it a try, email me for instructions at sfepackages at g mail dot com.

Hi, this is a very early draft for setting up a SFE build environment.

If you find some improvements to to this guide, please drop me a note.
You might contribute with better wording or even have additions to the technical steps or have just questions.
You can send me an email to sfepackages at g mail dot com, write me on twitter @sfepackages or got to irc.freenode.org channel #pkgbuild
Thanks!

Are you good at editing a blog web page so that it looks a bit better structured afterwards?
If yes, then please get in contact and we can find the right mode to get it done.

Here I'll place the links to two files later on...

=======
The basic setup would be something like this: (parts taken from setup
script "bootstrap-sfe-testing-20160822-2211")

1) create a separate, non-root user-id with a home directory.
I'm using username "sfe"

2) assign these profiles to that user: (relogin sfe user to get them into effect)

echo " please check /etc/security for sufficient rights to
operate on pkg repositories."
echo " Solaris 12 (11)
/etc/security/exec_attr.d/package:pkg
Software Installation:solaris:cmd:::/usr/bin/pkg:uid=0
Software Installation:solaris:cmd:::/usr/bin/pkgrepo:uid=0
Software Installation:solaris:cmd:::/usr/bin/pkgsend:uid=0
Software Installation:solaris:cmd:::/usr/bin/pkgrecv:uid=0
"

You might as well for user "sfe" the ability to manage SMF:
grep "^sfe:.*Service Configuration" /etc/user_attr \
|| {
gsed -i.temp.bak.diff \
-e '/^sfe:.*profiles=/ s?Software Installation?Software Installation,Service Configuration?' \
/etc/user_attr
echo "changes to /etc/user_attr:"
echo "##########################"
diff -u /etc/user_attr.temp.bak.diff /etc/user_attr
echo "##########################"
rm /etc/user_attr.temp.bak.diff
}

The essence of that lines is, that you have a line similar to this one:
grep "^sfe" /etc/user_attr
sfe::::type=normal;profiles=Software Installation,Service Configuration

als user "sfe" run for a quick check:
profiles -l
This should show "pkg" "pkgrepo" and so an as running with uid=0

3) install package "pkgbuild"

4) I'm intalling on all systems solaris studio compiler, lots of spec
files still use it. depending on the target OS, gcc might be used more
and more often.

5) the "common build environment" is a set of scripts, that are used to
initialize the login shell to have some variables set like "PATH", "CC",
"CXX" and so on. It has historic reasons to have that, as it tried in
the past to insert more fresh versions of the toolset used to build the
software, like "automake" and such. The need for it is no longer that
strong.
That is the currently not so well maintained part.

Example variables you might try to start with:

omnios sfe ~ . /opt/*bld/bin/env.sh
Desktop CBE version 1.8.0 built on 2015-03-01 by sfe@omnios
Unsetting USER
Using CC=/opt/solarisstudio12.3/bin/cc
Using CXX=/opt/solarisstudio12.3/bin/CC
Setting
PATH=/opt/dtbld/bin:/opt/solarisstudio12.3/bin:/usr/gnu/bin:/usr/bin:/usr/sbin:/bin:/usr/sfw/bin
Setting CONFIG_SHELL=/bin/bash
Setting MAKESHELL=/bin/bash
Setting MAKE=/opt/dtbld/bin/make
Setting M4=/opt/dtbld/bin/m4

(MAKE and M4 could possibly left out now)

PKGBUILD_IPS_SERVER=file:///var/pkglocal/
PKGBUILD_SRC_IPS_SERVER=file:///var/pkglocal/

So at this point, please create a script to initialize the variables
before using "pkgbuild".

e.g.
. init-cbe.sh

Note: the package reposiory can be filled by http *or* by direct file
access. I'm using direct file access to get a bit more speed and to
avoid size limits of he cerrypy webserver (thing of boost, libreoffice,
qt with large large files)

6) create extra ZFS pools and filesystems to get a quicker "reset" of the
sometimes very large build spaces. You could as well set the ZFS
sync=disabled for explicitly those filesystems.

PACKAGEPOOL=omnipool
zpool create $PACKAGEPOOL c?t?d?
[ -z ${PACKAGEPOOL}" ] && PACKAGEPOOL=rpool
zfs set atime=off $PACKAGEPOOL

6a) extra filesystem for studio compiler
STUDIOZFSNAME=developerstudio12.5
STUDIOMOUNTPOINT=/opt/developerstudio12.5
/sbin/zfs create -o mountpoint=$STUDIOMOUNTPOINT $PACKAGEPOOL/$STUDIOZFSNAME

6b) local package spool
pkgtool/pkgbuild use path /var/tmp/pkgbuild-${USERNAME} for spooling files into packages, so lots
of traffic at the end of the builds:

#for user "sfe" this would be:
POOLUSERNAME=sfe
zfs create -o canmount=noauto ${PACKAGEPOOL}/var
zfs set mountpoint=/var ${PACKAGEPOOL}/var
zfs create -o canmount=noauto ${PACKAGEPOOL}/var/tmp
zfs create -o canmount=on ${PACKAGEPOOL}/var/tmp/pkgbuild-${POOLUSERNAME}
#check it
ls -l /var/tmp/pkgbuild-${POOLUSERNAME}
df -h /var/tmp/pkgbuild-${POOLUSERNAME}
#(this should show the pool ${PACKAGEPOOL})

the path /var/tmp/pkgbild-sfe is usually cleaned up after a packaging
run, but it contributes to filessystem fragmentation so you don't want
it in rpool.

6c) relocate the heavy filesystem stuff of the compile area to the
package pool

user "sfe" should already have a ZFS based HomeDir now.

POOLUSERNAME=sfe
ZFSCREATEOPTS=""
for ZFS in $POOLUSERNAME/packages
$POOLUSERNAME/packages/SOURCES $POOLUSERNAME/packages/PKGS
$POOLUSERNAME/packages/BUILD $POOLUSERNAME/packages/PKGMAPS
$POOLUSERNAME/packages/SPKGS $POOLUSERNAME/packages/SPECS
do
/sbin/zfs create $ZFSCREATEOPTS $PACKAGEPOOL/$ZFS
chown $POOLUSERNAME /$PACKAGEPOOL/$ZFS
done

"BUILD" gets *really* hughe sometimes.
"SOURCES" might geht huge by the source downloads

So these places are really "dirty" in terms of filesystem operations,
you should like having snapshots so deleting the cruft ist a simple
"rollback" then. Mind to not rollback the "SOURCES" as this would need
you to download sources again and again.

zfs snapshot -r $PACKAGEPOOL/$POOLUSERNAME/packages@initial

6d) filesystem for the local IPS repository

zfs create -o canmount=on ${PACKAGEPOOL}/var/pkglocal

and then follow the instructions to create the IPS repo as writen in
attached file "bootstrap-sfe-latest.ende-screen.txt"

There is an example on how to compile the first simple package in the
same file.

This filesystem is really not well placed in "rpool", so *share* it
between the OS boot environments. And it becomes hughe, as it collects
depending on your preference the binary packages *and* the source
packages as well. And is collects mutlitudes of versions of the packages
that are built over time.

7) compilers and svn tool

You might want to start with "svn" (omnios has none) and the "gcc"
compiler from the SFE repository.
For Solaris Studio you might be good with just loading the tarball of
the compiler and drop it into the path created above:
/opt/developerstudio12.5 so that CC=/opt/developerstudio12.5/bin/cc and
CXX=/opt/developerstudio12.5/bin/CC
is found. Set with CC / CXX if you want Studio,
set it to CC=/usr/gnu/bin/gcc and CXX=/usr/gnu/bin/g++
if you want gcc.
Note: Spec-files normally don't like mixing up compilers, so stay with
that what the spec file might set explicitly.

You would be installing either gcc 4.8.5 / gcc 4.9.4 / gcc 7, depending
on what is in the SFE IPS repository.

pkg publisher
PUBLISHER TYPE STATUS P LOCATION
localhostomnios origin online F file:///var/pkglocal/
omnios origin online F https://pkg.omniosce.org/r151030/core/

install svn:
pfexec pkg install pkg://localhostomnios/developer/versioning/gnu/subversion

install gcc:
pfexec pkg install pkg://localhostomnios/sfe/developer/gcc@4.9.4 #-0.151030.3:20190706T193434Z

Currently I'm using gcc 4.9.4 on Omnios

I'm sure there are pitfalls in my description above, so feel free to
write a screenlog e.g. with "script -a sfe-bootstrap" to have something
to show if things don't work.

8) check out SVN spec-files-extra

cd $HOME of user "sfe", please run svn as user "sfe".

svn co https://svn.code.sf.net/p/pkgbuild/code/spec-files-extra/trunk spec-files-extra

cd spec-files-extra

(initialise the variables with your script from above)

pkgtool --download --interactive build SFEbvi.spec

If you see strange errors, *ever* first check if you have set
PATH and CC and so on that you initialize with your script.

Plans are to move parts of the setup described above into an
IPS package to have automatic provision for build hosts.
And gettiing an easy setup for the beginners users.
But you know time is limited....

Please feel free to make notes about the steps above to improve the
setup guide that might be built from this email.

BTW: you can check IRC channel "#pkgbuild" on freenode.
=======