]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/rsync-updater/update-xonotic.sh
rsync updater: add support for running from inside the xonotic directory
[xonotic/xonotic.git] / misc / tools / rsync-updater / update-xonotic.sh
1 #!/bin/sh
2
3 if ! which rsync >/dev/null; then
4         echo >&2 "FATAL: rsync not found, please install the rsync package"
5         exit 1
6 fi
7
8 options="-Prtzil --executability --delete-after --delete-excluded --stats"
9
10 if [ -d "Xonotic-low" ]; then
11         url="rsync://beta.xonotic.org/autobuild-Xonotic-low/"
12         target="Xonotic-low/"
13 elif [ -d "Xonotic-high" ]; then
14         url="rsync://beta.xonotic.org/autobuild-Xonotic-high/"
15         target="Xonotic-high/"
16 elif [ -d "../../../data/.git" ]; then
17         echo >&2 "NOTE: this is a git repository download. Using the regular update method."
18         exec ../../../all update
19 elif [ -d "../../../data" ]; then
20         if [ -f ../../../data/xonotic-rsync-data-low.pk3 ]; then
21                 url="rsync://beta.xonotic.org/autobuild-Xonotic-low/"
22         elif [ -f ../../../data/xonotic-*-data-low.pk3 ]; then
23                 url="rsync://beta.xonotic.org/autobuild-Xonotic-low/"
24                 options="$options -y" # use fuzzy matching because file names differ
25         elif [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then
26                 url="rsync://beta.xonotic.org/autobuild-Xonotic-high/"
27         elif [ -f ../../../data/xonotic-*-data-high.pk3 ]; then
28                 url="rsync://beta.xonotic.org/autobuild-Xonotic-high/"
29                 options="$options -y" # use fuzzy matching because file names differ
30         elif [ -f ../../../data/xonotic-rsync-data.pk3 ]; then
31                 url="rsync://beta.xonotic.org/autobuild-Xonotic/"
32         elif [ -f ../../../data/xonotic-*-data.pk3 ]; then
33                 url="rsync://beta.xonotic.org/autobuild-Xonotic/"
34                 options="$options -y" # use fuzzy matching because file names differ
35         else
36                 echo >&2 "FATAL: unrecognized Xonotic build. This update script cannot be used."
37                 exit 1
38         fi
39         target="../../.."
40 else
41         url="rsync://beta.xonotic.org/autobuild-Xonotic/"
42         target="Xonotic/"
43 fi
44
45 excludes=
46 excludes="$excludes --exclude=/*.exe"
47 excludes="$excludes --exclude=/fteqcc/*.exe"
48 excludes="$excludes --exclude=/bin32"
49 excludes="$excludes --exclude=/*.dll"
50 excludes="$excludes --exclude=/bin64"
51
52 case `uname`:`uname -m` in
53         Darwin:*)
54                 excludes="$excludes --exclude=/xonotic-linux*"
55                 excludes="$excludes --exclude=/fteqcc/fteqcc.linux*"
56                 ;;
57         Linux:x86_64)
58                 excludes="$excludes --exclude=/Xonotic*.app"
59                 excludes="$excludes --exclude=/xonotic-osx-*"
60                 excludes="$excludes --exclude=/fteqcc/fteqcc.osx"
61                 excludes="$excludes --exclude=/xonotic-linux32-*"
62                 excludes="$excludes --exclude=/fteqcc/fteqcc.linux32"
63                 ;;
64         Linux:i?86)
65                 excludes="$excludes --exclude=/Xonotic*.app"
66                 excludes="$excludes --exclude=/xonotic-osx-*"
67                 excludes="$excludes --exclude=/fteqcc/fteqcc.osx"
68                 excludes="$excludes --exclude=/xonotic-linux64-*"
69                 excludes="$excludes --exclude=/fteqcc/fteqcc.linux64"
70                 ;;
71         *)
72                 echo >&2 "WARNING: Could not detect architecture - downloading all architectures"
73                 ;;
74 esac
75
76 rsync $options $excludes "$url" "$target"