Matt McCutchen's Web SiteUtilities  (Top, cp2, setexec, stat2, retex, ftc, ftx, gitar, patchsync, continusync, Isolated Firefox, ntfsresizecopy, git subtree-lite, Bottom).  Email me about this page.

Utilities

Here I collect Linux utilities that I have written that you might find useful.

cp2

Abbreviation for rsync -rltE --chmod=ugo=rwX, i.e., preserve data but use destination default security settings. cp2 has replaced cp as my copy command.

FileSizeModification time
cp2452005-10-24 20:37:44 +0000

setexec

setexec makes a file executable or nonexecutable by changing the appropriate x permissions according to the same smart algorithm I contributed to rsync. cleanexec is a wrapper that makes a file executable if and only if file(1) says the data is executable; you might find find . -type f -exec cleanexec {} \; useful.

FileSizeModification time
setexec10072006-03-18 19:10:57 +0000
cleanexec922006-06-22 13:46:35 +0000

stat2

Shows just about all information about a file except its data.

FileSizeModification time
stat28072005-10-04 14:22:51 +0000

retex

A TeX wrapper script that makes TeX compiling fit more nicely into build processes.  For example, it exits nonzero immediately if an error occurs, and it repeats until a fixed point is reached in order to handle LaTeX references correctly.

FileSizeModification time
retex12092006-07-12 21:10:07 +0000

ftc, ftx

ftc packages a file tree in a single file of a simplistic format that I designed, and ftx extracts such package files.  They have the same purposes as tar -c and tar -x respectively but have no bells or whistles.  They handle binary files safely, but a package of only text files is itself a text file.

FileSizeModification time
ftc5802006-08-11 04:15:40 +0000
ftx7522006-08-11 04:15:43 +0000

gitar

gitar ("git archive") uses the git backend to make really small packages out of file trees with lots of redundancy.  ungitar unpacks the packages; it requires ftx.

A .gitar package consists of an ftc package containing a bare git repository whose HEAD is the original tree and whose objects are all stored in a single pack.  Hence, git will represent similar files in the original tree as deltas.

gitar is great for compressing together several versions of the same piece of software.  I had seven versions of my custom rsync lying around, each about 585 KB as a tar-bz2 package.  I unpacked them all inside a single folder and gitared that folder; the resulting gitar package was only 865 KB.

Note (2008-06-01): A while ago, git gained a standardized binary format for "bundles"; I should change gitar and ungitar to work on bundles.

FileSizeModification time
gitar16832006-08-11 04:17:34 +0000
ungitar3342006-08-11 04:20:48 +0000

patchsync

patchsync synchronizes a trunk, a branch, and a patch that contains the differences between the two.  If the trunk or patch changes, it updates the branch; if the branch changes, it updates the patch.  I developed patchsync to help me follow branches of rsync, but I no longer use it for that purpose.  Depending on your situation, you may prefer a more sophisticated patch-management tool such as StGIT.

To set up a patchsync staging directory, run:

patchsync --new trunk patch branch where-to-create-staging

Then, to synchronize, run:

patchsync staging

Read the gigantic comment at the top of patchsync for much more information.

Version log

Patchsync files below are named for their versions; I recommend renaming the one you download to just patchsync.

From 2006.12.16 to 2006.12.24, a development version of patchsync was mistakenly identified as version 2.2.  As of 2006.12.24, the real version 2.2 is posted.

DescriptionFileSizeModification time
patchsync version 2.4 (current)patchsync-2.4153772007-07-05 21:40:59 +0000
patchsync version 2.3patchsync-2.3155122007-01-07 17:00:43 +0000
Really patchsync version 2.2patchsync-2.2155792006-12-16 19:45:17 +0000
patchsync version 2.1patchsync-2.1154682006-12-16 03:34:44 +0000
patchsync version 2patchsync-2154102006-12-14 22:13:11 +0000
patchsync version 1patchsync-128952006-09-03 17:39:32 +0000

continusync

Continusync is a perl script around inotifywait and rsync that performs continuous mirroring, as suggested by Buck Huppmann. It is currently experimental and rather inefficient, but it does appear to work in simple cases.  If you want to use it, I would be much obliged if you improved it as necessary and sent me the improved version.

DescriptionFileSizeModification time
current version of continusynccontinusync72282007-08-07 20:15:35 +0000

Isolated Firefox

This is a firefox wrapper script that creates and uses a disposable profile.  You can make it harder for people to correlate your activities across multiple Web sites by browsing each site with a separate Firefox profile created by this script.  This script was inspired by the Facebook Beacon outrage.

To use this script, install it in your $PATH and name your master Firefox profile (from which the disposable ones will be copied) 00000000.master; then just run firefox.  Your mileage may vary.

Last update 2007-12-02: Initial posting.  Seems to work.

FileSizeModification time
firefox12832007-12-02 21:22:23 +0000

ntfsresizecopy

ntfsresizecopy copies an NTFS filesystem from one block device to another, resizing it to the size of the destination device in the process.  (It uses ntfsprogs.)  This is EXPERIMENTAL; after using this script, you should mount the destination read-only and check that everything looks intact.

An expanding copy is just done with ntfsclone followed by ntfsresize.  A shrinking copy is done by running ntfsclone and ntfsresize on devices specially crafted with the Linux device-mapper (requires dmsetup and losetup); you may save time by checking first that the shrinkage is possible with `ntfsresize -n -s SIZE SRC'.

The special shrinking technique should be applicable to any filesystem type that has an in-place shrinking command that doesn't write outside the new size.  Just change the calls to ntfsclone and ntfsresize; ntfsclone can be replaced by a dd of the beginning of the source for filesystems that don't have a sparse clone command.

FileSizeModification time
ntfsresizecopy69342008-06-01 13:59:42 +0000

Change log

git subtree-lite

git subtree-lite is a tool to manage modified versions of content imported from other git repositories, now deprecated in favor of Braid, which is roughly equivalent but more mature.  The source repository remains available for historical interest.


Matt McCutchen's Web SiteUtilities  (Top, cp2, setexec, stat2, retex, ftc, ftx, gitar, patchsync, continusync, Isolated Firefox, ntfsresizecopy, git subtree-lite, Bottom).  Email me about this page.
Modification time of this page's main source file: 2016-11-30 21:04:23 +0000
Except where otherwise noted, Matt McCutchen waives his copyright to the content of this site.  This site comes with absolutely no warranty.  Why?