debian-mirror-gitlab/doc/user/packages/debian_repository/index.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

263 lines
8.7 KiB
Markdown
Raw Normal View History

2021-09-30 23:02:18 +05:30
---
stage: Package
2023-01-13 00:05:48 +05:30
group: Package Registry
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2021-09-30 23:02:18 +05:30
---
# Debian packages in the Package Registry **(FREE)**
2021-10-27 15:23:28 +05:30
> - Debian API [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42670) in GitLab 13.5.
> - Debian group API [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66188) in GitLab 14.2.
> - [Deployed behind a feature flag](../../feature_flags.md), disabled by default.
2021-09-30 23:02:18 +05:30
WARNING:
The Debian package registry for GitLab is under development and isn't ready for production use due to
2021-11-18 22:05:49 +05:30
limited functionality. This [epic](https://gitlab.com/groups/gitlab-org/-/epics/6057) details the remaining
work and timelines to make it production ready.
2021-09-30 23:02:18 +05:30
Publish Debian packages in your project's Package Registry. Then install the
packages whenever you need to use them as a dependency.
Project and Group packages are supported.
For documentation of the specific API endpoints that Debian package manager
clients use, see the [Debian API documentation](../../../api/packages/debian.md).
2023-05-27 22:25:52 +05:30
Prerequisites:
- The `dpkg-deb` binary must be installed on the GitLab instance.
This binary is usually provided by the [`dpkg` package](https://wiki.debian.org/Teams/Dpkg/Downstream),
installed by default on Debian and derivatives.
2021-10-27 15:23:28 +05:30
## Enable the Debian API **(FREE SELF)**
2021-09-30 23:02:18 +05:30
Debian repository support is still a work in progress. It's gated behind a feature flag that's
**disabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../../administration/feature_flags.md)
can opt to enable it.
To enable it:
```ruby
Feature.enable(:debian_packages)
```
To disable it:
```ruby
Feature.disable(:debian_packages)
```
2021-10-27 15:23:28 +05:30
## Enable the Debian group API **(FREE SELF)**
The Debian group repository is also behind a second feature flag that is disabled by default.
To enable it:
```ruby
Feature.enable(:debian_group_packages)
```
To disable it:
```ruby
Feature.disable(:debian_group_packages)
```
2021-09-30 23:02:18 +05:30
## Build a Debian package
Creating a Debian package is documented [on the Debian Wiki](https://wiki.debian.org/Packaging).
2023-04-23 21:23:45 +05:30
## Authenticate to the Debian endpoints
Authentication methods differs between [distributions APIs](#authenticate-to-the-debian-distributions-apis)
and [package repositories](#authenticate-to-the-debian-package-repositories).
2021-10-27 15:23:28 +05:30
2023-04-23 21:23:45 +05:30
### Authenticate to the Debian distributions APIs
2021-10-27 15:23:28 +05:30
2023-04-23 21:23:45 +05:30
To create, read, update, or delete a distribution, you need one of the following:
- [Personal access token](../../../api/rest/index.md#personalprojectgroup-access-tokens),
using `--header "PRIVATE-TOKEN: <personal_access_token>"`
- [Deploy token](../../project/deploy_tokens/index.md)
using `--header "Deploy-Token: <deploy_token>"`
2021-11-11 11:23:49 +05:30
- [CI/CD job token](../../../ci/jobs/ci_job_token.md)
2023-04-23 21:23:45 +05:30
using `--header "Job-Token: <job_token>"`
### Authenticate to the Debian Package Repositories
To publish a package, or install a private package, you need to use basic authentication,
with one of the following:
- [Personal access token](../../../api/rest/index.md#personalprojectgroup-access-tokens),
using `<username>:<personal_access_token>`
2021-10-27 15:23:28 +05:30
- [Deploy token](../../project/deploy_tokens/index.md)
2023-04-23 21:23:45 +05:30
using `<deploy_token_name>:<deploy_token>`
- [CI/CD job token](../../../ci/jobs/ci_job_token.md)
using `gitlab-ci-token:<job_token>`
2021-10-27 15:23:28 +05:30
2021-09-30 23:02:18 +05:30
## Create a Distribution
2023-06-20 00:43:36 +05:30
At the project level, Debian packages are published with **Debian distributions**. At the
group level, Debian packages are aggregated from the projects in the group provided that:
- The project visibility is set to `public`.
- The Debian `codename` for the group matches the Debian `codename` for the project.
2021-09-30 23:02:18 +05:30
2023-04-23 21:23:45 +05:30
To create a project-level distribution using a personal access token:
2021-09-30 23:02:18 +05:30
```shell
2023-04-23 21:23:45 +05:30
curl --request POST --header "PRIVATE-TOKEN: <personal_access_token>" \
"https://gitlab.example.com/api/v4/projects/<project_id>/debian_distributions?codename=<codename>"
2021-09-30 23:02:18 +05:30
```
2023-04-23 21:23:45 +05:30
Example response with `codename=sid`:
2021-09-30 23:02:18 +05:30
```json
{
"id": 1,
2023-04-23 21:23:45 +05:30
"codename": "sid",
2021-09-30 23:02:18 +05:30
"suite": null,
"origin": null,
"label": null,
"version": null,
"description": null,
"valid_time_duration_seconds": null,
"components": [
"main"
],
"architectures": [
"all",
"amd64"
]
}
```
More information on Debian distribution APIs:
- [Debian project distributions API](../../../api/packages/debian_project_distributions.md)
- [Debian group distributions API](../../../api/packages/debian_group_distributions.md)
## Publish a package
Once built, several files are created:
- `.deb` files: the binary packages
- `.udeb` files: lightened .deb files, used for Debian-Installer (if needed)
2023-05-27 22:25:52 +05:30
- `.ddeb` files: Ubuntu debug .deb files (if needed)
2021-09-30 23:02:18 +05:30
- `.tar.{gz,bz2,xz,...}` files: Source files
- `.dsc` file: Source metadata, and list of source files (with hashes)
- `.buildinfo` file: Used for Reproducible builds (optional)
- `.changes` file: Upload metadata, and list of uploaded files (all the above)
2023-04-23 21:23:45 +05:30
To upload these files, you can use `dput-ng >= 1.32` (Debian bullseye).
`<username>` and `<password>` are defined
[as above](#authenticate-to-the-debian-package-repositories):
2021-09-30 23:02:18 +05:30
```shell
cat <<EOF > dput.cf
[gitlab]
method = https
2023-04-23 21:23:45 +05:30
fqdn = <username>:<password>@gitlab.example.com
2021-09-30 23:02:18 +05:30
incoming = /api/v4/projects/<project_id>/packages/debian
EOF
dput --config=dput.cf --unchecked --no-upload-log gitlab <your_package>.changes
```
2023-06-20 00:43:36 +05:30
## Upload a package with explicit distribution and component
2023-04-23 21:23:45 +05:30
2023-06-20 00:43:36 +05:30
> Upload with explicit distribution and component [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/101838) in GitLab 15.9.
2023-04-23 21:23:45 +05:30
When you don't have access to `.changes` file, you can directly upload a `.deb` by passing
distribution `codename` and target `component` as parameters with
your [credentials](#authenticate-to-the-debian-package-repositories).
For example, to upload to component `main` of distribution `sid` using a personal access token:
```shell
curl --request PUT --user "<username>:<personal_access_token>" \
2023-06-20 00:43:36 +05:30
--get --data "distribution=sid" --data "component=main" \
"https://gitlab.example.com/api/v4/projects/<project_id>/packages/debian/" \
2023-04-23 21:23:45 +05:30
--upload-file /path/to/your.deb
```
2021-09-30 23:02:18 +05:30
## Install a package
2021-10-27 15:23:28 +05:30
To install a package:
1. Configure the repository:
2023-05-27 22:25:52 +05:30
If you are using a private project, add your [credentials](#authenticate-to-the-debian-package-repositories) to your apt configuration:
2021-10-27 15:23:28 +05:30
2023-05-27 22:25:52 +05:30
```shell
echo 'machine gitlab.example.com login <username> password <password>' \
| sudo tee /etc/apt/auth.conf.d/gitlab_project.conf
```
2021-10-27 15:23:28 +05:30
2023-05-27 22:25:52 +05:30
Download your distribution key using your [credentials](#authenticate-to-the-debian-distributions-apis):
2021-12-11 22:18:48 +05:30
2023-05-27 22:25:52 +05:30
```shell
sudo mkdir -p /usr/local/share/keyrings
curl --header "PRIVATE-TOKEN: <your_access_token>" \
"https://gitlab.example.com/api/v4/projects/<project_id>/debian_distributions/<codename>/key.asc" \
| \
gpg --dearmor \
| \
sudo tee /usr/local/share/keyrings/<codename>-archive-keyring.gpg \
> /dev/null
```
2021-12-11 22:18:48 +05:30
2023-05-27 22:25:52 +05:30
Add your project as a source:
2021-10-27 15:23:28 +05:30
2023-05-27 22:25:52 +05:30
```shell
echo 'deb [ signed-by=/usr/local/share/keyrings/<codename>-archive-keyring.gpg ] https://gitlab.example.com/api/v4/projects/<project_id>/packages/debian <codename> <component1> <component2>' \
| sudo tee /etc/apt/sources.list.d/gitlab_project.list
sudo apt-get update
```
2021-10-27 15:23:28 +05:30
1. Install the package:
2023-05-27 22:25:52 +05:30
```shell
sudo apt-get -y install -t <codename> <package-name>
```
2022-10-11 01:57:18 +05:30
## Download a source package
To download a source package:
1. Configure the repository:
2023-05-27 22:25:52 +05:30
If you are using a private project, add your [credentials](#authenticate-to-the-debian-package-repositories) to your apt configuration:
2022-10-11 01:57:18 +05:30
2023-05-27 22:25:52 +05:30
```shell
echo 'machine gitlab.example.com login <username> password <password>' \
| sudo tee /etc/apt/auth.conf.d/gitlab_project.conf
```
2022-10-11 01:57:18 +05:30
2023-05-27 22:25:52 +05:30
Download your distribution key using your [credentials](#authenticate-to-the-debian-distributions-apis):
2022-10-11 01:57:18 +05:30
2023-05-27 22:25:52 +05:30
```shell
sudo mkdir -p /usr/local/share/keyrings
curl --header "PRIVATE-TOKEN: <your_access_token>" \
"https://gitlab.example.com/api/v4/projects/<project_id>/debian_distributions/<codename>/key.asc" \
| \
gpg --dearmor \
| \
sudo tee /usr/local/share/keyrings/<codename>-archive-keyring.gpg \
> /dev/null
```
2022-10-11 01:57:18 +05:30
2023-05-27 22:25:52 +05:30
Add your project as a source:
2022-10-11 01:57:18 +05:30
2023-05-27 22:25:52 +05:30
```shell
echo 'deb-src [ signed-by=/usr/local/share/keyrings/<codename>-archive-keyring.gpg ] https://gitlab.example.com/api/v4/projects/<project_id>/packages/debian <codename> <component1> <component2>' \
| sudo tee /etc/apt/sources.list.d/gitlab_project-sources.list
sudo apt-get update
```
2022-10-11 01:57:18 +05:30
1. Download the source package:
2023-05-27 22:25:52 +05:30
```shell
sudo apt-get source -t <codename> <package-name>
```