native-packages 0.9.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 +5 -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 +28 -1
- data/docs/_reference/platforms.md +40 -5
- 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/appimage.rb +119 -8
- data/lib/native_packages/build.rb +35 -12
- data/lib/native_packages/cli.rb +19 -2
- data/lib/native_packages/configuration.rb +17 -2
- 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.
|
|
@@ -96,6 +97,7 @@ letters, digits, and hyphens, starting with a letter or digit.
|
|
|
96
97
|
| `before_build` | Command arguments run before copying a local input. |
|
|
97
98
|
| `after_package` | Command arguments run on each package before its hash is recorded. |
|
|
98
99
|
| `native` | Required for DMG, MSI and Inno. Contains `command` and `output`. |
|
|
100
|
+
| `appimage` | Optional for AppImage targets: `update_information`, embedded with a `.zsync` file beside the AppImage. See [AppImage](platforms.md#update-information). |
|
|
99
101
|
|
|
100
102
|
Formats are `deb`, `rpm`, `archlinux`, `apk`, `ipk`, `appimage`, `srpm`,
|
|
101
103
|
`msix`, `dmg`, `msi`, and `inno`. See [Supported platforms](platforms.md) for their requirements.
|
|
@@ -153,6 +155,31 @@ For DMGs, automatic Apple input signing finishes before the native command.
|
|
|
153
155
|
DMG signing and notarization run after `after_package`, before the final hash.
|
|
154
156
|
See [Apple signing and notarization](../_guides/apple-notarization.md).
|
|
155
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
|
+
|
|
156
183
|
## Replacement values
|
|
157
184
|
|
|
158
185
|
Strings can contain `@KEY@` values. Unknown or unavailable values cause an error.
|
|
@@ -19,12 +19,12 @@ libraries.
|
|
|
19
19
|
| `archlinux` | Linux | Arch-compatible files and explicit dependencies. | nFPM, `readelf` for binaries. |
|
|
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
|
-
| `appimage` | Linux | The same files as the DEB/RPM, including one desktop entry and its icon. | `mksquashfs` (squashfs-tools), `curl`, `readelf
|
|
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. |
|
|
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.
|
|
@@ -84,7 +84,41 @@ DEB and RPM do, and `build.json` lists what the binary links under
|
|
|
84
84
|
`required_libraries` with `"libraries": "host"`. It therefore runs where your
|
|
85
85
|
binary's glibc floor and those libraries are met, not on every Linux system.
|
|
86
86
|
Build on the oldest distribution you support, or link statically, to widen
|
|
87
|
-
that. The AppImage
|
|
87
|
+
that. The AppImage is not signed.
|
|
88
|
+
|
|
89
|
+
### Update information
|
|
90
|
+
|
|
91
|
+
AppImageUpdate, AppImageLauncher, AM, Gear Lever and other updaters find a
|
|
92
|
+
newer AppImage through the update information embedded in it, and download
|
|
93
|
+
only the blocks that changed through a `.zsync` file published beside it.
|
|
94
|
+
Give the target an `appimage.update_information`:
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
linux-amd64:
|
|
98
|
+
platform: linux
|
|
99
|
+
arch: amd64
|
|
100
|
+
libc: glibc
|
|
101
|
+
formats: [appimage]
|
|
102
|
+
appimage:
|
|
103
|
+
update_information: gh-releases-zsync|owner|app|latest|app-*-x86_64.AppImage.zsync
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The string goes into the runtime's `.upd_info` section, and the build reads
|
|
107
|
+
it back from the finished AppImage. `zsyncmake` then writes
|
|
108
|
+
`NAME-VERSION-ARCH.AppImage.zsync` beside it, with the AppImage's file name
|
|
109
|
+
as its relative URL, and the build checks the file's name, length and SHA-1
|
|
110
|
+
against the AppImage. `build.json` records the `.zsync` file with its
|
|
111
|
+
package, and `publish --to github` attaches both. The same inputs give the
|
|
112
|
+
same bytes for both files.
|
|
113
|
+
|
|
114
|
+
Two forms are accepted: `gh-releases-zsync|OWNER|REPOSITORY|TAG|PATTERN`,
|
|
115
|
+
where `TAG` is usually `latest` (the newest stable release), and
|
|
116
|
+
`zsync|https://URL.zsync`. A GitHub string must name `release.repository`,
|
|
117
|
+
and its pattern must match the target's `.zsync` file name, so validation
|
|
118
|
+
fails before a release could ship an AppImage whose updaters look for a file
|
|
119
|
+
that is not there. Each architecture needs its own target with its own
|
|
120
|
+
pattern. An `after_package` hook must leave the AppImage as it is, or the
|
|
121
|
+
`.zsync` file no longer describes it and the build fails.
|
|
88
122
|
|
|
89
123
|
Running an AppImage needs FUSE on the user's system, or
|
|
90
124
|
`./App.AppImage --appimage-extract-and-run`.
|
|
@@ -115,7 +149,8 @@ target with a local directory input. macOS inspection supports `amd64`,
|
|
|
115
149
|
|
|
116
150
|
Follow [macOS and Windows installers](../_guides/native-recipes.md) for setup.
|
|
117
151
|
DMG targets can automatically [sign and notarize](../_guides/apple-notarization.md)
|
|
118
|
-
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).
|
|
119
154
|
|
|
120
155
|
## Distribution recipes
|
|
121
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
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "digest"
|
|
4
|
+
|
|
3
5
|
module NativePackages
|
|
4
6
|
# Builds a type 2 AppImage from the same contents nFPM packages: the files
|
|
5
7
|
# are laid out in an AppDir, packed with mksquashfs and appended to a pinned
|
|
@@ -17,6 +19,13 @@ module NativePackages
|
|
|
17
19
|
"arm7" => ["armhf", "e9060d37577b8a29914ec12d8740add24e19ff29012fb1fa0f60daf62db0688d"]
|
|
18
20
|
}.freeze
|
|
19
21
|
ICON_DIRECTORIES = %w[usr/share/icons usr/share/pixmaps].freeze
|
|
22
|
+
# The runtime's ELF section that AppImageUpdate and the other updaters
|
|
23
|
+
# read: a NUL-terminated string in a fixed 1024 bytes.
|
|
24
|
+
UPDATE_SECTION = ".upd_info"
|
|
25
|
+
# AppImage's update information formats, without the `bintray-zsync`
|
|
26
|
+
# and `pling-v1-zsync` services that no longer exist.
|
|
27
|
+
GITHUB_UPDATE = /\Agh-releases-zsync\|([A-Za-z0-9_.-]+)\|([A-Za-z0-9_.-]+)\|([^|\s]+)\|([^|\s]+\.zsync)\z/
|
|
28
|
+
URL_UPDATE = %r{\Azsync\|https://[^|\s]+\.zsync\z}
|
|
20
29
|
attr_reader :root
|
|
21
30
|
|
|
22
31
|
def initialize(root)
|
|
@@ -29,10 +38,81 @@ module NativePackages
|
|
|
29
38
|
|
|
30
39
|
def self.filename(name, version, target) = "#{name}-#{version}-#{architecture(target)}.AppImage"
|
|
31
40
|
|
|
32
|
-
|
|
41
|
+
# The target's update information, checked against the AppImage it
|
|
42
|
+
# describes: a GitHub string must name the release repository, and its
|
|
43
|
+
# file pattern must match this target's `.zsync` file, so a release
|
|
44
|
+
# never ships an AppImage whose updaters look for a file that is not
|
|
45
|
+
# there. Returns nil when the target has none.
|
|
46
|
+
def self.update_information(target, name:, version:, repository:)
|
|
47
|
+
settings = target["appimage"]
|
|
48
|
+
return nil if settings.nil?
|
|
49
|
+
raise Error, "appimage: expected a mapping" unless settings.is_a?(Hash)
|
|
50
|
+
unknown = settings.keys - %w[update_information]
|
|
51
|
+
raise Error, "appimage: unknown fields #{unknown.join(', ')}" unless unknown.empty?
|
|
52
|
+
value = settings["update_information"]
|
|
53
|
+
raise Error, "appimage.update_information: expected a string" unless value.is_a?(String) && !value.empty?
|
|
54
|
+
raise Error, "appimage.update_information: at most 1023 bytes" if value.bytesize > 1023
|
|
55
|
+
if (match = GITHUB_UPDATE.match(value))
|
|
56
|
+
owner, project, _tag, pattern = match.captures
|
|
57
|
+
unless "#{owner}/#{project}".casecmp?(repository.to_s)
|
|
58
|
+
raise Error, "appimage.update_information names #{owner}/#{project}, but release.repository is #{repository.inspect}"
|
|
59
|
+
end
|
|
60
|
+
zsync = "#{filename(name, version, target)}.zsync"
|
|
61
|
+
unless File.fnmatch?(pattern, zsync, File::FNM_PATHNAME)
|
|
62
|
+
raise Error, "appimage.update_information: #{pattern} does not match #{zsync}"
|
|
63
|
+
end
|
|
64
|
+
elsif !URL_UPDATE.match?(value)
|
|
65
|
+
raise Error, "appimage.update_information: use gh-releases-zsync|OWNER|REPOSITORY|TAG|FILE.zsync or zsync|https://URL.zsync"
|
|
66
|
+
end
|
|
67
|
+
value
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# The file offset and size of the ELF section `name` in `bytes`, or nil.
|
|
71
|
+
# Every AppImage runtime is a little-endian ELF file, 32 or 64 bits.
|
|
72
|
+
def self.section(bytes, name)
|
|
73
|
+
raise Error, "AppImage runtime is not a little-endian ELF file" unless bytes.start_with?("\x7fELF".b) && bytes.getbyte(5) == 1
|
|
74
|
+
wide = { 1 => false, 2 => true }.fetch(bytes.getbyte(4)) { raise Error, "AppImage runtime has an unknown ELF class" }
|
|
75
|
+
offset = wide ? bytes.byteslice(0x28, 8).unpack1("Q<") : bytes.byteslice(0x20, 4).unpack1("V")
|
|
76
|
+
size, count, names = bytes.byteslice(wide ? 0x3A : 0x2E, 6).unpack("v3")
|
|
77
|
+
header = lambda do |index|
|
|
78
|
+
entry = bytes.byteslice(offset + (index * size), size)
|
|
79
|
+
raise Error, "AppImage runtime has a truncated section table" unless entry && entry.bytesize == size
|
|
80
|
+
wide ? [entry.unpack1("V"), *entry.byteslice(0x18, 16).unpack("Q<2")] : [entry.unpack1("V"), *entry.byteslice(0x10, 8).unpack("V2")]
|
|
81
|
+
end
|
|
82
|
+
_, strings, = header.call(names)
|
|
83
|
+
count.times do |index|
|
|
84
|
+
label, start, length = header.call(index)
|
|
85
|
+
found = bytes.byteslice(strings + label, name.bytesize + 1)
|
|
86
|
+
return [start, length] if found == "#{name}\0".b
|
|
87
|
+
end
|
|
88
|
+
nil
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# `runtime` with `information` in its update section.
|
|
92
|
+
def self.embed(runtime, information)
|
|
93
|
+
start, length = section(runtime, UPDATE_SECTION) || raise(Error, "AppImage runtime has no #{UPDATE_SECTION} section")
|
|
94
|
+
raise Error, "update information exceeds the runtime's #{length}-byte #{UPDATE_SECTION} section" if information.bytesize >= length
|
|
95
|
+
raise Error, "AppImage runtime's #{UPDATE_SECTION} section is outside the file" if start + length > runtime.bytesize
|
|
96
|
+
runtime = runtime.b
|
|
97
|
+
runtime[start, length] = information.b + ("\0".b * (length - information.bytesize))
|
|
98
|
+
runtime
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# The update information an AppImage carries, or nil when it has none.
|
|
102
|
+
def self.read_update_information(path)
|
|
103
|
+
bytes = File.binread(path)
|
|
104
|
+
start, length = section(bytes, UPDATE_SECTION)
|
|
105
|
+
return nil unless start
|
|
106
|
+
value = bytes.byteslice(start, length)[/\A[^\0]*/n]
|
|
107
|
+
value.empty? ? nil : value
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def doctor(target, update: false)
|
|
33
111
|
self.class.architecture(target)
|
|
34
|
-
|
|
35
|
-
|
|
112
|
+
tools = %w[mksquashfs curl]
|
|
113
|
+
tools << "zsyncmake" if update
|
|
114
|
+
missing = tools.reject { |tool| available?(tool) }
|
|
115
|
+
raise Error, "install required AppImage tools: #{missing.join(', ')} (mksquashfs is in squashfs-tools, zsyncmake in zsync)" unless missing.empty?
|
|
36
116
|
end
|
|
37
117
|
|
|
38
118
|
def runtime(target)
|
|
@@ -46,9 +126,11 @@ module NativePackages
|
|
|
46
126
|
path
|
|
47
127
|
end
|
|
48
128
|
|
|
49
|
-
# Returns the AppImage's path
|
|
50
|
-
|
|
51
|
-
|
|
129
|
+
# Returns the AppImage's path, what was put at the AppDir's root, and
|
|
130
|
+
# the `.zsync` file beside it when the AppImage carries update
|
|
131
|
+
# information (nil otherwise).
|
|
132
|
+
def build(package, target, destination, name:, version:, epoch:, update: nil)
|
|
133
|
+
doctor(target, update: !update.nil?)
|
|
52
134
|
output = destination / self.class.filename(name, version, target)
|
|
53
135
|
Dir.mktmpdir("native-packages-appimage-") do |directory|
|
|
54
136
|
appdir = Pathname.new(directory) / "AppDir"
|
|
@@ -59,14 +141,43 @@ module NativePackages
|
|
|
59
141
|
image = Pathname.new(directory) / "filesystem.squashfs"
|
|
60
142
|
run "mksquashfs", appdir, image, "-root-owned", "-noappend", "-no-xattrs", "-no-progress", "-quiet", "-comp", "zstd",
|
|
61
143
|
env: { "SOURCE_DATE_EPOCH" => epoch.to_s }
|
|
144
|
+
bytes = runtime(target).binread
|
|
145
|
+
bytes = self.class.embed(bytes, update) if update
|
|
62
146
|
File.open(output, "wb") do |file|
|
|
63
|
-
file.write(
|
|
147
|
+
file.write(bytes)
|
|
64
148
|
IO.copy_stream(image.to_s, file)
|
|
65
149
|
end
|
|
66
150
|
output.chmod(0o755)
|
|
67
151
|
check(output)
|
|
68
|
-
|
|
152
|
+
details = entry.merge("runtime" => RUNTIME, "libraries" => "host")
|
|
153
|
+
return [output, details, nil] unless update
|
|
154
|
+
raise Error, "AppImage lost its update information: #{output}" unless self.class.read_update_information(output) == update
|
|
155
|
+
[output, details.merge("update_information" => update), zsync(output, epoch)]
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Writes `<AppImage>.zsync` beside the AppImage, for updaters that fetch
|
|
160
|
+
# only the blocks that changed. Its URL is the AppImage's file name,
|
|
161
|
+
# relative to the `.zsync` file, so it works from wherever both are
|
|
162
|
+
# published. The AppImage's time is the build's, which zsyncmake records.
|
|
163
|
+
def zsync(path, epoch)
|
|
164
|
+
File.utime(epoch, epoch, path)
|
|
165
|
+
output = Pathname.new("#{path}.zsync")
|
|
166
|
+
run "zsyncmake", "-u", path.basename.to_s, "-o", output, path, chdir: path.dirname
|
|
167
|
+
check_zsync(output, path)
|
|
168
|
+
output
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Fails unless `zsync` describes the AppImage at `path` as it is now.
|
|
172
|
+
def check_zsync(zsync, path)
|
|
173
|
+
header = zsync.binread.split("\n\n".b, 2).first.to_s.force_encoding(Encoding::UTF_8).lines.to_h do |line|
|
|
174
|
+
key, value = line.chomp.split(": ", 2)
|
|
175
|
+
[key, value]
|
|
69
176
|
end
|
|
177
|
+
expected = { "Filename" => path.basename.to_s, "URL" => path.basename.to_s, "Length" => path.size.to_s,
|
|
178
|
+
"SHA-1" => Digest::SHA1.file(path).hexdigest }
|
|
179
|
+
wrong = expected.reject { |key, value| header[key] == value }.keys
|
|
180
|
+
raise Error, "#{zsync.basename} does not describe #{path.basename}: #{wrong.join(', ')}" unless wrong.empty?
|
|
70
181
|
end
|
|
71
182
|
|
|
72
183
|
def check(path)
|
|
@@ -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
|
|
@@ -33,12 +34,15 @@ module NativePackages
|
|
|
33
34
|
configuration.validate
|
|
34
35
|
selected = configuration.select(ids: ids, formats: formats)
|
|
35
36
|
nfpm_version if selected.values.any? { |target| !(target.fetch("formats") - Configuration::NATIVE_FORMATS - ["appimage"]).empty? }
|
|
36
|
-
selected.each_value
|
|
37
|
+
selected.each_value do |target|
|
|
38
|
+
AppImage.new(root).doctor(target, update: !target["appimage"].nil?) if target.fetch("formats").include?("appimage")
|
|
39
|
+
end
|
|
37
40
|
selected.each do |id, target|
|
|
38
41
|
next unless target["native"]
|
|
39
42
|
metadata = configuration.target_tokens(configuration.tokens("9.8.7"), id, target, "/payload").merge("PACKAGE" => "/output/package", "FORMAT" => target.fetch("formats").first)
|
|
40
43
|
NativeRecipe.new(root).doctor(target, render_tree(target.fetch("native").fetch("command"), metadata))
|
|
41
44
|
MacosSigning.new(root).doctor if target["platform"] == "macos"
|
|
45
|
+
WindowsSigning.new(configuration).doctor if target["platform"] == "windows"
|
|
42
46
|
end
|
|
43
47
|
required = []
|
|
44
48
|
required << "readelf" if selected.values.any? { |target| target["platform"] == "linux" && target.fetch("kind", "binary") == "binary" }
|
|
@@ -93,8 +97,13 @@ module NativePackages
|
|
|
93
97
|
end
|
|
94
98
|
output = Pathname.new(output || root / "dist/packages" / number).expand_path(root)
|
|
95
99
|
if dry_run
|
|
96
|
-
|
|
97
|
-
"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)
|
|
98
107
|
return
|
|
99
108
|
end
|
|
100
109
|
raise Error, "output exists: #{output}; choose a fresh --output" if output.exist?
|
|
@@ -140,7 +149,11 @@ module NativePackages
|
|
|
140
149
|
else
|
|
141
150
|
copy_input(source, payload, input.fetch("kind", "archive"))
|
|
142
151
|
end
|
|
143
|
-
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
|
|
144
157
|
with_signing(signer) do |signing|
|
|
145
158
|
signing.sign_payload(payload) if signing
|
|
146
159
|
payload_digest = native && native.digest(payload)
|
|
@@ -160,11 +173,12 @@ module NativePackages
|
|
|
160
173
|
elsif format == "appimage"
|
|
161
174
|
package = render_tree(configuration.package(target), configuration.target_tokens(info, id, target, payload))
|
|
162
175
|
inspection = Inspection.new(root, configuration.data.fetch("libraries")).check(package, target, format)
|
|
163
|
-
package_path, details = AppImage.new(root).build(package, target, destination, name: configuration.name, version: number,
|
|
164
|
-
epoch: info.fetch("SOURCE_DATE_EPOCH"))
|
|
176
|
+
package_path, details, zsync = AppImage.new(root).build(package, target, destination, name: configuration.name, version: number,
|
|
177
|
+
epoch: info.fetch("SOURCE_DATE_EPOCH"), update: configuration.update_information(target, number))
|
|
165
178
|
inspection["appimage"] = details
|
|
166
|
-
|
|
167
|
-
raise Error, "AppImage build must create only its package" unless
|
|
179
|
+
outputs = [package_path, zsync].compact.sort
|
|
180
|
+
raise Error, "AppImage build must create only its package and .zsync file" unless files(destination) == outputs
|
|
181
|
+
packages = [package_path]
|
|
168
182
|
else
|
|
169
183
|
package = render_tree(configuration.package(target), configuration.target_tokens(info, id, target, payload))
|
|
170
184
|
if number.include?("-") && (package.fetch("version_schema", "semver") != "semver" || %w[prerelease version_metadata].any? { |key| package.key?(key) && !package[key].to_s.empty? })
|
|
@@ -180,19 +194,28 @@ module NativePackages
|
|
|
180
194
|
packages = files(destination)
|
|
181
195
|
raise Error, "nFPM did not create exactly one #{format} package" unless packages.length == 1
|
|
182
196
|
end
|
|
197
|
+
outputs ||= packages
|
|
183
198
|
if target["after_package"]
|
|
184
199
|
hook_tokens = configuration.target_tokens(info, id, target, payload).merge("PACKAGE" => packages.first.to_s, "FORMAT" => format)
|
|
185
200
|
run(*render_tree(target.fetch("after_package"), hook_tokens), env: { "NATIVE_PACKAGES_TARGET" => id, "NATIVE_PACKAGES_VERSION" => number })
|
|
186
|
-
raise Error, "after_package must preserve the package path and output set" unless files(destination) ==
|
|
201
|
+
raise Error, "after_package must preserve the package path and output set" unless files(destination) == outputs
|
|
187
202
|
AppImage.new(root).check(packages.first) if format == "appimage"
|
|
203
|
+
AppImage.new(root).check_zsync(zsync, packages.first) if format == "appimage" && zsync
|
|
188
204
|
end
|
|
189
205
|
if native
|
|
190
206
|
native.check_output(packages.first, format)
|
|
191
207
|
raise Error, "native recipes/signing must not change their input payload" unless native.digest(payload) == payload_digest
|
|
192
208
|
end
|
|
193
|
-
|
|
194
|
-
|
|
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
|
|
215
|
+
record = { "target" => id, "format" => format, "path" => packages.first.relative_path_from(staging).to_s,
|
|
195
216
|
"sha256" => sha256(packages.first), "validation" => inspection }
|
|
217
|
+
record["zsync"] = zsync.relative_path_from(staging).to_s if format == "appimage" && zsync
|
|
218
|
+
records << record
|
|
196
219
|
end
|
|
197
220
|
end
|
|
198
221
|
end
|
|
@@ -381,7 +404,7 @@ module NativePackages
|
|
|
381
404
|
end
|
|
382
405
|
destinations.each do |destination|
|
|
383
406
|
if destination == "github"
|
|
384
|
-
paths = manifest.fetch("packages").
|
|
407
|
+
paths = manifest.fetch("packages").flat_map { |entry| [entry.fetch("path"), entry["zsync"]].compact.map { |path| output / path } }
|
|
385
408
|
paths += manifest.fetch("files").keys.grep(/-packaging\.tar\.xz\z/).map { |path| output / path }
|
|
386
409
|
names = paths.map { |path| path.basename.to_s }
|
|
387
410
|
raise Error, "duplicate release asset names; give variants distinct nFPM names/releases" unless names.uniq == names
|
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)
|
|
@@ -86,7 +87,7 @@ module NativePackages
|
|
|
86
87
|
metadata = tokens("9.8.7", epoch: 1_767_225_600)
|
|
87
88
|
targets.each do |id, target|
|
|
88
89
|
raise Error, "invalid target name: #{id}" unless /\A[a-z0-9][a-z0-9-]*\z/.match?(id)
|
|
89
|
-
unknown = target.keys - %w[platform arch libc abi kind formats input nfpm before_build after_package compiler_target native]
|
|
90
|
+
unknown = target.keys - %w[platform arch libc abi kind formats input nfpm before_build after_package compiler_target native appimage]
|
|
90
91
|
raise Error, "targets.#{id}: unknown fields #{unknown.join(', ')}" unless unknown.empty?
|
|
91
92
|
formats = target.fetch("formats")
|
|
92
93
|
unless formats.is_a?(Array) && !formats.empty? && formats.uniq == formats && (formats - FORMATS).empty?
|
|
@@ -125,6 +126,13 @@ module NativePackages
|
|
|
125
126
|
if formats.include?("appimage")
|
|
126
127
|
raise Error, "#{id}: AppImage requires a Linux binary target" unless target["platform"] == "linux" && kind == "binary"
|
|
127
128
|
AppImage.architecture(target)
|
|
129
|
+
elsif target.key?("appimage")
|
|
130
|
+
raise Error, "#{id}.appimage: only for targets that build an AppImage"
|
|
131
|
+
end
|
|
132
|
+
begin
|
|
133
|
+
update_information(target, "9.8.7")
|
|
134
|
+
rescue Error => error
|
|
135
|
+
raise Error, "#{id}.#{error.message}"
|
|
128
136
|
end
|
|
129
137
|
raise Error, "#{id}: IPK needs an explicit abi (device/distribution baseline)" if formats.include?("ipk") && target.fetch("abi", "").empty?
|
|
130
138
|
input = mapping(target.fetch("input"), "#{id}.input")
|
|
@@ -158,10 +166,17 @@ module NativePackages
|
|
|
158
166
|
relative_path(render(destination, metadata))
|
|
159
167
|
render((root / relative_path(source)).binread, metadata)
|
|
160
168
|
end
|
|
169
|
+
WindowsSigning.validate(data)
|
|
161
170
|
project.repositories
|
|
162
171
|
true
|
|
163
172
|
end
|
|
164
173
|
|
|
174
|
+
# The AppImage update information for `target`, checked against the
|
|
175
|
+
# AppImage `version` builds, or nil.
|
|
176
|
+
def update_information(target, version)
|
|
177
|
+
AppImage.update_information(target, name: name, version: version, repository: data.fetch("release")["repository"])
|
|
178
|
+
end
|
|
179
|
+
|
|
165
180
|
def tokens(version, epoch: nil)
|
|
166
181
|
epoch ||= Integer(ENV.fetch("SOURCE_DATE_EPOCH", Time.now.to_i.to_s))
|
|
167
182
|
result = { "NAME" => name, "VERSION" => version, "TAG" => "v#{version}", "DATE" => Time.at(epoch).utc.iso8601,
|