Distrib Distributes Files?
If it seems that I've downplayed the use of distrib to
actually distribute files, that's deliberate. Most casual users
know it will do that, but they might not understand how it works.
The hope is that the preceding sections have outlined the steps
involved well enough that the read understands the default actions
and how they can be modified. Let's run it down again from an
aerial view.
What Does Distrib Do?
As we have seen, distrib:
- Selects machines (lines in a configuration file). The
configuration file is the first of these that exists:
- The file specified by the -C option. If its name ends in
".mcf", it is first processed by m4.
- distrib.mcf in the current directory- after it's run
through m4
- distrib.cf in the current directory
- distrib.mcf in distrib's library path (run it -V
to see where that is- it's compiled in)- after it's run through
m4
- distrib.cf in distrib's library path (run it -V
to see where that is- it's compiled in)
- If you don't have one, it won't work, but there should be one
installed in the library directory.
- The machines selected are either the default set (or a
modification thereof) or the machines specified.
- If -a is given, the set is all the machines and could be
further modified (anded) by other options, but it's redundant in
those cases.
- If -m is given, only the specified machine is selected by
HOST.
- If -t is given, only machines with HOSTTYPE of one of the
specified types are selected. This set can be modified by other
options (-S, -G, explicit list of HOSTs).
- If none of the above options or -S or a list of HOSTs is given,
the default set is selected. The default set is all the machines
having HOSTTYPE the same as MYTYPE (which is compiled in to
distrib and can be seen with -V), except for the
current machine (the one that distrib is running on). This
set can only be modified by -I which also includes the current
machine.
- By itself, -S specifies all the machines that have HASSRC
defined. It can modify other sets as well as be modified by other
modifiers (-t, -G, explicit list of HOSTs).
- Modifiable sets can be modified with arbitrary m4 code
by use of the -G option. By itself, it specifies all machines that
match the m4 code. (It doesn't use the default set, even if
-I is specified.)
- A list of HOSTs can be given. This can be modified as well
(though distrib will whine about it).
- For each selected machine:
- Macros are set. These come from:
- The -D option to distrib
- Any macros set by an assignment that are in effect for that
line
- Any items in columns on the selected line (machine)
- With these macros set, m4 (M4_PATH from the environment
or the compiled in path) is run on the Distfile. That Distfile is
used for all the selected machines and is the first of:
- A degenerate file containing just "HOST" if you give
distrib the -H option.
- The command line as a Distfile if the -c option is given. This
is similar to the behavior of rdist. If only one argument is
given, "HOST" is added. A special line can be added with
distrib's -s option.
- The file specified by distrib's -f option. This could be
"-" for stdin
- "Distfile" in the current directory
- "distfile" in the current directory
- If those aren't found, you'll get an error
- If distrib thinks the Distfile is really an rdist
Distfile because of its name being "Distfile" or "distfile", or
because -c or -F was given, any files with names quoted by '@' are
run through m4 with the same macros used for the Distfile.
These processed files are stored in /tmp and their names are used
in the Distfile in place of the original files' names. The
processed files are made with the same modes as the originals so
rdist will do the right thing.
- Then distrib takes an action:
- Prints the processed Distfile to stdout if -E is
given.
- Otherwise, it runs RDIST_PATH from the currently defined
macros, or the environment, if it's set either place, else it runs
rdist from the compiled-in location. The options passed to
this program are mostly the remaining options of distrib and
the right stuff to make it use the correct Distfile (from
stdin or the command line).
- Finally, distrib cleans up any temporary files it
made.