mirror of https://github.com/dirtbags/moth.git
A few changes for upcoming build
This commit is contained in:
parent
5936814305
commit
6bc361ece4
114
Makefile
114
Makefile
|
@ -5,24 +5,74 @@ LIB = $(BASE)/lib
|
||||||
BIN = $(BASE)/bin
|
BIN = $(BASE)/bin
|
||||||
SBIN = $(BASE)/sbin
|
SBIN = $(BASE)/sbin
|
||||||
BASE_URL = /
|
BASE_URL = /
|
||||||
USERNAME = www-data
|
|
||||||
|
BUILD_DIR = build
|
||||||
|
|
||||||
TEMPLATE = $(CURDIR)/template.html
|
TEMPLATE = $(CURDIR)/template.html
|
||||||
MDWNTOHTML = $(CURDIR)/mdwntohtml.py --template=$(TEMPLATE) --base=$(BASE_URL)
|
MDWNTOHTML = $(CURDIR)/mdwntohtml.py --template=$(TEMPLATE) --base=$(BASE_URL)
|
||||||
|
|
||||||
default: install
|
default: install
|
||||||
|
|
||||||
SUBDIRS = mdwn
|
TARGETS = tanks puzzles
|
||||||
INSTALL_TARGETS = $(addsuffix -install, $(SUBDIRS))
|
include $(wildcard */*.mk)
|
||||||
include $(addsuffix /*.mk, $(SUBDIRS))
|
CLEAN_TARGETS = $(addsuffix -clean, $(TARGETS))
|
||||||
|
INSTALL_TARGETS = $(addsuffix -install, $(TARGETS))
|
||||||
|
.PHONY: $(CLEAN_TARGETS) $(INSTALL_TARGETS)
|
||||||
|
|
||||||
install: base-install $(INSTALL_TARGETS)
|
puzzles:
|
||||||
install --directory --owner=$(USERNAME) $(VAR)/tanks
|
git submodule update --init
|
||||||
install --directory --owner=$(USERNAME) $(VAR)/tanks/results
|
|
||||||
install --directory --owner=$(USERNAME) $(VAR)/tanks/errors
|
puzzles-build: puzzles
|
||||||
install --directory --owner=$(USERNAME) $(VAR)/tanks/ai
|
mkdir -p $(BUILD_DIR)/puzzles
|
||||||
install --directory --owner=$(USERNAME) $(VAR)/tanks/ai/players
|
$(MAKE) -C puzzles BUILD_DIR=$(abspath $(BUILD_DIR)/puzzles)
|
||||||
install --directory --owner=$(USERNAME) $(VAR)/tanks/ai/house
|
|
||||||
|
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 'VAR = "$(VAR)"' > ctf/paths.py
|
||||||
echo 'WWW = "$(WWW)"' >> 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 'SBIN = "$(SBIN)"' >> ctf/paths.py
|
||||||
echo 'BASE_URL = "$(BASE_URL)"' >> 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:
|
uninstall:
|
||||||
rm -rf $(VAR) $(WWW) $(LIB) $(BIN) $(SBIN)
|
rm -rf $(VAR) $(WWW) $(LIB) $(BIN) $(SBIN)
|
||||||
rmdir $(BASE) || true
|
rmdir $(BASE) || true
|
||||||
|
|
||||||
|
|
||||||
clean: $(addsuffix -clean, $(SUBDIRS))
|
clean: $(CLEAN_TARGETS)
|
||||||
|
$(MAKE) -C puzzles BUILD_DIR=$(abspath $(BUILD_DIR)/puzzles) clean
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ MDWN_SRC += $(wildcard $(MDWN_DIR)/src/*/*/*.mdwn)
|
||||||
|
|
||||||
MDWN_OUT = $(subst $(MDWN_DIR)/src/, $(WWW)/, $(MDWN_SRC:.mdwn=.html))
|
MDWN_OUT = $(subst $(MDWN_DIR)/src/, $(WWW)/, $(MDWN_SRC:.mdwn=.html))
|
||||||
|
|
||||||
|
mdwn:
|
||||||
|
|
||||||
mdwn-install: $(MDWN_OUT)
|
mdwn-install: $(MDWN_OUT)
|
||||||
|
|
||||||
$(WWW)/%.html: $(MDWN_DIR)/src/%.mdwn
|
$(WWW)/%.html: $(MDWN_DIR)/src/%.mdwn
|
||||||
|
@ -13,4 +15,6 @@ $(WWW)/%.html: $(MDWN_DIR)/src/%.mdwn
|
||||||
$(MDWNTOHTML) $< $@
|
$(MDWNTOHTML) $< $@
|
||||||
|
|
||||||
mdwn-clean:
|
mdwn-clean:
|
||||||
rm -f $(MDWN_OUT)
|
rm -f $(MDWN_OUT)
|
||||||
|
|
||||||
|
TARGETS += mdwn
|
||||||
|
|
10
mkpuzzles.py
10
mkpuzzles.py
|
@ -5,6 +5,7 @@ import shutil
|
||||||
import optparse
|
import optparse
|
||||||
import string
|
import string
|
||||||
import markdown
|
import markdown
|
||||||
|
import rfc822
|
||||||
from codecs import open
|
from codecs import open
|
||||||
|
|
||||||
p = optparse.OptionParser()
|
p = optparse.OptionParser()
|
||||||
|
@ -80,6 +81,15 @@ for cat in os.listdir(opts.puzzles):
|
||||||
keys.append((cat, points, key))
|
keys.append((cat, points, key))
|
||||||
elif fn == 'hint':
|
elif fn == 'hint':
|
||||||
pass
|
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':
|
elif fn == 'index.html':
|
||||||
readme = open(path, encoding='utf-8').read()
|
readme = open(path, encoding='utf-8').read()
|
||||||
elif fn == 'index.mdwn':
|
elif fn == 'index.mdwn':
|
||||||
|
|
2
puzzles
2
puzzles
|
@ -1 +1 @@
|
||||||
Subproject commit 1a217387a47583773b529cf1dea42fbf6f24cbc9
|
Subproject commit bc6116f4e2e5ccdd2f2d82e4687ee1f51f2e2a4f
|
Loading…
Reference in New Issue