haini.sh/haini.sh

54 lines
1.5 KiB
Bash
Raw Normal View History

2021-04-24 14:48:13 +00:00
#!/bin/sh
# Fallar ante cualquier error
set -e
# Por ahora sólo soportamos x86_64
uname -m | grep -q x86_64 || exit 1
# Sutty tiene que estar clonada en el directorio anterior
test -d ../sutty/.git || git clone git@0xacab.org:sutty/sutty.git ../sutty
# La versión de Alpine es el segundo argumento
ALPINE="${2:-3.13.5}"
ALPINE_URL="https://dl-cdn.alpinelinux.org/alpine/v${ALPINE%.*}/releases/x86_64/alpine-minirootfs-${ALPINE}-x86_64.tar.gz"
# Definir si vamos a usar wget o curl
type wget >/dev/null && download="wget -O -"
type curl >/dev/null && download="curl"
# Si no hay ninguno de los dos, salir
test -z "${download}" && exit 1
# Necesitamos proot
type proot >/dev/null || exit 1
# Necesario para algunas distribuciones
export PROOT_NO_SECCOMP=1
# El entorno de trabajo es desarrollo
export RAILS_ENV=development
# Darle permiso de lectura a otres también
umask 022
# Crear el directorio de trabajo
mkdir ../hain && cd ../hain
# Descargar y extraer Alpine
${download} "${ALPINE_URL}" | tar xvzf -
# Directorio de instalación de las gemas
install -dm 755 -o ${USER} -g $(id -g ${USER}) opt/sutty
# Instalar las dependencias
proot -S . /sbin/apk add --no-cache \
libxslt libxml2 libssh2 postgresql-libs sqlite-libs \
tzdata bash ffmpeg vips file git make \
ruby ruby-bundler ruby-json ruby-bigdecimal ruby-irb ruby-rake
# Habilitar la instalación de gemas binarias
sed -re "s/#(@platforms = )/\1/" -i usr/lib/ruby/2.7.0/rubygems.rb
# Instalar las gemas como root
proot -R . -w ../sutty /usr/bin/bundle install --path /opt/sutty