2

I need to move multiple symlinks within a VOB in a dynamic view.

As described in my previous question, this is not as trivial as it sounds (to me), as the target path is saved relative to the link itself and not to the VOB root or anything like that. This wouldn't be a big issue, if ClearCase would adjust the path information in those links, but appearantly, it does not.

Details: Let's assume following folder structure:

/myVOB
  /Originals
  /LinksA
    /SubDir
  /LinksB

Then moving a link to the file myVOB/Originals/readme.txt that is located in myVOB/LinksB to myVOB/LinksA/SubDir will prevent the link to find its target, as it is looking for myVOB/LinksA/SubDir/../Originals/readme.txt.

Does anyone know if it is possible to tell ClearCase to adjust the paths when moving symlinks? Usually I would think this should be done out of the box, but one never knows with ClearCase... Nevertheless, perhaps someone could try to reproduce this and tell me if it succeeded or not, perhaps it's just a bug on my system?

Edit: OK, so it looks like moving relative symlinks is not supported out-of-the-box. Would I need to move a great number of symlinks, I'd be writing a script right now that took a number of files/directories and moved them to a new location. If it encountered a symlink (whose target may be a file or directory) it would not just call cleartool mv or whatever, but follow the procedure as posted by VonC.

But I don't, so I'll probably do this by hand. Perhaps someone already wrote such a script, then this would be the right place to promote it ;)

Community
  • 1
  • 1
SvenS
  • 795
  • 7
  • 15
  • You might care to look at [Convert absolute path into relative path](http://stackoverflow.com/questions/2564634/bash-convert-absolute-path-into-relative-path-given-a-current-directory/2565049#2565049) for tools to help with manipulating relative paths and absolute paths. – Jonathan Leffler Sep 15 '11 at 07:01
  • Thanks, this may be of help to anyone writing the mentioned script (though I don't plan to do that myself ^^). Though, specific to clearcase, one could surely just get the target path of the symlink to move and tell cleartool to create a new symlink to that target in the destination directory. So the new relative path will be provided by cleartool. – SvenS Sep 15 '11 at 07:40

1 Answers1

3

If you consider this technote on "How to Manage symbolic links in ClearCase interop, it seems that:
(even if you aren't in an interop environment, ie even if your Windows views and Vob server are both on Windows)

  • symlinks are using primary relative path
  • you must recreate them if the target path change.

How to change a VOB symbolic link path

The only way to revise a VOB symbolic link to a relative path is to create a new symbolic link:

Note: You cannot edit (revise) a VOB symbolic link if it has been created using an absolute path to utilize a relative path.

-Check out the directory - Remove the old VOB link using the cleartool rmelem command - Create a new link with the same name

Example:

cleartool ln -slink -nc ../../same_file_name.txt
Check in the directory

Notes:

It is recommended that you use relative VOB symbolic links instead of absolute symbolic links.
The absolute VOB symbolic link requires you to use absolute path names from the view-tag level, for example, \view-tag\VOB-tag\filename.
Hence, they are valid only in the view in which they were created.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks as always @VonC. "The only way to revise a VOB symbolic link [...] is to create a new symbolic link", this basically says "symlinks cannot be moved, they need to be deleted at the source and recreated at the destination". I've adjusted my question to specifically ask for a workaround. – SvenS Sep 15 '11 at 06:55
  • @SvenS: you're welcome. I don't however know of an easy workaround when working with symlinks with changed targets. – VonC Sep 15 '11 at 07:39
  • Yeah, my only idea would be to automate the process with cleartool that I'm going to go through manually in the GUI: Lookup the target, create another symlink to the new folder, delete the old symlink. I'll be done with this in half an hour (and don't know cleartool too well), so it's no use writing a script myself. – SvenS Sep 15 '11 at 07:47