Skip to content
Snippets Groups Projects

Unaltered

Unaltered is a command-line tool to maintain checksum files in directories.

License

Copyright © 2024 Cédric Marie cedric@hjuvi.fr.eu.org

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Requirements

Unaltered uses Cargo (Rust package manager). In order to build the program from the source code, you have to install cargo package.

Building and installing

You can build and install the program in your ~/.cargo directory, by executing this script:

$ ./user-install.sh

You can also use cargo command directly. This script is just a "helper". It builds in release mode.

Make sure that $HOME/.cargo/bin is in your PATH environment variable, so that you can execute the program.

If you want to clean the build and uninstall the program, you can execute this other script:

$ ./user-uninstall.sh

Usage

First, you have to go to the directory in which you want to manage checksum files:

$ cd /path/to/data/with/checksums

All commands are executed in the current directory (and all its subdirectories). Make sure you are in the right directory before executing any command.

To create the checksum files (checksums.sha256):

$ unaltered update

In each directory that contains some files, a checksum file is created, that lists these files along with their SHA-256 sums. The files are sorted into case-sensitive alphabetical order.

The checksum files are compatible with sha256sum command (i.e. they can also be verified with sha256sum -c checksums.sha256).

If the content of these directories is likely to evolve, you will need to update. The list command will print a warning for all the files that have been added, removed or modified:

$ unaltered list

A file is considered "modified" when its last modification time is more recent than the one of the checksum file. It usually means that the file has been deliberately modified after the checksum file was created or updated for the last time. In that case, the file should not be considered altered (bad checksum), but instead its checksum should be updated.

To update the checksum files, and fix all the warnings detected by the list command, use the update command again:

$ unaltered update

NB: There is no create command, because there is no need for such a specific command. The update command already creates the checksum files if they are missing in some subdirectories.

To verify all the checksums (and print warnings if an update is required):

$ unaltered check

For more information, you can print the help:

$ unaltered --help

Support

To report a bug, or suggest an improvement, please send an email to the address mentioned at the beginning of this file.