ghitchens / bake

[deprecated] - Configure, compile and share systems, toolchains and linux firmware.
55 stars 3 forks source link

Bake installer script support for Linux / Windows #1

Open mobileoverlord opened 8 years ago

mobileoverlord commented 8 years ago

The bake installer script should be moved out of bakeware and into bake. It should also be written in elixir instead of ruby. This will allow us to ensure that the host machine you are installing bake onto has elixir installed to support running the escript.

The installer script should also perform the tasks if

These tasks should be tailored to run properly on windows and linux in addition to mac os

kfatehi commented 8 years ago

So far I've found this to work everywhere:

elixir -e "~s(https://gist.githubusercontent.com/kfatehi/12dc743ce2de71a107df/raw/43928a9634a207ea3944a1a82e1837241064932d/install.exs) |> Mix.Utils.read_path() |> elem(1) |> Code.eval_string()"

At this point it feels safe enough to start porting the ruby to elixir and then use the above as the delivery method. Thoughts?

Note: I had to use sigil for the URL string literal due to cross platform escaping inconsistency.

kfatehi commented 8 years ago

Actually, this is better, because it uses checksum and runs code only if it passes, and displays the checksum error otherwise:

# good checksum
$ elixir -e "case ~s(http://localhost:8000/install.exs) |> Mix.Utils.read_path(sha512: ~s(45b8ba592d816dbe56e58aaacf6378e9509a16acd3654f39ce7ee04af8696d0cc365f0a9aeee779d22506b8a5ca9590d1176df6dbabaf1477d16bfb25a2e0dd8)) do {:ok, code} -> code end |> Code.eval_string()"
helo wordl

#bad checksum
$ elixir -e "case ~s(http://localhost:8000/install.exs) |> Mix.Utils.read_path(sha512: ~s(123)) do {:ok, code} -> code end |> Code.eval_string()"
** (CaseClauseError) no case clause matching: {:checksum, "Data does not match the given sha512 checksum.\n\nExpected: 123\n  Actual: 45b8ba592d816dbe56e58aaacf6378e9509a16acd3654f39ce7ee04af8696d0cc365f0a9aeee779d22506b8a5ca9590d1176df6dbabaf1477d16bfb25a2e0dd8\n"}
    (stdlib) :erl_eval.expr/3
    (elixir) lib/code.ex:168: Code.eval_string/3
kfatehi commented 8 years ago

The install script works on all platforms. Check out the README at https://github.com/kfatehi/bake_install

The readme file is autogenerated by the default make task defined in the makefile. I did this so that it autogenerates the correct command with the sha512 of the install script.

fhunleth commented 8 years ago

I think this is really cool. My only complaint is that go_untar.exe is needed. The bake-0.1.1.tar.gz file is 6,245,404 bytes. bake is 6,290,427 bytes, so compression doesn't buy much. Any reservations on just downloading bake? Or if it's anticipated that bake has more files, maybe use the ZIP format and uncompress in Elixir via :zip.unzip/1?

mobileoverlord commented 8 years ago

Well, erlang has a built in tar tool. We could just resort to using that. I have it in BakeUtils. I think we need to go after a solution which uses tar because it's needed for in archiving systems and toolchains

fhunleth commented 8 years ago

Even better.

RaulRG commented 8 years ago

I tried the Elixir script in a Linux machine (Ubuntu 15) and didn't work for me. I used apt-get to install Elixir (and of course Erlang) but the function Mix.Utils.read_path() could not be found. I am new to Erlang / Elixir so that I don't know if it is something stupid on my side :-)

The only thing that looks strange for me is that apt-get installed a "1.1.0-development" version (or something like this) of Elixir. It seems that there are no 1.2 packages.

robphoenix commented 8 years ago

The install script at https://github.com/kfatehi/bake_install works for me on Ubuntu 14.04.

@RaulRG Have you added the Erlang solutions package? they've recently updated to 1.2

$ wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
$ sudo apt-get update
$ sudo apt-get install esl-erlang
$ sudo apt-get install elixir
RaulRG commented 8 years ago

Thank you bordeltabernacle!

I created a new Ubuntu 14.04 VM some days ago. I will try your suggestions. As I said before, my Image had no 1.2 Version. This is probably the Problem.

RaulRG commented 8 years ago

Ok, the error message is gone. Now it does not find fwup :-( I am not a Linux guy, so this is probably something "easy". I saw a blog post from you and I tried to install fwup using it, but it didn't work for me. It would be nice to have something like apt-get install fwup

robphoenix commented 8 years ago

@RaulRG Hi, you could try following the installation here it's a little more explicit. I'm not much of a Linux guy myself, but if you have any further problems I'd be happy to try and help, hit me up on the #nerves channel on the elixir-lang slack, we should keep this issues thread clear of general discussion.