[PackageKit-commit] packagekit: Branch 'master' - 20 commits

Richard Hughes hughsient at kemper.freedesktop.org
Mon Aug 25 05:20:00 PDT 2008


 backends/apt/aptDBUSBackend.py             |  102 +++
 backends/apt/pk-backend-apt.c              |   10 
 backends/poldek/pk-backend-poldek.c        |  758 ++++++++++++++++-------------
 backends/yum/helpers/yumBackend.py         |    4 
 client/pk-generate-pack-main.c             |    4 
 client/pk-generate-pack.c                  |    6 
 contrib/PackageKit.spec.in                 |    2 
 docs/api/Makefile.am                       |    1 
 docs/api/spec/pk-concepts.xml              |  247 ++++++---
 docs/api/spec/pk-transactions-download.png |binary
 docs/api/spec/pk-transactions.svg          |  245 +++++++++
 docs/html/img/kpk-confirm.png              |binary
 docs/html/img/kpk-information.png          |binary
 docs/html/img/kpk-notify.png               |binary
 docs/html/img/kpk-progress.png             |binary
 docs/html/img/kpk-search.png               |binary
 docs/html/img/kpk-settings.png             |binary
 docs/html/img/kpk-update.png               |binary
 docs/html/pk-help.html                     |   19 
 docs/html/pk-screenshots.html              |   12 
 man/pkgenpack.xml                          |   16 
 src/pk-interface-transaction.xml           |    2 
 src/pk-transaction.c                       |    3 
 23 files changed, 985 insertions(+), 446 deletions(-)

New commits:
commit 9b6ae4b15a04b7cdd1ca1dd48e5cf89392509e11
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Aug 25 13:16:31 2008 +0100

    trivial: fix one of the html pages

diff --git a/docs/html/pk-help.html b/docs/html/pk-help.html
index 0a5fe14..6cace7c 100644
--- a/docs/html/pk-help.html
+++ b/docs/html/pk-help.html
@@ -69,26 +69,11 @@ If you want to work on a feature and bring it forward, please just jump on the m
 as for instructions!
 </p>
 <p>
-<b>0.2.2</b> - To be released June 2008
-</p>
-<ul>
-<li>Network proxy server support <i>(70%)</i></li>
-<li>Multiple package install and remove from pkcon <i>(80%)</i></li>
-<li>NetworkManager integration so we can detect GPRS (and modem) connections. <i>(10%)</i></li>
-</ul>
-<p>
-<b>0.2.3</b> - To be released July 2008
+<b>0.3.2</b> - To be released September 2008
 </p>
 <ul>
 <li>Category support (install/remove whole categories of applications)<i>(0%)</i></li>
-<li>Multiple package installs from gpk-application <i>(0%)</i></li>
-<li>Ignoring packages from the update viewer per-session <i>(10%)</i></li>
-</ul>
-<p>
-<b>0.3.0</b> - To be released December 2008
-</p>
-<ul>
-<li>More composite types <code>s</code> to <code>as</code> <i>(0%)</i></li>
+<li>NetworkManager integration so we can detect GPRS (and modem) connections. <i>(10%)</i></li>
 </ul>
 
 <p>Back to the <a href="index.html">main page</a></p>
commit fd623d67e04b7732bfcd6554779935b60e58f8c0
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Aug 25 13:08:55 2008 +0100

    update some screenshots in the HTML page

diff --git a/docs/html/img/kpk-confirm.png b/docs/html/img/kpk-confirm.png
new file mode 100644
index 0000000..b0d2fd4
Binary files /dev/null and b/docs/html/img/kpk-confirm.png differ
diff --git a/docs/html/img/kpk-information.png b/docs/html/img/kpk-information.png
index 36f4aaf..0da5fa6 100644
Binary files a/docs/html/img/kpk-information.png and b/docs/html/img/kpk-information.png differ
diff --git a/docs/html/img/kpk-notify.png b/docs/html/img/kpk-notify.png
new file mode 100644
index 0000000..61ad31e
Binary files /dev/null and b/docs/html/img/kpk-notify.png differ
diff --git a/docs/html/img/kpk-progress.png b/docs/html/img/kpk-progress.png
new file mode 100644
index 0000000..fa75c98
Binary files /dev/null and b/docs/html/img/kpk-progress.png differ
diff --git a/docs/html/img/kpk-search.png b/docs/html/img/kpk-search.png
index 6642e49..2dcf3c1 100644
Binary files a/docs/html/img/kpk-search.png and b/docs/html/img/kpk-search.png differ
diff --git a/docs/html/img/kpk-settings.png b/docs/html/img/kpk-settings.png
new file mode 100644
index 0000000..aca2fe3
Binary files /dev/null and b/docs/html/img/kpk-settings.png differ
diff --git a/docs/html/img/kpk-update.png b/docs/html/img/kpk-update.png
index 0743549..a1acf92 100644
Binary files a/docs/html/img/kpk-update.png and b/docs/html/img/kpk-update.png differ
diff --git a/docs/html/pk-screenshots.html b/docs/html/pk-screenshots.html
index be43853..d0b15a1 100644
--- a/docs/html/pk-screenshots.html
+++ b/docs/html/pk-screenshots.html
@@ -100,6 +100,18 @@
 <center><img src="img/kpk-information.png" alt=""/></center>
 <p class="caption">KPackageKit Package Information</p>
 
+<center><img src="img/kpk-confirm.png" alt=""/></center>
+<p class="caption">Confirmation dialog</p>
+
+<center><img src="img/kpk-notify.png" alt=""/></center>
+<p class="caption">Updates available notification</p>
+
+<center><img src="img/kpk-progress.png" alt=""/></center>
+<p class="caption">Progress of transaction</p>
+
+<center><img src="img/kpk-settings.png" alt=""/></center>
+<p class="caption">Update settings</p>
+
 <center><img src="img/pk-opensuse-updater.png" alt=""/></center>
 <p class="caption">OpenSuse Updater</p>
 
commit 7549bc988e7e8fa2154340102eabe7810fc8bc5e
Merge: f3e19e0... 546dca5...
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Aug 25 12:04:08 2008 +0100

    Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit

commit f3e19e0e2a9859f29a24b9b89e3e3cbbd4124e9f
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Aug 25 12:03:39 2008 +0100

    clarify some documentation about the transaction methods

diff --git a/contrib/PackageKit.spec.in b/contrib/PackageKit.spec.in
index 3792bec..e39f329 100644
--- a/contrib/PackageKit.spec.in
+++ b/contrib/PackageKit.spec.in
@@ -14,7 +14,7 @@ Epoch:     1
 License:   GPLv2+
 Group:     System Environment/Libraries
 URL:       http://packagekit.freedesktop.org
-Source0:   http://people.freedesktop.org/~hughsient/releases/%{name}-%{version}.tar.gz
+Source0:   http://www.packagekit.org/releases/%{name}-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 Requires: dbus >= %{dbus_version}
diff --git a/docs/api/Makefile.am b/docs/api/Makefile.am
index d6fe3d6..da95f6e 100644
--- a/docs/api/Makefile.am
+++ b/docs/api/Makefile.am
@@ -52,6 +52,7 @@ HTML_IMAGES =						\
 	spec/pk-transactions.svg			\
 	spec/pk-transactions-set-locale.png		\
 	spec/pk-transactions-failure.png		\
+	spec/pk-transactions-download.png		\
 	spec/pk-transactions-sig-install.png		\
 	spec/pk-transactions-success.png		\
 	spec/pk-transactions-trusted.png
diff --git a/docs/api/spec/pk-concepts.xml b/docs/api/spec/pk-concepts.xml
index cfa5a48..5a0434a 100644
--- a/docs/api/spec/pk-concepts.xml
+++ b/docs/api/spec/pk-concepts.xml
@@ -636,79 +636,180 @@
       New methods require a new transaction path (i.e. another call to <literal>GetTid</literal>)
       which is synchronous and thus very fast.
     </para>
