]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/rsync-updater/update-to-release.sh
Require inputting Y to confirm in the Linux script as well, courtesy of Cloudwalk
[xonotic/xonotic.git] / misc / tools / rsync-updater / update-to-release.sh
1 #!/bin/sh
2
3 if [ -d "${0%/*}" ]; then
4         cd "${0%/*}"
5 fi
6
7 if ! which rsync >/dev/null; then
8         echo >&2 "FATAL: rsync not found, please install the rsync package"
9         exit 1
10 fi
11
12 read -rp "This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]?" choice
13 case "$choice" in
14   Y) ;;
15   y) ;;
16   *) exit 1 ;;
17 esac
18
19 case "${0##*/}" in
20         update-to-autobuild.sh)
21                 buildtype=autobuild
22                 ;;
23         *)
24                 buildtype=release
25                 ;;
26 esac
27
28 options="-Prtzil --executability --delete-after --delete-excluded --stats"
29
30 if [ -d "Xonotic-low" ]; then
31         url="rsync://beta.xonotic.org/$buildtype-Xonotic-low/"
32         target="Xonotic-low/"
33 elif [ -d "Xonotic-high" ]; then
34         url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
35         target="Xonotic-high/"
36 elif [ -d "../../../.git" ]; then
37         echo >&2 "NOTE: this is a git repository download. Using the regular update method."
38         exec ../../../all update
39 elif [ -d "../../../data" ]; then
40         if [ -f ../../../data/xonotic-rsync-data-low.pk3 ]; then
41                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-low/"
42         elif [ -f ../../../data/xonotic-*-data-low.pk3 ]; then
43                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-low/"
44                 options="$options -y" # use fuzzy matching because file names differ
45         elif [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then
46                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
47         elif [ -f ../../../data/xonotic-*-data-high.pk3 ]; then
48                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
49                 options="$options -y" # use fuzzy matching because file names differ
50         elif [ -f ../../../data/xonotic-rsync-data.pk3 ]; then
51                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
52         elif [ -f ../../../data/xonotic-*-data.pk3 ]; then
53                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
54                 options="$options -y" # use fuzzy matching because file names differ
55         else
56                 echo >&2 "FATAL: unrecognized Xonotic build. This update script cannot be used."
57                 exit 1
58         fi
59         target="../../.."
60 else
61         url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
62         target="Xonotic/"
63 fi
64
65 excludes=
66 if [ -z "$XONOTIC_INCLUDE_ALL" ]; then
67         excludes="$excludes --exclude=/*.exe"
68         excludes="$excludes --exclude=/gmqcc/*.exe"
69         excludes="$excludes --exclude=/bin32"
70         excludes="$excludes --exclude=/*.dll"
71         excludes="$excludes --exclude=/bin64"
72
73         case `uname`:`uname -m` in
74                 Darwin:*)
75                         excludes="$excludes --exclude=/xonotic-linux*"
76                         excludes="$excludes --exclude=/gmqcc/gmqcc.linux*"
77                         ;;
78                 Linux:x86_64)
79                         excludes="$excludes --exclude=/Xonotic*.app"
80                         excludes="$excludes --exclude=/xonotic-osx-*"
81                         excludes="$excludes --exclude=/gmqcc/gmqcc.osx"
82                         excludes="$excludes --exclude=/xonotic-linux32-*"
83                         excludes="$excludes --exclude=/gmqcc/gmqcc.linux32"
84                         ;;
85                 *)
86                         echo >&2 "WARNING: Could not detect architecture - downloading all architectures"
87                         ;;
88         esac
89 fi
90
91 rsync $options $excludes "$url" "$target"