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