Add --tmp to lorax-composer and set default tempdir

It was using /tmp/ which can fill up quickly when building images.
Default to /var/tmp unless the user passes --tmp /tmp/
This commit is contained in:
Brian C. Lane 2018-05-10 08:53:12 -07:00
parent 9a1dce5619
commit 3c31e52b3c

View File

@ -31,6 +31,7 @@ import pwd
import selinux import selinux
import sys import sys
import subprocess import subprocess
import tempfile
from threading import Lock from threading import Lock
from gevent import socket from gevent import socket
from gevent.wsgi import WSGIServer from gevent.wsgi import WSGIServer
@ -68,6 +69,8 @@ def get_parser():
help="Path to lorax-composer configuration file.") help="Path to lorax-composer configuration file.")
parser.add_argument("--releasever", default=None, metavar="STRING", parser.add_argument("--releasever", default=None, metavar="STRING",
help="Release version to use for $releasever in dnf repository urls") help="Release version to use for $releasever in dnf repository urls")
parser.add_argument("--tmp", default="/var/tmp",
help="Top level temporary directory")
parser.add_argument("BLUEPRINTS", metavar="BLUEPRINTS", parser.add_argument("BLUEPRINTS", metavar="BLUEPRINTS",
help="Path to the blueprints") help="Path to the blueprints")
@ -156,6 +159,7 @@ if __name__ == '__main__':
print(VERSION) print(VERSION)
sys.exit(0) sys.exit(0)
tempfile.tempdir = opts.tmp
logpath = os.path.abspath(os.path.dirname(opts.logfile)) logpath = os.path.abspath(os.path.dirname(opts.logfile))
if not os.path.isdir(logpath): if not os.path.isdir(logpath):
os.makedirs(logpath) os.makedirs(logpath)