mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
Compare commits
273 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2320030121 | ||
| c53c398cac | |||
|
|
f7b2baa363 | ||
|
d396165808
|
|||
| 66ccd9c6fd | |||
|
|
907f7babbc | ||
|
e030fee670
|
|||
|
|
0ea0596f69 | ||
| 03ed54ca78 | |||
|
|
9d98b6340b | ||
|
cbac633efb
|
|||
|
db723817bf
|
|||
|
|
509d8bf0b8 | ||
|
d7723ee766
|
|||
|
|
9c99da14b3 | ||
| ccb4f3f438 | |||
|
|
4c997758f8 | ||
| 8267ac1662 | |||
| 5c513ce2e7 | |||
| 6e2b9aa44a | |||
|
|
2758cc93cb | ||
|
|
970cb68701 | ||
|
|
a95a3c1c9a | ||
|
|
533dde85b1 | ||
| ca8951ccd3 | |||
|
cfc5155199
|
|||
|
|
78db99ea2d | ||
|
8a1ae4df1c
|
|||
|
|
5e2aaceb84 | ||
|
|
bcfdeacf95 | ||
|
2f0babae99
|
|||
|
|
6c32cebf96 | ||
| 1743035a6d | |||
|
c38075ee8c
|
|||
|
05d4d86743
|
|||
|
8f2c9f9d42
|
|||
|
|
06ec20fabf | ||
|
97f77f3b10
|
|||
|
|
e0eb0d32a8 | ||
|
85041112ef
|
|||
|
af0b2b83ab
|
|||
|
|
ea0d69d646 | ||
| 4821d18c47 | |||
| 680386a2f3 | |||
| bf81afeb4b | |||
| 8c9aba9a6b | |||
|
a5347602ca
|
|||
|
bc62c890ed
|
|||
|
23a9f30d45
|
|||
|
6ee6d8c13a
|
|||
|
3d6c7fff64
|
|||
|
d08d1b9b5c
|
|||
|
6e32219c24
|
|||
|
d2548191f1
|
|||
|
8ed16b27c0
|
|||
|
14f7aa13d9
|
|||
| 59ebbdaa2b | |||
|
d98c14dde5
|
|||
|
590b0ac21a
|
|||
|
8c84ef128f
|
|||
|
8b447b6237
|
|||
|
c3d19694e7
|
|||
|
cff89684c6
|
|||
|
48a512fbce
|
|||
|
a3530c02e8
|
|||
|
138ac74ba5
|
|||
|
0ba971ef61
|
|||
|
1ae8771b2c
|
|||
|
1f2868d4b3
|
|||
|
bfa5bcf79b
|
|||
| 02d85f899f | |||
|
aeb3a75e5c
|
|||
|
|
e0fd2b16eb
|
||
|
d24ac084b7
|
|||
| 159a7333de | |||
|
b582523642
|
|||
|
4f1e748df2
|
|||
|
d984633991
|
|||
|
616f74d624
|
|||
|
d7963b7664
|
|||
|
a20a8456ab
|
|||
|
8ad3ff4f53
|
|||
|
e31f5aaf93
|
|||
|
c2fb07fdb8
|
|||
|
07e0e3dacd
|
|||
|
efddb9ef92
|
|||
| f7f4c0433a | |||
|
cbd8cb27b6
|
|||
|
656b96510a
|
|||
|
084776db6b
|
|||
|
1e6d6cc6cf
|
|||
|
68ef4c066c
|
|||
|
d476fd33ec
|
|||
| baa5930467 | |||
|
743b10c751
|
|||
|
59f1bcd3e8
|
|||
| e767e284b7 | |||
|
8129a2e93b
|
|||
|
4ae288cae3
|
|||
|
3bd78d130a
|
|||
|
fb5362ce18
|
|||
|
1a34a9504a
|
|||
| 8513521d29 | |||
|
88bbefadc6
|
|||
|
f1bf1d93b8
|
|||
|
8a467b0d43
|
|||
|
9c29f721b4
|
|||
|
4ac71ddf39
|
|||
|
d338c136db
|
|||
|
d054a17fc7
|
|||
|
4030ceb9ca
|
|||
|
ad1a7dd62c
|
|||
| 665e6addec | |||
|
7f2aba0e4e
|
|||
|
be326b22aa
|
|||
|
ef4f2ad930
|
|||
|
2293c87fc9
|
|||
|
97178bf77a
|
|||
|
591c39e629
|
|||
|
d6c99f8c60
|
|||
|
bcbd01778d
|
|||
|
5602475542
|
|||
|
67b8c5f397
|
|||
|
4dad5812fa
|
|||
|
65bdff0b6d
|
|||
|
a956dc1b42
|
|||
|
af23b63518
|
|||
| 9c20f77fe3 | |||
|
2e2f9bc98a
|
|||
|
d63cd545aa
|
|||
|
1bbfe5d3ea
|
|||
|
b4c5184cef
|
|||
|
e7a991ef92
|
|||
|
7118ed8560
|
|||
|
a71cbda511
|
|||
|
4c0eb37353
|
|||
|
b81e101ca7
|
|||
| c760ffa25e | |||
|
|
931e6ddf9e | ||
|
f17f485b9f
|
|||
|
3622df550c
|
|||
|
2a9707ec89
|
|||
|
1fc7faac1f
|
|||
|
786d253df6
|
|||
|
228ae0939c
|
|||
|
ac943c430c
|
|||
|
bc3923c9ca
|
|||
|
e6b1e5a554
|
|||
|
94625fce38
|
|||
|
b03343f506
|
|||
|
b1896d4a4f
|
|||
|
9d32509c61
|
|||
|
1c2745cd36
|
|||
|
80a0d55b24
|
|||
|
fd0ec4d772
|
|||
|
c0c809a86a
|
|||
|
cb63806262
|
|||
|
6d7ab95ca2
|
|||
|
f4d6e3a56d
|
|||
|
3f1059940d
|
|||
|
5c722e36c5
|
|||
|
f52dd8dc6d
|
|||
|
4cdbaf1ec0
|
|||
|
f3a289b11c
|
|||
|
9019e73d60
|
|||
|
28930381a8
|
|||
|
df25e54ef7
|
|||
|
6d21d1bef4
|
|||
|
99aa76b398
|
|||
|
b60ca528f8
|
|||
|
23b8236e0a
|
|||
|
56d0364099
|
|||
|
6af597b427
|
|||
|
a331457e89
|
|||
| a4171555f5 | |||
|
adbcfc6fc4
|
|||
|
634861beea
|
|||
|
eeca7b798d
|
|||
|
e1500cbf53
|
|||
|
ca73ab7202
|
|||
|
fd6cd42d5c
|
|||
|
b719437bee
|
|||
| 368b9271ff | |||
|
87d2d67575
|
|||
|
72ca9ce2b6
|
|||
|
276a9da5ee
|
|||
|
87ecfbcec0
|
|||
|
55f35e1146
|
|||
|
72d0254772
|
|||
|
698756ac55
|
|||
|
1ffd735c23
|
|||
|
8d87c01db7
|
|||
|
3e1eb01e24
|
|||
|
d7c59ba4b2
|
|||
|
8f5ae8a6c2
|
|||
|
707bc9e0d1
|
|||
|
c55bf68e61
|
|||
| 26ce446226 | |||
|
ca2d4c38f6
|
|||
|
bd81870659
|
|||
|
5cd9d1c5fa
|
|||
| 6ae14b597c | |||
|
deda28e5ad
|
|||
|
3d6caac962
|
|||
| 11de27358d | |||
|
8237aa9272
|
|||
|
3ffe83c94e
|
|||
|
9f6ec5954f
|
|||
| 9ea79670d8 | |||
|
72e40248e1
|
|||
|
7259111478
|
|||
|
bb45cda023
|
|||
|
ab872202df
|
|||
|
2d1c5d47d9
|
|||
| 30a71c423e | |||
|
5c48445397
|
|||
|
bf7c4d5deb
|
|||
|
3ffeb4854c
|
|||
|
0a22d8393c
|
|||
|
ac8348323d
|
|||
| 59f52b65ee | |||
|
81a96f4d60
|
|||
|
1df39fafe6
|
|||
|
14a8d1aaaf
|
|||
|
272a3000a1
|
|||
|
d684cf560f
|
|||
| ea189a6713 | |||
|
63289216d7
|
|||
|
2054c8c0aa
|
|||
|
ca09d1a95f
|
|||
|
f1e60e31d9
|
|||
|
8d197aea73
|
|||
|
844df73c8f
|
|||
|
f1fc68c8f5
|
|||
|
e19a6a7bc2
|
|||
|
1000999eb2
|
|||
|
a75047fb3a
|
|||
|
a1641946e4
|
|||
|
581594da3c
|
|||
|
bdad382e7f
|
|||
|
e25ceaa7e2
|
|||
|
03ae8750b8
|
|||
|
269dbdb1dd
|
|||
| 713c970da4 | |||
|
dca023daec
|
|||
|
e56c26d06f
|
|||
|
b2860f22c3
|
|||
|
d1c5e7afb1
|
|||
|
ab55f5421c
|
|||
|
eb09d5fa49
|
|||
|
a47d3e0c6a
|
|||
|
5a61a72a73
|
|||
| 9cdf67e71b | |||
|
946856e9c2
|
|||
|
|
2247158051
|
||
|
4a7c507858
|
|||
|
884f1607f6
|
|||
|
c7daa1350b
|
|||
|
9223ff8e28
|
|||
|
70bf6b05d5
|
|||
|
8936f4762a
|
|||
|
be8e04e7a5
|
|||
| aadf32cbbe | |||
|
d8bbcb72b3
|
|||
|
d6f11b5459
|
|||
|
09e67381cb
|
|||
|
d21ccad3e4
|
|||
| 036d2a82d9 | |||
|
111cb64993
|
|||
|
fe3af6c4c9
|
|||
|
7ca3f52819
|
|||
|
0ab94da153
|
|||
|
01d27c0891
|
3
.github/.release-please-manifest.json
vendored
Normal file
3
.github/.release-please-manifest.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
".": "0.6.57"
|
||||
}
|
||||
14
.github/release-please-config.json
vendored
Normal file
14
.github/release-please-config.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"bootstrap-sha": "3d6c7fff64bda8ba0dbea181c9f94fb9716dd188",
|
||||
"packages": {
|
||||
".": {
|
||||
"release-type": "simple",
|
||||
"changelog-path": "CHANGELOG.md",
|
||||
"bump-minor-pre-major": true,
|
||||
"bump-patch-for-minor-pre-major": true,
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}
|
||||
},
|
||||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
||||
}
|
||||
49
.github/workflows/ci.yml
vendored
Normal file
49
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
name: CI
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.23"
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: v1.61
|
||||
env:
|
||||
VERBOSE: "true"
|
||||
|
||||
tidy:
|
||||
name: Tidy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.23"
|
||||
- name: Check if mods are tidy
|
||||
run: make check-tidy
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.23"
|
||||
- name: Run tests
|
||||
run: make test
|
||||
env:
|
||||
VERBOSE: "true"
|
||||
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref_name == 'main' || github.ref_name == 'master'
|
||||
steps:
|
||||
- uses: jimeh/release-please-manifest-action@v1
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
.DS_Store
|
||||
.envrc
|
||||
Formula/*
|
||||
Gemfile.lock
|
||||
bin
|
||||
builds
|
||||
sources
|
||||
tarballs
|
||||
|
||||
82
.golangci.yml
Normal file
82
.golangci.yml
Normal file
@@ -0,0 +1,82 @@
|
||||
linters-settings:
|
||||
funlen:
|
||||
lines: 100
|
||||
statements: 150
|
||||
goconst:
|
||||
min-occurrences: 5
|
||||
gocyclo:
|
||||
min-complexity: 20
|
||||
govet:
|
||||
enable-all: true
|
||||
disable:
|
||||
- fieldalignment
|
||||
lll:
|
||||
line-length: 80
|
||||
tab-width: 4
|
||||
maligned:
|
||||
suggest-new: true
|
||||
misspell:
|
||||
locale: US
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- bodyclose
|
||||
- copyloopvar
|
||||
- dupl
|
||||
- errcheck
|
||||
- funlen
|
||||
- gochecknoinits
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofumpt
|
||||
- goimports
|
||||
- goprintffuncname
|
||||
- goprintffuncname
|
||||
- gosec
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- lll
|
||||
- misspell
|
||||
- nakedret
|
||||
- nlreturn
|
||||
- noctx
|
||||
- nolintlint
|
||||
- revive
|
||||
- sqlclosecheck
|
||||
- staticcheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
- whitespace
|
||||
|
||||
issues:
|
||||
exclude:
|
||||
- Using the variable on range scope `tt` in function literal
|
||||
- Using the variable on range scope `tc` in function literal
|
||||
exclude-rules:
|
||||
- path: "_test\\.go"
|
||||
linters:
|
||||
- funlen
|
||||
- dupl
|
||||
- goconst
|
||||
- source: "^//go:generate "
|
||||
linters:
|
||||
- lll
|
||||
- source: "`json:"
|
||||
linters:
|
||||
- lll
|
||||
- source: "`yaml:"
|
||||
linters:
|
||||
- lll
|
||||
exclude-dirs:
|
||||
- builds
|
||||
- sources
|
||||
- tarballs
|
||||
|
||||
run:
|
||||
timeout: 2m
|
||||
allow-parallel-runners: true
|
||||
modules-download-mode: readonly
|
||||
29
.rubocop.yml
29
.rubocop.yml
@@ -1,5 +1,30 @@
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.4
|
||||
NewCops: enable
|
||||
|
||||
Layout/LineLength:
|
||||
Max: 80
|
||||
|
||||
Style/AccessorGrouping:
|
||||
Enabled: false
|
||||
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
Style/LineLength:
|
||||
Max: 80
|
||||
Metrics/AbcSize:
|
||||
Enabled: false
|
||||
|
||||
Metrics/BlockLength:
|
||||
Enabled: false
|
||||
|
||||
Metrics/ClassLength:
|
||||
Enabled: false
|
||||
|
||||
Metrics/CyclomaticComplexity:
|
||||
Enabled: false
|
||||
|
||||
Metrics/MethodLength:
|
||||
Enabled: false
|
||||
|
||||
Metrics/PerceivedComplexity:
|
||||
Enabled: false
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
tagPrefix: "",
|
||||
};
|
||||
8
Brewfile
8
Brewfile
@@ -1,13 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
brew 'autoconf'
|
||||
brew 'coreutils'
|
||||
brew 'curl'
|
||||
brew 'dbus'
|
||||
brew 'expat'
|
||||
brew 'gcc'
|
||||
brew 'gmp'
|
||||
brew 'gnu-sed'
|
||||
brew 'gnutls'
|
||||
brew 'jansson'
|
||||
brew 'libffi'
|
||||
brew 'libgccjit'
|
||||
brew 'libiconv'
|
||||
brew 'librsvg'
|
||||
brew 'libtasn1'
|
||||
@@ -19,5 +22,8 @@ brew 'make'
|
||||
brew 'ncurses'
|
||||
brew 'nettle'
|
||||
brew 'pkg-config'
|
||||
brew 'sqlite'
|
||||
brew 'texinfo'
|
||||
brew 'tree-sitter'
|
||||
brew 'webp'
|
||||
brew 'zlib'
|
||||
|
||||
615
CHANGELOG.md
615
CHANGELOG.md
@@ -1,6 +1,619 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
## [0.6.57](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.56...v0.6.57) (2024-12-07)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **patches/alpha-background:** add experimental alpha-background patch ([#129](https://github.com/jimeh/build-emacs-for-macos/issues/129)) ([c53c398](https://github.com/jimeh/build-emacs-for-macos/commit/c53c398cace6479a9c188e46196462791960abee)), closes [#111](https://github.com/jimeh/build-emacs-for-macos/issues/111)
|
||||
|
||||
## [0.6.56](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.55...v0.6.56) (2024-12-03)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **options:** add --patch option which accepts file path or URL ([#127](https://github.com/jimeh/build-emacs-for-macos/issues/127)) ([66ccd9c](https://github.com/jimeh/build-emacs-for-macos/commit/66ccd9c6fd077d558eae484cdbab831486fbfd58))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **patches:** improve chance of successful patch application by using -l ([d396165](https://github.com/jimeh/build-emacs-for-macos/commit/d396165808ab5852566e7ff6bcc23d47ddfdfdee))
|
||||
|
||||
## [0.6.55](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.54...v0.6.55) (2024-12-03)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **nix/deps:** update nixpkgs from 24.11-beta to 24.11 ([e030fee](https://github.com/jimeh/build-emacs-for-macos/commit/e030fee6704618b7ddefea7424dff4e94f43e84d))
|
||||
|
||||
## [0.6.54](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.53...v0.6.54) (2024-12-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **startup:** replace bundled site-start.el approach with a custom source patch ([#124](https://github.com/jimeh/build-emacs-for-macos/issues/124)) ([03ed54c](https://github.com/jimeh/build-emacs-for-macos/commit/03ed54ca78ce15b61f5c875f97410b3ff21ecd62))
|
||||
|
||||
## [0.6.53](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.52...v0.6.53) (2024-12-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **help:** correct formatting of help text output ([db72381](https://github.com/jimeh/build-emacs-for-macos/commit/db723817bf6c0ac85da1790a1d50fbea774cc0c0))
|
||||
|
||||
## [0.6.52](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.51...v0.6.52) (2024-11-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **nix/flake:** rename flake-package-versions.txt to flake.pkgs ([d7723ee](https://github.com/jimeh/build-emacs-for-macos/commit/d7723ee766574b6597997de7c54fb7ed7f37965c))
|
||||
|
||||
## [0.6.51](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.50...v0.6.51) (2024-11-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **build/embed:** include all Emacs C sources and related files in the Emacs.app bundle ([#120](https://github.com/jimeh/build-emacs-for-macos/issues/120)) ([ccb4f3f](https://github.com/jimeh/build-emacs-for-macos/commit/ccb4f3f438652c7ae98c202b8afed8861f40eeec))
|
||||
|
||||
## [0.6.50](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.49...v0.6.50) (2024-11-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **build/options:** add --optimize and related flags ([#119](https://github.com/jimeh/build-emacs-for-macos/issues/119)) ([8267ac1](https://github.com/jimeh/build-emacs-for-macos/commit/8267ac166203c0c495520e6970650735702eac35))
|
||||
* **deps:** add support for Nix package manager ([#116](https://github.com/jimeh/build-emacs-for-macos/issues/116)) ([6e2b9aa](https://github.com/jimeh/build-emacs-for-macos/commit/6e2b9aa44ae1cbc3eec8ec7318ce9c9968e2d673))
|
||||
* **package:** produce and include configure output log ([#118](https://github.com/jimeh/build-emacs-for-macos/issues/118)) ([5c513ce](https://github.com/jimeh/build-emacs-for-macos/commit/5c513ce2e7536c57f43a49739b3f0f66d15f7b6d))
|
||||
|
||||
## [0.6.49](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.48...v0.6.49) (2024-11-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compile-options:** increase runtime max open files limit ([#115](https://github.com/jimeh/build-emacs-for-macos/issues/115)) ([ca8951c](https://github.com/jimeh/build-emacs-for-macos/commit/ca8951ccd350ecee5ad6c637caae0af1831a9eb5)), closes [#106](https://github.com/jimeh/build-emacs-for-macos/issues/106)
|
||||
* **patches:** tidy up patches, deprecate optional poll patch ([cfc5155](https://github.com/jimeh/build-emacs-for-macos/commit/cfc5155199486c4e3fae7edbc7262299b3c9955c))
|
||||
|
||||
## [0.6.48](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.47...v0.6.48) (2024-08-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **local-lisp-path:** add Apple Silicon homebrew lisp-site ([8a1ae4d](https://github.com/jimeh/build-emacs-for-macos/commit/8a1ae4df1ca37a851f9936fcf2081536837e4c67))
|
||||
|
||||
## [0.6.47](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.46...v0.6.47) (2024-05-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **bootstrap:** remove --no-upgrade option from brew bundle ([2f0baba](https://github.com/jimeh/build-emacs-for-macos/commit/2f0babae990f908d706f5f60dc4a11573918c23d))
|
||||
|
||||
## [0.6.46](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.45...v0.6.46) (2024-04-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **emacs-builder:** resolve issues with notarizing Emacs app ([#100](https://github.com/jimeh/build-emacs-for-macos/issues/100)) ([1743035](https://github.com/jimeh/build-emacs-for-macos/commit/1743035a6d5d8c07a2c1da3f76cafe156e4ec31d))
|
||||
|
||||
## [0.6.45](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.44...v0.6.45) (2023-11-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **builder/cask:** support shared helpers template ([97f77f3](https://github.com/jimeh/build-emacs-for-macos/commit/97f77f3b1043b66da6ec737e5db91605ec961d08))
|
||||
|
||||
## [0.6.44](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.43...v0.6.44) (2023-11-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **builder/cask:** ensure release info helpers return correct asset ([af0b2b8](https://github.com/jimeh/build-emacs-for-macos/commit/af0b2b83abd5af0e61a085da386cc0da389f6588))
|
||||
|
||||
## [0.6.43](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.42...v0.6.43) (2023-11-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **bootstrap:** add Ruby (bundle install) to make bootstrap ([bc62c89](https://github.com/jimeh/build-emacs-for-macos/commit/bc62c890ed1aafe767286feed3eac0437ff62dc0))
|
||||
* **plan:** resolve issue loading build plan with Ruby 3.x ([a534760](https://github.com/jimeh/build-emacs-for-macos/commit/a5347602cad16fd852386d863d88c025d703b392))
|
||||
* **shared-libs:** correctly resolve libwebp libraries ([6ee6d8c](https://github.com/jimeh/build-emacs-for-macos/commit/6ee6d8c13ad4806b4174905dce121750ebd7aa27))
|
||||
* **signing:** add self-signing step that is enabled by default ([23a9f30](https://github.com/jimeh/build-emacs-for-macos/commit/23a9f30d45ea25fada809db757b85c175d048936))
|
||||
|
||||
### [0.6.42](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.41...v0.6.42) (2023-07-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* options for log-level and github source repository ([d08d1b9](https://github.com/jimeh/build-emacs-for-macos/commit/d08d1b9b5c4001302564dc8915884c465802f3b5))
|
||||
|
||||
### [0.6.41](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.40...v0.6.41) (2023-01-16)
|
||||
|
||||
### [0.6.40](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.39...v0.6.40) (2023-01-08)
|
||||
|
||||
### [0.6.39](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.38...v0.6.39) (2022-12-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **deprecate:** posix-spawn patch is no longer supported ([c3d1969](https://github.com/jimeh/build-emacs-for-macos/commit/c3d19694e7e4d33d462c9917683c2d63f69002f5))
|
||||
* **version:** correctly handle Emacs 30.x builds ([8b447b6](https://github.com/jimeh/build-emacs-for-macos/commit/8b447b6237fbbd94c4e72af8ee79969c7cfc9363))
|
||||
|
||||
### [0.6.38](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.37...v0.6.38) (2022-12-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **patch:** add round-undecorated-frame from emacs-plus for 29.x ([48a512f](https://github.com/jimeh/build-emacs-for-macos/commit/48a512fbce79759caa987e2880585bd0bc937977))
|
||||
* **patch:** add support for experimental poll patch from emacs-plus for 29.x ([a3530c0](https://github.com/jimeh/build-emacs-for-macos/commit/a3530c02e8260106f87d464e5cb398dcb2819460))
|
||||
|
||||
### [0.6.37](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.36...v0.6.37) (2022-12-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **tree-sitter:** support new --with-tree-sitter configure flag ([0ba971e](https://github.com/jimeh/build-emacs-for-macos/commit/0ba971ef61a195c91e87aa381d5d3b044461b4f6))
|
||||
|
||||
### [0.6.36](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.35...v0.6.36) (2022-10-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native-comp:** support new configure flag format ([1f2868d](https://github.com/jimeh/build-emacs-for-macos/commit/1f2868d4b3784e906665e9f3b6b9bba8fd72292f)), closes [#76](https://github.com/jimeh/build-emacs-for-macos/issues/76)
|
||||
|
||||
### [0.6.35](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.34...v0.6.35) (2022-08-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native-comp:** compatibility with libgccjit 12 homebrew formula ([e0fd2b1](https://github.com/jimeh/build-emacs-for-macos/commit/e0fd2b16eb91ac5a98ed4ec31f4773ab22cbd470))
|
||||
|
||||
### [0.6.34](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.33...v0.6.34) (2022-07-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **emacs-28:** patch configure.ac to support latest libgccjit ([b582523](https://github.com/jimeh/build-emacs-for-macos/commit/b582523642ad4c5298f5a7890edd9b48c0433684)), closes [#72](https://github.com/jimeh/build-emacs-for-macos/issues/72)
|
||||
|
||||
### [0.6.33](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.32...v0.6.33) (2022-04-30)
|
||||
|
||||
### [0.6.32](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.31...v0.6.32) (2022-04-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **dbus:** add flag to explicitly disable dbus support ([8ad3ff4](https://github.com/jimeh/build-emacs-for-macos/commit/8ad3ff4f53505408aa097527177032a1fd6008e0)), closes [#69](https://github.com/jimeh/build-emacs-for-macos/issues/69)
|
||||
* **deps:** add sqlite brew dependency for Emacs 29.x ([a20a845](https://github.com/jimeh/build-emacs-for-macos/commit/a20a8456ab1e8de6357d5d121b9565ba65a6dd71))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native-comp:** support libgccjit 11.3.0 ([e31f5aa](https://github.com/jimeh/build-emacs-for-macos/commit/e31f5aaf9355b674c2a86b8eda35f6513f344b72)), closes [#71](https://github.com/jimeh/build-emacs-for-macos/issues/71)
|
||||
|
||||
### [0.6.31](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.30...v0.6.31) (2022-02-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* set source-directory correctly ([07e0e3d](https://github.com/jimeh/build-emacs-for-macos/commit/07e0e3dacddfbdb7a59aceaa2dc9cdf503ac2bcc)), closes [#68](https://github.com/jimeh/build-emacs-for-macos/issues/68)
|
||||
|
||||
### [0.6.30](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.29...v0.6.30) (2022-02-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **site-lisp:** add Homebrew's site-lisp directory to locallisppath ([cbd8cb2](https://github.com/jimeh/build-emacs-for-macos/commit/cbd8cb27b6ceff2e128c38cd1cc8f8380b9b4bfb))
|
||||
|
||||
### [0.6.29](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.28...v0.6.29) (2022-02-07)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **cask:** add support for pretest builds ([084776d](https://github.com/jimeh/build-emacs-for-macos/commit/084776db6b7e61958088d7b2a2588e9889e60c21))
|
||||
|
||||
### [0.6.28](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.27...v0.6.28) (2022-01-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **build:** add dbus dependency to enable support in Emacs builds ([68ef4c0](https://github.com/jimeh/build-emacs-for-macos/commit/68ef4c066c3fd1a7337198e8f773866088b4f481))
|
||||
|
||||
### [0.6.27](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.26...v0.6.27) (2021-12-05)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **plan:** add support for pretest and release candidate builds ([743b10c](https://github.com/jimeh/build-emacs-for-macos/commit/743b10c751e146ec7569f39a475c20a0489955f4))
|
||||
|
||||
### [0.6.26](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.25...v0.6.26) (2021-11-27)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **build:** re-link eln files by default again ([4ae288c](https://github.com/jimeh/build-emacs-for-macos/commit/4ae288cae34c5e1d291dad7b6b654fe37c4a221f))
|
||||
* **native-comp:** no longer require gcc homebrew formula ([3bd78d1](https://github.com/jimeh/build-emacs-for-macos/commit/3bd78d130a5419a6530a7d30e271569e501870fb)), closes [#53](https://github.com/jimeh/build-emacs-for-macos/issues/53)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **embed:** relink shared libraries with [@rpath](https://github.com/rpath) instead of [@executable](https://github.com/executable)_path ([fb5362c](https://github.com/jimeh/build-emacs-for-macos/commit/fb5362ce183ce43e52afcc0fc721cf2145f9c85b))
|
||||
|
||||
### [0.6.25](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.24...v0.6.25) (2021-11-25)
|
||||
|
||||
### [0.6.24](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.23...v0.6.24) (2021-11-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **embedding:** embedding GCC fails when paths do not require sanitizing ([8a467b0](https://github.com/jimeh/build-emacs-for-macos/commit/8a467b0d43140f6956d53c27e2319ae1b572868c))
|
||||
|
||||
### [0.6.23](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.22...v0.6.23) (2021-11-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **build:** do not re-link eln files by default ([d338c13](https://github.com/jimeh/build-emacs-for-macos/commit/d338c136db8acc4378154cf66ed7db5462787602)), closes [#60](https://github.com/jimeh/build-emacs-for-macos/issues/60)
|
||||
|
||||
### [0.6.22](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.21...v0.6.22) (2021-11-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **patch:** add support for posix-spawn patch from emacs-plus ([4030ceb](https://github.com/jimeh/build-emacs-for-macos/commit/4030ceb9cab6749af3c28161ac97caec90a8aed0))
|
||||
|
||||
### [0.6.21](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.20...v0.6.21) (2021-10-27)
|
||||
|
||||
### [0.6.20](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.19...v0.6.20) (2021-10-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **notarization:** explicitly only copy *.c and *.h C source files ([591c39e](https://github.com/jimeh/build-emacs-for-macos/commit/591c39e629c9556adcf296cd5c15dd0b17c4d986))
|
||||
|
||||
### [0.6.19](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.18...v0.6.19) (2021-10-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **patch:** resolve emacs-29 symlink patches to their real URL ([bcbd017](https://github.com/jimeh/build-emacs-for-macos/commit/bcbd01778d416b99205c51f348a543489889f66d))
|
||||
|
||||
### [0.6.18](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.17...v0.6.18) (2021-10-23)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **docs:** embed C source files and set source-directory accordingly ([67b8c5f](https://github.com/jimeh/build-emacs-for-macos/commit/67b8c5f3974e178e31519846d46af82d9770ad6e))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **patches:** correctly use emacs 28.x and 29.x patches ([4dad581](https://github.com/jimeh/build-emacs-for-macos/commit/4dad5812fa2b67adc7262a778829013995a904bc))
|
||||
|
||||
### [0.6.17](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.16...v0.6.17) (2021-10-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **release:** tweak GitHub release description ([a956dc1](https://github.com/jimeh/build-emacs-for-macos/commit/a956dc1b42b2648e2663f5b48c72d7428fe75f19))
|
||||
|
||||
### [0.6.16](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.15...v0.6.16) (2021-10-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **build:** handle macOS Big Sur and later version number ([2e2f9bc](https://github.com/jimeh/build-emacs-for-macos/commit/2e2f9bc98acdc972a22add3d1015bd80cad20b41))
|
||||
* **cask:** make cask template helpers more flexible ([d63cd54](https://github.com/jimeh/build-emacs-for-macos/commit/d63cd545aab3a35e0cbbbcabd862525acbc414b8))
|
||||
* **plan:** allow build plan to be output as YAML or JSON ([1bbfe5d](https://github.com/jimeh/build-emacs-for-macos/commit/1bbfe5d3ea810215b417e5b80d2902f03d68f366))
|
||||
* **release:** add description to GitHub Releases ([7118ed8](https://github.com/jimeh/build-emacs-for-macos/commit/7118ed856053de06ddcdfba2a2d6fa40f58c17ab))
|
||||
* **release:** force-replace existing asset files by default ([e7a991e](https://github.com/jimeh/build-emacs-for-macos/commit/e7a991ef92a5c546106a8badaf9c60247a1397b5))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **release:** publish arguments are not handled as asset files to upload ([b4c5184](https://github.com/jimeh/build-emacs-for-macos/commit/b4c5184cefe43fdc54b1ad5c8a1970f104137644))
|
||||
|
||||
### [0.6.15](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.14...v0.6.15) (2021-08-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **build:** another --relink-eln-files flag fix ([3622df5](https://github.com/jimeh/build-emacs-for-macos/commit/3622df550c72fc9da70235005239b278b5822cf6))
|
||||
|
||||
### [0.6.14](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.13...v0.6.14) (2021-08-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **build:** silly typo ([1fc7faa](https://github.com/jimeh/build-emacs-for-macos/commit/1fc7faac1f040466fa4474a873d2290273780ee2))
|
||||
|
||||
### [0.6.13](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.12...v0.6.13) (2021-08-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native_comp:** add option to enable/disable relinking *.eln files ([ac943c4](https://github.com/jimeh/build-emacs-for-macos/commit/ac943c430c58e0761ac44e8d25d4d55a461d01a2))
|
||||
|
||||
### [0.6.12](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.11...v0.6.12) (2021-08-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **sign:** resolve signing issue caused by re-linking shared lib in *.eln files ([e6b1e5a](https://github.com/jimeh/build-emacs-for-macos/commit/e6b1e5a554fd0f776bd01c17cfb1ebbbdf7a7831))
|
||||
|
||||
### [0.6.11](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.10...v0.6.11) (2021-07-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native-comp:** fix re-linking and signing issue with *.eln files ([b03343f](https://github.com/jimeh/build-emacs-for-macos/commit/b03343f506aa3ceabdfa03f8a2916b2db4873f3f))
|
||||
|
||||
### [0.6.10](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.9...v0.6.10) (2021-07-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native-comp:** *.eln files were not being found during shared lib embedding ([9d32509](https://github.com/jimeh/build-emacs-for-macos/commit/9d32509c615076618957cc47c82f6e9d8f972fe7))
|
||||
|
||||
### [0.6.9](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.8...v0.6.9) (2021-07-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **release:** add bulk edit command to quickly change multiple GitHub releases ([cb63806](https://github.com/jimeh/build-emacs-for-macos/commit/cb638062625d9bc3eee12515067fb09e05a08414))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **plan:** correctly parse --test-release-type flag ([fd0ec4d](https://github.com/jimeh/build-emacs-for-macos/commit/fd0ec4d772dd3da93afc234fb3024220b2099c88))
|
||||
|
||||
### [0.6.8](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.7...v0.6.8) (2021-07-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **builds:** add support for stable builds ([f4d6e3a](https://github.com/jimeh/build-emacs-for-macos/commit/f4d6e3a56d2c15b0c86af18e8d16bebbeb92a8ab))
|
||||
|
||||
### [0.6.7](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.6...v0.6.7) (2021-07-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **bundle:** move bundled shared libraries to Contents/Frameworks ([5c722e3](https://github.com/jimeh/build-emacs-for-macos/commit/5c722e36c571aa7bf558b7f210c011f12d8d8a1c))
|
||||
|
||||
### [0.6.6](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.5...v0.6.6) (2021-07-01)
|
||||
|
||||
### [0.6.5](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.4...v0.6.5) (2021-07-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native_comp:** improve handling of *.eln files in .app bundle ([9019e73](https://github.com/jimeh/build-emacs-for-macos/commit/9019e73d606f0379f988f46d6008770f8f3f7a51))
|
||||
|
||||
### [0.6.4](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.3...v0.6.4) (2021-06-30)
|
||||
|
||||
### [0.6.3](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.2...v0.6.3) (2021-06-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **patches:** correctly set ref when loading a build plan YAML ([99aa76b](https://github.com/jimeh/build-emacs-for-macos/commit/99aa76b3985195c310a20bafa19a8c7a4c8558fd))
|
||||
|
||||
### [0.6.2](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.1...v0.6.2) (2021-06-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native_comp:** patch Emacs.pdmp for customized native-lisp paths ([23b8236](https://github.com/jimeh/build-emacs-for-macos/commit/23b8236e0a66fb09810e8422bedf02f7192a53e4))
|
||||
|
||||
### [0.6.1](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.0...v0.6.1) (2021-06-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cask:** add missing --force flag to cask update command ([6af597b](https://github.com/jimeh/build-emacs-for-macos/commit/6af597b4271341f9796c3d9c356de9918e0f6f85))
|
||||
|
||||
## [0.6.0](https://github.com/jimeh/build-emacs-for-macos/compare/v0.5.2...v0.6.0) (2021-06-28)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **cask:** add cask update command to manage cask formula ([adbcfc6](https://github.com/jimeh/build-emacs-for-macos/commit/adbcfc6fc433fcc99b10dc5ccb51ba458333fa9c))
|
||||
|
||||
### [0.5.2](https://github.com/jimeh/build-emacs-for-macos/compare/v0.5.1...v0.5.2) (2021-06-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native_comp:** rename native-lisp folder paths to appease Apple's codesign ([eeca7b7](https://github.com/jimeh/build-emacs-for-macos/commit/eeca7b798de236a3ffc1ab04b0f7735a37ce5af4))
|
||||
|
||||
### [0.5.1](https://github.com/jimeh/build-emacs-for-macos/compare/v0.5.0...v0.5.1) (2021-06-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native_comp:** symlink creation was missing a conditional check ([ca73ab7](https://github.com/jimeh/build-emacs-for-macos/commit/ca73ab7202877acefd97289f3d28e7c025e36b9d))
|
||||
|
||||
## [0.5.0](https://github.com/jimeh/build-emacs-for-macos/compare/v0.4.17...v0.5.0) (2021-06-21)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* **release:** Add v prefix to git version tags
|
||||
* **build:** New archive naming convention, and folder structure within archive.
|
||||
|
||||
### Features
|
||||
|
||||
* **build:** add ability to output as directory and/or archive ([3e1eb01](https://github.com/jimeh/build-emacs-for-macos/commit/3e1eb01e248ebbc314b8b9f50bbc371ac8df666b))
|
||||
* **cli:** add basis for new "emacs-builder" CLI tool written in Go ([8d87c01](https://github.com/jimeh/build-emacs-for-macos/commit/8d87c01db79201182fbcd1a210b1b19df9209aeb))
|
||||
* **notarize:** add notarize command to notarize and staple *.dmg files ([72d0254](https://github.com/jimeh/build-emacs-for-macos/commit/72d0254772bf7d0937b41634e9a4bfcf87f60fb6))
|
||||
* **package:** add package command to create a styled *.dmg for Emacs.app ([87ecfbc](https://github.com/jimeh/build-emacs-for-macos/commit/87ecfbcec05b46d7a30202269474612834b648f3))
|
||||
* **plan:** add plan command to create build plans ([1ffd735](https://github.com/jimeh/build-emacs-for-macos/commit/1ffd735c23e375479ea6bb2c771553ce4cac902b))
|
||||
* **release:** add release check command ([276a9da](https://github.com/jimeh/build-emacs-for-macos/commit/276a9da5eed618322e09fba11a486ae0d9925fdd))
|
||||
* **release:** add release publish command ([72ca9ce](https://github.com/jimeh/build-emacs-for-macos/commit/72ca9ce2b64505a8bbc50b3139c0f84fb24813fd))
|
||||
* **sign:** add sign command to sign Emacs.app bundles with codesign ([698756a](https://github.com/jimeh/build-emacs-for-macos/commit/698756ac5597d3dc7b69f28bc209093fc8c11f30))
|
||||
|
||||
|
||||
* **release:** add v prefix to git version tags ([b719437](https://github.com/jimeh/build-emacs-for-macos/commit/b719437bee9acf28d5d352eb44cbf4d3a17107d7))
|
||||
|
||||
### [0.4.17](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.16...0.4.17) (2021-06-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **download:** don't use GitHub API to get tarball URL ([707bc9e](https://github.com/jimeh/build-emacs-for-macos/commit/707bc9e0d13246b7cfb8d27da859a101d4a3c166))
|
||||
|
||||
### [0.4.16](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.15...0.4.16) (2021-06-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compiling:** improve portability of builds ([ca2d4c3](https://github.com/jimeh/build-emacs-for-macos/commit/ca2d4c38f69c434c77c266594104bfbf34ad5221))
|
||||
* **native_comp:** crash on launch when gcc homebrew package was not installed ([bd81870](https://github.com/jimeh/build-emacs-for-macos/commit/bd8187065928b9f79de8b14222c98f8dc34bfe5f))
|
||||
|
||||
### [0.4.15](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.14...0.4.15) (2021-05-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **github:** perform authenticated GitHub API requests when GITHUB_TOKEN env var is set ([deda28e](https://github.com/jimeh/build-emacs-for-macos/commit/deda28e5aded2817bcc7956f377378576372816f))
|
||||
|
||||
### [0.4.14](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.13...0.4.14) (2021-05-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **cli:** add "emacs" CLI launcher script to Emacs.app/Conents/MacOS/bin ([8237aa9](https://github.com/jimeh/build-emacs-for-macos/commit/8237aa9272ce1d13a412b2495cbaa90df38d928b)), closes [#41](https://github.com/jimeh/build-emacs-for-macos/issues/41)
|
||||
|
||||
### [0.4.13](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.12...0.4.13) (2021-05-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **codesign:** prevent "bundle format unrecognized" error from codesign ([7259111](https://github.com/jimeh/build-emacs-for-macos/commit/7259111478ecb838dea9c8f50ea39eafdf47ed5a))
|
||||
* **embed:** avoid potential error caused by trying to set duplicate rpath ([bb45cda](https://github.com/jimeh/build-emacs-for-macos/commit/bb45cda0231e99618571dc835348cf5c3345e277))
|
||||
|
||||
### [0.4.12](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.11...0.4.12) (2021-05-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **shared-libraries:** stop aggressive dylib re-linking ([0a22d83](https://github.com/jimeh/build-emacs-for-macos/commit/0a22d8393c53305354c4c6d8e784e7d59caa039a)), closes [#12](https://github.com/jimeh/build-emacs-for-macos/issues/12)
|
||||
* **svg:** enable SVG by default via librsvg ([bf7c4d5](https://github.com/jimeh/build-emacs-for-macos/commit/bf7c4d5debf32980dbbabc1ea99b58b266390011))
|
||||
|
||||
### [0.4.11](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.10...0.4.11) (2021-05-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **builds:** update build script for new plan.yml format ([1df39fa](https://github.com/jimeh/build-emacs-for-macos/commit/1df39fafe62ada385aa1d92e6b7f591c16c0a80c))
|
||||
* **release:** initial attempt at providing automatic builds ([6328921](https://github.com/jimeh/build-emacs-for-macos/commit/63289216d70e496d664a7e3078dea5a82eb8f65d))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **release:** attempt to fix issue with talking to GitHub API ([272a300](https://github.com/jimeh/build-emacs-for-macos/commit/272a3000a1f96d8f131e684736127b923513a205))
|
||||
|
||||
### [0.4.10](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.9...0.4.10) (2021-04-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cli:** correctly default to master branch if no git ref is given ([844df73](https://github.com/jimeh/build-emacs-for-macos/commit/844df73c8fa8440e657f7900ec89cdedb7c4c312))
|
||||
|
||||
### [0.4.9](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.8...0.4.9) (2021-04-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cli:** default to "master" if no git ref is given ([e19a6a7](https://github.com/jimeh/build-emacs-for-macos/commit/e19a6a7bc24379292ee06ae4c805b8c5365f2d97)), closes [#35](https://github.com/jimeh/build-emacs-for-macos/issues/35)
|
||||
* **native_comp:** skip symlink creation for recent builds which do not need symlinks ([1000999](https://github.com/jimeh/build-emacs-for-macos/commit/1000999eb2673dc207a390ff3f902b9987b99173))
|
||||
|
||||
### [0.4.8](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.7...0.4.8) (2021-02-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native_comp:** add support for new --with-native-compilation flag ([581594d](https://github.com/jimeh/build-emacs-for-macos/commit/581594da3cfbf1dd2fa28e91710b767e21ff75d2))
|
||||
|
||||
### [0.4.7](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.6...0.4.7) (2021-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native_comp:** add libgccjit include dir during build stage ([e25ceaa](https://github.com/jimeh/build-emacs-for-macos/commit/e25ceaa7e25b0e1b9947401597845b5ba43e6cd1)), closes [#20](https://github.com/jimeh/build-emacs-for-macos/issues/20)
|
||||
|
||||
### [0.4.6](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.5...0.4.6) (2021-02-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **native_comp:** improve env setup patch fixing potential issues ([dca023d](https://github.com/jimeh/build-emacs-for-macos/commit/dca023daecd8704f197cbc391380aa194bc47d62))
|
||||
|
||||
### [0.4.5](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.4...0.4.5) (2021-01-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cli:** remove defunct --[no-]native-comp-macos-fixes option ([ab55f54](https://github.com/jimeh/build-emacs-for-macos/commit/ab55f5421c81dc629e487bf4b8bb402657cb1bc4))
|
||||
|
||||
### [0.4.4](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.3...0.4.4) (2021-01-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** add autoconf to Brewfile ([a47d3e0](https://github.com/jimeh/build-emacs-for-macos/commit/a47d3e0c6a8ea8161a3bad0eafdac2401cf53129))
|
||||
|
||||
### [0.4.3](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.2...0.4.3) (2020-12-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **big-sur:** add Xcode CLI tools lib directory to runtime LIBRARY_PATH ([946856e](https://github.com/jimeh/build-emacs-for-macos/commit/946856e9c242d4a6fb5f839d8cae0acfafecdfc6))
|
||||
* **big-sur:** added support for building on Big Sur ([2247158](https://github.com/jimeh/build-emacs-for-macos/commit/2247158051d0f59933569b6974b2b5269f13c79e))
|
||||
|
||||
### [0.4.2](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.1...0.4.2) (2020-12-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cli:** avoid error if --git-sha is used without a branch/tag/sha argument ([884f160](https://github.com/jimeh/build-emacs-for-macos/commit/884f1607f6707ca187b1abfb0ce562757d872230)), closes [#21](https://github.com/jimeh/build-emacs-for-macos/issues/21)
|
||||
* **native_comp:** update env setup patch for recent changes to comp.el ([c7daa13](https://github.com/jimeh/build-emacs-for-macos/commit/c7daa1350bd69df172ce6484c54189d2cee8d97e))
|
||||
|
||||
### [0.4.1](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.0...0.4.1) (2020-10-29)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **native_comp:** remove patch based on feature/native-comp-macos-fixes branch ([70bf6b0](https://github.com/jimeh/build-emacs-for-macos/commit/70bf6b05d584976632b2fd2947c0bf692f5b6421))
|
||||
|
||||
## [0.4.0](https://github.com/jimeh/build-emacs-for-macos/compare/0.3.0...0.4.0) (2020-10-04)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* **native_comp:** Standard Homewbrew `gcc` and `libgccjit` formula are now required for native-comp, instead of the custom patched gcc formula.
|
||||
|
||||
### Features
|
||||
|
||||
* **native_comp:** use new libgccjit Homebrew formula ([d8bbcb7](https://github.com/jimeh/build-emacs-for-macos/commit/d8bbcb72b33f6bde8678c9d37548217ffdf3d641))
|
||||
|
||||
## [0.3.0](https://github.com/jimeh/build-emacs-for-macos/compare/0.2.0...0.3.0) (2020-09-22)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* **native_comp:** `--[no-]launcher` option is deprecated, as launcher script is no longer used.
|
||||
|
||||
### Features
|
||||
|
||||
* **native_comp:** use elisp patch instead of launcher script to set LIBRARY_PATH ([111cb64](https://github.com/jimeh/build-emacs-for-macos/commit/111cb6499368d14853a5927d38a43fc5e2f759f4)), closes [#14](https://github.com/jimeh/build-emacs-for-macos/issues/14)
|
||||
|
||||
## [0.2.0](https://github.com/jimeh/build-emacs-for-macos/compare/0.1.1...0.2.0) (2020-09-20)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* **native_comp:** Deprecate `--[no-]native-fast-boot` option in favor of `--[no-]native-full-aot`
|
||||
|
||||
### Features
|
||||
|
||||
* **native_comp:** add support for NATIVE_FULL_AOT, replacing NATIVE_FAST_BOOT ([0ab94da](https://github.com/jimeh/build-emacs-for-macos/commit/0ab94da15309b04978982369bdfa17e03e9b6329))
|
||||
|
||||
### [0.1.1](https://github.com/jimeh/build-emacs-for-macos/compare/0.1.0...0.1.1) (2020-09-19)
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
diff --git a/Formula/gcc.rb b/Formula/gcc.rb
|
||||
index 1bd636d496..03ad124218 100644
|
||||
--- a/Formula/gcc.rb
|
||||
+++ b/Formula/gcc.rb
|
||||
@@ -53,7 +53,7 @@ class Gcc < Formula
|
||||
# - Ada, which requires a pre-existing GCC Ada compiler to bootstrap
|
||||
# - Go, currently not supported on macOS
|
||||
# - BRIG
|
||||
- languages = %w[c c++ objc obj-c++ fortran]
|
||||
+ languages = %w[c c++ objc obj-c++ fortran jit]
|
||||
|
||||
osmajor = `uname -r`.split(".").first
|
||||
pkgversion = "Homebrew GCC #{pkg_version} #{build.used_options*" "}".strip
|
||||
@@ -73,6 +73,7 @@ class Gcc < Formula
|
||||
--with-system-zlib
|
||||
--with-pkgversion=#{pkgversion}
|
||||
--with-bugurl=https://github.com/Homebrew/homebrew-core/issues
|
||||
+ --enable-host-shared
|
||||
]
|
||||
|
||||
# Xcode 10 dropped 32-bit support
|
||||
3
Gemfile
3
Gemfile
@@ -2,7 +2,8 @@
|
||||
|
||||
source 'http://rubygems.org/'
|
||||
|
||||
gem 'ruby-macho'
|
||||
|
||||
group :development do
|
||||
gem 'byebug'
|
||||
gem 'rubocop'
|
||||
end
|
||||
|
||||
40
Gemfile.lock
Normal file
40
Gemfile.lock
Normal file
@@ -0,0 +1,40 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
ast (2.4.2)
|
||||
json (2.8.2)
|
||||
language_server-protocol (3.17.0.3)
|
||||
parallel (1.26.3)
|
||||
parser (3.3.6.0)
|
||||
ast (~> 2.4.1)
|
||||
racc
|
||||
racc (1.8.1)
|
||||
rainbow (3.1.1)
|
||||
regexp_parser (2.9.2)
|
||||
rubocop (1.68.0)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (>= 3.17.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.3.0.2)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 2.4, < 3.0)
|
||||
rubocop-ast (>= 1.32.2, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.36.1)
|
||||
parser (>= 3.3.1.0)
|
||||
ruby-macho (4.1.0)
|
||||
ruby-progressbar (1.13.0)
|
||||
unicode-display_width (2.6.0)
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin
|
||||
ruby
|
||||
x86_64-darwin
|
||||
|
||||
DEPENDENCIES
|
||||
rubocop
|
||||
ruby-macho
|
||||
|
||||
BUNDLED WITH
|
||||
2.5.23
|
||||
195
Makefile
Normal file
195
Makefile
Normal file
@@ -0,0 +1,195 @@
|
||||
PIP := $(shell command -v pip3 || command -v pip)
|
||||
SOURCES := $(shell \
|
||||
find * \
|
||||
-not -path 'sources/*' \
|
||||
-not -path 'builds/*' \( \
|
||||
-name "*.go" -or \
|
||||
-name "go.mod" -or \
|
||||
-name "go.sum" -or \
|
||||
-name "Makefile" -or \
|
||||
-type f -path 'internal/*' -or \
|
||||
-type f -path 'cmd/*' -or \
|
||||
-type f -path 'pkg/*' \
|
||||
\) | grep -v '.DS_Store' \
|
||||
)
|
||||
|
||||
#
|
||||
# Environment
|
||||
#
|
||||
|
||||
# Verbose output
|
||||
ifdef VERBOSE
|
||||
V = -v
|
||||
endif
|
||||
|
||||
BINDIR := bin
|
||||
TOOLDIR := $(BINDIR)/tools
|
||||
|
||||
# Global environment variables for all targets
|
||||
SHELL ?= /bin/bash
|
||||
SHELL := env \
|
||||
GO111MODULE=on \
|
||||
GOBIN=$(CURDIR)/$(BINDIR) \
|
||||
CGO_ENABLED=0 \
|
||||
PATH='$(CURDIR)/$(BINDIR):$(CURDIR)/$(TOOLDIR):$(PATH)' \
|
||||
$(SHELL)
|
||||
|
||||
#
|
||||
# Defaults
|
||||
#
|
||||
|
||||
# Default target
|
||||
.DEFAULT_GOAL := build
|
||||
|
||||
#
|
||||
# Bootstrap
|
||||
#
|
||||
|
||||
bootstrap: bootstrap-brew bootstrap-ruby
|
||||
|
||||
bootstrap-ruby:
|
||||
env BUNDLE_WITHOUT=development bundle install
|
||||
|
||||
bootstrap-brew:
|
||||
ifndef IN_NIX_SHELL
|
||||
brew bundle --verbose
|
||||
endif
|
||||
|
||||
bootstrap-pip:
|
||||
$(PIP) install -r requirements-ci.txt
|
||||
|
||||
#
|
||||
# Tools
|
||||
#
|
||||
|
||||
# external tool
|
||||
define tool # 1: binary-name, 2: go-import-path
|
||||
TOOLS += $(TOOLDIR)/$(1)
|
||||
|
||||
$(TOOLDIR)/$(1): Makefile
|
||||
GOBIN="$(CURDIR)/$(TOOLDIR)" go install "$(2)"
|
||||
endef
|
||||
|
||||
$(eval $(call tool,gofumpt,mvdan.cc/gofumpt@latest))
|
||||
$(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61))
|
||||
$(eval $(call tool,gomod,github.com/Helcaraxan/gomod@latest))
|
||||
|
||||
.PHONY: tools
|
||||
tools: $(TOOLS)
|
||||
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
LDFLAGS := -w -s
|
||||
|
||||
VERSION ?= $(shell git describe --tags --exact 2>/dev/null)
|
||||
COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null)
|
||||
DATE ?= $(shell date '+%FT%T%z')
|
||||
|
||||
ifeq ($(VERSION),)
|
||||
VERSION = 0.0.0-dev
|
||||
endif
|
||||
|
||||
CMDDIR := cmd
|
||||
BINS := $(shell test -d "$(CMDDIR)" && cd "$(CMDDIR)" && \
|
||||
find * -maxdepth 0 -type d -exec echo $(BINDIR)/{} \;)
|
||||
|
||||
.PHONY: build
|
||||
build: $(BINS)
|
||||
|
||||
$(BINS): $(BINDIR)/%: $(SOURCES)
|
||||
mkdir -p "$(BINDIR)"
|
||||
cd "$(CMDDIR)/$*" && go build -a $(V) \
|
||||
-o "$(CURDIR)/$(BINDIR)/$*" \
|
||||
-ldflags "$(LDFLAGS) \
|
||||
-X main.version=$(VERSION) \
|
||||
-X main.commit=$(COMMIT) \
|
||||
-X main.date=$(DATE)"
|
||||
|
||||
#
|
||||
# Development
|
||||
#
|
||||
|
||||
TEST ?= $$(go list ./... | grep -v 'sources/' | grep -v 'builds/')
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(BINARY) $(TOOLS)
|
||||
rm -f ./go.mod.tidy-check ./go.sum.tidy-check
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
CGO_ENABLED=1 go test $(V) -count=1 -race $(TESTARGS) $(TEST)
|
||||
|
||||
.PHONY: lint
|
||||
lint: $(TOOLDIR)/golangci-lint
|
||||
golangci-lint $(V) run
|
||||
|
||||
.PHONY: format
|
||||
format: $(TOOLDIR)/gofumpt
|
||||
gofumpt -w .
|
||||
|
||||
.PHONY: gen
|
||||
gen:
|
||||
go generate $$(go list ./... | grep -v 'sources/' | grep -v 'builds/')
|
||||
|
||||
.PHONY: nix-flake-update
|
||||
nix-flake-update:
|
||||
nix flake update \
|
||||
&& $(MAKE) flake.pkgs
|
||||
|
||||
.SILENT: flake-package-versions
|
||||
flake-package-versions:
|
||||
nix develop --command -- bash -c \
|
||||
'nix derivation show \
|
||||
$$(echo $$PATH | tr ":" "\n" | grep "/nix/store" | sort -u) \
|
||||
| jq -r ".[].name" | sort -u'
|
||||
|
||||
flake.pkgs: flake.nix flake.lock
|
||||
$(MAKE) flake-package-versions > "$@"
|
||||
|
||||
#
|
||||
# Dependencies
|
||||
#
|
||||
|
||||
.PHONY: deps
|
||||
deps:
|
||||
$(info Downloading dependencies)
|
||||
go mod download
|
||||
|
||||
.PHONY: deps-update
|
||||
deps-update:
|
||||
$(info Downloading dependencies)
|
||||
go get -u -t ./...
|
||||
|
||||
.PHONY: deps-analyze
|
||||
deps-analyze: $(TOOLDIR)/gomod
|
||||
gomod analyze
|
||||
|
||||
.PHONY: tidy
|
||||
tidy:
|
||||
go mod tidy $(V)
|
||||
|
||||
.PHONY: verify
|
||||
verify:
|
||||
go mod verify
|
||||
|
||||
.SILENT: check-tidy
|
||||
.PHONY: check-tidy
|
||||
check-tidy:
|
||||
cp go.mod go.mod.tidy-check
|
||||
cp go.sum go.sum.tidy-check
|
||||
go mod tidy
|
||||
( \
|
||||
diff go.mod go.mod.tidy-check && \
|
||||
diff go.sum go.sum.tidy-check && \
|
||||
rm -f go.mod go.sum && \
|
||||
mv go.mod.tidy-check go.mod && \
|
||||
mv go.sum.tidy-check go.sum \
|
||||
) || ( \
|
||||
rm -f go.mod go.sum && \
|
||||
mv go.mod.tidy-check go.mod && \
|
||||
mv go.sum.tidy-check go.sum; \
|
||||
exit 1 \
|
||||
)
|
||||
280
README.md
280
README.md
@@ -1,7 +1,8 @@
|
||||
# build-emacs-for-macos
|
||||
|
||||
My personal hacked together script for building a completely self-contained
|
||||
Emacs.app application on macOS, from any git branch, tag, or ref.
|
||||
Emacs.app application on macOS, from any git branch, tag, or ref. With support
|
||||
for native-compilation.
|
||||
|
||||
Use this script at your own risk.
|
||||
|
||||
@@ -16,21 +17,10 @@ Use this script at your own risk.
|
||||
built from the `master` branch. This script allows you to choose any branch,
|
||||
tag, or git ref you want.
|
||||
|
||||
## Status
|
||||
## Binary Builds
|
||||
|
||||
As of writing (2020-08-19) it works for me on my machine. Your luck may vary.
|
||||
|
||||
I have successfully built:
|
||||
|
||||
- `emacs-27.1` release git tag
|
||||
- `master` branch (Emacs 28.x)
|
||||
- `feature/native-comp` branch (Emacs 28.x)
|
||||
|
||||
For reference, my machine is:
|
||||
|
||||
- 13-inch MacBook Pro (2020), 10th-gen 2.3 GHz Quad-Core Intel Core i7 (4c/8t)
|
||||
- macOS 10.15.6 (19G2021)
|
||||
- Xcode 11.6
|
||||
Nightly and stable binary builds produced with this build script are available
|
||||
from [jimeh/emacs-builds](https://github.com/jimeh/emacs-builds).
|
||||
|
||||
## Limitations
|
||||
|
||||
@@ -40,28 +30,95 @@ The build produced does have some limitations:
|
||||
application will be that of the machine it was built on.
|
||||
- The minimum required macOS version of the built application will be the same
|
||||
as that of the machine it was built on.
|
||||
- The application is not signed, so running it on machines other than the one
|
||||
that built the application will yield warnings. If you want to make a signed
|
||||
Emacs.app, google is you friend for finding signing instructions.
|
||||
- The application is not signed automatically, but the CLI tool used to sign the
|
||||
nightly builds is available. Run `go run ./cmd/emacs-builder package --help`
|
||||
for details. More detailed instructions will come soon.
|
||||
|
||||
## Requirements
|
||||
|
||||
Required with both Nix and Homebrew approaches:
|
||||
|
||||
- [Xcode](https://apps.apple.com/gb/app/xcode/id497799835?mt=12)
|
||||
- [Homebrew](https://brew.sh/)
|
||||
- All Homebrew formula listed in the `Brewfile`, which can all easily be
|
||||
installed by running:
|
||||
```
|
||||
brew bundle
|
||||
```
|
||||
- Ruby 2.3.0 or later is needed to execute the build script itself. macOS comes
|
||||
with Ruby, check your version with `ruby --version`. If it's too old, you can
|
||||
install a newer version with:
|
||||
```
|
||||
brew install ruby
|
||||
```
|
||||
|
||||
### Nix
|
||||
|
||||
The [Nix](https://nixos.org/) package manager is the preferred and most reliable
|
||||
way to install all dependencies required to build Emacs, by way of a Nix flake
|
||||
included in the project root.
|
||||
|
||||
To install all required dependencies within the nix shell, run:
|
||||
|
||||
```
|
||||
nix develop --command make bootstrap
|
||||
```
|
||||
|
||||
### Homebrew
|
||||
|
||||
If you do not have Nix installed, then the alternative way to manage and install
|
||||
build-time dependencies is via [Homebrew](https://brew.sh/).
|
||||
|
||||
Ruby 3.3.x or later is also needed to execute the build script. Earlier versions
|
||||
may work, but are untested. Simplest way to install a recent Ruby version is via
|
||||
Homebrew:
|
||||
|
||||
```
|
||||
brew install ruby
|
||||
```
|
||||
|
||||
And finally, to install all built-time dependencies, run:
|
||||
|
||||
```
|
||||
make bootstrap
|
||||
```
|
||||
|
||||
## Status
|
||||
|
||||
As of writing (2024-11-30) it works for me on my machine and for the nightly
|
||||
builds in [jimeh/emacs-builds](https://github.com/jimeh/emacs-builds). Your luck
|
||||
may vary.
|
||||
|
||||
I have successfully built:
|
||||
|
||||
- `emacs-29.4` release tag.
|
||||
- `emacs-30.0.92` pretest tag.
|
||||
- `master` branch (Emacs 31.x).
|
||||
|
||||
For reference, my machine is:
|
||||
|
||||
- 14-inch MacBook Pro (2023), Apple M3 Max (16-cores)
|
||||
- macOS Sonoma 15.1.1 (24B91)
|
||||
- Xcode 16.1 (16B40)
|
||||
|
||||
The [nightly builds](https://github.com/jimeh/emacs-builds) are built with
|
||||
GitHub Actions on GitHub-hosted runners, using `macos-13` for Intel builds, and
|
||||
`macos-14` for Apple Silicon builds. The build environment is managed with Nix,
|
||||
and targets the macOS 11 SDK.
|
||||
|
||||
## Usage
|
||||
|
||||
### Nix
|
||||
|
||||
Ensure [Flakes](https://nixos.wiki/wiki/Flakes) are enabled, and enter the flake
|
||||
development environment with `nix develop`. Within this environment, you can
|
||||
execute the `./build-emacs-for-macos --help` to get started.
|
||||
|
||||
Or you can run the build script via `nix develop`:
|
||||
|
||||
```
|
||||
nix develop --command ./build-emacs-for-macos --help
|
||||
```
|
||||
|
||||
The Nix environment defaults to targeting the macOS 11 SDK, which makes Emacs
|
||||
builds compatible with macOS 11.3 or later. You can easily target later macOS
|
||||
SDKs. Versions 11 to 15 are available. For example, to target the macOS 12 SDK,
|
||||
run `nix develop .#macos12`
|
||||
|
||||
### Homebrew
|
||||
|
||||
Run `make boostrap` to ensure all Ruby and Homebrew dependencies are installed.
|
||||
|
||||
### Build Script
|
||||
|
||||
```
|
||||
Usage: ./build-emacs-for-macos [options] <branch/tag/sha>
|
||||
|
||||
@@ -69,17 +126,41 @@ Branch, tag, and SHA are from the emacs-mirror/emacs/emacs Github repo,
|
||||
available here: https://github.com/emacs-mirror/emacs
|
||||
|
||||
Options:
|
||||
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 8)
|
||||
--info Print environment info and detected library paths, then exit
|
||||
--preview Print preview details about build and exit.
|
||||
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 16)
|
||||
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
|
||||
--[no-]xwidgets Enable/disable XWidgets (default: enabled)
|
||||
--[no-]use-nix Use Nix instead of Homebrew to find dependencies (default: enabled if IN_NIX_SHELL is set)
|
||||
--[no-]tree-sitter Enable/disable tree-sitter if supported (default: enabled)
|
||||
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
|
||||
--[no-]native-fast-boot Enable/disable NATIVE_FAST_BOOT (default: enabled if native-comp supported)
|
||||
--[no-]native-comp-macos-fixes
|
||||
Enable/disable fix based on feature/native-comp-macos-fixes branch (default: enabled if native-comp supported)
|
||||
--[no-]launcher Enable/disable embedded launcher script (default: enabled if native-comp is enabled)
|
||||
--rsvg Enable SVG image support via librsvg, can yield a unstable build (default: disabled)
|
||||
--no-titlebar Apply no-titlebar patch (default: disabled)
|
||||
--no-frame-refocus Apply no-frame-refocus patch (default: disabled)
|
||||
--optimize Shorthand for --native-march --native-mtune --fomit-frame-pointer (default: disabled)
|
||||
--[no-]native-march Enable/disable -march=native CFLAG (default: disabled)
|
||||
--[no-]native-mtune Enable/disable -mtune=native CFLAG (default: disabled)
|
||||
--[no-]fomit-frame-pointer Enable/disable -fomit-frame-pointer CFLAG (default: disabled)
|
||||
--[no-]native-full-aot Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation (default: disabled)
|
||||
--[no-]relink-eln-files Enable/disable re-linking shared libraries in bundled *.eln files (default: enabled)
|
||||
--[no-]rsvg Enable/disable SVG image support via librsvg (default: enabled)
|
||||
--[no-]dbus Enable/disable dbus support (default: enabled)
|
||||
--[no-]alpha-background Enable/disable experimental alpha-background patch when building Emacs 30.x - 31.x (default: disabled)
|
||||
--no-frame-refocus Apply no-frame-refocus patch when building Emacs 27.x - 31.x (default: disabled)
|
||||
--no-titlebar Apply no-titlebar patch when building Emacs 27.x - 28.x (default: disabled)
|
||||
--[no-]xwidgets Enable/disable XWidgets when building Emacs 27.x (default: disabled)
|
||||
--[no-]poll Apply poll patch (deprecated)
|
||||
--posix-spawn Apply posix-spawn patch (deprecated)
|
||||
-p, --patch=URL Specify a custom patch file or URL to apply to the Emacs source (can be used multiple times)
|
||||
--[no-]fd-setsize SIZE Set an file descriptor (max open files) limit (default: 10000)
|
||||
--github-src-repo REPO Specify a GitHub repo to download source tarballs from (default: emacs-mirror/emacs)
|
||||
--[no-]github-auth Make authenticated GitHub API requests if GITHUB_TOKEN environment variable is set.(default: enabled)
|
||||
--work-dir DIR Specify a working directory where tarballs, sources, and builds will be stored and worked with
|
||||
-o, --output DIR Output directory for finished builds (default: <work-dir>/builds)
|
||||
--build-name NAME Override generated build name
|
||||
--dist-include x,y,z List of extra files to copy from Emacs source into build folder/archive (default: COPYING)
|
||||
--[no-]self-sign Enable/disable self-signing of Emacs.app (default: enabled)
|
||||
--[no-]archive Enable/disable creating *.tbz archive (default: enabled)
|
||||
--[no-]archive-keep-build-dir
|
||||
Enable/disable keeping source folder for archive (default: disabled)
|
||||
--log-level LEVEL Build script log level (default: info)
|
||||
--plan FILE Follow given plan file, instead of using given git ref/sha
|
||||
```
|
||||
|
||||
Resulting applications are saved to the `builds` directory in a bzip2 compressed
|
||||
@@ -88,19 +169,22 @@ tarball.
|
||||
If you don't want the build process to eat all your CPU cores, pass in a `-j`
|
||||
value of how many CPU cores you want it to use.
|
||||
|
||||
Re-building the same Git SHA again can yield weird results unless you first
|
||||
trash the corresponding directory from the `sources` directory.
|
||||
|
||||
### Examples
|
||||
|
||||
To download a tarball of the `master` branch (Emacs 28.x as of writing) and
|
||||
build Emacs.app from it:
|
||||
To download a tarball of the `master` branch (Emacs 28.x with native-compilation
|
||||
as of writing) and build Emacs.app from it:
|
||||
|
||||
```
|
||||
./build-emacs-for-macos
|
||||
```
|
||||
|
||||
To build the stable `emacs-27.1` release git tag run:
|
||||
To build the stable `emacs-29.4` release git tag run:
|
||||
|
||||
```
|
||||
./build-emacs-for-macos emacs-27.1
|
||||
./build-emacs-for-macos emacs-29.4
|
||||
```
|
||||
|
||||
All sources as downloaded as tarballs from the
|
||||
@@ -108,75 +192,73 @@ All sources as downloaded as tarballs from the
|
||||
to get a list of tags/branches available to install, simply check said
|
||||
repository.
|
||||
|
||||
## Use Emacs.app as `emacs` CLI Tool
|
||||
|
||||
Builds come with a custom `emacs` shell script launcher for use from the command
|
||||
line, located next to `emacsclient` in `Emacs.app/Contents/MacOS/bin`.
|
||||
|
||||
The custom `emacs` script makes sure to use the main
|
||||
`Emacs.app/Contents/MacOS/Emacs` executable from the correct path, ensuring it
|
||||
finds all the relevant dependencies within the Emacs.app bundle, regardless of
|
||||
it it's exposed via `PATH` or symlinked to from elsewhere.
|
||||
|
||||
To use it, simply add `Emacs.app/Contents/MacOS/bin` to your `PATH`. For
|
||||
example, if you place Emacs.app in `/Applications`:
|
||||
|
||||
```bash
|
||||
if [ -d "/Applications/Emacs.app/Contents/MacOS/bin" ]; then
|
||||
export PATH="/Applications/Emacs.app/Contents/MacOS/bin:$PATH"
|
||||
alias emacs="emacs -nw" # Always launch "emacs" in terminal mode.
|
||||
fi
|
||||
```
|
||||
|
||||
If you want `emacs` in your terminal to launch a GUI instance of Emacs, don't
|
||||
use the alias from the above example.
|
||||
|
||||
## Native-Comp
|
||||
|
||||
To build a Emacs.app with native-comp support
|
||||
([gccemacs](https://akrl.sdf.org/gccemacs.html)) from the `feature/native-comp`
|
||||
branch, you will need to install a patched version of Homebrew's `gcc` formula
|
||||
that includes libgccjit.
|
||||
The build script will automatically detect if the source tree being built
|
||||
supports native-compilation, and enable it if available. You can override the
|
||||
auto-detection logic to force enable or force disable native-compilation by
|
||||
passing `--native-comp` or `--no-native-comp` respectively.
|
||||
|
||||
The patch itself is in `./Formula/gcc.rb.patch`, and comes from
|
||||
[this](https://gist.github.com/mikroskeem/0a5c909c1880408adf732ceba6d3f9ab#1-gcc-with-libgccjit-enabled)
|
||||
gist.
|
||||
By default `NATIVE_FULL_AOT` is disabled which ensures a fast build by native
|
||||
compiling as few elisp source files as possible to build Emacs itself. Any
|
||||
remaining elisp files will be dynamically compiled in the background the first
|
||||
time they are used.
|
||||
|
||||
You can install the patched formula by running the helper script:
|
||||
|
||||
```
|
||||
./install-patched-gcc
|
||||
```
|
||||
|
||||
The helper script will copy your local `gcc.rb` Forumla from Homebrew to
|
||||
`./Formula`, and apply the `./Formula/gcc.rb.patch` to it. After which it then
|
||||
proceed to install the patched gcc formula which includes libgccjit.
|
||||
|
||||
As it requires installing and compiling GCC from source, it can take anywhere
|
||||
between 30-60 minutes or more depending on your machine.
|
||||
|
||||
And finally to build a Emacs.app with native compilation enabled, run:
|
||||
|
||||
```
|
||||
./build-emacs-for-macos feature/native-comp
|
||||
```
|
||||
|
||||
By default `NATIVE_FAST_BOOT` is enabled which ensures a fast build by native
|
||||
compiling as few lisp source files as possible to build the app. Any remaining
|
||||
lisp files will be dynamically compiled in the background the first time you use
|
||||
them.
|
||||
|
||||
On my machine it takes around 10-15 minutes to build Emacs.app with
|
||||
`NATIVE_FAST_BOOT` enabled. With it disabled it takes around 25 minutes.
|
||||
To enable native full Ahead-of-Time compilation, pass in the `--native-full-aot`
|
||||
option, which will native-compile all of Emacs' elisp at built-time. On my
|
||||
machine it takes around 10 minutes to build Emacs.app with `NATIVE_FULL_AOT`
|
||||
disabled, and around 20-25 minutes with it enabled.
|
||||
|
||||
### Configuration
|
||||
|
||||
Add the following near the top of your `early-init.el` or `init.el`:
|
||||
|
||||
```elisp
|
||||
(setq comp-speed 2)
|
||||
```
|
||||
#### Native-Lisp Cache Directory
|
||||
|
||||
By default natively compiled `*.eln` files will be cached in
|
||||
`~/.emacs.d/eln-cache/`. If you want to customize that, simply set a new path as
|
||||
the first element of the `comp-eln-load-path` variable. The path string must end
|
||||
with a `/`.
|
||||
|
||||
Also it seems somewhat common that some `*.eln` files are left behind with a
|
||||
zero-byte file size if Emacs is quit while async native compilation is in
|
||||
progress. Such empty files causes errors on startup, and needs to be deleted.
|
||||
the first element of the `native-comp-eln-load-path` variable. The path string
|
||||
must end with a `/`.
|
||||
|
||||
Below is an example which stores all compiled `*.eln` files in `cache/eln-cache`
|
||||
within your Emacs configuration directory, and also deletes any `*.eln` files in
|
||||
said directory which have a file size of zero bytes:
|
||||
within your Emacs configuration directory:
|
||||
|
||||
```elisp
|
||||
(when (boundp 'comp-eln-load-path)
|
||||
(let ((eln-cache-dir (expand-file-name "cache/eln-cache/" user-emacs-directory))
|
||||
(find-exec (executable-find "find")))
|
||||
(setcar comp-eln-load-path eln-cache-dir)
|
||||
;; Quitting emacs while native compilation in progress can leave zero byte
|
||||
;; sized *.eln files behind. Hence delete such files during startup.
|
||||
(when find-exec
|
||||
(call-process find-exec nil nil nil eln-cache-dir
|
||||
"-name" "*.eln" "-size" "0" "-delete"))))
|
||||
(when (boundp 'native-comp-eln-load-path)
|
||||
(setcar native-comp-eln-load-path
|
||||
(expand-file-name "cache/eln-cache/" user-emacs-directory)))
|
||||
```
|
||||
|
||||
#### Compilation Warnings
|
||||
|
||||
By default any warnings encountered during async native compilation will pop up
|
||||
a warnings buffer. As this tends to happen rather frequently with a lot of
|
||||
packages, it can get annoying. You can disable showing these warnings by setting
|
||||
`native-comp-async-report-warnings-errors` to `nil`:
|
||||
|
||||
```elisp
|
||||
(setq native-comp-async-report-warnings-errors nil)
|
||||
```
|
||||
|
||||
### Issues
|
||||
@@ -189,7 +271,7 @@ types of issues and or behavior you can expect.
|
||||
### Known Good Commits/Builds
|
||||
|
||||
A list of known "good" commits which produce working builds is tracked in:
|
||||
[#6 Known good commits of feature/native-comp branch](https://github.com/jimeh/build-emacs-for-macos/issues/6)
|
||||
[#6 Known good commits for native-comp](https://github.com/jimeh/build-emacs-for-macos/issues/6)
|
||||
|
||||
## Credits
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
24
cmd/emacs-builder/main.go
Normal file
24
cmd/emacs-builder/main.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/cli"
|
||||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
commit string
|
||||
date string
|
||||
)
|
||||
|
||||
func main() {
|
||||
cliInstance := cli.New(version, commit, date)
|
||||
|
||||
err := cliInstance.Run(os.Args)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1732981179,
|
||||
"narHash": "sha256-F7thesZPvAMSwjRu0K8uFshTk3ZZSNAsXTIFvXBT+34=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "62c435d93bf046a5396f3016472e8f7c8e2aed65",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
102
flake.nix
Normal file
102
flake.nix
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
description = "Development environment flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
# List of supported macOS SDK versions.
|
||||
sdk_versions = [ "11" "12" "13" "14" "15" ];
|
||||
default_sdk_version = "11";
|
||||
|
||||
mkDevShell = { macos_version ? default_sdk_version }:
|
||||
let
|
||||
apple_sdk = pkgs.${"apple-sdk_${macos_version}"};
|
||||
in
|
||||
pkgs.mkShell {
|
||||
# Package list specifically excludes ncurses, so that we link
|
||||
# against the system version of ncurses. This ensures emacs' TUI
|
||||
# works out of the box without the user having to manually set
|
||||
# TERMINFO in the shell before launching emacs.
|
||||
packages = with pkgs; [
|
||||
apple_sdk
|
||||
autoconf
|
||||
bash
|
||||
cairo
|
||||
clang
|
||||
coreutils
|
||||
curl
|
||||
darwin.DarwinTools # sw_vers
|
||||
dbus
|
||||
expat
|
||||
findutils
|
||||
gcc
|
||||
gettext
|
||||
giflib
|
||||
git
|
||||
gmp
|
||||
gnumake
|
||||
gnupatch
|
||||
gnused
|
||||
gnutar
|
||||
gnutls
|
||||
harfbuzz
|
||||
jansson
|
||||
jq
|
||||
lcms2
|
||||
libffi
|
||||
libgccjit
|
||||
libiconv
|
||||
libjpeg
|
||||
libpng
|
||||
librsvg
|
||||
libtasn1
|
||||
libunistring
|
||||
libwebp
|
||||
libxml2
|
||||
mailutils
|
||||
nettle
|
||||
pkg-config
|
||||
python3
|
||||
rsync
|
||||
ruby_3_3
|
||||
sqlite
|
||||
texinfo
|
||||
time
|
||||
tree-sitter
|
||||
which
|
||||
xcbuild
|
||||
zlib
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export CC=clang
|
||||
export MACOSX_DEPLOYMENT_TARGET="${macos_version}.0"
|
||||
export DEVELOPER_DIR="${apple_sdk}"
|
||||
export NIX_LIBGCCJIT_VERSION="${pkgs.libgccjit.version}"
|
||||
export NIX_LIBGCCJIT_ROOT="${pkgs.libgccjit.outPath}"
|
||||
export BUNDLE_WITHOUT=development
|
||||
'';
|
||||
};
|
||||
|
||||
# Generate an attrset of shells for each macOS SDK version.
|
||||
versionShells = builtins.listToAttrs (
|
||||
map (version: {
|
||||
name = "macos${version}";
|
||||
value = mkDevShell { macos_version = version; };
|
||||
}) sdk_versions
|
||||
);
|
||||
in
|
||||
{
|
||||
devShells = versionShells // {
|
||||
default = mkDevShell {};
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
67
flake.pkgs
Normal file
67
flake.pkgs
Normal file
@@ -0,0 +1,67 @@
|
||||
DarwinTools-1
|
||||
autoconf-2.72
|
||||
bash-5.2p37
|
||||
brotli-1.1.0
|
||||
bzip2-1.0.8
|
||||
cairo-1.18.2
|
||||
cctools-binutils-darwin-1010.6
|
||||
cctools-binutils-darwin-wrapper-1010.6
|
||||
clang-16.0.6
|
||||
clang-wrapper-16.0.6
|
||||
coreutils-9.5
|
||||
curl-8.11.0
|
||||
dbus-1.14.10
|
||||
diffutils-3.10
|
||||
expat-2.6.4
|
||||
file-5.45
|
||||
findutils-4.10.0
|
||||
fontconfig-2.15.0
|
||||
freetype-2.13.3
|
||||
gawk-5.3.1
|
||||
gcc-13.3.0
|
||||
gcc-wrapper-13.3.0
|
||||
gdk-pixbuf-2.42.12
|
||||
gettext-0.21.1
|
||||
giflib-5.2.2
|
||||
git-2.47.0
|
||||
glib-2.82.1
|
||||
gnugrep-3.11
|
||||
gnumake-4.4.1
|
||||
gnused-4.9
|
||||
gnutar-1.35
|
||||
gnutls-3.8.6
|
||||
graphite2-1.3.14
|
||||
gzip-1.13
|
||||
harfbuzz-10.0.1
|
||||
jq-1.7.1
|
||||
krb5-1.21.3
|
||||
lcms2-2.16
|
||||
libdeflate-1.22
|
||||
libgccjit-13.3.0
|
||||
libiconv-107
|
||||
libidn2-2.3.7
|
||||
libjpeg-turbo-3.0.4
|
||||
libpng-apng-1.6.43
|
||||
libpsl-0.21.5
|
||||
librsvg-2.58.3
|
||||
libtasn1-4.19.0
|
||||
libtiff-4.7.0
|
||||
libwebp-1.4.0
|
||||
libxml2-2.13.4
|
||||
mailutils-3.17
|
||||
nettle-3.10
|
||||
nghttp2-1.64.0
|
||||
openssl-3.3.2
|
||||
patch-2.7.6
|
||||
pkg-config-wrapper-0.29.2
|
||||
python3-3.12.7
|
||||
rsync-3.3.0
|
||||
ruby-3.3.5
|
||||
sqlite-3.46.1
|
||||
texinfo-7.1.1
|
||||
time-1.9
|
||||
tree-sitter-0.24.3
|
||||
which-2.21
|
||||
xcbuild-0.1.1-unstable-2019-11-20
|
||||
xz-5.6.3
|
||||
zstd-1.5.6
|
||||
35
go.mod
Normal file
35
go.mod
Normal file
@@ -0,0 +1,35 @@
|
||||
module github.com/jimeh/build-emacs-for-macos
|
||||
|
||||
go 1.23
|
||||
|
||||
require (
|
||||
github.com/bearer/gon v0.0.36
|
||||
github.com/google/go-github/v35 v35.3.0
|
||||
github.com/hashicorp/go-hclog v1.5.0
|
||||
github.com/hexops/gotextdiff v1.0.3
|
||||
github.com/jimeh/undent v1.1.0
|
||||
github.com/stretchr/testify v1.7.2
|
||||
github.com/urfave/cli/v2 v2.25.7
|
||||
golang.org/x/oauth2 v0.14.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
golang.org/x/crypto v0.17.0 // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
howett.net/plist v1.0.0 // indirect
|
||||
)
|
||||
154
go.sum
Normal file
154
go.sum
Normal file
@@ -0,0 +1,154 @@
|
||||
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
|
||||
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
|
||||
github.com/bearer/gon v0.0.36 h1:IswEKy8WbBPx7ZxCs4T7mHN6Rj8CbLpS/0u8wka6fO8=
|
||||
github.com/bearer/gon v0.0.36/go.mod h1:jiD3TC2OA5lR2oADhe83a/FLxNS7/ra+58QUT9sQveg=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-github/v35 v35.3.0 h1:fU+WBzuukn0VssbayTT+Zo3/ESKX9JYWjbZTLOTEyho=
|
||||
github.com/google/go-github/v35 v35.3.0/go.mod h1:yWB7uCcVWaUbUP74Aq3whuMySRMatyRmq5U9FTNlbio=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-hclog v0.9.3-0.20191025211905-234833755cb2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||
github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c=
|
||||
github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||
github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
|
||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jimeh/undent v1.1.0 h1:Cge7P4Ws6buy0SVuHBluY/aOKdFuJUMzoJswfAHZ4zE=
|
||||
github.com/jimeh/undent v1.1.0/go.mod h1:oxYCIzdbyQNy8GXnCnjRJ2NS6Uq4p4yWoeawiGFqoHI=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rhysd/go-fakeio v1.0.0 h1:+TjiKCOs32dONY7DaoVz/VPOdvRkPfBkEyUDIpM8FQY=
|
||||
github.com/rhysd/go-fakeio v1.0.0/go.mod h1:joYxF906trVwp2JLrE4jlN7A0z6wrz8O6o1UjarbFzE=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
|
||||
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0=
|
||||
golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
|
||||
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
|
||||
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
|
||||
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
|
||||
23
helper/emacs-cli.bash
Executable file
23
helper/emacs-cli.bash
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
resolve_link() {
|
||||
"$(command -v greadlink || command -v readlink)" "$1"
|
||||
}
|
||||
|
||||
abs_dirname() {
|
||||
local path="$1"
|
||||
local name
|
||||
local cwd
|
||||
cwd="$(pwd)"
|
||||
|
||||
while [ -n "$path" ]; do
|
||||
cd "${path%/*}" || exit 1
|
||||
name="${path##*/}"
|
||||
path="$(resolve_link "$name" || true)"
|
||||
done
|
||||
|
||||
pwd
|
||||
cd "$cwd" || exit 1
|
||||
}
|
||||
|
||||
exec "$(dirname "$(abs_dirname "$0")")/Emacs" "$@"
|
||||
@@ -1,27 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
set -e
|
||||
|
||||
brewdir="$(brew --prefix)"
|
||||
formula="${brewdir}/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gcc.rb"
|
||||
|
||||
if [ ! -f "$formula" ]; then
|
||||
echo "ERROR: ${formula} does not exist." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gnubins=(
|
||||
"${brewdir}/opt/coreutils/libexec/gnubin"
|
||||
"${brewdir}/opt/make/libexec/gnubin"
|
||||
"${brewdir}/opt/gnu-sed/libexec/gnubin"
|
||||
)
|
||||
|
||||
for gnubin in "${gnubins[@]}"; do
|
||||
if [ -d "$gnubin" ]; then
|
||||
export PATH="${gnubin}:$PATH"
|
||||
fi
|
||||
done
|
||||
|
||||
cp "$formula" ./Formula/
|
||||
|
||||
patch -f -p1 -i ./Formula/gcc.rb.patch
|
||||
brew install ./Formula/gcc.rb --build-from-source --force
|
||||
@@ -1,65 +0,0 @@
|
||||
#!/bin/bash
|
||||
# This launcher script is not part of Emacs proper. It is from the
|
||||
# build-emacs-for-macos project (https://github.com/jimeh/build-emacs-for-macos)
|
||||
# and helps facilitate proper startup of Emacs with environment varibales set as
|
||||
# needed.
|
||||
#
|
||||
# Licensed under CC0 1.0 Universal:
|
||||
# https://creativecommons.org/publicdomain/zero/1.0/
|
||||
#
|
||||
set -e
|
||||
|
||||
resolve_link() {
|
||||
local file="$1"
|
||||
|
||||
while [ -L "$file" ]; do
|
||||
file="$(readlink "$file")"
|
||||
done
|
||||
|
||||
echo "$file"
|
||||
}
|
||||
|
||||
realname() {
|
||||
local path="$1"
|
||||
local resolved
|
||||
local cwd
|
||||
|
||||
cwd="$(pwd)"
|
||||
resolved="$(resolve_link "$path")"
|
||||
cd "$(dirname "$resolved")"
|
||||
echo "$(pwd)/$(basename "$resolved")"
|
||||
cd "$cwd"
|
||||
}
|
||||
|
||||
join() {
|
||||
local IFS="$1"
|
||||
local parts=()
|
||||
shift
|
||||
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" != "" ]; then
|
||||
parts+=("$arg")
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${parts[*]}"
|
||||
}
|
||||
|
||||
DIR="$(dirname "$(realname "$0")")"
|
||||
BIN="${DIR}/Emacs<%= bin_suffix %>"
|
||||
|
||||
export PATH="${DIR}/bin:${DIR}/libexec:${PATH}"
|
||||
<% if library_paths.any? %>
|
||||
LIB_PATHS=(
|
||||
'<%= library_paths.map { |p| p.gsub('\'', "\"'\"") }.join("'\n '") %>'
|
||||
)
|
||||
for lib in "${LIB_PATHS[@]}"; do
|
||||
if [ -d "${DIR}/<%= lib_dir_name %>/${lib}" ]; then
|
||||
libs="$(join : "$libs" "${DIR}/<%= lib_dir_name %>/${lib}")"
|
||||
fi
|
||||
done
|
||||
|
||||
LIBRARY_PATH="$(join : "$libs" "$LIBRARY_PATH")"
|
||||
export LIBRARY_PATH
|
||||
<% end %>
|
||||
exec "$BIN" "$@"
|
||||
487
patches/emacs-29/ns-alpha-background.patch
Normal file
487
patches/emacs-29/ns-alpha-background.patch
Normal file
@@ -0,0 +1,487 @@
|
||||
From 9b436ccb00ea321fe778ea51cf1ad536aff7210f Mon Sep 17 00:00:00 2001
|
||||
From: Jon Rubens <jonathanrubens@gmail.com>
|
||||
Date: Wed, 24 Jan 2024 19:45:55 -0800
|
||||
Subject: [PATCH 1/3] Enable frame parameter alpha_background for MacOS
|
||||
|
||||
---
|
||||
src/macfont.m | 10 ++++++++--
|
||||
src/nsfns.m | 42 ++++++++++++++++++++++++++++++++++--------
|
||||
src/nsterm.m | 42 ++++++++++++++++++++++--------------------
|
||||
3 files changed, 64 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/src/macfont.m b/src/macfont.m
|
||||
index 8aba440d196e..56c1eb57024e 100644
|
||||
--- a/src/macfont.m
|
||||
+++ b/src/macfont.m
|
||||
@@ -2953,9 +2953,14 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||
CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
|
||||
else
|
||||
CG_SET_FILL_COLOR_WITH_FRAME_CURSOR (context, f);
|
||||
- }
|
||||
+ CGContextSetAlpha(context, 1);
|
||||
+ }
|
||||
else
|
||||
- CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
|
||||
+ {
|
||||
+ CGContextSetAlpha(context, f->alpha_background);
|
||||
+ CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
|
||||
+ }
|
||||
+ CGContextClearRect(context, background_rect);
|
||||
CGContextFillRects (context, &background_rect, 1);
|
||||
}
|
||||
|
||||
@@ -2964,6 +2969,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||
CGAffineTransform atfm;
|
||||
|
||||
CGContextScaleCTM (context, 1, -1);
|
||||
+ CGContextSetAlpha(context, 1);
|
||||
if (s->hl == DRAW_CURSOR)
|
||||
{
|
||||
if (face && (NS_FACE_BACKGROUND (face)
|
||||
diff --git a/src/nsfns.m b/src/nsfns.m
|
||||
index b0281aac2572..3e19cce89de9 100644
|
||||
--- a/src/nsfns.m
|
||||
+++ b/src/nsfns.m
|
||||
@@ -301,7 +301,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||
struct face *face;
|
||||
NSColor *col;
|
||||
NSView *view = FRAME_NS_VIEW (f);
|
||||
- EmacsCGFloat alpha;
|
||||
+ EmacsCGFloat alpha = f->alpha_background;
|
||||
|
||||
block_input ();
|
||||
if (ns_lisp_to_color (arg, &col))
|
||||
@@ -316,11 +316,10 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||
f->output_data.ns->background_color = col;
|
||||
|
||||
FRAME_BACKGROUND_PIXEL (f) = [col unsignedLong];
|
||||
- alpha = [col alphaComponent];
|
||||
|
||||
if (view != nil)
|
||||
{
|
||||
- [[view window] setBackgroundColor: col];
|
||||
+ [[view window] setBackgroundColor: [col colorWithAlphaComponent: alpha]];
|
||||
|
||||
if (alpha != (EmacsCGFloat) 1.0)
|
||||
[[view window] setOpaque: NO];
|
||||
@@ -330,10 +329,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||
face = FRAME_DEFAULT_FACE (f);
|
||||
if (face)
|
||||
{
|
||||
- col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)];
|
||||
- face->background = [[col colorWithAlphaComponent: alpha]
|
||||
- unsignedLong];
|
||||
-
|
||||
+ face->background = [col unsignedLong];
|
||||
update_face_from_frame_parameter (f, Qbackground_color, arg);
|
||||
}
|
||||
|
||||
@@ -346,6 +342,36 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||
unblock_input ();
|
||||
}
|
||||
|
||||
+static void
|
||||
+ns_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
|
||||
+{
|
||||
+ NSView *view = FRAME_NS_VIEW (f);
|
||||
+ double alpha = 1.0;
|
||||
+
|
||||
+ if (NILP (arg))
|
||||
+ alpha = 1.0;
|
||||
+ else if (FLOATP (arg))
|
||||
+ {
|
||||
+ alpha = XFLOAT_DATA (arg);
|
||||
+ if (! (0 <= alpha && alpha <= 1.0))
|
||||
+ args_out_of_range (make_float (0.0), make_float (1.0));
|
||||
+ }
|
||||
+ else if (FIXNUMP (arg))
|
||||
+ {
|
||||
+ EMACS_INT ialpha = XFIXNUM (arg);
|
||||
+ if (! (0 <= ialpha && ialpha <= 100))
|
||||
+ args_out_of_range (make_fixnum (0), make_fixnum (100));
|
||||
+ alpha = ialpha / 100.0;
|
||||
+ }
|
||||
+ else
|
||||
+ wrong_type_argument (Qnumberp, arg);
|
||||
+
|
||||
+ f->alpha_background = alpha;
|
||||
+ [[view window] setBackgroundColor: [f->output_data.ns->background_color
|
||||
+ colorWithAlphaComponent: alpha]];
|
||||
+ recompute_basic_faces (f);
|
||||
+ SET_FRAME_GARBAGED (f);
|
||||
+}
|
||||
|
||||
static void
|
||||
ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
|
||||
@@ -1065,7 +1091,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||
ns_set_z_group,
|
||||
0, /* x_set_override_redirect */
|
||||
gui_set_no_special_glyphs,
|
||||
- gui_set_alpha_background,
|
||||
+ ns_set_alpha_background,
|
||||
NULL,
|
||||
#ifdef NS_IMPL_COCOA
|
||||
ns_set_appearance,
|
||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||
index 518b38658d17..bda3a12172f5 100644
|
||||
--- a/src/nsterm.m
|
||||
+++ b/src/nsterm.m
|
||||
@@ -2618,8 +2618,9 @@ Hide the window (X11 semantics)
|
||||
|
||||
block_input ();
|
||||
ns_focus (f, &r, 1);
|
||||
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
|
||||
- (FACE_FROM_ID (f, DEFAULT_FACE_ID))] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
|
||||
+ (FACE_FROM_ID (f, DEFAULT_FACE_ID))]
|
||||
+ colorWithAlphaComponent: f->alpha_background] set];
|
||||
NSRectFill (r);
|
||||
ns_unfocus (f);
|
||||
|
||||
@@ -2647,7 +2648,7 @@ Hide the window (X11 semantics)
|
||||
|
||||
r = NSIntersectionRect (r, [view frame]);
|
||||
ns_focus (f, &r, 1);
|
||||
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
|
||||
|
||||
NSRectFill (r);
|
||||
|
||||
@@ -2751,7 +2752,7 @@ Hide the window (X11 semantics)
|
||||
return;
|
||||
|
||||
ns_focus (f, NULL, 1);
|
||||
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
|
||||
NSRectFill (NSMakeRect (0, margin, width, border));
|
||||
NSRectFill (NSMakeRect (0, 0, border, height));
|
||||
NSRectFill (NSMakeRect (0, margin, width, border));
|
||||
@@ -2802,7 +2803,7 @@ Hide the window (X11 semantics)
|
||||
NSRect r = NSMakeRect (0, y, FRAME_PIXEL_WIDTH (f), height);
|
||||
ns_focus (f, &r, 1);
|
||||
|
||||
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
|
||||
NSRectFill (NSMakeRect (0, y, width, height));
|
||||
NSRectFill (NSMakeRect (FRAME_PIXEL_WIDTH (f) - width,
|
||||
y, width, height));
|
||||
@@ -2966,8 +2967,7 @@ Hide the window (X11 semantics)
|
||||
if (! NSIsEmptyRect (clearRect))
|
||||
{
|
||||
NSTRACE_RECT ("clearRect", clearRect);
|
||||
-
|
||||
- [[NSColor colorWithUnsignedLong:face->background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:face->background] colorWithAlphaComponent: f->alpha_background] set];
|
||||
NSRectFill (clearRect);
|
||||
}
|
||||
|
||||
@@ -2998,7 +2998,7 @@ Hide the window (X11 semantics)
|
||||
else
|
||||
bm_color = f->output_data.ns->cursor_color;
|
||||
|
||||
- [bm_color set];
|
||||
+ [[bm_color colorWithAlphaComponent:f->alpha_background] set];
|
||||
[bmp fill];
|
||||
|
||||
[bmp release];
|
||||
@@ -3719,7 +3719,7 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
|
||||
{
|
||||
ns_draw_box (r, abs (hthickness), abs (vthickness),
|
||||
- [NSColor colorWithUnsignedLong:face->box_color],
|
||||
+ [[NSColor colorWithUnsignedLong:face->box_color] colorWithAlphaComponent: s->f->alpha_background],
|
||||
left_p, right_p);
|
||||
}
|
||||
else
|
||||
@@ -3757,8 +3757,10 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
{
|
||||
if (s->hl != DRAW_CURSOR)
|
||||
[(NS_FACE_BACKGROUND (face) != 0
|
||||
- ? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||
+ ? [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||
+ colorWithAlphaComponent: s->f->alpha_background]
|
||||
: FRAME_BACKGROUND_COLOR (s->f)) set];
|
||||
+
|
||||
else if (face && (NS_FACE_BACKGROUND (face)
|
||||
== [(NSColor *) FRAME_CURSOR_COLOR (s->f)
|
||||
unsignedLong]))
|
||||
@@ -3902,7 +3904,7 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
otherwise, since we composite the image under NS (instead of mucking
|
||||
with its background color), we must clear just the image area. */
|
||||
|
||||
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
|
||||
if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin
|
||||
|| s->img->mask || s->img->pixmap == 0 || s->width != s->background_width)
|
||||
@@ -3972,7 +3974,7 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
if (s->hl == DRAW_CURSOR)
|
||||
{
|
||||
[FRAME_CURSOR_COLOR (s->f) set];
|
||||
- tdCol = [NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)];
|
||||
+ tdCol = [[NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background];
|
||||
}
|
||||
else
|
||||
tdCol = [NSColor colorWithUnsignedLong: NS_FACE_FOREGROUND (face)];
|
||||
@@ -4066,10 +4068,10 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
|
||||
prepare_face_for_display (s->f, face);
|
||||
|
||||
- [[NSColor colorWithUnsignedLong: face->background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong: face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
}
|
||||
else
|
||||
- [[NSColor colorWithUnsignedLong: s->face->background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
NSRectFill (NSMakeRect (x, y, w, h));
|
||||
}
|
||||
}
|
||||
@@ -4095,7 +4097,7 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
if (s->hl == DRAW_CURSOR)
|
||||
[FRAME_CURSOR_COLOR (s->f) set];
|
||||
else
|
||||
- [[NSColor colorWithUnsignedLong: s->face->background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
|
||||
NSRectFill (NSMakeRect (x, s->y, background_width, s->height));
|
||||
}
|
||||
@@ -8436,8 +8438,8 @@ - (void)toggleFullScreen: (id)sender
|
||||
}
|
||||
|
||||
[w setContentView:[fw contentView]];
|
||||
- [w setBackgroundColor: col];
|
||||
- if ([col alphaComponent] != (EmacsCGFloat) 1.0)
|
||||
+ [w setBackgroundColor: [col colorWithAlphaComponent: f->alpha_background]];
|
||||
+ if (f->alpha_background != (EmacsCGFloat) 1.0)
|
||||
[w setOpaque: NO];
|
||||
|
||||
f->border_width = [w borderWidth];
|
||||
@@ -9172,9 +9174,9 @@ - (instancetype) initWithEmacsFrame: (struct frame *) f
|
||||
f->border_width = [self borderWidth];
|
||||
|
||||
col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
|
||||
- (FACE_FROM_ID (f, DEFAULT_FACE_ID))];
|
||||
- [self setBackgroundColor:col];
|
||||
- if ([col alphaComponent] != (EmacsCGFloat) 1.0)
|
||||
+ (FACE_FROM_ID (f, DEFAULT_FACE_ID))];
|
||||
+ [self setBackgroundColor:[col colorWithAlphaComponent:f->alpha_background]];
|
||||
+ if (f->alpha_background != (EmacsCGFloat) 1.0)
|
||||
[self setOpaque:NO];
|
||||
|
||||
/* toolbar support */
|
||||
|
||||
From 58cf6e6da20eefca161c1ab1fd0d6ad67d1ba710 Mon Sep 17 00:00:00 2001
|
||||
From: Jon Rubens <jonathanrubens@gmail.com>
|
||||
Date: Fri, 26 Jan 2024 09:35:15 -0800
|
||||
Subject: [PATCH 2/3] Fix code formatting
|
||||
|
||||
---
|
||||
src/macfont.m | 8 ++++----
|
||||
src/nsterm.m | 30 ++++++++++++++++++++----------
|
||||
2 files changed, 24 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/src/macfont.m b/src/macfont.m
|
||||
index 56c1eb57024e..8fb835c7ff01 100644
|
||||
--- a/src/macfont.m
|
||||
+++ b/src/macfont.m
|
||||
@@ -2953,14 +2953,14 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||
CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
|
||||
else
|
||||
CG_SET_FILL_COLOR_WITH_FRAME_CURSOR (context, f);
|
||||
- CGContextSetAlpha(context, 1);
|
||||
+ CGContextSetAlpha (context, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
- CGContextSetAlpha(context, f->alpha_background);
|
||||
+ CGContextSetAlpha (context, f->alpha_background);
|
||||
CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
|
||||
}
|
||||
- CGContextClearRect(context, background_rect);
|
||||
+ CGContextClearRect (context, background_rect);
|
||||
CGContextFillRects (context, &background_rect, 1);
|
||||
}
|
||||
|
||||
@@ -2969,7 +2969,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||
CGAffineTransform atfm;
|
||||
|
||||
CGContextScaleCTM (context, 1, -1);
|
||||
- CGContextSetAlpha(context, 1);
|
||||
+ CGContextSetAlpha (context, 1);
|
||||
if (s->hl == DRAW_CURSOR)
|
||||
{
|
||||
if (face && (NS_FACE_BACKGROUND (face)
|
||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||
index bda3a12172f5..9ab3ff8f783f 100644
|
||||
--- a/src/nsterm.m
|
||||
+++ b/src/nsterm.m
|
||||
@@ -2803,7 +2803,8 @@ Hide the window (X11 semantics)
|
||||
NSRect r = NSMakeRect (0, y, FRAME_PIXEL_WIDTH (f), height);
|
||||
ns_focus (f, &r, 1);
|
||||
|
||||
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||
+ colorWithAlphaComponent: f->alpha_background] set];
|
||||
NSRectFill (NSMakeRect (0, y, width, height));
|
||||
NSRectFill (NSMakeRect (FRAME_PIXEL_WIDTH (f) - width,
|
||||
y, width, height));
|
||||
@@ -2967,7 +2968,8 @@ Hide the window (X11 semantics)
|
||||
if (! NSIsEmptyRect (clearRect))
|
||||
{
|
||||
NSTRACE_RECT ("clearRect", clearRect);
|
||||
- [[[NSColor colorWithUnsignedLong:face->background] colorWithAlphaComponent: f->alpha_background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:face->background]
|
||||
+ colorWithAlphaComponent: f->alpha_background] set];
|
||||
NSRectFill (clearRect);
|
||||
}
|
||||
|
||||
@@ -3719,7 +3721,8 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
|
||||
{
|
||||
ns_draw_box (r, abs (hthickness), abs (vthickness),
|
||||
- [[NSColor colorWithUnsignedLong:face->box_color] colorWithAlphaComponent: s->f->alpha_background],
|
||||
+ [[NSColor colorWithUnsignedLong:face->box_color]
|
||||
+ colorWithAlphaComponent: s->f->alpha_background],
|
||||
left_p, right_p);
|
||||
}
|
||||
else
|
||||
@@ -3904,7 +3907,8 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
otherwise, since we composite the image under NS (instead of mucking
|
||||
with its background color), we must clear just the image area. */
|
||||
|
||||
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||
+ colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
|
||||
if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin
|
||||
|| s->img->mask || s->img->pixmap == 0 || s->width != s->background_width)
|
||||
@@ -3974,7 +3978,8 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
if (s->hl == DRAW_CURSOR)
|
||||
{
|
||||
[FRAME_CURSOR_COLOR (s->f) set];
|
||||
- tdCol = [[NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background];
|
||||
+ tdCol = [[NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)]
|
||||
+ colorWithAlphaComponent: s->f->alpha_background];
|
||||
}
|
||||
else
|
||||
tdCol = [NSColor colorWithUnsignedLong: NS_FACE_FOREGROUND (face)];
|
||||
@@ -4068,10 +4073,12 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
|
||||
prepare_face_for_display (s->f, face);
|
||||
|
||||
- [[[NSColor colorWithUnsignedLong: face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong: face->background]
|
||||
+ colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
}
|
||||
else
|
||||
- [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong: s->face->background]
|
||||
+ colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
NSRectFill (NSMakeRect (x, y, w, h));
|
||||
}
|
||||
}
|
||||
@@ -4097,7 +4104,8 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
if (s->hl == DRAW_CURSOR)
|
||||
[FRAME_CURSOR_COLOR (s->f) set];
|
||||
else
|
||||
- [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong: s->face->background]
|
||||
+ colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
|
||||
NSRectFill (NSMakeRect (x, s->y, background_width, s->height));
|
||||
}
|
||||
@@ -8438,7 +8446,8 @@ - (void)toggleFullScreen: (id)sender
|
||||
}
|
||||
|
||||
[w setContentView:[fw contentView]];
|
||||
- [w setBackgroundColor: [col colorWithAlphaComponent: f->alpha_background]];
|
||||
+ [w setBackgroundColor: [col colorWithAlphaComponent:
|
||||
+ f->alpha_background]];
|
||||
if (f->alpha_background != (EmacsCGFloat) 1.0)
|
||||
[w setOpaque: NO];
|
||||
|
||||
@@ -9175,7 +9184,8 @@ - (instancetype) initWithEmacsFrame: (struct frame *) f
|
||||
|
||||
col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
|
||||
(FACE_FROM_ID (f, DEFAULT_FACE_ID))];
|
||||
- [self setBackgroundColor:[col colorWithAlphaComponent:f->alpha_background]];
|
||||
+ [self setBackgroundColor:
|
||||
+ [col colorWithAlphaComponent:f->alpha_background]];
|
||||
if (f->alpha_background != (EmacsCGFloat) 1.0)
|
||||
[self setOpaque:NO];
|
||||
|
||||
|
||||
From 896596aac2932ab98dbeb68f48a963275fdb76c5 Mon Sep 17 00:00:00 2001
|
||||
From: Jon Rubens <jonathanrubens@gmail.com>
|
||||
Date: Wed, 31 Jan 2024 13:30:13 -0800
|
||||
Subject: [PATCH 3/3] More code formatting
|
||||
|
||||
---
|
||||
src/nsfns.m | 11 ++++++-----
|
||||
src/nsterm.m | 8 +++++---
|
||||
2 files changed, 11 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/nsfns.m b/src/nsfns.m
|
||||
index 3e19cce89de9..67d8449c70dd 100644
|
||||
--- a/src/nsfns.m
|
||||
+++ b/src/nsfns.m
|
||||
@@ -321,11 +321,6 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||
{
|
||||
[[view window] setBackgroundColor: [col colorWithAlphaComponent: alpha]];
|
||||
|
||||
- if (alpha != (EmacsCGFloat) 1.0)
|
||||
- [[view window] setOpaque: NO];
|
||||
- else
|
||||
- [[view window] setOpaque: YES];
|
||||
-
|
||||
face = FRAME_DEFAULT_FACE (f);
|
||||
if (face)
|
||||
{
|
||||
@@ -369,6 +364,12 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||
f->alpha_background = alpha;
|
||||
[[view window] setBackgroundColor: [f->output_data.ns->background_color
|
||||
colorWithAlphaComponent: alpha]];
|
||||
+
|
||||
+ if (alpha != (EmacsCGFloat) 1.0)
|
||||
+ [[view window] setOpaque: NO];
|
||||
+ else
|
||||
+ [[view window] setOpaque: YES];
|
||||
+
|
||||
recompute_basic_faces (f);
|
||||
SET_FRAME_GARBAGED (f);
|
||||
}
|
||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||
index 9ab3ff8f783f..6feef6236449 100644
|
||||
--- a/src/nsterm.m
|
||||
+++ b/src/nsterm.m
|
||||
@@ -2648,9 +2648,11 @@ Hide the window (X11 semantics)
|
||||
|
||||
r = NSIntersectionRect (r, [view frame]);
|
||||
ns_focus (f, &r, 1);
|
||||
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||
+ colorWithAlphaComponent: f->alpha_background] set];
|
||||
|
||||
NSRectFill (r);
|
||||
+ [[view window] invalidateShadow];
|
||||
|
||||
ns_unfocus (f);
|
||||
return;
|
||||
@@ -2752,7 +2754,8 @@ Hide the window (X11 semantics)
|
||||
return;
|
||||
|
||||
ns_focus (f, NULL, 1);
|
||||
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
|
||||
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||
+ colorWithAlphaComponent: f->alpha_background] set];
|
||||
NSRectFill (NSMakeRect (0, margin, width, border));
|
||||
NSRectFill (NSMakeRect (0, 0, border, height));
|
||||
NSRectFill (NSMakeRect (0, margin, width, border));
|
||||
@@ -4106,7 +4109,6 @@ Function modeled after x_draw_glyph_string_box ().
|
||||
else
|
||||
[[[NSColor colorWithUnsignedLong: s->face->background]
|
||||
colorWithAlphaComponent: s->f->alpha_background] set];
|
||||
-
|
||||
NSRectFill (NSMakeRect (x, s->y, background_width, s->height));
|
||||
}
|
||||
}
|
||||
13
pkg/cask/live_check.go
Normal file
13
pkg/cask/live_check.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package cask
|
||||
|
||||
type LiveCheck struct {
|
||||
Cask string `json:"cask"`
|
||||
Version LiveCheckVersion `json:"version"`
|
||||
}
|
||||
|
||||
type LiveCheckVersion struct {
|
||||
Current string `json:"current"`
|
||||
Latest string `json:"latest"`
|
||||
Outdated bool `json:"outdated"`
|
||||
NewerThanUpstream bool `json:"newer_than_upstream"`
|
||||
}
|
||||
67
pkg/cask/release_info.go
Normal file
67
pkg/cask/release_info.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package cask
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ReleaseInfo struct {
|
||||
Name string
|
||||
Version string
|
||||
Assets map[string]*ReleaseAsset
|
||||
}
|
||||
|
||||
func (s *ReleaseInfo) Asset(needles ...string) *ReleaseAsset {
|
||||
if len(needles) == 1 {
|
||||
if a, ok := s.Assets[needles[0]]; ok {
|
||||
return a
|
||||
}
|
||||
}
|
||||
|
||||
// Dirty and inefficient way to ensure assets are searched in a predictable
|
||||
// order.
|
||||
var assets []*ReleaseAsset
|
||||
for _, a := range s.Assets {
|
||||
assets = append(assets, a)
|
||||
}
|
||||
sort.SliceStable(assets, func(i, j int) bool {
|
||||
return assets[i].Filename < assets[j].Filename
|
||||
})
|
||||
|
||||
assetsLoop:
|
||||
for _, a := range assets {
|
||||
for _, needle := range needles {
|
||||
if !strings.Contains(a.Filename, needle) {
|
||||
continue assetsLoop
|
||||
}
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ReleaseInfo) DownloadURL(needles ...string) string {
|
||||
a := s.Asset(needles...)
|
||||
if a == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return a.DownloadURL
|
||||
}
|
||||
|
||||
func (s *ReleaseInfo) SHA256(needles ...string) string {
|
||||
a := s.Asset(needles...)
|
||||
if a == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return a.SHA256
|
||||
}
|
||||
|
||||
type ReleaseAsset struct {
|
||||
Filename string
|
||||
DownloadURL string
|
||||
SHA256 string
|
||||
}
|
||||
80
pkg/cask/release_info_test.go
Normal file
80
pkg/cask/release_info_test.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package cask
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAsset(t *testing.T) {
|
||||
// Define test cases
|
||||
tests := []struct {
|
||||
name string
|
||||
release ReleaseInfo
|
||||
needles []string
|
||||
want *ReleaseAsset
|
||||
}{
|
||||
{
|
||||
name: "single needle, exact match",
|
||||
release: ReleaseInfo{
|
||||
Assets: map[string]*ReleaseAsset{
|
||||
"asset1": {Filename: "asset1.zip"},
|
||||
"asset2": {Filename: "asset2.zip"},
|
||||
},
|
||||
},
|
||||
needles: []string{"asset1"},
|
||||
want: &ReleaseAsset{Filename: "asset1.zip"},
|
||||
},
|
||||
{
|
||||
name: "multiple needles, all",
|
||||
release: ReleaseInfo{
|
||||
Assets: map[string]*ReleaseAsset{
|
||||
"asset1": {Filename: "asset1.zip"},
|
||||
"asset2": {Filename: "asset2.zip"},
|
||||
},
|
||||
},
|
||||
needles: []string{"zip", "asset1"},
|
||||
want: &ReleaseAsset{Filename: "asset1.zip"},
|
||||
},
|
||||
{
|
||||
name: "multiple needles, one match",
|
||||
release: ReleaseInfo{
|
||||
Assets: map[string]*ReleaseAsset{
|
||||
"asset1": {Filename: "asset1.zip"},
|
||||
"asset2": {Filename: "asset2.zip"},
|
||||
},
|
||||
},
|
||||
needles: []string{"rar", "asset2"},
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "multiple needles, no match",
|
||||
release: ReleaseInfo{
|
||||
Assets: map[string]*ReleaseAsset{
|
||||
"asset1": {Filename: "asset1.zip"},
|
||||
"asset2": {Filename: "asset2.zip"},
|
||||
},
|
||||
},
|
||||
needles: []string{"rar", "asset3"},
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "no needles",
|
||||
release: ReleaseInfo{
|
||||
Assets: map[string]*ReleaseAsset{
|
||||
"asset1": {Filename: "asset1.zip"},
|
||||
"asset2": {Filename: "asset2.zip"},
|
||||
},
|
||||
},
|
||||
needles: nil,
|
||||
want: &ReleaseAsset{Filename: "asset1.zip"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := tt.release.Asset(tt.needles...)
|
||||
|
||||
assert.Equal(t, tt.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
504
pkg/cask/update.go
Normal file
504
pkg/cask/update.go
Normal file
@@ -0,0 +1,504 @@
|
||||
package cask
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-github/v35/github"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hexops/gotextdiff"
|
||||
"github.com/hexops/gotextdiff/myers"
|
||||
"github.com/hexops/gotextdiff/span"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||
)
|
||||
|
||||
// Error vars
|
||||
var (
|
||||
Err = errors.New("cask")
|
||||
ErrReleaseNotFound = fmt.Errorf("%w: release not found", Err)
|
||||
|
||||
ErrFailedSHA256Parse = fmt.Errorf(
|
||||
"%w: failed to parse SHA256 from asset", Err,
|
||||
)
|
||||
ErrFailedSHA256Download = fmt.Errorf(
|
||||
"%w: failed to download SHA256 asset", Err,
|
||||
)
|
||||
ErrNoTapOrOutput = fmt.Errorf(
|
||||
"%w: no tap repository or output directory specified", Err,
|
||||
)
|
||||
)
|
||||
|
||||
type UpdateOptions struct {
|
||||
// BuildsRepo is the GitHub repository containing binary releases.
|
||||
BuildsRepo *repository.Repository
|
||||
|
||||
// TapRepo is the GitHub repository to update the casks in.
|
||||
TapRepo *repository.Repository
|
||||
|
||||
// Ref is the git ref to apply cask updates on top of. Default branch will
|
||||
// be used if empty.
|
||||
Ref string
|
||||
|
||||
// OutputDir specifies a directory to write cask files to. When set, tap
|
||||
// repository is ignored and no changes will be committed directly against
|
||||
// any specified tap repository.
|
||||
OutputDir string
|
||||
|
||||
// Force update will ignore the outdated live check flag, and process all
|
||||
// casks regardless. But it will only update the cask in question if the
|
||||
// resulting output cask is different.
|
||||
Force bool
|
||||
|
||||
// TemplatesDir is the directory where cask templates are located.
|
||||
TemplatesDir string
|
||||
|
||||
LiveChecks []*LiveCheck
|
||||
|
||||
GithubToken string
|
||||
}
|
||||
|
||||
type Updater struct {
|
||||
BuildsRepo *repository.Repository
|
||||
TapRepo *repository.Repository
|
||||
Ref string
|
||||
OutputDir string
|
||||
TemplatesDir string
|
||||
|
||||
logger hclog.Logger
|
||||
gh *github.Client
|
||||
}
|
||||
|
||||
func Update(ctx context.Context, opts *UpdateOptions) error {
|
||||
updater := &Updater{
|
||||
BuildsRepo: opts.BuildsRepo,
|
||||
TapRepo: opts.TapRepo,
|
||||
Ref: opts.Ref,
|
||||
OutputDir: opts.OutputDir,
|
||||
TemplatesDir: opts.TemplatesDir,
|
||||
logger: hclog.FromContext(ctx).Named("cask"),
|
||||
gh: gh.New(ctx, opts.GithubToken),
|
||||
}
|
||||
|
||||
for _, chk := range opts.LiveChecks {
|
||||
err := updater.Update(ctx, chk, opts.Force)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Updater) Update(
|
||||
ctx context.Context,
|
||||
chk *LiveCheck,
|
||||
force bool,
|
||||
) error {
|
||||
if s.TapRepo == nil && s.OutputDir == "" {
|
||||
return ErrNoTapOrOutput
|
||||
}
|
||||
|
||||
if !force && !chk.Version.Outdated {
|
||||
s.logger.Info("skipping", "cask", chk.Cask, "reason", "up to date")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
newCaskContent, err := s.renderCask(ctx, chk)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
caskFile := chk.Cask + ".rb"
|
||||
|
||||
if s.OutputDir != "" {
|
||||
_, err = s.putFile(
|
||||
ctx, chk, filepath.Join(s.OutputDir, caskFile), newCaskContent,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err = s.putRepoFile(
|
||||
ctx, s.TapRepo, s.Ref, chk,
|
||||
filepath.Join("Casks", caskFile), newCaskContent,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Updater) putFile(
|
||||
_ context.Context,
|
||||
chk *LiveCheck,
|
||||
filename string,
|
||||
content []byte,
|
||||
) (bool, error) {
|
||||
parent := filepath.Dir(filename)
|
||||
s.logger.Info("processing cask update",
|
||||
"output-directory", parent, "cask", chk.Cask, "file", filename,
|
||||
)
|
||||
|
||||
err := os.MkdirAll(parent, 0o755)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
existingContent, err := os.ReadFile(filename)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
infoMsg := "creating cask"
|
||||
|
||||
if !os.IsNotExist(err) {
|
||||
infoMsg = "updating cask"
|
||||
if bytes.Equal(existingContent, content) {
|
||||
s.logger.Info(
|
||||
"skip update: no change to cask content",
|
||||
"cask", chk.Cask, "file", filename,
|
||||
)
|
||||
|
||||
s.logger.Debug(
|
||||
"cask content",
|
||||
"file", filename, "content", string(content),
|
||||
)
|
||||
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
existing := string(existingContent)
|
||||
edits := myers.ComputeEdits(
|
||||
span.URIFromPath(filename), existing, string(content),
|
||||
)
|
||||
diff := fmt.Sprint(gotextdiff.ToUnified(
|
||||
filename, filename, existing, edits,
|
||||
))
|
||||
|
||||
s.logger.Info(
|
||||
infoMsg,
|
||||
"cask", chk.Cask, "version", chk.Version.Latest, "file", filename,
|
||||
"diff", diff,
|
||||
)
|
||||
|
||||
s.logger.Debug(
|
||||
"cask content",
|
||||
"file", filename, "content", string(content),
|
||||
)
|
||||
|
||||
err = os.WriteFile(filename, content, 0o644) //nolint:gosec
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (s *Updater) putRepoFile(
|
||||
ctx context.Context,
|
||||
repo *repository.Repository,
|
||||
ref string,
|
||||
chk *LiveCheck,
|
||||
filename string,
|
||||
content []byte,
|
||||
) (bool, error) {
|
||||
s.logger.Info("processing cask update",
|
||||
"tap-repo", repo.Source, "cask", chk.Cask, "file", filename,
|
||||
)
|
||||
repoContent, _, resp, err := s.gh.Repositories.GetContents(
|
||||
ctx, repo.Owner(), repo.Name(), filename,
|
||||
&github.RepositoryContentGetOptions{Ref: ref},
|
||||
)
|
||||
if err != nil && resp.StatusCode != http.StatusNotFound {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
err := s.createRepoFile(ctx, repo, chk, filename, content)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
} else {
|
||||
_, err := s.updateRepoFile(
|
||||
ctx, repo, repoContent, chk, filename, content,
|
||||
)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (s *Updater) createRepoFile(
|
||||
ctx context.Context,
|
||||
repo *repository.Repository,
|
||||
chk *LiveCheck,
|
||||
filename string,
|
||||
content []byte,
|
||||
) error {
|
||||
commitMsg := fmt.Sprintf(
|
||||
"feat(cask): create %s with version %s",
|
||||
chk.Cask, chk.Version.Latest,
|
||||
)
|
||||
|
||||
edits := myers.ComputeEdits(
|
||||
span.URIFromPath(filename), "", string(content),
|
||||
)
|
||||
diff := fmt.Sprint(gotextdiff.ToUnified(filename, filename, "", edits))
|
||||
|
||||
s.logger.Info(
|
||||
"creating cask",
|
||||
"cask", chk.Cask, "version", chk.Version.Latest, "file", filename,
|
||||
"diff", diff,
|
||||
)
|
||||
s.logger.Debug(
|
||||
"cask content",
|
||||
"file", filename, "content", string(content),
|
||||
)
|
||||
contResp, _, err := s.gh.Repositories.CreateFile(
|
||||
ctx, repo.Owner(), repo.Name(), filename,
|
||||
&github.RepositoryContentFileOptions{
|
||||
Message: &commitMsg,
|
||||
Content: content,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.logger.Info(
|
||||
"new commit created",
|
||||
"commit", contResp.GetSHA(), "message", contResp.GetMessage(),
|
||||
"url", contResp.Commit.GetHTMLURL(),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Updater) updateRepoFile(
|
||||
ctx context.Context,
|
||||
repo *repository.Repository,
|
||||
repoContent *github.RepositoryContent,
|
||||
chk *LiveCheck,
|
||||
filename string,
|
||||
content []byte,
|
||||
) (bool, error) {
|
||||
existingContent, err := repoContent.GetContent()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if existingContent == string(content) {
|
||||
s.logger.Info(
|
||||
"skip update: no change to cask content",
|
||||
"cask", chk.Cask, "file", filename,
|
||||
)
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
sha := repoContent.GetSHA()
|
||||
|
||||
commitMsg := fmt.Sprintf(
|
||||
"feat(cask): update %s to version %s",
|
||||
chk.Cask, chk.Version.Latest,
|
||||
)
|
||||
|
||||
edits := myers.ComputeEdits(
|
||||
span.URIFromPath(filename), existingContent, string(content),
|
||||
)
|
||||
diff := fmt.Sprint(gotextdiff.ToUnified(
|
||||
filename, filename, existingContent, edits,
|
||||
))
|
||||
|
||||
s.logger.Info(
|
||||
"updating cask",
|
||||
"cask", chk.Cask, "version", chk.Version.Latest, "file", filename,
|
||||
"diff", diff,
|
||||
)
|
||||
s.logger.Debug(
|
||||
"cask content",
|
||||
"file", filename, "content", string(content),
|
||||
)
|
||||
|
||||
contResp, _, err := s.gh.Repositories.CreateFile(
|
||||
ctx, repo.Owner(), repo.Name(), filename,
|
||||
&github.RepositoryContentFileOptions{
|
||||
Message: &commitMsg,
|
||||
Content: content,
|
||||
SHA: &sha,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
s.logger.Info(
|
||||
"new commit created",
|
||||
"commit", contResp.GetSHA(), "message", contResp.GetMessage(),
|
||||
"url", contResp.Commit.GetHTMLURL(),
|
||||
)
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
//nolint:funlen
|
||||
func (s *Updater) renderCask(
|
||||
ctx context.Context,
|
||||
chk *LiveCheck,
|
||||
) ([]byte, error) {
|
||||
releaseName, err := release.VersionToName(chk.Version.Latest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.logger.Info("fetching release details",
|
||||
"release", releaseName, "repo", s.BuildsRepo.URL(),
|
||||
)
|
||||
release, resp, err := s.gh.Repositories.GetReleaseByTag(
|
||||
ctx, s.BuildsRepo.Owner(), s.BuildsRepo.Name(), releaseName,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if release == nil || resp.StatusCode == http.StatusNotFound {
|
||||
return nil, fmt.Errorf("%w: %s", ErrReleaseNotFound, releaseName)
|
||||
}
|
||||
|
||||
info := &ReleaseInfo{
|
||||
Name: release.GetName(),
|
||||
Version: chk.Version.Latest,
|
||||
Assets: map[string]*ReleaseAsset{},
|
||||
}
|
||||
|
||||
s.logger.Info("processing release assets")
|
||||
for _, asset := range release.Assets {
|
||||
filename := asset.GetName()
|
||||
s.logger.Debug("processing asset", "filename", filename)
|
||||
|
||||
filename = strings.TrimSuffix(filename, ".sha256")
|
||||
|
||||
if _, ok := info.Assets[filename]; !ok {
|
||||
info.Assets[filename] = &ReleaseAsset{
|
||||
Filename: filename,
|
||||
}
|
||||
}
|
||||
|
||||
if strings.HasSuffix(asset.GetName(), ".sha256") {
|
||||
s.logger.Debug("downloading *.sha256 asset to extract SHA256 value")
|
||||
r, err2 := s.downloadAssetContent(ctx, asset)
|
||||
if err2 != nil {
|
||||
return nil, err2
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
content := make([]byte, 64)
|
||||
n, err2 := io.ReadAtLeast(r, content, 64)
|
||||
if err2 != nil {
|
||||
return nil, err2
|
||||
}
|
||||
if n < 64 {
|
||||
return nil, fmt.Errorf(
|
||||
"%w: %s", ErrFailedSHA256Parse, asset.GetName(),
|
||||
)
|
||||
}
|
||||
|
||||
sha := string(content)[0:64]
|
||||
if sha == "" {
|
||||
return nil, fmt.Errorf(
|
||||
"%w: %s", ErrFailedSHA256Parse, asset.GetName(),
|
||||
)
|
||||
}
|
||||
|
||||
info.Assets[filename].SHA256 = sha
|
||||
} else {
|
||||
info.Assets[filename].DownloadURL = asset.GetBrowserDownloadURL()
|
||||
}
|
||||
}
|
||||
|
||||
tplContent, err := os.ReadFile(
|
||||
filepath.Join(s.TemplatesDir, chk.Cask+".rb.tpl"),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
helperContent, err := os.ReadFile(
|
||||
filepath.Join(s.TemplatesDir, "_helpers.tpl"),
|
||||
)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(helperContent) > 0 {
|
||||
tplContent = append(helperContent, tplContent...)
|
||||
}
|
||||
|
||||
tpl, err := template.New(chk.Cask).Parse(string(tplContent))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
err = tpl.Execute(&buf, info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func (s *Updater) downloadAssetContent(
|
||||
ctx context.Context,
|
||||
asset *github.ReleaseAsset,
|
||||
) (io.ReadCloser, error) {
|
||||
httpClient := &http.Client{Timeout: 60 * time.Second}
|
||||
|
||||
r, downloadURL, err := s.gh.Repositories.DownloadReleaseAsset(
|
||||
ctx, s.BuildsRepo.Owner(), s.BuildsRepo.Name(),
|
||||
asset.GetID(), httpClient,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if r == nil && downloadURL != "" {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", downloadURL, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//nolint:bodyclose
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r = resp.Body
|
||||
}
|
||||
|
||||
if r == nil {
|
||||
return nil, fmt.Errorf(
|
||||
"%s: %s", ErrFailedSHA256Download, asset.GetName(),
|
||||
)
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
158
pkg/cli/cask.go
Normal file
158
pkg/cli/cask.go
Normal file
@@ -0,0 +1,158 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/cask"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||
cli2 "github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
type caskOptions struct {
|
||||
BuildsRepo *repository.Repository
|
||||
GithubToken string
|
||||
}
|
||||
|
||||
func caskCmd() *cli2.Command {
|
||||
tokenDefaultText := ""
|
||||
if len(os.Getenv("GITHUB_TOKEN")) > 0 {
|
||||
tokenDefaultText = "***"
|
||||
}
|
||||
|
||||
return &cli2.Command{
|
||||
Name: "cask",
|
||||
Usage: "manage Homebrew Casks",
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "builds-repository",
|
||||
Aliases: []string{"builds-repo", "b"},
|
||||
Usage: "owner/name of GitHub repo for containing builds",
|
||||
EnvVars: []string{"EMACS_BUILDS_REPOSITORY"},
|
||||
Value: "jimeh/emacs-builds",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "github-token",
|
||||
Usage: "GitHub API Token",
|
||||
EnvVars: []string{"GITHUB_TOKEN"},
|
||||
DefaultText: tokenDefaultText,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
Subcommands: []*cli2.Command{
|
||||
caskUpdateCmd(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func caskActionWrapper(
|
||||
f func(*cli2.Context, *Options, *caskOptions) error,
|
||||
) func(*cli2.Context) error {
|
||||
return actionWrapper(func(c *cli2.Context, opts *Options) error {
|
||||
rOpts := &caskOptions{
|
||||
GithubToken: c.String("github-token"),
|
||||
}
|
||||
|
||||
if r := c.String("builds-repository"); r != "" {
|
||||
var err error
|
||||
rOpts.BuildsRepo, err = repository.NewGitHub(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return f(c, opts, rOpts)
|
||||
})
|
||||
}
|
||||
|
||||
func caskUpdateCmd() *cli2.Command {
|
||||
return &cli2.Command{
|
||||
Name: "update",
|
||||
Usage: "update casks based on brew livecheck result in JSON format",
|
||||
ArgsUsage: "<livecheck.json>",
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "ref",
|
||||
Usage: "git ref to create/update casks on top of in the " +
|
||||
"tap repository",
|
||||
EnvVars: []string{"GITHUB_REF"},
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "output",
|
||||
Aliases: []string{"o"},
|
||||
Usage: "directory to write cask files to",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "tap-repository",
|
||||
Aliases: []string{"tap"},
|
||||
Usage: "owner/name of GitHub repo for Homebrew Tap to " +
|
||||
"commit changes to if --output is not set",
|
||||
EnvVars: []string{"GITHUB_REPOSITORY"},
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "templates-dir",
|
||||
Aliases: []string{"t"},
|
||||
Usage: "path to directory of cask templates",
|
||||
EnvVars: []string{"CASK_TEMPLATE_DIR"},
|
||||
Required: true,
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "force",
|
||||
Aliases: []string{"f"},
|
||||
Usage: "force update file even if livecheck has it marked " +
|
||||
"as not outdated (does not force update if cask " +
|
||||
"content is unchanged)",
|
||||
Value: false,
|
||||
},
|
||||
},
|
||||
Action: caskActionWrapper(caskUpdateAction),
|
||||
}
|
||||
}
|
||||
|
||||
func caskUpdateAction(
|
||||
c *cli2.Context,
|
||||
_ *Options,
|
||||
cOpts *caskOptions,
|
||||
) error {
|
||||
updateOpts := &cask.UpdateOptions{
|
||||
BuildsRepo: cOpts.BuildsRepo,
|
||||
GithubToken: cOpts.GithubToken,
|
||||
Ref: c.String("ref"),
|
||||
OutputDir: c.String("output"),
|
||||
Force: c.Bool("force"),
|
||||
TemplatesDir: c.String("templates-dir"),
|
||||
}
|
||||
|
||||
if r := c.String("tap-repository"); r != "" {
|
||||
var err error
|
||||
updateOpts.TapRepo, err = repository.NewGitHub(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
arg := c.Args().First()
|
||||
if arg == "" {
|
||||
return errors.New("no livecheck argument given")
|
||||
}
|
||||
|
||||
if arg == "-" {
|
||||
err := json.NewDecoder(c.App.Reader).Decode(&updateOpts.LiveChecks)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
f, err := os.Open(arg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = json.NewDecoder(f).Decode(&updateOpts.LiveChecks)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return cask.Update(c.Context, updateOpts)
|
||||
}
|
||||
96
pkg/cli/cli.go
Normal file
96
pkg/cli/cli.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
cli2 "github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
type CLI struct {
|
||||
App *cli2.App
|
||||
Version string
|
||||
Commit string
|
||||
Date string
|
||||
}
|
||||
|
||||
func New(version, commit, date string) *CLI {
|
||||
if version == "" {
|
||||
version = "0.0.0-dev"
|
||||
}
|
||||
|
||||
c := &CLI{
|
||||
Version: version,
|
||||
Commit: commit,
|
||||
Date: date,
|
||||
App: &cli2.App{
|
||||
Name: "emacs-builder",
|
||||
Usage: "Tool to build emacs",
|
||||
Version: version,
|
||||
EnableBashCompletion: true,
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "log-level",
|
||||
Usage: "set log level",
|
||||
Aliases: []string{"l"},
|
||||
Value: "info",
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "quiet",
|
||||
Usage: "silence noisy output",
|
||||
Aliases: []string{"q"},
|
||||
Value: false,
|
||||
},
|
||||
cli2.VersionFlag,
|
||||
},
|
||||
Commands: []*cli2.Command{
|
||||
planCmd(),
|
||||
signCmd(),
|
||||
signFilesCmd(),
|
||||
notarizeCmd(),
|
||||
packageCmd(),
|
||||
releaseCmd(),
|
||||
caskCmd(),
|
||||
{
|
||||
Name: "version",
|
||||
Usage: "print the version",
|
||||
Aliases: []string{"v"},
|
||||
Action: func(c *cli2.Context) error {
|
||||
cli2.VersionPrinter(c)
|
||||
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cli2.VersionPrinter = c.VersionPrinter
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (s *CLI) VersionPrinter(c *cli2.Context) {
|
||||
version := c.App.Version
|
||||
if version == "" {
|
||||
version = "0.0.0-dev"
|
||||
}
|
||||
|
||||
extra := []string{}
|
||||
if len(s.Commit) >= 7 {
|
||||
extra = append(extra, s.Commit[0:7])
|
||||
}
|
||||
if s.Date != "" {
|
||||
extra = append(extra, s.Date)
|
||||
}
|
||||
var extraOut string
|
||||
if len(extra) > 0 {
|
||||
extraOut += " (" + strings.Join(extra, ", ") + ")"
|
||||
}
|
||||
|
||||
fmt.Printf("%s%s\n", version, extraOut)
|
||||
}
|
||||
|
||||
func (s *CLI) Run(args []string) error {
|
||||
return s.App.Run(args)
|
||||
}
|
||||
79
pkg/cli/notarize.go
Normal file
79
pkg/cli/notarize.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/notarize"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/plan"
|
||||
cli2 "github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func notarizeCmd() *cli2.Command {
|
||||
return &cli2.Command{
|
||||
Name: "notarize",
|
||||
Usage: "notarize and staple a dmg, zip, or pkg",
|
||||
ArgsUsage: "<file>",
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "bundle-id",
|
||||
Usage: "bundle identifier",
|
||||
Value: "org.gnu.Emacs",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "ac-username",
|
||||
Usage: "Apple Connect username",
|
||||
EnvVars: []string{"AC_USERNAME"},
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "ac-password",
|
||||
Usage: "Apple Connect password",
|
||||
EnvVars: []string{"AC_PASSWORD"},
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "ac-provider",
|
||||
Usage: "Apple Connect provider",
|
||||
EnvVars: []string{"AC_PROVIDER"},
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "staple",
|
||||
Usage: "staple file after notarization",
|
||||
Value: true,
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "plan",
|
||||
Usage: "path to build plan YAML file produced by " +
|
||||
"emacs-builder plan",
|
||||
Aliases: []string{"p"},
|
||||
EnvVars: []string{"EMACS_BUILDER_PLAN"},
|
||||
TakesFile: true,
|
||||
},
|
||||
},
|
||||
Action: actionWrapper(notarizeAction),
|
||||
}
|
||||
}
|
||||
|
||||
func notarizeAction(c *cli2.Context, _ *Options) error {
|
||||
options := ¬arize.Options{
|
||||
File: c.Args().Get(0),
|
||||
BundleID: c.String("bundle-id"),
|
||||
Username: c.String("ac-username"),
|
||||
Password: c.String("ac-password"),
|
||||
Provider: c.String("ac-provider"),
|
||||
Staple: c.Bool("staple"),
|
||||
}
|
||||
|
||||
if f := c.String("plan"); f != "" {
|
||||
p, err := plan.Load(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if p.Output != nil {
|
||||
options.File = filepath.Join(
|
||||
p.Output.Directory, p.Output.DiskImage,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return notarize.Notarize(c.Context, options)
|
||||
}
|
||||
49
pkg/cli/options.go
Normal file
49
pkg/cli/options.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
cli2 "github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
quiet bool
|
||||
}
|
||||
|
||||
func actionWrapper(
|
||||
f func(*cli2.Context, *Options) error,
|
||||
) func(*cli2.Context) error {
|
||||
return func(c *cli2.Context) error {
|
||||
opts := &Options{
|
||||
quiet: c.Bool("quiet"),
|
||||
}
|
||||
|
||||
levelStr := c.String("log-level")
|
||||
level := hclog.LevelFromString(levelStr)
|
||||
if level == hclog.NoLevel {
|
||||
return fmt.Errorf("invalid log level \"%s\"", levelStr)
|
||||
}
|
||||
|
||||
// Prevent things from logging if they weren't explicitly given a
|
||||
// logger.
|
||||
hclog.SetDefault(hclog.NewNullLogger())
|
||||
|
||||
// Create custom logger.
|
||||
logr := hclog.New(&hclog.LoggerOptions{
|
||||
Level: level,
|
||||
Output: os.Stderr,
|
||||
Mutex: &sync.Mutex{},
|
||||
TimeFormat: time.RFC3339,
|
||||
Color: hclog.ColorOff,
|
||||
})
|
||||
|
||||
ctx := hclog.WithContext(c.Context, logr)
|
||||
c.Context = ctx
|
||||
|
||||
return f(c, opts)
|
||||
}
|
||||
}
|
||||
230
pkg/cli/package.go
Normal file
230
pkg/cli/package.go
Normal file
@@ -0,0 +1,230 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/dmg"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/notarize"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/plan"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/sign"
|
||||
cli2 "github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func packageCmd() *cli2.Command {
|
||||
return &cli2.Command{
|
||||
Name: "package",
|
||||
Usage: "package a build directory containing Emacs.app into a dmg",
|
||||
ArgsUsage: "<source-dir>",
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "volume-name",
|
||||
Usage: "set volume name, defaults to basename of source dir",
|
||||
Aliases: []string{"n"},
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "sign",
|
||||
Usage: "sign Emacs.app before packaging, notarize and staple " +
|
||||
"dmg after packaging",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "output",
|
||||
Usage: "specify output dmg file name, if not specified the " +
|
||||
"output filename is based on source directory",
|
||||
Aliases: []string{"o"},
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "sha256",
|
||||
Usage: "create .sha256 checksum file for output dmg",
|
||||
Aliases: []string{"s"},
|
||||
Value: true,
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "remove-source-dir",
|
||||
Usage: "remove source directory after successfully " +
|
||||
"creating dmg",
|
||||
Aliases: []string{"rm"},
|
||||
Value: false,
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "verbose",
|
||||
Usage: "verbose output",
|
||||
Aliases: []string{"v"},
|
||||
Value: false,
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "dmgbuild",
|
||||
Usage: "specify custom path to dmgbuild executable",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "sign-identity",
|
||||
Usage: "(with --sign) signing identity passed to codesign",
|
||||
EnvVars: []string{"AC_SIGN_IDENTITY"},
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "bundle-id",
|
||||
Usage: "(with --sign) bundle identifier",
|
||||
Value: "org.gnu.Emacs",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "ac-username",
|
||||
Usage: "(with --sign) Apple Connect username",
|
||||
EnvVars: []string{"AC_USERNAME"},
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "ac-password",
|
||||
Usage: "(with --sign) Apple Connect password",
|
||||
EnvVars: []string{"AC_PASSWORD"},
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "ac-provider",
|
||||
Usage: "(with --sign) Apple Connect provider",
|
||||
EnvVars: []string{"AC_PROVIDER"},
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "staple",
|
||||
Usage: "(with --sign) stable after notarization",
|
||||
Value: true,
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "plan",
|
||||
Usage: "path to build plan YAML file produced by " +
|
||||
"emacs-builder plan",
|
||||
Aliases: []string{"p"},
|
||||
EnvVars: []string{"EMACS_BUILDER_PLAN"},
|
||||
TakesFile: true,
|
||||
},
|
||||
},
|
||||
Action: actionWrapper(packageAction),
|
||||
}
|
||||
}
|
||||
|
||||
//nolint:funlen
|
||||
func packageAction(c *cli2.Context, opts *Options) error {
|
||||
logger := hclog.FromContext(c.Context).Named("package")
|
||||
|
||||
sourceDir := c.Args().Get(0)
|
||||
doSign := c.Bool("sign")
|
||||
|
||||
var p *plan.Plan
|
||||
var err error
|
||||
if f := c.String("plan"); f != "" {
|
||||
p, err = plan.Load(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if doSign {
|
||||
app := filepath.Join(sourceDir, "Emacs.app")
|
||||
|
||||
signOpts := &sign.Options{
|
||||
Identity: c.String("sign-identity"),
|
||||
Options: []string{"runtime"},
|
||||
Deep: true,
|
||||
Timestamp: true,
|
||||
Force: true,
|
||||
Verbose: c.Bool("verbose"),
|
||||
}
|
||||
|
||||
if p != nil {
|
||||
if p.Output != nil && p.Build != nil {
|
||||
app = filepath.Join(
|
||||
p.Output.Directory, p.Build.Name, "Emacs.app",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if !opts.quiet {
|
||||
signOpts.Output = os.Stdout
|
||||
}
|
||||
|
||||
err = sign.Emacs(c.Context, app, signOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
dmgOpts := &dmg.Options{
|
||||
DMGBuild: c.String("dmgbuild"),
|
||||
SourceDir: sourceDir,
|
||||
VolumeName: c.String("volume-name"),
|
||||
OutputFile: c.String("output"),
|
||||
RemoveSourceDir: c.Bool("remove-source-dir"),
|
||||
Verbose: c.Bool("verbose"),
|
||||
}
|
||||
|
||||
if p != nil && p.Output != nil && p.Build != nil {
|
||||
dmgOpts.SourceDir = filepath.Join(
|
||||
p.Output.Directory, p.Build.Name,
|
||||
)
|
||||
dmgOpts.VolumeName = p.Build.Name
|
||||
dmgOpts.OutputFile = filepath.Join(
|
||||
p.Output.Directory, p.Output.DiskImage,
|
||||
)
|
||||
}
|
||||
|
||||
if !opts.quiet {
|
||||
dmgOpts.Output = os.Stdout
|
||||
}
|
||||
|
||||
outputDMG, err := dmg.Create(c.Context, dmgOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if doSign {
|
||||
notarizeOpts := ¬arize.Options{
|
||||
File: outputDMG,
|
||||
BundleID: c.String("bundle-id"),
|
||||
Username: c.String("ac-username"),
|
||||
Password: c.String("ac-password"),
|
||||
Provider: c.String("ac-provider"),
|
||||
Staple: c.Bool("staple"),
|
||||
}
|
||||
|
||||
err = notarize.Notarize(c.Context, notarizeOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if c.Bool("sha256") {
|
||||
sumFile := outputDMG + ".sha256"
|
||||
|
||||
logger.Info("generating SHA256 checksum", "file", outputDMG)
|
||||
sum, err := fileSHA256(outputDMG)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Info("checksum", "sha256", sum, "file", outputDMG)
|
||||
content := fmt.Sprintf("%s %s", sum, filepath.Base(outputDMG))
|
||||
err = os.WriteFile(sumFile, []byte(content), 0o644) //nolint:gosec
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger.Info("wrote checksum", "file", sumFile)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func fileSHA256(filename string) (string, error) {
|
||||
f, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
h := sha256.New()
|
||||
if _, err := io.Copy(h, f); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%x", h.Sum(nil)), nil
|
||||
}
|
||||
146
pkg/cli/plan.go
Normal file
146
pkg/cli/plan.go
Normal file
@@ -0,0 +1,146 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/plan"
|
||||
cli2 "github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func planCmd() *cli2.Command {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
wd = ""
|
||||
}
|
||||
|
||||
tokenDefaultText := ""
|
||||
if len(os.Getenv("GITHUB_TOKEN")) > 0 {
|
||||
tokenDefaultText = "***"
|
||||
}
|
||||
|
||||
return &cli2.Command{
|
||||
Name: "plan",
|
||||
Usage: "plan a Emacs.app bundle with codeplan",
|
||||
ArgsUsage: "<branch/tag>",
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "emacs-repo",
|
||||
Usage: "GitHub repository to get Emacs commit info and " +
|
||||
"tarball from",
|
||||
Aliases: []string{"e"},
|
||||
EnvVars: []string{"EMACS_REPO"},
|
||||
Value: "emacs-mirror/emacs",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "sha",
|
||||
Usage: "override commit SHA of specified git branch/tag",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "format",
|
||||
Aliases: []string{"f"},
|
||||
Usage: "output format of build plan (yaml or json)",
|
||||
Value: "yaml",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "output",
|
||||
Usage: "output filename to write plan to instead of printing " +
|
||||
"to STDOUT",
|
||||
Aliases: []string{"o"},
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "output-dir",
|
||||
Usage: "output directory where build result is stored",
|
||||
Value: filepath.Join(wd, "builds"),
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "test-build",
|
||||
Usage: "plan a test build with given name, which is " +
|
||||
"published to a draft or pre-release " +
|
||||
"\"test-builds\" release",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "test-release-type",
|
||||
Value: "prerelease",
|
||||
Usage: "type of release when doing a test-build " +
|
||||
"(prerelease or draft)",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "github-token",
|
||||
Usage: "GitHub API Token",
|
||||
EnvVars: []string{"GITHUB_TOKEN"},
|
||||
DefaultText: tokenDefaultText,
|
||||
},
|
||||
},
|
||||
Action: actionWrapper(planAction),
|
||||
}
|
||||
}
|
||||
|
||||
func planAction(c *cli2.Context, opts *Options) error {
|
||||
logger := hclog.FromContext(c.Context).Named("plan")
|
||||
|
||||
ref := c.Args().Get(0)
|
||||
if ref == "" {
|
||||
ref = "master"
|
||||
}
|
||||
|
||||
planOpts := &plan.Options{
|
||||
EmacsRepo: c.String("emacs-repo"),
|
||||
Ref: ref,
|
||||
SHAOverride: c.String("sha"),
|
||||
OutputDir: c.String("output-dir"),
|
||||
TestBuild: c.String("test-build"),
|
||||
TestBuildType: plan.Prerelease,
|
||||
GithubToken: c.String("github-token"),
|
||||
}
|
||||
|
||||
if c.String("test-release-type") == "draft" {
|
||||
planOpts.TestBuildType = plan.Draft
|
||||
}
|
||||
|
||||
if !opts.quiet {
|
||||
planOpts.Output = os.Stdout
|
||||
}
|
||||
|
||||
p, err := plan.Create(c.Context, planOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
format := c.String("format")
|
||||
var plan string
|
||||
switch format {
|
||||
case "yaml", "yml":
|
||||
format = "yaml"
|
||||
plan, err = p.YAML()
|
||||
case "json":
|
||||
format = "json"
|
||||
plan, err = p.JSON()
|
||||
default:
|
||||
err = fmt.Errorf("--format must be yaml or json")
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var out *os.File
|
||||
out = os.Stdout
|
||||
if f := c.String("output"); f != "" {
|
||||
logger.Info("writing plan", "file", f)
|
||||
logger.Debug("content", format, plan)
|
||||
out, err = os.Create(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
}
|
||||
|
||||
_, err = out.WriteString(plan)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
277
pkg/cli/release.go
Normal file
277
pkg/cli/release.go
Normal file
@@ -0,0 +1,277 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/plan"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||
cli2 "github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
type releaseOptions struct {
|
||||
Plan *plan.Plan
|
||||
Repository *repository.Repository
|
||||
Name string
|
||||
GithubToken string
|
||||
}
|
||||
|
||||
func releaseCmd() *cli2.Command {
|
||||
tokenDefaultText := ""
|
||||
if len(os.Getenv("GITHUB_TOKEN")) > 0 {
|
||||
tokenDefaultText = "***"
|
||||
}
|
||||
|
||||
return &cli2.Command{
|
||||
Name: "release",
|
||||
Usage: "manage GitHub releases",
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "plan",
|
||||
Usage: "path to build plan YAML file produced by " +
|
||||
"emacs-builder plan",
|
||||
Aliases: []string{"p"},
|
||||
EnvVars: []string{"EMACS_BUILDER_PLAN"},
|
||||
TakesFile: true,
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "repository",
|
||||
Aliases: []string{"repo", "r"},
|
||||
Usage: "owner/name of GitHub repo to check for release, " +
|
||||
"ignored if a plan is provided",
|
||||
EnvVars: []string{"GITHUB_REPOSITORY"},
|
||||
Value: "",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "name",
|
||||
Aliases: []string{"n"},
|
||||
Usage: "name of release to operate on, ignored if plan " +
|
||||
"is provided",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "github-token",
|
||||
Usage: "GitHub API Token",
|
||||
EnvVars: []string{"GITHUB_TOKEN"},
|
||||
DefaultText: tokenDefaultText,
|
||||
},
|
||||
},
|
||||
Subcommands: []*cli2.Command{
|
||||
releaseCheckCmd(),
|
||||
releasePublishCmd(),
|
||||
releaseBulkCmd(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func releaseActionWrapper(
|
||||
f func(*cli2.Context, *Options, *releaseOptions) error,
|
||||
) func(*cli2.Context) error {
|
||||
return actionWrapper(func(c *cli2.Context, opts *Options) error {
|
||||
rOpts := &releaseOptions{
|
||||
Name: c.String("name"),
|
||||
GithubToken: c.String("github-token"),
|
||||
}
|
||||
|
||||
if r := c.String("repository"); r != "" {
|
||||
var err error
|
||||
rOpts.Repository, err = repository.NewGitHub(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if f := c.String("plan"); f != "" {
|
||||
p, err := plan.Load(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rOpts.Plan = p
|
||||
}
|
||||
|
||||
return f(c, opts, rOpts)
|
||||
})
|
||||
}
|
||||
|
||||
func releaseCheckCmd() *cli2.Command {
|
||||
return &cli2.Command{
|
||||
Name: "check",
|
||||
Usage: "check if a GitHub release exists and has specified " +
|
||||
"asset files",
|
||||
ArgsUsage: "[<asset-file> ...]",
|
||||
Action: releaseActionWrapper(releaseCheckAction),
|
||||
}
|
||||
}
|
||||
|
||||
func releaseCheckAction(
|
||||
c *cli2.Context,
|
||||
_ *Options,
|
||||
rOpts *releaseOptions,
|
||||
) error {
|
||||
rlsOpts := &release.CheckOptions{
|
||||
Repository: rOpts.Repository,
|
||||
ReleaseName: rOpts.Name,
|
||||
AssetFiles: c.Args().Slice(),
|
||||
GithubToken: rOpts.GithubToken,
|
||||
}
|
||||
|
||||
if rOpts.Plan != nil && rOpts.Plan.Release != nil {
|
||||
rlsOpts.ReleaseName = rOpts.Plan.Release.Name
|
||||
}
|
||||
if rOpts.Plan != nil && rOpts.Plan.Output != nil {
|
||||
rlsOpts.AssetFiles = []string{rOpts.Plan.Output.DiskImage}
|
||||
}
|
||||
|
||||
return release.Check(c.Context, rlsOpts)
|
||||
}
|
||||
|
||||
func releasePublishCmd() *cli2.Command {
|
||||
return &cli2.Command{
|
||||
Name: "publish",
|
||||
Usage: "publish a GitHub release with specified asset " +
|
||||
"files",
|
||||
ArgsUsage: "[<asset-file> ...]",
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "sha",
|
||||
Aliases: []string{"s"},
|
||||
Usage: "git SHA to create release on",
|
||||
EnvVars: []string{"GITHUB_SHA"},
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "type",
|
||||
Aliases: []string{"t"},
|
||||
Usage: "release type, must be normal, prerelease, or draft",
|
||||
Value: "normal",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "title",
|
||||
Usage: "release title, will use release name if not " +
|
||||
"specified",
|
||||
Value: "",
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "asset-size-check",
|
||||
Usage: "Do not replace existing asset files if local and " +
|
||||
"remote file sizes match.",
|
||||
Value: false,
|
||||
},
|
||||
},
|
||||
Action: releaseActionWrapper(releasePublishAction),
|
||||
}
|
||||
}
|
||||
|
||||
func releasePublishAction(
|
||||
c *cli2.Context,
|
||||
_ *Options,
|
||||
rOpts *releaseOptions,
|
||||
) error {
|
||||
rlsOpts := &release.PublishOptions{
|
||||
Repository: rOpts.Repository,
|
||||
CommitRef: c.String("release-sha"),
|
||||
ReleaseName: rOpts.Name,
|
||||
ReleaseTitle: c.String("title"),
|
||||
AssetFiles: c.Args().Slice(),
|
||||
AssetSizeCheck: c.Bool("asset-size-check"),
|
||||
GithubToken: rOpts.GithubToken,
|
||||
}
|
||||
|
||||
rlsType := c.String("type")
|
||||
switch rlsType {
|
||||
case "draft":
|
||||
rlsOpts.ReleaseType = release.Draft
|
||||
case "prerelease":
|
||||
rlsOpts.ReleaseType = release.Prerelease
|
||||
case "normal":
|
||||
rlsOpts.ReleaseType = release.Normal
|
||||
default:
|
||||
return fmt.Errorf("invalid --type \"%s\"", rlsType)
|
||||
}
|
||||
|
||||
if c.Args().Len() > 0 {
|
||||
rlsOpts.AssetFiles = c.Args().Slice()
|
||||
}
|
||||
|
||||
if rOpts.Plan != nil {
|
||||
rlsOpts.Source = rOpts.Plan.Source
|
||||
|
||||
if rOpts.Plan.Release != nil {
|
||||
rlsOpts.ReleaseName = rOpts.Plan.Release.Name
|
||||
rlsOpts.ReleaseTitle = rOpts.Plan.Release.Title
|
||||
|
||||
if rOpts.Plan.Release.Draft {
|
||||
rlsOpts.ReleaseType = release.Draft
|
||||
} else if rOpts.Plan.Release.Prerelease {
|
||||
rlsOpts.ReleaseType = release.Prerelease
|
||||
}
|
||||
}
|
||||
|
||||
// Set asset files based on plan if no file arguments were given.
|
||||
if len(rlsOpts.AssetFiles) == 0 && rOpts.Plan.Output != nil {
|
||||
rlsOpts.AssetFiles = []string{
|
||||
filepath.Join(
|
||||
rOpts.Plan.Output.Directory,
|
||||
rOpts.Plan.Output.DiskImage,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return release.Publish(c.Context, rlsOpts)
|
||||
}
|
||||
|
||||
func releaseBulkCmd() *cli2.Command {
|
||||
return &cli2.Command{
|
||||
Name: "bulk",
|
||||
Usage: "bulk modify GitHub releases",
|
||||
ArgsUsage: "",
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "name",
|
||||
Usage: "regexp pattern matching release names to modify",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "prerelease",
|
||||
Usage: "change prerelease flag, must be \"true\" or " +
|
||||
"\"false\", otherwise prerelease value is not changed",
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "dry-run",
|
||||
Usage: "do not perform any changes",
|
||||
},
|
||||
},
|
||||
Action: releaseActionWrapper(releaseBulkAction),
|
||||
}
|
||||
}
|
||||
|
||||
func releaseBulkAction(
|
||||
c *cli2.Context,
|
||||
_ *Options,
|
||||
rOpts *releaseOptions,
|
||||
) error {
|
||||
bulkOpts := &release.BulkOptions{
|
||||
Repository: rOpts.Repository,
|
||||
NamePattern: c.String("name"),
|
||||
DryRun: c.Bool("dry-run"),
|
||||
GithubToken: rOpts.GithubToken,
|
||||
}
|
||||
|
||||
switch c.String("prerelease") {
|
||||
case "true":
|
||||
v := true
|
||||
bulkOpts.Prerelease = &v
|
||||
case "false":
|
||||
v := false
|
||||
bulkOpts.Prerelease = &v
|
||||
case "":
|
||||
default:
|
||||
return errors.New(
|
||||
"--prerelease by me \"true\" or \"false\" when specified",
|
||||
)
|
||||
}
|
||||
|
||||
return release.Bulk(c.Context, bulkOpts)
|
||||
}
|
||||
160
pkg/cli/sign.go
Normal file
160
pkg/cli/sign.go
Normal file
@@ -0,0 +1,160 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/plan"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/sign"
|
||||
cli2 "github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func signCmd() *cli2.Command {
|
||||
return &cli2.Command{
|
||||
Name: "sign",
|
||||
Usage: "sign a Emacs.app bundle with codesign",
|
||||
ArgsUsage: "<emacs-app>",
|
||||
Flags: []cli2.Flag{
|
||||
&cli2.StringFlag{
|
||||
Name: "sign",
|
||||
Aliases: []string{"s"},
|
||||
Usage: "signing identity passed to codesign",
|
||||
EnvVars: []string{"AC_SIGN_IDENTITY"},
|
||||
Required: true,
|
||||
},
|
||||
&cli2.StringSliceFlag{
|
||||
Name: "entitlements",
|
||||
Aliases: []string{"e"},
|
||||
Usage: "comma-separated list of entitlements to enable",
|
||||
Value: cli2.NewStringSlice(sign.DefaultEmacsEntitlements...),
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "deep",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "pass --deep to codesign",
|
||||
Value: true,
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "timestamp",
|
||||
Aliases: []string{"t"},
|
||||
Usage: "pass --timestamp to codesign",
|
||||
Value: true,
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "force",
|
||||
Aliases: []string{"f"},
|
||||
Usage: "pass --force to codesign",
|
||||
Value: true,
|
||||
},
|
||||
&cli2.BoolFlag{
|
||||
Name: "verbose",
|
||||
Aliases: []string{"v"},
|
||||
Usage: "pass --verbose to codesign",
|
||||
Value: false,
|
||||
},
|
||||
&cli2.StringSliceFlag{
|
||||
Name: "options",
|
||||
Aliases: []string{"o"},
|
||||
Usage: "options passed to codesign",
|
||||
Value: cli2.NewStringSlice("runtime"),
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "codesign",
|
||||
Usage: "specify custom path to codesign executable",
|
||||
},
|
||||
&cli2.StringFlag{
|
||||
Name: "plan",
|
||||
Usage: "path to build plan YAML file produced by " +
|
||||
"emacs-builder plan",
|
||||
Aliases: []string{"p"},
|
||||
EnvVars: []string{"EMACS_BUILDER_PLAN"},
|
||||
TakesFile: true,
|
||||
},
|
||||
},
|
||||
Action: actionWrapper(signAction),
|
||||
}
|
||||
}
|
||||
|
||||
func signAction(c *cli2.Context, opts *Options) error {
|
||||
signOpts := &sign.Options{
|
||||
Identity: c.String("sign"),
|
||||
Options: c.StringSlice("options"),
|
||||
Deep: c.Bool("deep"),
|
||||
Timestamp: c.Bool("timestamp"),
|
||||
Force: c.Bool("force"),
|
||||
Verbose: c.Bool("verbose"),
|
||||
CodeSignCmd: c.String("codesign"),
|
||||
}
|
||||
|
||||
if v := c.StringSlice("entitlements"); len(v) > 0 {
|
||||
e := sign.Entitlements(v)
|
||||
signOpts.Entitlements = &e
|
||||
}
|
||||
|
||||
if !opts.quiet {
|
||||
signOpts.Output = os.Stdout
|
||||
}
|
||||
|
||||
app := c.Args().Get(0)
|
||||
|
||||
if f := c.String("plan"); f != "" {
|
||||
p, err := plan.Load(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if p.Output != nil && p.Build != nil {
|
||||
app = filepath.Join(
|
||||
p.Output.Directory, p.Build.Name, "Emacs.app",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return sign.Emacs(c.Context, app, signOpts)
|
||||
}
|
||||
|
||||
func signFilesCmd() *cli2.Command {
|
||||
signCmd := signCmd()
|
||||
|
||||
var flags []cli2.Flag
|
||||
for _, f := range signCmd.Flags {
|
||||
n := f.Names()
|
||||
if len(n) > 0 && n[0] == "plan" {
|
||||
continue
|
||||
}
|
||||
|
||||
flags = append(flags, f)
|
||||
}
|
||||
|
||||
return &cli2.Command{
|
||||
Name: "sign-files",
|
||||
Usage: "sign files with codesign",
|
||||
ArgsUsage: "<file> [<file>...]",
|
||||
Hidden: true,
|
||||
Flags: flags,
|
||||
Action: actionWrapper(signFilesAction),
|
||||
}
|
||||
}
|
||||
|
||||
func signFilesAction(c *cli2.Context, opts *Options) error {
|
||||
signOpts := &sign.Options{
|
||||
Identity: c.String("sign"),
|
||||
Options: c.StringSlice("options"),
|
||||
Deep: c.Bool("deep"),
|
||||
Timestamp: c.Bool("timestamp"),
|
||||
Force: c.Bool("force"),
|
||||
Verbose: c.Bool("verbose"),
|
||||
CodeSignCmd: c.String("codesign"),
|
||||
}
|
||||
|
||||
if v := c.StringSlice("entitlements"); len(v) > 0 {
|
||||
e := sign.Entitlements(v)
|
||||
signOpts.Entitlements = &e
|
||||
}
|
||||
|
||||
if !opts.quiet {
|
||||
signOpts.Output = os.Stdout
|
||||
}
|
||||
|
||||
return sign.Files(c.Context, c.Args().Slice(), signOpts)
|
||||
}
|
||||
42
pkg/commit/commit.go
Normal file
42
pkg/commit/commit.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package commit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-github/v35/github"
|
||||
)
|
||||
|
||||
type Commit struct {
|
||||
SHA string `yaml:"sha" json:"sha"`
|
||||
Date *time.Time `yaml:"date" json:"date"`
|
||||
Author string `yaml:"author" json:"author"`
|
||||
Committer string `yaml:"committer" json:"committer"`
|
||||
Message string `yaml:"message" json:"message"`
|
||||
}
|
||||
|
||||
func New(rc *github.RepositoryCommit) *Commit {
|
||||
return &Commit{
|
||||
SHA: rc.GetSHA(),
|
||||
Date: rc.GetCommit().GetCommitter().Date,
|
||||
Author: fmt.Sprintf(
|
||||
"%s <%s>",
|
||||
rc.GetCommit().GetAuthor().GetName(),
|
||||
rc.GetCommit().GetAuthor().GetEmail(),
|
||||
),
|
||||
Committer: fmt.Sprintf(
|
||||
"%s <%s>",
|
||||
rc.GetCommit().GetCommitter().GetName(),
|
||||
rc.GetCommit().GetCommitter().GetEmail(),
|
||||
),
|
||||
Message: rc.GetCommit().GetMessage(),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Commit) ShortSHA() string {
|
||||
return s.SHA[0:7]
|
||||
}
|
||||
|
||||
func (s *Commit) DateString() string {
|
||||
return s.Date.Format("2006-01-02")
|
||||
}
|
||||
47
pkg/dmg/assets/assets.go
Normal file
47
pkg/dmg/assets/assets.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
)
|
||||
|
||||
//go:generate tiffutil -cathidpicheck bg.png bg@2x.png -out bg.tif
|
||||
|
||||
// Background is a raw byte slice of bytes of bg.tiff
|
||||
//
|
||||
//go:embed bg.tif
|
||||
var Background []byte
|
||||
|
||||
// BackgroundTempFile writes Background to a temporary file on disk, returning
|
||||
// the resulting file path. The returned filepath should be deleted with
|
||||
// os.Remove() when no longer needed.
|
||||
func BackgroundTempFile() (string, error) {
|
||||
return tempFile("*-emacs-bg.tif", Background)
|
||||
}
|
||||
|
||||
// Icon is a raw byte slice of bytes of vol.icns
|
||||
//
|
||||
//go:embed vol.icns
|
||||
var Icon []byte
|
||||
|
||||
// IconTempFile writes Icon to a temporary file on disk, returning the resulting
|
||||
// file path. The returned filepath should be deleted with os.Remove() when no
|
||||
// longer needed.
|
||||
func IconTempFile() (string, error) {
|
||||
return tempFile("*-emacs-vol.icns", Icon)
|
||||
}
|
||||
|
||||
func tempFile(pattern string, content []byte) (string, error) {
|
||||
f, err := os.CreateTemp("", pattern)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
_, err = f.Write(content)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return f.Name(), nil
|
||||
}
|
||||
BIN
pkg/dmg/assets/bg.afdesign
Normal file
BIN
pkg/dmg/assets/bg.afdesign
Normal file
Binary file not shown.
BIN
pkg/dmg/assets/bg.png
Normal file
BIN
pkg/dmg/assets/bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
BIN
pkg/dmg/assets/bg.tif
Normal file
BIN
pkg/dmg/assets/bg.tif
Normal file
Binary file not shown.
BIN
pkg/dmg/assets/bg@2x.png
Normal file
BIN
pkg/dmg/assets/bg@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
BIN
pkg/dmg/assets/vol.icns
Normal file
BIN
pkg/dmg/assets/vol.icns
Normal file
Binary file not shown.
151
pkg/dmg/dmg.go
Normal file
151
pkg/dmg/dmg.go
Normal file
@@ -0,0 +1,151 @@
|
||||
package dmg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/dmg/assets"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/dmgbuild"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
DMGBuild string
|
||||
|
||||
SourceDir string
|
||||
VolumeName string
|
||||
OutputFile string
|
||||
RemoveSourceDir bool
|
||||
Verbose bool
|
||||
Output io.Writer
|
||||
}
|
||||
|
||||
// Create will create a *.dmg disk image as specified by the given Options.
|
||||
//
|
||||
//nolint:funlen
|
||||
func Create(ctx context.Context, opts *Options) (string, error) {
|
||||
logger := hclog.FromContext(ctx).Named("package")
|
||||
|
||||
sourceDir, err := filepath.Abs(opts.SourceDir)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
appBundle := filepath.Join(sourceDir, "Emacs.app")
|
||||
_, err = os.Stat(appBundle)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
volIcon, err := assets.IconTempFile()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer os.Remove(volIcon)
|
||||
|
||||
bgImg, err := assets.BackgroundTempFile()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer os.Remove(bgImg)
|
||||
|
||||
volName := opts.VolumeName
|
||||
if volName == "" {
|
||||
volName = filepath.Base(sourceDir)
|
||||
}
|
||||
|
||||
outputDMG := opts.OutputFile
|
||||
if outputDMG == "" {
|
||||
outputDMG = sourceDir + ".dmg"
|
||||
}
|
||||
|
||||
settings := &dmgbuild.Settings{
|
||||
Logger: logger,
|
||||
|
||||
Filename: outputDMG,
|
||||
VolumeName: volName,
|
||||
Icon: volIcon,
|
||||
Format: dmgbuild.UDZOFormat,
|
||||
CompressionLevel: 9,
|
||||
Files: []*dmgbuild.File{
|
||||
{
|
||||
Path: appBundle,
|
||||
PosX: 170,
|
||||
PosY: 200,
|
||||
},
|
||||
},
|
||||
Symlinks: []*dmgbuild.Symlink{
|
||||
{
|
||||
Name: "Applications",
|
||||
Target: "/Applications",
|
||||
PosX: 510,
|
||||
PosY: 200,
|
||||
},
|
||||
},
|
||||
Window: dmgbuild.Window{
|
||||
Background: bgImg,
|
||||
PoxX: 200,
|
||||
PosY: 200,
|
||||
Width: 680,
|
||||
Height: 446,
|
||||
DefaultView: dmgbuild.Icon,
|
||||
},
|
||||
IconView: dmgbuild.IconView{
|
||||
IconSize: 160,
|
||||
TextSize: 16,
|
||||
},
|
||||
}
|
||||
|
||||
copyingFile := filepath.Join(sourceDir, "COPYING")
|
||||
fi, err := os.Stat(copyingFile)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return "", err
|
||||
} else if err == nil && fi.Mode().IsRegular() {
|
||||
settings.Files = append(settings.Files, &dmgbuild.File{
|
||||
Path: copyingFile,
|
||||
PosX: 340,
|
||||
PosY: 506,
|
||||
})
|
||||
}
|
||||
|
||||
configureOutputFile := filepath.Join(sourceDir, "configure_output.txt")
|
||||
fi, err = os.Stat(configureOutputFile)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return "", err
|
||||
} else if err == nil && fi.Mode().IsRegular() {
|
||||
settings.Files = append(settings.Files, &dmgbuild.File{
|
||||
Path: configureOutputFile,
|
||||
PosX: 340,
|
||||
PosY: 756,
|
||||
})
|
||||
}
|
||||
|
||||
if opts.Output != nil {
|
||||
settings.Stdout = opts.Output
|
||||
settings.Stderr = opts.Output
|
||||
}
|
||||
|
||||
logger.Info("creating dmg", "file", filepath.Base(outputDMG))
|
||||
|
||||
err = dmgbuild.Build(ctx, settings)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if opts.RemoveSourceDir {
|
||||
dir, err := filepath.Abs(opts.SourceDir)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
logger.Info("removing", "source-dir", dir)
|
||||
err = os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
return outputDMG, nil
|
||||
}
|
||||
84
pkg/dmgbuild/dmgbuild.go
Normal file
84
pkg/dmgbuild/dmgbuild.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package dmgbuild
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
func Build(ctx context.Context, settings *Settings) error {
|
||||
if settings == nil {
|
||||
return fmt.Errorf("no settings provided")
|
||||
}
|
||||
|
||||
logger := hclog.NewNullLogger()
|
||||
if settings.Logger != nil {
|
||||
logger = settings.Logger
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(logger.Name(), "dmgbuild") {
|
||||
logger = logger.Named("dmgbuild")
|
||||
}
|
||||
|
||||
_, err := os.Stat(settings.Filename)
|
||||
if !os.IsNotExist(err) {
|
||||
return fmt.Errorf("output dmg exists: %s", settings.Filename)
|
||||
}
|
||||
|
||||
baseCmd := settings.Command
|
||||
if baseCmd == "" {
|
||||
path, err2 := exec.LookPath("dmgbuild")
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
baseCmd = path
|
||||
}
|
||||
|
||||
file, err := settings.TempFile()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.Remove(file)
|
||||
|
||||
args := []string{"-s", file, settings.VolumeName, settings.Filename}
|
||||
|
||||
if logger.IsDebug() {
|
||||
content, err2 := os.ReadFile(file)
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
logger.Debug("using settings", file, string(content))
|
||||
logger.Debug("executing", "command", baseCmd, "args", args)
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, baseCmd, args...)
|
||||
if settings.Stdout != nil {
|
||||
cmd.Stdout = settings.Stdout
|
||||
}
|
||||
if settings.Stderr != nil {
|
||||
cmd.Stderr = settings.Stderr
|
||||
}
|
||||
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
f, err := os.Stat(settings.Filename)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return fmt.Errorf("output DMG file is missing")
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
if !f.Mode().IsRegular() {
|
||||
return fmt.Errorf("output DMG file is not a file")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
85
pkg/dmgbuild/icon_view.go
Normal file
85
pkg/dmgbuild/icon_view.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package dmgbuild
|
||||
|
||||
import "fmt"
|
||||
|
||||
type arrageOrder string
|
||||
|
||||
//nolint:golint
|
||||
var (
|
||||
NameOrder arrageOrder = "name"
|
||||
DateModifiedOrder arrageOrder = "date-modified"
|
||||
DateCreatedOrder arrageOrder = "date-created"
|
||||
DateAddedOrder arrageOrder = "date-added"
|
||||
DateLastOpenedOrder arrageOrder = "date-last-opened"
|
||||
SizeOrder arrageOrder = "size"
|
||||
KindOrder arrageOrder = "kind"
|
||||
LabelOrder arrageOrder = "label"
|
||||
)
|
||||
|
||||
type labelPosition string
|
||||
|
||||
//nolint:golint
|
||||
var (
|
||||
LabelBottom labelPosition = "bottom"
|
||||
LabelRight labelPosition = "right"
|
||||
)
|
||||
|
||||
type IconView struct {
|
||||
ArrangeBy arrageOrder
|
||||
GridOffsetX int
|
||||
GridOffsetY int
|
||||
GridSpacing float32
|
||||
ScrollPosX float32
|
||||
ScrollPosY float32
|
||||
LabelPosition labelPosition
|
||||
IconSize float32
|
||||
TextSize float32
|
||||
}
|
||||
|
||||
func NewIconView() IconView {
|
||||
return IconView{
|
||||
GridOffsetX: 0,
|
||||
GridOffsetY: 0,
|
||||
GridSpacing: 100,
|
||||
ScrollPosX: 0.0,
|
||||
ScrollPosY: 0.0,
|
||||
LabelPosition: LabelBottom,
|
||||
IconSize: 128,
|
||||
TextSize: 16,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IconView) Render() []string {
|
||||
r := []string{}
|
||||
|
||||
if s.ArrangeBy != "" {
|
||||
r = append(r, "arrange_by = "+pyStr(string(s.ArrangeBy))+"\n")
|
||||
}
|
||||
if s.GridOffsetX > 0 || s.GridOffsetY > 0 {
|
||||
r = append(r, fmt.Sprintf(
|
||||
"grid_offset = (%d, %d)\n",
|
||||
s.GridOffsetX, s.GridOffsetY,
|
||||
))
|
||||
}
|
||||
if s.GridSpacing > 0 {
|
||||
r = append(r, fmt.Sprintf("grid_spacing = %.2f\n", s.GridSpacing))
|
||||
}
|
||||
if s.ScrollPosX > 0 || s.ScrollPosY > 0 {
|
||||
r = append(r, fmt.Sprintf(
|
||||
"scroll_position = (%.2f, %.2f)\n",
|
||||
s.ScrollPosX, s.ScrollPosY,
|
||||
))
|
||||
}
|
||||
if s.LabelPosition != "" {
|
||||
r = append(r, "label_position = "+pyStr(string(s.LabelPosition))+"\n")
|
||||
}
|
||||
|
||||
if s.IconSize > 0 {
|
||||
r = append(r, fmt.Sprintf("icon_size = %.2f\n", s.IconSize))
|
||||
}
|
||||
if s.TextSize > 0 {
|
||||
r = append(r, fmt.Sprintf("text_size = %.2f\n", s.TextSize))
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
183
pkg/dmgbuild/license.go
Normal file
183
pkg/dmgbuild/license.go
Normal file
@@ -0,0 +1,183 @@
|
||||
package dmgbuild
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type locale string
|
||||
|
||||
//nolint:golint
|
||||
var (
|
||||
LocaleAfZA locale = "af_ZA"
|
||||
LocaleAr locale = "ar"
|
||||
LocaleBeBY locale = "be_BY"
|
||||
LocaleBgBG locale = "bg_BG"
|
||||
LocaleBn locale = "bn"
|
||||
LocaleBo locale = "bo"
|
||||
LocaleBr locale = "br"
|
||||
LocaleCaES locale = "ca_ES"
|
||||
LocaleCsCZ locale = "cs_CZ"
|
||||
LocaleCy locale = "cy"
|
||||
LocaleDaDK locale = "da_DK"
|
||||
LocaleDeAT locale = "de_AT"
|
||||
LocaleDeCH locale = "de_CH"
|
||||
LocaleDeDE locale = "de_DE"
|
||||
LocaleDzBT locale = "dz_BT"
|
||||
LocaleElCY locale = "el_CY"
|
||||
LocaleElGR locale = "el_GR"
|
||||
LocaleEnAU locale = "en_AU"
|
||||
LocaleEnCA locale = "en_CA"
|
||||
LocaleEnGB locale = "en_GB"
|
||||
LocaleEnIE locale = "en_IE"
|
||||
LocaleEnSG locale = "en_SG"
|
||||
LocaleEnUS locale = "en_US"
|
||||
LocaleEo locale = "eo"
|
||||
LocaleEs419 locale = "es_419"
|
||||
LocaleEsES locale = "es_ES"
|
||||
LocaleEtEE locale = "et_EE"
|
||||
LocaleFaIR locale = "fa_IR"
|
||||
LocaleFiFI locale = "fi_FI"
|
||||
LocaleFoFO locale = "fo_FO"
|
||||
LocaleFr001 locale = "fr_001"
|
||||
LocaleFrBE locale = "fr_BE"
|
||||
LocaleFrCA locale = "fr_CA"
|
||||
LocaleFrCH locale = "fr_CH"
|
||||
LocaleFrFR locale = "fr_FR"
|
||||
LocaleGaLatgIE locale = "ga-Latg_IE"
|
||||
LocaleGaIE locale = "ga_IE"
|
||||
LocaleGd locale = "gd"
|
||||
LocaleGrc locale = "grc"
|
||||
LocaleGuIN locale = "gu_IN"
|
||||
LocaleGv locale = "gv"
|
||||
LocaleHeIL locale = "he_IL"
|
||||
LocaleHiIN locale = "hi_IN"
|
||||
LocaleHrHR locale = "hr_HR"
|
||||
LocaleHuHU locale = "hu_HU"
|
||||
LocaleHyAM locale = "hy_AM"
|
||||
LocaleIsIS locale = "is_IS"
|
||||
LocaleItCH locale = "it_CH"
|
||||
LocaleItIT locale = "it_IT"
|
||||
LocaleIuCA locale = "iu_CA"
|
||||
LocaleJaJP locale = "ja_JP"
|
||||
LocaleKaGE locale = "ka_GE"
|
||||
LocaleKl locale = "kl"
|
||||
LocaleKoKR locale = "ko_KR"
|
||||
LocaleLtLT locale = "lt_LT"
|
||||
LocaleLvLV locale = "lv_LV"
|
||||
LocaleMkMK locale = "mk_MK"
|
||||
LocaleMrIN locale = "mr_IN"
|
||||
LocaleMtMT locale = "mt_MT"
|
||||
LocaleNbNO locale = "nb_NO"
|
||||
LocaleNeNP locale = "ne_NP"
|
||||
LocaleNlBE locale = "nl_BE"
|
||||
LocaleNlNL locale = "nl_NL"
|
||||
LocaleNnNO locale = "nn_NO"
|
||||
LocalePa locale = "pa"
|
||||
LocalePlPL locale = "pl_PL"
|
||||
LocalePtBR locale = "pt_BR"
|
||||
LocalePtPT locale = "pt_PT"
|
||||
LocaleRoRO locale = "ro_RO"
|
||||
LocaleRuRU locale = "ru_RU"
|
||||
LocaleSe locale = "se"
|
||||
LocaleSkSK locale = "sk_SK"
|
||||
LocaleSlSI locale = "sl_SI"
|
||||
LocaleSrRS locale = "sr_RS"
|
||||
LocaleSvSE locale = "sv_SE"
|
||||
LocaleThTH locale = "th_TH"
|
||||
LocaleToTO locale = "to_TO"
|
||||
LocaleTrTR locale = "tr_TR"
|
||||
LocaleUkUA locale = "uk_UA"
|
||||
LocaleUrIN locale = "ur_IN"
|
||||
LocaleUrPK locale = "ur_PK"
|
||||
LocaleUzUZ locale = "uz_UZ"
|
||||
LocaleViVN locale = "vi_VN"
|
||||
LocaleZhCN locale = "zh_CN"
|
||||
LocaleZhTW locale = "zh_TW"
|
||||
)
|
||||
|
||||
type Buttons struct {
|
||||
LanguageName string
|
||||
Agree string
|
||||
Disagree string
|
||||
Print string
|
||||
Save string
|
||||
Message string
|
||||
}
|
||||
|
||||
type License struct {
|
||||
DefaultLanguage locale
|
||||
Licenses map[locale]string
|
||||
Buttons map[locale]Buttons
|
||||
}
|
||||
|
||||
func NewLicense() License {
|
||||
return License{}
|
||||
}
|
||||
|
||||
func (s *License) Render() []string {
|
||||
var l []string
|
||||
|
||||
if s.DefaultLanguage != "" {
|
||||
l = append(l,
|
||||
"\"default-language\": "+pyStr(string(s.DefaultLanguage)),
|
||||
)
|
||||
}
|
||||
|
||||
if len(s.Licenses) > 0 {
|
||||
var items []string
|
||||
for k, v := range s.Licenses {
|
||||
items = append(items, fmt.Sprintf(
|
||||
"%s: %s", pyStr(string(k)), pyMStr(v),
|
||||
))
|
||||
}
|
||||
sort.SliceStable(items, func(i, j int) bool {
|
||||
return items[i] < items[j]
|
||||
})
|
||||
l = append(l,
|
||||
"\"licenses\": {\n "+
|
||||
strings.Join(items, ",\n ")+
|
||||
"\n }",
|
||||
)
|
||||
}
|
||||
|
||||
if len(s.Buttons) > 0 {
|
||||
var items []string
|
||||
for k, v := range s.Buttons {
|
||||
items = append(items, fmt.Sprintf(
|
||||
"%s: (\n"+
|
||||
" %s,\n"+
|
||||
" %s,\n"+
|
||||
" %s,\n"+
|
||||
" %s,\n"+
|
||||
" %s,\n"+
|
||||
" %s\n"+
|
||||
" )",
|
||||
pyStr(string(k)),
|
||||
pyStr(v.LanguageName),
|
||||
pyStr(v.Agree),
|
||||
pyStr(v.Disagree),
|
||||
pyStr(v.Print),
|
||||
pyStr(v.Save),
|
||||
pyStr(v.Message),
|
||||
))
|
||||
}
|
||||
sort.SliceStable(items, func(i, j int) bool {
|
||||
return items[i] < items[j]
|
||||
})
|
||||
l = append(l,
|
||||
"\"buttons\": {\n "+
|
||||
strings.Join(items, ",\n ")+
|
||||
"\n }",
|
||||
)
|
||||
}
|
||||
|
||||
if len(l) == 0 {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
return []string{
|
||||
"license = {\n " + strings.Join(l, ",\n ") + "\n}\n",
|
||||
}
|
||||
}
|
||||
154
pkg/dmgbuild/list_view.go
Normal file
154
pkg/dmgbuild/list_view.go
Normal file
@@ -0,0 +1,154 @@
|
||||
package dmgbuild
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type listColumn string
|
||||
|
||||
//nolint:golint
|
||||
var (
|
||||
NameColumn listColumn = "name"
|
||||
DateModifiedColumn listColumn = "date-modified"
|
||||
DateCreatedColumn listColumn = "date-created"
|
||||
DateAddedColumn listColumn = "date-added"
|
||||
DateLastOpenedColumn listColumn = "date-last-opened"
|
||||
SizeColumn listColumn = "size"
|
||||
KindColumn listColumn = "kind"
|
||||
LabelColumn listColumn = "label"
|
||||
VersionColumn listColumn = "version"
|
||||
CommentsColumn listColumn = "comments"
|
||||
)
|
||||
|
||||
type direction string
|
||||
|
||||
//nolint:golint
|
||||
var (
|
||||
Ascending direction = "ascending"
|
||||
Descending direction = "descending"
|
||||
)
|
||||
|
||||
type ListView struct {
|
||||
SortBy listColumn
|
||||
ScrollPosX int
|
||||
ScrollPosY int
|
||||
IconSize float32
|
||||
TextSize float32
|
||||
UseRelativeDates bool
|
||||
CalculateAllSizes bool
|
||||
Columns []listColumn
|
||||
ColumnWidths map[listColumn]int
|
||||
ColumnSortDirections map[listColumn]direction
|
||||
}
|
||||
|
||||
func NewListView() ListView {
|
||||
return ListView{
|
||||
SortBy: NameColumn,
|
||||
IconSize: 16,
|
||||
TextSize: 12,
|
||||
UseRelativeDates: true,
|
||||
Columns: []listColumn{
|
||||
NameColumn,
|
||||
DateModifiedColumn,
|
||||
SizeColumn,
|
||||
KindColumn,
|
||||
DateAddedColumn,
|
||||
},
|
||||
ColumnWidths: map[listColumn]int{
|
||||
(NameColumn): 300,
|
||||
(DateModifiedColumn): 181,
|
||||
(DateCreatedColumn): 181,
|
||||
(DateAddedColumn): 181,
|
||||
(DateLastOpenedColumn): 181,
|
||||
(SizeColumn): 97,
|
||||
(KindColumn): 115,
|
||||
(LabelColumn): 100,
|
||||
(VersionColumn): 75,
|
||||
(CommentsColumn): 300,
|
||||
},
|
||||
ColumnSortDirections: map[listColumn]direction{
|
||||
(NameColumn): Ascending,
|
||||
(DateModifiedColumn): Descending,
|
||||
(DateCreatedColumn): Descending,
|
||||
(DateAddedColumn): Descending,
|
||||
(DateLastOpenedColumn): Descending,
|
||||
(SizeColumn): Descending,
|
||||
(KindColumn): Ascending,
|
||||
(LabelColumn): Ascending,
|
||||
(VersionColumn): Ascending,
|
||||
(CommentsColumn): Ascending,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ListView) Render() []string {
|
||||
r := []string{}
|
||||
|
||||
if s.SortBy != "" {
|
||||
r = append(r, "list_sort_by = "+pyStr(string(s.SortBy))+"\n")
|
||||
}
|
||||
if s.ScrollPosX > 0 || s.ScrollPosY > 0 {
|
||||
r = append(r, fmt.Sprintf(
|
||||
"list_scroll_position = (%d, %d)\n",
|
||||
s.ScrollPosX, s.ScrollPosY,
|
||||
))
|
||||
}
|
||||
if s.IconSize > 0 {
|
||||
r = append(r, fmt.Sprintf("list_icon_size = %.2f\n", s.IconSize))
|
||||
}
|
||||
if s.TextSize > 0 {
|
||||
r = append(r, fmt.Sprintf("list_text_size = %.2f\n", s.TextSize))
|
||||
}
|
||||
r = append(r, "list_use_relative_dates = "+pyBool(s.UseRelativeDates)+"\n")
|
||||
r = append(
|
||||
r, "list_calculate_all_sizes = "+pyBool(s.CalculateAllSizes)+"\n",
|
||||
)
|
||||
|
||||
if len(s.Columns) > 0 {
|
||||
var cols []string
|
||||
for _, col := range s.Columns {
|
||||
cols = append(cols, pyStr(string(col)))
|
||||
}
|
||||
r = append(r,
|
||||
"list_columns = [\n "+strings.Join(cols, ",\n ")+"\n]\n",
|
||||
)
|
||||
}
|
||||
|
||||
if len(s.ColumnWidths) > 0 {
|
||||
var cols []string
|
||||
for col, w := range s.ColumnWidths {
|
||||
cols = append(cols, fmt.Sprintf(
|
||||
"%s: %d", pyStr(string(col)), w,
|
||||
))
|
||||
}
|
||||
sort.SliceStable(cols, func(i, j int) bool {
|
||||
return cols[i] < cols[j]
|
||||
})
|
||||
r = append(r,
|
||||
"list_column_widths = {\n "+
|
||||
strings.Join(cols, ",\n ")+
|
||||
"\n}\n",
|
||||
)
|
||||
}
|
||||
|
||||
if len(s.ColumnSortDirections) > 0 {
|
||||
var cols []string
|
||||
for col, direction := range s.ColumnSortDirections {
|
||||
cols = append(cols, fmt.Sprintf(
|
||||
"%s: %s", pyStr(string(col)), pyStr(string(direction)),
|
||||
))
|
||||
}
|
||||
sort.SliceStable(cols, func(i, j int) bool {
|
||||
return cols[i] < cols[j]
|
||||
})
|
||||
r = append(r,
|
||||
"list_column_sort_directions = {\n "+
|
||||
strings.Join(cols, ",\n ")+
|
||||
"\n}\n",
|
||||
)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
257
pkg/dmgbuild/settings.go
Normal file
257
pkg/dmgbuild/settings.go
Normal file
@@ -0,0 +1,257 @@
|
||||
package dmgbuild
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
type format string
|
||||
|
||||
//nolint:golint
|
||||
var (
|
||||
UDROFormat format = "UDRO" // Read-only
|
||||
UDCOFormat format = "UDCO" // Compressed (ADC)
|
||||
UDZOFormat format = "UDZO" // Compressed (gzip)
|
||||
UDBZFormat format = "UDBZ" // Compressed (bzip2)
|
||||
UFBIFormat format = "UFBI" // Entire device
|
||||
IPODFormat format = "IPOD" // iPod image
|
||||
UDxxFormat format = "UDxx" // UDIF stub
|
||||
UDSBFormat format = "UDSB" // Sparse bundle
|
||||
UDSPFormat format = "UDSP" // Sparse
|
||||
UDRWFormat format = "UDRW" // Read/write
|
||||
UDTOFormat format = "UDTO" // DVD/CD master
|
||||
DC42Format format = "DC42" // Disk Copy 4.2
|
||||
RdWrFormat format = "RdWr" // NDIF read/write
|
||||
RdxxFormat format = "Rdxx" // NDIF read-only
|
||||
ROCoFormat format = "ROCo" // NDIF Compressed
|
||||
RkenFormat format = "Rken" // NDIF Compressed (KenCode)
|
||||
)
|
||||
|
||||
type File struct {
|
||||
Path string
|
||||
PosX int
|
||||
PosY int
|
||||
Hidden bool
|
||||
HideExtension bool
|
||||
}
|
||||
|
||||
type Symlink struct {
|
||||
Name string
|
||||
Target string
|
||||
PosX int
|
||||
PosY int
|
||||
Hidden bool
|
||||
HideExtension bool
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
// Command can be set to a custom dmgbuild executable path. If not set,
|
||||
// the first "dmgbuild" executable within PATH will be used.
|
||||
Command string
|
||||
|
||||
// Stdout will be set as STDOUT target for dmgbuild execution if not nil.
|
||||
Stdout io.Writer
|
||||
|
||||
// Stderr will be set as STDERR target for dmgbuild execution if not nil.
|
||||
Stderr io.Writer
|
||||
|
||||
// Logger allows logging details of dmbuild process.
|
||||
Logger hclog.Logger
|
||||
|
||||
// dmgbuild settings
|
||||
Filename string
|
||||
VolumeName string
|
||||
Format format
|
||||
Size string
|
||||
CompressionLevel int
|
||||
Files []*File
|
||||
Symlinks []*Symlink
|
||||
Icon string
|
||||
BadgeIcon string
|
||||
Window Window
|
||||
IconView IconView
|
||||
ListView ListView
|
||||
License License
|
||||
}
|
||||
|
||||
func NewSettings() *Settings {
|
||||
return &Settings{
|
||||
Format: UDZOFormat,
|
||||
CompressionLevel: 9,
|
||||
Window: NewWindow(),
|
||||
IconView: NewIconView(),
|
||||
ListView: NewListView(),
|
||||
License: NewLicense(),
|
||||
}
|
||||
}
|
||||
|
||||
// Render returns a string slice where each string is a separate settings
|
||||
// statement.
|
||||
//
|
||||
//nolint:funlen,gocyclo
|
||||
func (s *Settings) Render() ([]string, error) {
|
||||
r := []string{
|
||||
"# -*- coding: utf-8 -*-\n",
|
||||
"from __future__ import unicode_literals\n",
|
||||
}
|
||||
|
||||
if s.Filename != "" {
|
||||
r = append(r, "filename = "+pyStr(s.Filename)+"\n")
|
||||
}
|
||||
if s.VolumeName != "" {
|
||||
r = append(r, "volume_name = "+pyStr(s.VolumeName)+"\n")
|
||||
}
|
||||
if s.Format != "" {
|
||||
r = append(r, "format = "+pyStr(string(s.Format))+"\n")
|
||||
}
|
||||
if s.CompressionLevel != 0 {
|
||||
r = append(r, fmt.Sprintf(
|
||||
"compression_level = %d\n", s.CompressionLevel,
|
||||
))
|
||||
}
|
||||
if s.Size != "" {
|
||||
r = append(r, "size = "+pyStr(s.Size)+"\n")
|
||||
}
|
||||
|
||||
var files []string
|
||||
var symlinks []string
|
||||
var hide []string
|
||||
var hideExt []string
|
||||
var iconLoc []string
|
||||
|
||||
if len(s.Files) > 0 {
|
||||
for _, f := range s.Files {
|
||||
files = append(files, pyStr(f.Path))
|
||||
name := filepath.Base(f.Path)
|
||||
if f.PosX > 0 || f.PosY > 0 {
|
||||
iconLoc = append(iconLoc,
|
||||
fmt.Sprintf("%s: (%d, %d)", pyStr(name), f.PosX, f.PosY),
|
||||
)
|
||||
}
|
||||
if f.Hidden {
|
||||
hide = append(hide, pyStr(filepath.Base(f.Path)))
|
||||
}
|
||||
if f.HideExtension {
|
||||
hideExt = append(hideExt, pyStr(filepath.Base(f.Path)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(s.Symlinks) > 0 {
|
||||
for _, l := range s.Symlinks {
|
||||
symlinks = append(symlinks, pyStr(l.Name)+": "+pyStr(l.Target))
|
||||
if l.PosX > 0 || l.PosY > 0 {
|
||||
iconLoc = append(iconLoc,
|
||||
fmt.Sprintf("%s: (%d, %d)", pyStr(l.Name), l.PosX, l.PosY),
|
||||
)
|
||||
}
|
||||
if l.Hidden {
|
||||
hide = append(hide, pyStr(l.Name))
|
||||
}
|
||||
if l.HideExtension {
|
||||
hideExt = append(hideExt, pyStr(l.Name))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(files) > 0 {
|
||||
r = append(r,
|
||||
"files = [\n "+strings.Join(files, ",\n ")+"\n]\n",
|
||||
)
|
||||
}
|
||||
if len(symlinks) > 0 {
|
||||
r = append(r,
|
||||
"symlinks = {\n "+strings.Join(symlinks, ",\n ")+"\n}\n",
|
||||
)
|
||||
}
|
||||
if len(hide) > 0 {
|
||||
r = append(r,
|
||||
"hide = [\n "+strings.Join(hide, ",\n ")+"\n]\n",
|
||||
)
|
||||
}
|
||||
if len(hideExt) > 0 {
|
||||
r = append(r,
|
||||
"hide_extensions = [\n "+strings.Join(hideExt, ",\n ")+
|
||||
"\n]\n",
|
||||
)
|
||||
}
|
||||
if len(iconLoc) > 0 {
|
||||
r = append(r,
|
||||
"icon_locations = {\n "+strings.Join(iconLoc, ",\n ")+"\n}\n",
|
||||
)
|
||||
}
|
||||
|
||||
if s.Icon != "" {
|
||||
r = append(r, "icon = "+pyStr(s.Icon)+"\n")
|
||||
}
|
||||
if s.BadgeIcon != "" {
|
||||
r = append(r, "badge_icon = "+pyStr(s.BadgeIcon)+"\n")
|
||||
}
|
||||
|
||||
r = append(r, s.Window.Render()...)
|
||||
r = append(r, s.IconView.Render()...)
|
||||
r = append(r, s.ListView.Render()...)
|
||||
r = append(r, s.License.Render()...)
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (s *Settings) Write(w io.Writer) error {
|
||||
out, err := s.Render()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range out {
|
||||
_, err := w.Write([]byte(o))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Settings) TempFile() (string, error) {
|
||||
f, err := os.CreateTemp("", "*.dmgbuild.settings.py")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
err = s.Write(f)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return f.Name(), nil
|
||||
}
|
||||
|
||||
func pyStr(s string) string {
|
||||
s = strings.ReplaceAll(s, `\`, `\\`)
|
||||
s = strings.ReplaceAll(s, `"`, `\"`)
|
||||
s = strings.ReplaceAll(s, "\r", `\r`)
|
||||
s = strings.ReplaceAll(s, "\n", `\n`)
|
||||
|
||||
return `"` + s + `"`
|
||||
}
|
||||
|
||||
func pyMStr(s string) string {
|
||||
s = strings.ReplaceAll(s, `\`, `\\`)
|
||||
s = strings.ReplaceAll(s, `"`, `\"`)
|
||||
|
||||
return `"""` + s + `"""`
|
||||
}
|
||||
|
||||
func pyBool(v bool) string {
|
||||
if v {
|
||||
return "True"
|
||||
}
|
||||
|
||||
return "False"
|
||||
}
|
||||
444
pkg/dmgbuild/settings_test.go
Normal file
444
pkg/dmgbuild/settings_test.go
Normal file
@@ -0,0 +1,444 @@
|
||||
package dmgbuild
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/jimeh/undent"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSettings_Write(t *testing.T) {
|
||||
test := []struct {
|
||||
name string
|
||||
entitlements *Settings
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
entitlements: &Settings{},
|
||||
want: undent.String(`
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
show_status_bar = False
|
||||
show_tab_view = False
|
||||
show_toolbar = False
|
||||
show_pathbar = False
|
||||
show_sidebar = False
|
||||
show_icon_preview = False
|
||||
show_item_info = False
|
||||
include_icon_view_settings = False
|
||||
include_list_view_settings = False
|
||||
list_use_relative_dates = False
|
||||
list_calculate_all_sizes = False`,
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "full",
|
||||
entitlements: &Settings{
|
||||
Filename: "/builds/Emacs.2021-05-25.f4dc646.master.dmg",
|
||||
VolumeName: "Emacs.2021-05-25.f4dc646.master",
|
||||
Format: UDBZFormat,
|
||||
CompressionLevel: 8,
|
||||
Size: "100m",
|
||||
Files: []*File{
|
||||
{
|
||||
Path: "/builds/Emacs.app",
|
||||
PosX: 200,
|
||||
PosY: 200,
|
||||
},
|
||||
{
|
||||
Path: "/builds/README.rtf",
|
||||
PosX: 200,
|
||||
PosY: 300,
|
||||
HideExtension: true,
|
||||
},
|
||||
{
|
||||
Path: "/builds/hide-me.png",
|
||||
Hidden: true,
|
||||
},
|
||||
},
|
||||
Symlinks: []*Symlink{
|
||||
{
|
||||
Name: "Applications",
|
||||
Target: "/Applications",
|
||||
PosX: 400,
|
||||
PosY: 400,
|
||||
},
|
||||
{
|
||||
Name: "QuickLook",
|
||||
Target: "/Library/QuickLook",
|
||||
PosX: 500,
|
||||
PosY: 400,
|
||||
Hidden: true,
|
||||
},
|
||||
{
|
||||
Name: "System",
|
||||
Target: "/System",
|
||||
HideExtension: true,
|
||||
},
|
||||
},
|
||||
Icon: "/opt/misc/assets/volIcon.icns",
|
||||
BadgeIcon: "/builds/Emacs.app/Contents/Resources/Icon.icns",
|
||||
Window: Window{
|
||||
PoxX: 200,
|
||||
PosY: 250,
|
||||
Width: 680,
|
||||
Height: 446,
|
||||
Background: "/opt/misc/assets/bg.tif",
|
||||
ShowStatusBar: true,
|
||||
ShowTabView: true,
|
||||
ShowToolbar: true,
|
||||
ShowPathbar: true,
|
||||
ShowSidebar: true,
|
||||
SidebarWidth: 165,
|
||||
DefaultView: list,
|
||||
ShowIconPreview: true,
|
||||
ShowItemInfo: true,
|
||||
IncludeIconViewSettings: true,
|
||||
IncludeListViewSettings: true,
|
||||
},
|
||||
IconView: IconView{
|
||||
ArrangeBy: NameOrder,
|
||||
GridOffsetX: 42,
|
||||
GridOffsetY: 43,
|
||||
GridSpacing: 44.5,
|
||||
ScrollPosX: 4.5,
|
||||
ScrollPosY: 5.5,
|
||||
LabelPosition: LabelBottom,
|
||||
IconSize: 160,
|
||||
TextSize: 15,
|
||||
},
|
||||
ListView: ListView{
|
||||
SortBy: NameColumn,
|
||||
ScrollPosX: 7,
|
||||
ScrollPosY: 8,
|
||||
IconSize: 16,
|
||||
TextSize: 12,
|
||||
UseRelativeDates: true,
|
||||
CalculateAllSizes: true,
|
||||
Columns: []listColumn{
|
||||
NameColumn,
|
||||
DateModifiedColumn,
|
||||
DateCreatedColumn,
|
||||
DateAddedColumn,
|
||||
DateLastOpenedColumn,
|
||||
SizeColumn,
|
||||
KindColumn,
|
||||
LabelColumn,
|
||||
VersionColumn,
|
||||
CommentsColumn,
|
||||
},
|
||||
ColumnWidths: map[listColumn]int{
|
||||
(NameColumn): 300,
|
||||
(DateModifiedColumn): 181,
|
||||
(DateCreatedColumn): 181,
|
||||
(DateAddedColumn): 181,
|
||||
(DateLastOpenedColumn): 181,
|
||||
(SizeColumn): 97,
|
||||
(KindColumn): 115,
|
||||
(LabelColumn): 100,
|
||||
(VersionColumn): 75,
|
||||
(CommentsColumn): 300,
|
||||
},
|
||||
ColumnSortDirections: map[listColumn]direction{
|
||||
(NameColumn): Ascending,
|
||||
(DateModifiedColumn): Descending,
|
||||
(DateCreatedColumn): Descending,
|
||||
(DateAddedColumn): Descending,
|
||||
(DateLastOpenedColumn): Descending,
|
||||
(SizeColumn): Descending,
|
||||
(KindColumn): Ascending,
|
||||
(LabelColumn): Ascending,
|
||||
(VersionColumn): Ascending,
|
||||
(CommentsColumn): Ascending,
|
||||
},
|
||||
},
|
||||
License: License{
|
||||
DefaultLanguage: LocaleEnUS,
|
||||
Licenses: map[locale]string{
|
||||
//nolint:lll
|
||||
(LocaleEnGB): undent.String(`
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf820
|
||||
{\fonttbl\f0\fnil\fcharset0 Helvetica-Bold;\f1\fnil\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
|
||||
{\*\expandedcolortbl;;\cssrgb\c0\c0\c0;}
|
||||
\paperw11905\paperh16837\margl1133\margr1133\margb1133\margt1133
|
||||
\deftab720
|
||||
\pard\pardeftab720\sa160\partightenfactor0
|
||||
\f0\b\fs60 \cf2 \expnd0\expndtw0\kerning0
|
||||
\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 Test License\
|
||||
\pard\pardeftab720\sa160\partightenfactor0
|
||||
\fs36 \cf2 \strokec2 What is this?\
|
||||
\pard\pardeftab720\sa160\partightenfactor0
|
||||
\f1\b0\fs22 \cf2 \strokec2 This is the English license. It says what you are allowed to do with this software.\
|
||||
\
|
||||
}`,
|
||||
),
|
||||
//nolint:lll
|
||||
(LocaleSe): undent.String(`
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf820
|
||||
{\fonttbl\f0\fnil\fcharset0 Helvetica-Bold;\f1\fnil\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
|
||||
{\*\expandedcolortbl;;\cssrgb\c0\c0\c0;}
|
||||
\paperw11905\paperh16837\margl1133\margr1133\margb1133\margt1133
|
||||
\deftab720
|
||||
\pard\pardeftab720\sa160\partightenfactor0
|
||||
\f0\b\fs60 \cf2 \expnd0\expndtw0\kerning0
|
||||
\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 Test License\
|
||||
\pard\pardeftab720\sa160\partightenfactor0
|
||||
\fs36 \cf2 \strokec2 What is this?\
|
||||
\pard\pardeftab720\sa160\partightenfactor0
|
||||
\f1\b0\fs22 \cf2 \strokec2 Detta är den engelska licensen. Det står vad du får göra med den här programvaran.\
|
||||
\
|
||||
}`,
|
||||
),
|
||||
},
|
||||
Buttons: map[locale]Buttons{
|
||||
(LocaleEnGB): {
|
||||
LanguageName: "English",
|
||||
Agree: "Agree",
|
||||
Disagree: "Disagree",
|
||||
Print: "Print",
|
||||
Save: "Save",
|
||||
Message: "If you agree with the terms of this " +
|
||||
"license, press \"Agree\" to install the " +
|
||||
"software. If you do not agree, press " +
|
||||
"\"Disagree\".",
|
||||
},
|
||||
(LocaleSe): {
|
||||
LanguageName: "Svenska",
|
||||
Agree: "Godkänn",
|
||||
Disagree: "Håller inte med",
|
||||
Print: "Skriv ut",
|
||||
Save: "Spara",
|
||||
Message: "Om du godkänner villkoren i denna " +
|
||||
"licens, tryck på \"Godkänn\" för att " +
|
||||
"installera programvaran. Om du inte håller " +
|
||||
"med, tryck på \"Håller inte med\".",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
//nolint:lll
|
||||
want: undent.String(`
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
filename = "/builds/Emacs.2021-05-25.f4dc646.master.dmg"
|
||||
volume_name = "Emacs.2021-05-25.f4dc646.master"
|
||||
format = "UDBZ"
|
||||
compression_level = 8
|
||||
size = "100m"
|
||||
files = [
|
||||
"/builds/Emacs.app",
|
||||
"/builds/README.rtf",
|
||||
"/builds/hide-me.png"
|
||||
]
|
||||
symlinks = {
|
||||
"Applications": "/Applications",
|
||||
"QuickLook": "/Library/QuickLook",
|
||||
"System": "/System"
|
||||
}
|
||||
hide = [
|
||||
"hide-me.png",
|
||||
"QuickLook"
|
||||
]
|
||||
hide_extensions = [
|
||||
"README.rtf",
|
||||
"System"
|
||||
]
|
||||
icon_locations = {
|
||||
"Emacs.app": (200, 200),
|
||||
"README.rtf": (200, 300),
|
||||
"Applications": (400, 400),
|
||||
"QuickLook": (500, 400)
|
||||
}
|
||||
icon = "/opt/misc/assets/volIcon.icns"
|
||||
badge_icon = "/builds/Emacs.app/Contents/Resources/Icon.icns"
|
||||
background = "/opt/misc/assets/bg.tif"
|
||||
show_status_bar = True
|
||||
show_tab_view = True
|
||||
show_toolbar = True
|
||||
show_pathbar = True
|
||||
show_sidebar = True
|
||||
sidebar_width = 165
|
||||
default_view = "list-view"
|
||||
window_rect = ((200, 250), (680, 446))
|
||||
show_icon_preview = True
|
||||
show_item_info = True
|
||||
include_icon_view_settings = True
|
||||
include_list_view_settings = True
|
||||
arrange_by = "name"
|
||||
grid_offset = (42, 43)
|
||||
grid_spacing = 44.50
|
||||
scroll_position = (4.50, 5.50)
|
||||
label_position = "bottom"
|
||||
icon_size = 160.00
|
||||
text_size = 15.00
|
||||
list_sort_by = "name"
|
||||
list_scroll_position = (7, 8)
|
||||
list_icon_size = 16.00
|
||||
list_text_size = 12.00
|
||||
list_use_relative_dates = True
|
||||
list_calculate_all_sizes = True
|
||||
list_columns = [
|
||||
"name",
|
||||
"date-modified",
|
||||
"date-created",
|
||||
"date-added",
|
||||
"date-last-opened",
|
||||
"size",
|
||||
"kind",
|
||||
"label",
|
||||
"version",
|
||||
"comments"
|
||||
]
|
||||
list_column_widths = {
|
||||
"comments": 300,
|
||||
"date-added": 181,
|
||||
"date-created": 181,
|
||||
"date-last-opened": 181,
|
||||
"date-modified": 181,
|
||||
"kind": 115,
|
||||
"label": 100,
|
||||
"name": 300,
|
||||
"size": 97,
|
||||
"version": 75
|
||||
}
|
||||
list_column_sort_directions = {
|
||||
"comments": "ascending",
|
||||
"date-added": "descending",
|
||||
"date-created": "descending",
|
||||
"date-last-opened": "descending",
|
||||
"date-modified": "descending",
|
||||
"kind": "ascending",
|
||||
"label": "ascending",
|
||||
"name": "ascending",
|
||||
"size": "descending",
|
||||
"version": "ascending"
|
||||
}
|
||||
license = {
|
||||
"default-language": "en_US",
|
||||
"licenses": {
|
||||
"en_GB": """{\\rtf1\\ansi\\ansicpg1252\\cocoartf1504\\cocoasubrtf820
|
||||
{\\fonttbl\\f0\\fnil\\fcharset0 Helvetica-Bold;\\f1\\fnil\\fcharset0 Helvetica;}
|
||||
{\\colortbl;\\red255\\green255\\blue255;\\red0\\green0\\blue0;}
|
||||
{\\*\\expandedcolortbl;;\\cssrgb\\c0\\c0\\c0;}
|
||||
\\paperw11905\\paperh16837\\margl1133\\margr1133\\margb1133\\margt1133
|
||||
\\deftab720
|
||||
\\pard\\pardeftab720\\sa160\\partightenfactor0
|
||||
\\f0\\b\\fs60 \\cf2 \\expnd0\\expndtw0\\kerning0
|
||||
\\up0 \\nosupersub \\ulnone \\outl0\\strokewidth0 \\strokec2 Test License\\
|
||||
\\pard\\pardeftab720\\sa160\\partightenfactor0
|
||||
\\fs36 \\cf2 \\strokec2 What is this?\\
|
||||
\\pard\\pardeftab720\\sa160\\partightenfactor0
|
||||
\\f1\\b0\\fs22 \\cf2 \\strokec2 This is the English license. It says what you are allowed to do with this software.\\
|
||||
\\
|
||||
}""",
|
||||
"se": """{\\rtf1\\ansi\\ansicpg1252\\cocoartf1504\\cocoasubrtf820
|
||||
{\\fonttbl\\f0\\fnil\\fcharset0 Helvetica-Bold;\\f1\\fnil\\fcharset0 Helvetica;}
|
||||
{\\colortbl;\\red255\\green255\\blue255;\\red0\\green0\\blue0;}
|
||||
{\\*\\expandedcolortbl;;\\cssrgb\\c0\\c0\\c0;}
|
||||
\\paperw11905\\paperh16837\\margl1133\\margr1133\\margb1133\\margt1133
|
||||
\\deftab720
|
||||
\\pard\\pardeftab720\\sa160\\partightenfactor0
|
||||
\\f0\\b\\fs60 \\cf2 \\expnd0\\expndtw0\\kerning0
|
||||
\\up0 \\nosupersub \\ulnone \\outl0\\strokewidth0 \\strokec2 Test License\\
|
||||
\\pard\\pardeftab720\\sa160\\partightenfactor0
|
||||
\\fs36 \\cf2 \\strokec2 What is this?\\
|
||||
\\pard\\pardeftab720\\sa160\\partightenfactor0
|
||||
\\f1\\b0\\fs22 \\cf2 \\strokec2 Detta är den engelska licensen. Det står vad du får göra med den här programvaran.\\
|
||||
\\
|
||||
}"""
|
||||
},
|
||||
"buttons": {
|
||||
"en_GB": (
|
||||
"English",
|
||||
"Agree",
|
||||
"Disagree",
|
||||
"Print",
|
||||
"Save",
|
||||
"If you agree with the terms of this license, press \"Agree\" to install the software. If you do not agree, press \"Disagree\"."
|
||||
),
|
||||
"se": (
|
||||
"Svenska",
|
||||
"Godkänn",
|
||||
"Håller inte med",
|
||||
"Skriv ut",
|
||||
"Spara",
|
||||
"Om du godkänner villkoren i denna licens, tryck på \"Godkänn\" för att installera programvaran. Om du inte håller med, tryck på \"Håller inte med\"."
|
||||
)
|
||||
}
|
||||
}`,
|
||||
),
|
||||
},
|
||||
}
|
||||
for _, tt := range test {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
err := tt.entitlements.Write(&buf)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, tt.want, strings.TrimSpace(buf.String()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_pyStr(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
s string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
s: "",
|
||||
want: `""`,
|
||||
},
|
||||
{
|
||||
name: "regular string",
|
||||
s: "foo-bar nope :)",
|
||||
want: `"foo-bar nope :)"`,
|
||||
},
|
||||
{
|
||||
name: "with single quotes",
|
||||
s: "john's lost 'flip-flop'",
|
||||
want: `"john's lost 'flip-flop'"`,
|
||||
},
|
||||
{
|
||||
name: "with double quotes",
|
||||
s: `john has lost a "flip-flop"`,
|
||||
want: `"john has lost a \"flip-flop\""`,
|
||||
},
|
||||
{
|
||||
name: "with backslashes",
|
||||
s: `C:\path\to\file.txt`,
|
||||
want: `"C:\\path\\to\\file.txt"`,
|
||||
},
|
||||
{
|
||||
name: "with line-feed",
|
||||
s: "hello\nworld",
|
||||
want: `"hello\nworld"`,
|
||||
},
|
||||
{
|
||||
name: "with carriage return",
|
||||
s: "hello\rworld",
|
||||
want: `"hello\rworld"`,
|
||||
},
|
||||
{
|
||||
name: "with backslashes, single and double quotes",
|
||||
s: `john's "lost" C:\path\to\file.txt`,
|
||||
want: `"john's \"lost\" C:\\path\\to\\file.txt"`,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := pyStr(tt.s)
|
||||
|
||||
assert.Equal(t, tt.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
83
pkg/dmgbuild/window.go
Normal file
83
pkg/dmgbuild/window.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package dmgbuild
|
||||
|
||||
import "fmt"
|
||||
|
||||
type view string
|
||||
|
||||
//nolint:golint
|
||||
var (
|
||||
Icon view = "icon-view"
|
||||
list view = "list-view"
|
||||
Column view = "column-view"
|
||||
Coverflow view = "coverflow"
|
||||
)
|
||||
|
||||
type Window struct {
|
||||
PoxX int
|
||||
PosY int
|
||||
Width int
|
||||
Height int
|
||||
Background string
|
||||
ShowStatusBar bool
|
||||
ShowTabView bool
|
||||
ShowToolbar bool
|
||||
ShowPathbar bool
|
||||
ShowSidebar bool
|
||||
SidebarWidth int
|
||||
DefaultView view
|
||||
ShowIconPreview bool
|
||||
ShowItemInfo bool
|
||||
IncludeIconViewSettings bool
|
||||
IncludeListViewSettings bool
|
||||
}
|
||||
|
||||
func NewWindow() Window {
|
||||
return Window{
|
||||
PoxX: 100,
|
||||
PosY: 150,
|
||||
Width: 640,
|
||||
Height: 280,
|
||||
Background: "builtin-arrow",
|
||||
DefaultView: Icon,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Window) Render() []string {
|
||||
r := []string{}
|
||||
|
||||
if s.Background != "" {
|
||||
r = append(r, "background = "+pyStr(s.Background)+"\n")
|
||||
}
|
||||
|
||||
r = append(r, "show_status_bar = "+pyBool(s.ShowStatusBar)+"\n")
|
||||
r = append(r, "show_tab_view = "+pyBool(s.ShowTabView)+"\n")
|
||||
r = append(r, "show_toolbar = "+pyBool(s.ShowToolbar)+"\n")
|
||||
r = append(r, "show_pathbar = "+pyBool(s.ShowPathbar)+"\n")
|
||||
r = append(r, "show_sidebar = "+pyBool(s.ShowSidebar)+"\n")
|
||||
|
||||
if s.SidebarWidth > 0 {
|
||||
r = append(r, fmt.Sprintf(
|
||||
"sidebar_width = %d\n", s.SidebarWidth,
|
||||
))
|
||||
}
|
||||
if s.DefaultView != "" {
|
||||
r = append(r, "default_view = "+pyStr(string(s.DefaultView))+"\n")
|
||||
}
|
||||
if s.Width > 0 && s.Height > 0 {
|
||||
r = append(r, fmt.Sprintf(
|
||||
"window_rect = ((%d, %d), (%d, %d))\n",
|
||||
s.PoxX, s.PosY, s.Width, s.Height,
|
||||
))
|
||||
}
|
||||
|
||||
r = append(r, "show_icon_preview = "+pyBool(s.ShowIconPreview)+"\n")
|
||||
r = append(r, "show_item_info = "+pyBool(s.ShowIconPreview)+"\n")
|
||||
r = append(
|
||||
r, "include_icon_view_settings = "+pyBool(s.ShowIconPreview)+"\n",
|
||||
)
|
||||
r = append(
|
||||
r, "include_list_view_settings = "+pyBool(s.ShowIconPreview)+"\n",
|
||||
)
|
||||
|
||||
return r
|
||||
}
|
||||
24
pkg/gh/gh.go
Normal file
24
pkg/gh/gh.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package gh
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/google/go-github/v35/github"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
func New(ctx context.Context, token string) *github.Client {
|
||||
if token == "" {
|
||||
token = os.Getenv("GITHUB_TOKEN")
|
||||
}
|
||||
|
||||
if token == "" {
|
||||
return github.NewClient(nil)
|
||||
}
|
||||
|
||||
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
|
||||
tc := oauth2.NewClient(ctx, ts)
|
||||
|
||||
return github.NewClient(tc)
|
||||
}
|
||||
123
pkg/notarize/notarize.go
Normal file
123
pkg/notarize/notarize.go
Normal file
@@ -0,0 +1,123 @@
|
||||
package notarize
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bearer/gon/notarize"
|
||||
"github.com/bearer/gon/staple"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
File string
|
||||
BundleID string
|
||||
Username string
|
||||
Password string
|
||||
Provider string
|
||||
Staple bool
|
||||
}
|
||||
|
||||
func Notarize(ctx context.Context, opts *Options) error {
|
||||
logger := hclog.FromContext(ctx).Named("notarize")
|
||||
|
||||
notarizeOpts := ¬arize.Options{
|
||||
File: opts.File,
|
||||
DeveloperId: opts.Username,
|
||||
Password: opts.Password,
|
||||
Provider: opts.Provider,
|
||||
BaseCmd: exec.CommandContext(ctx, ""),
|
||||
Status: &status{
|
||||
Lock: &sync.Mutex{},
|
||||
Logger: logger,
|
||||
},
|
||||
// Ensure we don't log anything from the notarize package, as it will
|
||||
// log the password. We'll handle logging ourselves.
|
||||
Logger: hclog.NewNullLogger(),
|
||||
}
|
||||
|
||||
logger.Info("notarizing", "file", filepath.Base(opts.File))
|
||||
|
||||
info, _, err := notarize.Notarize(ctx, notarizeOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Info(
|
||||
"notarization complete",
|
||||
"status", info.Status,
|
||||
"message", info.StatusMessage,
|
||||
)
|
||||
|
||||
if opts.Staple {
|
||||
logger.Info("stapling", "file", filepath.Base(opts.File))
|
||||
err := staple.Staple(ctx, &staple.Options{
|
||||
File: opts.File,
|
||||
BaseCmd: exec.CommandContext(ctx, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type status struct {
|
||||
Lock *sync.Mutex
|
||||
Logger hclog.Logger
|
||||
|
||||
lastinfoStatus string
|
||||
lastInfoStatusTime time.Time
|
||||
|
||||
lastLogStatus string
|
||||
lastLogStatusTime time.Time
|
||||
}
|
||||
|
||||
var _ notarize.Status = (*status)(nil)
|
||||
|
||||
func (s *status) Submitting() {
|
||||
s.Lock.Lock()
|
||||
defer s.Lock.Unlock()
|
||||
|
||||
s.Logger.Info("submitting file for notarization...")
|
||||
}
|
||||
|
||||
func (s *status) Submitted(uuid string) {
|
||||
s.Lock.Lock()
|
||||
defer s.Lock.Unlock()
|
||||
|
||||
msg := "submitted, waiting for result from Apple"
|
||||
if s.Logger.IsDebug() {
|
||||
s.Logger.Debug(msg, "uuid", uuid)
|
||||
} else {
|
||||
s.Logger.Info(msg)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *status) InfoStatus(info notarize.Info) {
|
||||
s.Lock.Lock()
|
||||
defer s.Lock.Unlock()
|
||||
|
||||
if s.lastinfoStatus != info.Status ||
|
||||
time.Now().After(s.lastInfoStatusTime.Add(60*time.Second)) {
|
||||
s.lastinfoStatus = info.Status
|
||||
s.lastInfoStatusTime = time.Now()
|
||||
s.Logger.Info("status update", "status", info.Status)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *status) LogStatus(log notarize.Log) {
|
||||
s.Lock.Lock()
|
||||
defer s.Lock.Unlock()
|
||||
|
||||
if s.lastLogStatus != log.Status ||
|
||||
time.Now().After(s.lastLogStatusTime.Add(60*time.Second)) {
|
||||
s.lastLogStatus = log.Status
|
||||
s.lastLogStatusTime = time.Now()
|
||||
s.Logger.Info("log status update", "status", log.Status)
|
||||
}
|
||||
}
|
||||
74
pkg/osinfo/osinfo.go
Normal file
74
pkg/osinfo/osinfo.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package osinfo
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type OSInfo struct {
|
||||
Name string `yaml:"name" json:"name"`
|
||||
Version string `yaml:"version" json:"version"`
|
||||
SDKVersion string `yaml:"sdk_version" json:"sdk_version"`
|
||||
Arch string `yaml:"arch" json:"arch"`
|
||||
}
|
||||
|
||||
func New() (*OSInfo, error) {
|
||||
version, err := exec.Command("sw_vers", "-productVersion").Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sdkVersion := os.Getenv("MACOSX_DEPLOYMENT_TARGET")
|
||||
if sdkVersion == "" {
|
||||
var ver []byte
|
||||
ver, err = exec.Command("xcrun", "--show-sdk-version").Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sdkVersion = string(ver)
|
||||
}
|
||||
|
||||
arch, err := exec.Command("uname", "-m").CombinedOutput()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &OSInfo{
|
||||
Name: "macOS",
|
||||
Version: strings.TrimSpace(string(version)),
|
||||
SDKVersion: strings.TrimSpace(sdkVersion),
|
||||
Arch: strings.TrimSpace(string(arch)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DistinctVersion returns macOS version down to a distinct "major" version. For
|
||||
// macOS 10.x, this will include the first two numeric parts of the version
|
||||
// (10.15), while for 11.x and later, the first numeric part is enough (11).
|
||||
func (s *OSInfo) DistinctVersion() string {
|
||||
return s.distinctVersion(s.Version)
|
||||
}
|
||||
|
||||
// DistinctSDKVersion returns macOS version down to a distinct "major" version.
|
||||
// For macOS 10.x, this will include the first two numeric parts of the version
|
||||
// (10.15), while for 11.x and later, the first numeric part is enough (11).
|
||||
func (s *OSInfo) DistinctSDKVersion() string {
|
||||
return s.distinctVersion(s.SDKVersion)
|
||||
}
|
||||
|
||||
func (s *OSInfo) distinctVersion(version string) string {
|
||||
parts := strings.Split(version, ".")
|
||||
|
||||
if n, _ := strconv.Atoi(parts[0]); n >= 11 {
|
||||
return parts[0]
|
||||
}
|
||||
|
||||
max := len(parts)
|
||||
if max > 2 {
|
||||
max = 2
|
||||
}
|
||||
|
||||
return strings.Join(parts[0:max], ".")
|
||||
}
|
||||
190
pkg/plan/create.go
Normal file
190
pkg/plan/create.go
Normal file
@@ -0,0 +1,190 @@
|
||||
package plan
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/commit"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/osinfo"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/sanitize"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/source"
|
||||
)
|
||||
|
||||
var gitTagMatcher = regexp.MustCompile(
|
||||
`^emacs(-.*)?-((\d+\.\d+)(?:\.(\d+))?(-rc\d+)?(.+)?)$`,
|
||||
)
|
||||
|
||||
type TestBuildType string
|
||||
|
||||
//nolint:golint
|
||||
const (
|
||||
Draft TestBuildType = "draft"
|
||||
Prerelease TestBuildType = "prerelease"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
GithubToken string
|
||||
EmacsRepo string
|
||||
Ref string
|
||||
SHAOverride string
|
||||
OutputDir string
|
||||
TestBuild string
|
||||
TestBuildType TestBuildType
|
||||
Output io.Writer
|
||||
}
|
||||
|
||||
func Create(ctx context.Context, opts *Options) (*Plan, error) { //nolint:funlen
|
||||
logger := hclog.FromContext(ctx).Named("plan")
|
||||
|
||||
repo, err := repository.NewGitHub(opts.EmacsRepo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gh := gh.New(ctx, opts.GithubToken)
|
||||
|
||||
lookupRef := opts.Ref
|
||||
if opts.SHAOverride != "" {
|
||||
lookupRef = opts.SHAOverride
|
||||
}
|
||||
logger.Info("fetching commit info", "ref", lookupRef)
|
||||
|
||||
repoCommit, _, err := gh.Repositories.GetCommit(
|
||||
ctx, repo.Owner(), repo.Name(), lookupRef,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
commitInfo := commit.New(repoCommit)
|
||||
osInfo, err := osinfo.New()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
absoluteVersion := fmt.Sprintf(
|
||||
"%s.%s.%s",
|
||||
commitInfo.DateString(),
|
||||
commitInfo.ShortSHA(),
|
||||
sanitize.String(opts.Ref),
|
||||
)
|
||||
|
||||
version, channel, err := parseGitRef(opts.Ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var releaseName string
|
||||
switch channel {
|
||||
case release.Stable, release.RC:
|
||||
releaseName = "Emacs-" + version
|
||||
case release.Pretest:
|
||||
version += "-pretest"
|
||||
absoluteVersion += "-pretest"
|
||||
releaseName = "Emacs-" + version
|
||||
default:
|
||||
version = absoluteVersion
|
||||
releaseName = "Emacs." + version
|
||||
}
|
||||
|
||||
// Attempt to get the macOS SDK version from the environment, if it's not
|
||||
// available, use the version from the system.
|
||||
targetMacOSVersion := osInfo.DistinctSDKVersion()
|
||||
if targetMacOSVersion == "" {
|
||||
targetMacOSVersion = osInfo.DistinctVersion()
|
||||
}
|
||||
|
||||
buildName := fmt.Sprintf(
|
||||
"Emacs.%s.%s.%s",
|
||||
absoluteVersion,
|
||||
sanitize.String(osInfo.Name+"-"+targetMacOSVersion),
|
||||
sanitize.String(osInfo.Arch),
|
||||
)
|
||||
diskImage := buildName + ".dmg"
|
||||
|
||||
plan := &Plan{
|
||||
Build: &Build{
|
||||
Name: buildName,
|
||||
},
|
||||
Source: &source.Source{
|
||||
Ref: opts.Ref,
|
||||
Repository: repo,
|
||||
Commit: commitInfo,
|
||||
Tarball: &source.Tarball{
|
||||
URL: repo.TarballURL(commitInfo.SHA),
|
||||
},
|
||||
},
|
||||
OS: osInfo,
|
||||
Release: &Release{
|
||||
Name: releaseName,
|
||||
Prerelease: channel != release.Stable,
|
||||
Channel: channel,
|
||||
},
|
||||
Output: &Output{
|
||||
Directory: opts.OutputDir,
|
||||
DiskImage: diskImage,
|
||||
},
|
||||
}
|
||||
|
||||
if opts.TestBuild != "" {
|
||||
testName := sanitize.String(opts.TestBuild)
|
||||
|
||||
plan.Build.Name += ".test." + testName
|
||||
plan.Release.Title = "Test Builds (" + testName + ")"
|
||||
plan.Release.Name = "test-builds"
|
||||
|
||||
plan.Release.Prerelease = false
|
||||
plan.Release.Draft = true
|
||||
if opts.TestBuildType == Prerelease {
|
||||
plan.Release.Prerelease = true
|
||||
plan.Release.Draft = false
|
||||
}
|
||||
|
||||
index := strings.LastIndex(diskImage, ".")
|
||||
plan.Output.DiskImage = diskImage[:index] + ".test." +
|
||||
testName + diskImage[index:]
|
||||
}
|
||||
|
||||
return plan, nil
|
||||
}
|
||||
|
||||
func parseGitRef(ref string) (string, release.Channel, error) {
|
||||
m := gitTagMatcher.FindStringSubmatch(ref)
|
||||
|
||||
if len(m) == 0 {
|
||||
return "", release.Nightly, nil
|
||||
}
|
||||
|
||||
if strings.Contains(m[1], "pretest") {
|
||||
return m[2], release.Pretest, nil
|
||||
}
|
||||
|
||||
if m[4] != "" {
|
||||
n, err := strconv.Atoi(m[4])
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
if n >= 90 {
|
||||
return m[2], release.Pretest, nil
|
||||
}
|
||||
}
|
||||
|
||||
if strings.HasPrefix(m[5], "-rc") {
|
||||
return m[2], release.RC, nil
|
||||
}
|
||||
|
||||
if m[2] == m[3] {
|
||||
return m[2], release.Stable, nil
|
||||
}
|
||||
|
||||
return "", "", nil
|
||||
}
|
||||
421
pkg/plan/create_test.go
Normal file
421
pkg/plan/create_test.go
Normal file
@@ -0,0 +1,421 @@
|
||||
package plan
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_parseGitRef(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
type args struct {
|
||||
ref string
|
||||
}
|
||||
type want struct {
|
||||
version string
|
||||
channel release.Channel
|
||||
err string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want want
|
||||
}{
|
||||
{
|
||||
name: "master",
|
||||
args: args{ref: "master"},
|
||||
want: want{version: "", channel: release.Nightly, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-28",
|
||||
args: args{ref: "emacs-28"},
|
||||
want: want{version: "", channel: release.Nightly, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27",
|
||||
args: args{ref: "emacs-27"},
|
||||
want: want{version: "", channel: release.Nightly, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26",
|
||||
args: args{ref: "emacs-26"},
|
||||
want: want{version: "", channel: release.Nightly, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24",
|
||||
args: args{ref: "emacs-24"},
|
||||
want: want{version: "", channel: release.Nightly, err: ""},
|
||||
},
|
||||
{
|
||||
name: "feature/native-comp",
|
||||
args: args{ref: "feature/native-comp"},
|
||||
want: want{version: "", channel: release.Nightly, err: ""},
|
||||
},
|
||||
{
|
||||
name: "feature/pgtk",
|
||||
args: args{ref: "feature/pgtk"},
|
||||
want: want{version: "", channel: release.Nightly, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-19.34",
|
||||
args: args{ref: "emacs-19.34"},
|
||||
want: want{version: "19.34", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-20.4",
|
||||
args: args{ref: "emacs-20.4"},
|
||||
want: want{version: "20.4", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-22.3",
|
||||
args: args{ref: "emacs-22.3"},
|
||||
want: want{version: "22.3", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-23.4",
|
||||
args: args{ref: "emacs-23.4"},
|
||||
want: want{version: "23.4", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.0.97",
|
||||
args: args{ref: "emacs-24.0.97"},
|
||||
want: want{version: "24.0.97", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.2",
|
||||
args: args{ref: "emacs-24.2"},
|
||||
want: want{version: "24.2", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.2.90",
|
||||
args: args{ref: "emacs-24.2.90"},
|
||||
want: want{version: "24.2.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.2.93",
|
||||
args: args{ref: "emacs-24.2.93"},
|
||||
want: want{version: "24.2.93", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.3",
|
||||
args: args{ref: "emacs-24.3"},
|
||||
want: want{version: "24.3", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.3-rc1",
|
||||
args: args{ref: "emacs-24.3-rc1"},
|
||||
want: want{version: "24.3-rc1", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.3.90",
|
||||
args: args{ref: "emacs-24.3.90"},
|
||||
want: want{version: "24.3.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.3.94",
|
||||
args: args{ref: "emacs-24.3.94"},
|
||||
want: want{version: "24.3.94", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.4",
|
||||
args: args{ref: "emacs-24.4"},
|
||||
want: want{version: "24.4", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.4-rc1",
|
||||
args: args{ref: "emacs-24.4-rc1"},
|
||||
want: want{version: "24.4-rc1", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.4.90",
|
||||
args: args{ref: "emacs-24.4.90"},
|
||||
want: want{version: "24.4.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.4.91",
|
||||
args: args{ref: "emacs-24.4.91"},
|
||||
want: want{version: "24.4.91", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.5",
|
||||
args: args{ref: "emacs-24.5"},
|
||||
want: want{version: "24.5", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.5-rc1",
|
||||
args: args{ref: "emacs-24.5-rc1"},
|
||||
want: want{version: "24.5-rc1", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.5-rc3",
|
||||
args: args{ref: "emacs-24.5-rc3"},
|
||||
want: want{version: "24.5-rc3", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-24.5-rc3-fixed",
|
||||
args: args{ref: "emacs-24.5-rc3-fixed"},
|
||||
want: want{version: "24.5-rc3-fixed", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.0.90",
|
||||
args: args{ref: "emacs-25.0.90"},
|
||||
want: want{version: "25.0.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.0.95",
|
||||
args: args{ref: "emacs-25.0.95"},
|
||||
want: want{version: "25.0.95", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.1",
|
||||
args: args{ref: "emacs-25.1"},
|
||||
want: want{version: "25.1", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.1-rc1",
|
||||
args: args{ref: "emacs-25.1-rc1"},
|
||||
want: want{version: "25.1-rc1", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.1-rc2",
|
||||
args: args{ref: "emacs-25.1-rc2"},
|
||||
want: want{version: "25.1-rc2", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.1.90",
|
||||
args: args{ref: "emacs-25.1.90"},
|
||||
want: want{version: "25.1.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.1.91",
|
||||
args: args{ref: "emacs-25.1.91"},
|
||||
want: want{version: "25.1.91", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.2",
|
||||
args: args{ref: "emacs-25.2"},
|
||||
want: want{version: "25.2", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.2-rc1",
|
||||
args: args{ref: "emacs-25.2-rc1"},
|
||||
want: want{version: "25.2-rc1", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-25.2-rc2",
|
||||
args: args{ref: "emacs-25.2-rc2"},
|
||||
want: want{version: "25.2-rc2", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.0.90",
|
||||
args: args{ref: "emacs-26.0.90"},
|
||||
want: want{version: "26.0.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.0.91",
|
||||
args: args{ref: "emacs-26.0.91"},
|
||||
want: want{version: "26.0.91", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.1",
|
||||
args: args{ref: "emacs-26.1"},
|
||||
want: want{version: "26.1", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.1-rc1",
|
||||
args: args{ref: "emacs-26.1-rc1"},
|
||||
want: want{version: "26.1-rc1", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.1.90",
|
||||
args: args{ref: "emacs-26.1.90"},
|
||||
want: want{version: "26.1.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.1.92",
|
||||
args: args{ref: "emacs-26.1.92"},
|
||||
want: want{version: "26.1.92", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.2",
|
||||
args: args{ref: "emacs-26.2"},
|
||||
want: want{version: "26.2", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.2.90",
|
||||
args: args{ref: "emacs-26.2.90"},
|
||||
want: want{version: "26.2.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.3",
|
||||
args: args{ref: "emacs-26.3"},
|
||||
want: want{version: "26.3", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-26.3-rc1",
|
||||
args: args{ref: "emacs-26.3-rc1"},
|
||||
want: want{version: "26.3-rc1", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.0.90",
|
||||
args: args{ref: "emacs-27.0.90"},
|
||||
want: want{version: "27.0.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.0.91",
|
||||
args: args{ref: "emacs-27.0.91"},
|
||||
want: want{version: "27.0.91", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.1",
|
||||
args: args{ref: "emacs-27.1"},
|
||||
want: want{version: "27.1", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.1-rc1",
|
||||
args: args{ref: "emacs-27.1-rc1"},
|
||||
want: want{version: "27.1-rc1", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.1-rc2",
|
||||
args: args{ref: "emacs-27.1-rc2"},
|
||||
want: want{version: "27.1-rc2", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.1.90",
|
||||
args: args{ref: "emacs-27.1.90"},
|
||||
want: want{version: "27.1.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.1.91",
|
||||
args: args{ref: "emacs-27.1.91"},
|
||||
want: want{version: "27.1.91", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.2",
|
||||
args: args{ref: "emacs-27.2"},
|
||||
want: want{version: "27.2", channel: release.Stable, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.2-rc1",
|
||||
args: args{ref: "emacs-27.2-rc1"},
|
||||
want: want{version: "27.2-rc1", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-27.2-rc2",
|
||||
args: args{ref: "emacs-27.2-rc2"},
|
||||
want: want{version: "27.2-rc2", channel: release.RC, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-28.0.90",
|
||||
args: args{ref: "emacs-28.0.90"},
|
||||
want: want{version: "28.0.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-21.0.100",
|
||||
args: args{ref: "emacs-pretest-21.0.100"},
|
||||
want: want{version: "21.0.100", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-21.0.106",
|
||||
args: args{ref: "emacs-pretest-21.0.106"},
|
||||
want: want{version: "21.0.106", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-21.0.90",
|
||||
args: args{ref: "emacs-pretest-21.0.90"},
|
||||
want: want{version: "21.0.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-21.0.99",
|
||||
args: args{ref: "emacs-pretest-21.0.99"},
|
||||
want: want{version: "21.0.99", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-22.0.90",
|
||||
args: args{ref: "emacs-pretest-22.0.90"},
|
||||
want: want{version: "22.0.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-22.0.99",
|
||||
args: args{ref: "emacs-pretest-22.0.99"},
|
||||
want: want{version: "22.0.99", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-22.0.990",
|
||||
args: args{ref: "emacs-pretest-22.0.990"},
|
||||
want: want{version: "22.0.990", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-22.1.90",
|
||||
args: args{ref: "emacs-pretest-22.1.90"},
|
||||
want: want{version: "22.1.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-22.2.90",
|
||||
args: args{ref: "emacs-pretest-22.2.90"},
|
||||
want: want{version: "22.2.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-23.0.90",
|
||||
args: args{ref: "emacs-pretest-23.0.90"},
|
||||
want: want{version: "23.0.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-23.1.90",
|
||||
args: args{ref: "emacs-pretest-23.1.90"},
|
||||
want: want{version: "23.1.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-23.2.90",
|
||||
args: args{ref: "emacs-pretest-23.2.90"},
|
||||
want: want{version: "23.2.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-23.2.91",
|
||||
args: args{ref: "emacs-pretest-23.2.91"},
|
||||
want: want{version: "23.2.91", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-23.2.93",
|
||||
args: args{ref: "emacs-pretest-23.2.93"},
|
||||
want: want{version: "23.2.93", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-23.2.93.1",
|
||||
args: args{ref: "emacs-pretest-23.2.93.1"},
|
||||
want: want{version: "23.2.93.1", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-23.3.90",
|
||||
args: args{ref: "emacs-pretest-23.3.90"},
|
||||
want: want{version: "23.3.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-24.0.05",
|
||||
args: args{ref: "emacs-pretest-24.0.05"},
|
||||
want: want{version: "24.0.05", channel: release.Pretest, err: ""},
|
||||
},
|
||||
{
|
||||
name: "emacs-pretest-24.0.90",
|
||||
args: args{ref: "emacs-pretest-24.0.90"},
|
||||
want: want{version: "24.0.90", channel: release.Pretest, err: ""},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, gotChannel, err := parseGitRef(tt.args.ref)
|
||||
|
||||
assert.Equal(t, tt.want.version, got)
|
||||
assert.Equal(t, tt.want.channel, gotChannel)
|
||||
|
||||
if tt.want.err == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.want.err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
92
pkg/plan/plan.go
Normal file
92
pkg/plan/plan.go
Normal file
@@ -0,0 +1,92 @@
|
||||
package plan
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/osinfo"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/source"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type Plan struct {
|
||||
Build *Build `yaml:"build,omitempty" json:"build,omitempty"`
|
||||
Source *source.Source `yaml:"source,omitempty" json:"source,omitempty"`
|
||||
OS *osinfo.OSInfo `yaml:"os,omitempty" json:"os,omitempty"`
|
||||
Release *Release `yaml:"release,omitempty" json:"release,omitempty"`
|
||||
Output *Output `yaml:"output,omitempty" json:"output,omitempty"`
|
||||
}
|
||||
|
||||
// Load attempts to loads a plan YAML from given filename.
|
||||
func Load(filename string) (*Plan, error) {
|
||||
b, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := &Plan{}
|
||||
err = yaml.Unmarshal(b, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// WriteYAML writes plan in YAML format to given io.Writer.
|
||||
func (s *Plan) WriteYAML(w io.Writer) error {
|
||||
enc := yaml.NewEncoder(w)
|
||||
enc.SetIndent(2)
|
||||
|
||||
return enc.Encode(s)
|
||||
}
|
||||
|
||||
// YAML returns plan in YAML format.
|
||||
func (s *Plan) YAML() (string, error) {
|
||||
var buf bytes.Buffer
|
||||
err := s.WriteYAML(&buf)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return buf.String(), nil
|
||||
}
|
||||
|
||||
// WriteJSON writes plan in JSON format to given io.Writer.
|
||||
func (s *Plan) WriteJSON(w io.Writer) error {
|
||||
enc := json.NewEncoder(w)
|
||||
enc.SetIndent("", " ")
|
||||
|
||||
return enc.Encode(s)
|
||||
}
|
||||
|
||||
// JSON returns plan in JSON format.
|
||||
func (s *Plan) JSON() (string, error) {
|
||||
var buf bytes.Buffer
|
||||
err := s.WriteJSON(&buf)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return buf.String(), nil
|
||||
}
|
||||
|
||||
type Build struct {
|
||||
Name string `yaml:"name,omitempty" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type Release struct {
|
||||
Name string `yaml:"name" json:"name"`
|
||||
Title string `yaml:"title,omitempty" json:"title,omitempty"`
|
||||
Draft bool `yaml:"draft,omitempty" json:"draft,omitempty"`
|
||||
Prerelease bool `yaml:"prerelease,omitempty" json:"prerelease,omitempty"`
|
||||
Channel release.Channel `yaml:"channel,omitempty" json:"channel,omitempty"`
|
||||
}
|
||||
|
||||
type Output struct {
|
||||
Directory string `yaml:"directory,omitempty" json:"directory,omitempty"`
|
||||
DiskImage string `yaml:"disk_image,omitempty" json:"disk_image,omitempty"`
|
||||
}
|
||||
84
pkg/release/bulk.go
Normal file
84
pkg/release/bulk.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"context"
|
||||
"regexp"
|
||||
|
||||
"github.com/google/go-github/v35/github"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||
)
|
||||
|
||||
type BulkOptions struct {
|
||||
Repository *repository.Repository
|
||||
NamePattern string
|
||||
Prerelease *bool
|
||||
DryRun bool
|
||||
GithubToken string
|
||||
}
|
||||
|
||||
func Bulk(ctx context.Context, opts *BulkOptions) error {
|
||||
logger := hclog.FromContext(ctx).Named("release")
|
||||
gh := gh.New(ctx, opts.GithubToken)
|
||||
|
||||
nameMatcher, err := regexp.Compile(opts.NamePattern)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nextPage := 1
|
||||
lastPage := 1
|
||||
|
||||
for nextPage <= lastPage {
|
||||
releases, resp, err := gh.Repositories.ListReleases(
|
||||
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||
&github.ListOptions{
|
||||
Page: nextPage,
|
||||
PerPage: 100,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nextPage = resp.NextPage
|
||||
lastPage = resp.LastPage
|
||||
|
||||
for _, r := range releases {
|
||||
if !nameMatcher.MatchString(r.GetName()) {
|
||||
continue
|
||||
}
|
||||
|
||||
logger.Info("match found", "release", r.GetName())
|
||||
|
||||
var changes []interface{}
|
||||
if opts.Prerelease != nil && r.GetPrerelease() != *opts.Prerelease {
|
||||
changes = append(changes, "prerelease", *opts.Prerelease)
|
||||
r.Prerelease = opts.Prerelease
|
||||
}
|
||||
|
||||
if len(changes) > 0 {
|
||||
changes = append(
|
||||
[]interface{}{"release", r.GetName()}, changes...,
|
||||
)
|
||||
logger.Info("modifying", changes...)
|
||||
if !opts.DryRun {
|
||||
_, _, err = gh.Repositories.EditRelease(
|
||||
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||
r.GetID(), r,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if nextPage == 0 || lastPage == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
11
pkg/release/channel.go
Normal file
11
pkg/release/channel.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package release
|
||||
|
||||
type Channel string
|
||||
|
||||
// Release channels
|
||||
const (
|
||||
Stable Channel = "stable"
|
||||
RC Channel = "release-candidate"
|
||||
Pretest Channel = "pretest"
|
||||
Nightly Channel = "nightly"
|
||||
)
|
||||
80
pkg/release/check.go
Normal file
80
pkg/release/check.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||
)
|
||||
|
||||
type CheckOptions struct {
|
||||
// Repository is the GitHub repository to check.
|
||||
Repository *repository.Repository
|
||||
|
||||
// ReleaseName is the name of the GitHub Release to check.
|
||||
ReleaseName string
|
||||
|
||||
// AssetFiles is a list of files which must all exist in the release for
|
||||
// the check to pass.
|
||||
AssetFiles []string
|
||||
|
||||
// GitHubToken is the OAuth token used to talk to the GitHub API.
|
||||
GithubToken string
|
||||
}
|
||||
|
||||
// Check checks if a GitHub repository has a Release by given name, and if the
|
||||
// release contains assets with given filenames.
|
||||
func Check(ctx context.Context, opts *CheckOptions) error {
|
||||
logger := hclog.FromContext(ctx).Named("release")
|
||||
gh := gh.New(ctx, opts.GithubToken)
|
||||
|
||||
repo := opts.Repository
|
||||
|
||||
release, resp, err := gh.Repositories.GetReleaseByTag(
|
||||
ctx, repo.Owner(), repo.Name(), opts.ReleaseName,
|
||||
)
|
||||
if err != nil {
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return fmt.Errorf("release %s does not exist", opts.ReleaseName)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Info("release exists", "release", opts.ReleaseName)
|
||||
|
||||
missingMap := map[string]bool{}
|
||||
for _, filename := range opts.AssetFiles {
|
||||
filename = filepath.Base(filename)
|
||||
missingMap[filename] = true
|
||||
for _, a := range release.Assets {
|
||||
if a.GetName() == filename {
|
||||
logger.Info("asset exists", "filename", filename)
|
||||
delete(missingMap, filename)
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(missingMap) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var missing []string
|
||||
for f := range missingMap {
|
||||
missing = append(missing, f)
|
||||
}
|
||||
|
||||
logger.Error("missing assets", "filenames", missing)
|
||||
|
||||
return fmt.Errorf(
|
||||
"release %s is missing assets:\n- %s",
|
||||
opts.ReleaseName, strings.Join(missing, "\n-"),
|
||||
)
|
||||
}
|
||||
299
pkg/release/publish.go
Normal file
299
pkg/release/publish.go
Normal file
@@ -0,0 +1,299 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/google/go-github/v35/github"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/source"
|
||||
)
|
||||
|
||||
type releaseType int
|
||||
|
||||
// Release type constants
|
||||
const (
|
||||
Normal releaseType = iota
|
||||
Draft
|
||||
Prerelease
|
||||
)
|
||||
|
||||
type PublishOptions struct {
|
||||
// Repository is the GitHub repository to publish the release on.
|
||||
Repository *repository.Repository
|
||||
|
||||
// CommitRef is the git commit ref to create the release tag on.
|
||||
CommitRef string
|
||||
|
||||
// ReleaseName is the name of the git tag to create the release on.
|
||||
ReleaseName string
|
||||
|
||||
// ReleaseTitle is the title of the release, if not specified ReleaseName
|
||||
// will be used.
|
||||
ReleaseTitle string
|
||||
|
||||
// ReleaseType is the type of release to create (normal, prerelease, or
|
||||
// draft)
|
||||
ReleaseType releaseType
|
||||
|
||||
// Source contains the source used to build the asset files. When set a
|
||||
// release body/description text will be generated based on source commit
|
||||
// details.
|
||||
Source *source.Source
|
||||
|
||||
// AssetFiles is a list of files which must all exist in the release for
|
||||
// the check to pass.
|
||||
AssetFiles []string
|
||||
|
||||
// AssetSizeCheck causes a file size check for any existing asset files on a
|
||||
// release which have the same filename as a asset we want to upload. If the
|
||||
// size of the local and remote files are the same, the existing asset file
|
||||
// is left in place. When this is false, given asset files will always be
|
||||
// uploaded, replacing any asset files with the same filename.
|
||||
AssetSizeCheck bool
|
||||
|
||||
// GitHubToken is the OAuth token used to talk to the GitHub API.
|
||||
GithubToken string
|
||||
}
|
||||
|
||||
// Publish creates and publishes a GitHub release.
|
||||
func Publish(ctx context.Context, opts *PublishOptions) error {
|
||||
logger := hclog.FromContext(ctx).Named("release")
|
||||
gh := gh.New(ctx, opts.GithubToken)
|
||||
|
||||
files, err := publishFileList(opts.AssetFiles)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tagName := opts.ReleaseName
|
||||
name := opts.ReleaseTitle
|
||||
if name == "" {
|
||||
name = tagName
|
||||
}
|
||||
|
||||
prerelease := opts.ReleaseType == Prerelease
|
||||
draft := opts.ReleaseType == Draft
|
||||
|
||||
body := ""
|
||||
if opts.Source != nil {
|
||||
body, err = releaseBody(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger.Debug("rendered release body", "content", body)
|
||||
}
|
||||
|
||||
created := false
|
||||
logger.Info("checking release", "tag", tagName)
|
||||
release, resp, err := gh.Repositories.GetReleaseByTag(
|
||||
ctx, opts.Repository.Owner(), opts.Repository.Name(), tagName,
|
||||
)
|
||||
if err != nil {
|
||||
if resp.StatusCode != http.StatusNotFound {
|
||||
return err
|
||||
}
|
||||
|
||||
created = true
|
||||
logger.Info("creating release", "tag", tagName, "name", name)
|
||||
|
||||
release, _, err = gh.Repositories.CreateRelease(
|
||||
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||
&github.RepositoryRelease{
|
||||
Name: &name,
|
||||
TagName: &tagName,
|
||||
TargetCommitish: &opts.CommitRef,
|
||||
Prerelease: boolPtr(false),
|
||||
Draft: boolPtr(true),
|
||||
Body: &body,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = uploadReleaseAssets(ctx, gh, release, files, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
changed := false
|
||||
if release.GetName() != name {
|
||||
release.Name = &name
|
||||
changed = true
|
||||
}
|
||||
|
||||
if body != "" && release.GetBody() != body {
|
||||
release.Body = &body
|
||||
changed = true
|
||||
}
|
||||
|
||||
if release.GetDraft() != draft {
|
||||
release.Draft = &draft
|
||||
changed = true
|
||||
}
|
||||
|
||||
if !draft && release.GetPrerelease() != prerelease {
|
||||
release.Prerelease = &prerelease
|
||||
changed = true
|
||||
}
|
||||
|
||||
if changed {
|
||||
logger.Info("updating release attributes", "url", release.GetHTMLURL())
|
||||
release, _, err = gh.Repositories.EditRelease(
|
||||
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||
release.GetID(), release,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if created {
|
||||
logger.Info("release created", "url", release.GetHTMLURL())
|
||||
} else {
|
||||
logger.Info("release updated", "url", release.GetHTMLURL())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func uploadReleaseAssets(
|
||||
ctx context.Context,
|
||||
gh *github.Client,
|
||||
release *github.RepositoryRelease,
|
||||
fileNames []string,
|
||||
opts *PublishOptions,
|
||||
) error {
|
||||
logger := hclog.FromContext(ctx).Named("release")
|
||||
|
||||
for _, fileName := range fileNames {
|
||||
logger.Debug("processing asset", "file", filepath.Base(fileName))
|
||||
|
||||
fileIO, err := os.Open(fileName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fileIO.Close()
|
||||
|
||||
fileInfo, err := fileIO.Stat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fileBaseName := filepath.Base(fileName)
|
||||
assetExists := false
|
||||
|
||||
for _, a := range release.Assets {
|
||||
if a.GetName() != fileBaseName {
|
||||
continue
|
||||
}
|
||||
|
||||
if opts.AssetSizeCheck && a.GetSize() == int(fileInfo.Size()) {
|
||||
logger.Info("asset exists with correct size",
|
||||
"file", fileBaseName,
|
||||
"local_size", byteCountIEC(fileInfo.Size()),
|
||||
"remote_size", byteCountIEC(int64(a.GetSize())),
|
||||
)
|
||||
assetExists = true
|
||||
} else {
|
||||
logger.Info(
|
||||
"deleting existing asset", "file", fileBaseName,
|
||||
)
|
||||
_, err = gh.Repositories.DeleteReleaseAsset(
|
||||
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||
a.GetID(),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !assetExists {
|
||||
logger.Info("uploading asset",
|
||||
"file", fileBaseName,
|
||||
"size", byteCountIEC(fileInfo.Size()),
|
||||
)
|
||||
_, _, err = gh.Repositories.UploadReleaseAsset(
|
||||
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||
release.GetID(),
|
||||
&github.UploadOptions{Name: fileBaseName},
|
||||
fileIO,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func publishFileList(files []string) ([]string, error) {
|
||||
results := map[string]struct{}{}
|
||||
for _, file := range files {
|
||||
var err error
|
||||
file, err = filepath.Abs(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stat, err := os.Stat(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !stat.Mode().IsRegular() {
|
||||
return nil, fmt.Errorf("\"%s\" is not a file", file)
|
||||
}
|
||||
|
||||
results[file] = struct{}{}
|
||||
sumFile := file + ".sha256"
|
||||
|
||||
_, err = os.Stat(sumFile)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
results[sumFile] = struct{}{}
|
||||
}
|
||||
|
||||
var output []string
|
||||
for f := range results {
|
||||
output = append(output, f)
|
||||
}
|
||||
|
||||
return output, nil
|
||||
}
|
||||
|
||||
func byteCountIEC(b int64) string {
|
||||
const unit = 1024
|
||||
if b < unit {
|
||||
if b == 1 {
|
||||
return fmt.Sprintf("%d byte", b)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%d bytes", b)
|
||||
}
|
||||
div, exp := int64(unit), 0
|
||||
for n := b / unit; n >= unit; n /= unit {
|
||||
div *= unit
|
||||
exp++
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%.1f %ciB",
|
||||
float64(b)/float64(div), "KMGTPE"[exp])
|
||||
}
|
||||
|
||||
func boolPtr(v bool) *bool {
|
||||
return &v
|
||||
}
|
||||
78
pkg/release/release_body.go
Normal file
78
pkg/release/release_body.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var tplFuncs = template.FuncMap{
|
||||
"indent": func(n int, s string) string {
|
||||
pad := strings.Repeat(" ", n)
|
||||
|
||||
return pad + strings.ReplaceAll(s, "\n", "\n"+pad)
|
||||
},
|
||||
}
|
||||
|
||||
var bodyTpl = template.Must(template.New("body").Funcs(tplFuncs).Parse(`
|
||||
{{- $t := "` + "`" + `" -}}
|
||||
### Build Details
|
||||
|
||||
{{ with .SourceURL -}}
|
||||
- Source: {{ . }}
|
||||
{{- end }}
|
||||
{{- if .CommitURL }}
|
||||
- Commit: {{ .CommitURL }}
|
||||
{{- if .CommitSHA }} ({{ $t }}{{ .CommitSHA }}{{ $t }}){{ end }}
|
||||
{{- end }}
|
||||
{{- with .TarballURL }}
|
||||
- Tarball: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .BuildLogURL }}
|
||||
- Build Log: {{ . }} (available for 90 days)
|
||||
{{- end }}`,
|
||||
))
|
||||
|
||||
type bodyData struct {
|
||||
SourceURL string
|
||||
CommitSHA string
|
||||
CommitURL string
|
||||
BuildLogURL string
|
||||
TarballURL string
|
||||
}
|
||||
|
||||
func releaseBody(opts *PublishOptions) (string, error) {
|
||||
src := opts.Source
|
||||
|
||||
if src.Repository == nil || src.Commit == nil {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
data := &bodyData{
|
||||
SourceURL: src.Repository.TreeURL(src.Ref),
|
||||
CommitSHA: src.Commit.SHA,
|
||||
CommitURL: src.Repository.CommitURL(src.Commit.SHA),
|
||||
TarballURL: src.Repository.TarballURL(src.Commit.SHA),
|
||||
}
|
||||
|
||||
// If available, use the exact value from the build plan.
|
||||
if src.Tarball != nil {
|
||||
data.TarballURL = src.Tarball.URL
|
||||
}
|
||||
|
||||
// If running within GitHub Actions, provide link to build log.
|
||||
if opts.Repository != nil {
|
||||
if id := os.Getenv("GITHUB_RUN_ID"); id != "" {
|
||||
data.BuildLogURL = opts.Repository.ActionRunURL(id)
|
||||
}
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
err := bodyTpl.Execute(&buf, data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return buf.String(), nil
|
||||
}
|
||||
44
pkg/release/version.go
Normal file
44
pkg/release/version.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Errors
|
||||
var (
|
||||
Err = errors.New("release")
|
||||
ErrInvalidName = fmt.Errorf("%w: invalid name", Err)
|
||||
ErrEmptyVersion = fmt.Errorf("%w: empty version", Err)
|
||||
ErrNotStableRef = fmt.Errorf(
|
||||
"%w: git ref is not stable tagged release", Err,
|
||||
)
|
||||
)
|
||||
|
||||
var (
|
||||
stableVersion = regexp.MustCompile(`^\d+\.\d+(?:[a-z]+)?$`)
|
||||
stableGitRef = regexp.MustCompile(`^emacs-(\d+\.\d+(?:[a-z]+)?)$`)
|
||||
)
|
||||
|
||||
func VersionToName(version string) (string, error) {
|
||||
if version == "" {
|
||||
return "", ErrEmptyVersion
|
||||
}
|
||||
|
||||
if stableVersion.MatchString(version) ||
|
||||
strings.HasSuffix(version, "-pretest") {
|
||||
return "Emacs-" + version, nil
|
||||
}
|
||||
|
||||
return "Emacs." + version, nil
|
||||
}
|
||||
|
||||
func GitRefToStableVersion(ref string) (string, error) {
|
||||
if m := stableGitRef.FindStringSubmatch(ref); len(m) > 1 {
|
||||
return m[1], nil
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("%w: \"%s\"", ErrNotStableRef, ref)
|
||||
}
|
||||
138
pkg/release/version_test.go
Normal file
138
pkg/release/version_test.go
Normal file
@@ -0,0 +1,138 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestVersionToName(t *testing.T) {
|
||||
type args struct {
|
||||
version string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
args: args{
|
||||
version: "",
|
||||
},
|
||||
wantErr: "release: empty version",
|
||||
},
|
||||
{
|
||||
name: "nightly",
|
||||
args: args{
|
||||
version: "2021-07-01.1b88404.master",
|
||||
},
|
||||
want: "Emacs.2021-07-01.1b88404.master",
|
||||
},
|
||||
{
|
||||
name: "stable",
|
||||
args: args{
|
||||
version: "27.2",
|
||||
},
|
||||
want: "Emacs-27.2",
|
||||
},
|
||||
{
|
||||
name: "stable with letter",
|
||||
args: args{
|
||||
version: "23.3b",
|
||||
},
|
||||
want: "Emacs-23.3b",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := VersionToName(tt.args.version)
|
||||
|
||||
assert.Equal(t, tt.want, got)
|
||||
|
||||
if tt.wantErr != "" {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGitRefToStableVersion(t *testing.T) {
|
||||
type args struct {
|
||||
version string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
args: args{
|
||||
version: "",
|
||||
},
|
||||
wantErr: "release: git ref is not stable tagged release: \"\"",
|
||||
},
|
||||
{
|
||||
name: "master",
|
||||
args: args{
|
||||
version: "master",
|
||||
},
|
||||
wantErr: "release: git ref is not stable tagged release: " +
|
||||
"\"master\"",
|
||||
},
|
||||
{
|
||||
name: "feature",
|
||||
args: args{
|
||||
version: "feature/native-comp",
|
||||
},
|
||||
wantErr: "release: git ref is not stable tagged release: " +
|
||||
"\"feature/native-comp\"",
|
||||
},
|
||||
{
|
||||
name: "stable",
|
||||
args: args{
|
||||
version: "emacs-27.2",
|
||||
},
|
||||
want: "27.2",
|
||||
},
|
||||
{
|
||||
name: "stable with letter",
|
||||
args: args{
|
||||
version: "emacs-23.3b",
|
||||
},
|
||||
want: "23.3b",
|
||||
},
|
||||
{
|
||||
name: "future stable",
|
||||
args: args{
|
||||
version: "emacs-239.33",
|
||||
},
|
||||
want: "239.33",
|
||||
},
|
||||
{
|
||||
name: "future stable with letter",
|
||||
args: args{
|
||||
version: "emacs-239.33c",
|
||||
},
|
||||
want: "239.33c",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := GitRefToStableVersion(tt.args.version)
|
||||
|
||||
assert.Equal(t, tt.want, got)
|
||||
|
||||
if tt.wantErr != "" {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
142
pkg/repository/repository.go
Normal file
142
pkg/repository/repository.go
Normal file
@@ -0,0 +1,142 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//nolint:golint
|
||||
var (
|
||||
Err = errors.New("repository")
|
||||
ErrGitHub = fmt.Errorf("%w: github", Err)
|
||||
)
|
||||
|
||||
const GitHubBaseURL = "https://github.com/"
|
||||
|
||||
// Type is a repository type
|
||||
type Type string
|
||||
|
||||
const GitHub Type = "github"
|
||||
|
||||
// Repository represents basic information about a repository with helper
|
||||
// methods to get various pieces of information from it.
|
||||
type Repository struct {
|
||||
Type Type `yaml:"type,omitempty" json:"type,omitempty"`
|
||||
Source string `yaml:"source,omitempty" json:"source,omitempty"`
|
||||
}
|
||||
|
||||
func NewGitHub(ownerAndName string) (*Repository, error) {
|
||||
parts := strings.Split(ownerAndName, "/")
|
||||
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
|
||||
return nil, fmt.Errorf(
|
||||
"%w: repository must be give in \"owner/name\" format",
|
||||
ErrGitHub,
|
||||
)
|
||||
}
|
||||
|
||||
return &Repository{
|
||||
Type: GitHub,
|
||||
Source: ownerAndName,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Repository) Owner() string {
|
||||
switch s.Type {
|
||||
case GitHub:
|
||||
return strings.SplitN(s.Source, "/", 2)[0]
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Repository) Name() string {
|
||||
switch s.Type {
|
||||
case GitHub:
|
||||
return strings.SplitN(s.Source, "/", 2)[1]
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Repository) URL() string {
|
||||
switch s.Type {
|
||||
case GitHub:
|
||||
return GitHubBaseURL + s.Source
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Repository) CloneURL() string {
|
||||
switch s.Type {
|
||||
case GitHub:
|
||||
return GitHubBaseURL + s.Source + ".git"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Repository) TarballURL(ref string) string {
|
||||
if ref == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
switch s.Type {
|
||||
case GitHub:
|
||||
return GitHubBaseURL + s.Source + "/tarball/" + ref
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Repository) CommitURL(ref string) string {
|
||||
if ref == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
switch s.Type {
|
||||
case GitHub:
|
||||
return GitHubBaseURL + s.Source + "/commit/" + ref
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Repository) TreeURL(ref string) string {
|
||||
if ref == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
switch s.Type {
|
||||
case GitHub:
|
||||
return GitHubBaseURL + s.Source + "/tree/" + ref
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Repository) ActionRunURL(runID string) string {
|
||||
if runID == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
switch s.Type {
|
||||
case GitHub:
|
||||
return GitHubBaseURL + s.Source + "/actions/runs/" + runID
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Repository) ReleaseURL(releaseName string) string {
|
||||
if releaseName == "" {
|
||||
return ""
|
||||
}
|
||||
switch s.Type {
|
||||
case GitHub:
|
||||
return GitHubBaseURL + s.Source + "/releases/tag/" + releaseName
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
54
pkg/repository/repository_test.go
Normal file
54
pkg/repository/repository_test.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRepository_ReleaseURL(t *testing.T) {
|
||||
type fields struct {
|
||||
Type Type
|
||||
Source string
|
||||
}
|
||||
type args struct {
|
||||
releaseName string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "empty name",
|
||||
fields: fields{Type: GitHub, Source: "foo/bar"},
|
||||
args: args{releaseName: ""},
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "GitHub, foo/bar, v1.0.0",
|
||||
fields: fields{Type: GitHub, Source: "foo/bar"},
|
||||
args: args{releaseName: "v1.0.0"},
|
||||
want: "https://github.com/foo/bar/releases/tag/v1.0.0",
|
||||
},
|
||||
{
|
||||
name: "Not GitHub, foo/bar, v1.0.0",
|
||||
fields: fields{Type: Type("oops"), Source: "foo/bar"},
|
||||
args: args{releaseName: "v1.0.0"},
|
||||
want: "",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
repo := &Repository{
|
||||
Type: tt.fields.Type,
|
||||
Source: tt.fields.Source,
|
||||
}
|
||||
|
||||
got := repo.ReleaseURL(tt.args.releaseName)
|
||||
|
||||
assert.Equal(t, tt.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
9
pkg/sanitize/string.go
Normal file
9
pkg/sanitize/string.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package sanitize
|
||||
|
||||
import "regexp"
|
||||
|
||||
var nonAlphaNum = regexp.MustCompile(`[^\w_-]+`)
|
||||
|
||||
func String(s string) string {
|
||||
return nonAlphaNum.ReplaceAllString(s, "-")
|
||||
}
|
||||
141
pkg/sign/emacs.go
Normal file
141
pkg/sign/emacs.go
Normal file
@@ -0,0 +1,141 @@
|
||||
package sign
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
// Emacs signs a Emacs.app application bundle with Apple's codesign utility,
|
||||
// using correct default entitlements, and also pre-signing any *.eln files
|
||||
// which are in the bundle, as codesign will not detect them as requiring
|
||||
// signing even with the --deep flag.
|
||||
func Emacs(ctx context.Context, appBundle string, opts *Options) error {
|
||||
if !strings.HasSuffix(appBundle, ".app") {
|
||||
return fmt.Errorf("%s is not a .app application bundle", appBundle)
|
||||
}
|
||||
|
||||
appBundle, err := filepath.Abs(appBundle)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = os.Stat(appBundle)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger := hclog.FromContext(ctx).Named("sign")
|
||||
logger.Info("preparing to sign Emacs.app", "app", appBundle)
|
||||
|
||||
newOpts := *opts
|
||||
|
||||
if newOpts.EntitlementsFile == "" {
|
||||
if newOpts.Entitlements == nil {
|
||||
e := Entitlements(DefaultEmacsEntitlements)
|
||||
newOpts.Entitlements = &e
|
||||
}
|
||||
|
||||
f, err2 := newOpts.Entitlements.TempFile()
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
defer os.Remove(f)
|
||||
|
||||
newOpts.EntitlementsFile = f
|
||||
newOpts.Entitlements = nil
|
||||
}
|
||||
|
||||
err = signElnFiles(ctx, appBundle, &newOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = signCLIHelper(ctx, appBundle, &newOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Ensure app bundle is signed last, as modifications to the bundle after
|
||||
// signing will invalidate the signature. Hence anything within it that
|
||||
// needs to be separately signed, has to happen before signing the whole
|
||||
// application bundle.
|
||||
return Files(ctx, []string{appBundle}, &newOpts)
|
||||
}
|
||||
|
||||
func signElnFiles(ctx context.Context, appBundle string, opts *Options) error {
|
||||
logger := hclog.FromContext(ctx).Named("sign")
|
||||
|
||||
elnFiles, err := elnFiles(appBundle)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(elnFiles) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
logger.Info(fmt.Sprintf(
|
||||
"found %d native-lisp *.eln files in %s to sign",
|
||||
len(elnFiles), filepath.Base(appBundle),
|
||||
))
|
||||
for _, file := range elnFiles {
|
||||
err := Files(ctx, []string{file}, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func signCLIHelper(ctx context.Context, appBundle string, opts *Options) error {
|
||||
logger := hclog.FromContext(ctx).Named("sign")
|
||||
|
||||
cliHelper := filepath.Join(appBundle, "Contents", "MacOS", "bin", "emacs")
|
||||
fi, err := os.Stat(cliHelper)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
} else if err == nil && fi.Mode().IsRegular() {
|
||||
logger.Info(fmt.Sprintf(
|
||||
"found Contents/MacOS/bin/emacs CLI helper script in %s to sign",
|
||||
filepath.Base(appBundle),
|
||||
))
|
||||
|
||||
err = Files(ctx, []string{cliHelper}, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// elnFiles finds all native-compilation *.eln files within a Emacs.app bundle,
|
||||
// excluding any *.eln which should be automatically located by codesign when
|
||||
// signing the Emacs.app bundle itself with the --deep flag. Essentially this
|
||||
// only returns *.eln files which must be individually signed before signing the
|
||||
// app bundle itself.
|
||||
func elnFiles(emacsApp string) ([]string, error) {
|
||||
var files []string
|
||||
walkDirFunc := func(path string, d fs.DirEntry, _ error) error {
|
||||
if d.Type().IsRegular() && strings.HasSuffix(path, ".eln") &&
|
||||
!strings.Contains(path, ".app/Contents/Frameworks/") {
|
||||
files = append(files, path)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
err := filepath.WalkDir(filepath.Join(emacsApp, "Contents"), walkDirFunc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return files, nil
|
||||
}
|
||||
55
pkg/sign/entitlements.go
Normal file
55
pkg/sign/entitlements.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package sign
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"io"
|
||||
"os"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// DefaultEmacsEntitlements is the default set of entitlements application
|
||||
// bundles are signed with if no entitlements are provided.
|
||||
var DefaultEmacsEntitlements = []string{
|
||||
"com.apple.security.cs.allow-jit",
|
||||
"com.apple.security.network.client",
|
||||
"com.apple.security.cs.disable-library-validation",
|
||||
"com.apple.security.cs.allow-dyld-environment-variables",
|
||||
"com.apple.security.automation.apple-events",
|
||||
}
|
||||
|
||||
//go:embed entitlements.tpl
|
||||
var entitlementsTemplate string
|
||||
|
||||
type Entitlements []string
|
||||
|
||||
func (e Entitlements) XML() ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
err := e.Write(&buf)
|
||||
|
||||
return buf.Bytes(), err
|
||||
}
|
||||
|
||||
func (e Entitlements) Write(w io.Writer) error {
|
||||
tpl, err := template.New("entitlements.plist").Parse(entitlementsTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tpl.Execute(w, e)
|
||||
}
|
||||
|
||||
func (e Entitlements) TempFile() (string, error) {
|
||||
f, err := os.CreateTemp("", "*.entitlements.plist")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
err = e.Write(f)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return f.Name(), nil
|
||||
}
|
||||
9
pkg/sign/entitlements.tpl
Normal file
9
pkg/sign/entitlements.tpl
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
{{- range . }}
|
||||
<key>{{ . }}</key>
|
||||
<true/>{{ end }}
|
||||
</dict>
|
||||
</plist>
|
||||
121
pkg/sign/entitlements_test.go
Normal file
121
pkg/sign/entitlements_test.go
Normal file
@@ -0,0 +1,121 @@
|
||||
package sign
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/jimeh/undent"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var entitlementsTestCases = []struct {
|
||||
name string
|
||||
entitlements Entitlements
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "none",
|
||||
entitlements: Entitlements{},
|
||||
//nolint:lll
|
||||
want: undent.String(`
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
</dict>
|
||||
</plist>`,
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "one",
|
||||
entitlements: Entitlements{"com.apple.security.cs.allow-jit"},
|
||||
//nolint:lll
|
||||
want: undent.String(`
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>`,
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "many",
|
||||
entitlements: Entitlements{
|
||||
"com.apple.security.cs.allow-jit",
|
||||
"com.apple.security.network.client",
|
||||
"com.apple.security.cs.disable-library-validation",
|
||||
"com.apple.security.cs.allow-dyld-environment-variables",
|
||||
"com.apple.security.automation.apple-events",
|
||||
},
|
||||
//nolint:lll
|
||||
want: undent.String(`
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||
<true/>
|
||||
<key>com.apple.security.automation.apple-events</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>`,
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
func TestDefaultEmacsEntitlements(t *testing.T) {
|
||||
assert.Equal(t,
|
||||
[]string{
|
||||
"com.apple.security.cs.allow-jit",
|
||||
"com.apple.security.network.client",
|
||||
"com.apple.security.cs.disable-library-validation",
|
||||
"com.apple.security.cs.allow-dyld-environment-variables",
|
||||
"com.apple.security.automation.apple-events",
|
||||
},
|
||||
DefaultEmacsEntitlements,
|
||||
)
|
||||
}
|
||||
|
||||
func TestEntitlements_Write(t *testing.T) {
|
||||
for _, tt := range entitlementsTestCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
err := tt.entitlements.Write(&buf)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, tt.want, strings.TrimSpace(buf.String()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEntitlements_TempFile(t *testing.T) {
|
||||
for _, tt := range entitlementsTestCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tmpFile, err := tt.entitlements.TempFile()
|
||||
require.NoError(t, err)
|
||||
defer os.Remove(tmpFile)
|
||||
|
||||
content, err := os.ReadFile(tmpFile)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, tt.want, strings.TrimSpace(string(content)))
|
||||
assert.True(t,
|
||||
strings.HasSuffix(tmpFile, ".entitlements.plist"),
|
||||
"temp file name does not match \"*.entitlements.plist\"",
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
67
pkg/sign/files.go
Normal file
67
pkg/sign/files.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package sign
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
func Files(ctx context.Context, files []string, opts *Options) error {
|
||||
logger := hclog.FromContext(ctx).Named("sign")
|
||||
args := []string{}
|
||||
|
||||
if opts.Identity != "" {
|
||||
args = append(args, "--sign", opts.Identity)
|
||||
}
|
||||
if opts.Deep {
|
||||
args = append(args, "--deep")
|
||||
}
|
||||
if opts.Timestamp {
|
||||
args = append(args, "--timestamp")
|
||||
}
|
||||
if opts.Force {
|
||||
args = append(args, "--force")
|
||||
}
|
||||
if opts.Verbose {
|
||||
args = append(args, "--verbose")
|
||||
}
|
||||
if len(opts.Options) > 0 {
|
||||
args = append(args, "--options", strings.Join(opts.Options, ","))
|
||||
}
|
||||
|
||||
if opts.EntitlementsFile != "" {
|
||||
args = append(args, "--entitlements", opts.EntitlementsFile)
|
||||
} else if opts.Entitlements != nil {
|
||||
entitlementsFile, err := opts.Entitlements.TempFile()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.Remove(entitlementsFile)
|
||||
logger.Debug("wrote entitlements", "file", entitlementsFile)
|
||||
|
||||
args = append(args, "--entitlements", entitlementsFile)
|
||||
}
|
||||
|
||||
baseCmd := opts.CodeSignCmd
|
||||
if baseCmd == "" {
|
||||
path, err := exec.LookPath("codesign")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
baseCmd = path
|
||||
}
|
||||
|
||||
args = append(args, files...)
|
||||
|
||||
logger.Debug("executing", "command", baseCmd, "args", args)
|
||||
cmd := exec.CommandContext(ctx, baseCmd, args...)
|
||||
if opts.Output != nil {
|
||||
cmd.Stdout = opts.Output
|
||||
cmd.Stderr = opts.Output
|
||||
}
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
16
pkg/sign/options.go
Normal file
16
pkg/sign/options.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package sign
|
||||
|
||||
import "io"
|
||||
|
||||
type Options struct {
|
||||
Identity string
|
||||
Entitlements *Entitlements
|
||||
EntitlementsFile string
|
||||
Options []string
|
||||
Deep bool
|
||||
Timestamp bool
|
||||
Force bool
|
||||
Verbose bool
|
||||
Output io.Writer
|
||||
CodeSignCmd string
|
||||
}
|
||||
17
pkg/source/source.go
Normal file
17
pkg/source/source.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/commit"
|
||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||
)
|
||||
|
||||
type Source struct {
|
||||
Ref string `yaml:"ref,omitempty" json:"ref,omitempty"`
|
||||
Repository *repository.Repository `yaml:"repository,omitempty" json:"repository,omitempty"`
|
||||
Commit *commit.Commit `yaml:"commit,omitempty" json:"commit,omitempty"`
|
||||
Tarball *Tarball `yaml:"tarball,omitempty" json:"tarball,omitempty"`
|
||||
}
|
||||
|
||||
type Tarball struct {
|
||||
URL string `yaml:"url,omitempty" json:"url,omitempty"`
|
||||
}
|
||||
1
requirements-ci.txt
Normal file
1
requirements-ci.txt
Normal file
@@ -0,0 +1 @@
|
||||
dmgbuild
|
||||
Reference in New Issue
Block a user