aboutsummaryrefslogtreecommitdiffstats
path: root/bin/buildworker-janitor
diff options
context:
space:
mode:
Diffstat (limited to 'bin/buildworker-janitor')
-rwxr-xr-xbin/buildworker-janitor133
1 files changed, 0 insertions, 133 deletions
diff --git a/bin/buildworker-janitor b/bin/buildworker-janitor
deleted file mode 100755
index 3d0bb68e..00000000
--- a/bin/buildworker-janitor
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/usr/bin/python
-'''
-Created on Feb 19, 2014
-
-__author__ = "Richard Purdie"
-__copyright__ = "Copyright 2014, Linux Foundation"
-__credits__ = ["Richard Purdie"]
-__license__ = "GPL"
-__version__ = "2.0"
-__maintainer__ = "Richard Purdie"
-__email__ = "richard.purdie@linuxfoundation.org"
-'''
-
-from __future__ import print_function
-import signal
-import os
-import sys
-import ConfigParser
-import threading
-import time
-
-tmpfile = '/tmp/.buildworker-janitor'+os.getcwd().replace('/', '-')
-
-if len(sys.argv) < 2:
- print("Please specify the path to the config file on the commandline as the first argument")
- sys.exit(1)
-
-config = ConfigParser.ConfigParser()
-config.read(sys.argv[1])
-
-sections = {}
-for section in config.sections():
- sections[section] = dict(config.items(section))
-
-if "GitSettings" not in sections:
- print("There is no GitSettings section in the configuration file?")
- sys.exit(1)
-
-gitsettings = sections["GitSettings"]
-
-if "ogit_trash_dir" not in gitsettings:
- print("Please set OGIT_TRASH_DIR in the configuration file")
- sys.exit(1)
-
-if "ogit_mirror_dir" not in gitsettings:
- print("Please set OGIT_MIRROR_DIR in the configuration file")
- sys.exit(1)
-
-trashdir = gitsettings["ogit_trash_dir"].replace('"','').replace("'",'')
-mirrordir = gitsettings["ogit_mirror_dir"].replace('"','').replace("'",'')
-
-mirrorlist = [
- "git://git.yoctoproject.org/meta-fsl-arm",
- "git://git.yoctoproject.org/meta-fsl-ppc",
- "git://git.yoctoproject.org/meta-intel",
- "git://git.yoctoproject.org/meta-minnow",
- "git://git.yoctoproject.org/meta-qt3",
- "git://git.yoctoproject.org/meta-qt4",
- "git://git.yoctoproject.org/poky",
- "git://git.yoctoproject.org/eclipse-poky-kepler",
- "git://git.yoctoproject.org/eclipse-poky-juno"
-]
-
-def trash_processor(trashdir):
- print("Monitoring trashdir %s" % trashdir)
- if not os.path.exists(trashdir):
- os.makedirs(trashdir)
- if trashdir == "/":
- print("Not prepared to use a trashdir of /")
- return
- while True:
- try:
- files = os.listdir(trashdir)
- if files:
- os.system("ionice -c 3 rm %s/* -rf" % trashdir)
- else:
- time.sleep(120*60) # 30 minutes
- except Exception as e:
- print("Exception %s in trash cleaner" % str(e))
- time.sleep(60) # 1 minute timeout to prevent crazy looping
- pass
- return
-
-def mirror_processor(mirrordir):
- print("Updating mirrors in %s" % mirrordir)
- mirrorpaths = []
- for mirror in mirrorlist:
- mirrorpaths.append(os.path.join(mirrordir, mirror.split("/")[2], mirror.split("/", 3)[3]))
- if not os.path.exists(mirrorpaths[-1] + "/.git/"):
- os.system("git clone %s %s" % (mirror, mirrorpaths[-1]))
- while True:
- for path in mirrorpaths:
- os.chdir(path)
- os.system("git fetch --prune --all")
- time.sleep(30*60) # 30 minutes
- return
-
-#Check to see if this is running already. If so, kill it and rerun
-if os.path.exists(tmpfile) and os.path.isfile(tmpfile):
- print("A prior PID file exists. Attempting to kill.")
- with open(tmpfile, 'r') as f:
- pid=f.readline()
- try:
- os.kill(int(pid), signal.SIGKILL)
- # We need to sleep for a second or two just to give the SIGKILL time
- time.sleep(2)
- except OSError as ex:
- print("""We weren't able to kill the prior buildworker-janitor. Trying again.""")
- pass
- # Check if the process that we killed is alive.
- try:
- os.kill(int(pid), 0)
- except OSError as ex:
- pass
-elif os.path.exists(tmpfile) and not os.path.isfile(tmpfile):
- raise Exception("""/tmp/.buildworker-janitor is a director. remove it to continue.""")
-try:
- os.unlink(tmpfile)
-except:
- pass
-with open(tmpfile, 'w') as f:
- print(os.getpid(), file=f)
-
-threads = []
-threads.append(threading.Thread(target=trash_processor, args=(trashdir,)))
-threads[-1].start()
-threads.append(threading.Thread(target=mirror_processor, args=(mirrordir,)))
-threads[-1].start()
-
-# wait for all threads to finish
-for t in threads:
- t.join()
-sys.exit(0)