Find top-level directories according to file specificity, stow installed directories


#1

I would like to create a recipe that installs the available top-level directories
in files. For example:

files/
default/
a/

redhat/
b/

on redhat it would mean calling remote_directory with ‘a’ and
’b’, otherwise just ‘a’. How do I find the directories in
question?

I looked in node and only saw a full path in @file_filenames. I
guess I can deduce it from that given a cookbook and FILE.
Is there a way to determine in a recipe which cookbook it belongs
to?

dirs.each do |d|
remote_directory File.join("/usr/local/stow", d)
source d
end
end

After installing these directories I want to run the command stow
to create synlinks from /usr/local/stow/$package to /usr/local.
Is there a way to kick off that command only if remote_directory
actually installed something? I noticed if I add a print
statement in the below source it executes every time instead of
just when the directory updates. If the answer here is a script
via notifies how do I pass data to the script (i.e. the directory
to stow)?

/Allan

Allan Wind
Life Integrity, LLC
http://lifeintegrity.com


#2

On 2010-10-20T17:36:18, Allan Wind wrote:

I looked in node and only saw a full path in @file_filenames. I
guess I can deduce it from that given a cookbook and FILE.
Is there a way to determine in a recipe which cookbook it belongs
to?

cookbook_name (by reviewing self.methods - Object.methods).

/Allan

Allan Wind
Life Integrity, LLC
http://lifeintegrity.com


#3

On 2010-10-20T17:36:18, Allan Wind wrote:

I would like to create a recipe that installs the available top-level directories
in files. For example:

files/
default/
a/

redhat/
b/

on redhat it would mean calling remote_directory with ‘a’ and
’b’, otherwise just ‘a’. How do I find the directories in
question?

The private method preferences_for_path implements the search path, and
all public methods that make use of the former requires a
directory component.

The attribute method file_filenames (including method manifest)
dumps all files, so on can probably figure out how to extract
all unique, top-level directories, then pass each through
relative_filenames_in_preferred_directory and handle
the exception to figure out which applies.

In my case I needed to check a list of candidates so ended up
calling relative_filenames_in_preferred_directory for each and
handling the exception.

/Allan

Allan Wind
Life Integrity, LLC
http://lifeintegrity.com