NB: The following information is known to be accurate as of revision 851.

requirepackage

This is one of the key functions in the ISGScriptSetup. It allows any utility to request a particular version of a package. This is done because not only does getting an older version of a piece of software often break code, but changes in newer versions can too. For example, while much of the bash code in ~isg/bin will die in bash 2, there's a section of code (in the RSTPublicTests?) that will fail to work correctly in a bash 4 environment.

Particularly given the diversification of the computing environment in Fall 2010 with machines still running Solaris 8 and Linux, it is very important to ensure consistent package selection across environments so that any code can be reasonably expected to work on each system. By creating the most particular possible dependencies on specific packages, the scripts are also protected from being broken by changes to programs in the default PATH.

Unfortunately, this goal has not been realized; there are few resources to dedicate to installing software and a reluctance to devote them to carry forward old versions of software, even if it gives a strong assurance of stability for the ISG infrastructure. While on Solaris some of these are available in standardized Xhier paths, they were not ported to Linux via the Xhier system; instead, they have been installed in a predetermined location on the cs_build account.

The setup program automatically requires two packages as they are used extensively; the versions chosen were based on availability on Solaris 8:

  • requirepackage perl-5.8.1
  • requirepackage bash-3.0

If the package cannot be found, then it will echo to standard error a warning message that no such package was found, and the fallback default will be used if it exists. To allow the public tests runners to run on Linux without spamming courses about the missing tetex-1.0 package, there is an option to suppress error reporting, but it is very strongly recommended that it not be used in any other context. The error message will report the name of the missing package, and attempt to determine if it is being run on a system that should be officially supported so it can report whether or not a different machine should be recommended.

requirepackage () {

   # Provide a way to suppress standard error.
   # This is fairly terrible, but is necessary to avoid having
   # the public test runners mistakenly report errors on every
   # request when running on the Linux systems.
   if [ ! -z "$ISG_SETUP_NO_REQPKG_STDERR" ]; then
      exec 8>&2
      exec 2>/dev/null
   fi
   local res=""

   # NOTE: This should be a readonly constant, but we don't want
   # to pollute every commands namespace more than we already are...
   # so, make this a local variable for this function.
   local ssh_fail_ind=could_not_determine

   # Now try to find the passed in package.
   # The array must be declared on two lines or bash-3.0 will interpret it
   # as a scalar value.
   #
   # The first location to search is the standard Xhier path.
   # The second is in machine-specific installations on the cs_build account.
   #  This requires cs_build to keep following this particular convention.
   local potential_paths
   potential_paths=( "/software/$1/bin" "/u/cs_build/packages/$(uname -r -s | tr ' ' '_')/$1/bin" )

   local testpath
   for testpath in "${potential_paths[@]}"; do
      if [[ -r "$testpath" && -x "$testpath" ]]; then
         res="$testpath"
         break
      fi
   done


   if [[ -z "$res" ]]; then

      # Format an appropriate error message, dumped to stderr; attempt only
      # to do this once.
      # Use an environment variable to try to accomplish this, which will handle
      # repeat requests from parent->child, but not amongst siblings.
      if ! echo -e "$ISG_CHECKED_PACKAGES" | egrep "^$1$" > /dev/null; then
         export ISG_CHECKED_PACKAGES="$ISG_CHECKED_PACKAGES\n$1"

         echo 'WARNING: Expected package' >&2
         echo "   $1" >&2
         echo "could not be found in any of the following locations: ${potential_paths[@]}" >&2
         echo 'Relying on the default.' >&2

         # Set up these variables if they are not already.
         # Ssh can be very expensive if it hangs, so *try* only to do
         # this once by dumping things into the environment.
         if [ -z "$ISG_SETUP_INTERNAL_SOLARIS_UNAME" ] ||
            [ -z "$ISG_SETUP_INTERNAL_LINUX_UNAME" ]; then

            local timeln=2
            export ISG_SETUP_INTERNAL_SOLARIS_UNAME="$(timed_auto_ssh $timeln -o "ConnectTimeout=5" "$ISG_PREFERRED_SOLARIS" -- uname -r -s)"
            export ISG_SETUP_INTERNAL_LINUX_UNAME="$(timed_auto_ssh $timeln -o "ConnectTimeout=5" "$ISG_PREFERRED_LINUX" -- uname -r -s)"
            export ISG_SETUP_INTERNAL_LOCAL_UNAME="$(uname -r -s)"

            # Sometimes ssh can fail, which will make these variables
            # empty.  Provide some sort of substitute value.
            ISG_SETUP_INTERNAL_SOLARIS_UNAME="${ISG_SETUP_INTERNAL_SOLARIS_UNAME:-$ssh_fail_ind}"
            ISG_SETUP_INTERNAL_LINUX_UNAME="${ISG_SETUP_INTERNAL_LINUX_UNAME:-$ssh_fail_ind}"
         fi

         if [ "$ISG_SETUP_INTERNAL_LOCAL_UNAME" == "$ISG_SETUP_INTERNAL_SOLARIS_UNAME" ] ||
            [ "$ISG_SETUP_INTERNAL_LOCAL_UNAME" == "$ISG_SETUP_INTERNAL_LINUX_UNAME" ]; then
            echo "Please report what server this package is missing on ($(hostname)) if this program fails to work correctly." >&2
         else
            if [ "$ssh_fail_ind" == "$ISG_SETUP_INTERNAL_SOLARIS_UNAME" ]; then
               echo "Warning: Could not connect to $ISG_PREFERRED_SOLARIS to determine system information." >&2
               echo "Unable to determine if this is a server supported by the ISG scripts." >&2
            elif [ "$ssh_fail_ind" == "$ISG_SETUP_INTERNAL_LINUX_UNAME" ]; then
               echo "Warning: Could not connect to $ISG_PREFERRED_LINUX to determine system information." >&2
               echo "Unable to determine if this is a server supported by the ISG scripts." >&2
            else
               echo "The current server ($(hostname)) does not appear to be a server supported by the ISG scripts." >&2
               echo "Please consider using $ISG_PREFERRED_SOLARIS or $ISG_PREFERRED_LINUX." >&2
            fi
         fi
         echo >&2
      fi
   else
      # Add the package that was found to the PATH.
      pathadd "$res"
   fi

   # Restore stderr if it was suppressed above.
   if [ ! -z "$ISG_SETUP_NO_REQPKG_STDERR" ]; then
      exec 2>&8 8>&-
   fi
}
Topic revision: r1 - 2010-10-18 - TerryVaskor
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback