Crystallize

Overview

A collection of tools for working with files and filesystems.

Note: There is an oddity in the version numbering: version 2.15.5.9.1 was followed immediately by version 2.15.5.9.3 (skipping 2.15.5.9.2); version 2.15.5.9.2 was then released following version 2.15.5.9.3 (and is identical to version 2.15.5.9.3 aside from the version number); normal numbering then resumed with version 2.15.5.9.4, .5, .6 etc. following version 2.15.5.9.2 (skipping version 2.15.5.9.3, as that number was already used).

Documentation

Usage

Crystallize provides the following primary user-facing command-line scripts.

crystallize
Archives a snapshot of a file or files and removes it/them (unless --keep is specified), providing an address and/or a pointer file that can be used to retrieve it/them. Synopsis: crystallize ( ([--version]) | ([--keep] [--] [--leave-pointer] <file>...) )
crystallize-backup
Backs up crystallized files with their associated metadata to the current directory. Synopsis: crystallize-backup <crystal-address>
decrystallize
Retrieves files stored using crystallize to the current directory, given their address. Synopsis: decrystallize <crystal-address> [--here]
decrystallize-pointer
Retrieves files stored using crystallize to the current directory, given a path to a pointer directory. Does not handle single-file pointers: use sreg_read_stream instead. Synopsis: decrystallize-pointer <file> [--here]

The following public-facing scripts are either used internally by the other tools and are mainly useful for writing other shell scripts, or are not thoroughly tested.

crystallize-getconf
Retrieve a configuration value from the configuration file used by Crystallize tools. Synopsis: crystallize-getconf <configuration-key-name>
csum
Generate and check against lists of file checksums. If no action is specified, save is assumed; if no checksum file name is specified, stdout/stdin are used for save and check respectively. Synopsis: csum [(save|check) [<checksum-file-name>]]
dequicklify
Retrieve a file stored using quickliquid. Synopsis: dequicklify (--no-trim-extensions|--trim-extensions) <URL>
fcache_init
Create an "fcache" cache directory: fcache is a naïve caching layer for non-changing URLs. Synopsis: fcache_init <directory-name> <cache-size-limit-in-bytes> (if the cache directory already exists, the current size limit will override the one provided as an argument)
fcache_request
Get an item using the specified "fcache" cache. Synopsis: fcache_request <cache-directory> <URL>
quickliquid
Quickly upload a file to the Internet Archive. Synopsis: quickliquid <file>
rubberfs
Not ready for production use! Provides tools for managing filesystems. Synopsis: rubberfs ( ((create|mount|soft-mount|remount|rename|cd|unmount|soft-unmount|attach|check|save|freeze|gc|thaw|patch|status|list|usage-write|destroy|destroy-no-upload|historybak|historypull) [<RubberFS-name>]) | usage | whereami | stub | (stash <file>...) | (delta [<RubberFS-name> [--keep]]) )
s3-streaming-upload
Not ready for production use! Streaming upload to Amazon S3–compatible endpoints, supporting some of the Internet Archive's extensions to S3. Synopsis: s3-streaming-upload <host-name> <collection> <identifier> <remote-file-name> <file-size-estimate> <title> <description> <keywords> [access-key-id] [secret-access-key] (if the access keys are not provided, s3-streaming-upload will attempt to retrieve them from ia's configuration file)
sreg_build_backup_set
Make a clone of the "sreg" (stream registry) stream database where the bodies of the streams are stored instead of the pointers. Synopsis: sreg_build_backup_set <target-directory>
sreg_check_failed
Check whether streams that could not be read in the past and were moved to the Failed Fsck directory have become readable in the meantime, and return them to the database if so. Synopsis: sreg_check_failed [--skip-cache]
sreg_flush_localstore
Convert LocalStore pointers to finished pointers. Synopsis: sreg_flush_localstore
sreg_folder_check
Go through the hashpointers in the specified directory, make sure that they are present in the stream registry, optionally verify those streams, and optionally remove any streams from the stream registry that are not referenced by the hashpointers in the specified directory. If no directory is specified, the current directory is assumed. Synopsis: sreg_folder_check [--verify] [--drop-unused] [<directory>]
sreg_fsck
Verify that all entries in the sreg stream database can be read correctly. Synopsis: sreg_fsck [--skip-cache] [--drop-failed]
sreg_fsck_hashpointers
Verify that all sreg hash pointers in the specified directory can be read correctly (an alias for sreg_folder_check --verify). Synopsis: sreg_fsck_hashpointers <path>
sreg_read_stream
Accepts a sreg pointer on stdin, and outputs the corresponding data from the stream registry. If a checksum is provided on the command line, the retrieved data will be checked against it. Synopsis: sreg_read_stream [--checksum <checksum>] [--disallow-hash-pointer] [--skip-cache]
sreg_store_stream
Stores data provided on stdin into the stream registry, and sends a pointer to it to stdout. A checksum, if one is known for the stream, can be provided on the command line for a slight performance improvement. Synopsis: sreg_store_stream [--assume-checksum <checksum>]
srfs
Mount and unmount a translation FUSE filesystem for a folder containing hash pointers. Synopsis: srfs (mount|unmount) [<root-folder-name>]
srpull
Copy the first argument into the second and replace any enclosed sreg pointers with their contents. The --replace option controls whether files that exist in the destination are overwritten (due to the implementation, with --replace, even files that do not need to be overwritten will be replaced) (files that exist in the destination that do not exist in the source will not be removed). Synopsis: srpull [--replace] <source-path> <destination-directory>
srsync
Copy the first argument into the second and replace non-pointerized or out-of-date files in the destination with their pointers. Synopsis: srsync [--verify|--no-verify] <source-path> <destination-directory>

In addition, Crystallize also provides the following scripts that it uses internally that are not supported for independent use.

crystallize-bash_setup
Set up the bash environment shared by Crystallize tools. Synopsis: source crystallize-bash_setup
crystallize-internal-ia
Part of crystallize that uploads the data body (not metadata). Synopsis: crystallize-internal-ia (needs specific environment variables set)
crystallize-internal-xz-b
Part of crystallize that compresses a JSON metadata file. Synopsis: crystallize-internal-xz-b (needs specific environment variables set)
crystallize-logsession
The main logic for crystallize. Synopsis: crystallize-logsession <log-file> <crystal-address> <file>... (needs specific environment variables set)
localstorecache_init
Create a "localstorecache" cache directory: localstorecache is a naïve caching layer for LocalStore crystals (variant of "fcache"). Synopsis: localstorecache_init <directory-name> <cache-size-limit-in-bytes> (if the cache directory already exists, the current size limit will override the one provided as an argument)
localstorecache_request
Get an item (returned as a file path) using the specified "localstorecache" cache. Synopsis: localstorecache_request <cache-directory> <crystal-address>
scache_gc
Drop old items from the specified (s/f/localstore)cache. Defaults to scache. Synopsis: scache_gc <cache-directory> [s|f|localstore]
sreg_fuse.py
Mount a FUSE filesystem overlay for sreg. Synopsis: sreg_fuse <mount-point> <sreg-directory-to-mount>
sregi_bundle_pointer
Given a LocalStore pointer, replace it with a remote pointer. Synopsis: sregi_bundle_pointer <path-to-remote-pointer-data> <path-to-pointer-to-replace> <crystalWorkdir-config-value>
sregi_check_failed_entry
Check that the specified pointer not in the stream registry database can be retrieved, and if so, move it into the stream registry database. If a tracking file (should contain only an integer) is specified, the file's value will be incremented. Synopsis: sregi_check_failed_entry <path-to-pointer> [tracking-file] [--skip-cache]
sregi_copy_write
Copy the first argument (must be a file) to the first argument appended to the destination folder, and replace it with a sreg pointer. If a tracking file (should contain only an integer) is specified, the file's value will be incremented. characters-to-trim is the number of characters to remove from the source filename to give the location of the destination file relative to the enclosing destination directory. Synopsis: sregi_copy_write [--no-verify] <path-to-file> <destination-folder> <tracking-file> <characters-to-trim>
sregi_drop_single_unused
Remove the specified pointer from the stream registry if it is not listed in the specified ID list (newline-separated list of pointer IDs). Synopsis: sregi_drop_single_unused <path-to-pointer> <path-to-ID-list> <tracking-file>
sregi_expand_pointers
For each file specified, if it is a sreg pointer, then replace it with the pointer's contents. Synopsis: sregi_expand_pointers <tracking-file> <file>...
sregi_file_backup
Accepts a sreg database entry as an argument, and replaces the entry with the entry's contents (but does nothing if this has already been done). Synopsis: sregi_file_backup <path-to-database-entry>
sregi_hashpointer_sane
Check that the pointer corresponding to the specified hash pointer (it's OK to toss pretty much any files at it — hash pointers, other pointers, and files that aren't pointers at all; non–hash pointer pointers will have hash pointers generated on demand for testing, and non-pointer files will be ignored and reported as success: this allows checking folders containing a mix of file types) is present in the stream registry, and add the specified hash pointer to the specified ID list for use by sregi_drop_single_unused. If instead of a file name "-" is given, the input to check will be read from standard input (use "./-" to check a file named "-" in the current directory). Synopsis: sregi_hashpointer_sane [<path-to-hashpointer>|-] [<path-to-ID-list> <tracking-file> [--verify]]
sregi_verify_entry
Check that the specified pointer can be retrieved. If a tracking file (should contain only an integer) is specified, the file's value will be incremented. Synopsis: sregi_verify_entry <path-to-pointer> [tracking-file] [--quick] [--skip-cache|--skip-drop-failed|--drop-failed]

