I need something to make sure tarballs are created intelligently and correctly reliably.
Go to file
Leopere b6c808ed75 Drastically simplify container setup to single build+test step and include binaries in repo 2025-03-20 18:34:27 -04:00
bin Drastically simplify container setup to single build+test step and include binaries in repo 2025-03-20 18:34:27 -04:00
test Drastically simplify container setup to single build+test step and include binaries in repo 2025-03-20 18:34:27 -04:00
.gitignore Drastically simplify container setup to single build+test step and include binaries in repo 2025-03-20 18:34:27 -04:00
Dockerfile Drastically simplify container setup to single build+test step and include binaries in repo 2025-03-20 18:34:27 -04:00
README.md Refactor test scripts into a single unified test file 2025-03-20 18:27:48 -04:00
docker-compose.yml Drastically simplify container setup to single build+test step and include binaries in repo 2025-03-20 18:34:27 -04:00
go.mod Initial implementation of tarballer utility with FreeBSD/macOS/Linux support and symlink handling 2025-03-20 13:06:29 -04:00
main.go Initial implementation of tarballer utility with FreeBSD/macOS/Linux support and symlink handling 2025-03-20 13:06:29 -04:00

README.md

Tarballer

A simple utility to create tarballs with a specific directory structure.

Features

  • Creates compressed tar archives (.tar.gz) from a source directory
  • Places all files under a specified prefix directory in the tarball
  • Preserves file permissions and directory structure
  • Handles symbolic links correctly
  • Cross-platform compatibility (FreeBSD, macOS, Linux)
  • Produces tarballs compatible with standard tar tools
  • Verified data integrity with MD5 hash comparison

Building

This project includes Docker support to build binaries for different platforms:

docker compose up --build build

This will create these binaries in the ./bin directory:

  • tarballer-freebsd: FreeBSD AMD64 compatible binary
  • tarballer-darwin: macOS ARM64 compatible binary
  • tarballer-linux: Linux AMD64 compatible binary

Testing

You can run the included tests to verify functionality:

# Run the basic functionality test
docker compose up --build test

# Run comparison test with standard tar tools
docker compose up --build tar-test

The tests will:

  1. Create test directory structures with nested directories and symlinks
  2. Create tarballs from them
  3. Extract the tarballs using standard tools
  4. Verify the contents and file structure, including symlinks
  5. Check that symlinks remain functional after extraction
  6. Compare output with standard tar tools to ensure compatibility
  7. Verify data integrity with MD5 hashing (original vs. extracted files)

Usage

The usage is the same for all binaries:

./bin/tarballer-<platform> -source /path/to/directory -output myarchive.tar.gz -prefix myprefix

Options

  • -source: The directory you want to compress (required)
  • -output: The name of the output tarball (defaults to "output.tar.gz")
  • -prefix: The directory name that will contain all files in the tarball (defaults to "myapp")

Example

# On macOS:
./bin/tarballer-darwin -source ./myproject -output release.tar.gz -prefix app

# On FreeBSD:
./bin/tarballer-freebsd -source ./myproject -output release.tar.gz -prefix app

When extracted, all files will be under the app/ directory in the tarball and can be extracted with standard tools like:

tar -xzf release.tar.gz -C /path/to/extract