Separate platform-specific installers

This commit is contained in:
Craig Everett 2020-01-20 15:50:43 +09:00
parent 4e3c5d7202
commit 3ed1513ea3
12 changed files with 100 additions and 197 deletions

View File

@ -1,14 +0,0 @@
Installation of ZX
For more complete installation information see the docs here:
Download/Install page: https://zxq9.com/projects/zomp/download.en.html
Linux/BSD/OSX/*nix:
To install this program from the current bundle make the install_unix script
executable and run it. ZX will expect you to have $HOME/bin in your $PATH,
though it can install without this (though it may not successfully update
itself after installation). To uninstall make the uninstall_unix script
executable and run it.
Windows:
Download the Windows installer from the download page (linked above).

View File

@ -1,13 +1,34 @@
# ZX: The Zomp client
TLDR: If you have ZX on your system, "zx run [program name]" will launch any Erlang-based program that exists in the Zomp system.
"zx create project" will start a project for you.
ZX is four things:
1. An end-user client for the Zomp package distribution system
2. A suite of code development and packaging tools in Erlang for Erlang
3. The back-end of Vapor, the Erlang GUI launcher and app browser
4. A runtime service for Erlang programs that need resources or notifications from Zomp
ZX and Zomp are developed with ZX and hosted with Zomp, so after initial installation keeping up to date is simple.
If you have ZX on your system, `zx run [program name]` will launch a program.
`zx create project` will start a project for you.
Read the [docs](http://zxq9.com/projects/zomp/) for more.
Zomp is a from-source code repository and distributed distribution system.
ZX is a front-end for that system that incorporates developer tools with end-user launching functionality.
## Docs
http://zxq9.com/projects/zomp/
[http://zxq9.com/projects/zomp/](http://zxq9.com/projects/zomp/)
## Code
https://gitlab.com/zxq9/zx/
[https://gitlab.com/zxq9/zx/](https://gitlab.com/zxq9/zx/)
# Installation
For complete installation information see the [installation page](https://zxq9.com/projects/zomp/qs.install.en.html).
## Linux/BSD/OSX/*nix:
To install this program from the current bundle make the `install_unix` script
executable and run it. ZX will expect you to have `$HOME/bin` in your $PATH,
though it can install without this (though it may not successfully update
itself after installation). To uninstall make the `uninstall_unix` script
executable and run it.
## Windows:
Download the Windows installer from the [download page](https://zxq9.com/projects/zomp/download.en.html).

57
install Executable file
View File

@ -0,0 +1,57 @@
#! /bin/bash
zomp_dir="$HOME"/zomp
bin="$HOME"/bin
cd "$(dirname $(realpath $0))"
chmod +x uninstall
if [ -d "$zomp_dir" ]
then
echo "Installation directory $zomp_dir already exists. Aborting."
exit 17
fi
if [ ! -d "$bin" ]
then
echo "$bin does not exist. Creating it."
mkdir "$bin"
fi
if [[ ":$PATH:" == *":$bin:"* ]]
then
echo "$bin was found in \$PATH. Good to go."
else
echo "$bin was not found in \$PATH. Adding it."
export PATH="$bin:$PATH"
fi
for rc in "$HOME/.profile" "$HOME/.bashrc" "$HOME/.bash_profile"
do
if grep -q "PATH=\"\$HOME/bin:\$PATH\"" "$rc"
then
echo "Path adjustment found in $rc."
else
echo "Path adjustment not found in $rc. Adding it."
echo "export PATH=\"\$HOME/bin:\$PATH\"" >> "$rc"
fi
done
cp -r zomp "$zomp_dir"
cp unix/zx "$zomp_dir"
cp unix/zxh "$zomp_dir"
cp README.md "$zomp_dir"
cp LICENSE "$zomp_dir"
cp uninstall "$zomp_dir"
ln -s "$zomp_dir"/zx "$bin"/zx
ln -s "$zomp_dir"/zxh "$bin"/zxh
if zx_link=$(command -v zx)
then
echo "zx found at $zx_link. Checking for upgrade."
echo "Running \`zx upgrade\`..."
zx upgrade
else
echo "zx is not yet in \$PATH."
echo "Add zx's location ($HOME/bin) to \$PATH run \`zx upgrade\`."
fi

View File

@ -1,138 +0,0 @@
#! /usr/bin/env escript
%% ZX install script
-mode(compile).
-spec main(Argv :: [string()]) -> no_return().
main(_) ->
ok = io:setopts([{encoding, unicode}]),
OS = os:type(),
ZompDir = zomp_dir(OS),
case filelib:is_dir(ZompDir) of
true ->
Message = "Installation directory (~ts) already exists. Aborting.~n",
ok = io:format(Message, [ZompDir]),
halt(0);
false ->
unpack(OS, ZompDir)
end.
-spec unpack(OS, ZompDir) -> no_return()
when OS :: {Family :: unix | win32,
Name :: atom()},
ZompDir :: file:filename().
unpack(OS, ZompDir) ->
BaseDir = filename:dirname(ZompDir),
{ok, Files} = zip:extract("zomp.zip", [{cwd, BaseDir}]),
ok = io:format("Extracted: ~tp~n", [Files]),
add_launcher(OS, ZompDir).
-spec add_launcher(OS, ZompDir) -> no_return()
when OS :: {Family :: unix | win32,
Name :: atom()},
ZompDir :: file:filename().
add_launcher({unix, linux}, ZompDir) ->
ok = add_unix_link(ZompDir),
halt(0);
add_launcher({unix, _}, ZompDir) ->
ok = add_unix_link(ZompDir),
halt(0);
add_launcher({win32, nt}, ZompDir) ->
ok = add_windows_link(ZompDir),
halt(0).
-spec add_unix_link(ZompDir) -> ok
when ZompDir :: file:filename().
add_unix_link(ZompDir) ->
Home = filename:dirname(ZompDir),
Link = filename:join(Home, "bin/zx"),
LinkH = filename:join(Home, "bin/zxh"),
HomeBin = filename:dirname(Link),
Target = filename:join(ZompDir, "zx"),
TargetH = filename:join(ZompDir, "zxh"),
ok = filelib:ensure_dir(Link),
LinkCommand = "env LANG=en ln -s " ++ Target ++ " " ++ Link,
LinkCommandH = "env LANG=en ln -s " ++ TargetH ++ " " ++ LinkH,
ModeCommand = "env LANG=en chmod +x " ++ Target,
ModeCommandH = "env LANG=en chmod +x " ++ TargetH,
ok = os_cmd(LinkCommand),
ok = os_cmd(LinkCommandH),
ok = os_cmd(ModeCommand),
ok = os_cmd(ModeCommandH),
Path = os:getenv("PATH"),
Parts = string:lexemes(Path, ":"),
Message =
case lists:member(HomeBin, Parts) of
true ->
"A link to ~ts has been created at ~ts.~n"
"~ts seems to be in $PATH already.~n"
"You should be able to run any Zomp/ZX program as a normal shell~n"
"command by typing `zx`, or with an Erlang shell attached by~n"
"typing `zxh` from anywhere in your system.~n";
false ->
"A link to ~ts has been created at ~ts. "
"~ts seems to be NOT in your $PATH. "
"You will need to add that to $PATH if you want to be able to run~n"
"zx by simply typing `zx` (or zxh to attach an Erlang shell) from~n"
"anywhere in your system.~n"
end,
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) ->
case os:cmd(Command) of
"" ->
ok;
Output ->
ok = io:format("Output of: ~tp~n", [Command]),
io:format("~ts~n", [Output])
end.
-spec zomp_dir(OS) -> file:filename()
when OS :: {Family :: unix | win32,
Name :: atom()}.
%% @private
%% Check the host OS and return the absolute path to the zomp filesystem root.
zomp_dir({unix, _}) ->
Home = os:getenv("HOME"),
filename:join(Home, "zomp");
zomp_dir({win32, _}) ->
Path = os:getenv("LOCALAPPDATA"),
filename:join(Path, "zomp");
zomp_dir(Unknown) ->
Message = "zx_install: ERROR Unknown host system type: ~tp",
ok = io:format(Message, [Unknown]),
halt(1).

View File

@ -1,17 +0,0 @@
#! /bin/sh
if escript_path=$(command -v escript)
then
echo "Using escript found at $escript_path"
escript install.escript
if zx_link=$(command -v zx)
then
echo "zx found in \$PATH at $zx_link. Checking for upgrade."
echo "Running \`zx upgrade\`..."
zx upgrade
else
echo "zx is not yet in \$PATH. Once you have added zx's location to \$PATH run \`zx upgrade\`."
fi
else
echo "Could not locate an Erlang installation."
fi

36
packup
View File

@ -1,22 +1,16 @@
#! /usr/bin/env escript
#! /bin/bash
-mode(compile).
main(_) ->
{ok, BV} = file:read_file("zomp/etc/version.txt"),
Version = string:strip(binary_to_list(BV), both, $\n),
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",
Inner],
{ok, Outer} = zip:create(Outer, Files),
ok = file:delete(Inner),
ok = io:format("~ts~n", [Outer]),
halt(0).
version=$(head -n1 zomp/etc/version.txt)
name=zx-"$version"
archive_gz="$name".tar.gz
archive_xz="$name".tar.xz
tmpdir=$(mktemp -d)
zxtmp="$tmpdir"/"$name"
mkdir "$zxtmp"
cp -r zomp "$zxtmp"
cp -r unix "$zxtmp"
cp install uninstall README.md LICENSE "$zxtmp"
tar -C "$tmpdir" -zcf "$PWD/$archive_gz" "$name"
tar -C "$tmpdir" -Jcf "$PWD/$archive_xz" "$name"
rm -rf "$tmpdir"
echo "$archive_xz"

View File

View File