Skip to content

Commit

Permalink
wsl-helper: Remove unused wix custom action code
Browse files Browse the repository at this point in the history
Since we no longer attempt to install WSL as part of our installer, we can
remove the code that was used to do so.

Signed-off-by: Mark Yen <[email protected]>
  • Loading branch information
mook-as committed Jan 17, 2025
1 parent dde0e12 commit e71f684
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 210 deletions.
2 changes: 1 addition & 1 deletion .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ HOSTPORT
hoverable
howett
hpa
hresult
HRESULT
htpasswd
httpconfig
Huawei
Expand Down
123 changes: 0 additions & 123 deletions src/go/wsl-helper/pkg/wsl-utils/dism_windows.go

This file was deleted.

22 changes: 0 additions & 22 deletions src/go/wsl-helper/pkg/wsl-utils/install_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,6 @@ import (
"golang.org/x/sys/windows"
)

// InstallWSL runs wsl.exe to install WSL.
func InstallWSL(ctx context.Context, log *logrus.Entry) error {
// wsl.exe calls wslapi.dll, which eventually uses the WinRT API
// Windows.ApplicationModel.Store.Preview.InstallControl — but that is
// (according to docs) private and only usable by Microsoft-signed apps.
// Just spawn wsl.exe and hope it does the job. Trying to reverse-engineer
// the WslInstaller COM component seems error-prone, and it will likely
// change in the future. Unfortunately, this means more UAC prompts.
newRunnerFunc := NewWSLRunner
if f := ctx.Value(&kWSLExeOverride); f != nil {
newRunnerFunc = f.(func() WSLRunner)
}
// WSL install hangs if we set stdout; don't set that here.
err := newRunnerFunc().
WithStderr(log.WriterLevel(logrus.InfoLevel)).
Run(ctx, "--install", "--no-distribution")
if err != nil {
return err
}
return nil
}

// UpdateWSL runs wsl.exe to update the WSL kernel. This assumes that WSL had
// already been installed. This may request elevation.
func UpdateWSL(ctx context.Context, log *logrus.Entry) error {
Expand Down
44 changes: 0 additions & 44 deletions src/go/wsl-helper/wix/install_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,50 +32,6 @@ func setupLogger(hInstall MSIHANDLE) *logrus.Entry {
})
}

// InstallWindowsFeatureImpl installs the Windows features necessary for WSL to
// be installed. This needs to be run elevated.
func InstallWindowsFeatureImpl(hInstall MSIHANDLE) uint32 {
ctx := context.Background()
log := setupLogger(hInstall)

log.Infof("Installing Windows feature...")
err := submitMessage(hInstall, INSTALLMESSAGE_ACTIONSTART, []string{
"", "InstalWindowsFeature", "Installing required Windows features...", "<unused>",
})
if err != nil {
log.WithError(err).Info("Failed to update progress")
}
if err := wslutils.DismDoInstall(ctx, log); err != nil {
log.WithError(err).Error("Failed to install feature")
return 1
}

return 0
}

// InstallWSLImpl installs WSL.
// This assumes WSL was not previously installed.
// This needs to be run as the user.
func InstallWSLImpl(hInstall MSIHANDLE) uint32 {
ctx := context.Background()
log := setupLogger(hInstall)

log.Info("Installing WSL...")
err := submitMessage(hInstall, INSTALLMESSAGE_ACTIONSTART, []string{
"", "InstallWSL", "Installing Windows Subsystem for Linux...", "<unused>",
})
if err != nil {
log.WithError(err).Info("Failed to update progress")
}
if err := wslutils.InstallWSL(ctx, log); err != nil {
log.WithError(err).Error("Installing WSL failed")
return 1
}

log.Info("WSL successfully installed.")
return 0
}

// UpdateWSLImpl updates the previously installed WSL.
// This needs to be run as the user, and may request elevation.
func UpdateWSLImpl(hInstall MSIHANDLE) uint32 {
Expand Down
20 changes: 0 additions & 20 deletions src/go/wsl-helper/wix/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,6 @@ func DetectWSL(hInstall C.ulong) C.ulong {
return C.ulong(DetectWSLImpl(MSIHANDLE(hInstall)))
}

// InstallWindowsFeature is a wrapper around InstallWindowsFeature; this is the
// stub to be exported in the DLL. This only exists to limit cgo to this file
// so that editing on a machine that requires cross compilation can avoid
// needing a cross cgo toolchain.
//
//export InstallWindowsFeature
func InstallWindowsFeature(hInstall C.ulong) C.ulong {
return C.ulong(InstallWindowsFeatureImpl(MSIHANDLE(hInstall)))
}

// InstallWSL is a wrapper around InstallWSLImpl; this is the stub to be
// exported in the DLL. This only exists to limit cgo to this file so that
// editing on a machine that requires cross compilation can avoid needing a
// cross cgo toolchain.
//
//export InstallWSL
func InstallWSL(hInstall C.ulong) C.ulong {
return C.ulong(InstallWSLImpl(MSIHANDLE(hInstall)))
}

// UpdateWSL is a wrapper around UpdateWSLImpl; this is the stub to be exported
// in the DLL. This only exists to limit cgo to this file so that editing on a
// machine that requires cross compilation can avoid needing a cross cgo
Expand Down

0 comments on commit e71f684

Please sign in to comment.