Copying symbolic links but pointing to same files(copied) but different target base directories - linux

I am trying to create a test environment by updating it with another test environment files. Heres my situation:
I have a directory SRC. It has directories "test_bundles" and "tools_bundles" which has all the required builds. Additionally, SRC has "latest" directory which has files "test_bundle_1", "tools_bundle_1" etc. which points to specific builds within directories "test_bundles" and "tools_bundles", i.e., symbolic links.
Now on a different Linux system, I have DEST directory which is regularly updated with contents of "test_bundles" and "tools_bundles" from the SRC directory. I also want to have "latest" directory in DEST that has same files as in "latest" within SRC directory, however, points to builds (these builds are same) inside "test_bundles" and "tools_bundles" within the DEST.
Note that files change their links to different builds and moreover, new files get added to "latest" within SRC as well. So whenever I do copy operation it should update everything.
I dont know what to call this. Am I trying to copy the SRC "latest" to DEST "latest" files (symbolic links) with links to different parent directory structure.
Note that my script is doing good by updating "test_bundles" and "tools_bundles". I just need a way for "latest" files with the test environment uses different base directories.

If the links in latest are relative there is nothing special that
needs to be done - parent directory names do not matter. – Michał
Politowski
Actually its the opposite, the links are not relative rather the
parent directory structure(tree) is different – user3685188
What Michał Politowski surely meant to suggest is that you should make the symbolic links relative in order to have your problem solved - and that is the most sane solution.

Related

Git thinks a file within a symlinked directory has been deleted after recreating the symlink, how can I fix it?

I have a symlinked directory within my repository, which links to files elsewhere on the filesystem. For whatever reason, the symlink breaks every now and then, and it turns into a regular empty folder. So I deleted the empty folder, and recreated the symlink with ln -s ../../ ext, which appears to have worked as I can browse that folder and see the contents. But when I run git status, it appears all the files that should be visible within the ext folder are missing. How can I make git see that they are there again, within the symlinked directory?
This is on Ubuntu 18 by the way.
Your setup is odd, because Git does not follow symlinks, it just stores them.
That is, if you have a symbolic link ext -> ../.. and you run git add ext, Git creates, in the index, an entry with mode 120000 (symlink) to store the blob contents ../... Committing will create a commit that, when extracted, will create the symbolic link ext pointing to ../... Git will not store any files within ext when it is storing this symbolic link.
If, on the other hand, you have an existing commit that contains files named ext/foo and ext/bar, and you clone this repository at this commit, or extract this commit into a new and otherwise empty work-tree, Git will see that in order to write to files named ext/foo and ext/bar, your OS requires that ext exists as a directory. It will therefore create the empty directory ext, in which it will then create files foo and bar as your OS requires, so as to create files that to Git are merely named ext/foo and ext/bar. These two names, ext/foo and ext/bar, will now be in the index, so that the next commit you make will also contain these two files.
It sounds like you:
cloned a repository (perhaps with git clone --no-checkout?);
manually created a symbolic link in the work-tree named ext, pointing to some existing directory (perhaps one with some files inside it);
convinced git checkout to create ext/foo and ext/bar without first removing the symbolic link ext and replacing it with a directory ext.
This is not a supported mode of operation1 and you should not be surprised when it goes wrong.
1It leads to security issues: Git is meant not to write any files "outside" the work-tree area, and writing to files "under" a symbolic link to a directory outside the work-tree would allow this to occur. Rather than carefully limit symbolic link usage, Git just generally doesn't store files "beyond" any link in the first place—though it's probably possible, through careful manipulation of the index and, at the OS level, the file system in which your work-tree resides, to trick Git manually.
just dont put a repo in a repo, its not worth it

Can I include a folder relative to the current directory in PATH in Powershell?

