summaryrefslogtreecommitdiff
path: root/pkg/machine/wsl/machine.go
diff options
context:
space:
mode:
authorGerard Braad <me@gbraad.nl>2022-07-13 05:36:06 +0000
committerJason T. Greene <jason.greene@redhat.com>2022-07-13 17:19:38 -0500
commit0f53abd093d171fe134fb5aa00f1679f0efed370 (patch)
tree05f7544e021007536964ee04087fa11aa78a672a /pkg/machine/wsl/machine.go
parent255740bdf8a45e644039a83082d6f829c1018512 (diff)
downloadpodman-0f53abd093d171fe134fb5aa00f1679f0efed370.tar.gz
podman-0f53abd093d171fe134fb5aa00f1679f0efed370.tar.bz2
podman-0f53abd093d171fe134fb5aa00f1679f0efed370.zip
Fixes #14698 Use prepared image for WSL2 machine init
This commit introduces a prepared image for setting up the WSL2 environment. This means that the deployment will take considerable less time to finish (as it does not need to run an update and package install), but also allows to rely on a cached image to re-init the environment without the need for an internet connection. [NO NEW TESTS NEEDED] Signed-off-by: Gerard Braad <me@gbraad.nl>
Diffstat (limited to 'pkg/machine/wsl/machine.go')
-rw-r--r--pkg/machine/wsl/machine.go28
1 files changed, 4 insertions, 24 deletions
diff --git a/pkg/machine/wsl/machine.go b/pkg/machine/wsl/machine.go
index 450d8b877..189723ac7 100644
--- a/pkg/machine/wsl/machine.go
+++ b/pkg/machine/wsl/machine.go
@@ -386,7 +386,7 @@ func downloadDistro(v *MachineVM, opts machine.InitOptions) error {
if _, e := strconv.Atoi(opts.ImagePath); e == nil {
v.ImageStream = opts.ImagePath
- dd, err = machine.NewFedoraDownloader(vmtype, v.Name, v.ImageStream)
+ dd, err = machine.NewFedoraDownloader(vmtype, v.Name, opts.ImagePath)
} else {
v.ImageStream = "custom"
dd, err = machine.NewGenericDownloader(vmtype, v.Name, opts.ImagePath)
@@ -449,34 +449,14 @@ func provisionWSLDist(v *MachineVM) (string, error) {
}
dist := toDist(v.Name)
- fmt.Println("Importing operating system into WSL (this may take 5+ minutes on a new WSL install)...")
+ fmt.Println("Importing operating system into WSL (this may take a few minutes on a new WSL install)...")
if err = runCmdPassThrough("wsl", "--import", dist, distTarget, v.ImagePath); err != nil {
return "", fmt.Errorf("the WSL import of guest OS failed: %w", err)
}
- fmt.Println("Installing packages (this will take awhile)...")
- if err = runCmdPassThrough("wsl", "-d", dist, "dnf", "upgrade", "-y"); err != nil {
- return "", fmt.Errorf("package upgrade on guest OS failed: %w", err)
- }
-
- fmt.Println("Enabling Copr")
- if err = runCmdPassThrough("wsl", "-d", dist, "dnf", "install", "-y", "'dnf-command(copr)'"); err != nil {
- return "", fmt.Errorf("enabling copr failed: %w", err)
- }
-
- fmt.Println("Enabling podman4 repo")
- if err = runCmdPassThrough("wsl", "-d", dist, "dnf", "-y", "copr", "enable", "rhcontainerbot/podman4"); err != nil {
- return "", fmt.Errorf("enabling copr failed: %w", err)
- }
-
- if err = runCmdPassThrough("wsl", "-d", dist, "dnf", "install",
- "podman", "podman-docker", "openssh-server", "procps-ng", "-y"); err != nil {
- return "", fmt.Errorf("package installation on guest OS failed: %w", err)
- }
-
// Fixes newuidmap
- if err = runCmdPassThrough("wsl", "-d", dist, "dnf", "reinstall", "shadow-utils", "-y"); err != nil {
- return "", fmt.Errorf("package reinstallation of shadow-utils on guest OS failed: %w", err)
+ if err = runCmdPassThrough("wsl", "-d", dist, "rpm", "-q", "--restore", "shadow-utils", "2>/dev/null"); err != nil {
+ return "", fmt.Errorf("package permissions restore of shadow-utils on guest OS failed: %w", err)
}
// Windows 11 (NT Version = 10, Build 22000) generates harmless but scary messages on every