From 0a43be05d4a42c7c8b64cfa03aa7bbaeebb75b1f Mon Sep 17 00:00:00 2001
From: gammafunk
Date: Tue, 22 Sep 2020 11:47:54 +0000
Subject: [PATCH 01/10] feat: Allow dgl games to always enable wizard mode
In the launchers, don't attempt to add the -wizard command line argument
for dgl admins if -wizard is already present. This allows game
configurations to always specify -wizard without breaking game launching
for admins.
---
chroot/bin/crawl-git-launcher.sh | 2 +-
chroot/bin/crawl-stable-launcher.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/chroot/bin/crawl-git-launcher.sh b/chroot/bin/crawl-git-launcher.sh
index 7bab619c..ffee4bd5 100755
--- a/chroot/bin/crawl-git-launcher.sh
+++ b/chroot/bin/crawl-git-launcher.sh
@@ -287,7 +287,7 @@ fi
BINARY_NAME="$CRAWL_BINARY_PATH/$BINARY_BASE_NAME-$OUR_GAME_HASH"
GAME_FOLDER="$CRAWL_GIT_DIR/$BINARY_BASE_NAME-$OUR_GAME_HASH"
-if user-is-admin; then
+if user-is-admin && [[ $* != *-wizard* ]]; then
set -- "$@" -wizard
fi
diff --git a/chroot/bin/crawl-stable-launcher.sh b/chroot/bin/crawl-stable-launcher.sh
index c9f9525f..fc526fa4 100755
--- a/chroot/bin/crawl-stable-launcher.sh
+++ b/chroot/bin/crawl-stable-launcher.sh
@@ -98,7 +98,7 @@ user-is-admin() {
BINARY_NAME="$CRAWL_BINARY_PATH/$BINARY_BASE_NAME"
GAME_FOLDER="$CRAWL_GIT_DIR/$BINARY_BASE_NAME"
-if user-is-admin; then
+if user-is-admin && [[ $* != *-wizard* ]]; then
set -- "$@" -wizard
fi
From 62772a99d357f757a510df07198af4a5208d7f95 Mon Sep 17 00:00:00 2001
From: gammafunk
Date: Tue, 3 Nov 2020 18:25:23 +0000
Subject: [PATCH 02/10] fix: Don't create Zot Defense directories
Zot Defense has been removed for a long time, and these directories
aren't needed.
---
chroot/sbin/install-stable.sh | 3 +--
chroot/sbin/install-trunk.sh | 4 +---
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/chroot/sbin/install-stable.sh b/chroot/sbin/install-stable.sh
index 1444bbf4..16ce4990 100755
--- a/chroot/sbin/install-stable.sh
+++ b/chroot/sbin/install-stable.sh
@@ -80,7 +80,6 @@ create-dgl-directories() {
# TODO: use long version (0.17) for everything.
mkdir -p "$CHROOT/dgldir/inprogress/crawl-$short_version-sprint/"
mkdir -p "$CHROOT/dgldir/inprogress/crawl-$short_version-tut/"
- mkdir -p "$CHROOT/dgldir/inprogress/crawl-$short_version-zotdef/"
mkdir -p "$CHROOT/dgldir/inprogress/crawl-$short_version/"
mkdir -p "$CHROOT/dgldir/rcfiles/crawl-0.$short_version/"
mkdir -p "$CHROOT/dgldir/data/crawl-0.$short_version-settings/"
@@ -92,7 +91,7 @@ fix-chroot-directory-permissions() {
}
install-game() {
- mkdir -p $SAVEDIR/{,sprint,zotdef}
+ mkdir -p $SAVEDIR/{,sprint}
mkdir -p $DATADIR
create-dgl-directories
diff --git a/chroot/sbin/install-trunk.sh b/chroot/sbin/install-trunk.sh
index d0f606f3..683d1074 100755
--- a/chroot/sbin/install-trunk.sh
+++ b/chroot/sbin/install-trunk.sh
@@ -80,14 +80,12 @@ link-logfiles() {
for file in logfile milestones scores; do
ln -sf $COMMON_DIR/saves/$file $SAVEDIR
ln -sf $COMMON_DIR/saves/$file-sprint $SAVEDIR
- ln -sf $COMMON_DIR/saves/$file-zotdef $SAVEDIR
done
}
create-dgl-directories() {
mkdir -p "$CHROOT/dgldir/inprogress/crawl-git-sprint/"
mkdir -p "$CHROOT/dgldir/inprogress/crawl-git-tut/"
- mkdir -p "$CHROOT/dgldir/inprogress/crawl-git-zotdef/"
mkdir -p "$CHROOT/dgldir/inprogress/crawl-git/"
mkdir -p "$CHROOT/dgldir/rcfiles/crawl-git/"
mkdir -p "$CHROOT/dgldir/data/crawl-git-settings/"
@@ -99,7 +97,7 @@ fix-chroot-directory-permissions() {
}
install-game() {
- mkdir -p $SAVEDIR/{,sprint,zotdef}
+ mkdir -p $SAVEDIR/{,sprint}
mkdir -p $DATADIR
create-dgl-directories
From 27690d87b4cd38bbb5277bba8f84fbf205b648c3 Mon Sep 17 00:00:00 2001
From: gammafunk
Date: Fri, 21 Oct 2022 18:18:44 -0500
Subject: [PATCH 03/10] fix: Remove stale binaries during trunk install
Remove the original copy of the recently built trunk binary from the
build dir. Otherwise these 200MB files simply accrue, filling up disk
space. They aren't needed after installation is finished, since the
binary is copied into the chroot.
---
chroot/sbin/install-trunk.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/chroot/sbin/install-trunk.sh b/chroot/sbin/install-trunk.sh
index 683d1074..5b26df14 100755
--- a/chroot/sbin/install-trunk.sh
+++ b/chroot/sbin/install-trunk.sh
@@ -186,6 +186,9 @@ if [[ -n "${SGV_MAJOR}" && -n "${SGV_MINOR}" ]]; then
echo "Installing game"
install-game
register-game-version
+
+ echo "Cleaning up source dir"
+ rm -f source/$GAME_BINARY
else
echo "Could not figure out version tags. Installation cancelled."
echo "Aborting installation!"
From 7b3e905086224b48df0230a473b938c9964b4a14 Mon Sep 17 00:00:00 2001
From: gammafunk
Date: Fri, 21 Oct 2022 18:24:03 -0500
Subject: [PATCH 04/10] feat: Support force pushes to git branches
Currently we do a `git pull` to update the repository, which of course
doesn't work in the case where the branch has been force pushed. Force
pushes shouldn't happen (hopefully) for stable or trunk, but they're
common for experimental branches. This commit has the repo update do a
`git fetch` followed by a hard reset to the relevant branch. It
additionally updates the stable installer to remove the data directory
with each installation. This way we'll not have stale data files lying
around and potentially loaded by crawl if they get removed from the
repository by a previous commit.
---
chroot/sbin/install-stable.sh | 1 +
crawl-build/update-public-repository.sh | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/chroot/sbin/install-stable.sh b/chroot/sbin/install-stable.sh
index 16ce4990..f93a0703 100755
--- a/chroot/sbin/install-stable.sh
+++ b/chroot/sbin/install-stable.sh
@@ -92,6 +92,7 @@ fix-chroot-directory-permissions() {
install-game() {
mkdir -p $SAVEDIR/{,sprint}
+ rm -rf $DATADIR
mkdir -p $DATADIR
create-dgl-directories
diff --git a/crawl-build/update-public-repository.sh b/crawl-build/update-public-repository.sh
index 7b8f43e3..d9154c28 100755
--- a/crawl-build/update-public-repository.sh
+++ b/crawl-build/update-public-repository.sh
@@ -20,7 +20,8 @@ update-crawl-ref() {
say "Updating git repository $REPO_DIR"
( cd $REPO_DIR && git checkout -f &&
git checkout $BRANCH &&
- git pull )
+ git fetch &&
+ git reset --hard FETCH_HEAD )
if [[ -n "$REVISION" ]]; then
say "Checking out requested revision: $REVISION"
( cd $REPO_DIR && git checkout "$REVISION" )
From c6f6d862555b1b4b13e75e5f66672227860fbeea Mon Sep 17 00:00:00 2001
From: gammafunk
Date: Tue, 31 Aug 2021 00:29:18 +0000
Subject: [PATCH 05/10] feat: Add a wizards group to DGL
This commit adds commands to manage a wizards user group for dgl who
have the ability to use Wizard mode without getting other associated
admin rights. The launchers now add the `-wizard` argument whenever a
user belongs to this group. Admins continue to get this argument as
well.
---
bin/wizard.sh | 95 +++++++++++++++++++++++++++++
chroot/bin/crawl-git-launcher.sh | 9 ++-
chroot/bin/crawl-stable-launcher.sh | 9 ++-
sh-utils | 10 ++-
4 files changed, 120 insertions(+), 3 deletions(-)
create mode 100644 bin/wizard.sh
diff --git a/bin/wizard.sh b/bin/wizard.sh
new file mode 100644
index 00000000..cb0aafcc
--- /dev/null
+++ b/bin/wizard.sh
@@ -0,0 +1,95 @@
+#! /bin/bash
+
+help < Make a wizard
+ $SCRIPT_NAME rm Make a non-wizard user.
+
+EOF
+
+assert-login-db-exists
+
+SUBCOMMAND=$1
+shift
+[[ -z "$SUBCOMMAND" ]] && SUBCOMMAND="ls"
+
+wizard-ls() {
+ echo "Existing wizard users:"
+ login-query <
Date: Tue, 31 Aug 2021 00:31:39 +0000
Subject: [PATCH 06/10] fix: Don't try to publish RC or macro files
The dgl scripts try to publish RC and macro files stored in this repo to
allow servers to have custom defaults. I don't believe any DGL servers
use this functionality, and it results in publishing potentially stale
files. Simply removing the in-repo files will cause errors with the
publishing script, so this commit also removes support for publishing
custom RC and macro files in the script.
The existing dgamealaunch config already uses the RC files installed by
the installer rather than those published by the dgl scripts. For
macros, we tweak the commands for resetting options to simply unlink the
user's macro file instead of copying a default file.
---
bin/publish.pl | 1 -
chroot/data/dgl-default.crawl-0.25.macro | 0
chroot/data/dgl-default.crawl-0.25.rc | 87 ------------------------
dgamelaunch.conf | 14 +---
4 files changed, 2 insertions(+), 100 deletions(-)
delete mode 100644 chroot/data/dgl-default.crawl-0.25.macro
delete mode 100644 chroot/data/dgl-default.crawl-0.25.rc
diff --git a/bin/publish.pl b/bin/publish.pl
index b89979ab..7c5f8162 100644
--- a/bin/publish.pl
+++ b/bin/publish.pl
@@ -31,7 +31,6 @@
[ 'banned_players.yml', "/crawl-master/webserver" ],
[ 'banned_players.txt', "/crawl-master/webserver" ],
[ 'chroot/data/menus/*.txt', "/dgldir/data/menus" ],
- [ 'chroot/data/*.{rc,macro}', "/dgldir/data" ],
[ 'chroot/bin/*.sh', '/bin' ],
[ 'chroot/sbin/*.sh', '/sbin' ]);
diff --git a/chroot/data/dgl-default.crawl-0.25.macro b/chroot/data/dgl-default.crawl-0.25.macro
deleted file mode 100644
index e69de29b..00000000
diff --git a/chroot/data/dgl-default.crawl-0.25.rc b/chroot/data/dgl-default.crawl-0.25.rc
deleted file mode 100644
index 16c52f5c..00000000
--- a/chroot/data/dgl-default.crawl-0.25.rc
+++ /dev/null
@@ -1,87 +0,0 @@
-##### Crawl Init file ###############################################
-# For descriptions of all options, as well as some more in-depth information
-# on setting them, consult the file
-# options_guide.txt
-# in your /docs directory. If you can't find it, the file is also available
-# online at:
-# https://github.com/crawl/crawl/blob/master/crawl-ref/docs/options_guide.txt
-#
-# Crawl uses the first file of the following list as its option file:
-# * init.txt in the -rcdir directory (if specified)
-# * .crawlrc in the -rcdir directory (if specified)
-# * init.txt (in the Crawl directory)
-# * ~/.crawl/init.txt (Unix only)
-# * ~/.crawlrc (Unix only)
-# * ~/init.txt (Unix only)
-# * settings/init.txt (in the Crawl directory)
-
-##### Some basic explanation of option syntax #######################
-# Lines beginning with '#' are comments. The basic syntax is:
-#
-# field = value or field.subfield = value
-#
-# Only one specification is allowed per line.
-#
-# The terms are typically case-insensitive except in the fairly obvious
-# cases (the character's name and specifying files or directories when
-# on a system that has case-sensitive filenames).
-#
-# White space is stripped from the beginning and end of the line, as
-# well as immediately before and after the '='. If the option allows
-# multiple comma/semicolon-separated terms (such as
-# autopickup_exceptions), all whitespace around the separator is also
-# trimmed. All other whitespace is left intact.
-#
-# There are three broad types of Crawl options: true/false values (booleans),
-# arbitrary values, and lists of values. The first two types use only the
-# simple =, with later options - which includes your options that are different
-# from the defaults - overriding earlier ones. List options allow using +=, ^=,
-# -=, and = to append, prepend, remove, and reset, respectively. Usually you will
-# want to use += to add to a list option. Lastly, there is := which you can use
-# to create an alias, like so:
-# ae := autopickup_exceptions
-# From there on, 'ae' will be treated as if it you typed autopickup_exceptions,
-# so you can save time typing it.
-#
-
-##### Other files ###################################################
-# You can include other files from your options file using the 'include'
-# option. Crawl will treat it as if you copied the whole text of that file
-# into your options file in that spot. You can uncomment some of the following
-# lines by removing the beginning '#' to include some of the other files in
-# this folder.
-
-# Some useful, more advanced options, implemented in LUA.
-# include = advanced_optioneering.txt
-
-# Alternative vi bindings for Dvorak users.
-# include = dvorak_command_keys.txt
-
-# Alternative vi bindings for Colemak users.
-# include = colemak_command_keys.txt
-
-# Alternative vi bindings for Neo users.
-# include = neo_command_keys.txt
-
-# Override the vi movement keys with a non-command.
-# include = no_vi_command_keys.txt
-
-# Turn the shift-vi keys into safe move, instead of run.
-# include = safe_move_shift.txt
-
-##### Ancient versions ##############################################
-# If you're used to the interface of ancient versions of Crawl, you may
-# get back parts of it by uncommenting the following options:
-
-# include = 034_command_keys.txt
-
-# And to revert monster glyph and colouring changes:
-
-# include = 052_monster_glyphs.txt
-# include = 060_monster_glyphs.txt
-# include = 071_monster_glyphs.txt
-# include = 080_monster_glyphs.txt
-# include = 0.9_monster_glyphs.txt
-# include = 0.12_monster_glyphs.txt
-# include = 0.13_monster_glyphs.txt
-# include = 0.14_monster_glyphs.txt
diff --git a/dgamelaunch.conf b/dgamelaunch.conf
index 5602880f..3275fa9f 100644
--- a/dgamelaunch.conf
+++ b/dgamelaunch.conf
@@ -115,15 +115,11 @@ watch_columns = [ ["", "", 0, "%s)"],
#
commands[register] = mkdir "%%CHROOT_TTYRECDIR%%/%n",
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-git/%n.macro",
ifnxcp "%rdata/crawl-git-settings/init.txt" "%rrcfiles/crawl-git/%n.rc",
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-0.25/%n.macro",
ifnxcp "%rdata/crawl-0.25-settings/init.txt" "%rrcfiles/crawl-0.25/%n.rc"
commands[login] = mkdir "%%CHROOT_TTYRECDIR%%/%n",
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-git/%n.macro",
ifnxcp "%rdata/crawl-git-settings/init.txt" "%rrcfiles/crawl-git/%n.rc",
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-0.25/%n.macro",
ifnxcp "%rdata/crawl-0.25-settings/init.txt" "%rrcfiles/crawl-0.25/%n.rc"
menu["mainmenu_anon"] {
@@ -205,7 +201,7 @@ menu["crawl-git-adv"] {
cp "%rdata/crawl-git-settings/init.txt" "%rrcfiles/crawl-git/%n.rc",
return
commands["M"] =
- cp "%rdata/crawl-git.macro" "%rrcfiles/crawl-git/%n.macro",
+ unlink "%rrcfiles/crawl-git/%n.macro",
return
commands["qQ"] = return
}
@@ -219,7 +215,7 @@ menu["crawl-0.25-adv"] {
cp "%rdata/crawl-0.25-settings/init.txt" "%rrcfiles/crawl-0.25/%n.rc",
return
commands["M"] =
- cp "%rdata/crawl-git.macro" "%rrcfiles/crawl-0.25/%n.macro",
+ unlink "%rrcfiles/crawl-0.25/%n.macro",
return
commands["qQ"] = return
}
@@ -254,7 +250,6 @@ DEFINE {
ttyrecdir = "%%CHROOT_TTYRECDIR%%/%n/"
commands =
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-git/%n.macro",
ifnxcp "%rdata/crawl-git-settings/init.txt" "%rrcfiles/crawl-git/%n.rc",
setenv "MAIL" "%%CHROOT_MAILSPOOL%%/%n",
setenv "SIMPLEMAIL" "1",
@@ -293,7 +288,6 @@ DEFINE {
ttyrecdir = "%%CHROOT_TTYRECDIR%%/%n/"
commands =
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-git/%n.macro",
ifnxcp "%rdata/crawl-git-settings/init.txt" "%rrcfiles/crawl-git/%n.rc",
setenv "MAIL" "%%CHROOT_MAILSPOOL%%/%n",
setenv "SIMPLEMAIL" "1",
@@ -332,7 +326,6 @@ DEFINE {
ttyrecdir = "%%CHROOT_TTYRECDIR%%/%n/"
commands =
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-git/%n.macro",
ifnxcp "%rdata/crawl-git-settings/init.txt" "%rrcfiles/crawl-git/%n.rc",
setenv "MAIL" "%%CHROOT_MAILSPOOL%%/%n",
setenv "SIMPLEMAIL" "1",
@@ -373,7 +366,6 @@ DEFINE {
ttyrecdir = "%%CHROOT_TTYRECDIR%%/%n/"
commands =
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-0.25/%n.macro",
ifnxcp "%rdata/crawl-0.25-settings/init.txt" "%rrcfiles/crawl-0.25/%n.rc",
setenv "MAIL" "%%CHROOT_MAILSPOOL%%/%n",
setenv "SIMPLEMAIL" "1",
@@ -412,7 +404,6 @@ DEFINE {
ttyrecdir = "%%CHROOT_TTYRECDIR%%/%n/"
commands =
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-0.25/%n.macro",
ifnxcp "%rdata/crawl-0.25-settings/init.txt" "%rrcfiles/crawl-0.25/%n.rc",
setenv "MAIL" "%%CHROOT_MAILSPOOL%%/%n",
setenv "SIMPLEMAIL" "1",
@@ -451,7 +442,6 @@ DEFINE {
ttyrecdir = "%%CHROOT_TTYRECDIR%%/%n/"
commands =
- ifnxcp "%rdata/crawl-git.macro" "%rrcfiles/crawl-0.25/%n.macro",
ifnxcp "%rdata/crawl-0.25-settings/init.txt" "%rrcfiles/crawl-0.25/%n.rc",
setenv "MAIL" "%%CHROOT_MAILSPOOL%%/%n",
setenv "SIMPLEMAIL" "1",
From 08a50a9df51f3c6a036aeb05050302a759d47c35 Mon Sep 17 00:00:00 2001
From: gammafunk
Date: Mon, 27 Jun 2022 02:14:44 +0000
Subject: [PATCH 07/10] feat: Scripts to support experimental branches
Previously we updated the stable branch scripts to allow them to work
with experimentals, but this had unwanted side effects. Directories were
created that experimentals don't use, some of which mangled the branch
name into a numeric version, and there was no support for using a game
name different from the git branch name. The latter is important since
developers like to use funny names that might confuse users in e.g.
WebTiles lobby listings.
This commit adds a set of scripts specifically for experimentals: a
build updater, an installer, and a launcher. The updater require two
arguments, a git branch name used for git purposes, and a game name used
in naming the crawl binary and any relevant directories. The installer
and launcher only expect the game name, since that's the only value they
need. The installer doesn't create sprint or tutorial directories, since
we don't use those for experimentals. The launcher uses the user's git
RC file for its RC.
We also revert changes to the stable updater that relaxed conditions on
the branch name. This script goes back to being specialized for the
stable DCSS release branches.
---
bin/update-experimental.sh | 6 +
chroot/bin/crawl-experimental-launcher.sh | 121 +++++++++++++++
chroot/sbin/install-experimental.sh | 145 ++++++++++++++++++
.../update-crawl-experimental-build.sh | 88 +++++++++++
crawl-build/update-crawl-stable-build.sh | 18 +--
5 files changed, 366 insertions(+), 12 deletions(-)
create mode 100644 bin/update-experimental.sh
create mode 100755 chroot/bin/crawl-experimental-launcher.sh
create mode 100755 chroot/sbin/install-experimental.sh
create mode 100755 crawl-build/update-crawl-experimental-build.sh
diff --git a/bin/update-experimental.sh b/bin/update-experimental.sh
new file mode 100644
index 00000000..c2c0bfe2
--- /dev/null
+++ b/bin/update-experimental.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+cd "$DGL_CONF_HOME/crawl-build"
+
+# shellcheck source=crawl-build/update-crawl-experimental-build.sh
+source ./update-crawl-experimental-build.sh
diff --git a/chroot/bin/crawl-experimental-launcher.sh b/chroot/bin/crawl-experimental-launcher.sh
new file mode 100755
index 00000000..5e3f356e
--- /dev/null
+++ b/chroot/bin/crawl-experimental-launcher.sh
@@ -0,0 +1,121 @@
+#! /bin/bash
+#
+# Must be called as crawl-git -name [...]; character name
+# must always be the second argument.
+#
+# ===========================================================================
+# Copyright (C) 2008, 2009, 2010, 2011 Marc H. Thoben
+# Copyright (C) 2011 Darshan Shaligram
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+# ===========================================================================
+#
+
+# The webtiles binary requires a UTF-8 locale.
+export LC_ALL=en_US.UTF-8
+
+set -o nounset
+
+GAME_NAME=$1
+shift
+
+CRAWL_GIT_DIR="%%CHROOT_CRAWL_BASEDIR%%"
+USER_DB="%%CHROOT_LOGIN_DB%%"
+CRAWL_BINARY_PATH="%%CHROOT_CRAWL_BINARY_PATH%%"
+BINARY_BASE_NAME="crawl-$GAME_NAME"
+USER_ID="%%DGL_UID%%"
+
+export HOME="%%CHROOT_COREDIR%%"
+
+# Word boundary regex; bash's =~ is funny about that.
+wb='\b'
+
+JUST_RUN_CRAWL_ALREADY=
+# If set, this script will not event report the existence of newer versions.
+[[ "$@" =~ -print-charset$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+[[ "$@" =~ -print-webtiles-options$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+[[ "$@" =~ -gametypes-json$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+[[ "$@" =~ -save-json$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+
+WEBTILES=
+[[ "$@" =~ -await-connection$wb ]] && WEBTILES=1
+
+cecho() {
+ [[ -z "$WEBTILES" ]] && echo "$@"
+}
+wecho() {
+ [[ -n "$WEBTILES" ]] && echo "$@"
+}
+
+TRANSFER_ENABLED="1"
+CHAR_NAME="$2"
+
+# Clear screen
+[[ -z "$JUST_RUN_CRAWL_ALREADY" && -z "$WEBTILES" ]] && printf "\e[2J\e[H"
+
+export LANG="en_US.UTF-8"
+export LC_CTYPE="en_US.UTF-8"
+
+if [[ $# == 0 || -z "$CHAR_NAME" ]]; then
+ if [[ -z "$JUST_RUN_CRAWL_ALREADY" ]]; then
+ echo "Parameters missing. Aborting..."
+ read -n 1 -s -p "--- any key to continue ---"
+ echo
+ fi;
+ exit 1
+fi
+
+ulimit -S -c 1536000 2>/dev/null
+ulimit -S -v 1024000 2>/dev/null
+
+first-real-file() {
+ for file in "$@"; do
+ if [[ -f "$file" ]]; then
+ printf "%s\n" "$file"
+ return 0
+ fi
+ done
+}
+
+user-is-admin() {
+ local found="$(echo "SELECT username FROM dglusers
+ WHERE username='$CHAR_NAME' AND (flags & 1) = 1;" |
+ sqlite3 "$USER_DB")"
+ [[ -n "$found" ]]
+}
+
+user-is-wizard() {
+ local found="$(echo "SELECT username FROM dglusers
+ WHERE username='$CHAR_NAME' AND (flags & 32) = 32;" |
+ sqlite3 "$USER_DB")"
+ [[ -n "$found" ]]
+}
+
+BINARY_NAME="$CRAWL_BINARY_PATH/$BINARY_BASE_NAME"
+GAME_FOLDER="$CRAWL_GIT_DIR/$BINARY_BASE_NAME"
+
+if ( user-is-admin || user-is-wizard ) && [[ "$*" != *-wizard* ]]; then
+ set -- "$@" -wizard
+fi
+
+if test -x "${BINARY_NAME}" -a -d "${GAME_FOLDER}"
+then
+ cd ${HOME}
+ exec ${BINARY_NAME} "$@"
+fi
+
+cecho "Failed starting: ${BINARY_NAME} not found!"
+read -n 1 -s -p "--- any key to continue ---"
+cecho
+exit 1
diff --git a/chroot/sbin/install-experimental.sh b/chroot/sbin/install-experimental.sh
new file mode 100755
index 00000000..ca5e5ca0
--- /dev/null
+++ b/chroot/sbin/install-experimental.sh
@@ -0,0 +1,145 @@
+#!/bin/bash
+#
+# This script needs a sudo entry for user crawl to run as root:
+# For obvious reasons, this script should not source any other scripts that
+# are not owned by root.
+#
+# ===========================================================================
+# Copyright (C) 2008, 2009, 2010, 2011 Marc H. Thoben
+# Copyright (C) 2011 Darshan Shaligram
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+# ===========================================================================
+#
+
+set -e
+set -u
+
+# These are not overrideable:
+CHROOT="%%DGL_CHROOT%%"
+CHROOT_BINARIES="%%CHROOT_CRAWL_BINARY_PATH%%"
+CHROOT_CRAWL_BASEDIR="%%CHROOT_CRAWL_BASEDIR%%"
+DESTDIR="%%CRAWL_BASEDIR%%"
+CRAWL_UGRP="%%CRAWL_UGRP%%"
+DGL_SETTINGS_DIR="%%DGL_SETTINGS_DIR%%"
+
+GAME_NAME="$1"
+
+GAME="crawl-$GAME_NAME"
+
+# Safe path:
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+if [[ "$UID" != "0" ]]; then
+ echo "$0 must be run as root"
+ exit 1
+fi
+
+copy-game-binary() {
+ echo "Installing game binary ($GAME_BINARY) in $BINARIES_DIR"
+ mkdir -p $BINARIES_DIR
+ if [[ -f $BINARIES_DIR/$GAME_BINARY ]]; then
+ mv $BINARIES_DIR/$GAME_BINARY $BINARIES_DIR/$GAME_BINARY.old
+ fi
+ if cp source/$GAME_BINARY $BINARIES_DIR; then
+ rm $BINARIES_DIR/$GAME_BINARY.old || true
+ else
+ local ERR=$?
+ mv $BINARIES_DIR/$GAME_BINARY.old $BINARIES_DIR/$GAME_BINARY || true
+ return $ERR
+ fi
+}
+
+copy-data-files() {
+ echo "Copying game data files to $DATADIR"
+ cp -r source/dat docs settings $DATADIR
+ # Only one of these exists, don't error for the other.
+ cp -r README.txt README.md $DATADIR 2>/dev/null || true
+ cp -r settings/. $DGL_SETTINGS_DIR/$GAME-settings
+ cp -r source/webserver/game_data/. $DATADIR/web
+
+ mkdir -p "$ABS_COMMON_DIR/data/docs"
+ cp docs/crawl_changelog.txt "$ABS_COMMON_DIR/data/docs"
+}
+
+create-dgl-directories() {
+ mkdir -p "$CHROOT/dgldir/inprogress/$GAME"
+ mkdir -p "$CHROOT/dgldir/data/$GAME-settings/"
+}
+
+fix-chroot-directory-permissions() {
+ chown -R crawl:crawl "$CHROOT/crawl-master"
+ chown -R crawl:crawl "$CHROOT/dgldir"
+}
+
+install-game() {
+ mkdir -p $SAVEDIR
+ rm -rf $DATADIR
+ mkdir -p $DATADIR
+
+ create-dgl-directories
+ fix-chroot-directory-permissions
+ copy-game-binary
+ copy-data-files
+
+ chown -R $CRAWL_UGRP $SAVEDIR
+}
+
+assert-not-evil() {
+ local file=$1
+ if [[ "$file" != "$(echo "$file" |
+ perl -lpe 's{[.]{2}|[^.a-zA-Z0-9_/-]+}{}g')" ]]
+ then
+ echo -e "Path $file contains characters I don't like, aborting."
+ exit 1
+ fi
+}
+
+if [[ -z "$GAME_NAME" ]]; then
+ echo -e "Missing game name argument"
+ exit 1
+fi
+
+assert-not-evil "$GAME_NAME"
+
+if [[ ! ( "$CRAWL_UGRP" =~ ^[a-z0-9]+:[a-z0-9]+$ ) ]]; then
+ echo -e "Expected CRAWL_UGRP to be user:group, but got $CRAWL_UGRP"
+ exit 1
+fi
+
+# COMMON_DIR is the absolute path *inside* the chroot jail of the
+# directory holding common data for all game versions, viz: saves.
+COMMON_DIR=$CHROOT_CRAWL_BASEDIR/$GAME
+assert-not-evil "$COMMON_DIR"
+
+# ABS_COMMON_DIR is the absolute path from outside the chroot
+# corresponding to COMMON_DIR
+ABS_COMMON_DIR=$CHROOT$COMMON_DIR
+
+if [[ ! -d "$ABS_COMMON_DIR" ]]; then
+ mkdir -p "$ABS_COMMON_DIR"
+fi
+
+GAME_BINARY=$GAME
+BINARIES_DIR=$CHROOT$CHROOT_BINARIES
+
+GAMEDIR=$CHROOT$CHROOT_CRAWL_BASEDIR/$GAME
+# Absolute path to save game directory
+SAVEDIR=$GAMEDIR/saves
+DATADIR=$GAMEDIR/data
+assert-not-evil "$SAVEDIR"
+assert-not-evil "$DATADIR"
+
+echo "Installing game"
+install-game
diff --git a/crawl-build/update-crawl-experimental-build.sh b/crawl-build/update-crawl-experimental-build.sh
new file mode 100755
index 00000000..485760ff
--- /dev/null
+++ b/crawl-build/update-crawl-experimental-build.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+BRANCH="$1"
+GAME_NAME="$2"
+
+# Quoting for =~ changed from bash 3.0 to 3.2; using a variable for the
+# regexp works with both.
+BRANCH_RE='^[[:alnum:]][-._[:alnum:]]+$'
+if [[ ! $BRANCH =~ $BRANCH_RE ]]; then
+ echo "Bad git branch name $BRANCH"
+ exit 1
+fi
+
+if [[ ! $GAME_NAME =~ $BRANCH_RE ]]; then
+ echo "Bad crawl game name $GAME_NAME"
+ exit 1
+fi
+
+set -e
+lock-or-die crawl-update "someone is already updating the crawl build"
+
+source $DGL_CONF_HOME/crawl-git.conf
+GAME=crawl-$GAME_NAME
+
+export DESTDIR=$CRAWL_BASEDIR
+
+check-crawl-basedir-exists
+enable-prompts $*
+
+TODAY="$(dgl-today)"
+
+# Third argument can be a revision (SHA) to build
+REVISION="$3"
+./update-public-repository.sh $BRANCH "$REVISION"
+
+REVISION="$(git-do rev-parse HEAD | cut -c 1-7)"
+REVISION_FULL="$(git-do describe --long HEAD)"
+VER_STR="$(git-do describe HEAD)"
+VER_STR_OLD="$(($CRAWL_BINARY_PATH/$GAME -version 2>/dev/null || true) | sed -ne 's/Crawl version //p')"
+REVISION_OLD="${VER_STR_OLD##*-g}"
+
+[[ "$REVISION" == "$REVISION_OLD" || "$VER_STR" = "$VER_STR_OLD" ]] && \
+ abort-saying "Nothing new to install at the moment: you asked for $REVISION_FULL and it's already installed"
+
+prompt "start update build"
+
+cd $CRAWL_REPOSITORY_DIR/crawl-ref
+
+echo "Copying CREDITS to docs/crawl_credits.txt..."
+cp CREDITS.txt docs/crawl_credits.txt
+
+dgl-git-log() {
+ git-do log --pretty=tformat:"--------------------------------------------------------------------------------%n%h | %an | %ci%n%n%s%n%b" "$@" | grep -v "git-svn-id" | awk 1 RS= ORS="\n\n" | fold -s
+}
+
+echo "Creating changelog in docs/crawl_changelog.txt..."
+dgl-git-log $BRANCH > docs/crawl_changelog.txt
+
+if prompts-enabled; then
+ echo "Changes to $BRANCH from $REVISION_OLD .. $REVISION"
+ dgl-git-log ${REVISION_OLD:+$REVISION_OLD..}${REVISION} | less
+fi
+
+prompt "compile ${GAME} (${REVISION})"
+
+# REMEMBER to adjust /var/lib/dgamelaunch/sbin/install-stable.sh as well if make parameters change!
+##################################################################################################
+
+say-do crawl-do nice make -C source \
+ GAME=${GAME} \
+ GAME_MAIN=${GAME} MCHMOD=0755 MCHMOD_SAVEDIR=755 \
+ INSTALL_UGRP=$CRAWL_UGRP \
+ WEBTILES=YesPlease USE_DGAMELAUNCH=YesPlease WIZARD=YesPlease \
+ STRIP=true DESTDIR=${DESTDIR} prefix= bin_prefix=/bin \
+ SAVEDIR=$CHROOT_CRAWL_BASEDIR/${GAME}/saves \
+ DATADIR=$CHROOT_CRAWL_BASEDIR/${GAME}/data \
+ WEBDIR=$CHROOT_CRAWL_BASEDIR/${GAME}/data/web \
+ USE_PCRE=y \
+ EXTERNAL_FLAGS_L="-g"
+
+prompt "install ${GAME} (${REVISION})"
+
+say-do sudo -H $DGL_CHROOT/sbin/install-experimental.sh "$GAME_NAME"
+
+announce "Experimental ($BRANCH) branch on $DGL_SERVER updated to: ${REVISION_FULL}"
+
+echo "All done."
+echo
diff --git a/crawl-build/update-crawl-stable-build.sh b/crawl-build/update-crawl-stable-build.sh
index e3c619cc..e05d7d68 100755
--- a/crawl-build/update-crawl-stable-build.sh
+++ b/crawl-build/update-crawl-stable-build.sh
@@ -4,11 +4,11 @@ VERSION=${1:-}
# Quoting for =~ changed from bash 3.0 to 3.2; using a variable for the
# regexp works with both.
-# VERS_RE='^[0-9]+.[0-9]+$'
-# if [[ ! $VERSION =~ $VERS_RE ]]; then
-# echo "Bad crawl version $VERSION"
-# exit 1
-# fi
+VERS_RE='^[0-9]+.[0-9]+$'
+if [[ ! $VERSION =~ $VERS_RE ]]; then
+ echo "Bad crawl version $VERSION"
+ exit 1
+fi
set -e
lock-or-die crawl-update "someone is already updating the crawl build"
@@ -80,13 +80,7 @@ prompt "install ${GAME} (${REVISION})"
say-do sudo -H $DGL_CHROOT/sbin/install-stable.sh "$VERSION"
-if [[ $VERSION = [0-9]* ]]; then
- SUPER_VER="Stable"
-else
- SUPER_VER="Experimental"
-fi
-
-announce "$SUPER_VER ($VERSION) branch on $DGL_SERVER updated to: ${REVISION_FULL}"
+announce "Stable ($VERSION) branch on $DGL_SERVER updated to: ${REVISION_FULL}"
echo "All done."
echo
From 403d896a28f5c4eb8ed3efdfba63ff606eaf99fe Mon Sep 17 00:00:00 2001
From: gammafunk
Date: Thu, 14 Jul 2022 08:54:44 +0000
Subject: [PATCH 08/10] fix: Clean up output for admin and wizard commands
Don't use `echo -e`, using printf instead if we need to control
newlines. Also fix up existing printf usage.
---
bin/admin.sh | 16 ++++++++--------
bin/wizard.sh | 14 +++++++-------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/bin/admin.sh b/bin/admin.sh
index cf76853e..dda91681 100644
--- a/bin/admin.sh
+++ b/bin/admin.sh
@@ -48,9 +48,9 @@ EOF
admin-add() {
local new_admin="$1"
dgl-user-exists "$new_admin" || \
- abort-saying "Cannot find user $new_admin in dgl login db"
+ abort-saying "Cannot find user $new_admin in dgl login db."
if dgl-user-is-admin "$new_admin"; then
- echo -e "User $new_admin is already an admin"
+ echo "User $new_admin is already an admin."
exit 0
fi
@@ -58,10 +58,10 @@ admin-add() {
dgl-user-make-admin "$new_admin"
if dgl-user-is-admin "$new_admin"; then
- printf "%s" "\nDone, $new_admin is now a DGL admin.\n"
+ printf 'Done, %s is now a DGL admin.\n' "$new_admin"
exit 0
else
- echo -e "Oops, couldn't make $new_admin a DGL admin.\n"
+ echo "Oops, couldn't make $new_admin a DGL admin."
exit 1
fi
}
@@ -69,9 +69,9 @@ admin-add() {
admin-rm() {
local ex_admin="$1"
dgl-user-exists "$ex_admin" || \
- abort-saying "Cannot find user $ex_admin in dgl login db"
+ abort-saying "Cannot find user $ex_admin in dgl login db."
if ! dgl-user-is-admin "$ex_admin"; then
- echo -e "User $ex_admin is not an admin, nothing to do"
+ echo "User $ex_admin is not an admin, nothing to do."
exit 0
fi
@@ -79,10 +79,10 @@ admin-rm() {
dgl-user-unmake-admin "$ex_admin"
if ! dgl-user-is-admin "$ex_admin"; then
- printf "%s" "\nDone, $ex_admin is now a regular DGL non-admin user.\n"
+ printf 'Done, %s is now a regular DGL non-admin user.\n' "$ex_admin"
exit 0
else
- echo -e "Oops, couldn't make $ex_admin a regular DGL non-admin user."
+ echo "Oops, couldn't make $ex_admin a regular DGL non-admin user."
exit 1
fi
}
diff --git a/bin/wizard.sh b/bin/wizard.sh
index cb0aafcc..5668e7d4 100644
--- a/bin/wizard.sh
+++ b/bin/wizard.sh
@@ -48,9 +48,9 @@ EOF
wizard-add() {
local new_wizard="$1"
dgl-user-exists "$new_wizard" || \
- abort-saying "Cannot find user $new_wizard in dgl login db"
+ abort-saying "Cannot find user $new_wizard in dgl login db."
if dgl-user-is-wizard "$new_wizard"; then
- echo -e "User $new_wizard is already an wizard"
+ echo "User $new_wizard is already an wizard."
exit 0
fi
@@ -58,10 +58,10 @@ wizard-add() {
dgl-user-make-wizard "$new_wizard"
if dgl-user-is-wizard "$new_wizard"; then
- printf "%s" "\nDone, $new_wizard is now a DGL wizard.\n"
+ printf 'Done, %s is now a DGL wizard.\n' "$new_wizard"
exit 0
else
- echo -e "Oops, couldn't make $new_wizard a DGL wizard.\n"
+ echo "Oops, couldn't make $new_wizard a DGL wizard."
exit 1
fi
}
@@ -69,9 +69,9 @@ wizard-add() {
wizard-rm() {
local ex_wizard="$1"
dgl-user-exists "$ex_wizard" || \
- abort-saying "Cannot find user $ex_wizard in dgl login db"
+ abort-saying "Cannot find user $ex_wizard in dgl login db."
if ! dgl-user-is-wizard "$ex_wizard"; then
- echo -e "User $ex_wizard is not an wizard, nothing to do"
+ echo "User $ex_wizard is not an wizard, nothing to do."
exit 0
fi
@@ -79,7 +79,7 @@ wizard-rm() {
dgl-user-unmake-wizard "$ex_wizard"
if ! dgl-user-is-wizard "$ex_wizard"; then
- printf "%s" "\nDone, $ex_wizard is now a regular DGL non-wizard user.\n"
+ printf 'Done, %s is now a regular DGL non-wizard user.\n' "$ex_wizard"
exit 0
else
echo -e "Oops, couldn't make $ex_wizard a regular DGL non-wizard user."
From dce29bb67043753871f3c7ee0247c37c216107ea Mon Sep 17 00:00:00 2001
From: gammafunk
Date: Fri, 26 Aug 2022 23:31:18 +0000
Subject: [PATCH 09/10] fix: Correct prompt for the dgl passwd command
This current arguments don't match the bash builtin read argument
syntax.
---
bin/passwd.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bin/passwd.sh b/bin/passwd.sh
index 4f9b7b3c..e23bd030 100644
--- a/bin/passwd.sh
+++ b/bin/passwd.sh
@@ -71,12 +71,12 @@ echo "Password hint for $USER: '$(password-hint "$USER")'"
if [[ "$UID" == "0" ]]; then
echo
- read -s -p -r "Enter new password for $USER: " PASSWORD
+ read -s -r -p "Enter new password for $USER: " PASSWORD
echo
if [[ -z "$PASSWORD" ]]; then
abort-saying "Empty password"
fi
- read -s -p -r "Retype password for $USER: " CONFIRM_PASSWORD
+ read -s -r -p "Retype password for $USER: " CONFIRM_PASSWORD
echo
if [[ "$PASSWORD" != "$CONFIRM_PASSWORD" ]]; then
From 6edef29129489039215194c2a38ebc61f79f9ff4 Mon Sep 17 00:00:00 2001
From: gammafunk
Date: Sat, 27 Aug 2022 01:51:25 +0000
Subject: [PATCH 10/10] feat: A bot-only crawl install
For running bots like qw, its helpful to have installs of stable and
trunk that are accessible only to bot accounts. This way qw can run on
an untracked server like CDI, but the bot-only logfiles and milestone
files can still be added to Sequell, Tournament, and CAO scoring. In
the future, bots might additionally need slightly different game build
options.
This commit adds a bot user flag (value 64) and updaters, installers,
and launchers for bot-only installs of stable and trunk. The launcher
refuses to execute crawl if the user does not have the bot flag,
providing an appropriate message in both dgamelaunch and webtiles when
this happens. When running the bot stable/git updaters along with the
regular updaters, a proper ccache setup will ensure that the bot builds
are very fast. Both installers do the same type of install as the
regular stable installer, namely games are always forced transfered.
Bots don't need to decide on a per-commit basis whether to transfer a
trunk game, and not maintaining an additional set of per-commit builds
of trunk simplifies management.
Since this functionality is likely only useful to myself and CDI, I'm
not adding any configuration examples to dgamelaunch.conf or configy.py.
---
bin/bot.sh | 95 ++++++++++++
bin/update-bot-stable.sh | 6 +
bin/update-bot-trunk.sh | 6 +
chroot/bin/crawl-bot-git-launcher.sh | 149 ++++++++++++++++++
chroot/bin/crawl-bot-stable-launcher.sh | 152 ++++++++++++++++++
chroot/sbin/install-bot-stable.sh | 153 +++++++++++++++++++
chroot/sbin/install-bot-trunk.sh | 140 +++++++++++++++++
crawl-build/update-crawl-bot-stable-build.sh | 84 ++++++++++
crawl-build/update-crawl-bot-trunk-build.sh | 70 +++++++++
sh-utils | 8 +
10 files changed, 863 insertions(+)
create mode 100644 bin/bot.sh
create mode 100644 bin/update-bot-stable.sh
create mode 100644 bin/update-bot-trunk.sh
create mode 100755 chroot/bin/crawl-bot-git-launcher.sh
create mode 100755 chroot/bin/crawl-bot-stable-launcher.sh
create mode 100755 chroot/sbin/install-bot-stable.sh
create mode 100755 chroot/sbin/install-bot-trunk.sh
create mode 100755 crawl-build/update-crawl-bot-stable-build.sh
create mode 100755 crawl-build/update-crawl-bot-trunk-build.sh
diff --git a/bin/bot.sh b/bin/bot.sh
new file mode 100644
index 00000000..74fe325e
--- /dev/null
+++ b/bin/bot.sh
@@ -0,0 +1,95 @@
+#! /bin/bash
+
+help < Make a bot
+ $SCRIPT_NAME rm Make a non-bot user.
+
+EOF
+
+assert-login-db-exists
+
+SUBCOMMAND=$1
+shift
+[[ -z "$SUBCOMMAND" ]] && SUBCOMMAND="ls"
+
+bot-ls() {
+ echo "Existing bot users:"
+ login-query < [...]; character name
+# must always be the second argument.
+#
+# ===========================================================================
+# Copyright (C) 2008, 2009, 2010, 2011 Marc H. Thoben
+# Copyright (C) 2011 Darshan Shaligram
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+# ===========================================================================
+#
+
+# The webtiles binary requires a UTF-8 locale.
+export LC_ALL=en_US.UTF-8
+
+set -o nounset
+
+CRAWL_GIT_DIR="%%CHROOT_CRAWL_BASEDIR%%"
+USER_DB="%%CHROOT_LOGIN_DB%%"
+CRAWL_BINARY_PATH="%%CHROOT_CRAWL_BINARY_PATH%%"
+BINARY_BASE_NAME="crawl-bot-git"
+USER_ID="%%DGL_UID%%"
+
+export HOME="%%CHROOT_COREDIR%%"
+
+# Word boundary regex; bash's =~ is funny about that.
+wb='\b'
+
+JUST_RUN_CRAWL_ALREADY=
+# If set, this script will not event report the existence of newer versions.
+[[ "$@" =~ -print-charset$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+[[ "$@" =~ -print-webtiles-options$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+[[ "$@" =~ -gametypes-json$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+[[ "$@" =~ -save-json$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+
+WEBTILES=
+[[ "$@" =~ -await-connection$wb ]] && WEBTILES=1
+
+cecho() {
+ [[ -z "$WEBTILES" ]] && echo "$@"
+}
+wecho() {
+ [[ -n "$WEBTILES" ]] && echo "$@"
+}
+
+wcat() {
+ if [[ -n "$WEBTILES" ]]; then
+ tr '\n' ' ' | sed -e 's/ $//'
+ echo
+ else
+ cat >/dev/null
+ fi
+}
+
+TRANSFER_ENABLED="1"
+CHAR_NAME="$2"
+
+# Clear screen
+[[ -z "$JUST_RUN_CRAWL_ALREADY" && -z "$WEBTILES" ]] && printf "\e[2J\e[H"
+
+export LANG="en_US.UTF-8"
+export LC_CTYPE="en_US.UTF-8"
+
+if [[ $# == 0 || -z "$CHAR_NAME" ]]; then
+ if [[ -z "$JUST_RUN_CRAWL_ALREADY" ]]; then
+ echo "Parameters missing. Aborting..."
+ read -n 1 -s -p "--- any key to continue ---"
+ echo
+ fi;
+ exit 1
+fi
+
+ulimit -S -c 1536000 2>/dev/null
+ulimit -S -v 1024000 2>/dev/null
+
+first-real-file() {
+ for file in "$@"; do
+ if [[ -f "$file" ]]; then
+ printf "%s\n" "$file"
+ return 0
+ fi
+ done
+}
+
+user-is-admin() {
+ local found="$(echo "SELECT username FROM dglusers
+ WHERE username='$CHAR_NAME' AND (flags & 1) = 1;" |
+ sqlite3 "$USER_DB")"
+ [[ -n "$found" ]]
+}
+
+user-is-wizard() {
+ local found="$(echo "SELECT username FROM dglusers
+ WHERE username='$CHAR_NAME' AND (flags & 32) = 32;" |
+ sqlite3 "$USER_DB")"
+ [[ -n "$found" ]]
+}
+
+user-is-bot() {
+ local found="$(echo "SELECT username FROM dglusers
+ WHERE username='$CHAR_NAME' AND (flags & 64) = 64;" |
+ sqlite3 "$USER_DB")"
+ [[ -n "$found" ]]
+}
+
+BINARY_NAME="$CRAWL_BINARY_PATH/$BINARY_BASE_NAME"
+GAME_FOLDER="$CRAWL_GIT_DIR/$BINARY_BASE_NAME"
+
+if ! user-is-bot; then
+ wecho '{"msg":"layer", "layer":"crt"}'
+ wecho -n '{"msg":"show_dialog", "html":"'
+ wcat <You don't have permission to play this game.
+
+"}
+EOF
+ cecho "You don't have permission to play this game."
+ cecho -n "--- any key to continue ---"
+ read -n 1 -s
+ wecho '{"msg":"hide_dialog"}'
+ exit 1
+fi
+
+if ( user-is-admin || user-is-wizard ) && [[ "$*" != *-wizard* ]]; then
+ set -- "$@" -wizard
+fi
+
+if test -x "${BINARY_NAME}" -a -d "${GAME_FOLDER}"
+then
+ cd ${HOME}
+ exec ${BINARY_NAME} "$@"
+fi
+
+cecho "Failed starting: ${BINARY_NAME} not found!"
+read -n 1 -s -p "--- any key to continue ---"
+cecho
+exit 1
diff --git a/chroot/bin/crawl-bot-stable-launcher.sh b/chroot/bin/crawl-bot-stable-launcher.sh
new file mode 100755
index 00000000..0455c18e
--- /dev/null
+++ b/chroot/bin/crawl-bot-stable-launcher.sh
@@ -0,0 +1,152 @@
+#! /bin/bash
+#
+# Must be called as crawl-git -name [...]; character name
+# must always be the second argument.
+#
+# ===========================================================================
+# Copyright (C) 2008, 2009, 2010, 2011 Marc H. Thoben
+# Copyright (C) 2011 Darshan Shaligram
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+# ===========================================================================
+#
+
+# The webtiles binary requires a UTF-8 locale.
+export LC_ALL=en_US.UTF-8
+
+set -o nounset
+
+VERSION=$1
+shift
+
+CRAWL_GIT_DIR="%%CHROOT_CRAWL_BASEDIR%%"
+USER_DB="%%CHROOT_LOGIN_DB%%"
+CRAWL_BINARY_PATH="%%CHROOT_CRAWL_BINARY_PATH%%"
+BINARY_BASE_NAME="crawl-bot-$VERSION"
+USER_ID="%%DGL_UID%%"
+
+export HOME="%%CHROOT_COREDIR%%"
+
+# Word boundary regex; bash's =~ is funny about that.
+wb='\b'
+
+JUST_RUN_CRAWL_ALREADY=
+# If set, this script will not event report the existence of newer versions.
+[[ "$@" =~ -print-charset$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+[[ "$@" =~ -print-webtiles-options$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+[[ "$@" =~ -gametypes-json$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+[[ "$@" =~ -save-json$wb ]] && JUST_RUN_CRAWL_ALREADY=1
+
+WEBTILES=
+[[ "$@" =~ -await-connection$wb ]] && WEBTILES=1
+
+cecho() {
+ [[ -z "$WEBTILES" ]] && echo "$@"
+}
+wecho() {
+ [[ -n "$WEBTILES" ]] && echo "$@"
+}
+
+wcat() {
+ if [[ -n "$WEBTILES" ]]; then
+ tr '\n' ' ' | sed -e 's/ $//'
+ echo
+ else
+ cat >/dev/null
+ fi
+}
+
+TRANSFER_ENABLED="1"
+CHAR_NAME="$2"
+
+# Clear screen
+[[ -z "$JUST_RUN_CRAWL_ALREADY" && -z "$WEBTILES" ]] && printf "\e[2J\e[H"
+
+export LANG="en_US.UTF-8"
+export LC_CTYPE="en_US.UTF-8"
+
+if [[ $# == 0 || -z "$CHAR_NAME" ]]; then
+ if [[ -z "$JUST_RUN_CRAWL_ALREADY" ]]; then
+ echo "Parameters missing. Aborting..."
+ read -n 1 -s -p "--- any key to continue ---"
+ echo
+ fi;
+ exit 1
+fi
+
+ulimit -S -c 1536000 2>/dev/null
+ulimit -S -v 1024000 2>/dev/null
+
+first-real-file() {
+ for file in "$@"; do
+ if [[ -f "$file" ]]; then
+ printf "%s\n" "$file"
+ return 0
+ fi
+ done
+}
+
+user-is-admin() {
+ local found="$(echo "SELECT username FROM dglusers
+ WHERE username='$CHAR_NAME' AND (flags & 1) = 1;" |
+ sqlite3 "$USER_DB")"
+ [[ -n "$found" ]]
+}
+
+user-is-wizard() {
+ local found="$(echo "SELECT username FROM dglusers
+ WHERE username='$CHAR_NAME' AND (flags & 32) = 32;" |
+ sqlite3 "$USER_DB")"
+ [[ -n "$found" ]]
+}
+
+user-is-bot() {
+ local found="$(echo "SELECT username FROM dglusers
+ WHERE username='$CHAR_NAME' AND (flags & 64) = 64;" |
+ sqlite3 "$USER_DB")"
+ [[ -n "$found" ]]
+}
+
+BINARY_NAME="$CRAWL_BINARY_PATH/$BINARY_BASE_NAME"
+GAME_FOLDER="$CRAWL_GIT_DIR/$BINARY_BASE_NAME"
+
+if ! user-is-bot; then
+ wecho '{"msg":"layer", "layer":"crt"}'
+ wecho -n '{"msg":"show_dialog", "html":"'
+ wcat <You don't have permission to play this game.
+
+"}
+EOF
+ cecho "You don't have permission to play this game."
+ cecho -n "--- any key to continue ---"
+ read -n 1 -s
+ wecho '{"msg":"hide_dialog"}'
+ exit 1
+fi
+
+if ( user-is-admin || user-is-wizard ) && [[ "$*" != *-wizard* ]]; then
+ set -- "$@" -wizard
+fi
+
+if test -x "${BINARY_NAME}" -a -d "${GAME_FOLDER}"
+then
+ cd ${HOME}
+ exec ${BINARY_NAME} "$@"
+fi
+
+cecho "Failed starting: ${BINARY_NAME} not found!"
+read -n 1 -s -p "--- any key to continue ---"
+cecho
+exit 1
diff --git a/chroot/sbin/install-bot-stable.sh b/chroot/sbin/install-bot-stable.sh
new file mode 100755
index 00000000..880c5750
--- /dev/null
+++ b/chroot/sbin/install-bot-stable.sh
@@ -0,0 +1,153 @@
+#!/bin/bash
+#
+# This script needs a sudo entry for user crawl to run as root:
+# For obvious reasons, this script should not source any other scripts that
+# are not owned by root.
+#
+# ===========================================================================
+# Copyright (C) 2008, 2009, 2010, 2011 Marc H. Thoben
+# Copyright (C) 2011 Darshan Shaligram
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+# ===========================================================================
+#
+
+set -e
+set -u
+
+# These are not overrideable:
+CHROOT="%%DGL_CHROOT%%"
+CHROOT_BINARIES="%%CHROOT_CRAWL_BINARY_PATH%%"
+CHROOT_CRAWL_BASEDIR="%%CHROOT_CRAWL_BASEDIR%%"
+DESTDIR="%%CRAWL_BASEDIR%%"
+VERSIONS_DB="%%VERSIONS_DB%%"
+CRAWL_UGRP="%%CRAWL_UGRP%%"
+DGL_SETTINGS_DIR="%%DGL_SETTINGS_DIR%%"
+
+VERSION="$1"
+
+GAME="crawl-bot-$VERSION"
+
+# Safe path:
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+if [[ "$UID" != "0" ]]; then
+ echo "$0 must be run as root"
+ exit 1
+fi
+
+copy-game-binary() {
+ echo "Installing game binary ($GAME_BINARY) in $BINARIES_DIR"
+ mkdir -p $BINARIES_DIR
+ if [[ -f $BINARIES_DIR/$GAME_BINARY ]]; then
+ mv $BINARIES_DIR/$GAME_BINARY $BINARIES_DIR/$GAME_BINARY.old
+ fi
+ if cp source/$GAME_BINARY $BINARIES_DIR/$GAME_BINARY; then
+ rm $BINARIES_DIR/$GAME_BINARY.old || true
+ else
+ local ERR=$?
+ mv $BINARIES_DIR/$GAME_BINARY.old $BINARIES_DIR/$GAME_BINARY || true
+ return $ERR
+ fi
+}
+
+copy-data-files() {
+ echo "Copying game data files to $DATADIR"
+ cp -r source/dat docs settings $DATADIR
+ # Only one of these exists, don't error for the other.
+ cp -r README.txt README.md $DATADIR 2>/dev/null || true
+ cp -r settings/. $DGL_SETTINGS_DIR/$GAME-settings
+ cp -r source/webserver/game_data/. $DATADIR/web
+
+ mkdir -p "$ABS_COMMON_DIR/data/docs"
+ cp docs/crawl_changelog.txt "$ABS_COMMON_DIR/data/docs"
+}
+
+create-dgl-directories() {
+ local short_version
+ short_version="${VERSION//0./}" # 0.17 --> 17
+ # TODO: use long version (0.17) for everything.
+ mkdir -p "$CHROOT/dgldir/inprogress/crawl-bot-$short_version-sprint/"
+ mkdir -p "$CHROOT/dgldir/inprogress/crawl-bot-$short_version-tut/"
+ mkdir -p "$CHROOT/dgldir/inprogress/crawl-bot-$short_version-seeded/"
+ mkdir -p "$CHROOT/dgldir/inprogress/crawl-bot-$short_version/"
+ mkdir -p "$CHROOT/dgldir/rcfiles/crawl-bot-0.$short_version/"
+ mkdir -p "$CHROOT/dgldir/data/crawl-bot-0.$short_version-settings/"
+}
+
+fix-chroot-directory-permissions() {
+ chown -R crawl:crawl "$CHROOT/crawl-master"
+ chown -R crawl:crawl "$CHROOT/dgldir"
+}
+
+install-game() {
+ mkdir -p $SAVEDIR/{,sprint}
+ rm -rf $DATADIR
+ mkdir -p $DATADIR
+
+ create-dgl-directories
+ fix-chroot-directory-permissions
+ copy-game-binary
+ copy-data-files
+
+ chown -R $CRAWL_UGRP $SAVEDIR
+}
+
+assert-not-evil() {
+ local file=$1
+ if [[ "$file" != "$(echo "$file" |
+ perl -lpe 's{[.]{2}|[^.a-zA-Z0-9_/-]+}{}g')" ]]
+ then
+ echo -e "Path $file contains characters I don't like, aborting."
+ exit 1
+ fi
+}
+
+if [[ -z "$VERSION" ]]; then
+ echo -e "Missing version argument"
+ exit 1
+fi
+
+assert-not-evil "$VERSION"
+
+if [[ ! ( "$CRAWL_UGRP" =~ ^[a-z0-9]+:[a-z0-9]+$ ) ]]; then
+ echo -e "Expected CRAWL_UGRP to be user:group, but got $CRAWL_UGRP"
+ exit 1
+fi
+
+# COMMON_DIR is the absolute path *inside* the chroot jail of the
+# directory holding common data for all game versions, viz: saves.
+COMMON_DIR=$CHROOT_CRAWL_BASEDIR/$GAME
+assert-not-evil "$COMMON_DIR"
+
+# ABS_COMMON_DIR is the absolute path from outside the chroot
+# corresponding to COMMON_DIR
+ABS_COMMON_DIR=$CHROOT$COMMON_DIR
+
+if [[ ! -d "$ABS_COMMON_DIR" ]]; then
+ mkdir -p "$ABS_COMMON_DIR"
+fi
+
+GAME_BINARY=$GAME
+BINARIES_DIR=$CHROOT$CHROOT_BINARIES
+
+GAMEDIR=$CHROOT$CHROOT_CRAWL_BASEDIR/$GAME
+# Absolute path to save game directory
+SAVEDIR=$GAMEDIR/saves
+DATADIR=$GAMEDIR/data
+assert-not-evil "$SAVEDIR"
+assert-not-evil "$DATADIR"
+
+echo "Installing game"
+install-game
diff --git a/chroot/sbin/install-bot-trunk.sh b/chroot/sbin/install-bot-trunk.sh
new file mode 100755
index 00000000..7d4cb336
--- /dev/null
+++ b/chroot/sbin/install-bot-trunk.sh
@@ -0,0 +1,140 @@
+#!/bin/bash
+#
+# This script needs a sudo entry for user crawl to run as root:
+# For obvious reasons, this script should not source any other scripts that
+# are not owned by root.
+#
+# ===========================================================================
+# Copyright (C) 2008, 2009, 2010, 2011 Marc H. Thoben
+# Copyright (C) 2011 Darshan Shaligram
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+# ===========================================================================
+#
+
+set -e
+set -u
+
+# These are not overrideable:
+CHROOT="%%DGL_CHROOT%%"
+CHROOT_BINARIES="%%CHROOT_CRAWL_BINARY_PATH%%"
+CHROOT_CRAWL_BASEDIR="%%CHROOT_CRAWL_BASEDIR%%"
+DESTDIR="%%CRAWL_BASEDIR%%"
+VERSIONS_DB="%%VERSIONS_DB%%"
+CRAWL_UGRP="%%CRAWL_UGRP%%"
+DGL_SETTINGS_DIR="%%DGL_SETTINGS_DIR%%"
+GAME="crawl-bot-git"
+
+# Safe path:
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+if [[ "$UID" != "0" ]]; then
+ echo "$0 must be run as root"
+ exit 1
+fi
+
+copy-game-binary() {
+ echo "Installing game binary ($GAME_BINARY) in $BINARIES_DIR"
+ mkdir -p $BINARIES_DIR
+ if [[ -f $BINARIES_DIR/$GAME_BINARY ]]; then
+ mv $BINARIES_DIR/$GAME_BINARY $BINARIES_DIR/$GAME_BINARY.old
+ fi
+ if cp source/$GAME_BINARY $BINARIES_DIR/$GAME_BINARY; then
+ rm $BINARIES_DIR/$GAME_BINARY.old || true
+ else
+ local ERR=$?
+ mv $BINARIES_DIR/$GAME_BINARY.old $BINARIES_DIR/$GAME_BINARY || true
+ return $ERR
+ fi
+}
+
+copy-data-files() {
+ echo "Copying game data files to $DATADIR"
+ cp -r source/dat docs settings $DATADIR
+ # Only one of these exists, don't error for the other.
+ cp -r README.txt README.md $DATADIR 2>/dev/null || true
+ cp -r settings/. $DGL_SETTINGS_DIR/$GAME-settings
+ cp -r source/webserver/game_data/. $DATADIR/web
+
+ mkdir -p "$ABS_COMMON_DIR/data/docs"
+ cp docs/crawl_changelog.txt "$ABS_COMMON_DIR/data/docs"
+}
+
+create-dgl-directories() {
+ mkdir -p "$CHROOT/dgldir/inprogress/crawl-bot-git-sprint/"
+ mkdir -p "$CHROOT/dgldir/inprogress/crawl-bot-git-tut/"
+ mkdir -p "$CHROOT/dgldir/inprogress/crawl-bot-git-seeded/"
+ mkdir -p "$CHROOT/dgldir/inprogress/crawl-bot-git/"
+ mkdir -p "$CHROOT/dgldir/rcfiles/crawl-bot-git/"
+ mkdir -p "$CHROOT/dgldir/data/crawl-bot-git-settings/"
+}
+
+fix-chroot-directory-permissions() {
+ chown -R crawl:crawl "$CHROOT/crawl-master"
+ chown -R crawl:crawl "$CHROOT/dgldir"
+}
+
+install-game() {
+ mkdir -p $SAVEDIR/{,sprint}
+ rm -rf $DATADIR
+ mkdir -p $DATADIR
+
+ create-dgl-directories
+ fix-chroot-directory-permissions
+ copy-game-binary
+ copy-data-files
+
+ chown -R $CRAWL_UGRP $SAVEDIR
+}
+
+assert-not-evil() {
+ local file=$1
+ if [[ "$file" != "$(echo "$file" |
+ perl -lpe 's{[.]{2}|[^.a-zA-Z0-9_/-]+}{}g')" ]]
+ then
+ echo -e "Path $file contains characters I don't like, aborting."
+ exit 1
+ fi
+}
+
+if [[ ! ( "$CRAWL_UGRP" =~ ^[a-z0-9]+:[a-z0-9]+$ ) ]]; then
+ echo -e "Expected CRAWL_UGRP to be user:group, but got $CRAWL_UGRP"
+ exit 1
+fi
+
+# COMMON_DIR is the absolute path *inside* the chroot jail of the
+# directory holding common data for all game versions, viz: saves.
+COMMON_DIR=$CHROOT_CRAWL_BASEDIR/$GAME
+assert-not-evil "$COMMON_DIR"
+
+# ABS_COMMON_DIR is the absolute path from outside the chroot
+# corresponding to COMMON_DIR
+ABS_COMMON_DIR=$CHROOT$COMMON_DIR
+
+if [[ ! -d "$ABS_COMMON_DIR" ]]; then
+ mkdir -p "$ABS_COMMON_DIR"
+fi
+
+GAME_BINARY=$GAME
+BINARIES_DIR=$CHROOT$CHROOT_BINARIES
+
+GAMEDIR=$CHROOT$CHROOT_CRAWL_BASEDIR/$GAME
+# Absolute path to save game directory
+SAVEDIR=$GAMEDIR/saves
+DATADIR=$GAMEDIR/data
+assert-not-evil "$SAVEDIR"
+assert-not-evil "$DATADIR"
+
+echo "Installing game"
+install-game
diff --git a/crawl-build/update-crawl-bot-stable-build.sh b/crawl-build/update-crawl-bot-stable-build.sh
new file mode 100755
index 00000000..00c31567
--- /dev/null
+++ b/crawl-build/update-crawl-bot-stable-build.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+VERSION=${1:-}
+
+# Quoting for =~ changed from bash 3.0 to 3.2; using a variable for the
+# regexp works with both.
+VERS_RE='^[0-9]+.[0-9]+$'
+if [[ ! $VERSION =~ $VERS_RE ]]; then
+ echo "Bad crawl version $VERSION"
+ exit 1
+fi
+
+set -e
+lock-or-die crawl-update "someone is already updating the crawl build"
+
+source $DGL_CONF_HOME/crawl-git.conf
+GAME=crawl-bot-$VERSION
+
+export DESTDIR=$CRAWL_BASEDIR
+BRANCH=stone_soup-$VERSION
+if [[ $VERSION != [0-9]* ]]; then
+ BRANCH=$VERSION
+fi
+
+check-crawl-basedir-exists
+enable-prompts $*
+
+TODAY="$(dgl-today)"
+
+# Second argument can be a revision (SHA) to build
+REVISION="$2"
+./update-public-repository.sh $BRANCH "$REVISION"
+
+REVISION="$(git-do rev-parse HEAD | cut -c 1-7)"
+REVISION_FULL="$(git-do describe --long HEAD)"
+VER_STR="$(git-do describe HEAD)"
+VER_STR_OLD="$(($CRAWL_BINARY_PATH/$GAME -version 2>/dev/null || true) | sed -ne 's/Crawl version //p')"
+REVISION_OLD="${VER_STR_OLD##*-g}"
+
+[[ "$REVISION" == "$REVISION_OLD" || "$VER_STR" = "$VER_STR_OLD" ]] && \
+ abort-saying "Nothing new to install at the moment: you asked for $REVISION_FULL and it's already installed"
+
+prompt "start update build"
+
+cd $CRAWL_REPOSITORY_DIR/crawl-ref
+
+echo "Copying CREDITS to docs/crawl_credits.txt..."
+cp CREDITS.txt docs/crawl_credits.txt
+
+dgl-git-log() {
+ git-do log --pretty=tformat:"--------------------------------------------------------------------------------%n%h | %an | %ci%n%n%s%n%b" "$@" | grep -v "git-svn-id" | awk 1 RS= ORS="\n\n" | fold -s
+}
+
+echo "Creating changelog in docs/crawl_changelog.txt..."
+dgl-git-log $BRANCH > docs/crawl_changelog.txt
+
+if prompts-enabled; then
+ echo "Changes to $BRANCH from $REVISION_OLD .. $REVISION"
+ dgl-git-log ${REVISION_OLD:+$REVISION_OLD..}${REVISION} | less
+fi
+
+prompt "compile ${GAME} (${REVISION})"
+
+# REMEMBER to adjust /var/lib/dgamelaunch/sbin/install-bot-stable.sh as well if make parameters change!
+##################################################################################################
+
+say-do crawl-do nice make -C source \
+ GAME=${GAME} \
+ GAME_MAIN=${GAME} MCHMOD=0755 MCHMOD_SAVEDIR=755 \
+ INSTALL_UGRP=$CRAWL_UGRP \
+ WEBTILES=YesPlease USE_DGAMELAUNCH=YesPlease WIZARD=YesPlease \
+ STRIP=true DESTDIR=${DESTDIR} prefix= bin_prefix=/bin \
+ SAVEDIR=$CHROOT_CRAWL_BASEDIR/${GAME}/saves \
+ DATADIR=$CHROOT_CRAWL_BASEDIR/${GAME}/data \
+ WEBDIR=$CHROOT_CRAWL_BASEDIR/${GAME}/data/web \
+ USE_PCRE=y \
+ EXTERNAL_FLAGS_L="-g"
+
+prompt "install ${GAME} (${REVISION})"
+
+say-do sudo -H $DGL_CHROOT/sbin/install-bot-stable.sh "$VERSION"
+
+echo "All done."
+echo
diff --git a/crawl-build/update-crawl-bot-trunk-build.sh b/crawl-build/update-crawl-bot-trunk-build.sh
new file mode 100755
index 00000000..feaac789
--- /dev/null
+++ b/crawl-build/update-crawl-bot-trunk-build.sh
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+set -e
+lock-or-die crawl-update "someone is already updating the crawl build"
+
+source $DGL_CONF_HOME/crawl-git.conf
+GAME=crawl-bot-git
+
+export DESTDIR=$CRAWL_BASEDIR
+
+check-crawl-basedir-exists
+enable-prompts $*
+
+TODAY="$(dgl-today)"
+
+# Second argument can be a revision (SHA) to build
+REVISION="$1"
+./update-public-repository.sh $BRANCH "$REVISION"
+
+REVISION="$(git-do rev-parse HEAD | cut -c 1-10)"
+REVISION_FULL="$(git-do describe --long HEAD)"
+VER_STR="$(git-do describe HEAD)"
+VER_STR_OLD="$( ($CRAWL_BINARY_PATH/$GAME -version 2>/dev/null || true) | sed -ne 's/Crawl version //p')"
+REVISION_OLD="${VER_STR_OLD##*-g}"
+
+[[ "$REVISION" == "$REVISION_OLD" || "$VER_STR" = "$VER_STR_OLD" ]] && \
+ abort-saying "Nothing new to install at the moment: you asked for $REVISION_FULL and it's already installed"
+
+prompt "start update build"
+
+cd $CRAWL_REPOSITORY_DIR/crawl-ref
+
+echo "Copying CREDITS to docs/crawl_credits.txt..."
+cp CREDITS.txt docs/crawl_credits.txt
+
+dgl-git-log() {
+ git-do log --pretty=tformat:"--------------------------------------------------------------------------------%n%h | %an | %ci%n%n%s%n%b" "$@" | grep -v "git-svn-id" | awk 1 RS= ORS="\n\n" | fold -s
+}
+
+echo "Creating changelog in docs/crawl_changelog.txt..."
+dgl-git-log $BRANCH > docs/crawl_changelog.txt
+
+if prompts-enabled; then
+ echo "Changes to $BRANCH from $REVISION_OLD .. $REVISION"
+ dgl-git-log ${REVISION_OLD:+$REVISION_OLD..}${REVISION} | less
+fi
+
+prompt "compile ${GAME} (${REVISION})"
+
+# REMEMBER to adjust /var/lib/dgamelaunch/sbin/install-bot-trunk.sh as well if make parameters change!
+##################################################################################################
+
+say-do crawl-do nice make -C source \
+ GAME=${GAME} \
+ GAME_MAIN=${GAME} MCHMOD=0755 MCHMOD_SAVEDIR=755 \
+ INSTALL_UGRP=$CRAWL_UGRP \
+ WEBTILES=YesPlease USE_DGAMELAUNCH=YesPlease WIZARD=YesPlease \
+ STRIP=true DESTDIR=${DESTDIR} prefix= bin_prefix=/bin \
+ SAVEDIR=$CHROOT_CRAWL_BASEDIR/${GAME}/saves \
+ DATADIR=$CHROOT_CRAWL_BASEDIR/${GAME}/data \
+ WEBDIR=$CHROOT_CRAWL_BASEDIR/${GAME}/data/web \
+ USE_PCRE=y \
+ EXTERNAL_FLAGS_L="-g"
+
+prompt "install ${GAME} (${REVISION})"
+
+say-do sudo -H $DGL_CHROOT/sbin/install-bot-trunk.sh
+
+echo "All done."
+echo
diff --git a/sh-utils b/sh-utils
index 732b4e9d..2eb09042 100644
--- a/sh-utils
+++ b/sh-utils
@@ -179,3 +179,11 @@ dgl-user-is-wizard() {
login-query)"
[[ -n "$found" ]]
}
+
+dgl-user-is-bot() {
+ local user="$1"
+ local found="$(echo "SELECT username FROM dglusers
+ WHERE username='$user' AND (flags & 64) = 64;" |
+ login-query)"
+ [[ -n "$found" ]]
+}