-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the
msi
artifact so we can build msi installers from `grafana-b…
…uild` (#381)
- Loading branch information
Showing
26 changed files
with
3,098 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package msi | ||
|
||
import ( | ||
"fmt" | ||
|
||
"dagger.io/dagger" | ||
"github.com/grafana/grafana-build/containers" | ||
) | ||
|
||
func Build(d *dagger.Client, builder *dagger.Container, targz *dagger.File, version string, enterprise bool) (*dagger.File, error) { | ||
wxsFiles, err := WXSFiles(version, enterprise) | ||
if err != nil { | ||
return nil, fmt.Errorf("error generating wxs files: %w", err) | ||
} | ||
|
||
f := containers.ExtractedArchive(d, targz) | ||
builder = builder.WithDirectory("/src/grafana", f, dagger.ContainerWithDirectoryOpts{ | ||
// Hack from grafana/build-pipeline: Remove files with names too long... | ||
Exclude: []string{ | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/app_insights/app_insights_querystring_builder.test.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/app_insights/app_insights_querystring_builder.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.test.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.test.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/app_insights/app_insights_datasource.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/app_insights/app_insights_datasource.test.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/insights_analytics/insights_analytics_datasource.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_filter_builder.test.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_filter_builder.ts", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.test.tsx", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsConfig.test.tsx", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/__snapshots__/AnalyticsConfig.test.tsx.snap", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/__snapshots__/AzureCredentialsForm.test.tsx.snap", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/__snapshots__/InsightsConfig.test.tsx.snap", | ||
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/__snapshots__/ConfigEditor.test.tsx.snap", | ||
"storybook", | ||
}, | ||
}).WithWorkdir("/src") | ||
|
||
for _, v := range wxsFiles { | ||
builder = builder.WithNewFile(v.Name, v.Contents) | ||
} | ||
|
||
// 1. `heat`: create 'grafana.wxs' | ||
// 2. 'candle': Compile .wxs files into .wixobj | ||
// 3. `light`: assembles the MSI | ||
builder = builder. | ||
WithExec([]string{"/bin/sh", "-c", "cp -r /src/resources/resources/* /src && rm -rf /src/resources"}). | ||
WithExec([]string{"/bin/sh", "-c", `WINEPATH=$(winepath /src/wix3) wine heat dir /src -platform x64 -sw5150 -srd -cg GrafanaX64 -gg -sfrag -dr GrafanaX64Dir -template fragment -out $(winepath -w grafana.wxs)`}). | ||
WithExec([]string{"winepath"}). | ||
WithExec([]string{"mkdir", "/root/.wine/drive_c/temp"}) | ||
|
||
for _, name := range []string{ | ||
"grafana-service.wxs", | ||
"grafana-firewall.wxs", | ||
"grafana.wxs", | ||
"grafana-product.wxs", | ||
} { | ||
builder = builder.WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`WINEPATH=$(winepath /src/wix3) wine candle -ext WixFirewallExtension -ext WixUtilExtension -v -arch x64 $(winepath -w %s)`, name)}) | ||
} | ||
builder = builder. | ||
WithExec([]string{"/bin/bash", "-c", "WINEPATH=$(winepath /src/wix3) wine light -cultures:en-US -ext WixUIExtension.dll -ext WixFirewallExtension -ext WixUtilExtension -v -sval -spdb grafana-service.wixobj grafana-firewall.wixobj grafana.wixobj grafana-product.wixobj -out $(winepath -w /src/grafana.msi)"}) | ||
|
||
return builder.File("/src/grafana.msi"), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package msi | ||
|
||
import ( | ||
"dagger.io/dagger" | ||
"github.com/grafana/grafana-build/containers" | ||
) | ||
|
||
func Builder(d *dagger.Client) (*dagger.Container, error) { | ||
nssm := d.Container().From("busybox"). | ||
WithExec([]string{"wget", "https://nssm.cc/release/nssm-2.24.zip"}). | ||
WithExec([]string{"unzip", "nssm-2.24.zip"}). | ||
Directory("nssm-2.24") | ||
|
||
wix3 := d.Container().From("busybox"). | ||
WithWorkdir("/src"). | ||
WithExec([]string{"wget", "https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip"}). | ||
WithExec([]string{"unzip", "wix314-binaries.zip"}). | ||
WithExec([]string{"rm", "wix314-binaries.zip"}). | ||
Directory("/src") | ||
|
||
builder := d.Container().From("scottyhardy/docker-wine:stable-9.0"). | ||
WithEntrypoint([]string{}). | ||
WithMountedDirectory("/src/nssm-2.24", nssm). | ||
WithMountedDirectory("/src/wix3", wix3). | ||
WithWorkdir("/src") | ||
|
||
return containers.WithEmbeddedFS(d, builder, "/src/resources", resources) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package msi | ||
|
||
import "embed" | ||
|
||
//go:embed resources/* | ||
var resources embed.FS |
Oops, something went wrong.