Dear Staf users,

Following steps describe how to compile STAF on OpenSolaris with Sun
Studio C++ compiler. 
The files used within this post are attached to this posting.

I kindly ask STAF developers to review and merge changes to main trunk.
The change on  STAFConnectionProvider::~STAFConnectionProvider() is
especially important
as I'm observing an exception being thrown while stack unwinding is in
progress, which forces
STAFProc process to call abort() and core dump.



0. CONTEXT: 
I have used
- STAF version 3.3.5 
- OpenSolaris version 2009.06 on x86 
- Sun Studio version 12 update 1:

$ uname -a
SunOS giant 5.11 snv_111b i86pc i386 i86pc Solaris

$ CC -V
CC: Sun C++ 5.10 SunOS_i386 2009/06/03


You also need zlib source code if you wish to use STAF's zip service.
http://www.zlib.net/


A. BUILDING

1) It might be useful to create a user dedicated to STAF processes:
# useradd -c "STAF User" -d /export/home/staf -g staff -s /bin/bash -m
staf

2) Unzip the zlib source package.
To configure use
$ ./configure --shared --prefix=/your-prefix/zlib-1.2.3
Then follow the installation procedure for zlib.

3) Unzip the STAF 3.3.5 source package. Note that we shall use the
OpenSSL libraries
bundled with OpenSolaris.

4) Apply the changes to the STAF source tree, in the diff file given
below.

5) If you wish to use a STAF Perl service, it is highly recommended that
you
obtain ActivePerl's vinary distribution (v5.8.9 or later).
http://ActivePerl.com

Using OpenSolaris default Perl version (v5.8.4) will create problems for
services written in Perl later on, 
if you select it as default Perl interpreter.

6) Set the environment variables for building STAF:

export CC_NAME=suncc
export OS_NAME=solaris
export BUILD_TYPE=retail
export OPENSSL_ROOT=/
export ZLIB_SOURCEDIR=/export/home/semihc/Packages/zlib-1.2.3
export STAF_USE_SSL=1
export STAF_USE_IPV6=
export PROJECTS="staf connprov* java perl zip"
# For building Perl support
export PERL_V58_ROOT=/opt/ActivePerl-5.8.9
export PERL_V58_INCLUDEDIRS=$PERL_V58_ROOT/lib/CORE
export PERL_V58_LIBDIRS=$PERL_V58_ROOT/lib/CORE
export PERL_BUILD_V58=1
# For Java components
export JAVA_BUILD_V11=0
export JAVA_BUILD_V12=1
export JAVA_V12_ROOT=/usr/jdk/jdk1.6.0_13
export JAVA_DEFAULT_VERSION=V12


7) Follow the STAF build process; that is

$ gmake 2>&1 |tee make.log

# After the build completes successfully cd to this directory
$ pwd
/your-path-to-staf/staf-3.3.5/rel/solaris/staf/retail/lib

mkdir IPv4
cp -p libSTAF.so IPv4/.
cp -p libSTAFTCP.so IPv4/.
cd ..

./STAFInst -target /install-destination/staf-3.3.5 -verbose




B. CREATING SMF SPECIFICATION

Optionally you can create SMF (Service Management Facility)
specification
which will ensure that STAF daemon (STAFProc) will be managed by OS. For
instance when
a reboot occurs STAFProc will be launched by OS automatically.
For more details about SMF please see:
http://hub.opensolaris.org/bin/view/Community+Group+smf/


1) Modify startSTAFProc.sh script as indicated by following diff. Adapt
the paths.

$ diff startSTAFProc.sh.org startSTAFProc.sh
5c5,10
< nohup /nec/STAF/staf-3.3.5/bin/STAFProc &
---
> #nohup /nec/STAF/staf-3.3.5/bin/STAFProc &
>
> LOGFN=/nec/STAF/staf/data/STAFProc.log
> LD_PRELOAD_32=libperl.so /nec/STAF/staf/bin/STAFProc >$LOGFN 2>&1 &
> echo "Check $LOGFN for logs"


