Commit 78d6b3f7 authored by kyodev's avatar kyodev

maj

parent a41bf49e
Pipeline #62486 failed with stage
in 18 seconds
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Overview: module code &#8212; live-wrapper 0.7 documentation</title>
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.7',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">live-wrapper 0.7 documentation</a> &#187;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<h1>All modules for which code is available</h1>
<ul><li><a href="lwr/disk.html">lwr.disk</a></li>
<li><a href="lwr/grub.html">lwr.grub</a></li>
<li><a href="lwr/isolinux.html">lwr.isolinux</a></li>
<li><a href="lwr/vm.html">lwr.vm</a></li>
<li><a href="lwr/xorriso.html">lwr.xorriso</a></li>
</ul>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">live-wrapper 0.7 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, Iain R. Learmonth.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.6.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lwr.disk &#8212; live-wrapper 0.7 documentation</title>
<link rel="stylesheet" href="../../_static/classic.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '0.7',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">live-wrapper 0.7 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<h1>Source code for lwr.disk</h1><div class="highlight"><pre>
<span></span><span class="c1"># live-wrapper - Wrapper for vmdebootstrap for creating live images</span>
<span class="c1"># (C) Iain R. Learmonth 2015 &lt;irl@debian.org&gt;</span>
<span class="c1"># See COPYING for terms of usage, modification and redistribution.</span>
<span class="c1">#</span>
<span class="c1"># lwr/disk.py - .disk folder helpers</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module provides helpers for generating the metadata stored in .disk/ on</span>
<span class="sd">the cdroot.</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">datetime</span>
<div class="viewcode-block" id="get_default_description"><a class="viewcode-back" href="../../lwr.html#lwr.disk.get_default_description">[docs]</a><span class="k">def</span> <span class="nf">get_default_description</span><span class="p">(</span><span class="n">distribution</span><span class="p">):</span>
<span class="n">distribution</span> <span class="o">=</span> <span class="n">distribution</span> <span class="k">if</span> <span class="n">distribution</span> <span class="k">else</span> <span class="s2">&quot;dist&quot;</span>
<span class="k">if</span> <span class="s1">&#39;official&#39;</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;LWR_DEBUG&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">):</span>
<span class="k">return</span> <span class="s2">&quot;Official Debian GNU/Linux &#39;</span><span class="si">%s</span><span class="s2">&#39; Live&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">distribution</span><span class="p">,)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="s2">&quot;Unofficial Debian GNU/Linux &#39;</span><span class="si">%s</span><span class="s2">&#39; Live&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">distribution</span><span class="p">,)</span></div>
<div class="viewcode-block" id="install_disk_info"><a class="viewcode-back" href="../../lwr.html#lwr.disk.install_disk_info">[docs]</a><span class="k">def</span> <span class="nf">install_disk_info</span><span class="p">(</span><span class="n">cdroot</span><span class="p">,</span> <span class="n">description</span><span class="p">,</span> <span class="n">xorriso_args</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> This function creates the .disk/ metadata and installs it into the</span>
<span class="sd"> specified cdroot.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">timestamp</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">utcnow</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2">T%H:%M&quot;</span><span class="p">)</span>
<span class="n">metadir</span> <span class="o">=</span> <span class="n">cdroot</span><span class="p">[</span><span class="s1">&#39;.disk&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">path</span>
<span class="k">with</span> <span class="nb">open</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">join</span><span class="p">(</span><span class="n">metadir</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">i</span><span class="p">:</span>
<span class="n">i</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">description</span><span class="p">,</span> <span class="n">timestamp</span><span class="p">,))</span>
<span class="k">with</span> <span class="nb">open</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">join</span><span class="p">(</span><span class="n">metadir</span><span class="p">,</span> <span class="s2">&quot;udeb_include&quot;</span><span class="p">),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">i</span><span class="p">:</span>
<span class="n">i</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;netcfg</span><span class="se">\n</span><span class="s2">ethdetect</span><span class="se">\n</span><span class="s2">pcmciautils-udeb</span><span class="se">\n</span><span class="s2">live-installer</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</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">join</span><span class="p">(</span><span class="n">metadir</span><span class="p">,</span> <span class="s2">&quot;cd_type&quot;</span><span class="p">),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">i</span><span class="p">:</span>
<span class="n">i</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;live&quot;</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</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">join</span><span class="p">(</span><span class="n">metadir</span><span class="p">,</span> <span class="s2">&quot;base_installable&quot;</span><span class="p">),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">i</span><span class="p">:</span>
<span class="n">i</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</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">join</span><span class="p">(</span><span class="n">metadir</span><span class="p">,</span> <span class="s2">&quot;base_components&quot;</span><span class="p">),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">i</span><span class="p">:</span>
<span class="n">i</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;main&quot;</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</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">join</span><span class="p">(</span><span class="n">metadir</span><span class="p">,</span> <span class="s2">&quot;mkisofs&quot;</span><span class="p">),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">i</span><span class="p">:</span>
<span class="n">i</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">xorriso_args</span><span class="p">)</span></div>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../../search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">live-wrapper 0.7 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, Iain R. Learmonth.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.6.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lwr.grub &#8212; live-wrapper 0.7 documentation</title>
<link rel="stylesheet" href="../../_static/classic.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '0.7',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">live-wrapper 0.7 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<h1>Source code for lwr.grub</h1><div class="highlight"><pre>
<span></span><span class="c1"># live-wrapper - Wrapper for vmdebootstrap for creating live images</span>
<span class="c1"># (C) Iain R. Learmonth 2015 &lt;irl@debian.org&gt;</span>
<span class="c1"># See COPYING for terms of usage, modification and redistribution.</span>
<span class="c1">#</span>
<span class="c1"># lwr/grub.py - Grub 2 helpers</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">The lwr.grub module contains helpers for GRUB 2 including the installation</span>
<span class="sd">of GRUB files to the cdroot and the generation of the grub.cfg and loopback.cfg</span>
<span class="sd">files.</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">os</span>
<div class="viewcode-block" id="generate_cfg"><a class="viewcode-back" href="../../lwr.html#lwr.grub.generate_cfg">[docs]</a><span class="k">def</span> <span class="nf">generate_cfg</span><span class="p">(</span><span class="n">bootconfig</span><span class="p">,</span> <span class="n">submenu</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">submenu</span><span class="p">:</span>
<span class="n">ret</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;if [ $</span><span class="si">{iso_path}</span><span class="s2"> ] ; then</span><span class="se">\n</span><span class="s2">set loopback=</span><span class="se">\&quot;</span><span class="s2">&quot;</span> <span class="o">+</span>
<span class="s2">&quot;findiso=$</span><span class="si">{iso_path}</span><span class="se">\&quot;\n</span><span class="s2">fi</span><span class="se">\n\n</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">ret</span> <span class="o">=</span> <span class="nb">str</span><span class="p">()</span>
<span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">bootconfig</span><span class="o">.</span><span class="n">entries</span><span class="p">:</span>
<span class="k">if</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;menu&quot;</span><span class="p">:</span>
<span class="k">if</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;subentries&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">is_empty</span><span class="p">([</span><span class="s2">&quot;linux&quot;</span><span class="p">,</span> <span class="s2">&quot;menu&quot;</span><span class="p">]):</span>
<span class="k">continue</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;submenu </span><span class="se">\&quot;</span><span class="si">%s</span><span class="se">\&quot;</span><span class="s2"> {</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;description&#39;</span><span class="p">],)</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="n">generate_cfg</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;subentries&#39;</span><span class="p">],</span> <span class="n">submenu</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;}</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">if</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;linux&quot;</span><span class="p">:</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;menuentry </span><span class="se">\&quot;</span><span class="si">%s</span><span class="se">\&quot;</span><span class="s2"> {</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;description&#39;</span><span class="p">],)</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; linux </span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2"> </span><span class="se">\&quot;</span><span class="s2">$</span><span class="si">{loopback}</span><span class="se">\&quot;\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;kernel&#39;</span><span class="p">],</span> <span class="n">entry</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;cmdline&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),)</span>
<span class="k">if</span> <span class="n">entry</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;initrd&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; initrd </span><span class="si">%s</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;initrd&#39;</span><span class="p">],)</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;}</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">return</span> <span class="n">ret</span></div>
<div class="viewcode-block" id="install_grub"><a class="viewcode-back" href="../../lwr.html#lwr.grub.install_grub">[docs]</a><span class="k">def</span> <span class="nf">install_grub</span><span class="p">(</span><span class="n">cdroot</span><span class="p">,</span> <span class="n">bootconfig</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Can use cdroot as a relative path inside the actual cdroot.</span>
<span class="sd"> The d-i/ and live/ directories are used directly.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">cfg</span> <span class="o">=</span> <span class="n">generate_cfg</span><span class="p">(</span><span class="n">bootconfig</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2">/boot/grub/grub.cfg&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">cdroot</span><span class="p">,),</span> <span class="s2">&quot;a&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">cfgout</span><span class="p">:</span>
<span class="n">cfgout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">cfg</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2">/boot/grub/loopback.cfg&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">cdroot</span><span class="p">,),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">loopout</span><span class="p">:</span>
<span class="n">loopout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;source /grub/grub.cfg&quot;</span><span class="p">)</span></div>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../../search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">live-wrapper 0.7 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, Iain R. Learmonth.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.6.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lwr.isolinux &#8212; live-wrapper 0.7 documentation</title>
<link rel="stylesheet" href="../../_static/classic.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '0.7',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">live-wrapper 0.7 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<h1>Source code for lwr.isolinux</h1><div class="highlight"><pre>
<span></span><span class="c1"># live-wrapper - Wrapper for vmdebootstrap for creating live images</span>
<span class="c1"># (C) Iain R. Learmonth 2015 &lt;irl@debian.org&gt;</span>
<span class="c1"># See COPYING for terms of usage, modification and redistribution.</span>
<span class="c1">#</span>
<span class="c1"># lwr/isolinux.py - ISOLINUX helpers</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">The lwr.isolinux module contains helpers for isolinux including the</span>
<span class="sd">installation of isolinux files to the cdroot and the generation of the</span>
<span class="sd">isolinux.cfg files.</span>
<span class="sd">Directory listing of /isolinux/</span>
<span class="sd">advanced.cfg boot.cat hdt.c32 install.cfg isolinux.bin isolinux.cfg</span>
<span class="sd">ldlinux.c32 libcom32.c32 libutil.c32 live.cfg menu.cfg splash.png</span>
<span class="sd">stdmenu.cfg vesamenu.c32</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">shutil</span>
<span class="kn">import</span> <span class="nn">string</span>
<span class="kn">import</span> <span class="nn">fileinput</span>
<span class="kn">import</span> <span class="nn">tempfile</span>
<span class="kn">import</span> <span class="nn">cliapp</span>
<span class="kn">from</span> <span class="nn">vmdebootstrap.base</span> <span class="k">import</span> <span class="n">runcmd</span>
<span class="kn">from</span> <span class="nn">lwr.vm</span> <span class="k">import</span> <span class="n">detect_kernels</span>
<span class="kn">from</span> <span class="nn">lwr.apt_udeb</span> <span class="k">import</span> <span class="n">get_apt_handler</span>
<span class="c1"># pylint: disable=missing-docstring</span>
<div class="viewcode-block" id="generate_cfg"><a class="viewcode-back" href="../../lwr.html#lwr.isolinux.generate_cfg">[docs]</a><span class="k">def</span> <span class="nf">generate_cfg</span><span class="p">(</span><span class="n">bootconfig</span><span class="p">,</span> <span class="n">submenu</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="n">ret</span> <span class="o">=</span> <span class="nb">str</span><span class="p">()</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">submenu</span><span class="p">:</span>
<span class="n">first</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;INCLUDE stdmenu.cfg</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;MENU title Main Menu</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">first</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">bootconfig</span><span class="o">.</span><span class="n">entries</span><span class="p">:</span>
<span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;description&#39;</span><span class="p">],)</span>
<span class="k">if</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]</span> <span class="ow">is</span> <span class="s1">&#39;menu&#39;</span><span class="p">:</span>
<span class="k">if</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;subentries&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">is_empty</span><span class="p">([</span><span class="s2">&quot;menu&quot;</span><span class="p">,</span> <span class="s2">&quot;linux&quot;</span><span class="p">,</span> <span class="s2">&quot;linux16&quot;</span><span class="p">,</span> <span class="s2">&quot;com32&quot;</span><span class="p">]):</span>
<span class="k">continue</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;MENU begin advanced</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;MENU title </span><span class="si">%s</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">label</span><span class="p">,)</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="n">generate_cfg</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;subentries&#39;</span><span class="p">],</span> <span class="n">submenu</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; LABEL mainmenu </span><span class="se">\n</span><span class="s2"> &quot;</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; MENU label Back</span><span class="se">\n</span><span class="s2"> &quot;</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; MENU exit</span><span class="se">\n</span><span class="s2"> &quot;</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; MENU end</span><span class="se">\n</span><span class="s2"> &quot;</span>
<span class="c1"># do not want to default to menus</span>
<span class="k">if</span> <span class="n">first</span><span class="p">:</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;DEFAULT </span><span class="si">%s</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">label</span><span class="p">,)</span>
<span class="n">first</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">if</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;linux&#39;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]</span> <span class="ow">is</span> <span class="s1">&#39;com32&#39;</span><span class="p">:</span>
<span class="nb">type</span> <span class="o">=</span> <span class="s1">&#39;linux&#39;</span> <span class="k">if</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;linux&#39;</span><span class="p">)</span> <span class="k">else</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;LABEL </span><span class="si">%s</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">label</span><span class="p">,)</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; SAY </span><span class="se">\&quot;</span><span class="s2">Booting </span><span class="si">%s</span><span class="s2">...</span><span class="se">\&quot;\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;description&#39;</span><span class="p">],)</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; </span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">],</span> <span class="n">entry</span><span class="p">[</span><span class="s1">&#39;kernel&#39;</span><span class="p">],)</span>
<span class="k">if</span> <span class="n">entry</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;initrd&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; APPEND initrd=</span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;initrd&#39;</span><span class="p">],</span> <span class="n">entry</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;cmdline&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),)</span>
<span class="k">elif</span> <span class="n">entry</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;cmdline&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot; APPEND </span><span class="si">%s</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="s1">&#39;cmdline&#39;</span><span class="p">],)</span>
<span class="n">ret</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">return</span> <span class="n">ret</span></div>
<div class="viewcode-block" id="install_isolinux"><a class="viewcode-back" href="../../lwr.html#lwr.isolinux.install_isolinux">[docs]</a><span class="k">def</span> <span class="nf">install_isolinux</span><span class="p">(</span><span class="n">cdroot</span><span class="p">,</span> <span class="n">mirror</span><span class="p">,</span> <span class="n">suite</span><span class="p">,</span> <span class="n">architecture</span><span class="p">,</span> <span class="n">bootconfig</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Download and unpack the correct syslinux-common</span>
<span class="sd"> and isolinux packages for isolinux support.</span>
<span class="sd"> ISOLINUX looks first in boot/isolinux/ then isolinux/ then /</span>
<span class="sd"> This function puts all files into isolinux/</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">destdir</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">()</span>
<span class="n">handler</span> <span class="o">=</span> <span class="n">get_apt_handler</span><span class="p">(</span><span class="n">destdir</span><span class="p">,</span> <span class="n">mirror</span><span class="p">,</span> <span class="n">suite</span><span class="p">,</span> <span class="n">architecture</span><span class="p">)</span>
<span class="n">filename</span> <span class="o">=</span> <span class="n">handler</span><span class="o">.</span><span class="n">download_package</span><span class="p">(</span><span class="s1">&#39;syslinux-common&#39;</span><span class="p">,</span> <span class="n">destdir</span><span class="p">)</span>
<span class="c1"># these files are put directly into cdroot/isolinux</span>
<span class="n">syslinux_files</span> <span class="o">=</span> <span class="p">[</span>
<span class="s1">&#39;ldlinux.c32&#39;</span><span class="p">,</span> <span class="s1">&#39;libcom32.c32&#39;</span><span class="p">,</span> <span class="s1">&#39;vesamenu.c32&#39;</span><span class="p">,</span>
<span class="s1">&#39;libutil.c32&#39;</span><span class="p">,</span> <span class="s1">&#39;libmenu.c32&#39;</span><span class="p">,</span> <span class="s1">&#39;libgpl.c32&#39;</span><span class="p">,</span> <span class="s1">&#39;hdt.c32&#39;</span>
<span class="p">]</span>
<span class="k">if</span> <span class="n">filename</span><span class="p">:</span>
<span class="n">runcmd</span><span class="p">([</span><span class="s1">&#39;dpkg&#39;</span><span class="p">,</span> <span class="s1">&#39;-x&#39;</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">destdir</span><span class="p">])</span>
<span class="k">for</span> <span class="n">syslinux_file</span> <span class="ow">in</span> <span class="n">syslinux_files</span><span class="p">:</span>
<span class="n">shutil</span><span class="o">.</span><span class="n">copyfile</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">join</span><span class="p">(</span><span class="n">destdir</span><span class="p">,</span> <span class="s2">&quot;usr/lib/syslinux/modules/bios/</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">syslinux_file</span><span class="p">),</span>
<span class="s2">&quot;</span><span class="si">%s</span><span class="s2">/</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">cdroot</span><span class="p">,</span> <span class="n">syslinux_file</span><span class="p">))</span>
<span class="n">shutil</span><span class="o">.</span><span class="n">copyfile</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">join</span><span class="p">(</span><span class="n">destdir</span><span class="p">,</span> <span class="s2">&quot;usr/lib/syslinux/memdisk&quot;</span><span class="p">),</span>
<span class="s2">&quot;</span><span class="si">%s</span><span class="s2">/memdisk&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">cdroot</span><span class="p">,))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">handler</span><span class="o">.</span><span class="n">clean_up_apt</span><span class="p">()</span>
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">destdir</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">cliapp</span><span class="o">.</span><span class="n">AppException</span><span class="p">(</span><span class="s1">&#39;Unable to download syslinux-common&#39;</span><span class="p">)</span>
<span class="n">filename</span> <span class="o">=</span> <span class="n">handler</span><span class="o">.</span><span class="n">download_package</span><span class="p">(</span><span class="s1">&#39;isolinux&#39;</span><span class="p">,</span> <span class="n">destdir</span><span class="p">)</span>
<span class="k">if</span> <span class="n">filename</span><span class="p">:</span>
<span class="n">runcmd</span><span class="p">([</span><span class="s1">&#39;dpkg&#39;</span><span class="p">,</span> <span class="s1">&#39;-x&#39;</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">destdir</span><span class="p">])</span>
<span class="n">shutil</span><span class="o">.</span><span class="n">copyfile</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">join</span><span class="p">(</span><span class="n">destdir</span><span class="p">,</span> <span class="s2">&quot;usr/lib/ISOLINUX/isolinux.bin&quot;</span><span class="p">),</span>
<span class="s2">&quot;</span><span class="si">%s</span><span class="s2">/isolinux.bin&quot;</span> <span class="o">%</span> <span class="n">cdroot</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">handler</span><span class="o">.</span><span class="n">clean_up_apt</span><span class="p">()</span>
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">destdir</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">cliapp</span><span class="o">.</span><span class="n">AppException</span><span class="p">(</span><span class="s1">&#39;Unable to download isolinux&#39;</span><span class="p">)</span>
<span class="n">handler</span><span class="o">.</span><span class="n">clean_up_apt</span><span class="p">()</span>
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">destdir</span><span class="p">)</span>
<span class="n">cfg</span> <span class="o">=</span> <span class="n">generate_cfg</span><span class="p">(</span><span class="n">bootconfig</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2">/</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">cdroot</span><span class="p">,</span> <span class="s2">&quot;menu.cfg&quot;</span><span class="p">),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">cfgout</span><span class="p">:</span>
<span class="n">cfgout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">cfg</span><span class="p">)</span>
<span class="c1"># Fix the menu display size in stdmeny.cfg (#861421)</span>
<span class="n">runcmd</span><span class="p">([</span><span class="s1">&#39;sed&#39;</span><span class="p">,</span> <span class="s1">&#39;-i&#39;</span><span class="p">,</span> <span class="s1">&#39;s,menu rows 12,menu rows 8,g&#39;</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">join</span><span class="p">(</span><span class="n">cdroot</span><span class="p">,</span> <span class="s1">&#39;stdmenu.cfg&#39;</span><span class="p">)])</span></div>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../../search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">live-wrapper 0.7 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, Iain R. Learmonth.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.6.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lwr.vm &#8212; live-wrapper 0.7 documentation</title>
<link rel="stylesheet" href="../../_static/classic.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '0.7',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>