Is it possible to use the patch utility to delete a file? - version-control

It is well known how to use patch to create a new file.
But how to do the opposite: delete an existing file with arbitrary content, or replace it with given content?
Context: suppose there's a directory in the Linux tree with a Makefile and/or Kconfig. I want to build only one custom module (driver) from the assortment they have there, for this I want to add my source file (this is easy) and also replace entire existing Makefile and Kconfig with my content (only the single line or block for my module).
I want to pack all this into a single patch file.
I don't want to modify the existing files because of high risk of conflicts in surrounding "context".

Related

How do I configure mplayer to use a default edl file name?

I want to configure mplayer to look for an edl when playing a video. Specifically, I want it to use "show.edl" when playing "show.mp4", assuming both are in the same directory. Very similar to how it looks for subtitles.
I can add a default edl in the config file by adding the following:
edl=default.edl
And this will look for the file "default.edl" IN THE CURRENT DIRECTORY, rather than in the directory where the media file is. And it isn't named after the media file either, and thus even if it did look in the right place, I'd have one single edl file for every media file in that directory.
Not really what I wanted.
So, is there a way, in the "~/.mplayer/config" file, to specify the edl relative to the input file name?
Mplayer's config file format doesn't seem to support any sort of replacement syntax. So there's no way to do this?
MPlayer does not have a native method to specify strings in the config file relative to the input file name. So there's no native way to deal with this.
There's a variety of approaches you could use to get around that. Writing a wrapper around mplayer to parse out the input file and add an "-edl=" parameter is fairly general, but will fail on playlists, and I'm sure lots of other edge cases. The most general solution would of course be to add the functionality to mplayer's config parser (m_parse.c, iirc.)
The simplest, though, is to (ab)use media-specific configuration files.
pros:
Doesn't require recompiling mplayer!
Well defined and limited failure modes. I.E. the ways it fails and when it fails are easily understood, and there aren't hidden "oops, didn't expect that" behaviors hidden anywhere.
Construction and updating of the edl files is easily automated.
cons:
Fails if you move the media around, as the config files need to full path to the edl file to function correctly.
Requires you have a ".conf" file as well as an EDL file, which adds clutter to the file system.
Malicious config files in the media directory may be a security issue. (Though if you're allowing general upload of media files, you probably have bigger problems. mplayer is not at all a security-hardened codebase, nor generally are the codecs it uses.)
To make this work:
Add "use-filedir-conf=yes" to "/etc/mplayer.conf" or "~/.mplayer/config". This is required, as looking in the media directory for config files is turned off by default,
For each file "clip.mp4" which has an edl "clip.edl" in the same directory, create a file "clip.mp4.conf" which contains the single line "edl=/path/to/clip.edl". The complete path is required.
Enjoy!
Automatic creation and updating of the media-specific .conf files is left as an exercise for the student.

How to move files whose file name is not used in a set of text files?

I'm a Powershell beginner and this is my first post on stackoverflow. I can understand some simple pipelines, but the following challenge is too complicated for me at this point:
I have a folder with testdata containing *.bmp files and their associated files. I want a powershell script to check which bmp-files are still used. If not used, move bmp-files and associated files to another folder.
Details:
bmp-files and associated files: For example; car01.bmp, car01.log, car01.file, car02.bmp, (...)
The bmp-files are in use if their file name (eg, car01.bmp) is mentioned in any of the (text/csv) files in at least one of 2 locations (incl. subfolders).
If the file name is not found in any of the text files, I want the script to move that file, and any file who's name differs only by file extension to a designated folder.
Looking forward to your solutions!

What is the best way to localize Markdown files in Weblate?

So I have been trialling Weblate using Docker, and pointing it at a Git repo with some .md files I want to localize. I believe a good way of doing this is to use po4a to first convert the .md (basically text) files to a Gettext .pot file then import these as individual components.
My main aim is to make the process as automated as possible but so far it looks like the steps will be something like this:
Convert from .md to .pot using po4a-getextize
Copy .pot file to .en.po file
Commit both files
Create new Component for this file in Weblate, manually putting in
the name of the '.pot' file
Add new languages to translate this Component to
Wait for translators to do their thing
Download all .po files
Convert back to original format with po4a-translate
Feels like I'm missing something with the way Weblate creates components... or how the .pot & .po files work together... ideally I'd like to automatically pick up and create Components when .potfile appear in the repo, then just set up some scripts outside Weblate to automate the conversion to/from the different file formats.
You can use component discovery or API to automatically create the components.

Is there a way to ignore temporary folders in RTC client?

I have temporary files created in separate folders inside my source tree which I would like to ignore. Something like:
project/
|--component/
|--.jazzignore
|--file.src
|--file-9df29e29373e66caef72/
|--file.src.tmp
I already ignore file.src.tmp by extension using .jazzignore, but I would also like to ignore the file-9df29e29373e66caef72/. The folder looks empty in the "Unresolved" category for the component, but since its name changes over time, I cannot ignore it by name.
since its name changes over time, I cannot ignore it by name.
Still, if you know its naming convention, you might consider an ignore pattern:
core.ignore= \
file-*
Note it is non-recursive, you that would ignore any file, folder or symlink named file-... anywhere under component.
Here, that would ignore only file-... directly under component.
Eclipse workspaces often include files or folders, such as compiler output, log files, and so on, that you do not want to place under source control.
You can specify resources or classes of resources to be ignored by Rational Team Concertâ„¢ source control. Ignored resources are never checked in.
A .jazzignore file is used to prevent items from being checked into change sets.
A .jazzignore file consists of a series of patterns. Any file, folder, or symbolic link whose name matches a pattern cannot be committed to a change set.
There are two types of patterns in a .jazzignore file:
core.ignore patterns, that are effective in the same directory as the ignore file; and
core.ignore.recursive patterns that affect items in all of the directories below the .jazzignore file.

Can I use `diff -r` to just tell me the files that are in one of the trees that have changed in the other?

I want to generate a summary of the files that are in one tree that are also in the other, that have been modified in the second.
The use case is this: I have a product distribution, which contains web content files. Those files are then imported into a client-specific project, and may be modified from there. I now want to see all the files in the client-specific project that have changed since the prduct was imported, so I can update the product, and keep the client-specific changes.
I'm thinking something like this might work
diff -r productDistribution/WebContent clientProject/WebContent
However, there are a number of files that are in the client specific project that are not in the product distribution, that I am not concerned with in this process. Essentially, I want an 'outer join', in SQL parlance.
Ideally, I want to be able to create a patch that contains all the client-specific changes. Then, I can just overlay the new product files, and apply the patch, and I should be all set.
Any ideas?
By default diff only prints a single line for each file that is in only one of the trees, so it's easy to filter these out:
diff -r productDistribution/WebContent clientProject/WebContent | \
grep -v 'Only in clientProject'