# Arch Linux Archive Tools

## Introduction

**archivetools** is the project used to run the [Arch Linux Archive](https://wiki.archlinux.org/index.php/Arch_Linux_Archive). It's a turnkey solution to snapshot [Arch Linux](https://www.archlinux.org) packages repositories, ISOs images and boostrap tarballs. You can deploy one for your own needs.

The **Archive** is built by rsync'ing [rsync.archlinux.org](rsync://rsync.archlinux.org), or its mirrors, each day. _Rsync_ features are used to transfer only the diff of new data from the previous snapshot and files are stored once with use of hardlinks.

## Installation

Create a pacman package and install it.

```bash
cd archivetools
makepkg -i
systemctl enable archive.timer
```

## Testing

The project includes automated tests that can be run locally or in CI:

### Local Testing

```bash
# Set up test configuration
export DEBUG=1
export ARCHIVE_CONFIG=archive.conf.test

# Run the archive script
./archive.sh

# Test the cleaner
./archive-cleaner --repo "$HOME/test-archive/repos/last" --archive "$HOME/test-archive" --keep-years 1
```

### CI Testing

The project uses GitLab CI for automated testing. The CI pipeline includes:

1. Lint stage:
   - Shellcheck for bash scripts
   - Pylint for Python code

2. Test stage:
   - Creates test directory structure
   - Creates mock package data
   - Runs archive.sh to test basic archiving
   - Verifies archive structure
   - Tests archive-cleaner functionality
   - Tests incremental sync
   - Tests hardlinking

3. Coverage stage:
   - Generates coverage reports for archive-cleaner
   - Produces both HTML and XML coverage reports

To run tests locally:

```bash
# Install test dependencies
sudo pacman -S python-coverage python-libarchive-c shellcheck python-pylint

# Run the test suite
./test-archive.sh
```

## Dependencies

- [Bash](http://www.gnu.org/software/bash/bash.html)
- [Rsync](http://rsync.samba.org/)
- [Hardlink](http://jak-linux.org/projects/hardlink/)
- [xz](http://tukaani.org/xz/)
- [util-linux](https://www.kernel.org/pub/linux/utils/util-linux/)
- [Python](https://www.python.org/)
- [python-libarchive-c](https://github.com/libarchive/python-libarchive-c)
- [pacman-contrib](https://gitlab.archlinux.org/pacman/pacman-contrib) (for pacsort)

## Development Dependencies

For testing and development:

- gitlab-ci-local (for running CI tests locally)
- git (for version control)

## Sources

**archivetools** sources are available on [github](https://github.com/seblu/archivetools/).

## License

**archivetools** is licensied under the term of [GPL v2](http://www.gnu.org/licenses/gpl-2.0.html).

## Author

**archivetools** was started by _Sébastien Luttringer_ in August 2013 to replace the former _Arch Linux Rollback Machine_ service.
