in reply to Re^5: Getting all subpaths from a path
in thread Getting all subpaths from a path

Would it be correct to assume you have access to the filesystem where these files are located? In other words, the Perl script, the input list of files, and the files themselves are all on the same machine?

Yes.

It's also still unclear to me if you want to mirror the files exactly as they are on the host machine, or if you want to manipulate the paths in any way?

Exactly the same.

Anyway, your code is exactly what I need, especially the first part ("gather all dirs, files, and links"). It's a good start. I have only one question for now. For that I will use the example I presented in the first post:
I have a path: /usr/vsa/pkgs/python3/3.6.3a/bin/python3.6. There are two links in the path:
/usr/vsa -> /root/site/tools/gauv /usr/vsa/pkgs/python3/3.6.3a -> 3.6.3
With your code I get three links:
ln -snf /root/site/tools/gauv /usr/vsa ln -snf 3.6.3 /usr/vsa/pkgs/python3/3.6.3a ln -snf 3.6.3 /root/site/tools/gauv/pkgs/python3/3.6.3a
For the second link I get an error:
ln: failed to create symbolic link '/usr/vsa/pkgs/python3/3.6.3a': No +such file or directory which is correct
Which makes sense since '/usr/vsa/pkgs/python3/3.6.3a' is not a realpath (even though I can access this path since it has a link on the way). Uncommenting this line works to build the recipe since this link is unnecessary because the third one is the correct one (it does what the second one wants to do). How can I "ignore"/"remove" those kind of links from %links?

Replies are listed 'Best First'.
Re^7: Getting all subpaths from a path
by haukex (Archbishop) on Apr 03, 2021 at 08:13 UTC
    For the second link I get an error: ln: failed to create symbolic link '/usr/vsa/pkgs/python3/3.6.3a': No such file or directory

    I can't reproduce this. To create a test directory structure I tried:

    mkdir -p /tmp/site/tools/gauv/pkgs/python3/3.6.3/bin/python3.6 ln -fns /tmp/site/tools/gauv /tmp/vsa ln -fns 3.6.3 /tmp/site/tools/gauv/pkgs/python3/3.6.3a

    And running my script with /tmp/vsa/pkgs/python3/3.6.3a/bin/python3.6 as the input produces this output:

    mkdir -p /tmp/site/tools/gauv/pkgs/python3/3.6.3/bin/python3.6 ln -snf /tmp/site/tools/gauv /tmp/vsa ln -snf 3.6.3 /tmp/vsa/pkgs/python3/3.6.3a ln -snf 3.6.3 /tmp/site/tools/gauv/pkgs/python3/3.6.3a

    Which looks like the output you've shown (minus the mkdir command, which you are running first, right?). And if I delete /tmp/site and /tmp/vsa, the above set of commands work fine. I can only guess that perhaps there's a permissions issue (/root often has restrictive permissions set). I also noticed an inconsistency in the example you give in the root node: your example array of subpaths ends on /root/site/tools/gauv/python3/3.6.3/bin/python3.6, which is missing the pkgs from its path. I did not test my code in the presence of broken symlinks.

    Something doesn't add up. I've asked several times now for code, input, and output to reproduce the questions you have. Please read and understand all of the following, and provide actual, runnable code that reproduces the issue you're having, along with representative sample input, the expected output for that input, and the complete actual output, including any error messages.