Skip to content

Commit 8b6fa81

Browse files
committed
feat(ffmpeg): add ffmpegdist classifier for eugeneware/ffmpeg-static
Upstream uses non-standard OS/arch names (x64, ia32, win32, arm) and ships both bare binaries and .gz-compressed copies. classifyFFmpegDist maps those to canonical names and keeps only bare binaries. Also adds source-override logic to installerconf so that github_releases + source = ffmpegdist works: GitHub is used for fetching while the custom classifier handles classification.
1 parent 0f69f58 commit 8b6fa81

3 files changed

Lines changed: 92 additions & 0 deletions

File tree

ffmpeg/releases.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
source = ffmpegdist
12
github_releases = eugeneware/ffmpeg-static
23
asset_filter = ffmpeg
34
version_prefix = b

internal/classifypkg/classifypkg.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ func classifySource(pkg string, conf *installerconf.Conf, d *rawcache.Dir) ([]st
166166
return classifyMariaDBDist(d)
167167
case "zigdist":
168168
return classifyZigDist(d)
169+
case "ffmpegdist":
170+
return classifyFFmpegDist(d)
169171
default:
170172
return nil, nil
171173
}
@@ -464,6 +466,86 @@ func classifyGitHub(pkg string, conf *installerconf.Conf, d *rawcache.Dir) ([]st
464466
return assets, nil
465467
}
466468

469+
var ffmpegOSMap = map[string]string{
470+
"linux": "linux",
471+
"darwin": "darwin",
472+
"win32": "windows",
473+
}
474+
475+
var ffmpegArchMap = map[string]string{
476+
"x64": "x86_64",
477+
"ia32": "x86",
478+
"arm64": "aarch64",
479+
"arm": "armv7",
480+
}
481+
482+
// classifyFFmpegDist handles eugeneware/ffmpeg-static releases.
483+
// Upstream uses non-standard names (x64, ia32, win32, arm) and ships both
484+
// bare binaries and .gz-compressed copies. Only bare binaries are kept —
485+
// the install template has no handler for single-file .gz extraction.
486+
func classifyFFmpegDist(d *rawcache.Dir) ([]storage.Asset, error) {
487+
releases, err := ReadAllRaw(d)
488+
if err != nil {
489+
return nil, err
490+
}
491+
492+
var assets []storage.Asset
493+
for _, data := range releases {
494+
var rel ghRelease
495+
if err := json.Unmarshal(data, &rel); err != nil {
496+
continue
497+
}
498+
if rel.Draft {
499+
continue
500+
}
501+
502+
version := strings.TrimPrefix(rel.TagName, "b")
503+
504+
channel := "stable"
505+
if rel.Prerelease {
506+
channel = "beta"
507+
}
508+
509+
date := ""
510+
if len(rel.PublishedAt) >= 10 {
511+
date = rel.PublishedAt[:10]
512+
}
513+
514+
for _, a := range rel.Assets {
515+
if strings.Contains(a.Name, ".") {
516+
continue
517+
}
518+
if !strings.HasPrefix(a.Name, "ffmpeg-") {
519+
continue
520+
}
521+
522+
parts := strings.SplitN(a.Name, "-", 3)
523+
if len(parts) != 3 {
524+
continue
525+
}
526+
527+
os, osOK := ffmpegOSMap[parts[1]]
528+
arch, archOK := ffmpegArchMap[parts[2]]
529+
if !osOK || !archOK {
530+
continue
531+
}
532+
533+
assets = append(assets, storage.Asset{
534+
Filename: a.Name,
535+
Version: version,
536+
Channel: channel,
537+
OS: os,
538+
Arch: arch,
539+
Format: "",
540+
Download: a.BrowserDownloadURL,
541+
Date: date,
542+
})
543+
}
544+
}
545+
546+
return assets, nil
547+
}
548+
467549
// classifyServiceman handles serviceman's dual-repo layout: binary releases
468550
// from therootcompany/serviceman (≤v0.8.x) and source-only releases from
469551
// bnnanet/serviceman (v0.9.x+). Emits binary assets where available, plus

internal/installerconf/installerconf.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ func Read(path string) (*Conf, error) {
162162
c := &Conf{}
163163

164164
// Infer source from primary key, falling back to explicit "source".
165+
// When both github_releases and source are set, parse the repo ref
166+
// from github_releases but use the explicit source for classification.
165167
switch {
166168
// GitHub binary releases.
167169
case raw["github_releases"] != "":
@@ -213,6 +215,13 @@ func Read(path string) (*Conf, error) {
213215
default:
214216
}
215217

218+
// Explicit "source" overrides the inferred source when both are present.
219+
// This lets packages like ffmpeg use github_releases for fetching but
220+
// a custom classifier for classification.
221+
if raw["source"] != "" && c.Source != "" {
222+
c.Source = raw["source"]
223+
}
224+
216225
// git_url can appear alongside any source type (e.g. github_sources)
217226
// to provide a git clone fallback. When it's the only key, it's the
218227
// primary source (gittag).

0 commit comments

Comments
 (0)