Skip to content

Serve and Publish Repositories

Publish a standard repository to a filesystem target in client-safe order, serve it with Nginx, and deliver updates or offline copies.

Putting a repository on a web server is more than copying a directory. While an update is in flight, a client can read the new index before its packages arrive, or keep using a cached index after you deleted the packages it names. Both show up as 404 or checksum errors in dnf and apt. A hand-written copy script also cannot resume a half-finished upload or tell you what the server actually holds.

For a standard repository, sow publish handles this for you:

  • Client-safe order. It copies package files first, then metadata with content-specific file names, and replaces the entry points that clients read first, repomd.xml and Release, last.
  • Resumable. It records progress, so rerunning the same command finishes an interrupted publication. Rerunning it after success is a no-op.
  • Cache grace before deletion. Files that the new build no longer needs stay on the target for the cache lifetime you declare, so clients holding an old index can still download what it names. Only then can sow gc remove them.
  • Verified delivery. It reads the published files back through the public endpoint before it records the publication.

In this tutorial you publish the local repository to a directory, serve that directory with Nginx, check it from a client, and publish an update. A final section covers hosts that SOW cannot reach.

You need:

  • The local repository and its el9 and bookworm Dists from Your first standard repository, in the /srv/sow workspace.
  • Nginx on the serving host, and sudo to create /srv/repo-public.
  • A dnf or apt client that can reach the server.

The source tree is /srv/sow/local; the public copy will be /srv/repo-public/local. Both hold the complete pool/ and dists/ tree. sow.yml and the private .sow/ state stay outside the server root.

1. Build and check

cd /srv/sow
sow build -r local
sow check -r local

publish delivers the last completed build, so build pending changes first. Continue when check succeeds.

2. Add a filesystem target

Create the target’s parent directory and give the account that runs sow publish, here your own, write access to it:

sudo install -d -m 0755 /srv/repo-public
sudo chown "$(id -u):$(id -g)" /srv/repo-public

The endpoint must already exist as a real directory; SOW rejects a path with a symlink component. Add the target to /srv/sow/sow.yml:

targets:
  public:
    repository: local
    provider: filesystem
    endpoint: file:///srv/repo-public
    prefix: local
    public_endpoint: file:///srv/repo-public/local/
    max_cache_ttl: 0s
    authoritative_workspace: true
    single_writer: true
    exclusive_write_authority: true

SOW creates /srv/repo-public/local from endpoint and prefix. The three authority fields declare that this workspace is the source of truth and the only writer for that path. They default to true when omitted, and an explicit false is rejected. Give other tools their own prefix; sibling targets with distinct prefixes under the same parent directory do not block each other.

public_endpoint and max_cache_ttl tell SOW where clients read the files and how long they may cache them. This example checks the files through file:// and declares no cache, so superseded files get no grace period. Once clients cache older indexes, or you put a proxy or CDN in front, set public_endpoint to the public repository URL and max_cache_ttl to the longest cache lifetime, then apply the change with sow publish public --rebind.

Publish the repository:

sow publish public

For the sample repository, the first run and a repeat print:

published local generation=00000000000000000004 to public (filesystem): phase=grace objects=28
publication local generation=00000000000000000004 to public is already current (noop)

The Generation number and object count depend on your repository. Exit status 0 means the target holds the current build.

3. Configure Nginx

Install Nginx and add a server block like this one, with your hostname in place of repo.example.com:

server {
    listen 80;
    server_name repo.example.com;

    root /srv/repo-public;
    autoindex off;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ (^|/)\. {
        deny all;
    }
}

The last location keeps hidden files, including temporary files, private. Check and reload the configuration:

sudo nginx -t
sudo nginx -s reload

reload assumes Nginx is already running. On a new installation, start it through your service manager once nginx -t succeeds.

Clients use these addresses:

Client Address
DNF baseurl http://repo.example.com/local/dists/el9/$basearch/
APT URIs http://repo.example.com/local
APT Suites / Components bookworm / main

The YUM and APT tutorials show the full source configuration. To verify signatures, distribute the public key as described in Sign your repository.

4. Check client access

Configure a client with the addresses above, refresh its indexes, and install a package. Success proves that both dists/ and pool/ are reachable over HTTP; if only the refresh works, the server treats the two directories differently. Give them the same access rules.

Publish an update

After you change membership or configuration, build and publish again:

sow build -r local
sow check -r local
sow publish public

If publication stops partway, rerun sow publish public to resume it. Once the cache grace period has passed, remove the files that no current build needs from the target:

sow gc public

See sow publish for abort, recovery, and target changes, and target GC for what gc keeps.

Deliver to an isolated host

When SOW cannot reach the destination, you take over the ordering that publish normally provides. Never copy over the live tree: build a complete new release directory and switch to it in one step. Stop all writes to the source repository while you create and check the copy.

  1. Run sow check on the source.
  2. Copy the complete repository to a new release directory on the destination. Preserve hard links, for example with rsync -aH or tar.
  3. Verify the transferred files against sow changes 0, which lists every file of the current build with its size and SHA-256, or against an archive checksum manifest.
  4. Switch the server’s path to the new release directory.
  5. Keep package and immutable metadata URLs that old indexes reference reachable until the longest client cache lifetime has passed, then remove the old release.

During that interval, the HTTP server can fall back to the previous release directory for paths missing from the new one.

Warning

Copying directly over a live tree can expose indexes before their package files arrive. Prepare the new directory first and switch it as a unit.

Serve a simple repository

For a simple repository, serve the directory you passed to sow create, with the same dotfile rule so temporary hidden files stay private. sow publish works only for standard repositories, so switch updates to a simple repository as a unit, as described above.

Publish to R2

For Cloudflare R2, use provider: r2 and configure its endpoint, bucket, credential reference, public URL, and cache lifetime; see the target configuration reference. Publish to a test prefix first and check it from your package clients.

On R2, sow gc TARGET only reports candidates after the cache grace period. If this workspace is the sole writer to the prefix, run sow gc TARGET --delete to reclaim them. See target GC.

Next steps

Table reader