-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.setup
77 lines (67 loc) · 3.83 KB
/
Makefile.setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
BASEDIR ?= $(shell pwd)
VIRTUALENV ?= virtualenv
PYTHON ?= /tools/python/bin/python
PIP_PACKAGES_FILE ?= master-pip.txt
HG ?= hg
HG_HOST = http://hg.mozilla.org
HG_DIR = build
MASTER_NAME = $(error MASTER_NAME must be defined (see setup-master.py -l for a list))
DATABASE = tm-b01-master01.mozilla.org/buildbot
MYSQL_CONFIG = $(HOME)/.$(MASTER_NAME)_update_from_files.conf
CRONTAB = /etc/cron.d/$(MASTER_NAME)
VIRTUALENV_PYTHON = $(BASEDIR)/bin/python
PIP = $(BASEDIR)/bin/pip
BUILDBOT = $(BASEDIR)/bin/buildbot
USER = cltbld
HOME = /home/$(USER)
BUILDBOT_BRANCH = production-0.8
BUILDBOTCUSTOM_BRANCH = production-0.8
BUILDBOTCONFIGS_BRANCH = production
INSTALL_BUILDBOT_SLAVE=
ifdef MASTERS_JSON
SETUP_MASTER=setup-master.py -j $(MASTERS_JSON)
else
SETUP_MASTER=setup-master.py -8
endif
all: virtualenv deps install-buildbot master master-makefile other-files done
done:
@echo
@echo
@echo You probably want to update at least the following files to contain accurate passwords/descriptions:
@echo BuildSlaves.py, passwords.py, $(MYSQL_CONFIG)
@echo You should also run the "cron" target as root, with the same variables set.
virtualenv:
$(VIRTUALENV) --distribute --no-site-packages -p $(PYTHON) $(BASEDIR)
deps:
$(PIP) install $(PIP_FLAGS) -r $(PIP_PACKAGES_FILE)
# HACK ALERT: This only works when there's only one python version in "lib".
# This is generally true when using virtualenvs.
install-buildbot: SITE_PACKAGES = $(BASEDIR)/lib/$(shell ls $(BASEDIR)/lib/)/site-packages
install-buildbot:
test -d $(BASEDIR)/buildbot || $(HG) clone -b $(BUILDBOT_BRANCH) $(HG_HOST)/$(HG_DIR)/buildbot $(BASEDIR)/buildbot
(cd $(BASEDIR)/buildbot/master; $(VIRTUALENV_PYTHON) setup.py develop install)
ifdef INSTALL_BUILDBOT_SLAVE
(cd $(BASEDIR)/buildbot/slave; $(VIRTUALENV_PYTHON) setup.py develop install)
endif
test -d $(BASEDIR)/buildbotcustom || $(HG) clone -b $(BUILDBOTCUSTOM_BRANCH) $(HG_HOST)/$(HG_DIR)/buildbotcustom $(BASEDIR)/buildbotcustom
test -d $(BASEDIR)/buildbot-configs || $(HG) clone -b $(BUILDBOTCONFIGS_BRANCH) $(HG_HOST)/$(HG_DIR)/buildbot-configs $(BASEDIR)/buildbot-configs
test -d $(BASEDIR)/tools || $(HG) clone $(HG_HOST)/$(HG_DIR)/tools $(BASEDIR)/tools
# Get buildbotcustom and the build/tools library into PYTHONPATH
ln -sf $(BASEDIR)/buildbotcustom $(SITE_PACKAGES)/buildbotcustom
echo "$(BASEDIR)/tools/lib/python" > $(SITE_PACKAGES)/build-tools-lib.pth
master:
(cd $(BASEDIR)/buildbot-configs; $(VIRTUALENV_PYTHON) $(SETUP_MASTER) -b $(BUILDBOT) $(BASEDIR)/master $(MASTER_NAME))
master-makefile:
cp $(BASEDIR)/buildbot-configs/Makefile.master $(BASEDIR)/Makefile
other-files:
echo "[DEFAULT]" > $(MYSQL_CONFIG)
echo "database = mysql://buildbot:password@$(DATABASE)" >> $(MYSQL_CONFIG)
echo "master = http://this-master:port" >> $(MYSQL_CONFIG)
echo "name = $(MASTER_NAME)" >> $(MYSQL_CONFIG)
cron:
echo "[email protected]" > $(CRONTAB)
echo "@hourly cltbld (source $(HOME)/.bash_profile && $(VIRTUALENV_PYTHON) $(BASEDIR)/tools/buildfarm/maintenance/watch_twistd_log.py -t .$(MASTER_NAME)-last-time.txt -n $(MASTER_NAME) -f cltbld@`hostname --fqdn` -e [email protected] $(BASEDIR)/master)" >> $(CRONTAB)
echo "15 * * * * cltbld lockfile -60 -r 3 $(HOME)/lockfile.$(MASTER_NAME)_cleanup 2>/dev/null && (source $(HOME)/.bash_profile && nice -n 19 $(VIRTUALENV_PYTHON) $(BASEDIR)/tools/buildfarm/maintenance/master_cleanup.py -t4 $(BASEDIR)/master ; rm -f $(HOME)/lockfile.$(MASTER_NAME)_cleanup) >> cleanup.log 2>&1" >> $(CRONTAB)
echo "*/2 * * * * cltbld lockfile -20 -r 3 $(HOME)/lockfile.bbdb 2>/dev/null && (source $(HOME)/.bash_profile && cd $(BASEDIR)/master; time nice $(VIRTUALENV_PYTHON) $(BASEDIR)/buildbotcustom/bin/update_from_files.py -c $(MYSQL_CONFIG) . ; rm -f $(HOME)/lockfile.bbdb ) >> update.log 2>&1" >> $(CRONTAB)
echo "@hourly cltbld find $(HOME) -name lockfile.bbdb -mmin +360 -delete" >> $(CRONTAB)
chmod 644 $(CRONTAB)