native-packages 0.10.0 → 0.11.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/README.md +3 -1
- data/docs/_guides/distribution-recipes.md +3 -1
- data/docs/_guides/getting-started.md +2 -2
- data/docs/_guides/github-actions.md +6 -4
- data/docs/_guides/multi-platform.md +1 -1
- data/docs/_guides/native-recipes.md +6 -2
- data/docs/_guides/omarchy.md +131 -0
- data/docs/_guides/prereleases.md +1 -1
- data/docs/_guides/release-signing.md +4 -4
- data/docs/_guides/windows-signing.md +259 -0
- data/docs/_reference/commands.md +29 -1
- data/docs/_reference/configuration.md +27 -1
- data/docs/_reference/platforms.md +4 -3
- data/docs/_reference/troubleshooting.md +22 -2
- data/docs/releasing.md +2 -2
- data/examples/native-packages-all-formats.yaml +1 -1
- data/examples/native-packages.yaml +1 -1
- data/lib/native_packages/build.rb +20 -4
- data/lib/native_packages/cli.rb +19 -2
- data/lib/native_packages/configuration.rb +3 -1
- data/lib/native_packages/omarchy.rb +140 -0
- data/lib/native_packages/support.rb +1 -1
- data/lib/native_packages/windows_signing.rb +284 -0
- metadata +5 -1
|
@@ -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.11.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. |
|
|
@@ -40,6 +40,7 @@ expressions. Use the replacement values listed below.
|
|
|
40
40
|
| `revisions` | Package revision numbers by app version and recipe path. |
|
|
41
41
|
| `version_file` | Cargo manifest checked by `check-version`. |
|
|
42
42
|
| `version_section` | Cargo section to check; defaults to `package`. |
|
|
43
|
+
| `windows` | Optional. `windows.signing` turns on [Windows code signing](#windows-signing). |
|
|
43
44
|
|
|
44
45
|
Quote tool versions so they remain strings. A version mismatch reports the
|
|
45
46
|
command needed to install and select the configured gem.
|
|
@@ -154,6 +155,31 @@ For DMGs, automatic Apple input signing finishes before the native command.
|
|
|
154
155
|
DMG signing and notarization run after `after_package`, before the final hash.
|
|
155
156
|
See [Apple signing and notarization](../_guides/apple-notarization.md).
|
|
156
157
|
|
|
158
|
+
## Windows signing
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
windows:
|
|
162
|
+
signing:
|
|
163
|
+
provider: azure-artifact-signing
|
|
164
|
+
description: Hello
|
|
165
|
+
description_url: https://example.org/hello
|
|
166
|
+
publisher: Example Ltd
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
| Field | Purpose |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `provider` | Required. `azure-artifact-signing`. |
|
|
172
|
+
| `description` | Program name shown in Windows' permission prompts. Defaults to the package name. |
|
|
173
|
+
| `description_url` | An `https://` URL in the signature. Defaults to `nfpm.homepage`. |
|
|
174
|
+
| `publisher` | Optional. The organization every signature must name, checked after signing. |
|
|
175
|
+
|
|
176
|
+
The account comes from the environment, never the file:
|
|
177
|
+
`AZURE_SIGNING_ENDPOINT`, `AZURE_SIGNING_ACCOUNT` and `AZURE_SIGNING_PROFILE`.
|
|
178
|
+
With none set, builds are unsigned; an incomplete set fails. With all three,
|
|
179
|
+
MSI and Inno builds sign the input's unsigned code before the native command,
|
|
180
|
+
and the installer after `after_package`, before the final hash. See
|
|
181
|
+
[Windows code signing](../_guides/windows-signing.md).
|
|
182
|
+
|
|
157
183
|
## Replacement values
|
|
158
184
|
|
|
159
185
|
Strings can contain `@KEY@` values. Unknown or unavailable values cause an error.
|
|
@@ -23,8 +23,8 @@ libraries.
|
|
|
23
23
|
| `srpm` | Linux source target | RPM spec and source files. | nFPM; native RPM tooling for rebuild tests. |
|
|
24
24
|
| `msix` | Windows | Windows binaries, identity, application assets, and capabilities. | nFPM; Windows tools for signing and installation tests. |
|
|
25
25
|
| `dmg` | macOS | Complete app and a DMG script. | macOS, `lipo`, and your script's tools, such as `hdiutil`. |
|
|
26
|
-
| `msi` | Windows | Complete app and a Windows Installer recipe/wrapper, such as a WiX project. | Windows and your installed MSI toolset, such as WiX. |
|
|
27
|
-
| `inno` | Windows | Complete app and an Inno Setup recipe/wrapper. | Windows and your installed Inno compiler. |
|
|
26
|
+
| `msi` | Windows | Complete app and a Windows Installer recipe/wrapper, such as a WiX project. | Windows and your installed MSI toolset, such as WiX; optional Azure Artifact Signing. |
|
|
27
|
+
| `inno` | Windows | Complete app and an Inno Setup recipe/wrapper. | Windows and your installed Inno compiler; optional Azure Artifact Signing. |
|
|
28
28
|
|
|
29
29
|
The supported nFPM version is **2.47.0**. It writes package files from your
|
|
30
30
|
prepared contents. Native DMG, MSI and Inno targets call your scripts instead.
|
|
@@ -149,7 +149,8 @@ target with a local directory input. macOS inspection supports `amd64`,
|
|
|
149
149
|
|
|
150
150
|
Follow [macOS and Windows installers](../_guides/native-recipes.md) for setup.
|
|
151
151
|
DMG targets can automatically [sign and notarize](../_guides/apple-notarization.md)
|
|
152
|
-
when complete Apple credentials are available.
|
|
152
|
+
when complete Apple credentials are available. MSI and Inno targets can sign
|
|
153
|
+
their code and installer with [Azure Artifact Signing](../_guides/windows-signing.md).
|
|
153
154
|
|
|
154
155
|
## Distribution recipes
|
|
155
156
|
|
|
@@ -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.11.0
|
|
27
|
+
native-packages _0.11.0_ doctor
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
`tool.version` is an exact match. In CI, use the matching released reusable
|
|
@@ -165,6 +165,26 @@ A native script must package `@PAYLOAD@` and preserve its signatures. A failure
|
|
|
165
165
|
from Apple's service prevents a completed signed build. Use the submission
|
|
166
166
|
information in the error to investigate Apple's result before retrying.
|
|
167
167
|
|
|
168
|
+
## Windows signing fails or is skipped
|
|
169
|
+
|
|
170
|
+
Signing needs the configuration's `windows.signing` section and all three of
|
|
171
|
+
`AZURE_SIGNING_ENDPOINT`, `AZURE_SIGNING_ACCOUNT` and `AZURE_SIGNING_PROFILE`.
|
|
172
|
+
None means an unsigned build; an incomplete set fails. `native-packages doctor`
|
|
173
|
+
checks them and the Azure CLI sign-in.
|
|
174
|
+
|
|
175
|
+
- `AADSTS700213: No matching federated identity record found` from
|
|
176
|
+
`azure/login`: the federated credential's subject differs from the token's.
|
|
177
|
+
Repositories that present GitHub's immutable subject need
|
|
178
|
+
`repo:OWNER@OWNER_ID/REPOSITORY@REPOSITORY_ID:environment:NAME`; see
|
|
179
|
+
[Windows code signing](../_guides/windows-signing.md#2-trust-your-github-workflow-with-the-right-subject).
|
|
180
|
+
- `403 Forbidden` from SignTool: the endpoint's region differs from the
|
|
181
|
+
account's, the account or profile name is wrong, or the identity lacks the
|
|
182
|
+
Artifact Signing Certificate Profile Signer role.
|
|
183
|
+
- A publisher mismatch: the certificate profile is not the one
|
|
184
|
+
`windows.signing.publisher` names.
|
|
185
|
+
- A pinned SHA-256 mismatch: nuget.org served a different SignTool or client
|
|
186
|
+
package. The download is deleted; do not override the hash.
|
|
187
|
+
|
|
168
188
|
## Get help
|
|
169
189
|
|
|
170
190
|
If the error persists, [open an issue](https://github.com/crmne/native-packages/issues)
|
data/docs/releasing.md
CHANGED
|
@@ -23,7 +23,7 @@ Update the gemspec, `NativePackages::VERSION`, example/version references and ch
|
|
|
23
23
|
Create a GitHub release for that commit:
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
|
-
gh release create v0.
|
|
26
|
+
gh release create v0.11.0 --target main --title 'native-packages 0.11.0' --notes-file release-notes.md
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Adding `--draft` permits review before publication and does not trigger the publisher. The tag must match the exact gem version and point to a commit on `main`. Set `--prerelease` only for a prerelease gem version.
|
|
@@ -36,7 +36,7 @@ If the workflow itself needs a correction, fix it on `main` and dispatch the
|
|
|
36
36
|
corrected release workflow against the existing published tag:
|
|
37
37
|
|
|
38
38
|
```sh
|
|
39
|
-
gh workflow run release.yml --ref main -f tag=v0.
|
|
39
|
+
gh workflow run release.yml --ref main -f tag=v0.11.0
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
Validation resolves the original tag to an exact commit, requires it to be on
|
|
@@ -4,6 +4,7 @@ require_relative "configuration"
|
|
|
4
4
|
require_relative "inspection"
|
|
5
5
|
require_relative "native_recipe"
|
|
6
6
|
require_relative "macos_signing"
|
|
7
|
+
require_relative "windows_signing"
|
|
7
8
|
require_relative "appimage"
|
|
8
9
|
|
|
9
10
|
module NativePackages
|
|
@@ -41,6 +42,7 @@ module NativePackages
|
|
|
41
42
|
metadata = configuration.target_tokens(configuration.tokens("9.8.7"), id, target, "/payload").merge("PACKAGE" => "/output/package", "FORMAT" => target.fetch("formats").first)
|
|
42
43
|
NativeRecipe.new(root).doctor(target, render_tree(target.fetch("native").fetch("command"), metadata))
|
|
43
44
|
MacosSigning.new(root).doctor if target["platform"] == "macos"
|
|
45
|
+
WindowsSigning.new(configuration).doctor if target["platform"] == "windows"
|
|
44
46
|
end
|
|
45
47
|
required = []
|
|
46
48
|
required << "readelf" if selected.values.any? { |target| target["platform"] == "linux" && target.fetch("kind", "binary") == "binary" }
|
|
@@ -95,8 +97,13 @@ module NativePackages
|
|
|
95
97
|
end
|
|
96
98
|
output = Pathname.new(output || root / "dist/packages" / number).expand_path(root)
|
|
97
99
|
if dry_run
|
|
98
|
-
|
|
99
|
-
"recipes" => defer_recipes ? "deferred" : "included", "targets" => selected.transform_values { |target| target.slice("formats", "platform", "arch", "input", "before_build", "after_package", "native") }
|
|
100
|
+
plan = { "version" => number, "mode" => release ? "release" : "local", "output" => output.to_s,
|
|
101
|
+
"recipes" => defer_recipes ? "deferred" : "included", "targets" => selected.transform_values { |target| target.slice("formats", "platform", "arch", "input", "before_build", "after_package", "native") } }
|
|
102
|
+
windows = WindowsSigning.new(configuration)
|
|
103
|
+
if windows.configured? && selected.values.any? { |target| target["platform"] == "windows" && target["native"] }
|
|
104
|
+
plan["windows_signing"] = { "provider" => WindowsSigning::PROVIDER, "state" => windows.state }
|
|
105
|
+
end
|
|
106
|
+
puts JSON.pretty_generate(plan)
|
|
100
107
|
return
|
|
101
108
|
end
|
|
102
109
|
raise Error, "output exists: #{output}; choose a fresh --output" if output.exist?
|
|
@@ -142,7 +149,11 @@ module NativePackages
|
|
|
142
149
|
else
|
|
143
150
|
copy_input(source, payload, input.fetch("kind", "archive"))
|
|
144
151
|
end
|
|
145
|
-
signer = target["platform"] == "macos"
|
|
152
|
+
signer = if target["platform"] == "macos"
|
|
153
|
+
MacosSigning.new(root)
|
|
154
|
+
elsif target["platform"] == "windows" && native
|
|
155
|
+
WindowsSigning.new(configuration)
|
|
156
|
+
end
|
|
146
157
|
with_signing(signer) do |signing|
|
|
147
158
|
signing.sign_payload(payload) if signing
|
|
148
159
|
payload_digest = native && native.digest(payload)
|
|
@@ -195,7 +206,12 @@ module NativePackages
|
|
|
195
206
|
native.check_output(packages.first, format)
|
|
196
207
|
raise Error, "native recipes/signing must not change their input payload" unless native.digest(payload) == payload_digest
|
|
197
208
|
end
|
|
198
|
-
|
|
209
|
+
if signing.is_a?(MacosSigning)
|
|
210
|
+
inspection["apple"] = signing.notarize(packages.first)
|
|
211
|
+
elsif signing
|
|
212
|
+
inspection["windows_signature"] = signing.sign_package(packages.first)
|
|
213
|
+
native.check_output(packages.first, format)
|
|
214
|
+
end
|
|
199
215
|
record = { "target" => id, "format" => format, "path" => packages.first.relative_path_from(staging).to_s,
|
|
200
216
|
"sha256" => sha256(packages.first), "validation" => inspection }
|
|
201
217
|
record["zsync"] = zsync.relative_path_from(staging).to_s if format == "appimage" && zsync
|
data/lib/native_packages/cli.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative "build"
|
|
4
4
|
require_relative "scaffold"
|
|
5
5
|
require_relative "release_signing"
|
|
6
|
+
require_relative "omarchy"
|
|
6
7
|
|
|
7
8
|
module NativePackages
|
|
8
9
|
module CLI
|
|
@@ -16,6 +17,7 @@ module NativePackages
|
|
|
16
17
|
[--output DIRECTORY] [--dry-run] Choose output or inspect the plan
|
|
17
18
|
[--defer-recipes] Build targets without recipe assets/tools
|
|
18
19
|
notarize-macos DIRECTORY --output DIRECTORY Copy, sign and notarize portable Mac code
|
|
20
|
+
sign-windows FILE... Sign Windows files in place (Azure Artifact Signing)
|
|
19
21
|
release-checksums DIRECTORY --output FILE Hash a flat directory of release artifacts
|
|
20
22
|
sign-checksums FILE --public-key HEX_FILE Sign verified checksums with Ed25519
|
|
21
23
|
[--key-env VARIABLE] Default: NATIVE_PACKAGES_SIGNING_KEY
|
|
@@ -31,6 +33,8 @@ module NativePackages
|
|
|
31
33
|
publish TARGET [--body-file FILE] Publish a staged downstream update
|
|
32
34
|
status [TARGET] [--json] [--offline] Check downstream versions and requests
|
|
33
35
|
check-version TAG Check the application's version
|
|
36
|
+
omarchy-recipe CHECKOUT --release TAG Write a first Omarchy -bin recipe
|
|
37
|
+
[--package NAME] into an omarchy-pkgs checkout
|
|
34
38
|
Legacy commands remain available:
|
|
35
39
|
prepare VERSION [--output DIRECTORY]
|
|
36
40
|
check DIRECTORY
|
|
@@ -70,6 +74,10 @@ module NativePackages
|
|
|
70
74
|
flags.on("--version VERSION") { |value| options[:value] = value }
|
|
71
75
|
flags.on("--dry-run") { options[:dry_run] = true }
|
|
72
76
|
end
|
|
77
|
+
if command == "omarchy-recipe"
|
|
78
|
+
flags.on("--release TAG") { |value| options[:release] = value }
|
|
79
|
+
flags.on("--package NAME") { |value| options[:package] = value }
|
|
80
|
+
end
|
|
73
81
|
flags.on("--finalize-recipes") { options[:finalize_recipes] = true } if command == "aggregate"
|
|
74
82
|
if command == "init"
|
|
75
83
|
flags.on("--interactive") { options[:interactive] = true }
|
|
@@ -92,8 +100,8 @@ module NativePackages
|
|
|
92
100
|
arity = { "init" => 0..0, "migrate" => 0..0, "build" => 0..0, "doctor" => 0..0, "aggregate" => 1..,
|
|
93
101
|
"release-checksums" => 1..1, "sign-checksums" => 1..1, "verify-checksums" => 1..1,
|
|
94
102
|
"prepare" => 1..1, "check" => 1..1, "artifacts" => 1..1, "publish-release" => 2..2,
|
|
95
|
-
"notarize-macos" => 1..1, "repositories" => 0..0, "stage" => 2..2, "diff" => 1..1, "publish" => options[:from] ? 0..0 : 1..1,
|
|
96
|
-
"publish-aur" => 1..1, "status" => 0..1, "check-version" => 1..1, "validate" => 0..0 }[command]
|
|
103
|
+
"notarize-macos" => 1..1, "sign-windows" => 1.., "repositories" => 0..0, "stage" => 2..2, "diff" => 1..1, "publish" => options[:from] ? 0..0 : 1..1,
|
|
104
|
+
"publish-aur" => 1..1, "status" => 0..1, "check-version" => 1..1, "validate" => 0..0, "omarchy-recipe" => 1..1 }[command]
|
|
97
105
|
raise Error, HELP unless arity&.cover?(arguments.length)
|
|
98
106
|
if %w[release-checksums sign-checksums verify-checksums].include?(command)
|
|
99
107
|
path = Pathname.new(arguments.first).expand_path(root)
|
|
@@ -116,6 +124,15 @@ module NativePackages
|
|
|
116
124
|
end
|
|
117
125
|
path = Configuration.discover(root, config_path)
|
|
118
126
|
configuration = path && Configuration.new(path)
|
|
127
|
+
if command == "sign-windows"
|
|
128
|
+
raise Error, "create native-packages.yaml with windows.signing to sign Windows files" unless configuration
|
|
129
|
+
return WindowsSigning.new(configuration).sign_files(arguments.map { |file| Pathname.new(file).expand_path(root) })
|
|
130
|
+
end
|
|
131
|
+
if command == "omarchy-recipe"
|
|
132
|
+
raise Error, "create native-packages.yaml with init" unless configuration
|
|
133
|
+
raise Error, "omarchy-recipe requires --release" unless options[:release]
|
|
134
|
+
return Omarchy.new(configuration).recipe(Pathname.new(arguments.first).expand_path(root), **options.slice(:release, :package))
|
|
135
|
+
end
|
|
119
136
|
if %w[build doctor aggregate].include?(command) || options[:from]
|
|
120
137
|
raise Error, "create native-packages.yaml with init, or convert existing packaging with migrate" unless configuration
|
|
121
138
|
builder = Build.new(configuration)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "project"
|
|
4
4
|
require_relative "appimage"
|
|
5
|
+
require_relative "windows_signing"
|
|
5
6
|
|
|
6
7
|
module NativePackages
|
|
7
8
|
class Configuration
|
|
@@ -10,7 +11,7 @@ module NativePackages
|
|
|
10
11
|
FORMATS = (%w[deb rpm archlinux apk ipk msix srpm appimage] + NATIVE_FORMATS).freeze
|
|
11
12
|
NFPM_VERSION = "2.47.0"
|
|
12
13
|
NAMES = %w[native-packages.yaml native-packages.yml].freeze
|
|
13
|
-
KEYS = %w[schema tool nfpm targets release assets templates repositories revisions libraries version_file version_section].freeze
|
|
14
|
+
KEYS = %w[schema tool nfpm targets release assets templates repositories revisions libraries version_file version_section windows].freeze
|
|
14
15
|
attr_reader :root, :path, :data
|
|
15
16
|
|
|
16
17
|
def self.discover(root, explicit = nil)
|
|
@@ -165,6 +166,7 @@ module NativePackages
|
|
|
165
166
|
relative_path(render(destination, metadata))
|
|
166
167
|
render((root / relative_path(source)).binread, metadata)
|
|
167
168
|
end
|
|
169
|
+
WindowsSigning.validate(data)
|
|
168
170
|
project.repositories
|
|
169
171
|
true
|
|
170
172
|
end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "build"
|
|
4
|
+
|
|
5
|
+
module NativePackages
|
|
6
|
+
# Writes a first Omarchy recipe (omacom/omarchy-pkgs) from the app's AUR -bin
|
|
7
|
+
# templates. Omarchy's bot then opens every later version bump itself, from
|
|
8
|
+
# the upstream declaration in .omarchy/package.json, so this runs once.
|
|
9
|
+
class Omarchy
|
|
10
|
+
include Support
|
|
11
|
+
ARCHITECTURES = %w[x86_64 aarch64].freeze
|
|
12
|
+
# The policy RawMakase and superwhisper-bin use: hourly, self-merging updates that wait a day
|
|
13
|
+
# after each GitHub release and go to every channel at once.
|
|
14
|
+
POLICY = { "source" => "local", "auto_merge" => true, "release_ring" => "fast", "min_release_age" => "24h" }.freeze
|
|
15
|
+
PROBE = "999.0.0"
|
|
16
|
+
# Releases are tagged vMAJOR.MINOR.PATCH; the watch must match the whole tag.
|
|
17
|
+
TAG_PATTERN = "v(?P<version>[0-9]+(?:\\.[0-9]+)*)"
|
|
18
|
+
|
|
19
|
+
attr_reader :configuration, :root
|
|
20
|
+
|
|
21
|
+
def initialize(configuration)
|
|
22
|
+
@configuration = configuration
|
|
23
|
+
@root = configuration.root
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def recipe(checkout, release:, package: nil)
|
|
27
|
+
configuration.validate
|
|
28
|
+
version = version_arg(release)
|
|
29
|
+
name = package || bin_package
|
|
30
|
+
templates = configuration.data.fetch("templates").select { |path, _| path.start_with?("arch/#{name}/") }
|
|
31
|
+
raise Error, "no template for arch/#{name}/PKGBUILD" unless templates.key?("arch/#{name}/PKGBUILD")
|
|
32
|
+
checkout = Pathname.new(checkout).expand_path
|
|
33
|
+
raise Error, "#{checkout} is not an omarchy-pkgs checkout (no pkgbuilds/)" unless (checkout / "pkgbuilds").directory?
|
|
34
|
+
destination = checkout / "pkgbuilds" / name
|
|
35
|
+
raise Error, "#{destination} exists; after the first PR Omarchy's bot updates it" if destination.exist? || destination.symlink?
|
|
36
|
+
|
|
37
|
+
build = Build.new(configuration)
|
|
38
|
+
metadata = build.metadata(version, release: true).merge("PKGREL" => 1)
|
|
39
|
+
checksums = build.release_checksums(metadata)
|
|
40
|
+
configuration.data.fetch("assets").each_key do |key|
|
|
41
|
+
digest = checksums[metadata.fetch("#{key}_FILE")]
|
|
42
|
+
metadata["#{key}_SHA256"] = digest if digest
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Dir.mktmpdir(".#{name}-", checkout / "pkgbuilds") do |temporary|
|
|
46
|
+
staging = Pathname.new(temporary) / name
|
|
47
|
+
templates.each do |path, source|
|
|
48
|
+
template = root / relative_path(source)
|
|
49
|
+
content = render(template.binread, metadata)
|
|
50
|
+
content = follow_pkgver(content, version) if File.basename(path) == "PKGBUILD"
|
|
51
|
+
write(staging / relative_path(path).relative_path_from(Pathname.new("arch/#{name}")), content, executable: template.executable?)
|
|
52
|
+
end
|
|
53
|
+
upstream = declaration(staging, name, version, checksums)
|
|
54
|
+
write(staging / ".omarchy/package.json", JSON.pretty_generate(POLICY.merge("upstream" => upstream)) + "\n")
|
|
55
|
+
staging.rename(destination)
|
|
56
|
+
end
|
|
57
|
+
puts "Wrote #{destination}"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# The one AUR binary recipe, unless the caller names it.
|
|
61
|
+
def bin_package
|
|
62
|
+
names = configuration.data.fetch("templates").keys.filter_map { |path| path[%r{\Aarch/([^/]+-bin)/PKGBUILD\z}, 1] }
|
|
63
|
+
raise Error, "no arch/NAME-bin/PKGBUILD template; add one or pass --package" if names.empty?
|
|
64
|
+
raise Error, "several -bin templates (#{names.join(', ')}); pass --package" if names.length > 1
|
|
65
|
+
names.first
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Omarchy's bot rewrites only pkgver, pkgrel and the checksums, so every
|
|
69
|
+
# source URL has to be written in terms of pkgver.
|
|
70
|
+
def follow_pkgver(content, version)
|
|
71
|
+
literal = /(?<![0-9.])#{Regexp.escape(version)}(?![0-9])/
|
|
72
|
+
content.gsub(/^source(?:_[A-Za-z0-9_]+)?=\(.*?\)/m) { |array| array.gsub(literal, "${pkgver}") }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def declaration(staging, name, version, checksums)
|
|
76
|
+
pkgbuild = staging / "PKGBUILD"
|
|
77
|
+
run "bash", "-n", pkgbuild
|
|
78
|
+
upstream = configuration.project.upstream
|
|
79
|
+
sources = {}
|
|
80
|
+
architectures = nil
|
|
81
|
+
ARCHITECTURES.each do |arch|
|
|
82
|
+
recipe = inspect_recipe(pkgbuild, arch)
|
|
83
|
+
architectures ||= recipe.fetch("arch")
|
|
84
|
+
raise Error, "PKGBUILD pkgname must be #{name}" unless recipe.fetch("pkgname") == [name]
|
|
85
|
+
raise Error, "PKGBUILD pkgver must be #{version}" unless recipe.fetch("pkgver") == [version]
|
|
86
|
+
unless !architectures.empty? && (architectures - ARCHITECTURES).empty?
|
|
87
|
+
raise Error, "PKGBUILD arch must list x86_64 and/or aarch64"
|
|
88
|
+
end
|
|
89
|
+
if recipe.fetch("source").any? { |entry| entry.split("::", 2).last.match?(%r{\A[a-z+]+://}) }
|
|
90
|
+
raise Error, "move downloads into source_<arch>: each architecture downloads its own release assets"
|
|
91
|
+
end
|
|
92
|
+
next unless architectures.include?(arch)
|
|
93
|
+
|
|
94
|
+
urls = recipe.fetch("source_#{arch}").map { |entry| entry.split("::", 2).last }
|
|
95
|
+
sums = recipe.fetch("sha256sums_#{arch}")
|
|
96
|
+
raise Error, "source_#{arch} must download the release assets" if urls.empty?
|
|
97
|
+
raise Error, "sha256sums_#{arch} must match source_#{arch}" unless sums.length == urls.length
|
|
98
|
+
prefix = "#{upstream}/releases/download/v#{version}/"
|
|
99
|
+
urls.each_with_index do |url, index|
|
|
100
|
+
raise Error, "source_#{arch} leaves a variable unexpanded; use double quotes: #{url}" if url.include?("$")
|
|
101
|
+
raise Error, "source_#{arch} must come from #{prefix}: #{url}" unless url.start_with?(prefix)
|
|
102
|
+
file = url.delete_prefix(prefix)
|
|
103
|
+
raise Error, "#{file} is not listed in the release checksums" unless checksums.key?(file)
|
|
104
|
+
raise Error, "sha256sums_#{arch} disagrees with the release checksums for #{file}" unless sums[index] == checksums.fetch(file)
|
|
105
|
+
end
|
|
106
|
+
sources[arch] = urls
|
|
107
|
+
end
|
|
108
|
+
# Prove the URLs move with pkgver, as they will when the bot bumps it.
|
|
109
|
+
probe = staging / "PKGBUILD.probe"
|
|
110
|
+
probe.write(pkgbuild.read.sub(/^pkgver=.*$/, "pkgver=#{PROBE}"))
|
|
111
|
+
begin
|
|
112
|
+
sources.each do |arch, urls|
|
|
113
|
+
moved = inspect_recipe(probe, arch).fetch("source_#{arch}").map { |entry| entry.split("::", 2).last }
|
|
114
|
+
raise Error, "source_#{arch} does not follow pkgver" unless moved == urls.map { |url| url.gsub(version, PROBE) }
|
|
115
|
+
end
|
|
116
|
+
ensure
|
|
117
|
+
probe.delete
|
|
118
|
+
end
|
|
119
|
+
# The watch takes each new tag's SHA-256 from the digest GitHub reports
|
|
120
|
+
# for the asset at that exact URL, which is why every source above must
|
|
121
|
+
# be a release download and match the release's own checksums.
|
|
122
|
+
{ "watch" => { "github" => configuration.data.fetch("release").fetch("repository"), "pattern" => TAG_PATTERN } }
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Source the recipe the way omarchy-pkgs' tooling does: CARCH set and
|
|
126
|
+
# nothing else from the environment.
|
|
127
|
+
def inspect_recipe(path, arch)
|
|
128
|
+
script = <<~'BASH'
|
|
129
|
+
source "$1" >/dev/null
|
|
130
|
+
emit() { printf '%s' "$1"; shift; printf '\t%s' "$@"; printf '\n'; }
|
|
131
|
+
emit pkgname "${pkgname[@]}"; emit pkgver "$pkgver"; emit arch "${arch[@]}"; emit source "${source[@]}"
|
|
132
|
+
for name in source_x86_64 source_aarch64 sha256sums_x86_64 sha256sums_aarch64; do
|
|
133
|
+
declare -n values="$name"; emit "$name" "${values[@]}"; unset -n values
|
|
134
|
+
done
|
|
135
|
+
BASH
|
|
136
|
+
output = capture("env", "-i", "PATH=/usr/bin:/bin", "CARCH=#{arch}", "bash", "-c", script, "bash", path.basename, chdir: path.dirname)
|
|
137
|
+
output.lines.to_h { |line| key, *values = line.chomp.split("\t", -1); [key, values.reject(&:empty?)] }
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|