1) Copy stafd.sh to /install-destination  (Default is /nec/STAF)

2) Review staf.xml specification. Please adapt the paths to your
circumstances. (Default install directory is /nec/STAF/staf)

3) Ensure staf.xml is valid XML
$ xmllint --valid /var/svc/manifest/application/staf.xml

4) Copy SMF manifest to proper directory
$ pfexec cp staf.xml /var/svc/manifest/application/staf.xml

5) Further validation via svccfg utility
$ pfexec svccfg validate /var/svc/manifest/application/staf.xml

6) Import specification into SMF graph
$ pfexec svccfg import /var/svc/manifest/application/staf.xml

6a) OPTIONAL: If an error occurs in above commands and you are in need
of starting afresh,
don't forget to return back to a clean state:
$ pfexec svccfg delete stafd

7) Enable STAF deamon service (will start STAFProc)
$ pfexec svcadm enable stafd

7a) OPTIONAL: Disable STAF daemon service permanently (will stop
STAFProc)
$ pfexec svcadm disable stafd

7b) OPTIONAL: Disable STAF daemon service temporarily (will stop
STAFProc)
$ pfexec svcadm disable -t stafd

8) Inspection of stafd service is performed via:
$ svcs -x stafd
svc:/application/staf/stafd:default (STAF Daemon (STAFProc))
 State: online since 17 December 2009 10:03:39 AM
   See: http://staf.sourceforge.net
   See: /var/svc/log/application-staf-stafd:default.log
Impact: None.


Kind regards,
Semih Cemiloglu 


This email may be confidential and/or privileged. Only the intended recipient 
may access or use it. If you are not the intended recipient, please delete this 
email and notify NEC Australia Pty Ltd promptly. NEC uses antivirus software 
but excludes all liability for viruses or similar in any attachment.
Please consider our environment before printing this email.
diff -bwruN -x '*.log' -x '*.org' -x CVS src.org/staf/build/makefile.suncc 
src/staf/build/makefile.suncc
--- src.org/staf/build/makefile.suncc   2009-09-29 14:02:57.000000000 +1000
+++ src/staf/build/makefile.suncc       2009-12-11 11:04:23.410562086 +1100
@@ -14,7 +14,7 @@
 
 CC_CC             := CC -mt
 CC_C              := cc -mt
-CC_MK_SHARED_LIB  := CC -mt -G
+CC_MK_SHARED_LIB  := CC -mt -G -library=Cstd
 
 ifeq ($(BUILD_TYPE),retail)
     CC_BUILD_TYPE_FLAGS = $(CC_OPTIMIZE) -DNDEBUG
@@ -23,7 +23,7 @@
 endif
 
 CC_DEBUG        := -g #-g0
-CC_OPTIMIZE     := #-xO2
+CC_OPTIMIZE     := -xO2
 CC_FPIC         := -KPIC
 CC_STL_PTHREADS := -D_PTHREADS
 CC_SHAREDLIBNAMEFLAGS = -DSTAF_SHARED_LIB_PREFIX=$(OS_SHARED_LIB_PREFIX) \
