]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/rsync-updater/update-to-autobuild.sh
Update rsync scripts and README
[xonotic/xonotic.git] / misc / tools / rsync-updater / update-to-autobuild.sh
1 #!/bin/sh
2
3 cd "${0%/*}" || exit 1
4
5 if ! which rsync > /dev/null; then
6         echo >&2 "FATAL: rsync not found, please install the rsync package"
7         exit 1
8 fi
9
10 if [ "$1" = "-y" ] || [ "$1" = "--yes" ]; then
11         choice=y
12 fi
13 until [ "$choice" = y ] || [ "$choice" = Y ]; do
14         printf "This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]? "
15         read -r choice
16         [ "$choice" = n ] || [ "$choice" = N ] && exit 1
17 done
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 "../../../.git" ]; then
31         echo >&2 "NOTE: this is a git repository download. Using the regular update method."
32         exec ../../../all update
33 elif [ -e "Xonotic" ]; then
34         echo "found manually created 'Xonotic' file"
35         echo "targetting the normal $buildtype version"
36         url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
37         target="../../.."
38         options="$options -y" # use fuzzy matching because file names may differ
39 elif [ -e "Xonotic-high" ]; then
40         echo "found manually created 'Xonotic-high' file"
41         echo "targetting the high $buildtype version"
42         url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
43         target="../../.."
44         options="$options -y" # use fuzzy matching because file names may differ
45 elif [ -d "../../../data" ]; then
46         if [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then
47                 echo "found rsync high data files"
48                 echo "targetting the high $buildtype version"
49                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
50         elif [ -f ../../../data/xonotic-*-data-high.pk3 ]; then
51                 echo "found release high data files"
52                 echo "targetting the high $buildtype version"
53                 url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/"
54                 options="$options -y" # use fuzzy matching because file names differ
55         elif [ -f ../../../data/xonotic-rsync-data.pk3 ]; then
56                 echo "found Xonotic rsync data files"
57                 echo "targetting the normal $buildtype version"
58                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
59         elif [ -f ../../../data/xonotic-*-data.pk3 ]; then
60                 echo "found Xonotic release data files"
61                 echo "targetting the normal $buildtype version"
62                 url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
63                 options="$options -y" # use fuzzy matching because file names differ
64         else
65                 echo >&2 "FATAL: unrecognized Xonotic build. This update script cannot be used."
66                 exit 1
67         fi
68         target="../../.."
69 else
70         url="rsync://beta.xonotic.org/$buildtype-Xonotic/"
71         target="Xonotic/"
72 fi
73
74 excludes=
75 if [ -z "$XONOTIC_INCLUDE_ALL" ]; then
76         excludes="$excludes --exclude=/*.exe"
77         excludes="$excludes --exclude=/bin32"
78         excludes="$excludes --exclude=/*.dll"
79         excludes="$excludes --exclude=/bin64"
80
81         case $(uname):$(uname -m) in
82                 Darwin:*)
83                         excludes="$excludes --exclude=/xonotic-linux*"
84                         ;;
85                 Linux:x86_64)
86                         excludes="$excludes --exclude=/Xonotic*.app"
87                         excludes="$excludes --exclude=/xonotic-osx-*"
88                         ;;
89                 *)
90                         printf >&2 "\e[1;31m"
91                         printf >&2 "WARNING: Could not detect architecture\n"
92                         printf >&2 "WARNING: Xonotic does NOT provide pre-built %s executables\n" "$(uname):$(uname -m)"
93                         printf >&2 "WARNING: Please run make. More info is available at\n"
94                         printf >&2 "WARNING: \e[1;36mhttps://gitlab.com/xonotic/xonotic/-/wikis/Compiling\e[m\n"
95                         excludes="$excludes --exclude=/Xonotic*.app"
96                         excludes="$excludes --exclude=/xonotic-osx-*"
97                         excludes="$excludes --exclude=/xonotic-linux64-*"
98                         ;;
99         esac
100 fi
101
102 rsync $options $excludes "$url" "$target"