45d93040e7
The instroot module provides the old upd-instroot functionality.
128 lines
4.7 KiB
Python
Executable File
128 lines
4.7 KiB
Python
Executable File
#!/usr/bin/python -tt
|
|
#
|
|
# lorax
|
|
# Install image and tree support data generation tool.
|
|
#
|
|
# Copyright (C) 2008 Red Hat, Inc.
|
|
#
|
|
# 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; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# 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 General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# Author(s): David Cantrell <dcantrell@redhat.com>
|
|
#
|
|
|
|
import getopt
|
|
import os
|
|
import sys
|
|
|
|
import pylorax
|
|
|
|
def usage(prog):
|
|
print("Usage: %s -v VERSION -p PRODUCT -r RELEASE -o PATH REPO\n" % (prog,))
|
|
print("Required arguments:")
|
|
print(" -v, --version=STRING Version identifier.")
|
|
print(" -p, --product=STRING Product name.")
|
|
print(" -r, --release=STRING Release information or comment.\n")
|
|
print(" -o, --output=PATHSPEC Where to write output files.")
|
|
print("Optional arguments:")
|
|
print(" -d, --debug Enable debugging messages.")
|
|
print(" -t, --variant=STRING Variant name.")
|
|
print(" -b, --bugurl=URL Bug reporting URL for the product.")
|
|
print(" -u, --updates=PATHSPEC Path to find updated RPMS.")
|
|
print(" -m, --mirrorlist=REPO Mirror list repo, may be listed multiple times.\n")
|
|
print("A 'REPO' specification is a valid yum repository path.\n")
|
|
print("See the man page lorax(8) for more information.")
|
|
|
|
if __name__ == "__main__":
|
|
prog = os.path.basename(sys.argv[0])
|
|
opts, args, mirrorlist, extrarepos = [], [], [], []
|
|
version, product, release, output, repo = None, None, None, None, None
|
|
debug = False
|
|
variant, updates = '', ''
|
|
bugurl = 'your distribution provided bug reporting tool.'
|
|
|
|
try:
|
|
opts, args = getopt.getopt(sys.argv[1:], "v:p:r:o:dt:b:u:m:V",
|
|
["version=", "product=", "release=",
|
|
"output=", "debug", "variant=",
|
|
"bugurl=", "updates=", "mirrorlist="])
|
|
except getopt.GetoptError:
|
|
usage(prog)
|
|
sys.exit(1)
|
|
|
|
for o, a in opts:
|
|
if o in ('-v', '--version'):
|
|
version = a
|
|
elif o in ('-p', '--product'):
|
|
product = a
|
|
elif o in ('-r', '--release'):
|
|
release = a
|
|
elif o in ('-o', '--output'):
|
|
output = a
|
|
elif o in ('-d', '--debug'):
|
|
debug = True
|
|
elif o in ('-t', '--variant'):
|
|
variant = a
|
|
elif o in ('-b', '--bugurl'):
|
|
bugurl = a
|
|
elif o in ('-u', '--updates'):
|
|
updates = a
|
|
elif o in ('-m', '--mirrorlist'):
|
|
mirrorlist.append(a)
|
|
elif o in ('-V'):
|
|
pylorax.show_version(prog)
|
|
sys.exit(0)
|
|
|
|
if version is None or product is None or release is None or output is None:
|
|
sys.stderr.write("ERROR: Missing a required argument.\n")
|
|
sys.exit(1)
|
|
|
|
if len(args) == 0:
|
|
sys.stderr.write("ERROR: Missing repo to use for image generation.\n")
|
|
sys.exit(1)
|
|
|
|
# collect all repos specified on the command line. the first repo is
|
|
# designated the main repo (I guess)
|
|
repo, extrarepos = pylorax.collectRepos(args)
|
|
|
|
# create directories that we will be using for image generation
|
|
buildinstdir, treedir, cachedir = pylorax.initializeDirs(output)
|
|
|
|
# write out yum.conf used for image generation
|
|
yumconf = pylorax.writeYumConf(cachedir=cachedir, repo=repo, extrarepos=extrarepos, mirrorlist=mirrorlist)
|
|
if yumconf is None:
|
|
sys.stderr.write("ERROR: Could not generate temporary yum.conf file.\n")
|
|
sys.exit(1)
|
|
|
|
buildarch = pylorax.getBuildArch()
|
|
|
|
# upd-instroot
|
|
if not pylorax.instroot.createInstRoot(yumconf=yumconf, arch=buildarch, treedir=treedir, updates=updates):
|
|
sys.stderr.write("ERROR: Could not create inst root.\n")
|
|
sys.exit(1)
|
|
|
|
# write .treeinfo file
|
|
if not pylorax.treeinfo.write(family=product, variant=variant, version=version, arch=buildarch, outdir=output):
|
|
sys.stderr.write("Error writing %s/.treeinfo file.\n" % (output,))
|
|
|
|
# mk-images
|
|
# XXX
|
|
|
|
# write .discinfo file
|
|
if not pylorax.discinfo.write(release=release, arch=buildarch, outdir=output):
|
|
sys.stderr.write("Error writing %s/.discinfo file.\n" % (output,))
|
|
|
|
# clean up
|
|
trash = [yumconf, treedir, buildinstdir]
|
|
pylorax.cleanup(trash)
|