Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Support for Windows ( bfirsh/whalebrew#29 ) #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

3846masa
Copy link

@3846masa 3846masa commented Jan 31, 2017

Whalebrew on Windows 馃悑 馃帀 馃惓 ( #29 )

I checked on cmd and MSYS2 bash with Docker for Windows.


PR for Windows

syscall -> exec (3846masa@8a6d783)

To change syscall.Exec to exec.Command because syscall.Exec causes Error on Windows.

Fix checking args

First argument checking hack is not working on Windows. I changed it.

Add batch file support (3846masa@ffbdd15)

When whalebrew install on Windows, generate batch file.
Batch file passes shell file and args to whalebrew.

Fix default WHALEBREW_INSTALL_PATH (3846masa@74db526)

I have no idea where is good for install_path on Windows.
Temporally, WHALEBREW_INSTALL_PATH is C:\whalebrew if on Windows.

Add install script for Windows (3846masa@94a625d)

Install script will download whalebrew.exe and set Path and WHALEBREW_INSTALL_PATH.

path.Join -> filepath.Join (3846masa@7453d37)

c.f. ) http://stackoverflow.com/questions/9371031/how-do-i-create-crossplatform-file-paths-in-go

Rewrite test for Windows (3846masa@bc12aa0)

Add MakePackagePath function (3846masa@fe06f35)

Because package file name is different on Windows and *nix


TODO

  • CI Test for Windows
  • Best solution for WHALEBREW_INSTALL_PATH on Windows

This is first time to write golang. Please check changes. 馃檹
Thanks.

@Foucl
Copy link

Foucl commented Feb 2, 2017

I can confirm that this works on Win 10 x64, Preview 15019 with latest docker for windows beta release. I used it with cmd, but also have msys2 installed and its binaries in my PATH (don't know if that's relevant).
tiny note: maybe create the install directory if it doesn't exist (whalebrew install currently throws an error if it doesn't).

main.go Outdated
// Check if not command exists
if _, _, err := cmd.RootCmd.Find(os.Args); err != nil {
// Check if file exists
if _, err := os.Stat(os.Args[1]); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

This seems even more flimsy than my hack. ;) e.g. I can envisage lots of stuff unexpectedly not working if they collide with command names.

You could just run whalebrew run [pkg] in the batch script.

@bfirsh
Copy link
Member

bfirsh commented Feb 2, 2017

Thanks for this @3846masa! This is a great start.

Some thoughts:

  • syscall.Exec can't be trivially replaced (exit code won't be returned, signals won't be passed, etc. Probably lots of unknown unknowns here.)
  • I think we can come up with a neater solution than writing two files. I did the YAML file with shebang method because it works neatly on *nix, but that's clearly not the case on Windows.
  • I don't run windows, and I'm sure a lot of contributors won't, so we need thorough integration tests and CI to make sure we don't break it. This is the main reason I want to be conservative about including this - it'll slow down development.
  • Presumably we'll need some different installation instructions for windows, including setting up paths.

@bfirsh bfirsh mentioned this pull request Feb 3, 2017
@mapitman
Copy link
Contributor

mapitman commented Feb 5, 2017

Didn't realize this PR existed and I've been working on my own branch to get whalebrew working on Windows. I found a problem with using exec.Command and hooking up stdin, stdout and stderr. I tested with the whalebrew/lynx package and it doesn't work so well. Packages that don't require any input other than what's passed on the command line seem to work fine. Maybe whalebrew can just write out the full Docker command into the batch files?

@mapitman
Copy link
Contributor

mapitman commented Feb 5, 2017

Even running the whalebrew/lynx docker container directly from the commandline doesn't seem to work very well on Windows. It's not as bad as when using exec.Command from inside whalebrew, but still not very usable.

@mapitman
Copy link
Contributor

mapitman commented Feb 5, 2017

More info: when you pass a commandline argument to the lynx command, it hangs and I thought it was only on windows, but it is happening on macOS as well:

lynx http://google.com

So, I don't think there is a problem using command.Exec on Windows. I figured out a way to write out the batch files with YAML embedded too.

@3846masa
Copy link
Author

3846masa commented Feb 5, 2017

Thanks for comments. I changed code.

  • Use exec.Command on only Windows
    • Fix to return status code of exec.Command
  • Batch file includes YAML (This is valid as YAML and batch file)
    • This solution generates only one file
    :: |
      @( whalebrew run %~f0 %* ) & exit /b errorlevel
    image: whalebrew/whalesay
  • Revert args hack
    • I agree @bfirsh opinion.
    • For windows, user just run whalebrew run [pkg] via batch file

@3846masa 3846masa changed the title Support for Windows ( bfirsh/whalebrew#29 ) [WIP] Support for Windows ( bfirsh/whalebrew#29 ) Feb 5, 2017
@3846masa
Copy link
Author

3846masa commented Feb 5, 2017

I wrote TODO in first comment and changed PR title.

@3846masa 3846masa force-pushed the support-windows-rebase branch 3 times, most recently from cf83dff to 3107cb8 Compare February 13, 2017 13:21
@3846masa
Copy link
Author

3846masa commented Feb 13, 2017

I changed.

@3846masa
Copy link
Author

3846masa commented Sep 8, 2017

Bump to 0.1.0.
Also add install script for Windows.

@bfirsh
Copy link
Member

bfirsh commented Sep 8, 2017

Nice, thank you @3846masa! (and @mapitman!) I will take a proper look at this when I get some time.

Would you be willing to help maintain the Windows support? I don't have a Windows machine so I am worried it will deteriorate unless somebody's keeping an eye on it. The CI will certainly help - thanks for that. :)

