.. _archive_repository:

===================
Archive Repository
===================

The archive repository is a directory structure that stores historical package files and their signatures. This allows for reproducible builds by preserving build dependencies and enables tracking of package history.

Structure
=========

The archive repository uses a hierarchical directory structure to organize packages:

.. code-block:: text

    archive/
    ├── package/
    │   ├── a/
    │   │   ├── alsa-lib/
    │   │   │   ├── alsa-lib-1.2.8-1-x86_64.pkg.tar.zst
    │   │   │   └── alsa-lib-1.2.8-1-x86_64.pkg.tar.zst.sig
    │   │   └── ...
    │   ├── b/
    │   │   └── ...
    │   └── ...
    └── source/
        ├── a/
        │   └── ...
        ├── b/
        │   └── ...
        └── ...

The structure consists of:

- A top-level ``archive`` directory
- Subdirectories ``package`` and ``source`` for binary packages and source files respectively
- First-letter subdirectories (e.g. ``a/``, ``b/``) to distribute files
- Package name subdirectories containing the actual package files and signatures

Configuration
============

Archive directories can be configured globally and per repository in ``repod.conf``. For example:

.. code-block:: toml

    [archiving]
    packages = "/var/lib/repod/archive/package/"
    sources = "/var/lib/repod/archive/source/"

    [repository.core]
    archiving = true

    [repository.extra]
    archiving.packages = "/var/lib/repod/archive/extra/package/"
    archiving.sources = "/var/lib/repod/archive/extra/source/"

When archiving is enabled for a repository, repod will:

1. Create the required directory structure automatically
2. Copy package files and signatures to the appropriate location when importing packages
3. Use the archive to verify build dependencies exist when importing new packages

Build Reproducibility
===================

The archive plays an important role in ensuring build reproducibility by:

- Preserving exact versions of packages used as build dependencies
- Allowing verification that all build dependencies exist before accepting new packages
- Maintaining a historical record of all packages that were part of the repository

This helps ensure that packages can be rebuilt consistently using the same dependency versions that were used in the original build.

See Also
========

- :ref:`binary_repository` - Documentation on binary package repositories
- :ref:`source_repository` - Documentation on source package repositories 