Skip to content

Commit cf29cc8

Browse files
authored
Merge pull request #35 from AkihiroSuda/dev
docs: update
2 parents 69c618f + 48e5b23 commit cf29cc8

4 files changed

Lines changed: 127 additions & 48 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ jobs:
2323
- run: go test -v ./...
2424
- run: go build ./cmd/usr-lib-apt-methods-oci
2525
- run: sudo cp -a usr-lib-apt-methods-oci /usr/lib/apt/methods/oci
26-
- run: echo "deb [trusted=yes] oci://ghcr.io/akihirosuda/hello-apt-transport-oci:latest /" | sudo tee /etc/apt/sources.list.d/oci.list
26+
- run: |
27+
sudo tee /etc/apt/sources.list.d/oci.sources <<EOF
28+
Types: deb
29+
URIs: oci://ghcr.io/akihirosuda/hello-apt-transport-oci:latest
30+
Suites: stable
31+
Components: main
32+
Signed-By: /etc/apt/keyrings/AkihiroSuda.gpg
33+
EOF
34+
- run: curl -fsSL https://github.com/AkihiroSuda.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/AkihiroSuda.gpg
2735
- run: sudo apt-get update
2836
- run: sudo apt-get install hello-apt-transport-oci
2937
- run: hello-apt-transport-oci

‎README.md‎

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,57 @@
22

33
`apt-transport-oci` is an `apt-get` plugin to support distributing `*.deb` packages over an OCI registry such as `ghcr.io` .
44

5+
> [!NOTE]
6+
> "OCI" here refers to the "[Open Container Initiative](https://opencontainers.org/)", not to the "Oracle Cloud Infrastructure".
7+
58
## Motivation
69
The motivation is to distribute `*.deb` packages without running a web server but using a popular fully-managed service such as `ghcr.io`.
710

811
If GitHub could offer fully-managed apt repo, this plugin wouldn't be needed.
912

10-
## Usage
1113

