]> skyeroc.xyz Git - dgamelaunch/commitdiff
Add install-dgl-nh500 and patches
authorsbkelley <sb24kelley@gmail.com>
Mon, 1 Jun 2026 19:42:43 +0000 (15:42 -0400)
committersbkelley <sb24kelley@gmail.com>
Mon, 1 Jun 2026 20:43:58 +0000 (16:43 -0400)
dgl-nh500.patch [new file with mode: 0644]
dgl.patch [new file with mode: 0644]
install-dgl-nh500 [new file with mode: 0644]

diff --git a/dgl-nh500.patch b/dgl-nh500.patch
new file mode 100644 (file)
index 0000000..b3decf3
--- /dev/null
@@ -0,0 +1,89 @@
+diff -urB NetHack-5.0.0.bak/include/config.h NetHack-5.0.0/include/config.h
+--- NetHack-5.0.0.bak/include/config.h 2026-05-21 17:21:57.837822465 -0400
++++ NetHack-5.0.0/include/config.h     2026-05-21 17:22:19.470437749 -0400
+@@ -340,7 +340,7 @@
+ #endif
+ #ifndef PERS_IS_UID
+ #if !defined(MICRO) && !defined(MACOS9) && !defined(WIN32)
+-#define PERS_IS_UID 1 /* delete for PERSMAX per name; now per uid */
++#define PERS_IS_UID 0 /* delete for PERSMAX per name; now per uid */
+ #else
+ #define PERS_IS_UID 0
+ #endif
+@@ -444,7 +444,7 @@
+  * otherwise it will be the current directory.
+  */
+ #ifndef HACKDIR
+-#define HACKDIR "/usr/games/lib/nethackdir"
++#define HACKDIR "/opt/nh500"
+ #endif
+ /*
+diff -urB NetHack-5.0.0.bak/include/unixconf.h NetHack-5.0.0/include/unixconf.h
+--- NetHack-5.0.0.bak/include/unixconf.h       2026-05-21 17:21:57.845822692 -0400
++++ NetHack-5.0.0/include/unixconf.h   2026-05-21 17:22:19.478437978 -0400
+@@ -83,7 +83,7 @@
+  * If you want the static parts of your playground on a read-only file
+  * system, define VAR_PLAYGROUND to be where the variable parts are kept.
+  */
+-/* #define VAR_PLAYGROUND "/var/lib/games/nethack" */
++#define VAR_PLAYGROUND "/var/nh500"
+ /*
+  * Define DEF_PAGER as your default pager, e.g. "/bin/cat" or "/usr/ucb/more"
+diff -urB NetHack-5.0.0.bak/sys/unix/hints/include/multiw-1.500 NetHack-5.0.0/sys/unix/hints/include/multiw-1.500
+--- NetHack-5.0.0.bak/sys/unix/hints/include/multiw-1.500      2026-05-21 17:21:57.929825081 -0400
++++ NetHack-5.0.0/sys/unix/hints/include/multiw-1.500  2026-05-21 17:25:44.476492435 -0400
+@@ -5,8 +5,8 @@
+ # 1. Which windowing interface(s) should be included in this binary?
+ # One or more of these can be manually uncommented and/or can be specified
+ # on the 'make' command line.  If none are enabled, tty will be used.
+-#WANT_WIN_TTY=1
+-#WANT_WIN_CURSES=1
++WANT_WIN_TTY=1
++WANT_WIN_CURSES=1
+ #WANT_WIN_X11=1
+ #WANT_WIN_QT=1
+@@ -14,7 +14,7 @@
+ # Exactly one of these can be manually uncommented and/or can be specified
+ # on the 'make' command line.  If none is enabled, the first among
+ # WANT_WIN_{tty,curses,X11,Qt} that is enabled will become default.
+-#WANT_DEFAULT=tty
++WANT_DEFAULT=tty
+ #WANT_DEFAULT=curses
+ #WANT_DEFAULT=Qt
+ #WANT_DEFAULT=X11
+diff -urB NetHack-5.0.0.bak/sys/unix/hints/linux.500 NetHack-5.0.0/sys/unix/hints/linux.500
+--- NetHack-5.0.0.bak/sys/unix/hints/linux.500 2026-05-21 17:21:57.929825081 -0400
++++ NetHack-5.0.0/sys/unix/hints/linux.500     2026-05-21 17:22:19.482438091 -0400
+@@ -40,7 +40,7 @@
+ endif
+ #4. Other
+-GAMEUID  = $(USER)
++GAMEUID  = games
+ GAMEGRP  = games
+ # This gives better backtraces by making all core functions global; this
+@@ -418,16 +418,16 @@
+ MOREALL=$(MAKE) install
+ else #!WANT_SOURCE_INSTALL
+ #PREFIX=/usr
+-PREFIX=$(wildcard ~)/nh/install
+-HACKDIR=$(PREFIX)/games/lib/nethackdir
+-SHELLDIR = $(PREFIX)/games
++PREFIX=/.
++HACKDIR=$(PREFIX)/opt/nh500
++SHELLDIR = $(PREFIX)
+ VARDIRPERM = 0755
+ VARFILEPERM = 0600
+ GAMEPERM = 0755
+ endif #?WANT_SOURCE_INSTALL
+ INSTDIR=$(HACKDIR)
+-VARDIR = $(HACKDIR)
++VARDIR = $(PREFIX)/var/nh500
+ ifdef MAKEFILE_TOP
+ TESTGDBPATH=/usr/bin/gdb
diff --git a/dgl.patch b/dgl.patch
new file mode 100644 (file)
index 0000000..e677228
--- /dev/null
+++ b/dgl.patch
@@ -0,0 +1,269 @@
+diff -urB dgamelaunch.bak/examples/dgamelaunch.conf dgamelaunch.new/examples/dgamelaunch.conf
+--- dgamelaunch.bak/examples/dgamelaunch.conf  2020-03-07 06:27:35.000000000 -0500
++++ dgamelaunch.new/examples/dgamelaunch.conf  2026-05-23 03:21:19.009017983 -0400
+@@ -1,12 +1,7 @@
+-# This is a sample dgamelaunch configuration file. Only bash-style comments
+-# are allowed, such as this. Each configuration option will be explained
+-# along with its default value.
+-
+-
+-
+-# Global config variables:
+-
++# This is a sample dgamelaunch configuration file.
++# Also, functional.
++### Global config variables:
+ # Max amount of registered users to allow. Has no effect if dgl was
+ # compiled with SQLite
+ maxusers = 64000
+@@ -41,20 +36,20 @@
+ #                 ]
+ # Path to a prepared chroot jail.
+-chroot_path = "/opt/nethack/nethack.alt.org/"
++chroot_path = "/opt/dgamelaunch"
+ # From inside the jail, dgamelaunch's working directory for rcfiles/ttyrec/etc
+-dglroot = "/dgldir/"
++dglroot = "/var/"
+ # Server ID string
+-server_id = "nethack.alt.org - http://nethack.alt.org/"
++server_id = "Generic NetHack-Enabled dgamelaunch Server"
+ # From inside the jail, location of a banner file, the topmost line will be
+ # shown in submenus that cannot be defined separately.
+ # Some string substitution is done for the file:
+ # $VERSION   replaced with "dgamelaunch v" + dgl version number.
+ # $SERVERID  replaced with the server_id string, as defined above.
+-banner = "/dgl-banner"
++banner = "/etc/menu/dgl-banner"
+ # The following two options are fairly insecure. They will force us to
+ # load the password/group database into memory while still having root
+@@ -152,7 +147,7 @@
+ # First, the menu shown to anonymous user:
+ menu["mainmenu_anon"] {
+-        bannerfile = "dgl_menu_main_anon.txt"
++        bannerfile = "/etc/menu/dgl_menu_main_anon.txt"
+         cursor = (5,18)
+         commands["l"] = ask_login
+         commands["r"] = ask_register
+@@ -165,7 +160,7 @@
+ menu["mainmenu_user"] {
+ # contents of this file are written to screen.
+ # the file must be inside the chroot.
+-        bannerfile = "dgl_menu_main_user.txt"
++        bannerfile = "/etc/menu/dgl_menu_main_user.txt"
+ # after which cursor is moved to this location
+ # if cursor-definition is missing, the cursor is put
+ # to the end of the last line of the banner.
+@@ -176,15 +171,18 @@
+         commands["c"] = chpasswd
+         commands["e"] = chmail
+         commands["w"] = watch_menu
+-        commands["o"] = ifnxcp "/dgl-default-rcfile.nh343" "%ruserdata/%n/%n.nh343rc",
+-                      exec "/bin/virus" "%ruserdata/%n/%n.nh343rc"
+-        commands["p"] = play_game "NH343"
++        commands["o"] = ifnxcp "/etc/dgl-default-rcfile.nh500" "%ruserdata/%n/%n.nh500rc",
++                      exec "/bin/virus" "%ruserdata/%n/%n.nh500rc"
++        commands["O"] = ifnxcp "/etc/dgl-default-rcfile.nh500" "%ruserdata/%n/%n.nh500rc",
++                      exec "/bin/nano" "%ruserdata/%n/%n.nh500rc"
++        commands["p"] = play_game "nh500curses"
++      commands["P"] = play_game "nh500tty"
+         commands["q"] = quit
+ }
+ # this menu is shown when user presses '?' in the watching menu
+ menu["watchmenu_help"] {
+-      bannerfile = "dgl_menu_watchmenu_help.txt"
++      bannerfile = "/etc/menu/dgl_menu_watchmenu_help.txt"
+       commands["qQ "] = return
+ }
+@@ -193,29 +191,41 @@
+ # Next, we'll define one game's data:
+-#DEFINE {
++DEFINE {
+ #  # From inside the jail, the location of the binary to be launched.
+-#  game_path = "/bin/nethackstub"
+-#
++  game_path = "/bin/nh500"
++
++#  # If the game uses an ancient encoding, you may specify "ibm" or "dec".
++#  # If set to "ask", the game will be run with --print-charset beforehand,
++#  # expected to return one of these values.
++#  encoding = "unicode"
++
+ #  # Full name of the game
+-#  game_name = "NetHack stub"
+-#
++  game_name = "NetHack 5.0.0 (tty)"
++
+ #  # Short name, used in the watching menu
+-#  short_name = "NHstb"
+-#
++  short_name = "nh500tty"
++
+ #  # arguments for when we exec the binary
+-#  game_args = "/bin/nethackstub",
+-#           "foo",
+-#           "user:%n",
+-#           "shed_uid:%u",
+-#           "bar"
+-#
++  game_args = "/bin/nethackstub", "-u", "%n", "-wtty"
++
+ #  # From inside the jail, where dgamelaunch should put mail.
+-#  spooldir = "/var/mail/"
+-#
++  spooldir = "/mail/"
++
+ #  # From inside the jail, the default .nethackrc that is copied for new users.
+-#  # rc_template = "/dgl-default-rcfile"
+-#
++  rc_template = "/etc/dgl-default-rcfile.nh500"
++# Format for writing users' own RC files
++  rc_fmt = "%ruserdata/%n/%n.nh500rc"
++
++#  # Make sure the inprogress dir actually exists. default is "inprogress/"
++#  # Each game you define here must have it's own.
++  inprogressdir = "%rinprogress-nh500/"
++
++# The place where ttyrecs are stored for this game.
++# If this is not defined, ttyrecs are not saved for this game.
++# Leaving this undefined also means the games cannot be spectated.
++  ttyrecdir = "%ruserdata/%n/ttyrec/"
++
+ #  # If player idles longer than max_idle_time seconds, the game will
+ #  # receive a sighup. Default value is 0, which disables the idling timer.
+ #  max_idle_time = 2000
+@@ -229,57 +239,74 @@
+ #  # will be sorted to appear before lower weights.
+ #  # 
+ #  extra_info_file = "%rgamedir/%n.extrainfo"
+-#
+-#  # Make sure the inprogress dir actually exists. default is "inprogress/"
+-#  # Each game you define here must have it's own.
+-#  inprogressdir = "%rinprogress-nethackstub/"
+-#
++
+ #  # We can also define per-game commands, that are executed
+ #  # when the game starts:
+ #  # commands = chdir "/dgldir", mkdir "foo_%u_%g"
+-#
+-#  # If the game uses an ancient encoding, you may specify "ibm" or "dec".
+-#  # If set to "ask", the game will be run with --print-charset beforehand,
+-#  # expected to return one of these values.
+-#  encoding = "unicode"
+-#}
++  # back up savefile
++  commands = cp "/var/nh500/save/%u%n.gz" "/var/nh500/save/%u%n.gz.bak",
++  # set NETHACKOPTIONS to point to the rcfile
++             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh500rc",
++  # set up nethack mail stuff, assuming it's compiled with it...
++             setenv "MAIL" "/mail/%n",
++             setenv "SIMPLEMAIL" "1",
++  # don't let the mail file grow
++             unlink "/mail/%n"
++}
++# Defining it again for the curses option.
++DEFINE {
++  game_path = "/bin/nh500"
++  game_name = "NetHack 5.0.0 (curses)"
++  short_name = "nh500curses"
++  game_args = "/bin/nethackstub", "-u", "%n", "-wcurses"
++  spooldir = "/mail/"
++  rc_template = "/etc/dgl-default-rcfile.nh500"
++  rc_fmt = "%ruserdata/%n/%n.nh500rc"
++  inprogressdir = "%rinprogress-nh500/"
++  ttyrecdir = "%ruserdata/%n/ttyrec/"
++  commands = cp "/var/nh500/save/%u%n.gz" "/var/nh500/save/%u%n.gz.bak",
++             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh500rc",
++             setenv "MAIL" "/mail/%n",
++             setenv "SIMPLEMAIL" "1",
++             unlink "/mail/%n"
++}
+ #
+ # the second game
+ #
+ #
+-DEFINE {
+-  game_path = "/nh343/nethack"
+-  game_name = "NetHack 3.4.3"
+-  short_name = "NH343"
+-
+-  game_args = "/nh343/nethack", "-u", "%n"
+-
+-  spooldir = "/mail/"
+-  rc_template = "/dgl-default-rcfile.nh343"
+-
+-  rc_fmt = "%ruserdata/%n/%n.nh343rc"
+-
+-  inprogressdir = "%rinprogress-nh343/"
+-
++#DEFINE {
++#  game_path = "/nh343/nethack"
++#  game_name = "NetHack 3.4.3"
++#  short_name = "NH343"
++#
++#  game_args = "/nh343/nethack", "-u", "%n"
++#
++#  spooldir = "/mail/"
++#  rc_template = "/dgl-default-rcfile.nh343"
++#
++#  rc_fmt = "%ruserdata/%n/%n.nh343rc"
++#
++#  inprogressdir = "%rinprogress-nh343/"
++#
+ # The place where ttyrecs are stored for this game.
+ # If this is not defined, ttyrecs are not saved for this game.
+ # Leaving this undefined also means the games cannot be spectated.
+-  ttyrecdir = "%ruserdata/%n/ttyrec/"
+-
+-
++#  ttyrecdir = "%ruserdata/%n/ttyrec/"
++#
++#
+   # back up savefile
+-  commands = cp "/nh343/var/save/%u%n.gz" "/nh343/var/save/%u%n.gz.bak",
++#  commands = cp "/nh343/var/save/%u%n.gz" "/nh343/var/save/%u%n.gz.bak",
+   # set NETHACKOPTIONS to point to the rcfile
+-             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh343rc",
++#             setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh343rc",
+   # set up nethack mail stuff, assuming it's compiled with it...
+-             setenv "MAIL" "/mail/%n",
+-             setenv "SIMPLEMAIL" "1",
++#             setenv "MAIL" "/mail/%n",
++#             setenv "SIMPLEMAIL" "1",
+   # don't let the mail file grow
+-             unlink "/mail/%n"
+-}
++#             unlink "/mail/%n"
++#}
+ #
+ # third game
+diff -urB dgamelaunch.bak/examples/dgl_menu_main_user.txt dgamelaunch.new/examples/dgl_menu_main_user.txt
+--- dgamelaunch.bak/examples/dgl_menu_main_user.txt    2020-03-07 06:27:35.000000000 -0500
++++ dgamelaunch.new/examples/dgl_menu_main_user.txt    2026-05-23 03:21:44.601752899 -0400
+@@ -11,8 +11,10 @@
+  c) Change password
+  e) Change email address
+  w) Watch games in progress
+- o) Edit options
+- p) Play NetHack 3.4.3
++ o) Edit options (Virus)
++ O) Edit options (Nano)
++ p) Play NetHack 5.0.0 (curses)
++ P) Play NetHack 5.0.0 (tty)
+  q) Quit
+  =>
diff --git a/install-dgl-nh500 b/install-dgl-nh500
new file mode 100644 (file)
index 0000000..16e5e34
--- /dev/null
@@ -0,0 +1,336 @@
+#!/bin/bash
+
+# Script for setting up Debian DGL/NetHack 5.0.0 environment
+# (hopefully to also set up DCSS 0.34.1 too)
+#
+# You should run this as root.
+#
+# Should be run in the directory it was shipped in.
+
+## SETTINGS
+
+# Source repositories and checksums.
+# If you change these, know what you're doing!
+NETHACK500=https://www.nethack.org/download/5.0.0/nethack-500-src.tgz
+NETHACKSHA256=2959b7886aac76185b90aea0c9f80d14343f604de0ae96b3dd2a760f7ab3bde9
+DGL=https://github.com/crawl/dgamelaunch/archive/455308b96fa7522c8c9873653401b4e0cf8f71e4.zip
+
+# If this thing ain't working, and you can't figure out why, try disabling
+# the -s flag to make by commenting out this line. It won't fix anything,
+# but there might be some tell-tale warnings or errors.
+QUIETMAKE=1
+
+# If you downloaded NetHack yourself, and have applied dgl-nh500.patch etc,
+# then comment these lines out to skip fetching/patching.
+# Skipping patch step also skips running <nh-src>/sys/unix/setup.sh;
+# so know what you're doing, or look up a guide on installing NetHack!
+
+# Disable if you already have NetHack-5.0.0 source downloaded and uncompressed.
+FETCHNH=1
+# Disable if you don't want to patch linux.500 and config.h to make life easy.
+PATCHNH=1
+# Disable if you already built NetHack-5.0.0 with your preferred settings!
+BUILDNH=1
+# Disable if you don't want NetHack to be installed in DGL's root.
+INSTALLNH=1
+
+# If you got this script already bundled with DGL, this should already be
+# disabled.
+#FETCHDGL=1
+
+# Install nano in chroot/bin
+DGLNANO=1
+
+# Configuration options for DGL.
+# User and group for NetHack and DGL.
+USRGRP="games:games"
+
+# DGL chroot. NetHack is actually installed with prefix '/.', and
+# then moved later; it ultimately lives entirely within the chroot
+# and can't run without it.
+#
+# If you change this here, you will have to change it in <chroot>/etc/dgamelaunch.conf too.
+CHROOT="/opt/dgamelaunch"
+
+# In theory these would help keep dgamelaunch organized within its own environment.
+#
+# Each directory is within the chroot!
+#
+# In practice, I haven't figured out what breaks -- I suspect something to do
+# with the database -- but they must just be left alone.
+#
+#DGLVAR="/dgldir"
+#DGLETC="/."
+#MENUDIR="$DGLETC"
+DGLVAR="/var"
+DGLETC="/etc"
+MENUDIR="$DGLETC/menu"
+
+# The path of the sqlite db for users.
+# If this is left undefined (commented out), DGL will be built
+# without sqlite3. Also, it'll probably not work.
+ SQLITE_DBFILE="$DGLVAR/dgamelaunch.db"
+
+# These are baked into the patch files, so if you change them here,
+# change them there also.
+HACKDIR="/opt/nh500"
+PLAYGROUND="/var/nh500"
+
+# These are set in the NetHack Makefile, and possibly config.h
+# Note: the Makefile only appears after you run:
+# sys/unix/setup.sh sys/unix/hints/linux.500
+# from inside the NetHack source directory.
+COMPRESSBIN="/bin/gzip"
+GREPBIN="/bin/grep"
+
+# DON'T CHANGE THESE
+WORKDIR="`pwd`"
+NETHACKBIN="$HACKDIR/nethack"
+
+################
+# Some functions
+errorexit() {
+  echo "$@" >&2
+  exit 1
+}
+
+stripsl() {
+  echo "${@#/}"
+}
+
+stripsr() {
+  echo "${@%/}"
+}
+
+standdir() {
+  TMP=`stripsl $@`
+  TMP=`stripsr $TMP`
+  TMP=`echo "$TMP" | tr -d "[:space:]"`
+  echo "$TMP"
+}
+
+# findlibs from original dgl-create-chroot
+findlibs()
+{
+  for i in "$@"; do
+    if [ -z "`ldd "$i" | grep 'not a dynamic executable'`" ]; then
+      echo $(ldd "$i" | awk '{ print $3 }' | egrep -v ^'\(')
+      echo $(ldd "$i" | grep 'ld-linux' | awk '{print $1}')
+    fi
+  done
+}
+
+# cpbin refactored out of original dgl-create-chroot
+cpbin()
+{
+  if [ -e "`which $1`" ]; then
+    NEWDIR=`dirname $1`
+    NEWDIR=`standdir $NEWDIR`
+    echo "Copying $1 to `pwd`/$NEWDIR"
+    mkdir -p "$NEWDIR"
+    cp "`which $1`" "$NEWDIR/"
+    LIBS="$LIBS `findlibs $1`"
+  fi
+}
+
+CHROOT=`standdir $CHROOT`
+DGLVAR=`standdir $DGLVAR`
+DGLETC=`standdir $DGLETC`
+MENUDIR=`standdir $MENUDIR`
+SQLITE_DBFILE=`standdir $SQLITE_DBFILE`
+echo "SQLITE_DBFILE: '$SQLITE_DBFILE'"
+HACKDIR=`standdir $HACKDIR`
+PLAYGROUND=`standdir $PLAYGROUND`
+COMPRESSBIN=`standdir $COMPRESSBIN`
+GREPBIN=`standdir $GREPBIN`
+NETHACKBIN=`standdir $NETHACKBIN`
+WORKDIR=`standdir $WORKDIR`
+
+# We'll fetch, patch, build, and install NetHack,
+# then fetch, patch, and build dgamelaunch, then go through the
+# dgl-create-chroot script.
+
+set -e
+if [ -n "$QUIETMAKE" ]; then
+  MAKEFLAGS="-s"
+  AUTOGENFLAGS="-q"
+fi
+###############
+# Fetch, patch, build, install NetHack
+if [ -n "$FETCHNH" ]; then
+  wget ${NETHACK500}
+  expectsum=${NETHACKSHA256}
+  actualsum=`shasum -a256 ./nethack-500-src.tgz | awk '{ print $1 }'`
+  if [ $actualsum != $expectsum ]; then
+      rm ./nethack-500-src.tgz
+      rm dgamelaunch.zip
+      errorexit 2 "NetHack SHA256 sum is WRONG!!! Edit the script with the right source, or the right checksum."
+  fi
+  tar -xf nethack-500-src.tgz
+fi
+if [ -n "$PATCHNH" -o -n "$BUILDNH" -o -n "$INSTALLNH" ]; then
+  cd NetHack-5.0.0
+fi
+if [ -n "$PATCHNH" ]; then
+  patch -p1 --verbose < "/$WORKDIR/dgl-nh500.patch"
+  sys/unix/setup.sh sys/unix/hints/linux.500
+fi
+if [ -n "$BUILDNH" ]; then
+  make $MAKEFLAGS fetch-lua
+  echo "NOTE: btw, don't worry about these git messages. git doesn't matter."
+  make $MAKEFLAGS all
+fi
+if [ -n "$INSTALLNH" ]; then
+  make $MAKEFLAGS install
+fi
+cd "/$WORKDIR"
+
+###################################
+# Patch, build, install dgamelaunch
+if [ -n "$FETCHDGL" ]; then
+  wget -O dgamelaunch.zip ${DGL}
+  unzip -q dgamelaunch.zip
+  dglmess="dgamelaunch-`echo "${DGL}" | awk -F/ '{ print $7 }' | awk -F. '{ print $1 }'`"
+  mv "$dglmess" dgamelaunch
+  cd dgamelaunch
+  patch -p1 --verbose < "/$WORKDIR/dgl.patch"
+fi
+
+autoupdate
+if [ -n "$SQLITE_DBFILE" ]; then
+  AUTOGENFLAGS="$AUTOGENFLAGS --enable-sqlite --with-sqlite-db=/$SQLITE_DBFILE"
+fi
+AUTOGENFLAGS="$AUTOGENFLAGS --enable-debugfile --enable-shmem --with-config-file=/$CHROOT/$DGLETC/dgamelaunch.conf --prefix=/$CHROOT"
+MAKEFLAGS="$MAKEFLAGS CFLAGS+=-Wno-implicit-function-declaration"
+echo "Autogen flags: $AUTOGENFLAGS"
+./autogen.sh $AUTOGENFLAGS
+make $MAKEFLAGS
+
+# note to self: do not cd right here
+
+##### dgl-create-chroot ###########################################
+# Run dgl-create-chroot. Rather than patch the script, just building
+# it into this one...
+#
+# Original dgl-create-chroot by joshk@triplehelix.org
+#       modifications by jilles@stack.nl
+# Subsequent modifications by paxed@alt.org
+# Obtained from crawl team at https://github.com/crawl/dgamelaunch
+#      (along with the rest of dgamelaunch)
+# This version by Skyebe, distributed at random
+
+umask 022
+
+if [ -e "/$CHROOT" ]; then
+   errorexit "Chroot /$CHROOT already exists."
+fi
+
+CURDIR="`pwd`"
+CURDIR="`standdir $CURDIR`"
+
+# Create chroot filesystem hierarchy
+mkdir -p "/$CHROOT" || errorexit "Cannot create chroot."
+
+cd "/$CHROOT"
+
+mkdir -p "$MENUDIR" "$DGLVAR" etc var opt lib mail usr bin dev
+mkdir -p "$DGLVAR/inprogress-nh500"
+mkdir -p "$DGLVAR/userdata"
+
+chown "$USRGRP" "$DGLVAR" mail
+chown "$USRGRP" "./$DGLVAR/inprogress-nh500"
+chown "$USRGRP" "./$DGLVAR/userdata"
+
+# Create randomness device
+cd dev
+mknod urandom c 1 9
+cd "/$CHROOT"
+echo "We just used mknod! :confetti:"
+
+# Copy DGL files to /etc
+cp "/$CURDIR/examples/dgamelaunch.conf" "$DGLETC"
+[ -f /etc/localtime ] && cp /etc/localtime .
+cp "/$CURDIR/examples/dgl_menu_main_anon.txt" "$MENUDIR"
+cp "/$CURDIR/examples/dgl_menu_main_user.txt" "$MENUDIR"
+cp "/$CURDIR/examples/dgl_menu_watchmenu_help.txt" "$MENUDIR"
+cp "/$CURDIR/examples/dgl-banner" "$MENUDIR"
+cp "/$CURDIR/dgl-default-rcfile" "$DGLETC/dgl-default-rcfile.nh500"
+chmod go+r "$MENUDIR/dgl_menu_main_anon.txt" "$MENUDIR/dgl_menu_main_user.txt" "$MENUDIR/dgl-banner" "$DGLETC/dgl-default-rcfile.nh500"
+
+# Copy extraneous binaries to /bin
+cpbin /$COMPRESSBIN
+cpbin /$GREPBIN
+if [ -n "$DGLNANO" ]; then
+  cpbin /bin/nano
+fi
+cp "/$CURDIR/virus" bin
+
+# Copy NetHack and DGL
+if [ -n "$INSTALLNH" ]; then
+  NHBINFILE="`basename /$NETHACKBIN`.`date +%Y%m%d`"
+  LIBS="$LIBS `findlibs /$NETHACKBIN`"
+  LHACKDIR="`echo "$HACKDIR" | awk -F/ 'BEGIN {OFS=FS} {NF-=1; print}'`"
+  LPLAYGROUND="`echo "$PLAYGROUND" | awk -F/ 'BEGIN {OFS=FS} {NF-=1; print}'`"
+  cp -r "/$HACKDIR" "$LHACKDIR"
+  cp "$NETHACKBIN" "$HACKDIR/$NHBINFILE"
+  ln -s "/$HACKDIR/$NHBINFILE" bin/nh500
+  cp -r "/$PLAYGROUND" "$LPLAYGROUND"
+  chown -R "$USRGRP" "$HACKDIR"
+  chown -R "$USRGRP" "$PLAYGROUND"
+fi
+
+DGLFILE="dgamelaunch.`date +%Y%m%d`"
+LIBS="$LIBS `findlibs /$CURDIR/dgamelaunch`"
+cp "/$CURDIR/dgamelaunch" "bin/$DGLFILE"
+ln -s "$DGLFILE" bin/dgamelaunch
+
+# Creating sqlite db
+if [ -n "$SQLITE_DBFILE" ]; then
+  sqlite3 "/$CHROOT/$SQLITE_DBFILE" "create table dglusers (id integer primary key, username text, email text, env text, password text, flags integer);"
+  chown "$USRGRP" "/$CHROOT/$SQLITE_DBFILE"
+fi
+
+# Copying libraries
+LIBS=`for lib in $LIBS; do echo $lib; done | sort | uniq`
+for lib in $LIBS; do
+  mkdir -p "/$CHROOT`dirname $lib`"
+  cp $lib "/$CHROOT$lib"
+done
+
+# Curses junk
+if [ -z "$TERMDATA" ]; then
+    SEARCHTERMDATA="/etc/terminfo /usr/share/lib/terminfo /usr/share/terminfo /lib/terminfo"
+    for dir in $SEARCHTERMDATA; do
+       if [ -e "$dir/x/xterm" ]; then
+           TERMDATA="$TERMDATA $dir"
+       fi
+    done
+    if [ -z "$TERMDATA" ]; then
+       errorexit 1 "Couldn't find terminfo definitions. Please specify in 'TERMDATA' variable."
+    fi
+fi
+if [ -n "$TERMDATA" ]; then
+    echo "Copying termdata files from $TERMDATA"
+    for termdat in $TERMDATA; do
+       mkdir -p "/$CHROOT`dirname $termdat`"
+       if [ -d $termdat/. ]; then
+               cp -LR $termdat/. /$CHROOT$termdat
+       else
+               cp $termdat /$CHROOT`dirname $termdat`
+       fi
+    done
+fi
+
+
+# cleanup
+cd "/$WORKDIR"
+RM_ME="/opt/nh500 /var/nh500 NetHack-5.0.0 dgamelaunch.zip nethack-500-src.tgz"
+if [ -n $INSTALLDGL ]; then
+  RM_ME="$RM_ME dgamelaunch"
+fi
+rm -rf $RM_ME
+
+echo "Finished."
+
+
+