fileset

git mirror of https://ccx.te2000.cz/bzr/fileset
git clone https://ccx.te2000.cz/git/fileset
Log | Files | Refs | README

README (4855B)


      1 Fileset is a mini-DSL to ease creation, manipulation and inspection of
      2 filesystem hierarchies, including content of files. It can express arbitrary
      3 strings both as filenames and file content, with only very simple escaping for
      4 newlines. It can be easily generated using a templating/macro language.
      5 
      6 Fileset language consists of statements. Each line that starts with non-tab
      7 character is start of new statement. Lines that start with tab character are
      8 continuation lines from previous statement, where the newline is semantically
      9 retained but the tab character is ignored where processing. This means that you
     10 can embed literal "\n" by replacing each occurence with "\n\t", which is still
     11 conveniently readable in plain text, unlike most other escaping schemes.
     12 
     13 Each statement with single command character. The command may either take fixed
     14 number of tab-separated argument or operate on whole rest of statement.
     15 When the command does not consume whole statement, next command is taken from the
     16 first character after a tab delimiting the last argument.
     17 Two special commands ("/" and "P") do nothing by themselves, they only set the
     18 path (filename) for subsequent commands to operate on.
     19 
     20 Commands that take one argument:
     21 
     22 /<path>
     23 	set the path (filename) to operate on (may not contain tab, see P)
     24 
     25 u<mode>
     26 	set the umask for creating new files
     27 
     28 o<owner>
     29 	change owner (and group) of the filename, argument is directly passed to chown
     30 
     31 m<mode>
     32 	change file mode (permissions), argument is directly passed to chmod
     33 
     34 r<flags>
     35 	remove filename, for flags see below
     36 
     37 f<flags>
     38 	create plain file
     39 
     40 d<flags>
     41 	create a directory
     42 
     43 p<flags>
     44 	(not implemented) create FIFO / named pipe
     45 
     46 Commands that take two arguments:
     47 
     48 l<flags><tab><destination>
     49 	create symbolic link pointing to destination (destination may not contain tab, see L)
     50 
     51 h<flags><tab><destination>
     52 	(not implemented) create a hard link pointing to destination (ditto, see H)
     53 
     54 c<flags><tab><content>
     55 	create plain file with specified content (content may not contain tab, see C)
     56 	a final newline is appended if the content does not end in newline,
     57 	unless following flags are given:
     58 	"n" - always append a newline
     59 	"N" - never append a newline
     60 
     61 b<flags><tab><content>
     62 	base64, TODO description
     63 
     64 s<flags><tab><content>
     65 	checksum, TODO description
     66 
     67 D<flags><tab><device-type>:<major>:<minor>
     68 	TODO
     69 
     70 Commands that take whole statement:
     71 
     72 P<tab><path>
     73 	set the path (filename) to operate on
     74 
     75 L<flags><tab><destination>
     76 	create symbolic link pointing to destination
     77 
     78 H<flags><tab><destination>
     79 	(not implemented) create a hard link pointing to destination
     80 
     81 C<flags><tab><content>
     82 	create regular file with specified content, additional flags as with "c"
     83 
     84 B<flags><tab><content>
     85 	create regular file with content specified as base64,
     86 	additional flags as with "b"
     87 
     88 X<flags><tab><content>
     89 	create regular file with content specified as hexdump as produced by xxd
     90 
     91 !<flags><tab><command>
     92 	run shell command on file, depending on the flags:
     93 	"i" - redirect stdin from the file for the command
     94 	"o" - redirect stdout to the file for the command, rewriting it
     95 	"a" - redirect stdout to the file for the command, appending to it
     96 	"f" - use command as a filter, redirecting the file to stdin and stdout to
     97 	      temporary file, overwriting the original if change was detected
     98 	      also takes additional flags as for "f" command
     99 	"c" - with "f" create empty file first if it doesn't exist yet
    100 
    101 Flags taken by the rfdlhcLHC commands:
    102 	"!" - remove existing file if already present and of different type (eg.
    103 	      symlink instead of directory)
    104 	      files of same type are always replaced even without this flag
    105 	"r" - when removing existing file (directory), do it recursively (rm -r)
    106 	"f" - when removing existing file, do it forcibly (rm -f)
    107 	"p" - create parent directories if they don't exist (mkdir -p)
    108 
    109 ?<flags><tab><command>
    110 	Modifies following ! command. The command specified as argument will be run
    111 	to determine the following ! command should be run
    112 	(if ? command exits nonzero) and if so it's used once again after
    113 	to check that ! command performed required action (when ? command exits zero).
    114 	flags:
    115 	"i" - redirect stdin from the file for the command
    116 
    117 Commandline utilities:
    118 
    119 fileset [file [file ...]]
    120 	Convert fileset language into executable shell script. Read stdin if no
    121 	files are passed.
    122 
    123 fsapply [-x] root [file [file ...]]
    124 	Convert fileset language to shell script and execute it, relative to root
    125 	directory. The shell executed is determined by FILESET_SHELL environment
    126 	variable, defaulting to "sh". The -x option is passed to the shell, so
    127 	tracing can be turned on.
    128 
    129 fslist [file [file ...]]
    130 	Print out attributes and content of given files in fileset format. If
    131 	directories are given, they are processed recursively. When nothing is
    132 	given, current working directory is used.