Add support for --repo to read yum .repo files directly (#1430479)
This makes it easier to specify existing repos with extra args, eg. /etc/yum.repos.d/redhat.repo generated by subscription-manager. Resolves: rhbz#1430479
This commit is contained in:
parent
81d534670b
commit
487618314c
10
docs/lorax.1
10
docs/lorax.1
@ -3,7 +3,7 @@
|
|||||||
lorax \- Create installer boot iso
|
lorax \- Create installer boot iso
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
lorax -p PRODUCT -v VERSION -r RELEASE -s REPOSITORY OUTPUTDIR
|
lorax -p PRODUCT -v VERSION -r RELEASE [-s REPOSITORY|--repo CONFIG] OUTPUTDIR
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
|
||||||
@ -37,6 +37,10 @@ release information
|
|||||||
\fB\-s REPOSITORY, \-\-source=REPOSITORY\fR
|
\fB\-s REPOSITORY, \-\-source=REPOSITORY\fR
|
||||||
source repository (may be listed multiple times)
|
source repository (may be listed multiple times)
|
||||||
|
|
||||||
|
.TP
|
||||||
|
\fB\--repo CONFIG\fR
|
||||||
|
repository configuration file (may be listed multiple times)
|
||||||
|
|
||||||
.SH
|
.SH
|
||||||
OPTIONAL ARGUMENTS:
|
OPTIONAL ARGUMENTS:
|
||||||
|
|
||||||
@ -89,6 +93,10 @@ Path to logfile
|
|||||||
\fB\-\-tmp=TMP\fR
|
\fB\-\-tmp=TMP\fR
|
||||||
Top level temporary directory
|
Top level temporary directory
|
||||||
|
|
||||||
|
.TP
|
||||||
|
\fB\-\-noverifyssl\fR
|
||||||
|
This disables SSL certificate checking. eg. to allow using https: sources with self-signed certificates.
|
||||||
|
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
.nf
|
.nf
|
||||||
Martin Gracik
|
Martin Gracik
|
||||||
|
@ -31,6 +31,7 @@ yum_log = logging.getLogger("yum")
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
@ -99,6 +100,9 @@ def main(args):
|
|||||||
required.add_option("-s", "--source",
|
required.add_option("-s", "--source",
|
||||||
help="source repository (may be listed multiple times)",
|
help="source repository (may be listed multiple times)",
|
||||||
metavar="REPOSITORY", action="append", default=[])
|
metavar="REPOSITORY", action="append", default=[])
|
||||||
|
required.add_option("--repo",
|
||||||
|
help="source yum repository file",
|
||||||
|
dest="repo_files", metavar="REPOSITORY", action="append", default=[])
|
||||||
|
|
||||||
# optional arguments
|
# optional arguments
|
||||||
optional = OptionGroup(parser, "optional arguments")
|
optional = OptionGroup(parser, "optional arguments")
|
||||||
@ -173,7 +177,7 @@ def main(args):
|
|||||||
|
|
||||||
# check for the required arguments
|
# check for the required arguments
|
||||||
if not opts.product or not opts.version or not opts.release \
|
if not opts.product or not opts.version or not opts.release \
|
||||||
or not opts.source or not outputdir:
|
or not (opts.source or opts.repo_files) or not outputdir:
|
||||||
parser.error("missing one or more required arguments")
|
parser.error("missing one or more required arguments")
|
||||||
|
|
||||||
if os.path.exists(outputdir):
|
if os.path.exists(outputdir):
|
||||||
@ -198,6 +202,7 @@ def main(args):
|
|||||||
os.mkdir(yumtempdir)
|
os.mkdir(yumtempdir)
|
||||||
|
|
||||||
yb = get_yum_base_object(installtree, opts.source, opts.mirrorlist,
|
yb = get_yum_base_object(installtree, opts.source, opts.mirrorlist,
|
||||||
|
opts.repo_files,
|
||||||
yumtempdir, opts.proxy, opts.excludepkgs,
|
yumtempdir, opts.proxy, opts.excludepkgs,
|
||||||
not opts.noverifyssl)
|
not opts.noverifyssl)
|
||||||
|
|
||||||
@ -235,7 +240,7 @@ def main(args):
|
|||||||
remove_temp=True)
|
remove_temp=True)
|
||||||
|
|
||||||
|
|
||||||
def get_yum_base_object(installroot, repositories, mirrorlists=[],
|
def get_yum_base_object(installroot, repositories, mirrorlists=[], repo_files=[],
|
||||||
tempdir="/var/tmp", proxy=None, excludepkgs=[],
|
tempdir="/var/tmp", proxy=None, excludepkgs=[],
|
||||||
sslverify=True):
|
sslverify=True):
|
||||||
|
|
||||||
@ -285,13 +290,15 @@ def get_yum_base_object(installroot, repositories, mirrorlists=[],
|
|||||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||||
|
|
||||||
# add the main repository - the first repository from list
|
# add the main repository - the first repository from list
|
||||||
section = "lorax-repo"
|
# This list may be empty if using --repo to load .repo files
|
||||||
data = {"name": "lorax repo",
|
if repositories:
|
||||||
"baseurl": repositories[0],
|
section = "lorax-repo"
|
||||||
"enabled": 1}
|
data = {"name": "lorax repo",
|
||||||
|
"baseurl": repositories[0],
|
||||||
|
"enabled": 1}
|
||||||
|
|
||||||
c.add_section(section)
|
c.add_section(section)
|
||||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||||
|
|
||||||
# add the extra repositories
|
# add the extra repositories
|
||||||
for n, extra in enumerate(repositories[1:], start=1):
|
for n, extra in enumerate(repositories[1:], start=1):
|
||||||
@ -330,6 +337,11 @@ def get_yum_base_object(installroot, repositories, mirrorlists=[],
|
|||||||
yb.logger.setLevel(logging.DEBUG)
|
yb.logger.setLevel(logging.DEBUG)
|
||||||
yb.verbose_logger.setLevel(logging.DEBUG)
|
yb.verbose_logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
# Add .repo files from the cmdline
|
||||||
|
for fn in repo_files:
|
||||||
|
if os.path.exists(fn):
|
||||||
|
yb.getReposFromConfigFile(fn)
|
||||||
|
|
||||||
return yb
|
return yb
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user