|
1 | | -# Creating an apt repo on an OCI registry |
2 | | - |
3 | | -## Step 1: Create dpkg |
4 | | -Create `hello-apt-transport-oci_0.1_all.deb` from [`helloapt-transport-oci` directory](./hello-apt-transport-oci). |
5 | | - |
6 | | -```bash |
7 | | -dpkg-deb --build --root-owner-group hello-apt-transport-oci hello-apt-transport-oci_0.1_all.deb |
8 | | -``` |
9 | | - |
10 | | -## Step 2: Create repository data |
11 | | - |
12 | | -Use [aptly](https://www.aptly.info) to create the repository data. |
13 | | - |
14 | | -```bash |
15 | | -sudo apt-get install aptly |
16 | | -``` |
17 | | - |
18 | | -```bash |
19 | | -aptly repo create hello-apt-transport-oci |
20 | | -aptly repo add hello-apt-transport-oci hello-apt-transport-oci_0.1_all.deb |
21 | | -aptly publish repo -distribution=stable -architectures=all,amd64,arm64 hello-apt-transport-oci |
22 | | -``` |
23 | | - |
24 | | -The repository data will be locally published on `~/.aptly/public`. |
25 | | - |
26 | | -```console |
27 | | -$ tree ~/.aptly/public |
28 | | -/home/USER/.aptly/public |
29 | | -├── dists |
30 | | -│ └── stable |
31 | | -│ ├── Contents-all.gz |
32 | | -│ ├── Contents-amd64.gz |
33 | | -│ ├── Contents-arm64.gz |
34 | | -│ ├── InRelease |
35 | | -│ ├── main |
36 | | -│ │ ├── binary-all |
37 | | -│ │ │ ├── Packages |
38 | | -│ │ │ ├── Packages.bz2 |
39 | | -│ │ │ ├── Packages.gz |
40 | | -│ │ │ └── Release |
41 | | -│ │ ├── binary-amd64 |
42 | | -│ │ │ ├── Packages |
43 | | -│ │ │ ├── Packages.bz2 |
44 | | -│ │ │ ├── Packages.gz |
45 | | -│ │ │ └── Release |
46 | | -│ │ ├── binary-arm64 |
47 | | -│ │ │ ├── Packages |
48 | | -│ │ │ ├── Packages.bz2 |
49 | | -│ │ │ ├── Packages.gz |
50 | | -│ │ │ └── Release |
51 | | -│ │ ├── Contents-all.gz |
52 | | -│ │ ├── Contents-amd64.gz |
53 | | -│ │ └── Contents-arm64.gz |
54 | | -│ ├── Release |
55 | | -│ └── Release.gpg |
56 | | -└── pool |
57 | | - └── main |
58 | | - └── h |
59 | | - └── hello-apt-transport-oci |
60 | | - └── hello-apt-transport-oci_0.1_all.deb |
61 | | - |
62 | | -11 directories, 22 files |
63 | | -``` |
64 | | - |
65 | | -## Step 3: Push to an OCI registry |
66 | | -Push the deb file and the `Packages` file to an OCI registry (e.g., `ghcr.io`). |
67 | | - |
68 | | -The easiest way is to use [ORAS](https://github.com/oras-project/oras) CLI. |
69 | | - |
70 | | -```bash |
71 | | -sudo apt-get install oras |
72 | | -``` |
73 | | - |
74 | | -```bash |
75 | | -echo YOUR_GITHUB_PERSONAL_ACCESS_TOKEN | docker login ghcr.io -u USERNAME --password-stdin |
76 | | -``` |
77 | | - |
78 | | -```bash |
79 | | -cd ~/.aptly/public |
80 | | -find . -type f -printf "%p:application/octet-stream\n" | xargs oras push --image-spec=v1.0 ghcr.io/USERNAME/hello-apt-transport:latest |
81 | | -``` |
82 | | - |
83 | | -- See [GHCR documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) to learn |
84 | | -how to create a [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens) (PAT) for `ghcr.io`. |
85 | | -- Use GitHub Web UI to make the image public / private. |
86 | | - |
87 | | -## Step 4: Tell users the instruction |
88 | | - |
89 | | -Tell your users how to install your package: |
90 | | - |
91 | | -> - Create `/etc/apt/sources.list.d/oci.sources` with the following content: |
92 | | -> ``` |
93 | | -> Types: deb |
94 | | -> URIs: oci://ghcr.io/USERNAME/hello-apt-transport-oci:latest |
95 | | -> Suites: stable |
96 | | -> Components: main |
97 | | -> Signed-By: /etc/apt/keyrings/USERNAME.gpg |
98 | | -> ``` |
99 | | -> |
100 | | -> - Register a GPG key: |
101 | | -> ```bash |
102 | | -> curl -fsSL https://github.com/USERNAME.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/USERNAME.gpg |
103 | | -> ``` |
| 1 | +Moved to <https://github.com/AkihiroSuda/apt-transport-oci-examples>. |
0 commit comments