diff -bwruN -x '*.log' -x '*.org' -x CVS 
src.org/staf/connproviders/tcp/makefile.connprov_tcp 
src/staf/connproviders/tcp/makefile.connprov_tcp
--- src.org/staf/connproviders/tcp/makefile.connprov_tcp        2009-09-29 
14:03:03.000000000 +1000
+++ src/staf/connproviders/tcp/makefile.connprov_tcp    2009-12-10 
16:47:28.767332373 +1100
@@ -47,10 +47,10 @@
 
     # Verify that the two OpenSSL libraries required exist
     ifneq ($(OPENSSL_LIBDIRS)/$(LIB_SSL_V), $(shell find $(OPENSSL_LIBDIRS) 
-name $(LIB_SSL_V) -print))
-        $(error File $(LIB_SSL_V) does not exist in directory 
$(OPENSSL_LIBDIRS).  Check your settings for OPENSSL_ROOT and STAF_USE_SSL)
+        $(warn File $(LIB_SSL_V) does not exist in directory 
$(OPENSSL_LIBDIRS).  Check your settings for OPENSSL_ROOT and STAF_USE_SSL)
     endif
     ifneq ($(OPENSSL_LIBDIRS)/$(LIB_CRYPTO_V), $(shell find $(OPENSSL_LIBDIRS) 
-name $(LIB_CRYPTO_V) -print))
-        $(error File $(LIB_CRYPTO_V) does not exist in directory 
$(OPENSSL_LIBDIRS).  Check your settings for OPENSSL_ROOT and STAF_USE_SSL)
+        $(warn File $(LIB_CRYPTO_V) does not exist in directory 
$(OPENSSL_LIBDIRS).  Check your settings for OPENSSL_ROOT and STAF_USE_SSL)
     endif
     
     ifneq ($(filter aix aix64,$(OS_NAME)),)
diff -bwruN -x '*.log' -x '*.org' -x CVS src.org/staf/lang/perl/PLSTAF.cpp 
src/staf/lang/perl/PLSTAF.cpp
--- src.org/staf/lang/perl/PLSTAF.cpp   2009-09-29 14:03:32.000000000 +1000
+++ src/staf/lang/perl/PLSTAF.cpp       2009-12-10 16:08:12.370739463 +1100
@@ -6,6 +6,9 @@
 /*****************************************************************************/
 
 #define PERL_NO_GET_CONTEXT
+#ifdef __SUNPRO_CC
+# include <sys/vnode.h>
+#endif
 #include "STAFOSTypes.h"
 #include "STAF.h"
 
diff -bwruN -x '*.log' -x '*.org' -x CVS 
src.org/staf/lang/perl/PLSTAFCommandParser.cpp 
src/staf/lang/perl/PLSTAFCommandParser.cpp
--- src.org/staf/lang/perl/PLSTAFCommandParser.cpp      2009-09-29 
14:03:32.000000000 +1000
+++ src/staf/lang/perl/PLSTAFCommandParser.cpp  2009-12-10 16:09:19.685703713 
+1100
@@ -6,6 +6,9 @@
 /*****************************************************************************/
 
 #define PERL_NO_GET_CONTEXT
+#ifdef __SUNPRO_CC
+# include <sys/vnode.h>
+#endif
 #include "STAFCommandParser.h"
 
 #include "EXTERN.h"
diff -bwruN -x '*.log' -x '*.org' -x CVS src.org/staf/lang/perl/STAFPerlGlue.h 
src/staf/lang/perl/STAFPerlGlue.h
--- src.org/staf/lang/perl/STAFPerlGlue.h       2009-09-29 14:03:33.000000000 
+1000
+++ src/staf/lang/perl/STAFPerlGlue.h   2009-12-10 15:56:58.189991678 +1100
@@ -7,6 +7,9 @@
 
 #ifndef __STAFPERLGLUE_H__
 #define __STAFPERLGLUE_H__
+#if defined(__SUNPRO_CC)
+# include <sys/vnode.h>
+#endif
 #include "STAFMutexSem.h"
 #include "STAFPerlSyncHelper.h"
 #include "STAFServiceInterface.h"
@@ -43,3 +46,4 @@
 void printerr(char *str);
 
 #endif
\ No newline at end of file
+
diff -bwruN -x '*.log' -x '*.org' -x CVS src.org/staf/makefile src/staf/makefile
--- src.org/staf/makefile       2009-09-29 14:03:36.000000000 +1000
+++ src/staf/makefile   2009-12-11 14:24:47.050274893 +1100
@@ -601,7 +601,7 @@
 define COPY_FILE
     @$(CREATE_PATH)
     @echo "*** Copying $(@F) ***"
