feat: add APT repository setup script and documentation

This commit is contained in:
bryanpedini committed 2026-11-12 14:58:39 +01:00
1 parent 999193fe86
commit f8115ac0e2
2 files changed
+105

No files matched your search

+71
View File
@@ -1 +1,72 @@
# deb metadata
Bootstrap script and shared documentation for the `deb` organization's APT repository on [BJPHoster Gitea](https://git.bjphoster.com/deb).
## Quick setup
Run this one-liner on a Debian-based machine with Bash, curl and CA certificates installed:
```bash
curl -fsSL https://git.bjphoster.com/deb/.meta/raw/branch/main/setup.sh | bash
```
The script runs privileged commands directly when the effective UID is `0`. Otherwise it uses `sudo`, which may prompt for your password. If `sudo` is unavailable, it exits with status `1` and prints `manca sudo ed è necessario` to standard error. Your account must be allowed to run the installation commands and `apt update` through sudo.
The script checks for `apt`, `curl`, `install` and `mktemp`, then:
1. Downloads the registry's public signing key over HTTPS into a temporary directory.
2. Creates `/etc/apt/keyrings` and `/etc/apt/sources.list.d` if needed.
3. Installs the key as `/etc/apt/keyrings/bjphoster-deb.asc` with mode `0644`.
4. Writes `/etc/apt/sources.list.d/bjphoster-deb.list` with mode `0644`.
5. Runs `apt update` to refresh package indexes.
Temporary files are removed on exit. A failed command stops setup with a nonzero status. Files already installed remain in place if a later step fails. Running the script again replaces the same two files without appending duplicate entries. If you previously added this repository to a different source file, remove that duplicate entry yourself.
To inspect the script before running it:
```bash
curl -fsSL https://git.bjphoster.com/deb/.meta/raw/branch/main/setup.sh -o setup.sh
less setup.sh
bash setup.sh
```
## Repository configuration
The source entry is:
```text
deb [signed-by=/etc/apt/keyrings/bjphoster-deb.asc] https://git.bjphoster.com/api/packages/deb/debian stable main
```
`stable` is the registry's distribution name and `main` is its component. Use these values on supported Debian-based systems, regardless of the host's release codename. Each package still has its own architecture and operating system dependency requirements; adding the repository does not guarantee every package supports your machine.
The key is downloaded from:
```text
https://git.bjphoster.com/api/packages/deb/debian/repository.key
```
`signed-by` limits this key to this source entry. Gitea generates the package indexes and signed release metadata from packages published to the organization's Debian registry. Git repositories and release attachments alone do not publish packages to APT. See the [Gitea Debian registry documentation](https://docs.gitea.com/usage/packages/debian/).
## Install packages
After setup, install a published package normally, for example:
```bash
sudo apt install skeptical-updater
```
When already running as root, omit `sudo`. Setup itself only configures the repository and refreshes indexes; it does not install or upgrade packages.
## Remove the repository
```bash
sudo rm -f /etc/apt/sources.list.d/bjphoster-deb.list /etc/apt/keyrings/bjphoster-deb.asc
sudo apt update
```
When already running as root, omit `sudo`. Removing the source leaves installed packages in place.
## License
MIT, see [LICENSE](LICENSE).
Executable
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
main() (
set -euo pipefail
as_root=()
if (( EUID != 0 )); then
if ! command -v sudo >/dev/null 2>&1; then
printf '%s\n' 'manca sudo ed è necessario' >&2
exit 1
fi
as_root=(sudo)
fi
for dependency in apt curl install mktemp; do
command -v "$dependency" >/dev/null 2>&1 || {
printf 'Missing required command: %s\n' "$dependency" >&2
exit 1
}
done
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
curl -fsSL https://git.bjphoster.com/api/packages/deb/debian/repository.key -o "$work/repository.asc"
printf '%s\n' 'deb [signed-by=/etc/apt/keyrings/bjphoster-deb.asc] https://git.bjphoster.com/api/packages/deb/debian stable main' > "$work/repository.list"
"${as_root[@]}" install -d -m 0755 /etc/apt/keyrings /etc/apt/sources.list.d
"${as_root[@]}" install -m 0644 "$work/repository.asc" /etc/apt/keyrings/bjphoster-deb.asc
"${as_root[@]}" install -m 0644 "$work/repository.list" /etc/apt/sources.list.d/bjphoster-deb.list
"${as_root[@]}" apt update
)
main