|
| 1 | +--- |
| 2 | +date: "2023-01-07T00:00:00+00:00" |
| 3 | +title: "Debian Packages Repository" |
| 4 | +slug: "packages/debian" |
| 5 | +draft: false |
| 6 | +toc: false |
| 7 | +menu: |
| 8 | + sidebar: |
| 9 | + parent: "packages" |
| 10 | + name: "Debian" |
| 11 | + weight: 35 |
| 12 | + identifier: "debian" |
| 13 | +--- |
| 14 | + |
| 15 | +# Debian Packages Repository |
| 16 | + |
| 17 | +Publish [Debian](https://www.debian.org/distrib/packages) packages for your user or organization. |
| 18 | + |
| 19 | +**Table of Contents** |
| 20 | + |
| 21 | +{{< toc >}} |
| 22 | + |
| 23 | +## Requirements |
| 24 | + |
| 25 | +To work with the Debian registry, you need to use a HTTP client like `curl` to upload and a package manager like `apt` to consume packages. |
| 26 | + |
| 27 | +The following examples use `apt`. |
| 28 | + |
| 29 | +## Configuring the package registry |
| 30 | + |
| 31 | +To register the Debian registry add the url to the list of known apt sources: |
| 32 | + |
| 33 | +```shell |
| 34 | +echo "deb https://gitea.example.com/api/packages/{owner}/debian {distribution} {component}" | sudo tee -a /etc/apt/sources.list.d/gitea.list |
| 35 | +``` |
| 36 | + |
| 37 | +| Placeholder | Description | |
| 38 | +| -------------- | ----------- | |
| 39 | +| `owner` | The owner of the package. | |
| 40 | +| `distribution` | The distribution to use. | |
| 41 | +| `component` | The component to use. | |
| 42 | + |
| 43 | +If the registry is private, provide credentials in the url. You can use a password or a [personal access token]({{< relref "doc/development/api-usage.en-us.md#authentication" >}}): |
| 44 | + |
| 45 | +```shell |
| 46 | +echo "deb https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/debian {distribution} {component}" | sudo tee -a /etc/apt/sources.list.d/gitea.list |
| 47 | +``` |
| 48 | + |
| 49 | +The Debian registry files are signed with a PGP key which must be known to apt: |
| 50 | + |
| 51 | +```shell |
| 52 | +sudo curl https://gitea.example.com/api/packages/{owner}/debian/repository.key -o /etc/apt/trusted.gpg.d/gitea-{owner}.asc |
| 53 | +``` |
| 54 | + |
| 55 | +Afterwards update the local package index: |
| 56 | + |
| 57 | +```shell |
| 58 | +apt update |
| 59 | +``` |
| 60 | + |
| 61 | +## Publish a package |
| 62 | + |
| 63 | +To publish a Debian package (`*.deb`), perform a HTTP PUT operation with the package content in the request body. |
| 64 | + |
| 65 | +``` |
| 66 | +PUT https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/upload |
| 67 | +``` |
| 68 | + |
| 69 | +| Parameter | Description | |
| 70 | +| -------------- | ----------- | |
| 71 | +| `owner` | The owner of the package. | |
| 72 | +| `distribution` | The distribution may match the release name of the OS, ex: `bionic`. | |
| 73 | +| `component` | The component can be used to group packages or just `main` or similar. | |
| 74 | + |
| 75 | +Example request using HTTP Basic authentication: |
| 76 | + |
| 77 | +```shell |
| 78 | +curl --user your_username:your_password_or_token \ |
| 79 | + --upload-file path/to/file.deb \ |
| 80 | + https://gitea.example.com/api/packages/testuser/debian/pool/bionic/main/upload |
| 81 | +``` |
| 82 | + |
| 83 | +If you are using 2FA or OAuth use a [personal access token]({{< relref "doc/development/api-usage.en-us.md#authentication" >}}) instead of the password. |
| 84 | +You cannot publish a file with the same name twice to a package. You must delete the existing package version first. |
| 85 | + |
| 86 | +The server reponds with the following HTTP Status codes. |
| 87 | + |
| 88 | +| HTTP Status Code | Meaning | |
| 89 | +| ----------------- | ------- | |
| 90 | +| `201 Created` | The package has been published. | |
| 91 | +| `400 Bad Request` | The package name, version, distribution, component or architecture are invalid. | |
| 92 | +| `409 Conflict` | A package file with the same combination of parameters exist already in the package. | |
| 93 | + |
| 94 | +## Delete a package |
| 95 | + |
| 96 | +To delete a Debian package perform a HTTP DELETE operation. This will delete the package version too if there is no file left. |
| 97 | + |
| 98 | +``` |
| 99 | +DELETE https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/{package_name}/{package_version}/{architecture} |
| 100 | +``` |
| 101 | + |
| 102 | +| Parameter | Description | |
| 103 | +| ----------------- | ----------- | |
| 104 | +| `owner` | The owner of the package. | |
| 105 | +| `package_name` | The package name. | |
| 106 | +| `package_version` | The package version. | |
| 107 | +| `distribution` | The package distribution. | |
| 108 | +| `component` | The package component. | |
| 109 | +| `architecture` | The package architecture. | |
| 110 | + |
| 111 | +Example request using HTTP Basic authentication: |
| 112 | + |
| 113 | +```shell |
| 114 | +curl --user your_username:your_token_or_password -X DELETE \ |
| 115 | + https://gitea.example.com/api/packages/testuser/debian/pools/bionic/main/test-package/1.0.0/amd64 |
| 116 | +``` |
| 117 | + |
| 118 | +The server reponds with the following HTTP Status codes. |
| 119 | + |
| 120 | +| HTTP Status Code | Meaning | |
| 121 | +| ----------------- | ------- | |
| 122 | +| `204 No Content` | Success | |
| 123 | +| `404 Not Found` | The package or file was not found. | |
| 124 | + |
| 125 | +## Install a package |
| 126 | + |
| 127 | +To install a package from the Debian registry, execute the following commands: |
| 128 | + |
| 129 | +```shell |
| 130 | +# use latest version |
| 131 | +apt install {package_name} |
| 132 | +# use specific version |
| 133 | +apt install {package_name}={package_version} |
| 134 | +``` |
0 commit comments