Lorsqu'un package est spécifié dans la section package d'un fichier manifest, il est installé dans la zone d'image de package par le constructeur de distribution. Si vous disposez d'une autre version de ce package (votre copie privée d'un package, par exemple), vous pouvez la tester à l'aide d'un script de finalisation personnalisé. Le script de finalisation remplacera la version installée précédente du package par une version testée à partir d'un autre référentiel.
Dans le script personnalisé suivant, un serveur de référentiel IPS est en cours d'exécution sur http://localhost:10000. Le nom du package à remplacer est transmis sous forme d'argument. Le script désinstalle d'abord la version existante du package, puis installe la version testée à partir de l'autre référentiel. Ce script personnalisé indique également comment transmettre les arguments en tant qu'arguments de script de finalisation. Dans le script, notez les commentaires qui expliquent comment il réalise ces tâches.
#!/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 |