Jay's home page · Tools

mkswlinks

This is a little tool to manage a tree of symlinks to software packages.

On my home systems, I install packages into /sw/package-version. For instance, GhostScript 5.03 goes into /sw/gs-5.03, which its binaries in /sw/gs-5.03/bin, its manual pages in /sw/gs-5.03/man/man1, and so forth. However, I want symlinks to the files that make up the package from /usr/local, so that /usr/local/bin/gs is a symlink to /sw/gs-5.03/bin/gs and so forth.

This script handles that process, with a few bells and whistles:

It's also missing a lot of features one might like Most importantly, there's no support for unlinking a package (I usually do this with after checking the output of the find command to make sure it's going to delete the links I want it to, but it should be supported by the script)

Here's the script:

And here's the output of mkswlinks -h:
    Usage:
      mkswlinks [options] <package_name>
    Options:
      -h                get help
      -dest <dir>       link under <dir> instead of /usr/local
      -src <dir>        package is in <dir> rather than /sw
      -n                don't really install, just print actions
      -y                pre-answer all questions "yes"
      -q                quiet mode (don't print READMEs, etc.)
    Examples:
      mkswlinks mh-6.8.3
      mkswlinks -n tk-4.0
      mkswlinks -y -dest /usr/testing elm-2.4
  There must be a directory /sw/<package_name>.  For any well-known
  subdirectory names under <package_name> (such as bin, sbin, lib,
  etc.), that subdirectory's _contents_ will be symlinked to the
  corresponding subdirectory under /usr/local.  (For instance,
  /sw/mh-6.8.3/bin/inc would be symlinked to /usr/local/bin/inc.) Note
  that typically the contents of a packages lib directory should be
  another subdirectory, so that for instance /sw/mh-6.8.3/lib/mh-6.8.3
  will be symlinked to /usr/local/lib/mh-6.8.3 .  (man and catman
  directories are treated specially, to Do The Right Thing(TM).)

  Subdirectories under /usr/local are created as needed.

  Non-well-known subdirectories are an error, and probably mean that
  this script needs to be updated.

  If a file "link.sh" exists, it will be executed instead to create the
  links.

  If a file "install.sh" exists, the user will be given the option to
  execute it _in addition to_ making the symlinks.  This would
  typically be used to copy some of the files to local disk, e.g.  so
  there can be a copy of tcsh in /bin .

Jay Sekora <js@aq.org>
last modified 1999.12.18