Search This Blog

Loading...

Wednesday, 13 March 2013

Solaris Package creation with relocation support

Solaris Packages can be created in 4 simple steps listed below:
  1. Create a pkginfo for information about your package.
  2. Create a prototype of your package to include the files which you want to ship.
  3. Make the package to make it ready to ship.
  4. Transfer the package from directory to a data stream file.
Explanation:
There are mainly 6 scripts that you can add to your package. There are some other scripts also which are used for patching. They are:
  1. request: To prompt user for input. This script will not be executed if an instance of package is already installed with instance=overwrite in /var/sadm/install/admin/default file
  2. checkinstall: Used to check whether the package is already installed or the system meets the requirements of package or to configure the installation of your package by setting environment for other scripts.
  3. preinstall: Used to configure installation according to the environment set in checkinstall script.
  4. postinstall: Used to configure installation after the installation has happened.
  5. preremove: Used to execute some pre un-installation commands like removing the new files created by the package which were not part of the package supplied.
  6. postremove: Used to execute full cleanup and other system commands like ldconfig to remove the broken links left by the package removal.
Here is an example for above steps:
# Copy all your scripts to some temp dir
cat $request > /tmp/request
cat $preinstall > /tmp/preinstall
cat $postinstall > /tmp/postinstall
cat $checkinstall > /tmp/checkinstall
cat $preremove > /tmp/preremove
cat $postremove > /tmp/postremove
cat $copyright > /tmp/copyright #for copyright message
cat $depend > /tmp/depend #for adding package names which are required for your package in format of <type> <pkg.abbr> <name>

# Create pkginfo
echo "PKG=$pkg\nNAME=$pkg\nVERSION=$ver\nARCH=$arch\nCLASSES=none\nCATEGORY=application\nVENDOR=$vendor\nPSTAMP=`date`\nEMAIL=mymail@mydomain.com\nBASEDIR=$path" > /tmp/pkginfo

# Create prototype
echo "i pkginfo\ni preinstall\ni postinstall\ni checkinstall\ni request\ni preremove\ni postremove\ni copyright\ni depend" > /tmp/Prototype
pkgproto $path/$pkg=$pkg >> /tmp/Prototype

# For creating relocatable packages
sed -i "s:$path:\$BASEDIR/:g" /tmp/Prototype # Only path represents a variable in this command.

# Make package
#if the package is relocatable then supply "BASEDIR=$path" in below command
pkgmk -o -r / -d /tmp -f /tmp/Prototype


# Transfer the package
cd /tmp
pkgtrans -s `pwd` /tmp/$pkgfile $pkg

Tips:
  1. You can use any temporary directory just replace /tmp with your choice.
  2. You can set the file permissions  before creating a prototype file.
  3. You can use your custom prototype file for file mappings pointing to files in specific directory. for e.g. : i pkginfo=/home/user/mysrc/pkginfo.
  4. You can use your own custom prototype file to define the file permissions also.
Note: All word starting with $ are variables use them as per you choice.

Building gcc 4.1.2 on solaris 10



Solaris by default comes with gcc 3.4.3 and binutils 2.15. Follow the following steps to build gcc 4.1.2 on solaris 10:
PreBuild:

  1. Use ksh shell
  2. export CONFIG_SHELL=/usr/bin/ksh
  3. Copy/Create links to all gnu tools into one directory and remember to remove letter 'g' from the prefix of the name of executable.
  4. export PATH=/Mytools/binutils_2_18/bin:/gnutools:/sbin:/bin:/usr/bin:/usr/ccs/bin:/usr/sfw/bin
  5. export CC="/usr/sfw/bin/gcc -fPIC"
  6. export CXX="/usr/sfw/bin/g++ -fPIC"

Build:

  1. Install/Build gnu binutils version 2.18 using gcc 3.4.3(available in solaris by default).
  2. cd gcc_source_dir
  3. mkdir objdir && cd objdir
  4. ../configure --with-gnu-as --with-as=/binutils_2_18/bin/as --with-gnu-ld --with-ld=/binutils_2_18/bin/ld --prefix=$PREFIX --enable-threads=posix --enable-checking=release --with-system-zlib --enable-shared --disable-symvers --enable-languages=c,c++
  5. gmake #referring to gnu make
  6. gmake install