12-
- Install the `apt-transport-oci` plugin onto `/usr/lib/apt/methods/oci`:
14+
## Install
15+
The `apt-transport-oci` plugin is officially [packaged](https://repology.org/project/apt-transport-oci/versions) in Debian and Ubuntu,
16+
since Debian 14 and Ubuntu 26.04.
17+
18+
```bash
19+
sudo apt install apt-transport-oci
1320
```
21+
22+
<details><summary>Build from source</summary>
23+
<p>
24+
25+
```bash
1426
sudo go build -o /usr/lib/apt/methods/oci ./cmd/usr-lib-apt-methods-oci
1527
```
1628

17-
- Create `/etc/apt/sources.list.d/oci.list` with the following content to enable [`oci://ghcr.io/akihirosuda/hello-apt-transport-oci`](https://ghcr.io/akihirosuda/hello-apt-transport-oci) repo:
29+
</p>
30+
</details>
31+
32+
## Example
33+
The following example installs the `hello-apt-transport-oci` package from the [`oci://ghcr.io/akihirosuda/hello-apt-transport-oci`](https://ghcr.io/akihirosuda/hello-apt-transport-oci) repo.
34+
35+
> [!TIP]
36+
> See [`./examples`](./examples) for how to build and push this package to your own registry.
37+
38+
- Create `/etc/apt/sources.list.d/oci.sources` with the following content:
1839
```
19-
deb [trusted=yes] oci://ghcr.io/akihirosuda/hello-apt-transport-oci:latest /
40+
Types: deb
41+
URIs: oci://ghcr.io/akihirosuda/hello-apt-transport-oci:latest
42+
Suites: stable
43+
Components: main
44+
Signed-By: /etc/apt/keyrings/AkihiroSuda.gpg
2045
```
2146

22-
- Run `sudo apt-get update && sudo apt-get install hello-apt-transport-oci`
23-
24-
```console
25-
$ sudo apt-get update
26-
...
27-
Get:7 oci://ghcr.io/akihirosuda/hello-apt-transport-oci:latest Packages [478 B]
28-
...
29-
Reading package lists... Done
47+
- Register a GPG key:
48+
```bash
49+
curl -fsSL https://github.com/AkihiroSuda.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/AkihiroSuda.gpg
3050
```
3151

32-
```console
33-
$ sudo apt-get install hello-apt-transport-oci
34-
Reading package lists... Done
35-
Building dependency tree... Done
36-
Reading state information... Done
37-
The following NEW packages will be installed:
38-
hello-apt-transport-oci
39-
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
40-
Need to get 1,106 B of archives.
41-
After this operation, 0 B of additional disk space will be used.
42-
Get:1 oci://ghcr.io/akihirosuda/hello-apt-transport-oci:latest hello-apt-transport-oci 0.0 [1,106 B]
43-
Selecting previously unselected package hello-apt-transport-oci.
44-
(Reading database ... 249739 files and directories currently installed.)
45-
Preparing to unpack .../hello-apt-transport-oci_0.0_amd64.deb ...
46-
Unpacking hello-apt-transport-oci (0.0) ...
47-
Setting up hello-apt-transport-oci (0.0) ...
52+
- Run:
53+
```bash
54+
sudo apt update
55+
sudo apt install hello-apt-transport-oci
4856
```
4957

5058
- Make sure `hello-apt-transport-oci` is installed
@@ -53,19 +61,16 @@ $ hello-apt-transport-oci
5361
Hello, apt-transport-oci
5462
```
5563

56-
### Hints
64+
## Hints
5765
- Create `/root/.docker/config.json` to enable authentication.
5866
- Non-TLS registry is supported only for 127.0.0.1
5967
- Troubleshooting: Run `apt-get -o Debug::pkgAcquire::Worker=1 update 2>&1` and grep `FailReason`
6068

61-
## Creating an apt repo
62-
See [`./examples`](./examples) .
63-
6469
## Specification
65-
The spec corresponds to the behavior of `oras push IMAGE FILE1:application/octet-stream FILE2:application/octet-stream ...` (ORAS v0.12).
70+
The spec corresponds to the behavior of `oras push --image-spec=v1.0 IMAGE FILE1:application/octet-stream FILE2:application/octet-stream ...`.
6671

6772
- An image index MAY have multiple manifests, but all the manifests SHOULD refer to the same set of layers (because `apt-get` itself supports multi-arch repo).
6873
- A layer MUST have `org.opencontainers.image.title` annotation that corresponds to the file name.
6974
- A layer SHOULD have one of the following media types:
70-
- `application/octet-stream`
71-
- `application/x-binary`
75+
- `application/octet-stream`
76+
- `application/x-binary`

‎examples/README.md‎

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,103 @@
11
# Creating an apt repo on an OCI registry
22

33
## Step 1: Create dpkg
4-
Create `hello-apt-transport-oci_0.0_amd64.deb` from [`helloapt-transport-oci` directory](./hello-apt-transport-oci).
5-
The easiest way is to use [fpm](https://fpm.readthedocs.io/).
4+
Create `hello-apt-transport-oci_0.1_all.deb` from [`helloapt-transport-oci` directory](./hello-apt-transport-oci).
65

76
```bash
8-
sudo gem install fpm
7+
dpkg-deb --build --root-owner-group hello-apt-transport-oci hello-apt-transport-oci_0.1_all.deb
98
```
109

10+
## Step 2: Create repository data
11+
12+
Use [aptly](https://www.aptly.info) to create the repository data.
13+
1114
```bash
12-
fpm -s dir -t deb -m example@example.com -n hello-apt-transport-oci -v 0.0 ./hello-apt-transport-oci/usr/bin/hello-apt-transport-oci=/usr/bin/hello-apt-transport-oci
15+
sudo apt-get install aptly
1316
```
1417

15-
## Step 2: Create metadata
16-
Create `Packages` file
17-
```
18-
dpkg-scanpackages -m . > Packages
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
1922
```
2023

21-
Hint: to create GPG-signed repo, use [`apt-ftparchive`](https://www.google.com/search?q=apt-ftparchive+gpg) .
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+
```
2264

2365
## Step 3: Push to an OCI registry
2466
Push the deb file and the `Packages` file to an OCI registry (e.g., `ghcr.io`).
2567

2668
The easiest way is to use [ORAS](https://github.com/oras-project/oras) CLI.
2769

2870
```bash
29-
curl -fsSL https://github.com/oras-project/oras/releases/download/v0.12.0/oras_0.12.0_linux_amd64.tar.gz | sudo tar Cxzv /usr/local/bin/ oras
71+
sudo apt-get install oras
3072
```
3173

3274
```bash
3375
echo YOUR_GITHUB_PERSONAL_ACCESS_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
3476
```
3577

3678
```bash
37-
oras push ghcr.io/USERNAME/hello-apt-transport-oci:latest hello-apt-transport-oci_0.0_amd64.deb:application/octet-stream Packages:application/octet-stream`
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
3881
```
3982

4083
- See [GHCR documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) to learn
41-
how to create a GitHub Personal Access Token (PAT) for `ghcr.io`.
84+
how to create a [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens) (PAT) for `ghcr.io`.
4285
- 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+
> ```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Package: hello-apt-transport-oci
2+
Version: 0.1
3+
Architecture: all
4+
Maintainer: example@example.com
5+
Description: hello apt-transport-oci

0 commit comments

Comments
 (0)