-    <para>
-      A typical successful transaction can be seen below.
-    </para>
-    <mediaobject id="pk-transactions-success">
-      <imageobject>
-        <imagedata format="PNG" fileref="pk-transactions-success.png" align="center"/>
-      </imageobject>
-    </mediaobject>
-    <para>
-      A typical simple transaction failure case can be seen below.
-      The user is not given the change to requeue the transaction as it is a fatal error.
-    </para>
-    <mediaobject id="pk-transactions-failure">
-      <imageobject>
-        <imagedata format="PNG" fileref="pk-transactions-failure.png" align="center"/>
-      </imageobject>
-    </mediaobject>
-    <para>
-      In this non-trivial example, a local file install is being attempted.
-      First the <literal>InstallFile</literal> is called with the <literal>trusted</literal>
-      flag set.
-      This will fail if the package does not have a valid GPG key, and ordinarily the transaction
-      would fail. What the client can do, e.g. using <literal>gnome-packagekit</literal>, is
-      to re-request the <literal>InstallFile</literal> with <literal>non-trusted</literal>.
-      This will use a different PolicyKit authentication, and allow the file to succeed.
-    </para>
-    <para>
-      So why do we bother calling <literal>trusted</literal> in the first place?
-      Well, the trusted PolicyKit role can be saved in the gnome-keyring, or could be
-      set to the users password as the GPG key is already trusted by the user.
-      The <literal>non-trusted</literal> action would likely ask for the administrator password,
-      and not allowed to be saved. This gives the user the benifit of installing trusted local
-      files without a password (common case) but requiring something stronger for untrusted or
-      unsigned files.
-    </para>
-    <mediaobject id="pk-transactions-trusted">
-      <imageobject>
-        <imagedata format="PNG" fileref="pk-transactions-trusted.png" align="center"/>
-      </imageobject>
-    </mediaobject>
-    <para>
-      If the package is signed, and a valid GPG signature is available, then we need to ask the
-      user to import the key, and re-run the transaction.
-      This is done as three transactions, as other transactions may be queued and have a higher
-      priority, and to make sure that the transaction object is not reused.
-    </para>
-    <mediaobject id="pk-transactions-sig-install">
-      <imageobject>
-        <imagedata format="PNG" fileref="pk-transactions-sig-install.png" align="center"/>
-      </imageobject>
-    </mediaobject>
-    <para>
-      If the package is signed, and a valid GPG signature is available, then we need to ask the
-      user to import the key, and re-run the transaction.
-      This is done as three transactions, as other transactions may be queued and have a higher
-      priority, and to make sure that the transaction object is not reused.
-    </para>
-    <mediaobject id="pk-transactions-set-locale">
-      <imageobject>
-        <imagedata format="PNG" fileref="pk-transactions-set-locale.png" align="center"/>
-      </imageobject>
-    </mediaobject>
-    <para>
-      The PackageKit backend may support native localisation, which we should support if the
-      translations exist.
-      In the prior examples the <literal>SetLocale()</literal> method has been left out for brevity.
-      If you are using the raw DBUS methods to access PackageKit, you will also need to make
-      a call to <literal>SetLocale()</literal> so the daemon knows what locale to assign the
-      transaction.
-      If you are using libpackagekit to schedule transactions, then the locale will be set
-      automatically in the <literal>PkControl</literal> GObject, and you do not need to call
-      <literal>pk_client_set_locale()</literal> manually.
-    </para>
+
+    <sect2 id="introduction-ideas-transactions-success">
+      <title>Transaction example: Success</title>
+      <mediaobject id="pk-transactions-success">
+        <imageobject>
+          <imagedata format="PNG" fileref="pk-transactions-success.png" align="center"/>
+        </imageobject>
+      </mediaobject>
+      <para>
+        A typical successful transaction would emit signals such as
+        <literal>::Progress()</literal>, <literal>::Package()</literal> and
+        <literal>::StatusChanged()</literal>.
+        These are used to inform the client application of the current state,
+        so widgets such as icons or description text can be updated.
+      </para>
+    </sect2>
+
+    <sect2 id="introduction-ideas-transactions-failure">
+      <title>Transaction example: Failure</title>
+      <mediaobject id="pk-transactions-failure">
+        <imageobject>
+          <imagedata format="PNG" fileref="pk-transactions-failure.png" align="center"/>
+        </imageobject>
+      </mediaobject>
+      <para>
+        This is the typical transaction failure case when there is no network available.
+        The user is not given the chance to requeue the transaction as it is a fatal error.
+      </para>
+    </sect2>
+
+    <sect2 id="introduction-ideas-transactions-trusted">
+      <title>Transaction example: Trusted</title>
+      <mediaobject id="pk-transactions-trusted">
+        <imageobject>
+          <imagedata format="PNG" fileref="pk-transactions-trusted.png" align="center"/>
+        </imageobject>
+      </mediaobject>
+      <para>
+        In this non-trivial example, a local file install is being attempted.
+        First the <literal>InstallFile</literal> is called with the <literal>trusted</literal>
+        flag set.
+        This will fail if the package does not have a valid GPG key, and ordinarily the transaction
+        would fail. What the client can do, e.g. using <literal>libpackagekit</literal>, is
+        to re-request the <literal>InstallFile</literal> with <literal>non-trusted</literal>.
+        This will use a different PolicyKit authentication, and allow the file to succeed.
+      </para>
+      <para>
+        So why do we bother calling <literal>trusted</literal> in the first place?
+        Well, the trusted PolicyKit role can be saved in the gnome-keyring, or could be
+        set to the users password as the GPG key is already trusted by the user.
+        The <literal>non-trusted</literal> action would likely ask for the administrator password,
+        and not allowed to be saved. This gives the user the benifit of installing trusted local
+        files without a password (common case) but requiring something stronger for untrusted or
+        unsigned files.
+      </para>
+    </sect2>
+
+    <sect2 id="introduction-ideas-transactions-sig-install">
+      <title>Transaction example: Package signature install</title>
+      <mediaobject id="pk-transactions-sig-install">
+        <imageobject>
+          <imagedata format="PNG" fileref="pk-transactions-sig-install.png" align="center"/>
+        </imageobject>
+      </mediaobject>
+      <para>
+        If the package is signed, and a valid GPG signature is available, then we need to ask the
+        user to import the key, and re-run the transaction.
+        This is done as three transactions, as other transactions may be queued and have a higher
+        priority, and to make sure that the transaction object is not reused.
+      </para>
+      <para>
+        Keep in mind that PackageKit can only be running one transaction at any
+        one time.
+        If we had designed the PackageKit API to block and wait for user input,
+        then no other transactions could be run whilst we are waiting for the user.
+      </para>
+      <para>
+        This is best explained using an example:
+      </para>
+      <itemizedlist>
+        <listitem>
+          <para>User clicks "install vmware" followed by "confirm".</para>
+        </listitem>
+        <listitem>
+          <para>User walks away from the computer and takes a nap</para>
+        </listitem>
+        <listitem>
+          <para>System upgrade is scheduled (300Mb of updates)</para>
+        </listitem>
+      </itemizedlist>
+      <para>
+        The vmware package is downloaded, but cannot be installed until a EULA
+        is agreed to.
+        If we pause the transaction then we never apply the updates automatically
+        and the computer is not kept up to date.
+        The user would have to wait a substantial amount of time waiting for
+        the updates to download when returning from his nap after clicking "I agree"
+        to the vmware EULA.
+      </para>
+      <para>
+        In the current system where transactions cannot block, the first
+        transaction downloads vmware, and then it finishes, and puts up a UI
+        for the user to click.
+        In the meantime the second transaction (the update) is scheduled,
+        downloaded and installed, and then finishes.
+        The user returns, clicks "okay" and a third transaction is created that
+        accepts the eula, and a forth that actually installs vmware.
+      </para>
+      <para>
+        It seems complicated, but it's essential to make sure none of the
+        callbacks block and stop other transactions from happening.
+      </para>
+    </sect2>
+
+    <sect2 id="introduction-ideas-transactions-download">
+      <title>Transaction example: Download</title>
+      <mediaobject id="pk-transactions-download">
+        <imageobject>
+          <imagedata format="PNG" fileref="pk-transactions-download.png" align="center"/>
+        </imageobject>
+      </mediaobject>
+      <para>
+        When the <literal>DownloadPackages()</literal> method is called on a number
+        of packages, then these are downloaded by the daemon into a temporary
+        directory.
+        This directory can only be written by the <literal>packagekitd</literal>
+        user (usually root) but can be read by all users.
+        The files are not downloaded into any specific directory, instead a
+        random one is created in <literal>/var/cache/PackageKit</literal>.
+        The reason for this intermediate step is that the
+        <literal>DownloadPackages()</literal> method does not take a destination
+        directory as the dameon is running as a different user to the user,
+        and in a different SELinux context.
+      </para>
+      <para>
+        To preserve the SELinux attributes and the correct user and group ownership
+        of the newly created files, the client (running in the user session) has
+        to copy the files from the temporary directory into the chosen destination
+        directory.
+        NOTE: this copy step is optional but recommended, as the files will remain in
+        the temporary directory until the daemon is times out and is restarted.
+        As the client does not know (intentionally) the temporary directory or the
+        filenames of the packages that are created, the <literal>::Files()</literal>
+        signal is emitted with the full path of the downloaded files.
+        It is expected the <literal>package_id</literal> parameter of
+        <literal>::Files()</literal> will be blank, although this is not mandated.
+      </para>
+      <para>
+        Multiple <literal>::Files()</literal> signals can be sent by the dameon,
+        as the download operation may be pipelined, and the client should honour
+        every signal by copying each file.
+      </para>
+    </sect2>
+
+    <sect2 id="introduction-ideas-transactions-set-locale">
+      <title>Transaction example: Setting the locale</title>
+      <mediaobject id="pk-transactions-set-locale">
+        <imageobject>
+          <imagedata format="PNG" fileref="pk-transactions-set-locale.png" align="center"/>
+        </imageobject>
+      </mediaobject>
+      <para>
+        The PackageKit backend may support native localisation, which we should support if the
+        translations exist.
+        In the prior examples the <literal>SetLocale()</literal> method has been left out for brevity.
+        If you are using the raw DBUS methods to access PackageKit, you will also need to make
+        a call to <literal>SetLocale()</literal> so the daemon knows what locale to assign the
+        transaction.
+        If you are using libpackagekit to schedule transactions, then the locale will be set
+        automatically in the <literal>PkControl</literal> GObject, and you do not need to call
+        <literal>pk_client_set_locale()</literal> manually.
+      </para>
+    </sect2>
+
   </sect1>
 
   <sect1 id="introduction-ideas-transactionid">
diff --git a/docs/api/spec/pk-transactions-download.png b/docs/api/spec/pk-transactions-download.png
new file mode 100644
index 0000000..52bd066
Binary files /dev/null and b/docs/api/spec/pk-transactions-download.png differ
diff --git a/docs/api/spec/pk-transactions.svg b/docs/api/spec/pk-transactions.svg
index 2a39467..f19062f 100644
--- a/docs/api/spec/pk-transactions.svg
+++ b/docs/api/spec/pk-transactions.svg
@@ -90,9 +90,9 @@
      objecttolerance="10"
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
-     inkscape:zoom="0.7"
-     inkscape:cx="277.52317"
-     inkscape:cy="649.44446"
+     inkscape:zoom="1.4"
+     inkscape:cx="245.14291"
+     inkscape:cy="-303.42646"
      inkscape:document-units="px"
      inkscape:current-layer="layer1"
      showgrid="true"
@@ -1465,5 +1465,242 @@
            height="42.426407"
            x="-0.50507629"
            y="1106.4054" /></flowRegion><flowPara
-         id="flowPara2656"></flowPara></flowRoot>  </g>
+         id="flowPara2656" /></flowRoot>    <rect
+       style="opacity:1;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.42000827;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect2609"
+       width="475.07999"
+       height="179.9048"
+       x="30.019876"
+       y="1222.3502"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180" />
+    <rect
+       style="opacity:0.76146785;fill:#8d5fd3;fill-opacity:1"
+       id="rect2611"
+       width="35"
+       height="150.00012"
+       x="465.05988"
+       y="1247.3903"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180" />
+    <rect
+       style="opacity:0.76146785;fill:#ff8080;fill-opacity:1"
+       id="rect2613"
+       width="35"
+       height="169.97192"
+       x="250.05986"
+       y="1227.3903"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180" />
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3.75028491;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow2Mstart);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 290,1382.3622 L 464.98906,1382.3623"
+       id="path2687"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180"
+       sodipodi:nodetypes="cc" />
+    <rect
+       style="opacity:0.76146785;fill:#5fd38d;fill-opacity:1"
+       id="rect2615"
+       width="35"
+       height="104.97192"
+       x="35.059872"
+       y="1227.3903"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180" />
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
+       x="-1278.495"
+       y="60"
+       id="text2619"
+       transform="matrix(0,-1,1,0,0,0)"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180"><tspan
+         sodipodi:role="line"
+         id="tspan2621"
+         x="-1278.495"
+         y="60"
+         style="font-size:20px;text-align:center;text-anchor:middle">Manager</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
+       x="-1315.0575"
+       y="490"
+       id="text2623"
+       transform="matrix(0,-1,1,0,0,0)"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180"><tspan
+         sodipodi:role="line"
+         id="tspan2625"
+         x="-1315.0575"
+         y="490"
+         style="font-size:20px;text-align:center;text-anchor:middle">Transaction</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
+       x="-1313.4169"
+       y="275"
+       id="text2627"
+       transform="matrix(0,-1,1,0,0,0)"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180"><tspan
+         sodipodi:role="line"
+         id="tspan2629"
+         x="-1313.4169"
+         y="275"
+         style="font-size:20px;text-align:center;text-anchor:middle">Client</tspan></text>
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3.7523787;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow2Mstart);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 460.00294,1262.3904 L 285.05988,1262.3904"
+       id="path2631"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180" />
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3.75172305;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow2Mstart);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 75.05988,1242.3904 L 249.93173,1242.3904"
+       id="path2633"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180" />
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
+       x="164.3997"
+       y="1237.3903"
+       id="text2635"
+       sodipodi:linespacing="125%"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180"><tspan
+         sodipodi:role="line"
+         id="tspan2637"
+         x="164.3997"
+         y="1237.3903"
+         style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Sans;-inkscape-font-specification:Sans">GetTid()</tspan></text>
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3.39060569;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow2Mstart);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 245.03003,1252.3972 L 119.6421,1252.3972 L 110,1242.3622"
+       id="path2639"
+       sodipodi:nodetypes="ccc"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180" />
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
+       x="370.39972"
+       y="1257.3903"
+       id="text2641"
+       sodipodi:linespacing="125%"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180"><tspan
+         sodipodi:role="line"
+         id="tspan2643"
+         x="370.39972"
+         y="1257.3903"
+         style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Sans;-inkscape-font-specification:Sans">DownloadPackages(p)</tspan></text>
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3.7523787;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow2Mstart);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 290.11682,1302.3904 L 465.05988,1302.3904"
+       id="path2645"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180" />
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
+       x="381.23956"
+       y="1297.3903"
+       id="text2647"
+       sodipodi:linespacing="125%"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180"><tspan
+         sodipodi:role="line"
+         id="tspan2649"
+         x="381.23956"
+         y="1297.3903"
+         style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Sans;-inkscape-font-specification:Sans">::Downloading(p)</tspan></text>
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3.7523787;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow2Mstart);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 290.05988,1342.3904 L 465.00294,1342.3904"
+       id="path2669"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180" />
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
+       x="381.18262"
+       y="1337.3903"
+       id="text2671"
+       sodipodi:linespacing="125%"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180"><tspan
+         sodipodi:role="line"
+         id="tspan2673"
+         x="381.18262"
+         y="1337.3903"
+         style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Sans;-inkscape-font-specification:Sans">::Files(a;b;c)</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
+       x="380.66309"
+       y="1377.3903"
+       id="text2689"
+       sodipodi:linespacing="125%"
+       inkscape:export-filename="/home/hughsie/Code/PackageKit/docs/spec/pk-transactions-trusted.png"
+       inkscape:export-xdpi="180"
+       inkscape:export-ydpi="180"><tspan
+         sodipodi:role="line"
+         id="tspan2691"
+         x="380.66309"
+         y="1377.3903"
+         style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Sans;-inkscape-font-specification:Sans">::Finished(success)</tspan></text>
+    <rect
+       style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.43315262;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       id="rect2693"
+       width="130.06685"
+       height="60.007923"
+       x="89.966576"
+       y="1307.3287"
+       ry="9.3762369" />
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Sans;-inkscape-font-specification:Sans"
+       x="152.6875"
+       y="1327.3622"
+       id="text2711"><tspan
+         sodipodi:role="line"
+         id="tspan2713"
+         x="152.6875"
+         y="1327.3622"
+         style="font-size:12px;text-align:center;text-anchor:middle">Client copies files</tspan><tspan
+         sodipodi:role="line"
+         x="152.6875"
+         y="1342.3622"
+         style="font-size:12px;text-align:center;text-anchor:middle"
+         id="tspan2715">from a, b and c to</tspan><tspan
+         sodipodi:role="line"
+         x="154.59766"
+         y="1357.3622"
+         style="font-size:12px;text-align:center;text-anchor:middle"
+         id="tspan2721">final destination </tspan></text>
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3.75000000000000000;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none"
+       d="M 250,1337.3622 C 220,1337.3622 220,1337.3622 220,1337.3622"
+       id="path2729" />
+  </g>
 </svg>
