[Cook] Scratch directory/file creation and cleanup

Fredrick Paul Eisele phreed at netarx.com
Sat Aug 3 04:13:59 EST 2002


I need to create a temp directory within a rule.
I have a function ...

function workdir = {
  local PREFIX = [@1];
  local COMMAND = [catenate
      "use File::Temp;"
      "print File::Temp::tempdir( \"" [PREFIX] "-XXXXX\" , DIR => 
\"/tmp\");"
      ];
return [collect /usr/bin/perl -e \'[COMMAND]\'];
}

which is called from a rule

a: b { local WIP = [workdir "ABC-"];  rm -rf [WIP]; }

The funny thing is even though the rule only fires once the function 
gets run twice.
This means the the first temporary directory doesn't get removed when 
cook is done.
First, what is causing this behavior?
Second, how can I prevent the first directory from being created?

Does cook provide a mechanism for creating unique temporary 
directories/files?






More information about the Cook-users mailing list