2015-05-11 23:44:09 +00:00
<!DOCTYPE html>
<!-- [if IE 8]><html class="no - js lt - ie9" lang="en" > <![endif] -->
<!-- [if gt IE 8]><! --> < html class = "no-js" lang = "en" > <!-- <![endif] -->
< head >
< meta charset = "utf-8" >
2015-07-10 18:39:39 +00:00
2015-05-11 23:44:09 +00:00
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
2015-12-04 18:12:19 +00:00
< title > pylorax.treebuilder — Lorax 24.6 documentation< / title >
2015-05-11 23:44:09 +00:00
< link rel = "stylesheet" href = "../../_static/css/theme.css" type = "text/css" / >
2015-12-04 18:12:19 +00:00
< link rel = "top" title = "Lorax 24.6 documentation" href = "../../index.html" / >
2015-05-11 23:44:09 +00:00
< link rel = "up" title = "pylorax" href = "../pylorax.html" / >
2015-07-10 18:39:39 +00:00
< script src = "_static/js/modernizr.min.js" > < / script >
2015-05-11 23:44:09 +00:00
< / head >
< body class = "wy-body-for-nav" role = "document" >
< div class = "wy-grid-for-nav" >
< nav data-toggle = "wy-nav-shift" class = "wy-nav-side" >
< div class = "wy-side-nav-search" >
2015-07-10 18:39:39 +00:00
< a href = "../../index.html" class = "icon icon-home" > Lorax
2015-05-11 23:44:09 +00:00
2015-07-10 18:39:39 +00:00
< / a >
2015-05-11 23:44:09 +00:00
< div role = "search" >
< form id = "rtd-search-form" class = "wy-form" action = "../../search.html" method = "get" >
< input type = "text" name = "q" placeholder = "Search docs" / >
< input type = "hidden" name = "check_keywords" value = "yes" / >
< input type = "hidden" name = "area" value = "default" / >
< / form >
< / div >
2015-07-10 18:39:39 +00:00
2015-05-11 23:44:09 +00:00
< / div >
< div class = "wy-menu wy-menu-vertical" data-spy = "affix" role = "navigation" aria-label = "main navigation" >
< ul >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../intro.html" > Introduction to Lorax< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../intro.html#before-lorax" > Before Lorax< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../lorax.html" > lorax< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../livemedia-creator.html" > livemedia-creator< / a > < ul >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#quickstart" > Quickstart< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#how-iso-creation-works" > How ISO creation works< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#kickstarts" > Kickstarts< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#anaconda-image-install-no-virt" > Anaconda image install (no-virt)< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#ami-images" > AMI Images< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#appliance-creation" > Appliance Creation< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#filesystem-image-creation" > Filesystem Image Creation< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#tar-file-creation" > TAR File Creation< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#live-image-for-pxe-boot" > Live Image for PXE Boot< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#atomic-live-image-for-pxe-boot" > Atomic Live Image for PXE Boot< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#using-mock-to-create-images" > Using Mock to Create Images< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#openstack-image-creation" > OpenStack Image Creation< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#docker-image-creation" > Docker Image Creation< / a > < / li >
2015-12-04 18:12:19 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#open-container-initiative-image-creation" > Open Container Initiative Image Creation< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#vagrant-image-creation" > Vagrant Image Creation< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#creating-uefi-disk-images-with-virt" > Creating UEFI disk images with virt< / a > < / li >
2015-05-11 23:44:09 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#debugging-problems" > Debugging problems< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "../../livemedia-creator.html#hacking" > Hacking< / a > < / li >
< / ul >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../product-images.html" > Product and Updates Images< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../modules.html" > pylorax< / a > < ul >
2015-07-10 18:39:39 +00:00
< li class = "toctree-l2" > < a class = "reference internal" href = "../../pylorax.html" > pylorax package< / a > < ul >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#submodules" > Submodules< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.base" > pylorax.base module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.buildstamp" > pylorax.buildstamp module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.decorators" > pylorax.decorators module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.discinfo" > pylorax.discinfo module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.dnfhelper" > pylorax.dnfhelper module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.executils" > pylorax.executils module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.imgutils" > pylorax.imgutils module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.ltmpl" > pylorax.ltmpl module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.monitor" > pylorax.monitor module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.mount" > pylorax.mount module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.output" > pylorax.output module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.sysutils" > pylorax.sysutils module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.treebuilder" > pylorax.treebuilder module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax.treeinfo" > pylorax.treeinfo module< / a > < / li >
< li class = "toctree-l3" > < a class = "reference internal" href = "../../pylorax.html#module-pylorax" > Module contents< / a > < / li >
< / ul >
< / li >
2015-05-11 23:44:09 +00:00
< / ul >
< / li >
< / ul >
< / div >
< / nav >
< section data-toggle = "wy-nav-shift" class = "wy-nav-content-wrap" >
< nav class = "wy-nav-top" role = "navigation" aria-label = "top navigation" >
< i data-toggle = "wy-nav-top" class = "fa fa-bars" > < / i >
< a href = "../../index.html" > Lorax< / a >
< / nav >
< div class = "wy-nav-content" >
< div class = "rst-content" >
< div role = "navigation" aria-label = "breadcrumbs navigation" >
< ul class = "wy-breadcrumbs" >
< li > < a href = "../../index.html" > Docs< / a > » < / li >
< li > < a href = "../index.html" > Module code< / a > » < / li >
< li > < a href = "../pylorax.html" > pylorax< / a > » < / li >
< li > pylorax.treebuilder< / li >
< li class = "wy-breadcrumbs-aside" >
2015-07-10 18:39:39 +00:00
2015-05-11 23:44:09 +00:00
< / li >
< / ul >
< hr / >
< / div >
< div role = "main" class = "document" >
< h1 > Source code for pylorax.treebuilder< / h1 > < div class = "highlight" > < pre >
< span class = "c" > # treebuilder.py - handle arch-specific tree building stuff using templates< / span >
< span class = "c" > #< / span >
< span class = "c" > # Copyright (C) 2011-2015 Red Hat, Inc.< / span >
< span class = "c" > #< / span >
< span class = "c" > # This program is free software; you can redistribute it and/or modify< / span >
< span class = "c" > # it under the terms of the GNU General Public License as published by< / span >
< span class = "c" > # the Free Software Foundation; either version 2 of the License, or< / span >
< span class = "c" > # (at your option) any later version.< / span >
< span class = "c" > #< / span >
< span class = "c" > # This program is distributed in the hope that it will be useful,< / span >
< span class = "c" > # but WITHOUT ANY WARRANTY; without even the implied warranty of< / span >
< span class = "c" > # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the< / span >
< span class = "c" > # GNU General Public License for more details.< / span >
< span class = "c" > #< / span >
< span class = "c" > # You should have received a copy of the GNU General Public License< / span >
< span class = "c" > # along with this program. If not, see < http://www.gnu.org/licenses/> .< / span >
< span class = "c" > #< / span >
< span class = "c" > # Author(s): Will Woods < wwoods@redhat.com> < / span >
< span class = "kn" > import< / span > < span class = "nn" > logging< / span >
< span class = "n" > logger< / span > < span class = "o" > =< / span > < span class = "n" > logging< / span > < span class = "o" > .< / span > < span class = "n" > getLogger< / span > < span class = "p" > (< / span > < span class = "s" > " pylorax.treebuilder" < / span > < span class = "p" > )< / span >
< span class = "kn" > import< / span > < span class = "nn" > os< / span > < span class = "o" > ,< / span > < span class = "nn" > re< / span >
< span class = "kn" > from< / span > < span class = "nn" > os.path< / span > < span class = "kn" > import< / span > < span class = "n" > basename< / span >
< span class = "kn" > from< / span > < span class = "nn" > shutil< / span > < span class = "kn" > import< / span > < span class = "n" > copytree< / span > < span class = "p" > ,< / span > < span class = "n" > copy2< / span >
2015-08-25 22:51:32 +00:00
< span class = "kn" > from< / span > < span class = "nn" > pathlib< / span > < span class = "kn" > import< / span > < span class = "n" > Path< / span >
< span class = "kn" > import< / span > < span class = "nn" > itertools< / span >
2015-05-11 23:44:09 +00:00
< span class = "kn" > from< / span > < span class = "nn" > pylorax.sysutils< / span > < span class = "kn" > import< / span > < span class = "n" > joinpaths< / span > < span class = "p" > ,< / span > < span class = "n" > remove< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.base< / span > < span class = "kn" > import< / span > < span class = "n" > DataHolder< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.ltmpl< / span > < span class = "kn" > import< / span > < span class = "n" > LoraxTemplateRunner< / span >
< span class = "kn" > import< / span > < span class = "nn" > pylorax.imgutils< / span > < span class = "kn" > as< / span > < span class = "nn" > imgutils< / span >
2015-08-25 22:51:32 +00:00
< span class = "kn" > from< / span > < span class = "nn" > pylorax.executils< / span > < span class = "kn" > import< / span > < span class = "n" > runcmd< / span > < span class = "p" > ,< / span > < span class = "n" > runcmd_output< / span > < span class = "p" > ,< / span > < span class = "n" > execWithCapture< / span >
2015-05-11 23:44:09 +00:00
< span class = "n" > templatemap< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< span class = "s" > ' i386' < / span > < span class = "p" > :< / span > < span class = "s" > ' x86.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "s" > ' x86_64' < / span > < span class = "p" > :< / span > < span class = "s" > ' x86.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "s" > ' ppc' < / span > < span class = "p" > :< / span > < span class = "s" > ' ppc.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "s" > ' ppc64' < / span > < span class = "p" > :< / span > < span class = "s" > ' ppc.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "s" > ' ppc64le' < / span > < span class = "p" > :< / span > < span class = "s" > ' ppc64le.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "s" > ' s390' < / span > < span class = "p" > :< / span > < span class = "s" > ' s390.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "s" > ' s390x' < / span > < span class = "p" > :< / span > < span class = "s" > ' s390.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "s" > ' aarch64' < / span > < span class = "p" > :< / span > < span class = "s" > ' aarch64.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "s" > ' arm' < / span > < span class = "p" > :< / span > < span class = "s" > ' arm.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "s" > ' armhfp' < / span > < span class = "p" > :< / span > < span class = "s" > ' arm.tmpl' < / span > < span class = "p" > ,< / span >
< span class = "p" > }< / span >
< div class = "viewcode-block" id = "generate_module_info" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.generate_module_info" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > generate_module_info< / span > < span class = "p" > (< / span > < span class = "n" > moddir< / span > < span class = "p" > ,< / span > < span class = "n" > outfile< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
< span class = "k" > def< / span > < span class = "nf" > module_desc< / span > < span class = "p" > (< / span > < span class = "n" > mod< / span > < span class = "p" > ):< / span >
< span class = "n" > output< / span > < span class = "o" > =< / span > < span class = "n" > runcmd_output< / span > < span class = "p" > ([< / span > < span class = "s" > " modinfo" < / span > < span class = "p" > ,< / span > < span class = "s" > " -F" < / span > < span class = "p" > ,< / span > < span class = "s" > " description" < / span > < span class = "p" > ,< / span > < span class = "n" > mod< / span > < span class = "p" > ])< / span >
< span class = "k" > return< / span > < span class = "n" > output< / span > < span class = "o" > .< / span > < span class = "n" > strip< / span > < span class = "p" > ()< / span >
< span class = "k" > def< / span > < span class = "nf" > read_module_set< / span > < span class = "p" > (< / span > < span class = "n" > name< / span > < span class = "p" > ):< / span >
< span class = "k" > return< / span > < span class = "nb" > set< / span > < span class = "p" > (< / span > < span class = "n" > l< / span > < span class = "o" > .< / span > < span class = "n" > strip< / span > < span class = "p" > ()< / span > < span class = "k" > for< / span > < span class = "n" > l< / span > < span class = "ow" > in< / span > < span class = "nb" > open< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > moddir< / span > < span class = "p" > ,< / span > < span class = "n" > name< / span > < span class = "p" > ))< / span > < span class = "k" > if< / span > < span class = "s" > " .ko" < / span > < span class = "ow" > in< / span > < span class = "n" > l< / span > < span class = "p" > )< / span >
< span class = "n" > modsets< / span > < span class = "o" > =< / span > < span class = "p" > {< / span > < span class = "s" > ' scsi' < / span > < span class = "p" > :< / span > < span class = "n" > read_module_set< / span > < span class = "p" > (< / span > < span class = "s" > " modules.block" < / span > < span class = "p" > ),< / span >
< span class = "s" > ' eth' < / span > < span class = "p" > :< / span > < span class = "n" > read_module_set< / span > < span class = "p" > (< / span > < span class = "s" > " modules.networking" < / span > < span class = "p" > )}< / span >
< span class = "n" > modinfo< / span > < span class = "o" > =< / span > < span class = "nb" > list< / span > < span class = "p" > ()< / span >
< span class = "k" > for< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "n" > _dirs< / span > < span class = "p" > ,< / span > < span class = "n" > files< / span > < span class = "ow" > in< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > walk< / span > < span class = "p" > (< / span > < span class = "n" > moddir< / span > < span class = "p" > ):< / span >
< span class = "k" > for< / span > < span class = "n" > modtype< / span > < span class = "p" > ,< / span > < span class = "n" > modset< / span > < span class = "ow" > in< / span > < span class = "n" > modsets< / span > < span class = "o" > .< / span > < span class = "n" > items< / span > < span class = "p" > ():< / span >
< span class = "k" > for< / span > < span class = "n" > mod< / span > < span class = "ow" > in< / span > < span class = "n" > modset< / span > < span class = "o" > .< / span > < span class = "n" > intersection< / span > < span class = "p" > (< / span > < span class = "n" > files< / span > < span class = "p" > ):< / span > < span class = "c" > # modules in this dir< / span >
< span class = "p" > (< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span > < span class = "n" > _ext< / span > < span class = "p" > )< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > splitext< / span > < span class = "p" > (< / span > < span class = "n" > mod< / span > < span class = "p" > )< / span > < span class = "c" > # foo.ko -> (foo, .ko)< / span >
< span class = "n" > desc< / span > < span class = "o" > =< / span > < span class = "n" > module_desc< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "n" > mod< / span > < span class = "p" > ))< / span > < span class = "ow" > or< / span > < span class = "s" > " < / span > < span class = "si" > %s< / span > < span class = "s" > driver" < / span > < span class = "o" > %< / span > < span class = "n" > name< / span >
< span class = "n" > modinfo< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "nb" > dict< / span > < span class = "p" > (< / span > < span class = "n" > name< / span > < span class = "o" > =< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span > < span class = "nb" > type< / span > < span class = "o" > =< / span > < span class = "n" > modtype< / span > < span class = "p" > ,< / span > < span class = "n" > desc< / span > < span class = "o" > =< / span > < span class = "n" > desc< / span > < span class = "p" > ))< / span >
< span class = "n" > out< / span > < span class = "o" > =< / span > < span class = "nb" > open< / span > < span class = "p" > (< / span > < span class = "n" > outfile< / span > < span class = "ow" > or< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > moddir< / span > < span class = "p" > ,< / span > < span class = "s" > " module-info" < / span > < span class = "p" > ),< / span > < span class = "s" > " w" < / span > < span class = "p" > )< / span >
< span class = "n" > out< / span > < span class = "o" > .< / span > < span class = "n" > write< / span > < span class = "p" > (< / span > < span class = "s" > " Version 0< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "p" > )< / span >
< span class = "k" > for< / span > < span class = "n" > mod< / span > < span class = "ow" > in< / span > < span class = "nb" > sorted< / span > < span class = "p" > (< / span > < span class = "n" > modinfo< / span > < span class = "p" > ,< / span > < span class = "n" > key< / span > < span class = "o" > =< / span > < span class = "k" > lambda< / span > < span class = "n" > m< / span > < span class = "p" > :< / span > < span class = "n" > m< / span > < span class = "o" > .< / span > < span class = "n" > get< / span > < span class = "p" > (< / span > < span class = "s" > ' name' < / span > < span class = "p" > )):< / span >
< span class = "n" > out< / span > < span class = "o" > .< / span > < span class = "n" > write< / span > < span class = "p" > (< / span > < span class = "s" > ' {name}< / span > < span class = "se" > \n\t< / span > < span class = "s" > {type}< / span > < span class = "se" > \n\t< / span > < span class = "s" > " {desc:.65}" < / span > < span class = "se" > \n< / span > < span class = "s" > ' < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "o" > **< / span > < span class = "n" > mod< / span > < span class = "p" > ))< / span >
< / div >
< div class = "viewcode-block" id = "RuntimeBuilder" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder" > [docs]< / a > < span class = "k" > class< / span > < span class = "nc" > RuntimeBuilder< / span > < span class = "p" > (< / span > < span class = "nb" > object< / span > < span class = "p" > ):< / span >
< span class = "sd" > ' ' ' Builds the anaconda runtime image.' ' ' < / span >
< span class = "k" > def< / span > < span class = "nf" > __init__< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > product< / span > < span class = "p" > ,< / span > < span class = "n" > arch< / span > < span class = "p" > ,< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "n" > templatedir< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span >
< span class = "n" > installpkgs< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span >
< span class = "n" > add_templates< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span >
< span class = "n" > add_template_vars< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
< span class = "n" > root< / span > < span class = "o" > =< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > installroot< / span >
< span class = "c" > # use a copy of product so we can modify it locally< / span >
< span class = "n" > product< / span > < span class = "o" > =< / span > < span class = "n" > product< / span > < span class = "o" > .< / span > < span class = "n" > copy< / span > < span class = "p" > ()< / span >
< span class = "n" > product< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "o" > =< / span > < span class = "n" > product< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ()< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > =< / span > < span class = "n" > DataHolder< / span > < span class = "p" > (< / span > < span class = "n" > arch< / span > < span class = "o" > =< / span > < span class = "n" > arch< / span > < span class = "p" > ,< / span > < span class = "n" > product< / span > < span class = "o" > =< / span > < span class = "n" > product< / span > < span class = "p" > ,< / span > < span class = "n" > dbo< / span > < span class = "o" > =< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "n" > root< / span > < span class = "o" > =< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span >
< span class = "n" > basearch< / span > < span class = "o" > =< / span > < span class = "n" > arch< / span > < span class = "o" > .< / span > < span class = "n" > basearch< / span > < span class = "p" > ,< / span > < span class = "n" > libdir< / span > < span class = "o" > =< / span > < span class = "n" > arch< / span > < span class = "o" > .< / span > < span class = "n" > libdir< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > dbo< / span > < span class = "o" > =< / span > < span class = "n" > dbo< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > =< / span > < span class = "n" > LoraxTemplateRunner< / span > < span class = "p" > (< / span > < span class = "n" > inroot< / span > < span class = "o" > =< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "n" > outroot< / span > < span class = "o" > =< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span >
< span class = "n" > dbo< / span > < span class = "o" > =< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "n" > templatedir< / span > < span class = "o" > =< / span > < span class = "n" > templatedir< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > add_templates< / span > < span class = "o" > =< / span > < span class = "n" > add_templates< / span > < span class = "ow" > or< / span > < span class = "p" > []< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > add_template_vars< / span > < span class = "o" > =< / span > < span class = "n" > add_template_vars< / span > < span class = "ow" > or< / span > < span class = "p" > {}< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _installpkgs< / span > < span class = "o" > =< / span > < span class = "n" > installpkgs< / span > < span class = "ow" > or< / span > < span class = "p" > []< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > defaults< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > reset< / span > < span class = "p" > ()< / span >
< span class = "k" > def< / span > < span class = "nf" > _install_branding< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "n" > release< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span >
< span class = "n" > q< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > sack< / span > < span class = "o" > .< / span > < span class = "n" > query< / span > < span class = "p" > ()< / span >
< span class = "n" > a< / span > < span class = "o" > =< / span > < span class = "n" > q< / span > < span class = "o" > .< / span > < span class = "n" > available< / span > < span class = "p" > ()< / span >
< span class = "k" > for< / span > < span class = "n" > pkg< / span > < span class = "ow" > in< / span > < span class = "n" > a< / span > < span class = "o" > .< / span > < span class = "n" > filter< / span > < span class = "p" > (< / span > < span class = "n" > provides< / span > < span class = "o" > =< / span > < span class = "s" > ' /etc/system-release' < / span > < span class = "p" > ):< / span >
< span class = "k" > if< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "o" > .< / span > < span class = "n" > startswith< / span > < span class = "p" > (< / span > < span class = "s" > ' generic' < / span > < span class = "p" > ):< / span >
< span class = "k" > continue< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > release< / span > < span class = "o" > =< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > name< / span >
< span class = "k" > break< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > release< / span > < span class = "p" > :< / span >
< span class = "n" > logger< / span > < span class = "o" > .< / span > < span class = "n" > error< / span > < span class = "p" > (< / span > < span class = "s" > ' could not get the release' < / span > < span class = "p" > )< / span >
< span class = "k" > return< / span >
< span class = "c" > # release< / span >
< span class = "n" > logger< / span > < span class = "o" > .< / span > < span class = "n" > info< / span > < span class = "p" > (< / span > < span class = "s" > ' got release: < / span > < span class = "si" > %s< / span > < span class = "s" > ' < / span > < span class = "p" > ,< / span > < span class = "n" > release< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > installpkg< / span > < span class = "p" > (< / span > < span class = "n" > release< / span > < span class = "p" > )< / span >
< span class = "c" > # logos< / span >
< span class = "n" > release< / span > < span class = "p" > ,< / span > < span class = "n" > _suffix< / span > < span class = "o" > =< / span > < span class = "n" > release< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > (< / span > < span class = "s" > ' -' < / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > installpkg< / span > < span class = "p" > (< / span > < span class = "s" > ' < / span > < span class = "si" > %s< / span > < span class = "s" > -logos' < / span > < span class = "o" > %< / span > < span class = "n" > release< / span > < span class = "p" > )< / span >
< div class = "viewcode-block" id = "RuntimeBuilder.install" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.install" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > install< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "sd" > ' ' ' Install packages and do initial setup with runtime-install.tmpl' ' ' < / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _install_branding< / span > < span class = "p" > ()< / span >
< span class = "k" > if< / span > < span class = "nb" > len< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _installpkgs< / span > < span class = "p" > )< / span > < span class = "o" > > < / span > < span class = "mi" > 0< / span > < span class = "p" > :< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > installpkg< / span > < span class = "p" > (< / span > < span class = "o" > *< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _installpkgs< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > run< / span > < span class = "p" > (< / span > < span class = "s" > " runtime-install.tmpl" < / span > < span class = "p" > )< / span >
< span class = "k" > for< / span > < span class = "n" > tmpl< / span > < span class = "ow" > in< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > add_templates< / span > < span class = "p" > :< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > run< / span > < span class = "p" > (< / span > < span class = "n" > tmpl< / span > < span class = "p" > ,< / span > < span class = "o" > **< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > add_template_vars< / span > < span class = "p" > )< / span >
< / div >
< div class = "viewcode-block" id = "RuntimeBuilder.writepkglists" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.writepkglists" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > writepkglists< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > pkglistdir< / span > < span class = "p" > ):< / span >
< span class = "sd" > ' ' ' debugging data: write out lists of package contents' ' ' < / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isdir< / span > < span class = "p" > (< / span > < span class = "n" > pkglistdir< / span > < span class = "p" > ):< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > makedirs< / span > < span class = "p" > (< / span > < span class = "n" > pkglistdir< / span > < span class = "p" > )< / span >
< span class = "n" > q< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > sack< / span > < span class = "o" > .< / span > < span class = "n" > query< / span > < span class = "p" > ()< / span >
< span class = "k" > for< / span > < span class = "n" > pkgobj< / span > < span class = "ow" > in< / span > < span class = "n" > q< / span > < span class = "o" > .< / span > < span class = "n" > installed< / span > < span class = "p" > ():< / span >
< span class = "k" > with< / span > < span class = "nb" > open< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > pkglistdir< / span > < span class = "p" > ,< / span > < span class = "n" > pkgobj< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "p" > ),< / span > < span class = "s" > " w" < / span > < span class = "p" > )< / span > < span class = "k" > as< / span > < span class = "n" > fobj< / span > < span class = "p" > :< / span >
< span class = "k" > for< / span > < span class = "n" > fname< / span > < span class = "ow" > in< / span > < span class = "n" > pkgobj< / span > < span class = "o" > .< / span > < span class = "n" > files< / span > < span class = "p" > :< / span >
< span class = "n" > fobj< / span > < span class = "o" > .< / span > < span class = "n" > write< / span > < span class = "p" > (< / span > < span class = "s" > " {0}< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "n" > fname< / span > < span class = "p" > ))< / span >
< / div >
< div class = "viewcode-block" id = "RuntimeBuilder.postinstall" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.postinstall" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > postinstall< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "sd" > ' ' ' Do some post-install setup work with runtime-postinstall.tmpl' ' ' < / span >
< span class = "c" > # copy configdir into runtime root beforehand< / span >
< span class = "n" > configdir< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > templatedir< / span > < span class = "p" > ,< / span > < span class = "s" > " config_files" < / span > < span class = "p" > )< / span >
< span class = "n" > configdir_path< / span > < span class = "o" > =< / span > < span class = "s" > " tmp/config_files" < / span >
< span class = "n" > fullpath< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "n" > configdir_path< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "n" > fullpath< / span > < span class = "p" > ):< / span >
< span class = "n" > remove< / span > < span class = "p" > (< / span > < span class = "n" > fullpath< / span > < span class = "p" > )< / span >
< span class = "n" > copytree< / span > < span class = "p" > (< / span > < span class = "n" > configdir< / span > < span class = "p" > ,< / span > < span class = "n" > fullpath< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > run< / span > < span class = "p" > (< / span > < span class = "s" > " runtime-postinstall.tmpl" < / span > < span class = "p" > ,< / span > < span class = "n" > configdir< / span > < span class = "o" > =< / span > < span class = "n" > configdir_path< / span > < span class = "p" > )< / span >
< / div >
< div class = "viewcode-block" id = "RuntimeBuilder.cleanup" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.cleanup" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > cleanup< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "sd" > ' ' ' Remove unneeded packages and files with runtime-cleanup.tmpl' ' ' < / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > run< / span > < span class = "p" > (< / span > < span class = "s" > " runtime-cleanup.tmpl" < / span > < span class = "p" > )< / span >
< / div >
2015-08-25 22:51:32 +00:00
< div class = "viewcode-block" id = "RuntimeBuilder.verify" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.verify" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > verify< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "sd" > ' ' ' Ensure that contents of the installroot can run' ' ' < / span >
< span class = "n" > status< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span >
< span class = "n" > ELF_MAGIC< / span > < span class = "o" > =< / span > < span class = "n" > b< / span > < span class = "s" > ' < / span > < span class = "se" > \x7f< / span > < span class = "s" > ELF' < / span >
< span class = "c" > # Iterate over all files in /usr/bin and /usr/sbin< / span >
< span class = "c" > # For ELF files, gather them into a list and we' ll check them all at< / span >
< span class = "c" > # the end. For files with a #!, check them as we go< / span >
< span class = "n" > elf_files< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "n" > usr_bin< / span > < span class = "o" > =< / span > < span class = "n" > Path< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > root< / span > < span class = "o" > +< / span > < span class = "s" > ' /usr/bin' < / span > < span class = "p" > )< / span >
< span class = "n" > usr_sbin< / span > < span class = "o" > =< / span > < span class = "n" > Path< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > root< / span > < span class = "o" > +< / span > < span class = "s" > ' /usr/sbin' < / span > < span class = "p" > )< / span >
< span class = "k" > for< / span > < span class = "n" > path< / span > < span class = "ow" > in< / span > < span class = "p" > (< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > x< / span > < span class = "p" > )< / span > < span class = "k" > for< / span > < span class = "n" > x< / span > < span class = "ow" > in< / span > < span class = "n" > itertools< / span > < span class = "o" > .< / span > < span class = "n" > chain< / span > < span class = "p" > (< / span > < span class = "n" > usr_bin< / span > < span class = "o" > .< / span > < span class = "n" > iterdir< / span > < span class = "p" > (),< / span > < span class = "n" > usr_sbin< / span > < span class = "o" > .< / span > < span class = "n" > iterdir< / span > < span class = "p" > ())< / span > \
< span class = "k" > if< / span > < span class = "n" > x< / span > < span class = "o" > .< / span > < span class = "n" > is_file< / span > < span class = "p" > ()):< / span >
< span class = "k" > with< / span > < span class = "nb" > open< / span > < span class = "p" > (< / span > < span class = "n" > path< / span > < span class = "p" > ,< / span > < span class = "s" > " rb" < / span > < span class = "p" > )< / span > < span class = "k" > as< / span > < span class = "n" > f< / span > < span class = "p" > :< / span >
< span class = "n" > magic< / span > < span class = "o" > =< / span > < span class = "n" > f< / span > < span class = "o" > .< / span > < span class = "n" > read< / span > < span class = "p" > (< / span > < span class = "mi" > 4< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > magic< / span > < span class = "o" > ==< / span > < span class = "n" > ELF_MAGIC< / span > < span class = "p" > :< / span >
< span class = "c" > # Save the path, minus the chroot prefix< / span >
< span class = "n" > elf_files< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > path< / span > < span class = "p" > [< / span > < span class = "nb" > len< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > root< / span > < span class = "p" > ):])< / span >
< span class = "k" > elif< / span > < span class = "n" > magic< / span > < span class = "p" > [:< / span > < span class = "mi" > 2< / span > < span class = "p" > ]< / span > < span class = "o" > ==< / span > < span class = "n" > b< / span > < span class = "s" > ' #!' < / span > < span class = "p" > :< / span >
< span class = "c" > # Reopen the file as text and read the first line.< / span >
< span class = "c" > # Open as latin-1 so that stray 8-bit characters don' t make< / span >
< span class = "c" > # things blow up. We only really care about ASCII parts.< / span >
< span class = "k" > with< / span > < span class = "nb" > open< / span > < span class = "p" > (< / span > < span class = "n" > path< / span > < span class = "p" > ,< / span > < span class = "s" > " rt" < / span > < span class = "p" > ,< / span > < span class = "n" > encoding< / span > < span class = "o" > =< / span > < span class = "s" > " latin-1" < / span > < span class = "p" > )< / span > < span class = "k" > as< / span > < span class = "n" > f_text< / span > < span class = "p" > :< / span >
< span class = "c" > # Remove the #!, split on space, and take the first part< / span >
< span class = "n" > shabang< / span > < span class = "o" > =< / span > < span class = "n" > f_text< / span > < span class = "o" > .< / span > < span class = "n" > readline< / span > < span class = "p" > ()[< / span > < span class = "mi" > 2< / span > < span class = "p" > :]< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > ()[< / span > < span class = "mi" > 0< / span > < span class = "p" > ]< / span >
< span class = "c" > # Does the path exist?< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > root< / span > < span class = "o" > +< / span > < span class = "n" > shabang< / span > < span class = "p" > ):< / span >
< span class = "n" > logger< / span > < span class = "o" > .< / span > < span class = "n" > error< / span > < span class = "p" > (< / span > < span class = "s" > ' < / span > < span class = "si" > %s< / span > < span class = "s" > , needed by < / span > < span class = "si" > %s< / span > < span class = "s" > , does not exist' < / span > < span class = "p" > ,< / span > < span class = "n" > shabang< / span > < span class = "p" > ,< / span > < span class = "n" > path< / span > < span class = "p" > )< / span >
< span class = "n" > status< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span >
< span class = "c" > # Now, run ldd on all the ELF files< / span >
< span class = "c" > # Just run ldd once on everything so it isn' t logged a million times.< / span >
< span class = "c" > # At least one thing in the list isn' t going to be a dynamic executable,< / span >
< span class = "c" > # so use execWithCapture to ignore the exit code.< / span >
< span class = "n" > filename< / span > < span class = "o" > =< / span > < span class = "s" > ' ' < / span >
< span class = "k" > for< / span > < span class = "n" > line< / span > < span class = "ow" > in< / span > < span class = "n" > execWithCapture< / span > < span class = "p" > (< / span > < span class = "s" > ' ldd' < / span > < span class = "p" > ,< / span > < span class = "n" > elf_files< / span > < span class = "p" > ,< / span > < span class = "n" > root< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span >
< span class = "n" > log_output< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span > < span class = "p" > ,< / span > < span class = "n" > filter_stderr< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span > < span class = "p" > )< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > (< / span > < span class = "s" > ' < / span > < span class = "se" > \n< / span > < span class = "s" > ' < / span > < span class = "p" > ):< / span >
< span class = "k" > if< / span > < span class = "n" > line< / span > < span class = "ow" > and< / span > < span class = "ow" > not< / span > < span class = "n" > line< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > isspace< / span > < span class = "p" > ():< / span >
< span class = "c" > # New filename header, strip the : at the end and save< / span >
< span class = "n" > filename< / span > < span class = "o" > =< / span > < span class = "n" > line< / span > < span class = "p" > [:< / span > < span class = "o" > -< / span > < span class = "mi" > 1< / span > < span class = "p" > ]< / span >
< span class = "k" > elif< / span > < span class = "s" > ' not found' < / span > < span class = "ow" > in< / span > < span class = "n" > line< / span > < span class = "p" > :< / span >
< span class = "n" > logger< / span > < span class = "o" > .< / span > < span class = "n" > error< / span > < span class = "p" > (< / span > < span class = "s" > ' < / span > < span class = "si" > %s< / span > < span class = "s" > , needed by < / span > < span class = "si" > %s< / span > < span class = "s" > , not found' < / span > < span class = "p" > ,< / span > < span class = "n" > line< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > ()[< / span > < span class = "mi" > 0< / span > < span class = "p" > ],< / span > < span class = "n" > filename< / span > < span class = "p" > )< / span >
< span class = "n" > status< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span >
< span class = "k" > return< / span > < span class = "n" > status< / span >
< / div >
2015-05-11 23:44:09 +00:00
< div class = "viewcode-block" id = "RuntimeBuilder.writepkgsizes" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.writepkgsizes" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > writepkgsizes< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > pkgsizefile< / span > < span class = "p" > ):< / span >
< span class = "sd" > ' ' ' debugging data: write a big list of pkg sizes' ' ' < / span >
< span class = "n" > fobj< / span > < span class = "o" > =< / span > < span class = "nb" > open< / span > < span class = "p" > (< / span > < span class = "n" > pkgsizefile< / span > < span class = "p" > ,< / span > < span class = "s" > " w" < / span > < span class = "p" > )< / span >
< span class = "n" > getsize< / span > < span class = "o" > =< / span > < span class = "k" > lambda< / span > < span class = "n" > f< / span > < span class = "p" > :< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > lstat< / span > < span class = "p" > (< / span > < span class = "n" > f< / span > < span class = "p" > )< / span > < span class = "o" > .< / span > < span class = "n" > st_size< / span > < span class = "k" > if< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "n" > f< / span > < span class = "p" > )< / span > < span class = "k" > else< / span > < span class = "mi" > 0< / span >
< span class = "n" > q< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > sack< / span > < span class = "o" > .< / span > < span class = "n" > query< / span > < span class = "p" > ()< / span >
< span class = "k" > for< / span > < span class = "n" > p< / span > < span class = "ow" > in< / span > < span class = "nb" > sorted< / span > < span class = "p" > (< / span > < span class = "n" > q< / span > < span class = "o" > .< / span > < span class = "n" > installed< / span > < span class = "p" > ()):< / span >
< span class = "n" > pkgsize< / span > < span class = "o" > =< / span > < span class = "nb" > sum< / span > < span class = "p" > (< / span > < span class = "n" > getsize< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "n" > f< / span > < span class = "p" > ))< / span > < span class = "k" > for< / span > < span class = "n" > f< / span > < span class = "ow" > in< / span > < span class = "n" > p< / span > < span class = "o" > .< / span > < span class = "n" > files< / span > < span class = "p" > )< / span >
< span class = "n" > fobj< / span > < span class = "o" > .< / span > < span class = "n" > write< / span > < span class = "p" > (< / span > < span class = "s" > " {0.name}.{0.arch}: {1}< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "n" > p< / span > < span class = "p" > ,< / span > < span class = "n" > pkgsize< / span > < span class = "p" > ))< / span >
< / div >
< div class = "viewcode-block" id = "RuntimeBuilder.generate_module_data" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.generate_module_data" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > generate_module_data< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "n" > root< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > root< / span >
< span class = "n" > moddir< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "s" > " lib/modules/" < / span > < span class = "p" > )< / span >
< span class = "k" > for< / span > < span class = "n" > kver< / span > < span class = "ow" > in< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > listdir< / span > < span class = "p" > (< / span > < span class = "n" > moddir< / span > < span class = "p" > ):< / span >
< span class = "n" > ksyms< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "s" > " boot/System.map-< / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "n" > kver< / span > < span class = "p" > )< / span >
< span class = "n" > logger< / span > < span class = "o" > .< / span > < span class = "n" > info< / span > < span class = "p" > (< / span > < span class = "s" > " doing depmod and module-info for < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "p" > ,< / span > < span class = "n" > kver< / span > < span class = "p" > )< / span >
< span class = "n" > runcmd< / span > < span class = "p" > ([< / span > < span class = "s" > " depmod" < / span > < span class = "p" > ,< / span > < span class = "s" > " -a" < / span > < span class = "p" > ,< / span > < span class = "s" > " -F" < / span > < span class = "p" > ,< / span > < span class = "n" > ksyms< / span > < span class = "p" > ,< / span > < span class = "s" > " -b" < / span > < span class = "p" > ,< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "n" > kver< / span > < span class = "p" > ])< / span >
< span class = "n" > generate_module_info< / span > < span class = "p" > (< / span > < span class = "n" > moddir< / span > < span class = "o" > +< / span > < span class = "n" > kver< / span > < span class = "p" > ,< / span > < span class = "n" > outfile< / span > < span class = "o" > =< / span > < span class = "n" > moddir< / span > < span class = "o" > +< / span > < span class = "s" > " module-info" < / span > < span class = "p" > )< / span >
< / div >
< div class = "viewcode-block" id = "RuntimeBuilder.create_runtime" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.create_runtime" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > create_runtime< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > outfile< / span > < span class = "o" > =< / span > < span class = "s" > " /var/tmp/squashfs.img" < / span > < span class = "p" > ,< / span > < span class = "n" > compression< / span > < span class = "o" > =< / span > < span class = "s" > " xz" < / span > < span class = "p" > ,< / span > < span class = "n" > compressargs< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span > < span class = "n" > size< / span > < span class = "o" > =< / span > < span class = "mi" > 2< / span > < span class = "p" > ):< / span >
< span class = "c" > # make live rootfs image - must be named " LiveOS/rootfs.img" for dracut< / span >
< span class = "n" > compressargs< / span > < span class = "o" > =< / span > < span class = "n" > compressargs< / span > < span class = "ow" > or< / span > < span class = "p" > []< / span >
< span class = "n" > workdir< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > dirname< / span > < span class = "p" > (< / span > < span class = "n" > outfile< / span > < span class = "p" > ),< / span > < span class = "s" > " runtime-workdir" < / span > < span class = "p" > )< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > makedirs< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > workdir< / span > < span class = "p" > ,< / span > < span class = "s" > " LiveOS" < / span > < span class = "p" > ))< / span >
< span class = "n" > imgutils< / span > < span class = "o" > .< / span > < span class = "n" > mkrootfsimg< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > workdir< / span > < span class = "p" > ,< / span > < span class = "s" > " LiveOS/rootfs.img" < / span > < span class = "p" > ),< / span >
< span class = "s" > " Anaconda" < / span > < span class = "p" > ,< / span > < span class = "n" > size< / span > < span class = "o" > =< / span > < span class = "n" > size< / span > < span class = "p" > )< / span >
< span class = "c" > # squash the live rootfs and clean up workdir< / span >
< span class = "n" > imgutils< / span > < span class = "o" > .< / span > < span class = "n" > mksquashfs< / span > < span class = "p" > (< / span > < span class = "n" > workdir< / span > < span class = "p" > ,< / span > < span class = "n" > outfile< / span > < span class = "p" > ,< / span > < span class = "n" > compression< / span > < span class = "p" > ,< / span > < span class = "n" > compressargs< / span > < span class = "p" > )< / span >
< span class = "n" > remove< / span > < span class = "p" > (< / span > < span class = "n" > workdir< / span > < span class = "p" > )< / span >
< / div >
< div class = "viewcode-block" id = "RuntimeBuilder.finished" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.finished" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > finished< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Done using RuntimeBuilder< / span >
< span class = "sd" > Close the dnf base object< / span >
< span class = "sd" > " " " < / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > close< / span > < span class = "p" > ()< / span >
< / div > < / div >
< div class = "viewcode-block" id = "TreeBuilder" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.TreeBuilder" > [docs]< / a > < span class = "k" > class< / span > < span class = "nc" > TreeBuilder< / span > < span class = "p" > (< / span > < span class = "nb" > object< / span > < span class = "p" > ):< / span >
< span class = "sd" > ' ' ' Builds the arch-specific boot images.< / span >
< span class = "sd" > inroot should be the installtree root (the newly-built runtime dir)' ' ' < / span >
< span class = "k" > def< / span > < span class = "nf" > __init__< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > product< / span > < span class = "p" > ,< / span > < span class = "n" > arch< / span > < span class = "p" > ,< / span > < span class = "n" > inroot< / span > < span class = "p" > ,< / span > < span class = "n" > outroot< / span > < span class = "p" > ,< / span > < span class = "n" > runtime< / span > < span class = "p" > ,< / span > < span class = "n" > isolabel< / span > < span class = "p" > ,< / span > < span class = "n" > domacboot< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span > < span class = "p" > ,< / span > < span class = "n" > doupgrade< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span > < span class = "p" > ,< / span > < span class = "n" > templatedir< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span > < span class = "n" > add_templates< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span > < span class = "n" > add_template_vars< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span > < span class = "n" > workdir< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
< span class = "c" > # NOTE: if you pass an arg named " runtime" to a mako template it' ll< / span >
< span class = "c" > # clobber some mako internal variables - hence " runtime_img" .< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > =< / span > < span class = "n" > DataHolder< / span > < span class = "p" > (< / span > < span class = "n" > arch< / span > < span class = "o" > =< / span > < span class = "n" > arch< / span > < span class = "p" > ,< / span > < span class = "n" > product< / span > < span class = "o" > =< / span > < span class = "n" > product< / span > < span class = "p" > ,< / span > < span class = "n" > runtime_img< / span > < span class = "o" > =< / span > < span class = "n" > runtime< / span > < span class = "p" > ,< / span >
< span class = "n" > runtime_base< / span > < span class = "o" > =< / span > < span class = "n" > basename< / span > < span class = "p" > (< / span > < span class = "n" > runtime< / span > < span class = "p" > ),< / span >
< span class = "n" > inroot< / span > < span class = "o" > =< / span > < span class = "n" > inroot< / span > < span class = "p" > ,< / span > < span class = "n" > outroot< / span > < span class = "o" > =< / span > < span class = "n" > outroot< / span > < span class = "p" > ,< / span >
< span class = "n" > basearch< / span > < span class = "o" > =< / span > < span class = "n" > arch< / span > < span class = "o" > .< / span > < span class = "n" > basearch< / span > < span class = "p" > ,< / span > < span class = "n" > libdir< / span > < span class = "o" > =< / span > < span class = "n" > arch< / span > < span class = "o" > .< / span > < span class = "n" > libdir< / span > < span class = "p" > ,< / span >
< span class = "n" > isolabel< / span > < span class = "o" > =< / span > < span class = "n" > isolabel< / span > < span class = "p" > ,< / span > < span class = "n" > udev< / span > < span class = "o" > =< / span > < span class = "n" > udev_escape< / span > < span class = "p" > ,< / span > < span class = "n" > domacboot< / span > < span class = "o" > =< / span > < span class = "n" > domacboot< / span > < span class = "p" > ,< / span > < span class = "n" > doupgrade< / span > < span class = "o" > =< / span > < span class = "n" > doupgrade< / span > < span class = "p" > ,< / span >
< span class = "n" > workdir< / span > < span class = "o" > =< / span > < span class = "n" > workdir< / span > < span class = "p" > ,< / span > < span class = "n" > lower< / span > < span class = "o" > =< / span > < span class = "n" > string_lower< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > =< / span > < span class = "n" > LoraxTemplateRunner< / span > < span class = "p" > (< / span > < span class = "n" > inroot< / span > < span class = "p" > ,< / span > < span class = "n" > outroot< / span > < span class = "p" > ,< / span > < span class = "n" > templatedir< / span > < span class = "o" > =< / span > < span class = "n" > templatedir< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > defaults< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > add_templates< / span > < span class = "o" > =< / span > < span class = "n" > add_templates< / span > < span class = "ow" > or< / span > < span class = "p" > []< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > add_template_vars< / span > < span class = "o" > =< / span > < span class = "n" > add_template_vars< / span > < span class = "ow" > or< / span > < span class = "p" > {}< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > templatedir< / span > < span class = "o" > =< / span > < span class = "n" > templatedir< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > treeinfo_data< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span >
< span class = "nd" > @property< / span >
< div class = "viewcode-block" id = "TreeBuilder.kernels" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.TreeBuilder.kernels" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > kernels< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "k" > return< / span > < span class = "n" > findkernels< / span > < span class = "p" > (< / span > < span class = "n" > root< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > inroot< / span > < span class = "p" > )< / span >
< / div >
< div class = "viewcode-block" id = "TreeBuilder.rebuild_initrds" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.TreeBuilder.rebuild_initrds" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > rebuild_initrds< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > add_args< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span > < span class = "n" > backup< / span > < span class = "o" > =< / span > < span class = "s" > " " < / span > < span class = "p" > ,< / span > < span class = "n" > prefix< / span > < span class = "o" > =< / span > < span class = "s" > " " < / span > < span class = "p" > ):< / span >
< span class = "sd" > ' ' ' Rebuild all the initrds in the tree. If backup is specified, each< / span >
< span class = "sd" > initrd will be renamed with backup as a suffix before rebuilding.< / span >
< span class = "sd" > If backup is empty, the existing initrd files will be overwritten.< / span >
< span class = "sd" > If suffix is specified, the existing initrd is untouched and a new< / span >
< span class = "sd" > image is built with the filename " ${prefix}-${kernel.version}.img" < / span >
< span class = "sd" > ' ' ' < / span >
< span class = "n" > add_args< / span > < span class = "o" > =< / span > < span class = "n" > add_args< / span > < span class = "ow" > or< / span > < span class = "p" > []< / span >
< span class = "n" > dracut< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > " dracut" < / span > < span class = "p" > ,< / span > < span class = "s" > " --nomdadmconf" < / span > < span class = "p" > ,< / span > < span class = "s" > " --nolvmconf" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "n" > add_args< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > backup< / span > < span class = "p" > :< / span >
< span class = "n" > dracut< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " --force" < / span > < span class = "p" > )< / span >
< span class = "n" > kernels< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "n" > kernel< / span > < span class = "k" > for< / span > < span class = "n" > kernel< / span > < span class = "ow" > in< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > kernels< / span > < span class = "k" > if< / span > < span class = "nb" > hasattr< / span > < span class = "p" > (< / span > < span class = "n" > kernel< / span > < span class = "p" > ,< / span > < span class = "s" > " initrd" < / span > < span class = "p" > )]< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > kernels< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "ne" > Exception< / span > < span class = "p" > (< / span > < span class = "s" > " No initrds found, cannot rebuild_initrds" < / span > < span class = "p" > )< / span >
< span class = "c" > # Hush some dracut warnings. TODO: bind-mount proc in place?< / span >
< span class = "nb" > open< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > inroot< / span > < span class = "p" > ,< / span > < span class = "s" > " /proc/modules" < / span > < span class = "p" > ),< / span > < span class = "s" > " w" < / span > < span class = "p" > )< / span >
< span class = "k" > for< / span > < span class = "n" > kernel< / span > < span class = "ow" > in< / span > < span class = "n" > kernels< / span > < span class = "p" > :< / span >
< span class = "k" > if< / span > < span class = "n" > prefix< / span > < span class = "p" > :< / span >
< span class = "n" > idir< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > dirname< / span > < span class = "p" > (< / span > < span class = "n" > kernel< / span > < span class = "o" > .< / span > < span class = "n" > initrd< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "p" > )< / span >
< span class = "n" > outfile< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > idir< / span > < span class = "p" > ,< / span > < span class = "n" > prefix< / span > < span class = "o" > +< / span > < span class = "s" > ' -' < / span > < span class = "o" > +< / span > < span class = "n" > kernel< / span > < span class = "o" > .< / span > < span class = "n" > version< / span > < span class = "o" > +< / span > < span class = "s" > ' .img' < / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > outfile< / span > < span class = "o" > =< / span > < span class = "n" > kernel< / span > < span class = "o" > .< / span > < span class = "n" > initrd< / span > < span class = "o" > .< / span > < span class = "n" > path< / span >
< span class = "n" > logger< / span > < span class = "o" > .< / span > < span class = "n" > info< / span > < span class = "p" > (< / span > < span class = "s" > " rebuilding < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "p" > ,< / span > < span class = "n" > outfile< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > backup< / span > < span class = "p" > :< / span >
< span class = "n" > initrd< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > inroot< / span > < span class = "p" > ,< / span > < span class = "n" > outfile< / span > < span class = "p" > )< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > rename< / span > < span class = "p" > (< / span > < span class = "n" > initrd< / span > < span class = "p" > ,< / span > < span class = "n" > initrd< / span > < span class = "o" > +< / span > < span class = "n" > backup< / span > < span class = "p" > )< / span >
< span class = "n" > cmd< / span > < span class = "o" > =< / span > < span class = "n" > dracut< / span > < span class = "o" > +< / span > < span class = "p" > [< / span > < span class = "n" > outfile< / span > < span class = "p" > ,< / span > < span class = "n" > kernel< / span > < span class = "o" > .< / span > < span class = "n" > version< / span > < span class = "p" > ]< / span >
< span class = "n" > runcmd< / span > < span class = "p" > (< / span > < span class = "n" > cmd< / span > < span class = "p" > ,< / span > < span class = "n" > root< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > inroot< / span > < span class = "p" > )< / span >
< span class = "c" > # ppc64 cannot boot images > 32MiB, check size and warn< / span >
< span class = "k" > if< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > arch< / span > < span class = "o" > .< / span > < span class = "n" > basearch< / span > < span class = "ow" > in< / span > < span class = "p" > (< / span > < span class = "s" > " ppc64" < / span > < span class = "p" > ,< / span > < span class = "s" > " ppc64le" < / span > < span class = "p" > )< / span > < span class = "ow" > and< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "n" > outfile< / span > < span class = "p" > ):< / span >
< span class = "n" > st< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > stat< / span > < span class = "p" > (< / span > < span class = "n" > outfile< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > st< / span > < span class = "o" > .< / span > < span class = "n" > st_size< / span > < span class = "o" > > < / span > < span class = "mi" > 32< / span > < span class = "o" > *< / span > < span class = "mi" > 1024< / span > < span class = "o" > *< / span > < span class = "mi" > 1024< / span > < span class = "p" > :< / span >
< span class = "n" > logging< / span > < span class = "o" > .< / span > < span class = "n" > warning< / span > < span class = "p" > (< / span > < span class = "s" > " ppc64 initrd < / span > < span class = "si" > %s< / span > < span class = "s" > is > 32MiB" < / span > < span class = "p" > ,< / span > < span class = "n" > outfile< / span > < span class = "p" > )< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > unlink< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > inroot< / span > < span class = "p" > ,< / span > < span class = "s" > " /proc/modules" < / span > < span class = "p" > ))< / span >
< / div >
< div class = "viewcode-block" id = "TreeBuilder.build" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.TreeBuilder.build" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > build< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "n" > templatefile< / span > < span class = "o" > =< / span > < span class = "n" > templatemap< / span > < span class = "p" > [< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > arch< / span > < span class = "o" > .< / span > < span class = "n" > basearch< / span > < span class = "p" > ]< / span >
< span class = "k" > for< / span > < span class = "n" > tmpl< / span > < span class = "ow" > in< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > add_templates< / span > < span class = "p" > :< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > run< / span > < span class = "p" > (< / span > < span class = "n" > tmpl< / span > < span class = "p" > ,< / span > < span class = "o" > **< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > add_template_vars< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > run< / span > < span class = "p" > (< / span > < span class = "n" > templatefile< / span > < span class = "p" > ,< / span > < span class = "n" > kernels< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > kernels< / span > < span class = "p" > )< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > treeinfo_data< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > _runner< / span > < span class = "o" > .< / span > < span class = "n" > results< / span > < span class = "o" > .< / span > < span class = "n" > treeinfo< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > implantisomd5< / span > < span class = "p" > ()< / span >
< / div >
< div class = "viewcode-block" id = "TreeBuilder.implantisomd5" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.TreeBuilder.implantisomd5" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > implantisomd5< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "k" > for< / span > < span class = "n" > _section< / span > < span class = "p" > ,< / span > < span class = "n" > data< / span > < span class = "ow" > in< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > treeinfo_data< / span > < span class = "o" > .< / span > < span class = "n" > items< / span > < span class = "p" > ():< / span >
< span class = "k" > if< / span > < span class = "s" > ' boot.iso' < / span > < span class = "ow" > in< / span > < span class = "n" > data< / span > < span class = "p" > :< / span >
< span class = "n" > iso< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > outroot< / span > < span class = "p" > ,< / span > < span class = "n" > data< / span > < span class = "p" > [< / span > < span class = "s" > ' boot.iso' < / span > < span class = "p" > ])< / span >
< span class = "n" > runcmd< / span > < span class = "p" > ([< / span > < span class = "s" > " implantisomd5" < / span > < span class = "p" > ,< / span > < span class = "n" > iso< / span > < span class = "p" > ])< / span >
< / div >
< span class = "nd" > @property< / span >
< div class = "viewcode-block" id = "TreeBuilder.dracut_hooks_path" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.TreeBuilder.dracut_hooks_path" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > dracut_hooks_path< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return the path to the lorax dracut hooks scripts< / span >
< span class = "sd" > Use the configured share dir if it is setup,< / span >
< span class = "sd" > otherwise default to /usr/share/lorax/dracut_hooks< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > if< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > templatedir< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > templatedir< / span > < span class = "p" > ,< / span > < span class = "s" > " dracut_hooks" < / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "s" > " /usr/share/lorax/dracut_hooks" < / span >
< / div >
< div class = "viewcode-block" id = "TreeBuilder.copy_dracut_hooks" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.TreeBuilder.copy_dracut_hooks" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > copy_dracut_hooks< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > hooks< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Copy the hook scripts in hooks into the installroot' s /tmp/< / span >
< span class = "sd" > and return a list of commands to pass to dracut when creating the< / span >
< span class = "sd" > initramfs< / span >
< span class = "sd" > hooks is a list of tuples with the name of the hook script and the< / span >
< span class = "sd" > target dracut hook directory< / span >
< span class = "sd" > (eg. [(" 99anaconda-copy-ks.sh" , " /lib/dracut/hooks/pre-pivot" )])< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > dracut_commands< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "k" > for< / span > < span class = "n" > hook_script< / span > < span class = "p" > ,< / span > < span class = "n" > dracut_path< / span > < span class = "ow" > in< / span > < span class = "n" > hooks< / span > < span class = "p" > :< / span >
< span class = "n" > src< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > dracut_hooks_path< / span > < span class = "p" > ,< / span > < span class = "n" > hook_script< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "n" > src< / span > < span class = "p" > ):< / span >
< span class = "n" > logger< / span > < span class = "o" > .< / span > < span class = "n" > error< / span > < span class = "p" > (< / span > < span class = "s" > " Missing lorax dracut hook script < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "p" > ,< / span > < span class = "p" > (< / span > < span class = "n" > src< / span > < span class = "p" > ))< / span >
< span class = "k" > continue< / span >
< span class = "n" > dst< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > vars< / span > < span class = "o" > .< / span > < span class = "n" > inroot< / span > < span class = "p" > ,< / span > < span class = "s" > " /tmp/" < / span > < span class = "p" > ,< / span > < span class = "n" > hook_script< / span > < span class = "p" > )< / span >
< span class = "n" > copy2< / span > < span class = "p" > (< / span > < span class = "n" > src< / span > < span class = "p" > ,< / span > < span class = "n" > dst< / span > < span class = "p" > )< / span >
< span class = "n" > dracut_commands< / span > < span class = "o" > +=< / span > < span class = "p" > [< / span > < span class = "s" > " --include" < / span > < span class = "p" > ,< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "s" > " /tmp/" < / span > < span class = "p" > ,< / span > < span class = "n" > hook_script< / span > < span class = "p" > ),< / span >
< span class = "n" > dracut_path< / span > < span class = "p" > ]< / span >
< span class = "k" > return< / span > < span class = "n" > dracut_commands< / span >
< span class = "c" > #### TreeBuilder helper functions< / span >
< / div > < / div >
< div class = "viewcode-block" id = "findkernels" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.findkernels" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > findkernels< / span > < span class = "p" > (< / span > < span class = "n" > root< / span > < span class = "o" > =< / span > < span class = "s" > " /" < / span > < span class = "p" > ,< / span > < span class = "n" > kdir< / span > < span class = "o" > =< / span > < span class = "s" > " boot" < / span > < span class = "p" > ):< / span >
< span class = "c" > # To find possible flavors, awk ' /BuildKernel/ { print $4 }' kernel.spec< / span >
< span class = "n" > flavors< / span > < span class = "o" > =< / span > < span class = "p" > (< / span > < span class = "s" > ' debug' < / span > < span class = "p" > ,< / span > < span class = "s" > ' PAE' < / span > < span class = "p" > ,< / span > < span class = "s" > ' PAEdebug' < / span > < span class = "p" > ,< / span > < span class = "s" > ' smp' < / span > < span class = "p" > ,< / span > < span class = "s" > ' xen' < / span > < span class = "p" > ,< / span > < span class = "s" > ' lpae' < / span > < span class = "p" > )< / span >
< span class = "n" > kre< / span > < span class = "o" > =< / span > < span class = "n" > re< / span > < span class = "o" > .< / span > < span class = "n" > compile< / span > < span class = "p" > (< / span > < span class = "s" > r" vmlinuz-(?P< version> .+?\.(?P< arch> [a-z0-9_]+)" < / span >
< span class = "s" > r" (.(?P< flavor> {0}))?)$" < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "s" > " |" < / span > < span class = "o" > .< / span > < span class = "n" > join< / span > < span class = "p" > (< / span > < span class = "n" > flavors< / span > < span class = "p" > )))< / span >
< span class = "n" > kernels< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "n" > bootfiles< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > listdir< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root< / span > < span class = "p" > ,< / span > < span class = "n" > kdir< / span > < span class = "p" > ))< / span >
< span class = "k" > for< / span > < span class = "n" > f< / span > < span class = "ow" > in< / span > < span class = "n" > bootfiles< / span > < span class = "p" > :< / span >
< span class = "n" > match< / span > < span class = "o" > =< / span > < span class = "n" > kre< / span > < span class = "o" > .< / span > < span class = "n" > match< / span > < span class = "p" > (< / span > < span class = "n" > f< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > match< / span > < span class = "p" > :< / span >
< span class = "n" > kernel< / span > < span class = "o" > =< / span > < span class = "n" > DataHolder< / span > < span class = "p" > (< / span > < span class = "n" > path< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > kdir< / span > < span class = "p" > ,< / span > < span class = "n" > f< / span > < span class = "p" > ))< / span >
< span class = "n" > kernel< / span > < span class = "o" > .< / span > < span class = "n" > update< / span > < span class = "p" > (< / span > < span class = "n" > match< / span > < span class = "o" > .< / span > < span class = "n" > groupdict< / span > < span class = "p" > ())< / span > < span class = "c" > # sets version, arch, flavor< / span >
< span class = "n" > kernels< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > kernel< / span > < span class = "p" > )< / span >
< span class = "c" > # look for associated initrd/initramfs/etc.< / span >
< span class = "k" > for< / span > < span class = "n" > kernel< / span > < span class = "ow" > in< / span > < span class = "n" > kernels< / span > < span class = "p" > :< / span >
< span class = "k" > for< / span > < span class = "n" > f< / span > < span class = "ow" > in< / span > < span class = "n" > bootfiles< / span > < span class = "p" > :< / span >
< span class = "k" > if< / span > < span class = "n" > f< / span > < span class = "o" > .< / span > < span class = "n" > endswith< / span > < span class = "p" > (< / span > < span class = "s" > ' -' < / span > < span class = "o" > +< / span > < span class = "n" > kernel< / span > < span class = "o" > .< / span > < span class = "n" > version< / span > < span class = "o" > +< / span > < span class = "s" > ' .img' < / span > < span class = "p" > ):< / span >
< span class = "n" > imgtype< / span > < span class = "p" > ,< / span > < span class = "n" > _rest< / span > < span class = "o" > =< / span > < span class = "n" > f< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > (< / span > < span class = "s" > ' -' < / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "c" > # special backwards-compat case< / span >
< span class = "k" > if< / span > < span class = "n" > imgtype< / span > < span class = "o" > ==< / span > < span class = "s" > ' initramfs' < / span > < span class = "p" > :< / span >
< span class = "n" > imgtype< / span > < span class = "o" > =< / span > < span class = "s" > ' initrd' < / span >
< span class = "n" > kernel< / span > < span class = "p" > [< / span > < span class = "n" > imgtype< / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > DataHolder< / span > < span class = "p" > (< / span > < span class = "n" > path< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > kdir< / span > < span class = "p" > ,< / span > < span class = "n" > f< / span > < span class = "p" > ))< / span >
< span class = "n" > logger< / span > < span class = "o" > .< / span > < span class = "n" > debug< / span > < span class = "p" > (< / span > < span class = "s" > " kernels=< / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "p" > ,< / span > < span class = "n" > kernels< / span > < span class = "p" > )< / span >
< span class = "k" > return< / span > < span class = "n" > kernels< / span >
< span class = "c" > # udev whitelist: ' a-zA-Z0-9#+.:=@_-' (see is_whitelisted in libudev-util.c)< / span > < / div >
< span class = "n" > udev_blacklist< / span > < span class = "o" > =< / span > < span class = "s" > ' !" $%& < / span > < span class = "se" > \' < / span > < span class = "s" > ()*,/;< > ?[< / span > < span class = "se" > \\< / span > < span class = "s" > ]^`{|}~' < / span > < span class = "c" > # ASCII printable, minus whitelist< / span >
< span class = "n" > udev_blacklist< / span > < span class = "o" > +=< / span > < span class = "s" > ' ' < / span > < span class = "o" > .< / span > < span class = "n" > join< / span > < span class = "p" > (< / span > < span class = "nb" > chr< / span > < span class = "p" > (< / span > < span class = "n" > i< / span > < span class = "p" > )< / span > < span class = "k" > for< / span > < span class = "n" > i< / span > < span class = "ow" > in< / span > < span class = "nb" > range< / span > < span class = "p" > (< / span > < span class = "mi" > 32< / span > < span class = "p" > ))< / span > < span class = "c" > # ASCII non-printable< / span >
< div class = "viewcode-block" id = "udev_escape" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.udev_escape" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > udev_escape< / span > < span class = "p" > (< / span > < span class = "n" > label< / span > < span class = "p" > ):< / span >
< span class = "n" > out< / span > < span class = "o" > =< / span > < span class = "s" > ' ' < / span >
< span class = "k" > for< / span > < span class = "n" > ch< / span > < span class = "ow" > in< / span > < span class = "n" > label< / span > < span class = "p" > :< / span >
< span class = "n" > out< / span > < span class = "o" > +=< / span > < span class = "n" > ch< / span > < span class = "k" > if< / span > < span class = "n" > ch< / span > < span class = "ow" > not< / span > < span class = "ow" > in< / span > < span class = "n" > udev_blacklist< / span > < span class = "k" > else< / span > < span class = "s" > ' < / span > < span class = "se" > \\< / span > < span class = "s" > x< / span > < span class = "si" > %02x< / span > < span class = "s" > ' < / span > < span class = "o" > %< / span > < span class = "nb" > ord< / span > < span class = "p" > (< / span > < span class = "n" > ch< / span > < span class = "p" > )< / span >
< span class = "k" > return< / span > < span class = "n" > out< / span >
< / div >
< div class = "viewcode-block" id = "string_lower" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.treebuilder.string_lower" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > string_lower< / span > < span class = "p" > (< / span > < span class = "n" > string< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return a lowercase string.< / span >
< span class = "sd" > :param string: String to lowercase< / span >
< span class = "sd" > This is used as a filter in the templates.< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > return< / span > < span class = "n" > string< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ()< / span > < / div >
< / pre > < / div >
< / div >
< footer >
< hr / >
< div role = "contentinfo" >
< p >
© Copyright 2015, Red Hat, Inc..
< / p >
< / div >
Built with < a href = "http://sphinx-doc.org/" > Sphinx< / a > using a < a href = "https://github.com/snide/sphinx_rtd_theme" > theme< / a > provided by < a href = "https://readthedocs.org" > Read the Docs< / a > .
2015-07-10 18:39:39 +00:00
2015-05-11 23:44:09 +00:00
< / footer >
2015-07-10 18:39:39 +00:00
2015-05-11 23:44:09 +00:00
< / div >
< / div >
< / section >
< / div >
< script type = "text/javascript" >
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
2015-12-04 18:12:19 +00:00
VERSION:'24.6',
2015-05-11 23:44:09 +00:00
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
< / script >
< script type = "text/javascript" src = "../../_static/jquery.js" > < / script >
< script type = "text/javascript" src = "../../_static/underscore.js" > < / script >
< script type = "text/javascript" src = "../../_static/doctools.js" > < / script >
< script type = "text/javascript" src = "../../_static/js/theme.js" > < / script >
< script type = "text/javascript" >
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
< / script >
< / body >
< / html >