Temp directory for use with script resources?


#1

Quite a few of my more ad hoc recipes involve downloading a *.tar.gz
from some location (or via cookbook_file), and then performing some
random operation on it. (Like uncompressing it and copying part of it
to another location, or installing via ./configure && make && make
install.)

Is there a recommended directory to perform these activities?
Sometimes I use /tmp, and sometimes Chef::Config[:file_cache_path],
but I’m not that happy with either…

Ideally, some directory would be provided that’s guaranteed to exist,
be writable, and empty, and that is cleaned if the recipe completes
successfully, but left alone if not.

Michael


#2

Check out the Dir ruby class. It has a ::tmpdir method that returns the operating system’s temporary file path. Also ::mktmpdir will create a subdirectory under ::tmpdir for you.

–Dang Nguyen

On 8/28/12 10:39 AM, “Michael Stillwell” <mjs@beebo.orgmailto:mjs@beebo.org> wrote:

Quite a few of my more ad hoc recipes involve downloading a *.tar.gz
from some location (or via cookbook_file), and then performing some
random operation on it. (Like uncompressing it and copying part of it
to another location, or installing via ./configure && make && make
install.)

Is there a recommended directory to perform these activities?
Sometimes I use /tmp, and sometimes Chef::Config[:file_cache_path],
but I’m not that happy with either…

Ideally, some directory would be provided that’s guaranteed to exist,
be writable, and empty, and that is cleaned if the recipe completes
successfully, but left alone if not.

Michael


#3

If it’s for compilation and Linux I generally use /usr/local/src.

On Tuesday, August 28, 2012 at 10:39 AM, Michael Stillwell wrote:

Quite a few of my more ad hoc recipes involve downloading a *.tar.gz
from some location (or via cookbook_file), and then performing some
random operation on it. (Like uncompressing it and copying part of it
to another location, or installing via ./configure && make && make
install.)

Is there a recommended directory to perform these activities?
Sometimes I use /tmp, and sometimes Chef::Config[:file_cache_path],
but I’m not that happy with either…

Ideally, some directory would be provided that’s guaranteed to exist,
be writable, and empty, and that is cleaned if the recipe completes
successfully, but left alone if not.

Michael


#4

Have you looked at the ‘ark’ cookbook? It manages archives.
http://ckbk.it/ark

It may do what you want, and uses Dir.mktmpdir.
https://github.com/opscode-cookbooks/ark/blob/master/libraries/provider_ark.rb#L235

-Mike

On Tue, Aug 28, 2012 at 1:39 PM, Michael Stillwell mjs@beebo.org wrote:

Quite a few of my more ad hoc recipes involve downloading a *.tar.gz
from some location (or via cookbook_file), and then performing some
random operation on it. (Like uncompressing it and copying part of it
to another location, or installing via ./configure && make && make
install.)

Is there a recommended directory to perform these activities?
Sometimes I use /tmp, and sometimes Chef::Config[:file_cache_path],
but I’m not that happy with either…

Ideally, some directory would be provided that’s guaranteed to exist,
be writable, and empty, and that is cleaned if the recipe completes
successfully, but left alone if not.

Michael