diff --git a/src/pk-interface-transaction.xml b/src/pk-interface-transaction.xml
index 543be55..09e5e70 100644
--- a/src/pk-interface-transaction.xml
+++ b/src/pk-interface-transaction.xml
@@ -74,7 +74,7 @@
       <doc:doc>
         <doc:description>
           <doc:para>
-            This method downloads packages into a specified directory.
+            This method downloads packages into a temporary directory.
           </doc:para>
         </doc:description>
       </doc:doc>
commit 546dca5771c6452af4babd7c31d8ec975e2ec3c0
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Sun Aug 24 23:32:11 2008 +0200

    APT: Add method for calling InstallFiles in the dbusbackend, but do not assign it yet.

diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
index 1ba2c7c..ca8a6f1 100644
--- a/backends/apt/pk-backend-apt.c
+++ b/backends/apt/pk-backend-apt.c
@@ -149,6 +149,16 @@ backend_install_packages (PkBackend *backend, gchar **package_ids)
 }
 
 /**
+ *  * backend_install_files:
+ *   */
+static void
+backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+{
+	        pk_backend_dbus_install_files (dbus, trusted, full_paths);
+}
+
+
+/**
  * backend_remove_packages
  *  */
 static void
commit 5176c6f5ce0697b9bcb444e7d0ca501cbeece187
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Sun Aug 24 22:16:56 2008 +0200

    APT: Do not allow to remove essential packages

diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
index a690713..c64df5b 100755
--- a/backends/apt/aptDBUSBackend.py
+++ b/backends/apt/aptDBUSBackend.py
@@ -548,6 +548,11 @@ class PackageKitAptBackend(PackageKitBaseBackend):
                 self.Finished(EXIT_FAILED)
                 return
             pkgs.append(pkg.name[:])
+            if pkg._pkg.Essential == True:
+                self.ErrorCode(ERROR_CANNOT_REMOVE_SYSTEM_PACKAGE,
+                               "Package %s cannot be removed." % pkg.name)
+                self.Finished(EXIT_FAILED)
+                return
             try:
                 pkg.markDelete()
             except:
@@ -977,6 +982,11 @@ class PackageKitAptBackend(PackageKitBaseBackend):
                                "Package %s isn't available" % name)
                 self.Finished(EXIT_FAILED)
                 return
+            if pkg._pkg.Essential == True:
+                self.ErrorCode(ERROR_CANNOT_REMOVE_SYSTEM_PACKAGE,
+                               "Package %s cannot be removed." % pkg.name)
+                self.Finished(EXIT_FAILED)
+                return
             pkgs.append(pkg)
             try:
                 pkg.markDelete()
commit 4ba5ea57e42203db1ac033dd17823f9db7461502
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Sun Aug 24 22:06:55 2008 +0200

    APT: fix killing hanging installations

diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
index dc9f448..a690713 100755
--- a/backends/apt/aptDBUSBackend.py
+++ b/backends/apt/aptDBUSBackend.py
@@ -202,7 +202,7 @@ class PackageKitInstallProgress(apt.progress.InstallProgress):
         # we timed out, send ctrl-c
         if self.last_activity + self.timeout < time.time():
             pklog.critical("no activity for %s time sending ctrl-c" % self.timeout)
-            os.write(self.master_fd, 3)
+            os.write(self.master_fd, chr(3))
 
     def conffile(self, current, new):
         pklog.warning("Config file prompt: '%s' (sending no)" % current)
commit 3883e9545a216f3dadc7afabb35cbbb4e7d4835d
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Sun Aug 24 22:06:06 2008 +0200

    APT: Send a message if a later version of a locally installed package exists in the cache.

diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
index f6a52a7..dc9f448 100755
--- a/backends/apt/aptDBUSBackend.py
+++ b/backends/apt/aptDBUSBackend.py
@@ -797,6 +797,11 @@ class PackageKitAptBackend(PackageKitBaseBackend):
                                "Failed to install package %s" % deb.pkgname)
                 self.Finished(EXIT_FAILED)
                 return
+            # Check if there is a newer version in the cache
+            if deb.compareToVersionInCache() == apt.debfile.VERSION_OUTDATED:
+                self.Message(MESSAGE_NEWER_PACKAGE_EXISTS, 
+                             "There is a later version of %s "
+                             "available in the repositories." % deb.pkgname)
         self.PercentageChanged(100)
         self.Finished(EXIT_SUCCESS)
 
commit e91b75d6d1fbdaaf961481e7b5414d37144f9d5b
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Sun Aug 24 21:41:01 2008 +0200

    APT: Implement InstallFiles, but do not populate this method to packagekitd, since much of the code was made inside of python-apt and is still unreleased.

diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
index bc58216..f6a52a7 100755
--- a/backends/apt/aptDBUSBackend.py
+++ b/backends/apt/aptDBUSBackend.py
@@ -35,6 +35,7 @@ import urllib2
 import warnings
 
 import apt
+import apt.debfile
 import apt_pkg
 import dbus
 import dbus.glib
@@ -164,18 +165,16 @@ class PackageKitInstallProgress(apt.progress.InstallProgress):
     Handle the installation and removal process. Bits taken from
     DistUpgradeViewNonInteractive.
     '''
-
-    # a insanly long timeout to be able to kill hanging maintainer
-    # scripts
-    TIMEOUT = 10*60
-
     def __init__(self, backend, prange=(0,100)):
         apt.progress.InstallProgress.__init__(self)
         self._backend = backend
         self.pstart = prange[0]
         self.pend = prange[1]
         self.pprev = None
+        self.last_activity = None
         self.conffile_prompts = set()
+        # insanly long timeout to be able to kill hanging maintainer scripts
+        self.timeout = 10*60
 
     def statusChange(self, pkg, percent, status):
         progress = self.pstart + percent/100 * (self.pend - self.pstart)
@@ -201,8 +200,8 @@ class PackageKitInstallProgress(apt.progress.InstallProgress):
         except Exception, e:
             pklog.debug("ioerror: %s" % e)
         # we timed out, send ctrl-c
-        if self.last_activity + self.TIMEOUT < time.time():
-            pklog.critical("no activity for %s time sending ctrl-c" % self.TIMEOUT)
+        if self.last_activity + self.timeout < time.time():
+            pklog.critical("no activity for %s time sending ctrl-c" % self.timeout)
             os.write(self.master_fd, 3)
 
     def conffile(self, current, new):
@@ -216,6 +215,24 @@ class PackageKitInstallProgress(apt.progress.InstallProgress):
         if self.conffile_prompts:
             self._backend.Message(MESSAGE_CONFIG_FILES_CHANGED, "The following conffile prompts were found and need investiagtion: %s" % "\n".join(self.conffile_prompts))
 
+class PackageKitDpkgInstallProgress(apt.progress.DpkgInstallProgress,PackageKitInstallProgress):
+    def run(self, debfile):
+        apt.progress.DpkgInstallProgress.run(self, debfile)
+
+    def updateInterface(self):
+        #pklog.debug("Updating interface")
+        apt.progress.DpkgInstallProgress.updateInterface(self)
+       # pklog.critical("no activity for %s time sending ctrl-c" % self.timeout)
+       # os.write(self.master_fd, 3)
+        try:
+            pklog.debug("%s" % os.read(self.master_fd, 512))
+        except Exception, e:
+            pklog.debug("ioerror: %s" % e)
+        # we timed out, send ctrl-c
+        if self.last_activity + self.timeout < time.time():
+            pklog.critical("no activity for %s time sending ctrl-c" % self.timeout)
+            os.write(self.master_fd, chr(3))
+
 def sigquit(signum, frame):
     pklog.error("Was killed")
     sys.exit(1)
@@ -731,6 +748,60 @@ class PackageKitAptBackend(PackageKitBaseBackend):
 
     @threaded
     @async
+    def doInstallFiles(self, trusted, full_paths):
+        '''
+        Implement install-files for the apt backend
+        Install local Debian package files
+        '''
+        pklog.info("Installing package files: %s" % full_paths)
+        self.StatusChanged(STATUS_INSTALL)
+        self.AllowCancel(False)
+        self.PercentageChanged(0)
+        self._check_init(prange=(0,10))
+        self._cache.clear()
+        dependencies = []
+        packages = []
+        # Collect all dependencies which need to be installed
+        for path in full_paths:
+            deb = apt.debfile.DebPackage(path, self._cache)
+            packages.append(deb)
+            deb.checkDeb()
+            (install, remove, unauthenticated) = deb.requiredChanges
+            if len(remove) > 0:
+                self.ErrorCode(ERROR_UNKNOWN, "Remove the following packages "
+                                              "before: %s" % remove)
+                self.Finished(EXIT_FAILED)
+                return
+            dependencies.extend(install)
+        # Install all dependecies before
+        try:
+            for dep in dependencies:
+                self._cache[dep].markInstall()
+            self._cache.commit(PackageKitFetchProgress(self, prange=(10,25)),
+                               PackageKitInstallProgress(self, prange=(25,50)))
+        except:
+            self._open_cache(prange=(90,99))
+            self.ErrorCode(ERROR_UNKNOWN, "Failed to install dependecies")
+            self.Finished(EXIT_FAILED)
+            return
+        # Install the Debian package files
+        for deb in packages:
+            try:
+                res = deb.install(PackageKitDpkgInstallProgress(self))
+            except Exception, e:
+                self.ErrorCode(ERROR_UNKNOWN, "Failed to install dpkg: %s" % e)
+                self.Finished(EXIT_FAILED)
+                return
+            if res != 0:
+                self.ErrorCode(ERROR_UNKNOWN, 
+                               "Failed to install package %s" % deb.pkgname)
+                self.Finished(EXIT_FAILED)
+                return
+        self.PercentageChanged(100)
+        self.Finished(EXIT_SUCCESS)
+
+    @threaded
+    @async
     def doRefreshCache(self, force):
         '''
         Implement the {backend}-refresh_cache functionality
commit 613cefffef370bd1801dced47b44252cc7dbdae2
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Sat Aug 23 20:08:10 2008 +0200

    poldek: support documentation group

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index 4e1aa29..5e2789e 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -72,6 +72,7 @@ static PLDGroupRegex group_perlre[] = {
 	{PK_GROUP_ENUM_ACCESSORIES, "/.*Archiving\\|.*Dictionaries/"},
 	{PK_GROUP_ENUM_ADMIN_TOOLS, "/.*Databases.*\\|.*Admin/"},
 	{PK_GROUP_ENUM_COMMUNICATION, "/.*Communications/"},
+	{PK_GROUP_ENUM_DOCUMENTATION, "/Documentation/"},
 	{PK_GROUP_ENUM_EDUCATION, "/.*Engineering\\|.*Math\\|.*Science/"},
 	{PK_GROUP_ENUM_FONTS, "/Fonts/"},
 	{PK_GROUP_ENUM_GAMES, "/.*Games.*/"},
@@ -736,6 +737,8 @@ pld_group_to_enum (const gchar *group)
 		 strstr (group, "Math") != NULL	||
 		 strstr (group, "Science") != NULL)
 		return PK_GROUP_ENUM_EDUCATION;
+	else if (strcmp (group, "Documentation") == 0)
+		return PK_GROUP_ENUM_DOCUMENTATION;
 	else if (strcmp (group, "Fonts") == 0)
 		return PK_GROUP_ENUM_FONTS;
 	else if (strstr (group, "Games") != NULL)
@@ -2004,6 +2007,7 @@ backend_get_groups (PkBackend *backend)
 		PK_GROUP_ENUM_ACCESSORIES,
 		PK_GROUP_ENUM_ADMIN_TOOLS,
 		PK_GROUP_ENUM_COMMUNICATION,
+		PK_GROUP_ENUM_DOCUMENTATION,
 		PK_GROUP_ENUM_EDUCATION,
 		PK_GROUP_ENUM_FONTS,
 		PK_GROUP_ENUM_GAMES,
