624 lines
75 KiB
HTML
624 lines
75 KiB
HTML
|
|
|
|
<!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">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>pylorax — Lorax 24.6 documentation</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="top" title="Lorax 24.6 documentation" href="../index.html"/>
|
|
<link rel="up" title="Module code" href="index.html"/>
|
|
|
|
|
|
<script src="_static/js/modernizr.min.js"></script>
|
|
|
|
</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">
|
|
|
|
|
|
|
|
<a href="../index.html" class="icon icon-home"> Lorax
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
</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>
|
|
<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>
|
|
<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>
|
|
<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>
|
|
</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>pylorax</li>
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
</div>
|
|
<div role="main" class="document">
|
|
|
|
<h1>Source code for pylorax</h1><div class="highlight"><pre>
|
|
<span class="c">#</span>
|
|
<span class="c"># __init__.py</span>
|
|
<span class="c">#</span>
|
|
<span class="c"># Copyright (C) 2010-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"># Red Hat Author(s): Martin Gracik <mgracik@redhat.com></span>
|
|
<span class="c"># David Cantrell <dcantrell@redhat.com></span>
|
|
<span class="c"># Will Woods <wwoods@redhat.com></span>
|
|
|
|
<span class="c"># set up logging</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"</span><span class="p">)</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">NullHandler</span><span class="p">())</span>
|
|
|
|
<span class="n">program_log</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">"program"</span><span class="p">)</span>
|
|
|
|
<span class="kn">import</span> <span class="nn">sys</span>
|
|
<span class="kn">import</span> <span class="nn">os</span>
|
|
<span class="kn">import</span> <span class="nn">configparser</span>
|
|
<span class="kn">import</span> <span class="nn">tempfile</span>
|
|
<span class="kn">import</span> <span class="nn">locale</span>
|
|
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="kn">import</span> <span class="n">CalledProcessError</span>
|
|
<span class="kn">import</span> <span class="nn">selinux</span>
|
|
|
|
<span class="kn">from</span> <span class="nn">pylorax.base</span> <span class="kn">import</span> <span class="n">BaseLoraxClass</span><span class="p">,</span> <span class="n">DataHolder</span>
|
|
<span class="kn">import</span> <span class="nn">pylorax.output</span> <span class="kn">as</span> <span class="nn">output</span>
|
|
|
|
<span class="kn">import</span> <span class="nn">dnf</span>
|
|
|
|
<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="p">,</span> <span class="n">linktree</span>
|
|
|
|
<span class="kn">from</span> <span class="nn">pylorax.treebuilder</span> <span class="kn">import</span> <span class="n">RuntimeBuilder</span><span class="p">,</span> <span class="n">TreeBuilder</span>
|
|
<span class="kn">from</span> <span class="nn">pylorax.buildstamp</span> <span class="kn">import</span> <span class="n">BuildStamp</span>
|
|
<span class="kn">from</span> <span class="nn">pylorax.treeinfo</span> <span class="kn">import</span> <span class="n">TreeInfo</span>
|
|
<span class="kn">from</span> <span class="nn">pylorax.discinfo</span> <span class="kn">import</span> <span class="n">DiscInfo</span>
|
|
<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="c"># List of drivers to remove on ppc64 arch to keep initrd < 32MiB</span>
|
|
<span class="n">REMOVE_PPC64_DRIVERS</span> <span class="o">=</span> <span class="s">"floppy scsi_debug nouveau radeon cirrus mgag200"</span>
|
|
<span class="n">REMOVE_PPC64_MODULES</span> <span class="o">=</span> <span class="s">"drm plymouth"</span>
|
|
|
|
<div class="viewcode-block" id="ArchData"><a class="viewcode-back" href="../pylorax.html#pylorax.ArchData">[docs]</a><span class="k">class</span> <span class="nc">ArchData</span><span class="p">(</span><span class="n">DataHolder</span><span class="p">):</span>
|
|
<span class="n">lib64_arches</span> <span class="o">=</span> <span class="p">(</span><span class="s">"x86_64"</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="s">"s390x"</span><span class="p">,</span> <span class="s">"ia64"</span><span class="p">,</span> <span class="s">"aarch64"</span><span class="p">)</span>
|
|
<span class="n">bcj_arch</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">i386</span><span class="o">=</span><span class="s">"x86"</span><span class="p">,</span> <span class="n">x86_64</span><span class="o">=</span><span class="s">"x86"</span><span class="p">,</span>
|
|
<span class="n">ppc</span><span class="o">=</span><span class="s">"powerpc"</span><span class="p">,</span> <span class="n">ppc64</span><span class="o">=</span><span class="s">"powerpc"</span><span class="p">,</span> <span class="n">ppc64le</span><span class="o">=</span><span class="s">"powerpc"</span><span class="p">,</span>
|
|
<span class="n">arm</span><span class="o">=</span><span class="s">"arm"</span><span class="p">,</span> <span class="n">armhfp</span><span class="o">=</span><span class="s">"arm"</span><span class="p">)</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">buildarch</span><span class="p">):</span>
|
|
<span class="nb">super</span><span class="p">(</span><span class="n">ArchData</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__init__</span><span class="p">()</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">buildarch</span> <span class="o">=</span> <span class="n">buildarch</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">basearch</span> <span class="o">=</span> <span class="n">dnf</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">buildarch</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">libdir</span> <span class="o">=</span> <span class="s">"lib64"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basearch</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">lib64_arches</span> <span class="k">else</span> <span class="s">"lib"</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">bcj</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bcj_arch</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basearch</span><span class="p">)</span>
|
|
</div>
|
|
<div class="viewcode-block" id="Lorax"><a class="viewcode-back" href="../pylorax.html#pylorax.Lorax">[docs]</a><span class="k">class</span> <span class="nc">Lorax</span><span class="p">(</span><span class="n">BaseLoraxClass</span><span class="p">):</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">BaseLoraxClass</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">_configured</span> <span class="o">=</span> <span class="bp">False</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">product</span> <span class="o">=</span> <span class="bp">None</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">workdir</span> <span class="o">=</span> <span class="bp">None</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">arch</span> <span class="o">=</span> <span class="bp">None</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span> <span class="o">=</span> <span class="bp">None</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">inroot</span> <span class="o">=</span> <span class="bp">None</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">debug</span> <span class="o">=</span> <span class="bp">False</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span> <span class="o">=</span> <span class="bp">None</span>
|
|
|
|
<span class="c"># set locale to C</span>
|
|
<span class="n">locale</span><span class="o">.</span><span class="n">setlocale</span><span class="p">(</span><span class="n">locale</span><span class="o">.</span><span class="n">LC_ALL</span><span class="p">,</span> <span class="s">'C'</span><span class="p">)</span>
|
|
|
|
<div class="viewcode-block" id="Lorax.configure"><a class="viewcode-back" href="../pylorax.html#pylorax.Lorax.configure">[docs]</a> <span class="k">def</span> <span class="nf">configure</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">conf_file</span><span class="o">=</span><span class="s">"/etc/lorax/lorax.conf"</span><span class="p">):</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span> <span class="o">=</span> <span class="n">configparser</span><span class="o">.</span><span class="n">SafeConfigParser</span><span class="p">()</span>
|
|
|
|
<span class="c"># set defaults</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">add_section</span><span class="p">(</span><span class="s">"lorax"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"lorax"</span><span class="p">,</span> <span class="s">"debug"</span><span class="p">,</span> <span class="s">"1"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"lorax"</span><span class="p">,</span> <span class="s">"sharedir"</span><span class="p">,</span> <span class="s">"/usr/share/lorax"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"lorax"</span><span class="p">,</span> <span class="s">"logdir"</span><span class="p">,</span> <span class="s">"/var/log/lorax"</span><span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">add_section</span><span class="p">(</span><span class="s">"output"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"output"</span><span class="p">,</span> <span class="s">"colors"</span><span class="p">,</span> <span class="s">"1"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"output"</span><span class="p">,</span> <span class="s">"encoding"</span><span class="p">,</span> <span class="s">"utf-8"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"output"</span><span class="p">,</span> <span class="s">"ignorelist"</span><span class="p">,</span> <span class="s">"/usr/share/lorax/ignorelist"</span><span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">add_section</span><span class="p">(</span><span class="s">"templates"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"templates"</span><span class="p">,</span> <span class="s">"ramdisk"</span><span class="p">,</span> <span class="s">"ramdisk.ltmpl"</span><span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">add_section</span><span class="p">(</span><span class="s">"compression"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"compression"</span><span class="p">,</span> <span class="s">"type"</span><span class="p">,</span> <span class="s">"xz"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"compression"</span><span class="p">,</span> <span class="s">"args"</span><span class="p">,</span> <span class="s">""</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">"compression"</span><span class="p">,</span> <span class="s">"bcj"</span><span class="p">,</span> <span class="s">"on"</span><span class="p">)</span>
|
|
|
|
<span class="c"># read the config file</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">isfile</span><span class="p">(</span><span class="n">conf_file</span><span class="p">):</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">conf_file</span><span class="p">)</span>
|
|
|
|
<span class="c"># set up the output</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">debug</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">getboolean</span><span class="p">(</span><span class="s">"lorax"</span><span class="p">,</span> <span class="s">"debug"</span><span class="p">)</span>
|
|
<span class="n">output_level</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">DEBUG</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">debug</span> <span class="k">else</span> <span class="n">output</span><span class="o">.</span><span class="n">INFO</span>
|
|
|
|
<span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">isatty</span><span class="p">():</span>
|
|
<span class="n">colors</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">getboolean</span><span class="p">(</span><span class="s">"output"</span><span class="p">,</span> <span class="s">"colors"</span><span class="p">)</span>
|
|
<span class="k">else</span><span class="p">:</span>
|
|
<span class="n">colors</span> <span class="o">=</span> <span class="bp">False</span>
|
|
<span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"output"</span><span class="p">,</span> <span class="s">"encoding"</span><span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">output</span><span class="o">.</span><span class="n">basic_config</span><span class="p">(</span><span class="n">output_level</span><span class="o">=</span><span class="n">output_level</span><span class="p">,</span>
|
|
<span class="n">colors</span><span class="o">=</span><span class="n">colors</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">)</span>
|
|
|
|
<span class="n">ignorelist</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"output"</span><span class="p">,</span> <span class="s">"ignorelist"</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">isfile</span><span class="p">(</span><span class="n">ignorelist</span><span class="p">):</span>
|
|
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">ignorelist</span><span class="p">,</span> <span class="s">"r"</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">line</span> <span class="ow">in</span> <span class="n">fobj</span><span class="p">:</span>
|
|
<span class="n">line</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">strip</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="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">"#"</span><span class="p">):</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">output</span><span class="o">.</span><span class="n">ignore</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
|
|
|
|
<span class="c"># cron does not have sbin in PATH,</span>
|
|
<span class="c"># so we have to add it ourselves</span>
|
|
<span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s">"PATH"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"{0}:/sbin:/usr/sbin"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s">"PATH"</span><span class="p">])</span>
|
|
|
|
<span class="c"># remove some environmental variables that can cause problems with package scripts</span>
|
|
<span class="n">env_remove</span> <span class="o">=</span> <span class="p">(</span><span class="s">'DISPLAY'</span><span class="p">,</span> <span class="s">'DBUS_SESSION_BUS_ADDRESS'</span><span class="p">)</span>
|
|
<span class="nb">list</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">env_remove</span> <span class="k">if</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">_configured</span> <span class="o">=</span> <span class="bp">True</span>
|
|
</div>
|
|
<div class="viewcode-block" id="Lorax.init_stream_logging"><a class="viewcode-back" href="../pylorax.html#pylorax.Lorax.init_stream_logging">[docs]</a> <span class="k">def</span> <span class="nf">init_stream_logging</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
|
<span class="n">sh</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">()</span>
|
|
<span class="n">sh</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">sh</span><span class="p">)</span>
|
|
</div>
|
|
<div class="viewcode-block" id="Lorax.init_file_logging"><a class="viewcode-back" href="../pylorax.html#pylorax.Lorax.init_file_logging">[docs]</a> <span class="k">def</span> <span class="nf">init_file_logging</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">logdir</span><span class="p">,</span> <span class="n">logname</span><span class="o">=</span><span class="s">"pylorax.log"</span><span class="p">):</span>
|
|
<span class="n">fh</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">FileHandler</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">logdir</span><span class="p">,</span> <span class="n">logname</span><span class="p">),</span> <span class="n">mode</span><span class="o">=</span><span class="s">"w"</span><span class="p">)</span>
|
|
<span class="n">fh</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">fh</span><span class="p">)</span>
|
|
</div>
|
|
<div class="viewcode-block" id="Lorax.run"><a class="viewcode-back" href="../pylorax.html#pylorax.Lorax.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dbo</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">version</span><span class="p">,</span> <span class="n">release</span><span class="p">,</span> <span class="n">variant</span><span class="o">=</span><span class="s">""</span><span class="p">,</span> <span class="n">bugurl</span><span class="o">=</span><span class="s">""</span><span class="p">,</span>
|
|
<span class="n">isfinal</span><span class="o">=</span><span class="bp">False</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="n">outputdir</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">buildarch</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">volid</span><span class="o">=</span><span class="bp">None</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">remove_temp</span><span class="o">=</span><span class="bp">False</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">size</span><span class="o">=</span><span class="mi">2</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">add_arch_templates</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
|
|
<span class="n">add_arch_template_vars</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
|
|
<span class="n">verify</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
|
|
|
|
<span class="k">assert</span> <span class="bp">self</span><span class="o">.</span><span class="n">_configured</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="c"># get lorax version</span>
|
|
<span class="k">try</span><span class="p">:</span>
|
|
<span class="kn">import</span> <span class="nn">pylorax.version</span>
|
|
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
|
|
<span class="n">vernum</span> <span class="o">=</span> <span class="s">"devel"</span>
|
|
<span class="k">else</span><span class="p">:</span>
|
|
<span class="n">vernum</span> <span class="o">=</span> <span class="n">pylorax</span><span class="o">.</span><span class="n">version</span><span class="o">.</span><span class="n">num</span>
|
|
|
|
<span class="k">if</span> <span class="n">domacboot</span><span class="p">:</span>
|
|
<span class="k">try</span><span class="p">:</span>
|
|
<span class="n">runcmd</span><span class="p">([</span><span class="s">"rpm"</span><span class="p">,</span> <span class="s">"-q"</span><span class="p">,</span> <span class="s">"hfsplus-tools"</span><span class="p">])</span>
|
|
<span class="k">except</span> <span class="n">CalledProcessError</span><span class="p">:</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">critical</span><span class="p">(</span><span class="s">"you need to install hfsplus-tools to create mac images"</span><span class="p">)</span>
|
|
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
|
|
|
<span class="c"># set up work directory</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">workdir</span> <span class="o">=</span> <span class="n">workdir</span> <span class="ow">or</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s">"pylorax.work."</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">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">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="bp">self</span><span class="o">.</span><span class="n">workdir</span><span class="p">)</span>
|
|
|
|
<span class="c"># set up log directory</span>
|
|
<span class="n">logdir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"lorax"</span><span class="p">,</span> <span class="s">"logdir"</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">isdir</span><span class="p">(</span><span class="n">logdir</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">logdir</span><span class="p">)</span>
|
|
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">init_stream_logging</span><span class="p">()</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">init_file_logging</span><span class="p">(</span><span class="n">logdir</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">"version is </span><span class="si">%s</span><span class="s">"</span><span class="p">,</span> <span class="n">vernum</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">"using work directory </span><span class="si">%s</span><span class="s">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">workdir</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">"using log directory </span><span class="si">%s</span><span class="s">"</span><span class="p">,</span> <span class="n">logdir</span><span class="p">)</span>
|
|
|
|
<span class="c"># set up output directory</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span> <span class="o">=</span> <span class="n">outputdir</span> <span class="ow">or</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s">"pylorax.out."</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">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">outputdir</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="bp">self</span><span class="o">.</span><span class="n">outputdir</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">"using output directory </span><span class="si">%s</span><span class="s">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span><span class="p">)</span>
|
|
|
|
<span class="c"># do we have root privileges?</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">"checking for root privileges"</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">geteuid</span><span class="p">()</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">critical</span><span class="p">(</span><span class="s">"no root privileges"</span><span class="p">)</span>
|
|
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
|
|
|
<span class="c"># is selinux disabled?</span>
|
|
<span class="c"># With selinux in enforcing mode the rpcbind package required for</span>
|
|
<span class="c"># dracut nfs module, which is in turn required by anaconda module,</span>
|
|
<span class="c"># will not get installed, because it's preinstall scriptlet fails,</span>
|
|
<span class="c"># resulting in an incomplete initial ramdisk image.</span>
|
|
<span class="c"># The reason is that the scriptlet runs tools from the shadow-utils</span>
|
|
<span class="c"># package in chroot, particularly groupadd and useradd to add the</span>
|
|
<span class="c"># required rpc group and rpc user. This operation fails, because</span>
|
|
<span class="c"># the selinux context on files in the chroot, that the shadow-utils</span>
|
|
<span class="c"># tools need to access (/etc/group, /etc/passwd, /etc/shadow etc.),</span>
|
|
<span class="c"># is wrong and selinux therefore disallows access to these files.</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">"checking the selinux mode"</span><span class="p">)</span>
|
|
<span class="k">if</span> <span class="n">selinux</span><span class="o">.</span><span class="n">is_selinux_enabled</span><span class="p">()</span> <span class="ow">and</span> <span class="n">selinux</span><span class="o">.</span><span class="n">security_getenforce</span><span class="p">():</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">critical</span><span class="p">(</span><span class="s">"selinux must be disabled or in Permissive mode"</span><span class="p">)</span>
|
|
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
|
|
|
<span class="c"># do we have a proper dnf base object?</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">"checking dnf base object"</span><span class="p">)</span>
|
|
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dbo</span><span class="p">,</span> <span class="n">dnf</span><span class="o">.</span><span class="n">Base</span><span class="p">):</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">critical</span><span class="p">(</span><span class="s">"no dnf base object"</span><span class="p">)</span>
|
|
<span class="n">sys</span><span class="o">.</span><span class="n">exit</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">inroot</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="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">"using install root: </span><span class="si">%s</span><span class="s">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">inroot</span><span class="p">)</span>
|
|
|
|
<span class="k">if</span> <span class="ow">not</span> <span class="n">buildarch</span><span class="p">:</span>
|
|
<span class="n">buildarch</span> <span class="o">=</span> <span class="n">get_buildarch</span><span class="p">(</span><span class="n">dbo</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">"setting up build architecture"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">arch</span> <span class="o">=</span> <span class="n">ArchData</span><span class="p">(</span><span class="n">buildarch</span><span class="p">)</span>
|
|
<span class="k">for</span> <span class="n">attr</span> <span class="ow">in</span> <span class="p">(</span><span class="s">'buildarch'</span><span class="p">,</span> <span class="s">'basearch'</span><span class="p">,</span> <span class="s">'libdir'</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">"self.arch.</span><span class="si">%s</span><span class="s"> = </span><span class="si">%s</span><span class="s">"</span><span class="p">,</span> <span class="n">attr</span><span class="p">,</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="p">,</span><span class="n">attr</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">"setting up build parameters"</span><span class="p">)</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">product</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">product</span><span class="p">,</span> <span class="n">version</span><span class="o">=</span><span class="n">version</span><span class="p">,</span> <span class="n">release</span><span class="o">=</span><span class="n">release</span><span class="p">,</span>
|
|
<span class="n">variant</span><span class="o">=</span><span class="n">variant</span><span class="p">,</span> <span class="n">bugurl</span><span class="o">=</span><span class="n">bugurl</span><span class="p">,</span> <span class="n">isfinal</span><span class="o">=</span><span class="n">isfinal</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">"product data: </span><span class="si">%s</span><span class="s">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="p">)</span>
|
|
|
|
<span class="c"># NOTE: if you change isolabel, you need to change pungi to match, or</span>
|
|
<span class="c"># the pungi images won't boot.</span>
|
|
<span class="n">isolabel</span> <span class="o">=</span> <span class="n">volid</span> <span class="ow">or</span> <span class="s">"</span><span class="si">%s</span><span class="s">-</span><span class="si">%s</span><span class="s">-</span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">version</span><span class="p">,</span> <span class="bp">self</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">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">isolabel</span><span class="p">)</span> <span class="o">></span> <span class="mi">32</span><span class="p">:</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">fatal</span><span class="p">(</span><span class="s">"the volume id cannot be longer than 32 characters"</span><span class="p">)</span>
|
|
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
|
|
|
<span class="n">templatedir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"lorax"</span><span class="p">,</span> <span class="s">"sharedir"</span><span class="p">)</span>
|
|
<span class="c"># NOTE: rb.root = dbo.conf.installroot (== self.inroot)</span>
|
|
<span class="n">rb</span> <span class="o">=</span> <span class="n">RuntimeBuilder</span><span class="p">(</span><span class="n">product</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="p">,</span> <span class="n">arch</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">arch</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="n">installpkgs</span><span class="o">=</span><span class="n">installpkgs</span><span class="p">,</span>
|
|
<span class="n">add_templates</span><span class="o">=</span><span class="n">add_templates</span><span class="p">,</span>
|
|
<span class="n">add_template_vars</span><span class="o">=</span><span class="n">add_template_vars</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">"installing runtime packages"</span><span class="p">)</span>
|
|
<span class="n">rb</span><span class="o">.</span><span class="n">install</span><span class="p">()</span>
|
|
|
|
<span class="c"># write .buildstamp</span>
|
|
<span class="n">buildstamp</span> <span class="o">=</span> <span class="n">BuildStamp</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">version</span><span class="p">,</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">bugurl</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">isfinal</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">buildarch</span><span class="p">)</span>
|
|
|
|
<span class="n">buildstamp</span><span class="o">.</span><span class="n">write</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">inroot</span><span class="p">,</span> <span class="s">".buildstamp"</span><span class="p">))</span>
|
|
|
|
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">debug</span><span class="p">:</span>
|
|
<span class="n">rb</span><span class="o">.</span><span class="n">writepkglists</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">logdir</span><span class="p">,</span> <span class="s">"pkglists"</span><span class="p">))</span>
|
|
<span class="n">rb</span><span class="o">.</span><span class="n">writepkgsizes</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">logdir</span><span class="p">,</span> <span class="s">"original-pkgsizes.txt"</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 post-install configuration"</span><span class="p">)</span>
|
|
<span class="n">rb</span><span class="o">.</span><span class="n">postinstall</span><span class="p">()</span>
|
|
|
|
<span class="c"># write .discinfo</span>
|
|
<span class="n">discinfo</span> <span class="o">=</span> <span class="n">DiscInfo</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">release</span><span class="p">,</span> <span class="bp">self</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">discinfo</span><span class="o">.</span><span class="n">write</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">outputdir</span><span class="p">,</span> <span class="s">".discinfo"</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">"backing up installroot"</span><span class="p">)</span>
|
|
<span class="n">installroot</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">workdir</span><span class="p">,</span> <span class="s">"installroot"</span><span class="p">)</span>
|
|
<span class="n">linktree</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inroot</span><span class="p">,</span> <span class="n">installroot</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">"generating kernel module metadata"</span><span class="p">)</span>
|
|
<span class="n">rb</span><span class="o">.</span><span class="n">generate_module_data</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">"cleaning unneeded files"</span><span class="p">)</span>
|
|
<span class="n">rb</span><span class="o">.</span><span class="n">cleanup</span><span class="p">()</span>
|
|
|
|
<span class="k">if</span> <span class="n">verify</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">"verifying the installroot"</span><span class="p">)</span>
|
|
<span class="k">if</span> <span class="ow">not</span> <span class="n">rb</span><span class="o">.</span><span class="n">verify</span><span class="p">():</span>
|
|
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
|
<span class="k">else</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">"Skipping verify"</span><span class="p">)</span>
|
|
|
|
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">debug</span><span class="p">:</span>
|
|
<span class="n">rb</span><span class="o">.</span><span class="n">writepkgsizes</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">logdir</span><span class="p">,</span> <span class="s">"final-pkgsizes.txt"</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">"creating the runtime image"</span><span class="p">)</span>
|
|
<span class="n">runtime</span> <span class="o">=</span> <span class="s">"images/install.img"</span>
|
|
<span class="n">compression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"compression"</span><span class="p">,</span> <span class="s">"type"</span><span class="p">)</span>
|
|
<span class="n">compressargs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"compression"</span><span class="p">,</span> <span class="s">"args"</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> <span class="c"># pylint: disable=no-member</span>
|
|
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">getboolean</span><span class="p">(</span><span class="s">"compression"</span><span class="p">,</span> <span class="s">"bcj"</span><span class="p">):</span>
|
|
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">bcj</span><span class="p">:</span>
|
|
<span class="n">compressargs</span> <span class="o">+=</span> <span class="p">[</span><span class="s">"-Xbcj"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">bcj</span><span class="p">]</span>
|
|
<span class="k">else</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">"no BCJ filter for arch </span><span class="si">%s</span><span class="s">"</span><span class="p">,</span> <span class="bp">self</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">rb</span><span class="o">.</span><span class="n">create_runtime</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">installroot</span><span class="p">,</span><span class="n">runtime</span><span class="p">),</span>
|
|
<span class="n">compression</span><span class="o">=</span><span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="n">compressargs</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="n">rb</span><span class="o">.</span><span class="n">finished</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">"preparing to build output tree and boot images"</span><span class="p">)</span>
|
|
<span class="n">treebuilder</span> <span class="o">=</span> <span class="n">TreeBuilder</span><span class="p">(</span><span class="n">product</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="p">,</span> <span class="n">arch</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="p">,</span>
|
|
<span class="n">inroot</span><span class="o">=</span><span class="n">installroot</span><span class="p">,</span> <span class="n">outroot</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">outputdir</span><span class="p">,</span>
|
|
<span class="n">runtime</span><span class="o">=</span><span class="n">runtime</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">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">templatedir</span><span class="o">=</span><span class="n">templatedir</span><span class="p">,</span>
|
|
<span class="n">add_templates</span><span class="o">=</span><span class="n">add_arch_templates</span><span class="p">,</span>
|
|
<span class="n">add_template_vars</span><span class="o">=</span><span class="n">add_arch_template_vars</span><span class="p">,</span>
|
|
<span class="n">workdir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">workdir</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">"rebuilding initramfs images"</span><span class="p">)</span>
|
|
<span class="n">dracut_args</span> <span class="o">=</span> <span class="p">[</span><span class="s">"--xz"</span><span class="p">,</span> <span class="s">"--install"</span><span class="p">,</span> <span class="s">"/.buildstamp"</span><span class="p">,</span> <span class="s">"--no-early-microcode"</span><span class="p">]</span>
|
|
<span class="n">anaconda_args</span> <span class="o">=</span> <span class="n">dracut_args</span> <span class="o">+</span> <span class="p">[</span><span class="s">"--add"</span><span class="p">,</span> <span class="s">"anaconda pollcdrom qemu qemu-net"</span><span class="p">]</span>
|
|
|
|
<span class="c"># ppc64 cannot boot an initrd > 32MiB so remove some drivers</span>
|
|
<span class="k">if</span> <span class="bp">self</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="n">dracut_args</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="s">"--omit-drivers"</span><span class="p">,</span> <span class="n">REMOVE_PPC64_DRIVERS</span><span class="p">])</span>
|
|
|
|
<span class="c"># Only omit dracut modules from the initrd so that they're kept for</span>
|
|
<span class="c"># upgrade.img</span>
|
|
<span class="n">anaconda_args</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="s">"--omit"</span><span class="p">,</span> <span class="n">REMOVE_PPC64_MODULES</span><span class="p">])</span>
|
|
|
|
<span class="n">treebuilder</span><span class="o">.</span><span class="n">rebuild_initrds</span><span class="p">(</span><span class="n">add_args</span><span class="o">=</span><span class="n">anaconda_args</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">"populating output tree and building boot images"</span><span class="p">)</span>
|
|
<span class="n">treebuilder</span><span class="o">.</span><span class="n">build</span><span class="p">()</span>
|
|
|
|
<span class="c"># write .treeinfo file and we're done</span>
|
|
<span class="n">treeinfo</span> <span class="o">=</span> <span class="n">TreeInfo</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">version</span><span class="p">,</span>
|
|
<span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">variant</span><span class="p">,</span> <span class="bp">self</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">section</span><span class="p">,</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">treebuilder</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="n">treeinfo</span><span class="o">.</span><span class="n">add_section</span><span class="p">(</span><span class="n">section</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span>
|
|
<span class="n">treeinfo</span><span class="o">.</span><span class="n">write</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">outputdir</span><span class="p">,</span> <span class="s">".treeinfo"</span><span class="p">))</span>
|
|
|
|
<span class="c"># cleanup</span>
|
|
<span class="k">if</span> <span class="n">remove_temp</span><span class="p">:</span>
|
|
<span class="n">remove</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">workdir</span><span class="p">)</span>
|
|
|
|
</div></div>
|
|
<div class="viewcode-block" id="get_buildarch"><a class="viewcode-back" href="../pylorax.html#pylorax.get_buildarch">[docs]</a><span class="k">def</span> <span class="nf">get_buildarch</span><span class="p">(</span><span class="n">dbo</span><span class="p">):</span>
|
|
<span class="c"># get architecture of the available anaconda package</span>
|
|
<span class="n">buildarch</span> <span class="o">=</span> <span class="bp">None</span>
|
|
<span class="n">q</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">anaconda</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">name</span><span class="o">=</span><span class="s">"anaconda"</span><span class="p">):</span>
|
|
<span class="k">if</span> <span class="n">anaconda</span><span class="o">.</span><span class="n">arch</span> <span class="o">!=</span> <span class="s">"src"</span><span class="p">:</span>
|
|
<span class="n">buildarch</span> <span class="o">=</span> <span class="n">anaconda</span><span class="o">.</span><span class="n">arch</span>
|
|
<span class="k">break</span>
|
|
<span class="k">if</span> <span class="ow">not</span> <span class="n">buildarch</span><span class="p">:</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">critical</span><span class="p">(</span><span class="s">"no anaconda package in the repository"</span><span class="p">)</span>
|
|
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
|
|
|
<span class="k">return</span> <span class="n">buildarch</span>
|
|
|
|
</div>
|
|
<div class="viewcode-block" id="setup_logging"><a class="viewcode-back" href="../pylorax.html#pylorax.setup_logging">[docs]</a><span class="k">def</span> <span class="nf">setup_logging</span><span class="p">(</span><span class="n">logfile</span><span class="p">,</span> <span class="n">theLogger</span><span class="p">):</span>
|
|
<span class="sd">"""</span>
|
|
<span class="sd"> Setup the various logs</span>
|
|
|
|
<span class="sd"> :param logfile: filename to write the log to</span>
|
|
<span class="sd"> :type logfile: string</span>
|
|
<span class="sd"> :param theLogger: top-level logger</span>
|
|
<span class="sd"> :type theLogger: logging.Logger</span>
|
|
<span class="sd"> """</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">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</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">logfile</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">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</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">logfile</span><span class="p">)))</span>
|
|
|
|
<span class="c"># Setup logging to console and to logfile</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
|
|
<span class="n">theLogger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
|
|
|
|
<span class="n">sh</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">()</span>
|
|
<span class="n">sh</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span>
|
|
<span class="n">fmt</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span><span class="s">"</span><span class="si">%(asctime)s</span><span class="s">: </span><span class="si">%(message)s</span><span class="s">"</span><span class="p">)</span>
|
|
<span class="n">sh</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">fmt</span><span class="p">)</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">sh</span><span class="p">)</span>
|
|
<span class="n">theLogger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">sh</span><span class="p">)</span>
|
|
|
|
<span class="n">fh</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">FileHandler</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">logfile</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s">"w"</span><span class="p">)</span>
|
|
<span class="n">fh</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
|
|
<span class="n">fmt</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span><span class="s">"</span><span class="si">%(asctime)s</span><span class="s"> </span><span class="si">%(levelname)s</span><span class="s"> </span><span class="si">%(name)s</span><span class="s">: </span><span class="si">%(message)s</span><span class="s">"</span><span class="p">)</span>
|
|
<span class="n">fh</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">fmt</span><span class="p">)</span>
|
|
<span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">fh</span><span class="p">)</span>
|
|
<span class="n">theLogger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">fh</span><span class="p">)</span>
|
|
|
|
<span class="c"># External program output log</span>
|
|
<span class="n">program_log</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
|
|
<span class="n">f</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">abspath</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">logfile</span><span class="p">))</span><span class="o">+</span><span class="s">"/program.log"</span>
|
|
<span class="n">fh</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">FileHandler</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s">"w"</span><span class="p">)</span>
|
|
<span class="n">fh</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
|
|
<span class="n">program_log</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">fh</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>.
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT:'../',
|
|
VERSION:'24.6',
|
|
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> |