crystallize-bash_setup provides these bash functions.

rubberfs
Wrapper around the rubberfs script: this function should be used instead. Synopsis: Synopsis: rubberfs ( ((create|mount|soft-mount|remount|rename|cd|unmount|soft-unmount|attach|check|save|freeze|delta|gc|thaw|patch|status|list|usage-write|destroy|destroy-no-upload|historybak|historypull) [RubberFS name]) | usage | whereami | stub | (stash <file>...) )
git-absolute-path
???? Synopsis: git-absolute-path <file>
git-escape-path
???? Synopsis: git-escape-path <path>
sreg_fuse
Mount a FUSE filesystem overlay for sreg (wrapper around sreg_fuse.py). Synopsis: sreg_fuse <mount-point>
sregi_available_by_hash
Basic sanity check for a stream registry entry given a preexisting variable knownChecksum corresponding to the entry to check. Synopsis: sregi_available_by_hash
sregi_hash_from_file
Retrieves and prints the checksum from a pointer. Synopsis: sregi_hash_from_file <file>

Installation

For Wreathe 7.3, an ebuild (app-misc/crystallize) is available in the Wreathe overlay (this may also work for similar operating systems such as Ututo XS GNU/Linux).

For other operating systems, use the following installation instructions.

Instructions for installation without ebuild

Requirements

Wreathe 7.3 is required for full support. The simple invocations of the 'crystallize' and 'decrystallize' commands (with filenames as the only arguments) are also supported on Ubuntu GNU/Linux and macOS 10.12 in the interest of promoting the preservation of knowledge (although Ember strongly advises not using non-libre software such as those operating systems), and will probably work on many other UNIX-like operating systems; these instructions only cover that basic support. This is not as well tested as using the software in Wreathe. Please report issues if you encounter them.

While using full functionality is not supported without using the ebuild, the following additional requirements are needed for it (this list is probably incomplete/incorrect).

Download

To download Crystallize, run:

git clone https://github.com/ethus3h/crystallize.git
Copy scripts

To install the downloaded scripts, run cd crystallize; make.

Setup

Edit the configuration file; see the "Configuration file format" section for documentation of this.

Finally, run sudo make install.

Configuration file format

The configuration file is located in your system configuration directory (probably /usr/local/etc or /etc), and is named crystallize.conf. It is a list of key-value pairs in the format Key,Value, separated by a line feed (0x0A), as follows:

InstallationIdentifier
Installation UUID
Collection
Internet Archive collection identifier (write access to the collection is required)
Passphrase
Passphrase (must be a valid GPG passphrase)
WorkDirectory
Directory for working data (should be writeable and have sufficient free space to hold approximately three times the amount of data being crystallized at any one time)
EmberLibrary
Path to a directory tree of the format used by the Ember Library

Note that there is currently no facility for storing configuration values containing line feeds.

Development

To learn about contributing to this project, visit the development page.