diff --git a/README.md b/README.md index 030685b..cfe9f27 100644 --- a/README.md +++ b/README.md @@ -1 +1,47 @@ -Repository setup and metadata for the rpm organization. +# RPM repository setup + +Setup script and metadata for the [rpm organization](https://git.bjphoster.com/rpm) on BJPHoster Gitea. + +## Quick setup + +Run this one-liner on an RPM-based system with Bash, curl and DNF or YUM installed: + +```bash +curl -fsSL https://git.bjphoster.com/rpm/.meta/raw/branch/main/install.sh | bash +``` + +RHEL, Rocky Linux, AlmaLinux, CentOS Stream and Fedora use DNF or YUM. This repository is not an APT source and cannot be added to Debian or Ubuntu through APT. + +The script: + +1. Checks the effective UID. UID 0 runs directly; other users need sudo and are prompted for authentication when required. If sudo is missing, it exits with `manca sudo ed è necessario`. +2. Selects DNF, or falls back to YUM. If neither exists, it exits without installing the repository. +3. Downloads the Gitea-generated configuration from `https://git.bjphoster.com/api/packages/rpm/rpm.repo` to a temporary file. A failed download leaves the installed configuration untouched. +4. Installs that configuration as `/etc/yum.repos.d/gitea-rpm.repo`, with mode 0644. Re-running replaces the same file. +5. Refreshes metadata for `gitea-rpm` only. Other configured repositories are not refreshed by this command. If the refresh fails, the script returns an error and the installed repository file remains in place. + +The downloaded configuration enables the repository, sets `gpgcheck=1`, and points to the Gitea registry's public signing key. The package manager may ask you to accept that key when installing a package. No packages are installed or upgraded by the setup script, and no config-manager plugin is needed. + +## Install packages + +After setup, install a published package with the native package manager: + +```bash +sudo dnf install skeptical-updater +``` + +Use `yum` instead of `dnf` on systems that only provide YUM; omit `sudo` when running as root. Repository availability does not guarantee that every package supports every distribution or release: its dependencies must also be available on the target system. + +Packages must be uploaded to the organization's RPM package registry. Git repositories and release attachments alone do not make a package available through DNF or YUM. Gitea generates the repository configuration, metadata and signing key endpoints; this repository does not maintain copies of those files. + +## Remove the repository + +```bash +sudo rm /etc/yum.repos.d/gitea-rpm.repo +``` + +This removes the repository configuration and leaves installed packages in place. + +## License + +MIT; see [LICENSE](LICENSE). diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..b47fa8c --- /dev/null +++ b/install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +privilege=() +if (( EUID != 0 )); then + command -v sudo >/dev/null 2>&1 || { printf '%s\n' 'manca sudo ed è necessario' >&2; exit 1; } + privilege=(sudo) + sudo -v +fi +if command -v dnf >/dev/null 2>&1; then + manager=dnf +elif command -v yum >/dev/null 2>&1; then + manager=yum +else + printf '%s\n' 'DNF or YUM is required; this RPM repository does not support APT.' >&2 + exit 1 +fi +repo=$(mktemp) +trap 'rm -f "$repo"' EXIT +curl -fsSL https://git.bjphoster.com/api/packages/rpm/rpm.repo -o "$repo" +"${privilege[@]}" install -Dm644 "$repo" /etc/yum.repos.d/gitea-rpm.repo +"${privilege[@]}" "$manager" --disablerepo='*' --enablerepo=gitea-rpm makecache