Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 1 addition & 27 deletions assets/packaging/windows-msi/app.wxs.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="{{.applicationName}}">
<Directory Id="ASSETSDIRECTORY" Name="assets"/>
<Directory Id="FLUTTERASSETSDIRECTORY" Name="flutter_assets">
<?include directories.wxi ?>
</Directory>
<?include directories.wxi ?>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
Expand All @@ -18,25 +15,6 @@
</Directory>
<Icon Id="ShortcutIcon" SourceFile="build{{.pathSeparator}}assets{{.pathSeparator}}icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="ShortcutIcon"/>
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
<Component Id="{{.executableName}}.exe" Guid="*">
<File Id="{{.executableName}}.exe" Source="build{{.pathSeparator}}{{.executableName}}.exe" KeyPath="yes"/>
</Component>
<Component Id="flutter_engine.dll" Guid="*">
<File Id="flutter_engine.dll" Source="build{{.pathSeparator}}flutter_engine.dll" KeyPath="yes"/>
</Component>
<Component Id="icudtl.dat" Guid="*">
<File Id="icudtl.dat" Source="build{{.pathSeparator}}icudtl.dat" KeyPath="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="ASSETSDIRECTORY">
<Component Id="icon.png" Guid="*">
<File Id="icon.png" Source="build{{.pathSeparator}}assets{{.pathSeparator}}icon.png" KeyPath="yes"/>
</Component>
<Component Id="icon.ico" Guid="*">
<File Id="icon.ico" Source="build{{.pathSeparator}}assets{{.pathSeparator}}icon.ico" KeyPath="yes"/>
</Component>
</DirectoryRef>
<?include directory_refs.wxi ?>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="*">
Expand All @@ -51,10 +29,6 @@
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="{{.applicationName}}" Level="1">
<ComponentRef Id="{{.executableName}}.exe"/>
<ComponentRef Id="flutter_engine.dll"/>
<ComponentRef Id="icudtl.dat"/>
<ComponentRef Id="icon.png"/>
<ComponentRef Id="ApplicationShortcut"/>
<?include component_refs.wxi ?>
</Feature>
Expand Down
4 changes: 1 addition & 3 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,7 @@ func initBuildParameters(targetOS string, defaultBuildOrRunMode build.Mode) {
}