-    @$(COPY) $< $@
+    $(COPY) $< $@
 endef
 
 define RXPP_IT
@@ -612,44 +612,44 @@
 
 define STRIP_IT
     @echo "*** Stripping $(@F) ***"
-    @$(STRIP) $@
+    $(STRIP) $@
 endef
 
 define C_DEPEND_IT
-    @$(CREATE_PATH)
+    $(CREATE_PATH)
     @echo "*** Generating dependency for $(@F) *** "
-    @$(CC_DEPEND_IT)
+    $(CC_DEPEND_IT)
 endef
 
 define C_DEPEND_IT_C
-    @$(CREATE_PATH)
+    $(CREATE_PATH)
     @echo "*** Generating dependency for $(@F) *** "
-    @$(CC_DEPEND_IT_C)
+    $(CC_DEPEND_IT_C)
 endef
 
 define COMPILE_IT
-    @$(CREATE_PATH)
+    $(CREATE_PATH)
     @echo "*** Compiling $(@F) ***"
-    @$(CC_COMPILE_IT)
+    $(CC_COMPILE_IT)
 endef
 
 define COMPILE_IT_C
-    @$(CREATE_PATH)
+    $(CREATE_PATH)
     @echo "*** Compiling $(@F) ***"
-    @$(CC_COMPILE_IT_C)
+    $(CC_COMPILE_IT_C)
 endef
 
 define LINK_IT
-    @$(CREATE_PATH)
+    $(CREATE_PATH)
     @echo "*** Linking $(@F) ***"
-    @$(CC_LINK_IT)
+    $(CC_LINK_IT)
 endef
 
 define SHARED_LIB_IT
-    @$(CREATE_PATH)
+    $(CREATE_PATH)
     @echo "*** Linking shared library $(@F) ***"
-    @$(CC_SHARED_LIB_IT)
-    @$(MOVE_SIDE_DECK)
+    $(CC_SHARED_LIB_IT)
+    $(MOVE_SIDE_DECK)
 endef
 
 # Setup our global inference rules
