2015-02-10 13:19:34 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2016-09-21 12:49:13 +00:00
|
|
|
# along with this program; if not, see <https://gnu.org/licenses/>.
|
2015-02-10 13:19:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from kobo.shortcuts import force_list
|
2016-03-23 09:40:16 +00:00
|
|
|
from ..util import process_args
|
2015-02-10 13:19:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LoraxWrapper(object):
|
2015-12-03 13:19:15 +00:00
|
|
|
def get_lorax_cmd(self, product, version, release, repo_baseurl, output_dir,
|
|
|
|
variant=None, bugurl=None, nomacboot=False, noupgrade=False,
|
2016-03-23 09:40:16 +00:00
|
|
|
is_final=False, buildarch=None, volid=None, buildinstallpackages=None,
|
|
|
|
add_template=None, add_arch_template=None,
|
2016-11-09 07:50:37 +00:00
|
|
|
add_template_var=None, add_arch_template_var=None,
|
2016-11-17 15:15:03 +00:00
|
|
|
rootfs_size=None,
|
2016-11-09 07:50:37 +00:00
|
|
|
log_dir=None):
|
2015-02-10 13:19:34 +00:00
|
|
|
cmd = ["lorax"]
|
|
|
|
cmd.append("--product=%s" % product)
|
|
|
|
cmd.append("--version=%s" % version)
|
|
|
|
cmd.append("--release=%s" % release)
|
|
|
|
|
|
|
|
for i in force_list(repo_baseurl):
|
|
|
|
if "://" not in i:
|
|
|
|
i = "file://%s" % os.path.abspath(i)
|
|
|
|
cmd.append("--source=%s" % i)
|
|
|
|
|
|
|
|
if variant is not None:
|
|
|
|
cmd.append("--variant=%s" % variant)
|
|
|
|
|
|
|
|
if bugurl is not None:
|
2015-12-03 13:19:15 +00:00
|
|
|
cmd.append("--bugurl=%s" % bugurl)
|
2015-02-10 13:19:34 +00:00
|
|
|
|
|
|
|
if nomacboot:
|
|
|
|
cmd.append("--nomacboot")
|
|
|
|
|
|
|
|
if noupgrade:
|
|
|
|
cmd.append("--noupgrade")
|
|
|
|
|
|
|
|
if is_final:
|
|
|
|
cmd.append("--isfinal")
|
|
|
|
|
|
|
|
if buildarch:
|
|
|
|
cmd.append("--buildarch=%s" % buildarch)
|
|
|
|
|
|
|
|
if volid:
|
|
|
|
cmd.append("--volid=%s" % volid)
|
|
|
|
|
2016-05-25 11:37:39 +00:00
|
|
|
cmd.extend(process_args('--installpkgs=%s', buildinstallpackages))
|
|
|
|
cmd.extend(process_args('--add-template=%s', add_template))
|
|
|
|
cmd.extend(process_args('--add-arch-template=%s', add_arch_template))
|
|
|
|
cmd.extend(process_args('--add-template-var=%s', add_template_var))
|
|
|
|
cmd.extend(process_args('--add-arch-template-var=%s', add_arch_template_var))
|
2015-12-03 13:19:15 +00:00
|
|
|
|
2016-11-09 07:50:37 +00:00
|
|
|
if log_dir:
|
|
|
|
cmd.append('--logfile=%s' % os.path.join(log_dir, 'lorax.log'))
|
|
|
|
|
2016-11-17 15:15:03 +00:00
|
|
|
if rootfs_size is not None:
|
|
|
|
cmd.append('--rootfs-size=%s' % (rootfs_size))
|
|
|
|
|
2015-02-10 13:19:34 +00:00
|
|
|
output_dir = os.path.abspath(output_dir)
|
|
|
|
cmd.append(output_dir)
|
|
|
|
|
|
|
|
# TODO: workdir
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
|
|
|
|
def get_buildinstall_cmd(self, product, version, release, repo_baseurl, output_dir, variant=None, bugurl=None, nomacboot=False, noupgrade=False, is_final=False, buildarch=None, volid=None, brand=None):
|
|
|
|
# RHEL 6 compatibility
|
|
|
|
# Usage: buildinstall [--debug] --version <version> --brand <brand> --product <product> --release <comment> --final [--output outputdir] [--discs <discstring>] <root>
|
|
|
|
|
|
|
|
brand = brand or "redhat"
|
|
|
|
# HACK: ignore provided release
|
|
|
|
release = "%s %s" % (brand, version)
|
|
|
|
bugurl = bugurl or "https://bugzilla.redhat.com"
|
|
|
|
|
|
|
|
cmd = ["/usr/lib/anaconda-runtime/buildinstall"]
|
|
|
|
|
|
|
|
cmd.append("--debug")
|
|
|
|
|
|
|
|
cmd.extend(["--version", version])
|
|
|
|
cmd.extend(["--brand", brand])
|
|
|
|
cmd.extend(["--product", product])
|
|
|
|
cmd.extend(["--release", release])
|
|
|
|
|
|
|
|
if is_final:
|
|
|
|
cmd.append("--final")
|
|
|
|
|
|
|
|
if buildarch:
|
|
|
|
cmd.extend(["--buildarch", buildarch])
|
|
|
|
|
|
|
|
if bugurl:
|
|
|
|
cmd.extend(["--bugurl", bugurl])
|
|
|
|
|
|
|
|
output_dir = os.path.abspath(output_dir)
|
|
|
|
cmd.extend(["--output", output_dir])
|
|
|
|
|
|
|
|
for i in force_list(repo_baseurl):
|
|
|
|
if "://" not in i:
|
|
|
|
i = "file://%s" % os.path.abspath(i)
|
|
|
|
cmd.append(i)
|
|
|
|
|
|
|
|
return cmd
|