aboutsummaryrefslogtreecommitdiff
path: root/unix/hlib/extpkg.cl
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /unix/hlib/extpkg.cl
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'unix/hlib/extpkg.cl')
-rw-r--r--unix/hlib/extpkg.cl58
1 files changed, 58 insertions, 0 deletions
diff --git a/unix/hlib/extpkg.cl b/unix/hlib/extpkg.cl
new file mode 100644
index 00000000..105dd5bf
--- /dev/null
+++ b/unix/hlib/extpkg.cl
@@ -0,0 +1,58 @@
+# Dynamic Package Loading Script
+#
+# This script is "sourced" by the standard hlib$extern.pkg file when the
+# CL is loaded to automatically define any packages installed in the
+# iraf$extern directory. Both the package definition and helpdb strings
+# are defined to include the package, negating the previous manual
+# declarations required in hlib$extern.pkg
+#
+#
+
+string curdir, extdir, dpkg
+
+extdir = osfn ("iraf$extern")
+
+# Go to the dynamic package directory, but save the current directory so
+# we can return when we're done. At this stage of the login we need to
+# use host commands since the system package isn't available.
+printf ("!pwd\n") | cl () | scan (curdir)
+chdir (extdir)
+
+# Create a file list to process.
+dpkg = mktemp ("tmp$dpkg")
+if (access (dpkg) == yes)
+ printf ("!/bin/rm -f %s\n", osfn(dpkg)) | cl ()
+;
+printf ("!/bin/ls -1ad [a-y]*\n") | cl (,> dpkg)
+
+list = dpkg
+while (fscan (list, s1) != EOF) {
+
+ # We define an environment variable for installed directories, e.g. a
+ # package support directory of data might require it's own definition.
+ # This also works to define the variable for actual package code, but
+ # we don't declare the package just yet.
+ if (access (s1) == yes &&
+ (access (s1//"/.installed") == yes ||
+ access (s1//"/"//s1//".cl") == yes)) {
+ printf ("reset %s = %s/%s/\nkeep\n", s1, osfn("iraf$extern"), s1) | cl ()
+ }
+ ;
+
+ # We assume we can dynamically load a package if there is a "foo.cl"
+ # script file in the 'foo' subdirectory.
+ if (access (s1//"/"//s1//".cl") == yes) {
+ printf ("task %s.pkg = %s$%s.cl\nkeep\n", s1, s1, s1) | cl ()
+
+ # Add to the helpdb string.
+ printf ("reset helpdb=%s,%s$lib/helpdb.mip\nkeep\n",
+ envget("helpdb"), s1) | cl ()
+ }
+ ;
+}
+
+# Clean uo and go back to the login directory.
+printf ("!/bin/rm -f %s\n", osfn(dpkg)) | cl ()
+chdir (curdir)
+
+keep