WIP: Windows install/starup tweaks

This commit is contained in:
Craig Everett 2020-01-19 23:44:46 +09:00
parent 9f1763ec1c
commit 4e3c5d7202
7 changed files with 69 additions and 30 deletions

View File

@ -27,7 +27,8 @@ main(_) ->
unpack(OS, ZompDir) ->
BaseDir = filename:dirname(ZompDir),
ok = erl_tar:extract("zomp.tar.gz", [compressed, {cwd, BaseDir}]),
{ok, Files} = zip:extract("zomp.zip", [{cwd, BaseDir}]),
ok = io:format("Extracted: ~tp~n", [Files]),
add_launcher(OS, ZompDir).
@ -37,13 +38,13 @@ unpack(OS, ZompDir) ->
ZompDir :: file:filename().
add_launcher({unix, linux}, ZompDir) ->
add_unix_link(ZompDir),
ok = add_unix_link(ZompDir),
halt(0);
add_launcher({unix, _}, ZompDir) ->
add_unix_link(ZompDir),
ok = add_unix_link(ZompDir),
halt(0);
add_launcher({win32, nt}, _ZompDir) ->
ok = io:format("This is going to be a bit of a rodeo...~n"),
add_launcher({win32, nt}, ZompDir) ->
ok = add_windows_link(ZompDir),
halt(0).
@ -86,6 +87,27 @@ add_unix_link(ZompDir) ->
io:format(Message, [Target, Link, HomeBin]).
-spec add_windows_link(ZompDir) -> ok
when ZompDir :: file:filename().
add_windows_link(ZompDir) ->
Home = filename:join(os:getenv("HOMEDRIVE"), os:getenv("HOMEPATH")),
Launcher = filename:join(ZompDir, "zx.cmd"),
LauncherH = filename:join(ZompDir, "zxh.cmd"),
Vapor = filename:join(ZompDir, "vapor.cmd"),
Target = filename:join(Home, "zx.cmd"),
TargetH = filename:join(Home, "zxh.cmd"),
VaporL = filename:join([Home, "Desktop", "Vapor.cmd"]),
{ok, _} = file:copy(Launcher, Target),
{ok, _} = file:copy(LauncherH, TargetH),
{ok, _} = file:copy(Vapor, VaporL),
Message =
"`zx` and `zxh` launch scripts have been added to ~p~n"
"(available from cmd.exe in your home directory)~n"
"A GUI program launcher script has been added to the desktop.~n",
io:format(Message, [Home]).
-spec os_cmd(Command :: string()) -> ok.
os_cmd(Command) ->

16
packup
View File

@ -5,18 +5,18 @@
main(_) ->
{ok, BV} = file:read_file("zomp/etc/version.txt"),
Version = string:strip(binary_to_list(BV), both, $\n),
Tar = "zomp.tar.gz",
ok = erl_tar:create(Tar, ["zomp"], [compressed]),
Zip = "zx-" ++ Version ++ ".zip",
ZipFiles =
Inner = "zomp.zip",
Outer = "zx-" ++ Version ++ ".zip",
{ok, Inner} = zip:create(Inner, ["zomp"]),
Files =
["install.escript",
"install_unix",
"uninstall_unix",
"README.md",
"README.install",
"LICENSE",
Tar],
{ok, Zip} = zip:create(Zip, ZipFiles),
ok = file:delete(Tar),
ok = io:format("~ts~n", [Zip]),
Inner],
{ok, Outer} = zip:create(Outer, Files),
ok = file:delete(Inner),
ok = io:format("~ts~n", [Outer]),
halt(0).

1
vapor.cmd Normal file
View File

@ -0,0 +1 @@
start /min cmd.exe /c "%HOMEDRIVE%%HOMEPATH%\zx" run vapor

View File

@ -11,6 +11,10 @@ export ZX_DIR="$ZOMP_DIR/lib/otpr/zx/$ZX_VERSION"
start_dir="$PWD"
cd "$ZX_DIR"
./make_zx
if [ ! -f ebin/zx.erl ]
then
chmod +x make_zx
./make_zx
fi
cd "$start_dir"
erl -noshell -pa "$ZX_DIR/ebin" -run zx do -extra $@

View File

@ -1,9 +1,13 @@
@ECHO OFF
REM Prepare the environment for ZX and launch it
set ZOMP_DIR="%LOCALAPPDATA%\zomp"
set /P VERSION=<"%ZOMP_DIR%\etc\version.txt"
set ZX_DIR="%ZOMP_DIR%\lib\otpr\zx\%VERSION%"
pushd %ZX_DIR%
escript.exe make_zx
set ZOMP_DIR=%ZOMP_DIR:"=%
set /P ZX_VERSION=<"%ZOMP_DIR%\etc\version.txt"
set ZX_DIR=%ZOMP_DIR%\lib\otpr\zx\%ZX_VERSION%
set ZX_DIR=%ZX_DIR:"=%
pushd "%ZX_DIR%"
if not exist ebin\zx.erl "C:\Program Files\erl10.6\bin\escript.exe" make_zx
popd
erl.exe -pa "%ZX_DIR%/ebin" -run zx run "%*"
"C:\Program Files\erl10.6\bin\erl.exe" -noshell -pa "%ZX_DIR%/ebin" -run zx do -extra %*

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
if [ -f "$HOME/.bash_profile" ]
then
@ -11,6 +11,10 @@ export ZX_DIR="$ZOMP_DIR/lib/otpr/zx/$ZX_VERSION"
start_dir="$PWD"
cd "$ZX_DIR"
./make_zx
if [ ! -f ebin/zx.erl ]
then
chmod +x make_zx
./make_zx
fi
cd "$start_dir"
erl -pa "$ZX_DIR/ebin" -run zx do -extra $@

View File

@ -1,9 +1,13 @@
@ECHO OFF
REM Prepare the environment for ZX and launch it
set ZOMP_DIR="%LOCALAPPDATA%\zomp"
set /P VERSION=<"%ZOMP_DIR%\etc\version.txt"
set ZX_DIR="%ZOMP_DIR%\lib\otpr\zx\%VERSION%"
pushd %ZX_DIR%
escript.exe make_zx
set ZOMP_DIR=%ZOMP_DIR:"=%
set /P ZX_VERSION=<"%ZOMP_DIR%\etc\version.txt"
set ZX_DIR=%ZOMP_DIR%\lib\otpr\zx\%ZX_VERSION%
set ZX_DIR=%ZX_DIR:"=%
pushd "%ZX_DIR%"
if not exist ebin\zx.erl "C:\Program Files\erl10.6\bin\escript.exe" make_zx
popd
erl.exe -pa "%ZX_DIR%/ebin" -run zx run "%*"
"C:\Program Files\erl10.6\bin\werl.exe" -pa "%ZX_DIR%/ebin" -run zx do -extra %*