|
| 1 | +--- |
| 2 | +date: "2023-03-25T00:00:00+00:00" |
| 3 | +title: "Alpine Packages Repository" |
| 4 | +slug: "packages/alpine" |
| 5 | +draft: false |
| 6 | +toc: false |
| 7 | +menu: |
| 8 | + sidebar: |
| 9 | + parent: "packages" |
| 10 | + name: "Alpine" |
| 11 | + weight: 4 |
| 12 | + identifier: "alpine" |
| 13 | +--- |
| 14 | + |
| 15 | +# Alpine Packages Repository |
| 16 | + |
| 17 | +Publish [Alpine](https://pkgs.alpinelinux.org/) packages for your user or organization. |
| 18 | + |
| 19 | +**Table of Contents** |
| 20 | + |
| 21 | +{{< toc >}} |
| 22 | + |
| 23 | +## Requirements |
| 24 | + |
| 25 | +To work with the Alpine registry, you need to use a HTTP client like `curl` to upload and a package manager like `apk` to consume packages. |
| 26 | + |
| 27 | +The following examples use `apk`. |
| 28 | + |
| 29 | +## Configuring the package registry |
| 30 | + |
| 31 | +To register the Alpine registry add the url to the list of known apk sources (`/etc/apk/repositories`): |
| 32 | + |
| 33 | +``` |
| 34 | +https://gitea.example.com/api/packages/{owner}/alpine/<branch>/<repository> |
| 35 | +``` |
| 36 | + |
| 37 | +| Placeholder | Description | |
| 38 | +| ------------ | ----------- | |
| 39 | +| `owner` | The owner of the packages. | |
| 40 | +| `branch` | The branch to use. | |
| 41 | +| `repository` | The repository 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 | +``` |
| 46 | +https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/alpine/<branch>/<repository> |
| 47 | +``` |
| 48 | + |
| 49 | +The Alpine registry files are signed with a RSA key which must be known to apk. Download the public key and store it in `/etc/apk/keys/`: |
| 50 | + |
| 51 | +```shell |
| 52 | +curl -JO https://gitea.example.com/api/packages/{owner}/alpine/key |
| 53 | +``` |
| 54 | + |
| 55 | +Afterwards update the local package index: |
| 56 | + |
| 57 | +```shell |
| 58 | +apk update |
| 59 | +``` |
| 60 | + |
| 61 | +## Publish a package |
| 62 | + |
| 63 | +To publish an Alpine package (`*.apk`), perform a HTTP `PUT` operation with the package content in the request body. |
| 64 | + |
| 65 | +``` |
| 66 | +PUT https://gitea.example.com/api/packages/{owner}/alpine/{branch}/{repository} |
| 67 | +``` |
| 68 | + |
| 69 | +| Parameter | Description | |
| 70 | +| ------------ | ----------- | |
| 71 | +| `owner` | The owner of the package. | |
| 72 | +| `branch` | The branch may match the release version of the OS, ex: `v3.17`. | |
| 73 | +| `repository` | The repository can be used [to group packages](https://wiki.alpinelinux.org/wiki/Repositories) 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.apk \ |
| 80 | + https://gitea.example.com/api/packages/testuser/alpine/v3.17/main |
| 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 file first. |
| 85 | + |
| 86 | +The server responds 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, branch, repository 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 an Alpine 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}/alpine/{branch}/{repository}/{architecture}/{filename} |
| 100 | +``` |
| 101 | + |
| 102 | +| Parameter | Description | |
| 103 | +| -------------- | ----------- | |
| 104 | +| `owner` | The owner of the package. | |
| 105 | +| `branch` | The branch to use. | |
| 106 | +| `repository` | The repository to use. | |
| 107 | +| `architecture` | The package architecture. | |
| 108 | +| `filename` | The file to delete. |
| 109 | + |
| 110 | +Example request using HTTP Basic authentication: |
| 111 | + |
| 112 | +```shell |
| 113 | +curl --user your_username:your_token_or_password -X DELETE \ |
| 114 | + https://gitea.example.com/api/packages/testuser/alpine/v3.17/main/test-package-1.0.0.apk |
| 115 | +``` |
| 116 | + |
| 117 | +The server responds with the following HTTP Status codes. |
| 118 | + |
| 119 | +| HTTP Status Code | Meaning | |
| 120 | +| ----------------- | ------- | |
| 121 | +| `204 No Content` | Success | |
| 122 | +| `404 Not Found` | The package or file was not found. | |
| 123 | + |
| 124 | +## Install a package |
| 125 | + |
| 126 | +To install a package from the Alpine registry, execute the following commands: |
| 127 | + |
| 128 | +```shell |
| 129 | +# use latest version |
| 130 | +apk add {package_name} |
| 131 | +# use specific version |
| 132 | +apk add {package_name}={package_version} |
| 133 | +``` |
0 commit comments