commit dc34f1338e3f64b8eb01e26c055b10a581b2ce4e
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Sat Aug 23 14:50:01 2008 +0200

    bugfix: set "directory" as an argument for DownloadPackages(). Fix for backends using pk_backend_thread_create

diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 25d32f6..39bc104 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -908,6 +908,7 @@ pk_transaction_set_running (PkTransaction *transaction)
 	pk_backend_set_string (priv->backend, "key_id", priv->cached_key_id);
 	pk_backend_set_string (priv->backend, "parameter", priv->cached_parameter);
 	pk_backend_set_string (priv->backend, "value", priv->cached_value);
+	pk_backend_set_string (priv->backend, "directory", priv->cached_directory);
 
 	/* lets reduce pointer dereferences... */
 	desc = priv->backend->desc;
commit 7af2a28259aeb6ed0c7533291031275fab93880f
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Sat Aug 23 14:27:23 2008 +0200

    poldek: pass changes to GetUpdateDetail()

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index 3a071b7..4e1aa29 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -2358,10 +2358,12 @@ backend_get_update_detail_thread (PkBackend *backend)
 			pkg = n_array_nth (packages, 0);
 
 			if (strcmp (pkg->name, pi->name) == 0) {
-				gchar *updates;
-				gchar *obsoletes;
+				gchar *updates = NULL;
+				gchar *obsoletes = NULL;
 				gchar *cve_url = NULL;
+				const gchar *changes = NULL;
 				tn_array *cves = NULL;
+				struct pkguinf *upkg_uinf = NULL;
 
 				updates = package_id_from_pkg (pkg, "installed", 0);
 
@@ -2369,6 +2371,10 @@ backend_get_update_detail_thread (PkBackend *backend)
 
 				obsoletes = get_obsoletedby_pkg (upkg);
 
+				if ((upkg_uinf = pkg_uinf (upkg)) != NULL) {
+					changes = pkguinf_get_changelog (upkg_uinf, pkg->btime);
+				}
+
 				if ((cves = poldek_pkg_get_cves_from_pld_changelog (upkg, pkg->btime))) {
 					GString *string;
 					guint i;
@@ -2397,7 +2403,7 @@ backend_get_update_detail_thread (PkBackend *backend)
 							  "",
 							  cve_url ? cve_url : "",
 							  PK_RESTART_ENUM_NONE,
-							  "", NULL, PK_UPDATE_STATE_ENUM_UNKNOWN, NULL, NULL);
+							  "", changes, PK_UPDATE_STATE_ENUM_UNKNOWN, NULL, NULL);
 
 				g_free (updates);
 				g_free (obsoletes);
commit af42d36ac59acd3d6ed62c9d02a9ecc9d80b535a
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Sat Aug 23 14:14:05 2008 +0200

    poldek: use source name as repo description

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index e901cd7..3a071b7 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -2807,7 +2807,7 @@ backend_get_repo_list (PkBackend *backend, PkBitfield filters)
 			if (src->flags & PKGSOURCE_NOAUTO)
 				enabled = FALSE;
 
-			pk_backend_repo_detail (backend, src->name, src->path, enabled);
+			pk_backend_repo_detail (backend, src->path, src->name, enabled);
 		}
 
 		n_array_free (sources);
commit 4a82e664c45ef60b4a7ba8221737857a048f624f
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Sat Aug 23 14:12:51 2008 +0200

    poldek: removed backend reference count

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index b6654ae..e901cd7 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -132,7 +132,6 @@ typedef struct {
 
 /* global variables */
 static gint verbose = 1;
-static gint ref = 0;
 static PbError *pberror;
 /* cached locale variants */
 static GHashTable *clv;
@@ -1915,10 +1914,6 @@ backend_initalize (PkBackend *backend)
 	pberror = g_new0 (PbError, 1);
 	pberror->tslog = g_string_new ("");
 
-	/* reference count for the global variables */
-	if (ref++ > 1)
-		return;
-
 	do_poldek_init (backend);
 }
 /**
@@ -1927,9 +1922,6 @@ backend_initalize (PkBackend *backend)
 static void
 backend_destroy (PkBackend *backend)
 {
-	if (ref-- > 0)
-		return;
-
 	do_poldek_destroy (backend);
 
 	/* release PbError struct */
commit 3bb43f45e8d37fed0752c07d6b7d9abc2185ed62
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Sat Aug 23 14:09:50 2008 +0200

    poldek: get localized descriptions and summaries

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index d5a0098..b6654ae 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -134,6 +134,8 @@ typedef struct {
 static gint verbose = 1;
 static gint ref = 0;
 static PbError *pberror;
+/* cached locale variants */
+static GHashTable *clv;
 
 static struct poldek_ctx	*ctx = NULL;
 static struct poclidek_ctx	*cctx = NULL;
@@ -208,6 +210,123 @@ execute_packages_command (const gchar *format, ...)
 	return packages;
 }
 
