# Using reprepro for APT Repository Management

## Overview

This repository is now managed by **reprepro**, the standard Debian repository management tool. It replaces the custom `update-repo.sh` script with a single command.

## Configuration

Configuration is in `conf/distributions`:
- **Origin:** Silver Linings, LLC
- **Distributions:** stable, unstable
- **Architectures:** amd64 (plus automatic "all" architecture support)
- **Components:** main
- **Signing Key:** 1BE39A1142DEB0825A0130CE0790077DF5F93114 (Silver Linings, LLC)

### Distribution Policies:

- **stable** - Production-ready releases only. Thoroughly tested and approved.
- **unstable** - Development builds, testing versions, and work-in-progress releases.

## Common Commands

### Add a new package to unstable (development)
```bash
cd ~/apt-repo
reprepro includedeb unstable /path/to/package_1.0.0_all.deb
```

### Add a new package to stable (production)
```bash
cd ~/apt-repo
reprepro includedeb stable /path/to/package_1.0.0_all.deb
```

This automatically:
- Copies the .deb to the correct pool location
- Updates the Packages index
- Generates Release file with checksums
- Signs Release with GPG

### Copy a package from unstable to stable (promotion)
```bash
# After testing in unstable, promote to stable
reprepro copy stable unstable package-name
```

### List all packages
```bash
reprepro list stable     # List stable packages
reprepro list unstable   # List unstable packages
```

### Remove a package
```bash
reprepro remove stable package-name
```

### Remove a specific version
```bash
reprepro remove stable package-name=1.0.0
```

### Show package details
```bash
reprepro list stable package-name
```

### Re-export repository (regenerate metadata)
```bash
reprepro export stable
```

## Directory Structure

```
~/apt-repo/
├── conf/              # reprepro configuration (DO NOT deploy)
│   ├── distributions  # Main config file
│   └── options       # reprepro options
├── db/               # reprepro database (DO NOT deploy)
├── dists/            # Repository metadata (DEPLOY THIS)
│   └── stable/
│       ├── InRelease
│       ├── Release
│       ├── Release.gpg
│       └── main/
├── pool/             # Package files (DEPLOY THIS)
│   └── main/
└── *.gpg.key         # Public GPG key (DEPLOY THIS)
```

## Deployment

When deploying to proxy01, **exclude** the `conf/` and `db/` directories:

```bash
rsync -av ~/apt-repo/ proxy01:/var/www/projects.thedude.vip/apt/ \
  --exclude='conf' \
  --exclude='db'
```

## Migration from update-repo.sh

The old workflow:
```bash
# OLD
cp package.deb ~/apt-repo/pool/main/
cd ~/apt-repo && ./update-repo.sh
rsync -av ~/apt-repo/ server:/path/
```

The new workflow:
```bash
# NEW
reprepro -b ~/apt-repo includedeb stable package.deb
rsync -av ~/apt-repo/ server:/path/ --exclude='conf' --exclude='db'
```

## Recommended Workflow

### Development cycle:
```bash
# 1. Build and add to unstable for testing
./build-package.sh 3.5.26              # Defaults to unstable

# 2. Test on your servers with unstable distribution

# 3. When ready for production, promote to stable
cd ~/apt-repo
reprepro copy stable unstable bad-ips

# 4. Or rebuild directly to stable
./build-package.sh 3.5.26 --stable --deploy
```

### Client configuration:
```bash
# Production servers use stable
deb http://projects.thedude.vip/apt stable main

# Test servers use unstable
deb http://projects.thedude.vip/apt unstable main
```

## Why reprepro?

- ✅ Standard Debian practice (used by 90% of maintainers)
- ✅ Handles multiple packages automatically
- ✅ Single command to add/update packages
- ✅ Automatic metadata generation and GPG signing
- ✅ Built-in package versioning and replacement
- ✅ Database tracking of repository contents

## Documentation

- Man page: `man reprepro`
- Full docs: https://salsa.debian.org/brlink/reprepro