diff -bwruN -x '*.log' -x '*.org' -x CVS 
src.org/staf/stafif/STAFConnectionProviderInlImpl.cpp 
src/staf/stafif/STAFConnectionProviderInlImpl.cpp
--- src.org/staf/stafif/STAFConnectionProviderInlImpl.cpp       2009-09-29 
14:04:05.000000000 +1000
+++ src/staf/stafif/STAFConnectionProviderInlImpl.cpp   2009-12-11 
15:34:23.251558901 +1100
@@ -225,9 +225,17 @@
 
 STAF_INLINE STAFConnectionProvider::~STAFConnectionProvider()
 {
+  try {
     fFuncTable.provDestruct(&fProvider, 0, 0, 0);
     STAFDynamicLibraryClose(&fConnLib, 0);
 }
+   catch(STAFException& se) {
+    se.write("STAFConnectionProvider::~STAFConnectionProvider()", std::cerr);
+   }
+   catch(...) {
+     std::cerr << "Unknown exception at 
STAFConnectionProvider::~STAFConnectionProvider()" << endl;
+   }
+}
 
 
 STAF_INLINE STAFConnectionProvider::STAFConnectionProvider(
diff -bwruN -x '*.log' -x '*.org' -x CVS src.org/staf/stafproc/makefile.staf 
src/staf/stafproc/makefile.staf
--- src.org/staf/stafproc/makefile.staf 2009-09-29 14:04:08.000000000 +1000
+++ src/staf/stafproc/makefile.staf     2009-12-10 16:46:36.673622772 +1100
@@ -46,10 +46,10 @@
 
     # Verify that the two OpenSSL libraries required exist
     ifneq ($(OPENSSL_LIBDIRS)/$(LIB_SSL_V), $(shell find $(OPENSSL_LIBDIRS) 
-name $(LIB_SSL_V) -print))
-        $(error File $(LIB_SSL_V) does not exist in directory 
$(OPENSSL_LIBDIRS).  Check your settings for OPENSSL_ROOT and STAF_USE_SSL)
+        $(warn File $(LIB_SSL_V) does not exist in directory 
$(OPENSSL_LIBDIRS).  Check your settings for OPENSSL_ROOT and STAF_USE_SSL)
     endif
     ifneq ($(OPENSSL_LIBDIRS)/$(LIB_CRYPTO_V), $(shell find $(OPENSSL_LIBDIRS) 
-name $(LIB_CRYPTO_V) -print))
-        $(error File $(LIB_CRYPTO_V) does not exist in directory 
$(OPENSSL_LIBDIRS).  Check your settings for OPENSSL_ROOT and STAF_USE_SSL)
+        $(warn File $(LIB_CRYPTO_V) does not exist in directory 
$(OPENSSL_LIBDIRS).  Check your settings for OPENSSL_ROOT and STAF_USE_SSL)
     endif
     
     ifneq ($(filter aix aix64,$(OS_NAME)),)
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>

<!--
 Copyright 2009 Semih Cemiloglu

 The contents of this file are subject to the terms of the
 Common Development and Distribution License, Version 1.0 only
 (the "License").  You may not use this file except in compliance
 with the License.

 You can obtain a copy of the license at
  http://www.opensource.org/licenses/cddl1.php
 See the License for the specific language governing permissions and
 limitations under the License.

  staf.xml Version 1.0.0

  Quick way to run a STAF daemon (:
    (1) install the STAF executables (default is /nec/STAF/staf)
    (2) install this file as /var/svc/manifest/application/staf.xml
    (3) edit the values where edits are invited below
    (4) run "svccfg import /var/svc/manifest/application/perforce.xml"
    (5) run "svcadm enable stafd"

  It is preferable to use svccfg to change the configurable options, instead
  of editing this XML file.  It is also possible to have more than one
  Perforce server running, by adding another instance.  See the smf(5)
  man page for more details. 

  http://cemiloglu.wordpress.com

-->


<service_bundle type='manifest' name='staf-service'>
    <service
  name='application/staf/stafd'
  type='service'
  version='1'>
        
        <create_default_instance enabled='false' />
        
        <dependency
    name='network'
    grouping='require_all'
    restart_on='error'
    type='service'>
            <service_fmri value='svc:/milestone/network' />
        </dependency>
        
        <dependency
    name='filesystem'
    grouping='require_all'
    restart_on='none'
    type='service'>
            <service_fmri value='svc:/system/filesystem/local' />
        </dependency>
        
        <dependent
    name='staf-server_multi-user'
    grouping='optional_all'
    restart_on='none'>
            <service_fmri value='svc:/milestone/multi-user' />
        </dependent>
        
        <method_context>
            <method_credential user='staf' group='daemon' />
        </method_context>
        
        <exec_method
   type='method'
   name='start'
   exec='%{executables/admin} start NODAEMON'
   timeout_seconds='5'>
        </exec_method>
        
        <exec_method
   type='method'
   name='stop'
   exec='%{executables/admin} stop'
   timeout_seconds='30'>
        </exec_method>
        
        <property_group name='startd' type='framework'>
		    <!-- duration=child since STAFProc (daemon) process will indicate service availability -->
            <propval name='duration' type='astring' value='child' />
        </property_group>
        
        <property_group name='executables' type='application'>
            <propval name='admin' type='astring'   
	      value='/nec/STAF/stafd.sh' />
            <propval name='client' type='astring'
	      value='/usr/STAF/staf/bin/STAF' />
        </property_group>
        
        
        <stability value='External' />
        

        <template>
                <common_name>
                        <loctext xml:lang='C'>STAF Daemon (STAFProc)</loctext>
                </common_name>
                <documentation>
                        <doc_link name='documentation' uri='http://staf.sourceforge.net' />
                </documentation>
        </template>


    </service>
</service_bundle>

Attachment: stafd.sh
Description: stafd.sh

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to