native-packages 0.14.0 → 0.14.2
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/getting-started.md +2 -2
- data/docs/_guides/github-actions.md +28 -5
- data/docs/_guides/native-recipes.md +1 -1
- data/docs/_guides/release-signing.md +3 -3
- data/docs/_guides/windows-signing.md +1 -1
- data/docs/_reference/commands.md +1 -1
- data/docs/_reference/configuration.md +7 -2
- data/docs/_reference/troubleshooting.md +2 -2
- data/docs/index.md +35 -78
- 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/inspection.rb +16 -8
- data/lib/native_packages/repositories.rb +45 -15
- data/lib/native_packages/support.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 17fc26bd6a889fa6d41d323173c4581ecfef2658611d45b3e7749c47d8625bbd
|
|
4
|
+
data.tar.gz: cf9bc477f6d86699e6e9539dc096be0f3b3f40c43bc3ba02b9490b5825e27f4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c57db9d11df199c132820feaeb7260d16ad923819c7bfd84024fddb560a2f7f9d2c6dec76accca7914007a97c1db1852b347a29fe9ad3c95f8c42771f1cd4cff
|
|
7
|
+
data.tar.gz: b5515577429ad908e4a8f72fbad4567d6e52fc5813125478ef73611a209b703b3191763da61c39b76963b49c5f8261537398b252c44b6660909557bc269c7b19
|
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.14.
|
|
21
|
+
ruby test/gem_install.rb native-packages-0.14.2.gem
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
See [Releasing the gem](docs/releasing.md) for publication and
|
|
@@ -19,7 +19,7 @@ own compiled executable, or build the tiny example below.
|
|
|
19
19
|
You need Ruby 3.2 or later. Install the version used by these guides:
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
|
-
gem install native-packages --version 0.14.
|
|
22
|
+
gem install native-packages --version 0.14.2
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
For Linux packages, install **nFPM 2.47.0**, the helper native-packages uses to
|
|
@@ -81,7 +81,7 @@ Open the generated `native-packages.yaml` and replace its contents with:
|
|
|
81
81
|
```yaml
|
|
82
82
|
schema: 1
|
|
83
83
|
tool:
|
|
84
|
-
version: '0.14.
|
|
84
|
+
version: '0.14.2'
|
|
85
85
|
nfpm: '2.47.0'
|
|
86
86
|
|
|
87
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.14.
|
|
27
|
+
uses: crmne/native-packages/.github/workflows/package.yml@v0.14.2
|
|
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.14.
|
|
42
|
+
For an immutable workflow reference, replace `v0.14.2` 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.14.
|
|
60
|
+
uses: crmne/native-packages/.github/workflows/package.yml@v0.14.2
|
|
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.14.
|
|
75
|
+
uses: crmne/native-packages/.github/workflows/package.yml@v0.14.2
|
|
76
76
|
with:
|
|
77
77
|
version: '1.2.3'
|
|
78
78
|
source-artifact: linux-binaries
|
|
@@ -129,7 +129,8 @@ GitHub repository:
|
|
|
129
129
|
| AUR group `aur` | `PUBLISH_AUR=true` | `AUR_SSH_KEY`, `AUR_KNOWN_HOSTS` |
|
|
130
130
|
| Destination or group `homebrew` | `PUBLISH_HOMEBREW=true` | `HOMEBREW_TAP_SSH_KEY` or `HOMEBREW_TAP_GITHUB_TOKEN` |
|
|
131
131
|
|
|
132
|
-
These steps run only with `publish: true
|
|
132
|
+
These steps run only with `publish: true` and a version that is not a
|
|
133
|
+
prerelease; a prerelease only gets its release assets. For Homebrew, prefer a deploy key
|
|
133
134
|
with write access to the tap alone (`gh repo deploy-key add KEY.pub --repo
|
|
134
135
|
OWNER/homebrew-tap --allow-write`) stored as `HOMEBREW_TAP_SSH_KEY`: GitHub URLs in that step then go over SSH,
|
|
135
136
|
checked against GitHub's published host keys. A token
|
|
@@ -139,6 +140,28 @@ Use `secrets: inherit` as in the release example, or pass the named secrets
|
|
|
139
140
|
explicitly. If another tool already publishes a destination, keep one
|
|
140
141
|
publisher responsible for it.
|
|
141
142
|
|
|
143
|
+
## Publish hosted repositories
|
|
144
|
+
|
|
145
|
+
An `apt`, `dnf` or `pacman` section with a
|
|
146
|
+
[bucket](hosted-repositories.md#publish-to-a-bucket) is published by the
|
|
147
|
+
workflow right after the release assets are attached. Set the repository
|
|
148
|
+
variable `PUBLISH_HOSTED=true` and these secrets in your application's
|
|
149
|
+
GitHub repository:
|
|
150
|
+
|
|
151
|
+
| Secret | Purpose |
|
|
152
|
+
| --- | --- |
|
|
153
|
+
| `NATIVE_PACKAGES_GPG_KEY` | The repository signing key's armored secret key. |
|
|
154
|
+
| `NATIVE_PACKAGES_GPG_PASSPHRASE` | Its passphrase, if it has one. |
|
|
155
|
+
| `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` | Credentials that can read, write and delete in the bucket. |
|
|
156
|
+
|
|
157
|
+
The step runs only with `publish: true` and a version that is not a
|
|
158
|
+
prerelease, and publishes every section with a `bucket`; sections that only
|
|
159
|
+
write a directory are left to your own steps, since the runner's copy would
|
|
160
|
+
be lost. It installs `createrepo_c` when there is a DNF repository. A
|
|
161
|
+
section's `directory`, if set, is kept in the Actions cache between runs, so
|
|
162
|
+
only new files are downloaded; publishing corrects whatever an older copy
|
|
163
|
+
holds. A missing secret, or a publication that fails, fails the job.
|
|
164
|
+
|
|
142
165
|
## Multiple jobs and configurations
|
|
143
166
|
|
|
144
167
|
The reusable workflow gives different configuration paths and target
|
|
@@ -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.14.
|
|
70
|
+
The examples use `v0.14.2` 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.14.
|
|
82
|
+
- uses: crmne/native-packages/.github/actions/attest@v0.14.2
|
|
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.14.
|
|
111
|
+
- uses: crmne/native-packages/.github/actions/sign-release@v0.14.2
|
|
112
112
|
with:
|
|
113
113
|
directory: dist/release
|
|
114
114
|
public-key: assets/update-public-key.hex
|
|
@@ -152,7 +152,7 @@ jobs:
|
|
|
152
152
|
- uses: ruby/setup-ruby@v1
|
|
153
153
|
with:
|
|
154
154
|
ruby-version: '4.0'
|
|
155
|
-
- run: gem install native-packages --version 0.14.
|
|
155
|
+
- run: gem install native-packages --version 0.14.2 --no-document
|
|
156
156
|
- run: cargo build --locked --release --target x86_64-pc-windows-msvc
|
|
157
157
|
- name: Sign in to Azure for code signing
|
|
158
158
|
if: vars.AZURE_SIGNING_PROFILE != ''
|
data/docs/_reference/commands.md
CHANGED
|
@@ -224,7 +224,7 @@ If several gem versions are installed, RubyGems lets you select the one required
|
|
|
224
224
|
by the configuration:
|
|
225
225
|
|
|
226
226
|
```sh
|
|
227
|
-
native-packages _0.14.
|
|
227
|
+
native-packages _0.14.2_ build --version 1.2.3
|
|
228
228
|
```
|
|
229
229
|
|
|
230
230
|
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.14.
|
|
31
|
+
| `tool.version` | Required. Exact native-packages version, such as `'0.14.2'`. |
|
|
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. |
|
|
@@ -310,10 +310,15 @@ libraries:
|
|
|
310
310
|
rpm: libexample
|
|
311
311
|
```
|
|
312
312
|
|
|
313
|
-
Mappings extend the built-in DEB
|
|
313
|
+
Mappings extend the built-in DEB table. A mapping for an existing library
|
|
314
314
|
replaces that library's mapping, so include both formats if needed. Verify
|
|
315
315
|
package names against your supported distribution versions.
|
|
316
316
|
|
|
317
|
+
An RPM needs no mapping: it depends on each linked library's soname
|
|
318
|
+
capability (`libexample.so.1()(64bit)` for a 64-bit binary), as rpm's own
|
|
319
|
+
dependency generator does. Fedora and openSUSE both provide that capability,
|
|
320
|
+
whatever each names the package. An `rpm` mapping names a package instead.
|
|
321
|
+
|
|
317
322
|
## Revisions and version checks
|
|
318
323
|
|
|
319
324
|
To regenerate a recipe with a new package revision for the same app version:
|
|
@@ -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.14.
|
|
27
|
-
native-packages _0.14.
|
|
26
|
+
gem install native-packages --version 0.14.2
|
|
27
|
+
native-packages _0.14.2_ 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,85 +1,42 @@
|
|
|
1
1
|
---
|
|
2
2
|
layout: home
|
|
3
3
|
title: native-packages
|
|
4
|
-
|
|
5
|
-
title: DEB, RPM, AppImage, DMG and MSI from one config
|
|
6
|
-
description: Turn your built application into Linux packages, macOS disk images, and Windows installers. Publish releases from one configuration.
|
|
7
|
-
permalink: /
|
|
4
|
+
markdown_styles: false
|
|
8
5
|
hero:
|
|
9
|
-
|
|
10
|
-
text: Turn your app into installable packages
|
|
11
|
-
tagline: One configuration. Linux, macOS, and Windows. Build packages and publish them with every release.
|
|
12
|
-
actions:
|
|
13
|
-
- theme: brand
|
|
14
|
-
text: Get started
|
|
15
|
-
link: /getting-started/
|
|
16
|
-
- star: true
|
|
17
|
-
image:
|
|
6
|
+
logo:
|
|
18
7
|
src: /assets/images/logo.svg
|
|
19
|
-
alt:
|
|
20
|
-
width:
|
|
21
|
-
height:
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
8
|
+
alt: ""
|
|
9
|
+
width: 80
|
|
10
|
+
height: 80
|
|
11
|
+
size: 80
|
|
12
|
+
name: "native-packages:"
|
|
13
|
+
text: one config, every package.
|
|
14
|
+
tagline: You built the app. Describe it once in YAML, and get DEB, RPM, AppImage, Flatpak, DMG and MSI packages, attached to your GitHub release.
|
|
15
|
+
install:
|
|
16
|
+
command: gem install native-packages
|
|
17
|
+
label: Copy the install command
|
|
18
|
+
seo:
|
|
19
|
+
title: "native-packages: cross-platform installers from one YAML"
|
|
20
|
+
full_title: true
|
|
21
|
+
share_title: "native-packages: one config, every package."
|
|
22
|
+
share_description: Describe your app once. Build DEB, RPM, AppImage, Flatpak, DMG and MSI, attach them to the release, and host signed repositories.
|
|
23
|
+
image:
|
|
24
|
+
path: /assets/images/social-card.png
|
|
25
|
+
alt: "native-packages: One config. Every package."
|
|
26
|
+
width: 1200
|
|
27
|
+
height: 630
|
|
28
|
+
software:
|
|
29
|
+
type: SoftwareApplication
|
|
30
|
+
category: DeveloperApplication
|
|
31
|
+
operating_system: Linux, macOS, Windows
|
|
32
|
+
repository: https://github.com/crmne/native-packages
|
|
33
|
+
language: Ruby
|
|
34
|
+
license: https://opensource.org/licenses/MIT
|
|
35
|
+
keywords: [deb, rpm, appimage, flatpak, dmg, msi, packaging, installer]
|
|
36
|
+
description: Turn your built app into DEB, RPM, AppImage, Flatpak, DMG and MSI packages from one YAML file. Publish to GitHub releases and signed repositories.
|
|
37
|
+
permalink: /
|
|
41
38
|
---
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<style>
|
|
48
|
-
/* The theme sizes its hero for a square logo; the film is 16:9. */
|
|
49
|
-
.VPHero .hero-film {
|
|
50
|
-
display: block;
|
|
51
|
-
width: 100%;
|
|
52
|
-
max-width: 560px;
|
|
53
|
-
height: auto;
|
|
54
|
-
aspect-ratio: 16 / 9;
|
|
55
|
-
margin: 0 auto;
|
|
56
|
-
border-radius: 12px;
|
|
57
|
-
background: #0d0e1a;
|
|
58
|
-
}
|
|
59
|
-
.VPHero .image-container:has(.hero-film) {
|
|
60
|
-
width: 100%;
|
|
61
|
-
height: auto;
|
|
62
|
-
padding: 0 24px;
|
|
63
|
-
transform: none;
|
|
64
|
-
}
|
|
65
|
-
@media (max-width: 959px) {
|
|
66
|
-
.VPHero .image:has(.hero-film) {
|
|
67
|
-
margin: 0 0 32px;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
</style>
|
|
71
|
-
|
|
72
|
-
<script>
|
|
73
|
-
// The theme's hero takes a picture; the film takes its place where
|
|
74
|
-
// scripts run, and the logo stays where they do not.
|
|
75
|
-
(function () {
|
|
76
|
-
var film = document.querySelector(".hero-film");
|
|
77
|
-
var slot = document.querySelector(".VPHero .image-container");
|
|
78
|
-
if (!film || !slot) return;
|
|
79
|
-
slot.replaceChildren(film);
|
|
80
|
-
film.hidden = false;
|
|
81
|
-
if (!window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
82
|
-
film.play().catch(function () {});
|
|
83
|
-
}
|
|
84
|
-
})();
|
|
85
|
-
</script>
|
|
40
|
+
{::nomarkdown}
|
|
41
|
+
{% include native_packages/home.html %}
|
|
42
|
+
{:/nomarkdown}
|
|
@@ -9,15 +9,19 @@ module NativePackages
|
|
|
9
9
|
"ppc64" => [21, 2, 2], "ppc64le" => [21, 2, 1], "s390x" => [22, 2, 2],
|
|
10
10
|
"riscv64" => [243, 2, 1], "loong64" => [258, 2, 1] }.freeze
|
|
11
11
|
PE_ARCHES = { "386" => 0x14c, "amd64" => 0x8664, "arm64" => 0xaa64 }.freeze
|
|
12
|
+
# Debian package names for common libraries. RPMs need none: they
|
|
13
|
+
# depend on the library itself, its soname capability, which Fedora and
|
|
14
|
+
# openSUSE both provide under their own package names (libgcc on one,
|
|
15
|
+
# libgcc_s1 on the other).
|
|
12
16
|
LIBRARIES = {
|
|
13
|
-
"libgcc_s.so.1" => { "deb" => "libgcc-s1"
|
|
14
|
-
"libstdc++.so.6" => { "deb" => "libstdc++6"
|
|
15
|
-
"libasound.so.2" => { "deb" => "libasound2"
|
|
16
|
-
"libpulse.so.0" => { "deb" => "libpulse0"
|
|
17
|
-
"libpulse-simple.so.0" => { "deb" => "libpulse0"
|
|
18
|
-
"libpipewire-0.3.so.0" => { "deb" => "libpipewire-0.3-0"
|
|
19
|
-
"libssl.so.3" => { "deb" => "libssl3"
|
|
20
|
-
"libcrypto.so.3" => { "deb" => "libssl3"
|
|
17
|
+
"libgcc_s.so.1" => { "deb" => "libgcc-s1" },
|
|
18
|
+
"libstdc++.so.6" => { "deb" => "libstdc++6" },
|
|
19
|
+
"libasound.so.2" => { "deb" => "libasound2" },
|
|
20
|
+
"libpulse.so.0" => { "deb" => "libpulse0" },
|
|
21
|
+
"libpulse-simple.so.0" => { "deb" => "libpulse0" },
|
|
22
|
+
"libpipewire-0.3.so.0" => { "deb" => "libpipewire-0.3-0" },
|
|
23
|
+
"libssl.so.3" => { "deb" => "libssl3" },
|
|
24
|
+
"libcrypto.so.3" => { "deb" => "libssl3" }
|
|
21
25
|
}.freeze
|
|
22
26
|
attr_reader :root
|
|
23
27
|
|
|
@@ -74,11 +78,13 @@ module NativePackages
|
|
|
74
78
|
binaries = paths.select { |path| path.binread(4) == "\x7fELF" }
|
|
75
79
|
raise Error, "Linux target contains no ELF binaries" if binaries.empty?
|
|
76
80
|
required, versions, interpreters = [], [], []
|
|
81
|
+
wide = false
|
|
77
82
|
bundled = binaries.map { |path| path.basename.to_s }
|
|
78
83
|
binaries.each do |path|
|
|
79
84
|
header = path.binread(20)
|
|
80
85
|
machine = header.byteslice(18, 2)&.unpack1(header.getbyte(5) == 2 ? "S>" : "S<")
|
|
81
86
|
raise Error, "wrong ELF architecture: #{path}" unless [machine, header.getbyte(4), header.getbyte(5)] == expected
|
|
87
|
+
wide ||= header.getbyte(4) == 2
|
|
82
88
|
dynamic = capture("readelf", "-d", path)
|
|
83
89
|
required.concat(dynamic.scan(/Shared library: \[([^\]]+)\]/).flatten)
|
|
84
90
|
bundled.concat(dynamic.scan(/Library soname: \[([^\]]+)\]/).flatten)
|
|
@@ -105,6 +111,8 @@ module NativePackages
|
|
|
105
111
|
external.each do |library|
|
|
106
112
|
next if /\A(?:lib(?:c|m|dl|rt|pthread|resolv)\.so\.|ld-linux)/.match?(library)
|
|
107
113
|
dependency = @libraries[library]&.[](format)
|
|
114
|
+
# The soname capability rpm itself would record (rpmdeps).
|
|
115
|
+
dependency ||= "#{library}()#{wide ? '(64bit)' : ''}" if format == "rpm"
|
|
108
116
|
raise Error, "add libraries.#{library}.#{format} and declare runtime-loaded dependencies" unless dependency
|
|
109
117
|
depends << dependency
|
|
110
118
|
end
|
|
@@ -62,9 +62,21 @@ module NativePackages
|
|
|
62
62
|
output.strip
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
# Whether the remote has no refs at all, as the repository of a package
|
|
66
|
+
# that was never published (a new AUR package's, for one).
|
|
67
|
+
def empty_remote?(name, url) = git(name, "ls-remote", url).empty?
|
|
68
|
+
|
|
69
|
+
# Whether `ref` exists in the checkout.
|
|
70
|
+
def ref?(name, ref) = git(name, "rev-parse", "--verify", "--quiet", "#{ref}^{commit}", allow_failure: true).last.success?
|
|
71
|
+
|
|
72
|
+
# The ID of the empty tree, which a first publication's diff starts from.
|
|
73
|
+
def empty_tree(name) = git(name, "hash-object", "-t", "tree", "--stdin")
|
|
74
|
+
|
|
65
75
|
def refresh(name, entry)
|
|
66
76
|
cache.mkpath
|
|
67
77
|
path = checkout(name)
|
|
78
|
+
@empty ||= {}
|
|
79
|
+
@empty[name] = empty_remote?(name, entry.fetch("url"))
|
|
68
80
|
if path.exist?
|
|
69
81
|
raise Error, "#{path} is not a managed checkout" unless (path / ".git").directory?
|
|
70
82
|
unless git(name, "remote", "get-url", "upstream") == entry.fetch("url") &&
|
|
@@ -74,15 +86,22 @@ module NativePackages
|
|
|
74
86
|
end
|
|
75
87
|
else
|
|
76
88
|
path.dirname.mkpath
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
if @empty[name]
|
|
90
|
+
# Nothing to clone: start the configured branch, unborn, to push it.
|
|
91
|
+
git(name, "init", "--initial-branch=#{entry.fetch('branch')}", path)
|
|
92
|
+
git(name, "remote", "add", "upstream", entry.fetch("url"))
|
|
93
|
+
else
|
|
94
|
+
git(name, "clone", "--filter=blob:none", "--depth=1", "--no-checkout", "--origin", "upstream",
|
|
95
|
+
"--branch", entry.fetch("branch"), entry.fetch("url"), path)
|
|
96
|
+
end
|
|
79
97
|
git(name, "remote", "add", "origin", entry.fetch("fork_url", entry.fetch("url")))
|
|
80
98
|
git(name, "remote", "set-url", "--push", "origin", entry.fetch("push_url", entry.fetch("url")))
|
|
81
99
|
unless entry.fetch("package_path") == "."
|
|
82
100
|
git(name, "sparse-checkout", "set", "--cone", entry.fetch("package_path"), ".github")
|
|
83
101
|
end
|
|
84
|
-
git(name, "checkout", "--detach", "upstream/#{entry.fetch('branch')}")
|
|
102
|
+
git(name, "checkout", "--detach", "upstream/#{entry.fetch('branch')}") unless @empty[name]
|
|
85
103
|
end
|
|
104
|
+
return path if @empty[name]
|
|
86
105
|
[entry.fetch("branch"), entry["status_branch"]].compact.uniq.each do |branch|
|
|
87
106
|
git(name, "fetch", "--depth=1", "upstream", "+refs/heads/#{branch}:refs/remotes/upstream/#{branch}")
|
|
88
107
|
end
|
|
@@ -208,16 +227,22 @@ module NativePackages
|
|
|
208
227
|
end
|
|
209
228
|
git(name, "check-ref-format", "--branch", branch)
|
|
210
229
|
remote = remote_head(name, branch)
|
|
211
|
-
base = "upstream/#{entry.fetch('branch')}"
|
|
212
|
-
if remote && branch != entry.fetch("branch")
|
|
213
|
-
git(name, "fetch", "--depth=1", "origin", "+refs/heads/#{branch}:refs/remotes/origin/#{branch}")
|
|
214
|
-
base = "origin/#{branch}"
|
|
215
|
-
end
|
|
216
|
-
prevent_downgrade(name, repository_version(name, entry, base), version)
|
|
217
|
-
prevent_downgrade(name, repository_version(name, entry, "upstream/#{entry.fetch('branch')}"), version)
|
|
218
|
-
base_commit = git(name, "rev-parse", base)
|
|
219
230
|
local_branch = "packaging/#{name}/#{version}-#{SecureRandom.hex(4)}"
|
|
220
|
-
|
|
231
|
+
if @empty[name]
|
|
232
|
+
# A first publication: the package's files become the first commit.
|
|
233
|
+
base_commit = empty_tree(name)
|
|
234
|
+
git(name, "switch", "--orphan", local_branch)
|
|
235
|
+
else
|
|
236
|
+
base = "upstream/#{entry.fetch('branch')}"
|
|
237
|
+
if remote && branch != entry.fetch("branch")
|
|
238
|
+
git(name, "fetch", "--depth=1", "origin", "+refs/heads/#{branch}:refs/remotes/origin/#{branch}")
|
|
239
|
+
base = "origin/#{branch}"
|
|
240
|
+
end
|
|
241
|
+
prevent_downgrade(name, repository_version(name, entry, base), version)
|
|
242
|
+
prevent_downgrade(name, repository_version(name, entry, "upstream/#{entry.fetch('branch')}"), version)
|
|
243
|
+
base_commit = git(name, "rev-parse", base)
|
|
244
|
+
git(name, "switch", "-c", local_branch, base)
|
|
245
|
+
end
|
|
221
246
|
# Compute every destination before writing; a symlink must never redirect a copy.
|
|
222
247
|
destinations = sources.to_h { |relative, file| [contained_path(path, relative), file] }
|
|
223
248
|
destinations.each do |target, source|
|
|
@@ -277,7 +302,8 @@ module NativePackages
|
|
|
277
302
|
end
|
|
278
303
|
raise Error, "#{name}: unstaged edits exist; review and git add them first" unless git(name, "diff", "--name-only").empty?
|
|
279
304
|
raise Error, "#{name}: untracked files exist in the checkout" unless git(name, "ls-files", "--others", "--exclude-standard").empty?
|
|
280
|
-
|
|
305
|
+
# Empty before a first publication's commit.
|
|
306
|
+
head = git(name, "rev-parse", "--verify", "--quiet", "HEAD", allow_failure: true).first.strip
|
|
281
307
|
remote = remote_head(name, record.fetch("destination_branch"))
|
|
282
308
|
unless remote == record["remote_commit"] || remote == head
|
|
283
309
|
_, ancestry = git(name, "merge-base", "--is-ancestor", remote || "", head, allow_failure: true)
|
|
@@ -395,7 +421,11 @@ module NativePackages
|
|
|
395
421
|
refresh(name, entry) unless offline
|
|
396
422
|
if (checkout(name) / ".git").directory?
|
|
397
423
|
row["upstream_branch"] = entry.fetch("status_branch", entry.fetch("branch"))
|
|
398
|
-
|
|
424
|
+
if ref?(name, "upstream/#{row.fetch('upstream_branch')}")
|
|
425
|
+
row["upstream_version"] = repository_version(name, entry, "upstream/#{row.fetch('upstream_branch')}")
|
|
426
|
+
else
|
|
427
|
+
row["upstream_state"] = "not published yet"
|
|
428
|
+
end
|
|
399
429
|
row["local_changes"] = !git(name, "status", "--porcelain").empty?
|
|
400
430
|
else
|
|
401
431
|
row["remote_error"] = "not fetched (offline)"
|
|
@@ -416,7 +446,7 @@ module NativePackages
|
|
|
416
446
|
else
|
|
417
447
|
puts "TARGET UPSTREAM LOCAL OPEN REQUESTS"
|
|
418
448
|
rows.each do |row|
|
|
419
|
-
version = row["remote_error"] ? "unknown" : row["upstream_version"] || (entries.fetch(row.fetch("target"))["branch"] ? "absent" : "manual")
|
|
449
|
+
version = row["remote_error"] ? "unknown" : row["upstream_version"] || row["upstream_state"] || (entries.fetch(row.fetch("target"))["branch"] ? "absent" : "manual")
|
|
420
450
|
puts "#{row.fetch('target').ljust(14)} #{version.ljust(14)} #{[row['local_version'], row['local_state']].compact.join(' ').ljust(22)} #{Array(row['requests']).map { |request| request.fetch('url') }.join(' ')}"
|
|
421
451
|
%w[remote_error request_error notes].each { |key| puts " #{row[key]}" if row[key] }
|
|
422
452
|
end
|