fontist 3.0.37 → 3.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +1 -0
- data/.github/workflows/tebako-pack.yml +43 -4
- data/Gemfile +4 -5
- data/README.adoc +52 -2
- data/fontist.gemspec +2 -1
- data/lib/fontist/cli.rb +20 -0
- data/lib/fontist/font_installer.rb +65 -52
- data/lib/fontist/font_operations/convert.rb +1 -3
- data/lib/fontist/font_operations/extract.rb +3 -3
- data/lib/fontist/font_operations/instance.rb +7 -3
- data/lib/fontist/font_operations/subset.rb +7 -11
- data/lib/fontist/format_matcher.rb +21 -9
- data/lib/fontist/format_spec.rb +28 -3
- data/lib/fontist/import/google/font_database.rb +1 -0
- data/lib/fontist/import/google/formula_builders/formula_builder_v4.rb +6 -1
- data/lib/fontist/import/google/formula_builders/formula_builder_v5.rb +12 -0
- data/lib/fontist/import/sil_importer.rb +1 -0
- data/lib/fontist/manifest.rb +42 -16
- data/lib/fontist/manifest_cli.rb +19 -1
- data/lib/fontist/scan_row_fonts.rb +82 -0
- data/lib/fontist/system_index.rb +63 -5
- data/lib/fontist/validator.rb +64 -33
- data/lib/fontist/version.rb +1 -1
- data/lib/fontist.rb +1 -0
- data/packaging/nfpm.yaml +6 -1
- data/packaging/scripts/postinstall.sh +5 -0
- data/packaging/scripts/preremove.sh +12 -0
- data/script/tebako/git-prep.sh +25 -0
- data/script/tebako/package-smoke.sh +7 -2
- data/script/tebako/package.sh +3 -0
- data/script/tebako/smoke.sh +12 -1
- metadata +22 -4
data/lib/fontist/manifest.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "lutaml/model"
|
|
2
|
+
require_relative "format_matcher"
|
|
2
3
|
require_relative "format_spec"
|
|
3
4
|
|
|
4
5
|
module Fontist
|
|
@@ -10,6 +11,8 @@ module Fontist
|
|
|
10
11
|
attribute :format, :string
|
|
11
12
|
attribute :variable_axes, :string, collection: true
|
|
12
13
|
attribute :prefer_variable, :boolean, default: false
|
|
14
|
+
attribute :variable, :boolean
|
|
15
|
+
attribute :all_variants, :boolean, default: false
|
|
13
16
|
|
|
14
17
|
# Transcoding options
|
|
15
18
|
attribute :transcode_path, :string
|
|
@@ -30,6 +33,8 @@ module Fontist
|
|
|
30
33
|
format: format,
|
|
31
34
|
variable_axes: variable_axes,
|
|
32
35
|
prefer_variable: prefer_variable,
|
|
36
|
+
variable: variable,
|
|
37
|
+
all_variants: all_variants,
|
|
33
38
|
transcode_path: transcode_path,
|
|
34
39
|
keep_original: keep_original,
|
|
35
40
|
collection_index: collection_index,
|
|
@@ -63,6 +68,16 @@ module Fontist
|
|
|
63
68
|
Fontist::SystemFont.find_styles(font, style)
|
|
64
69
|
end
|
|
65
70
|
|
|
71
|
+
# True when every located file fails the font's static/variant spec —
|
|
72
|
+
# e.g. only a variable font's named instance resolves a variable: false
|
|
73
|
+
# request — so installation must fetch files that actually match.
|
|
74
|
+
def unsatisfied_by_spec?
|
|
75
|
+
return false unless format_spec.has_constraints?
|
|
76
|
+
|
|
77
|
+
matcher = FormatMatcher.new(format_spec)
|
|
78
|
+
style_paths.all? { |indexed| !matcher.matches_indexed_font?(indexed) }
|
|
79
|
+
end
|
|
80
|
+
|
|
66
81
|
def install(confirmation: "no", hide_licenses: false, no_progress: false,
|
|
67
82
|
location: nil)
|
|
68
83
|
validate_location_parameter!(location)
|
|
@@ -146,7 +161,8 @@ module Fontist
|
|
|
146
161
|
# format: woff2
|
|
147
162
|
#
|
|
148
163
|
# The plain form `Roboto: [Regular, Bold]` stays valid.
|
|
149
|
-
FONT_OPTIONS = %w[format variable_axes prefer_variable
|
|
164
|
+
FONT_OPTIONS = %w[format variable_axes prefer_variable variable
|
|
165
|
+
all_variants transcode_path
|
|
150
166
|
keep_original collection_index subset_unicodes
|
|
151
167
|
subset_text fallback_to_original instance].freeze
|
|
152
168
|
|
|
@@ -193,29 +209,39 @@ module Fontist
|
|
|
193
209
|
def self.from_file(path, locations: false)
|
|
194
210
|
Fontist.ui.debug("Manifest: #{path}")
|
|
195
211
|
|
|
196
|
-
|
|
197
|
-
raise Fontist::Errors::ManifestCouldNotBeFoundError,
|
|
198
|
-
"Manifest file not found: #{path}"
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
file_content = File.read(path).strip
|
|
212
|
+
manifest_model = model_from_file(path)
|
|
202
213
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
214
|
+
# Use performance optimizations for faster manifest compilation
|
|
215
|
+
with_performance_optimizations do
|
|
216
|
+
manifest_model.to_response(locations: locations)
|
|
206
217
|
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# The parsed manifest model with per-font options intact — from_file
|
|
221
|
+
# collapses resolved fonts into a response whose entries have lost
|
|
222
|
+
# them, so install flows that honor variable:/all_variants: must
|
|
223
|
+
# start here instead.
|
|
224
|
+
def self.model_from_file(path)
|
|
225
|
+
validate_manifest_path!(path)
|
|
207
226
|
|
|
208
|
-
|
|
209
|
-
from_yaml(
|
|
227
|
+
begin
|
|
228
|
+
from_yaml(File.read(path).strip)
|
|
210
229
|
rescue StandardError => e
|
|
211
230
|
raise Fontist::Errors::ManifestCouldNotBeReadError,
|
|
212
231
|
"Manifest file could not be read: #{e.message}"
|
|
213
232
|
end
|
|
233
|
+
end
|
|
214
234
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
235
|
+
def self.validate_manifest_path!(path)
|
|
236
|
+
unless File.exist?(path)
|
|
237
|
+
raise Fontist::Errors::ManifestCouldNotBeFoundError,
|
|
238
|
+
"Manifest file not found: #{path}"
|
|
218
239
|
end
|
|
240
|
+
|
|
241
|
+
return unless File.read(path).strip.empty?
|
|
242
|
+
|
|
243
|
+
raise Fontist::Errors::ManifestCouldNotBeReadError,
|
|
244
|
+
"Manifest file is empty: #{path}"
|
|
219
245
|
end
|
|
220
246
|
|
|
221
247
|
def self.from_hash(data, options = {})
|
|
@@ -270,7 +296,7 @@ location: nil)
|
|
|
270
296
|
fonts_casted.each do |font|
|
|
271
297
|
paths = font.group_paths
|
|
272
298
|
|
|
273
|
-
if paths.empty?
|
|
299
|
+
if paths.empty? || font.unsatisfied_by_spec?
|
|
274
300
|
font.install(confirmation: confirmation,
|
|
275
301
|
hide_licenses: hide_licenses,
|
|
276
302
|
no_progress: no_progress,
|
data/lib/fontist/manifest_cli.rb
CHANGED
|
@@ -13,9 +13,27 @@ module Fontist
|
|
|
13
13
|
type: :string, aliases: :l,
|
|
14
14
|
enum: ["fontist", "user", "system"],
|
|
15
15
|
desc: "Install location: fontist (default), user, system"
|
|
16
|
+
option :static, type: :boolean,
|
|
17
|
+
desc: "Install static fonts for entries that do not " \
|
|
18
|
+
"set variable: themselves"
|
|
19
|
+
option :both, type: :boolean,
|
|
20
|
+
desc: "Install both variants for entries that do not " \
|
|
21
|
+
"set all_variants: themselves"
|
|
16
22
|
def install(manifest)
|
|
17
23
|
handle_class_options(options)
|
|
18
|
-
instance = Fontist::Manifest.
|
|
24
|
+
instance = Fontist::Manifest.model_from_file(manifest)
|
|
25
|
+
|
|
26
|
+
if options[:static]
|
|
27
|
+
instance.fonts.each do |font|
|
|
28
|
+
font.variable = false if font.variable.nil?
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
if options[:both]
|
|
32
|
+
instance.fonts.each do |font|
|
|
33
|
+
font.all_variants = true unless font.all_variants
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
19
37
|
paths = instance.install(
|
|
20
38
|
confirmation: options[:accept_all_licenses] ? "yes" : "no",
|
|
21
39
|
hide_licenses: options[:hide_licenses],
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require "fontisan"
|
|
2
|
+
|
|
3
|
+
module Fontist
|
|
4
|
+
# Turns `Fontisan.scan` rows into the font objects the indexes already
|
|
5
|
+
# consume (`FontFile` for single fonts, a `FontFile` over the english-only
|
|
6
|
+
# names for collection faces), so one batch scan can replace the per-path
|
|
7
|
+
# `FontFile.from_path` / `CollectionFile.from_path` loads.
|
|
8
|
+
#
|
|
9
|
+
# Only rows that carry no error are usable; anything else is left to the
|
|
10
|
+
# per-file path so its message stays byte-identical.
|
|
11
|
+
module ScanRowFonts
|
|
12
|
+
SINGLE_FORMATS = %w[ttf otf woff woff2].freeze
|
|
13
|
+
COLLECTION_FORMATS = %w[ttc otc].freeze
|
|
14
|
+
|
|
15
|
+
class << self
|
|
16
|
+
def usable?(rows)
|
|
17
|
+
return false if rows.nil? || rows.empty?
|
|
18
|
+
|
|
19
|
+
if rows.first["is_collection"]
|
|
20
|
+
collection_usable?(rows)
|
|
21
|
+
else
|
|
22
|
+
single_usable?(rows)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def file_font(row)
|
|
27
|
+
report_validation(row)
|
|
28
|
+
info = symbolize(row["names"] || {})
|
|
29
|
+
if row["has_fvar"] && info[:family_name]
|
|
30
|
+
info[:variable_instances] =
|
|
31
|
+
row["variable_instances"].map { |i| symbolize(i) }
|
|
32
|
+
end
|
|
33
|
+
FontFile.new(info)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def collection_face(row)
|
|
37
|
+
FontFile.new(symbolize(row["english_names"] || {}))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def warn_file_extension(path, row)
|
|
41
|
+
FontFile.check_extension_warning(path, row["is_collection"])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def warn_collection_extension(path)
|
|
45
|
+
CollectionFile.send(:check_extension_warning, path)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def collection_usable?(rows)
|
|
51
|
+
COLLECTION_FORMATS.include?(rows.first["format"]) &&
|
|
52
|
+
rows.all? { |row| collection_row_ok?(row) }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def single_usable?(rows)
|
|
56
|
+
row = rows.first
|
|
57
|
+
rows.size == 1 && SINGLE_FORMATS.include?(row["format"]) &&
|
|
58
|
+
row["errors"]["font_file"].nil? && !row["names"].nil?
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def symbolize(hash)
|
|
62
|
+
hash.transform_keys(&:to_sym)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def collection_row_ok?(row)
|
|
66
|
+
row["is_collection"] && row["num_faces"].to_i.positive? &&
|
|
67
|
+
row["errors"]["collection_file"].nil? &&
|
|
68
|
+
row["errors"]["collection_member"].nil?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def report_validation(row)
|
|
72
|
+
validation = row["validation"]
|
|
73
|
+
return if validation.nil? || validation["valid"]
|
|
74
|
+
|
|
75
|
+
name = File.basename(row["path"])
|
|
76
|
+
Fontist.ui.debug(
|
|
77
|
+
"Font validation issues for #{name}: #{validation['error_summary']}",
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
data/lib/fontist/system_index.rb
CHANGED
|
@@ -190,6 +190,22 @@ module Fontist
|
|
|
190
190
|
map_instances to: :fonts
|
|
191
191
|
end
|
|
192
192
|
|
|
193
|
+
# Older fontist versions serialized the entries under a `fonts:` key
|
|
194
|
+
# together with inline scan metadata. Accept that shape so an index
|
|
195
|
+
# written by a released gem parses as its entry list instead of a
|
|
196
|
+
# single blank entry (which check_index reports as corruption).
|
|
197
|
+
def self.from_yaml(content, options = {})
|
|
198
|
+
legacy = legacy_font_entries(content)
|
|
199
|
+
super(legacy ? Array(legacy).to_yaml : content, options)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def self.legacy_font_entries(content)
|
|
203
|
+
data = YAML.safe_load(content, aliases: true)
|
|
204
|
+
data.is_a?(Hash) ? data["fonts"] : nil
|
|
205
|
+
rescue StandardError
|
|
206
|
+
nil
|
|
207
|
+
end
|
|
208
|
+
|
|
193
209
|
# Don't rebuild index more frequently than this (in seconds)
|
|
194
210
|
INDEX_REBUILD_THRESHOLD = 30 * 60 # 30 minutes
|
|
195
211
|
|
|
@@ -667,7 +683,8 @@ verbose:, stats:)
|
|
|
667
683
|
show_minimal_progress = !verbose && sorted_paths.size > 100
|
|
668
684
|
progress_interval = sorted_paths.size > 1000 ? 100 : 50
|
|
669
685
|
|
|
670
|
-
|
|
686
|
+
misses = []
|
|
687
|
+
slots = sorted_paths.each_with_index.map do |path, index|
|
|
671
688
|
if verbose && stats
|
|
672
689
|
display_progress(index + 1, sorted_paths.size, path, spinner_chars,
|
|
673
690
|
spinner_index)
|
|
@@ -678,25 +695,66 @@ verbose:, stats:)
|
|
|
678
695
|
spinner_index += 1
|
|
679
696
|
|
|
680
697
|
cached = existing_fonts_by_path[path]
|
|
681
|
-
|
|
698
|
+
if reusable_cache?(path, cached, stats: stats)
|
|
699
|
+
cached
|
|
700
|
+
else
|
|
701
|
+
misses << path unless excluded?(path)
|
|
702
|
+
path
|
|
703
|
+
end
|
|
704
|
+
end
|
|
705
|
+
|
|
706
|
+
rows = scan_rows_by_path(misses)
|
|
707
|
+
results = slots.flat_map do |slot|
|
|
708
|
+
slot.is_a?(String) ? entries_for_miss(slot, rows[slot], stats) : slot
|
|
682
709
|
end.compact
|
|
683
710
|
|
|
684
711
|
clear_progress_line if verbose
|
|
685
712
|
results
|
|
686
713
|
end
|
|
687
714
|
|
|
688
|
-
def
|
|
715
|
+
def reusable_cache?(path, cached, stats:)
|
|
689
716
|
# Fast path: reuse cached metadata if file unchanged
|
|
690
717
|
if cached&.any? && file_unchanged?(path, cached.first)
|
|
691
718
|
stats&.record_cache_hit
|
|
692
|
-
|
|
719
|
+
true
|
|
693
720
|
else
|
|
694
|
-
# Slow path: parse font file
|
|
695
721
|
stats&.record_cache_miss
|
|
722
|
+
false
|
|
723
|
+
end
|
|
724
|
+
end
|
|
725
|
+
|
|
726
|
+
# One batch scan for every cache miss. The digest and name decoding run
|
|
727
|
+
# inside Fontisan.scan; no forks, no threads here.
|
|
728
|
+
def scan_rows_by_path(paths)
|
|
729
|
+
return {} if paths.empty?
|
|
730
|
+
|
|
731
|
+
Fontisan.scan(paths).group_by { |row| row["path"] }
|
|
732
|
+
end
|
|
733
|
+
|
|
734
|
+
def entries_for_miss(path, rows, stats)
|
|
735
|
+
return if excluded?(path)
|
|
736
|
+
|
|
737
|
+
if ScanRowFonts.usable?(rows)
|
|
738
|
+
build_entries_from_rows(path, rows)
|
|
739
|
+
else
|
|
740
|
+
# A failing or unusual file keeps the per-file path, so its error
|
|
741
|
+
# text and stats are exactly what they were before batching.
|
|
696
742
|
detect_fonts(path, stats: stats)
|
|
697
743
|
end
|
|
698
744
|
end
|
|
699
745
|
|
|
746
|
+
def build_entries_from_rows(path, rows)
|
|
747
|
+
if rows.first["is_collection"]
|
|
748
|
+
ScanRowFonts.warn_collection_extension(path)
|
|
749
|
+
rows.map { |row| parse_font(ScanRowFonts.collection_face(row), path) }
|
|
750
|
+
else
|
|
751
|
+
ScanRowFonts.warn_file_extension(path, rows.first)
|
|
752
|
+
font_file = ScanRowFonts.file_font(rows.first)
|
|
753
|
+
entries = variable_font_entries(font_file, path)
|
|
754
|
+
entries.empty? ? parse_font(font_file, path) : entries
|
|
755
|
+
end
|
|
756
|
+
end
|
|
757
|
+
|
|
700
758
|
def display_progress(current, total, path, spinner_chars,
|
|
701
759
|
spinner_index = nil)
|
|
702
760
|
spinner_index ||= (current / 10) % spinner_chars.length
|
data/lib/fontist/validator.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "fontisan"
|
|
3
4
|
require "parallel"
|
|
4
5
|
|
|
5
6
|
module Fontist
|
|
@@ -43,14 +44,11 @@ module Fontist
|
|
|
43
44
|
# Build read-only lookup from cache (non-shared state)
|
|
44
45
|
cache_lookup = cache&.to_lookup || {}
|
|
45
46
|
|
|
46
|
-
#
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
validate_sequential(font_paths, cache_lookup: cache_lookup,
|
|
52
|
-
verbose: verbose)
|
|
53
|
-
end
|
|
47
|
+
# Cache hits are reused; every miss goes through one batch scan.
|
|
48
|
+
parallel = use_parallel && font_paths.size > 10
|
|
49
|
+
results = validate_batched(font_paths, cache_lookup: cache_lookup,
|
|
50
|
+
parallel: parallel,
|
|
51
|
+
verbose: verbose)
|
|
54
52
|
|
|
55
53
|
@report.results = results
|
|
56
54
|
@report.calculate_summary!
|
|
@@ -153,41 +151,74 @@ module Fontist
|
|
|
153
151
|
|
|
154
152
|
private
|
|
155
153
|
|
|
156
|
-
#
|
|
157
|
-
#
|
|
158
|
-
def
|
|
159
|
-
|
|
154
|
+
# Reuse unchanged cache entries, then validate the misses with a single
|
|
155
|
+
# Fontisan.scan. Results keep the order of +font_paths+.
|
|
156
|
+
def validate_batched(font_paths, cache_lookup:, parallel:, verbose:)
|
|
157
|
+
hits, misses = font_paths.partition do |path|
|
|
158
|
+
cached = cache_lookup[path]
|
|
159
|
+
cached && file_unchanged?(path, cached)
|
|
160
|
+
end
|
|
160
161
|
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
fresh = validate_misses(misses, parallel: parallel, verbose: verbose)
|
|
163
|
+
hit_set = hits.to_set
|
|
164
|
+
font_paths.filter_map do |path|
|
|
165
|
+
hit_set.include?(path) ? cache_lookup[path] : fresh[path]
|
|
163
166
|
end
|
|
167
|
+
end
|
|
164
168
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
# @return [Hash{String => FontValidationResult}]
|
|
170
|
+
def validate_misses(paths, parallel:, verbose:)
|
|
171
|
+
return {} if paths.empty?
|
|
172
|
+
|
|
173
|
+
fresh = scan_results(paths)
|
|
174
|
+
# Failing files keep the per-file path so their messages are unchanged.
|
|
175
|
+
leftovers = fresh.select { |_, result| result.nil? }.keys
|
|
176
|
+
validate_leftovers(leftovers, parallel: parallel, verbose: verbose)
|
|
177
|
+
.each { |result| fresh[result.path] = result }
|
|
178
|
+
fresh
|
|
170
179
|
end
|
|
171
180
|
|
|
172
|
-
#
|
|
173
|
-
def
|
|
174
|
-
|
|
175
|
-
|
|
181
|
+
# One scan for all paths; nil marks a file the scan could not read.
|
|
182
|
+
def scan_results(paths)
|
|
183
|
+
started = Time.now
|
|
184
|
+
rows = Fontisan.scan(paths).group_by { |row| row["path"] }
|
|
185
|
+
share = ((Time.now - started) / paths.size).round(4)
|
|
186
|
+
|
|
187
|
+
paths.to_h do |path|
|
|
188
|
+
[path, result_from_rows(path, rows[path], share)]
|
|
176
189
|
end
|
|
177
190
|
end
|
|
178
191
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
192
|
+
def validate_leftovers(paths, parallel:, verbose:)
|
|
193
|
+
if parallel && paths.size > 1
|
|
194
|
+
num_cores = [Parallel.processor_count, 8].min
|
|
195
|
+
if verbose
|
|
196
|
+
Fontist.ui.say("Using parallel processing with #{num_cores} cores")
|
|
197
|
+
end
|
|
198
|
+
Parallel.map(paths, in_threads: num_cores) { |p| validate_single(p) }
|
|
199
|
+
else
|
|
200
|
+
paths.map { |path| validate_single(path) }
|
|
187
201
|
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# A passing result when the scan row for +path+ read cleanly, else nil.
|
|
205
|
+
def result_from_rows(path, rows, time_taken)
|
|
206
|
+
row = rows&.first
|
|
207
|
+
return unless row && row["names"] && row["errors"]["font_file"].nil?
|
|
208
|
+
|
|
209
|
+
names = row["names"]
|
|
210
|
+
FontValidationResult.new(
|
|
211
|
+
path: path, valid: true, time_taken: time_taken,
|
|
212
|
+
family_name: names["family_name"], full_name: names["full_name"],
|
|
213
|
+
file_size: safe_stat { File.size(path) },
|
|
214
|
+
file_mtime: safe_stat { File.mtime(path).to_i }
|
|
215
|
+
)
|
|
216
|
+
end
|
|
188
217
|
|
|
189
|
-
|
|
190
|
-
|
|
218
|
+
def safe_stat
|
|
219
|
+
yield
|
|
220
|
+
rescue StandardError
|
|
221
|
+
0
|
|
191
222
|
end
|
|
192
223
|
|
|
193
224
|
# Check if file has unchanged metadata compared to cached result.
|
data/lib/fontist/version.rb
CHANGED
data/lib/fontist.rb
CHANGED
|
@@ -50,6 +50,7 @@ module Fontist
|
|
|
50
50
|
|
|
51
51
|
# Data models
|
|
52
52
|
autoload :CollectionFile, "#{__dir__}/fontist/collection_file"
|
|
53
|
+
autoload :ScanRowFonts, "#{__dir__}/fontist/scan_row_fonts"
|
|
53
54
|
autoload :Extract, "#{__dir__}/fontist/extract"
|
|
54
55
|
autoload :ExtractOptions, "#{__dir__}/fontist/extract"
|
|
55
56
|
autoload :Resource, "#{__dir__}/fontist/resource"
|
data/packaging/nfpm.yaml
CHANGED
|
@@ -27,7 +27,12 @@ overrides:
|
|
|
27
27
|
|
|
28
28
|
contents:
|
|
29
29
|
- src: ${BINARY}
|
|
30
|
-
dst: /usr/
|
|
30
|
+
dst: /usr/lib/fontist/fontist
|
|
31
31
|
expand: true # nfpm leaves ${BINARY} in src alone without this
|
|
32
32
|
file_info:
|
|
33
33
|
mode: 0755
|
|
34
|
+
|
|
35
|
+
# The postinstall script links the binary into /usr/local/bin.
|
|
36
|
+
scripts:
|
|
37
|
+
postinstall: packaging/scripts/postinstall.sh
|
|
38
|
+
preremove: packaging/scripts/preremove.sh
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Remove the /usr/local/bin symlink on removal, not on upgrade. dpkg passes
|
|
3
|
+
# "remove" or "purge"; rpm passes the number of copies left (0 on removal).
|
|
4
|
+
set -e
|
|
5
|
+
case "$1" in
|
|
6
|
+
remove|purge|0)
|
|
7
|
+
if [ "$(readlink /usr/local/bin/fontist 2>/dev/null)" = /usr/lib/fontist/fontist ]; then
|
|
8
|
+
rm -f /usr/local/bin/fontist
|
|
9
|
+
fi
|
|
10
|
+
;;
|
|
11
|
+
esac
|
|
12
|
+
exit 0
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Get git >= 2.43 on Ubuntu 22.04, the documented one-time step
|
|
3
|
+
# before installing the fontist .deb (see README.adoc). Run as root.
|
|
4
|
+
#
|
|
5
|
+
# script/tebako/git-prep.sh
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
export DEBIAN_FRONTEND=noninteractive
|
|
9
|
+
# shellcheck disable=SC1091
|
|
10
|
+
. /etc/os-release
|
|
11
|
+
|
|
12
|
+
apt-get update -qq
|
|
13
|
+
case "$ID:$VERSION_ID" in
|
|
14
|
+
ubuntu:22.04)
|
|
15
|
+
apt-get install -y -qq ca-certificates software-properties-common
|
|
16
|
+
add-apt-repository -y ppa:git-core/ppa
|
|
17
|
+
apt-get update -qq
|
|
18
|
+
apt-get install -y -qq git
|
|
19
|
+
;;
|
|
20
|
+
*)
|
|
21
|
+
echo "git-prep: nothing to do on $ID $VERSION_ID" >&2
|
|
22
|
+
exit 1
|
|
23
|
+
;;
|
|
24
|
+
esac
|
|
25
|
+
git --version
|
|
@@ -24,10 +24,15 @@ if command -v ruby >/dev/null; then
|
|
|
24
24
|
echo "package-smoke: this image has no business carrying ruby" >&2
|
|
25
25
|
exit 1
|
|
26
26
|
fi
|
|
27
|
+
link="$(readlink /usr/local/bin/fontist || true)"
|
|
28
|
+
if [ "$link" != /usr/lib/fontist/fontist ]; then
|
|
29
|
+
echo "package-smoke: /usr/local/bin/fontist links to '$link'" >&2
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
27
32
|
"$here/smoke.sh" "$(command -v fontist)"
|
|
28
33
|
remove
|
|
29
|
-
if command -v fontist >/dev/null; then
|
|
30
|
-
echo "package-smoke: fontist still
|
|
34
|
+
if [ -e /usr/local/bin/fontist ] || [ -L /usr/local/bin/fontist ] || command -v fontist >/dev/null; then
|
|
35
|
+
echo "package-smoke: fontist still present after removal" >&2
|
|
31
36
|
exit 1
|
|
32
37
|
fi
|
|
33
38
|
echo "package-smoke: ok"
|
data/script/tebako/package.sh
CHANGED
|
@@ -14,6 +14,9 @@ version="$(sed -n 's/.*VERSION = "\(.*\)".*/\1/p' "$root/lib/fontist/version.rb"
|
|
|
14
14
|
|
|
15
15
|
mkdir -p "$out"
|
|
16
16
|
BINARY="$(cd "$(dirname "$binary")" && pwd)/$(basename "$binary")"
|
|
17
|
+
out="$(cd "$out" && pwd)"
|
|
18
|
+
# nfpm resolves the script paths in nfpm.yaml against the working directory.
|
|
19
|
+
cd "$root"
|
|
17
20
|
export ARCH="$arch" VERSION="$version" BINARY
|
|
18
21
|
|
|
19
22
|
for packager in deb rpm; do
|
data/script/tebako/smoke.sh
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
#
|
|
4
4
|
# script/tebako/smoke.sh <fontist-executable>
|
|
5
5
|
#
|
|
6
|
-
# Uses a throwaway FONTIST_PATH so it never touches a
|
|
6
|
+
# Uses a throwaway FONTIST_PATH, then a throwaway HOME, so it never touches a
|
|
7
|
+
# real ~/.fontist.
|
|
7
8
|
set -euo pipefail
|
|
8
9
|
|
|
9
10
|
fontist="${1:?usage: smoke.sh <fontist-executable>}"
|
|
@@ -13,6 +14,7 @@ home="$(mktemp -d)"
|
|
|
13
14
|
trap 'rm -rf "$home"' EXIT
|
|
14
15
|
export FONTIST_PATH="$home"
|
|
15
16
|
|
|
17
|
+
"$fontist" --version
|
|
16
18
|
"$fontist" version
|
|
17
19
|
"$fontist" install --accept-all-licenses "$font"
|
|
18
20
|
|
|
@@ -22,4 +24,13 @@ if ! find "$home/fonts" -type f | grep -q .; then
|
|
|
22
24
|
fi
|
|
23
25
|
"$fontist" list "$font" | tee "$home/list.txt"
|
|
24
26
|
grep -qi "installed" "$home/list.txt"
|
|
27
|
+
|
|
28
|
+
# Without FONTIST_PATH, fonts land in ~/.fontist.
|
|
29
|
+
user_home="$(mktemp -d)"
|
|
30
|
+
trap 'rm -rf "$home" "$user_home"' EXIT
|
|
31
|
+
env -u FONTIST_PATH HOME="$user_home" "$fontist" install --accept-all-licenses "$font"
|
|
32
|
+
if ! find "$user_home/.fontist/fonts" -type f | grep -q .; then
|
|
33
|
+
echo "smoke: no font file landed under $user_home/.fontist/fonts" >&2
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
25
36
|
echo "smoke: ok"
|