]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/rsync-updater/update-to-release.sh
bd1c6fc9da818661169dd15cc49e7929146a337d
[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         echo NOTE: Xonotic-low is gone, downloading normal Xonotic.
32         url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
33         target="Xonotic-low/"
34 elif [ -d "Xonotic-high" ]; then
35         url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
36         target="Xonotic-high/"
37 elif [ -d "../../../.git" ]; then
38         echo >&2 "NOTE: this is a git repository download. Using the regular update method."
39         exec ../../../all update
40 elif [ -d "../../../data" ]; then
41         if [ -f ../../../data/xonotic-rsync-data-low.pk3 ]; then
42                 echo NOTE: Xonotic-low is gone, downloading normal Xonotic.
43                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
44         elif [ -f ../../../data/xonotic-*-data-low.pk3 ]; then
45                 echo NOTE: Xonotic-low is gone, downloading normal Xonotic.
46                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
47                 options="$options -y" # use fuzzy matching because file names differ
48         elif [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then
49                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
50         elif [ -f ../../../data/xonotic-*-data-high.pk3 ]; then
51                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
52                 options="$options -y" # use fuzzy matching because file names differ
53         elif [ -f ../../../data/xonotic-rsync-data.pk3 ]; then
54                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
55         elif [ -f ../../../data/xonotic-*-data.pk3 ]; then
56                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
57                 options="$options -y" # use fuzzy matching because file names differ
58         else
59                 echo >&2 "FATAL: unrecognized Xonotic build. This update script cannot be used."
60                 exit 1
61         fi
62         target="../../.."
63 else
64         url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
65         target="Xonotic/"
66 fi
67
68 excludes=
69 if [ -z "$XONOTIC_INCLUDE_ALL" ]; then
70         excludes="$excludes --exclude=/*.exe"
71         excludes="$excludes --exclude=/gmqcc/*.exe"
72         excludes="$excludes --exclude=/bin32"
73         excludes="$excludes --exclude=/*.dll"
74         excludes="$excludes --exclude=/bin64"
75
76         case `uname`:`uname -m` in
77                 Darwin:*)
78                         excludes="$excludes --exclude=/xonotic-linux*"
79                         excludes="$excludes --exclude=/gmqcc/gmqcc.linux*"
80                         ;;
81                 Linux:x86_64)
82                         excludes="$excludes --exclude=/Xonotic*.app"
83                         excludes="$excludes --exclude=/xonotic-osx-*"
84                         excludes="$excludes --exclude=/gmqcc/gmqcc.osx"
85                         excludes="$excludes --exclude=/xonotic-linux32-*"
86                         excludes="$excludes --exclude=/gmqcc/gmqcc.linux32"
87                         ;;
88                 *)
89                         echo >&2 "WARNING: Could not detect architecture - downloading all architectures"
90                         ;;
91         esac
92 fi
93
94 rsync $options $excludes "$url" "$target"