A few changes for upcoming build

This commit is contained in:
Neale Pickett 2010-05-15 10:32:13 -06:00
parent 5936814305
commit 6bc361ece4
4 changed files with 80 additions and 52 deletions

114
Makefile
View File

@ -5,24 +5,74 @@ LIB = $(BASE)/lib
BIN = $(BASE)/bin
SBIN = $(BASE)/sbin
BASE_URL = /
USERNAME = www-data
BUILD_DIR = build
TEMPLATE = $(CURDIR)/template.html
MDWNTOHTML = $(CURDIR)/mdwntohtml.py --template=$(TEMPLATE) --base=$(BASE_URL)
default: install
SUBDIRS = mdwn
INSTALL_TARGETS = $(addsuffix -install, $(SUBDIRS))
include $(addsuffix /*.mk, $(SUBDIRS))
TARGETS = tanks puzzles
include $(wildcard */*.mk)
CLEAN_TARGETS = $(addsuffix -clean, $(TARGETS))
INSTALL_TARGETS = $(addsuffix -install, $(TARGETS))
.PHONY: $(CLEAN_TARGETS) $(INSTALL_TARGETS)
install: base-install $(INSTALL_TARGETS)
install --directory --owner=$(USERNAME) $(VAR)/tanks
install --directory --owner=$(USERNAME) $(VAR)/tanks/results
install --directory --owner=$(USERNAME) $(VAR)/tanks/errors
install --directory --owner=$(USERNAME) $(VAR)/tanks/ai
install --directory --owner=$(USERNAME) $(VAR)/tanks/ai/players
install --directory --owner=$(USERNAME) $(VAR)/tanks/ai/house
puzzles:
git submodule update --init
puzzles-build: puzzles
mkdir -p $(BUILD_DIR)/puzzles
$(MAKE) -C puzzles BUILD_DIR=$(abspath $(BUILD_DIR)/puzzles)
puzzles-install: puzzles-build
./mkpuzzles.py --base=$(BASE_URL) --puzzles=$(BUILD_DIR)/puzzles \
--htmldir=$(WWW)/puzzler --keyfile=$(LIB)/puzzler.keys
puzzles-clean:
rm -rf $(BUILD_DIR)/puzzles $(WWW)/puzzler $(LIB)/puzzler.keys
tanks-install:
install --directory $(VAR)/tanks
install --directory $(VAR)/tanks/results
install --directory $(VAR)/tanks/errors
install --directory $(VAR)/tanks/ai
install --directory $(VAR)/tanks/ai/players
install --directory $(VAR)/tanks/ai/house
ln -sf $(VAR)/tanks/results $(WWW)/tanks/results
install bin/run-tanks $(SBIN)
tanks-clean:
rm -rf $(VAR)/tanks
rm -rf $(WWW)/tanks
install: puzzles-install tanks-install $(INSTALL_TARGETS)
install bin/pointscli $(BIN)
install bin/in.pointsd bin/in.flagd \
bin/scoreboard \
bin/run-ctf $(SBIN)
cp -r lib/* $(LIB)
cp -r www/* $(WWW)
cp template.html $(LIB)
install --directory $(VAR)/disabled
python setup.py install --prefix=$(BASE)
$(INSTALL_TARGETS): base-install
base-install:
install --directory $(LIB) $(BIN) $(SBIN)
install --directory $(VAR)
install --directory $(WWW)
install --directory $(WWW)/puzzler
install --directory $(VAR)/points
install --directory $(VAR)/points/tmp
install --directory $(VAR)/points/cur
install --directory $(VAR)/flags
echo 'VAR = "$(VAR)"' > ctf/paths.py
echo 'WWW = "$(WWW)"' >> ctf/paths.py
@ -31,47 +81,11 @@ install: base-install $(INSTALL_TARGETS)
echo 'SBIN = "$(SBIN)"' >> ctf/paths.py
echo 'BASE_URL = "$(BASE_URL)"' >> ctf/paths.py
install bin/pointscli $(BIN)
install bin/in.pointsd bin/in.flagd \
bin/scoreboard bin/run-tanks \
bin/run-ctf $(SBIN)
cp -r lib/* $(LIB)
cp -r www/* $(WWW)
rm -f $(WWW)/tanks/results
ln -s $(VAR)/tanks/results $(WWW)/tanks/results
cp template.html $(LIB)
./mkpuzzles.py --base=$(BASE_URL) --puzzles=puzzles \
--htmldir=$(WWW)/puzzler --keyfile=$(LIB)/puzzler.keys
install --directory $(VAR)/disabled
touch $(VAR)/disabled/bletchley
touch $(VAR)/disabled/compaq
touch $(VAR)/disabled/crypto
touch $(VAR)/disabled/forensics
touch $(VAR)/disabled/hackme
touch $(VAR)/disabled/hispaniola
touch $(VAR)/disabled/net-re
touch $(VAR)/disabled/skynet
touch $(VAR)/disabled/survey
python setup.py install
base-install:
install --directory $(LIB) $(BIN) $(SBIN)
install --directory --owner=$(USERNAME) $(VAR)
install --directory --owner=$(USERNAME) $(WWW)
install --directory --owner=$(USERNAME) $(WWW)/puzzler
install --directory --owner=$(USERNAME) $(VAR)/points
install --directory --owner=$(USERNAME) $(VAR)/points/tmp
install --directory --owner=$(USERNAME) $(VAR)/points/cur
install --directory --owner=$(USERNAME) $(VAR)/flags
uninstall:
rm -rf $(VAR) $(WWW) $(LIB) $(BIN) $(SBIN)
rmdir $(BASE) || true
clean: $(addsuffix -clean, $(SUBDIRS))
clean: $(CLEAN_TARGETS)
$(MAKE) -C puzzles BUILD_DIR=$(abspath $(BUILD_DIR)/puzzles) clean

View File

@ -6,6 +6,8 @@ MDWN_SRC += $(wildcard $(MDWN_DIR)/src/*/*/*.mdwn)
MDWN_OUT = $(subst $(MDWN_DIR)/src/, $(WWW)/, $(MDWN_SRC:.mdwn=.html))
mdwn:
mdwn-install: $(MDWN_OUT)
$(WWW)/%.html: $(MDWN_DIR)/src/%.mdwn
@ -13,4 +15,6 @@ $(WWW)/%.html: $(MDWN_DIR)/src/%.mdwn
$(MDWNTOHTML) $< $@
mdwn-clean:
rm -f $(MDWN_OUT)
rm -f $(MDWN_OUT)
TARGETS += mdwn

View File

@ -5,6 +5,7 @@ import shutil
import optparse
import string
import markdown
import rfc822
from codecs import open
p = optparse.OptionParser()
@ -80,6 +81,15 @@ for cat in os.listdir(opts.puzzles):
keys.append((cat, points, key))
elif fn == 'hint':
pass
elif fn == 'index.exe':
p = os.popen(path)
m = rfc822.Message(p)
for key in m.getallmatchingheaders('Key'):
print key
keys.append((cat, points, key))
readme = m.fp.read()
if m.get('Content-Type', 'text/markdown') == 'text/markdown':
readme = markdown.markdown(readme)
elif fn == 'index.html':
readme = open(path, encoding='utf-8').read()
elif fn == 'index.mdwn':

@ -1 +1 @@
Subproject commit 1a217387a47583773b529cf1dea42fbf6f24cbc9
Subproject commit bc6116f4e2e5ccdd2f2d82e4687ee1f51f2e2a4f