diff options
author | Mickaël Thomas | 2017-12-14 11:13:13 +0100 |
---|---|---|
committer | Mickaël Thomas | 2017-12-14 11:13:13 +0100 |
commit | 74bb1771f35b42cce9376d3ca1c7c664a1a10f50 (patch) | |
tree | 4ff20720fa440beba867911c5ec31e7ad262c52a | |
parent | 09ee62cf75310517d3afddff274597724f4951e6 (diff) | |
download | aur-74bb1771f35b42cce9376d3ca1c7c664a1a10f50.tar.gz |
Update to 0.16.1
-rw-r--r-- | .SRCINFO | 6 | ||||
-rw-r--r-- | PKGBUILD | 199 |
2 files changed, 120 insertions, 85 deletions
@@ -1,6 +1,6 @@ pkgbase = factorio-experimental - pkgdesc = A 2D game about building and maintaining factories (experimental branch) - pkgver = 0.15.40 + pkgdesc = A 2D game about building and maintaining factories (experimental branch). + pkgver = 0.16.1 pkgrel = 1 url = http://www.factorio.com/ arch = x86_64 @@ -11,7 +11,7 @@ pkgbase = factorio-experimental depends = libxrandr depends = libxinerama depends = mesa - provides = factorio=0.15.40 + provides = factorio=0.16.1 conflicts = factorio conflicts = factorio-demo options = !strip @@ -1,10 +1,11 @@ # Maintainer: D. Can Celasun <dcelasun[at]gmail[dot]com> # Contributor: Sebastien Duthil <duthils@free.fr> +# Contributor: mickael9 <mickael9@gmail.com> pkgname=factorio-experimental -pkgver=0.15.40 +pkgver=0.16.1 pkgrel=1 -pkgdesc="A 2D game about building and maintaining factories (experimental branch)" +pkgdesc="A 2D game about building and maintaining factories (experimental branch)." arch=('x86_64') url="http://www.factorio.com/" license=('custom: commercial') @@ -21,35 +22,26 @@ _gamepkg=factorio_alpha_x64_${pkgver}.tar.xz build() { msg "You need a full copy of this game in order to install it" - local pkgpaths_tries=() - [[ $SRCDEST != $startdir ]] && pkgpaths_tries+=("$SRCDEST") - pkgpaths_tries+=("$startdir" "$HOME" "${XDG_DOWNLOAD_DIR:-$HOME/Downloads}") + while true; do + _find_pkgpath_from_dir + [[ -f "${pkgpath}/${_gamepkg}" ]] && break - for pkgpath_try in "${pkgpaths_tries[@]}"; do - [[ -z "$pkgpath_try" ]] && continue + # could not find the path automatically, ask the user + _find_pkgpath_from_input + [[ -f "${pkgpath}/${_gamepkg}" ]] && break - msg "Searching for ${_gamepkg} in \"${pkgpath_try}\"" - if [[ -f "${pkgpath_try}/${_gamepkg}" ]]; then - pkgpath="${pkgpath_try}" - break - fi - done + # if user entered nothing, try to download + _find_pkgpath_from_download + [[ -f "${pkgpath}/${_gamepkg}" ]] && break - while [[ ! -f "${pkgpath}/${_gamepkg}" ]]; do - error "Game package not found." - if [[ -n $FACTORIO_LOGIN && -n $FACTORIO_PASSWORD ]]; then - msg "Using Factorio credentials from environ: username is $FACTORIO_LOGIN" - _download && pkgpath="$SRCDEST" || true - break - else - read -rp "Please provide the path to the directory containing ${_gamepkg} or leave blank to download the game using your Factorio credentials:" pkgpath - fi + error "Unable to find game package." + [[ ! -t 0 ]] && return 1 - if [[ -z "$pkgpath" ]]; then - _download && pkgpath="$SRCDEST" || true - fi + read -n1 -p "Try again? (Y/n) " try_again ; echo + [[ "${try_again,,*}" == "n" ]] && return 1 done + # unpack game tarball msg "Found game package, unpacking..." tar xf "${pkgpath}/${_gamepkg}" -C "${srcdir}" } @@ -59,90 +51,133 @@ build() { # - config in ~/.factorio package() { - cd "$srcdir/factorio" + cd "${srcdir}/factorio" install -d "${pkgdir}/usr/bin" install -d "${pkgdir}/usr/share/applications" install -d "${pkgdir}/usr/share/factorio" install -d "${pkgdir}/usr/share/licenses/factorio" - install -d -m777 "${pkgdir}/usr/share/factorio/scenario-pack" - install -m755 "bin/x64/factorio" "$pkgdir/usr/bin/factorio" - cp -r data/* "$pkgdir/usr/share/factorio" + install -m755 "bin/x64/factorio" "${pkgdir}/usr/bin/factorio" + cp -r data/* "${pkgdir}/usr/share/factorio" install -m644 "${srcdir}/factorio.desktop" "${pkgdir}/usr/share/applications/factorio.desktop" install -m644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/factorio/LICENSE" } -_download() { +_find_pkgpath_from_dir() { + local pkgpaths_tries=() + [[ $SRCDEST != $startdir ]] && pkgpaths_tries+=("$SRCDEST") + pkgpaths_tries+=("$startdir" "$HOME" "${XDG_DOWNLOAD_DIR:-$HOME/Downloads}") + + msg "Searching for ${_gamepkg} in:" + + for pkgpath_try in "${pkgpaths_tries[@]}"; do + msg2 "$pkgpath_try" + if [[ -f "${pkgpath_try}/${_gamepkg}" ]]; then + pkgpath=${pkgpath_try} + break + fi + done + + if [[ -z $pkgpath ]]; then + warning "Game package not found" + else + msg "Game package found" + fi +} + +_find_pkgpath_from_input() { + # don't interact if standard input isn't a terminal + # or if we should download the game using FACTORIO_LOGIN and FACTORIO_PASSWORD + + [[ ! -t 0 || -n "$FACTORIO_LOGIN" ]] && return + + while [[ ! -f "${pkgpath}/${_gamepkg}" ]]; do + read -rp "Please provide the path to the directory containing ${_gamepkg} or leave blank to download it using your Factorio credentials: " pkgpath + [[ -z $pkgpath ]] && break + + # also accept a full path to the file if it has the good name + if [[ -f $pkgpath && ${pkgpath##*/} = ${_gamepkg} ]]; then + pkgpath=${pkgpath%/*} + fi + + if [[ ! -f "${pkgpath}/${_gamepkg}" ]]; then + error "${_gamepkg} not found in ${pkgpath}" + fi + done +} + +_find_pkgpath_from_download() { + msg "Downloading game using Factorio credentials" + local cookie=$(mktemp) - local ret=1 - while true; do + while [[ -z "${pkgpath}" ]] ; do local login="$FACTORIO_LOGIN" local password="$FACTORIO_PASSWORD" local file="${SRCDEST}/${_gamepkg}" if [[ -z $login || -z $password ]]; then + [[ ! -t 0 ]] && return read -rp "Username or email: " login - [[ -n $login ]] && read -rsp "Password: " password ; echo + [[ -z "${login}" ]] && break + read -rsp "Password: " password ; echo + [[ -z "${password}" ]] && break fi - if [[ -n $login && -n $password ]]; then - msg "Logging in..." - local csrf_token=$( - curl --silent --fail \ - --cookie-jar "$cookie" \ - https://www.factorio.com/login \ - | grep -Po '(?<=name="csrf_token" type="hidden" value=")[^"]+' - ) - - if [[ -z "$csrf_token" ]]; then - error "Could not find the CSRF token. This script might be broken." - break - fi + msg2 "Logging in..." + local csrf_token=$( + curl --silent --fail \ + --cookie-jar "$cookie" \ + https://www.factorio.com/login \ + | grep -Po '(?<=name="csrf_token" type="hidden" value=")[^"]+' + ) + + if [[ -z "$csrf_token" ]]; then + error "Could not find the CSRF token. This script might be broken." + break + fi - local output=$( - curl --dump-header - \ - --silent --fail \ - --cookie-jar "$cookie" \ - --cookie "$cookie" \ - https://www.factorio.com/login \ - --data-urlencode username_or_email="$login" \ - --data-urlencode password="$password" \ - --data-urlencode csrf_token="$csrf_token" \ - ) - - if echo "$output" | grep -q '^Location: '; then - msg2 "Logged in" - msg "Downloading ${_gamepkg} from $_url ..." - - curl --retry 10 --retry-delay 3 \ - --fail --location \ - --cookie "$cookie" \ - --continue-at - \ - --output "${file}.part" \ - "$_url" \ - || rm -f "${file}.part" - - if [[ -f "${file}.part" ]]; then - ret=0 - msg2 "Download successful" - mv "${file}"{.part,} - else - error "Download failed" - fi + local output=$( + curl --dump-header - \ + --silent --fail \ + --cookie-jar "$cookie" \ + --cookie "$cookie" \ + https://www.factorio.com/login \ + --data-urlencode username_or_email="$login" \ + --data-urlencode password="$password" \ + --data-urlencode csrf_token="$csrf_token" \ + ) + + if ! echo "$output" | grep -q '^Location: '; then + error "Login failed" + read -n1 -p "Retry login? (Y/n) " try_again ; echo + if [[ "${try_again,,*}" == "n" ]]; then break else - error "Login failed" - #echo "$output" - read -rp "Try again? (Y/n)" - [[ $REPLY == n ]] && break + continue fi - else + fi + + msg2 "Downloading ${_gamepkg} from ${_url} ..." + + curl --retry 10 --retry-delay 3 \ + --fail --location \ + --cookie "${cookie}" \ + --continue-at - \ + --output "${file}.part" \ + "${_url}" \ + || rm -f "${file}.part" + + if [[ ! -f "${file}.part" ]]; then + error "Download failed" break fi + + msg2 "Download successful" + mv "${file}"{.part,} + pkgpath="${SRCDEST}" done rm $cookie - return $ret } |