Whalebrew seems pretty stable and feature complete now, so I doubt there'll be much involved.

@3846masa
Copy link
Author

3846masa commented Sep 8, 2017

Ok, I'll help maintain for Windows.
I want whalebrew on Windows because I use Windows machine everyday 馃憤

@3846masa 3846masa force-pushed the support-windows-rebase branch 2 times, most recently from aea13b2 to c48c383 Compare October 28, 2017 03:01
Squashed commit of the following:

commit b677dbc
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Sat Oct 28 11:35:30 2017 +0900

    Fix golang version

commit 43bc363
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Sat Oct 28 11:12:42 2017 +0900

    Fix shebang for Windows

commit ed225df
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Fri Sep 8 10:29:39 2017 +0900

    Fix CI

commit 94a625d
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Fri Sep 8 10:26:49 2017 +0900

    Fix windows installer

commit 0bea8fb
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Fri Sep 8 10:26:20 2017 +0900

    Fix README for Windows installer

commit 237a4a7
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Thu Sep 7 19:11:19 2017 +0900

    Fix build for Windows

commit bc508d7
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Thu Sep 7 18:59:16 2017 +0900

    Fix to set API version (moby/moby#32779)

commit 442be2f
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Thu Sep 7 18:03:01 2017 +0900

    Update README for Windows

commit e83b2ed
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Thu Sep 7 18:01:01 2017 +0900

    Add installer for Windows

commit 776b931
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Thu Sep 7 18:00:38 2017 +0900

    Build for Windows

commit bc01aef
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Thu Sep 7 17:43:43 2017 +0900

    Fix `run.go` for Windows

commit 63b9490
Merge: a72237f 0fea7e2
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Thu Sep 7 17:43:01 2017 +0900

    Merge tag '0.1.0' of https://github.com/bfirsh/whalebrew into support-windows

commit a72237f
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Thu Sep 7 17:26:29 2017 +0900

    Fix `ForceInstall` for windows

commit de458d9
Merge: 03d00bf e7d0792
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Thu Sep 7 17:22:41 2017 +0900

    Merge tag '0.0.5' into support-windows

commit 03d00bf
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Tue Feb 14 00:01:52 2017 +0900

    Fix batch file's shebang

commit 21bcf14
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Mon Feb 13 22:19:25 2017 +0900

    Fix .travis.yml for forked project

commit a0e486c
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Mon Feb 13 21:59:19 2017 +0900

    Add appveyor.yml

commit fe06f35
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Mon Feb 13 21:34:46 2017 +0900

    MakePackagePath

commit bc12aa0
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Mon Feb 13 21:23:31 2017 +0900

    Rewrite test

commit 7453d37
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Mon Feb 13 20:28:33 2017 +0900

    `path.Join` -> `filepath.Join`

commit 4ded1a2
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Mon Feb 13 16:53:51 2017 +0900

    LF -> CRLF in batch file

commit 8078165
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Mon Feb 13 16:34:08 2017 +0900

    Fix edit for Windows

commit 8746496
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Mon Feb 13 16:15:55 2017 +0900

    Fix run for windows

commit bb652d4
Merge: 8a6d783 e7e6427
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Mon Feb 13 16:08:42 2017 +0900

    Merge v0.0.4

    Merge remote-tracking branch 'origin/master' into support-windows

commit 8a6d783
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Sun Feb 5 21:11:59 2017 +0900

    Support to run and return status code on Windows

commit ce3d298
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Sun Feb 5 20:58:21 2017 +0900

    Revert "syscall -> exec (for working on windows)"

    This reverts commit 276a9cd.

commit ffbdd15
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Sun Feb 5 20:50:08 2017 +0900

    Add batch file support (for working on windows)

commit cdc5a05
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Sun Feb 5 20:34:30 2017 +0900

    Revert "Add batch file support (for working on windows)"

    This reverts commit aba79b0.

commit 10e10a0
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Fri Feb 3 00:53:23 2017 +0900

    Revert "Fix checking args (for working on windows)"

    This reverts commit 926f422.

commit 74db526
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Wed Feb 1 03:14:59 2017 +0900

    Fix default WHALEBREW_INSTALL_PATH (for working on windows)

commit aba79b0
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Wed Feb 1 03:06:00 2017 +0900

    Add batch file support (for working on windows)

commit 926f422
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Wed Feb 1 01:45:51 2017 +0900

    Fix checking args (for working on windows)

commit 276a9cd
Author: 3846masa <3846masahiro+git@gmail.com>
Date:   Wed Feb 1 01:36:56 2017 +0900

    syscall -> exec (for working on windows)
tjamet added a commit that referenced this pull request Oct 14, 2020
This allows to move forward in the direction of windows compatibility.

This takes part of changes from #34 and makes a step forward for #29.
@asadakbarml
Copy link

Is there a timeline for this?

@tjamet
Copy link
Contributor

tjamet commented Jun 23, 2021

Hi @asadakbarml thanks for the heads up.
There is currently no work being done on windows.
I would be happy though to accept pull requests to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants