Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to skip outermost directory entry in cptofs #297

Closed
copumpkin opened this issue Jan 16, 2017 · 8 comments
Closed

Option to skip outermost directory entry in cptofs #297

copumpkin opened this issue Jan 16, 2017 · 8 comments

Comments

@copumpkin
Copy link

copumpkin commented Jan 16, 2017

Given my last ticket #296, I decided to instead copy my target filesystem into a temporary folder and then bulk cptofs from that temporary folder into the root of the target image. Unfortunately, cptofs insists (as far as I could tell) on putting the outermost directory in the root. So for example if I create $TMP/target-root and then put bin, etc, and so on into there. Then calling cptofs ... $TMP/target-root / will put everything into /target-root, which isn't what I want.

@copumpkin
Copy link
Author

I'm willing to write a PR to fix this but am not sure of how best to do it without changing the general shape of the directory traversal code. Open to suggestions if anyone more familiar with the code can see a trivial fix 😄

@copumpkin
Copy link
Author

copumpkin commented Jan 16, 2017

I can see a not-terribly-shitty way to do it by adding a boolean parameter to searchdir and do_entry, and then setting that boolean at the outermost level and not setting it in recursive calls, based on a command-line flag. Still feels a bit hacky though.

@copumpkin
Copy link
Author

#298 sort of addresses this by letting me write foo/* as a source and having the shell take care of doing the outermost expansion

@tavip
Copy link
Member

tavip commented Jan 18, 2017

@copumpkin I think this is the correct behavior, cp -r does the same.

@copumpkin
Copy link
Author

@tavip not quite though: if I call cp -r foo dest it behaves differently from cp -r foo/ dest. The latter skips the outermost entry, whereas the former copies it too.

@copumpkin
Copy link
Author

@tavip
Copy link
Member

tavip commented Jan 18, 2017

Perhaps that's just a darwin thing though? http://serverfault.com/questions/11518/recursive-cp-copies-folder-contents-instead-of-folder-on-os-x

I think so since on my Linux machine cp -r foo dest and cp -r foo/ dest both copy the folder.

@copumpkin
Copy link
Author

I see. That's probably more sensible either way. Now that we support multiple source arguments, this issue should be roughly equivalent to using foo/* as a source anyway (unless you're copying a massive directory that exceeds the argument limit, which is unlikely), so I'll close for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants