diff options
-rwxr-xr-x | scripts/ac_build_iraf_pkg | 152 | ||||
-rw-r--r--[-rwxr-xr-x] | scripts/ac_install_iraf_pkg | 36 | ||||
-rw-r--r-- | scripts/iraf_defs | 6 |
3 files changed, 185 insertions, 9 deletions
diff --git a/scripts/ac_build_iraf_pkg b/scripts/ac_build_iraf_pkg new file mode 100755 index 0000000..8c8024b --- /dev/null +++ b/scripts/ac_build_iraf_pkg @@ -0,0 +1,152 @@ +#!/bin/sh + +# Copy external IRAF package source from the current working directory to +# $PREFIX/iraf_extern/package_name, add any configuration files from the conda +# recipe (eg. ur_extern.pkg), update extern.pkg accordingly, compile the +# package and its help in place and remove any proprietary files. The build is +# done using the installed copy since the package and its dependencies must +# already be defined in IRAF at build time and IRAF packages are installed as a +# source tree anyway. +# +# This script is used by the AstroConda build process (with no arguments and +# the usual conda build variables set). Users wanting pre-built AstroConda IRAF +# packages should install them with "conda install" or "conda create" instead. + +# Determine the directory this script lives in (for later use) and source some +# common name definitions from the same place: +script_dir=`dirname "$0"` +script_dir=`cd "$script_dir" && pwd` # canonical version of path +. "$script_dir/iraf_defs" + +# The parameters are effectively conda build variables, which must be set here: +if [ -n "$1" -o -z "$PREFIX" -o -z "$RECIPE_DIR" -o -z "$PKG_NAME" ]; then + echo "ERROR: `basename "$0"` should be called via \"conda build\"" >&2 + echo " (with no arguments), to define the necessary environment" >&2 + exit 1 +fi + +# IRAF must also be defined in the environment: +if [ -z "$iraf" -o -z "$IRAFARCH" ]; then + echo "ERROR: must configure IRAF environment (. setup_iraf.sh)" >&2 + exit 1 +fi + +# These conda-set variables could interfere with building IRAF packages: +unset ARCH CFLAGS CXXFLAGS LDFLAGS MACOSX_DEPLOYMENT_TARGET + +# Create any new dirs & files with the expected permissions: +umask 022 + +# Strip any "iraf." from the Conda package name, to get the IRAF equivalent +# and determine the installation path accordingly: +pkg_name=`echo "$PKG_NAME" | sed -e 's|^iraf[.]||'` +pkg_path="${PREFIX}/${extern_dir}/${pkg_name}" + +# Create the destination directory, if needed: +if ! mkdir -p "$pkg_path"; then + echo "ERROR: failed to create $pkg_path" >&2 + exit 1 +fi + +# Ensure the destination is writeable (a bit redundant but clearer than the +# subsequent message would be for this case): +if [ ! -w "$pkg_path" ]; then + echo "ERROR: cannot write to $pkg_path" >&2 + exit 1 +fi + +# Copy the package source (CWD contents) to its destination: +if ! tar cf - ./ | (cd "$pkg_path" && tar xf -); then + echo "ERROR: failed to copy source to $pkg_path" >&2 + exit 1 +fi + +# Add package configuration files from the recipe (overwriting any copies +# already in the tarball; any source patches should already have been added +# separately by conda): +for file_name in $ac_iraf_files; do + file_path="${RECIPE_DIR}/${file_name}" + if [ -r "$file_path" ]; then + if ! cp -pf "$file_path" "$pkg_path"/; then + echo "ERROR: failed to copy $file_name to $pkg_path" >&2 + exit 1 + fi + fi +done + +# Define the new package in the (temporary build-time) extern.pkg: +if ! "$script_dir/update_extern_pkg" "$PREFIX" "$pkg_name"; then + echo "ERROR: failed to update $extern_pkg" >&2 + exit 1 +fi + +# Continue working in the destination directory: +cd "$pkg_path" || exit 1 # (failure would have to be 1-off race condition...) + +# Remove any bin directories that aren't needed for this IRAF architecture and +# ensure we do have those that are needed: +rm -fr bin.* +mkdir bin.generic "bin.$IRAFARCH" +if [ -L bin ]; then # apart from being safer, there is a bin/ dir in mscdb + rm -f bin + ln -s "bin.$IRAFARCH" bin +fi + +# Enable compilation with debugging symbols (from the STScI IRAF "make_all"): +export XC_LFLAGS="-g $XC_LFLAGS" + +# Compile the package source, either as specified by the recipe or as usual: +file_path="${RECIPE_DIR}/${pkg_mkpkg_cmd}" +if [ -r "$file_path" ]; then + sh "$file_path" > "$log_name" 2>&1 + st=$? +else + # This is an IRAF convention that usually applies but doesn't always: + mkpkg -p "$pkg_name" update > "$log_name" 2>&1 + st=$? +fi + +# Although mkpkg doesn't return a useful exit status, check whether it failed +# to run (IRAF not set up properly) or a ur_mkpkg_cmd script complained etc.: +if [ $st -ne 0 ]; then + echo "ERROR: compilation command failed" >&2 + exit 1 +fi + +# Check that the build appears to have succeeded: +if ! "$script_dir/check_iraf_pkg_build" ./ ; then + echo "ERROR: package build apparently failed" >&2 + exit 1 +fi + +# Generate the help & apropos databases using the appropriate IRAF tasks, via +# PyRAF (past attempts to do this using cl have crashed intermittently): +file_path="${RECIPE_DIR}/${pkg_mkhelp_cmd}" +if [ -r "$file_path" ]; then + sh "$file_path" > "$help_log_name" 2>&1 + st=$? +else + # This is an IRAF convention that usually applies but doesn't always: + "$script_dir/make_helpdb" "$pkg_name" > "$help_log_name" 2>&1 + st=$? +fi + +if [ $st -ne 0 ]; then + echo "ERROR: failed to generate help databases" >&2 + exit 1 +fi + +# Ensure all files are readable (eg. binaries sometimes get odd --x perms): +chmod -R +r . + +# Delete any proprietary source code from the build: +if [ -r "$pkg_omit_list" ]; then + if ! "$iraf/util/de_numrec" "$pkg_omit_list" >> "$log_name" 2>&1; then + echo "ERROR: removal of proprietary source files failed" >&2 + exit 1 + fi +fi + +# Ensure status=0 on reaching the end (& not left over from some condition). +exit 0 + diff --git a/scripts/ac_install_iraf_pkg b/scripts/ac_install_iraf_pkg index 6d0ee39..6032fe3 100755..100644 --- a/scripts/ac_install_iraf_pkg +++ b/scripts/ac_install_iraf_pkg @@ -2,27 +2,35 @@ # Copy external IRAF package source from the current working directory to # $PREFIX/iraf_extern/package_name, add any configuration files from the conda -# recipe (eg. ur_extern.pkg) and update extern.pkg accordingly. This is -# normally done *before* building the package in place, since it (and its -# dependencies) already have to be defined in IRAF at build time and the source -# gets distributed anyway. +# recipe (eg. ur_extern.pkg), update extern.pkg accordingly, compile the +# package in place and remove any proprietary files. The build is done using +# the installed copy since the package and its dependencies must already be +# defined in IRAF at build time and IRAF packages are installed as a source +# tree anyway. # # This script is used by the AstroConda build process; users wanting pre-built # AstroConda IRAF packages should instead install them with "conda install" or # "conda create". -# Source some common IRAF package defs (and later other scripts) from the -# same directory as this one: +# Determine the directory this script lives in (for later use) and source some +# common name definitions from the same place: script_dir=`dirname "$0"` -script_dir=`cd "$script_dir"; pwd` # canonical version +script_dir=`cd "$script_dir" && pwd` # canonical version of path . "$script_dir/iraf_defs" +# The parameters are effectively conda build variables, which must be set here: if [ -n "$1" -o -z "$PREFIX" -o -z "$RECIPE_DIR" -o -z "$PKG_NAME" ]; then echo "ERROR: `basename "$0"` should be called via \"conda build\"" >&2 echo " (with no arguments), to define the necessary environment" >&2 exit 1 fi +# IRAF must also be defined in the environment: +if [ -z "$iraf" -o -z "$IRAFARCH" ]; then + echo "ERROR: must configure IRAF environment (. setup_iraf.sh)" >&2 + exit 1 +fi + # Create any new dirs & files with the expected permissions: umask 022 @@ -68,6 +76,20 @@ if ! "$script_dir/update_extern_pkg" "$PREFIX" "$pkg_name"; then exit 1 fi +# Continue working in the destination directory: +cd "$pkg_path" || exit 1 # (failure would have to be 1-off race condition...) + +# Remove any bin directories that aren't needed for this IRAF architecture and +# ensure we do have those that are needed: +rm -fr bin.* +mkdir bin.generic "bin.$IRAFARCH" +if [ -L bin ]; then # apart from being safer, there is a bin/ dir in mscdb + rm -f bin + ln -s "bin.$IRAFARCH" bin +fi + # Ensure status=0 on reaching the end (not some left-over condition value). exit 0 +# This won't get picked up until checked in! + diff --git a/scripts/iraf_defs b/scripts/iraf_defs index 2f7ea1b..fe5aca8 100644 --- a/scripts/iraf_defs +++ b/scripts/iraf_defs @@ -9,11 +9,13 @@ pkg_manifest="ur_manifest" pkg_patterns="ur_mkpkg_patterns" pkg_mkpkg_cmd="ur_mkpkg_cmd" pkg_mkhelp_cmd="ur_mkhelp_cmd" +pkg_omit_list="numrec_list.txt" log_name="build_log" err_log_name="build_log.errors" +help_log_name="help_log" -# Files to copy from the recipe to the build: +# Files to copy from the recipe to the build (if present): ac_iraf_files="$pkg_extpkg $pkg_manifest $pkg_patterns $pkg_mkpkg_cmd\ - $pkg_mkhelp_cmd" + $pkg_mkhelp_cmd $pkg_omit_list" |