]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/rsync-updater/update-to-release.sh
update-to-autobuild.sh: add "-y" argument to skip confirmation prompt
[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 [ "$1" = "-y" ] && choice=y
13 until [ "$choice" = y ] || [ "$choice" = Y ]; do
14         read -rp "This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]? " choice
15         [ "$choice" = n ] || [ "$choice" = N ] && exit 1
16 done
17
18 case "${0##*/}" in
19         update-to-autobuild.sh)
20                 buildtype=autobuild
21                 ;;
22         *)
23                 buildtype=release
24                 ;;
25 esac
26
27 options="-Prtzil --executability --delete-after --delete-excluded --stats"
28
29 if [ -d "Xonotic-low" ]; then
30         echo NOTE: Xonotic-low is gone, downloading normal Xonotic.
31         url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
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                 echo NOTE: Xonotic-low is gone, downloading normal Xonotic.
42                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
43         elif [ -f ../../../data/xonotic-*-data-low.pk3 ]; then
44                 echo NOTE: Xonotic-low is gone, downloading normal Xonotic.
45                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
46                 options="$options -y" # use fuzzy matching because file names differ
47         elif [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then
48                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
49         elif [ -f ../../../data/xonotic-*-data-high.pk3 ]; then
50                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
51                 options="$options -y" # use fuzzy matching because file names differ
52         elif [ -f ../../../data/xonotic-rsync-data.pk3 ]; then
53                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
54         elif [ -f ../../../data/xonotic-*-data.pk3 ]; then
55                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
56                 options="$options -y" # use fuzzy matching because file names differ
57         else
58                 echo >&2 "FATAL: unrecognized Xonotic build. This update script cannot be used."
59                 exit 1
60         fi
61         target="../../.."
62 else
63         url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
64         target="Xonotic/"
65 fi
66
67 excludes=
68 if [ -z "$XONOTIC_INCLUDE_ALL" ]; then
69         excludes="$excludes --exclude=/*.exe"
70         excludes="$excludes --exclude=/gmqcc/*.exe"
71         excludes="$excludes --exclude=/bin32"
72         excludes="$excludes --exclude=/*.dll"
73         excludes="$excludes --exclude=/bin64"
74
75         case `uname`:`uname -m` in
76                 Darwin:*)
77                         excludes="$excludes --exclude=/xonotic-linux*"
78                         excludes="$excludes --exclude=/gmqcc/gmqcc.linux*"
79                         ;;
80                 Linux:x86_64)
81                         excludes="$excludes --exclude=/Xonotic*.app"
82                         excludes="$excludes --exclude=/xonotic-osx-*"
83                         excludes="$excludes --exclude=/gmqcc/gmqcc.osx"
84                         excludes="$excludes --exclude=/xonotic-linux32-*"
85                         excludes="$excludes --exclude=/gmqcc/gmqcc.linux32"
86                         ;;
87                 *)
88                         echo >&2 "WARNING: Could not detect architecture - downloading all architectures"
89                         ;;
90         esac
91 fi
92
93 rsync $options $excludes "$url" "$target"