Tar: is there a way to exclude directories whose name match a given regex? - tar

More specifically, I have a workspace directory containing several coding projects, which in turn contain node_module directories. I want to create a tar.gz of my workspace while excluding all node_module directories, but when I try something like:
tar -cvzf projects.tar.gz projects/ --exclude="node_modules"
It does not exclude any of the node_modules subdirectories. Is there a way to do this?
Thank your for your help

Related

Keep directory structure in Copy Files Build Phase in XCode

In XCode 11.7, when I add a Copy Files build phase, it only allows me to select files, not directories, and while I can select files from within sub-directories, they all get mashed together into the top-level.
I can work around it by adding multiple Copy Files phases with a different subpath so that the structure ends up correct, but this is tedious and feels wrong.
Is there a better way to make the output directory structure of Copy Files match the input?
I figured out how to do it - instead of a Copy Files phase, I added a Run Script phase and used the cp -R command.
In my case, I wanted to copy a TargetApp/www folder to the "Wrapper" (root of the app), so my full script is:
echo "copying $SRCROOT/TargetApp/www to $TARGET_BUILD_DIR/$CONTENTS_FOLDER_PATH"
cp -R "$SRCROOT/TargetApp/www" "$TARGET_BUILD_DIR/$CONTENTS_FOLDER_PATH"

Recursively ignore directory by name using .tfignore

I have the following folder structure:
foo1/
node_modules/
foo2/
node_modules/
bar/
node_modules/
.tfignore
A single .tfignore file is in the root directory.
What should I add to the .tfignore in order to ignore node_modules directories recursively no matter where they are in the directory hierarchy?
There're a lot of questions similar to mine. But all are pretty wide. I want to keep it simple. Please don't suggest anything with "Pending Changes". I only need a single line in .tfignore
The .tfignore file will ignore the given pattern in all subdirectories (unless otherwise specified). And it will ignore files or folders with the given name. For folders, it will apply recursively.
As a result, a .tfignore with:
node_modules
will ignore any folder named node_modules in your filesystem hierarchy, and it will ignore them recursively.

Docker build extra folders

I was trying to dockerize a nodejs application. I am adding code files to container using ADD command in Dockerfile. But i just noticed that folders named branches, objects, config, hooks are created automatically. Anybody out there know if its docker?
Found the issue. Using ADD ./* ./folder name/ instead of ADD . ./folder name created the extra folders.
But still wonder where those folders came from.
If your code file is in a git repo, you would have a .git subfolder that could be included by your ADD command.
That would explain the branches, hooks, ... folders.
As mentioned in "How to ADD all files/directories except hidden directory like .git in Dockerfile", you can exclude that folder with a .dockerignore file.

How do I create a fileset in Apache Ant that includes child files but exclude the containing directory?

I am able to create a fileset which includes certain directories. I am including this fileset to a copy. I want to take the child file and copy it without taking the parent folder.
My source structure is:
root
Folder1
Folder2
script.js
Folder3
script2.js
So I want script.js and script2.js copied, but in the destination directory I get Folder2 and Folder3 included.
I'm out of depth. Help would be appreciated.
Simply use copy task with flatten attribute set to true :
Ignore the directory structure of the source files, and copy all files
into the directory specified by the todir attribute. Note that you can
achieve the same effect by using a flatten mapper.

How do I copy a directory from one Jenkins job workspace to another?

I want to copy a complete directory (with all subdirectories) from a workspace in a job a into another job b's workspace.
I try with artifact but I don't find a way to copy all subdirectories and there is no option to preserve directory structure.
For artifact archiving, use **/* to copy all workspace files and subdirectories
For the Copy Artifacts step in other job, you can leave it blank to copy all artifacts, or you can use **/* syntax again
If the directory is very large or has a lot of files, it might be better to archive the source workspace directory using something like zip and archive the resulting zip file. Jenkins is notoriously slow at archiving artifacts, so even though you should be able to do it all with individual files, I myself have found moving a single (often much smaller) zip file has much better performance.

Resources