# EveBox Debian/Ubuntu Package Repository

This directory contains a complete Debian/Ubuntu APT repository setup for the EveBox project.

## Repository Structure

- **stable**: Production-ready packages
- **unstable**: Development/testing packages
- **Architectures**: amd64, arm64, source (deb822 format)

## Quick Start

### 1. Initial Setup

```bash
# Install dependencies and initialize repository
./setup-repo.sh

# Generate GPG signing key
./setup-gpg-key.sh
```

### 2. Adding Packages

Add binary packages to the repository:

```bash
# Add to unstable (default)
./add-package.sh evebox_0.18.0_amd64.deb

# Add to stable
./add-package.sh --distribution stable evebox_0.18.0_arm64.deb

# Force overwrite existing package
./add-package.sh --force evebox_0.18.0_amd64.deb
```

Add source packages to the repository:

```bash
# Add source package to unstable (default)
./add-source-package.sh evebox_0.18.0.dsc

# Add source package to stable
./add-source-package.sh --distribution stable evebox_0.18.0.dsc
```

### 3. Web Server Setup

Serve this directory through your existing web server with TLS enabled. The repository root should point to this directory.

## Client Configuration

### Modern Method (deb822 format - Recommended for Ubuntu 22.04+/Debian 12+)

```bash
# Download and install GPG key
wget -qO - https://repo.evebox.org/evebox-repo.asc | sudo tee /usr/share/keyrings/evebox-archive-keyring.gpg > /dev/null

# Add repository configuration
sudo tee /etc/apt/sources.list.d/evebox.sources << 'EOF'
Types: deb deb-src
URIs: https://repo.evebox.org/
Suites: stable
Components: main
Architectures: amd64 arm64
Signed-By: /usr/share/keyrings/evebox-archive-keyring.gpg
EOF

# Update and install
sudo apt update
sudo apt install evebox
```

### Legacy Method (traditional format)

```bash
# Add GPG key
wget -qO - https://repo.evebox.org/evebox-repo.asc | sudo apt-key add -

# Add repository
echo "deb [arch=amd64,arm64] https://repo.evebox.org/ stable main" | sudo tee /etc/apt/sources.list.d/evebox.list

# Update and install
sudo apt update
sudo apt install evebox
```

## Scripts

- **setup-repo.sh**: Initialize repository structure and install dependencies
- **setup-gpg-key.sh**: Generate GPG key for package signing
- **add-package.sh**: Add binary packages to the repository
  - Options:
    - `-d, --distribution`: stable or unstable (default: unstable)
    - `-a, --architecture`: amd64 or arm64 (auto-detected)
    - `-f, --force`: Overwrite existing packages
    - `-h, --help`: Show help message
- **add-source-package.sh**: Add source packages (DSC format) to the repository
  - Options:
    - `-d, --distribution`: stable or unstable (default: unstable)
    - `-f, --force`: Overwrite existing packages
    - `-h, --help`: Show help message

## Directory Structure

```
.
├── conf/                    # Reprepro configuration
│   ├── distributions       # Repository distributions config
│   └── options            # Reprepro options
├── dists/                  # Distribution metadata
│   ├── stable/
│   └── unstable/
├── pool/                   # Package pool
│   └── main/
└── evebox-repo.asc         # Public GPG key
```

## Managing the Repository

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

### Remove a package
```bash
reprepro remove stable evebox
reprepro remove unstable evebox
```

### Check repository status
```bash
reprepro check
```

## Security

- All packages are signed with GPG
- The public key must be distributed to clients
- Keep the private GPG key secure
- Use HTTPS for serving the repository

## Troubleshooting

1. **GPG signing errors**: Ensure GPG key exists and is trusted
2. **Permission denied**: Check file permissions and web server user
3. **Package not found**: Verify package was added and repository was updated
4. **Architecture mismatch**: Ensure client architecture matches package architecture