// hover.yaml file needs to be set before accessing config.GetConfig()
if buildOrRunHoverFlavor == "" {
config.SetDefaultHoverYamlFile()
} else {
if buildOrRunHoverFlavor != "" {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment

config.SetHoverFlavor(buildOrRunHoverFlavor)
}

Expand Down
33 changes: 15 additions & 18 deletions cmd/packaging/windows-msi.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package packaging

import (
"crypto/rand"
"crypto/sha1"
"encoding/hex"
"fmt"
Expand All @@ -14,6 +13,7 @@ import (
"strings"

ico "github.com/Kodeworks/golang-image-ico"
"github.com/google/uuid"

"github.com/go-flutter-desktop/hover/internal/log"
)
Expand Down Expand Up @@ -102,14 +102,11 @@ var WindowsMsiTask = &packagingTask{
},
},
generateInitFiles: func(packageName, path string) {
b := make([]byte, 16)
_, err := rand.Read(b)
if err != nil {
log.Errorf("Failed to generate GUID: %v", err)
os.Exit(1)
}
upgradeCode := strings.ToUpper(fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]))
err = ioutil.WriteFile(filepath.Join(path, "upgrade-code.txt"), []byte(fmt.Sprintf("%s\n# This GUID is your upgrade code and ensures that you can properly update your app.\n# Don't change it.", upgradeCode)), 0755)
err := ioutil.WriteFile(
filepath.Join(path, "upgrade-code.txt"),
[]byte(fmt.Sprintf("%s\n# This GUID is your upgrade code and ensures that you can properly update your app.\n# Don't change it.", uuid.New())),
0755,
)
if err != nil {
log.Errorf("Failed to create `upgrade-code.txt` file: %v", err)
os.Exit(1)
Expand Down Expand Up @@ -165,7 +162,7 @@ var WindowsMsiTask = &packagingTask{
directoriesFileContent = append(directoriesFileContent, "<Include>")
directoryRefsFileContent = append(directoryRefsFileContent, "<Include>")
componentRefsFileContent = append(componentRefsFileContent, "<Include>")
windowsMsiProcessFiles(filepath.Join(tmpPath, "build", "flutter_assets"))
windowsMsiProcessFiles(filepath.Join(tmpPath, "build"))
directoriesFileContent = append(directoriesFileContent, "</Include>")
directoryRefsFileContent = append(directoryRefsFileContent, "</Include>")
componentRefsFileContent = append(componentRefsFileContent, "</Include>")
Expand Down Expand Up @@ -216,11 +213,11 @@ func windowsMsiProcessFiles(path string) {

for _, f := range files {
p := filepath.Join(path, f.Name())
relativePath := strings.Split(strings.Split(p, "flutter_assets"+pathSeparator)[1], pathSeparator)
relativePath := strings.Split(strings.Split(p, "build"+pathSeparator)[1], pathSeparator)
id := hashSha1(strings.Join(relativePath, ""))
if f.IsDir() {
directoriesFileContent = append(directoriesFileContent,
fmt.Sprintf(`<Directory Id="FLUTTERASSETSDIRECTORY_%s" Name="%s">`, id, f.Name()),
fmt.Sprintf(`<Directory Id="APPLICATIONROOTDIRECTORY_%s" Name="%s">`, id, f.Name()),
)
windowsMsiProcessFiles(p)
directoriesFileContent = append(directoriesFileContent,
Expand All @@ -229,22 +226,22 @@ func windowsMsiProcessFiles(path string) {
} else {
if len(relativePath) > 1 {
directoryRefsFileContent = append(directoryRefsFileContent,
fmt.Sprintf(`<DirectoryRef Id="FLUTTERASSETSDIRECTORY_%s">`, hashSha1(strings.Join(relativePath[:len(relativePath)-1], ""))),
fmt.Sprintf(`<DirectoryRef Id="APPLICATIONROOTDIRECTORY_%s">`, hashSha1(strings.Join(relativePath[:len(relativePath)-1], ""))),
)
} else {
directoryRefsFileContent = append(directoryRefsFileContent,
`<DirectoryRef Id="FLUTTERASSETSDIRECTORY">`,
`<DirectoryRef Id="APPLICATIONROOTDIRECTORY">`,
)
}
fileSource := filepath.Join("build", "flutter_assets", strings.Join(relativePath, pathSeparator))
fileSource := filepath.Join("build", strings.Join(relativePath, pathSeparator))
directoryRefsFileContent = append(directoryRefsFileContent,
fmt.Sprintf(`<Component Id="flutter_assets_%s" Guid="*">`, id),
fmt.Sprintf(`<File Id="flutter_assets_%s" Source="%s" KeyPath="yes"/>`, id, fileSource),
fmt.Sprintf(`<Component Id="build_%s" Guid="%s">`, id, uuid.New()),
fmt.Sprintf(`<File Id="build_%s" Source="%s" KeyPath="yes"/>`, id, fileSource),
"</Component>",
"</DirectoryRef>",
)
componentRefsFileContent = append(componentRefsFileContent,
fmt.Sprintf(`<ComponentRef Id="flutter_assets_%s"/>`, id),
fmt.Sprintf(`<ComponentRef Id="build_%s"/>`, id),
)
}
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/daaku/go.zipexe v1.0.1 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/uuid v1.1.2
github.com/hashicorp/go-version v1.2.1
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
Expand Down
8 changes: 3 additions & 5 deletions internal/config/flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ var hoverYaml string

// GetHoverFlavorYaml returns the Hover yaml file
func GetHoverFlavorYaml() string {
if len(hoverYaml) == 0 {
hoverYaml = "hover.yaml"
}
return hoverYaml
}

// SetDefaultFlavorFile sets the default hover.yaml
func SetDefaultHoverYamlFile() {
hoverYaml = "hover.yaml"
}

Comment on lines +16 to -23
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes were needed, because the config needed to be loaded for init-packaging. It removes the need to call SetDefaultHoverYamlFile().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes, sense. I was not aware that len returns 0 on a nil

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings are never nil they are just empty

// SetHoverFlavor sets the user defined hover flavor.
// eg. hover-develop.yaml, hover-staging.yaml, etc.
func SetHoverFlavor(flavor string) {
Expand Down
20 changes: 10 additions & 10 deletions internal/fileutils/rice-box.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.