]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/rsync-updater/update-to-autobuild.sh
Add yes/no dialogs to the update scripts, fixes #148
[xonotic/xonotic.git] / misc / tools / rsync-updater / update-to-autobuild.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 echo >&2 "This script will DELETE any custom files in the Xonotic folder. Press ENTER to continue, or Ctrl-C to abort."
13 read -r DUMMY
14
15 case "${0##*/}" in
16         update-to-autobuild.sh)
17                 buildtype=autobuild
18                 ;;
19         *)
20                 buildtype=release
21                 ;;
22 esac
23
24 options="-Prtzil --executability --delete-after --delete-excluded --stats"
25
26 if [ -d "Xonotic-low" ]; then
27         url="rsync://beta.xonotic.org/$buildtype-Xonotic-low/"
28         target="Xonotic-low/"
29 elif [ -d "Xonotic-high" ]; then
30         url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
31         target="Xonotic-high/"
32 elif [ -d "../../../.git" ]; then
33         echo >&2 "NOTE: this is a git repository download. Using the regular update method."
34         exec ../../../all update
35 elif [ -d "../../../data" ]; then
36         if [ -f ../../../data/xonotic-rsync-data-low.pk3 ]; then
37                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-low/"
38         elif [ -f ../../../data/xonotic-*-data-low.pk3 ]; then
39                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-low/"
40                 options="$options -y" # use fuzzy matching because file names differ
41         elif [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then
42                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
43         elif [ -f ../../../data/xonotic-*-data-high.pk3 ]; then
44                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
45                 options="$options -y" # use fuzzy matching because file names differ
46         elif [ -f ../../../data/xonotic-rsync-data.pk3 ]; then
47                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
48         elif [ -f ../../../data/xonotic-*-data.pk3 ]; then
49                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
50                 options="$options -y" # use fuzzy matching because file names differ
51         else
52                 echo >&2 "FATAL: unrecognized Xonotic build. This update script cannot be used."
53                 exit 1
54         fi
55         target="../../.."
56 else
57         url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
58         target="Xonotic/"
59 fi
60
61 excludes=
62 if [ -z "$XONOTIC_INCLUDE_ALL" ]; then
63         excludes="$excludes --exclude=/*.exe"
64         excludes="$excludes --exclude=/gmqcc/*.exe"
65         excludes="$excludes --exclude=/bin32"
66         excludes="$excludes --exclude=/*.dll"
67         excludes="$excludes --exclude=/bin64"
68
69         case `uname`:`uname -m` in
70                 Darwin:*)
71                         excludes="$excludes --exclude=/xonotic-linux*"
72                         excludes="$excludes --exclude=/gmqcc/gmqcc.linux*"
73                         ;;
74                 Linux:x86_64)
75                         excludes="$excludes --exclude=/Xonotic*.app"
76                         excludes="$excludes --exclude=/xonotic-osx-*"
77                         excludes="$excludes --exclude=/gmqcc/gmqcc.osx"
78                         excludes="$excludes --exclude=/xonotic-linux32-*"
79                         excludes="$excludes --exclude=/gmqcc/gmqcc.linux32"
80                         ;;
81                 *)
82                         echo >&2 "WARNING: Could not detect architecture - downloading all architectures"
83                         ;;
84         esac
85 fi
86
87 rsync $options $excludes "$url" "$target"