+/**
+ * cut_country_code: (copied from poldek::misc.c)
+ *
+ * Usually lang looks like:
+ *   ll[_CC][.EEEE][@dddd]
+ * where:
+ *   ll      ISO language code
+ *   CC      (optional) ISO country code
+ *   EE      (optional) encoding
+ *   dd      (optional) dialect
+ *
+ * Returns: lang without country code (ll[.EEEE][@dddd]) or NULL when it's not
+ *          present in lang string. Returned value must be released.
+ **/
+static gchar*
+cut_country_code (const gchar *lang)
+{
+	gchar *p;
+	gchar *q;
+	gchar *newlang;
+
+	if ((q = strchr (lang, '_')) == NULL)
+		return NULL;
+
+	/* newlang is always shorter than lang */
+	newlang = malloc (strlen (lang));
+
+	p = n_strncpy (newlang, lang, q - lang + 1);
+
+	if ((q = strchr (lang, '.')))
+		n_strncpy (p, q, strlen (q) + 1);
+	else if ((q = strchr (lang, '@')))
+		n_strncpy(p, q, strlen(q) + 1);
+
+	return newlang;
+}
+
+/**
+ * get_locale_variants:
+ *
+ * Returns pointer to tn_array in which are locales which suit to lang. For
+ * example: for lang "pl_PL.UTF-8", returned array will contain "pl_PL.UTF-8",
+ * "pl.UTF-8", "pl_PL" and "pl". This array is needed by pkg_xuinf().
+ **/
+static tn_array*
+get_locale_variants (PkBackend *backend, const gchar *lang)
+{
+	tn_array *langs;
+	gchar *copy;
+	gchar *wocc = NULL;
+	gchar *sep = "@.";
+	gint len;
+
+	/* first check cached_locale_variants */
+	if ((langs = g_hash_table_lookup (clv, lang)) != NULL)
+		return langs;
+
+	langs = n_array_new (2, (tn_fn_free)free, NULL);
+
+	n_array_push (langs, g_strdup (lang));
+
+	/* try without country code */
+	if ((wocc = cut_country_code (lang)) != NULL)
+		n_array_push (langs, wocc);
+
+	len = strlen (lang) + 1;
+	copy = g_alloca (len);
+	memcpy (copy, lang, len);
+
+	while (*sep) {
+		gchar *p;
+
+		if ((p = strchr (copy, *sep)) != NULL) {
+			*p = '\0';
+
+			n_array_push (langs, g_strdup (copy));
+
+			/* try without country code */
+			if ((wocc = cut_country_code (copy)) != NULL)
+				n_array_push (langs, wocc);
+		}
+
+		sep++;
+	}
+
+	g_hash_table_insert (clv, g_strdup (lang), langs);
+
+	return langs;
+}
+
+/**
+ * pkg_uinf_i18n:
+ *
+ * Returns pointer to struct pkguinf with localized summary and description.
+ **/
+static struct pkguinf*
+pkg_uinf_i18n (PkBackend *backend, struct pkg *pkg)
+{
+	struct pkguinf *pkgu = NULL;
+	gchar *lang = NULL;
+
+	lang = pk_backend_get_locale (backend);
+
+	if (lang) {
+		tn_array *langs;
+
+		langs = get_locale_variants (backend, lang);
+		pkgu = pkg_xuinf (pkg, langs);
+	} else {
+		pkgu = pkg_uinf (pkg);
+	}
+
+	g_free (lang);
+
+	return pkgu;
+}
+
 static gint
 poldek_get_files_to_download (const struct poldek_ts *ts)
 {
@@ -1096,8 +1215,8 @@ package_id_from_pkg (struct pkg *pkg, const gchar *repo, PkBitfield filters)
 static void
 poldek_backend_package (PkBackend *backend, struct pkg *pkg, PkInfoEnum infoenum, PkBitfield filters)
 {
-	struct pkguinf	*pkgu;
-	gchar		*package_id;
+	struct pkguinf *pkgu = NULL;
+	gchar *package_id;
 
 	if (infoenum == PK_INFO_ENUM_UNKNOWN) {
 		if (pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
@@ -1115,10 +1234,9 @@ poldek_backend_package (PkBackend *backend, struct pkg *pkg, PkInfoEnum infoenum
 
 	package_id = package_id_from_pkg (pkg, NULL, filters);
 
-	pkgu = pkg_uinf (pkg);
-
-	if (pkgu) {
+	if ((pkgu = pkg_uinf_i18n (backend, pkg))) {
 		pk_backend_package (backend, infoenum, package_id, pkguinf_get (pkgu, PKGUINF_SUMMARY));
+
 		pkguinf_free (pkgu);
 	} else {
 		pk_backend_package (backend, infoenum, package_id, "");
@@ -1501,6 +1619,7 @@ static void
 pb_error_clean (void)
 {
 	g_free (pberror->vfffmsg);
+	pberror->vfffmsg = NULL;
 
 	pberror->tslog = g_string_erase (pberror->tslog, 0, -1);
 	pberror->rpmstate = PB_RPM_STATE_ENUM_NONE;
@@ -1639,8 +1758,10 @@ poldek_backend_log (void *data, int pri, char *message)
 		if (pberror->vfffmsg) {
 			if (strcmp (pberror->vfffmsg, message) == 0)
 				return;
-			else
+			else {
 				g_free (pberror->vfffmsg);
+				pberror->vfffmsg = NULL;
+			}
 		}
 
 		pberror->vfffmsg = g_strdup (message);
@@ -1748,6 +1869,8 @@ do_poldek_init (PkBackend *backend)
 	/* disable unique package names */
 	poldek_configure (ctx, POLDEK_CONF_OPT, POLDEK_OP_UNIQN, 0);
 
+	poldek_configure (ctx, POLDEK_CONF_OPT, POLDEK_OP_LDALLDESC, 1);
+
 	/* poldek has to ask. Otherwise callbacks won't be used */
 	poldek_configure (ctx, POLDEK_CONF_OPT, POLDEK_OP_CONFIRM_INST, 1);
 	poldek_configure (ctx, POLDEK_CONF_OPT, POLDEK_OP_CONFIRM_UNINST, 1);
@@ -1787,6 +1910,8 @@ poldek_reload (PkBackend *backend, gboolean load_packages) {
 static void
 backend_initalize (PkBackend *backend)
 {
+	clv = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)n_array_free);
+
 	pberror = g_new0 (PbError, 1);
 	pberror->tslog = g_string_new ("");
 
@@ -1811,6 +1936,8 @@ backend_destroy (PkBackend *backend)
 	g_free (pberror->vfffmsg);
 	g_string_free (pberror->tslog, TRUE);
 
+	g_hash_table_destroy (clv);
+
 	g_free (pberror);
 }
 
@@ -1997,11 +2124,9 @@ backend_get_details_thread (PkBackend *backend)
 			struct pkguinf *pkgu = NULL;
 			PkGroupEnum group;
 
-			pkgu = pkg_uinf (pkg);
-
 			group = pld_group_to_enum (pkg_group (pkg));
 
-			if (pkgu) {
+			if ((pkgu = pkg_uinf_i18n (backend, pkg)) != NULL) {
 				pk_backend_details (backend,
 							package_ids[n],
 							pkguinf_get (pkgu, PKGUINF_LICENSE),
commit 6ade409951b0794a0b872f5c271338b0c15ffff4
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Sat Aug 23 13:47:53 2008 +0200

    poldek: fix crash

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index e17f2e4..d5a0098 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -249,20 +249,23 @@ poldek_get_bytes_to_download (struct poldek_ts *ts, tn_array *pkgs)
 static long
 poldek_get_bytes_to_download_from_ts (struct poldek_ts *ts)
 {
-	gchar mark[2][2] = {"I", "D"};
+	tn_array *pkgs = NULL;
 	long bytes = 0;
-	gint i = 0;
 
-	while (mark[i]) {
-		tn_array *pkgs = poldek_ts_get_summary (ts, mark[i]);
+	pkgs = poldek_ts_get_summary (ts, "I");
 
-		if (pkgs) {
-			bytes += do_get_bytes_to_download (ts, pkgs);
+	if (pkgs) {
+		bytes += do_get_bytes_to_download (ts, pkgs);
 
-			n_array_free (pkgs);
-		}
+		n_array_free (pkgs);
+	}
 
-		i++;
+	pkgs = poldek_ts_get_summary (ts, "D");
+
+	if (pkgs) {
+		bytes += do_get_bytes_to_download (ts, pkgs);
+
+		n_array_free (pkgs);
 	}
 
 	return bytes;
commit 57a13732b7455622d2a29ecb45061e565ef7ac00
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Fri Aug 22 21:29:12 2008 +0200

    poldek: make execute_* functions use va_list

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index a45bce6..e17f2e4 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -146,12 +146,18 @@ static struct poclidek_ctx	*cctx = NULL;
  * Returns TRUE on success, FALSE when some error occurs.
  **/
 static gboolean
-execute_command (const gchar *command)
+execute_command (const gchar *format, ...)
 {
 	struct poclidek_rcmd *rcmd;
 	struct poldek_ts *ts;
+	gchar *command;
+	va_list args;
 	gboolean result = FALSE;
 
+	va_start (args, format);
+	command = g_strdup_vprintf (format, args);
+	va_end (args);
+
 	ts = poldek_ts_new (ctx, 0);
 	rcmd = poclidek_rcmd_new (cctx, ts);
 
@@ -164,6 +170,8 @@ execute_command (const gchar *command)
 	poclidek_rcmd_free (rcmd);
 	poldek_ts_free (ts);
 
+	g_free (command);
+
 	return result;
 }
 
@@ -176,10 +184,16 @@ execute_command (const gchar *command)
  * result of specified command. On failure returns NULL.
  **/
 static tn_array*
-execute_packages_command (const gchar *command)
+execute_packages_command (const gchar *format, ...)
 {
 	struct poclidek_rcmd *rcmd;
 	tn_array *packages = NULL;
+	va_list args;
+	gchar *command;
+
+	va_start (args, format);
+	command = g_strdup_vprintf (format, args);
+	va_end (args);
 
 	rcmd = poclidek_rcmd_new (cctx, NULL);
 
@@ -189,6 +203,8 @@ execute_packages_command (const gchar *command)
 
 	poclidek_rcmd_free (rcmd);
 
+	g_free (command);
+
 	return packages;
 }
 
@@ -288,16 +304,14 @@ poldek_vf_progress_new (void *data, const gchar *label)
 	guint ts_type = pk_backend_get_uint (backend, "ts_type");
 
 	if (ts_type == TS_TYPE_ENUM_INSTALL || ts_type == TS_TYPE_ENUM_UPDATE) {
-		gchar *filename = g_path_get_basename (label), *pkgname, *command;
+		gchar *filename = g_path_get_basename (label), *pkgname;
 		tn_array *packages = NULL;
 
 		pkgname = g_strndup (filename, (sizeof(gchar)*strlen(filename)-4));
 
-		command = g_strdup_printf ("cd /all-avail; ls -q %s", pkgname);
-
 		pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD);
 
-		if ((packages = execute_packages_command (command)) != NULL) {
+		if ((packages = execute_packages_command ("cd /all-avail; ls -q %s", pkgname)) != NULL) {
 			struct pkg *pkg = n_array_nth (packages, 0);
 
 			poldek_backend_package (backend, pkg, PK_INFO_ENUM_DOWNLOADING, PK_FILTER_ENUM_NONE);
@@ -305,7 +319,6 @@ poldek_vf_progress_new (void *data, const gchar *label)
 			n_array_free (packages);
 		}
 
-		g_free (command);
 		g_free (pkgname);
 		g_free (filename);
 	}
@@ -732,18 +745,15 @@ poldek_pkg_get_cves_from_pld_changelog (struct pkg *pkg, time_t since)
 			s += 7; /* cut "\n- see " */
 
 			if ((e = strchr (s, '\''))) {
-				gchar *command;
 				tn_array *packages = NULL;
 
 				*e = '\0'; /* now s is the name of package with changelog */
 
-				command = g_strdup_printf ("cd /all-avail; ls -q %s*", s);
-
 				/* release it */
 				g_free (chlog);
 				chlog = NULL;
 
-				if ((packages = execute_packages_command (command)) != NULL) {
+				if ((packages = execute_packages_command ("cd /all-avail; ls -q %s*", s)) != NULL) {
 					struct pkg *p = n_array_nth (packages, 0);
 					struct pkguinf *inf_parent = NULL;
 
@@ -756,8 +766,6 @@ poldek_pkg_get_cves_from_pld_changelog (struct pkg *pkg, time_t since)
 
 					n_array_free (packages);
 				}
-
-				g_free (command);
 			}
 		}
 	}
@@ -1124,15 +1132,14 @@ poldek_get_pkg_from_package_id (const gchar *package_id)
 {
 	PkPackageId		*pi;
 	struct pkg		*result = NULL;
-	gchar			*vr, *command;
+	gchar			*vr;
 	tn_array *packages = NULL;
 
 	pi = pk_package_id_new_from_string (package_id);
 
 	vr = poldek_get_vr_from_package_id_evr (pi->version);
-	command = g_strdup_printf ("cd /%s; ls -q %s-%s.%s", pi->data, pi->name, vr, pi->arch);
 
-	if ((packages = execute_packages_command (command)) != NULL) {
+	if ((packages = execute_packages_command ("cd /%s; ls -q %s-%s.%s", pi->data, pi->name, vr, pi->arch)) != NULL) {
 		if (n_array_size (packages) > 0) {
 			/* only one package is needed */
 			result = pkg_link (n_array_nth (packages, 0));
@@ -1143,7 +1150,6 @@ poldek_get_pkg_from_package_id (const gchar *package_id)
 	pk_package_id_free (pi);
 
 	g_free (vr);
-	g_free (command);
 
 	return result;
 }
@@ -1248,22 +1254,14 @@ search_package_thread (PkBackend *backend)
 	}
 
 	if (search_cmd != NULL) {
-		gchar		*command;
 		tn_array	*pkgs = NULL, *installed = NULL, *available = NULL;
 
 		if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
-			command = g_strdup_printf ("cd /installed; %s", search_cmd);
-
-			installed = execute_packages_command (command);
-
-			g_free (command);
+			installed = execute_packages_command ("cd /installed; %s", search_cmd);
 		}
-		if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
-			command = g_strdup_printf ("cd /all-avail; %s", search_cmd);
-
-			available = execute_packages_command (command);
 
-			g_free (command);
+		if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
+			available = execute_packages_command ("cd /all-avail; %s", search_cmd);
 		}
 
 		if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED) &&
@@ -2228,14 +2226,11 @@ backend_get_update_detail_thread (PkBackend *backend)
 
 	for (n = 0; n < g_strv_length (package_ids); n++) {
 		PkPackageId *pi = NULL;
-		gchar *command;
 		tn_array *packages = NULL;
 
 		pi = pk_package_id_new_from_string (package_ids[n]);
 
-		command = g_strdup_printf ("cd /installed; ls -q %s", pi->name);
-
-		if ((packages = execute_packages_command (command)) != NULL) {
+		if ((packages = execute_packages_command ("cd /installed; ls -q %s", pi->name)) != NULL) {
 			struct pkg *pkg = NULL;
 			struct pkg *upkg = NULL;
 
@@ -2304,7 +2299,6 @@ backend_get_update_detail_thread (PkBackend *backend)
 						  "", NULL, PK_UPDATE_STATE_ENUM_UNKNOWN, NULL, NULL);
 		}
 
-		g_free (command);
 		pk_package_id_free (pi);
 	}
 
commit 4040a6e32b0689758f3f4765d00317d6b7893d76
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Fri Aug 22 21:18:46 2008 +0200

    poldek: execute poldek commands via execute_command and execute_packages_command functions

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index 49028bd..a45bce6 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -25,6 +25,7 @@
 #include <log.h>
 #include <capreq.h>
 #include <poldek.h>
+#include <poclidek/dent.h>
 #include <poclidek/poclidek.h>
 #include <pkgdir/pkgdir.h>
 #include <pkgdir/source.h>
@@ -137,6 +138,60 @@ static PbError *pberror;
 static struct poldek_ctx	*ctx = NULL;
 static struct poclidek_ctx	*cctx = NULL;
 
+/**
+ * execute_command:
+ *
+ * Execute specified command.
+ *
+ * Returns TRUE on success, FALSE when some error occurs.
+ **/
+static gboolean
+execute_command (const gchar *command)
+{
+	struct poclidek_rcmd *rcmd;
+	struct poldek_ts *ts;
+	gboolean result = FALSE;
+
+	ts = poldek_ts_new (ctx, 0);
+	rcmd = poclidek_rcmd_new (cctx, ts);
+
+	ts->setop(ts, POLDEK_OP_PARTICLE, 0);
+
+	if (poclidek_rcmd_execline (rcmd, command)) {
+		result = TRUE;
+	}
+
+	poclidek_rcmd_free (rcmd);
+	poldek_ts_free (ts);
+
+	return result;
+}
+
+/**
+ * execute_packages_command:
+ *
+ * Execute specified command.
+ *
+ * Returns on success pointer to the tn_array containing packages which are the
+ * result of specified command. On failure returns NULL.
+ **/
+static tn_array*
+execute_packages_command (const gchar *command)
+{
+	struct poclidek_rcmd *rcmd;
+	tn_array *packages = NULL;
+
+	rcmd = poclidek_rcmd_new (cctx, NULL);
+
+	if (poclidek_rcmd_execline (rcmd, command)) {
+		packages = poclidek_rcmd_get_packages (rcmd);
+	}
+
+	poclidek_rcmd_free (rcmd);
+
+	return packages;
+}
+
 static gint
 poldek_get_files_to_download (const struct poldek_ts *ts)
 {
@@ -233,10 +288,8 @@ poldek_vf_progress_new (void *data, const gchar *label)
 	guint ts_type = pk_backend_get_uint (backend, "ts_type");
 
 	if (ts_type == TS_TYPE_ENUM_INSTALL || ts_type == TS_TYPE_ENUM_UPDATE) {
-		gchar		*filename = g_path_get_basename (label), *pkgname, *command;
-		struct poclidek_rcmd *rcmd;
-		tn_array	*pkgs = NULL;
-		struct pkg	*pkg = NULL;
+		gchar *filename = g_path_get_basename (label), *pkgname, *command;
+		tn_array *packages = NULL;
 
 		pkgname = g_strndup (filename, (sizeof(gchar)*strlen(filename)-4));
 
@@ -244,16 +297,13 @@ poldek_vf_progress_new (void *data, const gchar *label)
 
 		pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD);
 
-		rcmd = poclidek_rcmd_new (cctx, NULL);
-		poclidek_rcmd_execline (rcmd, command);
-		pkgs = poclidek_rcmd_get_packages (rcmd);
+		if ((packages = execute_packages_command (command)) != NULL) {
+			struct pkg *pkg = n_array_nth (packages, 0);
 
-		if (pkgs) {
-			pkg = n_array_nth (pkgs, 0);
 			poldek_backend_package (backend, pkg, PK_INFO_ENUM_DOWNLOADING, PK_FILTER_ENUM_NONE);
-		}
 
-		poclidek_rcmd_free (rcmd);
+			n_array_free (packages);
+		}
 
 		g_free (command);
 		g_free (pkgname);
@@ -527,18 +577,7 @@ pkg_is_installed (struct pkg *pkg)
 static tn_array*
 poldek_get_security_updates (void)
 {
-	struct poclidek_rcmd *rcmd = NULL;
-	tn_array *pkgs = NULL;
-
-	rcmd = poclidek_rcmd_new (cctx, NULL);
-
-	poclidek_rcmd_execline (rcmd, "cd /all-avail; ls -S");
-
-	pkgs = poclidek_rcmd_get_packages (rcmd);
-
-	poclidek_rcmd_free (rcmd);
-
-	return pkgs;
+	return execute_packages_command ("cd /all-avail; ls -S");
 }
 
 /**
@@ -669,17 +708,7 @@ poldek_get_nvra_from_package_id (const gchar* package_id)
 static tn_array*
 poldek_get_installed_packages (void)
 {
-	struct poclidek_rcmd	*rcmd = NULL;
-	tn_array		*arr = NULL;
-
-	rcmd = poclidek_rcmd_new (cctx, NULL);
-	poclidek_rcmd_execline (rcmd, "cd /installed; ls -q *");
-
-	arr = poclidek_rcmd_get_packages (rcmd);
-
-	poclidek_rcmd_free (rcmd);
-
-	return arr;
+	return poclidek_get_dent_packages (cctx, POCLIDEK_INSTALLEDDIR);
 }
 
 static tn_array*
@@ -703,39 +732,30 @@ poldek_pkg_get_cves_from_pld_changelog (struct pkg *pkg, time_t since)
 			s += 7; /* cut "\n- see " */
 
 			if ((e = strchr (s, '\''))) {
-				struct poclidek_rcmd *rcmd;
 				gchar *command;
+				tn_array *packages = NULL;
 
 				*e = '\0'; /* now s is the name of package with changelog */
 
-				rcmd = poclidek_rcmd_new (cctx, NULL);
-
 				command = g_strdup_printf ("cd /all-avail; ls -q %s*", s);
 
 				/* release it */
 				g_free (chlog);
 				chlog = NULL;
 
-				if (poclidek_rcmd_execline (rcmd, command)) {
-					tn_array *pkgs;
+				if ((packages = execute_packages_command (command)) != NULL) {
+					struct pkg *p = n_array_nth (packages, 0);
+					struct pkguinf *inf_parent = NULL;
 
-					pkgs = poclidek_rcmd_get_packages (rcmd);
+					if ((inf_parent = pkg_uinf (p))) {
+						if ((ch = pkguinf_get_changelog (inf_parent, since)))
+							chlog = g_strdup(ch);
 
-					if (pkgs) {
-						struct pkg *p = n_array_nth (pkgs, 0);
-						struct pkguinf *inf_parent = NULL;
-
-						if ((inf_parent = pkg_uinf (p))) {
-							if ((ch = pkguinf_get_changelog (inf_parent, since)))
-								chlog = g_strdup(ch);
-
-							pkguinf_free (inf_parent);
-						}
+						pkguinf_free (inf_parent);
 					}
-					n_array_cfree (&pkgs);
-				}
 
-				poclidek_rcmd_free (rcmd);
+					n_array_free (packages);
+				}
 
 				g_free (command);
 			}
@@ -1103,31 +1123,23 @@ static struct pkg*
 poldek_get_pkg_from_package_id (const gchar *package_id)
 {
 	PkPackageId		*pi;
-	struct poclidek_rcmd	*rcmd;
 	struct pkg		*result = NULL;
 	gchar			*vr, *command;
+	tn_array *packages = NULL;
 
 	pi = pk_package_id_new_from_string (package_id);
 
-	rcmd = poclidek_rcmd_new (cctx, NULL);
-
 	vr = poldek_get_vr_from_package_id_evr (pi->version);
 	command = g_strdup_printf ("cd /%s; ls -q %s-%s.%s", pi->data, pi->name, vr, pi->arch);
 
-	if (poclidek_rcmd_execline (rcmd, command)) {
-		tn_array	*pkgs = NULL;
-
-		pkgs = poclidek_rcmd_get_packages (rcmd);
-
-		if (n_array_size (pkgs) > 0) {
+	if ((packages = execute_packages_command (command)) != NULL) {
+		if (n_array_size (packages) > 0) {
 			/* only one package is needed */
-			result = pkg_link (n_array_nth (pkgs, 0));
+			result = pkg_link (n_array_nth (packages, 0));
 		}
-		n_array_free (pkgs);
+		n_array_free (packages);
 	}
 
-	poclidek_rcmd_free (rcmd);
-
 	pk_package_id_free (pi);
 
 	g_free (vr);
@@ -1171,14 +1183,11 @@ search_package_thread (PkBackend *backend)
 	PkBitfield		filters;
 	PkProvidesEnum		provides;
 	gchar			*search_cmd = NULL;
-	struct poclidek_rcmd	*cmd = NULL;
 	const gchar *search;
 	guint mode;
 
 	pb_load_packages (backend);
 
-	cmd = poclidek_rcmd_new (cctx, NULL);
-
 	mode = pk_backend_get_uint (backend, "mode");
 	filters = pk_backend_get_uint (backend, "filters");
 
@@ -1238,22 +1247,21 @@ search_package_thread (PkBackend *backend)
 		g_free (packages_str);
 	}
 
-	if (cmd != NULL && search_cmd != NULL) {
+	if (search_cmd != NULL) {
 		gchar		*command;
 		tn_array	*pkgs = NULL, *installed = NULL, *available = NULL;
 
 		if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
 			command = g_strdup_printf ("cd /installed; %s", search_cmd);
-			if (poclidek_rcmd_execline (cmd, command)) {
-				installed = poclidek_rcmd_get_packages (cmd);
-			}
+
+			installed = execute_packages_command (command);
 
 			g_free (command);
 		}
 		if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
 			command = g_strdup_printf ("cd /all-avail; %s", search_cmd);
-			if (poclidek_rcmd_execline (cmd, command))
-				available = poclidek_rcmd_get_packages (cmd);
+
+			available = execute_packages_command (command);
 
 			g_free (command);
 		}
@@ -1330,7 +1338,6 @@ search_package_thread (PkBackend *backend)
 		} else {
 			pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Package not found");
 		}
-		poclidek_rcmd_free (cmd);
 	}
 
 	if (sigint_reached ()) {
@@ -1382,22 +1389,14 @@ update_packages_thread (PkBackend *backend)
 	cmd = g_string_new ("upgrade ");
 
 	if (update_system) {
-		struct poclidek_rcmd *rcmd;
-
-		rcmd = poclidek_rcmd_new (cctx, NULL);
-
-		if (poclidek_rcmd_execline (rcmd, "cd /all-avail; ls -q -u")) {
-			tn_array *pkgs;
-
-			pkgs = poclidek_rcmd_get_packages (rcmd);
+		tn_array *packages = NULL;
 
+		if ((packages = execute_packages_command ("cd /all-avail; ls -q -u")) != NULL) {
 			/* UpdateSystem updates to the newest available packages */
-			do_newest (pkgs);
+			do_newest (packages);
 
-			for (i = 0; i < n_array_size (pkgs); i++) {
-				struct pkg *pkg;
-
-				pkg = n_array_nth (pkgs, i);
+			for (i = 0; i < n_array_size (packages); i++) {
+				struct pkg *pkg = n_array_nth (packages, i);
 
 				/* don't try to update blocked packages */
 				if (!(pkg->flags & PKG_HELD)) {
@@ -1408,10 +1407,8 @@ update_packages_thread (PkBackend *backend)
 				}
 			}
 
-			n_array_free (pkgs);
+			n_array_free (packages);
 		}
-
-		poclidek_rcmd_free (rcmd);
 	} else {
 		for (i = 0; i < g_strv_length (package_ids); i++) {
 			struct pkg *pkg;
@@ -1430,19 +1427,9 @@ update_packages_thread (PkBackend *backend)
 	command = g_string_free (cmd, FALSE);
 
 	if (toupdate > 0) {
-		struct poclidek_rcmd *rcmd;
-		struct poldek_ts *ts;
-
-		ts = poldek_ts_new (ctx, 0);
-		rcmd = poclidek_rcmd_new (cctx, ts);
-
-		ts->setop(ts, POLDEK_OP_PARTICLE, 0);
-
-		if (!poclidek_rcmd_execline (rcmd, command))
+		if (execute_command (command) == FALSE) {
 			pb_error_show (backend, PK_ERROR_ENUM_TRANSACTION_ERROR);
-
-		poclidek_rcmd_free (rcmd);
-		poldek_ts_free (ts);
+		}
 	}
 
 	poldek_backend_percentage_data_destroy (backend);
@@ -1996,42 +1983,44 @@ static gboolean
 backend_get_details_thread (PkBackend *backend)
 {
 	gchar **package_ids;
-	struct pkg	*pkg = NULL;
+	guint n;
 
 	package_ids = pk_backend_get_strv (backend, "package_ids");
 
 	pb_load_packages (backend);
 
-	pkg = poldek_get_pkg_from_package_id (package_ids[0]);
+	for (n = 0; n < g_strv_length (package_ids); n++) {
+		struct pkg *pkg = NULL;
 
-	if (pkg) {
-		struct pkguinf	*pkgu = NULL;
-		PkGroupEnum	group;
+		if ((pkg = poldek_get_pkg_from_package_id (package_ids[n])) != NULL) {
+			struct pkguinf *pkgu = NULL;
+			PkGroupEnum group;
 
-		pkgu = pkg_uinf (pkg);
+			pkgu = pkg_uinf (pkg);
 
-		group = pld_group_to_enum (pkg_group (pkg));
+			group = pld_group_to_enum (pkg_group (pkg));
 
-		if (pkgu) {
-			pk_backend_details (backend,
-						package_ids[0],
-						pkguinf_get (pkgu, PKGUINF_LICENSE),
-						group,
-						pkguinf_get (pkgu, PKGUINF_DESCRIPTION),
-						pkguinf_get (pkgu, PKGUINF_URL),
-						pkg->fsize);
-			pkguinf_free (pkgu);
-		} else {
-			pk_backend_details (backend,
-						package_ids[0],
-						"",
-						group,
-						"",
-						"",
-						pkg->fsize);
-		}
+			if (pkgu) {
+				pk_backend_details (backend,
+							package_ids[n],
+							pkguinf_get (pkgu, PKGUINF_LICENSE),
+							group,
+							pkguinf_get (pkgu, PKGUINF_DESCRIPTION),
+							pkguinf_get (pkgu, PKGUINF_URL),
+							pkg->fsize);
+				pkguinf_free (pkgu);
+			} else {
+				pk_backend_details (backend,
+							package_ids[n],
+							"",
+							group,
+							"",
+							"",
+							pkg->fsize);
+			}
 
-		pkg_free (pkg);
+			pkg_free (pkg);
+		}
 	}
 
 	pk_backend_finished (backend);
@@ -2230,94 +2219,95 @@ get_obsoletedby_pkg (struct pkg *pkg)
 static gboolean
 backend_get_update_detail_thread (PkBackend *backend)
 {
-	PkPackageId	*pi;
 	gchar **package_ids;
-	struct poclidek_rcmd	*rcmd;
-	gchar		*command;
+	guint n;
 
 	package_ids = pk_backend_get_strv (backend, "package_ids");
 
 	pb_load_packages (backend);
 
-	pi = pk_package_id_new_from_string (package_ids[0]);
+	for (n = 0; n < g_strv_length (package_ids); n++) {
+		PkPackageId *pi = NULL;
+		gchar *command;
+		tn_array *packages = NULL;
 
-	rcmd = poclidek_rcmd_new (cctx, NULL);
+		pi = pk_package_id_new_from_string (package_ids[n]);
 
-	command = g_strdup_printf ("cd /installed; ls -q %s", pi->name);
+		command = g_strdup_printf ("cd /installed; ls -q %s", pi->name);
 
-	if (poclidek_rcmd_execline (rcmd, command)) {
-		tn_array	*pkgs = NULL;
-		struct pkg	*pkg = NULL, *upkg = NULL;
+		if ((packages = execute_packages_command (command)) != NULL) {
+			struct pkg *pkg = NULL;
+			struct pkg *upkg = NULL;
 
-		pkgs = poclidek_rcmd_get_packages (rcmd);
+			/* get one package */
+			pkg = n_array_nth (packages, 0);
 
-		/* get one package */
-		pkg = n_array_nth (pkgs, 0);
+			if (strcmp (pkg->name, pi->name) == 0) {
+				gchar *updates;
+				gchar *obsoletes;
+				gchar *cve_url = NULL;
+				tn_array *cves = NULL;
 
-		if (strcmp (pkg->name, pi->name) == 0) {
-			gchar	*updates, *obsoletes, *cve_url = NULL;
-			tn_array *cves = NULL;
+				updates = package_id_from_pkg (pkg, "installed", 0);
 
-			updates = package_id_from_pkg (pkg, "installed", 0);
+				upkg = poldek_get_pkg_from_package_id (package_ids[n]);
 
-			upkg = poldek_get_pkg_from_package_id (package_ids[0]);
+				obsoletes = get_obsoletedby_pkg (upkg);
 
-			obsoletes = get_obsoletedby_pkg (upkg);
+				if ((cves = poldek_pkg_get_cves_from_pld_changelog (upkg, pkg->btime))) {
+					GString *string;
+					guint i;
 
-			if ((cves = poldek_pkg_get_cves_from_pld_changelog (upkg, pkg->btime))) {
-				GString	*string;
-				gint i;
+					string = g_string_new ("");
 
-				string = g_string_new ("");
+					for (i = 0; i < n_array_size (cves); i++) {
+						gchar *cve = n_array_nth (cves, i);
 
-				for (i = 0; i < n_array_size (cves); i++) {
-					gchar *cve = n_array_nth (cves, i);
+						g_string_append_printf (string,
+									"http://nvd.nist.gov/nvd.cfm?cvename=%s;%s",
+									cve, cve);
 
-					g_string_append_printf (string,
-								"http://nvd.nist.gov/nvd.cfm?cvename=%s;%s",
-								cve, cve);
+						if ((i + 1) < n_array_size (cves))
+							g_string_append_printf (string, ";");
+					}
 
-					if ((i + 1) < n_array_size (cves))
-						g_string_append_printf (string, ";");
+					cve_url = g_string_free (string, FALSE);
 				}
 
-				cve_url = g_string_free (string, FALSE);
+				pk_backend_update_detail (backend,
+							  package_ids[n],
+							  updates,
+							  obsoletes ? obsoletes : "",
+							  "",
+							  "",
+							  cve_url ? cve_url : "",
+							  PK_RESTART_ENUM_NONE,
+							  "", NULL, PK_UPDATE_STATE_ENUM_UNKNOWN, NULL, NULL);
+
+				g_free (updates);
+				g_free (obsoletes);
+				g_free (cve_url);
+
+				n_array_cfree (&cves);
 			}
 
+			n_array_free (packages);
+		} else {
 			pk_backend_update_detail (backend,
-						  package_ids[0],
-						  updates,
-						  obsoletes ? obsoletes : "",
+						  package_ids[n],
+						  "",
+						  "",
+						  "",
 						  "",
 						  "",
-						  cve_url ? cve_url : "",
 						  PK_RESTART_ENUM_NONE,
 						  "", NULL, PK_UPDATE_STATE_ENUM_UNKNOWN, NULL, NULL);
-
-			g_free (updates);
-			g_free (obsoletes);
-			g_free (cve_url);
-
-			n_array_cfree (&cves);
 		}
 
-		n_array_free (pkgs);
-	} else {
-		pk_backend_update_detail (backend,
-					  package_ids[0],
-					  "",
-					  "",
-					  "",
-					  "",
-					  "",
-					  PK_RESTART_ENUM_NONE,
-					  "", NULL, PK_UPDATE_STATE_ENUM_UNKNOWN, NULL, NULL);
+		g_free (command);
+		pk_package_id_free (pi);
 	}
 
-	g_free (command);
-	poclidek_rcmd_free (rcmd);
-	pk_package_id_free (pi);
-
 	pk_backend_finished (backend);
 	return TRUE;
 }
@@ -2338,45 +2328,37 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
 static gboolean
 backend_get_updates_thread (PkBackend *backend)
 {
-	struct poclidek_rcmd	*rcmd = NULL;
+	tn_array *packages = NULL;
 
 	pb_load_packages (backend);
 
-	rcmd = poclidek_rcmd_new (cctx, NULL);
+	if ((packages = execute_packages_command ("cd /all-avail; ls -q -u")) != NULL) {
+		tn_array *secupgrades = NULL;
+		guint i;
 
-	if (rcmd) {
-		if (poclidek_rcmd_execline (rcmd, "cd /all-avail; ls -q -u")) {
-			tn_array	*pkgs = NULL;
-			tn_array	*secupgrades = NULL;
-			gint		i;
+		/* GetUpdates returns only the newest packages */
+		do_newest (packages);
 
-			pkgs = poclidek_rcmd_get_packages (rcmd);
+		secupgrades = poldek_get_security_updates ();
 
-			/* GetUpdates returns only the newest packages */
-			do_newest (pkgs);
+		for (i = 0; i < n_array_size (packages); i++) {
+			struct pkg *pkg = n_array_nth (packages, i);
 
-			secupgrades = poldek_get_security_updates ();
-
-			for (i = 0; i < n_array_size (pkgs); i++) {
-				struct pkg	*pkg = n_array_nth (pkgs, i);
-
-				if (sigint_reached ())
-					break;
+			if (sigint_reached ())
+				break;
 
-				/* mark held packages as blocked */
-				if (pkg->flags & PKG_HELD)
-					poldek_backend_package (backend, pkg, PK_INFO_ENUM_BLOCKED, PK_FILTER_ENUM_NONE);
-				else if (poldek_pkg_in_array (pkg, secupgrades, (tn_fn_cmp)pkg_cmp_name_evr))
-					poldek_backend_package (backend, pkg, PK_INFO_ENUM_SECURITY, PK_FILTER_ENUM_NONE);
-				else
-					poldek_backend_package (backend, pkg, PK_INFO_ENUM_NORMAL, PK_FILTER_ENUM_NONE);
-			}
-			n_array_cfree (&secupgrades);
-			n_array_free (pkgs);
+			/* mark held packages as blocked */
+			if (pkg->flags & PKG_HELD)
+				poldek_backend_package (backend, pkg, PK_INFO_ENUM_BLOCKED, PK_FILTER_ENUM_NONE);
+			else if (poldek_pkg_in_array (pkg, secupgrades, (tn_fn_cmp)pkg_cmp_name_evr))
+				poldek_backend_package (backend, pkg, PK_INFO_ENUM_SECURITY, PK_FILTER_ENUM_NONE);
+			else
+				poldek_backend_package (backend, pkg, PK_INFO_ENUM_NORMAL, PK_FILTER_ENUM_NONE);
 		}
-	}
 
-	poclidek_rcmd_free (rcmd);
+		n_array_cfree (&secupgrades);
+		n_array_free (packages);
+	}
 
 	if (sigint_reached ())
 		pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "Action cancelled.");
@@ -2401,8 +2383,6 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
 static gboolean
 backend_install_packages_thread (PkBackend *backend)
 {
-	struct poldek_ts	*ts;
-	struct poclidek_rcmd	*rcmd;
 	gchar			*command;
 	struct vf_progress	vf_progress;
 	gchar **package_ids;
@@ -2416,11 +2396,6 @@ backend_install_packages_thread (PkBackend *backend)
 
 	pb_load_packages (backend);
 
-	ts = poldek_ts_new (ctx, 0);
-	rcmd = poclidek_rcmd_new (cctx, ts);
-
-	ts->setop(ts, POLDEK_OP_PARTICLE, 0);
-
 	cmd = g_string_new ("install ");
 
 	/* prepare command */
@@ -2436,16 +2411,14 @@ backend_install_packages_thread (PkBackend *backend)
 
 	pk_backend_set_status (backend, PK_STATUS_ENUM_DEP_RESOLVE);
 
-	if (!poclidek_rcmd_execline (rcmd, command))
-		pb_error_show (backend, PK_ERROR_ENUM_TRANSACTION_ERROR);
-	else
+	if (execute_command (command)) {
 		pb_error_check (backend);
+	} else {
+		pb_error_show (backend, PK_ERROR_ENUM_TRANSACTION_ERROR);
+	}
 
 	g_free (command);
 
-	poldek_ts_free (ts);
-	poclidek_rcmd_free (rcmd);
-
 	poldek_backend_percentage_data_destroy (backend);
 
 	pk_backend_finished (backend);
@@ -2549,8 +2522,6 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
 static gboolean
 backend_remove_packages_thread (PkBackend *backend)
 {
-	struct poclidek_rcmd	*rcmd;
-	struct poldek_ts	*ts;
 	GString *cmd;
 	gchar *command;
 	gchar **package_ids;
@@ -2559,9 +2530,6 @@ backend_remove_packages_thread (PkBackend *backend)
 	package_ids = pk_backend_get_strv (backend, "package_ids");
 	pb_load_packages (backend);
 
-	ts = poldek_ts_new (ctx, 0);
-	rcmd = poclidek_rcmd_new (cctx, ts);
-
 	cmd = g_string_new ("uninstall ");
 
 	/* prepare command */
@@ -2577,16 +2545,12 @@ backend_remove_packages_thread (PkBackend *backend)
 
 	pk_backend_set_status (backend, PK_STATUS_ENUM_DEP_RESOLVE);
 
-	if (!poclidek_rcmd_execline (rcmd, command))
-	{
+	if (execute_command (command) == FALSE) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE, pberror->tslog->str);
 	}
 
 	g_free (command);
 
-	poldek_ts_free (ts);
-	poclidek_rcmd_free (rcmd);
-
 	pk_backend_finished (backend);
 	return TRUE;
 }
commit 0a19b3085cac301fb6e61472c01d8854dd5636e5
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Fri Aug 22 20:19:05 2008 +0200

    poldek: support multiple package_ids in GetFiles

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index 8db89c9..49028bd 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -793,14 +793,14 @@ poldek_pkg_get_cves_from_pld_changelog (struct pkg *pkg, time_t since)
 static void
 do_newest (tn_array *pkgs)
 {
-	guint	i = 1;
+	guint i = 1;
 
 	if (!n_array_is_sorted (pkgs))
 		n_array_sort_ex (pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev_recno);
 
 	while (i < pkgs->items) {
 		if (pkg_cmp_name (pkgs->data[i - 1], pkgs->data[i]) == 0) {
-			struct pkg	*pkg = n_array_nth (pkgs, i);
+			struct pkg *pkg = n_array_nth (pkgs, i);
 
 			if (!pkg_is_installed (pkg)) {
 				n_array_remove_nth (pkgs, i);
@@ -1180,7 +1180,6 @@ search_package_thread (PkBackend *backend)
 	cmd = poclidek_rcmd_new (cctx, NULL);
 
 	mode = pk_backend_get_uint (backend, "mode");
-	search = pk_backend_get_string (backend, "search");
 	filters = pk_backend_get_uint (backend, "filters");
 
 	/* GetPackages */
@@ -1188,26 +1187,36 @@ search_package_thread (PkBackend *backend)
 		search_cmd = g_strdup ("ls -q");
 	/* SearchName */
 	} else if (mode == SEARCH_ENUM_NAME) {
+		search = pk_backend_get_string (backend, "search");
+
 		search_cmd = g_strdup_printf ("ls -q *%s*", search);
 	/* SearchGroup */
 	} else if (mode == SEARCH_ENUM_GROUP) {
 		PkGroupEnum	group;
 		const gchar	*regex;
 
+		search = pk_backend_get_string (backend, "search");
+
 		group = pk_group_enum_from_text (search);
 		regex = pld_group_get_regex_from_enum (group);
 
 		search_cmd = g_strdup_printf ("search -qg --perlre %s", regex);
 	/* SearchDetails */
 	} else if (mode == SEARCH_ENUM_DETAILS) {
+		search = pk_backend_get_string (backend, "search");
+
 		search_cmd = g_strdup_printf ("search -dsq *%s*", search);
 	/* SearchFile */
 	} else if (mode == SEARCH_ENUM_FILE) {
+		search = pk_backend_get_string (backend, "search");
+
 		search_cmd = g_strdup_printf ("search -qlf *%s*", search);
 	/* WhatProvides */
 	} else if (mode == SEARCH_ENUM_PROVIDES) {
 		provides = pk_backend_get_uint (backend, "provides");
 
+		search = pk_backend_get_string (backend, "search");
+
 		if (provides == PK_PROVIDES_ENUM_ANY) {
 			search_cmd = g_strdup_printf ("search -qp %s", search);
 		} else if (provides == PK_PROVIDES_ENUM_MODALIAS) {
@@ -1215,16 +1224,21 @@ search_package_thread (PkBackend *backend)
 		} else if (provides == PK_PROVIDES_ENUM_MIMETYPE) {
 			search_cmd = g_strdup_printf ("search -qp mimetype(%s)", search);
 		}
+	/* Resolve */
 	} else if (mode == SEARCH_ENUM_RESOLVE) {
 		gchar **package_ids;
+		gchar *packages_str;
 
 		package_ids = pk_backend_get_strv (backend, "package_ids");
 
-		search_cmd = g_strdup_printf ("ls -q %s", package_ids[0]);
+		packages_str = g_strjoinv(" ", package_ids);
+
+		search_cmd = g_strdup_printf ("ls -q %s", packages_str);
+
+		g_free (packages_str);
 	}
 
-	if (cmd != NULL && search_cmd)
-	{
+	if (cmd != NULL && search_cmd != NULL) {
 		gchar		*command;
 		tn_array	*pkgs = NULL, *installed = NULL, *available = NULL;
 
@@ -1247,12 +1261,12 @@ search_package_thread (PkBackend *backend)
 		if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED) &&
 		    !pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED) &&
 		    installed && available) {
-			gint	i;
+			guint i;
 
-			pkgs = installed;
+			pkgs = available;
 
-			for (i = 0; i < n_array_size (available); i++) {
-				struct pkg	*pkg = n_array_nth (available, i);
+			for (i = 0; i < n_array_size (installed); i++) {
+				struct pkg *pkg = n_array_nth (installed, i);
 
 				/* check for duplicates */
 				if (!poldek_pkg_in_array (pkg, pkgs, (tn_fn_cmp)pkg_cmp_name_evr)) {
@@ -1262,11 +1276,12 @@ search_package_thread (PkBackend *backend)
 
 			n_array_sort_ex(pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev_recno);
 
-			n_array_free (available);
+			n_array_free (installed);
 		} else if (pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED) || available) {
 			pkgs = available;
 		} else if (pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED) || installed)
 			pkgs = installed;
+
 		if (pkgs) {
 			gint	i;
 
@@ -1274,7 +1289,7 @@ search_package_thread (PkBackend *backend)
 				do_newest (pkgs);
 
 			for (i = 0; i < n_array_size (pkgs); i++) {
-				struct pkg	*pkg = n_array_nth (pkgs, i);
+				struct pkg *pkg = n_array_nth (pkgs, i);
 
 				if (sigint_reached ())
 					break;
@@ -2040,56 +2055,59 @@ static gboolean
 backend_get_files_thread (PkBackend *backend)
 {
 	gchar **package_ids;
-	struct pkg	*pkg;
+	gint n;
 
 	package_ids = pk_backend_get_strv (backend, "package_ids");
 
 	pb_load_packages (backend);
 
-	pkg = poldek_get_pkg_from_package_id (package_ids[0]);
+	for (n = 0; n < g_strv_length (package_ids); n++) {
+		struct pkg *pkg;
 
-	if (pkg) {
-		struct pkgflist		*flist = pkg_get_flist (pkg);
-		GString			*filelist;
-		gchar			*result, *sep;
-		gint			i, j;
+		pkg = poldek_get_pkg_from_package_id (package_ids[n]);
 
-		sep = "";
+		if (pkg != NULL) {
+			struct pkgflist *flist = pkg_get_flist (pkg);
+			GString *filelist;
+			gchar *result, *sep;
+			gint i, j;
 
-		if (!flist) {
-			pkg_free (pkg);
-			pk_backend_finished (backend);
-			return TRUE;
-		}
+			sep = "";
 
-		filelist = g_string_new ("");
+			if (flist == NULL) {
+				pkg_free (pkg);
+				continue;
+			}
 
-		for (i = 0; i < n_tuple_size (flist->fl); i++) {
-			struct pkgfl_ent	*flent = n_tuple_nth (flist->fl, i);
-			gchar			*dirname;
+			filelist = g_string_new ("");
 
-			dirname = g_strdup_printf ("%s%s", *flent->dirname == '/' ? "" : "/", flent->dirname);
+			for (i = 0; i < n_tuple_size (flist->fl); i++) {
+				struct pkgfl_ent *flent = n_tuple_nth (flist->fl, i);
+				gchar *dirname;
 
-			for (j = 0; j < flent->items; j++) {
-				struct flfile	*f = flent->files[j];
+				dirname = g_strdup_printf ("%s%s", *flent->dirname == '/' ? "" : "/", flent->dirname);
 
-				if (strcmp (dirname, "/") == 0)
-					g_string_append_printf (filelist, "%s/%s", sep, f->basename);
-				else
-					g_string_append_printf (filelist, "%s%s/%s", sep, dirname, f->basename);
+				for (j = 0; j < flent->items; j++) {
+					struct flfile *f = flent->files[j];
+
+					if (strcmp (dirname, "/") == 0)
+						g_string_append_printf (filelist, "%s/%s", sep, f->basename);
+					else
+						g_string_append_printf (filelist, "%s%s/%s", sep, dirname, f->basename);
 
-				sep = ";";
+					sep = ";";
+				}
+				g_free (dirname);
 			}
-			g_free (dirname);
-		}
 
-		result = g_string_free (filelist, FALSE);
+			result = g_string_free (filelist, FALSE);
 
-		pk_backend_files (backend, package_ids[0], result);
+			pk_backend_files (backend, package_ids[n], result);
 
-		g_free (result);
+			g_free (result);
 
-		pkg_free (pkg);
+			pkg_free (pkg);
+		}
 	}
 
 	pk_backend_finished (backend);
@@ -2293,7 +2311,7 @@ backend_get_update_detail_thread (PkBackend *backend)
 					  "",
 					  "",
 					  PK_RESTART_ENUM_NONE,
-					  "");
+					  "", NULL, PK_UPDATE_STATE_ENUM_UNKNOWN, NULL, NULL);
 	}
 
 	g_free (command);
@@ -2693,7 +2711,7 @@ backend_update_system (PkBackend *backend)
 static void
 backend_get_repo_list (PkBackend *backend, PkBitfield filters)
 {
-	tn_array	*sources = NULL;
+	tn_array *sources = NULL;
 
 	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
 	poldek_backend_set_allow_cancel (backend, FALSE, TRUE);
@@ -2702,11 +2720,11 @@ backend_get_repo_list (PkBackend *backend, PkBitfield filters)
 	sources = poldek_get_sources (ctx);
 
 	if (sources) {
-		gint	i;
+		gint i;
 
 		for (i = 0; i < n_array_size (sources); i++) {
-			struct source	*src = n_array_nth (sources, i);
-			gboolean	enabled = TRUE;
+			struct source *src = n_array_nth (sources, i);
+			gboolean enabled = TRUE;
 
 			if (src->flags & PKGSOURCE_NOAUTO)
 				enabled = FALSE;
commit fb45eb303b2689f097ece6ee9cabd0ed4d136758
Author: Shishir Goel <crazyontheedge at gmail.com>
Date:   Fri Aug 22 23:06:39 2008 +0530

    Change Service Packs' extension from .pack to .servicepack

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index c025ed7..4e3926f 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -874,13 +874,13 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         for inst_file in inst_files:
             if inst_file.endswith('.rpm'):
                 continue
-            elif inst_file.endswith('.pack'):
+            elif inst_file.endswith('.servicepack'):
                 inst_packs.append(inst_file)
             else:
                 self.error(ERROR_INVALID_PACKAGE_FILE,'Only rpm files and packs are supported')
                 return
 
-        # decompress and add the contents of any .pack files
+        # decompress and add the contents of any .servicepack files
         for inst_pack in inst_packs:
             inst_files.remove(inst_pack)
             pack = tarfile.TarFile(name = inst_pack,mode = "r")
diff --git a/client/pk-generate-pack-main.c b/client/pk-generate-pack-main.c
index 0cbd95e..45abe77 100644
--- a/client/pk-generate-pack-main.c
+++ b/client/pk-generate-pack-main.c
@@ -113,8 +113,8 @@ main (int argc, char *argv[])
 	}
 
 	/* check the suffix */
-	if (!g_str_has_suffix (pack_filename,".pack")) {
-		g_print(_("Invalid name for the service pack, Specify a name with .pack extension\n"));
+	if (!g_str_has_suffix (pack_filename,".servicepack")) {
+		g_print(_("Invalid name for the service pack, Specify a name with .servicepack extension\n"));
 		goto out;
 	}
 
diff --git a/client/pk-generate-pack.c b/client/pk-generate-pack.c
index ccc7d08..b9a3544 100644
--- a/client/pk-generate-pack.c
+++ b/client/pk-generate-pack.c
@@ -697,11 +697,11 @@ libst_generate_pack (LibSelfTest *test)
 		libst_failed (test, NULL);
 
 	/************************************************************/
-	libst_title (test, "generate pack /tmp/gitk.pack gitk");
+	libst_title (test, "generate pack /tmp/gitk.servicepack gitk");
 	file_array = g_ptr_array_new ();
 	src = g_build_filename ("/tmp", "gitk-1.5.5.1-1.fc9.i386.rpm", NULL);
 	g_ptr_array_add (file_array, src);
-	ret = pk_generate_pack_create ("/tmp/gitk.pack",file_array, &error);
+	ret = pk_generate_pack_create ("/tmp/gitk.servicepack",file_array, &error);
 	if (!ret) {
 		if (error != NULL) {
 			libst_failed (test, "failed to create pack %s" , error->message);
@@ -714,7 +714,7 @@ libst_generate_pack (LibSelfTest *test)
 	}
 	if (file_array != NULL)
 		g_ptr_array_free (file_array, TRUE);
-	g_remove ("/tmp/gitk.pack");
+	g_remove ("/tmp/gitk.servicepack");
 
 	/************************************************************/
 	libst_end (test);
diff --git a/man/pkgenpack.xml b/man/pkgenpack.xml
index b516fd5..4ec8962 100644
--- a/man/pkgenpack.xml
+++ b/man/pkgenpack.xml
@@ -95,7 +95,7 @@ manpage.1: manpage.xml
   <refsect1>
     <title>Naming a Service Pack</title>
     <para>
-     The only valid extension for a service pack is ".pack". The user needs to specify
+     The only valid extension for a service pack is ".servicepack". The user needs to specify
      the full path of the pack, when using pkgenpack to generate a service pack.
     </para>
   </refsect1>
@@ -108,23 +108,23 @@ manpage.1: manpage.xml
       have installed Fedora 9 two days ago. James simply runs:
     </para>
     <para>
-      [james at jamesbook:~]$pkgenpack /media/USB/TimPacks/valgrind.pack valgrind
+      [james at jamesbook:~]$pkgenpack /media/USB/TimPacks/valgrind.servicepack valgrind
     </para>
     <para>
-     This generates a file valgrind.pack on the USB key Tim gave to James. Tim can now go home,
-     insert the USB key and double click on the valgrind.pack to be prompted to install these packages.
+     This generates a file valgrind.servicepack on the USB key Tim gave to James. Tim can now go home,
+     insert the USB key and double click on the valgrind.servicepack to be prompted to install these packages.
     </para>
     <para>
-      2. Bill wants to create a service pack named kdegames.pack for his new system which does not have
+      2. Bill wants to create a service pack named kdegames.servicepack for his new system which does not have
       an internet connection. He generates a list of packages on his system using pk-generate-package-list
       and copies that list to his USB key. He then gives that USB to Rishi who has a good internet connectivity.
       Rishi runs the following command on his system:
     </para>
     <para>
-      [rishi at devils-temple:~]$pkgenpack --with-package-list /media/USB/package-list.txt /home/rishi/Desktop/kdegames.pack kdegames
+      [rishi at devils-temple:~]$pkgenpack --with-package-list /media/USB/package-list.txt /home/rishi/Desktop/kdegames.servicepack kdegames
     </para>
     <para>
-      This generates a service pack, kdegames.pack, on Rishi's Desktop, which can be distributed
+      This generates a service pack, kdegames.servicepack, on Rishi's Desktop, which can be distributed
       to Bill and users with similar requirements.
     </para>
   </refsect1>
@@ -134,7 +134,7 @@ manpage.1: manpage.xml
       Service Packs can be installed using pkcon by specifying the valid path. For example:
     </para>
     <para>
-      [hacker at tim-lounge:~]$pkcon install /home/USB/TimPacks/valgrind.pack
+      [hacker at tim-lounge:~]$pkcon install /home/USB/TimPacks/valgrind.servicepack
     </para>
   </refsect1>
   <refsect1>
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 04b31c7..25d32f6 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -2342,7 +2342,7 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
 			return;
 		}
 		/* valid */
-		if (g_str_has_suffix (full_paths[i], ".pack")) {
+		if (g_str_has_suffix (full_paths[i], ".servicepack")) {
 			ret = pk_transaction_check_pack_distro_id (full_paths[i], &failure);
 			if (!ret) {
 				error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_PACK_INVALID, "%s", failure);


More information about the PackageKit-commit mailing list