Re: Re: CHEF-2398 : adding a cwd attr to the link resource


#1

Joseph Holsten joseph@josephholsten.com writes:

Could you explain why this is useful? I haven’t used them in ages, so I can’t
remember what they’re good for (besides surprising me).

In particular, I have no idea what the example in the ticket is supposed to
do.

Hi

the example in the ticket is supposed to maintain a symbolic link in
/boot called “linux” with a relative reference to “linux-3.0.0”

to make it simple, can you see the difference between:

  1. ln -s /boot/linux-3.0.0 /boot/linux
    vs
  2. cd /boot; ln -s linux-3.0.0 linux

My bootloader doesn’t mount the device on /boot when booting, in that
case the absolute reference is unresolvable, that why I’m making it
relative.

but it could also be:

  1. ln -sf /home/laurent/Private/.chef /home/laurent/
    vs
  2. cd /home/laurent; ln -sf Private/.chef .chef

The symbolic links (with absolute reference) in my homedir won’t
survive if my home dir is moved to /home/users/l/laurent. In that case
the /home/users/l/laurent/.chef symlink would point to nonexistent
/home/laurent/Private/.chef

Does that make sense ?


#2

On Apr 15, 2012, at 12:50 , Laurent Desarmes wrote:

Could you explain why this is useful? I haven’t used them in ages, so I can’t
remember what they’re good for (besides surprising me).

In particular, I have no idea what the example in the ticket is supposed to
do.

Hi

the example in the ticket is supposed to maintain a symbolic link in
/boot called “linux” with a relative reference to “linux-3.0.0”

to make it simple, can you see the difference between:

  1. ln -s /boot/linux-3.0.0 /boot/linux
    vs
  2. cd /boot; ln -s linux-3.0.0 linux

You don’t need to chdir(), 1) is equivalent to in -s linux-3.0.0 /boot/linux

Relative symlinks are relative to the directory where the symlink is placed, not getcwd.

You can use Pathname#relative_path_from to make the calculations for you:
1.9.2p290 :003 > Pathname.new(’/boot/linux-3.0.0’).relative_path_from(Pathname.new(’/boot/linux’).dirname)
=> #Pathname:linux-3.0.0


#3

Maciej Pasternacki maciej@pasternacki.net writes:

On Apr 15, 2012, at 12:50 , Laurent Desarmes wrote:

Could you explain why this is useful? I haven’t used them in ages, so I can’t
remember what they’re good for (besides surprising me).

In particular, I have no idea what the example in the ticket is supposed to
do.

Hi

the example in the ticket is supposed to maintain a symbolic link in
/boot called “linux” with a relative reference to “linux-3.0.0”

to make it simple, can you see the difference between:

  1. ln -s /boot/linux-3.0.0 /boot/linux
    vs
  2. cd /boot; ln -s linux-3.0.0 linux

You don’t need to chdir(), 1) is equivalent to in -s linux-3.0.0 /boot/linux

  1. you meant.

Relative symlinks are relative to the directory where the symlink is placed, not getcwd.

yep that’s correct. (don’t know about win32)
I’ll have a look this evening, thanks.
(my patch doesn’t fix the issue at all anyway…)


Laurent


#4

On Apr 15, 2012, at 13:38 , Laurent Desarmes wrote:

Could you explain why this is useful? I haven’t used them in ages, so I can’t
remember what they’re good for (besides surprising me).

In particular, I have no idea what the example in the ticket is supposed to
do.

Hi

the example in the ticket is supposed to maintain a symbolic link in
/boot called “linux” with a relative reference to “linux-3.0.0”

to make it simple, can you see the difference between:

  1. ln -s /boot/linux-3.0.0 /boot/linux
    vs
  2. cd /boot; ln -s linux-3.0.0 linux

You don’t need to chdir(), 1) is equivalent to in -s linux-3.0.0 /boot/linux

  1. you meant.

You’re right.

On Linux (and probably other Unices) it works with Chef as well - I’ve got this in my cookbooks:

ree doesn’t leave a versioned binary, which makes rake use system one.

link “/usr/local/bin/ruby1.8” do
to "ruby"
end

– M