native-packages 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -1
- data/docs/_guides/apple-notarization.md +2 -0
- data/docs/_guides/distribution-recipes.md +2 -1
- data/docs/_guides/getting-started.md +4 -2
- data/docs/_guides/github-actions.md +4 -4
- data/docs/_guides/hosted-repositories.md +47 -4
- data/docs/_guides/native-recipes.md +3 -1
- data/docs/_guides/release-signing.md +3 -3
- data/docs/_guides/windows-signing.md +4 -2
- data/docs/_reference/commands.md +3 -3
- data/docs/_reference/configuration.md +2 -1
- data/docs/_reference/platforms.md +4 -4
- data/docs/_reference/troubleshooting.md +2 -2
- data/docs/index.md +3 -3
- data/examples/native-packages-all-formats.yaml +1 -1
- data/examples/native-packages-linux-distribution.yaml +1 -1
- data/examples/native-packages.yaml +1 -1
- data/lib/native_packages/apt_repository.rb +8 -18
- data/lib/native_packages/build.rb +3 -1
- data/lib/native_packages/configuration.rb +4 -2
- data/lib/native_packages/dnf_repository.rb +7 -7
- data/lib/native_packages/hosted_repository.rb +24 -0
- data/lib/native_packages/openpgp.rb +4 -2
- data/lib/native_packages/pacman_repository.rb +202 -0
- data/lib/native_packages/support.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec10e4325aa358b66b54463b9ae2b6c76bd7715f133479acc026e769cf3d70f9
|
|
4
|
+
data.tar.gz: 23f0be78b2606bb4d7e22a8117fd5c2b8120dcaf9893531d7a9e2ac693a4fb6a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e20c7c977a8d097f7c3abf4d5e372a4b0ff1ddde227d5b105ca3c51a2a6c8d2bc351cbcef849f20fd894cf088335f4924cdea483340e162418a37bbe44e106a0
|
|
7
|
+
data.tar.gz: a2662f46985ac1dae617a7527050b80ff8bab863838fe64182f1cc35fe532cc2fb96267fb918fc901508039abeb376e6ce5a477b2157eaf821dc00c0b34e037c
|
data/CONTRIBUTING.md
CHANGED
|
@@ -18,7 +18,7 @@ To check the packaged gem and standalone command:
|
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
20
|
gem build native-packages.gemspec
|
|
21
|
-
ruby test/gem_install.rb native-packages-0.
|
|
21
|
+
ruby test/gem_install.rb native-packages-0.13.0.gem
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
See [Releasing the gem](docs/releasing.md) for publication and
|
|
@@ -191,4 +191,5 @@ Once the process is tested, enable destination publication in
|
|
|
191
191
|
For package files themselves, use [Publishing a release](publishing.md).
|
|
192
192
|
To ship your AUR binary recipe in Omarchy's repository as well, see
|
|
193
193
|
[Omarchy packages](omarchy.md).
|
|
194
|
-
|
|
194
|
+
To serve signed APT, DNF or pacman repositories of your own, see
|
|
195
|
+
[Hosted package repositories](hosted-repositories.md).
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Getting started
|
|
3
|
+
seo:
|
|
4
|
+
title: "Getting started: build a DEB and RPM package"
|
|
3
5
|
description: Install native-packages and build a DEB and RPM from a compiled Linux application.
|
|
4
6
|
nav_order: 1
|
|
5
7
|
---
|
|
@@ -17,7 +19,7 @@ own compiled executable, or build the tiny example below.
|
|
|
17
19
|
You need Ruby 3.2 or later. Install the version used by these guides:
|
|
18
20
|
|
|
19
21
|
```sh
|
|
20
|
-
gem install native-packages --version 0.
|
|
22
|
+
gem install native-packages --version 0.13.0
|
|
21
23
|
```
|
|
22
24
|
|
|
23
25
|
For Linux packages, install **nFPM 2.47.0**, the helper native-packages uses to
|
|
@@ -79,7 +81,7 @@ Open the generated `native-packages.yaml` and replace its contents with:
|
|
|
79
81
|
```yaml
|
|
80
82
|
schema: 1
|
|
81
83
|
tool:
|
|
82
|
-
version: '0.
|
|
84
|
+
version: '0.13.0'
|
|
83
85
|
nfpm: '2.47.0'
|
|
84
86
|
|
|
85
87
|
nfpm:
|
|
@@ -24,7 +24,7 @@ packaging:
|
|
|
24
24
|
needs: release
|
|
25
25
|
permissions:
|
|
26
26
|
contents: write
|
|
27
|
-
uses: crmne/native-packages/.github/workflows/package.yml@v0.
|
|
27
|
+
uses: crmne/native-packages/.github/workflows/package.yml@v0.13.0
|
|
28
28
|
with:
|
|
29
29
|
version: ${{ github.ref_name }}
|
|
30
30
|
publish: true
|
|
@@ -39,7 +39,7 @@ The configuration must include `release.repository` and a `release_asset`
|
|
|
39
39
|
for each selected target. See [Publishing a release](publishing.md).
|
|
40
40
|
|
|
41
41
|
Use the same native-packages release for the workflow and `tool.version`.
|
|
42
|
-
For an immutable workflow reference, replace `v0.
|
|
42
|
+
For an immutable workflow reference, replace `v0.13.0` with that release's
|
|
43
43
|
full commit SHA.
|
|
44
44
|
|
|
45
45
|
## Build without publishing
|
|
@@ -57,7 +57,7 @@ permissions:
|
|
|
57
57
|
contents: read
|
|
58
58
|
jobs:
|
|
59
59
|
packaging:
|
|
60
|
-
uses: crmne/native-packages/.github/workflows/package.yml@v0.
|
|
60
|
+
uses: crmne/native-packages/.github/workflows/package.yml@v0.13.0
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
Validation does not compile the app or check that future release inputs exist.
|
|
@@ -72,7 +72,7 @@ packaging:
|
|
|
72
72
|
needs: build
|
|
73
73
|
permissions:
|
|
74
74
|
contents: write
|
|
75
|
-
uses: crmne/native-packages/.github/workflows/package.yml@v0.
|
|
75
|
+
uses: crmne/native-packages/.github/workflows/package.yml@v0.13.0
|
|
76
76
|
with:
|
|
77
77
|
version: '1.2.3'
|
|
78
78
|
source-artifact: linux-binaries
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Hosted package repositories
|
|
3
|
-
description: Publish signed APT, DNF and Flatpak repositories that users add once and update with their package manager.
|
|
3
|
+
description: Publish signed APT, DNF, pacman and Flatpak repositories that users add once and update with their package manager.
|
|
4
4
|
nav_order: 13
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -50,6 +50,10 @@ dnf:
|
|
|
50
50
|
directory: ../hello-site/rpm
|
|
51
51
|
url: https://example.org/rpm
|
|
52
52
|
signing_key: 0123456789ABCDEF0123456789ABCDEF01234567
|
|
53
|
+
pacman:
|
|
54
|
+
directory: ../hello-site/arch
|
|
55
|
+
url: https://example.org/arch
|
|
56
|
+
signing_key: 0123456789ABCDEF0123456789ABCDEF01234567
|
|
53
57
|
flatpak:
|
|
54
58
|
# The app's id, runtime, command and permissions, as for any Flatpak.
|
|
55
59
|
repository:
|
|
@@ -64,8 +68,9 @@ flatpak:
|
|
|
64
68
|
| `directory` | Required. Where the repository is written, relative to the configuration file. |
|
|
65
69
|
| `url` | Required. The `https://` URL at which that directory is served. |
|
|
66
70
|
| `signing_key` | Required. The signing key's full fingerprint. |
|
|
67
|
-
| `keep` | APT and
|
|
71
|
+
| `keep` | APT, DNF and pacman only. How many versions of each package and architecture to keep. Defaults to `3`. |
|
|
68
72
|
| `suite`, `component` | APT only. Default to `stable` and `main`. |
|
|
73
|
+
| `name` | APT, DNF and pacman only. The repository's name: it names the key and source files users download, APT's `Origin` and `Label`, and the section in `.repo` files and `pacman.conf`. Defaults to the package name; set it when several apps share the repository. |
|
|
69
74
|
| `title`, `homepage` | Flatpak only. The repository's name in software centers (defaults to the package name) and an `https://` homepage. |
|
|
70
75
|
|
|
71
76
|
## 3. Publish
|
|
@@ -74,7 +79,7 @@ Build as usual, then publish the build to the repositories:
|
|
|
74
79
|
|
|
75
80
|
```sh
|
|
76
81
|
native-packages build --version 1.2.3
|
|
77
|
-
native-packages publish --from dist/packages/1.2.3 --to github,apt,dnf,flatpak
|
|
82
|
+
native-packages publish --from dist/packages/1.2.3 --to github,apt,dnf,pacman,flatpak
|
|
78
83
|
```
|
|
79
84
|
|
|
80
85
|
Each publication adds the build's packages to what the directory already
|
|
@@ -82,6 +87,20 @@ holds, removes versions beyond `keep`, and rewrites and signs the indexes. A
|
|
|
82
87
|
file that is already published can only be published again unchanged. Then
|
|
83
88
|
commit and push the directory.
|
|
84
89
|
|
|
90
|
+
### One repository for several apps
|
|
91
|
+
|
|
92
|
+
Several apps can publish into the same directories. The APT, DNF and pacman
|
|
93
|
+
indexes are rebuilt from every package in the directory, whichever app
|
|
94
|
+
published it, and `keep` counts versions of each package separately, so
|
|
95
|
+
publishing one app leaves the others' packages listed. For this to hold, the
|
|
96
|
+
directory must contain everything already published before you publish into
|
|
97
|
+
it: when the repository lives in object storage rather than a Git checkout,
|
|
98
|
+
download it first, publish, then upload it, and let one release publish at a
|
|
99
|
+
time. Use the same signing key for every app, and give each repository the
|
|
100
|
+
same `name` in every app's configuration, such as the name of your site,
|
|
101
|
+
rather than an app's: users then add one `example.sources`, `example.repo` or
|
|
102
|
+
`[example]` section and get every app from it.
|
|
103
|
+
|
|
85
104
|
## APT
|
|
86
105
|
|
|
87
106
|
`publish --to apt` copies each `.deb` into `pool/main/h/hello/` and writes
|
|
@@ -121,6 +140,30 @@ for Zypper (`zypper addrepo https://example.org/rpm/hello.repo`). Install
|
|
|
121
140
|
`createrepo_c` (in the `createrepo-c` package on Debian and Ubuntu) on the
|
|
122
141
|
machine that publishes.
|
|
123
142
|
|
|
143
|
+
## pacman
|
|
144
|
+
|
|
145
|
+
`publish --to pacman` copies each Arch package into a directory per
|
|
146
|
+
architecture, such as `x86_64/` and `aarch64/` (a package built for `any`
|
|
147
|
+
goes into each), and signs it beside itself as `.sig`. It then writes the
|
|
148
|
+
databases pacman reads, `hello.db` and `hello.files`, the way `repo-add`
|
|
149
|
+
does, without pacman's own tools, and signs them. Static hosts serve no
|
|
150
|
+
symbolic links, so `hello.db.tar.gz` and `hello.files.tar.gz` are copies of
|
|
151
|
+
the same files rather than links. Beside the architectures goes the public key
|
|
152
|
+
as `hello.asc`. Users install with:
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
curl -fsSL https://example.org/arch/hello.asc | sudo pacman-key --add -
|
|
156
|
+
sudo pacman-key --lsign-key 0123456789ABCDEF0123456789ABCDEF01234567
|
|
157
|
+
printf '\n[hello]\nSigLevel = Required\nServer = https://example.org/arch/$arch\n' | sudo tee -a /etc/pacman.conf
|
|
158
|
+
sudo pacman -Syu hello
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`SigLevel = Required` makes pacman check the signatures of both the
|
|
162
|
+
databases and the packages. Signatures are binary, as pacman requires, and
|
|
163
|
+
are served beside the packages rather than embedded in the database, as
|
|
164
|
+
`repo-add` does by default. Publishing needs `bsdtar` (libarchive), which
|
|
165
|
+
builds of Arch packages already use.
|
|
166
|
+
|
|
124
167
|
## Flatpak
|
|
125
168
|
|
|
126
169
|
`publish --to flatpak` imports each Flatpak bundle into an OSTree
|
|
@@ -155,7 +198,7 @@ release job can check out the site beside the app:
|
|
|
155
198
|
repository: example/hello-site
|
|
156
199
|
path: hello-site
|
|
157
200
|
token: ${{ secrets.SITE_TOKEN }}
|
|
158
|
-
- run: native-packages publish --from dist/native-packages --to apt,dnf,flatpak
|
|
201
|
+
- run: native-packages publish --from dist/native-packages --to apt,dnf,pacman,flatpak
|
|
159
202
|
env:
|
|
160
203
|
NATIVE_PACKAGES_GPG_KEY: ${{ secrets.PACKAGES_GPG_KEY }}
|
|
161
204
|
- run: |
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: macOS and Windows installers
|
|
3
|
+
seo:
|
|
4
|
+
title: DMG, MSI and Inno Setup installers
|
|
3
5
|
description: Connect your DMG, MSI or Inno Setup script to the same build and publication process as your Linux packages.
|
|
4
6
|
nav_order: 5
|
|
5
7
|
---
|
|
@@ -31,7 +33,7 @@ Here is a complete configuration for an ARM64 Mac app and an x86-64 Windows app:
|
|
|
31
33
|
```yaml
|
|
32
34
|
schema: 1
|
|
33
35
|
tool:
|
|
34
|
-
version: '0.
|
|
36
|
+
version: '0.13.0'
|
|
35
37
|
nfpm: '2.47.0'
|
|
36
38
|
nfpm:
|
|
37
39
|
name: hello
|
|
@@ -67,7 +67,7 @@ Package publication's separate `packaging-checksums.txt` is also unchanged.
|
|
|
67
67
|
|
|
68
68
|
## Attest in the application's build job
|
|
69
69
|
|
|
70
|
-
The examples use `v0.
|
|
70
|
+
The examples use `v0.13.0` for readability. For release workflows, replace it
|
|
71
71
|
with that release's reviewed full commit SHA, not a mutable branch.
|
|
72
72
|
After producing the final package, before uploading it, add this step to the
|
|
73
73
|
job that built it:
|
|
@@ -79,7 +79,7 @@ permissions:
|
|
|
79
79
|
attestations: write
|
|
80
80
|
steps:
|
|
81
81
|
# Existing checkout, build, platform signing and packaging steps go here.
|
|
82
|
-
- uses: crmne/native-packages/.github/actions/attest@v0.
|
|
82
|
+
- uses: crmne/native-packages/.github/actions/attest@v0.13.0
|
|
83
83
|
with:
|
|
84
84
|
subject-path: dist/*.tar.gz
|
|
85
85
|
```
|
|
@@ -108,7 +108,7 @@ and install Ruby 3.2 or later with Ed25519-capable OpenSSL before the signing
|
|
|
108
108
|
step. Then call:
|
|
109
109
|
|
|
110
110
|
```yaml
|
|
111
|
-
- uses: crmne/native-packages/.github/actions/sign-release@v0.
|
|
111
|
+
- uses: crmne/native-packages/.github/actions/sign-release@v0.13.0
|
|
112
112
|
with:
|
|
113
113
|
directory: dist/release
|
|
114
114
|
public-key: assets/update-public-key.hex
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Windows code signing
|
|
3
|
-
|
|
3
|
+
seo:
|
|
4
|
+
title: "Windows code signing: Azure Artifact Signing"
|
|
5
|
+
description: Sign Windows executables and installers with Azure Artifact Signing (formerly Trusted Signing) from GitHub Actions through OIDC, with no stored secret.
|
|
4
6
|
nav_order: 7
|
|
5
7
|
---
|
|
6
8
|
|
|
@@ -150,7 +152,7 @@ jobs:
|
|
|
150
152
|
- uses: ruby/setup-ruby@v1
|
|
151
153
|
with:
|
|
152
154
|
ruby-version: '4.0'
|
|
153
|
-
- run: gem install native-packages --version 0.
|
|
155
|
+
- run: gem install native-packages --version 0.13.0 --no-document
|
|
154
156
|
- run: cargo build --locked --release --target x86_64-pc-windows-msvc
|
|
155
157
|
- name: Sign in to Azure for code signing
|
|
156
158
|
if: vars.AZURE_SIGNING_PROFILE != ''
|
data/docs/_reference/commands.md
CHANGED
|
@@ -98,8 +98,8 @@ native-packages publish --from dist/linux --to github --target linux-amd64
|
|
|
98
98
|
|
|
99
99
|
`--from` selects the build directory; `--to` lists destinations separated by
|
|
100
100
|
commas. `github` uploads release assets, `snapcraft` uploads snaps to the
|
|
101
|
-
Snap Store, and `apt`, `dnf` and `flatpak` write the signed repositories configured under
|
|
102
|
-
`apt`, `dnf` and `flatpak.repository`. Other names select entries or groups in `repositories`.
|
|
101
|
+
Snap Store, and `apt`, `dnf`, `pacman` and `flatpak` write the signed repositories configured under
|
|
102
|
+
`apt`, `dnf`, `pacman` and `flatpak.repository`. Other names select entries or groups in `repositories`.
|
|
103
103
|
|
|
104
104
|
The build must be complete and its recorded files unmodified. Repeated
|
|
105
105
|
`--target` options require exactly those targets, with all their formats.
|
|
@@ -222,7 +222,7 @@ If several gem versions are installed, RubyGems lets you select the one required
|
|
|
222
222
|
by the configuration:
|
|
223
223
|
|
|
224
224
|
```sh
|
|
225
|
-
native-packages _0.
|
|
225
|
+
native-packages _0.13.0_ build --version 1.2.3
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
Bundler also works if you prefer to manage the gem in a Gemfile.
|
|
@@ -28,7 +28,7 @@ expressions. Use the replacement values listed below.
|
|
|
28
28
|
| Field | Purpose |
|
|
29
29
|
| --- | --- |
|
|
30
30
|
| `schema` | Required. Set to `1`. |
|
|
31
|
-
| `tool.version` | Required. Exact native-packages version, such as `'0.
|
|
31
|
+
| `tool.version` | Required. Exact native-packages version, such as `'0.13.0'`. |
|
|
32
32
|
| `tool.nfpm` | Required. Set to `'2.47.0'`, including in native-only configurations. |
|
|
33
33
|
| `nfpm` | Shared package metadata and installed-file mappings, or a relative YAML filename. Requires `name`. |
|
|
34
34
|
| `targets` | Required. Named build targets; use `{}` for recipe-only projects. |
|
|
@@ -45,6 +45,7 @@ expressions. Use the replacement values listed below.
|
|
|
45
45
|
| `snap` | Required by `snap` targets: the base, confinement and apps, and the Snap Store channels. See [Snap](platforms.md#snap). |
|
|
46
46
|
| `apt` | Optional signed APT repository for `publish --to apt`. See [Hosted package repositories](../_guides/hosted-repositories.md). |
|
|
47
47
|
| `dnf` | Optional signed DNF repository for `publish --to dnf`. See [Hosted package repositories](../_guides/hosted-repositories.md). |
|
|
48
|
+
| `pacman` | Optional signed pacman repository for `publish --to pacman`. See [Hosted package repositories](../_guides/hosted-repositories.md). |
|
|
48
49
|
|
|
49
50
|
Quote tool versions so they remain strings. A version mismatch reports the
|
|
50
51
|
command needed to install and select the configured gem.
|
|
@@ -16,7 +16,7 @@ libraries.
|
|
|
16
16
|
| --- | --- | --- | --- |
|
|
17
17
|
| `deb` | Linux | Compatible Linux files and package metadata. | nFPM, `readelf` for binaries; `gpg` for a hosted APT repository. |
|
|
18
18
|
| `rpm` | Linux | Compatible Linux files and RPM-specific dependencies. | nFPM, `readelf` for binaries; `createrepo_c` and `gpg` for a hosted DNF repository. |
|
|
19
|
-
| `archlinux` | Linux | Arch-compatible files and explicit dependencies. | nFPM, `readelf` for binaries. |
|
|
19
|
+
| `archlinux` | Linux | Arch-compatible files and explicit dependencies. | nFPM, `readelf` for binaries; `bsdtar` and `gpg` for a hosted pacman repository. |
|
|
20
20
|
| `apk` | Linux | Suitable Alpine files, usually musl or static binaries, and dependencies. | nFPM, `readelf` for binaries. |
|
|
21
21
|
| `ipk` | Linux | Files for the device/distribution baseline, dependencies, and an `abi` label. | nFPM, `readelf` for binaries. |
|
|
22
22
|
| `appimage` | Linux | The same files as the DEB/RPM, including one desktop entry and its icon. | `mksquashfs` (squashfs-tools), `curl`, `readelf`; `zsyncmake` (zsync) with update information. |
|
|
@@ -279,9 +279,9 @@ An Arch package file and an AUR recipe are separate outputs: the former can
|
|
|
279
279
|
be installed directly; the latter tells Arch tooling how to obtain and package
|
|
280
280
|
your app.
|
|
281
281
|
|
|
282
|
-
native-packages can also write signed APT, DNF and Flatpak
|
|
283
|
-
your DEB, RPM and Flatpak packages, served as static
|
|
284
|
-
[Hosted package repositories](../_guides/hosted-repositories.md). There is no
|
|
282
|
+
native-packages can also write signed APT, DNF, pacman and Flatpak
|
|
283
|
+
repositories from your DEB, RPM, Arch and Flatpak packages, served as static
|
|
284
|
+
files; see [Hosted package repositories](../_guides/hosted-repositories.md). There is no
|
|
285
285
|
NSIS adapter. Keep that workflow in your app's release process if you need it.
|
|
286
286
|
|
|
287
287
|
## What validation establishes
|
|
@@ -23,8 +23,8 @@ working on with `doctor --target ID` and `build --target ID --dry-run`.
|
|
|
23
23
|
Install and select the version named in the error:
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
|
-
gem install native-packages --version 0.
|
|
27
|
-
native-packages _0.
|
|
26
|
+
gem install native-packages --version 0.13.0
|
|
27
|
+
native-packages _0.13.0_ doctor
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
`tool.version` is an exact match. In CI, use the matching released reusable
|
data/docs/index.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
layout: home
|
|
3
3
|
title: native-packages
|
|
4
|
+
seo:
|
|
5
|
+
title: DEB, RPM, AppImage, DMG and MSI from one config
|
|
4
6
|
description: Turn your built application into Linux packages, macOS disk images, and Windows installers. Publish releases from one configuration.
|
|
5
7
|
permalink: /
|
|
6
8
|
hero:
|
|
@@ -11,9 +13,7 @@ hero:
|
|
|
11
13
|
- theme: brand
|
|
12
14
|
text: Get started
|
|
13
15
|
link: /getting-started/
|
|
14
|
-
-
|
|
15
|
-
text: GitHub
|
|
16
|
-
link: https://github.com/crmne/native-packages
|
|
16
|
+
- star: true
|
|
17
17
|
image:
|
|
18
18
|
src: /assets/images/logo.svg
|
|
19
19
|
alt: native-packages logo
|
|
@@ -12,7 +12,7 @@ module NativePackages
|
|
|
12
12
|
# by this class without Debian's own tools. Beside them go the public key
|
|
13
13
|
# (NAME.gpg) and a deb822 NAME.sources file for users to install.
|
|
14
14
|
class AptRepository < HostedRepository
|
|
15
|
-
KEYS = (HostedRepository::KEYS + %w[suite component]).freeze
|
|
15
|
+
KEYS = (HostedRepository::KEYS + %w[name suite component]).freeze
|
|
16
16
|
WORD = /\A[a-z0-9][a-z0-9._-]*\z/
|
|
17
17
|
# The order apt-ftparchive writes; other fields follow in their own order.
|
|
18
18
|
FIELDS = %w[Package Version Architecture].freeze
|
|
@@ -121,8 +121,8 @@ module NativePackages
|
|
|
121
121
|
|
|
122
122
|
def instructions
|
|
123
123
|
["sudo install -d -m 0755 /etc/apt/keyrings",
|
|
124
|
-
"sudo curl -fsSLo /etc/apt/keyrings/#{
|
|
125
|
-
"sudo curl -fsSLo /etc/apt/sources.list.d/#{
|
|
124
|
+
"sudo curl -fsSLo /etc/apt/keyrings/#{repository}.gpg #{url}/#{repository}.gpg",
|
|
125
|
+
"sudo curl -fsSLo /etc/apt/sources.list.d/#{repository}.sources #{url}/#{repository}.sources",
|
|
126
126
|
"sudo apt update && sudo apt install #{name}"]
|
|
127
127
|
end
|
|
128
128
|
|
|
@@ -146,13 +146,13 @@ module NativePackages
|
|
|
146
146
|
write(dists / "Release", release(dists, architectures, indexes))
|
|
147
147
|
signing.clearsign(dists / "Release", dists / "InRelease")
|
|
148
148
|
signing.detach_sign(dists / "Release", dists / "Release.gpg")
|
|
149
|
-
write(directory / "#{
|
|
150
|
-
write(directory / "#{
|
|
149
|
+
write(directory / "#{repository}.gpg", signing.public_key)
|
|
150
|
+
write(directory / "#{repository}.sources", <<~SOURCES)
|
|
151
151
|
Types: deb
|
|
152
152
|
URIs: #{url}
|
|
153
153
|
Suites: #{suite}
|
|
154
154
|
Components: #{component}
|
|
155
|
-
Signed-By: /etc/apt/keyrings/#{
|
|
155
|
+
Signed-By: /etc/apt/keyrings/#{repository}.gpg
|
|
156
156
|
SOURCES
|
|
157
157
|
end
|
|
158
158
|
|
|
@@ -167,24 +167,14 @@ module NativePackages
|
|
|
167
167
|
|
|
168
168
|
def release(dists, architectures, indexes)
|
|
169
169
|
epoch = ENV["SOURCE_DATE_EPOCH"] ? Integer(ENV.fetch("SOURCE_DATE_EPOCH")) : Time.now.to_i
|
|
170
|
-
lines = ["Origin: #{
|
|
170
|
+
lines = ["Origin: #{repository}", "Label: #{repository}", "Suite: #{suite}", "Codename: #{suite}",
|
|
171
171
|
"Date: #{Time.at(epoch).utc.strftime('%a, %d %b %Y %H:%M:%S UTC')}", "Architectures: #{architectures.join(' ')}",
|
|
172
|
-
"Components: #{component}", "Description: #{
|
|
172
|
+
"Components: #{component}", "Description: #{repository} packages"]
|
|
173
173
|
{ "MD5Sum" => Digest::MD5, "SHA1" => Digest::SHA1, "SHA256" => Digest::SHA256 }.each do |label, digest|
|
|
174
174
|
lines << "#{label}:"
|
|
175
175
|
indexes.each { |relative| lines << " #{digest.file(dists / relative).hexdigest} #{(dists / relative).size} #{relative}" }
|
|
176
176
|
end
|
|
177
177
|
lines.join("\n") + "\n"
|
|
178
178
|
end
|
|
179
|
-
|
|
180
|
-
# The same bytes for the same index: no name or time in the header.
|
|
181
|
-
def gzip(text)
|
|
182
|
-
io = StringIO.new("".b)
|
|
183
|
-
writer = Zlib::GzipWriter.new(io, Zlib::BEST_COMPRESSION)
|
|
184
|
-
writer.mtime = 0
|
|
185
|
-
writer.write(text)
|
|
186
|
-
writer.finish
|
|
187
|
-
io.string
|
|
188
|
-
end
|
|
189
179
|
end
|
|
190
180
|
end
|
|
@@ -13,7 +13,7 @@ module NativePackages
|
|
|
13
13
|
class Build
|
|
14
14
|
include Support
|
|
15
15
|
# Destinations signed with the OpenPGP key from the environment.
|
|
16
|
-
HOSTED = %w[apt dnf flatpak].freeze
|
|
16
|
+
HOSTED = %w[apt dnf pacman flatpak].freeze
|
|
17
17
|
attr_reader :configuration, :root, :project
|
|
18
18
|
|
|
19
19
|
def initialize(configuration)
|
|
@@ -442,6 +442,8 @@ module NativePackages
|
|
|
442
442
|
AptRepository.new(configuration).publish(packages(manifest, output, "deb"), **signing)
|
|
443
443
|
elsif destination == "dnf"
|
|
444
444
|
DnfRepository.new(configuration).publish(packages(manifest, output, "rpm"), **signing)
|
|
445
|
+
elsif destination == "pacman"
|
|
446
|
+
PacmanRepository.new(configuration).publish(packages(manifest, output, "archlinux"), **signing)
|
|
445
447
|
elsif destination == "flatpak"
|
|
446
448
|
FlatpakRepository.new(configuration).publish(packages(manifest, output, "flatpak"), **signing)
|
|
447
449
|
elsif destination == "snapcraft"
|
|
@@ -7,6 +7,7 @@ require_relative "snap"
|
|
|
7
7
|
require_relative "apt_repository"
|
|
8
8
|
require_relative "dnf_repository"
|
|
9
9
|
require_relative "flatpak_repository"
|
|
10
|
+
require_relative "pacman_repository"
|
|
10
11
|
require_relative "windows_signing"
|
|
11
12
|
|
|
12
13
|
module NativePackages
|
|
@@ -17,11 +18,11 @@ module NativePackages
|
|
|
17
18
|
# without nFPM.
|
|
18
19
|
IMAGE_FORMATS = %w[appimage flatpak snap].freeze
|
|
19
20
|
# Publish destinations besides the configured downstream repositories.
|
|
20
|
-
DESTINATIONS = %w[github snapcraft apt dnf flatpak].freeze
|
|
21
|
+
DESTINATIONS = %w[github snapcraft apt dnf pacman flatpak].freeze
|
|
21
22
|
FORMATS = (%w[deb rpm archlinux apk ipk msix srpm appimage flatpak snap] + NATIVE_FORMATS).freeze
|
|
22
23
|
NFPM_VERSION = "2.47.0"
|
|
23
24
|
NAMES = %w[native-packages.yaml native-packages.yml].freeze
|
|
24
|
-
KEYS = %w[schema tool nfpm targets release assets templates repositories revisions libraries version_file version_section windows flatpak snap apt dnf].freeze
|
|
25
|
+
KEYS = %w[schema tool nfpm targets release assets templates repositories revisions libraries version_file version_section windows flatpak snap apt dnf pacman].freeze
|
|
25
26
|
attr_reader :root, :path, :data
|
|
26
27
|
|
|
27
28
|
def self.discover(root, explicit = nil)
|
|
@@ -191,6 +192,7 @@ module NativePackages
|
|
|
191
192
|
Snap.validate(data)
|
|
192
193
|
AptRepository.validate(data)
|
|
193
194
|
DnfRepository.validate(data)
|
|
195
|
+
PacmanRepository.validate(data)
|
|
194
196
|
FlatpakRepository.validate(data)
|
|
195
197
|
project.repositories
|
|
196
198
|
true
|
|
@@ -14,7 +14,7 @@ module NativePackages
|
|
|
14
14
|
|
|
15
15
|
def self.validate(data)
|
|
16
16
|
settings = data["dnf"]
|
|
17
|
-
check(settings, "dnf", KEYS) unless settings.nil?
|
|
17
|
+
check(settings, "dnf", KEYS + %w[name]) unless settings.nil?
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def initialize(configuration)
|
|
@@ -109,23 +109,23 @@ module NativePackages
|
|
|
109
109
|
# gzip, which every dnf and zypper reads; newer createrepo_c defaults to zstd.
|
|
110
110
|
run "createrepo_c", "--quiet", "--no-database", "--general-compress-type=gz", directory
|
|
111
111
|
signing.detach_sign(directory / "repodata/repomd.xml", directory / "repodata/repomd.xml.asc")
|
|
112
|
-
write(directory / "#{
|
|
112
|
+
write(directory / "#{repository}.asc", signing.public_key(armor: true))
|
|
113
113
|
end
|
|
114
114
|
signed = entries.values.all? { |_, header| header.fetch("signed") }
|
|
115
|
-
write(directory / "#{
|
|
116
|
-
[#{
|
|
117
|
-
name=#{
|
|
115
|
+
write(directory / "#{repository}.repo", <<~REPO)
|
|
116
|
+
[#{repository}]
|
|
117
|
+
name=#{repository}
|
|
118
118
|
baseurl=#{url}
|
|
119
119
|
enabled=1
|
|
120
120
|
repo_gpgcheck=1
|
|
121
121
|
gpgcheck=#{signed ? 1 : 0}
|
|
122
|
-
gpgkey=#{url}/#{
|
|
122
|
+
gpgkey=#{url}/#{repository}.asc
|
|
123
123
|
REPO
|
|
124
124
|
puts "Published #{entries.length} package#{"s" unless entries.length == 1} to #{directory}. Install with:", *instructions.map { |line| " #{line}" }
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
def instructions
|
|
128
|
-
["sudo curl -fsSLo /etc/yum.repos.d/#{
|
|
128
|
+
["sudo curl -fsSLo /etc/yum.repos.d/#{repository}.repo #{url}/#{repository}.repo", "sudo dnf install #{name}"]
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "stringio"
|
|
4
|
+
require "zlib"
|
|
3
5
|
require_relative "openpgp"
|
|
4
6
|
|
|
5
7
|
module NativePackages
|
|
@@ -10,6 +12,8 @@ module NativePackages
|
|
|
10
12
|
include Support
|
|
11
13
|
KEYS = %w[directory url keep signing_key].freeze
|
|
12
14
|
KEEP = 3
|
|
15
|
+
# A repository name: a file name and, for DNF and pacman, a section name.
|
|
16
|
+
NAME = /\A[a-z0-9][a-z0-9_-]*\z/
|
|
13
17
|
attr_reader :root, :name, :settings, :directory
|
|
14
18
|
|
|
15
19
|
# Checks the settings shared by every hosted repository, under `label`.
|
|
@@ -23,6 +27,9 @@ module NativePackages
|
|
|
23
27
|
end
|
|
24
28
|
keep = settings.fetch("keep", KEEP)
|
|
25
29
|
raise Error, "#{label}.keep: expected how many versions of each package to keep (1 or more)" unless keep.is_a?(Integer) && keep.positive?
|
|
30
|
+
if settings.key?("name") && !NAME.match?(settings["name"].to_s)
|
|
31
|
+
raise Error, "#{label}.name: use lowercase letters, digits, underscores or hyphens"
|
|
32
|
+
end
|
|
26
33
|
OpenPGP.fingerprint(settings["signing_key"], "#{label}.signing_key")
|
|
27
34
|
end
|
|
28
35
|
|
|
@@ -36,6 +43,11 @@ module NativePackages
|
|
|
36
43
|
def url = settings.fetch("url").chomp("/")
|
|
37
44
|
def keep = settings.fetch("keep", KEEP)
|
|
38
45
|
|
|
46
|
+
# The name of the files users install (key, source list) and of the
|
|
47
|
+
# repository itself, shared by every app that publishes into it. Defaults
|
|
48
|
+
# to the package name.
|
|
49
|
+
def repository = settings.fetch("name", name)
|
|
50
|
+
|
|
39
51
|
def signer(secret: nil, passphrase: nil)
|
|
40
52
|
OpenPGP.new(OpenPGP.fingerprint(settings.fetch("signing_key"), "signing_key"), secret: secret, passphrase: passphrase)
|
|
41
53
|
end
|
|
@@ -69,5 +81,17 @@ module NativePackages
|
|
|
69
81
|
end
|
|
70
82
|
entries.except(*removed)
|
|
71
83
|
end
|
|
84
|
+
|
|
85
|
+
private
|
|
86
|
+
|
|
87
|
+
# The same bytes for the same index: no name or time in the header.
|
|
88
|
+
def gzip(text)
|
|
89
|
+
io = StringIO.new("".b)
|
|
90
|
+
writer = Zlib::GzipWriter.new(io, Zlib::BEST_COMPRESSION)
|
|
91
|
+
writer.mtime = 0
|
|
92
|
+
writer.write(text)
|
|
93
|
+
writer.finish
|
|
94
|
+
io.string
|
|
95
|
+
end
|
|
72
96
|
end
|
|
73
97
|
end
|
|
@@ -75,8 +75,10 @@ module NativePackages
|
|
|
75
75
|
verify(output)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
# An ASCII-armored signature unless `armor` is false: pacman reads
|
|
79
|
+
# binary signatures only.
|
|
80
|
+
def detach_sign(input, output, armor: true)
|
|
81
|
+
sign("--detach-sign", input, output, *("--armor" if armor))
|
|
80
82
|
verify(output, input)
|
|
81
83
|
end
|
|
82
84
|
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "digest"
|
|
4
|
+
require "rubygems/package"
|
|
5
|
+
require "stringio"
|
|
6
|
+
require_relative "hosted_repository"
|
|
7
|
+
|
|
8
|
+
module NativePackages
|
|
9
|
+
# A signed pacman repository for Arch Linux: a directory per architecture
|
|
10
|
+
# (x86_64/, aarch64/) holds the .pkg.tar.zst files, each with a detached
|
|
11
|
+
# .sig, and the databases pacman reads (REPO.db and REPO.files), written by
|
|
12
|
+
# this class as repo-add writes them, without pacman's own tools. Static
|
|
13
|
+
# hosts serve no symlinks, so REPO.db and REPO.db.tar.gz are two copies of
|
|
14
|
+
# the same file, as are REPO.files and REPO.files.tar.gz. Beside the
|
|
15
|
+
# architectures goes the public key (REPO.asc) for users to trust.
|
|
16
|
+
class PacmanRepository < HostedRepository
|
|
17
|
+
KEYS = (HostedRepository::KEYS + %w[name]).freeze
|
|
18
|
+
# The architecture directories an `any` package goes into when the
|
|
19
|
+
# repository has none yet.
|
|
20
|
+
ARCHITECTURES = %w[x86_64 aarch64].freeze
|
|
21
|
+
# .PKGINFO keys that may repeat, and the desc entries they become.
|
|
22
|
+
LISTS = { "group" => "GROUPS", "license" => "LICENSE", "replaces" => "REPLACES", "conflict" => "CONFLICTS",
|
|
23
|
+
"provides" => "PROVIDES", "depend" => "DEPENDS", "optdepend" => "OPTDEPENDS", "makedepend" => "MAKEDEPENDS",
|
|
24
|
+
"checkdepend" => "CHECKDEPENDS" }.freeze
|
|
25
|
+
PACKAGE = /\.pkg\.tar(?:\.(?:zst|xz|gz|bz2|lz4|lzo|lrz|Z))?\z/
|
|
26
|
+
|
|
27
|
+
def self.validate(data)
|
|
28
|
+
settings = data["pacman"]
|
|
29
|
+
return if settings.nil?
|
|
30
|
+
check(settings, "pacman", KEYS)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def initialize(configuration)
|
|
34
|
+
super(configuration, configuration.data.fetch("pacman") { raise Error, "configure pacman to publish --to pacman" })
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# The fields of the package at `path`, from its .PKGINFO: single values
|
|
38
|
+
# as strings, repeatable ones as arrays.
|
|
39
|
+
def self.info(path)
|
|
40
|
+
text = Open3.capture3("bsdtar", "-xOqf", path.to_s, ".PKGINFO", binmode: true).then do |output, error, status|
|
|
41
|
+
raise Error, "#{File.basename(path)} is not a pacman package: #{error.strip}" unless status.success? && !output.empty?
|
|
42
|
+
output.force_encoding(Encoding::UTF_8)
|
|
43
|
+
end
|
|
44
|
+
fields = text.each_line.each_with_object(Hash.new { |hash, key| hash[key] = [] }) do |line, result|
|
|
45
|
+
next if line.start_with?("#") || !line.include?("=")
|
|
46
|
+
key, value = line.split("=", 2).map(&:strip)
|
|
47
|
+
result[key] << value.gsub(/\s+/, " ")
|
|
48
|
+
end
|
|
49
|
+
%w[pkgname pkgver arch].each { |key| raise Error, "#{File.basename(path)}: .PKGINFO has no #{key}" if fields[key].empty? }
|
|
50
|
+
fields.to_h { |key, values| [key, LISTS.key?(key) || key == "backup" ? values : values.last] }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# The files the package installs, as repo-add lists them.
|
|
54
|
+
def self.contents(path)
|
|
55
|
+
output, error, status = Open3.capture3("bsdtar", "--exclude=^.*", "-tf", path.to_s, binmode: true)
|
|
56
|
+
raise Error, "#{File.basename(path)} could not be listed: #{error.strip}" unless status.success?
|
|
57
|
+
output.force_encoding(Encoding::UTF_8).lines.map(&:chomp).reject(&:empty?).uniq.sort_by(&:b)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# pacman's version order (vercmp): -1, 0 or 1.
|
|
61
|
+
def self.compare(left, right)
|
|
62
|
+
return 0 if left == right
|
|
63
|
+
left, right = [left, right].map do |version|
|
|
64
|
+
epoch, rest = version.match?(/\A\d*:/) ? version.split(":", 2) : ["0", version]
|
|
65
|
+
upstream, _, release = rest.include?("-") ? rest.rpartition("-") : [rest, nil, nil]
|
|
66
|
+
[epoch.empty? ? "0" : epoch, upstream, release]
|
|
67
|
+
end
|
|
68
|
+
order = compare_part(left[0], right[0]).nonzero? || compare_part(left[1], right[1])
|
|
69
|
+
return order unless order.zero? && left[2] && right[2]
|
|
70
|
+
compare_part(left[2], right[2])
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# libalpm's rpmvercmp, which differs from RPM's: no special tilde or
|
|
74
|
+
# caret, a letter suffix sorts before the bare version (1.0a < 1.0), and
|
|
75
|
+
# a longer separator wins.
|
|
76
|
+
def self.compare_part(left, right)
|
|
77
|
+
return 0 if left == right
|
|
78
|
+
one, two = left, right
|
|
79
|
+
until one.empty? || two.empty?
|
|
80
|
+
separators = [one[/\A[^A-Za-z0-9]*/].length, two[/\A[^A-Za-z0-9]*/].length]
|
|
81
|
+
one, two = one[separators[0]..], two[separators[1]..]
|
|
82
|
+
break if one.empty? || two.empty?
|
|
83
|
+
return separators[0] < separators[1] ? -1 : 1 unless separators[0] == separators[1]
|
|
84
|
+
numeric = one.match?(/\A\d/)
|
|
85
|
+
pattern = numeric ? /\A\d+/ : /\A[A-Za-z]+/
|
|
86
|
+
mine, theirs = one[pattern], two[pattern]
|
|
87
|
+
# A number is newer than letters.
|
|
88
|
+
return numeric ? 1 : -1 unless theirs
|
|
89
|
+
order = if numeric
|
|
90
|
+
a, b = [mine, theirs].map { |number| number.sub(/\A0+/, "") }
|
|
91
|
+
(a.length <=> b.length).nonzero? || (a <=> b)
|
|
92
|
+
else
|
|
93
|
+
mine <=> theirs
|
|
94
|
+
end
|
|
95
|
+
return order unless order.zero?
|
|
96
|
+
one, two = one[mine.length..], two[theirs.length..]
|
|
97
|
+
end
|
|
98
|
+
return 0 if one.empty? && two.empty?
|
|
99
|
+
# A remaining letter never beats the end.
|
|
100
|
+
(one.empty? && !two.match?(/\A[A-Za-z]/)) || one.match?(/\A[A-Za-z]/) ? -1 : 1
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def publish(packages, secret: nil, passphrase: nil)
|
|
104
|
+
raise Error, "the build contains no Arch packages to publish --to pacman" if packages.empty?
|
|
105
|
+
raise Error, "install bsdtar (libarchive) to publish --to pacman" unless available?("bsdtar")
|
|
106
|
+
infos = packages.to_h { |path| [path, self.class.info(path)] }
|
|
107
|
+
present = published.map { |path| path.dirname.basename.to_s }.uniq
|
|
108
|
+
built = infos.values.map { |info| info.fetch("arch") } - ["any"]
|
|
109
|
+
architectures = (present | built).then { |found| found.empty? ? ARCHITECTURES : found }
|
|
110
|
+
remaining = nil
|
|
111
|
+
signer(secret: secret, passphrase: passphrase).session do |signing|
|
|
112
|
+
infos.each do |path, info|
|
|
113
|
+
(info.fetch("arch") == "any" ? architectures : [info.fetch("arch")]).each do |architecture|
|
|
114
|
+
destination = directory / architecture / path.basename
|
|
115
|
+
place(path, destination)
|
|
116
|
+
signature = Pathname.new("#{destination}.sig")
|
|
117
|
+
signing.detach_sign(destination, signature, armor: false) unless signature.exist?
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
# Indexes cover every package in the directory, not only this build's.
|
|
121
|
+
entries = published.to_h do |path|
|
|
122
|
+
info = self.class.info(path)
|
|
123
|
+
[path, [[path.dirname.basename.to_s, info.fetch("pkgname")], info.fetch("pkgver"), info]]
|
|
124
|
+
end
|
|
125
|
+
remaining = prune(entries) { |left, right| self.class.compare(left, right) }
|
|
126
|
+
(entries.keys - remaining.keys).each do |path|
|
|
127
|
+
signature = Pathname.new("#{path}.sig")
|
|
128
|
+
signature.delete if signature.exist?
|
|
129
|
+
end
|
|
130
|
+
remaining.group_by { |path, _| path.dirname }.sort.each do |folder, rows|
|
|
131
|
+
write_databases(folder, rows.to_h, signing)
|
|
132
|
+
end
|
|
133
|
+
write(directory / "#{repository}.asc", signing.public_key(armor: true))
|
|
134
|
+
end
|
|
135
|
+
puts "Published #{remaining.length} package#{"s" unless remaining.length == 1} to #{directory}. Install with:", *instructions.map { |line| " #{line}" }
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def instructions
|
|
139
|
+
fingerprint = OpenPGP.fingerprint(settings.fetch("signing_key"), "signing_key")
|
|
140
|
+
["curl -fsSL #{url}/#{repository}.asc | sudo pacman-key --add -",
|
|
141
|
+
"sudo pacman-key --lsign-key #{fingerprint}",
|
|
142
|
+
"printf '\\n[#{repository}]\\nSigLevel = Required\\nServer = #{url}/$arch\\n' | sudo tee -a /etc/pacman.conf",
|
|
143
|
+
"sudo pacman -Syu #{name}"]
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
private
|
|
147
|
+
|
|
148
|
+
# Every package in the directory, whichever project published it.
|
|
149
|
+
def published = Pathname.glob(directory / "*/*.pkg.tar*").select { |path| PACKAGE.match?(path.basename.to_s) }.sort
|
|
150
|
+
|
|
151
|
+
# REPO.db and REPO.files in `folder`, as gzip-compressed tar archives,
|
|
152
|
+
# each signed and written twice: once under each name pacman may ask for.
|
|
153
|
+
def write_databases(folder, entries, signing)
|
|
154
|
+
rows = entries.map { |path, (_, _, info)| [path, info, desc(path, info)] }.sort_by { |_, info, _| [info.fetch("pkgname"), info.fetch("pkgver")] }
|
|
155
|
+
databases = {
|
|
156
|
+
"db" => rows.map { |_, info, text| [entry(info), { "desc" => text }] },
|
|
157
|
+
"files" => rows.map { |path, info, text| [entry(info), { "desc" => text, "files" => "%FILES%\n#{self.class.contents(path).map { |line| "#{line}\n" }.join}" }] }
|
|
158
|
+
}
|
|
159
|
+
databases.each do |kind, members|
|
|
160
|
+
archive = gzip(tar(members))
|
|
161
|
+
base = folder / "#{repository}.#{kind}"
|
|
162
|
+
write(base, archive)
|
|
163
|
+
signing.detach_sign(base, Pathname.new("#{base}.sig"), armor: false)
|
|
164
|
+
write(Pathname.new("#{base}.tar.gz"), archive)
|
|
165
|
+
write(Pathname.new("#{base}.tar.gz.sig"), Pathname.new("#{base}.sig").binread)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def entry(info) = "#{info.fetch('pkgname')}-#{info.fetch('pkgver')}"
|
|
170
|
+
|
|
171
|
+
# The package's desc entry, in repo-add's order. Signatures are served
|
|
172
|
+
# beside the packages rather than embedded, as repo-add does by default.
|
|
173
|
+
def desc(path, info)
|
|
174
|
+
fields = [["FILENAME", path.basename.to_s], ["NAME", info["pkgname"]], ["BASE", info["pkgbase"]], ["VERSION", info["pkgver"]],
|
|
175
|
+
["DESC", info["pkgdesc"]], ["GROUPS", info["group"]], ["CSIZE", path.size.to_s], ["ISIZE", info["size"]],
|
|
176
|
+
["SHA256SUM", Digest::SHA256.file(path).hexdigest], ["URL", info["url"]], ["LICENSE", info["license"]], ["ARCH", info["arch"]],
|
|
177
|
+
["BUILDDATE", info["builddate"]], ["PACKAGER", info["packager"]], ["REPLACES", info["replaces"]], ["CONFLICTS", info["conflict"]],
|
|
178
|
+
["PROVIDES", info["provides"]], ["DEPENDS", info["depend"]], ["OPTDEPENDS", info["optdepend"]],
|
|
179
|
+
["MAKEDEPENDS", info["makedepend"]], ["CHECKDEPENDS", info["checkdepend"]]]
|
|
180
|
+
fields.filter_map do |key, value|
|
|
181
|
+
values = Array(value)
|
|
182
|
+
next if values.empty? || values.first.to_s.empty?
|
|
183
|
+
"%#{key}%\n#{values.map { |line| "#{line}\n" }.join}\n"
|
|
184
|
+
end.join
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# A tar archive of one directory per package, holding its entries.
|
|
188
|
+
def tar(members)
|
|
189
|
+
io = StringIO.new("".b)
|
|
190
|
+
Gem::Package::TarWriter.new(io) do |writer|
|
|
191
|
+
members.each do |folder, files|
|
|
192
|
+
writer.mkdir(folder, 0o755)
|
|
193
|
+
files.each do |file, text|
|
|
194
|
+
bytes = text.b
|
|
195
|
+
writer.add_file_simple("#{folder}/#{file}", 0o644, bytes.bytesize) { |stream| stream.write(bytes) }
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
io.string
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: native-packages
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carmine Paolino
|
|
@@ -70,6 +70,7 @@ files:
|
|
|
70
70
|
- lib/native_packages/native_recipe.rb
|
|
71
71
|
- lib/native_packages/omarchy.rb
|
|
72
72
|
- lib/native_packages/openpgp.rb
|
|
73
|
+
- lib/native_packages/pacman_repository.rb
|
|
73
74
|
- lib/native_packages/project.rb
|
|
74
75
|
- lib/native_packages/release_signing.rb
|
|
75
76
|
- lib/native_packages/repositories.rb
|