I run a lot of node projects and often have binaries located in:
.\node_modules\.bin
...relative to the projects folder. I'd like to be able to have PATH always include these directories, if they exist. I don't want to include other directories, just the one relative to the current directory. I'm familiar with
Add-PathVariable from PSCX and other Powershell basics, but how do I include a folder relative to the current dir in PATH?
Edit: as mentioned in the question, already, I expect the path to stay updated as the directory changes. This is not simply asking about how to use pwd.
You can use a relative path in Env:PATH and the binaries found will update dynamically:
Eg:
$env:PATH += ';.\node_modules\.bin'
Or with the PowerShell Community Extensions (PSCX):
Add-PathVariable '.\node_modules\.bin'
Unlike using $(pwd) the . is not immediately resolved to an absolute path, so PATH is always relative to the current working directory.
Testing this:
$ which uuid
C:\Users\username\Documents\myapp\node_modules\.bin\uuid.cmd
Then changing directory, uuid now refers to a program in a different dir:
$ cd ..\blog\
$ which uuid
C:\Users\username\Documents\blog\node_modules\.bin\uuid.cmd
It's also possible to persistently change PATH in the user or system environment:
[Environment]::SetEnvironmentVariable(($env:PATH + ';.'), 'User')
or
[Environment]::SetEnvironmentVariable(($env:PATH + ';.'), 'Machine')
Security note: when entering a command Windows will automatically search all directories in $env:PATH for files with one of the extensions listed in $env:PATHEXT and execute the first match it finds. Depending on where exactly in the search path you placed . that may even supersede system executables.
You may want to take a look at how to use package installed locally in node_modules for alternative approaches.

Including extra directories with Keter

I have a Yesod site and have created a handler for handling downloads and enforcing constraints. My Yesod project directory has a subdirectory called downloads, and it contains files I want the user to be able to download if they are logged in. The handler works great in my development and staging boxes, but breaks when I transfer to production. I tracked the problem down to yesod keter not archiving the files when it builds its bundle.
How do I convince keter to include the directory?
All the yesod keter command does is create a .tar.gz compressed archive file with the .keter extension containing the following subdirectories:
config: an exact copy of the identically named directory in your source tree
dist: contains a subdirectory bin containing your app's binary
static: an exact copy of the identically named directory in your source tree
Note that the path to your app's binary is set in config/keter.yml via the exec setting while the path to your static files is set via the root setting. The exact set of files included by the yesod keter command is specified in the findFiles function if you want to take a look at the source code.
If you want to customize the contents of your .keter file it is probably most straightforward to write a shell script to create the archive. With this script you can add arbitrary extra directories to the archive.
The bare minimum bash script you'd need to emulate the behaviour of yesod keter is as follows:
#!/bin/bash
tar cvf myapp.keter config/ dist/bin/ static/
You can customize this however you want to produce the correct content. Adding download/ to the end of this command line should do the trick.

Tortoisesvn auto resolve conflicts on folder?

is it possible to set a 'rule' that tells TortoiseSVN to automatically resolve conflicts on a specific folder?
ie. we have a shared resources folder - "/shared" that we use to store our latest bin files in. when we do a local build, the local bin files in that folder gets overwritten.
next time we do an svn update on that folder the update should pull the latest bin files from SVN and overwrite the previously locally-built bin files but this will throw a conflict because the files are binary and cannot be merged (and, should not be merged anyway)
we would like to setup a rule that tells tortoise to always "resolve using theirs" on that /shared folder ("svn update -R --accept theirs-full")
There's a SVN misuse here. If the files should not be merged as you said, the directory should be set to ignore all .bin files (svn:ignore). It doesn't make sense keep in version control binary files that are changed frequently causing so much collisions.
In your place, I would delete all .bin files from this folder. If it's really necessary to keep the files versioned, I would create a directory and place these .bin files in there, avoiding frequent changing.
But if you really want to keep the files as they are, I recommend you to write client-side hooks for post-update events. See TortoiseSVN Docs for more information.

Multiple locations within a folder hierarchy to run SCons from

So far, I've only seen examples of running SCons in the same folder as the single SConstruct file resides. Let's say my project structure is like:
src/*.(cpp|h)
tools/mytool/*.(cpp|h)
What I'd like is to be able to run 'scons' at the root and also inside tools/mytool. The latter compiles only mytool. Is this possible with SCons?
I assume it involves creating another SConstruct file. I've made another one: tools/mytool/SConstruct
I made it contain only:
SConscript('../../SConstruct')
and I was thinking of doing Import('env mytoolTarget') and calling Default(mytoolTarget), but running it with just the above runs in the current directory instead of from the root, so the include paths are broken.
What's the correct way to do this?
You can use the -u option to do this. From any subdirectory, scons -u will search upwards in the directory tree for an SConstruct file.

Resources