# Supported Repositories

slpkg supports two types of repositories:

- **SlackBuild** — source-based repositories. slpkg downloads the SlackBuild script and source, compiles, and installs the package.
- **Binary** — pre-compiled binary package repositories. slpkg downloads and installs the `.txz` / `.tgz` package directly.

---

## Repository Table

| Name | URL | Type | Tag | Default |
|---|---|---|---|---|
| sbo | [slackbuilds.org](https://slackbuilds.org/) | SlackBuild | `_SBo` | ✓ |
| ponce | [cgit.ponce.cc](https://cgit.ponce.cc/slackbuilds/) | SlackBuild | `_SBo` | |
| slack | [slackware.uk](https://slackware.uk/slackware/) | Binary | — | |
| slack_extra | [slackware.uk](https://slackware.uk/slackware/) | Binary | — | |
| slack_patches | [slackware.uk](https://slackware.uk/slackware/) | Binary | — | |
| slack_testing | [slackware.uk](https://slackware.uk/slackware/) | Binary | — | |
| alien | [slackware.uk](https://slackware.uk/people/alien/sbrepos/) | Binary | `alien` | |
| multilib | [slackware.nl](https://slackware.nl/people/alien/multilib/) | Binary | `alien` | |
| restricted | [slackware.nl](https://slackware.nl/people/alien/restricted_sbrepos/) | Binary | `alien` | |
| gnome | [slackware.uk](https://slackware.uk/gfs/) | Binary | `gfs` | |
| cosmic | [slackware.uk](https://slackware.uk/cosmicde/) | Binary | `cosmic` | |
| msb | [slackware.uk](https://slackware.uk/msb/) | Binary | `msb` | |
| csb | [slackware.uk](https://slackware.uk/csb/) | Binary | `csb` | |
| conraid | [slackers.it](https://slackers.it/repository/) | Binary | `cf` | |
| slackonly | [packages.slackonly.com](https://packages.slackonly.com/pub/packages/) | Binary | `slonly` | |
| salix | [repo.greeklug.gr](https://repo.greeklug.gr/data/pub/linux/salix/) | Binary | — | |
| salix_extra | [repo.greeklug.gr](https://repo.greeklug.gr/data/pub/linux/salix/) | Binary | — | |
| slackel | [slackel.gr](http://www.slackel.gr/repo/) | Binary | `dj` | |
| slint | [slackware.uk](https://slackware.uk/slint/) | Binary | `slint` | |
| pprkut | [repo.liwjatan.org](https://repo.liwjatan.org/pprkut/) | Binary | `pprkut` | |
| slackdce | [slackware.halpanet.org](https://slackware.halpanet.org/slackdce/packages/15.0/x86_64/) | Binary | `slackdce` | |
| d2slack | [slackdce.theworkpc.com](https://slackdce.theworkpc.com/mirrors/d2slack/) | Binary | `d2slack` | |

> The **Tag** column shows the suffix appended to installed package filenames (e.g. `ffmpeg-7.1-x86_64-1_SBo`).
> A dash (—) means no tag is appended.

---

## Enabling a Repository

Only `sbo` is enabled by default. To enable additional repositories, edit `/etc/slpkg/repositories.toml` and set `ENABLE = true` in the relevant section:

```toml
[ALIEN]
ENABLE = true
MIRROR = "https://slackware.uk/people/alien/sbrepos/15.0/x86_64/"
```

Then update the database:

```bash
$ slpkg update
```

---

## Selecting the Default Repository

The default repository is set in `/etc/slpkg/repositories.toml` under the `[DEFAULT]` section:

```toml
[DEFAULT]
REPOSITORY = "sbo"
```

It can also be overridden at runtime with the `SLPKG_REPO` environment variable without modifying the config file:

```bash
$ export SLPKG_REPO=alien          # for the current shell session
$ SLPKG_REPO=alien slpkg install vlc  # inline, for a single command
```

Or use the `-o` / `--repository` flag per command:

```bash
$ slpkg install vlc -o alien
```

---

## Git Mirror Support (sbo and ponce)

The `sbo` and `ponce` repositories support cloning directly from GitHub or GitLab. When a `.git` URL is configured as the mirror and the local clone exists, slpkg resolves the raw-file base URL automatically.

The branch can be set explicitly:

```toml
[SBO]
ENABLE = true
MIRROR = "https://github.com/Ponce/slackbuilds.git"
BRANCH = "master"

[PONCE]
ENABLE = false
MIRROR = "https://gitlab.com/Ponce/slackbuilds.git"
BRANCH = "current"
```

---

## Adding a Custom Repository

Any section in `repositories.toml` that does not match a built-in repository name is treated as a custom binary repository. The minimum required fields are `ENABLE`, `MIRROR`, and `TAG`:

```toml
[MYREPO]
ENABLE = true
MIRROR = "https://example.com/packages/15.0/x86_64/"
TAG    = "myrepo"
```

Optional fields:

| Field | Description |
|---|---|
| `CHANGELOG` | Separate URL for the `ChangeLog.txt` (defaults to `MIRROR`) |
| `TAG` | Package tag suffix |

After adding the section, run `slpkg update` to fetch the package database.

---

## Managing Repositories (`slpkg repo`)

The `repo` command lets you enable, disable, and change mirrors without editing `repositories.toml` manually. All writes use [`tomlkit`](https://github.com/sdispater/tomlkit), which preserves the original file formatting, ordering, and comments.

### List all repositories

```bash
slpkg repo           # full table view
slpkg repo -q        # names only (one per line)
```

Without options, prints a table with each repository's enabled/disabled status and mirror URL. The default repository is marked with `*`. Use `-q/--quiet` for machine-readable output (one name per line, no table).

### Enable / disable

```bash
slpkg repo --enable alien ponce     # enable one or more repos
slpkg repo --disable sbo            # disable a repo
```

- Repository names are matched **case-insensitively**.
- Multiple names can be passed in a single call.
- If a repository is already in the requested state, slpkg reports `Already enabled` / `Already disabled` and makes no changes.
- After enabling a repository, run `slpkg update` to fetch its package database.

### Change a mirror

```bash
slpkg repo --mirror alien https://slackware.uk/people/alien/sbrepos/15.0/x86_64/
```

Updates the `MIRROR` key for the named repository. Only the mirror is changed; `ENABLE`, `TAG`, and all other fields remain untouched. Run `slpkg update` afterwards to refresh the database.

### Set the default repository

```bash
slpkg repo --default alien
```

Updates `REPOSITORY` in the `[DEFAULT]` section of `repositories.toml`. The default repository is used when no `-o/--repository` flag is given and the `SLPKG_REPO` environment variable is not set.

### Set the all-repos priority

```bash
slpkg repo --priority ponce alien   # set order for -o all
slpkg repo --priority               # clear the list
```

Updates `PRIORITY` in the `[ALL_REPOS]` section of `repositories.toml`. The list controls which repositories participate in `slpkg upgrade -o all` and `slpkg install <pkg> -o all`, and in what order. Passing no names clears the list, reverting to all enabled repositories in `repositories.toml` order.

---

## All-Repos mode (`-o all`)

Both `upgrade` and `install` accept `-o all` (or equivalently `-o "*"`) to operate across **all enabled repositories in a single interactive pass**.

- **`slpkg upgrade -o all`** — upgrades installed packages from all priority repositories.
- **`slpkg install <pkg> -o all`** — searches all priority repositories for the given package name(s), lets the user pick which to install (including from which repository when the same package appears in more than one), resolves dependencies, and installs.

### Configuration

**`repositories.toml`** — control which repositories are included and in what order:

```toml
[ALL_REPOS]
# Repositories to include when using '-o all' with 'upgrade' or 'install',
# listed in processing order (case-insensitive). The first name is processed first.
# If left empty, all enabled repositories are used in repositories.toml order.
# Example:
# PRIORITY = ["ponce", "alien"]
PRIORITY = []
```

- If `PRIORITY` is **empty** (the default), all enabled repositories are used
  in the order they appear in `repositories.toml`. Both commands work
  out-of-the-box without any configuration.
- If `PRIORITY` is set, **only** the listed repositories are included.
  Repositories not listed are skipped.
- Names are matched **case-insensitively** (`"Ponce"` == `"ponce"`).
- Disabled repositories in the list are silently skipped.

**`slpkg.toml`** — control when the confirmation prompt is shown:

```toml
[behavior]
# "once"     — ask once for all repositories (default).
# "per_repo" — ask separately before each repository.
ALL_REPOS_CONFIRM = "once"
```

### Interactive flow

Both commands follow the same flow:

```
1. Databases loading ...
2. ONE combined package selection (all repos) — each entry labelled [repo] in cyan
3. ONE combined dependency selection          — each dep labelled [repo] in cyan
4. Unified display:
     Upgrading:              ffmpeg  7.1   ponce
                             vlc     3.0   alien
     Upgrading dependencies: libvpx  1.13  ponce
5. Conflict warning (upgrade only, for selected packages found in multiple repos)
6. Confirmation prompt
7. Execution per repository in PRIORITY order
   — SBo/Ponce repos: one build pass each
   — Binary repos: merged into a single download+install pass
8. ONE combined Finished: timer
```

### Conflict handling

**Upgrade mode:** if the same package appears in more than one repository, the **first repository in priority order wins**. A warning is shown only for packages the user actually selected:

```
Warning: the following packages were found in multiple repositories.
Only the first repository in PRIORITY list order is used:

   bash : found in 'ponce' and 'slack' — using 'ponce'
```

**Install mode:** if the same package appears in more than one repository, **all versions are shown** in the terminal selector with a cyan `[repo]` suffix so the user can choose which to install:

```
> [*] vlc [alien]
  [ ] vlc [sbo]
```

### Examples

```bash
slpkg upgrade -o all                              # interactive upgrade-all
slpkg upgrade -o all --check                      # dry run, no changes made
slpkg upgrade -o all -y                           # skip confirmation prompt
slpkg upgrade -o all -D                           # use dialog interface for selection
slpkg upgrade -o all --repos-priority alien ponce # override repo order this run only

slpkg install vlc -o all                          # search all repos, choose which to install
slpkg install vlc -o all --check                  # dry run, show what would be installed
slpkg install vlc -o all -y                       # skip confirmation prompt
```

> `"*"` is accepted as a synonym for `all` (e.g. `slpkg upgrade -o "*"`) for backward compatibility.

Use `--repos-priority NAME [NAME ...]` to temporarily override the `[ALL_REPOS] PRIORITY` order for a single run without modifying `repositories.toml`. Only the named repositories are processed, filtered to those currently enabled. Use `slpkg repo --priority` to make a permanent change.
