Skip Navigation Links | |
Exit Print View | |
Oracle Solaris 11 Express Distribution Constructor Guide Oracle Solaris 11 Express 11/10 |
1. Introduction to the Distribution Constructor
2. Design and Build Oracle Solaris Images
3. x86: Design and Build a Virtual Machine
A. Custom Finalizer Scripts, Examples
When a particular package is specified in the package section of a manifest file, that package is installed in the package image area by the distribution constructor. If you have an alternate version of this package, such as your own private copy of a package, you could test this version of the package by using a custom finalizer script. The finalizer script would replace the previously installed version of the package with a test version from an alternate repository.
In the following custom script, an IPS repository server is running on http://localhost:10000. The name of the package to replace is passed as an argument. The script first uninstalls the existing version of the package, then installs the test version from the alternate repository. This custom script also demonstrates how to have arguments passed in as finalizer script arguments. Note the comments in the script that explain how the script accomplishes these tasks.
Example A-2 Sample Script for Testing Packages
#!/bin/ksh # # # Name: # test_my_pkg # # Description: # This script will build an image using my test package # from my local repository. # # Args: # # These Arguments are passed in by default from the DC. # # MFEST_SOCKET: Socket needed to get manifest data via ManifestRead object \ # (not used in this example) # PKG_IMG_PATH: Package image area # TMP_DIR: Temporary directory # BR_BUILD: Area where boot archive is put together (not used in this example) # MEDIA_DIR: Area where the media is put (not used) # TEST_PKG: Package to replace with one from the test repo # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if [ "$#" != "6" ] ; then print -u2 "Usage: $0: Requires 6 args:" print -u2 " Reader socket, pkg_image area, tmp dir," print -u2 " boot archive build area, media area, pkg_name" exit 1 fi PKG_IMG_PATH=$2 if [ ! -d $PKG_IMG_PATH ] ; then print -u2 "$0: Image package area $PKG_IMG_PATH is not valid" exit 1 fi PKGCMD="/bin/pkg" #The test packages are passed in as arguments to this finalizer script #You would have specified the argument like this in the finalizer section #to pass in the argument # # # <finalizer> # <script name="/my/update_my_pkg_test"> # <checkpoint name="update-pkg" message= \ "Replaces an existing package with my own"/> # <argslist> # "SUNWcdrw" # </argslist> # </script> # </finalizer> # TEST_PKG=$6 # Assume that my test package resides in #a repository running on port 10000 of the localhost. # Specify alternate repository URL add_url="http://localhost:10000" # Specify alternate repository authority add_auth="MY_TEST" # Check if authority is already set in the package image area, if not, # add it in added_authority=0 ${PKGCMD} -R $PKG_IMG_PATH authority $add_auth > /dev/null 2>& 1 if [ $? != 0 ] ; then ${PKGCMD} -R $PKG_IMG_PATH set-authority -O ${add_url} ${add_auth} if [ $? != "0" ] ; then print -u2 "$0: Unable to set additional authority" exit 1 fi added_authority=1 fi if [ $? != "0" ] ; then print -u2 "$0: Unable to set additional authority" exit 1 fi # Remove the package that's currently in the package image area. ${PKGCMD} -R $PKG_IMG_PATH uninstall ${TEST_PKG} if [ $? != "0" ] ; then print -u2 "$0: Unable to uninstall ${TEST_PKG}" exit 1 fi # Install the package from test repo pkg_name="pkg://${add_auth}/${TEST_PKG}" ${PKGCMD} -R $PKG_IMG_PATH install ${pkg_name} if [ $? != "0" ] ; then print -u2 "$0: Unable to install ${pkg_name}" exit 1 fi # if we have added the additional authority, unset it so it doesn't pollute what's # originally there if [ $added_authority == 1 ] ; then ${PKGCMD} -R $PKG_IMG_PATH unset-authority ${add_auth} fi exit 0