feat(setup/unix.sh): refactor
This commit is contained in:
17
packages/haxelib.txt
Normal file
17
packages/haxelib.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
away3d git github.com/moxie-coder/away3d
|
||||
flixel git git.disroot.org/FNF-i486-Engine/flixel-fork
|
||||
flxanimate git github.com/Dot-Stuff/flxanimate 768740a56b26aa0c072720e0d1236b94afe68e3e
|
||||
funkin.vis git github.com/FunkinCrew/funkVis 22b1ce089dd924f15cdc4632397ef3504d464e90
|
||||
grig.audio git gitlab.com/haxe-grig/grig.audio.git
|
||||
hxcpp git github.com/th2l-devs/hxcpp
|
||||
hxdiscord_rpc git github.com/MAJigsaw77/hxdiscord_rpc
|
||||
hxvlc git github.com/th2l-devs/hxvlc
|
||||
lime git github.com/th2l-devs/lime
|
||||
linc_luajit git github.com/th2l-devs/linc_luajit
|
||||
openfl git github.com/th2l-devs/openfl
|
||||
tjson git github.com/moxie-coder/tjson
|
||||
flixel-addons release 3.2.3
|
||||
flixel-tools release 1.5.1
|
||||
flixel-ui release 2.6.0
|
||||
hscript release
|
||||
hxcpp-debug-server release
|
6
packages/system/dpkg.txt
Normal file
6
packages/system/dpkg.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
libgl-dev
|
||||
libncurses-dev
|
||||
libx11-dev
|
||||
libxi-dev
|
||||
libxpm-dev
|
||||
libxrandr-dev
|
6
packages/system/english.txt
Normal file
6
packages/system/english.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
an OpenGL implementation with development headers
|
||||
ncurses with development headers
|
||||
the X11 library with development headers
|
||||
the Xi library with development headers
|
||||
the Xpm library with development headers
|
||||
the Xrandr library with development headers
|
6
packages/system/pacman.txt
Normal file
6
packages/system/pacman.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
libgl
|
||||
ncurses
|
||||
libx11
|
||||
libxi
|
||||
libxpm
|
||||
libxrandr
|
6
packages/system/portage.txt
Normal file
6
packages/system/portage.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
media-libs/mesa
|
||||
sys-libs/ncurses
|
||||
x11-libs/libX11
|
||||
x11-libs/libXi
|
||||
x11-libs/libXpm
|
||||
x11-libs/libXrandr
|
301
setup/unix.sh
301
setup/unix.sh
@@ -1,30 +1,283 @@
|
||||
#!/bin/sh
|
||||
# SETUP FOR MAC AND LINUX SYSTEMS!!!
|
||||
# REMINDER THAT YOU NEED HAXE INSTALLED PRIOR TO USING THIS
|
||||
# https://haxe.org/download
|
||||
|
||||
# Package installation script for POSIX-compatible *nix operating systems
|
||||
#
|
||||
# The following package managers are currently supported:
|
||||
# - dpkg
|
||||
# - pacman
|
||||
# - Portage
|
||||
#
|
||||
# Let us know if you use another *nix, such as macOS, Fedora or openSUSE.
|
||||
|
||||
current_revision=2
|
||||
|
||||
stty_ctrl_c_sends_quit() {
|
||||
old_stty="$(stty -g)" || return 128
|
||||
stty_restored=0
|
||||
|
||||
restore_stty() {
|
||||
[ "$stty_restored" -eq "1" ] && return 0
|
||||
|
||||
stty_restored=1
|
||||
|
||||
stty "$old_stty"
|
||||
}
|
||||
|
||||
trap 'restore_stty' QUIT INT
|
||||
|
||||
stty quit '^C'
|
||||
}
|
||||
|
||||
message() {
|
||||
printf -- '%s\n' "$*"
|
||||
}
|
||||
|
||||
message "Installing dependencies..."
|
||||
message "This might take a few moments depending on your internet speed."
|
||||
sudo apt install libgl-dev libx11-dev libxi-dev libxpm-dev libxrandr-dev libncurses-dev
|
||||
haxelib git lime https://github.com/th2l-devs/lime --quiet
|
||||
haxelib git openfl https://github.com/th2l-devs/openfl --quiet
|
||||
haxelib git flixel https://git.disroot.org/FNF-i486-Engine/flixel-fork --quiet
|
||||
haxelib install flixel-addons 3.2.3 --quiet
|
||||
haxelib install flixel-tools 1.5.1 --quiet
|
||||
haxelib install flixel-ui 2.6.0 --quiet
|
||||
haxelib install hscript --quiet
|
||||
haxelib install hxcpp-debug-server --quiet
|
||||
haxelib git away3d https://github.com/moxie-coder/away3d --quiet
|
||||
haxelib git tjson https://github.com/moxie-coder/tjson --quiet
|
||||
haxelib git hxcpp https://github.com/th2l-devs/hxcpp --quiet
|
||||
haxelib git flxanimate https://github.com/Dot-Stuff/flxanimate 768740a56b26aa0c072720e0d1236b94afe68e3e --quiet
|
||||
haxelib git linc_luajit https://github.com/th2l-devs/linc_luajit --quiet
|
||||
haxelib git funkin.vis https://github.com/FunkinCrew/funkVis 22b1ce089dd924f15cdc4632397ef3504d464e90 --quiet
|
||||
haxelib git grig.audio https://gitlab.com/haxe-grig/grig.audio.git --quiet
|
||||
haxelib git hxdiscord_rpc https://github.com/MAJigsaw77/hxdiscord_rpc --quiet
|
||||
haxelib git hxvlc https://github.com/th2l-devs/hxvlc --quiet
|
||||
message "Finished!"
|
||||
indented() {
|
||||
printf -- ' '
|
||||
"$@"
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
command -v "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
if ! command_exists tput || [ ! -t 1 ]; then
|
||||
tput() {
|
||||
true # no operation
|
||||
}
|
||||
fi
|
||||
|
||||
error() {
|
||||
message "$(tput setaf 1)Error$(tput sgr0): $*" >&2
|
||||
}
|
||||
|
||||
script_dir="$(dirname "$0")" || return 128
|
||||
pkg_list_dir="${script_dir}/../packages"
|
||||
if ! [ -d "$pkg_list_dir" ]; then
|
||||
error "Package list directory does not exist"
|
||||
exit 128
|
||||
fi
|
||||
|
||||
require_command() {
|
||||
if ! command_exists "$1"; then
|
||||
error "Command \"$1\" not found. Please install ${2:-"it"}."
|
||||
exit 127
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$(id -u)" -ne "0" ]; then
|
||||
if command_exists doas; then
|
||||
superuser() {
|
||||
doas "$@"
|
||||
}
|
||||
elif command_exists sudo; then
|
||||
superuser() {
|
||||
sudo "$@"
|
||||
}
|
||||
else
|
||||
error 'Neither "doas" nor "sudo" found were found. Please run the script as root.'
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
superuser() {
|
||||
"$@"
|
||||
}
|
||||
fi
|
||||
|
||||
system_all_installed=1
|
||||
system_packages=""
|
||||
|
||||
system_package_add() {
|
||||
package="$1"
|
||||
|
||||
system_package_check "$package" && return 0
|
||||
|
||||
system_all_installed=0
|
||||
|
||||
system_packages="$system_packages $package"
|
||||
}
|
||||
|
||||
system_packages_go() {
|
||||
if [ "$system_all_installed" -eq "1" ]; then
|
||||
indented message "All system packages are already installed."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! system_package_install_many $system_packages; then
|
||||
error "Failed to install the system packages."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
haxe_all_installed=1
|
||||
haxe_packages=""
|
||||
haxelib_list_cache=""
|
||||
|
||||
haxelib() {
|
||||
if [ "$1" = "list" ]; then
|
||||
if [ -z "$haxelib_list_cache" ]; then
|
||||
haxelib_list_cache="$(command haxelib list)" || exit 1
|
||||
fi
|
||||
|
||||
message "$haxelib_list_cache"
|
||||
return 0
|
||||
fi
|
||||
|
||||
yes | command haxelib "$@" > /dev/null
|
||||
}
|
||||
|
||||
haxe_package_check() {
|
||||
haxelib list | grep -q "^${1}:"
|
||||
}
|
||||
|
||||
haxe_package_add() {
|
||||
package="$1"
|
||||
|
||||
haxe_package_check "$package" && return 0
|
||||
|
||||
haxe_all_installed=0
|
||||
|
||||
haxe_packages="$(printf '%s\n%s' "$haxe_packages" "$*")"
|
||||
}
|
||||
|
||||
haxe_packages_go() {
|
||||
if [ "$haxe_all_installed" -eq "1" ] || [ -z "$haxe_packages" ]; then
|
||||
indented message "All Haxe packages are already installed."
|
||||
return 0
|
||||
fi
|
||||
|
||||
message "$haxe_packages" \
|
||||
| while IFS=" " read -r package type url_or_version git_hash; do
|
||||
[ -z "$package" ] && continue
|
||||
|
||||
indented printf '%s: ' "$package"
|
||||
|
||||
case "$type" in
|
||||
release)
|
||||
cmd="install"
|
||||
|
||||
if [ -n "$url_or_version" ]; then
|
||||
haxelib "$cmd" "$package" "$url_or_version"
|
||||
else
|
||||
haxelib "$cmd" "$package"
|
||||
fi
|
||||
;;
|
||||
git)
|
||||
cmd="git"
|
||||
url="https://${url_or_version}"
|
||||
|
||||
if [ -n "$git_hash" ]; then
|
||||
haxelib "$cmd" "$package" "$url" "$git_hash"
|
||||
else
|
||||
haxelib "$cmd" "$package" "$url"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
error "Unknown type of package installation"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$?" -ne "0" ]; then
|
||||
error "An error occurred during installation of Haxe \
|
||||
package" "$package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
message "$(tput setaf 2)OK$(tput sgr0)"
|
||||
done || exit "$?"
|
||||
}
|
||||
|
||||
safe_break_in() {
|
||||
stty_ctrl_c_sends_quit
|
||||
"$@"
|
||||
restore_stty
|
||||
}
|
||||
|
||||
# Main
|
||||
cat <<EOF
|
||||
$(tput setaf 7)setup/unix.sh revision ${current_revision}$(tput sgr0)
|
||||
Refactored by Intel A80486DX2-66
|
||||
Licensed under Apache License 2.0
|
||||
|
||||
EOF
|
||||
|
||||
require_command haxelib "Haxe"
|
||||
|
||||
if command_exists dpkg; then
|
||||
system_package_manager="dpkg"
|
||||
|
||||
require_command apt-get
|
||||
|
||||
system_package_check() {
|
||||
dpkg -s "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
system_package_install_many() {
|
||||
superuser apt-get install "$@"
|
||||
}
|
||||
elif command_exists pacman; then
|
||||
system_package_manager="pacman"
|
||||
|
||||
system_package_check() {
|
||||
pacman -Qi "$1" > /dev/null
|
||||
}
|
||||
|
||||
system_package_install_many() {
|
||||
superuser pacman -S "$@"
|
||||
}
|
||||
elif command_exists emerge; then
|
||||
system_package_manager="portage"
|
||||
|
||||
require_command qlist
|
||||
|
||||
system_package_check() {
|
||||
qlist -I "$1"
|
||||
}
|
||||
|
||||
system_package_install_many() {
|
||||
superuser emerge -av "$@"
|
||||
}
|
||||
else
|
||||
system_package_manager="unknown"
|
||||
fi
|
||||
|
||||
if [ "$system_package_manager" = "unknown" ]; then
|
||||
message "Please manually check if these packages are installed:"
|
||||
|
||||
while IFS="" read -r package; do
|
||||
printf '* %s\n' "$package"
|
||||
done < "${pkg_list_dir}/system/english.txt"
|
||||
|
||||
warning() {
|
||||
message
|
||||
message "Please install those packages before proceeding."
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
printf -- 'Press Enter to continue (yes) or Ctrl+C to cancel (no): '
|
||||
trap 'warning' QUIT INT
|
||||
read -r _
|
||||
else
|
||||
message "$(tput smul)NOTE$(tput rmul): This might take a few minutes \
|
||||
depending on your internet speed."
|
||||
message
|
||||
|
||||
message "Installing system packages:"
|
||||
while IFS="" read -r package; do
|
||||
system_package_add "$package"
|
||||
done < "${pkg_list_dir}/system/${system_package_manager}.txt"
|
||||
safe_break_in system_packages_go
|
||||
fi
|
||||
|
||||
message "Installing Haxe packages:"
|
||||
while IFS=" " read -r package rest; do
|
||||
haxe_package_add "$package" "$rest"
|
||||
done < "${pkg_list_dir}/haxelib.txt"
|
||||
safe_break_in haxe_packages_go
|
||||
|
||||
if [ "$((system_all_installed + haxe_all_installed))" -lt "2" ]; then
|
||||
message
|
||||
message "$(tput setaf 2)All done!$(tput sgr0)"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user