/usr/share/gtk-doc/html/PackageKit/backend-spawn.html is in packagekit-docs 1.1.9-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Spawned Backends: PackageKit Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="PackageKit Reference Manual">
<link rel="up" href="specification.html" title="PackageKit Specification">
<link rel="prev" href="backend-compiled.html" title="Compiled Backends">
<link rel="next" href="api-reference.html" title="D-Bus API Reference">
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="specification.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="backend-compiled.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="api-reference.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="backend-spawn"></a>Spawned Backends</h2></div></div></div>
<div class="toc"><dl class="toc"><dt><span class="sect1"><a href="backend-spawn.html#backends-spawn-intro">Introduction</a></span></dt></dl></div>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="backends-spawn-intro"></a>Introduction</h2></div></div></div>
<p>
If you do not have a C or C++ language binding, PackageKit executes
helper scripts written in pretty much any language.
It then watches the standard out and standard error and parses the
output into compiled backend commands.
This means a python library can be interfaced easily with a C backend.
</p>
<p>
Even when using helpers, a compiled backend stub is still used for
two reasons:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>
It is still needed for the dlopen internally in PackageKit.
</p></li>
<li class="listitem"><p>
You can add cleverness in the C backend that you might not want to
do in the scripted backend, for example using a hash table in C
rather than checking all the names in awk.
</p></li>
</ul></div>
<p>
Backends are typically open-programmable, which means we can define a
standard for what goes on stdin and stdout to try and maximise
the common code between the backends.
</p>
<p>
If you are unable to write scripts that conform to these specifications
then just launch a PkSpawn object in the compiled helper with stdout
callbacks and then try to do screenscraping in the backend.
</p>
<p>
Backends scripts are run with arguments and data is sent to standard out
and standard error asynchronously so that PackageKit can proxy this to D-Bus.
A method has command line arguments separated with tabs, and data is also
separated with tabs.
</p>
<p>
It is important to flush the standard output after each output, else
Linux will helpfully buffer the output into more efficient size chunks.
If you do not flush, then there will be a long IPC delay.
Flushing can be achieved in C using <code class="literal">fflush</code> or in python
using <code class="literal">sys.stdout.flush()</code>.
</p>
<p>
The "dispatcher" mode is where a command is used to startup the
backend, for instance <code class="literal">yumBackend.py search-name none power</code>
and then the backend then sits and waits for more standard input.
Further operations can be done on the loaded backend sending commands
to stdin, e.g. <code class="literal">search-name none power</code>.
If there are no more operations after a preset time (default 5 seconds)
then the backend is sent <code class="literal">exit</code> over stdin, and the
backend terminates.
The daemon will ensure the operations are serialised, and that backends
not sending <code class="literal">finished</code> are cleaned up properly.
</p>
<p>
The dispatcher mode does not have to implemented in python; any
language that can read from stdin can block and be used in this way.
</p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.27</div>
</body>
</html>
|