-
Notifications
You must be signed in to change notification settings - Fork 3
/
winget_package.libsonnet
82 lines (76 loc) · 2.95 KB
/
winget_package.libsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
Installer(product, version):: {
MinimumOSVersion: '10.0.0.0',
Scope: std.get(version, 'Scope', std.get(product, 'Scope', 'user')),
InstallModes: [
'silent',
'silentWithProgress',
],
UpgradeBehavior: 'install',
InstallerType: 'wix',
PackageIdentifier: product.PackageIdentifier,
PackageVersion: version.PackageVersion,
InstallerLocale: product.PackageLocale,
Installers: [
{
Architecture: 'x64',
InstallerUrl: version.InstallerUrl,
InstallerSha256: version.InstallerSha256,
ProductCode: version.ProductCode,
AppsAndFeaturesEntries: [
{
DisplayName: product.PackageName + " " + version.PackageVersion,
UpgradeCode: std.get(version, 'UpgradeCode', default=product.UpdateCode)
}
]
},
],
ManifestType: 'installer',
ManifestVersion: '1.4.0',
},
Locale(product, version):: {
PackageIdentifier: product.PackageIdentifier,
PackageVersion: version.PackageVersion,
PackageLocale: product.PackageLocale,
Publisher: product.Publisher,
PublisherUrl: product.PublisherUrl,
PublisherSupportUrl: product.PublisherSupportUrl,
Author: product.Author,
PackageName: product.PackageName,
PackageUrl: product.PackageUrl,
License: product.License,
Copyright: product.Copyright ,
ShortDescription: product.ShortDescription,
Moniker: product.Moniker,
Tags: product.Tags,
ManifestType: 'defaultLocale',
ManifestVersion: '1.4.0',
},
Version(product, version):: {
PackageIdentifier: product.PackageIdentifier,
PackageVersion: version.PackageVersion,
DefaultLocale: product.PackageLocale,
ManifestType: 'version',
ManifestVersion: '1.4.0',
},
Merged(product, version)::
$.Installer(product, version) + $.Locale(product, version) + $.Version(product, version) + {
ManifestType: 'merged'
},
Release(product, version)::
local packageIdentifierParts = std.split(product.PackageIdentifier, '.');
local basePath = std.asciiLower(product.PackageIdentifier[0]) + '/' + packageIdentifierParts[0] + '/' + packageIdentifierParts[1];
local packageIdentifierHash = std.substr(std.md5(product.PackageIdentifier),0,4);
{
[basePath + '/' + version.PackageVersion + '/' + product.PackageIdentifier + '.installer.json']: $.Installer(product, version),
[basePath + '/' + version.PackageVersion + '/' + product.PackageIdentifier + '.locale.en-US.json']: $.Locale(product, version),
[basePath + '/' + version.PackageVersion + '/' + product.PackageIdentifier + '.json']: $.Version(product, version),
[basePath + '/' + version.PackageVersion + '/' + packageIdentifierHash + "-" + product.PackageIdentifier + '.json']: $.Merged(product, version),
},
Files(product, releases)::
std.foldl(function(x, y) x + y,
[
$.Release(product, x)
for x in releases
], {})
}