diff options
| -rw-r--r-- | cmd/podman/machine/machine.go | 2 | ||||
| -rw-r--r-- | cmd/podman/machine/machine_unix.go | 12 | ||||
| -rw-r--r-- | cmd/podman/machine/machine_windows.go | 11 | ||||
| -rwxr-xr-x | hack/buildah-vendor-treadmill | 82 | ||||
| -rw-r--r-- | pkg/util/utils_windows.go | 10 | ||||
| -rw-r--r-- | test/e2e/build_test.go | 13 | ||||
| -rw-r--r-- | test/e2e/save_test.go | 5 | ||||
| -rw-r--r-- | test/e2e/volume_create_test.go | 6 |
8 files changed, 112 insertions, 29 deletions
diff --git a/cmd/podman/machine/machine.go b/cmd/podman/machine/machine.go index 553f1ef7a..5a8a06b9d 100644 --- a/cmd/podman/machine/machine.go +++ b/cmd/podman/machine/machine.go @@ -115,7 +115,7 @@ func resolveEventSock() ([]string, error) { return err case info.IsDir(): return nil - case info.Type() != os.ModeSocket: + case !isUnixSocket(info): return nil case !re.MatchString(info.Name()): return nil diff --git a/cmd/podman/machine/machine_unix.go b/cmd/podman/machine/machine_unix.go new file mode 100644 index 000000000..213c24f8c --- /dev/null +++ b/cmd/podman/machine/machine_unix.go @@ -0,0 +1,12 @@ +//go:build linux || ignore || aix || ignore || android || ignore || darwin || ignore || freebsd || ignore || hurd || ignore || illumos || ignore || ios || ignore || netbsd || ignore || openbsd || ignore || solaris +// +build linux ignore aix ignore android ignore darwin ignore freebsd ignore hurd ignore illumos ignore ios ignore netbsd ignore openbsd ignore solaris + +package machine + +import ( + "os" +) + +func isUnixSocket(file os.DirEntry) bool { + return file.Type()&os.ModeSocket != 0 +} diff --git a/cmd/podman/machine/machine_windows.go b/cmd/podman/machine/machine_windows.go new file mode 100644 index 000000000..ffd5d8827 --- /dev/null +++ b/cmd/podman/machine/machine_windows.go @@ -0,0 +1,11 @@ +package machine + +import ( + "os" + "strings" +) + +func isUnixSocket(file os.DirEntry) bool { + // Assume a socket on Windows, since sock mode is not supported yet https://github.com/golang/go/issues/33357 + return !file.Type().IsDir() && strings.HasSuffix(file.Name(), ".sock") +} diff --git a/hack/buildah-vendor-treadmill b/hack/buildah-vendor-treadmill index 0aa4245c5..d579a180a 100755 --- a/hack/buildah-vendor-treadmill +++ b/hack/buildah-vendor-treadmill @@ -14,9 +14,10 @@ use warnings; use File::Temp qw(tempfile); use JSON; use LWP::UserAgent; +use POSIX qw(strftime); (our $ME = $0) =~ s|.*/||; -our $VERSION = '0.2'; +our $VERSION = '0.3'; # For debugging, show data structures using DumpTree($var) #use Data::TreeDumper; $Data::TreeDumper::Displayaddress = 0; @@ -65,7 +66,7 @@ eval ' sub usage { print <<"END_USAGE"; -Usage: $ME [OPTIONS] [--sync | --pick ] +Usage: $ME [OPTIONS] [--sync | --pick | --reset ] $ME is (2022-04-20) **EXPERIMENTAL** @@ -82,6 +83,9 @@ Call me with one of two options: --pick Used for really-truly vendoring in a new buildah; will cherry-pick a commit on your buildah-vendor working branch + --reset Used after vendoring buildah into main, when there + really aren't any buildah patches to keep rolling. + For latest documentation and best practices, please see: $Docs_URL @@ -105,8 +109,9 @@ our $NOT = ''; # print "blahing the blah$NOT\n" if $debug sub handle_opts { use Getopt::Long; GetOptions( - 'sync' => sub { $action{sync}++ }, - 'pick' => sub { $action{pick}++ }, + 'sync' => sub { $action{sync}++ }, + 'pick' => sub { $action{pick}++ }, + 'reset' => sub { $action{reset}++ }, 'force-old-main' => \$force_old_main, 'force-testing' => \$force_testing, @@ -183,8 +188,10 @@ sub do_sync { pull_main(); git('checkout', '-q', $current_branch); - # Preserve local patches - git('format-patch', "--output=$Patch_File", 'HEAD^'); + # Preserve local patches. --always will generate empty patches (e.g., + # after a buildah vendor when everything is copacetic); --no-signature + # prevents a buildup of "-- 2.35" (git version) lines at the end. + git('format-patch', '--always', '--no-signature', "--output=$Patch_File", 'HEAD^'); progress("Treadmill patches saved to $Patch_File"); # @@ -250,20 +257,11 @@ END_FAIL_INSTRUCTIONS } # Commit everything. - git('commit', '-as', '-m', <<"END_COMMIT_MESSAGE"); -[DO NOT MERGE] vendor in buildah \@ $buildah_new - -This is a JUNK COMMIT from $ME v$VERSION. - -DO NOT MERGE. This is just a way to keep the buildah-podman -vendoring in sync. Refer to: - - $Docs_URL -END_COMMIT_MESSAGE + git_commit_buildah($buildah_new); # And, finally, this has the highest possibility of failing progress('Reapplying preserved patches'); - git('am', $Patch_File); + git('am', '--empty=keep', $Patch_File); # It worked! Clean up: remove our local die() handler and the patch file undef $SIG{__DIE__}; @@ -638,6 +636,38 @@ END_EDIT_SCRIPT # END pick and its helpers ############################################################################### +# BEGIN reset and its helpers + +sub do_reset { + my $current_branch = git_current_branch(); + + # Make sure side branch == main (i.e., there are no commits on the branch) + if (git('rev-parse', $current_branch) ne git('rev-parse', 'main')) { + die "$ME: for --reset, $current_branch must == main\n"; + } + + # Pull main, and pivot back to this branch + pull_main(); + git('checkout', '-q', $current_branch); + + git('rebase', '--empty=keep', 'main'); + git_commit_buildah('[none]'); + + my $ymd = strftime("%Y-%m-%d", localtime); + git('commit', '--allow-empty', '-s', '-m' => <<"END_COMMIT_MESSAGE"); +$Treadmill_PR_Title + +As you run --sync, please update this commit message with your +actual changes. + +Changes since $ymd: +END_COMMIT_MESSAGE + + progress("Done. You may now run --sync.\n"); +} + +# END reset and its helpers +############################################################################### # BEGIN general-purpose helpers ############## @@ -728,6 +758,24 @@ sub git_upstream { die "$ME: did not find a remote with 'github.com/containers/podman'\n"; } +######################## +# git_commit_buildah # Do the buildah commit +######################## +sub git_commit_buildah { + my $buildah_version = shift; + + # When called by --reset, this can be empty + git('commit', '-as', '--allow-empty', '-m', <<"END_COMMIT_MESSAGE"); +DO NOT MERGE: vendor in buildah \@ $buildah_version + +This is a JUNK COMMIT from $ME v$VERSION. + +DO NOT MERGE! This is just a way to keep the buildah-podman +vendoring in sync. Refer to: + + $Docs_URL +END_COMMIT_MESSAGE +} ######### # git # Run a git command diff --git a/pkg/util/utils_windows.go b/pkg/util/utils_windows.go index 2732124f2..b91680f7a 100644 --- a/pkg/util/utils_windows.go +++ b/pkg/util/utils_windows.go @@ -4,6 +4,9 @@ package util import ( + "path/filepath" + + "github.com/containers/storage/pkg/homedir" "github.com/pkg/errors" ) @@ -34,7 +37,12 @@ func GetRootlessPauseProcessPidPathGivenDir(unused string) (string, error) { // GetRuntimeDir returns the runtime directory func GetRuntimeDir() (string, error) { - return "", errors.New("this function is not implemented for windows") + data, err := homedir.GetDataHome() + if err != nil { + return "", err + } + runtimeDir := filepath.Join(data, "containers", "podman") + return runtimeDir, nil } // GetRootlessConfigHomeDir returns the config home directory when running as non root diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index b5cec5fff..dcdd17143 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -786,17 +786,18 @@ RUN ls /dev/test1`, ALPINE) It("podman build use absolute path even if given relative", func() { containerFile := fmt.Sprintf(`FROM %s`, ALPINE) - err = os.Mkdir("relative", 0755) + relativeDir := filepath.Join(podmanTest.TempDir, "relativeDir") + containerFilePath := filepath.Join(relativeDir, "Containerfile") + buildRoot := filepath.Join(relativeDir, "build-root") + + err = os.Mkdir(relativeDir, 0755) Expect(err).To(BeNil()) - containerFilePath := filepath.Join("relative", "Containerfile") - err = os.Mkdir("relative/build-root", 0755) + err = os.Mkdir(buildRoot, 0755) Expect(err).To(BeNil()) err = ioutil.WriteFile(containerFilePath, []byte(containerFile), 0755) Expect(err).To(BeNil()) - build := podmanTest.Podman([]string{"build", "-f", "./relative/Containerfile", "./relative/build-root"}) + build := podmanTest.Podman([]string{"build", "-f", containerFilePath, buildRoot}) build.WaitWithDefaultTimeout() Expect(build).To(Exit(0)) - err = os.RemoveAll("relative") - Expect(err).To(BeNil()) }) }) diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index 536eefda7..897e49ef7 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -164,12 +164,13 @@ var _ = Describe("Podman save", func() { err = cmd.Run() Expect(err).To(BeNil()) - cmd = exec.Command("cp", "/etc/containers/registries.d/default.yaml", "default.yaml") + defaultYaml := filepath.Join(podmanTest.TempDir, "default.yaml") + cmd = exec.Command("cp", "/etc/containers/registries.d/default.yaml", defaultYaml) if err = cmd.Run(); err != nil { Skip("no signature store to verify") } defer func() { - cmd = exec.Command("cp", "default.yaml", "/etc/containers/registries.d/default.yaml") + cmd = exec.Command("cp", defaultYaml, "/etc/containers/registries.d/default.yaml") err := cmd.Run() Expect(err).ToNot(HaveOccurred()) }() diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go index 09e5da8a0..0bf5acbf1 100644 --- a/test/e2e/volume_create_test.go +++ b/test/e2e/volume_create_test.go @@ -3,6 +3,7 @@ package integration import ( "fmt" "os" + "path/filepath" . "github.com/containers/podman/v4/test/utils" . "github.com/onsi/ginkgo" @@ -90,7 +91,8 @@ var _ = Describe("Podman volume create", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.Podman([]string{"volume", "export", volName, "--output=hello.tar"}) + helloTar := filepath.Join(podmanTest.TempDir, "hello.tar") + session = podmanTest.Podman([]string{"volume", "export", volName, "--output", helloTar}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) @@ -98,7 +100,7 @@ var _ = Describe("Podman volume create", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.Podman([]string{"volume", "import", "my_vol2", "hello.tar"}) + session = podmanTest.Podman([]string{"volume", "import", "my_vol2", helloTar}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(session.OutputToString()).To(Equal(""), "output of volume import") |
