[PackageKit-commit] packagekit: Branch 'master' - 27 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Sat May 29 07:04:20 PDT 2010
backends/apt/aptBackend.py | 159 -
backends/entropy/entropyBackend.py | 26
backends/yum/Makefile.am | 85
backends/yum/libzif/egg-debug.c | 1
backends/yum/libzif/egg-debug.h | 1
backends/yum/libzif/zif-changeset.c | 479 ----
backends/yum/libzif/zif-changeset.h | 84
backends/yum/libzif/zif-completion.c | 738 ------
backends/yum/libzif/zif-completion.h | 100
backends/yum/libzif/zif-config.c | 850 -------
backends/yum/libzif/zif-config.h | 92
backends/yum/libzif/zif-depend.c | 175 -
backends/yum/libzif/zif-depend.h | 62
backends/yum/libzif/zif-download.c | 447 ----
backends/yum/libzif/zif-download.h | 78
backends/yum/libzif/zif-groups.c | 473 ----
backends/yum/libzif/zif-groups.h | 80
backends/yum/libzif/zif-lock.c | 458 ----
backends/yum/libzif/zif-lock.h | 78
backends/yum/libzif/zif-md-comps.c | 959 --------
backends/yum/libzif/zif-md-comps.h | 78
backends/yum/libzif/zif-md-filelists-sql.c | 542 ----
backends/yum/libzif/zif-md-filelists-sql.h | 63
backends/yum/libzif/zif-md-filelists-xml.c | 675 ------
backends/yum/libzif/zif-md-filelists-xml.h | 63
backends/yum/libzif/zif-md-metalink.c | 503 ----
backends/yum/libzif/zif-md-metalink.h | 68
backends/yum/libzif/zif-md-mirrorlist.c | 346 ---
backends/yum/libzif/zif-md-mirrorlist.h | 67
backends/yum/libzif/zif-md-other-sql.c | 524 ----
backends/yum/libzif/zif-md-other-sql.h | 63
backends/yum/libzif/zif-md-primary-sql.c | 731 ------
backends/yum/libzif/zif-md-primary-sql.h | 64
backends/yum/libzif/zif-md-primary-xml.c | 953 --------
backends/yum/libzif/zif-md-primary-xml.h | 64
backends/yum/libzif/zif-md-updateinfo.c | 783 -------
backends/yum/libzif/zif-md-updateinfo.h | 73
backends/yum/libzif/zif-md.c | 1359 ------------
backends/yum/libzif/zif-md.h | 258 --
backends/yum/libzif/zif-monitor.c | 256 --
backends/yum/libzif/zif-monitor.h | 71
backends/yum/libzif/zif-package-local.c | 694 ------
backends/yum/libzif/zif-package-local.h | 71
backends/yum/libzif/zif-package-remote.c | 323 --
backends/yum/libzif/zif-package-remote.h | 75
backends/yum/libzif/zif-package.c | 1492 -------------
backends/yum/libzif/zif-package.h | 197 -
backends/yum/libzif/zif-repos.c | 637 -----
backends/yum/libzif/zif-repos.h | 88
backends/yum/libzif/zif-store-array.c | 855 -------
backends/yum/libzif/zif-store-array.h | 152 -
backends/yum/libzif/zif-store-local.c | 1325 -----------
backends/yum/libzif/zif-store-local.h | 68
backends/yum/libzif/zif-store-remote.c | 3228 -----------------------------
backends/yum/libzif/zif-store-remote.h | 107
backends/yum/libzif/zif-store.c | 602 -----
backends/yum/libzif/zif-store.h | 217 -
backends/yum/libzif/zif-string.c | 197 -
backends/yum/libzif/zif-string.h | 44
backends/yum/libzif/zif-update-info.c | 345 ---
backends/yum/libzif/zif-update-info.h | 86
backends/yum/libzif/zif-update.c | 626 -----
backends/yum/libzif/zif-update.h | 103
backends/yum/libzif/zif-utils.c | 792 -------
backends/yum/libzif/zif-utils.h | 74
backends/yum/libzif/zif.h | 46
backends/yum/pk-backend-yum.c | 822 +++++--
backends/yum/yumBackend.py | 176 -
backends/yum/yumMediaManager.py | 104
backends/yum/yumMediaManagerDeviceKit.py | 152 -
backends/yum/yumMediaManagerGIO.py | 153 -
backends/yum/yumMediaManagerHAL.py | 167 -
backends/yum/yumMediaManagerOS.py | 136 -
backends/zypp/TODO | 9
backends/zypp/pk-backend-zypp.cpp | 112 -
backends/zypp/zypp-utils.cpp | 55
backends/zypp/zypp-utils.h | 20
client/pk-console.c | 125 -
client/pk-monitor.c | 40
configure.ac | 49
lib/packagekit-glib2/pk-task-sync.c | 848 +++++++
lib/packagekit-glib2/pk-task-sync.h | 145 +
lib/packagekit-glib2/pk-task.c | 1083 +++++++++
lib/packagekit-glib2/pk-task.h | 145 +
lib/packagekit-qt/src/client.h | 1
lib/python/packagekit/backend.py | 2
po/da.po | 335 +--
po/fi.po | 489 ++--
src/pk-engine.c | 41
89 files changed, 3687 insertions(+), 26995 deletions(-)
New commits:
commit 2e3605d941458f77951dba56e4a493b2a456d9d9
Author: Richard Hughes <richard at hughsie.com>
Date: Thu May 27 16:28:32 2010 +0100
yum: catch and ignore the socket exception on oddball systems. Fixes rh#596779
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index f90ce59..94d7dab 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -272,8 +272,11 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
# use idle bandwidth by setting congestion control algorithm to TCP Low Priority
if self.background:
socket.TCP_CONGESTION = 13
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_CONGESTION, "lp")
+ try:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_CONGESTION, "lp")
+ except socket.error, e:
+ pass;
# we only check these types
self.transaction_sig_check_map = [TS_UPDATE, TS_INSTALL, TS_TRUEINSTALL, TS_OBSOLETING]
commit 79ea70836449f33c57b6c28945b38c3bcddc9e63
Author: vpv <vpv at fedoraproject.org>
Date: Fri May 21 20:02:19 2010 +0000
l10n: Updates to Finnish (fi) translation
Transmitted-via: Transifex (translate.fedoraproject.org)
diff --git a/po/fi.po b/po/fi.po
index d806b20..02bb6ca 100644
--- a/po/fi.po
+++ b/po/fi.po
@@ -1,15 +1,15 @@
# Finnish translation of packagekit.
# Copyright (C) 2008 packagekit's COPYRIGHT HOLDER
# This file is distributed under the same license as the packagekit package.
-# Ville-Pekka Vainio <vpivaini at cs.helsinki.fi>, 2008-2009.
+# Ville-Pekka Vainio <vpivaini at cs.helsinki.fi>, 2008-2010.
msgid ""
msgstr ""
"Project-Id-Version: packagekit\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-03-24 14:18+0000\n"
-"PO-Revision-Date: 2010-03-24 17:32+0200\n"
+"POT-Creation-Date: 2010-05-18 18:09+0000\n"
+"PO-Revision-Date: 2010-05-18 21:19+0300\n"
"Last-Translator: Ville-Pekka Vainio <vpivaini at cs.helsinki.fi>\n"
-"Language-Team: Finnish <laatu at lokalisointi.org>\n"
+"Language-Team: Finnish <gnome-fi-laatu at lists.sourceforge.net>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -17,115 +17,115 @@ msgstr ""
#. TRANSLATORS: this is an atomic transaction
#. TRANSLATORS: the role is the point of the transaction, e.g. update-system
-#: ../client/pk-console.c:175 ../client/pk-console.c:597
+#: ../client/pk-console.c:176 ../client/pk-console.c:598
msgid "Transaction"
msgstr "Transaktio"
#. TRANSLATORS: this is the time the transaction was started in system timezone
-#: ../client/pk-console.c:177
+#: ../client/pk-console.c:178
msgid "System time"
msgstr "Järjestelmän aika"
#. TRANSLATORS: this is if the transaction succeeded or not
-#: ../client/pk-console.c:179
+#: ../client/pk-console.c:180
msgid "Succeeded"
msgstr "Onnistui"
-#: ../client/pk-console.c:179
+#: ../client/pk-console.c:180
msgid "True"
msgstr "Tosi"
-#: ../client/pk-console.c:179
+#: ../client/pk-console.c:180
msgid "False"
msgstr "Epätosi"
#. TRANSLATORS: this is the transactions role, e.g. "update-system"
#. TRANSLATORS: the trasaction role, e.g. update-system
-#: ../client/pk-console.c:181 ../src/pk-polkit-action-lookup.c:332
+#: ../client/pk-console.c:182 ../src/pk-polkit-action-lookup.c:332
msgid "Role"
msgstr "Rooli"
#. TRANSLATORS: this is The duration of the transaction
-#: ../client/pk-console.c:186
+#: ../client/pk-console.c:187
msgid "Duration"
msgstr "Kesto"
-#: ../client/pk-console.c:186
+#: ../client/pk-console.c:187
msgid "(seconds)"
msgstr "(sekuntia)"
#. TRANSLATORS: this is The command line used to do the action
#. TRANSLATORS: the command line of the thing that wants the authentication
-#: ../client/pk-console.c:190 ../src/pk-polkit-action-lookup.c:346
+#: ../client/pk-console.c:191 ../src/pk-polkit-action-lookup.c:346
msgid "Command line"
msgstr "Komentorivi"
#. TRANSLATORS: this is the user ID of the user that started the action
-#: ../client/pk-console.c:192
+#: ../client/pk-console.c:193
msgid "User ID"
msgstr "Käyttäjän tunniste"
#. TRANSLATORS: this is the username, e.g. hughsie
-#: ../client/pk-console.c:199
+#: ../client/pk-console.c:200
msgid "Username"
msgstr "Käyttäjätunnus"
#. TRANSLATORS: this is the users real name, e.g. "Richard Hughes"
-#: ../client/pk-console.c:203
+#: ../client/pk-console.c:204
msgid "Real name"
msgstr "Oikea nimi"
-#: ../client/pk-console.c:211
+#: ../client/pk-console.c:212
msgid "Affected packages:"
msgstr "Käsiteltävät paketit:"
-#: ../client/pk-console.c:213
+#: ../client/pk-console.c:214
msgid "Affected packages: None"
msgstr "Käsiteltävät paketit: Ei yhtään"
#. TRANSLATORS: this is the distro, e.g. Fedora 10
-#: ../client/pk-console.c:248
+#: ../client/pk-console.c:249
msgid "Distribution"
msgstr "Jakeluversio"
#. TRANSLATORS: this is type of update, stable or testing
-#: ../client/pk-console.c:250
+#: ../client/pk-console.c:251
msgid "Type"
msgstr "Tyyppi"
#. TRANSLATORS: this is any summary text describing the upgrade
#. TRANSLATORS: this is the summary of the group
-#: ../client/pk-console.c:252 ../client/pk-console.c:291
+#: ../client/pk-console.c:253 ../client/pk-console.c:292
msgid "Summary"
msgstr "Yhteenveto"
#. TRANSLATORS: this is the group category name
-#: ../client/pk-console.c:280
+#: ../client/pk-console.c:281
msgid "Category"
msgstr "Luokka"
#. TRANSLATORS: this is group identifier
-#: ../client/pk-console.c:282
+#: ../client/pk-console.c:283
msgid "ID"
msgstr "Tunniste"
#. TRANSLATORS: this is the parent group
-#: ../client/pk-console.c:285
+#: ../client/pk-console.c:286
msgid "Parent"
msgstr "Pääluokka"
#. TRANSLATORS: this is the name of the parent group
-#: ../client/pk-console.c:288
+#: ../client/pk-console.c:289
msgid "Name"
msgstr "Nimi"
#. TRANSLATORS: this is preferred icon for the group
-#: ../client/pk-console.c:294
+#: ../client/pk-console.c:295
msgid "Icon"
msgstr "Kuvake"
#. TRANSLATORS: this is a header for the package that can be updated
-#: ../client/pk-console.c:340
+#: ../client/pk-console.c:341
msgid "Details about the update:"
msgstr "Tietoja päivityksestä:"
@@ -134,7 +134,7 @@ msgstr "Tietoja päivityksestä:"
#. TRANSLATORS: the package that is not signed by a known key
#. TRANSLATORS: the package name that was trying to be installed
#. TRANSLATORS: title, the names of the packages that the method is processing
-#: ../client/pk-console.c:346 ../client/pk-console.c:616
+#: ../client/pk-console.c:347 ../client/pk-console.c:617
#: ../lib/packagekit-glib2/pk-task-text.c:126
#: ../lib/packagekit-glib2/pk-task-text.c:208
#: ../src/pk-polkit-action-lookup.c:357
@@ -144,165 +144,165 @@ msgstr[0] "Paketti"
msgstr[1] "Paketit"
#. TRANSLATORS: details about the update, any packages that this update updates
-#: ../client/pk-console.c:349
+#: ../client/pk-console.c:350
msgid "Updates"
msgstr "Päivitykset"
#. TRANSLATORS: details about the update, any packages that this update obsoletes
-#: ../client/pk-console.c:353
+#: ../client/pk-console.c:354
msgid "Obsoletes"
msgstr "Vanhentaa"
#. TRANSLATORS: details about the update, the vendor URLs
#. TRANSLATORS: the vendor (e.g. vmware) that is providing the EULA
-#: ../client/pk-console.c:357 ../lib/packagekit-glib2/pk-task-text.c:211
+#: ../client/pk-console.c:358 ../lib/packagekit-glib2/pk-task-text.c:211
msgid "Vendor"
msgstr "Toimittaja"
#. TRANSLATORS: details about the update, the bugzilla URLs
-#: ../client/pk-console.c:361
+#: ../client/pk-console.c:362
msgid "Bugzilla"
msgstr "Bugzilla"
#. TRANSLATORS: details about the update, the CVE URLs
-#: ../client/pk-console.c:365
+#: ../client/pk-console.c:366
msgid "CVE"
msgstr "CVE"
#. TRANSLATORS: details about the update, if the package requires a restart
-#: ../client/pk-console.c:369
+#: ../client/pk-console.c:370
msgid "Restart"
msgstr "Uudelleenkäynnistys"
#. TRANSLATORS: details about the update, any description of the update
-#: ../client/pk-console.c:373
+#: ../client/pk-console.c:374
msgid "Update text"
msgstr "Päivityksen kuvaus"
#. TRANSLATORS: details about the update, the changelog for the package
-#: ../client/pk-console.c:377
+#: ../client/pk-console.c:378
msgid "Changes"
msgstr "Muutokset"
#. TRANSLATORS: details about the update, the ongoing state of the update
-#: ../client/pk-console.c:381
+#: ../client/pk-console.c:382
msgid "State"
msgstr "Tila"
#. TRANSLATORS: details about the update, date the update was issued
-#: ../client/pk-console.c:385
+#: ../client/pk-console.c:386
msgid "Issued"
msgstr "Julkaistu"
#. TRANSLATORS: details about the update, date the update was updated
#. TRANSLATORS: The action of the package, in past tense
-#: ../client/pk-console.c:389 ../lib/packagekit-glib2/pk-console-shared.c:511
+#: ../client/pk-console.c:390 ../lib/packagekit-glib2/pk-console-shared.c:517
msgid "Updated"
msgstr "Päivitetty"
#. TRANSLATORS: if the repo is enabled
-#: ../client/pk-console.c:425
+#: ../client/pk-console.c:426
msgid "Enabled"
msgstr "Käytössä"
#. TRANSLATORS: if the repo is disabled
-#: ../client/pk-console.c:428
+#: ../client/pk-console.c:429
msgid "Disabled"
msgstr "Poissa käytöstä"
#. TRANSLATORS: a package requires the system to be restarted
-#: ../client/pk-console.c:460
+#: ../client/pk-console.c:461
msgid "System restart required by:"
msgstr "Järjestelmän uudelleenkäynnistyksen tarvitsee:"
#. TRANSLATORS: a package requires the session to be restarted
-#: ../client/pk-console.c:463
+#: ../client/pk-console.c:464
msgid "Session restart required:"
msgstr "Istunnon uudelleenkäynnistyksen tarvitsee"
#. TRANSLATORS: a package requires the system to be restarted due to a security update
-#: ../client/pk-console.c:466
+#: ../client/pk-console.c:467
msgid "System restart (security) required by:"
msgstr "Järjestelmän uudelleenkäynnistyksen (turvallisuussyistä) tarvitsee:"
#. TRANSLATORS: a package requires the session to be restarted due to a security update
-#: ../client/pk-console.c:469
+#: ../client/pk-console.c:470
msgid "Session restart (security) required:"
msgstr "Istunnon uudelleenkäynnistyksen (turvallisuussyistä) tarvitsee:"
#. TRANSLATORS: a package requires the application to be restarted
-#: ../client/pk-console.c:472
+#: ../client/pk-console.c:473
msgid "Application restart required by:"
msgstr "Sovelluksen uudelleenkäynnistyksen tarvitsee"
#. TRANSLATORS: This a list of details about the package
-#: ../client/pk-console.c:507
+#: ../client/pk-console.c:508
msgid "Package description"
msgstr "Paketin kuvaus"
#. TRANSLATORS: This a message (like a little note that may be of interest) from the transaction
-#: ../client/pk-console.c:538
+#: ../client/pk-console.c:539
msgid "Message:"
msgstr "Viesti:"
#. TRANSLATORS: This where the package has no files
-#: ../client/pk-console.c:559
+#: ../client/pk-console.c:560
msgid "No files"
msgstr "Ei tiedostoja"
#. TRANSLATORS: This a list files contained in the package
-#: ../client/pk-console.c:564
+#: ../client/pk-console.c:565
msgid "Package files"
msgstr "Paketin tiedostot"
#. TRANSLATORS: the percentage complete of the transaction
-#: ../client/pk-console.c:632
+#: ../client/pk-console.c:633
msgid "Percentage"
msgstr "Prosentti"
#. TRANSLATORS: the status of the transaction (e.g. downloading)
-#: ../client/pk-console.c:650
+#: ../client/pk-console.c:651
msgid "Status"
msgstr "Tila"
#. TRANSLATORS: the results from the transaction
-#: ../client/pk-console.c:679
+#: ../client/pk-console.c:680
msgid "Results:"
msgstr "Tulokset:"
#. TRANSLATORS: we failed to get any results, which is pretty fatal in my book
-#: ../client/pk-console.c:686
+#: ../client/pk-console.c:687
msgid "Fatal error"
msgstr "Vakava virhe"
#. TRANSLATORS: the transaction failed in a way we could not expect
-#: ../client/pk-console.c:695
+#: ../client/pk-console.c:696
#: ../contrib/command-not-found/pk-command-not-found.c:433
#: ../contrib/command-not-found/pk-command-not-found.c:606
msgid "The transaction failed"
msgstr "Transaktio epäonnistui"
#. TRANSLATORS: print a message when there are no updates
-#: ../client/pk-console.c:726
+#: ../client/pk-console.c:727
msgid "There are no updates available at this time."
msgstr "Päivityksiä ei ole saatavilla tällä hetkellä."
-#: ../client/pk-console.c:749
+#: ../client/pk-console.c:750
msgid "There are no upgrades available at this time."
msgstr "Päivityksiä ei ole saatavilla tällä hetkellä."
#. TRANSLATORS: a package needs to restart their system
-#: ../client/pk-console.c:816
+#: ../client/pk-console.c:817
msgid "Please restart the computer to complete the update."
msgstr "Käynnistä tietokone uudelleen päivityksen viimeistelemiseksi."
#. TRANSLATORS: a package needs to restart the session
-#: ../client/pk-console.c:819
+#: ../client/pk-console.c:820
msgid "Please logout and login to complete the update."
msgstr "Kirjaudu ulos ja takaisin sisään päivityksen viimeistelemiseksi."
#. TRANSLATORS: a package needs to restart their system (due to security)
-#: ../client/pk-console.c:822
+#: ../client/pk-console.c:823
msgid ""
"Please restart the computer to complete the update as important security "
"updates have been installed."
@@ -311,7 +311,7 @@ msgstr ""
"turvallisuuspäivityksiä on asennettu."
#. TRANSLATORS: a package needs to restart the session (due to security)
-#: ../client/pk-console.c:825
+#: ../client/pk-console.c:826
msgid ""
"Please logout and login to complete the update as important security updates "
"have been installed."
@@ -320,29 +320,29 @@ msgstr ""
"turvallisuuspäivityksiä on asennettu."
#. TRANSLATORS: The user used 'pkcon install dave.rpm' rather than 'pkcon install-local dave.rpm'
-#: ../client/pk-console.c:851
+#: ../client/pk-console.c:852
#, c-format
msgid ""
-"Extected package name, actually got file. Try using 'pkcon install-local %s' "
+"Expected package name, actually got file. Try using 'pkcon install-local %s' "
"instead."
msgstr ""
"Odotettiin paketin nimeä, mutta saatiin tiedosto. Kokeile komennon âpkcon "
"install-local %sâ käyttämistä."
#. TRANSLATORS: There was an error getting the list of files for the package. The detailed error follows
-#: ../client/pk-console.c:859
+#: ../client/pk-console.c:860
#, c-format
msgid "This tool could not find any available package: %s"
msgstr "Tämä työkalu ei löytänyt saatavilla olevaa pakettia: %s"
#. TRANSLATORS: There was an error getting the list of files for the package. The detailed error follows
-#: ../client/pk-console.c:887
+#: ../client/pk-console.c:888
#, c-format
msgid "This tool could not find the installed package: %s"
msgstr "Tämä työkalu ei löytänyt asennettua pakettia: %s"
#. TRANSLATORS: There was an error getting the list of files for the package. The detailed error follows
-#: ../client/pk-console.c:915 ../client/pk-console.c:943
+#: ../client/pk-console.c:916 ../client/pk-console.c:944
#, c-format
msgid "This tool could not find the package: %s"
msgstr "Tämä työkalu ei löytänyt pakettia: %s"
@@ -351,63 +351,68 @@ msgstr "Tämä työkalu ei löytänyt pakettia: %s"
#. TRANSLATORS: There was an error getting the dependencies for the package. The detailed error follows
#. TRANSLATORS: There was an error getting the details about the package. The detailed error follows
#. TRANSLATORS: The package name was not found in any software sources. The detailed error follows
-#: ../client/pk-console.c:971 ../client/pk-console.c:999
-#: ../client/pk-console.c:1027 ../client/pk-console.c:1055
-#: ../client/pk-console.c:1083
+#: ../client/pk-console.c:972 ../client/pk-console.c:1000
+#: ../client/pk-console.c:1028 ../client/pk-console.c:1056
+#: ../client/pk-console.c:1084
#, c-format
msgid "This tool could not find all the packages: %s"
msgstr "Tämä työkalu ei löytänyt paketteja: %s"
#. TRANSLATORS: This is when the daemon crashed, and we are up shit creek without a paddle
-#: ../client/pk-console.c:1112
+#: ../client/pk-console.c:1113
msgid "The daemon crashed mid-transaction!"
msgstr "Taustaprosessi kaatui kesken toimenpiteen"
#. TRANSLATORS: This is the header to the --help menu
-#: ../client/pk-console.c:1146
+#: ../client/pk-console.c:1147
msgid "PackageKit Console Interface"
msgstr "PackageKitin konsolikäyttöliittymä"
#. these are commands we can use with pkcon
-#: ../client/pk-console.c:1148
+#: ../client/pk-console.c:1149
msgid "Subcommands:"
msgstr "Alikomennot:"
#. TRANSLATORS: we keep a database updated with the time that an action was last executed
-#: ../client/pk-console.c:1227
+#: ../client/pk-console.c:1228
msgid "Failed to get the time since this action was last completed"
msgstr "Tämän toiminnon edellisen suorittamisen aikaa ei saatu"
#. TRANSLATORS: command line argument, just show the version string
-#: ../client/pk-console.c:1263 ../client/pk-monitor.c:306
+#: ../client/pk-console.c:1268 ../client/pk-monitor.c:356
msgid "Show the program version and exit"
msgstr "Näytä ohjelman versio ja lopeta"
#. TRANSLATORS: command line argument, use a filter to narrow down results
-#: ../client/pk-console.c:1266
+#: ../client/pk-console.c:1271
msgid "Set the filter, e.g. installed"
msgstr "Aseta suodin, esim. asennettu"
+#. TRANSLATORS: command line argument, use a non-standard install prefix
+#: ../client/pk-console.c:1274
+msgid "Set the install root, e.g. '/' or '/mnt/ltsp'"
+msgstr "Aseta asennuksen juurihakemisto, esimerkiksi â/â tai â/mnt/ltspâ"
+
#. TRANSLATORS: command line argument, work asynchronously
-#: ../client/pk-console.c:1269
+#: ../client/pk-console.c:1277
msgid "Exit without waiting for actions to complete"
msgstr "Lopeta odottamatta toimintojen valmistumista"
#. command line argument, do we ask questions
-#: ../client/pk-console.c:1272
+#: ../client/pk-console.c:1280
#: ../contrib/debuginfo-install/pk-debuginfo-install.c:527
msgid "Install the packages without asking for confirmation"
msgstr "Asenna paketit kysymättä vahvistusta"
#. TRANSLATORS: command line argument, this command is not a priority
-#: ../client/pk-console.c:1275
+#: ../client/pk-console.c:1283
msgid "Run the command using idle network bandwidth and also using less power"
msgstr ""
"Suorita komento käyttäen ylimääräistä verkon kaistanleveyttä ja tavallista "
"vähemmän virtaa"
#. TRANSLATORS: command line argument, just output without fancy formatting
-#: ../client/pk-console.c:1278
+#: ../client/pk-console.c:1286
msgid ""
"Print to screen a machine readable output, rather than using animated widgets"
msgstr ""
@@ -415,117 +420,127 @@ msgstr ""
"käyttämisen sijaan"
#. TRANSLATORS: we failed to contact the daemon
-#: ../client/pk-console.c:1300
+#: ../client/pk-console.c:1308
msgid "Failed to contact PackageKit"
msgstr "PackageKitiin ei saatu yhteyttä"
#. TRANSLATORS: The user specified an incorrect filter
-#: ../client/pk-console.c:1358
+#: ../client/pk-console.c:1369
+msgid "The proxy could not be set"
+msgstr "Välityspalvelinta ei voitu asettaa"
+
+#. TRANSLATORS: The user specified an incorrect filter
+#: ../client/pk-console.c:1381
+msgid "The install root could not be set"
+msgstr "Asennuksen juurihakemistoa ei voitu asettaa"
+
+#. TRANSLATORS: The user specified an incorrect filter
+#: ../client/pk-console.c:1393
msgid "The filter specified was invalid"
msgstr "Annettu suodin oli virheellinen"
#. TRANSLATORS: a search type can be name, details, file, etc
-#: ../client/pk-console.c:1377
+#: ../client/pk-console.c:1412
msgid "A search type is required, e.g. name"
msgstr "Haun tyyppi tarvitaan, esim. nimi"
#. TRANSLATORS: the user needs to provide a search term
-#: ../client/pk-console.c:1384 ../client/pk-console.c:1396
-#: ../client/pk-console.c:1408 ../client/pk-console.c:1420
+#: ../client/pk-console.c:1419 ../client/pk-console.c:1431
+#: ../client/pk-console.c:1443 ../client/pk-console.c:1455
msgid "A search term is required"
msgstr "Hakutermi on annettava"
#. TRANSLATORS: the search type was provided, but invalid
-#: ../client/pk-console.c:1430
+#: ../client/pk-console.c:1465
msgid "Invalid search type"
msgstr "Virheellinen haun tyyppi"
#. TRANSLATORS: the user did not specify what they wanted to install
-#: ../client/pk-console.c:1436
+#: ../client/pk-console.c:1471
msgid "A package name to install is required"
msgstr "Asennettavan paketin nimi on annettava"
#. TRANSLATORS: the user did not specify what they wanted to install
-#: ../client/pk-console.c:1445
+#: ../client/pk-console.c:1480
msgid "A filename to install is required"
msgstr "Asennettavan tiedoston nimi on annettava"
#. TRANSLATORS: geeky error, 99.9999% of users won't see this
-#: ../client/pk-console.c:1457
+#: ../client/pk-console.c:1492
msgid "A type, key_id and package_id are required"
msgstr "Tyyppi, key_id ja package_id on annettava"
#. TRANSLATORS: the user did not specify what they wanted to remove
-#: ../client/pk-console.c:1468
+#: ../client/pk-console.c:1503
msgid "A package name to remove is required"
msgstr "Poistettavan paketin nimi on annettava"
#. TRANSLATORS: the user did not specify anything about what to download or where
-#: ../client/pk-console.c:1477
+#: ../client/pk-console.c:1512
msgid "A destination directory and the package names to download are required"
msgstr "Kohdehakemisto ja ladattavien pakettien nimet paketit on annettava"
#. TRANSLATORS: the directory does not exist, so we can't continue
-#: ../client/pk-console.c:1484
+#: ../client/pk-console.c:1519
msgid "Directory not found"
msgstr "Hakemistoa ei löytynyt"
#. TRANSLATORS: geeky error, 99.9999% of users won't see this
-#: ../client/pk-console.c:1493
+#: ../client/pk-console.c:1528
msgid "A licence identifier (eula-id) is required"
msgstr "Lisenssin tunniste (eula-id) on annettava"
#. TRANSLATORS: geeky error, 99.9999% of users won't see this
-#: ../client/pk-console.c:1504
+#: ../client/pk-console.c:1539
msgid "A transaction identifier (tid) is required"
msgstr "Transaktion tunniste (tid) on annettava"
#. TRANSLATORS: The user did not specify a package name
-#: ../client/pk-console.c:1525
+#: ../client/pk-console.c:1560
msgid "A package name to resolve is required"
msgstr "Ratkaistavan paketin nimi on annettava"
#. TRANSLATORS: The user did not specify a repository (software source) name
-#: ../client/pk-console.c:1536 ../client/pk-console.c:1547
+#: ../client/pk-console.c:1571 ../client/pk-console.c:1582
msgid "A repository name is required"
msgstr "Asennuslähteen nimi on annettava"
#. TRANSLATORS: The user didn't provide any data
-#: ../client/pk-console.c:1558
+#: ../client/pk-console.c:1593
msgid "A repo name, parameter and value are required"
msgstr "Asennuslähteen nimi, parametri ja arvo on annettava"
#. TRANSLATORS: The user didn't specify what action to use
-#: ../client/pk-console.c:1575
+#: ../client/pk-console.c:1610
msgid "An action, e.g. 'update-system' is required"
msgstr "Toiminto, esim. âupdate-systemâ on annettava"
#. TRANSLATORS: The user specified an invalid action
-#: ../client/pk-console.c:1582
+#: ../client/pk-console.c:1617
msgid "A correct role is required"
msgstr "Sopiva rooli on annettava"
#. TRANSLATORS: The user did not provide a package name
#. TRANSLATORS: This is when the user fails to supply the package name
-#: ../client/pk-console.c:1592 ../client/pk-console.c:1607
-#: ../client/pk-console.c:1616 ../client/pk-console.c:1636
-#: ../client/pk-console.c:1645 ../client/pk-generate-pack.c:316
+#: ../client/pk-console.c:1627 ../client/pk-console.c:1642
+#: ../client/pk-console.c:1651 ../client/pk-console.c:1671
+#: ../client/pk-console.c:1680 ../client/pk-generate-pack.c:316
msgid "A package name is required"
msgstr "Paketin nimi on annettava"
#. TRANSLATORS: each package "provides" certain things, e.g. mime(gstreamer-decoder-mp3), the user didn't specify it
-#: ../client/pk-console.c:1625
+#: ../client/pk-console.c:1660
msgid "A package provide string is required"
msgstr "Paketin tarjoaja-merkkijono on annettava"
#. TRANSLATORS: The user tried to use an unsupported option on the command line
-#: ../client/pk-console.c:1705
+#: ../client/pk-console.c:1740
#, c-format
msgid "Option '%s' is not supported"
msgstr "Valitsinta â%sâ ei tueta"
#. TRANSLATORS: Generic failure of what they asked to do
-#: ../client/pk-console.c:1715
+#: ../client/pk-console.c:1750
msgid "Command failed"
msgstr "Komento epäonnistui"
@@ -537,8 +552,7 @@ msgstr ""
#. TRANSLATORS: the output location
#: ../client/pk-generate-pack.c:258
-msgid ""
-"The output file or directory (the current directory is used if ommitted)"
+msgid "The output file or directory (the current directory is used if omitted)"
msgstr ""
"Kohdetiedosto tai -hakemisto. Jos jätetään tyhjäksi, valitaan "
"automaattisesti nykyinen hakemisto."
@@ -568,9 +582,9 @@ msgstr "Molempia valitsimia on käytetty."
msgid "A output directory or file name is required"
msgstr "Kohdehakemiston tai -tiedoston nimi on annettava"
-#. TRANSLATORS: This is when the dameon is not-installed/broken and fails to startup
+#. TRANSLATORS: This is when the daemon is not-installed/broken and fails to startup
#: ../client/pk-generate-pack.c:342
-msgid "The dameon failed to startup"
+msgid "The daemon failed to startup"
msgstr "Taustaprosessin käynnistys epäonnistui"
#. TRANSLATORS: This is when the backend doesn't have the capability to get-depends
@@ -641,12 +655,12 @@ msgstr "Huoltopakkaus â%sâ on luotu"
msgid "Failed to create '%s': %s"
msgstr "Huoltopakkauksen â%sâ luominen epäonnistui: %s"
-#: ../client/pk-monitor.c:236
+#: ../client/pk-monitor.c:286
msgid "Failed to get daemon state"
msgstr "Taustaprosessin tilaa ei saatu"
#. TRANSLATORS: this is a program that monitors PackageKit
-#: ../client/pk-monitor.c:322
+#: ../client/pk-monitor.c:372
msgid "PackageKit Monitor"
msgstr "PackageKit-tarkkailija"
@@ -963,7 +977,7 @@ msgstr "Simulointitilassa ei asenneta paketteja"
#. TRANSLATORS: we are now installing the debuginfo packages we found earlier
#. TRANSLATORS: transaction state, installing packages
#: ../contrib/debuginfo-install/pk-debuginfo-install.c:862
-#: ../lib/packagekit-glib2/pk-console-shared.c:283
+#: ../lib/packagekit-glib2/pk-console-shared.c:289
#, c-format
msgid "Installing packages"
msgstr "Asennetaan paketteja"
@@ -1094,464 +1108,464 @@ msgstr "PackageKit-pakettiluettelo"
msgid "PackageKit Service Pack"
msgstr "PackageKit-huoltopakkaus"
-#: ../lib/packagekit-glib2/pk-console-shared.c:59
+#: ../lib/packagekit-glib2/pk-console-shared.c:65
#, c-format
msgid "Please enter a number from 1 to %i: "
msgstr "Anna numero väliltä 1-%i: "
#. TRANSLATORS: more than one package could be found that matched, to follow is a list of possible packages
-#: ../lib/packagekit-glib2/pk-console-shared.c:185
+#: ../lib/packagekit-glib2/pk-console-shared.c:191
msgid "More than one package matches:"
msgstr "Useita vastaavia paketteja saatavilla:"
#. TRANSLATORS: This finds out which package in the list to use
-#: ../lib/packagekit-glib2/pk-console-shared.c:196
+#: ../lib/packagekit-glib2/pk-console-shared.c:202
msgid "Please choose the correct package: "
msgstr "Valitse oikea paketti:"
#. TRANSLATORS: This is when the transaction status is not known
-#: ../lib/packagekit-glib2/pk-console-shared.c:251
+#: ../lib/packagekit-glib2/pk-console-shared.c:257
msgid "Unknown state"
msgstr "Tuntematon tila"
#. TRANSLATORS: transaction state, the daemon is in the process of starting
-#: ../lib/packagekit-glib2/pk-console-shared.c:255
+#: ../lib/packagekit-glib2/pk-console-shared.c:261
msgid "Starting"
msgstr "Käynnistetään"
#. TRANSLATORS: transaction state, the transaction is waiting for another to complete
-#: ../lib/packagekit-glib2/pk-console-shared.c:259
+#: ../lib/packagekit-glib2/pk-console-shared.c:265
msgid "Waiting in queue"
msgstr "Jonotetaan"
#. TRANSLATORS: transaction state, just started
-#: ../lib/packagekit-glib2/pk-console-shared.c:263
+#: ../lib/packagekit-glib2/pk-console-shared.c:269
msgid "Running"
msgstr "Suoritetaan"
#. TRANSLATORS: transaction state, is querying data
-#: ../lib/packagekit-glib2/pk-console-shared.c:267
+#: ../lib/packagekit-glib2/pk-console-shared.c:273
msgid "Querying"
msgstr "Kysellään"
#. TRANSLATORS: transaction state, getting data from a server
-#: ../lib/packagekit-glib2/pk-console-shared.c:271
+#: ../lib/packagekit-glib2/pk-console-shared.c:277
msgid "Getting information"
msgstr "Haetaan tietoja"
#. TRANSLATORS: transaction state, removing packages
-#: ../lib/packagekit-glib2/pk-console-shared.c:275
+#: ../lib/packagekit-glib2/pk-console-shared.c:281
msgid "Removing packages"
msgstr "Poistetaan paketteja"
#. TRANSLATORS: transaction state, downloading package files
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:279
-#: ../lib/packagekit-glib2/pk-console-shared.c:657
+#: ../lib/packagekit-glib2/pk-console-shared.c:285
+#: ../lib/packagekit-glib2/pk-console-shared.c:663
msgid "Downloading packages"
msgstr "Ladataan paketteja"
#. TRANSLATORS: transaction state, refreshing internal lists
-#: ../lib/packagekit-glib2/pk-console-shared.c:287
+#: ../lib/packagekit-glib2/pk-console-shared.c:293
msgid "Refreshing software list"
msgstr "Virkistetään ohjelmaluetteloa"
#. TRANSLATORS: transaction state, installing updates
-#: ../lib/packagekit-glib2/pk-console-shared.c:291
+#: ../lib/packagekit-glib2/pk-console-shared.c:297
msgid "Installing updates"
msgstr "Asennetaan päivityksiä"
#. TRANSLATORS: transaction state, removing old packages, and cleaning config files
-#: ../lib/packagekit-glib2/pk-console-shared.c:295
+#: ../lib/packagekit-glib2/pk-console-shared.c:301
msgid "Cleaning up packages"
msgstr "Siivotaan paketteja"
#. TRANSLATORS: transaction state, obsoleting old packages
-#: ../lib/packagekit-glib2/pk-console-shared.c:299
+#: ../lib/packagekit-glib2/pk-console-shared.c:305
msgid "Obsoleting packages"
msgstr "Vanhennetaan paketteja"
#. TRANSLATORS: transaction state, checking the transaction before we do it
-#: ../lib/packagekit-glib2/pk-console-shared.c:303
+#: ../lib/packagekit-glib2/pk-console-shared.c:309
msgid "Resolving dependencies"
msgstr "Ratkaistaan riippuvuuksia"
#. TRANSLATORS: transaction state, checking if we have all the security keys for the operation
-#: ../lib/packagekit-glib2/pk-console-shared.c:307
+#: ../lib/packagekit-glib2/pk-console-shared.c:313
msgid "Checking signatures"
msgstr "Tarkistetaan allekirjoituksia"
#. TRANSLATORS: transaction state, when we return to a previous system state
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:311
-#: ../lib/packagekit-glib2/pk-console-shared.c:617
+#: ../lib/packagekit-glib2/pk-console-shared.c:317
+#: ../lib/packagekit-glib2/pk-console-shared.c:623
msgid "Rolling back"
msgstr "Peruutetaan"
#. TRANSLATORS: transaction state, when we're doing a test transaction
-#: ../lib/packagekit-glib2/pk-console-shared.c:315
+#: ../lib/packagekit-glib2/pk-console-shared.c:321
msgid "Testing changes"
msgstr "Testataan muutoksia"
#. TRANSLATORS: transaction state, when we're writing to the system package database
-#: ../lib/packagekit-glib2/pk-console-shared.c:319
+#: ../lib/packagekit-glib2/pk-console-shared.c:325
msgid "Committing changes"
msgstr "Toteutetaan muutoksia"
#. TRANSLATORS: transaction state, requesting data from a server
-#: ../lib/packagekit-glib2/pk-console-shared.c:323
+#: ../lib/packagekit-glib2/pk-console-shared.c:329
msgid "Requesting data"
msgstr "Pyydetään dataa"
#. TRANSLATORS: transaction state, all done!
-#: ../lib/packagekit-glib2/pk-console-shared.c:327
+#: ../lib/packagekit-glib2/pk-console-shared.c:333
msgid "Finished"
msgstr "Valmis"
#. TRANSLATORS: transaction state, in the process of cancelling
-#: ../lib/packagekit-glib2/pk-console-shared.c:331
+#: ../lib/packagekit-glib2/pk-console-shared.c:337
msgid "Cancelling"
msgstr "Perutaan"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:335
+#: ../lib/packagekit-glib2/pk-console-shared.c:341
msgid "Downloading repository information"
msgstr "Ladataan asennuslähdetietoja"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:339
+#: ../lib/packagekit-glib2/pk-console-shared.c:345
msgid "Downloading list of packages"
msgstr "Ladataan pakettiluetteloa"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:343
+#: ../lib/packagekit-glib2/pk-console-shared.c:349
msgid "Downloading file lists"
msgstr "Ladataan tiedostoluetteloita"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:347
+#: ../lib/packagekit-glib2/pk-console-shared.c:353
msgid "Downloading lists of changes"
msgstr "Ladataan muutosluetteloja"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:351
+#: ../lib/packagekit-glib2/pk-console-shared.c:357
msgid "Downloading groups"
msgstr "Ladataan ryhmiä"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:355
+#: ../lib/packagekit-glib2/pk-console-shared.c:361
msgid "Downloading update information"
msgstr "Ladataan päivitystietoja"
#. TRANSLATORS: transaction state, repackaging delta files
-#: ../lib/packagekit-glib2/pk-console-shared.c:359
+#: ../lib/packagekit-glib2/pk-console-shared.c:365
msgid "Repackaging files"
msgstr "Paketoidaan tiedostoja uudelleen"
#. TRANSLATORS: transaction state, loading databases
-#: ../lib/packagekit-glib2/pk-console-shared.c:363
+#: ../lib/packagekit-glib2/pk-console-shared.c:369
msgid "Loading cache"
msgstr "Ladataan välimuistia"
#. TRANSLATORS: transaction state, scanning for running processes
-#: ../lib/packagekit-glib2/pk-console-shared.c:367
+#: ../lib/packagekit-glib2/pk-console-shared.c:373
msgid "Scanning applications"
msgstr "Etsitään ohjelmia"
#. TRANSLATORS: transaction state, generating a list of packages installed on the system
-#: ../lib/packagekit-glib2/pk-console-shared.c:371
+#: ../lib/packagekit-glib2/pk-console-shared.c:377
msgid "Generating package lists"
msgstr "Luodaan pakettiluetteloita"
#. TRANSLATORS: transaction state, when we're waiting for the native tools to exit
-#: ../lib/packagekit-glib2/pk-console-shared.c:375
+#: ../lib/packagekit-glib2/pk-console-shared.c:381
msgid "Waiting for package manager lock"
msgstr "Odotetaan paketinhallinnan lukkoa"
#. TRANSLATORS: transaction state, waiting for user to type in a password
-#: ../lib/packagekit-glib2/pk-console-shared.c:379
+#: ../lib/packagekit-glib2/pk-console-shared.c:385
msgid "Waiting for authentication"
msgstr "Odotetaan tunnistautumista"
#. TRANSLATORS: transaction state, we are updating the list of processes
-#: ../lib/packagekit-glib2/pk-console-shared.c:383
+#: ../lib/packagekit-glib2/pk-console-shared.c:389
msgid "Updating running applications"
msgstr "Päivitetään suoritettavia ohjelmia"
#. TRANSLATORS: transaction state, we are checking executable files currently in use
-#: ../lib/packagekit-glib2/pk-console-shared.c:387
+#: ../lib/packagekit-glib2/pk-console-shared.c:393
msgid "Checking applications in use"
msgstr "Etsitään käytössä olevia ohjelmia"
#. TRANSLATORS: transaction state, we are checking for libraries currently in use
-#: ../lib/packagekit-glib2/pk-console-shared.c:391
+#: ../lib/packagekit-glib2/pk-console-shared.c:397
msgid "Checking libraries in use"
msgstr "Etsitään käytössä olevia kirjastoja"
#. TRANSLATORS: transaction state, we are copying package files before or after the transaction
-#: ../lib/packagekit-glib2/pk-console-shared.c:395
+#: ../lib/packagekit-glib2/pk-console-shared.c:401
msgid "Copying files"
msgstr "Kopioidaan tiedostoja"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:413
+#: ../lib/packagekit-glib2/pk-console-shared.c:419
msgid "Trivial"
msgstr "Vähäpätöinen"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:417
+#: ../lib/packagekit-glib2/pk-console-shared.c:423
msgid "Normal"
msgstr "Tavallinen"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:421
+#: ../lib/packagekit-glib2/pk-console-shared.c:427
msgid "Important"
msgstr "Tärkeä"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:425
+#: ../lib/packagekit-glib2/pk-console-shared.c:431
msgid "Security"
msgstr "Turvallisuus"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:429
+#: ../lib/packagekit-glib2/pk-console-shared.c:435
msgid "Bug fix "
msgstr "Virhekorjaus"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:433
+#: ../lib/packagekit-glib2/pk-console-shared.c:439
msgid "Enhancement"
msgstr "Kehittävä"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:437
+#: ../lib/packagekit-glib2/pk-console-shared.c:443
msgid "Blocked"
msgstr "Estetty"
#. TRANSLATORS: The state of a package
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:442
-#: ../lib/packagekit-glib2/pk-console-shared.c:515
+#: ../lib/packagekit-glib2/pk-console-shared.c:448
+#: ../lib/packagekit-glib2/pk-console-shared.c:521
msgid "Installed"
msgstr "Asennettu"
#. TRANSLATORS: The state of a package, i.e. not installed
-#: ../lib/packagekit-glib2/pk-console-shared.c:447
+#: ../lib/packagekit-glib2/pk-console-shared.c:453
msgid "Available"
msgstr "Saatavilla"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:465
+#: ../lib/packagekit-glib2/pk-console-shared.c:471
msgid "Downloading"
msgstr "Ladataan"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:469
+#: ../lib/packagekit-glib2/pk-console-shared.c:475
msgid "Updating"
msgstr "Päivitetään"
#. TRANSLATORS: The action of the package, in present tense
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:473
-#: ../lib/packagekit-glib2/pk-console-shared.c:593
+#: ../lib/packagekit-glib2/pk-console-shared.c:479
+#: ../lib/packagekit-glib2/pk-console-shared.c:599
msgid "Installing"
msgstr "Asennetaan"
#. TRANSLATORS: The action of the package, in present tense
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:477
-#: ../lib/packagekit-glib2/pk-console-shared.c:589
+#: ../lib/packagekit-glib2/pk-console-shared.c:483
+#: ../lib/packagekit-glib2/pk-console-shared.c:595
msgid "Removing"
msgstr "Poistetaan"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:481
+#: ../lib/packagekit-glib2/pk-console-shared.c:487
msgid "Cleaning up"
msgstr "Siivotaan"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:485
+#: ../lib/packagekit-glib2/pk-console-shared.c:491
msgid "Obsoleting"
msgstr "Vanhennetaan"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:489
+#: ../lib/packagekit-glib2/pk-console-shared.c:495
msgid "Reinstalling"
msgstr "Asennetaan uudelleen"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:507
+#: ../lib/packagekit-glib2/pk-console-shared.c:513
msgid "Downloaded"
msgstr "Ladattu"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:519
+#: ../lib/packagekit-glib2/pk-console-shared.c:525
msgid "Removed"
msgstr "Poistettu"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:523
+#: ../lib/packagekit-glib2/pk-console-shared.c:529
msgid "Cleaned up"
msgstr "Siivottu"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:527
+#: ../lib/packagekit-glib2/pk-console-shared.c:533
msgid "Obsoleted"
msgstr "Vanhennettu"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:531
+#: ../lib/packagekit-glib2/pk-console-shared.c:537
msgid "Reinstalled"
msgstr "Asennettu uudelleen"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:549
+#: ../lib/packagekit-glib2/pk-console-shared.c:555
msgid "Unknown role type"
msgstr "Tuntematon roolityyppi"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:553
+#: ../lib/packagekit-glib2/pk-console-shared.c:559
msgid "Getting dependencies"
msgstr "Haetaan riippuvuuksia"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:557
+#: ../lib/packagekit-glib2/pk-console-shared.c:563
msgid "Getting update details"
msgstr "Haetaan päivitystietoja"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:561
+#: ../lib/packagekit-glib2/pk-console-shared.c:567
msgid "Getting details"
msgstr "Haetaan tietoja"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:565
+#: ../lib/packagekit-glib2/pk-console-shared.c:571
msgid "Getting requires"
msgstr "Haetaan vaatimuksia"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:569
+#: ../lib/packagekit-glib2/pk-console-shared.c:575
msgid "Getting updates"
msgstr "Haetaan päivityksiä"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:573
+#: ../lib/packagekit-glib2/pk-console-shared.c:579
msgid "Searching by details"
msgstr "Etsitään tietojen perusteella"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:577
+#: ../lib/packagekit-glib2/pk-console-shared.c:583
msgid "Searching by file"
msgstr "Etsitään tiedoston perusteella"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:581
+#: ../lib/packagekit-glib2/pk-console-shared.c:587
msgid "Searching groups"
msgstr "Etsitään ryhmiä"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:585
+#: ../lib/packagekit-glib2/pk-console-shared.c:591
msgid "Searching by name"
msgstr "Etsitään nimen perusteella"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:597
+#: ../lib/packagekit-glib2/pk-console-shared.c:603
msgid "Installing files"
msgstr "Asennetaan tiedostoja"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:601
+#: ../lib/packagekit-glib2/pk-console-shared.c:607
msgid "Refreshing cache"
msgstr "Virkistetään välimuistia"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:605
+#: ../lib/packagekit-glib2/pk-console-shared.c:611
msgid "Updating packages"
msgstr "Päivitetään paketteja"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:609
+#: ../lib/packagekit-glib2/pk-console-shared.c:615
msgid "Updating system"
msgstr "Päivitetään järjestelmää"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:613
+#: ../lib/packagekit-glib2/pk-console-shared.c:619
msgid "Canceling"
msgstr "Perutaan"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:621
+#: ../lib/packagekit-glib2/pk-console-shared.c:627
msgid "Getting repositories"
msgstr "Haetaan asennuslähteitä"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:625
+#: ../lib/packagekit-glib2/pk-console-shared.c:631
msgid "Enabling repository"
msgstr "Otetaan asennuslähde käyttöön"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:629
+#: ../lib/packagekit-glib2/pk-console-shared.c:635
msgid "Setting data"
msgstr "Asetetaan dataa"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:633
+#: ../lib/packagekit-glib2/pk-console-shared.c:639
msgid "Resolving"
msgstr "Ratkaistaan"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:637
+#: ../lib/packagekit-glib2/pk-console-shared.c:643
msgid "Getting file list"
msgstr "Haetaan tiedostoluetteloa"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:641
+#: ../lib/packagekit-glib2/pk-console-shared.c:647
msgid "Getting provides"
msgstr "Haetaan tarjoajia"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:645
+#: ../lib/packagekit-glib2/pk-console-shared.c:651
msgid "Installing signature"
msgstr "Asennetaan allekirjoitusta"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:649
+#: ../lib/packagekit-glib2/pk-console-shared.c:655
msgid "Getting packages"
msgstr "Haetaan paketteja"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:653
+#: ../lib/packagekit-glib2/pk-console-shared.c:659
msgid "Accepting EULA"
msgstr "Hyväksytään käyttöoikeussopimusta"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:661
+#: ../lib/packagekit-glib2/pk-console-shared.c:667
msgid "Getting upgrades"
msgstr "Haetaan päivityksiä"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:665
+#: ../lib/packagekit-glib2/pk-console-shared.c:671
msgid "Getting categories"
msgstr "Haetaan kategorioita"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:669
+#: ../lib/packagekit-glib2/pk-console-shared.c:675
msgid "Getting transactions"
msgstr "Haetaan transaktioita"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:673
-#: ../lib/packagekit-glib2/pk-console-shared.c:677
+#: ../lib/packagekit-glib2/pk-console-shared.c:679
+#: ../lib/packagekit-glib2/pk-console-shared.c:683
msgid "Simulating install"
msgstr "Simuloidaan asennusta"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:681
+#: ../lib/packagekit-glib2/pk-console-shared.c:687
msgid "Simulating remove"
msgstr "Simuloidaan poistoa"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:685
+#: ../lib/packagekit-glib2/pk-console-shared.c:691
msgid "Simulating update"
msgstr "Simuloidaan päivitystä"
@@ -1721,39 +1735,46 @@ msgstr "Ohjelmistolähdeasetusten muuttaminen vaatii tunnistautumisen"
#: ../policy/org.freedesktop.packagekit.policy.in.h:11
msgid ""
+"Authentication is required to change the location used to decompress packages"
+msgstr ""
+"Pakettien purkamiseen käytettävän sijainnin vaihtaminen vaatii "
+"tunnistautumisen"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:12
+msgid ""
"Authentication is required to consider a key used for signing packages as "
"trusted"
msgstr ""
"Pakettien allekirjoittamiseen käytettyyn avaimeen luottaminen vaatii "
"tunnistautumisen"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:12
+#: ../policy/org.freedesktop.packagekit.policy.in.h:13
msgid "Authentication is required to install a signed package"
msgstr "Allekirjoitetun paketin asentaminen vaatii tunnistautumisen"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:13
+#: ../policy/org.freedesktop.packagekit.policy.in.h:14
msgid "Authentication is required to install an untrusted package"
msgstr ""
"Tunnistautuminen vaaditaan, jotta voidaan asentaa paketti, johon ei luoteta"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:14
+#: ../policy/org.freedesktop.packagekit.policy.in.h:15
msgid "Authentication is required to refresh the system sources"
msgstr "Järjestelmälähteiden virkistäminen vaatii tunnistautumisen"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:15
+#: ../policy/org.freedesktop.packagekit.policy.in.h:16
msgid "Authentication is required to reload the device with a new driver"
msgstr ""
"Laitteen liittäminen uudelleen uudella ajurilla vaatii tunnistautumisen"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:16
+#: ../policy/org.freedesktop.packagekit.policy.in.h:17
msgid "Authentication is required to remove packages"
msgstr "Pakettien poistaminen vaatii tunnistautumisen"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:17
+#: ../policy/org.freedesktop.packagekit.policy.in.h:18
msgid "Authentication is required to rollback a transaction"
msgstr "Transaktion peruuttaminen vaatii tunnistautumisen"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:18
+#: ../policy/org.freedesktop.packagekit.policy.in.h:19
msgid ""
"Authentication is required to set the network proxy used for downloading "
"packages"
@@ -1761,7 +1782,7 @@ msgstr ""
"Pakettien lataamiseen käytettävän välipalvelimen asettaminen vaatii "
"tunnistautumisen"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:19
+#: ../policy/org.freedesktop.packagekit.policy.in.h:20
msgid "Authentication is required to update packages"
msgstr "Pakettien päivittäminen vaatii tunnistautumisen"
@@ -1770,16 +1791,26 @@ msgstr "Pakettien päivittäminen vaatii tunnistautumisen"
#. authentication, but a different user id needs the admin password
#. to cancel another users task.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:25
+#: ../policy/org.freedesktop.packagekit.policy.in.h:26
msgid "Cancel foreign task"
msgstr "Peru tuntematon tehtävä"
#. SECURITY:
+#. - This is used when users want to install to a different prefix, for
+#. instance to a LTSP image or a virtual machine.
+#. - This could be used to overwrite files not owned by the user using
+#. a carefully created package file.
+#.
+#: ../policy/org.freedesktop.packagekit.policy.in.h:33
+msgid "Change location that packages are installed"
+msgstr "Vaihda sijaintia, johon paketit asennetaan"
+
+#. SECURITY:
#. - Normal users require admin authentication to enable or disable
#. software sources as this can be used to enable new updates or
#. install different versions of software.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:31
+#: ../policy/org.freedesktop.packagekit.policy.in.h:39
msgid "Change software source parameters"
msgstr "Muuta ohjelmistolähdeasetuksia"
@@ -1789,7 +1820,7 @@ msgstr "Muuta ohjelmistolähdeasetuksia"
#. - Paranoid users (or parents!) can change this to 'auth_admin' or
#. 'auth_admin_keep'.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:38
+#: ../policy/org.freedesktop.packagekit.policy.in.h:46
msgid "Install signed package"
msgstr "Asenna allekirjoitettu paketti"
@@ -1799,7 +1830,7 @@ msgstr "Asenna allekirjoitettu paketti"
#. password would be a massive security hole.
#. - This is not retained as each package should be authenticated.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:45
+#: ../policy/org.freedesktop.packagekit.policy.in.h:53
msgid "Install untrusted local file"
msgstr "Asenna paikallinen tiedosto, johon ei luoteta"
@@ -1807,7 +1838,7 @@ msgstr "Asenna paikallinen tiedosto, johon ei luoteta"
#. - Normal users do not require admin authentication to refresh the
#. cache, as this doesn't actually install or remove software.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:50
+#: ../policy/org.freedesktop.packagekit.policy.in.h:58
msgid "Refresh system sources"
msgstr "Virkistä järjestelmälähteet"
@@ -1818,7 +1849,7 @@ msgstr "Virkistä järjestelmälähteet"
#. try to rebind drivers in use, for instance security authentication
#. devices.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:58
+#: ../policy/org.freedesktop.packagekit.policy.in.h:66
msgid "Reload a device"
msgstr "Lataa laite uudelleen"
@@ -1831,7 +1862,7 @@ msgstr "Lataa laite uudelleen"
#. be removed. If this is not possible, change this authentication to
#. 'auth_admin'.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:68
+#: ../policy/org.freedesktop.packagekit.policy.in.h:76
msgid "Remove package"
msgstr "Poista paketti"
@@ -1840,7 +1871,7 @@ msgstr "Poista paketti"
#. as this will change a large number of packages, and could expose the
#. system to previously patched security vulnerabilities.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:74
+#: ../policy/org.freedesktop.packagekit.policy.in.h:82
msgid "Rollback to a previous transaction"
msgstr "Peruuta edelliseen transaktioon"
@@ -1848,7 +1879,7 @@ msgstr "Peruuta edelliseen transaktioon"
#. - Normal users do not require admin authentication to set the proxy
#. used for downloading packages.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:79
+#: ../policy/org.freedesktop.packagekit.policy.in.h:87
msgid "Set network proxy"
msgstr "Aseta välipalvelin"
@@ -1858,7 +1889,7 @@ msgstr "Aseta välipalvelin"
#. without a secure authentication.
#. - This is not kept as each package should be authenticated.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:86
+#: ../policy/org.freedesktop.packagekit.policy.in.h:94
msgid "Trust a key used for signing packages"
msgstr "Luota pakettien allekirjoittamiseen käytettyyn avaimeen"
@@ -1869,7 +1900,7 @@ msgstr "Luota pakettien allekirjoittamiseen käytettyyn avaimeen"
#. - Changing this to anything other than 'yes' will break unattended
#. updates.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:94
+#: ../policy/org.freedesktop.packagekit.policy.in.h:102
msgid "Update packages"
msgstr "Päivitä paketteja"
@@ -2035,9 +2066,6 @@ msgstr "Näytä virheenjäljitysvalitsimet"
#~ msgid "This tool could not install the files: %s"
#~ msgstr "Tämä työkalu ei voinut asentaa tiedostoja: %s"
-#~ msgid "This tool could not remove %s: %s"
-#~ msgstr "Tämä työkalu ei voinut poistaa pakettia %s: %s"
-
#~ msgid "This tool could not remove the packages: %s"
#~ msgstr "Tämä työkalu ei voinut poistaa paketteja: %s"
@@ -2148,9 +2176,6 @@ msgstr "Näytä virheenjäljitysvalitsimet"
#~ msgid "Media ID"
#~ msgstr "Tallennusvälineen tunniste"
-#~ msgid "The package could not be found"
-#~ msgstr "Pakettia ei löytynyt"
-
#~ msgid "You need to specify a search type, e.g. name"
#~ msgstr "Haun tyyppi on annettava, esim. nimi"
commit b10ce45afa4927313f339ac3b2351efea9c2caba
Author: Fabio Erculiani <lxnay at sabayon.org>
Date: Fri May 21 13:20:31 2010 +0200
entropy: make backend working with latest Entropy releases
diff --git a/backends/entropy/entropyBackend.py b/backends/entropy/entropyBackend.py
index b81e440..cd3516b 100755
--- a/backends/entropy/entropyBackend.py
+++ b/backends/entropy/entropyBackend.py
@@ -684,7 +684,7 @@ class PackageKitEntropyClient(Client):
_pk_message = None
def output(self, text, header = "", footer = "", back = False,
- importance = 0, type = "info", count = None, percent = False):
+ importance = 0, level = "info", count = None, percent = False):
"""
Reimplemented from entropy.output.TextInterface.
"""
@@ -763,15 +763,23 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin):
}
def __sigquit(self, signum, frame):
- if hasattr(self, '_entropy'):
- self._entropy.destroy()
- raise SystemExit(1)
+ self._entropy.shutdown()
+ raise SystemExit(0)
+
+ def destroy(self):
+ if hasattr(self, "_entropy"):
+ self._entropy.shutdown()
+
+ def __del__(self):
+ self.destroy()
def __init__(self, args):
PackageKitEntropyMixin.__init__(self)
+ PackageKitBaseBackend.__init__(self, args)
- signal.signal(signal.SIGQUIT, self.__sigquit)
self._entropy = PackageKitEntropyClient()
+ self.doLock()
+ signal.signal(signal.SIGQUIT, self.__sigquit)
PkUrlFetcher._pk_progress = self.sub_percentage
self._entropy.urlFetcher = PkUrlFetcher
self._repo_name_cache = {}
@@ -783,7 +791,9 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin):
level = self._settings['system']['log_level'],
filename = self._log_fname, header = "[packagekit]")
- PackageKitBaseBackend.__init__(self, args)
+ def unLock(self):
+ self.destroy()
+ PackageKitBaseBackend.unLock(self)
def _convert_date_to_iso8601(self, unix_time_str):
unix_time = float(unix_time_str)
@@ -798,7 +808,7 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin):
self._log_message(__name__, "_generic_message:", decolorize(message))
def _config_files_message(self):
- scandata = self._entropy.FileUpdates.scanfs(dcache = True,
+ scandata = self._entropy.FileUpdates.scan(dcache = True,
quiet = True)
if scandata is None:
return
@@ -1584,6 +1594,8 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin):
# now feed stdout
self._pk_feed_sorted_pkgs(pkgs)
+ self.percentage(100)
+
def search_name(self, filters, values):
self._log_message(__name__, "search_name: got %s and %s" % (
commit 529507cb6139b38e8e3884a364b49ddeefd0b284
Author: Michael Meeks <michael.meeks at novell.com>
Date: Wed May 19 18:08:57 2010 +0100
tweak from merge
diff --git a/client/pk-console.c b/client/pk-console.c
index 8c06a21..077ccaf 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1732,9 +1732,9 @@ main (int argc, char *argv[])
} else if (strcmp (mode, "refresh") == 0) {
gboolean force = value && !strcmp (value, "--force");
- pk_task_refresh_cache_asyunc (PK_TASK (task), force, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_refresh_cache_async (PK_TASK (task), force, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else {
/* TRANSLATORS: The user tried to use an unsupported option on the command line */
commit 937fe4512d572e3bd7491f56f93a1f0061591802
Author: Michael Meeks <michael.meeks at novell.com>
Date: Wed May 19 16:38:05 2010 +0100
build conditional BUILD_ZIF needs to be at the top level
diff --git a/configure.ac b/configure.ac
index f3af6ef..2b7a4e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -635,6 +635,7 @@ fi
AC_DEFINE_UNQUOTED(DEFAULT_BACKEND, "$with_default_backend", [default backend prefix])
AC_SUBST(DEFAULT_BACKEND, "$with_default_backend")
+build_zif=no
if test x$enable_yum = xyes; then
dnl ---------------------------------------------------------------------------
dnl - Zif is an experimental library for direct metadata access
@@ -644,14 +645,12 @@ if test x$enable_yum = xyes; then
if test x$enable_zif = xyes; then
PKG_CHECK_MODULES(ZIF, zif,
build_zif=yes, build_zif=no)
- else
- build_zif=no
fi
if test "x$build_zif" = "xyes"; then
AC_DEFINE([HAVE_ZIF], [1], [If Zif support should be enabled])
fi
- AM_CONDITIONAL(PK_BUILD_ZIF, test $build_zif = "yes")
fi
+AM_CONDITIONAL(PK_BUILD_ZIF, test $build_zif = "yes")
if test x$enable_apt = xyes; then
PY_CHECK_MOD([apt_pkg],,,AC_MSG_ERROR([Apt backend needs python-apt]))
commit af07c481d42c6c98bf1fb24b3dd35389d20d548a
Author: Michael Meeks <michael.meeks at novell.com>
Date: Wed May 19 16:34:39 2010 +0100
add --force argument to pkcon refresh
diff --git a/client/pk-console.c b/client/pk-console.c
index e8dc4dc..8c06a21 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1174,7 +1174,7 @@ pk_console_get_summary (void)
pk_bitfield_contain (roles, PK_ROLE_ENUM_UPDATE_PACKAGES))
g_string_append_printf (string, " %s\n", "update <package>");
if (pk_bitfield_contain (roles, PK_ROLE_ENUM_REFRESH_CACHE))
- g_string_append_printf (string, " %s\n", "refresh");
+ g_string_append_printf (string, " %s\n", "refresh [--force]");
if (pk_bitfield_contain (roles, PK_ROLE_ENUM_RESOLVE))
g_string_append_printf (string, " %s\n", "resolve [package]");
if (pk_bitfield_contain (roles, PK_ROLE_ENUM_GET_UPDATES))
@@ -1731,9 +1731,10 @@ main (int argc, char *argv[])
(GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "refresh") == 0) {
- pk_task_refresh_cache_async (PK_TASK (task),FALSE, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ gboolean force = value && !strcmp (value, "--force");
+ pk_task_refresh_cache_asyunc (PK_TASK (task), force, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else {
/* TRANSLATORS: The user tried to use an unsupported option on the command line */
commit 25f1e4f98fcd42a85271cadb27a436a183e06ccf
Author: kristho <kristho at fedoraproject.org>
Date: Fri May 14 22:06:25 2010 +0000
l10n: Updates to Danish (da) translation
Transmitted-via: Transifex (translate.fedoraproject.org)
diff --git a/po/da.po b/po/da.po
index 117fee9..88a6587 100644
--- a/po/da.po
+++ b/po/da.po
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: packagekit\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-04-19 02:38+0000\n"
-"PO-Revision-Date: 2010-04-19 10:17+0200\n"
+"POT-Creation-Date: 2010-05-14 15:34+0000\n"
+"PO-Revision-Date: 2010-05-15 00:05+0200\n"
"Last-Translator: Kris Thomsen <lakristho at gmail.com>\n"
"Language-Team: Danish <dansk at dansk-gruppen.dk>\n"
"MIME-Version: 1.0\n"
@@ -197,7 +197,7 @@ msgstr "Udgivet"
#. TRANSLATORS: details about the update, date the update was updated
#. TRANSLATORS: The action of the package, in past tense
-#: ../client/pk-console.c:390 ../lib/packagekit-glib2/pk-console-shared.c:511
+#: ../client/pk-console.c:390 ../lib/packagekit-glib2/pk-console-shared.c:517
msgid "Updated"
msgstr "Opdateret"
@@ -380,35 +380,40 @@ msgid "Failed to get the time since this action was last completed"
msgstr "Kunne ikke hente tid siden denne handling sidst blev gennemført"
#. TRANSLATORS: command line argument, just show the version string
-#: ../client/pk-console.c:1267 ../client/pk-monitor.c:326
+#: ../client/pk-console.c:1268 ../client/pk-monitor.c:356
msgid "Show the program version and exit"
msgstr "Vis programversionen og afslut"
#. TRANSLATORS: command line argument, use a filter to narrow down results
-#: ../client/pk-console.c:1270
+#: ../client/pk-console.c:1271
msgid "Set the filter, e.g. installed"
msgstr "Sæt filteret, f.eks. installeret"
+#. TRANSLATORS: command line argument, use a non-standard install prefix
+#: ../client/pk-console.c:1274
+msgid "Set the install root, e.g. '/' or '/mnt/ltsp'"
+msgstr "Sæt installationsroden, f.eks. \"/\" eller \"/mnt/ltsp\""
+
#. TRANSLATORS: command line argument, work asynchronously
-#: ../client/pk-console.c:1273
+#: ../client/pk-console.c:1277
msgid "Exit without waiting for actions to complete"
msgstr "Afslut uden at vente på at handlingerne færdiggøres"
#. command line argument, do we ask questions
-#: ../client/pk-console.c:1276
+#: ../client/pk-console.c:1280
#: ../contrib/debuginfo-install/pk-debuginfo-install.c:527
msgid "Install the packages without asking for confirmation"
msgstr "Installér pakkerne uden at spørge efter bekræftelse"
#. TRANSLATORS: command line argument, this command is not a priority
-#: ../client/pk-console.c:1279
+#: ../client/pk-console.c:1283
msgid "Run the command using idle network bandwidth and also using less power"
msgstr ""
"Kør kommandoen ved at bruge lav netværksbåndbredde, hvilket bruger mindre "
"strøm"
#. TRANSLATORS: command line argument, just output without fancy formatting
-#: ../client/pk-console.c:1282
+#: ../client/pk-console.c:1286
msgid ""
"Print to screen a machine readable output, rather than using animated widgets"
msgstr ""
@@ -416,122 +421,127 @@ msgstr ""
"widgets"
#. TRANSLATORS: we failed to contact the daemon
-#: ../client/pk-console.c:1304
+#: ../client/pk-console.c:1308
msgid "Failed to contact PackageKit"
msgstr "Kunne ikke kontakte PackageKit"
#. TRANSLATORS: The user specified an incorrect filter
-#: ../client/pk-console.c:1365
+#: ../client/pk-console.c:1369
msgid "The proxy could not be set"
msgstr "Denne proxy kunne ikke blive sat"
#. TRANSLATORS: The user specified an incorrect filter
-#: ../client/pk-console.c:1377
+#: ../client/pk-console.c:1381
+msgid "The install root could not be set"
+msgstr "Installationsroden ikke blive sat"
+
+#. TRANSLATORS: The user specified an incorrect filter
+#: ../client/pk-console.c:1393
msgid "The filter specified was invalid"
msgstr "Filteret det blev angivet er ugyldigt"
#. TRANSLATORS: a search type can be name, details, file, etc
-#: ../client/pk-console.c:1396
+#: ../client/pk-console.c:1412
msgid "A search type is required, e.g. name"
msgstr "En søgetype kræves, f.eks. navn"
#. TRANSLATORS: the user needs to provide a search term
-#: ../client/pk-console.c:1403 ../client/pk-console.c:1415
-#: ../client/pk-console.c:1427 ../client/pk-console.c:1439
+#: ../client/pk-console.c:1419 ../client/pk-console.c:1431
+#: ../client/pk-console.c:1443 ../client/pk-console.c:1455
msgid "A search term is required"
msgstr "En søgeterm kræves"
#. TRANSLATORS: the search type was provided, but invalid
-#: ../client/pk-console.c:1449
+#: ../client/pk-console.c:1465
msgid "Invalid search type"
msgstr "Ugyldig søgetype"
#. TRANSLATORS: the user did not specify what they wanted to install
-#: ../client/pk-console.c:1455
+#: ../client/pk-console.c:1471
msgid "A package name to install is required"
msgstr "Et pakkenavn til installation er påkrævet"
#. TRANSLATORS: the user did not specify what they wanted to install
-#: ../client/pk-console.c:1464
+#: ../client/pk-console.c:1480
msgid "A filename to install is required"
msgstr "Et filnavn til installation er påkrævet"
#. TRANSLATORS: geeky error, 99.9999% of users won't see this
-#: ../client/pk-console.c:1476
+#: ../client/pk-console.c:1492
msgid "A type, key_id and package_id are required"
msgstr "En type, nøgle_id og pakke_id kræves"
#. TRANSLATORS: the user did not specify what they wanted to remove
-#: ../client/pk-console.c:1487
+#: ../client/pk-console.c:1503
msgid "A package name to remove is required"
msgstr "Et pakkenavn til fjernelse kræves"
#. TRANSLATORS: the user did not specify anything about what to download or where
-#: ../client/pk-console.c:1496
+#: ../client/pk-console.c:1512
msgid "A destination directory and the package names to download are required"
msgstr "En destinationsmappe og pakkenavnene kræves for at blive hentet"
#. TRANSLATORS: the directory does not exist, so we can't continue
-#: ../client/pk-console.c:1503
+#: ../client/pk-console.c:1519
msgid "Directory not found"
msgstr "Mappe ikke fundet"
#. TRANSLATORS: geeky error, 99.9999% of users won't see this
-#: ../client/pk-console.c:1512
+#: ../client/pk-console.c:1528
msgid "A licence identifier (eula-id) is required"
msgstr "En licensgenkender (eula-id) kræves"
#. TRANSLATORS: geeky error, 99.9999% of users won't see this
-#: ../client/pk-console.c:1523
+#: ../client/pk-console.c:1539
msgid "A transaction identifier (tid) is required"
msgstr "En overførselsgenkender (tid) kræves"
#. TRANSLATORS: The user did not specify a package name
-#: ../client/pk-console.c:1544
+#: ../client/pk-console.c:1560
msgid "A package name to resolve is required"
msgstr "Et pakkenavn til at løse kræves"
#. TRANSLATORS: The user did not specify a repository (software source) name
-#: ../client/pk-console.c:1555 ../client/pk-console.c:1566
+#: ../client/pk-console.c:1571 ../client/pk-console.c:1582
msgid "A repository name is required"
msgstr "Et pakkearkivnavn kræves"
#. TRANSLATORS: The user didn't provide any data
-#: ../client/pk-console.c:1577
+#: ../client/pk-console.c:1593
msgid "A repo name, parameter and value are required"
msgstr "Et pakkearkivnavn, parameter og værdi kræves"
#. TRANSLATORS: The user didn't specify what action to use
-#: ../client/pk-console.c:1594
+#: ../client/pk-console.c:1610
msgid "An action, e.g. 'update-system' is required"
msgstr "En handling, f.eks. \"update-system\" kræves"
#. TRANSLATORS: The user specified an invalid action
-#: ../client/pk-console.c:1601
+#: ../client/pk-console.c:1617
msgid "A correct role is required"
msgstr "En korrekt rolle kræves"
#. TRANSLATORS: The user did not provide a package name
#. TRANSLATORS: This is when the user fails to supply the package name
-#: ../client/pk-console.c:1611 ../client/pk-console.c:1626
-#: ../client/pk-console.c:1635 ../client/pk-console.c:1655
-#: ../client/pk-console.c:1664 ../client/pk-generate-pack.c:316
+#: ../client/pk-console.c:1627 ../client/pk-console.c:1642
+#: ../client/pk-console.c:1651 ../client/pk-console.c:1671
+#: ../client/pk-console.c:1680 ../client/pk-generate-pack.c:316
msgid "A package name is required"
msgstr "Et pakkenavn kræves"
#. TRANSLATORS: each package "provides" certain things, e.g. mime(gstreamer-decoder-mp3), the user didn't specify it
-#: ../client/pk-console.c:1644
+#: ../client/pk-console.c:1660
msgid "A package provide string is required"
msgstr "En pakke udbydningsstreng kræves"
#. TRANSLATORS: The user tried to use an unsupported option on the command line
-#: ../client/pk-console.c:1724
+#: ../client/pk-console.c:1740
#, c-format
msgid "Option '%s' is not supported"
msgstr "Indstilling \"%s\" er ikke understøttet"
#. TRANSLATORS: Generic failure of what they asked to do
-#: ../client/pk-console.c:1734
+#: ../client/pk-console.c:1750
msgid "Command failed"
msgstr "Kommando fejlede"
@@ -543,7 +553,8 @@ msgstr "Angiv filnavnet på afhængigheder der skal ekskluderes"
#. TRANSLATORS: the output location
#: ../client/pk-generate-pack.c:258
msgid "The output file or directory (the current directory is used if omitted)"
-msgstr "Outputfilen eller -mappen (den nuværende mappe bliver brugt hvis undladt)"
+msgstr ""
+"Outputfilen eller -mappen (den nuværende mappe bliver brugt hvis undladt)"
#. TRANSLATORS: put a list of packages in the pack
#: ../client/pk-generate-pack.c:261
@@ -643,12 +654,12 @@ msgstr "Servicepakke oprettet \"%s\""
msgid "Failed to create '%s': %s"
msgstr "Kunne ikke oprette \"%s\": %s"
-#: ../client/pk-monitor.c:256
+#: ../client/pk-monitor.c:286
msgid "Failed to get daemon state"
msgstr "Kunne ikke hente status for dæmon"
#. TRANSLATORS: this is a program that monitors PackageKit
-#: ../client/pk-monitor.c:342
+#: ../client/pk-monitor.c:372
msgid "PackageKit Monitor"
msgstr "PackageKit overvåger"
@@ -965,7 +976,7 @@ msgstr "Installerer ikke pakker i simuleringstilstand"
#. TRANSLATORS: we are now installing the debuginfo packages we found earlier
#. TRANSLATORS: transaction state, installing packages
#: ../contrib/debuginfo-install/pk-debuginfo-install.c:862
-#: ../lib/packagekit-glib2/pk-console-shared.c:283
+#: ../lib/packagekit-glib2/pk-console-shared.c:289
#, c-format
msgid "Installing packages"
msgstr "Installerer pakker"
@@ -1096,464 +1107,464 @@ msgstr "PackageKit pakkeliste"
msgid "PackageKit Service Pack"
msgstr "PackageKit-servicepakke"
-#: ../lib/packagekit-glib2/pk-console-shared.c:59
+#: ../lib/packagekit-glib2/pk-console-shared.c:65
#, c-format
msgid "Please enter a number from 1 to %i: "
msgstr "Indtast et nummer fra 1 til %i: "
#. TRANSLATORS: more than one package could be found that matched, to follow is a list of possible packages
-#: ../lib/packagekit-glib2/pk-console-shared.c:185
+#: ../lib/packagekit-glib2/pk-console-shared.c:191
msgid "More than one package matches:"
msgstr "Mere end én pakke passede:"
#. TRANSLATORS: This finds out which package in the list to use
-#: ../lib/packagekit-glib2/pk-console-shared.c:196
+#: ../lib/packagekit-glib2/pk-console-shared.c:202
msgid "Please choose the correct package: "
msgstr "Vælg venligst den rigtige pakke: "
#. TRANSLATORS: This is when the transaction status is not known
-#: ../lib/packagekit-glib2/pk-console-shared.c:251
+#: ../lib/packagekit-glib2/pk-console-shared.c:257
msgid "Unknown state"
msgstr "Ukendt status"
#. TRANSLATORS: transaction state, the daemon is in the process of starting
-#: ../lib/packagekit-glib2/pk-console-shared.c:255
+#: ../lib/packagekit-glib2/pk-console-shared.c:261
msgid "Starting"
msgstr "Starter"
#. TRANSLATORS: transaction state, the transaction is waiting for another to complete
-#: ../lib/packagekit-glib2/pk-console-shared.c:259
+#: ../lib/packagekit-glib2/pk-console-shared.c:265
msgid "Waiting in queue"
msgstr "Venter i kø"
#. TRANSLATORS: transaction state, just started
-#: ../lib/packagekit-glib2/pk-console-shared.c:263
+#: ../lib/packagekit-glib2/pk-console-shared.c:269
msgid "Running"
msgstr "Kører"
#. TRANSLATORS: transaction state, is querying data
-#: ../lib/packagekit-glib2/pk-console-shared.c:267
+#: ../lib/packagekit-glib2/pk-console-shared.c:273
msgid "Querying"
msgstr "Forespørger"
#. TRANSLATORS: transaction state, getting data from a server
-#: ../lib/packagekit-glib2/pk-console-shared.c:271
+#: ../lib/packagekit-glib2/pk-console-shared.c:277
msgid "Getting information"
msgstr "Henter information"
#. TRANSLATORS: transaction state, removing packages
-#: ../lib/packagekit-glib2/pk-console-shared.c:275
+#: ../lib/packagekit-glib2/pk-console-shared.c:281
msgid "Removing packages"
msgstr "Fjerner pakker"
#. TRANSLATORS: transaction state, downloading package files
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:279
-#: ../lib/packagekit-glib2/pk-console-shared.c:657
+#: ../lib/packagekit-glib2/pk-console-shared.c:285
+#: ../lib/packagekit-glib2/pk-console-shared.c:663
msgid "Downloading packages"
msgstr "Henter pakker"
#. TRANSLATORS: transaction state, refreshing internal lists
-#: ../lib/packagekit-glib2/pk-console-shared.c:287
+#: ../lib/packagekit-glib2/pk-console-shared.c:293
msgid "Refreshing software list"
msgstr "Genopfrisker liste over pakkearkiver"
#. TRANSLATORS: transaction state, installing updates
-#: ../lib/packagekit-glib2/pk-console-shared.c:291
+#: ../lib/packagekit-glib2/pk-console-shared.c:297
msgid "Installing updates"
msgstr "Installerer opdateringer"
#. TRANSLATORS: transaction state, removing old packages, and cleaning config files
-#: ../lib/packagekit-glib2/pk-console-shared.c:295
+#: ../lib/packagekit-glib2/pk-console-shared.c:301
msgid "Cleaning up packages"
msgstr "Rydder op i pakker"
#. TRANSLATORS: transaction state, obsoleting old packages
-#: ../lib/packagekit-glib2/pk-console-shared.c:299
+#: ../lib/packagekit-glib2/pk-console-shared.c:305
msgid "Obsoleting packages"
msgstr "Overflødigører pakker"
#. TRANSLATORS: transaction state, checking the transaction before we do it
-#: ../lib/packagekit-glib2/pk-console-shared.c:303
+#: ../lib/packagekit-glib2/pk-console-shared.c:309
msgid "Resolving dependencies"
msgstr "Løser afhængigheder"
#. TRANSLATORS: transaction state, checking if we have all the security keys for the operation
-#: ../lib/packagekit-glib2/pk-console-shared.c:307
+#: ../lib/packagekit-glib2/pk-console-shared.c:313
msgid "Checking signatures"
msgstr "Kontrollerer signaturer"
#. TRANSLATORS: transaction state, when we return to a previous system state
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:311
-#: ../lib/packagekit-glib2/pk-console-shared.c:617
+#: ../lib/packagekit-glib2/pk-console-shared.c:317
+#: ../lib/packagekit-glib2/pk-console-shared.c:623
msgid "Rolling back"
msgstr "Ruller tilbage"
#. TRANSLATORS: transaction state, when we're doing a test transaction
-#: ../lib/packagekit-glib2/pk-console-shared.c:315
+#: ../lib/packagekit-glib2/pk-console-shared.c:321
msgid "Testing changes"
msgstr "Tester ændringer"
#. TRANSLATORS: transaction state, when we're writing to the system package database
-#: ../lib/packagekit-glib2/pk-console-shared.c:319
+#: ../lib/packagekit-glib2/pk-console-shared.c:325
msgid "Committing changes"
msgstr "Indsender ændringer"
#. TRANSLATORS: transaction state, requesting data from a server
-#: ../lib/packagekit-glib2/pk-console-shared.c:323
+#: ../lib/packagekit-glib2/pk-console-shared.c:329
msgid "Requesting data"
msgstr "Forespørger data"
#. TRANSLATORS: transaction state, all done!
-#: ../lib/packagekit-glib2/pk-console-shared.c:327
+#: ../lib/packagekit-glib2/pk-console-shared.c:333
msgid "Finished"
msgstr "Afsluttet"
#. TRANSLATORS: transaction state, in the process of cancelling
-#: ../lib/packagekit-glib2/pk-console-shared.c:331
+#: ../lib/packagekit-glib2/pk-console-shared.c:337
msgid "Cancelling"
msgstr "Annullerer"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:335
+#: ../lib/packagekit-glib2/pk-console-shared.c:341
msgid "Downloading repository information"
msgstr "Henter information om pakkearkiv"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:339
+#: ../lib/packagekit-glib2/pk-console-shared.c:345
msgid "Downloading list of packages"
msgstr "Henter liste over pakker"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:343
+#: ../lib/packagekit-glib2/pk-console-shared.c:349
msgid "Downloading file lists"
msgstr "Henter fillister"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:347
+#: ../lib/packagekit-glib2/pk-console-shared.c:353
msgid "Downloading lists of changes"
msgstr "Henter liste over ændringer"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:351
+#: ../lib/packagekit-glib2/pk-console-shared.c:357
msgid "Downloading groups"
msgstr "Henter grupper"
#. TRANSLATORS: transaction state, downloading metadata
-#: ../lib/packagekit-glib2/pk-console-shared.c:355
+#: ../lib/packagekit-glib2/pk-console-shared.c:361
msgid "Downloading update information"
msgstr "Henter opdateringsinformation"
#. TRANSLATORS: transaction state, repackaging delta files
-#: ../lib/packagekit-glib2/pk-console-shared.c:359
+#: ../lib/packagekit-glib2/pk-console-shared.c:365
msgid "Repackaging files"
msgstr "Genpakker filer"
#. TRANSLATORS: transaction state, loading databases
-#: ../lib/packagekit-glib2/pk-console-shared.c:363
+#: ../lib/packagekit-glib2/pk-console-shared.c:369
msgid "Loading cache"
msgstr "Indlæser cache"
#. TRANSLATORS: transaction state, scanning for running processes
-#: ../lib/packagekit-glib2/pk-console-shared.c:367
+#: ../lib/packagekit-glib2/pk-console-shared.c:373
msgid "Scanning applications"
msgstr "Skanner programmer"
#. TRANSLATORS: transaction state, generating a list of packages installed on the system
-#: ../lib/packagekit-glib2/pk-console-shared.c:371
+#: ../lib/packagekit-glib2/pk-console-shared.c:377
msgid "Generating package lists"
msgstr "Genererer pakkelister"
#. TRANSLATORS: transaction state, when we're waiting for the native tools to exit
-#: ../lib/packagekit-glib2/pk-console-shared.c:375
+#: ../lib/packagekit-glib2/pk-console-shared.c:381
msgid "Waiting for package manager lock"
msgstr "Venter på at pakkehåndteringen låser"
#. TRANSLATORS: transaction state, waiting for user to type in a password
-#: ../lib/packagekit-glib2/pk-console-shared.c:379
+#: ../lib/packagekit-glib2/pk-console-shared.c:385
msgid "Waiting for authentication"
msgstr "Venter på godkendelse"
#. TRANSLATORS: transaction state, we are updating the list of processes
-#: ../lib/packagekit-glib2/pk-console-shared.c:383
+#: ../lib/packagekit-glib2/pk-console-shared.c:389
msgid "Updating running applications"
msgstr "Opdaterer kørende programmer"
#. TRANSLATORS: transaction state, we are checking executable files currently in use
-#: ../lib/packagekit-glib2/pk-console-shared.c:387
+#: ../lib/packagekit-glib2/pk-console-shared.c:393
msgid "Checking applications in use"
msgstr "Kontrollerer programmer som er i brug"
#. TRANSLATORS: transaction state, we are checking for libraries currently in use
-#: ../lib/packagekit-glib2/pk-console-shared.c:391
+#: ../lib/packagekit-glib2/pk-console-shared.c:397
msgid "Checking libraries in use"
msgstr "Kontrollerer biblioteker som er i brug"
#. TRANSLATORS: transaction state, we are copying package files before or after the transaction
-#: ../lib/packagekit-glib2/pk-console-shared.c:395
+#: ../lib/packagekit-glib2/pk-console-shared.c:401
msgid "Copying files"
msgstr "Kopierer filer"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:413
+#: ../lib/packagekit-glib2/pk-console-shared.c:419
msgid "Trivial"
msgstr "Triviel"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:417
+#: ../lib/packagekit-glib2/pk-console-shared.c:423
msgid "Normal"
msgstr "Normal"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:421
+#: ../lib/packagekit-glib2/pk-console-shared.c:427
msgid "Important"
msgstr "Vigtig"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:425
+#: ../lib/packagekit-glib2/pk-console-shared.c:431
msgid "Security"
msgstr "Sikkerhed"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:429
+#: ../lib/packagekit-glib2/pk-console-shared.c:435
msgid "Bug fix "
msgstr "Fejlrettelse "
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:433
+#: ../lib/packagekit-glib2/pk-console-shared.c:439
msgid "Enhancement"
msgstr "Forbedring"
#. TRANSLATORS: The type of update
-#: ../lib/packagekit-glib2/pk-console-shared.c:437
+#: ../lib/packagekit-glib2/pk-console-shared.c:443
msgid "Blocked"
msgstr "Blokeret"
#. TRANSLATORS: The state of a package
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:442
-#: ../lib/packagekit-glib2/pk-console-shared.c:515
+#: ../lib/packagekit-glib2/pk-console-shared.c:448
+#: ../lib/packagekit-glib2/pk-console-shared.c:521
msgid "Installed"
msgstr "Installeret"
#. TRANSLATORS: The state of a package, i.e. not installed
-#: ../lib/packagekit-glib2/pk-console-shared.c:447
+#: ../lib/packagekit-glib2/pk-console-shared.c:453
msgid "Available"
msgstr "Tilgængelig"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:465
+#: ../lib/packagekit-glib2/pk-console-shared.c:471
msgid "Downloading"
msgstr "Hentning"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:469
+#: ../lib/packagekit-glib2/pk-console-shared.c:475
msgid "Updating"
msgstr "Opdaterer"
#. TRANSLATORS: The action of the package, in present tense
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:473
-#: ../lib/packagekit-glib2/pk-console-shared.c:593
+#: ../lib/packagekit-glib2/pk-console-shared.c:479
+#: ../lib/packagekit-glib2/pk-console-shared.c:599
msgid "Installing"
msgstr "Installerer"
#. TRANSLATORS: The action of the package, in present tense
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:477
-#: ../lib/packagekit-glib2/pk-console-shared.c:589
+#: ../lib/packagekit-glib2/pk-console-shared.c:483
+#: ../lib/packagekit-glib2/pk-console-shared.c:595
msgid "Removing"
msgstr "Fjerner"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:481
+#: ../lib/packagekit-glib2/pk-console-shared.c:487
msgid "Cleaning up"
msgstr "Rydder op"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:485
+#: ../lib/packagekit-glib2/pk-console-shared.c:491
msgid "Obsoleting"
msgstr "Forælder"
#. TRANSLATORS: The action of the package, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:489
+#: ../lib/packagekit-glib2/pk-console-shared.c:495
msgid "Reinstalling"
msgstr "Geninstallerer"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:507
+#: ../lib/packagekit-glib2/pk-console-shared.c:513
msgid "Downloaded"
msgstr "Hentede"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:519
+#: ../lib/packagekit-glib2/pk-console-shared.c:525
msgid "Removed"
msgstr "Fjernede"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:523
+#: ../lib/packagekit-glib2/pk-console-shared.c:529
msgid "Cleaned up"
msgstr "Ryddede op"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:527
+#: ../lib/packagekit-glib2/pk-console-shared.c:533
msgid "Obsoleted"
msgstr "Forældede"
#. TRANSLATORS: The action of the package, in past tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:531
+#: ../lib/packagekit-glib2/pk-console-shared.c:537
msgid "Reinstalled"
msgstr "Geninstallerede"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:549
+#: ../lib/packagekit-glib2/pk-console-shared.c:555
msgid "Unknown role type"
msgstr "Ukendt rolletype"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:553
+#: ../lib/packagekit-glib2/pk-console-shared.c:559
msgid "Getting dependencies"
msgstr "Henter afhængigheder"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:557
+#: ../lib/packagekit-glib2/pk-console-shared.c:563
msgid "Getting update details"
msgstr "Henter opdateringsdetaljer"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:561
+#: ../lib/packagekit-glib2/pk-console-shared.c:567
msgid "Getting details"
msgstr "Henter detaljer"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:565
+#: ../lib/packagekit-glib2/pk-console-shared.c:571
msgid "Getting requires"
msgstr "Henter afhængigheder"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:569
+#: ../lib/packagekit-glib2/pk-console-shared.c:575
msgid "Getting updates"
msgstr "Henter opdateringer"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:573
+#: ../lib/packagekit-glib2/pk-console-shared.c:579
msgid "Searching by details"
msgstr "Søger efter detaljer"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:577
+#: ../lib/packagekit-glib2/pk-console-shared.c:583
msgid "Searching by file"
msgstr "Søger efter fil"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:581
+#: ../lib/packagekit-glib2/pk-console-shared.c:587
msgid "Searching groups"
msgstr "Søger efter grupper"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:585
+#: ../lib/packagekit-glib2/pk-console-shared.c:591
msgid "Searching by name"
msgstr "Søger efter navn"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:597
+#: ../lib/packagekit-glib2/pk-console-shared.c:603
msgid "Installing files"
msgstr "Installerer filer"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:601
+#: ../lib/packagekit-glib2/pk-console-shared.c:607
msgid "Refreshing cache"
msgstr "Genopfrisker cache"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:605
+#: ../lib/packagekit-glib2/pk-console-shared.c:611
msgid "Updating packages"
msgstr "Opdaterer pakker"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:609
+#: ../lib/packagekit-glib2/pk-console-shared.c:615
msgid "Updating system"
msgstr "Opdaterer system"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:613
+#: ../lib/packagekit-glib2/pk-console-shared.c:619
msgid "Canceling"
msgstr "Annullerer"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:621
+#: ../lib/packagekit-glib2/pk-console-shared.c:627
msgid "Getting repositories"
msgstr "Henter pakkearkiver"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:625
+#: ../lib/packagekit-glib2/pk-console-shared.c:631
msgid "Enabling repository"
msgstr "Aktiverer pakkearkiv"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:629
+#: ../lib/packagekit-glib2/pk-console-shared.c:635
msgid "Setting data"
msgstr "Indstiller data"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:633
+#: ../lib/packagekit-glib2/pk-console-shared.c:639
msgid "Resolving"
msgstr "Løser"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:637
+#: ../lib/packagekit-glib2/pk-console-shared.c:643
msgid "Getting file list"
msgstr "Henter filliste"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:641
+#: ../lib/packagekit-glib2/pk-console-shared.c:647
msgid "Getting provides"
msgstr "Henter udbydere"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:645
+#: ../lib/packagekit-glib2/pk-console-shared.c:651
msgid "Installing signature"
msgstr "Installerer signatur"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:649
+#: ../lib/packagekit-glib2/pk-console-shared.c:655
msgid "Getting packages"
msgstr "Henter pakker"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:653
+#: ../lib/packagekit-glib2/pk-console-shared.c:659
msgid "Accepting EULA"
msgstr "Accepterer EULA"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:661
+#: ../lib/packagekit-glib2/pk-console-shared.c:667
msgid "Getting upgrades"
msgstr "Henter opgraderinger"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:665
+#: ../lib/packagekit-glib2/pk-console-shared.c:671
msgid "Getting categories"
msgstr "Henter kategorier"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:669
+#: ../lib/packagekit-glib2/pk-console-shared.c:675
msgid "Getting transactions"
msgstr "Henter overførsler"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:673
-#: ../lib/packagekit-glib2/pk-console-shared.c:677
+#: ../lib/packagekit-glib2/pk-console-shared.c:679
+#: ../lib/packagekit-glib2/pk-console-shared.c:683
msgid "Simulating install"
msgstr "Simulerer installation"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:681
+#: ../lib/packagekit-glib2/pk-console-shared.c:687
msgid "Simulating remove"
msgstr "Simulerer fjernelse"
#. TRANSLATORS: The role of the transaction, in present tense
-#: ../lib/packagekit-glib2/pk-console-shared.c:685
+#: ../lib/packagekit-glib2/pk-console-shared.c:691
msgid "Simulating update"
msgstr "Simulerer opdatering"
@@ -1724,44 +1735,50 @@ msgstr "Godkendelse kræves for at ændre softewarekildeparametre"
#: ../policy/org.freedesktop.packagekit.policy.in.h:11
msgid ""
+"Authentication is required to change the location used to decompress packages"
+msgstr ""
+"Godkendelse kræves for at ændre placeringen, som er brugt til at afkomprimere pakker"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:12
+msgid ""
"Authentication is required to consider a key used for signing packages as "
"trusted"
msgstr ""
"Godkendelse kræves for at overveje en nøgle brugt til signering af pakker "
"som pålidelig"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:12
+#: ../policy/org.freedesktop.packagekit.policy.in.h:13
msgid "Authentication is required to install a signed package"
msgstr "Godkendelse kræves for at installere en signeret pakke"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:13
+#: ../policy/org.freedesktop.packagekit.policy.in.h:14
msgid "Authentication is required to install an untrusted package"
msgstr "Godkendelse kræves for at installere en upålidelig pakke"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:14
+#: ../policy/org.freedesktop.packagekit.policy.in.h:15
msgid "Authentication is required to refresh the system sources"
msgstr "Godkendelse kræves for at opdatere systemkilderne"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:15
+#: ../policy/org.freedesktop.packagekit.policy.in.h:16
msgid "Authentication is required to reload the device with a new driver"
msgstr "Godkendelse kræves for at genindlæse enheden med en ny driver"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:16
+#: ../policy/org.freedesktop.packagekit.policy.in.h:17
msgid "Authentication is required to remove packages"
msgstr "Godkendelse kræves for at fjerne pakker"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:17
+#: ../policy/org.freedesktop.packagekit.policy.in.h:18
msgid "Authentication is required to rollback a transaction"
msgstr "Godkendelse kræves for at rulle en transaktion tilbage"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:18
+#: ../policy/org.freedesktop.packagekit.policy.in.h:19
msgid ""
"Authentication is required to set the network proxy used for downloading "
"packages"
msgstr ""
"Godkendelse kræves for at sætte netværksproxyen brugt til hentning af pakker"
-#: ../policy/org.freedesktop.packagekit.policy.in.h:19
+#: ../policy/org.freedesktop.packagekit.policy.in.h:20
msgid "Authentication is required to update packages"
msgstr "Godkendelse kræves for at opdatere pakker"
@@ -1770,16 +1787,26 @@ msgstr "Godkendelse kræves for at opdatere pakker"
#. authentication, but a different user id needs the admin password
#. to cancel another users task.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:25
+#: ../policy/org.freedesktop.packagekit.policy.in.h:26
msgid "Cancel foreign task"
msgstr "Annullér fremmed opgave"
#. SECURITY:
+#. - This is used when users want to install to a different prefix, for
+#. instance to a LTSP image or a virtual machine.
+#. - This could be used to overwrite files not owned by the user using
+#. a carefully created package file.
+#.
+#: ../policy/org.freedesktop.packagekit.policy.in.h:33
+msgid "Change location that packages are installed"
+msgstr "Ãndr placeringen som pakkerne er installeret pÃ¥"
+
+#. SECURITY:
#. - Normal users require admin authentication to enable or disable
#. software sources as this can be used to enable new updates or
#. install different versions of software.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:31
+#: ../policy/org.freedesktop.packagekit.policy.in.h:39
msgid "Change software source parameters"
msgstr "Ãndr softwarekildeparametre"
@@ -1789,7 +1816,7 @@ msgstr "Ãndr softwarekildeparametre"
#. - Paranoid users (or parents!) can change this to 'auth_admin' or
#. 'auth_admin_keep'.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:38
+#: ../policy/org.freedesktop.packagekit.policy.in.h:46
msgid "Install signed package"
msgstr "Installér signeret pakke"
@@ -1799,7 +1826,7 @@ msgstr "Installér signeret pakke"
#. password would be a massive security hole.
#. - This is not retained as each package should be authenticated.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:45
+#: ../policy/org.freedesktop.packagekit.policy.in.h:53
msgid "Install untrusted local file"
msgstr "Installér upålidelig lokal fil"
@@ -1807,7 +1834,7 @@ msgstr "Installér upålidelig lokal fil"
#. - Normal users do not require admin authentication to refresh the
#. cache, as this doesn't actually install or remove software.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:50
+#: ../policy/org.freedesktop.packagekit.policy.in.h:58
msgid "Refresh system sources"
msgstr "Opdatér systemkilder"
@@ -1818,7 +1845,7 @@ msgstr "Opdatér systemkilder"
#. try to rebind drivers in use, for instance security authentication
#. devices.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:58
+#: ../policy/org.freedesktop.packagekit.policy.in.h:66
msgid "Reload a device"
msgstr "Genindlæs en enhed"
@@ -1831,7 +1858,7 @@ msgstr "Genindlæs en enhed"
#. be removed. If this is not possible, change this authentication to
#. 'auth_admin'.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:68
+#: ../policy/org.freedesktop.packagekit.policy.in.h:76
msgid "Remove package"
msgstr "Fjern pakke"
@@ -1840,7 +1867,7 @@ msgstr "Fjern pakke"
#. as this will change a large number of packages, and could expose the
#. system to previously patched security vulnerabilities.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:74
+#: ../policy/org.freedesktop.packagekit.policy.in.h:82
msgid "Rollback to a previous transaction"
msgstr "Rul tilbage til en tidligere overførsel"
@@ -1848,7 +1875,7 @@ msgstr "Rul tilbage til en tidligere overførsel"
#. - Normal users do not require admin authentication to set the proxy
#. used for downloading packages.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:79
+#: ../policy/org.freedesktop.packagekit.policy.in.h:87
msgid "Set network proxy"
msgstr "Sæt netværksproxy"
@@ -1858,7 +1885,7 @@ msgstr "Sæt netværksproxy"
#. without a secure authentication.
#. - This is not kept as each package should be authenticated.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:86
+#: ../policy/org.freedesktop.packagekit.policy.in.h:94
msgid "Trust a key used for signing packages"
msgstr "Betro en nøgle brugt til signering af pakker"
@@ -1869,7 +1896,7 @@ msgstr "Betro en nøgle brugt til signering af pakker"
#. - Changing this to anything other than 'yes' will break unattended
#. updates.
#.
-#: ../policy/org.freedesktop.packagekit.policy.in.h:94
+#: ../policy/org.freedesktop.packagekit.policy.in.h:102
msgid "Update packages"
msgstr "Opdatér pakker"
commit 9aa9a3711d52712af4665807a24cf795e4b3d61e
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 22:19:13 2010 +0100
yum: Update backend to libzif git master
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index c6e60d9..b56316b 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-//#include <config.h>
+#include <config.h>
#include <gio/gio.h>
#include <pk-backend.h>
#include <pk-backend-spawn.h>
@@ -46,7 +46,7 @@ typedef struct {
ZifStoreLocal *store_local;
ZifRepos *repos;
ZifGroups *groups;
- ZifCompletion *completion;
+ ZifState *state;
ZifLock *lock;
#endif
GTimer *timer;
@@ -92,13 +92,13 @@ backend_yum_repos_changed_cb (GFileMonitor *monitor_, GFile *file, GFile *other_
#ifdef HAVE_ZIF
static void
-backend_completion_percentage_changed_cb (ZifCompletion *completion, guint percentage, PkBackend *backend)
+backend_state_percentage_changed_cb (ZifState *state, guint percentage, PkBackend *backend)
{
pk_backend_set_percentage (backend, percentage);
}
static void
-backend_completion_subpercentage_changed_cb (ZifCompletion *completion, guint subpercentage, PkBackend *backend)
+backend_state_subpercentage_changed_cb (ZifState *state, guint subpercentage, PkBackend *backend)
{
pk_backend_set_sub_percentage (backend, subpercentage);
}
@@ -386,7 +386,7 @@ backend_filter_package_array (GPtrArray *array, PkBitfield filters)
* backend_emit_package_array:
**/
static gboolean
-backend_emit_package_array (PkBackend *backend, GPtrArray *array, ZifCompletion *completion)
+backend_emit_package_array (PkBackend *backend, GPtrArray *array, ZifState *state)
{
guint i;
gboolean installed;
@@ -404,8 +404,8 @@ backend_emit_package_array (PkBackend *backend, GPtrArray *array, ZifCompletion
package_id = zif_package_get_package_id (package);
/* FIXME: should be okay as shouldn't be doing any action */
- zif_completion_reset (completion);
- summary = zif_package_get_summary (package, priv->cancellable, completion, NULL);
+ zif_state_reset (state);
+ summary = zif_package_get_summary (package, state, NULL);
/* if we set a hint, use that, otherwise just get the installed status correct */
info_hint = (const gchar *)g_object_get_data (G_OBJECT(package), "kind");
@@ -424,7 +424,7 @@ backend_emit_package_array (PkBackend *backend, GPtrArray *array, ZifCompletion
* backend_error_handler_cb:
*/
static gboolean
-backend_error_handler_cb (GPtrArray *store_array, const GError *error, PkBackend *backend)
+backend_error_handler_cb (const GError *error, PkBackend *backend)
{
/* emit a warning, this isn't fatal */
pk_backend_message (backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "%s", error->message);
@@ -435,7 +435,7 @@ backend_error_handler_cb (GPtrArray *store_array, const GError *error, PkBackend
* backend_get_default_store_array_for_filter:
*/
static GPtrArray *
-backend_get_default_store_array_for_filter (PkBackend *backend, PkBitfield filters, ZifCompletion *completion, GError **error)
+backend_get_default_store_array_for_filter (PkBackend *backend, PkBitfield filters, ZifState *state, GError **error)
{
GPtrArray *store_array;
ZifStore *store;
@@ -453,7 +453,7 @@ backend_get_default_store_array_for_filter (PkBackend *backend, PkBitfield filte
/* add remote packages to the store_array */
if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
- array = zif_repos_get_stores_enabled (priv->repos, priv->cancellable, completion, &error_local);
+ array = zif_repos_get_stores_enabled (priv->repos, state, &error_local);
if (array == NULL) {
g_set_error (error, 1, 0, "failed to get enabled stores: %s", error_local->message);
g_error_free (error_local);
@@ -482,7 +482,7 @@ backend_search_thread (PkBackend *backend)
GPtrArray *result;
PkBitfield filters;
PkRoleEnum role;
- ZifCompletion *completion_local;
+ ZifState *state_local;
GError *error = NULL;
gchar **search;
filters = (PkBitfield) pk_backend_get_uint (backend, "filters");
@@ -508,13 +508,13 @@ backend_search_thread (PkBackend *backend)
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, 0);
- /* setup completion */
- zif_completion_reset (priv->completion);
- zif_completion_set_number_steps (priv->completion, 4);
+ /* setup state */
+ zif_state_reset (priv->state);
+ zif_state_set_number_steps (priv->state, 4);
/* get default store_array */
- completion_local = zif_completion_get_child (priv->completion);
- store_array = backend_get_default_store_array_for_filter (backend, filters, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ store_array = backend_get_default_store_array_for_filter (backend, filters, state_local, &error);
if (store_array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to get stores: %s", error->message);
g_error_free (error);
@@ -522,13 +522,18 @@ backend_search_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+ zif_state_set_error_handler (priv->state, (ZifStateErrorHandlerCb) backend_error_handler_cb, backend);
/* do get action */
if (role == PK_ROLE_ENUM_GET_PACKAGES) {
- completion_local = zif_completion_get_child (priv->completion);
- array = zif_store_array_get_packages (store_array, (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ array = zif_store_array_get_packages (store_array, state_local, &error);
if (array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to get packages: %s", error->message);
g_error_free (error);
@@ -545,31 +550,19 @@ backend_search_thread (PkBackend *backend)
array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
/* do OR search */
- completion_local = zif_completion_get_child (priv->completion);
+ state_local = zif_state_get_child (priv->state);
if (role == PK_ROLE_ENUM_SEARCH_NAME) {
- array = zif_store_array_search_name (store_array, search,
- (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ array = zif_store_array_search_name (store_array, search, state_local, &error);
} else if (role == PK_ROLE_ENUM_SEARCH_DETAILS) {
- array = zif_store_array_search_details (store_array, search,
- (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ array = zif_store_array_search_details (store_array, search, state_local, &error);
} else if (role == PK_ROLE_ENUM_SEARCH_GROUP) {
- array = zif_store_array_search_category (store_array, search,
- (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ array = zif_store_array_search_category (store_array, search, state_local, &error);
} else if (role == PK_ROLE_ENUM_SEARCH_FILE) {
- array = zif_store_array_search_file (store_array, search,
- (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ array = zif_store_array_search_file (store_array, search, state_local, &error);
} else if (role == PK_ROLE_ENUM_RESOLVE) {
- array = zif_store_array_resolve (store_array, search,
- (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ array = zif_store_array_resolve (store_array, search, state_local, &error);
} else if (role == PK_ROLE_ENUM_WHAT_PROVIDES) {
- array = zif_store_array_what_provides (store_array, search,
- (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ array = zif_store_array_what_provides (store_array, search, state_local, &error);
}
if (array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to search: %s", error->message);
@@ -584,23 +577,38 @@ backend_search_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* filter */
result = backend_filter_package_array (array, filters);
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* done */
pk_backend_set_percentage (backend, 100);
/* emit */
- completion_local = zif_completion_get_child (priv->completion);
- backend_emit_package_array (backend, result, completion_local);
+ state_local = zif_state_get_child (priv->state);
+ backend_emit_package_array (backend, result, state_local);
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
out:
if (store_array != NULL)
g_ptr_array_unref (store_array);
@@ -723,10 +731,10 @@ backend_initialize (PkBackend *backend)
/* TODO: hook up errors */
priv->cancellable = g_cancellable_new ();
- /* ZifCompletion */
- priv->completion = zif_completion_new ();
- g_signal_connect (priv->completion, "percentage-changed", G_CALLBACK (backend_completion_percentage_changed_cb), backend);
- g_signal_connect (priv->completion, "subpercentage-changed", G_CALLBACK (backend_completion_subpercentage_changed_cb), backend);
+ /* ZifState */
+ priv->state = zif_state_new ();
+ g_signal_connect (priv->state, "percentage-changed", G_CALLBACK (backend_state_percentage_changed_cb), backend);
+ g_signal_connect (priv->state, "subpercentage-changed", G_CALLBACK (backend_state_subpercentage_changed_cb), backend);
/* ZifConfig */
priv->config = zif_config_new ();
@@ -802,8 +810,8 @@ backend_destroy (PkBackend *backend)
g_object_unref (priv->config);
if (priv->download != NULL)
g_object_unref (priv->download);
- if (priv->completion != NULL)
- g_object_unref (priv->completion);
+ if (priv->state != NULL)
+ g_object_unref (priv->state);
if (priv->repos != NULL)
g_object_unref (priv->repos);
if (priv->groups != NULL)
@@ -828,6 +836,9 @@ backend_get_groups (PkBackend *backend)
{
#ifdef HAVE_ZIF
GError *error = NULL;
+ GPtrArray *array = NULL;
+ guint i;
+ const gchar *group_str;
#endif
PkBitfield groups = 0;
@@ -862,12 +873,18 @@ backend_get_groups (PkBackend *backend)
#ifdef HAVE_ZIF
/* get the dynamic group list */
- groups = zif_groups_get_groups (priv->groups, &error);
- if (groups == 0) {
+ array = zif_groups_get_groups (priv->groups, &error);
+ if (array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_GROUP_LIST_INVALID, "failed to get the list of groups: %s", error->message);
g_error_free (error);
goto out;
}
+
+ /* convert to a bitfield */
+ for (i=0; i<array->len; i++) {
+ group_str = g_ptr_array_index (array, i);
+ pk_bitfield_add (groups, pk_group_enum_from_string (group_str));
+ }
#endif
/* add the virtual groups */
@@ -974,7 +991,7 @@ backend_download_packages_thread (PkBackend *backend)
const gchar *directory = pk_backend_get_string (backend, "directory");
GPtrArray *store_array = NULL;
ZifPackage *package;
- ZifCompletion *completion_local;
+ ZifState *state_local;
GPtrArray *packages = NULL;
const gchar *id;
guint i;
@@ -1002,15 +1019,15 @@ backend_download_packages_thread (PkBackend *backend)
/* set the network state */
backend_setup_network (backend);
- /* setup completion */
- zif_completion_reset (priv->completion);
+ /* setup state */
+ zif_state_reset (priv->state);
len = g_strv_length (package_ids);
- zif_completion_set_number_steps (priv->completion, (len * 4) + 1);
+ zif_state_set_number_steps (priv->state, (len * 4) + 1);
/* find all the packages */
packages = g_ptr_array_new ();
- completion_local = zif_completion_get_child (priv->completion);
- store_array = backend_get_default_store_array_for_filter (backend, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED), completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ store_array = backend_get_default_store_array_for_filter (backend, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED), state_local, &error);
if (store_array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to get stores: %s", error->message);
g_error_free (error);
@@ -1018,13 +1035,18 @@ backend_download_packages_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
for (i=0; package_ids[i] != NULL; i++) {
id = package_ids[i];
- completion_local = zif_completion_get_child (priv->completion);
- package = zif_store_array_find_package (store_array, id, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ package = zif_store_array_find_package (store_array, id, state_local, &error);
if (package == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "failed to find %s: %s", package_ids[i], error->message);
g_error_free (error);
@@ -1032,14 +1054,24 @@ backend_download_packages_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
g_ptr_array_add (packages, g_object_ref (package));
g_object_unref (package);
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* download list */
pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD);
@@ -1047,8 +1079,8 @@ backend_download_packages_thread (PkBackend *backend)
package = g_ptr_array_index (packages, i);
/* get filename */
- completion_local = zif_completion_get_child (priv->completion);
- filename = zif_package_get_filename (package, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ filename = zif_package_get_filename (package, state_local, &error);
if (filename == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED,
"failed to get filename for %s: %s", zif_package_get_id (package), error->message);
@@ -1057,11 +1089,16 @@ backend_download_packages_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* download */
- completion_local = zif_completion_get_child (priv->completion);
- ret = zif_package_download (package, directory, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ ret = zif_package_download (package, directory, state_local, &error);
if (!ret) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED,
"failed to download %s: %s", filename, error->message);
@@ -1077,7 +1114,12 @@ backend_download_packages_thread (PkBackend *backend)
g_free (path);
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
}
out:
backend_unlock (backend);
@@ -1135,8 +1177,8 @@ backend_get_details_thread (PkBackend *backend)
gchar **package_ids = pk_backend_get_strv (backend, "package_ids");
GPtrArray *store_array = NULL;
ZifPackage *package;
- ZifCompletion *completion_local;
- ZifCompletion *completion_loop;
+ ZifState *state_local;
+ ZifState *state_loop;
const gchar *id;
guint i;
guint len;
@@ -1144,6 +1186,7 @@ backend_get_details_thread (PkBackend *backend)
const gchar *license;
const gchar *description;
const gchar *url;
+ const gchar *group_str;
PkGroupEnum group;
guint64 size;
PkBitfield filters = PK_FILTER_ENUM_UNKNOWN;
@@ -1167,15 +1210,15 @@ backend_get_details_thread (PkBackend *backend)
len = g_strv_length (package_ids);
- /* setup completion */
- zif_completion_reset (priv->completion);
- zif_completion_set_number_steps (priv->completion, len + 1);
+ /* setup state */
+ zif_state_reset (priv->state);
+ zif_state_set_number_steps (priv->state, len + 1);
/* find all the packages */
- completion_local = zif_completion_get_child (priv->completion);
+ state_local = zif_state_get_child (priv->state);
if (backend_is_all_installed (package_ids))
pk_bitfield_add (filters, PK_FILTER_ENUM_INSTALLED);
- store_array = backend_get_default_store_array_for_filter (backend, filters, completion_local, &error);
+ store_array = backend_get_default_store_array_for_filter (backend, filters, state_local, &error);
if (store_array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to get stores: %s", error->message);
g_error_free (error);
@@ -1183,19 +1226,24 @@ backend_get_details_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
for (i=0; package_ids[i] != NULL; i++) {
id = package_ids[i];
- /* set up completion */
- completion_local = zif_completion_get_child (priv->completion);
- zif_completion_set_number_steps (completion_local, 6);
+ /* set up state */
+ state_local = zif_state_get_child (priv->state);
+ zif_state_set_number_steps (state_local, 6);
/* find package */
- completion_loop = zif_completion_get_child (completion_local);
- package = zif_store_array_find_package (store_array, id, priv->cancellable, completion_loop, &error);
+ state_loop = zif_state_get_child (state_local);
+ package = zif_store_array_find_package (store_array, id, state_loop, &error);
if (package == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "failed to find %s: %s", package_ids[i], error->message);
g_error_free (error);
@@ -1203,42 +1251,79 @@ backend_get_details_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (completion_local);
+ ret = zif_state_done (state_local, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* get license */
- completion_loop = zif_completion_get_child (completion_local);
- license = zif_package_get_license (package, priv->cancellable, completion_loop, NULL);
+ state_loop = zif_state_get_child (state_local);
+ license = zif_package_get_license (package, state_loop, NULL);
/* this section done */
- zif_completion_done (completion_local);
+ ret = zif_state_done (state_local, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* get group */
- completion_loop = zif_completion_get_child (completion_local);
- group = zif_package_get_group (package, priv->cancellable, completion_loop, NULL);
+ state_loop = zif_state_get_child (state_local);
+ group_str = zif_package_get_group (package, state_loop, &error);
+
+ /* not being in a group is non-fatal */
+ if (group_str == NULL) {
+ egg_warning ("failed to get group: %s", error->message);
+ g_clear_error (&error);
+ }
+ group = pk_group_enum_from_text (group_str);
/* this section done */
- zif_completion_done (completion_local);
+ ret = zif_state_done (state_local, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* get description */
- completion_loop = zif_completion_get_child (completion_local);
- description = zif_package_get_description (package, priv->cancellable, completion_loop, NULL);
+ state_loop = zif_state_get_child (state_local);
+ description = zif_package_get_description (package, state_loop, NULL);
/* this section done */
- zif_completion_done (completion_local);
+ ret = zif_state_done (state_local, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* get url */
- completion_loop = zif_completion_get_child (completion_local);
- url = zif_package_get_url (package, priv->cancellable, completion_loop, NULL);
+ state_loop = zif_state_get_child (state_local);
+ url = zif_package_get_url (package, state_loop, NULL);
/* this section done */
- zif_completion_done (completion_local);
+ ret = zif_state_done (state_local, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* get size */
- completion_loop = zif_completion_get_child (completion_local);
- size = zif_package_get_size (package, priv->cancellable, completion_loop, NULL);
+ state_loop = zif_state_get_child (state_local);
+ size = zif_package_get_size (package, state_loop, NULL);
/* this section done */
- zif_completion_done (completion_local);
+ ret = zif_state_done (state_local, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* emit */
pk_backend_details (backend,
@@ -1250,7 +1335,12 @@ backend_get_details_thread (PkBackend *backend)
(gulong) size);
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* free */
g_object_unref (package);
@@ -1301,11 +1391,11 @@ backend_get_distro_upgrades_thread (PkBackend *backend)
guint version;
GError *error = NULL;
GKeyFile *file = NULL;
- ZifCompletion *child;
+ ZifState *child;
/* download, then parse */
- zif_completion_reset (priv->completion);
- zif_completion_set_number_steps (priv->completion, 2);
+ zif_state_reset (priv->state);
+ zif_state_set_number_steps (priv->state, 2);
/* set proxy */
proxy = pk_backend_get_proxy_http (backend);
@@ -1318,15 +1408,20 @@ backend_get_distro_upgrades_thread (PkBackend *backend)
/* download new file */
filename = g_build_filename ("/var/cache/PackageKit", "releases.txt", NULL);
- child = zif_completion_get_child (priv->completion);
+ child = zif_state_get_child (priv->state);
pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD_UPDATEINFO);
- ret = zif_download_file (priv->download, "http://mirrors.fedoraproject.org/releases.txt", filename, NULL, child, &error);
+ ret = zif_download_file (priv->download, "http://mirrors.fedoraproject.org/releases.txt", filename, child, &error);
if (!ret) {
pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "failed to download %s: %s", filename, error->message);
g_error_free (error);
goto out;
}
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
file = g_key_file_new ();
ret = g_key_file_load_from_file (file, filename, G_KEY_FILE_NONE, &error);
@@ -1374,7 +1469,12 @@ backend_get_distro_upgrades_thread (PkBackend *backend)
pk_backend_distro_upgrade (backend, PK_DISTRO_UPGRADE_ENUM_STABLE, distro_id, groups[newest]);
/* we're done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
out:
pk_backend_finished (backend);
g_free (distro_id);
@@ -1416,7 +1516,7 @@ backend_get_files_thread (PkBackend *backend)
GPtrArray *store_array = NULL;
ZifPackage *package;
GPtrArray *files;
- ZifCompletion *completion_local;
+ ZifState *state_local;
const gchar *id;
guint i, j;
guint len;
@@ -1450,15 +1550,15 @@ backend_get_files_thread (PkBackend *backend)
len = g_strv_length (package_ids);
- /* setup completion */
- zif_completion_reset (priv->completion);
- zif_completion_set_number_steps (priv->completion, (len * 2) + 1);
+ /* setup state */
+ zif_state_reset (priv->state);
+ zif_state_set_number_steps (priv->state, (len * 2) + 1);
/* find all the packages */
- completion_local = zif_completion_get_child (priv->completion);
+ state_local = zif_state_get_child (priv->state);
if (backend_is_all_installed (package_ids))
pk_bitfield_add (filters, PK_FILTER_ENUM_INSTALLED);
- store_array = backend_get_default_store_array_for_filter (backend, filters, completion_local, &error);
+ store_array = backend_get_default_store_array_for_filter (backend, filters, state_local, &error);
if (store_array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to get stores: %s", error->message);
g_error_free (error);
@@ -1469,13 +1569,18 @@ backend_get_files_thread (PkBackend *backend)
backend_profile ("add local");
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
for (i=0; package_ids[i] != NULL; i++) {
id = package_ids[i];
- completion_local = zif_completion_get_child (priv->completion);
- package = zif_store_array_find_package (store_array, id, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ package = zif_store_array_find_package (store_array, id, state_local, &error);
if (package == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "failed to find %s: %s", package_ids[i], error->message);
g_error_free (error);
@@ -1486,11 +1591,16 @@ backend_get_files_thread (PkBackend *backend)
backend_profile ("find package");
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* get files */
- completion_local = zif_completion_get_child (priv->completion);
- files = zif_package_get_files (package, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ files = zif_package_get_files (package, state_local, &error);
if (files == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "no files for %s: %s", package_ids[i], error->message);
g_error_free (error);
@@ -1511,7 +1621,12 @@ backend_get_files_thread (PkBackend *backend)
backend_profile ("emit files");
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
g_string_free (files_str, TRUE);
g_object_unref (package);
@@ -1569,8 +1684,8 @@ backend_get_updates_thread (PkBackend *backend)
#ifdef HAVE_ZIF
PkBitfield filters = (PkBitfield) pk_backend_get_uint (backend, "filters");
GPtrArray *store_array = NULL;
- ZifCompletion *completion_local;
- ZifCompletion *completion_loop;
+ ZifState *state_local;
+ ZifState *state_loop;
GPtrArray *array = NULL;
GPtrArray *result = NULL;
GPtrArray *packages = NULL;
@@ -1579,6 +1694,7 @@ backend_get_updates_thread (PkBackend *backend)
ZifUpdate *update;
ZifPackage *package;
PkInfoEnum info;
+ ZifUpdateKind update_kind;
guint i;
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -1605,14 +1721,14 @@ backend_get_updates_thread (PkBackend *backend)
/* set the network state */
backend_setup_network (backend);
- /* setup completion */
- zif_completion_reset (priv->completion);
- zif_completion_set_number_steps (priv->completion, 5);
+ /* setup state */
+ zif_state_reset (priv->state);
+ zif_state_set_number_steps (priv->state, 5);
/* get a store_array of remote stores */
store_array = zif_store_array_new ();
- completion_local = zif_completion_get_child (priv->completion);
- ret = zif_store_array_add_remote_enabled (store_array, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ ret = zif_store_array_add_remote_enabled (store_array, state_local, &error);
if (!ret) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to add enabled stores: %s\n", error->message);
g_error_free (error);
@@ -1620,14 +1736,19 @@ backend_get_updates_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* profile */
backend_profile ("get remote stores");
/* get all the installed packages */
- completion_local = zif_completion_get_child (priv->completion);
- packages = zif_store_get_packages (ZIF_STORE (priv->store_local), NULL, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ packages = zif_store_get_packages (ZIF_STORE (priv->store_local), state_local, &error);
if (packages == NULL) {
g_print ("failed to get local store: %s", error->message);
g_error_free (error);
@@ -1636,7 +1757,12 @@ backend_get_updates_thread (PkBackend *backend)
egg_debug ("searching for updates with %i packages", packages->len);
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* profile */
backend_profile ("get installed packages");
@@ -1645,15 +1771,20 @@ backend_get_updates_thread (PkBackend *backend)
zif_package_array_filter_newest (packages);
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* profile */
backend_profile ("filter installed newest");
/* get updates */
- completion_local = zif_completion_get_child (priv->completion);
- array = zif_store_array_get_updates (store_array, packages, (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ zif_state_set_error_handler (priv->state, (ZifStateErrorHandlerCb) backend_error_handler_cb, backend);
+ array = zif_store_array_get_updates (store_array, packages, state_local, &error);
if (array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to get updates: %s\n", error->message);
g_error_free (error);
@@ -1661,28 +1792,42 @@ backend_get_updates_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* profile */
backend_profile ("get updates of packages");
- /* setup steps on updatinfo completion */
- completion_local = zif_completion_get_child (priv->completion);
+ /* setup steps on updatinfo state */
+ state_local = zif_state_get_child (priv->state);
if (array->len > 0)
- zif_completion_set_number_steps (completion_local, array->len);
+ zif_state_set_number_steps (state_local, array->len);
/* get update info */
for (i=0; i<array->len; i++) {
package = g_ptr_array_index (array, i);
- completion_loop = zif_completion_get_child (completion_local);
- update = zif_package_get_update_detail (package, priv->cancellable, completion_loop, &error);
+ state_loop = zif_state_get_child (state_local);
+
+ /* updates without updatinfo */
+ info = PK_INFO_ENUM_NORMAL;
+
+ update = zif_package_get_update_detail (package, state_loop, &error);
if (update == NULL) {
egg_debug ("failed to get updateinfo for %s", zif_package_get_id (package));
g_clear_error (&error);
- zif_completion_finished (completion_loop);
- info = PK_INFO_ENUM_NORMAL;
+ ret = zif_state_finished (state_loop, NULL);
} else {
- info = zif_update_get_kind (update);
+ update_kind = zif_update_get_kind (update);
+ if (update_kind == ZIF_UPDATE_KIND_BUGFIX)
+ info = PK_INFO_ENUM_BUGFIX;
+ else if (update_kind == ZIF_UPDATE_KIND_SECURITY)
+ info = PK_INFO_ENUM_SECURITY;
+ else if (update_kind == ZIF_UPDATE_KIND_ENHANCEMENT)
+ info = PK_INFO_ENUM_ENHANCEMENT;
g_object_unref (update);
}
@@ -1690,11 +1835,21 @@ backend_get_updates_thread (PkBackend *backend)
g_object_set_data (G_OBJECT(package), "kind", (gpointer)pk_info_enum_to_string (info));
/* this section done */
- zif_completion_done (completion_local);
+ ret = zif_state_done (state_local, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* profile */
backend_profile ("get updateinfo");
@@ -1706,8 +1861,8 @@ backend_get_updates_thread (PkBackend *backend)
pk_backend_set_percentage (backend, 100);
/* emit */
- completion_local = zif_completion_get_child (priv->completion);
- backend_emit_package_array (backend, result, completion_local);
+ state_local = zif_state_get_child (priv->state);
+ backend_emit_package_array (backend, result, state_local);
/* profile */
backend_profile ("filter and emit");
@@ -1773,7 +1928,7 @@ backend_get_update_detail_thread (PkBackend *backend)
guint j;
gboolean ret;
ZifUpdate *update;
- ZifCompletion *completion_local;
+ ZifState *state_local;
ZifPackage *package;
GError *error = NULL;
@@ -1803,21 +1958,24 @@ backend_get_update_detail_thread (PkBackend *backend)
/* set the network state */
backend_setup_network (backend);
- /* setup completion */
- zif_completion_reset (priv->completion);
- zif_completion_set_number_steps (priv->completion, g_strv_length (package_ids));
+ /* setup state */
+ zif_state_reset (priv->state);
+ zif_state_set_number_steps (priv->state, g_strv_length (package_ids));
/* get the update info */
for (i=0; package_ids[i] != NULL; i++) {
package = zif_package_new ();
- ret = zif_package_set_id (package, package_ids[i]);
+ ret = zif_package_set_id (package, package_ids[i], &error);
if (!ret) {
- g_error ("moo");
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR,
+ "failed to set id: %s", error->message);
+ g_error_free (error);
+ goto out;
}
- completion_local = zif_completion_get_child (priv->completion);
- update = zif_package_get_update_detail (package, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ update = zif_package_get_update_detail (package, state_local, &error);
if (update == NULL) {
egg_debug ("failed to get updateinfo for %s", zif_package_get_id (package));
g_clear_error (&error);
@@ -1866,7 +2024,12 @@ backend_get_update_detail_thread (PkBackend *backend)
g_object_unref (package);
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
}
out:
backend_unlock (backend);
@@ -1985,7 +2148,7 @@ backend_refresh_cache_thread (PkBackend *backend)
GPtrArray *store_array = NULL;
gboolean ret;
GError *error = NULL;
- ZifCompletion *completion_local;
+ ZifState *state_local;
gboolean force = pk_backend_get_bool (backend, "force");
/* get lock */
@@ -2005,9 +2168,9 @@ backend_refresh_cache_thread (PkBackend *backend)
/* set the network state */
backend_setup_network (backend);
- /* setup completion */
- zif_completion_reset (priv->completion);
- zif_completion_set_number_steps (priv->completion, 2);
+ /* setup state */
+ zif_state_reset (priv->state);
+ zif_state_set_number_steps (priv->state, 2);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, 0);
@@ -2020,8 +2183,8 @@ backend_refresh_cache_thread (PkBackend *backend)
/* get a store_array of remote stores */
store_array = zif_store_array_new ();
- completion_local = zif_completion_get_child (priv->completion);
- ret = zif_store_array_add_remote_enabled (store_array, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ ret = zif_store_array_add_remote_enabled (store_array, state_local, &error);
if (!ret) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to add enabled stores: %s\n", error->message);
g_error_free (error);
@@ -2029,12 +2192,17 @@ backend_refresh_cache_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* clean all the repos */
- completion_local = zif_completion_get_child (priv->completion);
- ret = zif_store_array_clean (store_array, (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ zif_state_set_error_handler (priv->state, (ZifStateErrorHandlerCb) backend_error_handler_cb, backend);
+ ret = zif_store_array_clean (store_array, state_local, &error);
if (!ret) {
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to clean: %s\n", error->message);
g_error_free (error);
@@ -2220,7 +2388,7 @@ backend_get_repo_list_thread (PkBackend *backend)
guint i;
GPtrArray *array = NULL;
ZifStoreRemote *store;
- ZifCompletion *completion_local;
+ ZifState *state_local;
const gchar *repo_id;
const gchar *name;
gboolean enabled;
@@ -2247,12 +2415,12 @@ backend_get_repo_list_thread (PkBackend *backend)
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, 0);
- /* setup completion */
- zif_completion_reset (priv->completion);
- zif_completion_set_number_steps (priv->completion, 2);
+ /* setup state */
+ zif_state_reset (priv->state);
+ zif_state_set_number_steps (priv->state, 2);
- completion_local = zif_completion_get_child (priv->completion);
- array = zif_repos_get_stores (priv->repos, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ array = zif_repos_get_stores (priv->repos, state_local, &error);
if (array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "failed to find repos: %s", error->message);
g_error_free (error);
@@ -2266,34 +2434,50 @@ backend_get_repo_list_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
- /* setup completion */
- completion_local = zif_completion_get_child (priv->completion);
- zif_completion_set_number_steps (completion_local, array->len);
+ /* setup state */
+ state_local = zif_state_get_child (priv->state);
+ zif_state_set_number_steps (state_local, array->len);
/* looks at each store */
for (i=0; i<array->len; i++) {
store = g_ptr_array_index (array, i);
if (pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_DEVELOPMENT)) {
- /* TODO: completion */
- devel = zif_store_remote_is_devel (store, priv->cancellable, NULL, NULL);
+ /* TODO: state */
+ devel = zif_store_remote_is_devel (store, NULL, NULL);
if (devel)
- continue;
+ goto skip;
}
+
+ /* TODO: state */
+ name = zif_store_remote_get_name (store, NULL, NULL);
+ /* TODO: state */
+ enabled = zif_store_remote_get_enabled (store, NULL, NULL);
repo_id = zif_store_get_id (ZIF_STORE (store));
- /* TODO: completion */
- name = zif_store_remote_get_name (store, priv->cancellable, NULL, NULL);
- /* TODO: completion */
- enabled = zif_store_remote_get_enabled (store, priv->cancellable, NULL, NULL);
pk_backend_repo_detail (backend, repo_id, name, enabled);
-
+skip:
/* this section done */
- zif_completion_done (completion_local);
+ ret = zif_state_done (state_local, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
out:
backend_unlock (backend);
pk_backend_finished (backend);
@@ -2356,7 +2540,7 @@ backend_repo_enable_thread (PkBackend *backend)
pk_backend_set_percentage (backend, 0);
/* find the right repo */
- repo = zif_repos_get_store (priv->repos, repo_id, priv->cancellable, priv->completion, &error);
+ repo = zif_repos_get_store (priv->repos, repo_id, priv->state, &error);
if (repo == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "failed to find repo: %s", error->message);
g_error_free (error);
@@ -2491,10 +2675,10 @@ backend_get_categories_thread (PkBackend *backend)
guint i;
GPtrArray *array = NULL;
GPtrArray *stores = NULL;
- PkCategory *cat;
+ ZifCategory *cat;
gchar *cat_id;
- ZifCompletion *completion_local;
+ ZifState *state_local;
GError *error = NULL;
/* get lock */
@@ -2514,16 +2698,16 @@ backend_get_categories_thread (PkBackend *backend)
/* set the network state */
backend_setup_network (backend);
- /* setup completion */
- zif_completion_reset (priv->completion);
- zif_completion_set_number_steps (priv->completion, 3);
+ /* setup state */
+ zif_state_reset (priv->state);
+ zif_state_set_number_steps (priv->state, 3);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, 0);
/* get enabled repos */
- completion_local = zif_completion_get_child (priv->completion);
- stores = zif_repos_get_stores_enabled (priv->repos, priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ stores = zif_repos_get_stores_enabled (priv->repos, state_local, &error);
if (stores == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR, "failed to add remote stores: %s", error->message);
g_error_free (error);
@@ -2531,12 +2715,17 @@ backend_get_categories_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* get sorted list of unique categories */
- completion_local = zif_completion_get_child (priv->completion);
- array = zif_store_array_get_categories (stores, (ZifStoreArrayErrorCb) backend_error_handler_cb, backend,
- priv->cancellable, completion_local, &error);
+ state_local = zif_state_get_child (priv->state);
+ zif_state_set_error_handler (priv->state, (ZifStateErrorHandlerCb) backend_error_handler_cb, backend);
+ array = zif_store_array_get_categories (stores, state_local, &error);
if (array == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_GROUP_LIST_INVALID, "failed to add get categories: %s", error->message);
g_error_free (error);
@@ -2544,27 +2733,37 @@ backend_get_categories_thread (PkBackend *backend)
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
/* emit each cat obj */
for (i=0; i<array->len; i++) {
cat = g_ptr_array_index (array, i);
/* FIXME: in the yum backend, we signify a group with a '@' prefix */
- if (pk_category_get_parent_id (cat) != NULL)
- cat_id = g_strdup_printf ("@%s", pk_category_get_id (cat));
+ if (zif_category_get_parent_id (cat) != NULL)
+ cat_id = g_strdup_printf ("@%s", zif_category_get_id (cat));
else
- cat_id = g_strdup (pk_category_get_id (cat));
+ cat_id = g_strdup (zif_category_get_id (cat));
pk_backend_category (backend,
- pk_category_get_parent_id (cat),
+ zif_category_get_parent_id (cat),
cat_id,
- pk_category_get_name (cat),
- pk_category_get_summary (cat),
- pk_category_get_icon (cat));
+ zif_category_get_name (cat),
+ zif_category_get_summary (cat),
+ zif_category_get_icon (cat));
g_free (cat_id);
}
/* this section done */
- zif_completion_done (priv->completion);
+ ret = zif_state_done (priv->state, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "cancelled: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
out:
backend_unlock (backend);
pk_backend_finished (backend);
commit 1b5d99d57acf67ecc0dbe790f18f445e68e41650
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 20:35:46 2010 +0100
yum: use the system installed version of the zif accellerator
diff --git a/backends/yum/Makefile.am b/backends/yum/Makefile.am
index 0c96ef1..d68f2ed 100644
--- a/backends/yum/Makefile.am
+++ b/backends/yum/Makefile.am
@@ -8,16 +8,8 @@ dist_helper_DATA = \
INCLUDES = \
-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE \
- -DZIF_COMPILATION \
- $(SQLITE_CFLAGS) \
- $(RPM_CFLAGS) \
- $(ZLIB_CFLAGS) \
- $(BZLIB_CFLAGS) \
- $(SOUP_CFLAGS) \
- $(ARCHIVE_CFLAGS) \
- -DSYSCONFDIR=\""$(sysconfdir)"\" \
- -I$(top_srcdir)/backends/yum/libzif \
- -I$(top_builddir)/backends/yum/libzif
+ $(ZIF_CFLAGS) \
+ -DSYSCONFDIR=\""$(sysconfdir)"\"
plugindir = $(PK_PLUGIN_DIR)
plugin_LTLIBRARIES = libpk_backend_yum.la
@@ -26,78 +18,8 @@ libpk_backend_yum_la_LIBADD = $(PK_PLUGIN_LIBS)
libpk_backend_yum_la_LDFLAGS = -module -avoid-version
libpk_backend_yum_la_CFLAGS = $(PK_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
-libpk_backend_yum_la_SOURCES += \
- libzif/egg-debug.c \
- libzif/egg-debug.h \
- libzif/zif.h \
- libzif/zif-lock.c \
- libzif/zif-lock.h \
- libzif/zif-completion.c \
- libzif/zif-completion.h \
- libzif/zif-string.c \
- libzif/zif-string.h \
- libzif/zif-depend.c \
- libzif/zif-depend.h \
- libzif/zif-package.c \
- libzif/zif-package.h \
- libzif/zif-package-local.c \
- libzif/zif-package-local.h \
- libzif/zif-package-remote.c \
- libzif/zif-package-remote.h \
- libzif/zif-store.c \
- libzif/zif-store.h \
- libzif/zif-store-local.c \
- libzif/zif-store-local.h \
- libzif/zif-store-remote.c \
- libzif/zif-store-remote.h \
- libzif/zif-md.c \
- libzif/zif-md.h \
- libzif/zif-md-filelists-sql.c \
- libzif/zif-md-filelists-sql.h \
- libzif/zif-md-filelists-xml.c \
- libzif/zif-md-filelists-xml.h \
- libzif/zif-md-primary-sql.c \
- libzif/zif-md-primary-sql.h \
- libzif/zif-md-other-sql.c \
- libzif/zif-md-other-sql.h \
- libzif/zif-md-primary-xml.c \
- libzif/zif-md-primary-xml.h \
- libzif/zif-md-metalink.c \
- libzif/zif-md-metalink.h \
- libzif/zif-md-mirrorlist.c \
- libzif/zif-md-mirrorlist.h \
- libzif/zif-md-updateinfo.c \
- libzif/zif-md-updateinfo.h \
- libzif/zif-md-comps.c \
- libzif/zif-md-comps.h \
- libzif/zif-store-array.c \
- libzif/zif-store-array.h \
- libzif/zif-repos.c \
- libzif/zif-repos.h \
- libzif/zif-changeset.c \
- libzif/zif-changeset.h \
- libzif/zif-utils.c \
- libzif/zif-utils.h \
- libzif/zif-groups.c \
- libzif/zif-groups.h \
- libzif/zif-config.c \
- libzif/zif-config.h \
- libzif/zif-monitor.c \
- libzif/zif-monitor.h \
- libzif/zif-update.c \
- libzif/zif-update.h \
- libzif/zif-update-info.c \
- libzif/zif-update-info.h \
- libzif/zif-download.c \
- libzif/zif-download.h
-
libpk_backend_yum_la_LIBADD += \
- $(SQLITE_LIBS) \
- $(ZLIB_LIBS) \
- $(BZLIB_LIBS) \
- $(RPM_LIBS) \
- $(SOUP_LIBS) \
- $(ARCHIVE_LIBS) \
+ $(ZIF_LIBS) \
$(NULL)
confdir = $(PK_CONF_DIR)
diff --git a/backends/yum/libzif/egg-debug.c b/backends/yum/libzif/egg-debug.c
deleted file mode 120000
index c07e03a..0000000
--- a/backends/yum/libzif/egg-debug.c
+++ /dev/null
@@ -1 +0,0 @@
-../../../src/egg-debug.c
\ No newline at end of file
diff --git a/backends/yum/libzif/egg-debug.h b/backends/yum/libzif/egg-debug.h
deleted file mode 120000
index 005d030..0000000
--- a/backends/yum/libzif/egg-debug.h
+++ /dev/null
@@ -1 +0,0 @@
-../../../src/egg-debug.h
\ No newline at end of file
diff --git a/backends/yum/libzif/zif-changeset.c b/backends/yum/libzif/zif-changeset.c
deleted file mode 100644
index 9d78c67..0000000
--- a/backends/yum/libzif/zif-changeset.c
+++ /dev/null
@@ -1,479 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-changeset
- * @short_description: Generic object to represent some information about a changeset.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "egg-debug.h"
-
-#include "zif-changeset.h"
-
-#define ZIF_CHANGESET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_CHANGESET, ZifChangesetPrivate))
-
-struct _ZifChangesetPrivate
-{
- guint64 date;
- gchar *author;
- gchar *description;
- gchar *version;
-};
-
-enum {
- PROP_0,
- PROP_DATE,
- PROP_AUTHOR,
- PROP_DESCRIPTION,
- PROP_VERSION,
- PROP_LAST
-};
-
-G_DEFINE_TYPE (ZifChangeset, zif_changeset, G_TYPE_OBJECT)
-
-/**
- * zif_changeset_get_date:
- * @changeset: the #ZifChangeset object
- *
- * Gets the date and date of the update.
- *
- * Return value: the date of the update, or 0 for unset.
- *
- * Since: 0.0.1
- **/
-guint64
-zif_changeset_get_date (ZifChangeset *changeset)
-{
- g_return_val_if_fail (ZIF_IS_CHANGESET (changeset), 0);
- return changeset->priv->date;
-}
-
-/**
- * zif_changeset_get_author:
- * @changeset: the #ZifChangeset object
- *
- * Gets the author for this changeset.
- *
- * Return value: A string value, or %NULL.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_changeset_get_author (ZifChangeset *changeset)
-{
- g_return_val_if_fail (ZIF_IS_CHANGESET (changeset), NULL);
- return changeset->priv->author;
-}
-
-/**
- * zif_changeset_get_description:
- * @changeset: the #ZifChangeset object
- *
- * Gets the description for this changeset.
- *
- * Return value: A string value, or %NULL.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_changeset_get_description (ZifChangeset *changeset)
-{
- g_return_val_if_fail (ZIF_IS_CHANGESET (changeset), NULL);
- return changeset->priv->description;
-}
-
-/**
- * zif_changeset_get_version:
- * @changeset: the #ZifChangeset object
- *
- * Gets the date this changeset was version.
- *
- * Return value: A string value, or %NULL.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_changeset_get_version (ZifChangeset *changeset)
-{
- g_return_val_if_fail (ZIF_IS_CHANGESET (changeset), NULL);
- return changeset->priv->version;
-}
-
-/**
- * zif_changeset_set_date:
- * @changeset: the #ZifChangeset object
- * @date: The date of the changeset
- *
- * Sets the changeset date status.
- *
- * Since: 0.0.1
- **/
-void
-zif_changeset_set_date (ZifChangeset *changeset, guint64 date)
-{
- g_return_if_fail (ZIF_IS_CHANGESET (changeset));
- changeset->priv->date = date;
-}
-
-/**
- * zif_changeset_set_author:
- * @changeset: the #ZifChangeset object
- * @author: the changeset author
- *
- * Sets the changeset author.
- *
- * Since: 0.0.1
- **/
-void
-zif_changeset_set_author (ZifChangeset *changeset, const gchar *author)
-{
- g_return_if_fail (ZIF_IS_CHANGESET (changeset));
- g_return_if_fail (author != NULL);
- g_return_if_fail (changeset->priv->author == NULL);
-
- changeset->priv->author = g_strdup (author);
-}
-
-/**
- * zif_changeset_set_description:
- * @changeset: the #ZifChangeset object
- * @description: the changeset description
- *
- * Sets the changeset description.
- *
- * Since: 0.0.1
- **/
-void
-zif_changeset_set_description (ZifChangeset *changeset, const gchar *description)
-{
- g_return_if_fail (ZIF_IS_CHANGESET (changeset));
- g_return_if_fail (description != NULL);
- g_return_if_fail (changeset->priv->description == NULL);
-
- changeset->priv->description = g_strdup (description);
-}
-
-/**
- * zif_changeset_set_version:
- * @changeset: the #ZifChangeset object
- * @version: the changeset version date
- *
- * Sets the date the changeset was version.
- *
- * Since: 0.0.1
- **/
-void
-zif_changeset_set_version (ZifChangeset *changeset, const gchar *version)
-{
- g_return_if_fail (ZIF_IS_CHANGESET (changeset));
- g_return_if_fail (version != NULL);
- g_return_if_fail (changeset->priv->version == NULL);
-
- changeset->priv->version = g_strdup (version);
-}
-
-/**
- * zif_changeset_parse_header:
- * @changeset: the #ZifChangeset object
- * @header: the package header, e.g "Ania Hughes <ahughes at redhat.com> - 2.29.91-1.fc13"
- *
- * Sets the author and version from the package header.
- *
- * Return value: %TRUE if the data was parsed correctly
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_changeset_parse_header (ZifChangeset *changeset, const gchar *header, GError **error)
-{
- gboolean ret = FALSE;
- gchar *temp = NULL;
- gchar *found;
- guint len;
-
- /* check if there is a version field */
- len = strlen (header);
- if (header[len-1] == '>') {
- zif_changeset_set_author (changeset, header);
- ret = TRUE;
- goto out;
- }
-
- /* operate on copy */
- temp = g_strdup (header);
-
- /* get last space */
- found = g_strrstr (temp, " ");
- if (found == NULL) {
- g_set_error (error, 1, 0, "format invalid: %s", header);
- goto out;
- }
-
- /* set version */
- zif_changeset_set_version (changeset, found + 1);
-
- /* trim to first non-space or '-' char */
- for (;found != temp;found--) {
- if (*found != ' ' && *found != '-')
- break;
- }
-
- /* terminate here */
- found[1] = '\0';
-
- /* set author */
- zif_changeset_set_author (changeset, temp);
-
- /* success */
- ret = TRUE;
-out:
- g_free (temp);
- return ret;
-}
-
-/**
- * zif_changeset_get_property:
- **/
-static void
-zif_changeset_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- ZifChangeset *changeset = ZIF_CHANGESET (object);
- ZifChangesetPrivate *priv = changeset->priv;
-
- switch (prop_id) {
- case PROP_DATE:
- g_value_set_uint64 (value, priv->date);
- break;
- case PROP_AUTHOR:
- g_value_set_string (value, priv->author);
- break;
- case PROP_DESCRIPTION:
- g_value_set_string (value, priv->description);
- break;
- case PROP_VERSION:
- g_value_set_string (value, priv->version);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * zif_changeset_set_property:
- **/
-static void
-zif_changeset_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
-}
-
-/**
- * zif_changeset_finalize:
- **/
-static void
-zif_changeset_finalize (GObject *object)
-{
- ZifChangeset *changeset;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_CHANGESET (object));
- changeset = ZIF_CHANGESET (object);
-
- g_free (changeset->priv->author);
- g_free (changeset->priv->description);
- g_free (changeset->priv->version);
-
- G_OBJECT_CLASS (zif_changeset_parent_class)->finalize (object);
-}
-
-/**
- * zif_changeset_class_init:
- **/
-static void
-zif_changeset_class_init (ZifChangesetClass *klass)
-{
- GParamSpec *pspec;
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_changeset_finalize;
- object_class->get_property = zif_changeset_get_property;
- object_class->set_property = zif_changeset_set_property;
-
- /**
- * ZifChangeset:date:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_uint64 ("date", NULL, NULL,
- 0, G_MAXUINT64, 0,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_DATE, pspec);
-
- /**
- * ZifChangeset:author:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_string ("author", NULL, NULL,
- NULL,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_AUTHOR, pspec);
-
- /**
- * ZifChangeset:description:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_string ("description", NULL, NULL,
- NULL,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_DESCRIPTION, pspec);
-
- /**
- * ZifChangeset:version:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_string ("version", NULL, NULL,
- NULL,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_VERSION, pspec);
-
- g_type_class_add_private (klass, sizeof (ZifChangesetPrivate));
-}
-
-/**
- * zif_changeset_init:
- **/
-static void
-zif_changeset_init (ZifChangeset *changeset)
-{
- changeset->priv = ZIF_CHANGESET_GET_PRIVATE (changeset);
- changeset->priv->date = 0;
- changeset->priv->author = NULL;
- changeset->priv->description = NULL;
- changeset->priv->version = NULL;
-}
-
-/**
- * zif_changeset_new:
- *
- * Return value: A new #ZifChangeset class instance.
- *
- * Since: 0.0.1
- **/
-ZifChangeset *
-zif_changeset_new (void)
-{
- ZifChangeset *changeset;
- changeset = g_object_new (ZIF_TYPE_CHANGESET, NULL);
- return ZIF_CHANGESET (changeset);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_changeset_test (EggTest *test)
-{
- gboolean ret;
- const gchar *temp;
- ZifChangeset *changeset;
-
- if (!egg_test_start (test, "ZifChangeset"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get changeset");
- changeset = zif_changeset_new ();
- zif_changeset_set_description (changeset, "Update to latest stable version");
- egg_test_assert (test, changeset != NULL);
-
- /************************************************************/
- egg_test_title (test, "parse header 0 (fail)");
- ret = zif_changeset_parse_header (changeset, "this-is-an-invalid-header", NULL);
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "parse header 1 (success)");
- ret = zif_changeset_parse_header (changeset, "Milan Crha <mcrha at redhat.com> - 2.29.91-1.fc13", NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "check description");
- temp = zif_changeset_get_description (changeset);
- if (g_strcmp0 (temp, "Update to latest stable version") != 0)
- egg_test_failed (test, "incorrect value, got: %s", temp);
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check author");
- temp = zif_changeset_get_author (changeset);
- if (g_strcmp0 (temp, "Milan Crha <mcrha at redhat.com>") != 0)
- egg_test_failed (test, "incorrect value, got: %s", temp);
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check version");
- temp = zif_changeset_get_version (changeset);
- if (g_strcmp0 (temp, "2.29.91-1.fc13") != 0)
- egg_test_failed (test, "incorrect value, got: %s", temp);
- egg_test_success (test, NULL);
-
- /* reset */
- g_object_unref (changeset);
- changeset = zif_changeset_new ();
-
- /************************************************************/
- egg_test_title (test, "parse header 2 (success)");
- ret = zif_changeset_parse_header (changeset, "Milan Crha <mcrha at redhat.com> 2.29.91-1.fc13", NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "check author");
- temp = zif_changeset_get_author (changeset);
- if (g_strcmp0 (temp, "Milan Crha <mcrha at redhat.com>") != 0)
- egg_test_failed (test, "incorrect value, got: %s", temp);
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check version");
- temp = zif_changeset_get_version (changeset);
- if (g_strcmp0 (temp, "2.29.91-1.fc13") != 0)
- egg_test_failed (test, "incorrect value, got: %s", temp);
- egg_test_success (test, NULL);
-
- g_object_unref (changeset);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-changeset.h b/backends/yum/libzif/zif-changeset.h
deleted file mode 100644
index fdde41b..0000000
--- a/backends/yum/libzif/zif-changeset.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_CHANGESET_H
-#define __ZIF_CHANGESET_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_CHANGESET (zif_changeset_get_type ())
-#define ZIF_CHANGESET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_CHANGESET, ZifChangeset))
-#define ZIF_CHANGESET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_CHANGESET, ZifChangesetClass))
-#define ZIF_IS_CHANGESET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_CHANGESET))
-#define ZIF_IS_CHANGESET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_CHANGESET))
-#define ZIF_CHANGESET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_CHANGESET, ZifChangesetClass))
-#define ZIF_CHANGESET_ERROR (zif_changeset_error_quark ())
-
-typedef struct _ZifChangeset ZifChangeset;
-typedef struct _ZifChangesetPrivate ZifChangesetPrivate;
-typedef struct _ZifChangesetClass ZifChangesetClass;
-
-#include "zif-package.h"
-
-struct _ZifChangeset
-{
- GObject parent;
- ZifChangesetPrivate *priv;
-};
-
-struct _ZifChangesetClass
-{
- GObjectClass parent_class;
-};
-
-GType zif_changeset_get_type (void);
-ZifChangeset *zif_changeset_new (void);
-
-/* public getters */
-guint64 zif_changeset_get_date (ZifChangeset *changeset);
-const gchar *zif_changeset_get_author (ZifChangeset *changeset);
-const gchar *zif_changeset_get_description (ZifChangeset *changeset);
-const gchar *zif_changeset_get_version (ZifChangeset *changeset);
-
-/* internal setters: TODO, in seporate -internal header file */
-void zif_changeset_set_date (ZifChangeset *changeset,
- guint64 date);
-void zif_changeset_set_author (ZifChangeset *changeset,
- const gchar *author);
-void zif_changeset_set_description (ZifChangeset *changeset,
- const gchar *description);
-void zif_changeset_set_version (ZifChangeset *changeset,
- const gchar *version);
-gboolean zif_changeset_parse_header (ZifChangeset *changeset,
- const gchar *header,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_CHANGESET_H */
-
diff --git a/backends/yum/libzif/zif-completion.c b/backends/yum/libzif/zif-completion.c
deleted file mode 100644
index e057e32..0000000
--- a/backends/yum/libzif/zif-completion.c
+++ /dev/null
@@ -1,738 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-completion
- * @short_description: A #ZifCompletion object allows progress reporting
- *
- * Objects can use zif_completion_set_percentage() if the absolute percentage
- * is known. Percentages should always go up, not down.
- *
- * Modules usually set the number of steps that are expected using
- * zif_completion_set_number_steps() and then after each section is completed,
- * the zif_completion_done() function should be called. This will automatically
- * call zif_completion_set_percentage() with the correct values.
- *
- * #ZifCompletion allows sub-modules to be "chained up" to the parent module
- * so that as the sub-module progresses, so does the parent.
- * The child can be reused for each section, and chains can be deep.
- *
- * To get a child object, you should use zif_completion_get_child() and then
- * use the result in any sub-process. You should ensure that the child object
- * is not re-used without calling zif_completion_done().
- *
- * There are a few nice touches in this module, so that if a module only has
- * one progress step, the child progress is used for updates.
- *
- *
- * <example>
- * <title>Using a #ZifCompletion.</title>
- * <programlisting>
- * static void
- * _do_something (ZifCompletion *completion)
- * {
- * ZifCompletion *completion_local;
- *
- * // setup correct number of steps
- * zif_completion_set_number_steps (completion, 2);
- *
- * // run a sub function
- * completion_local = zif_completion_get_child (completion);
- * _do_something_else1 (completion_local);
- *
- * // this section done
- * zif_completion_done (completion);
- *
- * // run another sub function
- * completion_local = zif_completion_get_child (completion);
- * _do_something_else2 (completion_local);
- *
- * // this section done (all complete)
- * zif_completion_done (completion);
- * }
- * </programlisting>
- * </example>
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-
-#include "zif-utils.h"
-#include "zif-completion.h"
-
-#include "egg-debug.h"
-
-#define ZIF_COMPLETION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_COMPLETION, ZifCompletionPrivate))
-
-struct _ZifCompletionPrivate
-{
- guint steps;
- guint current;
- guint last_percentage;
- ZifCompletion *child;
- ZifCompletion *parent;
- gulong percentage_child_id;
- gulong subpercentage_child_id;
- gchar *id;
-};
-
-enum {
- SIGNAL_PERCENTAGE_CHANGED,
- SIGNAL_SUBPERCENTAGE_CHANGED,
- SIGNAL_LAST
-};
-
-static guint signals [SIGNAL_LAST] = { 0 };
-
-G_DEFINE_TYPE (ZifCompletion, zif_completion, G_TYPE_OBJECT)
-
-/**
- * zif_completion_discrete_to_percent:
- * @discrete: The discrete level
- * @steps: The number of discrete steps
- *
- * We have to be carefull when converting from discrete->%.
- *
- * Return value: The percentage for this discrete value.
- **/
-static gfloat
-zif_completion_discrete_to_percent (guint discrete, guint steps)
-{
- /* check we are in range */
- if (discrete > steps)
- return 100;
- if (steps == 0) {
- egg_warning ("steps is 0!");
- return 0;
- }
- return ((gfloat) discrete * (100.0f / (gfloat) (steps)));
-}
-
-/**
- * zif_completion_set_percentage:
- * @completion: the #ZifCompletion object
- * @percentage: A manual percentage value
- *
- * Set a percentage manually.
- * NOTE: this must be above what was previously set, or it will be rejected.
- *
- * Return value: %TRUE if the signal was propagated, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_completion_set_percentage (ZifCompletion *completion, guint percentage)
-{
- /* is it the same */
- if (percentage == completion->priv->last_percentage)
- goto out;
-
- /* is it less */
- if (percentage < completion->priv->last_percentage) {
- egg_warning ("percentage cannot go down from %i to %i on %p!", completion->priv->last_percentage, percentage, completion);
- return FALSE;
- }
-
- /* emit and save */
- g_signal_emit (completion, signals [SIGNAL_PERCENTAGE_CHANGED], 0, percentage);
- completion->priv->last_percentage = percentage;
-out:
- return TRUE;
-}
-
-/**
- * zif_completion_get_percentage:
- * @completion: the #ZifCompletion object
- *
- * Get the percentage completion.
- *
- * Return value: A percentage value, or G_MAXUINT for error
- *
- * Since: 0.0.1
- **/
-guint
-zif_completion_get_percentage (ZifCompletion *completion)
-{
- return completion->priv->last_percentage;
-}
-
-/**
- * zif_completion_set_subpercentage:
- **/
-static gboolean
-zif_completion_set_subpercentage (ZifCompletion *completion, guint percentage)
-{
- /* just emit */
- g_signal_emit (completion, signals [SIGNAL_SUBPERCENTAGE_CHANGED], 0, percentage);
- return TRUE;
-}
-
-/**
- * zif_completion_child_percentage_changed_cb:
- **/
-static void
-zif_completion_child_percentage_changed_cb (ZifCompletion *child, guint percentage, ZifCompletion *completion)
-{
- gfloat offset;
- gfloat range;
- gfloat extra;
-
- /* propagate up the stack if ZifCompletion has only one step */
- if (completion->priv->steps == 1) {
- zif_completion_set_percentage (completion, percentage);
- return;
- }
-
- /* did we call done on a completion that did not have a size set? */
- if (completion->priv->steps == 0) {
- egg_warning ("done on a completion %p that did not have a size set!", completion);
- return;
- }
-
- /* always provide two levels of signals */
- zif_completion_set_subpercentage (completion, percentage);
-
- /* already at >= 100% */
- if (completion->priv->current >= completion->priv->steps) {
- egg_warning ("already at %i/%i steps on %p", completion->priv->current, completion->priv->steps, completion);
- return;
- }
-
- /* get the offset */
- offset = zif_completion_discrete_to_percent (completion->priv->current, completion->priv->steps);
-
- /* get the range between the parent step and the next parent step */
- range = zif_completion_discrete_to_percent (completion->priv->current+1, completion->priv->steps) - offset;
- if (range < 0.01) {
- egg_warning ("range=%f (from %i to %i), should be impossible", range, completion->priv->current+1, completion->priv->steps);
- return;
- }
-
- /* get the extra contributed by the child */
- extra = ((gfloat) percentage / 100.0f) * range;
-
- /* emit from the parent */
- zif_completion_set_percentage (completion, (guint) (offset + extra));
-}
-
-/**
- * zif_completion_child_subpercentage_changed_cb:
- **/
-static void
-zif_completion_child_subpercentage_changed_cb (ZifCompletion *child, guint percentage, ZifCompletion *completion)
-{
- /* discard this, unless the ZifCompletion has only one step */
- if (completion->priv->steps != 1)
- return;
-
- /* propagate up the stack as if the parent didn't exist */
- zif_completion_set_subpercentage (completion, percentage);
-}
-
-/**
- * zif_completion_reset:
- * @completion: the #ZifCompletion object
- *
- * Resets the #ZifCompletion object to unset
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_completion_reset (ZifCompletion *completion)
-{
- g_return_val_if_fail (ZIF_IS_COMPLETION (completion), FALSE);
-
- /* reset values */
- completion->priv->steps = 0;
- completion->priv->current = 0;
- completion->priv->last_percentage = 0;
-
- /* disconnect client */
- if (completion->priv->percentage_child_id != 0) {
- g_signal_handler_disconnect (completion->priv->child, completion->priv->percentage_child_id);
- completion->priv->percentage_child_id = 0;
- }
- if (completion->priv->subpercentage_child_id != 0) {
- g_signal_handler_disconnect (completion->priv->child, completion->priv->subpercentage_child_id);
- completion->priv->subpercentage_child_id = 0;
- }
-
- /* unref child */
- if (completion->priv->child != NULL) {
- g_object_unref (completion->priv->child);
- completion->priv->child = NULL;
- }
-
- return TRUE;
-}
-
-/**
- * zif_completion_get_child:
- * @completion: the #ZifCompletion object
- *
- * Monitor a child completion and proxy back up to the parent completion.
- * Yo udo not have to g_object_unref() this value.
- *
- * Return value: a new %ZifCompletion or %NULL for failure
- *
- * Since: 0.0.1
- **/
-ZifCompletion *
-zif_completion_get_child (ZifCompletion *completion)
-{
- ZifCompletion *child = NULL;
-
- g_return_val_if_fail (ZIF_IS_COMPLETION (completion), NULL);
-
- /* already set child */
- if (completion->priv->child != NULL) {
- g_signal_handler_disconnect (completion->priv->child, completion->priv->percentage_child_id);
- g_signal_handler_disconnect (completion->priv->child, completion->priv->subpercentage_child_id);
- g_object_unref (completion->priv->child);
- }
-
- /* connect up signals */
- child = zif_completion_new ();
- completion->priv->child = g_object_ref (child);
- completion->priv->child->priv->parent = g_object_ref (completion);
- completion->priv->percentage_child_id =
- g_signal_connect (child, "percentage-changed", G_CALLBACK (zif_completion_child_percentage_changed_cb), completion);
- completion->priv->subpercentage_child_id =
- g_signal_connect (child, "subpercentage-changed", G_CALLBACK (zif_completion_child_subpercentage_changed_cb), completion);
-
- /* reset child */
- child->priv->current = 0;
- child->priv->last_percentage = 0;
-
- return child;
-}
-
-/**
- * zif_completion_set_number_steps:
- * @completion: the #ZifCompletion object
- * @steps: The number of sub-tasks in this transaction
- *
- * Sets the number of sub-tasks, i.e. how many times the zif_completion_done()
- * function will be called in the loop.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_completion_set_number_steps_real (ZifCompletion *completion, guint steps, const gchar *function_name, gint function_line)
-{
- g_return_val_if_fail (ZIF_IS_COMPLETION (completion), FALSE);
- g_return_val_if_fail (steps != 0, FALSE);
-
- /* did we call done on a completion that did not have a size set? */
- if (completion->priv->steps != 0) {
- egg_warning ("steps already set (%i)! [%s:%i]",
- completion->priv->steps, function_name, function_line);
- return FALSE;
- }
-
- /* set id */
- completion->priv->id = g_strdup_printf ("%s:%i", function_name, function_line);
-
- /* imply reset */
- zif_completion_reset (completion);
-
- /* set steps */
- completion->priv->steps = steps;
-
- return TRUE;
-}
-
-/**
- * zif_completion_print_parent_chain:
- **/
-static void
-zif_completion_print_parent_chain (ZifCompletion *completion, guint level)
-{
- if (completion->priv->parent != NULL)
- zif_completion_print_parent_chain (completion->priv->parent, level + 1);
- g_print ("%i) %s (%i/%i)\n",
- level, completion->priv->id, completion->priv->current, completion->priv->steps);
-}
-
-/**
- * zif_completion_done:
- * @completion: the #ZifCompletion object
- *
- * Called when the current sub-task has finished.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_completion_done_real (ZifCompletion *completion, const gchar *function_name, gint function_line)
-{
- gboolean ret = TRUE;
- gfloat percentage;
-
- g_return_val_if_fail (ZIF_IS_COMPLETION (completion), FALSE);
-
- /* did we call done on a completion that did not have a size set? */
- if (completion->priv->steps == 0) {
- egg_warning ("done on a completion %p that did not have a size set! [%s:%i]",
- completion, function_name, function_line);
- zif_completion_print_parent_chain (completion, 0);
- ret = FALSE;
- goto out;
- }
-
- /* is already at 100%? */
- if (completion->priv->current == completion->priv->steps) {
- egg_warning ("already at 100%% completion [%s:%i]", function_name, function_line);
- zif_completion_print_parent_chain (completion, 0);
- ret = FALSE;
- goto out;
- }
-
- /* is child not at 100%? */
- if (completion->priv->child != NULL) {
- ZifCompletionPrivate *child_priv = completion->priv->child->priv;
- if (child_priv->current != child_priv->steps) {
- egg_warning ("child is at %i/%i steps and parent done [%s:%i]",
- child_priv->current, child_priv->steps, function_name, function_line);
- zif_completion_print_parent_chain (completion->priv->child, 0);
- ret = FALSE;
- /* do not abort, as we want to clean this up */
- }
- }
-
- /* another */
- completion->priv->current++;
-
- /* find new percentage */
- percentage = zif_completion_discrete_to_percent (completion->priv->current, completion->priv->steps);
- zif_completion_set_percentage (completion, (guint) percentage);
-
- /* reset child if it exists */
- if (completion->priv->child != NULL)
- zif_completion_reset (completion->priv->child);
-out:
- return ret;
-}
-
-/**
- * zif_completion_finished:
- * @completion: the #ZifCompletion object
- *
- * Called when the current sub-task wants to finish early and still complete.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_completion_finished_real (ZifCompletion *completion, const gchar *function_name, gint function_line)
-{
- g_return_val_if_fail (ZIF_IS_COMPLETION (completion), FALSE);
-
- /* did we call done on a completion that did not have a size set? */
- if (completion->priv->steps == 0) {
- egg_warning ("finished on a completion %p that did not have a size set! [%s:%i]",
- completion, function_name, function_line);
- return FALSE;
- }
-
- /* is already at 100%? */
- if (completion->priv->current == completion->priv->steps) {
- egg_warning ("already at 100%% completion [%s:%i]", function_name, function_line);
- return FALSE;
- }
-
- /* all done */
- completion->priv->current = completion->priv->steps;
-
- /* set new percentage */
- zif_completion_set_percentage (completion, 100);
-
- return TRUE;
-}
-
-/**
- * zif_completion_finalize:
- **/
-static void
-zif_completion_finalize (GObject *object)
-{
- ZifCompletion *completion;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_COMPLETION (object));
- completion = ZIF_COMPLETION (object);
-
- /* unref child too */
- zif_completion_reset (completion);
- if (completion->priv->parent != NULL)
- g_object_unref (completion->priv->parent);
-
- G_OBJECT_CLASS (zif_completion_parent_class)->finalize (object);
-}
-
-/**
- * zif_completion_class_init:
- **/
-static void
-zif_completion_class_init (ZifCompletionClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_completion_finalize;
-
- signals [SIGNAL_PERCENTAGE_CHANGED] =
- g_signal_new ("percentage-changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ZifCompletionClass, percentage_changed),
- NULL, NULL, g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
-
- signals [SIGNAL_SUBPERCENTAGE_CHANGED] =
- g_signal_new ("subpercentage-changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ZifCompletionClass, subpercentage_changed),
- NULL, NULL, g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
-
- g_type_class_add_private (klass, sizeof (ZifCompletionPrivate));
-}
-
-/**
- * zif_completion_init:
- **/
-static void
-zif_completion_init (ZifCompletion *completion)
-{
- completion->priv = ZIF_COMPLETION_GET_PRIVATE (completion);
- completion->priv->child = NULL;
- completion->priv->parent = NULL;
- completion->priv->steps = 0;
- completion->priv->current = 0;
- completion->priv->last_percentage = 0;
- completion->priv->percentage_child_id = 0;
- completion->priv->subpercentage_child_id = 0;
-}
-
-/**
- * zif_completion_new:
- *
- * Return value: A new #ZifCompletion class instance.
- *
- * Since: 0.0.1
- **/
-ZifCompletion *
-zif_completion_new (void)
-{
- ZifCompletion *completion;
- completion = g_object_new (ZIF_TYPE_COMPLETION, NULL);
- return ZIF_COMPLETION (completion);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-static guint _updates = 0;
-static guint _last_percent = 0;
-static guint _last_subpercent = 0;
-
-static void
-zif_completion_test_percentage_changed_cb (ZifCompletion *completion, guint value, gpointer data)
-{
- _last_percent = value;
- _updates++;
-}
-
-static void
-zif_completion_test_subpercentage_changed_cb (ZifCompletion *completion, guint value, gpointer data)
-{
- _last_subpercent = value;
-}
-
-void
-zif_completion_test (EggTest *test)
-{
- ZifCompletion *completion;
- ZifCompletion *child;
- gboolean ret;
-
- if (!egg_test_start (test, "ZifCompletion"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get completion");
- completion = zif_completion_new ();
- egg_test_assert (test, completion != NULL);
- g_signal_connect (completion, "percentage-changed", G_CALLBACK (zif_completion_test_percentage_changed_cb), NULL);
- g_signal_connect (completion, "subpercentage-changed", G_CALLBACK (zif_completion_test_subpercentage_changed_cb), NULL);
-
- /************************************************************/
- egg_test_title (test, "set steps");
- ret = zif_completion_set_number_steps (completion, 5);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "done one step");
- ret = zif_completion_done (completion);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "ensure 1 update");
- egg_test_assert (test, (_updates == 1));
-
- /************************************************************/
- egg_test_title (test, "ensure correct percent");
- egg_test_assert (test, (_last_percent == 20));
-
- /************************************************************/
- egg_test_title (test, "done the rest");
- ret = zif_completion_done (completion);
- ret = zif_completion_done (completion);
- ret = zif_completion_done (completion);
- ret = zif_completion_done (completion);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "done one extra");
- ret = zif_completion_done (completion);
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "ensure 5 updates");
- egg_test_assert (test, (_updates == 5));
-
- /************************************************************/
- egg_test_title (test, "ensure correct percent");
- egg_test_assert (test, (_last_percent == 100));
-
- g_object_unref (completion);
-
- /* reset */
- _updates = 0;
- completion = zif_completion_new ();
- zif_completion_set_number_steps (completion, 2);
- g_signal_connect (completion, "percentage-changed", G_CALLBACK (zif_completion_test_percentage_changed_cb), NULL);
- g_signal_connect (completion, "subpercentage-changed", G_CALLBACK (zif_completion_test_subpercentage_changed_cb), NULL);
-
- // completion: |-----------------------|-----------------------|
- // step1: |-----------------------|
- // child: |-------------|---------|
-
- /* PARENT UPDATE */
- zif_completion_done (completion);
-
- /************************************************************/
- egg_test_title (test, "ensure 1 update");
- egg_test_assert (test, (_updates == 1));
-
- /************************************************************/
- egg_test_title (test, "ensure correct percent");
- egg_test_assert (test, (_last_percent == 50));
-
- /* now test with a child */
- child = zif_completion_get_child (completion);
- zif_completion_set_number_steps (child, 2);
-
- /* CHILD UPDATE */
- zif_completion_done (child);
-
- /************************************************************/
- egg_test_title (test, "ensure 2 updates");
- egg_test_assert (test, (_updates == 2));
-
- /************************************************************/
- egg_test_title (test, "ensure correct percent");
- egg_test_assert (test, (_last_percent == 75));
-
- /* CHILD UPDATE */
- zif_completion_done (child);
-
- /************************************************************/
- egg_test_title (test, "ensure 3 updates");
- if (_updates == 3)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "got %i updates", _updates);
-
- /************************************************************/
- egg_test_title (test, "ensure correct percent");
- egg_test_assert (test, (_last_percent == 100));
-
- /* PARENT UPDATE */
- zif_completion_done (completion);
-
- /************************************************************/
- egg_test_title (test, "ensure 3 updates (and we ignored the duplicate)");
- if (_updates == 3)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "got %i updates", _updates);
-
- /************************************************************/
- egg_test_title (test, "ensure still correct percent");
- egg_test_assert (test, (_last_percent == 100));
-
- egg_debug ("unref completion");
- g_object_unref (completion);
-
- egg_debug ("unref child");
- g_object_unref (child);
-
- egg_debug ("reset");
- /* reset */
- _updates = 0;
- completion = zif_completion_new ();
- zif_completion_set_number_steps (completion, 1);
- g_signal_connect (completion, "percentage-changed", G_CALLBACK (zif_completion_test_percentage_changed_cb), NULL);
- g_signal_connect (completion, "subpercentage-changed", G_CALLBACK (zif_completion_test_subpercentage_changed_cb), NULL);
-
- /* now test with a child */
- child = zif_completion_get_child (completion);
- zif_completion_set_number_steps (child, 2);
-
- /* CHILD SET VALUE */
- zif_completion_set_percentage (child, 33);
-
- /************************************************************/
- egg_test_title (test, "ensure 1 updates for completion with one step");
- egg_test_assert (test, (_updates == 1));
-
- /************************************************************/
- egg_test_title (test, "ensure using child value as parent");
- egg_test_assert (test, (_last_percent == 33));
-
- g_object_unref (completion);
- g_object_unref (child);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-completion.h b/backends/yum/libzif/zif-completion.h
deleted file mode 100644
index 1429172..0000000
--- a/backends/yum/libzif/zif-completion.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_COMPLETION_H
-#define __ZIF_COMPLETION_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_COMPLETION (zif_completion_get_type ())
-#define ZIF_COMPLETION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_COMPLETION, ZifCompletion))
-#define ZIF_COMPLETION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_COMPLETION, ZifCompletionClass))
-#define ZIF_IS_COMPLETION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_COMPLETION))
-#define ZIF_IS_COMPLETION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_COMPLETION))
-#define ZIF_COMPLETION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_COMPLETION, ZifCompletionClass))
-
-typedef struct _ZifCompletion ZifCompletion;
-typedef struct _ZifCompletionPrivate ZifCompletionPrivate;
-typedef struct _ZifCompletionClass ZifCompletionClass;
-
-struct _ZifCompletion
-{
- GObject parent;
- ZifCompletionPrivate *priv;
-};
-
-struct _ZifCompletionClass
-{
- GObjectClass parent_class;
- /* Signals */
- void (* percentage_changed) (ZifCompletion *completion,
- guint value);
- void (* subpercentage_changed) (ZifCompletion *completion,
- guint value);
- /* Padding for future expansion */
- void (*_zif_reserved1) (void);
- void (*_zif_reserved2) (void);
- void (*_zif_reserved3) (void);
- void (*_zif_reserved4) (void);
-};
-
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#define zif_completion_done(completion) zif_completion_done_real (completion, __func__, __LINE__)
-#define zif_completion_finished(completion) zif_completion_finished_real (completion, __func__, __LINE__)
-#define zif_completion_set_number_steps(completion, steps) zif_completion_set_number_steps_real (completion, steps, __func__, __LINE__)
-#elif defined(__GNUC__) && __GNUC__ >= 3
-#define zif_completion_done(completion) zif_completion_done_real (completion, __FUNCTION__, __LINE__)
-#define zif_completion_finished(completion) zif_completion_finished_real (completion, __FUNCTION__, __LINE__)
-#define zif_completion_set_number_steps(completion, steps) zif_completion_set_number_steps_real (completion, steps, __FUNCTION__, __LINE__)
-#else
-#define zif_completion_done(completion)
-#define zif_completion_finished(completion)
-#define zif_completion_set_number_steps(completion, steps)
-#endif
-
-GType zif_completion_get_type (void);
-ZifCompletion *zif_completion_new (void);
-ZifCompletion *zif_completion_get_child (ZifCompletion *completion);
-gboolean zif_completion_set_number_steps_real (ZifCompletion *completion,
- guint steps,
- const gchar *function_name,
- gint function_line);
-gboolean zif_completion_set_percentage (ZifCompletion *completion,
- guint percentage);
-guint zif_completion_get_percentage (ZifCompletion *completion);
-gboolean zif_completion_done_real (ZifCompletion *completion,
- const gchar *function_name,
- gint function_line);
-gboolean zif_completion_finished_real (ZifCompletion *completion,
- const gchar *function_name,
- gint function_line);
-gboolean zif_completion_reset (ZifCompletion *completion);
-
-G_END_DECLS
-
-#endif /* __ZIF_COMPLETION_H */
-
diff --git a/backends/yum/libzif/zif-config.c b/backends/yum/libzif/zif-config.c
deleted file mode 100644
index f904bb1..0000000
--- a/backends/yum/libzif/zif-config.c
+++ /dev/null
@@ -1,850 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-config
- * @short_description: A #ZifConfig object manages system wide config options
- *
- * #ZifConfig allows settings to be read from a central config file. Some
- * values can be overridden in a running instance.
- *
- * The values that are overridden can be reset back to the defaults without
- * re-reading the config file.
- *
- * Different types of data can be read (string, bool, uint, time).
- * Before reading any data, the backing config file has to be set with
- * zif_config_set_filename() and any reads prior to that will fail.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <string.h>
-
-#include <glib.h>
-#include <packagekit-glib2/packagekit.h>
-#include <rpm/rpmlib.h>
-
-#include "zif-config.h"
-#include "zif-utils.h"
-#include "zif-monitor.h"
-
-#include "egg-debug.h"
-
-#define ZIF_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_CONFIG, ZifConfigPrivate))
-
-struct _ZifConfigPrivate
-{
- GKeyFile *keyfile;
- gboolean loaded;
- ZifMonitor *monitor;
- GHashTable *hash;
- gchar **basearch_list;
-};
-
-G_DEFINE_TYPE (ZifConfig, zif_config, G_TYPE_OBJECT)
-static gpointer zif_config_object = NULL;
-
-/**
- * zif_config_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_config_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_config_error");
- return quark;
-}
-
-/**
- * zif_config_get_string:
- * @config: the #ZifConfig object
- * @key: the key name to retrieve, e.g. "cachedir"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets a string value from a local setting, falling back to the config file.
- *
- * Return value: the allocated value, or %NULL
- *
- * Since: 0.0.1
- **/
-gchar *
-zif_config_get_string (ZifConfig *config, const gchar *key, GError **error)
-{
- gchar *value = NULL;
- const gchar *value_tmp;
- const gchar *info;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_CONFIG (config), NULL);
- g_return_val_if_fail (key != NULL, NULL);
-
- /* not loaded yet */
- if (!config->priv->loaded) {
- g_set_error_literal (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "config not loaded");
- goto out;
- }
-
- /* exists as local override */
- value_tmp = g_hash_table_lookup (config->priv->hash, key);
- if (value_tmp != NULL) {
- value = g_strdup (value_tmp);
- goto out;
- }
-
- /* get value */
- value = g_key_file_get_string (config->priv->keyfile, "main", key, &error_local);
- if (value != NULL)
- goto out;
-
- /* special keys, FIXME: add to yum */
- if (g_strcmp0 (key, "reposdir") == 0) {
- value = g_strdup ("/etc/yum.repos.d");
- goto free_error;
- }
- if (g_strcmp0 (key, "pidfile") == 0) {
- value = g_strdup ("/var/run/yum.pid");
- goto free_error;
- }
-
- /* special rpmkeys */
- if (g_strcmp0 (key, "osinfo") == 0) {
- rpmGetOsInfo (&info, NULL);
- value = g_strdup (info);
- goto free_error;
- }
- if (g_strcmp0 (key, "archinfo") == 0) {
- rpmGetArchInfo (&info, NULL);
- value = g_strdup (info);
- goto free_error;
- }
-
- /* dumb metadata */
- if (g_strcmp0 (key, "basearch") == 0) {
- rpmGetArchInfo (&info, NULL);
- if (g_strcmp0 (info, "i486") == 0 ||
- g_strcmp0 (info, "i586") == 0 ||
- g_strcmp0 (info, "i686") == 0)
- info = "i386";
- value = g_strdup (info);
- goto free_error;
- }
-
- /* nothing matched */
- g_set_error (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "failed to read %s: %s", key, error_local->message);
-free_error:
- g_error_free (error_local);
-out:
- return value;
-}
-
-/**
- * zif_config_get_boolean:
- * @config: the #ZifConfig object
- * @key: the key name to retrieve, e.g. "keepcache"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets a boolean value from a local setting, falling back to the config file.
- *
- * Return value: %TRUE or %FALSE
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_config_get_boolean (ZifConfig *config, const gchar *key, GError **error)
-{
- gchar *value;
- gboolean ret = FALSE;
-
- g_return_val_if_fail (ZIF_IS_CONFIG (config), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* get string value */
- value = zif_config_get_string (config, key, error);
- if (value == NULL)
- goto out;
-
- /* convert to bool */
- ret = zif_boolean_from_text (value);
-
-out:
- g_free (value);
- return ret;
-}
-
-/**
- * zif_config_get_uint:
- * @config: the #ZifConfig object
- * @key: the key name to retrieve, e.g. "keepcache"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets a unsigned integer value from a local setting, falling back to the config file.
- *
- * Return value: the data value, or %G_MAXUINT for error
- *
- * Since: 0.0.1
- **/
-guint
-zif_config_get_uint (ZifConfig *config, const gchar *key, GError **error)
-{
- gchar *value;
- guint retval = G_MAXUINT;
- gchar *endptr = NULL;
-
- g_return_val_if_fail (ZIF_IS_CONFIG (config), G_MAXUINT);
- g_return_val_if_fail (key != NULL, G_MAXUINT);
- g_return_val_if_fail (error == NULL || *error == NULL, G_MAXUINT);
-
- /* get string value */
- value = zif_config_get_string (config, key, error);
- if (value == NULL)
- goto out;
-
- /* convert to int */
- retval = g_ascii_strtoull (value, &endptr, 10);
- if (value == endptr) {
- g_set_error (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "failed to convert '%s' to unsigned integer", value);
- goto out;
- }
-
-out:
- g_free (value);
- return retval;
-}
-
-/**
- * zif_config_string_to_time:
- *
- * Converts: 10s to 10
- * 10m to 600 (10*60)
- * 10h to 36000 (10*60*60)
- * 10d to 864000 (10*60*60*24)
- **/
-static guint
-zif_config_string_to_time (const gchar *value)
-{
- guint len;
- guint timeval = 0;
- gchar suffix;
- gchar *value_copy = NULL;
- gchar *endptr = NULL;
-
- g_return_val_if_fail (value != NULL, FALSE);
-
- /* long enough */
- len = strlen (value);
- if (len < 2)
- goto out;
-
- /* get suffix */
- suffix = value[len-1];
-
- /* remove suffix */
- value_copy = g_strdup (value);
- value_copy[len-1] = '\0';
-
- /* convert to number */
- timeval = g_ascii_strtoull (value_copy, &endptr, 10);
- if (value_copy == endptr) {
- egg_warning ("failed to convert %s", value_copy);
- goto out;
- }
-
- /* seconds, minutes, hours, days */
- if (suffix == 's')
- timeval *= 1;
- else if (suffix == 'm')
- timeval *= 60;
- else if (suffix == 'h')
- timeval *= 60*60;
- else if (suffix == 'd')
- timeval *= 24*60*60;
- else {
- egg_warning ("unknown suffix: '%c'", suffix);
- timeval = 0;
- }
-out:
- g_free (value_copy);
- return timeval;
-}
-
-/**
- * zif_config_get_time:
- * @config: the #ZifConfig object
- * @key: the key name to retrieve, e.g. "metadata_expire"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets a time value from a local setting, falling back to the config file.
- *
- * Return value: the data value, or 0 for an error
- *
- * Since: 0.0.1
- **/
-guint
-zif_config_get_time (ZifConfig *config, const gchar *key, GError **error)
-{
- gchar *value;
- guint timeval = 0;
-
- g_return_val_if_fail (ZIF_IS_CONFIG (config), 0);
- g_return_val_if_fail (key != NULL, 0);
- g_return_val_if_fail (error == NULL || *error == NULL, 0);
-
- /* get string value */
- value = zif_config_get_string (config, key, error);
- if (value == NULL)
- goto out;
-
- /* convert to time */
- timeval = zif_config_string_to_time (value);
-out:
- g_free (value);
- return timeval;
-}
-
-/**
- * zif_config_strreplace:
- **/
-static gchar *
-zif_config_strreplace (const gchar *text, const gchar *find, const gchar *replace)
-{
- gchar **array;
- gchar *retval;
-
- /* common case, not found */
- if (g_strstr_len (text, -1, find) == NULL) {
- return g_strdup (text);
- }
-
- /* split apart and rejoin with new delimiter */
- array = g_strsplit (text, find, 0);
- retval = g_strjoinv (replace, array);
- g_strfreev (array);
- return retval;
-}
-
-/**
- * zif_config_expand_substitutions:
- * @config: the #ZifConfig object
- * @text: string to scan, e.g. "http://fedora/$releasever/$basearch/moo.rpm"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Replaces substitutions in text with the actual values of the running system.
- *
- * Return value: A new allocated string or %NULL for error, free with g_free()
- *
- * Since: 0.0.1
- **/
-gchar *
-zif_config_expand_substitutions (ZifConfig *config, const gchar *text, GError **error)
-{
- gchar *basearch = NULL;
- gchar *releasever = NULL;
- gchar *name1 = NULL;
- gchar *name2 = NULL;
-
- g_return_val_if_fail (ZIF_IS_CONFIG (config), NULL);
- g_return_val_if_fail (text != NULL, NULL);
-
- /* get data */
- basearch = zif_config_get_string (config, "basearch", error);
- if (basearch == NULL)
- goto out;
-
- releasever = zif_config_get_string (config, "releasever", error);
- if (releasever == NULL)
- goto out;
-
- /* do the replacements */
- name1 = zif_config_strreplace (text, "$releasever", releasever);
- name2 = zif_config_strreplace (name1, "$basearch", basearch);
-
-out:
- g_free (basearch);
- g_free (releasever);
- g_free (name1);
- return name2;
-}
-
-/**
- * zif_config_get_basearch_array:
- * @config: the #ZifConfig object
- *
- * Gets the list of architectures that packages are native on for this machine.
- *
- * Return value: A array of strings, do not free, e.g. [ "i386", "i486", "noarch" ]
- *
- * Since: 0.0.1
- **/
-gchar **
-zif_config_get_basearch_array (ZifConfig *config)
-{
- g_return_val_if_fail (ZIF_IS_CONFIG (config), NULL);
- return config->priv->basearch_list;
-}
-
-/**
- * zif_config_get_release_filename:
- **/
-static const gchar *
-zif_config_get_release_filename (ZifConfig *config)
-{
- const gchar *filename;
- filename = "/etc/fedora-release";
- if (g_file_test (filename, G_FILE_TEST_EXISTS))
- return filename;
- filename = "/etc/redhat-release";
- if (g_file_test (filename, G_FILE_TEST_EXISTS))
- return filename;
- return NULL;
-}
-
-/**
- * zif_config_set_filename:
- * @config: the #ZifConfig object
- * @filename: the system wide config file, e.g. "/etc/yum.conf"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Sets the filename to use as the system wide config file.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_config_set_filename (ZifConfig *config, const gchar *filename, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- gchar *basearch = NULL;
- gchar *releasever = NULL;
- const gchar *release_filename;
- const gchar *text;
- GPtrArray *array;
- guint i;
-
- g_return_val_if_fail (ZIF_IS_CONFIG (config), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (!config->priv->loaded, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* check file exists */
- ret = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
- if (!ret) {
- g_set_error (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "config file %s does not exist", filename);
- goto out;
- }
-
- /* setup watch */
- ret = zif_monitor_add_watch (config->priv->monitor, filename, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "failed to setup watch: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* load file */
- ret = g_key_file_load_from_file (config->priv->keyfile, filename, G_KEY_FILE_NONE, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "failed to load config file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* done */
- config->priv->loaded = TRUE;
-
- /* calculate the release version if not specified in the config file */
- releasever = zif_config_get_string (config, "releasever", NULL);
- if (releasever == NULL) {
-
- /* get correct file */
- release_filename = zif_config_get_release_filename (config);
- if (release_filename == NULL) {
- ret = FALSE;
- g_set_error_literal (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "could not get a correct release filename");
- goto out;
- }
-
- /* get distro constants from fedora-release */
- ret = g_file_get_contents (release_filename, &releasever, NULL, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "failed to get distro release version: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* get the value from 'Fedora release 11.92 (Rawhide)' */
- g_strdelimit (releasever, " ", '\0');
-
- /* set local */
- ret = zif_config_set_local (config, "releasever", releasever+15, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "failed to set distro release version: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* calculate the valid basearchs */
- basearch = zif_config_get_string (config, "basearch", &error_local);
- if (basearch == NULL) {
- g_set_error (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "failed to get basearch: %s", error_local->message);
- g_error_free (error_local);
- ret = FALSE;
- goto out;
- }
-
- /* add valid archs to array */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- g_ptr_array_add (array, g_strdup (basearch));
- g_ptr_array_add (array, g_strdup ("noarch"));
- if (g_strcmp0 (basearch, "i386") == 0) {
- g_ptr_array_add (array, g_strdup ("i486"));
- g_ptr_array_add (array, g_strdup ("i586"));
- g_ptr_array_add (array, g_strdup ("i686"));
- }
-
- /* copy into GStrv array */
- config->priv->basearch_list = g_new0 (gchar*, array->len+1);
- for (i=0; i < array->len; i++) {
- text = g_ptr_array_index (array, i);
- config->priv->basearch_list[i] = g_strdup (text);
- }
- g_ptr_array_unref (array);
-out:
- g_free (basearch);
- g_free (releasever);
- return ret;
-}
-
-/**
- * zif_config_reset_default:
- * @config: the #ZifConfig object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Removes any local settings previously set.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_config_reset_default (ZifConfig *config, GError **error)
-{
- g_return_val_if_fail (ZIF_IS_CONFIG (config), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_hash_table_remove_all (config->priv->hash);
- return TRUE;
-}
-
-/**
- * zif_config_set_local:
- * @config: the #ZifConfig object
- * @key: the key name to save, e.g. "keepcache"
- * @value: the key data to save, e.g. "always"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Sets a local value which is used in preference to the config value.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_config_set_local (ZifConfig *config, const gchar *key, const gchar *value, GError **error)
-{
- const gchar *value_tmp;
- gboolean ret = TRUE;
-
- g_return_val_if_fail (ZIF_IS_CONFIG (config), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* already exists? */
- value_tmp = g_hash_table_lookup (config->priv->hash, key);
- if (value_tmp != NULL) {
- g_set_error (error, ZIF_CONFIG_ERROR, ZIF_CONFIG_ERROR_FAILED,
- "already set key %s to %s, cannot overwrite with %s", key, value_tmp, value);
- ret = FALSE;
- goto out;
- }
-
- /* insert into table */
- g_hash_table_insert (config->priv->hash, g_strdup (key), g_strdup (value));
-out:
- return ret;
-}
-
-/**
- * zif_config_file_monitor_cb:
- **/
-static void
-zif_config_file_monitor_cb (ZifMonitor *monitor, ZifConfig *config)
-{
- egg_warning ("config file changed");
- config->priv->loaded = FALSE;
-}
-
-/**
- * zif_config_finalize:
- **/
-static void
-zif_config_finalize (GObject *object)
-{
- ZifConfig *config;
- g_return_if_fail (ZIF_IS_CONFIG (object));
- config = ZIF_CONFIG (object);
-
- g_key_file_free (config->priv->keyfile);
- g_hash_table_unref (config->priv->hash);
- g_object_unref (config->priv->monitor);
- g_strfreev (config->priv->basearch_list);
-
- G_OBJECT_CLASS (zif_config_parent_class)->finalize (object);
-}
-
-/**
- * zif_config_class_init:
- **/
-static void
-zif_config_class_init (ZifConfigClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_config_finalize;
- g_type_class_add_private (klass, sizeof (ZifConfigPrivate));
-}
-
-/**
- * zif_config_init:
- **/
-static void
-zif_config_init (ZifConfig *config)
-{
- config->priv = ZIF_CONFIG_GET_PRIVATE (config);
- config->priv->keyfile = g_key_file_new ();
- config->priv->loaded = FALSE;
- config->priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- config->priv->basearch_list = NULL;
- config->priv->monitor = zif_monitor_new ();
- g_signal_connect (config->priv->monitor, "changed", G_CALLBACK (zif_config_file_monitor_cb), config);
-}
-
-/**
- * zif_config_new:
- *
- * Return value: A new #ZifConfig class instance.
- *
- * Since: 0.0.1
- **/
-ZifConfig *
-zif_config_new (void)
-{
- if (zif_config_object != NULL) {
- g_object_ref (zif_config_object);
- } else {
- zif_config_object = g_object_new (ZIF_TYPE_CONFIG, NULL);
- g_object_add_weak_pointer (zif_config_object, &zif_config_object);
- }
- return ZIF_CONFIG (zif_config_object);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_config_test (EggTest *test)
-{
- ZifConfig *config;
- gboolean ret;
- GError *error = NULL;
- gchar *value;
- guint time;
- guint len;
- gchar **array;
-
- if (!egg_test_start (test, "ZifConfig"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get config");
- config = zif_config_new ();
- egg_test_assert (test, config != NULL);
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_config_set_filename (config, "../test/etc/yum.conf", &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set filename '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "get cachedir");
- value = zif_config_get_string (config, "cachedir", NULL);
- if (g_strcmp0 (value, "../test/cache") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value '%s'", value);
- g_free (value);
-
- /************************************************************/
- egg_test_title (test, "get cachexxxdir");
- value = zif_config_get_string (config, "cachexxxdir", NULL);
- if (value == NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value '%s'", value);
- g_free (value);
-
- /************************************************************/
- egg_test_title (test, "get exactarch");
- ret = zif_config_get_boolean (config, "exactarch", NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "set local cachedir");
- ret = zif_config_set_local (config, "cachedir", "/tmp/cache", NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "set local cachedir (again, should fail)");
- ret = zif_config_set_local (config, "cachedir", "/tmp/cache", NULL);
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "get cachedir");
- value = zif_config_get_string (config, "cachedir", NULL);
- if (g_strcmp0 (value, "/tmp/cache") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value '%s'", value);
- g_free (value);
-
- /************************************************************/
- egg_test_title (test, "reset back to defaults");
- ret = zif_config_reset_default (config, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "get cachedir");
- value = zif_config_get_string (config, "cachedir", NULL);
- if (g_strcmp0 (value, "../test/cache") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value '%s'", value);
- g_free (value);
-
- /************************************************************/
- egg_test_title (test, "do substitutions (none)");
- value = zif_config_expand_substitutions (config, "http://fedora/4/6/moo.rpm", NULL);
- if (g_strcmp0 (value, "http://fedora/4/6/moo.rpm") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value '%s'", value);
- g_free (value);
-
- /************************************************************/
- egg_test_title (test, "do substitutions (both)");
- value = zif_config_expand_substitutions (config, "http://fedora/$releasever/$basearch/moo.rpm", NULL);
- if (g_strcmp0 (value, "http://fedora/11/i386/moo.rpm") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value '%s'", value);
- g_free (value);
-
- /************************************************************/
- egg_test_title (test, "get basearch array size");
- array = zif_config_get_basearch_array (config);
- len = g_strv_length (array);
- if (len == 5)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid size '%i'", len);
-
- /************************************************************/
- egg_test_title (test, "get basearch array value");
- if (g_strcmp0 (array[0], "i386") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value '%s'", array[0]);
-
- /************************************************************/
- egg_test_title (test, "convert time (invalid)");
- time = zif_config_string_to_time ("");
- egg_test_assert (test, (time == 0));
-
- /************************************************************/
- egg_test_title (test, "convert time (no suffix)");
- time = zif_config_string_to_time ("10");
- egg_test_assert (test, (time == 0));
-
- /************************************************************/
- egg_test_title (test, "convert time (invalid suffix)");
- time = zif_config_string_to_time ("10f");
- egg_test_assert (test, (time == 0));
-
- /************************************************************/
- egg_test_title (test, "convert time (seconds)");
- time = zif_config_string_to_time ("10s");
- egg_test_assert (test, (time == 10));
-
- /************************************************************/
- egg_test_title (test, "convert time (minutes)");
- time = zif_config_string_to_time ("10m");
- egg_test_assert (test, (time == 600));
-
- /************************************************************/
- egg_test_title (test, "convert time (hours)");
- time = zif_config_string_to_time ("10h");
- egg_test_assert (test, (time == 36000));
-
- /************************************************************/
- egg_test_title (test, "convert time (days)");
- time = zif_config_string_to_time ("10d");
- egg_test_assert (test, (time == 864000));
-
- g_object_unref (config);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-config.h b/backends/yum/libzif/zif-config.h
deleted file mode 100644
index 8ddd340..0000000
--- a/backends/yum/libzif/zif-config.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_CONFIG_H
-#define __ZIF_CONFIG_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_CONFIG (zif_config_get_type ())
-#define ZIF_CONFIG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_CONFIG, ZifConfig))
-#define ZIF_CONFIG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_CONFIG, ZifConfigClass))
-#define ZIF_IS_CONFIG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_CONFIG))
-#define ZIF_IS_CONFIG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_CONFIG))
-#define ZIF_CONFIG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_CONFIG, ZifConfigClass))
-#define ZIF_CONFIG_ERROR (zif_config_error_quark ())
-
-typedef struct _ZifConfig ZifConfig;
-typedef struct _ZifConfigPrivate ZifConfigPrivate;
-typedef struct _ZifConfigClass ZifConfigClass;
-
-struct _ZifConfig
-{
- GObject parent;
- ZifConfigPrivate *priv;
-};
-
-struct _ZifConfigClass
-{
- GObjectClass parent_class;
-};
-
-typedef enum {
- ZIF_CONFIG_ERROR_FAILED,
- ZIF_CONFIG_ERROR_LAST
-} ZifConfigError;
-
-GQuark zif_config_error_quark (void);
-GType zif_config_get_type (void);
-ZifConfig *zif_config_new (void);
-gboolean zif_config_set_filename (ZifConfig *config,
- const gchar *filename,
- GError **error);
-gchar *zif_config_get_string (ZifConfig *config,
- const gchar *key,
- GError **error);
-gboolean zif_config_get_boolean (ZifConfig *config,
- const gchar *key,
- GError **error);
-guint zif_config_get_uint (ZifConfig *config,
- const gchar *key,
- GError **error);
-guint zif_config_get_time (ZifConfig *config,
- const gchar *key,
- GError **error);
-gboolean zif_config_set_local (ZifConfig *config,
- const gchar *key,
- const gchar *value,
- GError **error);
-gboolean zif_config_reset_default (ZifConfig *config,
- GError **error);
-gchar *zif_config_expand_substitutions (ZifConfig *config,
- const gchar *text,
- GError **error);
-gchar **zif_config_get_basearch_array (ZifConfig *config);
-
-G_END_DECLS
-
-#endif /* __ZIF_CONFIG_H */
diff --git a/backends/yum/libzif/zif-depend.c b/backends/yum/libzif/zif-depend.c
deleted file mode 100644
index ccb467c..0000000
--- a/backends/yum/libzif/zif-depend.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-
-#include "egg-debug.h"
-
-#include "zif-utils.h"
-#include "zif-depend.h"
-
-/**
- * zif_depend_flag_to_string:
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_depend_flag_to_string (ZifDependFlag flag)
-{
- if (flag == ZIF_DEPEND_FLAG_ANY)
- return "~";
- if (flag == ZIF_DEPEND_FLAG_LESS)
- return "<";
- if (flag == ZIF_DEPEND_FLAG_GREATER)
- return ">";
- if (flag == ZIF_DEPEND_FLAG_EQUAL)
- return "=";
- return "unknown";
-}
-
-/**
- * zif_depend_new:
- *
- * Since: 0.0.1
- **/
-ZifDepend *
-zif_depend_new (const gchar *name, ZifDependFlag flag, const gchar *version)
-{
- ZifDepend *depend;
- depend = g_new0 (ZifDepend, 1);
- depend->count = 1;
- depend->name = g_strdup (name);
- depend->flag = flag;
- depend->version = g_strdup (version);
- return depend;
-}
-
-/**
- * zif_depend_new_value:
- *
- * Since: 0.0.1
- **/
-ZifDepend *
-zif_depend_new_value (gchar *name, ZifDependFlag flag, gchar *version)
-{
- ZifDepend *depend;
- depend = g_new0 (ZifDepend, 1);
- depend->count = 1;
- depend->name = name;
- depend->flag = flag;
- depend->version = version;
- return depend;
-}
-
-/**
- * zif_depend_ref:
- *
- * Since: 0.0.1
- **/
-ZifDepend *
-zif_depend_ref (ZifDepend *depend)
-{
- g_return_val_if_fail (depend != NULL, NULL);
- depend->count++;
- return depend;
-}
-
-/**
- * zif_depend_unref:
- *
- * Since: 0.0.1
- **/
-ZifDepend *
-zif_depend_unref (ZifDepend *depend)
-{
- if (depend == NULL)
- zif_debug_crash ();
-
- g_return_val_if_fail (depend != NULL, NULL);
- depend->count--;
- if (depend->count == 0) {
- g_free (depend->name);
- g_free (depend->version);
- g_free (depend);
- depend = NULL;
- }
- return depend;
-}
-
-/**
- * zif_depend_to_string:
- *
- * Since: 0.0.1
- **/
-gchar *
-zif_depend_to_string (const ZifDepend *depend)
-{
- g_return_val_if_fail (depend != NULL, NULL);
- if (depend->version == NULL)
- return g_strdup (depend->name);
- return g_strdup_printf ("%s %s %s", depend->name, zif_depend_flag_to_string (depend->flag), depend->version);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_depend_test (EggTest *test)
-{
- ZifDepend *depend;
-
- if (!egg_test_start (test, "ZifDepend"))
- return;
-
- /************************************************************/
- egg_test_title (test, "create");
- depend = zif_depend_new ("kernel", ZIF_DEPEND_FLAG_GREATER, "2.6.0");
- if (g_strcmp0 (depend->name, "kernel") == 0 && depend->count == 1)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect value %s:%i", depend->name, depend->count);
-
- /************************************************************/
- egg_test_title (test, "ref");
- zif_depend_ref (depend);
- egg_test_assert (test, depend->count == 2);
-
- /************************************************************/
- egg_test_title (test, "unref");
- zif_depend_unref (depend);
- egg_test_assert (test, depend->count == 1);
-
- /************************************************************/
- egg_test_title (test, "unref");
- depend = zif_depend_unref (depend);
- egg_test_assert (test, depend == NULL);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-depend.h b/backends/yum/libzif/zif-depend.h
deleted file mode 100644
index 2226bf1..0000000
--- a/backends/yum/libzif/zif-depend.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_DEPEND_H
-#define __ZIF_DEPEND_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-typedef enum {
- ZIF_DEPEND_FLAG_ANY,
- ZIF_DEPEND_FLAG_LESS,
- ZIF_DEPEND_FLAG_GREATER,
- ZIF_DEPEND_FLAG_EQUAL,
- ZIF_DEPEND_FLAG_UNKNOWN
-} ZifDependFlag;
-
-typedef struct {
- gchar *name;
- ZifDependFlag flag;
- gchar *version;
- guint count;
-} ZifDepend;
-
-ZifDepend *zif_depend_new (const gchar *name,
- ZifDependFlag flag,
- const gchar *version);
-ZifDepend *zif_depend_new_value (gchar *name,
- ZifDependFlag flag,
- gchar *version);
-ZifDepend *zif_depend_ref (ZifDepend *depend);
-ZifDepend *zif_depend_unref (ZifDepend *depend);
-gchar *zif_depend_to_string (const ZifDepend *depend);
-const gchar *zif_depend_flag_to_string (ZifDependFlag flag);
-
-G_END_DECLS
-
-#endif /* __ZIF_DEPEND_H */
-
diff --git a/backends/yum/libzif/zif-download.c b/backends/yum/libzif/zif-download.c
deleted file mode 100644
index d896615..0000000
--- a/backends/yum/libzif/zif-download.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-download
- * @short_description: Generic object to download packages.
- *
- * This object is a trivial wrapper around libsoup.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <libsoup/soup.h>
-
-#include "zif-config.h"
-#include "zif-download.h"
-#include "zif-completion.h"
-
-#include "egg-debug.h"
-
-#define ZIF_DOWNLOAD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_DOWNLOAD, ZifDownloadPrivate))
-
-/**
- * ZifDownloadPrivate:
- *
- * Private #ZifDownload data
- **/
-struct _ZifDownloadPrivate
-{
- gchar *proxy;
- SoupSession *session;
- SoupMessage *msg;
- ZifCompletion *completion;
- ZifConfig *config;
-};
-
-static gpointer zif_download_object = NULL;
-
-G_DEFINE_TYPE (ZifDownload, zif_download, G_TYPE_OBJECT)
-
-/**
- * zif_download_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_download_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_download_error");
- return quark;
-}
-
-/**
- * zif_download_file_got_chunk_cb:
- **/
-static void
-zif_download_file_got_chunk_cb (SoupMessage *msg, SoupBuffer *chunk, ZifDownload *download)
-{
- guint percentage;
- guint header_size;
- guint body_length;
-
- /* get data */
- body_length = (guint) msg->response_body->length;
- header_size = soup_message_headers_get_content_length (msg->response_headers);
-
- /* how can this happen */
- if (header_size < body_length) {
- egg_warning ("length=%i/%i", body_length, header_size);
- goto out;
- }
-
- /* calulate percentage */
- percentage = (100 * body_length) / header_size;
- if (percentage == 100) {
- egg_warning ("ignoring percentage: %i", percentage);
- goto out;
- }
-
- egg_debug ("DOWNLOAD: %i%% (%i, %i) - %p, %p", percentage, body_length, header_size, msg, download);
- zif_completion_set_percentage (download->priv->completion, percentage);
-
-out:
- return;
-}
-
-/**
- * zif_download_file_finished_cb:
- **/
-static void
-zif_download_file_finished_cb (SoupMessage *msg, ZifDownload *download)
-{
- egg_debug ("done!");
- g_object_unref (download->priv->msg);
- download->priv->msg = NULL;
-}
-
-/**
- * zif_download_cancelled_cb:
- **/
-static void
-zif_download_cancelled_cb (GCancellable *cancellable, ZifDownload *download)
-{
- g_return_if_fail (ZIF_IS_DOWNLOAD (download));
-
- /* check we have a download */
- if (download->priv->msg == NULL) {
- egg_debug ("nothing to cancel");
- return;
- }
-
- /* cancel */
- egg_warning ("cancelling download");
- soup_session_cancel_message (download->priv->session, download->priv->msg, SOUP_STATUS_CANCELLED);
-}
-
-/**
- * zif_download_file:
- * @download: the #ZifDownload object
- * @uri: the full remote URI
- * @filename: the local filename to save to
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Downloads a file.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_download_file (ZifDownload *download, const gchar *uri, const gchar *filename, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- SoupURI *base_uri;
- SoupMessage *msg = NULL;
- GError *error_local = NULL;
- gulong cancellable_id = 0;
-
- g_return_val_if_fail (ZIF_IS_DOWNLOAD (download), FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (download->priv->msg == NULL, FALSE);
- g_return_val_if_fail (download->priv->session != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* save an instance of the completion object */
- download->priv->completion = g_object_ref (completion);
-
- /* set up cancel */
- if (cancellable != NULL) {
- g_cancellable_reset (cancellable);
- cancellable_id = g_cancellable_connect (cancellable, G_CALLBACK (zif_download_cancelled_cb), download, NULL);
- }
-
- base_uri = soup_uri_new (uri);
- if (base_uri == NULL) {
- g_set_error (error, ZIF_DOWNLOAD_ERROR, ZIF_DOWNLOAD_ERROR_FAILED,
- "could not parse uri: %s", uri);
- goto out;
- }
-
- /* GET package */
- msg = soup_message_new_from_uri (SOUP_METHOD_GET, base_uri);
- if (msg == NULL) {
- g_set_error_literal (error, ZIF_DOWNLOAD_ERROR, ZIF_DOWNLOAD_ERROR_FAILED,
- "could not setup message");
- goto out;
- }
-
- /* we want progress updates */
- g_signal_connect (msg, "got-chunk", G_CALLBACK (zif_download_file_got_chunk_cb), download);
- g_signal_connect (msg, "finished", G_CALLBACK (zif_download_file_finished_cb), download);
-
- /* we need this for cancelling */
- download->priv->msg = g_object_ref (msg);
-
- /* request */
-// soup_message_set_flags (msg, SOUP_MESSAGE_NO_REDIRECT);
-
- /* send sync */
- soup_session_send_message (download->priv->session, msg);
-
- /* find length */
- if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
- g_set_error (error, ZIF_DOWNLOAD_ERROR, ZIF_DOWNLOAD_ERROR_FAILED,
- "failed to get valid response for %s: %s", uri, soup_status_get_phrase (msg->status_code));
- goto out;
- }
-
- /* write file */
- ret = g_file_set_contents (filename, msg->response_body->data, msg->response_body->length, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_DOWNLOAD_ERROR, ZIF_DOWNLOAD_ERROR_FAILED,
- "failed to write file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-out:
- if (cancellable_id != 0)
- g_cancellable_disconnect (cancellable, cancellable_id);
- g_object_unref (download->priv->completion);
- download->priv->completion = NULL;
- if (base_uri != NULL)
- soup_uri_free (base_uri);
- if (msg != NULL)
- g_object_unref (msg);
- return ret;
-}
-
-/**
- * zif_download_set_proxy:
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_download_set_proxy (ZifDownload *download, const gchar *http_proxy, GError **error)
-{
- gboolean ret = FALSE;
- SoupURI *proxy = NULL;
- guint connection_timeout;
-
- g_return_val_if_fail (ZIF_IS_DOWNLOAD (download), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* get default value from the config file */
- connection_timeout = zif_config_get_uint (download->priv->config, "connection_timeout", NULL);
- if (connection_timeout == G_MAXUINT)
- connection_timeout = 5;
-
- /* setup the session */
- if (http_proxy != NULL) {
- egg_debug ("using proxy %s", http_proxy);
- proxy = soup_uri_new (http_proxy);
- }
- download->priv->session = soup_session_sync_new_with_options (SOUP_SESSION_PROXY_URI, proxy,
- SOUP_SESSION_USER_AGENT, "zif",
- SOUP_SESSION_TIMEOUT, connection_timeout,
- NULL);
- if (download->priv->session == NULL) {
- g_set_error_literal (error, ZIF_DOWNLOAD_ERROR, ZIF_DOWNLOAD_ERROR_FAILED,
- "could not setup session");
- goto out;
- }
- ret = TRUE;
-out:
- if (proxy != NULL)
- soup_uri_free (proxy);
- return ret;
-}
-
-/**
- * zif_download_finalize:
- **/
-static void
-zif_download_finalize (GObject *object)
-{
- ZifDownload *download;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_DOWNLOAD (object));
- download = ZIF_DOWNLOAD (object);
-
- g_free (download->priv->proxy);
- if (download->priv->msg != NULL)
- g_object_unref (download->priv->msg);
- if (download->priv->session != NULL)
- g_object_unref (download->priv->session);
- g_object_unref (download->priv->config);
-
- G_OBJECT_CLASS (zif_download_parent_class)->finalize (object);
-}
-
-/**
- * zif_download_class_init:
- **/
-static void
-zif_download_class_init (ZifDownloadClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_download_finalize;
-
- g_type_class_add_private (klass, sizeof (ZifDownloadPrivate));
-}
-
-/**
- * zif_download_init:
- **/
-static void
-zif_download_init (ZifDownload *download)
-{
- download->priv = ZIF_DOWNLOAD_GET_PRIVATE (download);
- download->priv->msg = NULL;
- download->priv->session = NULL;
- download->priv->proxy = NULL;
- download->priv->completion = NULL;
- download->priv->config = zif_config_new ();
-}
-
-/**
- * zif_download_new:
- *
- * Return value: A new download class instance.
- *
- * Since: 0.0.1
- **/
-ZifDownload *
-zif_download_new (void)
-{
- if (zif_download_object != NULL) {
- g_object_ref (zif_download_object);
- } else {
- zif_download_object = g_object_new (ZIF_TYPE_DOWNLOAD, NULL);
- g_object_add_weak_pointer (zif_download_object, &zif_download_object);
- }
- return ZIF_DOWNLOAD (zif_download_object);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-static guint _updates = 0;
-static GMainLoop *_loop = NULL;
-
-static void
-zif_download_progress_changed (ZifDownload *download, guint value, gpointer data)
-{
- _updates++;
-}
-
-static gboolean
-zif_download_cancel_cb (GCancellable *cancellable)
-{
- egg_debug ("sending cancel");
- g_cancellable_cancel (cancellable);
- g_main_loop_quit (_loop);
- return FALSE;
-}
-
-static gpointer
-zif_download_cancel_thread_cb (GCancellable *cancellable)
-{
- egg_debug ("thread running");
- g_timeout_add (50, (GSourceFunc) zif_download_cancel_cb, cancellable);
- _loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (_loop);
- g_main_loop_unref (_loop);
- return NULL;
-}
-
-void
-zif_download_test (EggTest *test)
-{
- ZifDownload *download;
- ZifCompletion *completion;
- GCancellable *cancellable;
- gboolean ret;
- GError *error = NULL;
-
- if (!egg_test_start (test, "ZifDownload"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get download");
- download = zif_download_new ();
- cancellable = g_cancellable_new ();
- egg_test_assert (test, download != NULL);
-
- completion = zif_completion_new ();
- g_signal_connect (completion, "percentage-changed", G_CALLBACK (zif_download_progress_changed), NULL);
-
- /************************************************************/
- egg_test_title (test, "set proxy");
- ret = zif_download_set_proxy (download, NULL, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "cancel not yet started download");
- g_cancellable_cancel (cancellable);
- egg_test_assert (test, TRUE);
-
- /************************************************************/
- egg_test_title (test, "download file");
- ret = zif_download_file (download, "http://people.freedesktop.org/~hughsient/temp/Screenshot.png",
- "../test/downloads", cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "enough updates");
- if (_updates > 5)
- egg_test_success (test, "got %i updates", _updates);
- else
- egg_test_failed (test, "got %i updates", _updates);
-
- /* setup cancel */
- g_thread_create ((GThreadFunc) zif_download_cancel_thread_cb, cancellable, FALSE, NULL);
-
- /************************************************************/
- egg_test_title (test, "download second file (should be cancelled)");
- zif_completion_reset (completion);
- ret = zif_download_file (download, "http://people.freedesktop.org/~hughsient/temp/Screenshot.png",
- "../test/downloads", cancellable, completion, &error);
- if (!ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to be cancelled");
-
- g_object_unref (download);
- g_object_unref (completion);
- g_object_unref (cancellable);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-download.h b/backends/yum/libzif/zif-download.h
deleted file mode 100644
index 73b91ed..0000000
--- a/backends/yum/libzif/zif-download.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_DOWNLOAD_H
-#define __ZIF_DOWNLOAD_H
-
-#include <glib-object.h>
-#include "zif-completion.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_DOWNLOAD (zif_download_get_type ())
-#define ZIF_DOWNLOAD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_DOWNLOAD, ZifDownload))
-#define ZIF_DOWNLOAD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_DOWNLOAD, ZifDownloadClass))
-#define ZIF_IS_DOWNLOAD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_DOWNLOAD))
-#define ZIF_IS_DOWNLOAD_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_DOWNLOAD))
-#define ZIF_DOWNLOAD_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_DOWNLOAD, ZifDownloadClass))
-#define ZIF_DOWNLOAD_ERROR (zif_download_error_quark ())
-
-typedef struct _ZifDownload ZifDownload;
-typedef struct _ZifDownloadPrivate ZifDownloadPrivate;
-typedef struct _ZifDownloadClass ZifDownloadClass;
-
-struct _ZifDownload
-{
- GObject parent;
- ZifDownloadPrivate *priv;
-};
-
-struct _ZifDownloadClass
-{
- GObjectClass parent_class;
-};
-
-typedef enum {
- ZIF_DOWNLOAD_ERROR_FAILED,
- ZIF_DOWNLOAD_ERROR_LAST
-} ZifDownloadError;
-
-GType zif_download_get_type (void);
-GQuark zif_download_error_quark (void);
-ZifDownload *zif_download_new (void);
-gboolean zif_download_set_proxy (ZifDownload *download,
- const gchar *http_proxy,
- GError **error);
-gboolean zif_download_file (ZifDownload *download,
- const gchar *uri,
- const gchar *filename,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_DOWNLOAD_H */
-
diff --git a/backends/yum/libzif/zif-groups.c b/backends/yum/libzif/zif-groups.c
deleted file mode 100644
index 9974d02..0000000
--- a/backends/yum/libzif/zif-groups.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-groups
- * @short_description: A #ZifGroups class handles category to group mapping
- *
- * In Zif, we have a few groups that are enumerated, and categories that are
- * not enumerated and are custom to the vendor. The mapping from categories
- * to groups (and vice versa) is done with a mapping file which has to be
- * set using zif_groups_set_mapping_file() before any queries are done.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <string.h>
-
-#include <glib.h>
-
-#include "zif-groups.h"
-#include "zif-monitor.h"
-
-#include "egg-debug.h"
-
-#define ZIF_GROUPS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_GROUPS, ZifGroupsPrivate))
-
-/**
- * ZifGroupsPrivate:
- *
- * Private #ZifGroups data
- **/
-struct _ZifGroupsPrivate
-{
- gboolean loaded;
- PkBitfield groups;
- GPtrArray *categories;
- GHashTable *hash;
- gchar *mapping_file;
- ZifMonitor *monitor;
-};
-
-G_DEFINE_TYPE (ZifGroups, zif_groups, G_TYPE_OBJECT)
-static gpointer zif_groups_object = NULL;
-
-/**
- * zif_groups_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_groups_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_groups_error");
- return quark;
-}
-
-/**
- * zif_groups_set_mapping_file:
- * @groups: the #ZifGroups object
- * @mapping_file: mapping file from categories to groups
- * @error: a #GError which is used on failure, or %NULL
- *
- * This sets up the file that is used to map categories to group enums.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_groups_set_mapping_file (ZifGroups *groups, const gchar *mapping_file, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_GROUPS (groups), FALSE);
- g_return_val_if_fail (groups->priv->mapping_file == NULL, FALSE);
- g_return_val_if_fail (!groups->priv->loaded, FALSE);
- g_return_val_if_fail (mapping_file != NULL, FALSE);
-
- /* check file exists */
- ret = g_file_test (mapping_file, G_FILE_TEST_IS_REGULAR);
- if (!ret) {
- g_set_error (error, ZIF_GROUPS_ERROR, ZIF_GROUPS_ERROR_FAILED,
- "mapping file %s does not exist", mapping_file);
- goto out;
- }
-
- /* setup watch */
- ret = zif_monitor_add_watch (groups->priv->monitor, mapping_file, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_GROUPS_ERROR, ZIF_GROUPS_ERROR_FAILED,
- "failed to setup watch: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- groups->priv->mapping_file = g_strdup (mapping_file);
-out:
- return ret;
-}
-
-/**
- * zif_groups_load:
- * @groups: the #ZifGroups object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Loads the mapping file from disk into memory.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_groups_load (ZifGroups *groups, GError **error)
-{
- gboolean ret = TRUE;
- gchar *data = NULL;
- gchar **lines = NULL;
- gchar **cols;
- gchar **entries;
- guint i, j;
- PkGroupEnum group;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_GROUPS (groups), FALSE);
- g_return_val_if_fail (groups->priv->categories->len == 0, FALSE);
-
- /* already loaded */
- if (groups->priv->loaded)
- goto out;
-
- /* no mapping file */
- if (groups->priv->mapping_file == NULL) {
- egg_warning ("no mapping file, so cannot load group lists");
- goto out;
- }
-
- /* get data */
- ret = g_file_get_contents (groups->priv->mapping_file, &data, NULL, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_GROUPS_ERROR, ZIF_GROUPS_ERROR_FAILED,
- "failed to get groups data: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* process each line */
- lines = g_strsplit (data, "\n", 0);
- for (i=0; lines[i] != NULL; i++) {
- cols = g_strsplit (lines[i], "=", -1);
- if (g_strv_length (cols) != 2)
- goto cont;
-
- /* add to groups list */
- group = pk_group_enum_from_text (cols[0]);
- pk_bitfield_add (groups->priv->groups, group);
-
- /* add entries to cats list and dist */
- entries = g_strsplit (cols[1], ",", -1);
- for (j=0; entries[j] != NULL; j++) {
- g_ptr_array_add (groups->priv->categories, g_strdup (entries[j]));
- g_hash_table_insert (groups->priv->hash, g_strdup (entries[j]), GUINT_TO_POINTER(group));
- }
- g_strfreev (entries);
-cont:
- g_strfreev (cols);
- }
-
- groups->priv->loaded = TRUE;
-
-out:
- g_free (data);
- g_strfreev (lines);
- return ret;
-}
-
-/**
- * zif_groups_get_groups:
- * @groups: the #ZifGroups object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the groups supported by the packaging system.
- *
- * Return value: A #PkBitfield of the groups that are supported
- *
- * Since: 0.0.1
- **/
-PkBitfield
-zif_groups_get_groups (ZifGroups *groups, GError **error)
-{
- GError *error_local;
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_GROUPS (groups), 0);
-
- /* if not already loaded, load */
- if (!groups->priv->loaded) {
- ret = zif_groups_load (groups, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_GROUPS_ERROR, ZIF_GROUPS_ERROR_FAILED,
- "failed to load config file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-out:
- return groups->priv->groups;
-}
-
-/**
- * zif_groups_get_categories:
- * @groups: the #ZifGroups object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the categories supported by the packaging system.
- *
- * Return value: category list as an array of strings
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_groups_get_categories (ZifGroups *groups, GError **error)
-{
- guint i;
- GPtrArray *array = NULL;
- GError *error_local;
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_GROUPS (groups), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!groups->priv->loaded) {
- ret = zif_groups_load (groups, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_GROUPS_ERROR, ZIF_GROUPS_ERROR_FAILED,
- "failed to load config file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- for (i=0; i<groups->priv->categories->len; i++)
- g_ptr_array_add (array, g_strdup (g_ptr_array_index (groups->priv->categories, i)));
-out:
- return array;
-}
-
-/**
- * zif_groups_get_group_for_cat:
- * @groups: the #ZifGroups object
- * @cat: the category name, e.g. "games/action"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Returns the group enumerated type for the category.
- *
- * Return value: the specific #PkGroupEnum or %PK_GROUP_ENUM_UNKNOWN
- *
- * Since: 0.0.1
- **/
-PkGroupEnum
-zif_groups_get_group_for_cat (ZifGroups *groups, const gchar *cat, GError **error)
-{
- gpointer data;
- PkGroupEnum group = PK_GROUP_ENUM_UNKNOWN;
- GError *error_local;
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_GROUPS (groups), PK_GROUP_ENUM_UNKNOWN);
- g_return_val_if_fail (cat != NULL, PK_GROUP_ENUM_UNKNOWN);
- g_return_val_if_fail (error == NULL || *error == NULL, PK_GROUP_ENUM_UNKNOWN);
-
- /* if not already loaded, load */
- if (!groups->priv->loaded) {
- ret = zif_groups_load (groups, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_GROUPS_ERROR, ZIF_GROUPS_ERROR_FAILED,
- "failed to load config file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get cat -> group mapping */
- data = g_hash_table_lookup (groups->priv->hash, cat);
- if (data == NULL)
- goto out;
-
- group = GPOINTER_TO_INT(data);
-out:
- return group;
-}
-
-/**
- * zif_groups_file_monitor_cb:
- **/
-static void
-zif_groups_file_monitor_cb (ZifMonitor *monitor, ZifGroups *groups)
-{
- /* free invalid data */
- groups->priv->loaded = FALSE;
- g_ptr_array_set_size (groups->priv->categories, 0);
- g_hash_table_remove_all (groups->priv->hash);
-
- egg_debug ("mapping file changed");
-}
-
-/**
- * zif_groups_finalize:
- **/
-static void
-zif_groups_finalize (GObject *object)
-{
- ZifGroups *groups;
- g_return_if_fail (ZIF_IS_GROUPS (object));
- groups = ZIF_GROUPS (object);
-
- g_ptr_array_unref (groups->priv->categories);
- g_hash_table_unref (groups->priv->hash);
- g_free (groups->priv->mapping_file);
- g_object_unref (groups->priv->monitor);
-
- G_OBJECT_CLASS (zif_groups_parent_class)->finalize (object);
-}
-
-/**
- * zif_groups_class_init:
- **/
-static void
-zif_groups_class_init (ZifGroupsClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_groups_finalize;
- g_type_class_add_private (klass, sizeof (ZifGroupsPrivate));
-}
-
-/**
- * zif_groups_init:
- **/
-static void
-zif_groups_init (ZifGroups *groups)
-{
- groups->priv = ZIF_GROUPS_GET_PRIVATE (groups);
- groups->priv->mapping_file = NULL;
- groups->priv->loaded = FALSE;
- groups->priv->groups = 0;
- groups->priv->categories = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- groups->priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
- groups->priv->monitor = zif_monitor_new ();
- g_signal_connect (groups->priv->monitor, "changed", G_CALLBACK (zif_groups_file_monitor_cb), groups);
-}
-
-/**
- * zif_groups_new:
- *
- * Return value: A new #ZifGroups class instance.
- *
- * Since: 0.0.1
- **/
-ZifGroups *
-zif_groups_new (void)
-{
- if (zif_groups_object != NULL) {
- g_object_ref (zif_groups_object);
- } else {
- zif_groups_object = g_object_new (ZIF_TYPE_GROUPS, NULL);
- g_object_add_weak_pointer (zif_groups_object, &zif_groups_object);
- }
- return ZIF_GROUPS (zif_groups_object);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_groups_test (EggTest *test)
-{
- ZifGroups *groups;
- gboolean ret;
- GPtrArray *array;
- GError *error = NULL;
- PkGroupEnum group;
- PkBitfield groups_bit;
- gchar *text;
-
- if (!egg_test_start (test, "ZifGroups"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get groups");
- groups = zif_groups_new ();
- egg_test_assert (test, groups != NULL);
-
- /************************************************************/
- egg_test_title (test, "set mapping file");
- ret = zif_groups_set_mapping_file (groups, "../test/share/yum-comps-groups.conf", &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set file '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_groups_load (groups, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "get groups");
- groups_bit = zif_groups_get_groups (groups, NULL);
- text = pk_group_bitfield_to_string (groups_bit);
- if (g_strcmp0 (text, "admin-tools;desktop-gnome;desktop-kde;desktop-other;"
- "education;fonts;games;graphics;internet;"
- "legacy;localization;multimedia;office;other;programming;"
- "publishing;servers;system;virtualization") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid groups '%s'", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "get categories");
- array = zif_groups_get_categories (groups, NULL);
- if (array->len > 100)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid size '%i'", array->len);
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "get group for cat");
- group = zif_groups_get_group_for_cat (groups, "language-support;kashubian-support", NULL);
- if (g_strcmp0 (pk_group_enum_to_text(group), "localization") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid groups '%s'", pk_group_enum_to_text (group));
-
- g_object_unref (groups);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-groups.h b/backends/yum/libzif/zif-groups.h
deleted file mode 100644
index 1d94f27..0000000
--- a/backends/yum/libzif/zif-groups.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_GROUPS_H
-#define __ZIF_GROUPS_H
-
-#include <glib-object.h>
-#include <packagekit-glib2/packagekit.h>
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_GROUPS (zif_groups_get_type ())
-#define ZIF_GROUPS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_GROUPS, ZifGroups))
-#define ZIF_GROUPS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_GROUPS, ZifGroupsClass))
-#define ZIF_IS_GROUPS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_GROUPS))
-#define ZIF_IS_GROUPS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_GROUPS))
-#define ZIF_GROUPS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_GROUPS, ZifGroupsClass))
-#define ZIF_GROUPS_ERROR (zif_groups_error_quark ())
-
-typedef struct _ZifGroups ZifGroups;
-typedef struct _ZifGroupsPrivate ZifGroupsPrivate;
-typedef struct _ZifGroupsClass ZifGroupsClass;
-
-struct _ZifGroups
-{
- GObject parent;
- ZifGroupsPrivate *priv;
-};
-
-struct _ZifGroupsClass
-{
- GObjectClass parent_class;
-};
-
-typedef enum {
- ZIF_GROUPS_ERROR_FAILED,
- ZIF_GROUPS_ERROR_LAST
-} ZifGroupsError;
-
-GType zif_groups_get_type (void);
-GQuark zif_groups_error_quark (void);
-ZifGroups *zif_groups_new (void);
-gboolean zif_groups_set_mapping_file (ZifGroups *groups,
- const gchar *mapping_file,
- GError **error);
-gboolean zif_groups_load (ZifGroups *groups,
- GError **error);
-PkBitfield zif_groups_get_groups (ZifGroups *groups,
- GError **error);
-GPtrArray *zif_groups_get_categories (ZifGroups *groups,
- GError **error);
-PkGroupEnum zif_groups_get_group_for_cat (ZifGroups *groups,
- const gchar *cat,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_GROUPS_H */
diff --git a/backends/yum/libzif/zif-lock.c b/backends/yum/libzif/zif-lock.c
deleted file mode 100644
index e5c8f14..0000000
--- a/backends/yum/libzif/zif-lock.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-lock
- * @short_description: Generic object to lock the package system.
- *
- * This object works with the generic lock file.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <glib.h>
-#include <glib/gstdio.h>
-
-#include "zif-lock.h"
-#include "zif-config.h"
-
-#include "egg-debug.h"
-
-#define ZIF_LOCK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_LOCK, ZifLockPrivate))
-
-/**
- * ZifLockPrivate:
- *
- * Private #ZifLock data
- **/
-struct _ZifLockPrivate
-{
- gchar *filename;
- ZifConfig *config;
- gboolean self_locked;
-};
-
-static gpointer zif_lock_object = NULL;
-
-G_DEFINE_TYPE (ZifLock, zif_lock, G_TYPE_OBJECT)
-
-/**
- * zif_lock_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_lock_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_lock_error");
- return quark;
-}
-
-/**
- * zif_lock_get_pid:
- **/
-static guint
-zif_lock_get_pid (ZifLock *lock)
-{
- gboolean ret;
- GError *error = NULL;
- guint64 pid = 0;
- gchar *contents = NULL;
- gchar *endptr = NULL;
-
- g_return_val_if_fail (ZIF_IS_LOCK (lock), FALSE);
-
- /* file doesn't exists */
- ret = g_file_test (lock->priv->filename, G_FILE_TEST_EXISTS);
- if (!ret)
- goto out;
-
- /* get contents */
- ret = g_file_get_contents (lock->priv->filename, &contents, NULL, &error);
- if (!ret) {
- egg_warning ("failed to get data: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* convert to int */
- pid = g_ascii_strtoull (contents, &endptr, 10);
-
- /* failed to parse */
- if (contents == endptr) {
- egg_warning ("failed to parse pid: %s", contents);
- pid = 0;
- goto out;
- }
-
- /* too large */
- if (pid > G_MAXUINT) {
- egg_warning ("pid too large %" G_GUINT64_FORMAT, pid);
- pid = 0;
- goto out;
- }
-
-out:
- g_free (contents);
- return (guint) pid;
-}
-
-/**
- * zif_lock_is_locked:
- * @lock: the #ZifLock object
- * @pid: the PID of the process holding the lock, or %NULL
- *
- * Gets the lock state.
- *
- * Return value: %TRUE if we are already locked
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_lock_is_locked (ZifLock *lock, guint *pid)
-{
- guint pid_tmp;
- gboolean ret = FALSE;
- gchar *filename = NULL;
-
- g_return_val_if_fail (ZIF_IS_LOCK (lock), FALSE);
-
- /* optimise as we hold the lock */
- if (lock->priv->self_locked) {
- ret = TRUE;
- if (pid != NULL)
- *pid = getpid ();
- goto out;
- }
-
- /* get pid */
- pid_tmp = zif_lock_get_pid (lock);
- if (pid_tmp == 0)
- goto out;
-
- /* pid is not still running? */
- filename = g_strdup_printf ("/proc/%i/cmdline", pid_tmp);
- ret = g_file_test (filename, G_FILE_TEST_EXISTS);
- if (!ret)
- goto out;
-
- /* return pid */
- if (pid != NULL)
- *pid = pid_tmp;
-out:
- g_free (filename);
- return ret;
-}
-
-/**
- * zif_lock_set_locked:
- * @lock: the #ZifLock object
- * @pid: the PID of the process holding the lock, or %NULL
- * @error: a #GError which is used on failure, or %NULL
- *
- * Tries to lock the packaging system.
- *
- * Return value: %TRUE if we locked, else %FALSE and the error is set
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_lock_set_locked (ZifLock *lock, guint *pid, GError **error)
-{
- gboolean ret = FALSE;
- guint pid_tmp = 0;
- gchar *pid_text = NULL;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_LOCK (lock), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* already locked */
- ret = zif_lock_is_locked (lock, &pid_tmp);
- if (ret) {
- g_set_error (error, ZIF_LOCK_ERROR, ZIF_LOCK_ERROR_ALREADY_LOCKED,
- "already locked by %i", pid_tmp);
- if (pid != NULL)
- *pid = pid_tmp;
- ret = FALSE;
- goto out;
- }
-
- /* no lock file set */
- if (lock->priv->filename == NULL) {
- g_set_error_literal (error, ZIF_LOCK_ERROR, ZIF_LOCK_ERROR_FAILED,
- "lock file not set");
- ret = FALSE;
- goto out;
- }
-
- /* save our pid */
- pid_tmp = getpid ();
- pid_text = g_strdup_printf ("%i", pid_tmp);
- ret = g_file_set_contents (lock->priv->filename, pid_text, -1, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_LOCK_ERROR, ZIF_LOCK_ERROR_FAILED,
- "failed to write: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* optimise as we now hold the lock */
- lock->priv->self_locked = TRUE;
-
- /* return pid */
- if (pid != NULL)
- *pid = pid_tmp;
-out:
- g_free (pid_text);
- return ret;
-}
-
-/**
- * zif_lock_set_unlocked:
- * @lock: the #ZifLock object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Unlocks the packaging system.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_lock_set_unlocked (ZifLock *lock, GError **error)
-{
- gboolean ret = FALSE;
- guint pid = 0;
- guint pid_tmp;
- gint retval;
-
- g_return_val_if_fail (ZIF_IS_LOCK (lock), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* optimise as we hold the lock */
- if (lock->priv->self_locked) {
- lock->priv->self_locked = FALSE;
- goto skip_checks;
- }
-
- /* are we already locked */
- ret = zif_lock_is_locked (lock, &pid);
- if (!ret) {
- g_set_error_literal (error, ZIF_LOCK_ERROR, ZIF_LOCK_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* is it locked by somethine that isn't us? */
- pid_tmp = getpid ();
- if (pid != pid_tmp) {
- g_set_error (error, ZIF_LOCK_ERROR, ZIF_LOCK_ERROR_ALREADY_LOCKED,
- "locked by %i, cannot unlock", pid_tmp);
- ret = FALSE;
- goto out;
- }
-
-skip_checks:
-
- /* remove file */
- retval = g_unlink (lock->priv->filename);
- if (retval != 0) {
- g_set_error (error, ZIF_LOCK_ERROR, ZIF_LOCK_ERROR_FAILED,
- "cannot remove %s, cannot unlock", lock->priv->filename);
- ret = FALSE;
- goto out;
- }
-
- /* success */
- ret = TRUE;
-out:
- return ret;
-}
-
-/**
- * zif_lock_finalize:
- **/
-static void
-zif_lock_finalize (GObject *object)
-{
- ZifLock *lock;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_LOCK (object));
- lock = ZIF_LOCK (object);
-
- /* unlock if we hold the lock */
- if (lock->priv->self_locked)
- zif_lock_set_unlocked (lock, NULL);
-
- g_free (lock->priv->filename);
- g_object_unref (lock->priv->config);
-
- G_OBJECT_CLASS (zif_lock_parent_class)->finalize (object);
-}
-
-/**
- * zif_lock_class_init:
- **/
-static void
-zif_lock_class_init (ZifLockClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_lock_finalize;
-
- g_type_class_add_private (klass, sizeof (ZifLockPrivate));
-}
-
-/**
- * zif_lock_init:
- **/
-static void
-zif_lock_init (ZifLock *lock)
-{
- GError *error = NULL;
- lock->priv = ZIF_LOCK_GET_PRIVATE (lock);
- lock->priv->self_locked = FALSE;
- lock->priv->config = zif_config_new ();
- lock->priv->filename = zif_config_get_string (lock->priv->config, "pidfile", &error);
- if (lock->priv->filename == NULL) {
- egg_warning ("failed to get pidfile: %s", error->message);
- g_error_free (error);
- }
-}
-
-/**
- * zif_lock_new:
- *
- * Return value: A new lock class instance.
- *
- * Since: 0.0.1
- **/
-ZifLock *
-zif_lock_new (void)
-{
- if (zif_lock_object != NULL) {
- g_object_ref (zif_lock_object);
- } else {
- zif_lock_object = g_object_new (ZIF_TYPE_LOCK, NULL);
- g_object_add_weak_pointer (zif_lock_object, &zif_lock_object);
- }
- return ZIF_LOCK (zif_lock_object);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_lock_test (EggTest *test)
-{
- ZifLock *lock;
- ZifConfig *config;
- gboolean ret;
- GError *error = NULL;
- gchar *pidfile;
- guint pid = 0;
-
- if (!egg_test_start (test, "ZifLock"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get config");
- config = zif_config_new ();
- egg_test_assert (test, config != NULL);
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_config_set_filename (config, "../test/etc/yum.conf", &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set filename '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "get lock");
- lock = zif_lock_new ();
- egg_test_assert (test, lock != NULL);
-
- /************************************************************/
- egg_test_title (test, "get pidfile");
- pidfile = zif_config_get_string (config, "pidfile", NULL);
- if (g_strcmp0 (pidfile, "../test/run/zif.lock") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value '%s'", pidfile);
-
- /* remove file */
- g_unlink (pidfile);
-
- /************************************************************/
- egg_test_title (test, "ensure non-locked");
- ret = zif_lock_is_locked (lock, &pid);
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "unlock not yet locked lock");
- ret = zif_lock_set_unlocked (lock, NULL);
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "lock that should succeed");
- ret = zif_lock_set_locked (lock, &pid, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "ensure locked");
- ret = zif_lock_is_locked (lock, &pid);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "ensure pid is us");
- egg_test_assert (test, (pid == getpid ()));
-
- /************************************************************/
- egg_test_title (test, "unlock that should succeed");
- ret = zif_lock_set_unlocked (lock, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "unlock again that should fail");
- ret = zif_lock_set_unlocked (lock, NULL);
- egg_test_assert (test, !ret);
-
- g_object_unref (lock);
- g_object_unref (config);
- g_free (pidfile);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-lock.h b/backends/yum/libzif/zif-lock.h
deleted file mode 100644
index c9627e9..0000000
--- a/backends/yum/libzif/zif-lock.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_LOCK_H
-#define __ZIF_LOCK_H
-
-#include <glib-object.h>
-#include "zif-completion.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_LOCK (zif_lock_get_type ())
-#define ZIF_LOCK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_LOCK, ZifLock))
-#define ZIF_LOCK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_LOCK, ZifLockClass))
-#define ZIF_IS_LOCK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_LOCK))
-#define ZIF_IS_LOCK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_LOCK))
-#define ZIF_LOCK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_LOCK, ZifLockClass))
-#define ZIF_LOCK_ERROR (zif_lock_error_quark ())
-
-typedef struct _ZifLock ZifLock;
-typedef struct _ZifLockPrivate ZifLockPrivate;
-typedef struct _ZifLockClass ZifLockClass;
-
-struct _ZifLock
-{
- GObject parent;
- ZifLockPrivate *priv;
-};
-
-struct _ZifLockClass
-{
- GObjectClass parent_class;
-};
-
-typedef enum {
- ZIF_LOCK_ERROR_FAILED,
- ZIF_LOCK_ERROR_ALREADY_LOCKED,
- ZIF_LOCK_ERROR_NOT_LOCKED,
- ZIF_LOCK_ERROR_LAST
-} ZifLockError;
-
-GType zif_lock_get_type (void);
-GQuark zif_lock_error_quark (void);
-ZifLock *zif_lock_new (void);
-gboolean zif_lock_is_locked (ZifLock *lock,
- guint *pid);
-gboolean zif_lock_set_locked (ZifLock *lock,
- guint *pid,
- GError **error);
-gboolean zif_lock_set_unlocked (ZifLock *lock,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_LOCK_H */
-
diff --git a/backends/yum/libzif/zif-md-comps.c b/backends/yum/libzif/zif-md-comps.c
deleted file mode 100644
index 3d0b966..0000000
--- a/backends/yum/libzif/zif-md-comps.c
+++ /dev/null
@@ -1,959 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md-comps
- * @short_description: Comps metadata functionality
- *
- * Provide access to the comps repo metadata.
- * This object is a subclass of #ZifMd
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <glib.h>
-
-#include "zif-md.h"
-#include "zif-md-comps.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_COMPS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_COMPS, ZifMdCompsPrivate))
-
-typedef enum {
- ZIF_MD_COMPS_SECTION_GROUP,
- ZIF_MD_COMPS_SECTION_CATEGORY,
- ZIF_MD_COMPS_SECTION_UNKNOWN
-} ZifMdCompsSection;
-
-typedef enum {
- ZIF_MD_COMPS_SECTION_GROUP_ID,
- ZIF_MD_COMPS_SECTION_GROUP_NAME,
- ZIF_MD_COMPS_SECTION_GROUP_DESCRIPTION,
- ZIF_MD_COMPS_SECTION_GROUP_VISIBLE,
- ZIF_MD_COMPS_SECTION_GROUP_PACKAGELIST,
- ZIF_MD_COMPS_SECTION_GROUP_PACKAGE,
- ZIF_MD_COMPS_SECTION_GROUP_UNKNOWN
-} ZifMdCompsSectionGroup;
-
-typedef enum {
- ZIF_MD_COMPS_SECTION_GROUP_TYPE_DEFAULT,
- ZIF_MD_COMPS_SECTION_GROUP_TYPE_OPTIONAL,
- ZIF_MD_COMPS_SECTION_GROUP_TYPE_CONDITIONAL,
- ZIF_MD_COMPS_SECTION_GROUP_TYPE_UNKNOWN
-} ZifMdCompsSectionGroupType;
-
-typedef enum {
- ZIF_MD_COMPS_SECTION_CATEGORY_ID,
- ZIF_MD_COMPS_SECTION_CATEGORY_NAME,
- ZIF_MD_COMPS_SECTION_CATEGORY_DESCRIPTION,
- ZIF_MD_COMPS_SECTION_CATEGORY_GROUPLIST,
- ZIF_MD_COMPS_SECTION_CATEGORY_GROUP,
- ZIF_MD_COMPS_SECTION_CATEGORY_UNKNOWN
-} ZifMdCompsSectionCategory;
-
-typedef struct {
- gchar *id;
- gchar *name;
- gchar *description;
- gboolean visible;
- GPtrArray *packagelist; /* stored as gchar */
-} ZifMdCompsGroupData;
-
-typedef struct {
- gchar *id;
- gchar *name;
- gchar *description;
- GPtrArray *grouplist; /* stored as gchar */
-} ZifMdCompsCategoryData;
-
-/**
- * ZifMdCompsPrivate:
- *
- * Private #ZifMdComps data
- **/
-struct _ZifMdCompsPrivate
-{
- gboolean loaded;
- GPtrArray *array_groups; /* stored as ZifMdCompsGroupData */
- GPtrArray *array_categories; /* stored as ZifMdCompsCategoryData */
- /* for parser */
- ZifMdCompsSection section;
- ZifMdCompsSectionGroup section_group;
- ZifMdCompsSectionGroupType section_group_type;
- ZifMdCompsSectionCategory section_category;
- ZifMdCompsGroupData *group_data_temp;
- ZifMdCompsCategoryData *category_data_temp;
-};
-
-G_DEFINE_TYPE (ZifMdComps, zif_md_comps, ZIF_TYPE_MD)
-
-/**
- * zif_md_comps_group_data_new:
- **/
-static ZifMdCompsGroupData *
-zif_md_comps_group_data_new (void)
-{
- ZifMdCompsGroupData *data;
- data = g_new0 (ZifMdCompsGroupData, 1);
- data->packagelist = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- return data;
-}
-
-/**
- * zif_md_comps_category_data_new:
- **/
-static ZifMdCompsCategoryData *
-zif_md_comps_category_data_new (void)
-{
- ZifMdCompsCategoryData *data;
- data = g_new0 (ZifMdCompsCategoryData, 1);
- data->grouplist = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- return data;
-}
-
-/**
- * zif_md_comps_group_data_free:
- **/
-static void
-zif_md_comps_group_data_free (ZifMdCompsGroupData *data)
-{
- g_free (data->id);
- g_free (data->name);
- g_free (data->description);
- g_ptr_array_unref (data->packagelist);
- g_free (data);
-}
-
-/**
- * zif_md_comps_category_data_free:
- **/
-static void
-zif_md_comps_category_data_free (ZifMdCompsCategoryData *data)
-{
- g_free (data->id);
- g_free (data->name);
- g_free (data->description);
- g_ptr_array_unref (data->grouplist);
- g_free (data);
-}
-
-/**
- * zif_md_comps_parser_start_element:
- **/
-static void
-zif_md_comps_parser_start_element (GMarkupParseContext *context, const gchar *element_name,
- const gchar **attribute_names, const gchar **attribute_values,
- gpointer user_data, GError **error)
-{
- guint i;
- ZifMdComps *comps = user_data;
-
- g_return_if_fail (ZIF_IS_MD_COMPS (comps));
-
- /* group element */
- if (comps->priv->section == ZIF_MD_COMPS_SECTION_UNKNOWN) {
-
- /* start of group */
- if (g_strcmp0 (element_name, "group") == 0) {
- comps->priv->section = ZIF_MD_COMPS_SECTION_GROUP;
- comps->priv->group_data_temp = zif_md_comps_group_data_new ();
- goto out;
- }
-
- /* start of category */
- if (g_strcmp0 (element_name, "category") == 0) {
- comps->priv->section = ZIF_MD_COMPS_SECTION_CATEGORY;
- comps->priv->category_data_temp = zif_md_comps_category_data_new ();
- goto out;
- }
-
- goto out;
- }
-
- /* group element */
- if (comps->priv->section == ZIF_MD_COMPS_SECTION_GROUP) {
- /* id */
- if (g_strcmp0 (element_name, "id") == 0) {
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_ID;
- goto out;
- }
- if (g_strcmp0 (element_name, "name") == 0) {
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_NAME;
- goto out;
- }
- if (g_strcmp0 (element_name, "description") == 0) {
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_DESCRIPTION;
- goto out;
- }
- if (g_strcmp0 (element_name, "uservisible") == 0) {
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_VISIBLE;
- goto out;
- }
- if (g_strcmp0 (element_name, "packagelist") == 0) {
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_PACKAGELIST;
- goto out;
- }
- if (g_strcmp0 (element_name, "packagereq") == 0) {
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_PACKAGE;
-
- /* find the package type as a bonus */
- comps->priv->section_group_type = ZIF_MD_COMPS_SECTION_GROUP_TYPE_UNKNOWN;
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (element_name, "type") == 0) {
- if (g_strcmp0 (attribute_values[i], "default"))
- comps->priv->section_group_type = ZIF_MD_COMPS_SECTION_GROUP_TYPE_DEFAULT;
- break;
- }
- }
- goto out;
- }
- }
-
- /* category element */
- if (comps->priv->section == ZIF_MD_COMPS_SECTION_CATEGORY) {
- /* id */
- if (g_strcmp0 (element_name, "id") == 0) {
- comps->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_ID;
- goto out;
- }
- if (g_strcmp0 (element_name, "name") == 0) {
- comps->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_NAME;
- goto out;
- }
- if (g_strcmp0 (element_name, "description") == 0) {
- comps->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_DESCRIPTION;
- goto out;
- }
- if (g_strcmp0 (element_name, "grouplist") == 0) {
- comps->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_GROUPLIST;
- goto out;
- }
- if (g_strcmp0 (element_name, "groupid") == 0) {
- comps->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_GROUP;
- goto out;
- }
- }
-out:
- return;
-}
-
-/**
- * zif_md_comps_parser_end_element:
- **/
-static void
-zif_md_comps_parser_end_element (GMarkupParseContext *context, const gchar *element_name,
- gpointer user_data, GError **error)
-{
- ZifMdComps *comps = user_data;
-
- /* end of group */
- if (g_strcmp0 (element_name, "group") == 0) {
- comps->priv->section = ZIF_MD_COMPS_SECTION_UNKNOWN;
-
- /* add to array */
- g_ptr_array_add (comps->priv->array_groups, comps->priv->group_data_temp);
-
- if (FALSE)
- egg_debug ("added GROUP '%s' name:%s, desc:%s, visible:%i, list=%p",
- comps->priv->group_data_temp->id,
- comps->priv->group_data_temp->name,
- comps->priv->group_data_temp->description,
- comps->priv->group_data_temp->visible,
- comps->priv->group_data_temp->packagelist);
-
- comps->priv->group_data_temp = NULL;
- goto out;
- }
-
- /* start of group */
- if (g_strcmp0 (element_name, "category") == 0) {
- comps->priv->section = ZIF_MD_COMPS_SECTION_UNKNOWN;
-
- /* add to array */
- g_ptr_array_add (comps->priv->array_categories, comps->priv->category_data_temp);
-
- if (FALSE)
- egg_debug ("added CATEGORY '%s' name:%s, desc:%s, list=%p",
- comps->priv->category_data_temp->id,
- comps->priv->category_data_temp->name,
- comps->priv->category_data_temp->description,
- comps->priv->category_data_temp->grouplist);
-
- comps->priv->category_data_temp = NULL;
- goto out;
- }
-out:
- return;
-}
-
-/**
- * zif_md_comps_parser_text:
- **/
-static void
-zif_md_comps_parser_text (GMarkupParseContext *context, const gchar *text, gsize text_len,
- gpointer user_data, GError **error)
-
-{
- ZifMdComps *comps = user_data;
-
- /* skip whitespace */
- if (text_len < 1 || text[0] == ' ' || text[0] == '\t' || text[0] == '\n')
- goto out;
-
- /* group section */
- if (comps->priv->section == ZIF_MD_COMPS_SECTION_GROUP) {
- if (comps->priv->section_group == ZIF_MD_COMPS_SECTION_GROUP_ID) {
- comps->priv->group_data_temp->id = g_strdup (text);
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_UNKNOWN;
- goto out;
- }
- if (comps->priv->section_group == ZIF_MD_COMPS_SECTION_GROUP_NAME) {
- /* ignore translated versions for now */
- if (comps->priv->group_data_temp->name != NULL)
- goto out;
- comps->priv->group_data_temp->name = g_strdup (text);
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_UNKNOWN;
- goto out;
- }
- if (comps->priv->section_group == ZIF_MD_COMPS_SECTION_GROUP_DESCRIPTION) {
- /* ignore translated versions for now */
- if (comps->priv->group_data_temp->description != NULL)
- goto out;
- comps->priv->group_data_temp->description = g_strdup (text);
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_UNKNOWN;
- goto out;
- }
- if (comps->priv->section_group == ZIF_MD_COMPS_SECTION_GROUP_VISIBLE) {
- /* TODO: parse true and false */
- comps->priv->group_data_temp->visible = atoi (text);
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_UNKNOWN;
- goto out;
- }
- if (comps->priv->section_group == ZIF_MD_COMPS_SECTION_GROUP_PACKAGE) {
- g_ptr_array_add (comps->priv->group_data_temp->packagelist, g_strdup (text));
- comps->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_UNKNOWN;
- goto out;
- }
- goto out;
- }
-
- /* category section */
- if (comps->priv->section == ZIF_MD_COMPS_SECTION_CATEGORY) {
- if (comps->priv->section_category == ZIF_MD_COMPS_SECTION_CATEGORY_ID) {
- comps->priv->category_data_temp->id = g_strdup (text);
- comps->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_UNKNOWN;
- goto out;
- }
- if (comps->priv->section_category == ZIF_MD_COMPS_SECTION_CATEGORY_NAME) {
- /* ignore translated versions for now */
- if (comps->priv->category_data_temp->name != NULL)
- goto out;
- comps->priv->category_data_temp->name = g_strdup (text);
- comps->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_UNKNOWN;
- goto out;
- }
- if (comps->priv->section_category == ZIF_MD_COMPS_SECTION_CATEGORY_DESCRIPTION) {
- /* ignore translated versions for now */
- if (comps->priv->category_data_temp->description != NULL)
- goto out;
- comps->priv->category_data_temp->description = g_strdup (text);
- comps->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_UNKNOWN;
- goto out;
- }
- if (comps->priv->section_category == ZIF_MD_COMPS_SECTION_CATEGORY_GROUP) {
- g_ptr_array_add (comps->priv->category_data_temp->grouplist, g_strdup (text));
- comps->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_UNKNOWN;
- goto out;
- }
- goto out;
- }
-out:
- return;
-}
-
-/**
- * zif_md_comps_unload:
- **/
-static gboolean
-zif_md_comps_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- return ret;
-}
-
-/**
- * zif_md_comps_load:
- **/
-static gboolean
-zif_md_comps_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = TRUE;
- gchar *contents = NULL;
- const gchar *filename;
- gsize size;
- GMarkupParseContext *context = NULL;
- const GMarkupParser gpk_md_comps_markup_parser = {
- zif_md_comps_parser_start_element,
- zif_md_comps_parser_end_element,
- zif_md_comps_parser_text,
- NULL, /* passthrough */
- NULL /* error */
- };
- ZifMdComps *comps = ZIF_MD_COMPS (md);
-
- g_return_val_if_fail (ZIF_IS_MD_COMPS (md), FALSE);
-
- /* already loaded */
- if (comps->priv->loaded)
- goto out;
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for comps");
- goto out;
- }
-
- /* open database */
- egg_debug ("filename = %s", filename);
-
- /* get repo contents */
- ret = g_file_get_contents (filename, &contents, &size, error);
- if (!ret)
- goto out;
-
- /* create parser */
- context = g_markup_parse_context_new (&gpk_md_comps_markup_parser, G_MARKUP_PREFIX_ERROR_POSITION, comps, NULL);
-
- /* parse data */
- ret = g_markup_parse_context_parse (context, contents, (gssize) size, error);
- if (!ret)
- goto out;
-
- comps->priv->loaded = TRUE;
-out:
- if (context != NULL)
- g_markup_parse_context_free (context);
- g_free (contents);
- return ret;
-}
-
-/**
- * zif_md_comps_category_set_icon:
- *
- * Check the icon exists, otherwise fallback to the parent ID, and then
- * something sane.
- **/
-static void
-zif_md_comps_category_set_icon (PkCategory *category)
-{
- const gchar *icon;
- GString *filename = g_string_new ("");
-
- /* try the proper group icon */
- icon = pk_category_get_id (category);
- g_string_printf (filename, "/usr/share/pixmaps/comps/%s.png", icon);
- if (g_file_test (filename->str, G_FILE_TEST_EXISTS))
- goto out;
-
- /* fall back to parent icon */
- icon = pk_category_get_parent_id (category);
- g_string_printf (filename, "/usr/share/pixmaps/comps/%s.png", icon);
- if (g_file_test (filename->str, G_FILE_TEST_EXISTS))
- goto out;
-
- /* fall back to the missing icon */
- icon = "image-missing";
-out:
- pk_category_set_icon (category, icon);
- g_string_free (filename, TRUE);
-}
-
-/**
- * zif_md_comps_get_categories:
- * @md: the #ZifMdComps object
- * @cancellable: the %GCancellable, or %NULL
- * @completion: the %ZifCompletion object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the available list of categories.
- *
- * Return value: %PkCategory array of categories, with parent_id set to %NULL
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_comps_get_categories (ZifMdComps *md, GCancellable *cancellable,
- ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- guint i;
- guint len;
- gboolean ret;
- GError *error_local = NULL;
- const ZifMdCompsCategoryData *data;
- PkCategory *category;
-
- g_return_val_if_fail (ZIF_IS_MD_COMPS (md), NULL);
-
- /* if not already loaded, load */
- if (!md->priv->loaded) {
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to get load comps: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get categories */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- len = md->priv->array_categories->len;
- for (i=0; i<len; i++) {
- data = g_ptr_array_index (md->priv->array_categories, i);
- category = pk_category_new ();
- pk_category_set_id (category, data->id);
- pk_category_set_name (category, data->name);
- pk_category_set_summary (category, data->description);
- zif_md_comps_category_set_icon (category);
- g_ptr_array_add (array, category);
- }
-out:
- return array;
-}
-
-/**
- * zif_md_comps_get_category_for_group:
- **/
-static PkCategory *
-zif_md_comps_get_category_for_group (ZifMdComps *md, const gchar *group_id)
-{
- guint i;
- guint len;
- PkCategory *category = NULL;
- ZifMdCompsGroupData *data;
-
- /* find group matching group_id */
- len = md->priv->array_groups->len;
- for (i=0; i<len; i++) {
- data = g_ptr_array_index (md->priv->array_groups, i);
- if (g_strcmp0 (group_id, data->id) == 0) {
- category = pk_category_new ();
- pk_category_set_id (category, data->id);
- pk_category_set_name (category, data->name);
- pk_category_set_summary (category, data->description);
- break;
- }
- }
- return category;
-}
-
-/**
- * zif_md_comps_get_groups_for_category:
- * @md: the #ZifMdComps object
- * @category_id: the category to search for
- * @cancellable: the %GCancellable, or %NULL
- * @completion: the %ZifCompletion object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the list of groups for a specific category.
- *
- * Return value: %PkCategory array of groups
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_comps_get_groups_for_category (ZifMdComps *md, const gchar *category_id,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- guint i;
- guint j;
- guint len;
- gboolean ret;
- GError *error_local = NULL;
- const ZifMdCompsCategoryData *data;
- const gchar *id;
- PkCategory *category;
-
- g_return_val_if_fail (ZIF_IS_MD_COMPS (md), NULL);
- g_return_val_if_fail (category_id != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!md->priv->loaded) {
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to get load comps: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get categories */
- len = md->priv->array_categories->len;
- for (i=0; i<len; i++) {
- data = g_ptr_array_index (md->priv->array_categories, i);
-
- /* category matches */
- if (g_strcmp0 (category_id, data->id) == 0) {
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (j=0; j<data->grouplist->len; j++) {
- id = g_ptr_array_index (data->grouplist, j);
- /* find group matching group_id */
- category = zif_md_comps_get_category_for_group (md, id);
- if (category == NULL)
- continue;
-
- /* add */
- pk_category_set_parent_id (category, category_id);
- zif_md_comps_category_set_icon (category);
- g_ptr_array_add (array, category);
- }
- break;
- }
- }
-
- /* nothing found */
- if (array == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "could not find category: %s", category_id);
- }
-out:
- return array;
-}
-
-/**
- * zif_md_comps_get_packages_for_group:
- * @md: the #ZifMdComps object
- * @group_id: the group to search for
- * @cancellable: the %GCancellable, or %NULL
- * @completion: the %ZifCompletion object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the package names for a group.
- *
- * Return value: gchar pointer array of package names (not %ZifPackage's)
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_comps_get_packages_for_group (ZifMdComps *md, const gchar *group_id,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- guint i;
- guint j;
- guint len;
- gboolean ret;
- GError *error_local = NULL;
- const ZifMdCompsGroupData *data;
- const gchar *packagename;
-
- g_return_val_if_fail (ZIF_IS_MD_COMPS (md), NULL);
- g_return_val_if_fail (group_id != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!md->priv->loaded) {
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to get load comps: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get packages in this group */
- len = md->priv->array_groups->len;
- for (i=0; i<len; i++) {
- data = g_ptr_array_index (md->priv->array_groups, i);
-
- /* category matches */
- if (g_strcmp0 (group_id, data->id) == 0) {
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- for (j=0; j<data->packagelist->len; j++) {
- packagename = g_ptr_array_index (data->packagelist, j);
- g_ptr_array_add (array, g_strdup (packagename));
- }
- break;
- }
- }
-
- /* nothing found */
- if (array == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "could not find group: %s", group_id);
- }
-out:
- return array;
-}
-
-/**
- * zif_md_comps_finalize:
- **/
-static void
-zif_md_comps_finalize (GObject *object)
-{
- ZifMdComps *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD_COMPS (object));
- md = ZIF_MD_COMPS (object);
-
- g_ptr_array_unref (md->priv->array_groups);
- g_ptr_array_unref (md->priv->array_categories);
-
- G_OBJECT_CLASS (zif_md_comps_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_comps_class_init:
- **/
-static void
-zif_md_comps_class_init (ZifMdCompsClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifMdClass *md_class = ZIF_MD_CLASS (klass);
- object_class->finalize = zif_md_comps_finalize;
-
- /* map */
- md_class->load = zif_md_comps_load;
- md_class->unload = zif_md_comps_unload;
- g_type_class_add_private (klass, sizeof (ZifMdCompsPrivate));
-}
-
-/**
- * zif_md_comps_init:
- **/
-static void
-zif_md_comps_init (ZifMdComps *md)
-{
- md->priv = ZIF_MD_COMPS_GET_PRIVATE (md);
- md->priv->loaded = FALSE;
- md->priv->section = ZIF_MD_COMPS_SECTION_UNKNOWN;
- md->priv->section_group = ZIF_MD_COMPS_SECTION_GROUP_UNKNOWN;
- md->priv->section_group_type = ZIF_MD_COMPS_SECTION_GROUP_TYPE_UNKNOWN;
- md->priv->section_category = ZIF_MD_COMPS_SECTION_CATEGORY_UNKNOWN;
- md->priv->group_data_temp = NULL;
- md->priv->category_data_temp = NULL;
- md->priv->array_groups = g_ptr_array_new_with_free_func ((GDestroyNotify) zif_md_comps_group_data_free);
- md->priv->array_categories = g_ptr_array_new_with_free_func ((GDestroyNotify) zif_md_comps_category_data_free);
-}
-
-/**
- * zif_md_comps_new:
- *
- * Return value: A new #ZifMdComps class instance.
- *
- * Since: 0.0.1
- **/
-ZifMdComps *
-zif_md_comps_new (void)
-{
- ZifMdComps *md;
- md = g_object_new (ZIF_TYPE_MD_COMPS, NULL);
- return ZIF_MD_COMPS (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_comps_test (EggTest *test)
-{
- ZifMdComps *md;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- const gchar *id;
- GCancellable *cancellable;
- ZifCompletion *completion;
- PkCategory *category;
-
- if (!egg_test_start (test, "ZifMdComps"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get md_comps md");
- md = zif_md_comps_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (ZIF_MD (md), "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set type");
- ret = zif_md_set_mdtype (ZIF_MD (md), ZIF_MD_TYPE_COMPS);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_md_set_filename (ZIF_MD (md), "../test/cache/comps-rawhide.xml");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum type");
- ret = zif_md_set_checksum_type (ZIF_MD (md), G_CHECKSUM_SHA256);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum uncompressed");
- ret = zif_md_set_checksum_uncompressed (ZIF_MD (md), "14f17b894303b4dc9683511104848f75d98cea8f76c107bf25e1b4db5741f6a8");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "get categories");
- array = zif_md_comps_get_categories (md, cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get categories '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len == 1)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect value %i", array->len);
-
- /************************************************************/
- egg_test_title (test, "correct id value");
- category = g_ptr_array_index (array, 0);
- if (g_strcmp0 (pk_category_get_id (category), "apps") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct id '%s'", pk_category_get_id (category));
-
- /************************************************************/
- egg_test_title (test, "correct name value");
- category = g_ptr_array_index (array, 0);
- if (g_strcmp0 (pk_category_get_name (category), "Applications") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct name '%s'", pk_category_get_name (category));
-
- /************************************************************/
- egg_test_title (test, "correct summary value");
- category = g_ptr_array_index (array, 0);
- if (g_strcmp0 (pk_category_get_summary (category), "Applications to perform a variety of tasks") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct summary '%s'", pk_category_get_summary (category));
-
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "get groups for category");
- array = zif_md_comps_get_groups_for_category (md, "apps", cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get categories '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len == 2)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect value %i", array->len);
-
- /************************************************************/
- egg_test_title (test, "correct id value");
- category = g_ptr_array_index (array, 0);
- if (g_strcmp0 (pk_category_get_id (category), "admin-tools") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct id '%s'", pk_category_get_id (category));
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "get packages for group");
- array = zif_md_comps_get_packages_for_group (md, "admin-tools", cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get categories '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len == 2)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect value %i", array->len);
-
- /************************************************************/
- egg_test_title (test, "correct value");
- id = g_ptr_array_index (array, 0);
- if (g_strcmp0 (id, "gnome-packagekit") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct id '%s'", id);
- g_ptr_array_unref (array);
-
- g_object_unref (md);
- g_object_unref (cancellable);
- g_object_unref (completion);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md-comps.h b/backends/yum/libzif/zif-md-comps.h
deleted file mode 100644
index 2ae15a4..0000000
--- a/backends/yum/libzif/zif-md-comps.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_COMPS_H
-#define __ZIF_MD_COMPS_H
-
-#include <glib-object.h>
-
-#include "zif-md.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD_COMPS (zif_md_comps_get_type ())
-#define ZIF_MD_COMPS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD_COMPS, ZifMdComps))
-#define ZIF_MD_COMPS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD_COMPS, ZifMdCompsClass))
-#define ZIF_IS_MD_COMPS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD_COMPS))
-#define ZIF_IS_MD_COMPS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD_COMPS))
-#define ZIF_MD_COMPS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD_COMPS, ZifMdCompsClass))
-
-typedef struct _ZifMdComps ZifMdComps;
-typedef struct _ZifMdCompsPrivate ZifMdCompsPrivate;
-typedef struct _ZifMdCompsClass ZifMdCompsClass;
-
-struct _ZifMdComps
-{
- ZifMd parent;
- ZifMdCompsPrivate *priv;
-};
-
-struct _ZifMdCompsClass
-{
- ZifMdClass parent_class;
-};
-
-GType zif_md_comps_get_type (void);
-ZifMdComps *zif_md_comps_new (void);
-
-GPtrArray *zif_md_comps_get_categories (ZifMdComps *md,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_comps_get_groups_for_category (ZifMdComps *md,
- const gchar *category_id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_comps_get_packages_for_group (ZifMdComps *md,
- const gchar *group_id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_COMPS_H */
-
diff --git a/backends/yum/libzif/zif-md-filelists-sql.c b/backends/yum/libzif/zif-md-filelists-sql.c
deleted file mode 100644
index 200c5cd..0000000
--- a/backends/yum/libzif/zif-md-filelists-sql.c
+++ /dev/null
@@ -1,542 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md-filelists-sql
- * @short_description: File list metadata functionality
- *
- * Provide access to the file list metadata.
- * This object is a subclass of #ZifMd
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include <gio/gio.h>
-
-#include "zif-md.h"
-#include "zif-md-filelists-sql.h"
-#include "zif-package-remote.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_FILELISTS_SQL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_FILELISTS_SQL, ZifMdFilelistsSqlPrivate))
-
-/**
- * ZifMdFilelistsSqlPrivate:
- *
- * Private #ZifMdFilelistsSql data
- **/
-struct _ZifMdFilelistsSqlPrivate
-{
- gboolean loaded;
- sqlite3 *db;
-};
-
-typedef struct {
- gchar *filename;
- GPtrArray *array;
-} ZifMdFilelistsSqlData;
-
-G_DEFINE_TYPE (ZifMdFilelistsSql, zif_md_filelists_sql, ZIF_TYPE_MD)
-
-/**
- * zif_md_filelists_sql_unload:
- **/
-static gboolean
-zif_md_filelists_sql_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- return ret;
-}
-
-/**
- * zif_md_filelists_sql_load:
- **/
-static gboolean
-zif_md_filelists_sql_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- const gchar *filename;
- gint rc;
- ZifMdFilelistsSql *filelists = ZIF_MD_FILELISTS_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_FILELISTS_SQL (md), FALSE);
-
- /* already loaded */
- if (filelists->priv->loaded)
- goto out;
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for filelists");
- goto out;
- }
-
- /* open database */
- egg_debug ("filename = %s", filename);
- rc = sqlite3_open (filename, &filelists->priv->db);
- if (rc != 0) {
- egg_warning ("Can't open database: %s\n", sqlite3_errmsg (filelists->priv->db));
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "can't open database: %s", sqlite3_errmsg (filelists->priv->db));
- goto out;
- }
-
- /* we don't need to keep syncing */
- sqlite3_exec (filelists->priv->db, "PRAGMA synchronous=OFF", NULL, NULL, NULL);
- filelists->priv->loaded = TRUE;
-out:
- return filelists->priv->loaded;
-}
-
-/**
- * zif_md_filelists_sql_sqlite_get_id_cb:
- **/
-static gint
-zif_md_filelists_sql_sqlite_get_id_cb (void *data, gint argc, gchar **argv, gchar **col_name)
-{
- gchar **pkgid = (gchar **) data;
- *pkgid = g_strdup (argv[0]);
- return 0;
-}
-
-/**
- * zif_md_filelists_sql_sqlite_get_pkgkey_cb:
- **/
-static gint
-zif_md_filelists_sql_sqlite_get_pkgkey_cb (void *data, gint argc, gchar **argv, gchar **col_name)
-{
- gint i;
- gchar **filenames = NULL;
- gchar **filenames_r = NULL;
- gchar **id_r = NULL;
- ZifMdFilelistsSqlData *fldata = (ZifMdFilelistsSqlData *) data;
-
- /* get pointers to the arguments */
- for (i=0;i<argc;i++) {
- if (g_strcmp0 (col_name[i], "pkgKey") == 0)
- id_r = &argv[i];
- else if (g_strcmp0 (col_name[i], "filenames") == 0)
- filenames_r = &argv[i];
- }
-
- /* either is undereferencable */
- if (filenames_r == NULL || id_r == NULL) {
- egg_warning ("no file data");
- goto out;
- }
-
- /* split the filenames */
- filenames = g_strsplit (*filenames_r, "/", -1);
- for (i=0; filenames[i] != NULL ;i++) {
- /* do we match */
- if (g_strcmp0 (fldata->filename, filenames[i]) == 0) {
- egg_debug ("found %s for %s", filenames[i], *id_r);
- g_ptr_array_add (fldata->array, GUINT_TO_POINTER (atoi (*id_r)));
- }
- }
-out:
- g_strfreev (filenames);
- return 0;
-}
-
-/**
- * zif_md_filelists_sql_sqlite_get_files_cb:
- **/
-static gint
-zif_md_filelists_sql_sqlite_get_files_cb (void *data, gint argc, gchar **argv, gchar **col_name)
-{
- gint i;
- gchar **filename = NULL;
- gchar **dirname = NULL;
- GPtrArray **array = (GPtrArray **) data;
-
- /* get pointers to the arguments */
- for (i=0;i<argc;i++) {
- if (g_strcmp0 (col_name[i], "filenames") == 0)
- filename = &argv[i];
- else if (g_strcmp0 (col_name[i], "dirname") == 0)
- dirname = &argv[i];
- }
-
- /* check for invalid entries */
- if (filename == NULL || dirname == NULL) {
- egg_warning ("failed on %p, %p", filename, dirname);
- return 0;
- }
-
- /* add complete path */
- g_ptr_array_add (*array, g_strdup (g_build_filename (*dirname, *filename, NULL)));
- return 0;
-}
-
-/**
- * zif_md_filelists_sql_get_files:
- **/
-static GPtrArray *
-zif_md_filelists_sql_get_files (ZifMd *md, ZifPackage *package,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement = NULL;
- gint rc;
- gboolean ret;
- const gchar *pkgid;
- gchar *pkgkey = NULL;
- GError *error_local = NULL;
- gchar *error_msg = NULL;
- GPtrArray *array = NULL;
- GPtrArray *files = NULL;
- ZifMdFilelistsSql *md_filelists_sql = ZIF_MD_FILELISTS_SQL (md);
-
- /* if not already loaded, load */
- if (!md_filelists_sql->priv->loaded) {
- ret = zif_md_load (md, cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to load store file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get pkgkey from pkgid */
- pkgid = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package));
- statement = g_strdup_printf ("SELECT pkgKey FROM packages WHERE pkgId = '%s' LIMIT 1", pkgid);
- rc = sqlite3_exec (md_filelists_sql->priv->db, statement, zif_md_filelists_sql_sqlite_get_id_cb, &pkgkey, &error_msg);
- g_free (statement);
- if (rc != SQLITE_OK) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "SQL error (failed to get packages): %s", error_msg);
- sqlite3_free (error_msg);
- goto out;
- }
-
- /* failed */
- if (pkgkey == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "failed to get pkgkey for %s", pkgid);
- goto out;
- }
-
- /* get files for pkgkey */
- files = g_ptr_array_new_with_free_func (g_free);
- statement = g_strdup_printf ("SELECT dirname, filenames FROM filelist WHERE pkgKey = '%s'", pkgkey);
- rc = sqlite3_exec (md_filelists_sql->priv->db, statement, zif_md_filelists_sql_sqlite_get_files_cb, &files, &error_msg);
- g_free (statement);
- if (rc != SQLITE_OK) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "SQL error (failed to get packages): %s", error_msg);
- sqlite3_free (error_msg);
- goto out;
- }
-
- /* success */
- array = g_ptr_array_ref (files);
-out:
- if (files != NULL)
- g_ptr_array_unref (files);
- return array;
-}
-
-/**
- * zif_md_filelists_sql_search_file:
- **/
-static GPtrArray *
-zif_md_filelists_sql_search_file (ZifMd *md, gchar **search,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- gchar *statement = NULL;
- gchar *error_msg = NULL;
- gint rc;
- gboolean ret;
- guint i;
- GError *error_local = NULL;
- gchar *filename = NULL;
- gchar *dirname = NULL;
- ZifMdFilelistsSql *md_filelists_sql = ZIF_MD_FILELISTS_SQL (md);
- ZifMdFilelistsSqlData *data = NULL;
-
- g_return_val_if_fail (ZIF_IS_MD_FILELISTS_SQL (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!md_filelists_sql->priv->loaded) {
- ret = zif_md_load (md, cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to load store file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* split the search term into directory and filename */
- dirname = g_path_get_dirname (search[0]);
- filename = g_path_get_basename (search[0]);
- egg_debug ("dirname=%s, filename=%s", dirname, filename);
-
- /* create data struct we can pass to the callback */
- data = g_new0 (ZifMdFilelistsSqlData, 1);
- data->filename = g_path_get_basename (search[0]);
- data->array = g_ptr_array_new ();
-
- /* populate _array with guint pkgKey */
- statement = g_strdup_printf ("SELECT filenames, pkgKey FROM filelist WHERE dirname = '%s'", dirname);
- rc = sqlite3_exec (md_filelists_sql->priv->db, statement, zif_md_filelists_sql_sqlite_get_pkgkey_cb, data, &error_msg);
- g_free (statement);
- if (rc != SQLITE_OK) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "SQL error (failed to get keys): %s\n", error_msg);
- sqlite3_free (error_msg);
- goto out;
- }
-
- /* convert each pkgKey */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- for (i=0; i<data->array->len; i++) {
- guint key;
- gchar *pkgid = NULL;
-
- /* convert the pkgKey to a pkgId */
- key = GPOINTER_TO_UINT (g_ptr_array_index (data->array, i));
- statement = g_strdup_printf ("SELECT pkgId FROM packages WHERE pkgKey = %i LIMIT 1", key);
- rc = sqlite3_exec (md_filelists_sql->priv->db, statement, zif_md_filelists_sql_sqlite_get_id_cb, &pkgid, &error_msg);
- g_free (statement);
- if (rc != SQLITE_OK) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "SQL error (failed to get packages): %s", error_msg);
- sqlite3_free (error_msg);
- goto out;
- }
-
- /* we failed to get any results */
- if (pkgid == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "failed to resolve pkgKey: %i", key);
- goto out;
- }
-
- /* added to tracked array, so no need to free pkgid */
- g_ptr_array_add (array, pkgid);
- }
-out:
- if (data != NULL) {
- g_free (data->filename);
- g_ptr_array_unref (data->array);
- g_free (data);
- }
- g_free (dirname);
- g_free (filename);
- return array;
-}
-
-/**
- * zif_md_filelists_sql_finalize:
- **/
-static void
-zif_md_filelists_sql_finalize (GObject *object)
-{
- ZifMdFilelistsSql *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD_FILELISTS_SQL (object));
- md = ZIF_MD_FILELISTS_SQL (object);
-
- sqlite3_close (md->priv->db);
-
- G_OBJECT_CLASS (zif_md_filelists_sql_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_filelists_sql_class_init:
- **/
-static void
-zif_md_filelists_sql_class_init (ZifMdFilelistsSqlClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifMdClass *md_class = ZIF_MD_CLASS (klass);
- object_class->finalize = zif_md_filelists_sql_finalize;
-
- /* map */
- md_class->load = zif_md_filelists_sql_load;
- md_class->unload = zif_md_filelists_sql_unload;
- md_class->search_file = zif_md_filelists_sql_search_file;
- md_class->get_files = zif_md_filelists_sql_get_files;
- g_type_class_add_private (klass, sizeof (ZifMdFilelistsSqlPrivate));
-}
-
-/**
- * zif_md_filelists_sql_init:
- **/
-static void
-zif_md_filelists_sql_init (ZifMdFilelistsSql *md)
-{
- md->priv = ZIF_MD_FILELISTS_SQL_GET_PRIVATE (md);
- md->priv->loaded = FALSE;
- md->priv->db = NULL;
-}
-
-/**
- * zif_md_filelists_sql_new:
- *
- * Return value: A new #ZifMdFilelistsSql class instance.
- *
- * Since: 0.0.1
- **/
-ZifMdFilelistsSql *
-zif_md_filelists_sql_new (void)
-{
- ZifMdFilelistsSql *md;
- md = g_object_new (ZIF_TYPE_MD_FILELISTS_SQL, NULL);
- return ZIF_MD_FILELISTS_SQL (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_filelists_sql_test (EggTest *test)
-{
- ZifMdFilelistsSql *md;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- const gchar *pkgid;
- GCancellable *cancellable;
- ZifCompletion *completion;
- const gchar *data[] = { "/usr/bin/gnome-power-manager", NULL };
-
- if (!egg_test_start (test, "ZifMdFilelistsSql"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get store_remote md");
- md = zif_md_filelists_sql_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (ZIF_MD (md), "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set type");
- ret = zif_md_set_mdtype (ZIF_MD (md), ZIF_MD_TYPE_FILELISTS_SQL);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum type");
- ret = zif_md_set_checksum_type (ZIF_MD (md), G_CHECKSUM_SHA256);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum compressed");
- ret = zif_md_set_checksum (ZIF_MD (md), "e00e88a8b6eee3798544764b6fe31ef8c9d071a824177c7cdc4fe749289198a9");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum uncompressed");
- ret = zif_md_set_checksum_uncompressed (ZIF_MD (md), "2b4336cb43e75610662bc0b3a362ca4cb7ba874528735a27c0d55148c3901792");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_md_set_filename (ZIF_MD (md), "../test/cache/fedora/e00e88a8b6eee3798544764b6fe31ef8c9d071a824177c7cdc4fe749289198a9-filelists.sqlite.bz2");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "search for files");
- array = zif_md_filelists_sql_search_file (ZIF_MD (md), (gchar**)data, cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- egg_test_assert (test, array->len == 1);
-
- /************************************************************/
- egg_test_title (test, "correct value");
- pkgid = g_ptr_array_index (array, 0);
- if (pkgid[0] != '\0' && strlen (pkgid) == 64)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get a correct pkgId '%s' (%i)", pkgid, strlen (pkgid));
- g_ptr_array_unref (array);
-
- g_object_unref (md);
- g_object_unref (cancellable);
- g_object_unref (completion);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md-filelists-sql.h b/backends/yum/libzif/zif-md-filelists-sql.h
deleted file mode 100644
index ce406bd..0000000
--- a/backends/yum/libzif/zif-md-filelists-sql.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_FILELISTS_SQL_H
-#define __ZIF_MD_FILELISTS_SQL_H
-
-#include <glib-object.h>
-
-#include "zif-md.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD_FILELISTS_SQL (zif_md_filelists_sql_get_type ())
-#define ZIF_MD_FILELISTS_SQL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD_FILELISTS_SQL, ZifMdFilelistsSql))
-#define ZIF_MD_FILELISTS_SQL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD_FILELISTS_SQL, ZifMdFilelistsSqlClass))
-#define ZIF_IS_MD_FILELISTS_SQL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD_FILELISTS_SQL))
-#define ZIF_IS_MD_FILELISTS_SQL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD_FILELISTS_SQL))
-#define ZIF_MD_FILELISTS_SQL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD_FILELISTS_SQL, ZifMdFilelistsSqlClass))
-
-typedef struct _ZifMdFilelistsSql ZifMdFilelistsSql;
-typedef struct _ZifMdFilelistsSqlPrivate ZifMdFilelistsSqlPrivate;
-typedef struct _ZifMdFilelistsSqlClass ZifMdFilelistsSqlClass;
-
-struct _ZifMdFilelistsSql
-{
- ZifMd parent;
- ZifMdFilelistsSqlPrivate *priv;
-};
-
-struct _ZifMdFilelistsSqlClass
-{
- ZifMdClass parent_class;
-};
-
-GType zif_md_filelists_sql_get_type (void);
-ZifMdFilelistsSql *zif_md_filelists_sql_new (void);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_FILELISTS_SQL_H */
-
diff --git a/backends/yum/libzif/zif-md-filelists-xml.c b/backends/yum/libzif/zif-md-filelists-xml.c
deleted file mode 100644
index 00269ad..0000000
--- a/backends/yum/libzif/zif-md-filelists-xml.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md-filelists-xml
- * @short_description: FilelistsXml metadata functionality
- *
- * Provide access to the filelists_xml repo metadata.
- * This object is a subclass of #ZifMd
- */
-
-typedef enum {
- ZIF_MD_FILELISTS_XML_SECTION_LIST,
- ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN
-} ZifMdFilelistsXmlSection;
-
-typedef enum {
- ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE,
- ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN
-} ZifMdFilelistsXmlSectionList;
-
-typedef enum {
- ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_FILE,
- ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_UNKNOWN
-} ZifMdFilelistsXmlSectionListPackage;
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include <gio/gio.h>
-
-#include "zif-md.h"
-#include "zif-md-filelists-xml.h"
-#include "zif-package-remote.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_FILELISTS_XML_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_FILELISTS_XML, ZifMdFilelistsXmlPrivate))
-
-/**
- * ZifMdFilelistsXmlPrivate:
- *
- * Private #ZifMdFilelistsXml data
- **/
-struct _ZifMdFilelistsXmlPrivate
-{
- gboolean loaded;
- ZifMdFilelistsXmlSection section;
- ZifMdFilelistsXmlSectionList section_list;
- ZifMdFilelistsXmlSectionListPackage section_list_package;
- ZifPackage *package_temp;
- GPtrArray *array;
- GPtrArray *array_temp;
-};
-
-G_DEFINE_TYPE (ZifMdFilelistsXml, zif_md_filelists_xml, ZIF_TYPE_MD)
-
-/**
- * zif_md_filelists_xml_unload:
- **/
-static gboolean
-zif_md_filelists_xml_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- return ret;
-}
-
-/**
- * zif_md_filelists_xml_parser_start_element:
- **/
-static void
-zif_md_filelists_xml_parser_start_element (GMarkupParseContext *context, const gchar *element_name,
- const gchar **attribute_names, const gchar **attribute_values,
- gpointer user_data, GError **error)
-{
- guint i;
- ZifMdFilelistsXml *filelists_xml = user_data;
-
- g_return_if_fail (ZIF_IS_MD_FILELISTS_XML (filelists_xml));
-
- /* group element */
- if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN) {
-
- /* start of update */
- if (g_strcmp0 (element_name, "filelists") == 0) {
- filelists_xml->priv->section = ZIF_MD_FILELISTS_XML_SECTION_LIST;
- goto out;
- }
-
- egg_warning ("unhandled element: %s", element_name);
- goto out;
- }
-
- /* update element */
- if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_LIST) {
-
- if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN) {
-
- if (g_strcmp0 (element_name, "package") == 0) {
- filelists_xml->priv->section_list = ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE;
- filelists_xml->priv->package_temp = ZIF_PACKAGE (zif_package_remote_new ());
- filelists_xml->priv->array_temp = g_ptr_array_new_with_free_func (g_free);
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "pkgid") == 0) {
- zif_package_remote_set_pkgid (ZIF_PACKAGE_REMOTE (filelists_xml->priv->package_temp),
- attribute_values[i]);
- }
- }
- goto out;
- }
-
- egg_warning ("unhandled update list tag: %s", element_name);
- goto out;
-
- }
- if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE) {
-
- if (g_strcmp0 (element_name, "version") == 0) {
- filelists_xml->priv->section_list_package = ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN;
- goto out;
- }
-
- if (g_strcmp0 (element_name, "file") == 0) {
- filelists_xml->priv->section_list_package = ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_FILE;
- goto out;
- }
- egg_warning ("unhandled update package tag: %s", element_name);
- goto out;
- }
- egg_warning ("unhandled package tag: %s", element_name);
- }
-
- egg_warning ("unhandled base tag: %s", element_name);
-
-out:
- return;
-}
-
-/**
- * zif_md_filelists_xml_parser_end_element:
- **/
-static void
-zif_md_filelists_xml_parser_end_element (GMarkupParseContext *context, const gchar *element_name,
- gpointer user_data, GError **error)
-{
- ZifMdFilelistsXml *filelists_xml = user_data;
-
- /* no element */
- if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN) {
- egg_warning ("unhandled base end tag: %s", element_name);
- goto out;
- }
-
- /* update element */
- if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_LIST) {
-
- /* update element */
- if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN) {
-
- /* end of list */
- if (g_strcmp0 (element_name, "filelists") == 0) {
- filelists_xml->priv->section = ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN;
- goto out;
- }
- egg_warning ("unhandled outside tag: %s", element_name);
- goto out;
- }
-
- /* update element */
- if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE) {
-
- if (filelists_xml->priv->section_list_package == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_UNKNOWN) {
-
- if (g_strcmp0 (element_name, "version") == 0)
- goto out;
-
- /* end of list */
- if (g_strcmp0 (element_name, "package") == 0) {
- zif_package_set_files (filelists_xml->priv->package_temp, filelists_xml->priv->array_temp);
- g_ptr_array_add (filelists_xml->priv->array, filelists_xml->priv->package_temp);
- filelists_xml->priv->package_temp = NULL;
- filelists_xml->priv->array_temp = NULL;
- filelists_xml->priv->section_list = ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN;
- goto out;
- }
- egg_warning ("unhandled package tag: %s", element_name);
- goto out;
- }
-
- if (filelists_xml->priv->section_list_package == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_FILE) {
- if (g_strcmp0 (element_name, "file") == 0) {
- filelists_xml->priv->section_list_package = ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_UNKNOWN;
- goto out;
- }
- egg_warning ("unhandled end of file tag: %s", element_name);
- goto out;
- }
- egg_warning ("unhandled end of package tag: %s", element_name);
- goto out;
- }
-
- egg_warning ("unhandled update end tag: %s", element_name);
- goto out;
- }
-
- egg_warning ("unhandled end tag: %s", element_name);
-out:
- return;
-}
-
-/**
- * zif_md_filelists_xml_parser_text:
- **/
-static void
-zif_md_filelists_xml_parser_text (GMarkupParseContext *context, const gchar *text, gsize text_len,
- gpointer user_data, GError **error)
-
-{
- ZifMdFilelistsXml *filelists_xml = user_data;
-
- /* skip whitespace */
- if (text_len < 1 || text[0] == ' ' || text[0] == '\t' || text[0] == '\n')
- goto out;
-
- /* group section */
- if (filelists_xml->priv->section == ZIF_MD_FILELISTS_XML_SECTION_LIST) {
- if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN) {
- egg_warning ("not saving: %s", text);
- goto out;
- }
- if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE) {
- if (filelists_xml->priv->section_list == ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_FILE) {
- g_ptr_array_add (filelists_xml->priv->array_temp, g_strdup (text));
- goto out;
- };
- egg_warning ("not saving: %s", text);
- goto out;
- }
- egg_warning ("not saving: %s", text);
- goto out;
- }
-out:
- return;
-}
-
-/**
- * zif_md_filelists_xml_load:
- **/
-static gboolean
-zif_md_filelists_xml_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- const gchar *filename;
- gboolean ret;
- gchar *contents = NULL;
- gsize size;
- ZifMdFilelistsXml *filelists_xml = ZIF_MD_FILELISTS_XML (md);
- GMarkupParseContext *context = NULL;
- const GMarkupParser gpk_md_filelists_xml_markup_parser = {
- zif_md_filelists_xml_parser_start_element,
- zif_md_filelists_xml_parser_end_element,
- zif_md_filelists_xml_parser_text,
- NULL, /* passthrough */
- NULL /* error */
- };
-
- g_return_val_if_fail (ZIF_IS_MD_FILELISTS_XML (md), FALSE);
-
- /* already loaded */
- if (filelists_xml->priv->loaded)
- goto out;
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for filelists_xml");
- goto out;
- }
-
- /* open database */
- egg_debug ("filename = %s", filename);
- ret = g_file_get_contents (filename, &contents, &size, error);
- if (!ret)
- goto out;
-
- /* create parser */
- context = g_markup_parse_context_new (&gpk_md_filelists_xml_markup_parser, G_MARKUP_PREFIX_ERROR_POSITION, filelists_xml, NULL);
-
- /* parse data */
- ret = g_markup_parse_context_parse (context, contents, (gssize) size, error);
- if (!ret)
- goto out;
-
- /* we don't need to keep syncing */
- filelists_xml->priv->loaded = TRUE;
-out:
- g_free (contents);
- return filelists_xml->priv->loaded;
-}
-
-/**
- * zif_md_filelists_xml_get_files:
- **/
-static GPtrArray *
-zif_md_filelists_xml_get_files (ZifMd *md, ZifPackage *package,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- GPtrArray *packages;
- ZifPackage *package_tmp;
- guint i;
- gboolean ret;
- const gchar *pkgid;
- const gchar *pkgid_tmp;
- GError *error_local = NULL;
- ZifCompletion *completion_local;
- ZifCompletion *completion_loop;
- ZifMdFilelistsXml *md_filelists = ZIF_MD_FILELISTS_XML (md);
-
- g_return_val_if_fail (ZIF_IS_MD_FILELISTS_XML (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* setup completion */
- if (md_filelists->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!md_filelists->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_md_load (ZIF_MD (md), cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to load md_filelists_xml file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* setup steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, md_filelists->priv->array->len);
-
- /* search array */
- pkgid = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package));
- packages = md_filelists->priv->array;
- for (i=0; i<packages->len; i++) {
- package_tmp = g_ptr_array_index (packages, i);
- pkgid_tmp = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package_tmp));
- if (g_strcmp0 (pkgid, pkgid_tmp) == 0) {
- completion_loop = zif_completion_get_child (completion_local);
- array = zif_package_get_files (package_tmp, cancellable, completion_loop, NULL);
- break;
- }
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_md_filelists_xml_search_file:
- **/
-static GPtrArray *
-zif_md_filelists_xml_search_file (ZifMd *md, gchar **search,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- GPtrArray *packages;
- ZifPackage *package;
- GPtrArray *files = NULL;
- const gchar *filename;
- guint i, j, k;
- gboolean ret;
- const gchar *pkgid;
- GError *error_local = NULL;
- ZifCompletion *completion_local;
- ZifCompletion *completion_loop;
- ZifMdFilelistsXml *md_filelists = ZIF_MD_FILELISTS_XML (md);
-
- g_return_val_if_fail (ZIF_IS_MD_FILELISTS_XML (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* setup completion */
- if (md_filelists->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!md_filelists->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_md_load (ZIF_MD (md), cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to load md_filelists_xml file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* create results array */
- array = g_ptr_array_new_with_free_func (g_free);
-
- /* no entries, so shortcut */
- if (md_filelists->priv->array->len == 0) {
- zif_completion_done (completion);
- goto out;
- }
-
- /* setup steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, md_filelists->priv->array->len);
-
- /* search array */
- packages = md_filelists->priv->array;
- for (i=0; i<packages->len; i++) {
- package = g_ptr_array_index (packages, i);
- pkgid = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package));
- completion_loop = zif_completion_get_child (completion_local);
- files = zif_package_get_files (package, cancellable, completion_loop, NULL);
- for (k=0; k<files->len; k++) {
- filename = g_ptr_array_index (files, k);
- for (j=0; search[j] != NULL; j++) {
- if (g_strcmp0 (filename, search[j]) == 0) {
- g_ptr_array_add (array, g_strdup (pkgid));
- break;
- }
- }
- }
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- if (files != NULL)
- g_ptr_array_unref (files);
- return array;
-}
-
-/**
- * zif_md_filelists_xml_finalize:
- **/
-static void
-zif_md_filelists_xml_finalize (GObject *object)
-{
- ZifMdFilelistsXml *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD_FILELISTS_XML (object));
- md = ZIF_MD_FILELISTS_XML (object);
-
- g_ptr_array_unref (md->priv->array);
-
- G_OBJECT_CLASS (zif_md_filelists_xml_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_filelists_xml_class_init:
- **/
-static void
-zif_md_filelists_xml_class_init (ZifMdFilelistsXmlClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifMdClass *md_class = ZIF_MD_CLASS (klass);
- object_class->finalize = zif_md_filelists_xml_finalize;
-
- /* map */
- md_class->load = zif_md_filelists_xml_load;
- md_class->unload = zif_md_filelists_xml_unload;
- md_class->search_file = zif_md_filelists_xml_search_file;
- md_class->get_files = zif_md_filelists_xml_get_files;
-
- g_type_class_add_private (klass, sizeof (ZifMdFilelistsXmlPrivate));
-}
-
-/**
- * zif_md_filelists_xml_init:
- **/
-static void
-zif_md_filelists_xml_init (ZifMdFilelistsXml *md)
-{
- md->priv = ZIF_MD_FILELISTS_XML_GET_PRIVATE (md);
- md->priv->array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- md->priv->loaded = FALSE;
- md->priv->section = ZIF_MD_FILELISTS_XML_SECTION_UNKNOWN;
- md->priv->section_list = ZIF_MD_FILELISTS_XML_SECTION_LIST_UNKNOWN;
- md->priv->section_list_package = ZIF_MD_FILELISTS_XML_SECTION_LIST_PACKAGE_UNKNOWN;
- md->priv->package_temp = NULL;
- md->priv->array_temp = NULL;
-}
-
-/**
- * zif_md_filelists_xml_new:
- *
- * Return value: A new #ZifMdFilelistsXml class instance.
- *
- * Since: 0.0.1
- **/
-ZifMdFilelistsXml *
-zif_md_filelists_xml_new (void)
-{
- ZifMdFilelistsXml *md;
- md = g_object_new (ZIF_TYPE_MD_FILELISTS_XML, NULL);
- return ZIF_MD_FILELISTS_XML (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_filelists_xml_test (EggTest *test)
-{
- ZifMdFilelistsXml *md;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- ZifPackage *package;
- ZifString *summary;
- GCancellable *cancellable;
- ZifCompletion *completion;
- gchar *pkgid;
- gchar *data[] = { "/usr/lib/debug/usr/bin/gpk-prefs.debug", NULL };
-
- if (!egg_test_start (test, "ZifMdFilelistsXml"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get md_filelists_xml md");
- md = zif_md_filelists_xml_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (ZIF_MD (md), "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set type");
- ret = zif_md_set_mdtype (ZIF_MD (md), ZIF_MD_TYPE_FILELISTS_XML);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum type");
- ret = zif_md_set_checksum_type (ZIF_MD (md), G_CHECKSUM_SHA256);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum compressed");
- ret = zif_md_set_checksum (ZIF_MD (md), "cadb324b10d395058ed22c9d984038927a3ea4ff9e0e798116be44b0233eaa49");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum uncompressed");
- ret = zif_md_set_checksum_uncompressed (ZIF_MD (md), "8018e177379ada1d380b4ebf800e7caa95ff8cf90fdd6899528266719bbfdeab");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_md_set_filename (ZIF_MD (md), "../test/cache/fedora/filelists.xml.gz");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "search for files");
- zif_completion_reset (completion);
- array = zif_md_filelists_xml_search_file (ZIF_MD (md), (gchar**)data, cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len != 1)
- egg_test_failed (test, "got %i", array->len);
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "correct value");
- pkgid = g_ptr_array_index (array, 0);
- if (pkgid == NULL)
- egg_test_failed (test, "failed to get a pkgId");
- else if (pkgid[0] != '\0' && strlen (pkgid) == 64)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get a correct pkgId '%s' (%i)", pkgid, strlen (pkgid));
- g_ptr_array_unref (array);
-
- g_object_unref (cancellable);
- g_object_unref (completion);
- g_object_unref (md);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md-filelists-xml.h b/backends/yum/libzif/zif-md-filelists-xml.h
deleted file mode 100644
index 02f7622..0000000
--- a/backends/yum/libzif/zif-md-filelists-xml.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_FILELISTS_XML_H
-#define __ZIF_MD_FILELISTS_XML_H
-
-#include <glib-object.h>
-
-#include "zif-md.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD_FILELISTS_XML (zif_md_filelists_xml_get_type ())
-#define ZIF_MD_FILELISTS_XML(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD_FILELISTS_XML, ZifMdFilelistsXml))
-#define ZIF_MD_FILELISTS_XML_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD_FILELISTS_XML, ZifMdFilelistsXmlClass))
-#define ZIF_IS_MD_FILELISTS_XML(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD_FILELISTS_XML))
-#define ZIF_IS_MD_FILELISTS_XML_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD_FILELISTS_XML))
-#define ZIF_MD_FILELISTS_XML_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD_FILELISTS_XML, ZifMdFilelistsXmlClass))
-
-typedef struct _ZifMdFilelistsXml ZifMdFilelistsXml;
-typedef struct _ZifMdFilelistsXmlPrivate ZifMdFilelistsXmlPrivate;
-typedef struct _ZifMdFilelistsXmlClass ZifMdFilelistsXmlClass;
-
-struct _ZifMdFilelistsXml
-{
- ZifMd parent;
- ZifMdFilelistsXmlPrivate *priv;
-};
-
-struct _ZifMdFilelistsXmlClass
-{
- ZifMdClass parent_class;
-};
-
-GType zif_md_filelists_xml_get_type (void);
-ZifMdFilelistsXml *zif_md_filelists_xml_new (void);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_FILELISTS_XML_H */
-
diff --git a/backends/yum/libzif/zif-md-metalink.c b/backends/yum/libzif/zif-md-metalink.c
deleted file mode 100644
index 936f2af..0000000
--- a/backends/yum/libzif/zif-md-metalink.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md-metalink
- * @short_description: Metalink metadata functionality
- *
- * Provide access to the metalink repo metadata.
- * This object is a subclass of #ZifMd
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <glib.h>
-#include <string.h>
-
-#include "zif-md.h"
-#include "zif-md-metalink.h"
-#include "zif-config.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_METALINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_METALINK, ZifMdMetalinkPrivate))
-
-typedef enum {
- ZIF_MD_METALINK_PARSER_SECTION_URL,
- ZIF_MD_METALINK_PARSER_SECTION_UNKNOWN
-} ZifMdMetalinkParserSection;
-
-typedef enum {
- ZIF_MD_METALINK_PROTOCOL_TYPE_FTP,
- ZIF_MD_METALINK_PROTOCOL_TYPE_HTTP,
- ZIF_MD_METALINK_PROTOCOL_TYPE_RSYNC,
- ZIF_MD_METALINK_PROTOCOL_TYPE_UNKNOWN
-} ZifMdMetalinkProtocolType;
-
-typedef struct {
- ZifMdMetalinkProtocolType protocol;
- gchar *uri;
- guint preference;
-} ZifMdMetalinkData;
-
-/**
- * ZifMdMetalinkPrivate:
- *
- * Private #ZifMdMetalink data
- **/
-struct _ZifMdMetalinkPrivate
-{
- gboolean loaded;
- GPtrArray *array;
- ZifConfig *config;
- /* for parser */
- ZifMdMetalinkParserSection section;
- ZifMdMetalinkData *temp;
-};
-
-G_DEFINE_TYPE (ZifMdMetalink, zif_md_metalink, ZIF_TYPE_MD)
-
-/**
- * zif_md_metalink_protocol_type_from_text:
- **/
-static ZifMdMetalinkProtocolType
-zif_md_metalink_protocol_type_from_text (const gchar *type_text)
-{
- if (g_strcmp0 (type_text, "ftp") == 0)
- return ZIF_MD_METALINK_PROTOCOL_TYPE_FTP;
- if (g_strcmp0 (type_text, "http") == 0)
- return ZIF_MD_METALINK_PROTOCOL_TYPE_HTTP;
- if (g_strcmp0 (type_text, "rsync") == 0)
- return ZIF_MD_METALINK_PROTOCOL_TYPE_RSYNC;
- return ZIF_MD_METALINK_PROTOCOL_TYPE_UNKNOWN;
-}
-
-/**
- * zif_md_metalink_parser_start_element:
- **/
-static void
-zif_md_metalink_parser_start_element (GMarkupParseContext *context, const gchar *element_name,
- const gchar **attribute_names, const gchar **attribute_values,
- gpointer user_data, GError **error)
-{
- guint i;
- ZifMdMetalink *metalink = user_data;
-
- g_return_if_fail (ZIF_IS_MD_METALINK (metalink));
- g_return_if_fail (metalink->priv->temp == NULL);
-
- /* just ignore non url entries */
- if (g_strcmp0 (element_name, "url") != 0) {
- metalink->priv->temp = NULL;
- metalink->priv->section = ZIF_MD_METALINK_PARSER_SECTION_UNKNOWN;
- goto out;
- }
-
- /* create new element */
- metalink->priv->section = ZIF_MD_METALINK_PARSER_SECTION_URL;
- metalink->priv->temp = g_new0 (ZifMdMetalinkData, 1);
-
- /* read keys */
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "protocol") == 0)
- metalink->priv->temp->protocol = zif_md_metalink_protocol_type_from_text (attribute_values[i]);
- if (g_strcmp0 (attribute_names[i], "preference") == 0)
- metalink->priv->temp->preference = atoi (attribute_values[i]);
- }
-
- /* add to array */
- g_ptr_array_add (metalink->priv->array, metalink->priv->temp);
-out:
- return;
-}
-
-/**
- * zif_md_metalink_parser_end_element:
- **/
-static void
-zif_md_metalink_parser_end_element (GMarkupParseContext *context, const gchar *element_name,
- gpointer user_data, GError **error)
-{
- ZifMdMetalink *metalink = user_data;
- metalink->priv->temp = NULL;
- metalink->priv->section = ZIF_MD_METALINK_PARSER_SECTION_UNKNOWN;
-}
-
-/**
- * zif_md_metalink_parser_text:
- **/
-static void
-zif_md_metalink_parser_text (GMarkupParseContext *context, const gchar *text, gsize text_len,
- gpointer user_data, GError **error)
-
-{
- ZifMdMetalink *metalink = user_data;
- gchar *uri = NULL;
- guint len;
-
- if (metalink->priv->section != ZIF_MD_METALINK_PARSER_SECTION_URL)
- goto out;
-
- /* shouldn't happen */
- if (metalink->priv->temp == NULL) {
- egg_warning ("no data, so cannot save %s!", text);
- goto out;
- }
-
- /* save uri */
- if (metalink->priv->temp->uri != NULL) {
- egg_warning ("previously set uri to '%s', cannot overwrite with '%s'", metalink->priv->temp->uri, text);
- goto out;
- }
-
- /* copy */
- uri = g_strdup (text);
-
- /* do we need to trim the junk from the end */
- if (g_str_has_suffix (uri, "/repodata/repomd.xml")) {
- len = strlen (uri);
- uri[len-19] = '\0';
- }
-
- /* save */
- metalink->priv->temp->uri = g_strdup (uri);
-out:
- g_free (uri);
- return;
-}
-
-/**
- * zif_md_metalink_unload:
- **/
-static gboolean
-zif_md_metalink_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- return ret;
-}
-
-/**
- * zif_md_metalink_load:
- **/
-static gboolean
-zif_md_metalink_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = TRUE;
- gchar *contents = NULL;
- const gchar *filename;
- gsize size;
- GMarkupParseContext *context = NULL;
- const GMarkupParser gpk_md_metalink_markup_parser = {
- zif_md_metalink_parser_start_element,
- zif_md_metalink_parser_end_element,
- zif_md_metalink_parser_text,
- NULL, /* passthrough */
- NULL /* error */
- };
- ZifMdMetalink *metalink = ZIF_MD_METALINK (md);
-
- g_return_val_if_fail (ZIF_IS_MD_METALINK (md), FALSE);
-
- /* already loaded */
- if (metalink->priv->loaded)
- goto out;
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for metalink");
- goto out;
- }
-
- /* open database */
- egg_debug ("filename = %s", filename);
-
- /* get repo contents */
- ret = g_file_get_contents (filename, &contents, &size, error);
- if (!ret)
- goto out;
-
- /* create parser */
- context = g_markup_parse_context_new (&gpk_md_metalink_markup_parser, G_MARKUP_PREFIX_ERROR_POSITION, metalink, NULL);
-
- /* parse data */
- ret = g_markup_parse_context_parse (context, contents, (gssize) size, error);
- if (!ret)
- goto out;
-
- metalink->priv->loaded = TRUE;
-out:
- if (context != NULL)
- g_markup_parse_context_free (context);
- g_free (contents);
- return ret;
-}
-
-/**
- * zif_md_metalink_get_uris:
- * @md: the #ZifMdMetalink object
- * @threshold: the threshold in percent
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds all mirrors we should use.
- *
- * Return value: the uris to use as an array of strings
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_metalink_get_uris (ZifMdMetalink *md, guint threshold,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- guint len;
- gchar *uri;
- GPtrArray *array = NULL;
- GError *error_local = NULL;
- ZifMdMetalinkData *data;
- guint i;
- ZifMdMetalink *metalink = ZIF_MD_METALINK (md);
-
- g_return_val_if_fail (ZIF_IS_MD_METALINK (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!metalink->priv->loaded) {
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to get mirrors from metalink: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- len = metalink->priv->array->len;
- for (i=0; i<len; i++) {
- data = g_ptr_array_index (metalink->priv->array, i);
-
- /* ignore not http mirrors */
- if (data->protocol != ZIF_MD_METALINK_PROTOCOL_TYPE_HTTP)
- continue;
-
- /* ignore low priority */
- if (data->preference >= threshold) {
- uri = zif_config_expand_substitutions (md->priv->config, data->uri, &error_local);
- if (uri == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to expand substitutions: %s", error_local->message);
- g_error_free (error_local);
- /* rip apart what we've done already */
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
- g_ptr_array_add (array, uri);
- }
- }
-out:
- return array;
-}
-
-/**
- * zif_md_metalink_free_data:
- **/
-static void
-zif_md_metalink_free_data (ZifMdMetalinkData *data)
-{
- g_free (data->uri);
- g_free (data);
-}
-
-/**
- * zif_md_metalink_finalize:
- **/
-static void
-zif_md_metalink_finalize (GObject *object)
-{
- ZifMdMetalink *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD_METALINK (object));
- md = ZIF_MD_METALINK (object);
-
- g_ptr_array_unref (md->priv->array);
- g_object_unref (md->priv->config);
-
- G_OBJECT_CLASS (zif_md_metalink_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_metalink_class_init:
- **/
-static void
-zif_md_metalink_class_init (ZifMdMetalinkClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifMdClass *md_class = ZIF_MD_CLASS (klass);
- object_class->finalize = zif_md_metalink_finalize;
-
- /* map */
- md_class->load = zif_md_metalink_load;
- md_class->unload = zif_md_metalink_unload;
- g_type_class_add_private (klass, sizeof (ZifMdMetalinkPrivate));
-}
-
-/**
- * zif_md_metalink_init:
- **/
-static void
-zif_md_metalink_init (ZifMdMetalink *md)
-{
- md->priv = ZIF_MD_METALINK_GET_PRIVATE (md);
- md->priv->loaded = FALSE;
- md->priv->config = zif_config_new ();
- md->priv->array = g_ptr_array_new_with_free_func ((GDestroyNotify) zif_md_metalink_free_data);
-}
-
-/**
- * zif_md_metalink_new:
- *
- * Return value: A new #ZifMdMetalink class instance.
- *
- * Since: 0.0.1
- **/
-ZifMdMetalink *
-zif_md_metalink_new (void)
-{
- ZifMdMetalink *md;
- md = g_object_new (ZIF_TYPE_MD_METALINK, NULL);
- return ZIF_MD_METALINK (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_metalink_test (EggTest *test)
-{
- ZifMdMetalink *md;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- const gchar *uri;
- GCancellable *cancellable;
- ZifCompletion *completion;
- ZifConfig *config;
-
- if (!egg_test_start (test, "ZifMdMetalink"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
- config = zif_config_new ();
- zif_config_set_filename (config, "../test/etc/yum.conf", NULL);
-
- /************************************************************/
- egg_test_title (test, "get md_metalink md");
- md = zif_md_metalink_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (ZIF_MD (md), "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set type");
- ret = zif_md_set_mdtype (ZIF_MD (md), ZIF_MD_TYPE_METALINK);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_md_set_filename (ZIF_MD (md), "../test/cache/fedora/metalink.xml");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "get uris");
- array = zif_md_metalink_get_uris (md, 50, cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len == 47)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect value %i", array->len);
-
- /************************************************************/
- egg_test_title (test, "correct value");
- uri = g_ptr_array_index (array, 0);
- if (g_strcmp0 (uri, "http://www.mirrorservice.org/sites/download.fedora.redhat.com/pub/fedora/linux/releases/12/Everything/i386/os/") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct url '%s'", uri);
- g_ptr_array_unref (array);
-
- g_object_unref (md);
- g_object_unref (cancellable);
- g_object_unref (completion);
- g_object_unref (config);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md-metalink.h b/backends/yum/libzif/zif-md-metalink.h
deleted file mode 100644
index 0032c0b..0000000
--- a/backends/yum/libzif/zif-md-metalink.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_METALINK_H
-#define __ZIF_MD_METALINK_H
-
-#include <glib-object.h>
-
-#include "zif-md.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD_METALINK (zif_md_metalink_get_type ())
-#define ZIF_MD_METALINK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD_METALINK, ZifMdMetalink))
-#define ZIF_MD_METALINK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD_METALINK, ZifMdMetalinkClass))
-#define ZIF_IS_MD_METALINK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD_METALINK))
-#define ZIF_IS_MD_METALINK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD_METALINK))
-#define ZIF_MD_METALINK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD_METALINK, ZifMdMetalinkClass))
-
-typedef struct _ZifMdMetalink ZifMdMetalink;
-typedef struct _ZifMdMetalinkPrivate ZifMdMetalinkPrivate;
-typedef struct _ZifMdMetalinkClass ZifMdMetalinkClass;
-
-struct _ZifMdMetalink
-{
- ZifMd parent;
- ZifMdMetalinkPrivate *priv;
-};
-
-struct _ZifMdMetalinkClass
-{
- ZifMdClass parent_class;
-};
-
-GType zif_md_metalink_get_type (void);
-ZifMdMetalink *zif_md_metalink_new (void);
-GPtrArray *zif_md_metalink_get_uris (ZifMdMetalink *md,
- guint threshold,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_METALINK_H */
-
diff --git a/backends/yum/libzif/zif-md-mirrorlist.c b/backends/yum/libzif/zif-md-mirrorlist.c
deleted file mode 100644
index 28a2547..0000000
--- a/backends/yum/libzif/zif-md-mirrorlist.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md-mirrorlist
- * @short_description: Mirrorlist metadata functionality
- *
- * Provide access to the mirrorlist repo metadata.
- * This object is a subclass of #ZifMd
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <glib.h>
-
-#include "zif-md.h"
-#include "zif-md-mirrorlist.h"
-#include "zif-config.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_MIRRORLIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_MIRRORLIST, ZifMdMirrorlistPrivate))
-
-/**
- * ZifMdMirrorlistPrivate:
- *
- * Private #ZifMdMirrorlist data
- **/
-struct _ZifMdMirrorlistPrivate
-{
- gboolean loaded;
- GPtrArray *array;
- ZifConfig *config;
-};
-
-G_DEFINE_TYPE (ZifMdMirrorlist, zif_md_mirrorlist, ZIF_TYPE_MD)
-
-/**
- * zif_md_mirrorlist_unload:
- **/
-static gboolean
-zif_md_mirrorlist_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- return ret;
-}
-
-/**
- * zif_md_mirrorlist_load:
- **/
-static gboolean
-zif_md_mirrorlist_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = TRUE;
- gchar *contents = NULL;
- const gchar *filename;
- gchar **lines = NULL;
- guint i;
- ZifMdMirrorlist *mirrorlist = ZIF_MD_MIRRORLIST (md);
-
- g_return_val_if_fail (ZIF_IS_MD_MIRRORLIST (md), FALSE);
-
- /* already loaded */
- if (mirrorlist->priv->loaded)
- goto out;
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for mirrorlist");
- goto out;
- }
-
- /* open database */
- egg_debug ("filename = %s", filename);
-
- /* get repo contents */
- ret = g_file_get_contents (filename, &contents, NULL, error);
- if (!ret)
- goto out;
-
- /* split, and add uris */
- lines = g_strsplit (contents, "\n", -1);
- for (i=0; lines[i] != NULL; i++) {
- if (lines[i][0] == '\0' ||
- lines[i][0] == '#')
- continue;
- if (g_str_has_prefix (lines[i], "http://"))
- g_ptr_array_add (mirrorlist->priv->array, g_strdup (lines[i]));
- }
-
- mirrorlist->priv->loaded = TRUE;
-out:
- g_strfreev (lines);
- g_free (contents);
- return ret;
-}
-
-/**
- * zif_md_mirrorlist_get_uris:
- * @md: the #ZifMdMirrorlist object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds all mirrors we should use.
- *
- * Return value: the uris to use as an array of strings
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_mirrorlist_get_uris (ZifMdMirrorlist *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- guint len;
- GPtrArray *array = NULL;
- GError *error_local = NULL;
- const gchar *data;
- gchar *uri;
- guint i;
- ZifMdMirrorlist *mirrorlist = ZIF_MD_MIRRORLIST (md);
-
- g_return_val_if_fail (ZIF_IS_MD_MIRRORLIST (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!mirrorlist->priv->loaded) {
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to get uris from mirrorlist: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- len = mirrorlist->priv->array->len;
- for (i=0; i<len; i++) {
- data = g_ptr_array_index (mirrorlist->priv->array, i);
- uri = zif_config_expand_substitutions (md->priv->config, data, &error_local);
- if (uri == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to expand substitutions: %s", error_local->message);
- g_error_free (error_local);
- /* rip apart what we've done already */
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
- g_ptr_array_add (array, uri);
- }
-out:
- return array;
-}
-
-/**
- * zif_md_mirrorlist_finalize:
- **/
-static void
-zif_md_mirrorlist_finalize (GObject *object)
-{
- ZifMdMirrorlist *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD_MIRRORLIST (object));
- md = ZIF_MD_MIRRORLIST (object);
-
- g_ptr_array_unref (md->priv->array);
- g_object_unref (md->priv->config);
-
- G_OBJECT_CLASS (zif_md_mirrorlist_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_mirrorlist_class_init:
- **/
-static void
-zif_md_mirrorlist_class_init (ZifMdMirrorlistClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifMdClass *md_class = ZIF_MD_CLASS (klass);
- object_class->finalize = zif_md_mirrorlist_finalize;
-
- /* map */
- md_class->load = zif_md_mirrorlist_load;
- md_class->unload = zif_md_mirrorlist_unload;
- g_type_class_add_private (klass, sizeof (ZifMdMirrorlistPrivate));
-}
-
-/**
- * zif_md_mirrorlist_init:
- **/
-static void
-zif_md_mirrorlist_init (ZifMdMirrorlist *md)
-{
- md->priv = ZIF_MD_MIRRORLIST_GET_PRIVATE (md);
- md->priv->loaded = FALSE;
- md->priv->config = zif_config_new ();
- md->priv->array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
-}
-
-/**
- * zif_md_mirrorlist_new:
- *
- * Return value: A new #ZifMdMirrorlist class instance.
- *
- * Since: 0.0.1
- **/
-ZifMdMirrorlist *
-zif_md_mirrorlist_new (void)
-{
- ZifMdMirrorlist *md;
- md = g_object_new (ZIF_TYPE_MD_MIRRORLIST, NULL);
- return ZIF_MD_MIRRORLIST (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_mirrorlist_test (EggTest *test)
-{
- ZifMdMirrorlist *md;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- const gchar *uri;
- GCancellable *cancellable;
- ZifCompletion *completion;
- ZifConfig *config;
-
- if (!egg_test_start (test, "ZifMdMirrorlist"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
- config = zif_config_new ();
- zif_config_set_filename (config, "../test/etc/yum.conf", NULL);
-
- /************************************************************/
- egg_test_title (test, "get md_mirrorlist md");
- md = zif_md_mirrorlist_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (ZIF_MD (md), "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set type");
- ret = zif_md_set_mdtype (ZIF_MD (md), ZIF_MD_TYPE_MIRRORLIST);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_md_set_filename (ZIF_MD (md), "../test/cache/mirrorlist.txt");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "get uris");
- array = zif_md_mirrorlist_get_uris (md, cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len == 3)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect value %i", array->len);
-
- /************************************************************/
- egg_test_title (test, "correct value");
- uri = g_ptr_array_index (array, 0);
- if (g_strcmp0 (uri, "http://rpm.livna.org/repo/11/i386/") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct url '%s'", uri);
- g_ptr_array_unref (array);
-
- g_object_unref (md);
- g_object_unref (cancellable);
- g_object_unref (completion);
- g_object_unref (config);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md-mirrorlist.h b/backends/yum/libzif/zif-md-mirrorlist.h
deleted file mode 100644
index 9b6e36a..0000000
--- a/backends/yum/libzif/zif-md-mirrorlist.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_MIRRORLIST_H
-#define __ZIF_MD_MIRRORLIST_H
-
-#include <glib-object.h>
-
-#include "zif-md.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD_MIRRORLIST (zif_md_mirrorlist_get_type ())
-#define ZIF_MD_MIRRORLIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD_MIRRORLIST, ZifMdMirrorlist))
-#define ZIF_MD_MIRRORLIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD_MIRRORLIST, ZifMdMirrorlistClass))
-#define ZIF_IS_MD_MIRRORLIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD_MIRRORLIST))
-#define ZIF_IS_MD_MIRRORLIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD_MIRRORLIST))
-#define ZIF_MD_MIRRORLIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD_MIRRORLIST, ZifMdMirrorlistClass))
-
-typedef struct _ZifMdMirrorlist ZifMdMirrorlist;
-typedef struct _ZifMdMirrorlistPrivate ZifMdMirrorlistPrivate;
-typedef struct _ZifMdMirrorlistClass ZifMdMirrorlistClass;
-
-struct _ZifMdMirrorlist
-{
- ZifMd parent;
- ZifMdMirrorlistPrivate *priv;
-};
-
-struct _ZifMdMirrorlistClass
-{
- ZifMdClass parent_class;
-};
-
-GType zif_md_mirrorlist_get_type (void);
-ZifMdMirrorlist *zif_md_mirrorlist_new (void);
-GPtrArray *zif_md_mirrorlist_get_uris (ZifMdMirrorlist *md,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_MIRRORLIST_H */
-
diff --git a/backends/yum/libzif/zif-md-other-sql.c b/backends/yum/libzif/zif-md-other-sql.c
deleted file mode 100644
index 9ff6bde..0000000
--- a/backends/yum/libzif/zif-md-other-sql.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md-other-sql
- * @short_description: Other metadata functionality
- *
- * Provide access to the other repo metadata.
- * This object is a subclass of #ZifMd
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include <gio/gio.h>
-
-#include "zif-md.h"
-#include "zif-changeset.h"
-#include "zif-md-other-sql.h"
-#include "zif-package-remote.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_OTHER_SQL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_OTHER_SQL, ZifMdOtherSqlPrivate))
-
-/**
- * ZifMdOtherSqlPrivate:
- *
- * Private #ZifMdOtherSql data
- **/
-struct _ZifMdOtherSqlPrivate
-{
- gboolean loaded;
- sqlite3 *db;
-};
-
-G_DEFINE_TYPE (ZifMdOtherSql, zif_md_other_sql, ZIF_TYPE_MD)
-
-/**
- * zif_md_other_sql_unload:
- **/
-static gboolean
-zif_md_other_sql_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- return ret;
-}
-
-/**
- * zif_md_other_sql_load:
- **/
-static gboolean
-zif_md_other_sql_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- const gchar *filename;
- gint rc;
- ZifMdOtherSql *other_sql = ZIF_MD_OTHER_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_OTHER_SQL (md), FALSE);
-
- /* already loaded */
- if (other_sql->priv->loaded)
- goto out;
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for other_sql");
- goto out;
- }
-
- /* open database */
- egg_debug ("filename = %s", filename);
- rc = sqlite3_open (filename, &other_sql->priv->db);
- if (rc != 0) {
- egg_warning ("Can't open database: %s\n", sqlite3_errmsg (other_sql->priv->db));
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "can't open database: %s", sqlite3_errmsg (other_sql->priv->db));
- goto out;
- }
-
- /* we don't need to keep syncing */
- sqlite3_exec (other_sql->priv->db, "PRAGMA synchronous=OFF", NULL, NULL, NULL);
- other_sql->priv->loaded = TRUE;
-out:
- return other_sql->priv->loaded;
-}
-
-/**
- * zif_md_other_sql_sqlite_create_changelog_cb:
- **/
-static gint
-zif_md_other_sql_sqlite_create_changelog_cb (void *data, gint argc, gchar **argv, gchar **col_name)
-{
- GPtrArray *array = (GPtrArray *) data;
- ZifChangeset *changeset;
- gint i;
- guint64 date = 0;
- const gchar *author = NULL;
- const gchar *changelog = NULL;
- gboolean ret;
- GError *error = NULL;
- gchar *endptr = NULL;
-
- /* get the ID */
- for (i=0; i<argc; i++) {
- if (g_strcmp0 (col_name[i], "date") == 0) {
- date = g_ascii_strtoull (argv[i], &endptr, 10);
- if (argv[i] == endptr)
- egg_warning ("failed to parse date %s", argv[i]);
- } else if (g_strcmp0 (col_name[i], "author") == 0) {
- author = argv[i];
- } else if (g_strcmp0 (col_name[i], "changelog") == 0) {
- changelog = argv[i];
- } else {
- egg_warning ("unrecognized: %s=%s", col_name[i], argv[i]);
- }
- }
-
- /* create new object */
- changeset = zif_changeset_new ();
- zif_changeset_set_date (changeset, date);
- zif_changeset_set_description (changeset, changelog);
- ret = zif_changeset_parse_header (changeset, author, &error);
- if (!ret) {
- egg_warning ("failed to parse header: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* add to the array */
- g_ptr_array_add (array, g_object_ref (changeset));
-out:
- g_object_unref (changeset);
- return 0;
-}
-
-/**
- * zif_md_other_sql_search_pkgkey:
- **/
-static GPtrArray *
-zif_md_other_sql_search_pkgkey (ZifMdOtherSql *md, guint pkgkey,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement = NULL;
- gchar *error_msg = NULL;
- gint rc;
- GPtrArray *array = NULL;
-
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- statement = g_strdup_printf ("SELECT author, date, changelog FROM changelog WHERE pkgKey = '%i' ORDER BY date DESC", pkgkey);
- rc = sqlite3_exec (md->priv->db, statement, zif_md_other_sql_sqlite_create_changelog_cb, array, &error_msg);
- if (rc != SQLITE_OK) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "SQL error: %s\n", error_msg);
- sqlite3_free (error_msg);
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
-out:
- g_free (statement);
- return array;
-}
-
-/**
- * zif_md_other_sql_sqlite_pkgkey_cb:
- **/
-static gint
-zif_md_other_sql_sqlite_pkgkey_cb (void *data, gint argc, gchar **argv, gchar **col_name)
-{
- gint i;
- guint pkgkey;
- gchar *endptr = NULL;
- GPtrArray *array = (GPtrArray *) data;
-
- /* get the ID */
- for (i=0; i<argc; i++) {
- if (g_strcmp0 (col_name[i], "pkgKey") == 0) {
- pkgkey = g_ascii_strtoull (argv[i], &endptr, 10);
- if (argv[i] == endptr)
- egg_warning ("could not parse pkgKey '%s'", argv[i]);
- else
- g_ptr_array_add (array, GUINT_TO_POINTER (pkgkey));
- } else {
- egg_warning ("unrecognized: %s=%s", col_name[i], argv[i]);
- }
- }
- return 0;
-}
-
-/**
- * zif_md_other_sql_get_changelog:
- **/
-static GPtrArray *
-zif_md_other_sql_get_changelog (ZifMd *md, const gchar *pkgid,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement = NULL;
- gchar *error_msg = NULL;
- gint rc;
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- GPtrArray *array_tmp = NULL;
- GPtrArray *pkgkey_array = NULL;
- guint i, j;
- guint pkgkey;
- ZifCompletion *completion_local;
- ZifCompletion *completion_loop;
- ZifChangeset *changeset;
- ZifMdOtherSql *md_other_sql = ZIF_MD_OTHER_SQL (md);
-
- /* setup completion */
- if (md_other_sql->priv->loaded)
- zif_completion_set_number_steps (completion, 2);
- else
- zif_completion_set_number_steps (completion, 3);
-
- /* if not already loaded, load */
- if (!md_other_sql->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_md_load (md, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to load md_other_sql file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* create data struct we can pass to the callback */
- pkgkey_array = g_ptr_array_new ();
- statement = g_strdup_printf ("SELECT pkgKey FROM packages WHERE pkgId = '%s'", pkgid);
- rc = sqlite3_exec (md_other_sql->priv->db, statement, zif_md_other_sql_sqlite_pkgkey_cb, pkgkey_array, &error_msg);
- if (rc != SQLITE_OK) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "SQL error: %s\n", error_msg);
- sqlite3_free (error_msg);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* output array */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-
- /* resolve each pkgkey to a package */
- completion_local = zif_completion_get_child (completion);
- if (pkgkey_array->len > 0)
- zif_completion_set_number_steps (completion_local, pkgkey_array->len);
- for (i=0; i<pkgkey_array->len; i++) {
- pkgkey = GPOINTER_TO_UINT (g_ptr_array_index (pkgkey_array, i));
-
- /* get changeset for pkgKey */
- completion_loop = zif_completion_get_child (completion_local);
- array_tmp = zif_md_other_sql_search_pkgkey (md_other_sql, pkgkey, cancellable, completion_loop, error);
- if (array_tmp == NULL) {
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
-
- /* no results */
- if (array_tmp->len == 0)
- egg_warning ("no changelog for pkgKey %i", pkgkey);
- for (j=0; j<array_tmp->len; j++) {
- changeset = g_ptr_array_index (array_tmp, j);
- g_ptr_array_add (array, g_object_ref (changeset));
- }
-
- /* clear array */
- g_ptr_array_unref (array_tmp);
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- g_free (statement);
- if (pkgkey_array != NULL)
- g_ptr_array_unref (pkgkey_array);
- return array;
-}
-
-/**
- * zif_md_other_sql_finalize:
- **/
-static void
-zif_md_other_sql_finalize (GObject *object)
-{
- ZifMdOtherSql *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD_OTHER_SQL (object));
- md = ZIF_MD_OTHER_SQL (object);
-
- sqlite3_close (md->priv->db);
-
- G_OBJECT_CLASS (zif_md_other_sql_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_other_sql_class_init:
- **/
-static void
-zif_md_other_sql_class_init (ZifMdOtherSqlClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifMdClass *md_class = ZIF_MD_CLASS (klass);
- object_class->finalize = zif_md_other_sql_finalize;
-
- /* map */
- md_class->load = zif_md_other_sql_load;
- md_class->unload = zif_md_other_sql_unload;
- md_class->get_changelog = zif_md_other_sql_get_changelog;
- g_type_class_add_private (klass, sizeof (ZifMdOtherSqlPrivate));
-}
-
-/**
- * zif_md_other_sql_init:
- **/
-static void
-zif_md_other_sql_init (ZifMdOtherSql *md)
-{
- md->priv = ZIF_MD_OTHER_SQL_GET_PRIVATE (md);
- md->priv->loaded = FALSE;
- md->priv->db = NULL;
-}
-
-/**
- * zif_md_other_sql_new:
- *
- * Return value: A new #ZifMdOtherSql class instance.
- *
- * Since: 0.0.1
- **/
-ZifMdOtherSql *
-zif_md_other_sql_new (void)
-{
- ZifMdOtherSql *md;
- md = g_object_new (ZIF_TYPE_MD_OTHER_SQL, NULL);
- return ZIF_MD_OTHER_SQL (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_other_sql_test (EggTest *test)
-{
- ZifMdOtherSql *md;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- ZifChangeset *changeset;
- GCancellable *cancellable;
- ZifCompletion *completion;
- const gchar *text;
-
- if (!egg_test_start (test, "ZifMdOtherSql"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get md_other_sql md");
- md = zif_md_other_sql_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (ZIF_MD (md), "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set type");
- ret = zif_md_set_mdtype (ZIF_MD (md), ZIF_MD_TYPE_OTHER_SQL);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum type");
- ret = zif_md_set_checksum_type (ZIF_MD (md), G_CHECKSUM_SHA256);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum compressed");
- ret = zif_md_set_checksum (ZIF_MD (md), "bc58c56b371a83dc546c86e1796d83b9ff78adbf733873c815c3fe5dd48b0d56");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum uncompressed");
- ret = zif_md_set_checksum_uncompressed (ZIF_MD (md), "c378618f9764ff9fa271a40b962a0c3569ff274e741ada2342d0fe3554614488");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_md_set_filename (ZIF_MD (md), "../test/cache/fedora/bc58c56b371a83dc546c86e1796d83b9ff78adbf733873c815c3fe5dd48b0d56-other.sqlite.bz2");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "search for files");
- zif_completion_reset (completion);
- array = zif_md_other_sql_get_changelog (ZIF_MD (md),
- "42b8d71b303b19c2fcc2b06bb9c764f2902dd72b9376525025ee9ba4a41c38e9",
- cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len != 10)
- egg_test_failed (test, "failed to get correct number: %i", array->len);
- egg_test_success (test, NULL);
-
- /* get first entry */
- changeset = g_ptr_array_index (array, 1);
-
- /************************************************************/
- egg_test_title (test, "correct version");
- text = zif_changeset_get_version (changeset);
- if (g_strcmp0 (text, "1.2-3") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct value '%s'", text);
-
- /************************************************************/
- egg_test_title (test, "correct author");
- text = zif_changeset_get_author (changeset);
- if (g_strcmp0 (text, "Rex Dieter <rdieter at fedoraproject.org>") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct value '%s'", text);
-
- /************************************************************/
- egg_test_title (test, "correct description");
- text = zif_changeset_get_description (changeset);
- if (g_strcmp0 (text, "- BR: libfac-devel,factory-devel >= 3.1\n- restore ExcludeArch: ppc64 (#253847)") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct value '%s'", text);
-
- /* remove array */
- g_ptr_array_unref (array);
-
- g_object_unref (cancellable);
- g_object_unref (completion);
- g_object_unref (md);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md-other-sql.h b/backends/yum/libzif/zif-md-other-sql.h
deleted file mode 100644
index b07aad7..0000000
--- a/backends/yum/libzif/zif-md-other-sql.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_OTHER_SQL_H
-#define __ZIF_MD_OTHER_SQL_H
-
-#include <glib-object.h>
-
-#include "zif-md.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD_OTHER_SQL (zif_md_other_sql_get_type ())
-#define ZIF_MD_OTHER_SQL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD_OTHER_SQL, ZifMdOtherSql))
-#define ZIF_MD_OTHER_SQL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD_OTHER_SQL, ZifMdOtherSqlClass))
-#define ZIF_IS_MD_OTHER_SQL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD_OTHER_SQL))
-#define ZIF_IS_MD_OTHER_SQL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD_OTHER_SQL))
-#define ZIF_MD_OTHER_SQL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD_OTHER_SQL, ZifMdOtherSqlClass))
-
-typedef struct _ZifMdOtherSql ZifMdOtherSql;
-typedef struct _ZifMdOtherSqlPrivate ZifMdOtherSqlPrivate;
-typedef struct _ZifMdOtherSqlClass ZifMdOtherSqlClass;
-
-struct _ZifMdOtherSql
-{
- ZifMd parent;
- ZifMdOtherSqlPrivate *priv;
-};
-
-struct _ZifMdOtherSqlClass
-{
- ZifMdClass parent_class;
-};
-
-GType zif_md_other_sql_get_type (void);
-ZifMdOtherSql *zif_md_other_sql_new (void);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_OTHER_SQL_H */
-
diff --git a/backends/yum/libzif/zif-md-primary-sql.c b/backends/yum/libzif/zif-md-primary-sql.c
deleted file mode 100644
index 3a32786..0000000
--- a/backends/yum/libzif/zif-md-primary-sql.c
+++ /dev/null
@@ -1,731 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009-2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md-primary-sql
- * @short_description: Primary metadata functionality
- *
- * Provide access to the primary repo metadata.
- * This object is a subclass of #ZifMd
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include <gio/gio.h>
-
-#include "zif-md.h"
-#include "zif-md-primary-sql.h"
-#include "zif-package-remote.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_PRIMARY_SQL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_PRIMARY_SQL, ZifMdPrimarySqlPrivate))
-
-/**
- * ZifMdPrimarySqlPrivate:
- *
- * Private #ZifMdPrimarySql data
- **/
-struct _ZifMdPrimarySqlPrivate
-{
- gboolean loaded;
- sqlite3 *db;
-};
-
-typedef struct {
- const gchar *id;
- GPtrArray *packages;
- ZifMdPrimarySql *md;
-} ZifMdPrimarySqlData;
-
-G_DEFINE_TYPE (ZifMdPrimarySql, zif_md_primary_sql, ZIF_TYPE_MD)
-
-/**
- * zif_md_primary_sql_unload:
- **/
-static gboolean
-zif_md_primary_sql_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- return ret;
-}
-
-/**
- * zif_md_primary_sql_load:
- **/
-static gboolean
-zif_md_primary_sql_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- const gchar *filename;
- gint rc;
- ZifMdPrimarySql *primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_SQL (md), FALSE);
-
- /* already loaded */
- if (primary_sql->priv->loaded)
- goto out;
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for primary_sql");
- goto out;
- }
-
- /* open database */
- egg_debug ("filename = %s", filename);
- rc = sqlite3_open (filename, &primary_sql->priv->db);
- if (rc != 0) {
- egg_warning ("Can't open database: %s\n", sqlite3_errmsg (primary_sql->priv->db));
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "can't open database: %s", sqlite3_errmsg (primary_sql->priv->db));
- goto out;
- }
-
- /* we don't need to keep syncing */
- sqlite3_exec (primary_sql->priv->db, "PRAGMA synchronous=OFF;", NULL, NULL, NULL);
-
- primary_sql->priv->loaded = TRUE;
-out:
- return primary_sql->priv->loaded;
-}
-
-/**
- * zif_md_primary_sql_sqlite_create_package_cb:
- **/
-static gint
-zif_md_primary_sql_sqlite_create_package_cb (void *data, gint argc, gchar **argv, gchar **col_name)
-{
- ZifMdPrimarySqlData *fldata = (ZifMdPrimarySqlData *) data;
- ZifPackageRemote *package;
- ZifStoreRemote *store_remote;
-
- package = zif_package_remote_new ();
- store_remote = zif_md_get_store_remote (ZIF_MD (fldata->md));
- if (store_remote != NULL) {
- /* this is not set in a test harness */
- zif_package_remote_set_store_remote (package, store_remote);
- } else {
- egg_warning ("no remote store for %s", argv[1]);
- }
- zif_package_remote_set_from_repo (package, argc, col_name, argv, fldata->id, NULL);
- g_ptr_array_add (fldata->packages, package);
-
- return 0;
-}
-
-#define ZIF_MD_PRIMARY_SQL_HEADER "SELECT pkgId, name, arch, version, " \
- "epoch, release, summary, description, url, " \
- "rpm_license, rpm_group, size_package, location_href FROM packages"
-
-/**
- * zif_md_primary_sql_search:
- **/
-static GPtrArray *
-zif_md_primary_sql_search (ZifMdPrimarySql *md, const gchar *statement,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *error_msg = NULL;
- gint rc;
- gboolean ret;
- GError *error_local = NULL;
- ZifMdPrimarySqlData *data = NULL;
- GPtrArray *array = NULL;
-
- /* if not already loaded, load */
- if (!md->priv->loaded) {
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to load md_primary_sql file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* create data struct we can pass to the callback */
- data = g_new0 (ZifMdPrimarySqlData, 1);
- data->md = md;
- data->id = zif_md_get_id (ZIF_MD (md));
- data->packages = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- rc = sqlite3_exec (md->priv->db, statement, zif_md_primary_sql_sqlite_create_package_cb, data, &error_msg);
- if (rc != SQLITE_OK) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "SQL error, failed to execute '%s': %s\n", statement, error_msg);
- sqlite3_free (error_msg);
- g_ptr_array_unref (data->packages);
- goto out;
- }
- /* list of packages */
- array = data->packages;
-out:
- g_free (data);
- return array;
-}
-
-/**
- * zif_md_primary_sql_strreplace:
- **/
-static gchar *
-zif_md_primary_sql_strreplace (const gchar *text, const gchar *find, const gchar *replace)
-{
- gchar **array;
- gchar *retval;
-
- /* split apart and rejoin with new delimiter */
- array = g_strsplit (text, find, 0);
- retval = g_strjoinv (replace, array);
- g_strfreev (array);
- return retval;
-}
-
-/**
- * zif_md_primary_sql_get_statement_for_pred:
- **/
-static gchar *
-zif_md_primary_sql_get_statement_for_pred (const gchar *pred, gchar **search)
-{
- guint i;
- const guint max_items = 20;
- GString *statement;
- gchar *temp;
-
- /* search with predicate */
- statement = g_string_new ("BEGIN;\n");
- for (i=0; search[i] != NULL; i++) {
- if (i % max_items == 0)
- g_string_append (statement, ZIF_MD_PRIMARY_SQL_HEADER " WHERE ");
- temp = zif_md_primary_sql_strreplace (pred, "###", search[i]);
- g_string_append (statement, temp);
- if (i % max_items == max_items - 1)
- g_string_append (statement, ";\n");
- else
- g_string_append (statement, " OR ");
- g_free (temp);
- }
-
- /* remove trailing OR entry */
- if (g_str_has_suffix (statement->str, " OR ")) {
- g_string_set_size (statement, statement->len - 4);
- g_string_append (statement, ";\n");
- }
- g_string_append (statement, "END;");
- return g_string_free (statement, FALSE);
-}
-
-/**
- * zif_md_primary_sql_resolve:
- **/
-static GPtrArray *
-zif_md_primary_sql_resolve (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement;
- GPtrArray *array;
- ZifMdPrimarySql *md_primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_SQL (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* simple name match */
- statement = zif_md_primary_sql_get_statement_for_pred ("name = '###'", search);
- array = zif_md_primary_sql_search (md_primary_sql, statement, cancellable, completion, error);
- g_free (statement);
- return array;
-}
-
-/**
- * zif_md_primary_sql_search_name:
- **/
-static GPtrArray *
-zif_md_primary_sql_search_name (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement;
- GPtrArray *array;
- ZifMdPrimarySql *md_primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_SQL (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* fuzzy name match */
- statement = zif_md_primary_sql_get_statement_for_pred ("name LIKE '%%###%%'", search);
- array = zif_md_primary_sql_search (md_primary_sql, statement, cancellable, completion, error);
- g_free (statement);
-
- return array;
-}
-
-/**
- * zif_md_primary_sql_search_details:
- **/
-static GPtrArray *
-zif_md_primary_sql_search_details (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement;
- GPtrArray *array;
- ZifMdPrimarySql *md_primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_SQL (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* fuzzy details match */
- statement = zif_md_primary_sql_get_statement_for_pred ("name LIKE '%%###%%' OR "
- "summary LIKE '%%###%%' OR "
- "description LIKE '%%###%%'", search);
- array = zif_md_primary_sql_search (md_primary_sql, statement, cancellable, completion, error);
- g_free (statement);
-
- return array;
-}
-
-/**
- * zif_md_primary_sql_search_group:
- **/
-static GPtrArray *
-zif_md_primary_sql_search_group (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement;
- GPtrArray *array;
- ZifMdPrimarySql *md_primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_SQL (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* simple group match */
- statement = zif_md_primary_sql_get_statement_for_pred ("rpm_group = '###'", search);
- array = zif_md_primary_sql_search (md_primary_sql, statement, cancellable, completion, error);
- g_free (statement);
-
- return array;
-}
-
-/**
- * zif_md_primary_sql_search_pkgid:
- **/
-static GPtrArray *
-zif_md_primary_sql_search_pkgid (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement;
- GPtrArray *array;
- ZifMdPrimarySql *md_primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_SQL (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* simple pkgid match */
- statement = zif_md_primary_sql_get_statement_for_pred ("pkgid = '###'", search);
- array = zif_md_primary_sql_search (md_primary_sql, statement, cancellable, completion, error);
- g_free (statement);
-
- return array;
-}
-
-/**
- * zif_md_primary_sql_search_pkgkey:
- **/
-static GPtrArray *
-zif_md_primary_sql_search_pkgkey (ZifMd *md, guint pkgkey,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement;
- GPtrArray *array;
- ZifMdPrimarySql *md_primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_SQL (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* search with predicate */
- statement = g_strdup_printf (ZIF_MD_PRIMARY_SQL_HEADER " WHERE pkgKey = '%i'", pkgkey);
- array = zif_md_primary_sql_search (md_primary_sql, statement, cancellable, completion, error);
- g_free (statement);
- return array;
-}
-
-/**
- * zif_md_primary_sql_sqlite_pkgkey_cb:
- **/
-static gint
-zif_md_primary_sql_sqlite_pkgkey_cb (void *data, gint argc, gchar **argv, gchar **col_name)
-{
- gint i;
- guint pkgkey;
- gchar *endptr = NULL;
- GPtrArray *array = (GPtrArray *) data;
-
- /* get the ID */
- for (i=0; i<argc; i++) {
- if (g_strcmp0 (col_name[i], "pkgKey") == 0) {
- pkgkey = g_ascii_strtoull (argv[i], &endptr, 10);
- if (argv[i] == endptr)
- egg_warning ("failed to parse pkgKey %s", argv[i]);
- else
- g_ptr_array_add (array, GUINT_TO_POINTER (pkgkey));
- } else {
- egg_warning ("unrecognized: %s=%s", col_name[i], argv[i]);
- }
- }
- return 0;
-}
-
-/**
- * zif_md_primary_sql_what_provides:
- **/
-static GPtrArray *
-zif_md_primary_sql_what_provides (ZifMd *md, gchar **search,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement = NULL;
- gchar *error_msg = NULL;
- gint rc;
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- GPtrArray *array_tmp = NULL;
- GPtrArray *pkgkey_array = NULL;
- guint i;
- guint pkgkey;
- ZifCompletion *completion_local;
- ZifCompletion *completion_loop;
- ZifPackage *package;
- ZifMdPrimarySql *md_primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- /* setup completion */
- if (md_primary_sql->priv->loaded)
- zif_completion_set_number_steps (completion, 2);
- else
- zif_completion_set_number_steps (completion, 3);
-
- /* if not already loaded, load */
- if (!md_primary_sql->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_md_load (md, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to load md_primary_sql file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* create data struct we can pass to the callback */
- pkgkey_array = g_ptr_array_new ();
- statement = g_strdup_printf ("SELECT pkgKey FROM provides WHERE name = '%s'", search[0]);
- rc = sqlite3_exec (md_primary_sql->priv->db, statement, zif_md_primary_sql_sqlite_pkgkey_cb, pkgkey_array, &error_msg);
- if (rc != SQLITE_OK) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_BAD_SQL,
- "SQL error: %s\n", error_msg);
- sqlite3_free (error_msg);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* output array */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-
- /* resolve each pkgkey to a package */
- completion_local = zif_completion_get_child (completion);
- if (pkgkey_array->len > 0)
- zif_completion_set_number_steps (completion_local, pkgkey_array->len);
- for (i=0; i<pkgkey_array->len; i++) {
- pkgkey = GPOINTER_TO_UINT (g_ptr_array_index (pkgkey_array, i));
-
- /* get packages for pkgKey */
- completion_loop = zif_completion_get_child (completion_local);
- array_tmp = zif_md_primary_sql_search_pkgkey (md, pkgkey, cancellable, completion_loop, error);
- if (array_tmp == NULL) {
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
-
- /* check we only got one result */
- if (array_tmp->len == 0) {
- egg_warning ("no package for pkgKey %i", pkgkey);
- } else if (array_tmp->len > 1 || array_tmp->len == 0) {
- egg_warning ("more than one package for pkgKey %i", pkgkey);
- } else {
- package = g_ptr_array_index (array_tmp, 0);
- g_ptr_array_add (array, g_object_ref (package));
- }
-
- /* clear array */
- g_ptr_array_unref (array_tmp);
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- g_free (statement);
- if (pkgkey_array != NULL)
- g_ptr_array_unref (pkgkey_array);
- return array;
-}
-
-/**
- * zif_md_primary_sql_find_package:
- **/
-static GPtrArray *
-zif_md_primary_sql_find_package (ZifMd *md, const gchar *package_id, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gchar *statement;
- GPtrArray *array;
- gchar **split;
- ZifMdPrimarySql *md_primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_SQL (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* search with predicate, TODO: search version (epoch+release) */
- split = pk_package_id_split (package_id);
- statement = g_strdup_printf (ZIF_MD_PRIMARY_SQL_HEADER " WHERE name = '%s' AND arch = '%s'",
- split[PK_PACKAGE_ID_NAME], split[PK_PACKAGE_ID_ARCH]);
- array = zif_md_primary_sql_search (md_primary_sql, statement, cancellable, completion, error);
- g_free (statement);
- g_strfreev (split);
-
- return array;
-}
-
-/**
- * zif_md_primary_sql_get_packages:
- **/
-static GPtrArray *
-zif_md_primary_sql_get_packages (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array;
- ZifMdPrimarySql *md_primary_sql = ZIF_MD_PRIMARY_SQL (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_SQL (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* search with predicate */
- array = zif_md_primary_sql_search (md_primary_sql, ZIF_MD_PRIMARY_SQL_HEADER, cancellable, completion, error);
- return array;
-}
-
-/**
- * zif_md_primary_sql_finalize:
- **/
-static void
-zif_md_primary_sql_finalize (GObject *object)
-{
- ZifMdPrimarySql *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD_PRIMARY_SQL (object));
- md = ZIF_MD_PRIMARY_SQL (object);
-
- sqlite3_close (md->priv->db);
-
- G_OBJECT_CLASS (zif_md_primary_sql_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_primary_sql_class_init:
- **/
-static void
-zif_md_primary_sql_class_init (ZifMdPrimarySqlClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifMdClass *md_class = ZIF_MD_CLASS (klass);
- object_class->finalize = zif_md_primary_sql_finalize;
-
- /* map */
- md_class->load = zif_md_primary_sql_load;
- md_class->unload = zif_md_primary_sql_unload;
- md_class->search_name = zif_md_primary_sql_search_name;
- md_class->search_details = zif_md_primary_sql_search_details;
- md_class->search_group = zif_md_primary_sql_search_group;
- md_class->search_pkgid = zif_md_primary_sql_search_pkgid;
- md_class->what_provides = zif_md_primary_sql_what_provides;
- md_class->resolve = zif_md_primary_sql_resolve;
- md_class->get_packages = zif_md_primary_sql_get_packages;
- md_class->find_package = zif_md_primary_sql_find_package;
- g_type_class_add_private (klass, sizeof (ZifMdPrimarySqlPrivate));
-}
-
-/**
- * zif_md_primary_sql_init:
- **/
-static void
-zif_md_primary_sql_init (ZifMdPrimarySql *md)
-{
- md->priv = ZIF_MD_PRIMARY_SQL_GET_PRIVATE (md);
- md->priv->loaded = FALSE;
- md->priv->db = NULL;
-}
-
-/**
- * zif_md_primary_sql_new:
- *
- * Return value: A new #ZifMdPrimarySql class instance.
- *
- * Since: 0.0.1
- **/
-ZifMdPrimarySql *
-zif_md_primary_sql_new (void)
-{
- ZifMdPrimarySql *md;
- md = g_object_new (ZIF_TYPE_MD_PRIMARY_SQL, NULL);
- return ZIF_MD_PRIMARY_SQL (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_primary_sql_test (EggTest *test)
-{
- ZifMdPrimarySql *md;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- ZifPackage *package;
- const gchar *summary;
- GCancellable *cancellable;
- ZifCompletion *completion;
- gchar *data[] = { "gnome-power-manager", "gnome-color-manager", NULL };
-
- if (!egg_test_start (test, "ZifMdPrimarySql"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get md_primary_sql md");
- md = zif_md_primary_sql_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (ZIF_MD (md), "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set type");
- ret = zif_md_set_mdtype (ZIF_MD (md), ZIF_MD_TYPE_PRIMARY_SQL);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum type");
- ret = zif_md_set_checksum_type (ZIF_MD (md), G_CHECKSUM_SHA256);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum compressed");
- ret = zif_md_set_checksum (ZIF_MD (md), "35d817e2bac701525fa72cec57387a2e3457bf32642adeee1e345cc180044c86");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum uncompressed");
- ret = zif_md_set_checksum_uncompressed (ZIF_MD (md), "9b2b072a83b5175bc88d03ee64b52b39c0d40fec1516baa62dba81eea73cc645");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_md_set_filename (ZIF_MD (md), "../test/cache/fedora/35d817e2bac701525fa72cec57387a2e3457bf32642adeee1e345cc180044c86-primary.sqlite.bz2");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "resolve");
- array = zif_md_primary_sql_resolve (ZIF_MD (md), data, cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- egg_test_assert (test, array->len == 1);
-
- /************************************************************/
- egg_test_title (test, "correct value");
- package = g_ptr_array_index (array, 0);
- zif_completion_reset (completion);
- summary = zif_package_get_summary (package, NULL, completion, NULL);
- if (g_strcmp0 (summary, "GNOME Power Manager") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct summary '%s'", summary);
- g_ptr_array_unref (array);
-
- g_object_unref (cancellable);
- g_object_unref (completion);
- g_object_unref (md);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md-primary-sql.h b/backends/yum/libzif/zif-md-primary-sql.h
deleted file mode 100644
index 746cb10..0000000
--- a/backends/yum/libzif/zif-md-primary-sql.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009-2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_PRIMARY_SQL_H
-#define __ZIF_MD_PRIMARY_SQL_H
-
-#include <glib-object.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-md.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD_PRIMARY_SQL (zif_md_primary_sql_get_type ())
-#define ZIF_MD_PRIMARY_SQL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD_PRIMARY_SQL, ZifMdPrimarySql))
-#define ZIF_MD_PRIMARY_SQL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD_PRIMARY_SQL, ZifMdPrimarySqlClass))
-#define ZIF_IS_MD_PRIMARY_SQL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD_PRIMARY_SQL))
-#define ZIF_IS_MD_PRIMARY_SQL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD_PRIMARY_SQL))
-#define ZIF_MD_PRIMARY_SQL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD_PRIMARY_SQL, ZifMdPrimarySqlClass))
-
-typedef struct _ZifMdPrimarySql ZifMdPrimarySql;
-typedef struct _ZifMdPrimarySqlPrivate ZifMdPrimarySqlPrivate;
-typedef struct _ZifMdPrimarySqlClass ZifMdPrimarySqlClass;
-
-struct _ZifMdPrimarySql
-{
- ZifMd parent;
- ZifMdPrimarySqlPrivate *priv;
-};
-
-struct _ZifMdPrimarySqlClass
-{
- ZifMdClass parent_class;
-};
-
-GType zif_md_primary_sql_get_type (void);
-ZifMdPrimarySql *zif_md_primary_sql_new (void);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_PRIMARY_SQL_H */
-
diff --git a/backends/yum/libzif/zif-md-primary-xml.c b/backends/yum/libzif/zif-md-primary-xml.c
deleted file mode 100644
index 6e3454b..0000000
--- a/backends/yum/libzif/zif-md-primary-xml.c
+++ /dev/null
@@ -1,953 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md-primary-xml
- * @short_description: PrimaryXml metadata functionality
- *
- * Provide access to the primary_xml repo metadata.
- * This object is a subclass of #ZifMd
- */
-
-typedef enum {
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE,
- ZIF_MD_PRIMARY_XML_SECTION_UNKNOWN
-} ZifMdPrimaryXmlSection;
-
-typedef enum {
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_NAME,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_ARCH,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_VERSION,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_CHECKSUM,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_SUMMARY,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_DESCRIPTION,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_URL,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_SIZE,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_LICENCE,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_LOCATION,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_GROUP,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_PROVIDES,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_REQUIRES,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_OBSOLETES,
- ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_UNKNOWN
-} ZifMdPrimaryXmlSectionPackage;
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include <gio/gio.h>
-
-#include "zif-md.h"
-#include "zif-utils.h"
-#include "zif-md-primary-xml.h"
-#include "zif-package-remote.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_PRIMARY_XML_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_PRIMARY_XML, ZifMdPrimaryXmlPrivate))
-
-/**
- * ZifMdPrimaryXmlPrivate:
- *
- * Private #ZifMdPrimaryXml data
- **/
-struct _ZifMdPrimaryXmlPrivate
-{
- gboolean loaded;
- ZifMdPrimaryXmlSection section;
- ZifMdPrimaryXmlSectionPackage section_package;
- ZifPackage *package_temp;
- GPtrArray *array;
- gchar *package_name_temp;
- gchar *package_arch_temp;
- gchar *package_version_temp;
- gchar *package_release_temp;
- guint package_epoch_temp;
-};
-
-G_DEFINE_TYPE (ZifMdPrimaryXml, zif_md_primary_xml, ZIF_TYPE_MD)
-
-/**
- * zif_md_primary_xml_unload:
- **/
-static gboolean
-zif_md_primary_xml_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- return ret;
-}
-
-
-/**
- * zif_md_primary_xml_parser_start_element:
- **/
-static void
-zif_md_primary_xml_parser_start_element (GMarkupParseContext *context, const gchar *element_name,
- const gchar **attribute_names, const gchar **attribute_values,
- gpointer user_data, GError **error)
-{
- guint i;
- ZifMdPrimaryXml *primary_xml = user_data;
-
- g_return_if_fail (ZIF_IS_MD_PRIMARY_XML (primary_xml));
-
- /* group element */
- if (primary_xml->priv->section == ZIF_MD_PRIMARY_XML_SECTION_UNKNOWN) {
-
- /* start of list */
- if (g_strcmp0 (element_name, "metadata") == 0)
- goto out;
-
- /* start of update */
- if (g_strcmp0 (element_name, "package") == 0) {
- primary_xml->priv->section = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE;
- primary_xml->priv->package_temp = ZIF_PACKAGE (zif_package_remote_new ());
- goto out;
- }
-
- egg_warning ("unhandled element: %s", element_name);
-
- goto out;
- }
-
- /* update element */
- if (primary_xml->priv->section == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE) {
-
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_UNKNOWN) {
- if (g_strcmp0 (element_name, "packager") == 0 ||
- g_strcmp0 (element_name, "format") == 0 ||
- g_strcmp0 (element_name, "file") == 0 ||
- g_strcmp0 (element_name, "rpm:vendor") == 0 ||
- g_strcmp0 (element_name, "rpm:buildhost") == 0 ||
- g_strcmp0 (element_name, "rpm:header-range") == 0 ||
- g_strcmp0 (element_name, "rpm:sourcerpm") == 0 ||
- g_strcmp0 (element_name, "time") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_UNKNOWN;
- goto out;
- }
- if (g_strcmp0 (element_name, "name") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_NAME;
- goto out;
- }
- if (g_strcmp0 (element_name, "checksum") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_CHECKSUM;
- goto out;
- }
- if (g_strcmp0 (element_name, "arch") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_ARCH;
- goto out;
- }
- if (g_strcmp0 (element_name, "summary") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_SUMMARY;
- goto out;
- }
- if (g_strcmp0 (element_name, "description") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_DESCRIPTION;
- goto out;
- }
- if (g_strcmp0 (element_name, "url") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_URL;
- goto out;
- }
- if (g_strcmp0 (element_name, "version") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_VERSION;
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "rel") == 0) {
- primary_xml->priv->package_release_temp = g_strdup (attribute_values[i]);
- } else if (g_strcmp0 (attribute_names[i], "epoch") == 0) {
- primary_xml->priv->package_epoch_temp = atoi (attribute_values[i]);
- } else if (g_strcmp0 (attribute_names[i], "ver") == 0) {
- primary_xml->priv->package_version_temp = g_strdup (attribute_values[i]);
- }
- }
- goto out;
- }
- if (g_strcmp0 (element_name, "size") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_SIZE;
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "package") == 0) {
- zif_package_set_size (primary_xml->priv->package_temp, atoi (attribute_values[i]));
- }
- }
- goto out;
- }
- if (g_strcmp0 (element_name, "location") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_LOCATION;
- goto out;
- }
- if (g_strcmp0 (element_name, "rpm:license") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_LICENCE;
- goto out;
- }
- if (g_strcmp0 (element_name, "rpm:group") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_GROUP;
- goto out;
- }
- if (g_strcmp0 (element_name, "rpm:provides") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_PROVIDES;
- goto out;
- }
- if (g_strcmp0 (element_name, "rpm:requires") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_REQUIRES;
- goto out;
- }
- if (g_strcmp0 (element_name, "rpm:obsoletes") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_OBSOLETES;
- goto out;
- }
- egg_warning ("unhandled update base tag: %s", element_name);
- goto out;
-
- } else if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_REQUIRES) {
- if (g_strcmp0 (element_name, "rpm:entry") == 0) {
- goto out;
- }
- } else if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_OBSOLETES) {
- if (g_strcmp0 (element_name, "rpm:entry") == 0) {
- goto out;
- }
- } else if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_PROVIDES) {
- if (g_strcmp0 (element_name, "rpm:entry") == 0) {
- goto out;
- }
- goto out;
- }
- egg_warning ("unhandled package tag: %s", element_name);
- }
-
- egg_warning ("unhandled base tag: %s", element_name);
-
-out:
- return;
-}
-
-/**
- * zif_md_primary_xml_parser_end_element:
- **/
-static void
-zif_md_primary_xml_parser_end_element (GMarkupParseContext *context, const gchar *element_name,
- gpointer user_data, GError **error)
-{
- ZifMdPrimaryXml *primary_xml = user_data;
- gchar *package_id = NULL;
-
- /* no element */
- if (primary_xml->priv->section == ZIF_MD_PRIMARY_XML_SECTION_UNKNOWN) {
- /* end of list */
- if (g_strcmp0 (element_name, "metadata") == 0)
- goto out;
- egg_warning ("unhandled base end tag: %s", element_name);
- }
-
- /* update element */
- if (primary_xml->priv->section == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE) {
-
- /* end of update */
- if (g_strcmp0 (element_name, "package") == 0) {
- primary_xml->priv->section = ZIF_MD_PRIMARY_XML_SECTION_UNKNOWN;
-
- /* add to array */
- package_id = zif_package_id_from_nevra (primary_xml->priv->package_name_temp,
- primary_xml->priv->package_epoch_temp,
- primary_xml->priv->package_version_temp,
- primary_xml->priv->package_release_temp,
- primary_xml->priv->package_arch_temp,
- zif_md_get_id (ZIF_MD (primary_xml)));
- zif_package_set_id (primary_xml->priv->package_temp, package_id);
- g_ptr_array_add (primary_xml->priv->array, primary_xml->priv->package_temp);
- primary_xml->priv->package_temp = NULL;
- goto out;
- }
-
- /* do not change section */
- if (g_strcmp0 (element_name, "rpm:entry") == 0) {
- goto out;
- }
-
- if (g_strcmp0 (element_name, "name") == 0 ||
- g_strcmp0 (element_name, "summary") == 0 ||
- g_strcmp0 (element_name, "arch") == 0 ||
- g_strcmp0 (element_name, "version") == 0 ||
- g_strcmp0 (element_name, "checksum") == 0 ||
- g_strcmp0 (element_name, "file") == 0 ||
- g_strcmp0 (element_name, "time") == 0 ||
- g_strcmp0 (element_name, "size") == 0 ||
- g_strcmp0 (element_name, "rpm:license") == 0 ||
- g_strcmp0 (element_name, "rpm:vendor") == 0 ||
- g_strcmp0 (element_name, "rpm:group") == 0 ||
- g_strcmp0 (element_name, "rpm:buildhost") == 0 ||
- g_strcmp0 (element_name, "rpm:provides") == 0 ||
- g_strcmp0 (element_name, "rpm:requires") == 0 ||
- g_strcmp0 (element_name, "rpm:obsoletes") == 0 ||
- g_strcmp0 (element_name, "rpm:sourcerpm") == 0 ||
- g_strcmp0 (element_name, "rpm:header-range") == 0 ||
- g_strcmp0 (element_name, "location") == 0 ||
- g_strcmp0 (element_name, "format") == 0 ||
- g_strcmp0 (element_name, "packager") == 0 ||
- g_strcmp0 (element_name, "description") == 0 ||
- g_strcmp0 (element_name, "url") == 0) {
- primary_xml->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_UNKNOWN;
- goto out;
- }
-
- egg_warning ("unhandled update end tag: %s", element_name);
- goto out;
- }
-
- egg_warning ("unhandled end tag: %s", element_name);
-out:
- g_free (package_id);
- return;
-}
-
-/**
- * zif_md_primary_xml_parser_text:
- **/
-static void
-zif_md_primary_xml_parser_text (GMarkupParseContext *context, const gchar *text, gsize text_len,
- gpointer user_data, GError **error)
-
-{
- ZifMdPrimaryXml *primary_xml = user_data;
- ZifString *string = NULL;
-
- /* skip whitespace */
- if (text_len < 1 || text[0] == ' ' || text[0] == '\t' || text[0] == '\n')
- goto out;
-
- /* group section */
- if (primary_xml->priv->section == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE) {
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_UNKNOWN)
- goto out;
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_NAME) {
- primary_xml->priv->package_name_temp = g_strdup (text);
- goto out;
- }
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_ARCH) {
- primary_xml->priv->package_arch_temp = g_strdup (text);
- goto out;
- }
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_SUMMARY) {
- string = zif_string_new (text);
- zif_package_set_summary (primary_xml->priv->package_temp, string);
- goto out;
- }
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_DESCRIPTION) {
- string = zif_string_new (text);
- zif_package_set_description (primary_xml->priv->package_temp, string);
- goto out;
- }
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_URL) {
- string = zif_string_new (text);
- zif_package_set_url (primary_xml->priv->package_temp, string);
- goto out;
- }
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_GROUP) {
- string = zif_string_new (text);
- zif_package_set_category (primary_xml->priv->package_temp, string);
- goto out;
- }
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_LICENCE) {
- string = zif_string_new (text);
- zif_package_set_license (primary_xml->priv->package_temp, string);
- goto out;
- }
- if (primary_xml->priv->section_package == ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_CHECKSUM) {
- zif_package_remote_set_pkgid (ZIF_PACKAGE_REMOTE (primary_xml->priv->package_temp), text);
- goto out;
- }
- egg_warning ("not saving: %s", text);
- goto out;
- }
-out:
- if (string != NULL)
- zif_string_unref (string);
- return;
-}
-
-/**
- * zif_md_primary_xml_load:
- **/
-static gboolean
-zif_md_primary_xml_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- const gchar *filename;
- gboolean ret;
- gchar *contents = NULL;
- gsize size;
- ZifMdPrimaryXml *primary_xml = ZIF_MD_PRIMARY_XML (md);
- GMarkupParseContext *context = NULL;
- const GMarkupParser gpk_md_primary_xml_markup_parser = {
- zif_md_primary_xml_parser_start_element,
- zif_md_primary_xml_parser_end_element,
- zif_md_primary_xml_parser_text,
- NULL, /* passthrough */
- NULL /* error */
- };
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_XML (md), FALSE);
-
- /* already loaded */
- if (primary_xml->priv->loaded)
- goto out;
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for primary_xml");
- goto out;
- }
-
- /* open database */
- egg_debug ("filename = %s", filename);
- ret = g_file_get_contents (filename, &contents, &size, error);
- if (!ret)
- goto out;
-
- /* create parser */
- context = g_markup_parse_context_new (&gpk_md_primary_xml_markup_parser, G_MARKUP_PREFIX_ERROR_POSITION, primary_xml, NULL);
-
- /* parse data */
- ret = g_markup_parse_context_parse (context, contents, (gssize) size, error);
- if (!ret)
- goto out;
-
- /* we don't need to keep syncing */
- primary_xml->priv->loaded = TRUE;
-out:
- g_free (contents);
- return primary_xml->priv->loaded;
-}
-
-typedef gboolean (*ZifPackageFilterFunc) (ZifPackage *package,
- gpointer user_data);
-
-/**
- * zif_md_primary_xml_filter:
- **/
-static GPtrArray *
-zif_md_primary_xml_filter (ZifMd *md, ZifPackageFilterFunc filter_func, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- GPtrArray *packages;
- ZifPackage *package;
- guint i;
- gboolean ret;
- GError *error_local = NULL;
- ZifCompletion *completion_local;
- ZifMdPrimaryXml *md_primary = ZIF_MD_PRIMARY_XML (md);
-
- g_return_val_if_fail (ZIF_IS_MD_PRIMARY_XML (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* setup completion */
- if (md_primary->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!md_primary->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_md_load (ZIF_MD (md), cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to load md_primary_xml file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* search array */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- packages = md_primary->priv->array;
- for (i=0; i<packages->len; i++) {
- package = g_ptr_array_index (packages, i);
- if (filter_func (package, user_data))
- g_ptr_array_add (array, g_object_ref (package));
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_md_primary_xml_resolve_cb:
- **/
-static gboolean
-zif_md_primary_xml_resolve_cb (ZifPackage *package, gpointer user_data)
-{
- guint i;
- const gchar *value;
- gchar **search = (gchar **) user_data;
- value = zif_package_get_name (package);
- for (i=0; search[i] != NULL; i++) {
- if (g_strcmp0 (value, search[i]) == 0)
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * zif_md_primary_xml_resolve:
- **/
-static GPtrArray *
-zif_md_primary_xml_resolve (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- return zif_md_primary_xml_filter (md, zif_md_primary_xml_resolve_cb, (gpointer) search,
- cancellable, completion, error);
-}
-
-/**
- * zif_md_primary_xml_search_name_cb:
- **/
-static gboolean
-zif_md_primary_xml_search_name_cb (ZifPackage *package, gpointer user_data)
-{
- guint i;
- const gchar *value;
- gchar **search = (gchar **) user_data;
- value = zif_package_get_name (package);
- for (i=0; search[i] != NULL; i++) {
- if (g_strstr_len (value, -1, search[i]) != NULL)
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * zif_md_primary_xml_search_name:
- **/
-static GPtrArray *
-zif_md_primary_xml_search_name (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- return zif_md_primary_xml_filter (md, zif_md_primary_xml_search_name_cb, (gpointer) search,
- cancellable, completion, error);
-}
-
-/**
- * zif_md_primary_xml_search_details_cb:
- **/
-static gboolean
-zif_md_primary_xml_search_details_cb (ZifPackage *package, gpointer user_data)
-{
- guint i;
- gboolean ret = FALSE;
- const gchar *name;
- const gchar *summary;
- const gchar *description;
- ZifCompletion *completion_tmp;
- GError *error = NULL;
- gchar **search = (gchar **) user_data;
-
- completion_tmp = zif_completion_new ();
- name = zif_package_get_name (package);
- summary = zif_package_get_summary (package, NULL, completion_tmp, &error);
- if (summary == NULL) {
- egg_warning ("failed to get summary: %s", error->message);
- g_error_free (error);
- goto out;
- }
- description = zif_package_get_description (package, NULL, completion_tmp, &error);
- if (description == NULL) {
- egg_warning ("failed to get description: %s", error->message);
- g_error_free (error);
- goto out;
- }
- for (i=0; search[i] != NULL; i++) {
- if (g_strstr_len (name, -1, search[i]) != NULL) {
- ret = TRUE;
- break;
- }
- if (g_strstr_len (summary, -1, search[i]) != NULL) {
- ret = TRUE;
- break;
- }
- if (g_strstr_len (description, -1, search[i]) != NULL) {
- ret = TRUE;
- break;
- }
- }
-out:
- g_object_unref (completion_tmp);
- return ret;
-}
-
-/**
- * zif_md_primary_xml_search_details:
- **/
-static GPtrArray *
-zif_md_primary_xml_search_details (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- return zif_md_primary_xml_filter (md, zif_md_primary_xml_search_details_cb, (gpointer) search,
- cancellable, completion, error);
-}
-
-/**
- * zif_md_primary_xml_search_group_cb:
- **/
-static gboolean
-zif_md_primary_xml_search_group_cb (ZifPackage *package, gpointer user_data)
-{
- guint i;
- gboolean ret = FALSE;
- const gchar *value;
- ZifCompletion *completion_tmp;
- GError *error = NULL;
- gchar **search = (gchar **) user_data;
-
- completion_tmp = zif_completion_new ();
- value = zif_package_get_category (package, NULL, completion_tmp, &error);
- if (value == NULL) {
- egg_warning ("failed to get category: %s", error->message);
- g_error_free (error);
- goto out;
- }
- for (i=0; search[i] != NULL; i++) {
- if (g_strstr_len (value, -1, search[i]) != NULL) {
- ret = TRUE;
- goto out;
- }
- }
-out:
- g_object_unref (completion_tmp);
- return ret;
-}
-
-/**
- * zif_md_primary_xml_search_group:
- **/
-static GPtrArray *
-zif_md_primary_xml_search_group (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- return zif_md_primary_xml_filter (md, zif_md_primary_xml_search_group_cb, (gpointer) search,
- cancellable, completion, error);
-}
-
-/**
- * zif_md_primary_xml_search_pkgid_cb:
- **/
-static gboolean
-zif_md_primary_xml_search_pkgid_cb (ZifPackage *package, gpointer user_data)
-{
- guint i;
- const gchar *pkgid;
- gchar **search = (gchar **) user_data;
- pkgid = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package));
- for (i=0; search[i] != NULL; i++) {
- if (g_strcmp0 (pkgid, search[i]) == 0)
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * zif_md_primary_xml_search_pkgid:
- **/
-static GPtrArray *
-zif_md_primary_xml_search_pkgid (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- return zif_md_primary_xml_filter (md, zif_md_primary_xml_search_pkgid_cb, (gpointer) search,
- cancellable, completion, error);
-}
-
-/**
- * zif_md_primary_xml_what_provides_cb:
- **/
-static gboolean
-zif_md_primary_xml_what_provides_cb (ZifPackage *package, gpointer user_data)
-{
-// guint i;
- gboolean ret;
- GPtrArray *array = NULL;
- ZifCompletion *completion_tmp;
- GError *error = NULL;
-// gchar **search = (gchar **) user_data;
-
- completion_tmp = zif_completion_new ();
- array = zif_package_get_provides (package, NULL, completion_tmp, &error);
- if (array == NULL) {
- egg_warning ("failed to get provides: %s", error->message);
- g_error_free (error);
- goto out;
- }
- /* TODO: do something with the ZifDepend objects */
- ret = FALSE;
- g_object_unref (completion_tmp);
-out:
- if (array != NULL)
- g_ptr_array_unref (array);
- return ret;
-}
-
-/**
- * zif_md_primary_xml_what_provides:
- **/
-static GPtrArray *
-zif_md_primary_xml_what_provides (ZifMd *md, gchar **search,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- return zif_md_primary_xml_filter (md, zif_md_primary_xml_what_provides_cb, (gpointer) search,
- cancellable, completion, error);
-}
-
-/**
- * zif_md_primary_xml_find_package_cb:
- **/
-static gboolean
-zif_md_primary_xml_find_package_cb (ZifPackage *package, gpointer user_data)
-{
- const gchar *value;
- const gchar *search = (const gchar *) user_data;
- value = zif_package_get_id (package);
- return (g_strcmp0 (value, search) == 0);
-}
-
-/**
- * zif_md_primary_xml_find_package:
- **/
-static GPtrArray *
-zif_md_primary_xml_find_package (ZifMd *md, const gchar *package_id, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- return zif_md_primary_xml_filter (md, zif_md_primary_xml_find_package_cb, (gpointer) package_id,
- cancellable, completion, error);
-}
-
-/**
- * zif_md_primary_xml_get_packages:
- **/
-static GPtrArray *
-zif_md_primary_xml_get_packages (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifMdPrimaryXml *primary_xml = ZIF_MD_PRIMARY_XML (md);
- return g_ptr_array_ref (primary_xml->priv->array);
-}
-
-/**
- * zif_md_primary_xml_finalize:
- **/
-static void
-zif_md_primary_xml_finalize (GObject *object)
-{
- ZifMdPrimaryXml *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD_PRIMARY_XML (object));
- md = ZIF_MD_PRIMARY_XML (object);
-
- g_ptr_array_unref (md->priv->array);
-
- G_OBJECT_CLASS (zif_md_primary_xml_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_primary_xml_class_init:
- **/
-static void
-zif_md_primary_xml_class_init (ZifMdPrimaryXmlClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifMdClass *md_class = ZIF_MD_CLASS (klass);
- object_class->finalize = zif_md_primary_xml_finalize;
-
- /* map */
- md_class->load = zif_md_primary_xml_load;
- md_class->unload = zif_md_primary_xml_unload;
- md_class->search_name = zif_md_primary_xml_search_name;
- md_class->search_details = zif_md_primary_xml_search_details;
- md_class->search_group = zif_md_primary_xml_search_group;
- md_class->search_pkgid = zif_md_primary_xml_search_pkgid;
- md_class->what_provides = zif_md_primary_xml_what_provides;
- md_class->resolve = zif_md_primary_xml_resolve;
- md_class->get_packages = zif_md_primary_xml_get_packages;
- md_class->find_package = zif_md_primary_xml_find_package;
-
- g_type_class_add_private (klass, sizeof (ZifMdPrimaryXmlPrivate));
-}
-
-/**
- * zif_md_primary_xml_init:
- **/
-static void
-zif_md_primary_xml_init (ZifMdPrimaryXml *md)
-{
- md->priv = ZIF_MD_PRIMARY_XML_GET_PRIVATE (md);
- md->priv->array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- md->priv->loaded = FALSE;
- md->priv->section = ZIF_MD_PRIMARY_XML_SECTION_UNKNOWN;
- md->priv->section_package = ZIF_MD_PRIMARY_XML_SECTION_PACKAGE_UNKNOWN;
- md->priv->package_temp = NULL;
-}
-
-/**
- * zif_md_primary_xml_new:
- *
- * Return value: A new #ZifMdPrimaryXml class instance.
- *
- * Since: 0.0.1
- **/
-ZifMdPrimaryXml *
-zif_md_primary_xml_new (void)
-{
- ZifMdPrimaryXml *md;
- md = g_object_new (ZIF_TYPE_MD_PRIMARY_XML, NULL);
- return ZIF_MD_PRIMARY_XML (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_primary_xml_test (EggTest *test)
-{
- ZifMdPrimaryXml *md;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- ZifPackage *package;
- const gchar *summary;
- GCancellable *cancellable;
- ZifCompletion *completion;
- gchar *data[] = { "gnome-power-manager", NULL };
-
- if (!egg_test_start (test, "ZifMdPrimaryXml"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get md_primary_xml md");
- md = zif_md_primary_xml_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (ZIF_MD (md), "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set type");
- ret = zif_md_set_mdtype (ZIF_MD (md), ZIF_MD_TYPE_PRIMARY_XML);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum type");
- ret = zif_md_set_checksum_type (ZIF_MD (md), G_CHECKSUM_SHA256);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum compressed");
- ret = zif_md_set_checksum (ZIF_MD (md), "33a0eed8e12f445618756b18aa49d05ee30069d280d37b03a7a15d1ec954f833");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum uncompressed");
- ret = zif_md_set_checksum_uncompressed (ZIF_MD (md), "52e4c37b13b4b23ae96432962186e726550b19e93cf3cbf7bf55c2a673a20086");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_md_set_filename (ZIF_MD (md), "../test/cache/fedora/primary.xml.gz");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "search for files");
- zif_completion_reset (completion);
- array = zif_md_primary_xml_resolve (ZIF_MD (md), data, cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- egg_test_assert (test, array->len == 1);
-
- /************************************************************/
- egg_test_title (test, "correct value");
- package = g_ptr_array_index (array, 0);
- zif_completion_reset (completion);
- summary = zif_package_get_summary (package, NULL, completion, NULL);
- if (g_strcmp0 (summary, "GNOME power management service") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct summary '%s'", summary);
- g_ptr_array_unref (array);
-
- g_object_unref (cancellable);
- g_object_unref (completion);
- g_object_unref (md);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md-primary-xml.h b/backends/yum/libzif/zif-md-primary-xml.h
deleted file mode 100644
index 2b38406..0000000
--- a/backends/yum/libzif/zif-md-primary-xml.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_PRIMARY_XML_H
-#define __ZIF_MD_PRIMARY_XML_H
-
-#include <glib-object.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-md.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD_PRIMARY_XML (zif_md_primary_xml_get_type ())
-#define ZIF_MD_PRIMARY_XML(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD_PRIMARY_XML, ZifMdPrimaryXml))
-#define ZIF_MD_PRIMARY_XML_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD_PRIMARY_XML, ZifMdPrimaryXmlClass))
-#define ZIF_IS_MD_PRIMARY_XML(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD_PRIMARY_XML))
-#define ZIF_IS_MD_PRIMARY_XML_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD_PRIMARY_XML))
-#define ZIF_MD_PRIMARY_XML_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD_PRIMARY_XML, ZifMdPrimaryXmlClass))
-
-typedef struct _ZifMdPrimaryXml ZifMdPrimaryXml;
-typedef struct _ZifMdPrimaryXmlPrivate ZifMdPrimaryXmlPrivate;
-typedef struct _ZifMdPrimaryXmlClass ZifMdPrimaryXmlClass;
-
-struct _ZifMdPrimaryXml
-{
- ZifMd parent;
- ZifMdPrimaryXmlPrivate *priv;
-};
-
-struct _ZifMdPrimaryXmlClass
-{
- ZifMdClass parent_class;
-};
-
-GType zif_md_primary_xml_get_type (void);
-ZifMdPrimaryXml *zif_md_primary_xml_new (void);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_PRIMARY_XML_H */
-
diff --git a/backends/yum/libzif/zif-md-updateinfo.c b/backends/yum/libzif/zif-md-updateinfo.c
deleted file mode 100644
index 98fe2a4..0000000
--- a/backends/yum/libzif/zif-md-updateinfo.c
+++ /dev/null
@@ -1,783 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md-updateinfo
- * @short_description: Updateinfo metadata functionality
- *
- * Provide access to the updateinfo repo metadata.
- * This object is a subclass of #ZifMd
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <glib.h>
-
-#include "zif-md.h"
-#include "zif-md-updateinfo.h"
-#include "zif-update.h"
-#include "zif-update-info.h"
-#include "zif-utils.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_UPDATEINFO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD_UPDATEINFO, ZifMdUpdateinfoPrivate))
-
-typedef enum {
- ZIF_MD_UPDATEINFO_SECTION_UPDATE,
- ZIF_MD_UPDATEINFO_SECTION_UNKNOWN
-} ZifMdUpdateinfoSection;
-
-typedef enum {
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_ID,
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_TITLE,
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_DESCRIPTION,
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_ISSUED,
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_REBOOT,
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_REFERENCES,
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_PKGLIST,
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_UNKNOWN
-} ZifMdUpdateinfoSectionGroup;
-
-typedef enum {
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_PKGLIST_PACKAGE,
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_PKGLIST_FILENAME,
- ZIF_MD_UPDATEINFO_SECTION_UPDATE_PKGLIST_UNKNOWN
-} ZifMdUpdateinfoSectionUpdatePkglistType;
-
-/**
- * ZifMdUpdateinfoPrivate:
- *
- * Private #ZifMdUpdateinfo data
- **/
-struct _ZifMdUpdateinfoPrivate
-{
- gboolean loaded;
- GPtrArray *array_updates; /* stored as ZifUpdate */
- /* for parser */
- ZifMdUpdateinfoSection section;
- ZifMdUpdateinfoSectionGroup section_group;
- ZifMdUpdateinfoSectionUpdatePkglistType section_group_type;
- ZifUpdate *update_temp;
- ZifUpdateInfo *update_info_temp;
- ZifPackage *package_temp;
-};
-
-G_DEFINE_TYPE (ZifMdUpdateinfo, zif_md_updateinfo, ZIF_TYPE_MD)
-
-/**
- * zif_md_updateinfo_parser_start_element:
- **/
-static void
-zif_md_updateinfo_parser_start_element (GMarkupParseContext *context, const gchar *element_name,
- const gchar **attribute_names, const gchar **attribute_values,
- gpointer user_data, GError **error)
-{
- guint i;
- ZifMdUpdateinfo *updateinfo = user_data;
-
- g_return_if_fail (ZIF_IS_MD_UPDATEINFO (updateinfo));
-
- /* group element */
- if (updateinfo->priv->section == ZIF_MD_UPDATEINFO_SECTION_UNKNOWN) {
-
- /* start of list */
- if (g_strcmp0 (element_name, "updates") == 0)
- goto out;
-
- /* start of update */
- if (g_strcmp0 (element_name, "update") == 0) {
- updateinfo->priv->section = ZIF_MD_UPDATEINFO_SECTION_UPDATE;
- updateinfo->priv->update_temp = zif_update_new ();
-
- /* find the update type as a bonus */
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "status") == 0) {
- zif_update_set_state (updateinfo->priv->update_temp,
- pk_update_state_enum_from_string (attribute_values[i]));
- }
- if (g_strcmp0 (element_name, "type") == 0) {
- zif_update_set_kind (updateinfo->priv->update_temp,
- pk_info_enum_from_string (attribute_values[i]));
- }
- }
- goto out;
- }
-
- egg_warning ("unhandled element: %s", element_name);
-
- goto out;
- }
-
- /* update element */
- if (updateinfo->priv->section == ZIF_MD_UPDATEINFO_SECTION_UPDATE) {
-
- if (updateinfo->priv->section_group == ZIF_MD_UPDATEINFO_SECTION_UPDATE_UNKNOWN) {
- if (g_strcmp0 (element_name, "release") == 0)
- goto out;
- if (g_strcmp0 (element_name, "id") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_ID;
- goto out;
- }
- if (g_strcmp0 (element_name, "title") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_TITLE;
- goto out;
- }
- if (g_strcmp0 (element_name, "description") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_DESCRIPTION;
- goto out;
- }
- if (g_strcmp0 (element_name, "reboot_suggested") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_REBOOT;
- goto out;
- }
- if (g_strcmp0 (element_name, "issued") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_ISSUED;
-
- /* find the issued date */
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "date") == 0) {
- zif_update_set_issued (updateinfo->priv->update_temp, attribute_values[i]);
- }
- }
- goto out;
- }
- if (g_strcmp0 (element_name, "references") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_REFERENCES;
- goto out;
- }
- if (g_strcmp0 (element_name, "pkglist") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_PKGLIST;
- goto out;
- }
- egg_warning ("unhandled update base tag: %s", element_name);
- goto out;
-
- } else if (updateinfo->priv->section_group == ZIF_MD_UPDATEINFO_SECTION_UPDATE_REFERENCES) {
- if (g_strcmp0 (element_name, "reference") == 0) {
- updateinfo->priv->update_info_temp = zif_update_info_new ();
-
- /* find the details about the info */
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "href") == 0) {
- zif_update_info_set_url (updateinfo->priv->update_info_temp,
- attribute_values[i]);
- }
- if (g_strcmp0 (attribute_names[i], "title") == 0) {
- zif_update_info_set_title (updateinfo->priv->update_info_temp,
- attribute_values[i]);
- }
- if (g_strcmp0 (attribute_names[i], "type") == 0) {
- zif_update_info_set_kind (updateinfo->priv->update_info_temp,
- zif_update_info_kind_from_string (attribute_values[i]));
- }
- }
-
- goto out;
- }
-
- egg_warning ("unhandled references tag: %s", element_name);
- goto out;
-
- } else if (updateinfo->priv->section_group == ZIF_MD_UPDATEINFO_SECTION_UPDATE_PKGLIST) {
- if (g_strcmp0 (element_name, "collection") == 0)
- goto out;
- if (g_strcmp0 (element_name, "name") == 0)
- goto out;
- if (g_strcmp0 (element_name, "reboot_suggested") == 0)
- goto out;
- //TODO: is this better than src?
- if (g_strcmp0 (element_name, "filename") == 0)
- goto out;
-
- if (g_strcmp0 (element_name, "package") == 0) {
- const gchar *name = NULL;
- guint epoch = 0;
- const gchar *version = NULL;
- const gchar *release = NULL;
- const gchar *arch = NULL;
- const gchar *src = NULL;
- const gchar *data;
- gchar *package_id;
- ZifString *string;
-
- updateinfo->priv->package_temp = zif_package_new ();
-
- /* find the details about the package */
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "name") == 0)
- name = attribute_values[i];
- else if (g_strcmp0 (attribute_names[i], "epoch") == 0)
- epoch = atoi (attribute_values[i]);
- else if (g_strcmp0 (attribute_names[i], "version") == 0)
- version = attribute_values[i];
- else if (g_strcmp0 (attribute_names[i], "release") == 0)
- release = attribute_values[i];
- else if (g_strcmp0 (attribute_names[i], "arch") == 0)
- arch = attribute_values[i];
- else if (g_strcmp0 (attribute_names[i], "src") == 0)
- src = attribute_values[i];
- }
-
- /* create a package from what we know */
- data = zif_md_get_id (ZIF_MD (updateinfo));
- package_id = zif_package_id_from_nevra (name, epoch, version, release, arch, data);
- zif_package_set_id (updateinfo->priv->package_temp, package_id);
- string = zif_string_new (src);
- zif_package_set_location_href (updateinfo->priv->package_temp, string);
- g_free (package_id);
- zif_string_unref (string);
- goto out;
- }
-
- egg_warning ("unexpected pklist tag: %s", element_name);
- }
-
- egg_warning ("unexpected update tag: %s", element_name);
- }
-
- egg_warning ("unhandled base tag: %s", element_name);
-
-out:
- return;
-}
-
-/**
- * zif_md_updateinfo_parser_end_element:
- **/
-static void
-zif_md_updateinfo_parser_end_element (GMarkupParseContext *context, const gchar *element_name,
- gpointer user_data, GError **error)
-{
- ZifMdUpdateinfo *updateinfo = user_data;
-
- /* no element */
- if (updateinfo->priv->section == ZIF_MD_UPDATEINFO_SECTION_UNKNOWN) {
-
- /* end of list */
- if (g_strcmp0 (element_name, "updates") == 0)
- goto out;
-
- egg_warning ("unhandled base end tag: %s", element_name);
- }
-
- /* update element */
- if (updateinfo->priv->section == ZIF_MD_UPDATEINFO_SECTION_UPDATE) {
-
- /* end of update */
- if (g_strcmp0 (element_name, "update") == 0) {
- updateinfo->priv->section = ZIF_MD_UPDATEINFO_SECTION_UNKNOWN;
-
- /* add to array */
- g_ptr_array_add (updateinfo->priv->array_updates, updateinfo->priv->update_temp);
- updateinfo->priv->update_temp = NULL;
- goto out;
- }
-
- if (g_strcmp0 (element_name, "id") == 0 ||
- g_strcmp0 (element_name, "title") == 0 ||
- g_strcmp0 (element_name, "release") == 0 ||
- g_strcmp0 (element_name, "description") == 0 ||
- g_strcmp0 (element_name, "issued") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_UNKNOWN;
- goto out;
- }
-
- if (updateinfo->priv->section_group == ZIF_MD_UPDATEINFO_SECTION_UPDATE_REBOOT) {
-
- /* add property */
- if (g_strcmp0 (element_name, "reboot_suggested") == 0) {
- zif_update_set_reboot (updateinfo->priv->update_temp, TRUE);
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_UNKNOWN;
- goto out;
- }
- egg_warning ("unhandled reboot_suggested end tag: %s", element_name);
- goto out;
- }
-
- if (updateinfo->priv->section_group == ZIF_MD_UPDATEINFO_SECTION_UPDATE_REFERENCES) {
-
- if (g_strcmp0 (element_name, "references") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_UNKNOWN;
- goto out;
- }
-
- if (g_strcmp0 (element_name, "reference") == 0) {
- zif_update_add_update_info (updateinfo->priv->update_temp,
- updateinfo->priv->update_info_temp);
- g_object_unref (updateinfo->priv->update_info_temp);
- updateinfo->priv->update_info_temp = NULL;
- goto out;
- }
- egg_warning ("unhandled references end tag: %s", element_name);
- goto out;
- }
-
- if (updateinfo->priv->section_group == ZIF_MD_UPDATEINFO_SECTION_UPDATE_PKGLIST) {
-
- if (g_strcmp0 (element_name, "pkglist") == 0) {
- updateinfo->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_UNKNOWN;
- goto out;
- }
-
- if (g_strcmp0 (element_name, "name") == 0)
- goto out;
- if (g_strcmp0 (element_name, "filename") == 0)
- goto out;
- if (g_strcmp0 (element_name, "collection") == 0)
- goto out;
- if (g_strcmp0 (element_name, "reboot_suggested") == 0)
- goto out;
-
- /* add to the update */
- if (g_strcmp0 (element_name, "package") == 0) {
- zif_update_add_package (updateinfo->priv->update_temp,
- updateinfo->priv->package_temp);
- g_object_unref (updateinfo->priv->package_temp);
- updateinfo->priv->package_temp = NULL;
- goto out;
- }
-
- egg_warning ("unhandled pkglist end tag: %s", element_name);
- }
-
- egg_warning ("unhandled update end tag: %s", element_name);
- goto out;
- }
-
- egg_warning ("unhandled end tag: %s", element_name);
-out:
- return;
-}
-
-/**
- * zif_md_updateinfo_parser_text:
- **/
-static void
-zif_md_updateinfo_parser_text (GMarkupParseContext *context, const gchar *text, gsize text_len,
- gpointer user_data, GError **error)
-
-{
- ZifMdUpdateinfo *updateinfo = user_data;
-
- /* skip whitespace */
- if (text_len < 1 || text[0] == ' ' || text[0] == '\t' || text[0] == '\n')
- goto out;
-
- /* group section */
- if (updateinfo->priv->section == ZIF_MD_UPDATEINFO_SECTION_UPDATE) {
- if (updateinfo->priv->section_group == ZIF_MD_UPDATEINFO_SECTION_UPDATE_ID) {
- zif_update_set_id (updateinfo->priv->update_temp, text);
- goto out;
- }
- if (updateinfo->priv->section_group == ZIF_MD_UPDATEINFO_SECTION_UPDATE_TITLE) {
- zif_update_set_title (updateinfo->priv->update_temp, text);
- goto out;
- }
- if (updateinfo->priv->section_group == ZIF_MD_UPDATEINFO_SECTION_UPDATE_DESCRIPTION) {
- zif_update_set_description (updateinfo->priv->update_temp, text);
- goto out;
- }
- goto out;
- }
-out:
- return;
-}
-
-/**
- * zif_md_updateinfo_unload:
- **/
-static gboolean
-zif_md_updateinfo_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- return ret;
-}
-
-/**
- * zif_md_updateinfo_load:
- **/
-static gboolean
-zif_md_updateinfo_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = TRUE;
- gchar *contents = NULL;
- const gchar *filename;
- gsize size;
- GMarkupParseContext *context = NULL;
- const GMarkupParser gpk_md_updateinfo_markup_parser = {
- zif_md_updateinfo_parser_start_element,
- zif_md_updateinfo_parser_end_element,
- zif_md_updateinfo_parser_text,
- NULL, /* passthrough */
- NULL /* error */
- };
- ZifMdUpdateinfo *updateinfo = ZIF_MD_UPDATEINFO (md);
-
- g_return_val_if_fail (ZIF_IS_MD_UPDATEINFO (md), FALSE);
-
- /* already loaded */
- if (updateinfo->priv->loaded)
- goto out;
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for updateinfo");
- goto out;
- }
-
- /* open database */
- egg_debug ("filename = %s", filename);
-
- /* get repo contents */
- ret = g_file_get_contents (filename, &contents, &size, error);
- if (!ret)
- goto out;
-
- /* create parser */
- context = g_markup_parse_context_new (&gpk_md_updateinfo_markup_parser, G_MARKUP_PREFIX_ERROR_POSITION, updateinfo, NULL);
-
- /* parse data */
- ret = g_markup_parse_context_parse (context, contents, (gssize) size, error);
- if (!ret)
- goto out;
-
- updateinfo->priv->loaded = TRUE;
-out:
- if (context != NULL)
- g_markup_parse_context_free (context);
- g_free (contents);
- return ret;
-}
-
-/**
- * zif_md_updateinfo_get_detail:
- * @md: the #ZifMdUpdateinfo object
- * @cancellable: the %GCancellable, or %NULL
- * @completion: the %ZifCompletion object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets all the available update data.
- *
- * Return value: #GPtrArray of #ZifUpdate's, free with g_ptr_array_unref()
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_updateinfo_get_detail (ZifMdUpdateinfo *md,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- gboolean ret;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_MD_UPDATEINFO (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!md->priv->loaded) {
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to get load updateinfo: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- array = g_ptr_array_ref (md->priv->array_updates);
-out:
- return array;
-}
-
-/**
- * zif_md_updateinfo_get_detail_for_package:
- * @md: the #ZifMdUpdateinfo object
- * @package_id: the group to search for
- * @cancellable: the %GCancellable, or %NULL
- * @completion: the %ZifCompletion object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the list of update details for the package_id.
- *
- * Return value: #GPtrArray of #ZifUpdate's, free with g_ptr_array_unref()
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_updateinfo_get_detail_for_package (ZifMdUpdateinfo *md, const gchar *package_id,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- GPtrArray *array_tmp;
- guint i;
- guint j;
- guint len;
- gboolean ret;
- GError *error_local = NULL;
- ZifUpdate *update;
- ZifPackage *package;
-
- g_return_val_if_fail (ZIF_IS_MD_UPDATEINFO (md), NULL);
- g_return_val_if_fail (package_id != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!md->priv->loaded) {
- ret = zif_md_load (ZIF_MD (md), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_TO_LOAD,
- "failed to get load updateinfo: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get packages in this group */
- len = md->priv->array_updates->len;
- for (i=0; i<len; i++) {
- update = g_ptr_array_index (md->priv->array_updates, i);
-
- /* have we matched on any entries */
- ret = FALSE;
-
- array_tmp = zif_update_get_packages (update);
- for (j=0; j<array_tmp->len; j++) {
- package = g_ptr_array_index (array_tmp, j);
- if (g_strcmp0 (zif_package_get_id (package), package_id) == 0) {
- ret = TRUE;
- break;
- }
- }
-
- /* we found a package match */
- if (ret) {
- if (array == NULL)
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- g_ptr_array_add (array, g_object_ref (update));
- }
- }
-
- /* nothing found */
- if (array == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "could not find package (%i in sack): %s", len, package_id);
- }
-out:
- return array;
-}
-
-/**
- * zif_md_updateinfo_finalize:
- **/
-static void
-zif_md_updateinfo_finalize (GObject *object)
-{
- ZifMdUpdateinfo *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD_UPDATEINFO (object));
- md = ZIF_MD_UPDATEINFO (object);
-
- g_ptr_array_unref (md->priv->array_updates);
-
- G_OBJECT_CLASS (zif_md_updateinfo_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_updateinfo_class_init:
- **/
-static void
-zif_md_updateinfo_class_init (ZifMdUpdateinfoClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifMdClass *md_class = ZIF_MD_CLASS (klass);
- object_class->finalize = zif_md_updateinfo_finalize;
-
- /* map */
- md_class->load = zif_md_updateinfo_load;
- md_class->unload = zif_md_updateinfo_unload;
- g_type_class_add_private (klass, sizeof (ZifMdUpdateinfoPrivate));
-}
-
-/**
- * zif_md_updateinfo_init:
- **/
-static void
-zif_md_updateinfo_init (ZifMdUpdateinfo *md)
-{
- md->priv = ZIF_MD_UPDATEINFO_GET_PRIVATE (md);
- md->priv->loaded = FALSE;
- md->priv->section = ZIF_MD_UPDATEINFO_SECTION_UNKNOWN;
- md->priv->section_group = ZIF_MD_UPDATEINFO_SECTION_UPDATE_UNKNOWN;
- md->priv->section_group_type = ZIF_MD_UPDATEINFO_SECTION_UPDATE_PKGLIST_UNKNOWN;
- md->priv->update_temp = NULL;
- md->priv->update_info_temp = NULL;
- md->priv->package_temp = NULL;
- md->priv->array_updates = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-}
-
-/**
- * zif_md_updateinfo_new:
- *
- * Return value: A new #ZifMdUpdateinfo class instance.
- *
- * Since: 0.0.1
- **/
-ZifMdUpdateinfo *
-zif_md_updateinfo_new (void)
-{
- ZifMdUpdateinfo *md;
- md = g_object_new (ZIF_TYPE_MD_UPDATEINFO, NULL);
- return ZIF_MD_UPDATEINFO (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_updateinfo_test (EggTest *test)
-{
- ZifMdUpdateinfo *md;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- const gchar *id;
- GCancellable *cancellable;
- ZifCompletion *completion;
- ZifUpdate *update;
-
- if (!egg_test_start (test, "ZifMdUpdateinfo"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get md_updateinfo md");
- md = zif_md_updateinfo_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (ZIF_MD (md), "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set type");
- ret = zif_md_set_mdtype (ZIF_MD (md), ZIF_MD_TYPE_UPDATEINFO);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set filename");
- ret = zif_md_set_filename (ZIF_MD (md), "../test/cache/updateinfo.xml");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum type");
- ret = zif_md_set_checksum_type (ZIF_MD (md), G_CHECKSUM_SHA256);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "set checksum uncompressed");
- ret = zif_md_set_checksum_uncompressed (ZIF_MD (md), "4fa3657a79af078c588e2ab181ab0a3a156c6008a084d85edccaf6c57d67d47d");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "get categories");
- array = zif_md_updateinfo_get_detail_for_package (md, "device-mapper-libs;1.02.27-7.fc10;ppc64;fedora", cancellable, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get categories '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len == 1)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect value %i", array->len);
-
- /************************************************************/
- egg_test_title (test, "correct id value");
- update = g_ptr_array_index (array, 0);
- if (g_strcmp0 (zif_update_get_id (update), "FEDORA-2008-9969") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct id '%s'", zif_update_get_id (update));
-
- /************************************************************/
- egg_test_title (test, "correct title value");
- update = g_ptr_array_index (array, 0);
- if (g_strcmp0 (zif_update_get_title (update), "lvm2-2.02.39-7.fc10") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct title '%s'", zif_update_get_title (update));
-
- /************************************************************/
- egg_test_title (test, "correct description value");
- update = g_ptr_array_index (array, 0);
- if (g_strcmp0 (zif_update_get_description (update), "Fix an incorrect path that prevents the clvmd init script from working and include licence files with the sub-packages.") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct id '%s'", zif_update_get_description (update));
-
- g_ptr_array_unref (array);
- g_object_unref (md);
- g_object_unref (cancellable);
- g_object_unref (completion);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md-updateinfo.h b/backends/yum/libzif/zif-md-updateinfo.h
deleted file mode 100644
index 38e708d..0000000
--- a/backends/yum/libzif/zif-md-updateinfo.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_UPDATEINFO_H
-#define __ZIF_MD_UPDATEINFO_H
-
-#include <glib-object.h>
-
-#include "zif-md.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD_UPDATEINFO (zif_md_updateinfo_get_type ())
-#define ZIF_MD_UPDATEINFO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD_UPDATEINFO, ZifMdUpdateinfo))
-#define ZIF_MD_UPDATEINFO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD_UPDATEINFO, ZifMdUpdateinfoClass))
-#define ZIF_IS_MD_UPDATEINFO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD_UPDATEINFO))
-#define ZIF_IS_MD_UPDATEINFO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD_UPDATEINFO))
-#define ZIF_MD_UPDATEINFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD_UPDATEINFO, ZifMdUpdateinfoClass))
-
-typedef struct _ZifMdUpdateinfo ZifMdUpdateinfo;
-typedef struct _ZifMdUpdateinfoPrivate ZifMdUpdateinfoPrivate;
-typedef struct _ZifMdUpdateinfoClass ZifMdUpdateinfoClass;
-
-struct _ZifMdUpdateinfo
-{
- ZifMd parent;
- ZifMdUpdateinfoPrivate *priv;
-};
-
-struct _ZifMdUpdateinfoClass
-{
- ZifMdClass parent_class;
-};
-
-GType zif_md_updateinfo_get_type (void);
-ZifMdUpdateinfo *zif_md_updateinfo_new (void);
-
-GPtrArray *zif_md_updateinfo_get_detail (ZifMdUpdateinfo *md,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_updateinfo_get_detail_for_package (ZifMdUpdateinfo *md,
- const gchar *package_id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_UPDATEINFO_H */
-
diff --git a/backends/yum/libzif/zif-md.c b/backends/yum/libzif/zif-md.c
deleted file mode 100644
index 9ba1e9d..0000000
--- a/backends/yum/libzif/zif-md.c
+++ /dev/null
@@ -1,1359 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-md
- * @short_description: Metadata file common functionality
- *
- * This provides an abstract metadata class.
- * It is implemented by #ZifMdFilelistsSql, #ZifMdMaster and #ZifMdPrimary.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <glib/gstdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "zif-utils.h"
-#include "zif-md.h"
-#include "zif-config.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MD, ZifMdPrivate))
-
-/**
- * ZifMdPrivate:
- *
- * Private #ZifMd data
- **/
-struct _ZifMdPrivate
-{
- gboolean loaded;
- gchar *id; /* fedora */
- gchar *filename; /* /var/cache/yum/fedora/repo.sqlite.bz2 */
- gchar *filename_uncompressed; /* /var/cache/yum/fedora/repo.sqlite */
- guint timestamp;
- gchar *location; /* repodata/35d817e-primary.sqlite.bz2 */
- gchar *checksum; /* of compressed file */
- gchar *checksum_uncompressed; /* of uncompressed file */
- GChecksumType checksum_type;
- ZifMdType type;
- ZifStoreRemote *remote;
- ZifConfig *config;
-};
-
-G_DEFINE_TYPE (ZifMd, zif_md, G_TYPE_OBJECT)
-
-/**
- * zif_md_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_md_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_md_error");
- return quark;
-}
-
-/**
- * zif_md_get_id:
- * @md: the #ZifMd object
- *
- * Gets the md identifier, usually the repo name.
- *
- * Return value: the repo id.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_md_get_id (ZifMd *md)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- return md->priv->id;
-}
-
-/**
- * zif_md_get_filename:
- * @md: the #ZifMd object
- *
- * Gets the compressed filename of the repo.
- *
- * Return value: the filename
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_md_get_filename (ZifMd *md)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- return md->priv->filename;
-}
-
-/**
- * zif_md_get_location:
- * @md: the #ZifMd object
- *
- * Gets the location of the repo.
- *
- * Return value: the location
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_md_get_location (ZifMd *md)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- return md->priv->location;
-}
-
-/**
- * zif_md_get_mdtype:
- * @md: the #ZifMd object
- *
- * Gets the type of the repo.
- *
- * Return value: the type
- *
- * Since: 0.0.1
- **/
-ZifMdType
-zif_md_get_mdtype (ZifMd *md)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), ZIF_MD_TYPE_UNKNOWN);
- return md->priv->type;
-}
-
-/**
- * zif_md_get_filename_uncompressed:
- * @md: the #ZifMd object
- *
- * Gets the uncompressed filename of the repo.
- *
- * Return value: the filename
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_md_get_filename_uncompressed (ZifMd *md)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- return md->priv->filename_uncompressed;
-}
-
-/**
- * zif_md_set_filename:
- * @md: the #ZifMd object
- * @filename: the base filename, e.g. "master.xml.bz2"
- *
- * Sets the filename of the compressed file.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_set_filename (ZifMd *md, const gchar *filename)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->filename == NULL, FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
-
- /* this is the compressed name */
- md->priv->filename = g_strdup (filename);
-
- /* this is the uncompressed name */
- md->priv->filename_uncompressed = zif_file_get_uncompressed_name (filename);
-
- return TRUE;
-}
-
-/**
- * zif_md_set_timestamp:
- * @md: the #ZifMd object
- * @timestamp: the timestamp value
- *
- * Sets the timestamp of the compressed file.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_set_timestamp (ZifMd *md, guint timestamp)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->timestamp == 0, FALSE);
- g_return_val_if_fail (timestamp != 0, FALSE);
-
- /* save new value */
- md->priv->timestamp = timestamp;
- return TRUE;
-}
-
-/**
- * zif_md_set_location:
- * @md: the #ZifMd object
- * @location: the location
- *
- * Sets the location of the compressed file, e.g. "repodata/35d817e-primary.sqlite.bz2"
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_set_location (ZifMd *md, const gchar *location)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->location == NULL, FALSE);
- g_return_val_if_fail (location != NULL, FALSE);
-
- /* save new value */
- md->priv->location = g_strdup (location);
- return TRUE;
-}
-
-/**
- * zif_md_set_checksum:
- * @md: the #ZifMd object
- * @checksum: the checksum value
- *
- * Sets the checksum of the compressed file.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_set_checksum (ZifMd *md, const gchar *checksum)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->checksum == NULL, FALSE);
- g_return_val_if_fail (checksum != NULL, FALSE);
-
- /* save new value */
- md->priv->checksum = g_strdup (checksum);
- return TRUE;
-}
-
-/**
- * zif_md_set_checksum_uncompressed:
- * @md: the #ZifMd object
- * @checksum_uncompressed: the uncompressed checksum value
- *
- * Sets the checksum of the uncompressed file.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_set_checksum_uncompressed (ZifMd *md, const gchar *checksum_uncompressed)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->checksum_uncompressed == NULL, FALSE);
- g_return_val_if_fail (checksum_uncompressed != NULL, FALSE);
-
- /* save new value */
- md->priv->checksum_uncompressed = g_strdup (checksum_uncompressed);
- return TRUE;
-}
-
-/**
- * zif_md_set_checksum_type:
- * @md: the #ZifMd object
- * @checksum_type: the checksum type
- *
- * Sets the checksum_type of the files.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_set_checksum_type (ZifMd *md, GChecksumType checksum_type)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->checksum_type == 0, FALSE);
-
- /* save new value */
- md->priv->checksum_type = checksum_type;
- return TRUE;
-}
-
-/**
- * zif_md_set_mdtype:
- * @md: the #ZifMd object
- * @type: the metadata type
- *
- * Sets the type of the metadata, e.g. ZIF_MD_TYPE_FILELISTS_SQL.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_set_mdtype (ZifMd *md, ZifMdType type)
-{
- gboolean ret = TRUE;
-
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->type == ZIF_MD_TYPE_UNKNOWN, FALSE);
- g_return_val_if_fail (type != ZIF_MD_TYPE_UNKNOWN, FALSE);
-
- /* save new value */
- md->priv->type = type;
-
- /* metalink is not specified in the repomd.xml file */
- if (type == ZIF_MD_TYPE_METALINK) {
- zif_md_set_location (md, "metalink.xml");
- goto out;
- }
-
- /* mirrorlist is not specified in the repomd.xml file */
- if (type == ZIF_MD_TYPE_MIRRORLIST) {
- zif_md_set_location (md, "mirrorlist.txt");
- goto out;
- }
-
- /* check we've got the needed data */
- if (md->priv->location != NULL && (md->priv->checksum == NULL || md->priv->timestamp == 0)) {
- egg_warning ("cannot load md for %s (loc=%s, checksum=%s, checksum_open=%s, timestamp=%i)",
- zif_md_type_to_text (type), md->priv->location,
- md->priv->checksum, md->priv->checksum_uncompressed, md->priv->timestamp);
- ret = FALSE;
- goto out;
- }
-out:
- return ret;
-}
-
-/**
- * zif_md_set_id:
- * @md: the #ZifMd object
- * @id: the repository id, e.g. "fedora"
- *
- * Sets the repository ID for this metadata.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_set_id (ZifMd *md, const gchar *id)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->id == NULL, FALSE);
- g_return_val_if_fail (id != NULL, FALSE);
-
- md->priv->id = g_strdup (id);
- return TRUE;
-}
-
-/**
- * zif_md_set_store_remote:
- * @md: the #ZifMd object
- * @remote: the #ZifStoreRemote that created this metadata object
- *
- * Sets the remote store for this metadata.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_set_store_remote (ZifMd *md, ZifStoreRemote *remote)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->remote == NULL, FALSE);
- g_return_val_if_fail (remote != NULL, FALSE);
-
- /* do not take a reference, else the parent device never goes away */
- md->priv->remote = remote;
- return TRUE;
-}
-
-/**
- * zif_md_get_store_remote:
- * @md: the #ZifMd object
- *
- * Gets the remote store for this metadata.
- *
- * Return value: A #ZifStoreRemote or %NULL for unset
- *
- * Since: 0.0.1
- **/
-ZifStoreRemote *
-zif_md_get_store_remote (ZifMd *md)
-{
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- return md->priv->remote;
-}
-
-/**
- * zif_md_delete_file:
- **/
-static gboolean
-zif_md_delete_file (const gchar *filename)
-{
- gint retval;
- gboolean ret;
-
- /* file exists? */
- ret = g_file_test (filename, G_FILE_TEST_EXISTS);
- if (!ret)
- goto out;
-
- egg_warning ("deleting %s", filename);
-
- /* remove */
- retval = g_unlink (filename);
- if (retval != 0) {
- egg_warning ("failed to delete %s", filename);
- ret = FALSE;
- }
-out:
- return ret;
-}
-
-/**
- * zif_md_load:
- * @md: the #ZifMd object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Load the metadata store.
- *
- * - Check compressed file
- * if invalid:
- * delete_it()
- * if online:
- * download_it()
- * if failure:
- * abort
- * check_it()
- * if failure:
- * abort
- * else
- * abort
- *
- * - Check uncompressed file
- * if invalid:
- * delete_it()
- * decompress_it()
- * if failure:
- * abort()
- * check_it()
- * if failure:
- * abort
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_load (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- gboolean uncompressed_check;
- gchar *dirname = NULL;
- GError *error_local = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
- ZifCompletion *completion_local;
-
- /* no support */
- if (klass->load == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- return FALSE;
- }
-
- /* setup completion */
- zif_completion_set_number_steps (completion, 3);
-
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
-
- /* optimise: if uncompressed file is okay, then don't even check the compressed file */
- uncompressed_check = zif_md_file_check (md, TRUE, &error_local);
- if (uncompressed_check) {
- zif_completion_done (completion);
- goto skip_compressed_check;
- }
-
- /* display any warning */
- egg_warning ("failed checksum for uncompressed: %s", error_local->message);
- g_clear_error (&error_local);
-
- /* check compressed file */
- ret = zif_md_file_check (md, FALSE, &error_local);
- if (!ret) {
-
- /* this one really is fatal */
- if (g_strstr_len (error_local->message, -1, "no filename") != NULL) {
- g_propagate_error (error, error_local);
- goto out;
- }
-
- egg_warning ("failed checksum for compressed: %s", error_local->message);
- g_clear_error (&error_local);
-
- /* delete file if it exists */
- zif_md_delete_file (md->priv->filename);
-
- /* if not online, then this is fatal */
- ret = zif_config_get_boolean (md->priv->config, "network", NULL);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_AS_OFFLINE,
- "failed to check %s checksum for %s and offline",
- zif_md_type_to_text (md->priv->type), md->priv->id);
- goto out;
- }
-
- /* download file */
- completion_local = zif_completion_get_child (completion);
- dirname = g_path_get_dirname (md->priv->filename);
- ret = zif_store_remote_download (md->priv->remote, md->priv->location, dirname, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED_DOWNLOAD,
- "failed to download missing compressed file: %s", error_local->message);
- goto out;
- }
-
- /* check newly downloaded compressed file */
- ret = zif_md_file_check (md, FALSE, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed checksum on downloaded file: %s", error_local->message);
- goto out;
- }
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* check uncompressed file */
- if (!uncompressed_check) {
-
- /* delete file if it exists */
- zif_md_delete_file (md->priv->filename_uncompressed);
-
- /* decompress file */
- egg_debug ("decompressing file");
- completion_local = zif_completion_get_child (completion);
- ret = zif_file_decompress (md->priv->filename, md->priv->filename_uncompressed,
- cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to decompress: %s", error_local->message);
- goto out;
- }
-
- /* check newly uncompressed file */
- ret = zif_md_file_check (md, TRUE, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed checksum on decompressed file: %s", error_local->message);
- goto out;
- }
- }
-
-skip_compressed_check:
-
- /* this section done */
- zif_completion_done (completion);
-
- /* do subclassed load */
- completion_local = zif_completion_get_child (completion);
- ret = klass->load (md, cancellable, completion_local, error);
-
- /* this section done */
- zif_completion_done (completion);
-out:
- g_free (dirname);
- return ret;
-}
-
-/**
- * zif_md_unload:
- * @md: the #ZifMd object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Unload the metadata store.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_unload (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* no support */
- if (klass->unload == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- return FALSE;
- }
-
- return klass->unload (md, cancellable, completion, error);
-}
-
-/**
- * zif_md_resolve:
- * @md: the #ZifMd object
- * @search: the search term, e.g. "gnome-power-manager"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds all remote packages that match the name exactly.
- *
- * Return value: an array of #ZifPackageRemote's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_resolve (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->resolve == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->resolve (md, search, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_search_file:
- * @md: the #ZifMd object
- * @search: the search term, e.g. "/usr/bin/powertop"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets a list of all packages that contain the file.
- * Results are pkgId's descriptors, i.e. 64 bit hashes as test.
- *
- * Return value: a string list of pkgId's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_search_file (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_file == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->search_file (md, search, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_search_name:
- * @md: the #ZifMd object
- * @search: the search term, e.g. "power"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds all packages that match the name.
- *
- * Return value: an array of #ZifPackageRemote's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_search_name (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_name == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->search_name (md, search, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_search_details:
- * @md: the #ZifMd object
- * @search: the search term, e.g. "advanced"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds all packages that match the name or description.
- *
- * Return value: an array of #ZifPackageRemote's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_search_details (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_details == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->search_details (md, search, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_search_group:
- * @md: the #ZifMd object
- * @search: the search term, e.g. "games/console"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds all packages that match the group.
- *
- * Return value: an array of #ZifPackageRemote's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_search_group (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_group == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->search_group (md, search, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_search_pkgid:
- * @md: the #ZifMd object
- * @search: the search term as a 64 bit hash
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds all packages that match the given pkgId.
- *
- * Return value: an array of #ZifPackageRemote's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_search_pkgid (ZifMd *md, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_pkgid == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->search_pkgid (md, search, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_what_provides:
- * @md: the #ZifMd object
- * @search: the provide, e.g. "mimehandler(application/ogg)"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds all packages that match the given provide.
- *
- * Return value: an array of #ZifPackageRemote's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_what_provides (ZifMd *md, gchar **search,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->what_provides == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->what_provides (md, search, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_find_package:
- * @md: the #ZifMd object
- * @package_id: the PackageId to match
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds all packages that match PackageId.
- *
- * Return value: an array of #ZifPackageRemote's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_find_package (ZifMd *md, const gchar *package_id, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->find_package == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->find_package (md, package_id, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_get_changelog:
- * @md: the #ZifMd object
- * @pkgid: the internal pkgid to match
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the changelog data for a specific package
- *
- * Return value: an array of #ZifChangeset's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_get_changelog (ZifMd *md, const gchar *pkgid, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->get_changelog == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->get_changelog (md, pkgid, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_get_files:
- * @md: the #ZifMd object
- * @package: the %ZifPackage
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the file list for a specific package.
- *
- * Return value: an array of strings, free with g_ptr_array_unref()
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_get_files (ZifMd *md, ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->get_files == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->get_files (md, package, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_get_packages:
- * @md: the #ZifMd object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Returns all packages in the repo.
- *
- * Return value: an array of #ZifPackageRemote's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_md_get_packages (ZifMd *md, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- ZifMdClass *klass = ZIF_MD_GET_CLASS (md);
-
- g_return_val_if_fail (ZIF_IS_MD (md), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->get_packages == NULL) {
- g_set_error_literal (error, ZIF_MD_ERROR, ZIF_MD_ERROR_NO_SUPPORT,
- "operation cannot be performed on this md");
- goto out;
- }
-
- /* do subclassed action */
- array = klass->get_packages (md, cancellable, completion, error);
-out:
- return array;
-}
-
-/**
- * zif_md_clean:
- * @md: the #ZifMd object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Clean the metadata store.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_clean (ZifMd *md, GError **error)
-{
- gboolean ret = FALSE;
- gboolean exists;
- const gchar *filename;
- GFile *file;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* get filename */
- filename = zif_md_get_filename (md);
- if (filename == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get filename for %s", zif_md_type_to_text (md->priv->type));
- ret = FALSE;
- goto out;
- }
-
- /* file does not exist */
- exists = g_file_test (filename, G_FILE_TEST_EXISTS);
- if (exists) {
- file = g_file_new_for_path (filename);
- ret = g_file_delete (file, NULL, &error_local);
- g_object_unref (file);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to delete metadata file %s: %s", filename, error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get filename */
- filename = zif_md_get_filename_uncompressed (md);
- if (filename == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get uncompressed filename for %s", zif_md_type_to_text (md->priv->type));
- ret = FALSE;
- goto out;
- }
-
- /* file does not exist */
- exists = g_file_test (filename, G_FILE_TEST_EXISTS);
- if (exists) {
- file = g_file_new_for_path (filename);
- ret = g_file_delete (file, NULL, &error_local);
- g_object_unref (file);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to delete metadata file %s: %s", filename, error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* okay */
- ret = TRUE;
-out:
- return ret;
-}
-
-/**
- * zif_md_type_to_text:
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_md_type_to_text (ZifMdType type)
-{
- if (type == ZIF_MD_TYPE_FILELISTS_XML)
- return "filelists";
- if (type == ZIF_MD_TYPE_FILELISTS_SQL)
- return "filelists_db";
- if (type == ZIF_MD_TYPE_PRIMARY_XML)
- return "primary";
- if (type == ZIF_MD_TYPE_PRIMARY_SQL)
- return "primary_db";
- if (type == ZIF_MD_TYPE_OTHER_XML)
- return "other";
- if (type == ZIF_MD_TYPE_OTHER_SQL)
- return "other_db";
- if (type == ZIF_MD_TYPE_COMPS)
- return "group";
- if (type == ZIF_MD_TYPE_COMPS_GZ)
- return "group_gz";
- if (type == ZIF_MD_TYPE_METALINK)
- return "metalink";
- if (type == ZIF_MD_TYPE_MIRRORLIST)
- return "mirrorlist";
- if (type == ZIF_MD_TYPE_PRESTODELTA)
- return "prestodelta";
- if (type == ZIF_MD_TYPE_UPDATEINFO)
- return "updateinfo";
- return "unknown";
-}
-
-/**
- * zif_md_file_check:
- * @md: the #ZifMd object
- * @use_uncompressed: If we should check only the uncompresed version
- * @error: a #GError which is used on failure, or %NULL
- *
- * Check the metadata files to make sure they are valid.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_md_file_check (ZifMd *md, gboolean use_uncompressed, GError **error)
-{
- gboolean ret = FALSE;
- GError *error_local = NULL;
- gchar *data = NULL;
- gchar *checksum = NULL;
- const gchar *filename;
- const gchar *checksum_wanted;
- gsize length;
-
- g_return_val_if_fail (ZIF_IS_MD (md), FALSE);
- g_return_val_if_fail (md->priv->id != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* metalink has no checksum... */
- if (md->priv->type == ZIF_MD_TYPE_METALINK ||
- md->priv->type == ZIF_MD_TYPE_MIRRORLIST) {
- egg_debug ("skipping checksum check on %s", zif_md_type_to_text (md->priv->type));
- ret = TRUE;
- goto out;
- }
-
- /* get correct filename */
- if (use_uncompressed)
- filename = md->priv->filename_uncompressed;
- else
- filename = md->priv->filename;
-
- /* no checksum set */
- if (filename == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "no filename for %s [%s]", md->priv->id, zif_md_type_to_text (md->priv->type));
- ret = FALSE;
- goto out;
- }
-
- /* get contents */
- ret = g_file_get_contents (filename, &data, &length, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "failed to get contents of %s: %s", filename, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* get the one we want */
- if (use_uncompressed)
- checksum_wanted = md->priv->checksum_uncompressed;
- else
- checksum_wanted = md->priv->checksum;
-
- /* no checksum set */
- if (checksum_wanted == NULL) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "checksum not set for %s", filename);
- ret = FALSE;
- goto out;
- }
-
- /* compute checksum */
- checksum = g_compute_checksum_for_data (md->priv->checksum_type, (guchar*) data, length);
-
- /* matches? */
- ret = (g_strcmp0 (checksum, checksum_wanted) == 0);
- if (!ret) {
- g_set_error (error, ZIF_MD_ERROR, ZIF_MD_ERROR_FAILED,
- "checksum incorrect, wanted %s, got %s for %s", checksum_wanted, checksum, filename);
- goto out;
- }
- egg_debug ("%s checksum correct (%s)", filename, checksum_wanted);
-out:
- g_free (data);
- g_free (checksum);
- return ret;
-}
-
-/**
- * zif_md_finalize:
- **/
-static void
-zif_md_finalize (GObject *object)
-{
- ZifMd *md;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MD (object));
- md = ZIF_MD (object);
-
- g_free (md->priv->id);
- g_free (md->priv->filename);
- g_free (md->priv->location);
- g_free (md->priv->checksum);
- g_free (md->priv->checksum_uncompressed);
-
- g_object_unref (md->priv->config);
-
- G_OBJECT_CLASS (zif_md_parent_class)->finalize (object);
-}
-
-/**
- * zif_md_class_init:
- **/
-static void
-zif_md_class_init (ZifMdClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_md_finalize;
- g_type_class_add_private (klass, sizeof (ZifMdPrivate));
-}
-
-/**
- * zif_md_init:
- **/
-static void
-zif_md_init (ZifMd *md)
-{
- md->priv = ZIF_MD_GET_PRIVATE (md);
- md->priv->type = ZIF_MD_TYPE_UNKNOWN;
- md->priv->loaded = FALSE;
- md->priv->id = NULL;
- md->priv->filename = NULL;
- md->priv->timestamp = 0;
- md->priv->location = NULL;
- md->priv->checksum = NULL;
- md->priv->checksum_uncompressed = NULL;
- md->priv->checksum_type = 0;
- md->priv->remote = NULL;
- md->priv->config = zif_config_new ();
-}
-
-/**
- * zif_md_new:
- *
- * Return value: A new #ZifMd class instance.
- *
- * Since: 0.0.1
- **/
-ZifMd *
-zif_md_new (void)
-{
- ZifMd *md;
- md = g_object_new (ZIF_TYPE_MD, NULL);
- return ZIF_MD (md);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_md_test (EggTest *test)
-{
- ZifMd *md;
- gboolean ret;
- GError *error = NULL;
- GCancellable *cancellable;
- ZifCompletion *completion;
-
- if (!egg_test_start (test, "ZifMd"))
- return;
-
- /* use */
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get store_remote md");
- md = zif_md_new ();
- egg_test_assert (test, md != NULL);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, !md->priv->loaded);
-
- /************************************************************/
- egg_test_title (test, "set id");
- ret = zif_md_set_id (md, "fedora");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set");
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_md_load (md, cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "loaded");
- egg_test_assert (test, md->priv->loaded);
-
- g_object_unref (md);
- g_object_unref (cancellable);
- g_object_unref (completion);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-md.h b/backends/yum/libzif/zif-md.h
deleted file mode 100644
index dd9c7a8..0000000
--- a/backends/yum/libzif/zif-md.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MD_H
-#define __ZIF_MD_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-
-#include "zif-md.h"
-#include "zif-completion.h"
-#include "zif-store-remote.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MD (zif_md_get_type ())
-#define ZIF_MD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MD, ZifMd))
-#define ZIF_MD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MD, ZifMdClass))
-#define ZIF_IS_MD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MD))
-#define ZIF_IS_MD_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MD))
-#define ZIF_MD_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MD, ZifMdClass))
-#define ZIF_MD_ERROR (zif_md_error_quark ())
-
-typedef struct _ZifMd ZifMd;
-typedef struct _ZifMdPrivate ZifMdPrivate;
-typedef struct _ZifMdClass ZifMdClass;
-
-struct _ZifMd
-{
- GObject parent;
- ZifMdPrivate *priv;
-};
-
-struct _ZifMdClass
-{
- GObjectClass parent_class;
- /* vtable */
- gboolean (*load) (ZifMd *md,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- gboolean (*unload) (ZifMd *md,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_file) (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_name) (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_details) (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_group) (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_pkgid) (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*what_provides) (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*resolve) (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*get_packages) (ZifMd *md,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*find_package) (ZifMd *md,
- const gchar *package_id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*get_changelog) (ZifMd *md,
- const gchar *pkgid,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*get_files) (ZifMd *md,
- ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-};
-
-/* types of metadata */
-typedef enum {
- ZIF_MD_TYPE_PRIMARY_XML,
- ZIF_MD_TYPE_PRIMARY_SQL,
- ZIF_MD_TYPE_FILELISTS_XML,
- ZIF_MD_TYPE_FILELISTS_SQL,
- ZIF_MD_TYPE_OTHER_XML,
- ZIF_MD_TYPE_OTHER_SQL,
- ZIF_MD_TYPE_COMPS,
- ZIF_MD_TYPE_COMPS_GZ,
- ZIF_MD_TYPE_METALINK,
- ZIF_MD_TYPE_MIRRORLIST,
- ZIF_MD_TYPE_PRESTODELTA,
- ZIF_MD_TYPE_UPDATEINFO,
- ZIF_MD_TYPE_UNKNOWN
-} ZifMdType;
-
-typedef enum {
- ZIF_MD_ERROR_FAILED,
- ZIF_MD_ERROR_NO_SUPPORT,
- ZIF_MD_ERROR_FAILED_TO_LOAD,
- ZIF_MD_ERROR_FAILED_AS_OFFLINE,
- ZIF_MD_ERROR_FAILED_DOWNLOAD,
- ZIF_MD_ERROR_BAD_SQL,
- ZIF_MD_ERROR_LAST
-} ZifMdError;
-
-GType zif_md_get_type (void);
-GQuark zif_md_error_quark (void);
-ZifMd *zif_md_new (void);
-
-/* setters */
-gboolean zif_md_set_mdtype (ZifMd *md,
- ZifMdType type);
-gboolean zif_md_set_store_remote (ZifMd *md,
- ZifStoreRemote *remote);
-ZifStoreRemote *zif_md_get_store_remote (ZifMd *md);
-gboolean zif_md_set_id (ZifMd *md,
- const gchar *id);
-gboolean zif_md_set_filename (ZifMd *md,
- const gchar *filename);
-gboolean zif_md_set_timestamp (ZifMd *md,
- guint timestamp);
-gboolean zif_md_set_location (ZifMd *md,
- const gchar *location);
-gboolean zif_md_set_checksum (ZifMd *md,
- const gchar *checksum);
-gboolean zif_md_set_checksum_uncompressed (ZifMd *md,
- const gchar *checksum_uncompressed);
-gboolean zif_md_set_checksum_type (ZifMd *md,
- GChecksumType checksum_type);
-const gchar *zif_md_type_to_text (ZifMdType type);
-
-/* getters */
-const gchar *zif_md_get_id (ZifMd *md);
-ZifMdType zif_md_get_mdtype (ZifMd *md);
-const gchar *zif_md_get_filename (ZifMd *md);
-const gchar *zif_md_get_filename_uncompressed (ZifMd *md);
-guint zif_md_get_age (ZifMd *md,
- GError **error);
-const gchar *zif_md_get_location (ZifMd *md);
-
-/* actions */
-gboolean zif_md_load (ZifMd *md,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_md_unload (ZifMd *md,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_md_clean (ZifMd *md,
- GError **error);
-gboolean zif_md_file_check (ZifMd *md,
- gboolean use_uncompressed,
- GError **error);
-GPtrArray *zif_md_search_file (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_search_name (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_search_details (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_search_group (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_search_pkgid (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_what_provides (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_resolve (ZifMd *md,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_get_packages (ZifMd *md,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_find_package (ZifMd *md,
- const gchar *package_id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_get_changelog (ZifMd *md,
- const gchar *pkgid,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_md_get_files (ZifMd *md,
- ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_MD_H */
-
diff --git a/backends/yum/libzif/zif-monitor.c b/backends/yum/libzif/zif-monitor.c
deleted file mode 100644
index 547064a..0000000
--- a/backends/yum/libzif/zif-monitor.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-monitor
- * @short_description: Generic object to monitor files for changes.
- *
- * This object is a trivial multiplexted wrapper around GIO.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <glib/gstdio.h>
-#include <gio/gio.h>
-#include <sys/types.h>
-#include <utime.h>
-
-#include "zif-utils.h"
-#include "zif-monitor.h"
-
-#include "egg-debug.h"
-
-#define ZIF_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_MONITOR, ZifMonitorPrivate))
-
-/**
- * ZifMonitorPrivate:
- *
- * Private #ZifMonitor data
- **/
-struct _ZifMonitorPrivate
-{
- GPtrArray *array;
-};
-
-enum {
- ZIF_MONITOR_SIGNAL_CHANGED,
- ZIF_MONITOR_SIGNAL_LAST_SIGNAL
-};
-
-static guint signals [ZIF_MONITOR_SIGNAL_LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (ZifMonitor, zif_monitor, G_TYPE_OBJECT)
-
-/**
- * zif_monitor_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_monitor_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_monitor_error");
- return quark;
-}
-
-/**
- * zif_monitor_file_monitor_cb:
- **/
-static void
-zif_monitor_file_monitor_cb (GFileMonitor *file_monitor, GFile *file, GFile *other, GFileMonitorEvent event, ZifMonitor *monitor)
-{
- gchar *filename;
- filename = g_file_get_path (file);
- egg_debug ("file changed: %s", filename);
- g_signal_emit (monitor, signals [ZIF_MONITOR_SIGNAL_CHANGED], 0);
- g_free (filename);
-}
-
-/**
- * zif_monitor_add_watch:
- * @monitor: the #ZifMonitor object
- * @filename: the full filename to watch
- * @error: a #GError which is used on failure, or %NULL
- *
- * Sets up a watch on the file, and reports the 'changed' signal when the
- * file is changed.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_monitor_add_watch (ZifMonitor *monitor, const gchar *filename, GError **error)
-{
- GFile *file;
- GError *error_local = NULL;
- gboolean ret = TRUE;
- GFileMonitor *file_monitor;
-
- g_return_val_if_fail (ZIF_IS_MONITOR (monitor), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* watch this file */
- file = g_file_new_for_path (filename);
- file_monitor = g_file_monitor (file, G_FILE_MONITOR_NONE, NULL, &error_local);
- if (file_monitor == NULL) {
- g_set_error (error, ZIF_MONITOR_ERROR, ZIF_MONITOR_ERROR_FAILED,
- "failed to add monitor: %s", error_local->message);
- g_error_free (error_local);
- g_object_unref (file_monitor);
- ret = FALSE;
- goto out;
- }
-
- /* setup callback */
- g_file_monitor_set_rate_limit (file_monitor, 100);
- g_signal_connect (file_monitor, "changed", G_CALLBACK (zif_monitor_file_monitor_cb), monitor);
-
- /* add to array */
- g_ptr_array_add (monitor->priv->array, file_monitor);
-out:
- g_object_unref (file);
- return ret;
-}
-
-/**
- * zif_monitor_finalize:
- **/
-static void
-zif_monitor_finalize (GObject *object)
-{
- ZifMonitor *monitor;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_MONITOR (object));
- monitor = ZIF_MONITOR (object);
-
- g_ptr_array_unref (monitor->priv->array);
-
- G_OBJECT_CLASS (zif_monitor_parent_class)->finalize (object);
-}
-
-/**
- * zif_monitor_class_init:
- **/
-static void
-zif_monitor_class_init (ZifMonitorClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_monitor_finalize;
- signals [ZIF_MONITOR_SIGNAL_CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- g_type_class_add_private (klass, sizeof (ZifMonitorPrivate));
-}
-
-/**
- * zif_monitor_init:
- **/
-static void
-zif_monitor_init (ZifMonitor *monitor)
-{
- monitor->priv = ZIF_MONITOR_GET_PRIVATE (monitor);
- monitor->priv->array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-}
-
-/**
- * zif_monitor_new:
- *
- * Return value: A new #ZifMonitor class instance.
- *
- * Since: 0.0.1
- **/
-ZifMonitor *
-zif_monitor_new (void)
-{
- ZifMonitor *monitor;
- monitor = g_object_new (ZIF_TYPE_MONITOR, NULL);
- return ZIF_MONITOR (monitor);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-static void
-zif_monitor_test_file_monitor_cb (ZifMonitor *monitor, EggTest *test)
-{
- egg_test_loop_quit (test);
-}
-
-static gboolean
-zif_monitor_test_touch (gpointer data)
-{
- utime ("../test/repos/fedora.repo", NULL);
- return FALSE;
-}
-
-void
-zif_monitor_test (EggTest *test)
-{
- ZifMonitor *monitor;
- gboolean ret;
- GError *error = NULL;
-
- if (!egg_test_start (test, "ZifMonitor"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get monitor");
- monitor = zif_monitor_new ();
- egg_test_assert (test, monitor != NULL);
-
- g_signal_connect (monitor, "changed", G_CALLBACK (zif_monitor_test_file_monitor_cb), test);
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_monitor_add_watch (monitor, "../test/repos/fedora.repo", &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /* touch in 10ms */
- g_timeout_add (10, (GSourceFunc) zif_monitor_test_touch, NULL);
-
- /* wait for changed */
- egg_test_loop_wait (test, 2000);
- egg_test_loop_check (test);
-
- g_object_unref (monitor);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-monitor.h b/backends/yum/libzif/zif-monitor.h
deleted file mode 100644
index 0e4cfac..0000000
--- a/backends/yum/libzif/zif-monitor.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_MONITOR_H
-#define __ZIF_MONITOR_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_MONITOR (zif_monitor_get_type ())
-#define ZIF_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_MONITOR, ZifMonitor))
-#define ZIF_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_MONITOR, ZifMonitorClass))
-#define ZIF_IS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_MONITOR))
-#define ZIF_IS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_MONITOR))
-#define ZIF_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_MONITOR, ZifMonitorClass))
-#define ZIF_MONITOR_ERROR (zif_monitor_error_quark ())
-
-typedef struct _ZifMonitor ZifMonitor;
-typedef struct _ZifMonitorPrivate ZifMonitorPrivate;
-typedef struct _ZifMonitorClass ZifMonitorClass;
-
-struct _ZifMonitor
-{
- GObject parent;
- ZifMonitorPrivate *priv;
-};
-
-struct _ZifMonitorClass
-{
- GObjectClass parent_class;
-};
-
-typedef enum {
- ZIF_MONITOR_ERROR_FAILED,
- ZIF_MONITOR_ERROR_LAST
-} ZifMonitorError;
-
-GType zif_monitor_get_type (void);
-GQuark zif_monitor_error_quark (void);
-ZifMonitor *zif_monitor_new (void);
-gboolean zif_monitor_add_watch (ZifMonitor *monitor,
- const gchar *filename,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_MONITOR_H */
-
diff --git a/backends/yum/libzif/zif-package-local.c b/backends/yum/libzif/zif-package-local.c
deleted file mode 100644
index 4a6cf5b..0000000
--- a/backends/yum/libzif/zif-package-local.c
+++ /dev/null
@@ -1,694 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-package-local
- * @short_description: Local package object
- *
- * This object is a subclass of #ZifPackage
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <packagekit-glib2/packagekit.h>
-#include <rpm/rpmlib.h>
-#include <rpm/rpmdb.h>
-#include <rpm/rpmts.h>
-
-#include "egg-debug.h"
-
-#include "zif-utils.h"
-#include "zif-package.h"
-#include "zif-package-local.h"
-#include "zif-groups.h"
-#include "zif-string.h"
-#include "zif-depend.h"
-
-#define ZIF_PACKAGE_LOCAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_PACKAGE_LOCAL, ZifPackageLocalPrivate))
-
-/**
- * ZifPackageLocalPrivate:
- *
- * Private #ZifPackageLocal data
- **/
-struct _ZifPackageLocalPrivate
-{
- ZifGroups *groups;
- Header header;
-};
-
-G_DEFINE_TYPE (ZifPackageLocal, zif_package_local, ZIF_TYPE_PACKAGE)
-
-/**
- * zif_get_header_string:
- **/
-static ZifString *
-zif_get_header_string (Header header, rpmTag tag)
-{
- gint retval;
- ZifString *data = NULL;
- rpmtd td;
-
- td = rpmtdNew ();
- retval = headerGet (header, tag, td, HEADERGET_MINMEM);
-
- if (retval != 1)
- goto out;
- data = zif_string_new (rpmtdGetString (td));
-out:
- rpmtdFreeData (td);
- rpmtdFree (td);
- return data;
-}
-
-/**
- * zif_get_header_u32:
- **/
-static guint
-zif_get_header_u32 (Header header, rpmTag tag)
-{
- gint retval;
- uint32_t *data_p;
- guint data = 0;
- rpmtd td;
-
- td = rpmtdNew ();
- retval = headerGet (header, RPMTAG_SIZE, td, HEADERGET_MINMEM);
- if (retval != 1)
- goto out;
- data_p = rpmtdGetUint32 (td);
- if (data_p != NULL)
- data = *data_p;
-out:
- rpmtdFreeData (td);
- rpmtdFree (td);
- return data;
-}
-
-/**
- * zif_get_header_uint32_index:
- **/
-static GPtrArray *
-zif_get_header_uint32_index (Header header, rpmTag tag, guint length)
-{
- gint retval;
- guint32 *data;
- GPtrArray *array = NULL;
- rpmtd td;
- guint i;
-
- td = rpmtdNew ();
- retval = headerGet (header, tag, td, HEADERGET_MINMEM);
- if (retval != 1)
- goto out;
- array = g_ptr_array_new ();
- data = rpmtdGetUint32 (td);
- for (i=0;i<length; i++)
- g_ptr_array_add (array, GUINT_TO_POINTER (*(data+i)));
-out:
- rpmtdFreeData (td);
- rpmtdFree (td);
- return array;
-}
-
-/**
- * zif_get_header_string_array:
- **/
-static GPtrArray *
-zif_get_header_string_array (Header header, rpmTag tag)
-{
- gint retval;
- const gchar *data;
- GPtrArray *array = NULL;
- rpmtd td;
-
- td = rpmtdNew ();
- retval = headerGet (header, tag, td, HEADERGET_MINMEM);
- if (retval != 1)
- goto out;
- array = g_ptr_array_new_with_free_func (g_free);
- data = rpmtdGetString (td);
- while (data != NULL) {
- g_ptr_array_add (array, g_strdup (data));
- data = rpmtdNextString (td);
- }
-out:
- rpmtdFreeData (td);
- rpmtdFree (td);
- return array;
-}
-
-/**
- * zif_package_local_id_from_header:
- **/
-static gchar *
-zif_package_local_id_from_header (Header header)
-{
- gchar *package_id;
- const gchar *name = NULL;
- guint epoch = 0;
- guint *epoch_p = NULL;
- const gchar *version = NULL;
- const gchar *release = NULL;
- const gchar *arch = NULL;
- struct rpmtd_s value;
-
- /* get NEVRA */
- if (headerGet(header, RPMTAG_NAME, &value, HEADERGET_DEFAULT))
- name = rpmtdGetString (&value);
- if (headerGet(header, RPMTAG_EPOCH, &value, HEADERGET_DEFAULT))
- epoch_p = rpmtdGetUint32 (&value);
- if (headerGet(header, RPMTAG_VERSION, &value, HEADERGET_DEFAULT))
- version = rpmtdGetString (&value);
- if (headerGet(header, RPMTAG_RELEASE, &value, HEADERGET_DEFAULT))
- release = rpmtdGetString (&value);
- if (headerGet(header, RPMTAG_ARCH, &value, HEADERGET_DEFAULT))
- arch = rpmtdGetString (&value);
-
- /* if we got a value, then dereference it */
- if (epoch_p != NULL)
- epoch = *epoch_p;
-
- /* with or without epoch */
- package_id = zif_package_id_from_nevra (name, epoch, version, release, arch, "installed");
- return package_id;
-}
-
-/**
- * zif_package_local_get_depends_from_name_flags_version:
- **/
-static GPtrArray *
-zif_package_local_get_depends_from_name_flags_version (GPtrArray *names, GPtrArray *flags, GPtrArray *versions)
-{
- guint i;
- rpmsenseFlags rpmflags;
- ZifDepend *depend;
- ZifDependFlag flag;
- const gchar *name;
- const gchar *version;
- GPtrArray *array;
-
- /* create requires */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) zif_depend_unref);
- for (i=0; i<names->len; i++) {
- name = g_ptr_array_index (names, i);
- version = g_ptr_array_index (versions, i);
-
- /* no version string */
- if (version == NULL || version[0] == '\0') {
- depend = zif_depend_new (name, ZIF_DEPEND_FLAG_ANY, NULL);
- g_ptr_array_add (array, depend);
- continue;
- }
-
- /* ignore rpmlib flags */
- rpmflags = GPOINTER_TO_UINT (g_ptr_array_index (flags, i));
- if ((rpmflags & RPMSENSE_RPMLIB) > 0)
- continue;
-
- /* convert to enums */
- flag = ZIF_DEPEND_FLAG_UNKNOWN;
- if ((rpmflags & RPMSENSE_LESS) > 0) {
- flag = ZIF_DEPEND_FLAG_LESS;
- } else if ((rpmflags & RPMSENSE_GREATER) > 0) {
- flag = ZIF_DEPEND_FLAG_GREATER;
- } else if ((rpmflags & RPMSENSE_EQUAL) > 0) {
- flag = ZIF_DEPEND_FLAG_EQUAL;
- }
-
- /* unknown */
- if (flag == ZIF_DEPEND_FLAG_UNKNOWN) {
-// egg_debug ("ignoring %s %s %s", name, zif_depend_flag_to_string (flag), version);
- continue;
- }
-
- depend = zif_depend_new (name, flag, version);
- g_ptr_array_add (array, depend);
- }
- return array;
-}
-
-/*
- * zif_package_local_ensure_data:
- */
-static gboolean
-zif_package_local_ensure_data (ZifPackage *pkg, ZifPackageEnsureType type, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *files;
- GPtrArray *dirnames;
- GPtrArray *basenames;
- GPtrArray *fileindex;
- guint i;
- gchar *filename;
- guint size;
- ZifString *tmp;
- const gchar *text;
- PkGroupEnum group;
-// GPtrArray *tmparray;
- GPtrArray *depends;
-// GPtrArray *provides;
- GPtrArray *flags;
- GPtrArray *names;
- GPtrArray *versions;
- gboolean ret = TRUE;
- Header header = ZIF_PACKAGE_LOCAL(pkg)->priv->header;
-
- /* eigh? */
- if (header == NULL) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "no header for %s", zif_package_get_id (pkg));
- ret = FALSE;
- goto out;
- }
-
- if (type == ZIF_PACKAGE_ENSURE_TYPE_FILES) {
- /* files */
- basenames = zif_get_header_string_array (header, RPMTAG_BASENAMES);
-
- /* create the files */
- if (basenames != NULL) {
-
- /* get the mapping */
- dirnames = zif_get_header_string_array (header, RPMTAG_DIRNAMES);
- fileindex = zif_get_header_uint32_index (header, RPMTAG_DIRINDEXES, basenames->len);
- if (basenames->len != fileindex->len) {
- ret = FALSE;
- g_set_error_literal (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "internal error, basenames length is not the same as index length, possibly corrupt db?");
- goto out;
- }
- if (fileindex->len > fileindex->len) {
- ret = FALSE;
- g_set_error_literal (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "internal error, fileindex length is bigger than index length, possibly corrupt db?");
- goto out;
- }
-
- files = g_ptr_array_new_with_free_func (g_free);
- for (i=0; i<basenames->len-2 /* why -1? I'm not sure */; i++) {
- guint idx;
- idx = GPOINTER_TO_UINT (g_ptr_array_index (fileindex, i));
- if (idx > dirnames->len) {
- egg_warning ("index bigger than dirnames (%i > %i) for package %s [%s], i=%i, dn=%i, bn=%i, fi=%i",
- idx, dirnames->len, zif_package_get_package_id (pkg),
- (const gchar *) g_ptr_array_index (basenames, i),
- i, dirnames->len, basenames->len, fileindex->len);
- continue;
- }
- filename = g_strconcat (g_ptr_array_index (dirnames, idx), g_ptr_array_index (basenames, i), NULL);
- g_ptr_array_add (files, filename);
- }
- zif_package_set_files (pkg, files);
- g_ptr_array_unref (files);
-
- /* free, as we have files */
- g_ptr_array_unref (dirnames);
- g_ptr_array_unref (basenames);
- g_ptr_array_unref (fileindex);
- } else {
- files = g_ptr_array_new_with_free_func (g_free);
- zif_package_set_files (pkg, files);
- g_ptr_array_unref (files);
- }
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_SUMMARY) {
- /* summary */
- tmp = zif_get_header_string (header, RPMTAG_SUMMARY);
- zif_package_set_summary (pkg, tmp);
- zif_string_unref (tmp);
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_LICENCE) {
- /* license */
- tmp = zif_get_header_string (header, RPMTAG_LICENSE);
- zif_package_set_license (pkg, tmp);
- zif_string_unref (tmp);
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_DESCRIPTION) {
- /* description */
- tmp = zif_get_header_string (header, RPMTAG_DESCRIPTION);
- if (tmp == NULL) {
- egg_warning ("no description for %s", zif_package_get_id (pkg));
- tmp = zif_string_new ("");
- }
- zif_package_set_description (pkg, tmp);
- zif_string_unref (tmp);
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_URL) {
- /* url */
- tmp = zif_get_header_string (header, RPMTAG_URL);
- if (tmp != NULL) {
- zif_package_set_url (pkg, tmp);
- zif_string_unref (tmp);
- }
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_SIZE) {
- /* size */
- size = zif_get_header_u32 (header, RPMTAG_SIZE);
- if (size != 0)
- zif_package_set_size (pkg, size);
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_CATEGORY) {
- /* category */
- tmp = zif_get_header_string (header, RPMTAG_GROUP);
- zif_package_set_category (pkg, tmp);
- zif_string_unref (tmp);
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_GROUP) {
- /* group */
- text = zif_package_get_category (pkg, cancellable, completion, error);
- if (text == NULL)
- goto out;
- group = zif_groups_get_group_for_cat (ZIF_PACKAGE_LOCAL (pkg)->priv->groups, text, NULL);
- if (group != PK_GROUP_ENUM_UNKNOWN)
- zif_package_set_group (pkg, group);
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_REQUIRES) {
- /* requires */
- names = zif_get_header_string_array (header, RPMTAG_REQUIRENAME);
- if (names == NULL) {
- depends = g_ptr_array_new_with_free_func ((GDestroyNotify) zif_depend_unref);
- zif_package_set_requires (pkg, depends);
- g_ptr_array_unref (depends);
- } else {
- versions = zif_get_header_string_array (header, RPMTAG_REQUIREVERSION);
- flags = zif_get_header_uint32_index (header, RPMTAG_REQUIREFLAGS, names->len);
- depends = zif_package_local_get_depends_from_name_flags_version (names, flags, versions);
- zif_package_set_requires (pkg, depends);
- g_ptr_array_unref (depends);
- g_ptr_array_unref (names);
- g_ptr_array_unref (versions);
- g_ptr_array_unref (flags);
- }
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_PROVIDES) {
- /* provides */
- names = zif_get_header_string_array (header, RPMTAG_PROVIDENAME);
- if (names == NULL) {
- depends = g_ptr_array_new_with_free_func ((GDestroyNotify) zif_depend_unref);
- zif_package_set_provides (pkg, depends);
- g_ptr_array_unref (depends);
- } else {
- versions = zif_get_header_string_array (header, RPMTAG_PROVIDEVERSION);
- flags = zif_get_header_uint32_index (header, RPMTAG_PROVIDEFLAGS, names->len);
- depends = zif_package_local_get_depends_from_name_flags_version (names, flags, versions);
- zif_package_set_provides (pkg, depends);
- g_ptr_array_unref (depends);
- g_ptr_array_unref (names);
- g_ptr_array_unref (versions);
- g_ptr_array_unref (flags);
- }
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_CONFLICTS) {
- /* conflicts */
- names = zif_get_header_string_array (header, RPMTAG_CONFLICTNAME);
- if (names == NULL) {
- depends = g_ptr_array_new_with_free_func ((GDestroyNotify) zif_depend_unref);
- //zif_package_set_conflicts (pkg, depends);
- g_ptr_array_unref (depends);
- } else {
- versions = zif_get_header_string_array (header, RPMTAG_CONFLICTVERSION);
- flags = zif_get_header_uint32_index (header, RPMTAG_CONFLICTFLAGS, names->len);
- depends = zif_package_local_get_depends_from_name_flags_version (names, flags, versions);
- //zif_package_set_conflicts (pkg, depends);
- g_ptr_array_unref (depends);
- g_ptr_array_unref (names);
- g_ptr_array_unref (versions);
- g_ptr_array_unref (flags);
- }
-
- } else if (type == ZIF_PACKAGE_ENSURE_TYPE_OBSOLETES) {
- /* obsoletes */
- names = zif_get_header_string_array (header, RPMTAG_OBSOLETENAME);
- if (names == NULL) {
- depends = g_ptr_array_new_with_free_func ((GDestroyNotify) zif_depend_unref);
- //zif_package_set_obsoletes (pkg, depends);
- g_ptr_array_unref (depends);
- } else {
- versions = zif_get_header_string_array (header, RPMTAG_OBSOLETEVERSION);
- flags = zif_get_header_uint32_index (header, RPMTAG_OBSOLETEFLAGS, names->len);
- depends = zif_package_local_get_depends_from_name_flags_version (names, flags, versions);
- //zif_package_set_obsoletes (pkg, depends);
- g_ptr_array_unref (depends);
- g_ptr_array_unref (names);
- g_ptr_array_unref (versions);
- g_ptr_array_unref (flags);
- }
- }
-out:
- return ret;
-}
-
-/**
- * zif_package_local_set_from_header:
- * @pkg: the #ZifPackageLocal object
- * @header: a rpm #Header structure
- * @error: a #GError which is used on failure, or %NULL
- *
- * Sets the local package from an RPM header object.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_local_set_from_header (ZifPackageLocal *pkg, Header header, GError **error)
-{
- gchar *package_id;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE_LOCAL (pkg), FALSE);
- g_return_val_if_fail (header != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- zif_package_set_installed (ZIF_PACKAGE (pkg), TRUE);
-
- /* save header so we can read when required */
- pkg->priv->header = headerLink (header);
-
- /* id */
- package_id = zif_package_local_id_from_header (header);
- zif_package_set_id (ZIF_PACKAGE (pkg), package_id);
- g_free (package_id);
-
- return TRUE;
-}
-
-/**
- * zif_package_local_rpmrc_to_string:
- **/
-static const gchar *
-zif_package_local_rpmrc_to_string (rpmRC rc)
-{
- if (rc == RPMRC_OK)
- return "Generic success";
- if (rc == RPMRC_NOTFOUND)
- return "Generic not found";
- if (rc == RPMRC_FAIL)
- return "Generic failure";
- if (rc == RPMRC_NOTTRUSTED)
- return "Signature is OK, but key is not trusted";
- if (rc == RPMRC_NOKEY)
- return "Public key is unavailable";
- return "Unknown error";
-}
-
-/**
- * zif_package_local_set_from_filename:
- * @pkg: the #ZifPackageLocal object
- * @filename: the local filename
- * @error: a #GError which is used on failure, or %NULL
- *
- * Sets a local package object from a local file.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_local_set_from_filename (ZifPackageLocal *pkg, const gchar *filename, GError **error)
-{
- rpmRC rc;
- FD_t fd = NULL;
- Header hdr = NULL;
- rpmts ts;
- gboolean ret = FALSE;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE_LOCAL (pkg), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* open the file for reading */
- fd = Fopen(filename, "r.fdio");
- if (fd == NULL) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "failed to open %s", filename);
- goto out;
- }
- if (Ferror(fd)) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "failed to open %s: %s", filename, Fstrerror(fd));
- goto out;
- }
-
- /* create an empty transaction set */
- ts = rpmtsCreate ();
-
- /* we don't want to abort on missing keys */
- rpmtsSetVSFlags (ts, _RPMVSF_NOSIGNATURES);
-
- /* read in the file */
- rc = rpmReadPackageFile (ts, fd, filename, &hdr);
- if (rc != RPMRC_OK) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "failed to read %s: %s", filename, zif_package_local_rpmrc_to_string (rc));
- goto out;
- }
-
- /* convert and upscale */
- headerConvert (hdr, HEADERCONV_RETROFIT_V3);
-
- /* set from header */
- ret = zif_package_local_set_from_header (pkg, hdr, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "failed to set from header: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* close the database used by the transaction */
- rc = rpmtsCloseDB (ts);
- if (rc != RPMRC_OK) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "failed to close: %s", zif_package_local_rpmrc_to_string (rc));
- ret = FALSE;
- goto out;
- }
-out:
- /* close header and file */
- if (hdr != NULL)
- headerFree (hdr);
- if (fd != NULL)
- Fclose (fd);
- return ret;
-}
-
-/**
- * zif_package_local_finalize:
- **/
-static void
-zif_package_local_finalize (GObject *object)
-{
- ZifPackageLocal *pkg;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_PACKAGE_LOCAL (object));
- pkg = ZIF_PACKAGE_LOCAL (object);
-
- g_object_unref (pkg->priv->groups);
- if (pkg->priv->header != NULL)
- headerUnlink (pkg->priv->header);
-
- G_OBJECT_CLASS (zif_package_local_parent_class)->finalize (object);
-}
-
-/**
- * zif_package_local_class_init:
- **/
-static void
-zif_package_local_class_init (ZifPackageLocalClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifPackageClass *package_class = ZIF_PACKAGE_CLASS (klass);
- object_class->finalize = zif_package_local_finalize;
-
- package_class->ensure_data = zif_package_local_ensure_data;
-
- g_type_class_add_private (klass, sizeof (ZifPackageLocalPrivate));
-}
-
-/**
- * zif_package_local_init:
- **/
-static void
-zif_package_local_init (ZifPackageLocal *pkg)
-{
- pkg->priv = ZIF_PACKAGE_LOCAL_GET_PRIVATE (pkg);
- pkg->priv->groups = zif_groups_new ();
- pkg->priv->header = NULL;
-}
-
-/**
- * zif_package_local_new:
- *
- * Return value: A new #ZifPackageLocal class instance.
- *
- * Since: 0.0.1
- **/
-ZifPackageLocal *
-zif_package_local_new (void)
-{
- ZifPackageLocal *pkg;
- pkg = g_object_new (ZIF_TYPE_PACKAGE_LOCAL, NULL);
- return ZIF_PACKAGE_LOCAL (pkg);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_package_local_test (EggTest *test)
-{
- ZifPackageLocal *pkg;
- gboolean ret;
- GError *error = NULL;
- gchar *filename;
-
- if (!egg_test_start (test, "ZifPackageLocal"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get package_local");
- pkg = zif_package_local_new ();
- egg_test_assert (test, pkg != NULL);
-
- /************************************************************/
- egg_test_title (test, "load file");
- filename = egg_test_get_data_file ("accountsdialog-0.4.1-1.fc13.i686.rpm");
- ret = zif_package_local_set_from_filename (pkg, filename, &error);
- if (!ret) {
- egg_test_failed (test, "failed to set from filename: %s", error->message);
- g_error_free (error);
- }
- g_free (filename);
- egg_test_success (test, NULL);
-
- g_object_unref (pkg);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-package-local.h b/backends/yum/libzif/zif-package-local.h
deleted file mode 100644
index 5bc2e4b..0000000
--- a/backends/yum/libzif/zif-package-local.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_PACKAGE_LOCAL_H
-#define __ZIF_PACKAGE_LOCAL_H
-
-#include <glib-object.h>
-#include <rpm/rpmlib.h>
-#include <rpm/rpmdb.h>
-
-#include "zif-package.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_PACKAGE_LOCAL (zif_package_local_get_type ())
-#define ZIF_PACKAGE_LOCAL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_PACKAGE_LOCAL, ZifPackageLocal))
-#define ZIF_PACKAGE_LOCAL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_PACKAGE_LOCAL, ZifPackageLocalClass))
-#define ZIF_IS_PACKAGE_LOCAL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_PACKAGE_LOCAL))
-#define ZIF_IS_PACKAGE_LOCAL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_PACKAGE_LOCAL))
-#define ZIF_PACKAGE_LOCAL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_PACKAGE_LOCAL, ZifPackageLocalClass))
-
-typedef struct _ZifPackageLocal ZifPackageLocal;
-typedef struct _ZifPackageLocalPrivate ZifPackageLocalPrivate;
-typedef struct _ZifPackageLocalClass ZifPackageLocalClass;
-
-struct _ZifPackageLocal
-{
- ZifPackage parent;
- ZifPackageLocalPrivate *priv;
-};
-
-struct _ZifPackageLocalClass
-{
- ZifPackageClass parent_class;
-};
-
-GType zif_package_local_get_type (void);
-ZifPackageLocal *zif_package_local_new (void);
-gboolean zif_package_local_set_from_header (ZifPackageLocal *pkg,
- Header header,
- GError **error);
-gboolean zif_package_local_set_from_filename (ZifPackageLocal *pkg,
- const gchar *filename,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_PACKAGE_LOCAL_H */
-
diff --git a/backends/yum/libzif/zif-package-remote.c b/backends/yum/libzif/zif-package-remote.c
deleted file mode 100644
index 6c552ad..0000000
--- a/backends/yum/libzif/zif-package-remote.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-package-remote
- * @short_description: Remote package object
- *
- * This object is a subclass of #ZifPackage
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "egg-debug.h"
-
-#include "zif-utils.h"
-#include "zif-package-remote.h"
-#include "zif-groups.h"
-#include "zif-string.h"
-#include "zif-store-remote.h"
-
-#define ZIF_PACKAGE_REMOTE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_PACKAGE_REMOTE, ZifPackageRemotePrivate))
-
-/**
- * ZifPackageRemotePrivate:
- *
- * Private #ZifPackageRemote data
- **/
-struct _ZifPackageRemotePrivate
-{
- ZifGroups *groups;
- ZifStoreRemote *store_remote;
- gchar *pkgid;
-};
-
-G_DEFINE_TYPE (ZifPackageRemote, zif_package_remote, ZIF_TYPE_PACKAGE)
-
-/**
- * zif_package_remote_set_from_repo:
- * @pkg: the #ZifPackageRemote object
- * @length: length of data and type arrays
- * @type: data type array
- * @data: data value array
- * @repo_id: the repository id
- * @error: a #GError which is used on failure, or %NULL
- *
- * Sets details on a remote package from repo data derived from the metadata xml.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_remote_set_from_repo (ZifPackageRemote *pkg, guint length, gchar **type, gchar **data, const gchar *repo_id, GError **error)
-{
- guint i;
- const gchar *name = NULL;
- guint epoch = 0;
- const gchar *version = NULL;
- const gchar *release = NULL;
- const gchar *arch = NULL;
- gchar *package_id;
- ZifString *string;
- gchar *endptr = NULL;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE_REMOTE (pkg), FALSE);
- g_return_val_if_fail (type != NULL, FALSE);
- g_return_val_if_fail (data != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* get the ID */
- for (i=0; i<length; i++) {
- if (g_strcmp0 (type[i], "name") == 0) {
- name = data[i];
- } else if (g_strcmp0 (type[i], "epoch") == 0) {
- epoch = g_ascii_strtoull (data[i], &endptr, 10);
- if (data[i] == endptr)
- egg_warning ("failed to parse epoch %s", data[i]);
- } else if (g_strcmp0 (type[i], "version") == 0) {
- version = data[i];
- } else if (g_strcmp0 (type[i], "release") == 0) {
- release = data[i];
- } else if (g_strcmp0 (type[i], "arch") == 0) {
- arch = data[i];
- } else if (g_strcmp0 (type[i], "summary") == 0) {
- string = zif_string_new (data[i]);
- zif_package_set_summary (ZIF_PACKAGE (pkg), string);
- zif_string_unref (string);
- } else if (g_strcmp0 (type[i], "description") == 0) {
- string = zif_string_new (data[i]);
- zif_package_set_description (ZIF_PACKAGE (pkg), string);
- zif_string_unref (string);
- } else if (g_strcmp0 (type[i], "url") == 0) {
- string = zif_string_new (data[i]);
- zif_package_set_url (ZIF_PACKAGE (pkg), string);
- zif_string_unref (string);
- } else if (g_strcmp0 (type[i], "rpm_license") == 0) {
- string = zif_string_new (data[i]);
- zif_package_set_license (ZIF_PACKAGE (pkg), string);
- zif_string_unref (string);
- } else if (g_strcmp0 (type[i], "rpm_group") == 0) {
- string = zif_string_new (data[i]);
- zif_package_set_category (ZIF_PACKAGE (pkg), string);
- zif_string_unref (string);
- } else if (g_strcmp0 (type[i], "size_package") == 0) {
- zif_package_set_size (ZIF_PACKAGE (pkg), atoi (data[i]));
- } else if (g_strcmp0 (type[i], "pkgId") == 0) {
- pkg->priv->pkgid = g_strdup (data[i]);
- } else if (g_strcmp0 (type[i], "location_href") == 0) {
- string = zif_string_new (data[i]);
- zif_package_set_location_href (ZIF_PACKAGE (pkg), string);
- zif_string_unref (string);
- } else {
- egg_warning ("unrecognized: %s=%s", type[i], data[i]);
- }
- }
-
- zif_package_set_installed (ZIF_PACKAGE (pkg), FALSE);
- package_id = zif_package_id_from_nevra (name, epoch, version, release, arch, repo_id);
- zif_package_set_id (ZIF_PACKAGE (pkg), package_id);
- g_free (package_id);
- return TRUE;
-}
-
-/**
- * zif_package_remote_get_pkgid:
- * @pkg: the #ZifPackageRemote object
- *
- * Gets the pkgid used internally to track the package item.
- *
- * Return value: the pkgid hash.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_remote_get_pkgid (ZifPackageRemote *pkg)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE_REMOTE (pkg), NULL);
- return pkg->priv->pkgid;
-}
-
-/**
- * zif_package_remote_set_pkgid:
- * @pkg: the #ZifPackageRemote object
- * @pkgid: the pkgid hash.
- *
- * Sets the pkgid used internally to track the package item.
- *
- * Return value: the pkgid hash.
- *
- * Since: 0.0.1
- **/
-void
-zif_package_remote_set_pkgid (ZifPackageRemote *pkg, const gchar *pkgid)
-{
- g_return_if_fail (ZIF_IS_PACKAGE_REMOTE (pkg));
- g_return_if_fail (pkgid != NULL);
- g_return_if_fail (pkg->priv->pkgid == NULL);
- pkg->priv->pkgid = g_strdup (pkgid);
-}
-
-/**
- * zif_package_remote_set_store_remote:
- * @pkg: the #ZifPackageRemote object
- * @store: the #ZifStoreRemote that created this package
- *
- * Sets the store used to create this package, which we may need of we ever
- * need to ensure() data at runtime.
- *
- * Return value: the pkgid hash.
- *
- * Since: 0.0.1
- **/
-void
-zif_package_remote_set_store_remote (ZifPackageRemote *pkg, ZifStoreRemote *store)
-{
- g_return_if_fail (ZIF_IS_PACKAGE_REMOTE (pkg));
- g_return_if_fail (ZIF_IS_STORE_REMOTE (store));
- g_return_if_fail (pkg->priv->store_remote == NULL);
- pkg->priv->store_remote = g_object_ref (store);
-}
-
-/*
- * zif_package_remote_ensure_data:
- */
-static gboolean
-zif_package_remote_ensure_data (ZifPackage *pkg, ZifPackageEnsureType type, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = TRUE;
- GPtrArray *array = NULL;
- ZifPackageRemote *pkg_remote = ZIF_PACKAGE_REMOTE (pkg);
-
- if (type == ZIF_PACKAGE_ENSURE_TYPE_FILES) {
-
- /* get the file list for this package */
- array = zif_store_remote_get_files (pkg_remote->priv->store_remote, pkg, cancellable, completion, error);
- if (array == NULL) {
- ret = FALSE;
- goto out;
- }
-
- /* set for this package */
- zif_package_set_files (pkg, array);
- } else {
- g_set_error (error, 1, 0,
- "Getting ensure type '%s' not supported on a ZifPackageRemote",
- zif_package_ensure_type_to_string (type));
- ret = FALSE;
- }
-out:
- if (array != NULL)
- g_ptr_array_unref (array);
- return ret;
-}
-
-/**
- * zif_package_remote_finalize:
- **/
-static void
-zif_package_remote_finalize (GObject *object)
-{
- ZifPackageRemote *pkg;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_PACKAGE_REMOTE (object));
- pkg = ZIF_PACKAGE_REMOTE (object);
-
- g_free (pkg->priv->pkgid);
- g_object_unref (pkg->priv->groups);
- if (pkg->priv->store_remote != NULL)
- g_object_unref (pkg->priv->store_remote);
-
- G_OBJECT_CLASS (zif_package_remote_parent_class)->finalize (object);
-}
-
-/**
- * zif_package_remote_class_init:
- **/
-static void
-zif_package_remote_class_init (ZifPackageRemoteClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifPackageClass *package_class = ZIF_PACKAGE_CLASS (klass);
- object_class->finalize = zif_package_remote_finalize;
- package_class->ensure_data = zif_package_remote_ensure_data;
- g_type_class_add_private (klass, sizeof (ZifPackageRemotePrivate));
-}
-
-/**
- * zif_package_remote_init:
- **/
-static void
-zif_package_remote_init (ZifPackageRemote *pkg)
-{
- pkg->priv = ZIF_PACKAGE_REMOTE_GET_PRIVATE (pkg);
- pkg->priv->pkgid = NULL;
- pkg->priv->store_remote = NULL;
- pkg->priv->groups = zif_groups_new ();
-}
-
-/**
- * zif_package_remote_new:
- *
- * Return value: A new #ZifPackageRemote class instance.
- *
- * Since: 0.0.1
- **/
-ZifPackageRemote *
-zif_package_remote_new (void)
-{
- ZifPackageRemote *pkg;
- pkg = g_object_new (ZIF_TYPE_PACKAGE_REMOTE, NULL);
- return ZIF_PACKAGE_REMOTE (pkg);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_package_remote_test (EggTest *test)
-{
- ZifPackageRemote *pkg;
-
- if (!egg_test_start (test, "ZifPackageRemote"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get package_remote");
- pkg = zif_package_remote_new ();
- egg_test_assert (test, pkg != NULL);
-
- g_object_unref (pkg);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-package-remote.h b/backends/yum/libzif/zif-package-remote.h
deleted file mode 100644
index 02fab89..0000000
--- a/backends/yum/libzif/zif-package-remote.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_PACKAGE_REMOTE_H
-#define __ZIF_PACKAGE_REMOTE_H
-
-#include <glib-object.h>
-
-#include "zif-package.h"
-#include "zif-store-remote.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_PACKAGE_REMOTE (zif_package_remote_get_type ())
-#define ZIF_PACKAGE_REMOTE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_PACKAGE_REMOTE, ZifPackageRemote))
-#define ZIF_PACKAGE_REMOTE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_PACKAGE_REMOTE, ZifPackageRemoteClass))
-#define ZIF_IS_PACKAGE_REMOTE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_PACKAGE_REMOTE))
-#define ZIF_IS_PACKAGE_REMOTE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_PACKAGE_REMOTE))
-#define ZIF_PACKAGE_REMOTE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_PACKAGE_REMOTE, ZifPackageRemoteClass))
-
-typedef struct _ZifPackageRemote ZifPackageRemote;
-typedef struct _ZifPackageRemotePrivate ZifPackageRemotePrivate;
-typedef struct _ZifPackageRemoteClass ZifPackageRemoteClass;
-
-struct _ZifPackageRemote
-{
- ZifPackage parent;
- ZifPackageRemotePrivate *priv;
-};
-
-struct _ZifPackageRemoteClass
-{
- ZifPackageClass parent_class;
-};
-
-GType zif_package_remote_get_type (void);
-ZifPackageRemote *zif_package_remote_new (void);
-gboolean zif_package_remote_set_from_repo (ZifPackageRemote *pkg,
- guint length,
- gchar **type,
- gchar **data,
- const gchar *repo_id,
- GError **error);
-const gchar *zif_package_remote_get_pkgid (ZifPackageRemote *pkg);
-void zif_package_remote_set_pkgid (ZifPackageRemote *pkg,
- const gchar *pkgid);
-void zif_package_remote_set_store_remote (ZifPackageRemote *pkg,
- ZifStoreRemote *store);
-
-G_END_DECLS
-
-#endif /* __ZIF_PACKAGE_REMOTE_H */
-
diff --git a/backends/yum/libzif/zif-package.c b/backends/yum/libzif/zif-package.c
deleted file mode 100644
index d0795ec..0000000
--- a/backends/yum/libzif/zif-package.c
+++ /dev/null
@@ -1,1492 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-package
- * @short_description: Generic object to represent an installed or remote package.
- *
- * This object is subclassed by #ZifPackageLocal and #ZifPackageRemote.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "egg-debug.h"
-
-#include "zif-depend.h"
-#include "zif-utils.h"
-#include "zif-config.h"
-#include "zif-package.h"
-#include "zif-repos.h"
-#include "zif-groups.h"
-#include "zif-string.h"
-
-#define ZIF_PACKAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_PACKAGE, ZifPackagePrivate))
-
-struct _ZifPackagePrivate
-{
- ZifConfig *config;
- ZifGroups *groups;
- ZifRepos *repos;
- gchar **package_id_split;
- gchar *package_id;
- ZifString *summary;
- ZifString *description;
- ZifString *license;
- ZifString *url;
- ZifString *category;
- ZifString *location_href;
- PkGroupEnum group;
- guint64 size;
- GPtrArray *files;
- GPtrArray *requires;
- GPtrArray *provides;
- gboolean installed;
-};
-
-G_DEFINE_TYPE (ZifPackage, zif_package, G_TYPE_OBJECT)
-
-/**
- * zif_package_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_package_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_package_error");
- return quark;
-}
-
-/**
- * zif_package_compare:
- * @a: the first package to compare
- * @b: the second package to compare
- *
- * Compares one package versions against each other.
- *
- * Return value: 1 for a>b, 0 for a==b, -1 for b>a, or G_MAXINT for error
- *
- * Since: 0.0.1
- **/
-gint
-zif_package_compare (ZifPackage *a, ZifPackage *b)
-{
- gchar **splita;
- gchar **splitb;
- gint val = G_MAXINT;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (a), G_MAXINT);
- g_return_val_if_fail (ZIF_IS_PACKAGE (b), G_MAXINT);
-
- /* no-copy */
- splita = a->priv->package_id_split;
- splitb = b->priv->package_id_split;
-
- /* check name the same */
- if (g_strcmp0 (splita[PK_PACKAGE_ID_NAME], splitb[PK_PACKAGE_ID_NAME]) != 0)
- goto out;
-
- /* do a version compare */
- val = zif_compare_evr (splita[PK_PACKAGE_ID_VERSION], splitb[PK_PACKAGE_ID_VERSION]);
-
- /* if the packages are equal, prefer the same architecture */
- if (val == 0)
- val = g_strcmp0 (splitb[PK_PACKAGE_ID_ARCH], splita[PK_PACKAGE_ID_ARCH]);
-out:
- return val;
-}
-
-/**
- * zif_package_array_get_newest:
- * @array: array of %ZifPackage's
- * @error: a #GError which is used on failure, or %NULL
- *
- * Returns the newest package from a list.
- *
- * Return value: a single %ZifPackage, or %NULL in the case of an error. Use g_object_unref() when done.
- *
- * Since: 0.0.1
- **/
-ZifPackage *
-zif_package_array_get_newest (GPtrArray *array, GError **error)
-{
- ZifPackage *package_newest;
- ZifPackage *package = NULL;
- guint i;
- gint retval;
-
- /* no results */
- if (array->len == 0) {
- g_set_error_literal (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "nothing in array");
- goto out;
- }
-
- /* start with the first package being the newest */
- package_newest = g_ptr_array_index (array, 0);
-
- /* find newest in rest of the array */
- for (i=1; i<array->len; i++) {
- package = g_ptr_array_index (array, i);
- retval = zif_package_compare (package, package_newest);
- if (retval > 0)
- package_newest = package;
- }
-
- /* return reference so we can unref the list */
- package = g_object_ref (package_newest);
-out:
- return package;
-}
-
-/**
- * zif_package_array_filter_newest:
- * @packages: array of %ZifPackage's
- *
- * Filters the list so that only the newest version of a package remains.
- *
- * Return value: %TRUE if the array was modified
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_array_filter_newest (GPtrArray *packages)
-{
- guint i;
- GHashTable *hash;
- ZifPackage *package;
- ZifPackage *package_tmp;
- const gchar *name;
- gboolean ret = FALSE;
-
- /* use a hash so it's O(n) not O(n^2) */
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- for (i=0; i<packages->len; i++) {
- package = ZIF_PACKAGE (g_ptr_array_index (packages, i));
- name = zif_package_get_name (package);
- package_tmp = g_hash_table_lookup (hash, name);
-
- /* does not already exist */
- if (package_tmp == NULL) {
- g_hash_table_insert (hash, g_strdup (name), g_object_ref (package));
- continue;
- }
-
- /* the new package is older */
- if (zif_package_compare (package, package_tmp) < 0) {
- egg_debug ("%s is older than %s, so ignoring it",
- zif_package_get_id (package), zif_package_get_id (package_tmp));
- g_ptr_array_remove_index_fast (packages, i);
- ret = TRUE;
- continue;
- }
-
- ret = TRUE;
- egg_debug ("removing %s", zif_package_get_id (package_tmp));
- egg_debug ("adding %s", zif_package_get_id (package));
-
- /* remove the old one */
- g_hash_table_remove (hash, zif_package_get_name (package_tmp));
- g_hash_table_insert (hash, g_strdup (name), g_object_ref (package));
- g_ptr_array_remove_fast (packages, package_tmp);
- }
- g_hash_table_unref (hash);
- return ret;
-}
-
-/**
- * zif_package_get_store_for_package:
- **/
-static ZifStoreRemote *
-zif_package_get_store_for_package (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreRemote *store_remote;
- store_remote = zif_repos_get_store (package->priv->repos, package->priv->package_id_split[PK_PACKAGE_ID_DATA],
- cancellable, completion, error);
- return store_remote;
-}
-
-/**
- * zif_package_download:
- * @package: the #ZifPackage object
- * @directory: the local directory to save to
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Downloads a package.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_download (ZifPackage *package, const gchar *directory, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- ZifStoreRemote *store_remote = NULL;
- GError *error_local = NULL;
- ZifCompletion *completion_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (directory != NULL, FALSE);
- g_return_val_if_fail (package->priv->package_id_split != NULL, FALSE);
-
- /* check we are not installed */
- if (package->priv->installed) {
- g_set_error_literal (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "cannot download installed packages");
- goto out;
- }
-
- /* two steps, TODO: the second will take longer than the first */
- zif_completion_set_number_steps (completion, 2);
-
- /* find correct repo */
- completion_local = zif_completion_get_child (completion);
- store_remote = zif_package_get_store_for_package (package, cancellable, completion_local, &error_local);
- if (store_remote == NULL) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "cannot find remote store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* create a chain of completions */
- completion_local = zif_completion_get_child (completion);
-
- /* download from the store */
- ret = zif_store_remote_download (store_remote, zif_string_get_value (package->priv->location_href), directory, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "cannot download from store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- if (store_remote != NULL)
- g_object_unref (store_remote);
- return ret;
-}
-
-/**
- * zif_package_get_update_detail:
- * @package: the #ZifPackage object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the update detail for a package.
- *
- * Return value: a %ZifUpdate, or %NULL for failure
- *
- * Since: 0.0.1
- **/
-ZifUpdate *
-zif_package_get_update_detail (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifUpdate *update = NULL;
- ZifStoreRemote *store_remote = NULL;
- GError *error_local = NULL;
- ZifCompletion *completion_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
-
- /* check we are not installed */
- if (package->priv->installed) {
- g_set_error_literal (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "cannot get details for installed packages");
- goto out;
- }
-
- /* two steps */
- zif_completion_set_number_steps (completion, 2);
-
- /* find correct repo */
- completion_local = zif_completion_get_child (completion);
- store_remote = zif_package_get_store_for_package (package, cancellable, completion_local, &error_local);
- if (store_remote == NULL) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "cannot find remote store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* download from the store */
- completion_local = zif_completion_get_child (completion);
- update = zif_store_remote_get_update_detail (store_remote, package->priv->package_id, cancellable, completion_local, &error_local);
- if (update == NULL) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "cannot get update detail from store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- if (store_remote != NULL)
- g_object_unref (store_remote);
- return update;
-}
-
-/**
- * zif_package_print:
- * @package: the #ZifPackage object
- *
- * Prints details about a package to %STDOUT.
- *
- * Since: 0.0.1
- **/
-void
-zif_package_print (ZifPackage *package)
-{
- guint i;
- gchar *text;
- const ZifDepend *depend;
- GPtrArray *array;
-
- g_return_if_fail (ZIF_IS_PACKAGE (package));
- g_return_if_fail (package->priv->package_id_split != NULL);
-
- g_print ("id=%s\n", package->priv->package_id);
- g_print ("summary=%s\n", zif_string_get_value (package->priv->summary));
- g_print ("description=%s\n", zif_string_get_value (package->priv->description));
- g_print ("license=%s\n", zif_string_get_value (package->priv->license));
- g_print ("group=%s\n", pk_group_enum_to_text (package->priv->group));
- g_print ("category=%s\n", zif_string_get_value (package->priv->category));
- if (package->priv->url != NULL)
- g_print ("url=%s\n", zif_string_get_value (package->priv->url));
- g_print ("size=%"G_GUINT64_FORMAT"\n", package->priv->size);
-
- if (package->priv->files != NULL) {
- g_print ("files:\n");
- array = package->priv->files;
- for (i=0; i<array->len; i++)
- g_print ("\t%s\n", (const gchar *) g_ptr_array_index (array, i));
- }
- if (package->priv->requires != NULL) {
- g_print ("requires:\n");
- array = package->priv->requires;
- for (i=0; i<array->len; i++) {
- depend = g_ptr_array_index (array, i);
- text = zif_depend_to_string (depend);
- g_print ("\t%s\n", text);
- g_free (text);
- }
- }
- if (package->priv->provides != NULL) {
- g_print ("provides:\n");
- array = package->priv->provides;
- for (i=0; i<array->len; i++) {
- depend = g_ptr_array_index (array, i);
- text = zif_depend_to_string (depend);
- g_print ("\t%s\n", text);
- g_free (text);
- }
- }
-}
-
-/**
- * zif_package_is_devel:
- * @package: the #ZifPackage object
- *
- * Finds out if a package is a development package.
- *
- * Return value: %TRUE or %FALSE
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_is_devel (ZifPackage *package)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (package->priv->package_id_split != NULL, FALSE);
-
- if (g_str_has_suffix (package->priv->package_id_split[PK_PACKAGE_ID_NAME], "-debuginfo"))
- return TRUE;
- if (g_str_has_suffix (package->priv->package_id_split[PK_PACKAGE_ID_NAME], "-devel"))
- return TRUE;
- if (g_str_has_suffix (package->priv->package_id_split[PK_PACKAGE_ID_NAME], "-static"))
- return TRUE;
- if (g_str_has_suffix (package->priv->package_id_split[PK_PACKAGE_ID_NAME], "-libs"))
- return TRUE;
- return FALSE;
-}
-
-/**
- * zif_package_is_gui:
- * @package: the #ZifPackage object
- *
- * Finds out if a package is a GUI package.
- *
- * Return value: %TRUE or %FALSE
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_is_gui (ZifPackage *package)
-{
- gboolean ret = FALSE;
- guint i;
- const ZifDepend *depend;
- GPtrArray *array;
- ZifCompletion *completion_tmp;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (package->priv->package_id_split != NULL, FALSE);
-
- /* get list of requires */
- completion_tmp = zif_completion_new ();
- array = zif_package_get_requires (package, NULL, completion_tmp, NULL);
- if (array == NULL)
- goto out;
- for (i=0; i<array->len; i++) {
- depend = g_ptr_array_index (array, i);
- if (g_strstr_len (depend->name, -1, "gtk") != NULL ||
- g_strstr_len (depend->name, -1, "kde") != NULL) {
- ret = TRUE;
- break;
- }
- }
- g_ptr_array_unref (array);
-out:
- g_object_unref (completion_tmp);
- return ret;
-}
-
-/**
- * zif_package_is_installed:
- * @package: the #ZifPackage object
- *
- * Finds out if a package is installed.
- *
- * Return value: %TRUE or %FALSE
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_is_installed (ZifPackage *package)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (package->priv->package_id_split != NULL, FALSE);
- return package->priv->installed;
-}
-
-/**
- * zif_package_is_native:
- * @package: the #ZifPackage object
- *
- * Finds out if a package is the native architecture for the system.
- *
- * Return value: %TRUE or %FALSE
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_is_native (ZifPackage *package)
-{
- gchar **array;
- guint i;
- const gchar *arch;
- gboolean ret = FALSE;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (package->priv->package_id_split != NULL, FALSE);
-
- /* is package in arch array */
- arch = package->priv->package_id_split[PK_PACKAGE_ID_ARCH];
- array = zif_config_get_basearch_array (package->priv->config);
- for (i=0; array[i] != NULL; i++) {
- if (g_strcmp0 (array[i], arch) == 0) {
- ret = TRUE;
- break;
- }
- }
- return ret;
-}
-
-/**
- * zif_package_is_free:
- * @package: the #ZifPackage object
- *
- * Check the string license_text for free licenses, indicated by
- * their short names as documented at
- * http://fedoraproject.org/wiki/Licensing
- *
- * Licenses can be grouped by " or " to indicate that the package
- * can be redistributed under any of the licenses in the group.
- * For instance: GPLv2+ or Artistic or FooLicense.
- *
- * Also, if a license ends with "+", the "+" is removed before
- * comparing it to the list of valid licenses. So if license
- * "FooLicense" is free, then "FooLicense+" is considered free.
- *
- * Groups of licenses can be grouped with " and " to indicate
- * that parts of the package are distributed under one group of
- * licenses, while other parts of the package are distributed
- * under another group. Groups may be wrapped in parenthesis.
- * For instance:
- * (GPLv2+ or Artistic) and (GPL+ or Artistic) and FooLicense.
- *
- * At least one license in each group must be free for the
- * package to be considered Free Software. If the license_text
- * is empty, the package is considered non-free.
- *
- * Return value: %TRUE or %FALSE
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_is_free (ZifPackage *package)
-{
- gboolean one_free_group = FALSE;
- gboolean group_is_free;
- gchar **groups;
- gchar **licenses;
- guint i;
- guint j;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (package->priv->package_id_split != NULL, FALSE);
-
- /* split AND clase */
- groups = g_strsplit (zif_string_get_value (package->priv->license), " and ", 0);
- for (i=0; groups[i] != NULL; i++) {
- /* remove grouping */
- g_strdelimit (groups[i], "()", ' ');
-
- /* split OR clase */
- licenses = g_strsplit (groups[i], " or ", 0);
-
- group_is_free = FALSE;
- for (j=0; licenses[j] != NULL; j++) {
-
- /* remove 'and later' */
- g_strdelimit (licenses[j], "+", ' ');
- g_strstrip (licenses[j]);
-
- /* nothing to process */
- if (licenses[j][0] == '\0')
- continue;
-
- /* a valid free license */
- if (pk_license_enum_from_text (licenses[j]) != PK_LICENSE_ENUM_UNKNOWN) {
- one_free_group = TRUE;
- group_is_free = TRUE;
- break;
- }
- }
- g_strfreev (licenses);
-
- if (!group_is_free)
- return FALSE;
- }
- g_strfreev (groups);
-
- if (!one_free_group)
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * zif_package_get_id:
- * @package: the #ZifPackage object
- *
- * Gets the id uniquely identifying the package in all repos.
- *
- * Return value: the PackageId representing the package.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_get_id (ZifPackage *package)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id != NULL, NULL);
- return package->priv->package_id;
-}
-
-/**
- * zif_package_get_name:
- * @package: the #ZifPackage object
- *
- * Gets the package name.
- *
- * Return value: the package name.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_get_name (ZifPackage *package)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id != NULL, NULL);
- return package->priv->package_id_split[PK_PACKAGE_ID_NAME];
-}
-
-/**
- * zif_package_get_package_id:
- * @package: the #ZifPackage object
- *
- * Gets the id (as text) uniquely identifying the package in all repos.
- *
- * Return value: The %package_id representing the package.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_get_package_id (ZifPackage *package)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
- return package->priv->package_id;
-}
-
-/**
- * zif_package_ensure_type_to_string:
- * @type: the #ZifPackageEnsureType enumerated value
- *
- * Gets the string representation of a #ZifPackageEnsureType
- *
- * Return value: The #ZifPackageEnsureType represented as a string
- **/
-const gchar *
-zif_package_ensure_type_to_string (ZifPackageEnsureType type)
-{
- if (type == ZIF_PACKAGE_ENSURE_TYPE_FILES)
- return "files";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_SUMMARY)
- return "summary";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_LICENCE)
- return "licence";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_DESCRIPTION)
- return "description";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_URL)
- return "url";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_SIZE)
- return "size";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_GROUP)
- return "group";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_REQUIRES)
- return "requires";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_PROVIDES)
- return "provides";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_CONFLICTS)
- return "conflicts";
- if (type == ZIF_PACKAGE_ENSURE_TYPE_OBSOLETES)
- return "obsoletes";
- return "unknown";
-}
-
-/**
- * zif_package_ensure_data:
- **/
-static gboolean
-zif_package_ensure_data (ZifPackage *package, ZifPackageEnsureType type,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- ZifPackageClass *klass = ZIF_PACKAGE_GET_CLASS (package);
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* no support */
- if (klass->ensure_data == NULL) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "cannot ensure data for %s data", zif_package_ensure_type_to_string (type));
- goto out;
- }
-
- ret = klass->ensure_data (package, type, cancellable, completion, error);
-out:
- return ret;
-}
-
-/**
- * zif_package_get_summary:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the package summary.
- *
- * Return value: the const string or %NULL
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_get_summary (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* not exists */
- if (package->priv->summary == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_SUMMARY, cancellable, completion, error);
- if (!ret)
- return NULL;
- }
-
- /* return const string */
- return zif_string_get_value (package->priv->summary);
-}
-
-/**
- * zif_package_get_description:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the package description.
- *
- * Return value: the const string or %NULL
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_get_description (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* not exists */
- if (package->priv->description == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_DESCRIPTION, cancellable, completion, error);
- if (!ret)
- return NULL;
- }
-
- /* return const string */
- return zif_string_get_value (package->priv->description);
-}
-
-/**
- * zif_package_get_license:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the package licence.
- *
- * Return value: the const string or %NULL
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_get_license (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* not exists */
- if (package->priv->license == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_LICENCE, cancellable, completion, error);
- if (!ret)
- return NULL;
- }
-
- /* return const string */
- return zif_string_get_value (package->priv->license);
-}
-
-/**
- * zif_package_get_url:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the homepage URL for the package.
- *
- * Return value: the const string or %NULL
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_get_url (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* not exists */
- if (package->priv->url == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_URL, cancellable, completion, error);
- if (!ret)
- return NULL;
- }
-
- /* return const string */
- return zif_string_get_value (package->priv->url);
-}
-
-/**
- * zif_package_get_filename:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the remote filename for the package, e.g. Packages/net-snmp-5.4.2-3.fc10.i386.rpm
- *
- * Return value: the const string or %NULL
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_get_filename (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* doesn't make much sense */
- if (package->priv->installed) {
- g_set_error_literal (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "cannot get remote filename for installed package");
- return NULL;
- }
-
- /* not exists */
- if (package->priv->location_href == NULL) {
- g_set_error (error, ZIF_PACKAGE_ERROR, ZIF_PACKAGE_ERROR_FAILED,
- "no data for %s", package->priv->package_id_split[PK_PACKAGE_ID_NAME]);
- return NULL;
- }
-
- /* return const string */
- return zif_string_get_value (package->priv->location_href);
-}
-
-/**
- * zif_package_get_category:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the category the packag is in.
- *
- * Return value: the const string or %NULL
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_package_get_category (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* not exists */
- if (package->priv->category == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_CATEGORY, cancellable, completion, error);
- if (!ret)
- return NULL;
- }
-
- /* return const string */
- return zif_string_get_value (package->priv->category);
-}
-
-/**
- * zif_package_get_group:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the package group.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-PkGroupEnum
-zif_package_get_group (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), 0);
- g_return_val_if_fail (error == NULL || *error == NULL, 0);
-
- /* not exists */
- if (package->priv->group == PK_GROUP_ENUM_UNKNOWN) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_GROUP, cancellable, completion, error);
- if (!ret)
- return PK_GROUP_ENUM_UNKNOWN;
- }
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), PK_GROUP_ENUM_UNKNOWN);
- g_return_val_if_fail (package->priv->package_id_split != NULL, PK_GROUP_ENUM_UNKNOWN);
- return package->priv->group;
-}
-
-/**
- * zif_package_get_size:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the size of the package.
- * This is the installed size for installed packages, and the download size for
- * remote packages.
- *
- * Return value: the package size, or 0 for failure
- *
- * Since: 0.0.1
- **/
-guint64
-zif_package_get_size (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), 0);
- g_return_val_if_fail (error == NULL || *error == NULL, 0);
-
- if (package->priv->size == 0) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_SIZE, cancellable, completion, error);
- if (!ret)
- return 0;
- }
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), 0);
- g_return_val_if_fail (package->priv->package_id_split != NULL, 0);
- return package->priv->size;
-}
-
-/**
- * zif_package_get_files:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the file list for the package.
- *
- * Return value: the reference counted #GPtrArray, use g_ptr_array_unref() when done
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_package_get_files (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* not exists */
- if (package->priv->files == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_FILES, cancellable, completion, error);
- if (!ret)
- return NULL;
- }
-
- /* return refcounted */
- return g_ptr_array_ref (package->priv->files);
-}
-
-/**
- * zif_package_get_requires:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets all the package requires.
- *
- * Return value: the reference counted #GPtrArray, use g_ptr_array_unref() when done
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_package_get_requires (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* not exists */
- if (package->priv->requires == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_REQUIRES, cancellable, completion, error);
- if (!ret)
- return NULL;
- }
-
- /* return refcounted */
- return g_ptr_array_ref (package->priv->requires);
-}
-
-/**
- * zif_package_get_provides:
- * @package: the #ZifPackage object
- * @error: a #GError which is used on failure, or %NULL
- *
- * Get all the package provides.
- *
- * Return value: the reference counted #GPtrArray, use g_ptr_array_unref() when done
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_package_get_provides (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
- g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* not exists */
- if (package->priv->provides == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_PROVIDES, cancellable, completion, error);
- if (!ret)
- return NULL;
- }
-
- /* return refcounted */
- return g_ptr_array_ref (package->priv->provides);
-}
-
-/**
- * zif_package_set_installed:
- * @package: the #ZifPackage object
- * @installed: If the package is installed
- *
- * Sets the package installed status.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_installed (ZifPackage *package, gboolean installed)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- package->priv->installed = installed;
- return TRUE;
-}
-
-/**
- * zif_package_set_id:
- * @package: the #ZifPackage object
- * @package_id: A PackageId defining the object
- *
- * Sets the unique id for the package.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_id (ZifPackage *package, const gchar *package_id)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (package_id != NULL, FALSE);
- g_return_val_if_fail (package->priv->package_id == NULL, FALSE);
-
- package->priv->package_id = g_strdup (package_id);
- package->priv->package_id_split = pk_package_id_split (package_id);
- return TRUE;
-}
-
-/**
- * zif_package_set_summary:
- * @package: the #ZifPackage object
- * @summary: the package summary
- *
- * Sets the package summary.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_summary (ZifPackage *package, ZifString *summary)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (summary != NULL, FALSE);
- g_return_val_if_fail (package->priv->summary == NULL, FALSE);
-
- package->priv->summary = zif_string_ref (summary);
- return TRUE;
-}
-
-/**
- * zif_package_set_description:
- * @package: the #ZifPackage object
- * @description: the package description
- *
- * Sets the package description.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_description (ZifPackage *package, ZifString *description)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (description != NULL, FALSE);
- g_return_val_if_fail (package->priv->description == NULL, FALSE);
-
- package->priv->description = zif_string_ref (description);
- return TRUE;
-}
-
-/**
- * zif_package_set_license:
- * @package: the #ZifPackage object
- * @license: license
- *
- * Sets the package license.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_license (ZifPackage *package, ZifString *license)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (license != NULL, FALSE);
- g_return_val_if_fail (package->priv->license == NULL, FALSE);
-
- package->priv->license = zif_string_ref (license);
- return TRUE;
-}
-
-/**
- * zif_package_set_url:
- * @package: the #ZifPackage object
- * @url: The package homepage URL
- *
- * Sets the project homepage URL.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_url (ZifPackage *package, ZifString *url)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (url != NULL, FALSE);
- g_return_val_if_fail (package->priv->url == NULL, FALSE);
-
- package->priv->url = zif_string_ref (url);
- return TRUE;
-}
-
-/**
- * zif_package_set_location_href:
- * @package: the #ZifPackage object
- * @location_href: the remote download filename
- *
- * Sets the remote download location.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_location_href (ZifPackage *package, ZifString *location_href)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (location_href != NULL, FALSE);
- g_return_val_if_fail (package->priv->location_href == NULL, FALSE);
-
- package->priv->location_href = zif_string_ref (location_href);
- return TRUE;
-}
-
-/**
- * zif_package_set_category:
- * @package: the #ZifPackage object
- * @category: category
- *
- * Sets the package category.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_category (ZifPackage *package, ZifString *category)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (category != NULL, FALSE);
- g_return_val_if_fail (package->priv->category == NULL, FALSE);
-
- package->priv->category = zif_string_ref (category);
- return TRUE;
-}
-
-/**
- * zif_package_set_group:
- * @package: the #ZifPackage object
- * @group: the package group
- *
- * Sets the package group.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_group (ZifPackage *package, PkGroupEnum group)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (group != PK_GROUP_ENUM_UNKNOWN, FALSE);
- g_return_val_if_fail (package->priv->group == PK_GROUP_ENUM_UNKNOWN, FALSE);
-
- package->priv->group = group;
- return TRUE;
-}
-
-/**
- * zif_package_set_size:
- * @package: the #ZifPackage object
- * @size: the package size in bytes
- *
- * Sets the package size in bytes.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_size (ZifPackage *package, guint64 size)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (size != 0, FALSE);
- g_return_val_if_fail (package->priv->size == 0, FALSE);
-
- package->priv->size = size;
- return TRUE;
-}
-
-/**
- * zif_package_set_files:
- * @package: the #ZifPackage object
- * @files: the package filelist
- *
- * Sets the package file list.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_files (ZifPackage *package, GPtrArray *files)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (files != NULL, FALSE);
- g_return_val_if_fail (package->priv->files == NULL, FALSE);
-
- package->priv->files = g_ptr_array_ref (files);
- return TRUE;
-}
-
-/**
- * zif_package_set_requires:
- * @package: the #ZifPackage object
- * @requires: the package requires
- *
- * Sets the package requires.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_requires (ZifPackage *package, GPtrArray *requires)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (requires != NULL, FALSE);
- g_return_val_if_fail (package->priv->requires == NULL, FALSE);
-
- package->priv->requires = g_ptr_array_ref (requires);
- return TRUE;
-}
-
-/**
- * zif_package_set_provides:
- * @package: the #ZifPackage object
- * @provides: the package provides
- *
- * Sets the package provides
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_package_set_provides (ZifPackage *package, GPtrArray *provides)
-{
- g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
- g_return_val_if_fail (provides != NULL, FALSE);
- g_return_val_if_fail (package->priv->provides == NULL, FALSE);
-
- package->priv->provides = g_ptr_array_ref (provides);
- return TRUE;
-}
-
-/**
- * zif_package_finalize:
- **/
-static void
-zif_package_finalize (GObject *object)
-{
- ZifPackage *package;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_PACKAGE (object));
- package = ZIF_PACKAGE (object);
-
- g_free (package->priv->package_id_split);
- g_free (package->priv->package_id);
- if (package->priv->summary != NULL)
- zif_string_unref (package->priv->summary);
- if (package->priv->description != NULL)
- zif_string_unref (package->priv->description);
- if (package->priv->license != NULL)
- zif_string_unref (package->priv->license);
- if (package->priv->url != NULL)
- zif_string_unref (package->priv->url);
- if (package->priv->category != NULL)
- zif_string_unref (package->priv->category);
- if (package->priv->location_href != NULL)
- zif_string_unref (package->priv->location_href);
- if (package->priv->files != NULL)
- g_ptr_array_unref (package->priv->files);
- if (package->priv->requires != NULL)
- g_ptr_array_unref (package->priv->requires);
- if (package->priv->provides != NULL)
- g_ptr_array_unref (package->priv->provides);
- g_object_unref (package->priv->repos);
- g_object_unref (package->priv->groups);
- g_object_unref (package->priv->config);
-
- G_OBJECT_CLASS (zif_package_parent_class)->finalize (object);
-}
-
-/**
- * zif_package_class_init:
- **/
-static void
-zif_package_class_init (ZifPackageClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_package_finalize;
- g_type_class_add_private (klass, sizeof (ZifPackagePrivate));
-}
-
-/**
- * zif_package_init:
- **/
-static void
-zif_package_init (ZifPackage *package)
-{
- package->priv = ZIF_PACKAGE_GET_PRIVATE (package);
- package->priv->package_id_split = NULL;
- package->priv->package_id = NULL;
- package->priv->summary = NULL;
- package->priv->description = NULL;
- package->priv->license = NULL;
- package->priv->url = NULL;
- package->priv->category = NULL;
- package->priv->files = NULL;
- package->priv->requires = NULL;
- package->priv->provides = NULL;
- package->priv->location_href = NULL;
- package->priv->installed = FALSE;
- package->priv->group = PK_GROUP_ENUM_UNKNOWN;
- package->priv->size = 0;
- package->priv->repos = zif_repos_new ();
- package->priv->groups = zif_groups_new ();
- package->priv->config = zif_config_new ();
-}
-
-/**
- * zif_package_new:
- *
- * Return value: A new #ZifPackage class instance.
- *
- * Since: 0.0.1
- **/
-ZifPackage *
-zif_package_new (void)
-{
- ZifPackage *package;
- package = g_object_new (ZIF_TYPE_PACKAGE, NULL);
- return ZIF_PACKAGE (package);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_package_test (EggTest *test)
-{
- ZifPackage *package;
-
- if (!egg_test_start (test, "ZifPackage"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get package");
- package = zif_package_new ();
- egg_test_assert (test, package != NULL);
-
- g_object_unref (package);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-package.h b/backends/yum/libzif/zif-package.h
deleted file mode 100644
index bd5ef2f..0000000
--- a/backends/yum/libzif/zif-package.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008-2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_PACKAGE_H
-#define __ZIF_PACKAGE_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-string.h"
-#include "zif-completion.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_PACKAGE (zif_package_get_type ())
-#define ZIF_PACKAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_PACKAGE, ZifPackage))
-#define ZIF_PACKAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_PACKAGE, ZifPackageClass))
-#define ZIF_IS_PACKAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_PACKAGE))
-#define ZIF_IS_PACKAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_PACKAGE))
-#define ZIF_PACKAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_PACKAGE, ZifPackageClass))
-#define ZIF_PACKAGE_ERROR (zif_package_error_quark ())
-
-typedef struct _ZifPackage ZifPackage;
-typedef struct _ZifPackagePrivate ZifPackagePrivate;
-typedef struct _ZifPackageClass ZifPackageClass;
-
-#include "zif-update.h"
-
-typedef enum {
- ZIF_PACKAGE_ENSURE_TYPE_FILES,
- ZIF_PACKAGE_ENSURE_TYPE_SUMMARY,
- ZIF_PACKAGE_ENSURE_TYPE_LICENCE,
- ZIF_PACKAGE_ENSURE_TYPE_DESCRIPTION,
- ZIF_PACKAGE_ENSURE_TYPE_URL,
- ZIF_PACKAGE_ENSURE_TYPE_SIZE,
- ZIF_PACKAGE_ENSURE_TYPE_GROUP,
- ZIF_PACKAGE_ENSURE_TYPE_CATEGORY,
- ZIF_PACKAGE_ENSURE_TYPE_REQUIRES,
- ZIF_PACKAGE_ENSURE_TYPE_PROVIDES,
- ZIF_PACKAGE_ENSURE_TYPE_CONFLICTS,
- ZIF_PACKAGE_ENSURE_TYPE_OBSOLETES,
- ZIF_PACKAGE_ENSURE_TYPE_LAST
-} ZifPackageEnsureType;
-
-struct _ZifPackage
-{
- GObject parent;
- ZifPackagePrivate *priv;
-};
-
-struct _ZifPackageClass
-{
- GObjectClass parent_class;
-
- /* vtable */
- gboolean (*ensure_data) (ZifPackage *package,
- ZifPackageEnsureType type,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-};
-
-typedef enum {
- ZIF_PACKAGE_ERROR_FAILED,
- ZIF_PACKAGE_ERROR_LAST
-} ZifPackageError;
-
-GType zif_package_get_type (void);
-GQuark zif_package_error_quark (void);
-ZifPackage *zif_package_new (void);
-
-/* public getters */
-const gchar *zif_package_get_id (ZifPackage *package);
-const gchar *zif_package_get_name (ZifPackage *package);
-const gchar *zif_package_get_summary (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-const gchar *zif_package_get_description (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-const gchar *zif_package_get_license (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-const gchar *zif_package_get_url (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-const gchar *zif_package_get_filename (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-const gchar *zif_package_get_category (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-PkGroupEnum zif_package_get_group (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-guint64 zif_package_get_size (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_package_get_files (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_package_get_requires (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_package_get_provides (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-/* internal setters: TODO, in seporate -internal header file */
-gboolean zif_package_set_installed (ZifPackage *package,
- gboolean installed);
-gboolean zif_package_set_id (ZifPackage *package,
- const gchar *package_id);
-gboolean zif_package_set_summary (ZifPackage *package,
- ZifString *summary);
-gboolean zif_package_set_description (ZifPackage *package,
- ZifString *description);
-gboolean zif_package_set_license (ZifPackage *package,
- ZifString *license);
-gboolean zif_package_set_url (ZifPackage *package,
- ZifString *url);
-gboolean zif_package_set_location_href (ZifPackage *package,
- ZifString *location_href);
-gboolean zif_package_set_category (ZifPackage *package,
- ZifString *category);
-gboolean zif_package_set_group (ZifPackage *package,
- PkGroupEnum group);
-gboolean zif_package_set_size (ZifPackage *package,
- guint64 size);
-gboolean zif_package_set_files (ZifPackage *package,
- GPtrArray *files);
-gboolean zif_package_set_requires (ZifPackage *package,
- GPtrArray *requires);
-gboolean zif_package_set_provides (ZifPackage *package,
- GPtrArray *provides);
-/* actions */
-gboolean zif_package_download (ZifPackage *package,
- const gchar *directory,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-ZifUpdate *zif_package_get_update_detail (ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-const gchar *zif_package_get_package_id (ZifPackage *package);
-void zif_package_print (ZifPackage *package);
-gboolean zif_package_is_devel (ZifPackage *package);
-gboolean zif_package_is_gui (ZifPackage *package);
-gboolean zif_package_is_installed (ZifPackage *package);
-gboolean zif_package_is_free (ZifPackage *package);
-gboolean zif_package_is_native (ZifPackage *package);
-gint zif_package_compare (ZifPackage *a,
- ZifPackage *b);
-ZifPackage *zif_package_array_get_newest (GPtrArray *array,
- GError **error);
-gboolean zif_package_array_filter_newest (GPtrArray *packages);
-const gchar *zif_package_ensure_type_to_string (ZifPackageEnsureType type);
-
-G_END_DECLS
-
-#endif /* __ZIF_PACKAGE_H */
-
diff --git a/backends/yum/libzif/zif-repos.c b/backends/yum/libzif/zif-repos.c
deleted file mode 100644
index ea8cc67..0000000
--- a/backends/yum/libzif/zif-repos.c
+++ /dev/null
@@ -1,637 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-repos
- * @short_description: A #ZifRepos object manages software sources
- *
- * A #ZifRepos is an object that allows easy interfacing with remote
- * repositories.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-
-#include "zif-config.h"
-#include "zif-completion.h"
-#include "zif-store-remote.h"
-#include "zif-repos.h"
-#include "zif-utils.h"
-#include "zif-monitor.h"
-
-#include "egg-debug.h"
-
-#define ZIF_REPOS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_REPOS, ZifReposPrivate))
-
-struct _ZifReposPrivate
-{
- gboolean loaded;
- gchar *repos_dir;
- ZifMonitor *monitor;
- GPtrArray *list;
- GPtrArray *enabled;
-};
-
-G_DEFINE_TYPE (ZifRepos, zif_repos, G_TYPE_OBJECT)
-static gpointer zif_repos_object = NULL;
-
-/**
- * zif_repos_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_repos_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_repos_error");
- return quark;
-}
-
-/**
- * zif_repos_set_repos_dir:
- * @repos: the #ZifRepos object
- * @repos_dir: the directory, e.g. "/etc/yum.repos.d"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Set the repository directory.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_repos_set_repos_dir (ZifRepos *repos, const gchar *repos_dir, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_REPOS (repos), FALSE);
- g_return_val_if_fail (repos->priv->repos_dir == NULL, FALSE);
- g_return_val_if_fail (!repos->priv->loaded, FALSE);
- g_return_val_if_fail (repos_dir != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* check directory exists */
- ret = g_file_test (repos_dir, G_FILE_TEST_IS_DIR);
- if (!ret) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "repo directory %s does not exist", repos_dir);
- goto out;
- }
-
- /* setup watch */
- ret = zif_monitor_add_watch (repos->priv->monitor, repos_dir, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to setup watch: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- repos->priv->repos_dir = g_strdup (repos_dir);
-out:
- return ret;
-}
-
-/**
- * zif_repos_get_for_filename:
- **/
-static gboolean
-zif_repos_get_for_filename (ZifRepos *repos, const gchar *filename, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GError *error_local = NULL;
- GKeyFile *file;
- gchar **repos_groups = NULL;
- ZifStoreRemote *store;
- ZifCompletion *completion_local;
- gboolean ret;
- gchar *path;
- guint i;
-
- /* find all the id's in this file */
- file = g_key_file_new ();
- path = g_build_filename (repos->priv->repos_dir, filename, NULL);
- ret = g_key_file_load_from_file (file, path, G_KEY_FILE_NONE, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to load %s: %s", path, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* for each group, add a store object */
- repos_groups = g_key_file_get_groups (file, NULL);
-
- /* set number of stores */
- zif_completion_set_number_steps (completion, g_strv_length (repos_groups));
-
- /* create each repo */
- for (i=0; repos_groups[i] != NULL; i++) {
- store = zif_store_remote_new ();
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_set_from_file (store, path, repos_groups[i], cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to set from %s: %s", path, error_local->message);
- g_error_free (error_local);
- break;
- }
- g_ptr_array_add (repos->priv->list, store);
-
- /* this section done */
- zif_completion_done (completion);
- }
-out:
- g_strfreev (repos_groups);
- g_free (path);
- g_key_file_free (file);
- return ret;
-}
-
-/**
- * zif_repos_load:
- * @repos: the #ZifRepos object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Load the repository, and parse it's config file.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_repos_load (ZifRepos *repos, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = TRUE;
- ZifStoreRemote *store;
- ZifCompletion *completion_local;
- GError *error_local = NULL;
- GDir *dir;
- const gchar *filename;
- guint i;
- GPtrArray *repofiles = NULL;
-
- g_return_val_if_fail (ZIF_IS_REPOS (repos), FALSE);
- g_return_val_if_fail (repos->priv->repos_dir != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* already loaded */
- if (repos->priv->loaded)
- goto out;
-
- /* search repos dir */
- dir = g_dir_open (repos->priv->repos_dir, 0, &error_local);
- if (dir == NULL) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to list directory: %s", error_local->message);
- g_error_free (error_local);
- ret = FALSE;
- goto out;
- }
-
- /* find the repo files we care about */
- repofiles = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- filename = g_dir_read_name (dir);
- while (filename != NULL) {
- if (g_str_has_suffix (filename, ".repo"))
- g_ptr_array_add (repofiles, g_strdup (filename));
- filename = g_dir_read_name (dir);
- }
- g_dir_close (dir);
-
- /* setup completion with the correct number of steps */
- zif_completion_set_number_steps (completion, repofiles->len + 1);
-
- /* for each repo files */
- for (i=0; i < repofiles->len; i++) {
-
- /* setup watch */
- filename = g_ptr_array_index (repofiles, i);
- ret = zif_monitor_add_watch (repos->priv->monitor, filename, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to setup watch: %s", error_local->message);
- g_error_free (error_local);
- break;
- }
-
- /* add all repos for filename */
- completion_local = zif_completion_get_child (completion);
- ret = zif_repos_get_for_filename (repos, filename, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to get filename %s: %s", filename, error_local->message);
- g_error_free (error_local);
- g_ptr_array_set_size (repos->priv->list, 0);
- ret = FALSE;
- break;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* we failed one file, abandon attempt */
- if (!ret)
- goto out;
-
- /* find enabled */
- for (i=0; i<repos->priv->list->len; i++) {
- store = g_ptr_array_index (repos->priv->list, i);
-
- /* get repo enabled state */
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_get_enabled (store, cancellable, completion_local, &error_local);
- if (error_local != NULL) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to get repo state for %s: %s", zif_store_get_id (ZIF_STORE (store)), error_local->message);
- g_ptr_array_set_size (repos->priv->enabled, 0);
- ret = FALSE;
- goto out;
- }
-
- /* if enabled, add to array */
- if (ret)
- g_ptr_array_add (repos->priv->enabled, g_object_ref (store));
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* all loaded okay */
- repos->priv->loaded = TRUE;
- ret = TRUE;
-
-out:
- if (repofiles != NULL)
- g_ptr_array_unref (repofiles);
- return ret;
-}
-
-/**
- * zif_repos_get_stores:
- * @repos: the #ZifRepos object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the enabled and disabled remote stores.
- *
- * Return value: a list of #ZifStore's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_repos_get_stores (ZifRepos *repos, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- GError *error_local = NULL;
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_REPOS (repos), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!repos->priv->loaded) {
- ret = zif_repos_load (repos, cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to load repos: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* make a copy */
- array = g_ptr_array_ref (repos->priv->list);
-out:
- return array;
-}
-
-/**
- * zif_repos_get_stores_enabled:
- * @repos: the #ZifRepos object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the enabled remote stores.
- *
- * Return value: a list of #ZifStore's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_repos_get_stores_enabled (ZifRepos *repos, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array = NULL;
- GError *error_local = NULL;
- ZifStoreRemote *store;
- gboolean ret;
- guint i;
-
- g_return_val_if_fail (ZIF_IS_REPOS (repos), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!repos->priv->loaded) {
- ret = zif_repos_load (repos, cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to load enabled repos: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* make a copy */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0; i<repos->priv->enabled->len; i++) {
- store = g_ptr_array_index (repos->priv->enabled, i);
- g_ptr_array_add (array, g_object_ref (store));
- }
-out:
- return array;
-}
-
-/**
- * zif_repos_get_store:
- * @repos: the #ZifRepos object
- * @id: the repository id, e.g. "fedora"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the store matching the ID.
- *
- * Return value: A #ZifStoreRemote object, or %NULL
- *
- * Since: 0.0.1
- **/
-ZifStoreRemote *
-zif_repos_get_store (ZifRepos *repos, const gchar *id, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- ZifStoreRemote *store = NULL;
- ZifStoreRemote *store_tmp;
- const gchar *id_tmp;
- GError *error_local = NULL;
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_REPOS (repos), NULL);
- g_return_val_if_fail (id != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if not already loaded, load */
- if (!repos->priv->loaded) {
- ret = zif_repos_load (repos, cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to load repos: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* search though all the cached repos */
- for (i=0; i<repos->priv->list->len; i++) {
- store_tmp = g_ptr_array_index (repos->priv->list, i);
-
- /* get the id */
- id_tmp = zif_store_get_id (ZIF_STORE (store_tmp));
- if (id_tmp == NULL) {
- g_set_error_literal (error, ZIF_REPOS_ERROR, ZIF_REPOS_ERROR_FAILED,
- "failed to get id");
- goto out;
- }
-
- /* is it what we want? */
- if (strcmp (id_tmp, id) == 0) {
- store = g_object_ref (store_tmp);
- break;
- }
- }
-out:
- return store;
-}
-
-/**
- * zif_repos_file_monitor_cb:
- **/
-static void
-zif_repos_file_monitor_cb (ZifMonitor *monitor, ZifRepos *repos)
-{
- g_ptr_array_set_size (repos->priv->list, 0);
- g_ptr_array_set_size (repos->priv->enabled, 0);
- repos->priv->loaded = FALSE;
- egg_debug ("repo file changed");
-}
-
-/**
- * zif_repos_finalize:
- **/
-static void
-zif_repos_finalize (GObject *object)
-{
- ZifRepos *repos;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_REPOS (object));
- repos = ZIF_REPOS (object);
-
- g_object_unref (repos->priv->monitor);
- g_free (repos->priv->repos_dir);
-
- g_ptr_array_unref (repos->priv->list);
- g_ptr_array_unref (repos->priv->enabled);
-
- G_OBJECT_CLASS (zif_repos_parent_class)->finalize (object);
-}
-
-/**
- * zif_repos_class_init:
- **/
-static void
-zif_repos_class_init (ZifReposClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_repos_finalize;
- g_type_class_add_private (klass, sizeof (ZifReposPrivate));
-}
-
-/**
- * zif_repos_init:
- **/
-static void
-zif_repos_init (ZifRepos *repos)
-{
- repos->priv = ZIF_REPOS_GET_PRIVATE (repos);
- repos->priv->repos_dir = NULL;
- repos->priv->list = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- repos->priv->enabled = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- repos->priv->monitor = zif_monitor_new ();
- g_signal_connect (repos->priv->monitor, "changed", G_CALLBACK (zif_repos_file_monitor_cb), repos);
-}
-
-/**
- * zif_repos_new:
- *
- * Return value: A new #ZifRepos class instance.
- *
- * Since: 0.0.1
- **/
-ZifRepos *
-zif_repos_new (void)
-{
- if (zif_repos_object != NULL) {
- g_object_ref (zif_repos_object);
- } else {
- zif_repos_object = g_object_new (ZIF_TYPE_REPOS, NULL);
- g_object_add_weak_pointer (zif_repos_object, &zif_repos_object);
- }
- return ZIF_REPOS (zif_repos_object);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-#include "zif-lock.h"
-
-void
-zif_repos_test (EggTest *test)
-{
- ZifStoreRemote *store;
- ZifConfig *config;
- ZifRepos *repos;
- ZifLock *lock;
- ZifCompletion *completion;
- GPtrArray *array;
- GError *error = NULL;
- const gchar *value;
- guint i;
- gchar *repos_dir;
- gboolean ret;
-
- if (!egg_test_start (test, "ZifRepos"))
- return;
-
- /* set this up as dummy */
- config = zif_config_new ();
- zif_config_set_filename (config, "../test/etc/yum.conf", NULL);
- repos_dir = zif_config_get_string (config, "reposdir", NULL);
-
- /************************************************************/
- egg_test_title (test, "get lock");
- lock = zif_lock_new ();
- egg_test_assert (test, lock != NULL);
-
- /************************************************************/
- egg_test_title (test, "lock");
- ret = zif_lock_set_locked (lock, NULL, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "get repos");
- repos = zif_repos_new ();
- egg_test_assert (test, repos != NULL);
-
- /* use completion object */
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "set repos dir %s", repos_dir);
- ret = zif_repos_set_repos_dir (repos, repos_dir, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set repos dir '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "get list of repos");
- array = zif_repos_get_stores (repos, NULL, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load metadata '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "list correct length");
- if (array->len == 2)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
-
- for (i=0; i<array->len; i++) {
- store = g_ptr_array_index (array, i);
- zif_store_print (ZIF_STORE (store));
- }
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "get list of enabled repos");
- array = zif_repos_get_stores_enabled (repos, NULL, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load metadata '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "enabled correct length");
- if (array->len == 2)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
-
- /* get ref for next test */
- store = g_object_ref (g_ptr_array_index (array, 0));
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "get name");
- value = zif_store_remote_get_name (store, NULL, completion, NULL);
- if (g_strcmp0 (value, "Fedora 11 - i386") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid name '%s'", value);
- g_object_unref (store);
-
- g_object_unref (completion);
- g_object_unref (repos);
- g_object_unref (config);
- g_object_unref (lock);
- g_free (repos_dir);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-repos.h b/backends/yum/libzif/zif-repos.h
deleted file mode 100644
index ee09481..0000000
--- a/backends/yum/libzif/zif-repos.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_REPOS_H
-#define __ZIF_REPOS_H
-
-#include <glib-object.h>
-#include "zif-store-remote.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_REPOS (zif_repos_get_type ())
-#define ZIF_REPOS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_REPOS, ZifRepos))
-#define ZIF_REPOS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_REPOS, ZifReposClass))
-#define ZIF_IS_REPOS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_REPOS))
-#define ZIF_IS_REPOS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_REPOS))
-#define ZIF_REPOS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_REPOS, ZifReposClass))
-#define ZIF_REPOS_ERROR (zif_repos_error_quark ())
-
-typedef struct _ZifRepos ZifRepos;
-typedef struct _ZifReposPrivate ZifReposPrivate;
-typedef struct _ZifReposClass ZifReposClass;
-
-struct _ZifRepos
-{
- GObject parent;
- ZifReposPrivate *priv;
-};
-
-struct _ZifReposClass
-{
- GObjectClass parent_class;
-};
-
-typedef enum {
- ZIF_REPOS_ERROR_FAILED,
- ZIF_REPOS_ERROR_LAST
-} ZifReposError;
-
-GType zif_repos_get_type (void);
-GQuark zif_repos_error_quark (void);
-ZifRepos *zif_repos_new (void);
-gboolean zif_repos_set_repos_dir (ZifRepos *repos,
- const gchar *repos_dir,
- GError **error);
-gboolean zif_repos_load (ZifRepos *repos,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_repos_get_stores (ZifRepos *repos,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_repos_get_stores_enabled (ZifRepos *repos,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-ZifStoreRemote *zif_repos_get_store (ZifRepos *repos,
- const gchar *id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-G_END_DECLS
-
-#endif /* __ZIF_REPOS_H */
-
diff --git a/backends/yum/libzif/zif-store-array.c b/backends/yum/libzif/zif-store-array.c
deleted file mode 100644
index 6542b91..0000000
--- a/backends/yum/libzif/zif-store-array.c
+++ /dev/null
@@ -1,855 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-store-array
- * @short_description: A store-array is a container that holds one or more stores
- *
- * A #GPtrArray is the container where #ZifStore's are kept. Global operations can
- * be done on the array and not the indervidual stores.
- *
- * IMPORTANT: any errors that happen on the ZifStores are fatal unless you're
- * using ZifStoreArrayErrorCb, and it returns TRUE.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-config.h"
-#include "zif-completion.h"
-#include "zif-store.h"
-#include "zif-store-local.h"
-#include "zif-store-array.h"
-#include "zif-package.h"
-#include "zif-utils.h"
-#include "zif-repos.h"
-
-#include "egg-debug.h"
-
-/* in PackageKit we split categories from groups using a special @ prefix (bodge) */
-#define PK_ROLE_ENUM_SEARCH_CATEGORY (PK_ROLE_ENUM_UNKNOWN + 1)
-
-/**
- * zif_store_array_add_store:
- * @store_array: the #GPtrArray of #ZifStores
- * @store: the #ZifStore to add
- *
- * Add a single #ZifStore to the #GPtrArray.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_array_add_store (GPtrArray *store_array, ZifStore *store)
-{
- g_return_val_if_fail (store != NULL, FALSE);
-
- g_ptr_array_add (store_array, g_object_ref (store));
- return TRUE;
-}
-
-/**
- * zif_store_array_add_stores:
- * @store_array: the #GPtrArray of #ZifStores
- * @stores: the array of #ZifStore's to add
- *
- * Add an array of #ZifStore's to the #GPtrArray.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_array_add_stores (GPtrArray *store_array, GPtrArray *stores)
-{
- guint i;
- ZifStore *store;
- gboolean ret = FALSE;
-
- g_return_val_if_fail (stores != NULL, FALSE);
-
- for (i=0; i<stores->len; i++) {
- store = g_ptr_array_index (stores, i);
- ret = zif_store_array_add_store (store_array, store);
- if (!ret)
- break;
- }
- return ret;
-}
-
-/**
- * zif_store_array_add_local:
- * @store_array: the #GPtrArray of #ZifStores
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Convenience function to add local store to the #GPtrArray.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_array_add_local (GPtrArray *store_array, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreLocal *store;
-
- store = zif_store_local_new ();
- zif_store_array_add_store (store_array, ZIF_STORE (store));
- g_object_unref (store);
-
- return TRUE;
-}
-
-/**
- * zif_store_array_add_remote:
- * @store_array: the #GPtrArray of #ZifStores
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Convenience function to add remote stores to the #GPtrArray.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_array_add_remote (GPtrArray *store_array, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array;
- ZifRepos *repos;
- GError *error_local = NULL;
- gboolean ret = TRUE;
-
- /* get stores */
- repos = zif_repos_new ();
- array = zif_repos_get_stores (repos, cancellable, completion, &error_local);
- if (array == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get enabled stores: %s", error_local->message);
- g_error_free (error_local);
- ret = FALSE;
- goto out;
- }
-
- /* add */
- zif_store_array_add_stores (store_array, array);
-
- /* free */
- g_ptr_array_unref (array);
-out:
- g_object_unref (repos);
- return ret;
-}
-
-/**
- * zif_store_array_add_remote_enabled:
- * @store_array: the #GPtrArray of #ZifStores
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Convenience function to add enabled remote stores to the #GPtrArray.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_array_add_remote_enabled (GPtrArray *store_array, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GPtrArray *array;
- ZifRepos *repos;
- GError *error_local = NULL;
- gboolean ret = TRUE;
-
- /* get stores */
- repos = zif_repos_new ();
- array = zif_repos_get_stores_enabled (repos, cancellable, completion, &error_local);
- if (array == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get enabled stores: %s", error_local->message);
- g_error_free (error_local);
- ret = FALSE;
- goto out;
- }
-
- /* add */
- zif_store_array_add_stores (store_array, array);
-
- /* free */
- g_ptr_array_unref (array);
-out:
- g_object_unref (repos);
- return ret;
-}
-
-/**
- * zif_store_array_repos_search:
- **/
-static GPtrArray *
-zif_store_array_repos_search (GPtrArray *store_array, PkRoleEnum role, gchar **search,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i, j;
- GPtrArray *array = NULL;
- GPtrArray *part;
- ZifStore *store;
- ZifPackage *package;
- GError *error_local = NULL;
- ZifCompletion *completion_local = NULL;
-
- /* nothing to do */
- if (store_array->len == 0) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "nothing to do as no stores in store_array");
- goto out;
- }
-
- /* set number of stores */
- zif_completion_set_number_steps (completion, store_array->len);
-
- /* do each one */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0; i<store_array->len; i++) {
- store = g_ptr_array_index (store_array, i);
-
- /* create a chain of completions */
- completion_local = zif_completion_get_child (completion);
-
- /* get results for this store */
- if (role == PK_ROLE_ENUM_RESOLVE)
- part = zif_store_resolve (store, search, cancellable, completion_local, &error_local);
- else if (role == PK_ROLE_ENUM_SEARCH_NAME)
- part = zif_store_search_name (store, search, cancellable, completion_local, &error_local);
- else if (role == PK_ROLE_ENUM_SEARCH_DETAILS)
- part = zif_store_search_details (store, search, cancellable, completion_local, &error_local);
- else if (role == PK_ROLE_ENUM_SEARCH_GROUP)
- part = zif_store_search_group (store, search, cancellable, completion_local, &error_local);
- else if (role == PK_ROLE_ENUM_SEARCH_CATEGORY)
- part = zif_store_search_category (store, search, cancellable, completion_local, &error_local);
- else if (role == PK_ROLE_ENUM_SEARCH_FILE)
- part = zif_store_search_file (store, search, cancellable, completion_local, &error_local);
- else if (role == PK_ROLE_ENUM_GET_PACKAGES)
- part = zif_store_get_packages (store, cancellable, completion_local, &error_local);
- else if (role == PK_ROLE_ENUM_GET_UPDATES)
- part = zif_store_get_updates (store, (GPtrArray *) search, cancellable, completion_local, &error_local);
- else if (role == PK_ROLE_ENUM_WHAT_PROVIDES)
- part = zif_store_what_provides (store, search, cancellable, completion_local, &error_local);
- else if (role == PK_ROLE_ENUM_GET_CATEGORIES)
- part = zif_store_get_categories (store, cancellable, completion_local, &error_local);
- else {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "internal error, no such role: %s", pk_role_enum_to_text (role));
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
- if (part == NULL) {
- /* do we need to skip this error */
- if (error_cb != NULL && error_cb (store_array, error_local, user_data)) {
- g_clear_error (&error_local);
- zif_completion_finished (completion_local);
- goto skip_error;
- }
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to %s in %s: %s", pk_role_enum_to_text (role), zif_store_get_id (store), error_local->message);
- g_error_free (error_local);
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
-
- for (j=0; j<part->len; j++) {
- package = g_ptr_array_index (part, j);
- g_ptr_array_add (array, g_object_ref (package));
- }
- g_ptr_array_unref (part);
-skip_error:
- /* this section done */
- zif_completion_done (completion);
- }
-out:
- return array;
-}
-
-/**
- * zif_store_array_find_package:
- * @store_array: the #GPtrArray of #ZifStores
- * @package_id: the PackageId which defines the package
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find a single package in the #GPtrArray.
- *
- * Return value: A single #ZifPackage or %NULL
- *
- * Since: 0.0.1
- **/
-ZifPackage *
-zif_store_array_find_package (GPtrArray *store_array, const gchar *package_id, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- ZifStore *store;
- ZifPackage *package = NULL;
- GError *error_local = NULL;
- ZifCompletion *completion_local = NULL;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* nothing to do */
- if (store_array->len == 0) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "package cannot be found as the store array is empty");
- goto out;
- }
-
- /* create a chain of completions */
- zif_completion_set_number_steps (completion, store_array->len);
-
- /* do each one */
- for (i=0; i<store_array->len; i++) {
- store = g_ptr_array_index (store_array, i);
-
- completion_local = zif_completion_get_child (completion);
- package = zif_store_find_package (store, package_id, cancellable, completion_local, &error_local);
-
- /* get results */
- if (package == NULL) {
- if (error_local->code == ZIF_STORE_ERROR_FAILED_TO_FIND) {
- /* do not abort */
- g_clear_error (&error_local);
- zif_completion_finished (completion_local);
- } else {
- g_set_error (error, 1, 0, "failed to find package: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- } else {
- zif_completion_finished (completion);
- break;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* nothing to do */
- if (package == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "package cannot be found");
- goto out;
- }
-out:
- return package;
-}
-
-/**
- * zif_store_array_clean:
- * @store_array: the #GPtrArray of #ZifStores
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Cleans the #ZifStoreRemote objects by deleting cache.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_array_clean (GPtrArray *store_array,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- ZifStore *store;
- gboolean ret = TRUE;
- GError *error_local = NULL;
- ZifCompletion *completion_local = NULL;
-
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* nothing to do */
- if (store_array->len == 0) {
- egg_debug ("nothing to do");
- goto out;
- }
-
- /* set number of stores */
- zif_completion_set_number_steps (completion, store_array->len);
-
- /* do each one */
- for (i=0; i<store_array->len; i++) {
- store = g_ptr_array_index (store_array, i);
-
- /* clean this one */
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_clean (store, cancellable, completion_local, &error_local);
- if (!ret) {
- /* do we need to skip this error */
- if (error_cb != NULL && error_cb (store_array, error_local, user_data)) {
- ret = TRUE;
- g_clear_error (&error_local);
- zif_completion_finished (completion_local);
- goto skip_error;
- }
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to clean %s: %s", zif_store_get_id (store), error_local->message);
- g_error_free (error_local);
- goto out;
- }
-skip_error:
- /* this section done */
- zif_completion_done (completion);
- }
-out:
- return ret;
-}
-
-/**
- * zif_store_array_refresh:
- * @store_array: the #GPtrArray of #ZifStores
- * @force: if the data should be re-downloaded if it's still valid
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Refreshs the #ZifStoreRemote objects by downloading new data
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_array_refresh (GPtrArray *store_array, gboolean force,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- ZifStore *store;
- gboolean ret = TRUE;
- GError *error_local = NULL;
- ZifCompletion *completion_local = NULL;
-
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* nothing to do */
- if (store_array->len == 0) {
- egg_debug ("nothing to do");
- goto out;
- }
-
- /* create a chain of completions */
- zif_completion_set_number_steps (completion, store_array->len);
-
- /* do each one */
- for (i=0; i<store_array->len; i++) {
- store = g_ptr_array_index (store_array, i);
-
- /* refresh this one */
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_refresh (store, force, cancellable, completion_local, &error_local);
- if (!ret) {
- /* do we need to skip this error */
- if (error_cb != NULL && error_cb (store_array, error_local, user_data)) {
- ret = TRUE;
- g_clear_error (&error_local);
- zif_completion_finished (completion_local);
- goto skip_error;
- }
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to clean %s: %s", zif_store_get_id (store), error_local->message);
- g_error_free (error_local);
- goto out;
- }
-skip_error:
- /* this section done */
- zif_completion_done (completion);
- }
-out:
- return ret;
-}
-
-/**
- * zif_store_array_resolve:
- * @store_array: the #GPtrArray of #ZifStores
- * @search: the search term, e.g. "gnome-power-manager"
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds packages matching the package name exactly.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_resolve (GPtrArray *store_array, gchar **search,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return zif_store_array_repos_search (store_array, PK_ROLE_ENUM_RESOLVE, search,
- error_cb, user_data, cancellable, completion, error);
-}
-
-/**
- * zif_store_array_search_name:
- * @store_array: the #GPtrArray of #ZifStores
- * @search: the search term, e.g. "power"
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that match the package name in some part.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_search_name (GPtrArray *store_array, gchar **search,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return zif_store_array_repos_search (store_array, PK_ROLE_ENUM_SEARCH_NAME, search,
- error_cb, user_data, cancellable, completion, error);
-}
-
-/**
- * zif_store_array_search_details:
- * @store_array: the #GPtrArray of #ZifStores
- * @search: the search term, e.g. "trouble"
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that match some detail about the package.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_search_details (GPtrArray *store_array, gchar **search,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return zif_store_array_repos_search (store_array, PK_ROLE_ENUM_SEARCH_DETAILS, search,
- error_cb, user_data, cancellable, completion, error);
-}
-
-/**
- * zif_store_array_search_group:
- * @store_array: the #GPtrArray of #ZifStores
- * @group_enum: the group enumerated value, e.g. "games"
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that belong in a specific group.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_search_group (GPtrArray *store_array, gchar **group_enum,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return zif_store_array_repos_search (store_array, PK_ROLE_ENUM_SEARCH_GROUP, group_enum,
- error_cb, user_data, cancellable, completion, error);
-}
-
-/**
- * zif_store_array_search_category:
- * @store_array: the #GPtrArray of #ZifStores
- * @group_id: the group id, e.g. "gnome-system-tools"
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that belong in a specific category.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_search_category (GPtrArray *store_array, gchar **group_id,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i, j;
- GPtrArray *array;
- ZifPackage *package;
- const gchar *package_id;
- const gchar *package_id_tmp;
- gchar **split;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* get all results from all repos */
- array = zif_store_array_repos_search (store_array, PK_ROLE_ENUM_SEARCH_CATEGORY, group_id,
- error_cb, user_data, cancellable, completion, error);
- if (array == NULL)
- goto out;
-
- /* remove duplicate package_ids */
- for (i=0; i<array->len; i++) {
- package = g_ptr_array_index (array, i);
- package_id = zif_package_get_id (package);
- for (j=0; j<array->len; j++) {
- if (i == j)
- continue;
- package = g_ptr_array_index (array, j);
- package_id_tmp = zif_package_get_id (package);
- if (g_strcmp0 (package_id, package_id_tmp) == 0) {
- split = pk_package_id_split (package_id);
- /* duplicate */
- g_ptr_array_remove_index (array, j);
- g_strfreev (split);
- }
- }
- }
-out:
- return array;
-}
-
-/**
- * zif_store_array_search_file:
- * @store_array: the #GPtrArray of #ZifStores
- * @search: the search term, e.g. "/usr/bin/gnome-power-manager"
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that provide the specified file.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_search_file (GPtrArray *store_array, gchar **search,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return zif_store_array_repos_search (store_array, PK_ROLE_ENUM_SEARCH_FILE, search,
- error_cb, user_data, cancellable, completion, error);
-}
-
-/**
- * zif_store_array_get_packages:
- * @store_array: the #GPtrArray of #ZifStores
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Return all packages in the #GPtrArray's.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_get_packages (GPtrArray *store_array,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return zif_store_array_repos_search (store_array, PK_ROLE_ENUM_GET_PACKAGES, NULL,
- error_cb, user_data, cancellable, completion, error);
-}
-
-/**
- * zif_store_array_get_updates:
- * @store_array: the #GPtrArray of #ZifStores
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Return a list of packages that are updatable.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_get_updates (GPtrArray *store_array, GPtrArray *packages,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return zif_store_array_repos_search (store_array, PK_ROLE_ENUM_GET_UPDATES, (gchar **) packages,
- error_cb, user_data, cancellable, completion, error);
-}
-
-/**
- * zif_store_array_what_provides:
- * @store_array: the #GPtrArray of #ZifStores
- * @search: the search term, e.g. "gstreamer(codec-mp3)"
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that provide a specific string.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_what_provides (GPtrArray *store_array, gchar **search,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* if this is a path, then we use the file list and treat like a SearchFile */
- if (g_str_has_prefix (search[0], "/")) {
- return zif_store_array_repos_search (store_array, PK_ROLE_ENUM_SEARCH_FILE, search,
- error_cb, user_data, cancellable, completion, error);
- }
- return zif_store_array_repos_search (store_array, PK_ROLE_ENUM_WHAT_PROVIDES, search,
- error_cb, user_data, cancellable, completion, error);
-}
-
-/**
- * zif_store_array_get_categories:
- * @store_array: the #GPtrArray of #ZifStores
- * @error_cb: a #ZifStoreArrayErrorCb which returns %FALSE if the error is fatal
- * @user_data: the user_data to be passed to the #ZifStoreArrayErrorCb
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Return a list of custom categories from all repos.
- *
- * Return value: an array of #PkCategory's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_get_categories (GPtrArray *store_array,
- ZifStoreArrayErrorCb error_cb, gpointer user_data,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i, j;
- GPtrArray *array;
- PkCategory *obj;
- PkCategory *obj_tmp;
- gchar *parent_id;
- gchar *parent_id_tmp;
- gchar *cat_id;
- gchar *cat_id_tmp;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* get all results from all repos */
- array = zif_store_array_repos_search (store_array, PK_ROLE_ENUM_GET_CATEGORIES, NULL,
- error_cb, user_data, cancellable, completion, error);
- if (array == NULL)
- goto out;
-
- /* remove duplicate parents and groups */
- for (i=0; i<array->len; i++) {
- obj = g_ptr_array_index (array, i);
- g_object_get (obj,
- "parent-id", &parent_id,
- "cat-id", &cat_id,
- NULL);
- for (j=0; j<array->len; j++) {
- if (i == j)
- continue;
- obj_tmp = g_ptr_array_index (array, j);
- g_object_get (obj_tmp,
- "parent-id", &parent_id_tmp,
- "cat-id", &cat_id_tmp,
- NULL);
- if (g_strcmp0 (parent_id_tmp, parent_id) == 0 &&
- g_strcmp0 (cat_id_tmp, cat_id) == 0) {
- /* duplicate */
- g_ptr_array_remove_index (array, j);
- }
- g_free (parent_id_tmp);
- g_free (cat_id_tmp);
- }
- g_free (parent_id);
- g_free (cat_id);
- }
-out:
- return array;
-}
-
-/**
- * zif_store_array_new:
- *
- * Return value: A new #GPtrArray class instance.
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_array_new (void)
-{
- GPtrArray *store_array;
- store_array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- return store_array;
-}
-
diff --git a/backends/yum/libzif/zif-store-array.h b/backends/yum/libzif/zif-store-array.h
deleted file mode 100644
index a214cc3..0000000
--- a/backends/yum/libzif/zif-store-array.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008-2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_STORE_ARRAY_H
-#define __ZIF_STORE_ARRAY_H
-
-#include <glib.h>
-
-#include "zif-store.h"
-#include "zif-package.h"
-#include "zif-completion.h"
-
-G_BEGIN_DECLS
-
-typedef gboolean (*ZifStoreArrayErrorCb) (GPtrArray *store_array,
- const GError *error,
- gpointer user_data);
-
-GPtrArray *zif_store_array_new (void);
-
-/* stores */
-gboolean zif_store_array_add_store (GPtrArray *store_array,
- ZifStore *store);
-gboolean zif_store_array_add_stores (GPtrArray *store_array,
- GPtrArray *stores);
-gboolean zif_store_array_add_local (GPtrArray *store_array,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_store_array_add_remote (GPtrArray *store_array,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_store_array_add_remote_enabled (GPtrArray *store_array,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-/* methods */
-gboolean zif_store_array_clean (GPtrArray *store_array,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_store_array_refresh (GPtrArray *store_array,
- gboolean force,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_resolve (GPtrArray *store_array,
- gchar **search,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_search_name (GPtrArray *store_array,
- gchar **search,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_search_details (GPtrArray *store_array,
- gchar **search,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_search_group (GPtrArray *store_array,
- gchar **group_enum,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_search_category (GPtrArray *store_array,
- gchar **group_id,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_search_file (GPtrArray *store_array,
- gchar **search,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_what_provides (GPtrArray *store_array,
- gchar **search,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_get_packages (GPtrArray *store_array,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_get_updates (GPtrArray *store_array,
- GPtrArray *packages,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-ZifPackage *zif_store_array_find_package (GPtrArray *store_array,
- const gchar *package_id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_array_get_categories (GPtrArray *store_array,
- ZifStoreArrayErrorCb error_cb,
- gpointer user_data,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_STORE_ARRAY_H */
-
diff --git a/backends/yum/libzif/zif-store-local.c b/backends/yum/libzif/zif-store-local.c
deleted file mode 100644
index 69c6a40..0000000
--- a/backends/yum/libzif/zif-store-local.c
+++ /dev/null
@@ -1,1336 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-store-local
- * @short_description: A local store is a store that can operate on installed packages
- *
- * A #ZifStoreLocal is a subclassed #ZifStore and operates on installed objects.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#define _GNU_SOURCE
-#include <string.h>
-
-#include <glib.h>
-#include <rpm/rpmlib.h>
-#include <rpm/rpmdb.h>
-#include <fcntl.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-store.h"
-#include "zif-store-local.h"
-#include "zif-groups.h"
-#include "zif-package-local.h"
-#include "zif-monitor.h"
-#include "zif-string.h"
-#include "zif-depend.h"
-#include "zif-lock.h"
-
-#include "egg-debug.h"
-
-#define ZIF_STORE_LOCAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_STORE_LOCAL, ZifStoreLocalPrivate))
-
-struct _ZifStoreLocalPrivate
-{
- gboolean loaded;
- gchar *prefix;
- GPtrArray *packages;
- ZifGroups *groups;
- ZifMonitor *monitor;
- ZifLock *lock;
-};
-
-
-G_DEFINE_TYPE (ZifStoreLocal, zif_store_local, ZIF_TYPE_STORE)
-static gpointer zif_store_local_object = NULL;
-
-/**
- * zif_store_local_set_prefix:
- * @store: the #ZifStoreLocal object
- * @prefix: the install root, e.g. "/"
- * @error: a #GError which is used on failure, or %NULL
- *
- * Sets the prefix to use for the install root.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_local_set_prefix (ZifStoreLocal *store, const gchar *prefix, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- gchar *filename = NULL;
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), FALSE);
- g_return_val_if_fail (prefix != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* check file exists */
- ret = g_file_test (prefix, G_FILE_TEST_IS_DIR);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "prefix %s does not exist", prefix);
- goto out;
- }
-
- /* is the same */
- if (g_strcmp0 (prefix, store->priv->prefix) == 0)
- goto out;
-
- /* empty cache */
- if (store->priv->loaded) {
- egg_debug ("abandoning cache");
- g_ptr_array_set_size (store->priv->packages, 0);
- store->priv->loaded = FALSE;
- }
-
- /* setup watch */
- filename = g_build_filename (prefix, "var", "lib", "rpm", "Packages", NULL);
- ret = zif_monitor_add_watch (store->priv->monitor, filename, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to setup watch: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* save new value */
- g_free (store->priv->prefix);
- store->priv->prefix = g_strdup (prefix);
-out:
- g_free (filename);
- return ret;
-}
-
-/**
- * zif_store_local_load:
- **/
-static gboolean
-zif_store_local_load (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gint retval;
- gboolean ret = TRUE;
- rpmdbMatchIterator mi;
- Header header;
- ZifPackageLocal *package;
- rpmdb db;
- GError *error_local = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), FALSE);
- g_return_val_if_fail (local->priv->prefix != NULL, FALSE);
- g_return_val_if_fail (local->priv->packages != NULL, FALSE);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* already loaded */
- if (local->priv->loaded)
- goto out;
-
- /* setup completion with the correct number of steps */
- zif_completion_set_number_steps (completion, 2);
-
- retval = rpmdbOpen (local->priv->prefix, &db, O_RDONLY, 0777);
- if (retval != 0) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to open rpmdb");
- ret = FALSE;
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* get list */
- mi = rpmdbInitIterator (db, RPMDBI_PACKAGES, NULL, 0);
- if (mi == NULL)
- egg_warning ("failed to get iterator");
- do {
- header = rpmdbNextIterator (mi);
- if (header == NULL)
- break;
- package = zif_package_local_new ();
- ret = zif_package_local_set_from_header (package, header, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to set from header: %s", error_local->message);
- g_error_free (error_local);
- g_object_unref (package);
- break;
- }
- g_ptr_array_add (local->priv->packages, package);
- } while (TRUE);
- rpmdbFreeIterator (mi);
- rpmdbClose (db);
-
- /* this section done */
- zif_completion_done (completion);
-
- /* okay */
- local->priv->loaded = TRUE;
-out:
- return ret;
-}
-
-/**
- * zif_store_local_search_name:
- **/
-static GPtrArray *
-zif_store_local_search_name (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i, j;
- GPtrArray *array = NULL;
- ZifPackage *package;
- const gchar *package_id;
- gchar **split;
- GError *error_local = NULL;
- gboolean ret;
- ZifCompletion *completion_local = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (local->priv->prefix != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* we have a different number of steps depending if we are loaded or not */
- if (local->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!local->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_local_load (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load package store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* check we have packages */
- if (local->priv->packages->len == 0) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "no packages in local sack");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, local->priv->packages->len);
-
- /* iterate list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0;i<local->priv->packages->len;i++) {
- package = g_ptr_array_index (local->priv->packages, i);
- package_id = zif_package_get_id (package);
- split = pk_package_id_split (package_id);
- for (j=0; search[j] != NULL; j++) {
- if (strcasestr (split[PK_PACKAGE_ID_NAME], search[j]) != NULL) {
- g_ptr_array_add (array, g_object_ref (package));
- break;
- }
- }
- g_strfreev (split);
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_local_search_category:
- **/
-static GPtrArray *
-zif_store_local_search_category (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i, j;
- GPtrArray *array = NULL;
- ZifPackage *package;
- const gchar *category;
- GError *error_local = NULL;
- gboolean ret;
- ZifCompletion *completion_local = NULL;
- ZifCompletion *completion_loop = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (local->priv->prefix != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED, "not locked");
- goto out;
- }
-
- /* we have a different number of steps depending if we are loaded or not */
- if (local->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!local->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_local_load (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load package store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* check we have packages */
- if (local->priv->packages->len == 0) {
- egg_warning ("no packages in sack, so nothing to do!");
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "no packages in local sack");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, local->priv->packages->len);
-
- /* iterate list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0;i<local->priv->packages->len;i++) {
- package = g_ptr_array_index (local->priv->packages, i);
- completion_loop = zif_completion_get_child (completion_local);
- category = zif_package_get_category (package, cancellable, completion_loop, NULL);
- for (j=0; search[j] != NULL; j++) {
- if (g_strcmp0 (category, search[j]) == 0) {
- g_ptr_array_add (array, g_object_ref (package));
- break;
- }
- }
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_local_earch_details:
- **/
-static GPtrArray *
-zif_store_local_search_details (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i, j;
- GPtrArray *array = NULL;
- ZifPackage *package;
- const gchar *package_id;
- const gchar *description;
- gchar **split;
- GError *error_local = NULL;
- gboolean ret;
- ZifCompletion *completion_local = NULL;
- ZifCompletion *completion_loop = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (local->priv->prefix != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED, "not locked");
- goto out;
- }
-
- /* we have a different number of steps depending if we are loaded or not */
- if (local->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!local->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_local_load (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load package store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* check we have packages */
- if (local->priv->packages->len == 0) {
- egg_warning ("no packages in sack, so nothing to do!");
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "no packages in local sack");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, local->priv->packages->len);
-
- /* iterate list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0;i<local->priv->packages->len;i++) {
- package = g_ptr_array_index (local->priv->packages, i);
- package_id = zif_package_get_id (package);
- completion_loop = zif_completion_get_child (completion_local);
- description = zif_package_get_description (package, cancellable, completion_loop, NULL);
- split = pk_package_id_split (package_id);
- for (j=0; search[j] != NULL; j++) {
- if (strcasestr (split[PK_PACKAGE_ID_NAME], search[j]) != NULL) {
- g_ptr_array_add (array, g_object_ref (package));
- break;
- } else if (strcasestr (description, search[j]) != NULL) {
- g_ptr_array_add (array, g_object_ref (package));
- break;
- }
- }
- g_strfreev (split);
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_local_search_group:
- **/
-static GPtrArray *
-zif_store_local_search_group (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i, j;
- GPtrArray *array = NULL;
- ZifPackage *package;
- PkGroupEnum group_tmp;
- GError *error_local = NULL;
- gboolean ret;
- PkGroupEnum group;
- ZifCompletion *completion_local = NULL;
- ZifCompletion *completion_loop = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- g_return_val_if_fail (local->priv->prefix != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED, "not locked");
- goto out;
- }
-
- /* we have a different number of steps depending if we are loaded or not */
- if (local->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!local->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_local_load (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load package store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* check we have packages */
- if (local->priv->packages->len == 0) {
- egg_warning ("no packages in sack, so nothing to do!");
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "no packages in local sack");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, local->priv->packages->len);
-
- /* iterate list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0;i<local->priv->packages->len;i++) {
- package = g_ptr_array_index (local->priv->packages, i);
- for (j=0; search[j] != NULL; j++) {
- group = pk_group_enum_from_text (search[j]);
- completion_loop = zif_completion_get_child (completion_local);
- group_tmp = zif_package_get_group (package, cancellable, completion_loop, NULL);
- if (group == group_tmp) {
- g_ptr_array_add (array, g_object_ref (package));
- break;
- }
- }
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_local_search_file:
- **/
-static GPtrArray *
-zif_store_local_search_file (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i, j, l;
- GPtrArray *array = NULL;
- ZifPackage *package;
- GPtrArray *files;
- GError *error_local = NULL;
- const gchar *filename;
- gboolean ret;
- ZifCompletion *completion_local = NULL;
- ZifCompletion *completion_loop = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- g_return_val_if_fail (local->priv->prefix != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED, "not locked");
- goto out;
- }
-
- /* we have a different number of steps depending if we are loaded or not */
- if (local->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!local->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_local_load (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load package store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* check we have packages */
- if (local->priv->packages->len == 0) {
- egg_warning ("no packages in sack, so nothing to do!");
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "no packages in local sack");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, local->priv->packages->len);
-
- /* iterate list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0;i<local->priv->packages->len;i++) {
- package = g_ptr_array_index (local->priv->packages, i);
- completion_loop = zif_completion_get_child (completion_local);
- files = zif_package_get_files (package, cancellable, completion_loop, &error_local);
- if (files == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get file lists: %s", error_local->message);
- g_error_free (error_local);
- g_ptr_array_unref (array);
- array = NULL;
- break;
- }
- for (j=0; j<files->len; j++) {
- filename = g_ptr_array_index (files, j);
- for (l=0; search[l] != NULL; l++) {
- if (g_strcmp0 (search[l], filename) == 0) {
- g_ptr_array_add (array, g_object_ref (package));
- break;
- }
- }
- }
- g_ptr_array_unref (files);
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-out:
- return array;
-}
-
-/**
- * zif_store_local_resolve:
- **/
-static GPtrArray *
-zif_store_local_resolve (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i, j;
- GPtrArray *array = NULL;
- ZifPackage *package;
- const gchar *package_id;
- GError *error_local = NULL;
- gboolean ret;
- gchar **split;
- ZifCompletion *completion_local = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (local->priv->prefix != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED, "not locked");
- goto out;
- }
-
- /* we have a different number of steps depending if we are loaded or not */
- if (local->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!local->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_local_load (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load package store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* check we have packages */
- if (local->priv->packages->len == 0) {
- egg_warning ("no packages in sack, so nothing to do!");
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "no packages in local sack");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, local->priv->packages->len);
-
- /* iterate list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0;i<local->priv->packages->len;i++) {
- package = g_ptr_array_index (local->priv->packages, i);
- package_id = zif_package_get_id (package);
- split = pk_package_id_split (package_id);
- for (j=0; search[j] != NULL; j++) {
- if (strcmp (split[PK_PACKAGE_ID_NAME], search[j]) == 0) {
- g_ptr_array_add (array, g_object_ref (package));
- break;
- }
- }
- g_strfreev (split);
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_local_what_provides:
- **/
-static GPtrArray *
-zif_store_local_what_provides (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- guint j, k;
- GPtrArray *array = NULL;
- ZifPackage *package;
- GPtrArray *provides;
- GError *error_local = NULL;
- gboolean ret;
- const ZifDepend *provide;
- ZifCompletion *completion_local = NULL;
- ZifCompletion *completion_loop = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (local->priv->prefix != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED, "not locked");
- goto out;
- }
-
- /* we have a different number of steps depending if we are loaded or not */
- if (local->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!local->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_local_load (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load package store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* check we have packages */
- if (local->priv->packages->len == 0) {
- egg_warning ("no packages in sack, so nothing to do!");
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "no packages in local sack");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, local->priv->packages->len);
-
- /* iterate list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0;i<local->priv->packages->len;i++) {
- package = g_ptr_array_index (local->priv->packages, i);
- completion_loop = zif_completion_get_child (completion_local);
- provides = zif_package_get_provides (package, cancellable, completion_loop, NULL);
- for (j=0; j<provides->len; j++) {
- provide = g_ptr_array_index (provides, j);
- for (k=0; search[k] != NULL; k++) {
- if (g_strcmp0 (provide->name, search[k]) == 0) {
- g_ptr_array_add (array, g_object_ref (package));
- break;
- }
- }
- }
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_local_get_packages:
- **/
-static GPtrArray *
-zif_store_local_get_packages (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- GPtrArray *array = NULL;
- ZifPackage *package;
- GError *error_local = NULL;
- gboolean ret;
- ZifCompletion *completion_local = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- g_return_val_if_fail (local->priv->prefix != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED, "not locked");
- goto out;
- }
-
- /* we have a different number of steps depending if we are loaded or not */
- if (local->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!local->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_local_load (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load package store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* check we have packages */
- if (local->priv->packages->len == 0) {
- egg_warning ("no packages in sack, so nothing to do!");
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "no packages in local sack");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, local->priv->packages->len);
-
- /* iterate list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0;i<local->priv->packages->len;i++) {
- package = g_ptr_array_index (local->priv->packages, i);
- g_ptr_array_add (array, g_object_ref (package));
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_local_find_package:
- **/
-static ZifPackage *
-zif_store_local_find_package (ZifStore *store, const gchar *package_id, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- GPtrArray *array = NULL;
- ZifPackage *package = NULL;
- ZifPackage *package_tmp = NULL;
- GError *error_local = NULL;
- gboolean ret;
- const gchar *package_id_tmp;
- ZifCompletion *completion_local = NULL;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- g_return_val_if_fail (local->priv->prefix != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (local->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED, "not locked");
- goto out;
- }
-
- /* we have a different number of steps depending if we are loaded or not */
- if (local->priv->loaded)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!local->priv->loaded) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_local_load (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load package store: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* check we have packages */
- if (local->priv->packages->len == 0) {
- egg_warning ("no packages in sack, so nothing to do!");
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "no packages in local sack");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- completion_local = zif_completion_get_child (completion);
-
- /* setup completion */
- zif_completion_set_number_steps (completion_local, local->priv->packages->len);
-
- /* iterate list */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0;i<local->priv->packages->len;i++) {
- package_tmp = g_ptr_array_index (local->priv->packages, i);
- package_id_tmp = zif_package_get_id (package_tmp);
- if (g_strcmp0 (package_id_tmp, package_id) == 0)
- g_ptr_array_add (array, g_object_ref (package_tmp));
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* nothing */
- if (array->len == 0) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED_TO_FIND,
- "failed to find package");
- goto out;
- }
-
- /* more than one match */
- if (array->len > 1) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_MULTIPLE_MATCHES,
- "more than one match");
- goto out;
- }
-
- /* return ref to package */
- package = g_object_ref (g_ptr_array_index (array, 0));
-
- /* this section done */
- zif_completion_done (completion);
-out:
- g_ptr_array_unref (array);
- return package;
-}
-
-/**
- * zif_store_local_get_id:
- **/
-static const gchar *
-zif_store_local_get_id (ZifStore *store)
-{
- g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
- return "installed";
-}
-
-/**
- * zif_store_local_print:
- **/
-static void
-zif_store_local_print (ZifStore *store)
-{
- guint i;
- ZifPackage *package;
- ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
-
- g_return_if_fail (ZIF_IS_STORE_LOCAL (store));
- g_return_if_fail (local->priv->prefix != NULL);
- g_return_if_fail (local->priv->packages->len != 0);
-
- for (i=0;i<local->priv->packages->len;i++) {
- package = g_ptr_array_index (local->priv->packages, i);
- zif_package_print (package);
- }
-}
-
-/**
- * zif_store_local_file_monitor_cb:
- **/
-static void
-zif_store_local_file_monitor_cb (ZifMonitor *monitor, ZifStoreLocal *store)
-{
- store->priv->loaded = FALSE;
-
- g_ptr_array_set_size (store->priv->packages, 0);
-
- egg_debug ("rpmdb changed");
-}
-
-/**
- * zif_store_local_finalize:
- **/
-static void
-zif_store_local_finalize (GObject *object)
-{
- ZifStoreLocal *store;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_STORE_LOCAL (object));
- store = ZIF_STORE_LOCAL (object);
-
- g_ptr_array_unref (store->priv->packages);
- g_object_unref (store->priv->groups);
- g_object_unref (store->priv->monitor);
- g_object_unref (store->priv->lock);
- g_free (store->priv->prefix);
-
- G_OBJECT_CLASS (zif_store_local_parent_class)->finalize (object);
-}
-
-/**
- * zif_store_local_class_init:
- **/
-static void
-zif_store_local_class_init (ZifStoreLocalClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifStoreClass *store_class = ZIF_STORE_CLASS (klass);
- object_class->finalize = zif_store_local_finalize;
-
- /* map */
- store_class->load = zif_store_local_load;
- store_class->search_name = zif_store_local_search_name;
- store_class->search_category = zif_store_local_search_category;
- store_class->search_details = zif_store_local_search_details;
- store_class->search_group = zif_store_local_search_group;
- store_class->search_file = zif_store_local_search_file;
- store_class->resolve = zif_store_local_resolve;
- store_class->what_provides = zif_store_local_what_provides;
- store_class->get_packages = zif_store_local_get_packages;
- store_class->find_package = zif_store_local_find_package;
- store_class->get_id = zif_store_local_get_id;
- store_class->print = zif_store_local_print;
-
- g_type_class_add_private (klass, sizeof (ZifStoreLocalPrivate));
-}
-
-/**
- * zif_store_local_init:
- **/
-static void
-zif_store_local_init (ZifStoreLocal *store)
-{
- store->priv = ZIF_STORE_LOCAL_GET_PRIVATE (store);
- store->priv->packages = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- store->priv->groups = zif_groups_new ();
- store->priv->monitor = zif_monitor_new ();
- store->priv->lock = zif_lock_new ();
- store->priv->prefix = NULL;
- store->priv->loaded = FALSE;
- g_signal_connect (store->priv->monitor, "changed", G_CALLBACK (zif_store_local_file_monitor_cb), store);
-}
-
-/**
- * zif_store_local_new:
- *
- * Return value: A new #ZifStoreLocal class instance.
- *
- * Since: 0.0.1
- **/
-ZifStoreLocal *
-zif_store_local_new (void)
-{
- if (zif_store_local_object != NULL) {
- g_object_ref (zif_store_local_object);
- } else {
- zif_store_local_object = g_object_new (ZIF_TYPE_STORE_LOCAL, NULL);
- g_object_add_weak_pointer (zif_store_local_object, &zif_store_local_object);
- }
- return ZIF_STORE_LOCAL (zif_store_local_object);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-#include "zif-config.h"
-
-void
-zif_store_local_test (EggTest *test)
-{
- ZifStoreLocal *store;
- gboolean ret;
- GPtrArray *array;
- ZifPackage *package;
- ZifGroups *groups;
- ZifLock *lock;
- ZifConfig *config;
- ZifCompletion *completion;
- GError *error = NULL;
- guint elapsed;
- const gchar *text;
- const gchar *string;
- const gchar *package_id;
- gchar **split;
- const gchar *to_array[] = { NULL, NULL };
-
- if (!egg_test_start (test, "ZifStoreLocal"))
- return;
-
- /* set this up as dummy */
- config = zif_config_new ();
- zif_config_set_filename (config, "../test/etc/yum.conf", NULL);
-
- /* use completion object */
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get groups");
- groups = zif_groups_new ();
- ret = zif_groups_set_mapping_file (groups, "../test/share/yum-comps-groups.conf", NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "get store");
- store = zif_store_local_new ();
- egg_test_assert (test, store != NULL);
-
- /************************************************************/
- egg_test_title (test, "get lock");
- lock = zif_lock_new ();
- egg_test_assert (test, lock != NULL);
-
- /************************************************************/
- egg_test_title (test, "lock");
- ret = zif_lock_set_locked (lock, NULL, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "set prefix");
- ret = zif_store_local_set_prefix (store, "/", &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to set prefix '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "load");
- ret = zif_store_local_load (ZIF_STORE (store), NULL, completion, &error);
- elapsed = egg_test_elapsed (test);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "check time < 1000ms");
- if (elapsed < 1000)
- egg_test_success (test, "time to load = %ims", elapsed);
- else
- egg_test_failed (test, "time to load = %ims", elapsed);
-
- /************************************************************/
- egg_test_title (test, "load (again)");
- zif_completion_reset (completion);
- ret = zif_store_local_load (ZIF_STORE (store), NULL, completion, &error);
- elapsed = egg_test_elapsed (test);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "check time < 10ms");
- if (elapsed < 10)
- egg_test_success (test, "time to load = %ims", elapsed);
- else
- egg_test_failed (test, "time to load = %ims", elapsed);
-
- /************************************************************/
- egg_test_title (test, "resolve");
- zif_completion_reset (completion);
- to_array[0] = "kernel";
- array = zif_store_local_resolve (ZIF_STORE (store), (gchar**)to_array, NULL, completion, NULL);
- elapsed = egg_test_elapsed (test);
- if (array->len >= 1)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "check time < 10ms");
- if (elapsed < 1000) /* TODO: reduce back down to 10ms */
- egg_test_success (test, "time to load = %ims", elapsed);
- else
- egg_test_failed (test, "time to load = %ims", elapsed);
-
- /************************************************************/
- egg_test_title (test, "search name");
- zif_completion_reset (completion);
- to_array[0] = "gnome-p";
- array = zif_store_local_search_name (ZIF_STORE (store), (gchar**)to_array, NULL, completion, NULL);
- if (array->len > 10)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "search details");
- zif_completion_reset (completion);
- to_array[0] = "manage packages";
- array = zif_store_local_search_details (ZIF_STORE (store), (gchar**)to_array, NULL, completion, NULL);
- if (array->len == 1)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "what-provides");
- zif_completion_reset (completion);
- to_array[0] = "config(PackageKit)";
- array = zif_store_local_what_provides (ZIF_STORE (store), (gchar**)to_array, NULL, completion, NULL);
- if (array->len == 1)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
-
- /* get this package */
- package = g_ptr_array_index (array, 0);
-
- /************************************************************/
- egg_test_title (test, "get id");
- package_id = zif_package_get_id (package);
- split = pk_package_id_split (package_id);
- if (g_strcmp0 (split[PK_PACKAGE_ID_NAME], "PackageKit") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect name: %s", split[PK_PACKAGE_ID_NAME]);
- g_strfreev (split);
-
- /************************************************************/
- egg_test_title (test, "get package id");
- text = zif_package_get_package_id (package);
- if (g_str_has_suffix (text, ";installed"))
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect package_id: %s", text);
-
- /************************************************************/
- egg_test_title (test, "get summary");
- zif_completion_reset (completion);
- string = zif_package_get_summary (package, NULL, completion, NULL);
- if (g_strcmp0 (string, "Package management service") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect summary: %s", string);
-
- /************************************************************/
- egg_test_title (test, "get license");
- zif_completion_reset (completion);
- string = zif_package_get_license (package, NULL, completion, NULL);
- if (g_strcmp0 (string, "GPLv2+") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect license: %s", string);
-
- /************************************************************/
- egg_test_title (test, "get category");
- zif_completion_reset (completion);
- string = zif_package_get_category (package, NULL, completion, NULL);
- if (g_strcmp0 (string, "System Environment/Libraries") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect category: %s", string);
-
- /************************************************************/
- egg_test_title (test, "is devel");
- ret = zif_package_is_devel (package);
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "is gui");
- ret = zif_package_is_gui (package);
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "is installed");
- ret = zif_package_is_installed (package);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "is free");
- ret = zif_package_is_free (package);
- egg_test_assert (test, ret);
-
- g_ptr_array_unref (array);
-
- g_object_unref (store);
- g_object_unref (groups);
- g_object_unref (config);
- g_object_unref (lock);
- g_object_unref (completion);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-store-local.h b/backends/yum/libzif/zif-store-local.h
deleted file mode 100644
index 74e4004..0000000
--- a/backends/yum/libzif/zif-store-local.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_STORE_LOCAL_H
-#define __ZIF_STORE_LOCAL_H
-
-#include <glib-object.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-store.h"
-#include "zif-package.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_STORE_LOCAL (zif_store_local_get_type ())
-#define ZIF_STORE_LOCAL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_STORE_LOCAL, ZifStoreLocal))
-#define ZIF_STORE_LOCAL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_STORE_LOCAL, ZifStoreLocalClass))
-#define ZIF_IS_STORE_LOCAL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_STORE_LOCAL))
-#define ZIF_IS_STORE_LOCAL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_STORE_LOCAL))
-#define ZIF_STORE_LOCAL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_STORE_LOCAL, ZifStoreLocalClass))
-
-typedef struct _ZifStoreLocal ZifStoreLocal;
-typedef struct _ZifStoreLocalPrivate ZifStoreLocalPrivate;
-typedef struct _ZifStoreLocalClass ZifStoreLocalClass;
-
-struct _ZifStoreLocal
-{
- ZifStore parent;
- ZifStoreLocalPrivate *priv;
-};
-
-struct _ZifStoreLocalClass
-{
- ZifStoreClass parent_class;
-};
-
-GType zif_store_local_get_type (void);
-ZifStoreLocal *zif_store_local_new (void);
-gboolean zif_store_local_set_prefix (ZifStoreLocal *store,
- const gchar *prefix,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_STORE_LOCAL_H */
-
diff --git a/backends/yum/libzif/zif-store-remote.c b/backends/yum/libzif/zif-store-remote.c
deleted file mode 100644
index 313573d..0000000
--- a/backends/yum/libzif/zif-store-remote.c
+++ /dev/null
@@ -1,3228 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008-2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-store-remote
- * @short_description: A remote store is a store that can operate on remote packages
- *
- * A #ZifStoreRemote is a subclassed #ZifStore and operates on remote objects.
- * A repository is another name for a #ZifStoreRemote.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <stdlib.h>
-#include <gio/gio.h>
-
-#include "zif-config.h"
-#include "zif-download.h"
-#include "zif-lock.h"
-#include "zif-monitor.h"
-#include "zif-package.h"
-#include "zif-package-remote.h"
-#include "zif-md-comps.h"
-#include "zif-md-updateinfo.h"
-#include "zif-md-filelists-sql.h"
-#include "zif-md-filelists-xml.h"
-#include "zif-md-metalink.h"
-#include "zif-md-mirrorlist.h"
-#include "zif-md-other-sql.h"
-#include "zif-md-primary-sql.h"
-#include "zif-md-primary-xml.h"
-#include "zif-store.h"
-#include "zif-store-local.h"
-#include "zif-store-remote.h"
-#include "zif-utils.h"
-
-#include "egg-debug.h"
-
-#define ZIF_STORE_REMOTE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_STORE_REMOTE, ZifStoreRemotePrivate))
-
-typedef enum {
- ZIF_STORE_REMOTE_PARSER_SECTION_CHECKSUM,
- ZIF_STORE_REMOTE_PARSER_SECTION_CHECKSUM_UNCOMPRESSED,
- ZIF_STORE_REMOTE_PARSER_SECTION_TIMESTAMP,
- ZIF_STORE_REMOTE_PARSER_SECTION_UNKNOWN
-} ZifStoreRemoteParserSection;
-
-struct _ZifStoreRemotePrivate
-{
- gchar *id; /* fedora */
- gchar *name; /* Fedora $arch */
- gchar *name_expanded; /* Fedora 1386 */
- gchar *directory; /* /var/cache/yum/fedora */
- gchar *repomd_filename; /* /var/cache/yum/fedora/repomd.xml */
- GPtrArray *baseurls; /* http://download.fedora.org/ */
- gchar *mirrorlist;
- gchar *metalink;
- gchar *cache_dir; /* /var/cache/yum */
- gchar *repo_filename; /* /etc/yum.repos.d/fedora.repo */
- gboolean enabled;
- gboolean loaded;
- gboolean loaded_metadata;
- ZifMd *md_other_sql;
- ZifMd *md_primary_sql;
- ZifMd *md_primary_xml;
- ZifMd *md_filelists_sql;
- ZifMd *md_filelists_xml;
- ZifMd *md_metalink;
- ZifMd *md_mirrorlist;
- ZifMd *md_comps;
- ZifMd *md_updateinfo;
- ZifConfig *config;
- ZifMonitor *monitor;
- ZifLock *lock;
- GPtrArray *packages;
- /* temp data for the xml parser */
- ZifMdType parser_type;
- ZifMdType parser_section;
-};
-
-G_DEFINE_TYPE (ZifStoreRemote, zif_store_remote, ZIF_TYPE_STORE)
-
-static gboolean zif_store_remote_load_metadata (ZifStoreRemote *store, GCancellable *cancellable, ZifCompletion *completion, GError **error);
-
-/**
- * zif_store_remote_checksum_type_from_text:
- **/
-static GChecksumType
-zif_store_remote_checksum_type_from_text (const gchar *type)
-{
- if (g_strcmp0 (type, "sha") == 0)
- return G_CHECKSUM_SHA1;
- if (g_strcmp0 (type, "sha1") == 0)
- return G_CHECKSUM_SHA1;
- if (g_strcmp0 (type, "sha256") == 0)
- return G_CHECKSUM_SHA256;
- return G_CHECKSUM_MD5;
-}
-
-/**
- * zif_store_remote_get_primary:
- **/
-static ZifMd *
-zif_store_remote_get_primary (ZifStoreRemote *store)
-{
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
-
- if (zif_md_get_location (store->priv->md_primary_sql) != NULL)
- return store->priv->md_primary_sql;
- if (zif_md_get_location (store->priv->md_primary_xml) != NULL)
- return store->priv->md_primary_xml;
-
- /* this should never happen */
- return NULL;
-}
-
-/**
- * zif_store_remote_get_filelists:
- **/
-static ZifMd *
-zif_store_remote_get_filelists (ZifStoreRemote *store)
-{
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
-
- if (zif_md_get_location (store->priv->md_filelists_sql) != NULL)
- return store->priv->md_filelists_sql;
- if (zif_md_get_location (store->priv->md_filelists_xml) != NULL)
- return store->priv->md_filelists_xml;
-
- /* this should never happen */
- return NULL;
-}
-
-/**
- * zif_store_remote_get_md_from_type:
- **/
-static ZifMd *
-zif_store_remote_get_md_from_type (ZifStoreRemote *store, ZifMdType type)
-{
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (type != ZIF_MD_TYPE_UNKNOWN, NULL);
-
- if (type == ZIF_MD_TYPE_FILELISTS_SQL)
- return store->priv->md_filelists_sql;
- if (type == ZIF_MD_TYPE_FILELISTS_XML)
- return store->priv->md_filelists_xml;
- if (type == ZIF_MD_TYPE_PRIMARY_SQL)
- return store->priv->md_primary_sql;
- if (type == ZIF_MD_TYPE_PRIMARY_XML)
- return store->priv->md_primary_xml;
- if (type == ZIF_MD_TYPE_OTHER_SQL)
- return store->priv->md_other_sql;
- if (type == ZIF_MD_TYPE_COMPS_GZ)
- return store->priv->md_comps;
- if (type == ZIF_MD_TYPE_UPDATEINFO)
- return store->priv->md_updateinfo;
- if (type == ZIF_MD_TYPE_METALINK)
- return store->priv->md_metalink;
- if (type == ZIF_MD_TYPE_MIRRORLIST)
- return store->priv->md_mirrorlist;
- return NULL;
-}
-
-/**
- * zif_store_remote_parser_start_element:
- **/
-static void
-zif_store_remote_parser_start_element (GMarkupParseContext *context, const gchar *element_name,
- const gchar **attribute_names, const gchar **attribute_values,
- gpointer user_data, GError **error)
-{
- guint i, j;
- ZifMd *md;
- ZifStoreRemote *store = user_data;
- GString *string;
-
- /* data */
- if (g_strcmp0 (element_name, "data") == 0) {
-
- /* reset */
- store->priv->parser_type = ZIF_MD_TYPE_UNKNOWN;
-
- /* find type */
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "type") == 0) {
- if (g_strcmp0 (attribute_values[i], "primary") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_PRIMARY_XML;
- else if (g_strcmp0 (attribute_values[i], "primary_db") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_PRIMARY_SQL;
- else if (g_strcmp0 (attribute_values[i], "filelists") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_FILELISTS_XML;
- else if (g_strcmp0 (attribute_values[i], "filelists_db") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_FILELISTS_SQL;
- else if (g_strcmp0 (attribute_values[i], "other") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_OTHER_XML;
- else if (g_strcmp0 (attribute_values[i], "other_db") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_OTHER_SQL;
- else if (g_strcmp0 (attribute_values[i], "group") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_COMPS;
- else if (g_strcmp0 (attribute_values[i], "group_gz") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_COMPS_GZ;
- else if (g_strcmp0 (attribute_values[i], "prestodelta") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_PRESTODELTA;
- else if (g_strcmp0 (attribute_values[i], "updateinfo") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_UPDATEINFO;
- else {
- if (error != NULL) {
- /* we didn't recognise the file type */
- string = g_string_new ("");
- g_string_append_printf (string, "unhandled data type '%s', expecting ", attribute_values[i]);
-
- /* list all the types we support */
- for (j=0; j<ZIF_MD_TYPE_UNKNOWN; j++)
- g_string_append_printf (string, "%s, ", zif_md_type_to_text (j));
-
- /* remove triling comma and space */
- g_string_set_size (string, string->len - 2);
-
- /* return error */
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "%s", string->str);
- g_string_free (string, TRUE);
- }
- }
- break;
- }
- }
- store->priv->parser_section = ZIF_STORE_REMOTE_PARSER_SECTION_UNKNOWN;
- goto out;
- }
-
- /* not a section we recognise */
- if (store->priv->parser_type == ZIF_MD_TYPE_UNKNOWN)
- goto out;
-
- /* get MetaData object */
- md = zif_store_remote_get_md_from_type (store, store->priv->parser_type);
- if (md == NULL)
- goto out;
-
- /* location */
- if (g_strcmp0 (element_name, "location") == 0) {
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "href") == 0) {
- zif_md_set_location (md, attribute_values[i]);
- break;
- }
- }
- store->priv->parser_section = ZIF_STORE_REMOTE_PARSER_SECTION_UNKNOWN;
- goto out;
- }
-
- /* checksum */
- if (g_strcmp0 (element_name, "checksum") == 0) {
- for (i=0; attribute_names[i] != NULL; i++) {
- if (g_strcmp0 (attribute_names[i], "type") == 0) {
- zif_md_set_checksum_type (md, zif_store_remote_checksum_type_from_text (attribute_values[i]));
- break;
- }
- }
- store->priv->parser_section = ZIF_STORE_REMOTE_PARSER_SECTION_CHECKSUM;
- goto out;
- }
-
- /* checksum */
- if (g_strcmp0 (element_name, "open-checksum") == 0) {
- store->priv->parser_section = ZIF_STORE_REMOTE_PARSER_SECTION_CHECKSUM_UNCOMPRESSED;
- goto out;
- }
-
- /* timestamp */
- if (g_strcmp0 (element_name, "timestamp") == 0) {
- store->priv->parser_section = ZIF_STORE_REMOTE_PARSER_SECTION_TIMESTAMP;
- goto out;
- }
-out:
- return;
-}
-
-/**
- * zif_store_remote_parser_end_element:
- **/
-static void
-zif_store_remote_parser_end_element (GMarkupParseContext *context, const gchar *element_name,
- gpointer user_data, GError **error)
-{
- ZifStoreRemote *store = user_data;
-
- /* reset */
- store->priv->parser_section = ZIF_STORE_REMOTE_PARSER_SECTION_UNKNOWN;
- if (g_strcmp0 (element_name, "data") == 0)
- store->priv->parser_type = ZIF_MD_TYPE_UNKNOWN;
-}
-
-/**
- * zif_store_remote_parser_text:
- **/
-static void
-zif_store_remote_parser_text (GMarkupParseContext *context, const gchar *text, gsize text_len,
- gpointer user_data, GError **error)
-
-{
- ZifMd *md;
- ZifStoreRemote *store = user_data;
-
- if (store->priv->parser_type == ZIF_MD_TYPE_UNKNOWN)
- return;
-
- /* get MetaData object */
- md = zif_store_remote_get_md_from_type (store, store->priv->parser_type);
- if (md == NULL)
- return;
-
- if (store->priv->parser_section == ZIF_STORE_REMOTE_PARSER_SECTION_CHECKSUM)
- zif_md_set_checksum (md, text);
- else if (store->priv->parser_section == ZIF_STORE_REMOTE_PARSER_SECTION_CHECKSUM_UNCOMPRESSED)
- zif_md_set_checksum_uncompressed (md, text);
- else if (store->priv->parser_section == ZIF_STORE_REMOTE_PARSER_SECTION_TIMESTAMP)
- zif_md_set_timestamp (md, atol (text));
-}
-
-/**
- * zif_store_remote_download_try:
- **/
-static gboolean
-zif_store_remote_download_try (ZifStoreRemote *store, const gchar *uri, const gchar *filename,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- GError *error_local = NULL;
- ZifDownload *download = NULL;
- gchar *contents = NULL;
- gsize length;
-
- /* download object */
- download = zif_download_new ();
- egg_debug ("trying to download %s and save to %s", uri, filename);
- ret = zif_download_file (download, uri, filename, cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to download %s from %s: %s", filename, uri, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* try to read it */
- ret = g_file_get_contents (filename, &contents, &length, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to download %s from %s: %s (unable to read file)", filename, uri, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* check we have some data */
- if (length == 0) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to download %s from %s: no data", filename, uri);
- ret = FALSE;
- goto out;
- }
-
- /* check this really isn't a fancy 404 page */
- if (g_str_has_prefix (contents, "<html>")) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to download %s from %s: invalid file", filename, uri);
- ret = FALSE;
- goto out;
- }
-
-out:
- g_free (contents);
- g_object_unref (download);
- return ret;
-}
-
-/**
- * zif_store_remote_ensure_parent_dir_exists:
- **/
-static gboolean
-zif_store_remote_ensure_parent_dir_exists (const gchar *filename, GError **error)
-{
- gchar *dirname = NULL;
- dirname = g_path_get_dirname (filename);
- if (!g_file_test (dirname, G_FILE_TEST_EXISTS)) {
- egg_debug ("creating directory %s", dirname);
- g_mkdir_with_parents (dirname, 0777);
- }
- g_free (dirname);
- return TRUE;
-}
-
-/**
- * zif_store_remote_download:
- * @store: the #ZifStoreRemote object
- * @filename: the completion filename to download, e.g. "Packages/hal-0.0.1.rpm"
- * @directory: the directory to put the downloaded file, e.g. "/var/cache/zif"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Downloads a remote package to a local directory.
- * NOTE: if @filename is "Packages/hal-0.0.1.rpm" and @directory is "/var/cache/zif"
- * then the downloaded file will "/var/cache/zif/hal-0.0.1.rpm"
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_remote_download (ZifStoreRemote *store, const gchar *filename, const gchar *directory,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- guint len;
- gboolean ret = FALSE;
- gchar *uri = NULL;
- GError *error_local = NULL;
- gchar *filename_local = NULL;
- gchar *basename = NULL;
- const gchar *baseurl;
- ZifCompletion *completion_local;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), FALSE);
- g_return_val_if_fail (store->priv->id != NULL, FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (directory != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* if not online, then this is fatal */
- ret = zif_config_get_boolean (store->priv->config, "network", NULL);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED_AS_OFFLINE,
- "failed to download %s as offline", filename);
- goto out;
- }
-
- /* check this isn't an absolute path */
- if (g_str_has_prefix (filename, "/")) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED_AS_OFFLINE,
- "filename %s' should not be an absolute path", filename);
- ret = FALSE;
- goto out;
- }
-
- /* setup completion */
- if (store->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* if not already loaded, load */
- if (!store->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load metadata: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* we need at least one baseurl */
- if (store->priv->baseurls->len == 0) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "no baseurls for %s", store->priv->id);
- ret = FALSE;
- goto out;
- }
-
- /* get the location to download to */
- basename = g_path_get_basename (filename);
- filename_local = g_build_filename (directory, basename, NULL);
-
- /* ensure path is valid */
- ret = zif_store_remote_ensure_parent_dir_exists (filename_local, error);
- if (!ret)
- goto out;
-
- /* try to use all uris */
- len = store->priv->baseurls->len;
- completion_local = zif_completion_get_child (completion);
- for (i=0; i<len; i++) {
-
- /* build url */
- baseurl = g_ptr_array_index (store->priv->baseurls, i);
- uri = g_build_filename (baseurl, filename, NULL);
-
- /* try download */
- zif_completion_reset (completion_local);
- ret = zif_store_remote_download_try (store, uri, filename_local, cancellable, completion_local, &error_local);
- if (!ret) {
- egg_debug ("failed to download (non-fatal): %s", error_local->message);
- g_clear_error (&error_local);
- }
-
- /* free */
- g_free (uri);
-
- /* succeeded, otherwise retry with new mirrors */
- if (ret)
- break;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* nothing */
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to download %s from any sources", filename);
- goto out;
- }
-out:
- g_free (basename);
- g_free (filename_local);
- return ret;
-}
-
-/**
- * zif_store_remote_get_update_detail:
- * @store: the #ZifStoreRemote object
- * @package_id: the package_id of the package to find
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Gets the update detail for a package.
- *
- * Return value: a %ZifUpdate, or %NULL for failure
- *
- * Since: 0.0.1
- **/
-ZifUpdate *
-zif_store_remote_get_update_detail (ZifStoreRemote *store, const gchar *package_id,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- const gchar *pkgid;
- gboolean ret;
- guint i;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- GPtrArray *array_installed = NULL;
- GPtrArray *changelog = NULL;
- GPtrArray *packages = NULL;
- ZifChangeset *changeset;
- ZifCompletion *completion_local;
- ZifMd *md;
- ZifPackage *package_installed = NULL;
- ZifUpdate *update = NULL;
- gchar **split = NULL;
- gchar **split_installed = NULL;
- ZifStoreLocal *store_local = NULL;
- const gchar *version;
- gchar *to_array[] = { NULL, NULL };
-
- /* setup completion */
- if (store->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 4);
- else
- zif_completion_set_number_steps (completion, 5);
-
- /* if not already loaded, load */
- if (!store->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load metadata: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* actually get the data */
- completion_local = zif_completion_get_child (completion);
- array = zif_md_updateinfo_get_detail_for_package (ZIF_MD_UPDATEINFO (store->priv->md_updateinfo), package_id,
- cancellable, completion_local, &error_local);
- if (array == NULL) {
- /* lets try this again with fresh metadata */
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to find any details in updateinfo (but referenced in primary): %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- if (array->len != 1) {
- /* FIXME: is this valid? */
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "invalid number of update entries: %i", array->len);
- goto out;
- }
-
- /* get ZifPackage for package-id */
- md = zif_store_remote_get_primary (store);
- packages = zif_md_find_package (md, package_id, cancellable, completion_local, &error_local);
- if (packages == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "cannot find package in primary repo: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- /* FIXME: non-fatal? */
- if (packages->len == 0) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "cannot find package in primary repo: %s", package_id);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* get pkgid */
- pkgid = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (g_ptr_array_index (packages, 0)));
-
- /* get changelog and add to ZifUpdate */
- completion_local = zif_completion_get_child (completion);
- changelog = zif_md_get_changelog (ZIF_MD (store->priv->md_other_sql), pkgid, cancellable, completion_local, &error_local);
- if (changelog == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get changelog: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* get the newest installed package with this name */
- completion_local = zif_completion_get_child (completion);
- split = pk_package_id_split (package_id);
- store_local = zif_store_local_new ();
- to_array[0] = split[PK_PACKAGE_ID_NAME];
- array_installed = zif_store_resolve (ZIF_STORE (store_local), to_array, cancellable, completion_local, &error_local);
- if (array_installed == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to resolve installed package for update: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* get newest, ignore error */
- package_installed = zif_package_array_get_newest (array_installed, NULL);
- split_installed = pk_package_id_split (zif_package_get_package_id (package_installed));
-
- /* add the changesets (the changelog) to the update */
- update = g_object_ref (g_ptr_array_index (array, 0));
- for (i=0; i<changelog->len; i++) {
- changeset = g_ptr_array_index (changelog, i);
- zif_update_add_changeset (update, changeset);
-
- /* abort when the changeset is older than what we have installed */
- version = zif_changeset_get_version (changeset);
- if (version != NULL &&
- zif_compare_evr (split_installed[PK_PACKAGE_ID_VERSION], version) >= 0)
- break;
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- g_strfreev (split);
- g_strfreev (split_installed);
- if (changelog != NULL)
- g_ptr_array_unref (changelog);
- if (array != NULL)
- g_ptr_array_unref (array);
- if (array_installed != NULL)
- g_ptr_array_unref (array_installed);
- if (packages != NULL)
- g_ptr_array_unref (packages);
- if (package_installed != NULL)
- g_object_unref (package_installed);
- if (store_local != NULL)
- g_object_unref (store_local);
- return update;
-}
-
-/**
- * zif_store_remote_add_metalink:
- **/
-static gboolean
-zif_store_remote_add_metalink (ZifStoreRemote *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- GPtrArray *array = NULL;
- GError *error_local = NULL;
- const gchar *uri_tmp;
- const gchar *filename;
- gboolean ret = FALSE;
- ZifCompletion *completion_local;
- ZifDownload *download = NULL;
-
- /* if we're loading the metadata with an empty cache, the file won't yet exist. So download it */
- filename = zif_md_get_filename_uncompressed (store->priv->md_metalink);
- if (filename == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "metalink filename not set for %s", store->priv->id);
- goto out;
- }
-
- zif_completion_set_number_steps (completion, 2);
-
- /* find if the file already exists */
- ret = g_file_test (filename, G_FILE_TEST_EXISTS);
- if (!ret) {
- completion_local = zif_completion_get_child (completion);
-
- /* ensure path is valid */
- ret = zif_store_remote_ensure_parent_dir_exists (filename, error);
- if (!ret)
- goto out;
-
- /* download object directly, as we don't have the repo setup yet */
- download = zif_download_new ();
- ret = zif_download_file (download, store->priv->metalink, filename, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to download %s from %s: %s", filename, store->priv->metalink, error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- zif_completion_done (completion);
-
- /* get mirrors */
- completion_local = zif_completion_get_child (completion);
- array = zif_md_metalink_get_uris (ZIF_MD_METALINK (store->priv->md_metalink), 50, cancellable, completion_local, &error_local);
- if (array == NULL) {
- ret = FALSE;
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to add mirrors from metalink: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* nothing here? */
- if (array->len == 0) {
- ret = FALSE;
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get any mirrors from metalink: %s", filename);
- goto out;
- }
-
- zif_completion_done (completion);
-
- /* add array */
- for (i=0; i<array->len; i++) {
- uri_tmp = g_ptr_array_index (array, i);
- g_ptr_array_add (store->priv->baseurls, g_strdup (uri_tmp));
- }
-out:
- if (array != NULL)
- g_ptr_array_unref (array);
- return ret;
-}
-
-/**
- * zif_store_remote_add_mirrorlist:
- **/
-static gboolean
-zif_store_remote_add_mirrorlist (ZifStoreRemote *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- GPtrArray *array = NULL;
- GError *error_local = NULL;
- const gchar *uri_tmp;
- const gchar *filename;
- gboolean ret = FALSE;
- ZifCompletion *completion_local;
- ZifDownload *download = NULL;
-
- /* if we're loading the metadata with an empty cache, the file won't yet exist. So download it */
- filename = zif_md_get_filename_uncompressed (store->priv->md_mirrorlist);
- if (filename == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "mirrorlist filename not set for %s", store->priv->id);
- goto out;
- }
-
- zif_completion_set_number_steps (completion, 2);
-
- /* find if the file already exists */
- ret = g_file_test (filename, G_FILE_TEST_EXISTS);
- if (!ret) {
- completion_local = zif_completion_get_child (completion);
-
- /* ensure path is valid */
- ret = zif_store_remote_ensure_parent_dir_exists (filename, error);
- if (!ret)
- goto out;
-
- /* download object directly, as we don't have the repo setup yet */
- download = zif_download_new ();
- ret = zif_download_file (download, store->priv->mirrorlist, filename, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to download %s from %s: %s", filename, store->priv->mirrorlist, error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- zif_completion_done (completion);
-
- /* get mirrors */
- completion_local = zif_completion_get_child (completion);
- array = zif_md_mirrorlist_get_uris (ZIF_MD_MIRRORLIST (store->priv->md_mirrorlist), cancellable, completion_local, &error_local);
- if (array == NULL) {
- ret = FALSE;
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to add mirrors from mirrorlist: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* nothing here? */
- if (array->len == 0) {
- ret = FALSE;
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get any mirrors from mirrorlist: %s", filename);
- goto out;
- }
-
- zif_completion_done (completion);
-
- /* add array */
- for (i=0; i<array->len; i++) {
- uri_tmp = g_ptr_array_index (array, i);
- g_ptr_array_add (store->priv->baseurls, g_strdup (uri_tmp));
- }
-out:
- if (download != NULL)
- g_object_unref (download);
- if (array != NULL)
- g_ptr_array_unref (array);
- return ret;
-
-}
-
-/**
- * zif_store_remote_load_metadata:
- *
- * This function does the following things:
- *
- * - opens repomd.xml (downloading it if it doesn't exist)
- * - parses the contents, and populates the ZifMd types
- * - parses metalink and mirrorlink into lists of plain urls
- * - checks all the compressed metadata checksums are valid, else they are deleted
- * - checks all the uncompressed metadata checksums are valid, else they are deleted
- **/
-static gboolean
-zif_store_remote_load_metadata (ZifStoreRemote *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- guint i;
- ZifCompletion *completion_local;
- const gchar *location;
- gboolean ret = TRUE;
- gchar *contents = NULL;
- gchar *basename;
- gchar *filename;
- gboolean primary_okay = FALSE;
- gsize size;
- GError *error_local = NULL;
- ZifMd *md;
- GMarkupParseContext *context = NULL;
- const GMarkupParser gpk_store_remote_markup_parser = {
- zif_store_remote_parser_start_element,
- zif_store_remote_parser_end_element,
- zif_store_remote_parser_text,
- NULL, /* passthrough */
- NULL /* error */
- };
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), FALSE);
-
- /* not locked */
- ret = zif_lock_is_locked (store->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* already loaded */
- if (store->priv->loaded_metadata)
- goto out;
-
- /* setup completion */
- zif_completion_set_number_steps (completion, 4);
-
- /* extract details from mirrorlist */
- if (store->priv->mirrorlist != NULL) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_add_mirrorlist (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to add mirrorlist: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* extract details from metalink */
- if (store->priv->metalink != NULL) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_add_metalink (store, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to add metalink: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* check we got something */
- if (store->priv->baseurls->len == 0) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- "no baseurls for %s, so can't download anything! [meta:%s, mirror:%s]",
- store->priv->id, store->priv->metalink, store->priv->mirrorlist);
- ret = FALSE;
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* repomd file does not exist */
- ret = g_file_test (store->priv->repomd_filename, G_FILE_TEST_EXISTS);
- if (!ret) {
- /* if not online, then this is fatal */
- ret = zif_config_get_boolean (store->priv->config, "network", NULL);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED_AS_OFFLINE,
- "failed to download repomd as offline");
- goto out;
- }
-
- /* download new file */
- completion_local = zif_completion_get_child (completion);
- store->priv->loaded_metadata = TRUE;
- ret = zif_store_remote_download (store, "repodata/repomd.xml", store->priv->directory, cancellable, completion_local, &error_local);
- store->priv->loaded_metadata = FALSE;
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to download missing repomd: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* get repo contents */
- ret = g_file_get_contents (store->priv->repomd_filename, &contents, &size, error);
- if (!ret)
- goto out;
-
- /* create parser */
- context = g_markup_parse_context_new (&gpk_store_remote_markup_parser, G_MARKUP_PREFIX_ERROR_POSITION, store, NULL);
-
- /* parse data */
- ret = g_markup_parse_context_parse (context, contents, (gssize) size, error);
- if (!ret)
- goto out;
-
- /* set MD id and filename for each repo type */
- for (i=0; i<ZIF_MD_TYPE_UNKNOWN; i++) {
- md = zif_store_remote_get_md_from_type (store, i);
- if (md == NULL) {
- /* TODO: until we've created ZifMdComps and ZifMdOther we'll get warnings here */
- egg_debug ("failed to get local store for %s with %s", zif_md_type_to_text (i), store->priv->id);
- continue;
- }
-
- /* no metalink? */
- if (i == ZIF_MD_TYPE_METALINK)
- continue;
-
- /* no mirrorlist? */
- if (i == ZIF_MD_TYPE_MIRRORLIST)
- continue;
-
- /* ensure we have at least one primary */
- location = zif_md_get_location (md);
- if (location != NULL &&
- (i == ZIF_MD_TYPE_PRIMARY_SQL ||
- i == ZIF_MD_TYPE_PRIMARY_XML)) {
- primary_okay = TRUE;
- }
-
- /* location not set */
- if (location == NULL) {
- egg_debug ("no location set for %s with %s", zif_md_type_to_text (i), store->priv->id);
- continue;
- }
-
- /* set MD id and filename */
- basename = g_path_get_basename (location);
- filename = g_build_filename (store->priv->directory, basename, NULL);
- zif_md_set_filename (md, filename);
- g_free (basename);
- g_free (filename);
- }
-
- /* messed up repo file, this is fatal */
- if (!primary_okay) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get primary metadata location for %s", store->priv->id);
- ret = FALSE;
- goto out;
- }
-
- /* all okay */
- store->priv->loaded_metadata = TRUE;
-
- /* this section done */
- zif_completion_done (completion);
-out:
- if (context != NULL)
- g_markup_parse_context_free (context);
- g_free (contents);
- return ret;
-}
-
-/**
- * zif_store_file_decompress:
- **/
-static gboolean
-zif_store_file_decompress (const gchar *filename, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = TRUE;
- gboolean compressed;
- gchar *filename_uncompressed = NULL;
-
- /* only do for compressed filenames */
- compressed = zif_file_is_compressed_name (filename);
- if (!compressed) {
- egg_debug ("%s not compressed", filename);
- goto out;
- }
-
- /* get new name */
- filename_uncompressed = zif_file_get_uncompressed_name (filename);
-
- /* decompress */
- ret = zif_file_decompress (filename, filename_uncompressed, cancellable, completion, error);
-out:
- g_free (filename_uncompressed);
- return ret;
-}
-
-/**
- * zif_store_remote_refresh:
- **/
-static gboolean
-zif_store_remote_refresh (ZifStore *store, gboolean force, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- GError *error_local = NULL;
- const gchar *filename;
- ZifCompletion *completion_local = NULL;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifMd *md;
- guint i;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), FALSE);
- g_return_val_if_fail (remote->priv->id != NULL, FALSE);
-
- /* if not online, then this is fatal */
- ret = zif_config_get_boolean (remote->priv->config, "network", NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED_AS_OFFLINE,
- "failed to refresh as offline");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- zif_completion_set_number_steps (completion, (ZIF_MD_TYPE_UNKNOWN * 2) + 2);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* get local completion object */
- completion_local = zif_completion_get_child (completion);
-
- /* download new repomd file */
- ret = zif_store_remote_download (remote, "repodata/repomd.xml", remote->priv->directory, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to download repomd: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* reload */
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load updated metadata: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* refresh each repo type */
- for (i=0; i<ZIF_MD_TYPE_UNKNOWN; i++) {
- md = zif_store_remote_get_md_from_type (remote, i);
- if (md == NULL) {
- egg_debug ("failed to get local store for %s", zif_md_type_to_text (i));
- continue;
- }
-
- /* get filename */
- filename = zif_md_get_location (md);
- if (filename == NULL) {
- egg_warning ("no filename set for %s", zif_md_type_to_text (i));
- continue;
- }
-
- /* does current uncompressed file equal what repomd says it should be */
- ret = zif_md_file_check (md, TRUE, &error_local);
- if (!ret) {
- egg_warning ("failed to verify md: %s", error_local->message);
- g_clear_error (&error_local);
- }
- if (ret && !force) {
- egg_debug ("%s is okay, and we're not forcing", zif_md_type_to_text (i));
- continue;
- }
-
- /* download new file */
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_download (remote, filename, remote->priv->directory, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to refresh %s (%s): %s", zif_md_type_to_text (i), filename, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* decompress */
- completion_local = zif_completion_get_child (completion);
- filename = zif_md_get_filename (md);
- ret = zif_store_file_decompress (filename, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to decompress %s for %s: %s",
- filename, zif_md_type_to_text (i), error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
-out:
- return ret;
-}
-
-/**
- * zif_store_remote_load:
- *
- * This function has to be fast, so don't download anything or load any
- * databases until zif_store_remote_load_metadata().
- **/
-static gboolean
-zif_store_remote_load (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GKeyFile *file = NULL;
- gboolean ret = TRUE;
- gchar *enabled = NULL;
- GError *error_local = NULL;
- gchar *temp;
- gchar *filename;
-// ZifCompletion *completion_local;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), FALSE);
- g_return_val_if_fail (remote->priv->id != NULL, FALSE);
- g_return_val_if_fail (remote->priv->repo_filename != NULL, FALSE);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* already loaded */
- if (remote->priv->loaded)
- goto out;
-
- /* setup completion with the correct number of steps */
- zif_completion_set_number_steps (completion, 2);
-
- file = g_key_file_new ();
- ret = g_key_file_load_from_file (file, remote->priv->repo_filename, G_KEY_FILE_NONE, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load %s: %s", remote->priv->repo_filename, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* name */
- remote->priv->name = g_key_file_get_string (file, remote->priv->id, "name", &error_local);
- if (error_local != NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get name: %s", error_local->message);
- g_error_free (error_local);
- ret = FALSE;
- goto out;
- }
-
- /* enabled */
- enabled = g_key_file_get_string (file, remote->priv->id, "enabled", &error_local);
- if (enabled == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get enabled: %s", error_local->message);
- g_error_free (error_local);
- ret = FALSE;
- goto out;
- }
-
- /* convert to bool */
- remote->priv->enabled = zif_boolean_from_text (enabled);
-
- /* expand out */
- remote->priv->name_expanded = zif_config_expand_substitutions (remote->priv->config, remote->priv->name, NULL);
-
- /* get base url (allowed to be blank) */
- temp = g_key_file_get_string (file, remote->priv->id, "baseurl", NULL);
- if (temp != NULL && temp[0] != '\0')
- g_ptr_array_add (remote->priv->baseurls, zif_config_expand_substitutions (remote->priv->config, temp, NULL));
- g_free (temp);
-
- /* get mirror list (allowed to be blank) */
- temp = g_key_file_get_string (file, remote->priv->id, "mirrorlist", NULL);
- if (temp != NULL && temp[0] != '\0')
- remote->priv->mirrorlist = zif_config_expand_substitutions (remote->priv->config, temp, NULL);
- g_free (temp);
-
- /* get metalink (allowed to be blank) */
- temp = g_key_file_get_string (file, remote->priv->id, "metalink", NULL);
- if (temp != NULL && temp[0] != '\0')
- remote->priv->metalink = zif_config_expand_substitutions (remote->priv->config, temp, NULL);
- g_free (temp);
-
- /* urgh.. yum allows mirrorlist= to be used as well as metalink= for metalink URLs */
- if (remote->priv->metalink == NULL &&
- remote->priv->mirrorlist != NULL &&
- g_strstr_len (remote->priv->mirrorlist, -1, "metalink?") != NULL) {
- /* swap */
- remote->priv->metalink = remote->priv->mirrorlist;
- remote->priv->mirrorlist = NULL;
- }
-
- /* we have to set this here in case we are using the metalink to download repodata.xml */
- if (remote->priv->metalink != NULL) {
- filename = g_build_filename (remote->priv->directory, "metalink.xml", NULL);
- zif_md_set_filename (remote->priv->md_metalink, filename);
- g_free (filename);
- }
-
- /* we have to set this here in case we are using the mirrorlist to download repodata.xml */
- if (remote->priv->mirrorlist != NULL) {
- filename = g_build_filename (remote->priv->directory, "mirrorlist.txt", NULL);
- zif_md_set_filename (remote->priv->md_mirrorlist, filename);
- g_free (filename);
- }
-
- /* we need either a base url or mirror list for an enabled store */
- if (remote->priv->enabled &&
- remote->priv->baseurls->len == 0 &&
- remote->priv->metalink == NULL &&
- remote->priv->mirrorlist == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "baseurl, metalink or mirrorlist required");
- ret = FALSE;
- goto out;
- }
-
- /* okay */
- remote->priv->loaded = TRUE;
-
- /* this section done */
- zif_completion_done (completion);
-out:
- g_free (enabled);
- if (file != NULL)
- g_key_file_free (file);
- return ret;
-}
-
-/**
- * zif_store_remote_clean:
- **/
-static gboolean
-zif_store_remote_clean (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- gboolean exists;
- GError *error_local = NULL;
- GFile *file;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- ZifMd *md;
- guint i;
- const gchar *location;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), FALSE);
- g_return_val_if_fail (remote->priv->id != NULL, FALSE);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion with the correct number of steps */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1+ZIF_MD_TYPE_UNKNOWN);
- else
- zif_completion_set_number_steps (completion, 2+ZIF_MD_TYPE_UNKNOWN);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- /* ignore this error */
- g_print ("failed to load xml: %s\n", error_local->message);
- g_error_free (error_local);
- ret = TRUE;
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* set MD id and filename for each repo type */
- for (i=0; i<ZIF_MD_TYPE_UNKNOWN; i++) {
- md = zif_store_remote_get_md_from_type (remote, i);
- if (md == NULL) {
- /* TODO: until we've created ZifMdComps and ZifMdOther we'll get warnings here */
- egg_debug ("failed to get local store for %s with %s", zif_md_type_to_text (i), remote->priv->id);
- goto skip;
- }
-
- /* location not set */
- location = zif_md_get_location (md);
- if (location == NULL) {
- egg_debug ("no location set for %s with %s", zif_md_type_to_text (i), remote->priv->id);
- goto skip;
- }
-
- /* clean md */
- ret = zif_md_clean (md, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to clean %s: %s", zif_md_type_to_text (i), error_local->message);
- g_error_free (error_local);
- goto out;
- }
-skip:
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* clean master (last) */
- exists = g_file_test (remote->priv->repomd_filename, G_FILE_TEST_EXISTS);
- if (exists) {
- file = g_file_new_for_path (remote->priv->repomd_filename);
- ret = g_file_delete (file, NULL, &error_local);
- g_object_unref (file);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to delete metadata file %s: %s",
- remote->priv->repomd_filename, error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return ret;
-}
-
-/**
- * zif_store_remote_set_from_file:
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_remote_set_from_file (ZifStoreRemote *store, const gchar *repo_filename, const gchar *id,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = TRUE;
- guint i;
- GError *error_local = NULL;
- ZifMd *md;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), FALSE);
- g_return_val_if_fail (repo_filename != NULL, FALSE);
- g_return_val_if_fail (id != NULL, FALSE);
- g_return_val_if_fail (store->priv->id == NULL, FALSE);
- g_return_val_if_fail (!store->priv->loaded, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* not locked */
- ret = zif_lock_is_locked (store->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* save */
- egg_debug ("setting store %s", id);
- store->priv->id = g_strdup (id);
- store->priv->repo_filename = g_strdup (repo_filename);
- store->priv->directory = g_build_filename (store->priv->cache_dir, store->priv->id, NULL);
-
- /* repomd location */
- store->priv->repomd_filename = g_build_filename (store->priv->cache_dir, store->priv->id, "repomd.xml", NULL);
-
- /* set MD id for each repo type */
- for (i=0; i<ZIF_MD_TYPE_UNKNOWN; i++) {
- md = zif_store_remote_get_md_from_type (store, i);
- if (md == NULL)
- continue;
- zif_md_set_id (md, store->priv->id);
- }
-
- /* setup watch */
- ret = zif_monitor_add_watch (store->priv->monitor, repo_filename, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to setup watch: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* get data */
- ret = zif_store_remote_load (ZIF_STORE (store), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load %s: %s", id, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-out:
- /* save */
- return ret;
-}
-
-/**
- * zif_store_remote_set_enabled:
- * @store: the #ZifStoreRemote object
- * @enabled: If the object should be enabled
- * @error: a #GError which is used on failure, or %NULL
- *
- * Enable or disable a remote repository.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_remote_set_enabled (ZifStoreRemote *store, gboolean enabled, GError **error)
-{
- GKeyFile *file;
- gboolean ret;
- GError *error_local = NULL;
- gchar *data;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), FALSE);
- g_return_val_if_fail (store->priv->id != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* not locked */
- ret = zif_lock_is_locked (store->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* load file */
- file = g_key_file_new ();
- ret = g_key_file_load_from_file (file, store->priv->repo_filename, G_KEY_FILE_KEEP_COMMENTS, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load store file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* toggle enabled */
- store->priv->enabled = enabled;
- g_key_file_set_boolean (file, store->priv->id, "enabled", store->priv->enabled);
-
- /* save new data to file */
- data = g_key_file_to_data (file, NULL, &error_local);
- if (data == NULL) {
- ret = FALSE;
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get save data: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- ret = g_file_set_contents (store->priv->repo_filename, data, -1, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to save: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- g_free (data);
- g_key_file_free (file);
-out:
- return ret;
-}
-
-/**
- * zif_store_remote_print:
- **/
-static void
-zif_store_remote_print (ZifStore *store)
-{
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
-
- g_return_if_fail (ZIF_IS_STORE_REMOTE (store));
- g_return_if_fail (remote->priv->id != NULL);
-
- g_print ("id: %s\n", remote->priv->id);
- g_print ("name: %s\n", remote->priv->name);
- g_print ("name-expanded: %s\n", remote->priv->name_expanded);
- g_print ("enabled: %i\n", remote->priv->enabled);
-}
-
-/**
- * zif_store_remote_resolve:
- **/
-static GPtrArray *
-zif_store_remote_resolve (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- ZifMd *primary;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (remote->priv->id != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load metadata for %s: %s", remote->priv->id, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- completion_local = zif_completion_get_child (completion);
- primary = zif_store_remote_get_primary (remote);
- array = zif_md_resolve (primary, search, cancellable, completion_local, error);
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_remote_search_name:
- **/
-static GPtrArray *
-zif_store_remote_search_name (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- ZifMd *md;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (remote->priv->id != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- completion_local = zif_completion_get_child (completion);
- md = zif_store_remote_get_primary (remote);
- array = zif_md_search_name (md, search, cancellable, completion_local, error);
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_remote_search_details:
- **/
-static GPtrArray *
-zif_store_remote_search_details (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- ZifMd *md;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (remote->priv->id != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- completion_local = zif_completion_get_child (completion);
- md = zif_store_remote_get_primary (remote);
- array = zif_md_search_details (md, search, cancellable, completion_local, error);
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_remote_search_category_resolve:
- **/
-static ZifPackage *
-zif_store_remote_search_category_resolve (ZifStore *store, const gchar *name, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreLocal *store_local = NULL;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- ZifPackage *package = NULL;
- ZifCompletion *completion_local;
- const gchar *to_array[] = { NULL, NULL };
-
- store_local = zif_store_local_new ();
-
- /* setup steps */
- zif_completion_set_number_steps (completion, 2);
-
- /* is already installed? */
- completion_local = zif_completion_get_child (completion);
- to_array[0] = name;
- array = zif_store_resolve (ZIF_STORE (store_local), (gchar**) to_array, cancellable, completion_local, &error_local);
- if (array == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to resolve installed package %s: %s", name, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* get newest, ignore error */
- package = zif_package_array_get_newest (array, NULL);
- if (package != NULL) {
- /* we don't need to do the second part */
- zif_completion_done (completion);
- goto out;
- }
-
- /* clear array */
- g_ptr_array_unref (array);
-
- /* is available in this repo? */
- completion_local = zif_completion_get_child (completion);
- to_array[0] = name;
- array = zif_store_resolve (ZIF_STORE (store), (gchar**)to_array, cancellable, completion_local, &error_local);
- if (array == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to resolve installed package %s: %s", name, error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* get newest, ignore error */
- package = zif_package_array_get_newest (array, NULL);
- if (package != NULL)
- goto out;
-
- /* we suck */
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED_TO_FIND,
- "failed to resolve installed package %s installed or in this repo", name);
-out:
- if (array != NULL)
- g_ptr_array_unref (array);
- if (store_local != NULL)
- g_object_unref (store_local);
- return package;
-}
-
-/**
- * zif_store_remote_search_category:
- **/
-static GPtrArray *
-zif_store_remote_search_category (ZifStore *store, gchar **group_id, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- GPtrArray *array_names = NULL;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- ZifCompletion *completion_loop;
- ZifPackage *package;
- const gchar *name;
- const gchar *location;
- guint i;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (remote->priv->id != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 2);
- else
- zif_completion_set_number_steps (completion, 3);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* does this repo have comps data? */
- location = zif_md_get_location (remote->priv->md_comps);
- if (location == NULL) {
- /* empty array, as we want success */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- zif_completion_finished (completion);
- goto out;
- }
-
- /* get package names for group */
- completion_local = zif_completion_get_child (completion);
- array_names = zif_md_comps_get_packages_for_group (ZIF_MD_COMPS (remote->priv->md_comps),
- group_id[0], cancellable, completion_local, &error_local);
- if (array_names == NULL) {
- /* ignore when group isn't present, TODO: use GError code */
- if (g_str_has_prefix (error_local->message, "could not find group")) {
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- g_error_free (error_local);
- zif_completion_finished (completion);
- goto out;
- }
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get packages for group %s: %s", group_id[0], error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* setup completion */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, array_names->len);
-
- /* results array */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-
- /* resolve names */
- for (i=0; i<array_names->len; i++) {
- name = g_ptr_array_index (array_names, i);
-
- /* completion */
- completion_loop = zif_completion_get_child (completion_local);
- package = zif_store_remote_search_category_resolve (store, name, cancellable, completion_loop, &error_local);
- if (package == NULL) {
- /* ignore when package isn't present */
- if (error_local->code == ZIF_STORE_ERROR_FAILED_TO_FIND) {
- g_clear_error (&error_local);
- egg_debug ("Failed to find %s installed or in repo %s", name, remote->priv->id);
- goto ignore_error;
- }
-
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get resolve %s for %s: %s", name, group_id[0], error_local->message);
- g_error_free (error_local);
-
- /* undo all our hard work */
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
-
- /* add to array */
- g_ptr_array_add (array, package);
-ignore_error:
- /* this section done */
- zif_completion_done (completion_local);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- if (array_names != NULL)
- g_ptr_array_unref (array_names);
- return array;
-}
-
-/**
- * zif_store_remote_search_group:
- **/
-static GPtrArray *
-zif_store_remote_search_group (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- ZifMd *primary;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (remote->priv->id != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- completion_local = zif_completion_get_child (completion);
- primary = zif_store_remote_get_primary (remote);
- array = zif_md_search_group (primary, search, cancellable, completion_local, error);
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_remote_find_package:
- **/
-static ZifPackage *
-zif_store_remote_find_package (ZifStore *store, const gchar *package_id, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GPtrArray *array = NULL;
- ZifPackage *package = NULL;
- GError *error_local = NULL;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- ZifMd *primary;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (remote->priv->id != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* search with predicate, TODO: search version (epoch+release) */
- completion_local = zif_completion_get_child (completion);
- primary = zif_store_remote_get_primary (remote);
- array = zif_md_find_package (primary, package_id, cancellable, completion_local, &error_local);
- if (array == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to search: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* nothing */
- if (array->len == 0) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED_TO_FIND,
- "failed to find package");
- goto out;
- }
-
- /* more than one match */
- if (array->len > 1) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_MULTIPLE_MATCHES,
- "more than one match");
- goto out;
- }
-
- /* return ref to package */
- package = g_object_ref (g_ptr_array_index (array, 0));
-out:
- g_ptr_array_unref (array);
- return package;
-}
-
-/**
- * zif_store_remote_get_packages:
- **/
-static GPtrArray *
-zif_store_remote_get_packages (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- ZifMd *primary;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (remote->priv->id != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- primary = zif_store_remote_get_primary (remote);
- completion_local = zif_completion_get_child (completion);
- array = zif_md_get_packages (primary, cancellable, completion_local, error);
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_remote_get_categories:
- **/
-static GPtrArray *
-zif_store_remote_get_categories (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- guint i, j;
- const gchar *location;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- GPtrArray *array_cats = NULL;
- GPtrArray *array_groups;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- ZifCompletion *completion_loop;
- PkCategory *group;
- PkCategory *category;
- PkCategory *category_tmp;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (remote->priv->id != NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 2);
- else
- zif_completion_set_number_steps (completion, 3);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* does this repo have comps data? */
- location = zif_md_get_location (remote->priv->md_comps);
- if (location == NULL) {
- /* empty array, as we want success */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- goto out;
- }
-
- /* get list of categories */
- completion_local = zif_completion_get_child (completion);
- array_cats = zif_md_comps_get_categories (ZIF_MD_COMPS (remote->priv->md_comps), cancellable, completion_local, &error_local);
- if (array_cats == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get categories: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* results array */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-
- /* no results */
- if (array_cats->len == 0)
- goto skip;
-
- /* setup steps */
- completion_local = zif_completion_get_child (completion);
- zif_completion_set_number_steps (completion_local, array_cats->len);
-
- /* get groups for categories */
- for (i=0; i<array_cats->len; i++) {
- category = g_ptr_array_index (array_cats, i);
-
- /* get the groups for this category */
- completion_loop = zif_completion_get_child (completion_local);
- array_groups = zif_md_comps_get_groups_for_category (ZIF_MD_COMPS (remote->priv->md_comps),
- pk_category_get_id (category), cancellable, completion_loop, &error_local);
- if (array_groups == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to get groups for %s: %s", pk_category_get_id (category), error_local->message);
- g_error_free (error_local);
-
- /* undo the work we've already done */
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
-
- /* only add categories which have groups */
- if (array_groups->len > 0) {
-
- /* first, add the parent */
- g_ptr_array_add (array, g_object_ref (category));
-
- /* second, add the groups belonging to this parent */
- for (j=0; j<array_groups->len; j++) {
- group = g_ptr_array_index (array_groups, j);
- category_tmp = g_object_ref (group);
- g_ptr_array_add (array, category_tmp);
- }
- }
-
- /* this section done */
- zif_completion_done (completion_local);
- }
-skip:
- /* this section done */
- zif_completion_done (completion);
-out:
- if (array_cats != NULL)
- g_ptr_array_unref (array_cats);
- return array;
-}
-
-/**
- * zif_store_remote_get_updates:
- **/
-static GPtrArray *
-zif_store_remote_get_updates (ZifStore *store, GPtrArray *packages,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GPtrArray *updates = NULL;
- GPtrArray *array = NULL;
- ZifPackage *package;
- ZifPackage *update;
- GError *error_local = NULL;
- guint i, j;
- gint val;
- const gchar *package_id;
- const gchar *package_id_update;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifCompletion *completion_local;
- gchar **split;
- gchar **split_update;
- ZifMd *primary;
- gchar **resolve_array = NULL;
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* create array for packages to update */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-
- /* get primary */
- primary = zif_store_remote_get_primary (remote);
-
- /* get the array of packages to resolve */
- resolve_array = g_new0 (gchar *, packages->len + 1);
- for (i=0; i<packages->len; i++) {
- package = ZIF_PACKAGE (g_ptr_array_index (packages, i));
- package_id = zif_package_get_id (package);
- split = pk_package_id_split (package_id);
- resolve_array[i] = g_strdup (split[PK_PACKAGE_ID_NAME]);
- g_strfreev (split);
- }
-
- /* resolve all of them in one fell swoop */
- completion_local = zif_completion_get_child (completion);
- updates = zif_md_resolve (primary, resolve_array,
- cancellable, completion_local, &error_local);
- if (updates == NULL) {
- egg_error ("failed to resolve: %s", error_local->message);
- g_error_free (error_local);
- }
-
- /* some repos contain lots of versions of one package */
- zif_package_array_filter_newest (updates);
-
- /* find each one in a remote repo */
- for (i=0; i<packages->len; i++) {
- package = ZIF_PACKAGE (g_ptr_array_index (packages, i));
- package_id = zif_package_get_id (package);
-
- /* find updates */
- for (j=0; j<updates->len; j++) {
- update = ZIF_PACKAGE (g_ptr_array_index (updates, j));
-
- /* newer? */
- val = zif_package_compare (update, package);
- if (val == G_MAXINT)
- continue;
- if (val > 0) {
- package_id_update = zif_package_get_id (update);
- split = pk_package_id_split (package_id);
- split_update = pk_package_id_split (package_id_update);
- egg_debug ("*** update %s from %s to %s",
- split[PK_PACKAGE_ID_NAME],
- split[PK_PACKAGE_ID_VERSION],
- split_update[PK_PACKAGE_ID_VERSION]);
- g_strfreev (split);
- g_strfreev (split_update);
- g_ptr_array_add (array, g_object_ref (update));
- }
- }
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- g_strfreev (resolve_array);
- if (updates != NULL)
- g_ptr_array_unref (updates);
- return array;
-}
-
-/**
- * zif_store_remote_what_provides:
- **/
-static GPtrArray *
-zif_store_remote_what_provides (ZifStore *store, gchar **search,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *array = NULL;
- ZifCompletion *completion_local;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifMd *primary;
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 1);
- else
- zif_completion_set_number_steps (completion, 2);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* get details */
- completion_local = zif_completion_get_child (completion);
- primary = zif_store_remote_get_primary (remote);
- array = zif_md_what_provides (primary, search,
- cancellable, completion_local, error);
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_remote_search_file:
- **/
-static GPtrArray *
-zif_store_remote_search_file (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *pkgids;
- GPtrArray *array = NULL;
- GPtrArray *tmp;
- ZifPackage *package;
- ZifCompletion *completion_local;
- const gchar *pkgid;
- guint i, j;
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- ZifMd *primary;
- ZifMd *filelists;
- const gchar *to_array[] = { NULL, NULL };
-
- /* not locked */
- ret = zif_lock_is_locked (remote->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* setup completion */
- if (remote->priv->loaded_metadata)
- zif_completion_set_number_steps (completion, 2);
- else
- zif_completion_set_number_steps (completion, 3);
-
- /* load metadata */
- if (!remote->priv->loaded_metadata) {
- completion_local = zif_completion_get_child (completion);
- ret = zif_store_remote_load_metadata (remote, cancellable, completion_local, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load xml: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
- }
-
- /* gets a list of pkgId's that match this file */
- completion_local = zif_completion_get_child (completion);
- filelists = zif_store_remote_get_filelists (remote);
- pkgids = zif_md_search_file (filelists,
- search, cancellable, completion_local, &error_local);
- if (pkgids == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load get list of pkgids: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* this section done */
- zif_completion_done (completion);
-
- /* get primary */
- primary = zif_store_remote_get_primary (remote);
-
- /* resolve the pkgId to a set of packages */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- for (i=0; i<pkgids->len; i++) {
- pkgid = g_ptr_array_index (pkgids, i);
-
- /* get the results (should just be one) */
- completion_local = zif_completion_get_child (completion);
- to_array[0] = pkgid;
- tmp = zif_md_search_pkgid (primary, (gchar **) to_array, cancellable, completion_local, &error_local);
- if (tmp == NULL) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED_TO_FIND,
- "failed to resolve pkgId to package: %s", error_local->message);
- g_error_free (error_local);
- /* free what we've collected already */
- g_ptr_array_unref (array);
- array = NULL;
- goto out;
- }
-
- /* add to main array */
- for (j=0; j<tmp->len; j++) {
- package = g_ptr_array_index (tmp, j);
- g_ptr_array_add (array, g_object_ref (package));
- }
-
- /* free temp array */
- g_ptr_array_unref (tmp);
- }
-
- /* this section done */
- zif_completion_done (completion);
-out:
- return array;
-}
-
-/**
- * zif_store_remote_is_devel:
- * @store: the #ZifStoreRemote object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds out if the repository is a development repository.
- *
- * Return value: %TRUE or %FALSE
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_remote_is_devel (ZifStoreRemote *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), FALSE);
- g_return_val_if_fail (store->priv->id != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* not locked */
- ret = zif_lock_is_locked (store->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* if not already loaded, load */
- if (!store->priv->loaded) {
- ret = zif_store_remote_load (ZIF_STORE (store), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load store file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* do tests */
- if (g_str_has_suffix (store->priv->id, "-debuginfo"))
- return TRUE;
- if (g_str_has_suffix (store->priv->id, "-testing"))
- return TRUE;
- if (g_str_has_suffix (store->priv->id, "-debug"))
- return TRUE;
- if (g_str_has_suffix (store->priv->id, "-development"))
- return TRUE;
- if (g_str_has_suffix (store->priv->id, "-source"))
- return TRUE;
-out:
- return FALSE;
-}
-
-/**
- * zif_store_remote_get_id:
- * @store: the #ZifStoreRemote object
- *
- * Get the id of this repository.
- *
- * Return value: The repository id, e.g. "fedora"
- **/
-static const gchar *
-zif_store_remote_get_id (ZifStore *store)
-{
- ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- return remote->priv->id;
-}
-
-/**
- * zif_store_remote_get_name:
- * @store: the #ZifStoreRemote object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Get the name of this repository.
- *
- * Return value: The repository name, e.g. "Fedora"
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_store_remote_get_name (ZifStoreRemote *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (store->priv->id != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* not locked */
- ret = zif_lock_is_locked (store->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* if not already loaded, load */
- if (!store->priv->loaded) {
- ret = zif_store_remote_load (ZIF_STORE (store), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load store file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-out:
- return store->priv->name_expanded;
-}
-
-/**
- * zif_store_remote_get_enabled:
- * @store: the #ZifStoreRemote object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find out if this repository is enabled or not.
- *
- * Return value: %TRUE or %FALSE
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_remote_get_enabled (ZifStoreRemote *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- GError *error_local = NULL;
- gboolean ret;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), FALSE);
- g_return_val_if_fail (store->priv->id != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* not locked */
- ret = zif_lock_is_locked (store->priv->lock, NULL);
- if (!ret) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NOT_LOCKED,
- "not locked");
- goto out;
- }
-
- /* if not already loaded, load */
- if (!store->priv->loaded) {
- ret = zif_store_remote_load (ZIF_STORE (store), cancellable, completion, &error_local);
- if (!ret) {
- g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
- "failed to load store file: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-out:
- return store->priv->enabled;
-}
-
-/**
- * zif_store_remote_get_files:
- **/
-GPtrArray *
-zif_store_remote_get_files (ZifStoreRemote *store, ZifPackage *package,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifMd *filelists;
-
- g_return_val_if_fail (ZIF_IS_STORE_REMOTE (store), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- filelists = zif_store_remote_get_filelists (store);
- return zif_md_get_files (filelists, package, cancellable, completion, error);
-}
-
-/**
- * zif_store_remote_file_monitor_cb:
- **/
-static void
-zif_store_remote_file_monitor_cb (ZifMonitor *monitor, ZifStoreRemote *store)
-{
- /* free invalid data */
- g_free (store->priv->id);
- g_free (store->priv->name);
- g_free (store->priv->name_expanded);
- g_free (store->priv->repo_filename);
- g_ptr_array_set_size (store->priv->baseurls, 0);
- g_free (store->priv->mirrorlist);
- g_free (store->priv->metalink);
-
- store->priv->loaded = FALSE;
- store->priv->loaded_metadata = FALSE;
- store->priv->enabled = FALSE;
- store->priv->id = NULL;
- store->priv->name = NULL;
- store->priv->name_expanded = NULL;
- store->priv->repo_filename = NULL;
- store->priv->mirrorlist = NULL;
- store->priv->metalink = NULL;
-
- egg_debug ("store file changed");
-}
-
-/**
- * zif_store_remote_finalize:
- **/
-static void
-zif_store_remote_finalize (GObject *object)
-{
- ZifStoreRemote *store;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_STORE_REMOTE (object));
- store = ZIF_STORE_REMOTE (object);
-
- g_free (store->priv->id);
- g_free (store->priv->name);
- g_free (store->priv->name_expanded);
- g_free (store->priv->repo_filename);
- g_free (store->priv->mirrorlist);
- g_free (store->priv->metalink);
- g_free (store->priv->cache_dir);
- g_free (store->priv->repomd_filename);
- g_free (store->priv->directory);
-
- g_object_unref (store->priv->md_other_sql);
- g_object_unref (store->priv->md_primary_sql);
- g_object_unref (store->priv->md_primary_xml);
- g_object_unref (store->priv->md_filelists_sql);
- g_object_unref (store->priv->md_filelists_xml);
- g_object_unref (store->priv->md_comps);
- g_object_unref (store->priv->md_updateinfo);
- g_object_unref (store->priv->md_metalink);
- g_object_unref (store->priv->md_mirrorlist);
- g_object_unref (store->priv->config);
- g_object_unref (store->priv->monitor);
- g_object_unref (store->priv->lock);
-
- g_ptr_array_unref (store->priv->baseurls);
-
- G_OBJECT_CLASS (zif_store_remote_parent_class)->finalize (object);
-}
-
-/**
- * zif_store_remote_class_init:
- **/
-static void
-zif_store_remote_class_init (ZifStoreRemoteClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- ZifStoreClass *store_class = ZIF_STORE_CLASS (klass);
- object_class->finalize = zif_store_remote_finalize;
-
- /* map */
- store_class->load = zif_store_remote_load;
- store_class->clean = zif_store_remote_clean;
- store_class->refresh = zif_store_remote_refresh;
- store_class->search_name = zif_store_remote_search_name;
- store_class->search_category = zif_store_remote_search_category;
- store_class->search_details = zif_store_remote_search_details;
- store_class->search_group = zif_store_remote_search_group;
- store_class->search_file = zif_store_remote_search_file;
- store_class->resolve = zif_store_remote_resolve;
- store_class->what_provides = zif_store_remote_what_provides;
- store_class->get_packages = zif_store_remote_get_packages;
- store_class->get_updates = zif_store_remote_get_updates;
- store_class->find_package = zif_store_remote_find_package;
- store_class->get_categories = zif_store_remote_get_categories;
- store_class->get_id = zif_store_remote_get_id;
- store_class->print = zif_store_remote_print;
-
- g_type_class_add_private (klass, sizeof (ZifStoreRemotePrivate));
-}
-
-/**
- * zif_store_remote_init:
- **/
-static void
-zif_store_remote_init (ZifStoreRemote *store)
-{
- gchar *cache_dir = NULL;
- guint i;
- GError *error = NULL;
- ZifMd *md;
-
- store->priv = ZIF_STORE_REMOTE_GET_PRIVATE (store);
- store->priv->loaded = FALSE;
- store->priv->loaded_metadata = FALSE;
- store->priv->id = NULL;
- store->priv->name = NULL;
- store->priv->directory = NULL;
- store->priv->name_expanded = NULL;
- store->priv->enabled = FALSE;
- store->priv->repo_filename = NULL;
- store->priv->baseurls = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- store->priv->mirrorlist = NULL;
- store->priv->metalink = NULL;
- store->priv->config = zif_config_new ();
- store->priv->monitor = zif_monitor_new ();
- store->priv->lock = zif_lock_new ();
- store->priv->md_filelists_sql = ZIF_MD (zif_md_filelists_sql_new ());
- store->priv->md_filelists_xml = ZIF_MD (zif_md_filelists_xml_new ());
- store->priv->md_other_sql = ZIF_MD (zif_md_other_sql_new ());
- store->priv->md_primary_sql = ZIF_MD (zif_md_primary_sql_new ());
- store->priv->md_primary_xml = ZIF_MD (zif_md_primary_xml_new ());
- store->priv->md_metalink = ZIF_MD (zif_md_metalink_new ());
- store->priv->md_mirrorlist = ZIF_MD (zif_md_mirrorlist_new ());
- store->priv->md_comps = ZIF_MD (zif_md_comps_new ());
- store->priv->md_updateinfo = ZIF_MD (zif_md_updateinfo_new ());
- store->priv->parser_type = ZIF_MD_TYPE_UNKNOWN;
- store->priv->parser_section = ZIF_STORE_REMOTE_PARSER_SECTION_UNKNOWN;
- g_signal_connect (store->priv->monitor, "changed", G_CALLBACK (zif_store_remote_file_monitor_cb), store);
-
- /* get cache */
- cache_dir = zif_config_get_string (store->priv->config, "cachedir", &error);
- if (cache_dir == NULL) {
- egg_warning ("failed to get cachedir: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* expand */
- store->priv->cache_dir = zif_config_expand_substitutions (store->priv->config, cache_dir, &error);
- if (store->priv->cache_dir == NULL) {
- egg_warning ("failed to get expand substitutions: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* set MD type on each repo */
- for (i=0; i<ZIF_MD_TYPE_UNKNOWN; i++) {
- md = zif_store_remote_get_md_from_type (store, i);
- if (md == NULL)
- continue;
-
- /* set parent reference */
- zif_md_set_store_remote (md, store);
-
- /* set MD type */
- zif_md_set_mdtype (md, i);
- }
-out:
- g_free (cache_dir);
-}
-
-/**
- * zif_store_remote_new:
- *
- * Return value: A new #ZifStoreRemote class instance.
- *
- * Since: 0.0.1
- **/
-ZifStoreRemote *
-zif_store_remote_new (void)
-{
- ZifStoreRemote *store;
- store = g_object_new (ZIF_TYPE_STORE_REMOTE, NULL);
- return ZIF_STORE_REMOTE (store);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-#include "zif-groups.h"
-
-void
-zif_store_remote_test (EggTest *test)
-{
- ZifGroups *groups;
- ZifStoreRemote *store;
- ZifStoreLocal *store_local;
- GPtrArray *packages;
- ZifConfig *config;
- ZifLock *lock;
- ZifCompletion *completion;
- GPtrArray *array;
- gboolean ret;
- GError *error = NULL;
- const gchar *id;
- PkCategory *category;
- guint i;
- const gchar *in_array[] = { NULL, NULL };
-
- if (!egg_test_start (test, "ZifStoreRemote"))
- return;
-
- /* set this up as dummy */
- config = zif_config_new ();
- zif_config_set_filename (config, "../test/etc/yum.conf", NULL);
-
- /* use completion object */
- completion = zif_completion_new ();
-
- /************************************************************/
- egg_test_title (test, "get store");
- store = zif_store_remote_new ();
- egg_test_assert (test, store != NULL);
-
- /************************************************************/
- egg_test_title (test, "get lock");
- lock = zif_lock_new ();
- egg_test_assert (test, lock != NULL);
-
- /************************************************************/
- egg_test_title (test, "lock");
- ret = zif_lock_set_locked (lock, NULL, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "load from a file");
- zif_completion_reset (completion);
- ret = zif_store_remote_set_from_file (store, "../test/repos/fedora.repo", "fedora", NULL, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load '%s'", error->message);
-
- /* setup state */
- groups = zif_groups_new ();
- zif_groups_set_mapping_file (groups, "../test/share/yum-comps-groups.conf", NULL);
- store_local = zif_store_local_new ();
- zif_store_local_set_prefix (store_local, "/", NULL);
-
- /************************************************************/
- egg_test_title (test, "get updates");
- zif_completion_reset (completion);
- packages = zif_store_get_packages (ZIF_STORE (store_local), NULL, completion, &error);
- if (packages == NULL)
- egg_test_failed (test, "failed to get local store: %s", error->message);
- zif_package_array_filter_newest (packages);
- zif_completion_reset (completion);
- array = zif_store_remote_get_updates (ZIF_STORE (store), packages, NULL, completion, &error);
- if (array == NULL)
- egg_test_failed (test, "no data: %s", error->message);
- else if (array->len > 0)
- egg_test_success (test, NULL);
- else
- egg_test_success (test, "no updates"); //TODO: failure
- g_ptr_array_unref (array);
- g_ptr_array_unref (packages);
-
- /************************************************************/
- egg_test_title (test, "is devel");
- ret = zif_store_remote_is_devel (store, NULL, completion, NULL);
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "is enabled");
- ret = zif_store_remote_get_enabled (store, NULL, completion, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "get id");
- id = zif_store_get_id (ZIF_STORE (store));
- if (g_strcmp0 (id, "fedora") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid id '%s'", id);
-
- /************************************************************/
- egg_test_title (test, "get name");
- id = zif_store_remote_get_name (store, NULL, completion, NULL);
- if (g_strcmp0 (id, "Fedora 11 - i386") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid name '%s'", id);
-
- /************************************************************/
- egg_test_title (test, "load metadata");
- zif_completion_reset (completion);
- ret = zif_store_remote_load (ZIF_STORE (store), NULL, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load metadata '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "resolve");
- zif_completion_reset (completion);
- in_array[0] = "kernel";
- array = zif_store_remote_resolve (ZIF_STORE (store), (gchar**)in_array, NULL, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to resolve '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len >= 1)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
-
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "search name");
- zif_completion_reset (completion);
- in_array[0] = "power-manager";
- array = zif_store_remote_search_name (ZIF_STORE (store), (gchar**)in_array, NULL, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search name '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "search name correct number");
- if (array->len == 3)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
-
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "search details");
- zif_completion_reset (completion);
- in_array[0] = "browser plugin";
- array = zif_store_remote_search_details (ZIF_STORE (store), (gchar**)in_array, NULL, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search details '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "search details correct number");
- if (array->len == 5)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
-
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "search file");
- zif_completion_reset (completion);
- in_array[0] = "/usr/bin/gnome-power-manager";
- array = zif_store_remote_search_file (ZIF_STORE (store), (gchar**)in_array, NULL, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to search details '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "search file correct number");
- if (array->len == 1)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
-
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "set disabled");
- ret = zif_store_remote_set_enabled (store, FALSE, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to disable '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "is enabled");
- ret = zif_store_remote_get_enabled (store, NULL, completion, NULL);
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "set enabled");
- ret = zif_store_remote_set_enabled (store, TRUE, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to enable '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "is enabled");
- ret = zif_store_remote_get_enabled (store, NULL, completion, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "get packages");
- zif_completion_reset (completion);
- array = zif_store_remote_get_packages (ZIF_STORE (store), NULL, completion, &error);
- if (array != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get packages '%s'", error->message);
-
- /************************************************************/
- egg_test_title (test, "correct number");
- if (array->len > 10000)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect length %i", array->len);
-
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "get categories");
- zif_completion_reset (completion);
- array = zif_store_remote_get_categories (ZIF_STORE (store), NULL, completion, &error);
- if (array == NULL)
- egg_test_failed (test, "no data: %s", error->message);
- else if (array->len > 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "no categories"); //TODO: failure
-
- /* get first object */
- category = g_ptr_array_index (array, 0);
-
- /************************************************************/
- egg_test_title (test, "test parent_id");
- if (pk_category_get_parent_id (category) == NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect data: %s", pk_category_get_parent_id (category));
-
- /************************************************************/
- egg_test_title (test, "test cat_id");
- if (g_strcmp0 (pk_category_get_id (category), "language-support") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect data: %s", pk_category_get_id (category));
-
- /************************************************************/
- egg_test_title (test, "test name");
- if (g_strcmp0 (pk_category_get_name (category), "Languages") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect data: %s", pk_category_get_name (category));
-
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "search category");
- zif_completion_reset (completion);
- in_array[0] = "admin-tools";
- array = zif_store_remote_search_category (ZIF_STORE (store), (gchar**)in_array, NULL, completion, &error);
- if (array == NULL)
- egg_test_failed (test, "no data: %s", error->message);
- else if (array->len > 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "no results");
-
- g_ptr_array_unref (array);
-
- g_object_unref (store);
- g_object_unref (config);
- g_object_unref (lock);
- g_object_unref (completion);
- g_object_unref (groups);
- g_object_unref (store_local);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-store-remote.h b/backends/yum/libzif/zif-store-remote.h
deleted file mode 100644
index 67ad327..0000000
--- a/backends/yum/libzif/zif-store-remote.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_STORE_REMOTE_H
-#define __ZIF_STORE_REMOTE_H
-
-#include <glib-object.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-store.h"
-#include "zif-package.h"
-#include "zif-update.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_STORE_REMOTE (zif_store_remote_get_type ())
-#define ZIF_STORE_REMOTE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_STORE_REMOTE, ZifStoreRemote))
-#define ZIF_STORE_REMOTE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_STORE_REMOTE, ZifStoreRemoteClass))
-#define ZIF_IS_STORE_REMOTE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_STORE_REMOTE))
-#define ZIF_IS_STORE_REMOTE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_STORE_REMOTE))
-#define ZIF_STORE_REMOTE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_STORE_REMOTE, ZifStoreRemoteClass))
-
-typedef struct _ZifStoreRemote ZifStoreRemote;
-typedef struct _ZifStoreRemotePrivate ZifStoreRemotePrivate;
-typedef struct _ZifStoreRemoteClass ZifStoreRemoteClass;
-
-struct _ZifStoreRemote
-{
- ZifStore parent;
- ZifStoreRemotePrivate *priv;
-};
-
-struct _ZifStoreRemoteClass
-{
- ZifStoreClass parent_class;
-};
-
-GType zif_store_remote_get_type (void);
-ZifStoreRemote *zif_store_remote_new (void);
-gboolean zif_store_remote_set_from_file (ZifStoreRemote *store,
- const gchar *filename,
- const gchar *id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_store_remote_is_devel (ZifStoreRemote *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-const gchar *zif_store_remote_get_name (ZifStoreRemote *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_remote_get_files (ZifStoreRemote *store,
- ZifPackage *package,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_store_remote_get_enabled (ZifStoreRemote *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_store_remote_set_enabled (ZifStoreRemote *store,
- gboolean enabled,
- GError **error);
-gboolean zif_store_remote_download (ZifStoreRemote *store,
- const gchar *filename,
- const gchar *directory,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-ZifUpdate *zif_store_remote_get_update_detail (ZifStoreRemote *store,
- const gchar *package_id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_store_remote_check (ZifStoreRemote *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __ZIF_STORE_REMOTE_H */
-
diff --git a/backends/yum/libzif/zif-store.c b/backends/yum/libzif/zif-store.c
deleted file mode 100644
index 958cfe4..0000000
--- a/backends/yum/libzif/zif-store.c
+++ /dev/null
@@ -1,602 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-store
- * @short_description: A store is an abstract collection of packages
- *
- * #ZifStoreLocal and #ZifStoreRemote both implement #ZifStore.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-store.h"
-#include "zif-package.h"
-
-#include "egg-debug.h"
-
-G_DEFINE_TYPE (ZifStore, zif_store, G_TYPE_OBJECT)
-
-/**
- * zif_store_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_store_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_store_error");
- return quark;
-}
-
-/**
- * zif_store_load:
- * @store: the #ZifStore object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Loads the #ZifStore object.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_load (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* no support */
- if (klass->load == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return FALSE;
- }
-
- return klass->load (store, cancellable, completion, error);
-}
-
-/**
- * zif_store_clean:
- * @store: the #ZifStore object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Cleans the #ZifStore objects by deleting cache.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_clean (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* no support */
- if (klass->clean == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return FALSE;
- }
-
- return klass->clean (store, cancellable, completion, error);
-}
-
-/**
- * zif_store_refresh:
- * @store: the #ZifStore object
- * @force: if the data should be re-downloaded if it's still valid
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * refresh the #ZifStore objects by downloading new data if required.
- *
- * Return value: %TRUE for success, %FALSE for failure
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_store_refresh (ZifStore *store, gboolean force, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* no support */
- if (klass->refresh == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return FALSE;
- }
-
- return klass->refresh (store, force, cancellable, completion, error);
-}
-
-/**
- * zif_store_search_name:
- * @store: the #ZifStore object
- * @search: the search term, e.g. "power"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that match the package name in some part.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_search_name (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_name == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->search_name (store, search, cancellable, completion, error);
-}
-
-/**
- * zif_store_search_category:
- * @store: the #ZifStore object
- * @search: the search term, e.g. "gnome/games"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Return packages in a specific category.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_search_category (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_category == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->search_category (store, search, cancellable, completion, error);
-}
-
-/**
- * zif_store_search_details:
- * @store: the #ZifStore object
- * @search: the search term, e.g. "trouble"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that match some detail about the package.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_search_details (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
-
- /* no support */
- if (klass->search_details == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->search_details (store, search, cancellable, completion, error);
-}
-
-/**
- * zif_store_search_group:
- * @store: the #ZifStore object
- * @search: the search term, e.g. "games"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that belong in a specific group.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_search_group (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_group == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->search_group (store, search, cancellable, completion, error);
-}
-
-/**
- * zif_store_search_file:
- * @store: the #ZifStore object
- * @search: the search term, e.g. "/usr/bin/gnome-power-manager"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that provide the specified file.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_search_file (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_file == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->search_file (store, search, cancellable, completion, error);
-}
-
-/**
- * zif_store_resolve:
- * @store: the #ZifStore object
- * @search: the search term, e.g. "gnome-power-manager"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Finds packages matching the package name exactly.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_resolve (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->resolve == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->resolve (store, search, cancellable, completion, error);
-}
-
-/**
- * zif_store_what_provides:
- * @store: the #ZifStore object
- * @search: the search term, e.g. "gstreamer(codec-mp3)"
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find packages that provide a specific string.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_what_provides (ZifStore *store, gchar **search, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->search_name == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->what_provides (store, search, cancellable, completion, error);
-}
-
-/**
- * zif_store_get_packages:
- * @store: the #ZifStore object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Return all packages in the #ZifSack's.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_get_packages (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->get_packages == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->get_packages (store, cancellable, completion, error);
-}
-
-/**
- * zif_store_get_updates:
- * @store: the #ZifStore object
- * @packages: an array of #ZifPackage's
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Return a list of packages that are updatable.
- *
- * Return value: an array of #ZifPackage's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_get_updates (ZifStore *store, GPtrArray *packages,
- GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- g_return_val_if_fail (packages != NULL, NULL);
-
- /* no support */
- if (klass->get_updates == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->get_updates (store, packages, cancellable, completion, error);
-}
-
-/**
- * zif_store_find_package:
- * @store: the #ZifStore object
- * @package_id: the package ID which defines the package
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Find a single package in the #ZifSack.
- *
- * Return value: A single #ZifPackage or %NULL
- *
- * Since: 0.0.1
- **/
-ZifPackage *
-zif_store_find_package (ZifStore *store, const gchar *package_id, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (package_id != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->find_package == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->find_package (store, package_id, cancellable, completion, error);
-}
-
-/**
- * zif_store_get_categories:
- * @store: the #ZifStore object
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a #GError which is used on failure, or %NULL
- *
- * Return a list of custom categories.
- *
- * Return value: an array of #PkCategory's
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_store_get_categories (ZifStore *store, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* no support */
- if (klass->get_categories == NULL) {
- g_set_error_literal (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_NO_SUPPORT,
- "operation cannot be performed on this store");
- return NULL;
- }
-
- return klass->get_categories (store, cancellable, completion, error);
-}
-
-/**
- * zif_store_get_id:
- * @store: the #ZifStore object
- *
- * Gets the id for the object.
- *
- * Return value: A text ID, or %NULL
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_store_get_id (ZifStore *store)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_val_if_fail (ZIF_IS_STORE (store), NULL);
-
- /* no support */
- if (klass->get_id == NULL)
- return NULL;
-
- return klass->get_id (store);
-}
-
-/**
- * zif_store_print:
- * @store: the #ZifStore object
- *
- * Prints all the objects in the store.
- *
- * Since: 0.0.1
- **/
-void
-zif_store_print (ZifStore *store)
-{
- ZifStoreClass *klass = ZIF_STORE_GET_CLASS (store);
-
- g_return_if_fail (ZIF_IS_STORE (store));
-
- /* no support */
- if (klass->print == NULL)
- return;
-
- klass->print (store);
-}
-
-/**
- * zif_store_finalize:
- **/
-static void
-zif_store_finalize (GObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_STORE (object));
-
- G_OBJECT_CLASS (zif_store_parent_class)->finalize (object);
-}
-
-/**
- * zif_store_class_init:
- **/
-static void
-zif_store_class_init (ZifStoreClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_store_finalize;
-}
-
-/**
- * zif_store_init:
- **/
-static void
-zif_store_init (ZifStore *store)
-{
-}
-
-/**
- * zif_store_new:
- *
- * Return value: A new #ZifStore class instance.
- *
- * Since: 0.0.1
- **/
-ZifStore *
-zif_store_new (void)
-{
- ZifStore *store;
- store = g_object_new (ZIF_TYPE_STORE, NULL);
- return ZIF_STORE (store);
-}
-
diff --git a/backends/yum/libzif/zif-store.h b/backends/yum/libzif/zif-store.h
deleted file mode 100644
index 8828227..0000000
--- a/backends/yum/libzif/zif-store.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_STORE_H
-#define __ZIF_STORE_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-package.h"
-#include "zif-completion.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_STORE (zif_store_get_type ())
-#define ZIF_STORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_STORE, ZifStore))
-#define ZIF_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_STORE, ZifStoreClass))
-#define ZIF_IS_STORE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_STORE))
-#define ZIF_IS_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_STORE))
-#define ZIF_STORE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_STORE, ZifStoreClass))
-#define ZIF_STORE_ERROR (zif_store_error_quark ())
-
-typedef struct _ZifStore ZifStore;
-typedef struct _ZifStorePrivate ZifStorePrivate;
-typedef struct _ZifStoreClass ZifStoreClass;
-
-struct _ZifStore
-{
- GObject parent;
- ZifStorePrivate *priv;
-};
-
-struct _ZifStoreClass
-{
- GObjectClass parent_class;
- /* vtable */
- gboolean (*load) (ZifStore *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- gboolean (*clean) (ZifStore *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- gboolean (*refresh) (ZifStore *store,
- gboolean force,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_name) (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_category) (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_details) (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_group) (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*search_file) (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*resolve) (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*what_provides) (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*get_packages) (ZifStore *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*get_updates) (ZifStore *store,
- GPtrArray *packages,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- ZifPackage *(*find_package) (ZifStore *store,
- const gchar *package_id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- GPtrArray *(*get_categories) (ZifStore *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
- const gchar *(*get_id) (ZifStore *store);
- void (*print) (ZifStore *store);
-};
-
-
-typedef enum {
- ZIF_STORE_ERROR_FAILED,
- ZIF_STORE_ERROR_FAILED_AS_OFFLINE,
- ZIF_STORE_ERROR_FAILED_TO_FIND,
- ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
- ZIF_STORE_ERROR_NO_SUPPORT,
- ZIF_STORE_ERROR_NOT_LOCKED,
- ZIF_STORE_ERROR_MULTIPLE_MATCHES,
- ZIF_STORE_ERROR_LAST
-} ZifStoreError;
-
-GType zif_store_get_type (void);
-GQuark zif_store_error_quark (void);
-ZifStore *zif_store_new (void);
-gboolean zif_store_load (ZifStore *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_store_clean (ZifStore *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gboolean zif_store_refresh (ZifStore *store,
- gboolean force,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_search_name (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_search_category (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_search_details (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_search_group (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_search_file (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_resolve (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_what_provides (ZifStore *store,
- gchar **search,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_get_packages (ZifStore *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_get_updates (ZifStore *store,
- GPtrArray *packages,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-ZifPackage *zif_store_find_package (ZifStore *store,
- const gchar *package_id,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-GPtrArray *zif_store_get_categories (ZifStore *store,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-const gchar *zif_store_get_id (ZifStore *store);
-void zif_store_print (ZifStore *store);
-
-G_END_DECLS
-
-#endif /* __ZIF_STORE_H */
-
diff --git a/backends/yum/libzif/zif-string.c b/backends/yum/libzif/zif-string.c
deleted file mode 100644
index 149e48a..0000000
--- a/backends/yum/libzif/zif-string.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-string
- * @short_description: Create and manage reference counted strings
- *
- * To avoid frequent malloc/free, we use reference counted strings to
- * optimise many of the zif internals.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-
-#include "egg-debug.h"
-
-#include "zif-utils.h"
-#include "zif-string.h"
-
-/* private structure */
-struct ZifString {
- gchar *value;
- guint count;
-};
-
-/**
- * zif_string_new:
- * @value: string to copy
- *
- * Creates a new referenced counted string
- *
- * Return value: New allocated object
- *
- * Since: 0.0.1
- **/
-ZifString *
-zif_string_new (const gchar *value)
-{
- ZifString *string;
- string = g_new0 (ZifString, 1);
- string->count = 1;
- string->value = g_strdup (value);
- return string;
-}
-
-/**
- * zif_string_new_value:
- * @value: string to use
- *
- * Creates a new referenced counted string, using the allocated memory.
- * Do not free this string as it is now owned by the #ZifString.
- *
- * Return value: New allocated object
- *
- * Since: 0.0.1
- **/
-ZifString *
-zif_string_new_value (gchar *value)
-{
- ZifString *string;
- string = g_new0 (ZifString, 1);
- string->count = 1;
- string->value = value;
- return string;
-}
-
-/**
- * zif_string_get_value:
- * @string: the #ZifString object
- *
- * Returns the string stored in the #ZifString.
- * This value is only valid while the #ZifString's reference count > 1.
- *
- * Return value: string value
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_string_get_value (ZifString *string)
-{
- g_return_val_if_fail (string != NULL, NULL);
- return string->value;
-}
-
-/**
- * zif_string_ref:
- * @string: the #ZifString object
- *
- * Increases the reference count on the object.
- *
- * Return value: the #ZifString object
- *
- * Since: 0.0.1
- **/
-ZifString *
-zif_string_ref (ZifString *string)
-{
- g_return_val_if_fail (string != NULL, NULL);
- string->count++;
- return string;
-}
-
-/**
- * zif_string_unref:
- * @string: the #ZifString object
- *
- * Decreses the reference count on the object, and frees the value if
- * it calls to zero.
- *
- * Return value: the #ZifString object
- *
- * Since: 0.0.1
- **/
-ZifString *
-zif_string_unref (ZifString *string)
-{
- if (string == NULL)
- zif_debug_crash ();
-
- g_return_val_if_fail (string != NULL, NULL);
- string->count--;
- if (string->count == 0) {
- g_free (string->value);
- g_free (string);
- string = NULL;
- }
- return string;
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_string_test (EggTest *test)
-{
- ZifString *string;
- const gchar *value;
-
- if (!egg_test_start (test, "ZifString"))
- return;
-
- /************************************************************/
- egg_test_title (test, "create");
- string = zif_string_new ("kernel");
- if (g_strcmp0 (string->value, "kernel") == 0 && string->count == 1)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect value %s:%i", string->value, string->count);
-
- /************************************************************/
- egg_test_title (test, "ref");
- zif_string_ref (string);
- egg_test_assert (test, string->count == 2);
-
- /************************************************************/
- egg_test_title (test, "unref");
- zif_string_unref (string);
- egg_test_assert (test, string->count == 1);
-
- /************************************************************/
- egg_test_title (test, "get value");
- value = zif_string_get_value (string);
- egg_test_assert (test, (g_strcmp0 (value, "kernel") == 0));
-
- /************************************************************/
- egg_test_title (test, "unref");
- string = zif_string_unref (string);
- egg_test_assert (test, string == NULL);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-string.h b/backends/yum/libzif/zif-string.h
deleted file mode 100644
index 6205c93..0000000
--- a/backends/yum/libzif/zif-string.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_STRING_H
-#define __ZIF_STRING_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-typedef struct ZifString ZifString;
-
-ZifString *zif_string_new (const gchar *value);
-ZifString *zif_string_new_value (gchar *value);
-ZifString *zif_string_ref (ZifString *string);
-ZifString *zif_string_unref (ZifString *string);
-const gchar *zif_string_get_value (ZifString *string);
-
-G_END_DECLS
-
-#endif /* __ZIF_STRING_H */
-
diff --git a/backends/yum/libzif/zif-update-info.c b/backends/yum/libzif/zif-update-info.c
deleted file mode 100644
index d780cc8..0000000
--- a/backends/yum/libzif/zif-update-info.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-update-info
- * @short_description: Generic object to represent some information about an update.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "egg-debug.h"
-
-#include "zif-update-info.h"
-
-#define ZIF_UPDATE_INFO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_UPDATE_INFO, ZifUpdateInfoPrivate))
-
-struct _ZifUpdateInfoPrivate
-{
- ZifUpdateInfoKind kind;
- gchar *url;
- gchar *title;
-};
-
-enum {
- PROP_0,
- PROP_KIND,
- PROP_URL,
- PROP_TITLE,
- PROP_LAST
-};
-
-G_DEFINE_TYPE (ZifUpdateInfo, zif_update_info, G_TYPE_OBJECT)
-
-/**
- * zif_update_info_get_kind:
- * @update_info: the #ZifUpdateInfo object
- *
- * Gets the update info kind.
- *
- * Return value: the kind of update info, e.g. %ZIF_UPDATE_INFO_KIND_CVE.
- *
- * Since: 0.0.1
- **/
-ZifUpdateInfoKind
-zif_update_info_get_kind (ZifUpdateInfo *update_info)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE_INFO (update_info), ZIF_UPDATE_INFO_KIND_LAST);
- return update_info->priv->kind;
-}
-
-/**
- * zif_update_info_get_url:
- * @update_info: the #ZifUpdateInfo object
- *
- * Gets the URL for this update.
- *
- * Return value: A string value, or %NULL.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_update_info_get_url (ZifUpdateInfo *update_info)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE_INFO (update_info), NULL);
- return update_info->priv->url;
-}
-
-/**
- * zif_update_info_get_title:
- * @update_info: the #ZifUpdateInfo object
- *
- * Gets the title for this update.
- *
- * Return value: A string value, or %NULL.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_update_info_get_title (ZifUpdateInfo *update_info)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE_INFO (update_info), NULL);
- return update_info->priv->title;
-}
-
-/**
- * zif_update_info_set_kind:
- * @update_info: the #ZifUpdateInfo object
- * @kind: the kind of update info, e.g. %ZIF_UPDATE_INFO_KIND_BUGZILLA
- *
- * Sets the update_info kind status.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_info_set_kind (ZifUpdateInfo *update_info, ZifUpdateInfoKind kind)
-{
- g_return_if_fail (ZIF_IS_UPDATE_INFO (update_info));
- update_info->priv->kind = kind;
-}
-
-/**
- * zif_update_info_set_url:
- * @update_info: the #ZifUpdateInfo object
- * @url: the update info URL
- *
- * Sets the update info URL.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_info_set_url (ZifUpdateInfo *update_info, const gchar *url)
-{
- g_return_if_fail (ZIF_IS_UPDATE_INFO (update_info));
- g_return_if_fail (url != NULL);
- g_return_if_fail (update_info->priv->url == NULL);
-
- update_info->priv->url = g_strdup (url);
-}
-
-/**
- * zif_update_info_set_title:
- * @update_info: the #ZifUpdateInfo object
- * @title: the update info title
- *
- * Sets the update info title.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_info_set_title (ZifUpdateInfo *update_info, const gchar *title)
-{
- g_return_if_fail (ZIF_IS_UPDATE_INFO (update_info));
- g_return_if_fail (title != NULL);
- g_return_if_fail (update_info->priv->title == NULL);
-
- update_info->priv->title = g_strdup (title);
-}
-
-/**
- * zif_update_info_kind_to_string:
- * @type: the #ZifUpdateInfoKind enumerated value
- *
- * Gets the string representation of a #ZifUpdateInfoKind
- *
- * Return value: The #ZifUpdateInfoKind represented as a string
- **/
-const gchar *
-zif_update_info_kind_to_string (ZifUpdateInfoKind kind)
-{
- if (kind == ZIF_UPDATE_INFO_KIND_CVE)
- return "cve";
- if (kind == ZIF_UPDATE_INFO_KIND_BUGZILLA)
- return "bugzilla";
- return "unknown";
-}
-
-/**
- * zif_update_info_kind_from_string:
- * @type: the #ZifUpdateInfoKind enumerated value
- *
- * Gets the string representation of a #ZifUpdateInfoKind
- *
- * Return value: The #ZifUpdateInfoKind represented as a string
- **/
-ZifUpdateInfoKind
-zif_update_info_kind_from_string (const gchar *type)
-{
- if (g_strcmp0 (type, "cve") == 0)
- return ZIF_UPDATE_INFO_KIND_CVE;
- if (g_strcmp0 (type, "bz") == 0)
- return ZIF_UPDATE_INFO_KIND_BUGZILLA;
- return ZIF_UPDATE_INFO_KIND_LAST;
-}
-
-/**
- * zif_update_info_get_property:
- **/
-static void
-zif_update_info_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- ZifUpdateInfo *update_info = ZIF_UPDATE_INFO (object);
- ZifUpdateInfoPrivate *priv = update_info->priv;
-
- switch (prop_id) {
- case PROP_KIND:
- g_value_set_uint (value, priv->kind);
- break;
- case PROP_URL:
- g_value_set_string (value, priv->url);
- break;
- case PROP_TITLE:
- g_value_set_string (value, priv->title);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * zif_update_info_set_property:
- **/
-static void
-zif_update_info_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
-}
-
-/**
- * zif_update_info_finalize:
- **/
-static void
-zif_update_info_finalize (GObject *object)
-{
- ZifUpdateInfo *update_info;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_UPDATE_INFO (object));
- update_info = ZIF_UPDATE_INFO (object);
-
- g_free (update_info->priv->url);
- g_free (update_info->priv->title);
-
- G_OBJECT_CLASS (zif_update_info_parent_class)->finalize (object);
-}
-
-/**
- * zif_update_info_class_init:
- **/
-static void
-zif_update_info_class_init (ZifUpdateInfoClass *klass)
-{
- GParamSpec *pspec;
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_update_info_finalize;
- object_class->get_property = zif_update_info_get_property;
- object_class->set_property = zif_update_info_set_property;
-
- /**
- * ZifUpdateInfo:kind:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_uint ("kind", NULL, NULL,
- 0, G_MAXUINT, 0,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_KIND, pspec);
-
- /**
- * ZifUpdateInfo:url:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_string ("url", NULL, NULL,
- NULL,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_URL, pspec);
-
- /**
- * ZifUpdateInfo:title:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_string ("title", NULL, NULL,
- NULL,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_TITLE, pspec);
- g_type_class_add_private (klass, sizeof (ZifUpdateInfoPrivate));
-}
-
-/**
- * zif_update_info_init:
- **/
-static void
-zif_update_info_init (ZifUpdateInfo *update_info)
-{
- update_info->priv = ZIF_UPDATE_INFO_GET_PRIVATE (update_info);
- update_info->priv->kind = ZIF_UPDATE_INFO_KIND_LAST;
- update_info->priv->url = NULL;
- update_info->priv->title = NULL;
-}
-
-/**
- * zif_update_info_new:
- *
- * Return value: A new #ZifUpdateInfo class instance.
- *
- * Since: 0.0.1
- **/
-ZifUpdateInfo *
-zif_update_info_new (void)
-{
- ZifUpdateInfo *update_info;
- update_info = g_object_new (ZIF_TYPE_UPDATE_INFO, NULL);
- return ZIF_UPDATE_INFO (update_info);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_update_info_test (EggTest *test)
-{
- ZifUpdateInfo *update_info;
-
- if (!egg_test_start (test, "ZifUpdateInfo"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get update_info");
- update_info = zif_update_info_new ();
- egg_test_assert (test, update_info != NULL);
-
- g_object_unref (update_info);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-update-info.h b/backends/yum/libzif/zif-update-info.h
deleted file mode 100644
index ced7585..0000000
--- a/backends/yum/libzif/zif-update-info.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_UPDATE_INFO_H
-#define __ZIF_UPDATE_INFO_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_UPDATE_INFO (zif_update_info_get_type ())
-#define ZIF_UPDATE_INFO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_UPDATE_INFO, ZifUpdateInfo))
-#define ZIF_UPDATE_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_UPDATE_INFO, ZifUpdateInfoClass))
-#define ZIF_IS_UPDATE_INFO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_UPDATE_INFO))
-#define ZIF_IS_UPDATE_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_UPDATE_INFO))
-#define ZIF_UPDATE_INFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_UPDATE_INFO, ZifUpdateInfoClass))
-#define ZIF_UPDATE_INFO_ERROR (zif_update_info_error_quark ())
-
-typedef struct _ZifUpdateInfo ZifUpdateInfo;
-typedef struct _ZifUpdateInfoPrivate ZifUpdateInfoPrivate;
-typedef struct _ZifUpdateInfoClass ZifUpdateInfoClass;
-
-typedef enum {
- ZIF_UPDATE_INFO_KIND_CVE,
- ZIF_UPDATE_INFO_KIND_BUGZILLA,
- ZIF_UPDATE_INFO_KIND_LAST
-} ZifUpdateInfoKind;
-
-struct _ZifUpdateInfo
-{
- GObject parent;
- ZifUpdateInfoPrivate *priv;
-};
-
-struct _ZifUpdateInfoClass
-{
- GObjectClass parent_class;
-};
-
-GType zif_update_info_get_type (void);
-ZifUpdateInfo *zif_update_info_new (void);
-
-/* public getters */
-ZifUpdateInfoKind zif_update_info_get_kind (ZifUpdateInfo *update_info);
-const gchar *zif_update_info_get_url (ZifUpdateInfo *update_info);
-const gchar *zif_update_info_get_title (ZifUpdateInfo *update_info);
-
-/* internal setters: TODO, in seporate -internal header file */
-void zif_update_info_set_kind (ZifUpdateInfo *update_info,
- ZifUpdateInfoKind kind);
-void zif_update_info_set_url (ZifUpdateInfo *update_info,
- const gchar *url);
-void zif_update_info_set_title (ZifUpdateInfo *update_info,
- const gchar *title);
-
-/* utility functions */
-const gchar *zif_update_info_kind_to_string (ZifUpdateInfoKind type);
-ZifUpdateInfoKind zif_update_info_kind_from_string (const gchar *type);
-
-G_END_DECLS
-
-#endif /* __ZIF_UPDATE_INFO_H */
-
diff --git a/backends/yum/libzif/zif-update.c b/backends/yum/libzif/zif-update.c
deleted file mode 100644
index fadabcf..0000000
--- a/backends/yum/libzif/zif-update.c
+++ /dev/null
@@ -1,626 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-update
- * @short_description: Generic object to represent some information about an update.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "egg-debug.h"
-
-#include "zif-update.h"
-
-#define ZIF_UPDATE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ZIF_TYPE_UPDATE, ZifUpdatePrivate))
-
-struct _ZifUpdatePrivate
-{
- PkUpdateStateEnum state;
- PkInfoEnum kind;
- gchar *id;
- gchar *title;
- gchar *description;
- gchar *issued;
- gboolean reboot;
- GPtrArray *update_infos;
- GPtrArray *packages;
- GPtrArray *changelog;
-};
-
-enum {
- PROP_0,
- PROP_STATE,
- PROP_KIND,
- PROP_ID,
- PROP_TITLE,
- PROP_DESCRIPTION,
- PROP_ISSUED,
- PROP_REBOOT,
- PROP_LAST
-};
-
-G_DEFINE_TYPE (ZifUpdate, zif_update, G_TYPE_OBJECT)
-
-/**
- * zif_update_get_state:
- * @update: the #ZifUpdate object
- *
- * Gets the update state.
- *
- * Return value: the state of update, e.g. %PK_UPDATE_STATE_ENUM_STABLE.
- *
- * Since: 0.0.1
- **/
-PkUpdateStateEnum
-zif_update_get_state (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), PK_UPDATE_STATE_ENUM_LAST);
- return update->priv->state;
-}
-
-/**
- * zif_update_get_kind:
- * @update: the #ZifUpdate object
- *
- * Gets the update kind.
- *
- * Return value: the state of update, e.g. %PK_INFO_ENUM_SECURITY.
- *
- * Since: 0.0.1
- **/
-PkInfoEnum
-zif_update_get_kind (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), PK_INFO_ENUM_LAST);
- return update->priv->state;
-}
-
-/**
- * zif_update_get_id:
- * @update: the #ZifUpdate object
- *
- * Gets the ID for this update.
- *
- * Return value: A string value, or %NULL.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_update_get_id (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), NULL);
- return update->priv->id;
-}
-
-/**
- * zif_update_get_title:
- * @update: the #ZifUpdate object
- *
- * Gets the title for this update.
- *
- * Return value: A string value, or %NULL.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_update_get_title (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), NULL);
- return update->priv->title;
-}
-
-/**
- * zif_update_get_description:
- * @update: the #ZifUpdate object
- *
- * Gets the description for this update.
- *
- * Return value: A string value, or %NULL.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_update_get_description (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), NULL);
- return update->priv->description;
-}
-
-/**
- * zif_update_get_issued:
- * @update: the #ZifUpdate object
- *
- * Gets the time this update was issued.
- *
- * Return value: A string value, or %NULL.
- *
- * Since: 0.0.1
- **/
-const gchar *
-zif_update_get_issued (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), NULL);
- return update->priv->issued;
-}
-
-/**
- * zif_update_get_reboot:
- * @update: the #ZifUpdate object
- *
- * Gets if the update requires a reboot.
- *
- * Return value: %TRUE for a reboot.
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_update_get_reboot (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), FALSE);
- return update->priv->reboot;
-}
-
-/**
- * zif_update_get_update_infos:
- * @update: the #ZifUpdate object
- *
- * Gets the update info for this update.
- *
- * Return value: A #GPtrArray of #ZifUpdateInfo, or %NULL.
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_update_get_update_infos (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), NULL);
- return update->priv->update_infos;
-}
-
-/**
- * zif_update_get_packages:
- * @update: the #ZifUpdate object
- *
- * Gets the packages for this update.
- *
- * Return value: A #GPtrArray of #ZifPackage, or %NULL.
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_update_get_packages (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), NULL);
- return update->priv->packages;
-}
-
-/**
- * zif_update_get_changelog:
- * @update: the #ZifUpdate object
- *
- * Gets the changelog for this update.
- *
- * Return value: A #GPtrArray of #ZifChangeset's, or %NULL.
- *
- * Since: 0.0.1
- **/
-GPtrArray *
-zif_update_get_changelog (ZifUpdate *update)
-{
- g_return_val_if_fail (ZIF_IS_UPDATE (update), NULL);
- return update->priv->changelog;
-}
-
-/**
- * zif_update_set_state:
- * @update: the #ZifUpdate object
- * @state: If the update is state
- *
- * Sets the update state status.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_set_state (ZifUpdate *update, PkUpdateStateEnum state)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
- update->priv->state = state;
-}
-
-/**
- * zif_update_set_kind:
- * @update: the #ZifUpdate object
- * @kind: If the update kind, e.g. %PK_INFO_ENUM_SECURITY.
- *
- * Sets the kind of update.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_set_kind (ZifUpdate *update, PkInfoEnum kind)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
- update->priv->kind = kind;
-}
-
-/**
- * zif_update_set_id:
- * @update: the #ZifUpdate object
- * @id: the update ID
- *
- * Sets the update ID.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_set_id (ZifUpdate *update, const gchar *id)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
- g_return_if_fail (id != NULL);
- g_return_if_fail (update->priv->id == NULL);
-
- update->priv->id = g_strdup (id);
-}
-
-/**
- * zif_update_set_title:
- * @update: the #ZifUpdate object
- * @title: the update title
- *
- * Sets the update title.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_set_title (ZifUpdate *update, const gchar *title)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
- g_return_if_fail (title != NULL);
- g_return_if_fail (update->priv->title == NULL);
-
- update->priv->title = g_strdup (title);
-}
-
-/**
- * zif_update_set_description:
- * @update: the #ZifUpdate object
- * @description: the update description
- *
- * Sets the update description.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_set_description (ZifUpdate *update, const gchar *description)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
- g_return_if_fail (description != NULL);
- g_return_if_fail (update->priv->description == NULL);
-
- update->priv->description = g_strdup (description);
-}
-
-/**
- * zif_update_set_issued:
- * @update: the #ZifUpdate object
- * @issued: the update issued time
- *
- * Sets the time the update was issued.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_set_issued (ZifUpdate *update, const gchar *issued)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
- g_return_if_fail (issued != NULL);
- g_return_if_fail (update->priv->issued == NULL);
-
- update->priv->issued = g_strdup (issued);
-}
-
-/**
- * zif_update_set_reboot:
- * @update: the #ZifUpdate object
- * @reboot: if the update requires a reboot
- *
- * Sets the update reboot status
- *
- * Since: 0.0.1
- **/
-void
-zif_update_set_reboot (ZifUpdate *update, gboolean reboot)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
-
- update->priv->reboot = reboot;
-}
-
-/**
- * zif_update_add_update_info:
- * @update: the #ZifUpdate object
- * @update_info: the #ZifUpdateInfo
- *
- * Adds some update info to the update.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_add_update_info (ZifUpdate *update, ZifUpdateInfo *update_info)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
- g_return_if_fail (update_info != NULL);
- g_ptr_array_add (update->priv->update_infos, g_object_ref (update_info));
-}
-
-/**
- * zif_update_add_package:
- * @update: the #ZifUpdate object
- * @package: the #ZifPackage
- *
- * Adds some update info to the update.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_add_package (ZifUpdate *update, ZifPackage *package)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
- g_return_if_fail (package != NULL);
- g_ptr_array_add (update->priv->packages, g_object_ref (package));
-}
-
-/**
- * zif_update_add_changeset:
- * @update: the #ZifUpdate object
- * @package: the #ZifPackage
- *
- * Adds a changeset to the update.
- *
- * Since: 0.0.1
- **/
-void
-zif_update_add_changeset (ZifUpdate *update, ZifChangeset *changeset)
-{
- g_return_if_fail (ZIF_IS_UPDATE (update));
- g_return_if_fail (changeset != NULL);
- g_ptr_array_add (update->priv->changelog, g_object_ref (changeset));
-}
-
-/**
- * zif_update_get_property:
- **/
-static void
-zif_update_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- ZifUpdate *update = ZIF_UPDATE (object);
- ZifUpdatePrivate *priv = update->priv;
-
- switch (prop_id) {
- case PROP_STATE:
- g_value_set_uint (value, priv->state);
- break;
- case PROP_KIND:
- g_value_set_uint (value, priv->kind);
- break;
- case PROP_ID:
- g_value_set_string (value, priv->id);
- break;
- case PROP_TITLE:
- g_value_set_string (value, priv->title);
- break;
- case PROP_DESCRIPTION:
- g_value_set_string (value, priv->description);
- break;
- case PROP_ISSUED:
- g_value_set_string (value, priv->issued);
- break;
- case PROP_REBOOT:
- g_value_set_boolean (value, priv->reboot);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * zif_update_set_property:
- **/
-static void
-zif_update_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
-}
-
-/**
- * zif_update_finalize:
- **/
-static void
-zif_update_finalize (GObject *object)
-{
- ZifUpdate *update;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (ZIF_IS_UPDATE (object));
- update = ZIF_UPDATE (object);
-
- g_free (update->priv->id);
- g_free (update->priv->title);
- g_free (update->priv->description);
- g_free (update->priv->issued);
- g_ptr_array_unref (update->priv->update_infos);
- g_ptr_array_unref (update->priv->packages);
- g_ptr_array_unref (update->priv->changelog);
-
- G_OBJECT_CLASS (zif_update_parent_class)->finalize (object);
-}
-
-/**
- * zif_update_class_init:
- **/
-static void
-zif_update_class_init (ZifUpdateClass *klass)
-{
- GParamSpec *pspec;
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = zif_update_finalize;
- object_class->get_property = zif_update_get_property;
- object_class->set_property = zif_update_set_property;
-
- /**
- * ZifUpdate:state:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_uint ("state", NULL, NULL,
- 0, G_MAXUINT, 0,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_STATE, pspec);
-
- /**
- * ZifUpdate:kind:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_uint ("kind", NULL, NULL,
- 0, G_MAXUINT, 0,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_KIND, pspec);
-
- /**
- * ZifUpdate:id:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_string ("id", NULL, NULL,
- NULL,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_ID, pspec);
-
- /**
- * ZifUpdate:title:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_string ("title", NULL, NULL,
- NULL,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_TITLE, pspec);
-
- /**
- * ZifUpdate:description:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_string ("description", NULL, NULL,
- NULL,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_DESCRIPTION, pspec);
-
- /**
- * ZifUpdate:issued:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_string ("issued", NULL, NULL,
- NULL,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_ISSUED, pspec);
-
- /**
- * ZifUpdate:reboot:
- *
- * Since: 0.0.1
- */
- pspec = g_param_spec_boolean ("reboot", NULL, NULL,
- FALSE,
- G_PARAM_READABLE);
- g_object_class_install_property (object_class, PROP_REBOOT, pspec);
-
- g_type_class_add_private (klass, sizeof (ZifUpdatePrivate));
-}
-
-/**
- * zif_update_init:
- **/
-static void
-zif_update_init (ZifUpdate *update)
-{
- update->priv = ZIF_UPDATE_GET_PRIVATE (update);
- update->priv->state = PK_UPDATE_STATE_ENUM_LAST;
- update->priv->kind = PK_INFO_ENUM_LAST;
- update->priv->id = NULL;
- update->priv->title = NULL;
- update->priv->description = NULL;
- update->priv->issued = NULL;
- update->priv->reboot = FALSE;
- update->priv->update_infos = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- update->priv->packages = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- update->priv->changelog = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-}
-
-/**
- * zif_update_new:
- *
- * Return value: A new #ZifUpdate class instance.
- *
- * Since: 0.0.1
- **/
-ZifUpdate *
-zif_update_new (void)
-{
- ZifUpdate *update;
- update = g_object_new (ZIF_TYPE_UPDATE, NULL);
- return ZIF_UPDATE (update);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_update_test (EggTest *test)
-{
- ZifUpdate *update;
-
- if (!egg_test_start (test, "ZifUpdate"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get update");
- update = zif_update_new ();
- egg_test_assert (test, update != NULL);
-
- g_object_unref (update);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-update.h b/backends/yum/libzif/zif-update.h
deleted file mode 100644
index 11e6ddd..0000000
--- a/backends/yum/libzif/zif-update.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_UPDATE_H
-#define __ZIF_UPDATE_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-update-info.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_TYPE_UPDATE (zif_update_get_type ())
-#define ZIF_UPDATE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ZIF_TYPE_UPDATE, ZifUpdate))
-#define ZIF_UPDATE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ZIF_TYPE_UPDATE, ZifUpdateClass))
-#define ZIF_IS_UPDATE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZIF_TYPE_UPDATE))
-#define ZIF_IS_UPDATE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ZIF_TYPE_UPDATE))
-#define ZIF_UPDATE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZIF_TYPE_UPDATE, ZifUpdateClass))
-#define ZIF_UPDATE_ERROR (zif_update_error_quark ())
-
-typedef struct _ZifUpdate ZifUpdate;
-typedef struct _ZifUpdatePrivate ZifUpdatePrivate;
-typedef struct _ZifUpdateClass ZifUpdateClass;
-
-#include "zif-package.h"
-#include "zif-changeset.h"
-
-struct _ZifUpdate
-{
- GObject parent;
- ZifUpdatePrivate *priv;
-};
-
-struct _ZifUpdateClass
-{
- GObjectClass parent_class;
-};
-
-GType zif_update_get_type (void);
-ZifUpdate *zif_update_new (void);
-
-/* public getters */
-PkUpdateStateEnum zif_update_get_state (ZifUpdate *update);
-PkInfoEnum zif_update_get_kind (ZifUpdate *update);
-const gchar *zif_update_get_id (ZifUpdate *update);
-const gchar *zif_update_get_title (ZifUpdate *update);
-const gchar *zif_update_get_description (ZifUpdate *update);
-const gchar *zif_update_get_issued (ZifUpdate *update);
-gboolean zif_update_get_reboot (ZifUpdate *update);
-GPtrArray *zif_update_get_update_infos (ZifUpdate *update);
-GPtrArray *zif_update_get_packages (ZifUpdate *update);
-GPtrArray *zif_update_get_changelog (ZifUpdate *update);
-
-/* internal setters: TODO, in seporate -internal header file */
-void zif_update_set_state (ZifUpdate *update,
- PkUpdateStateEnum state);
-void zif_update_set_kind (ZifUpdate *update,
- PkInfoEnum type);
-void zif_update_set_id (ZifUpdate *update,
- const gchar *id);
-void zif_update_set_title (ZifUpdate *update,
- const gchar *title);
-void zif_update_set_description (ZifUpdate *update,
- const gchar *description);
-void zif_update_set_issued (ZifUpdate *update,
- const gchar *issued);
-void zif_update_set_reboot (ZifUpdate *update,
- gboolean reboot);
-void zif_update_add_update_info (ZifUpdate *update,
- ZifUpdateInfo *update_info);
-void zif_update_add_package (ZifUpdate *update,
- ZifPackage *package);
-void zif_update_add_changeset (ZifUpdate *update,
- ZifChangeset *changeset);
-
-G_END_DECLS
-
-#endif /* __ZIF_UPDATE_H */
-
diff --git a/backends/yum/libzif/zif-utils.c b/backends/yum/libzif/zif-utils.c
deleted file mode 100644
index a310674..0000000
--- a/backends/yum/libzif/zif-utils.c
+++ /dev/null
@@ -1,792 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/**
- * SECTION:zif-utils
- * @short_description: Simple utility functions useful to zif
- *
- * Common, non-object functions are declared here.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glib.h>
-#include <rpm/rpmlib.h>
-#include <rpm/rpmdb.h>
-#include <archive.h>
-#include <archive_entry.h>
-#include <bzlib.h>
-#include <zlib.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "egg-debug.h"
-
-#include "zif-utils.h"
-#include "zif-package.h"
-
-#define ZIF_CRASH_DEBUG
-
-/**
- * zif_utils_error_quark:
- *
- * Return value: Our personal error quark.
- *
- * Since: 0.0.1
- **/
-GQuark
-zif_utils_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("zif_utils_error");
- return quark;
-}
-
-/**
- * zif_init:
- *
- * This must be called before any of the zif_* functions are called.
- *
- * Return value: %TRUE if we initialised correctly
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_init (void)
-{
- gint retval;
-
- retval = rpmReadConfigFiles (NULL, NULL);
- if (retval != 0) {
- egg_warning ("failed to read config files");
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- * zif_debug_crash:
- *
- * Does a null dereference, useful for debugging.
- *
- * Since: 0.0.1
- **/
-void
-zif_debug_crash (void)
-{
-#ifdef ZIF_CRASH_DEBUG
- GString *string = NULL;
- string->str = NULL;
-#endif
-}
-
-/**
- * zif_boolean_from_text:
- * @text: the input text
- *
- * Convert a text boolean into it's enumerated boolean state
- *
- * Return value: %TRUE for positive, %FALSE for negative
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_boolean_from_text (const gchar *text)
-{
- g_return_val_if_fail (text != NULL, FALSE);
- if (g_ascii_strcasecmp (text, "true") == 0 ||
- g_ascii_strcasecmp (text, "yes") == 0 ||
- g_ascii_strcasecmp (text, "1") == 0)
- return TRUE;
- return FALSE;
-}
-
-/**
- * zif_list_print_array:
- * @array: The string array to print
- *
- * Print an array of strings to %STDOUT.
- *
- * Since: 0.0.1
- **/
-void
-zif_list_print_array (GPtrArray *array)
-{
- guint i;
- ZifPackage *package;
-
- for (i=0;i<array->len;i++) {
- package = g_ptr_array_index (array, i);
- zif_package_print (package);
- }
-}
-
-/**
- * zif_package_id_from_header:
- * @name: The package name, e.g. "hal"
- * @epoch: The package epoch, e.g. 1 or 0 for none.
- * @version: The package version, e.g. "1.0.0"
- * @release: The package release, e.g. "2"
- * @arch: The package architecture, e.g. "i386"
- * @data: The package data, typically the repo name, or "installed"
- *
- * Formats a PackageId structure from a NEVRA.
- *
- * Return value: The PackageId value, or %NULL if invalid
- *
- * Since: 0.0.1
- **/
-gchar *
-zif_package_id_from_nevra (const gchar *name, guint epoch, const gchar *version, const gchar *release, const gchar *arch, const gchar *data)
-{
- gchar *version_compound;
- gchar *package_id;
-
- /* do we include an epoch? */
- if (epoch == 0)
- version_compound = g_strdup_printf ("%s-%s", version, release);
- else
- version_compound = g_strdup_printf ("%i:%s-%s", epoch, version, release);
-
- package_id = pk_package_id_build (name, version_compound, arch, data);
- g_free (version_compound);
- return package_id;
-}
-
-/**
- * zif_package_convert_evr:
- *
- * Modifies evr, so pass in copy
- **/
-static gboolean
-zif_package_convert_evr (gchar *evr, const gchar **epoch, const gchar **version, const gchar **release)
-{
- gchar *find;
-
- g_return_val_if_fail (evr != NULL, FALSE);
-
- /* set to NULL initially */
- *version = NULL;
-
- /* split possible epoch */
- find = strstr (evr, ":");
- if (find != NULL) {
- *find = '\0';
- *epoch = evr;
- *version = find+1;
- } else {
- *epoch = NULL;
- *version = evr;
- }
-
- /* split possible release */
- find = g_strrstr (*version, "-");
- if (find != NULL) {
- *find = '\0';
- *release = find+1;
- } else {
- *release = NULL;
- }
-
- return TRUE;
-}
-
-/**
- * zif_compare_evr:
- * @a: the first version string
- * @b: the second version string
- *
- * Compare two [epoch:]version[-release] strings
- *
- * Return value: 1 for a>b, 0 for a==b, -1 for b>a
- *
- * Since: 0.0.1
- **/
-gint
-zif_compare_evr (const gchar *a, const gchar *b)
-{
- gint val = 0;
- gchar *ad = NULL;
- gchar *bd = NULL;
- const gchar *ae, *av, *ar;
- const gchar *be, *bv, *br;
-
- g_return_val_if_fail (a != NULL, 0);
- g_return_val_if_fail (b != NULL, 0);
-
- /* exactly the same, optimise */
- if (strcmp (a, b) == 0)
- goto out;
-
- /* copy */
- ad = g_strdup (a);
- bd = g_strdup (b);
-
- /* split */
- zif_package_convert_evr (ad, &ae, &av, &ar);
- zif_package_convert_evr (bd, &be, &bv, &br);
-
- /* compare epoch */
- if (ae != NULL && be != NULL) {
- val = rpmvercmp (ae, be);
- if (val != 0)
- goto out;
- } else if (ae != NULL && atol (ae) > 0) {
- val = 1;
- goto out;
- } else if (be != NULL && atol (be) > 0) {
- val = -1;
- goto out;
- }
-
- /* compare version */
- val = rpmvercmp (av, bv);
- if (val != 0)
- goto out;
-
- /* compare release */
- if (ar != NULL && br != NULL)
- val = rpmvercmp (ar, br);
-
-out:
- g_free (ad);
- g_free (bd);
- return val;
-}
-
-#define ZIF_BUFFER_SIZE 16384
-
-/**
- * zif_file_decompress_zlib:
- **/
-static gboolean
-zif_file_decompress_zlib (const gchar *in, const gchar *out, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- gint size;
- gint written;
- gzFile *f_in = NULL;
- FILE *f_out = NULL;
- guchar buf[ZIF_BUFFER_SIZE];
-
- g_return_val_if_fail (in != NULL, FALSE);
- g_return_val_if_fail (out != NULL, FALSE);
-
- /* open file for reading */
- f_in = gzopen (in, "rb");
- if (f_in == NULL) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED_TO_READ,
- "cannot open %s for reading", in);
- goto out;
- }
-
- /* open file for writing */
- f_out = fopen (out, "w");
- if (f_out == NULL) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED_TO_WRITE,
- "cannot open %s for writing", out);
- goto out;
- }
-
- /* read in all data in chunks */
- while (TRUE) {
- /* read data */
- size = gzread (f_in, buf, ZIF_BUFFER_SIZE);
- if (size == 0)
- break;
-
- /* error */
- if (size < 0) {
- g_set_error_literal (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED_TO_READ,
- "failed read");
- goto out;
- }
-
- /* write data */
- written = fwrite (buf, 1, size, f_out);
- if (written != size) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED_TO_WRITE,
- "only wrote %i/%i bytes", written, size);
- goto out;
- }
-
- /* is cancelled */
- ret = !g_cancellable_is_cancelled (cancellable);
- if (!ret) {
- g_set_error_literal (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_CANCELLED, "cancelled");
- goto out;
- }
- }
-
- /* success */
- ret = TRUE;
-out:
- if (f_in != NULL)
- gzclose (f_in);
- if (f_out != NULL)
- fclose (f_out);
- return ret;
-}
-
-/**
- * zif_file_decompress_bz2:
- **/
-static gboolean
-zif_file_decompress_bz2 (const gchar *in, const gchar *out, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
- FILE *f_in = NULL;
- FILE *f_out = NULL;
- BZFILE *b = NULL;
- gint size;
- gint written;
- gchar buf[ZIF_BUFFER_SIZE];
- gint bzerror = BZ_OK;
-
- g_return_val_if_fail (in != NULL, FALSE);
- g_return_val_if_fail (out != NULL, FALSE);
-
- /* open file for reading */
- f_in = fopen (in, "r");
- if (f_in == NULL) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED_TO_READ,
- "cannot open %s for reading", in);
- goto out;
- }
-
- /* open file for writing */
- f_out = fopen (out, "w");
- if (f_out == NULL) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED_TO_WRITE,
- "cannot open %s for writing", out);
- goto out;
- }
-
- /* read in file */
- b = BZ2_bzReadOpen (&bzerror, f_in, 0, 0, NULL, 0);
- if (bzerror != BZ_OK) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED_TO_READ,
- "cannot open %s for bz2 reading", in);
- goto out;
- }
-
- /* read in all data in chunks */
- while (bzerror != BZ_STREAM_END) {
- /* read data */
- size = BZ2_bzRead (&bzerror, b, buf, ZIF_BUFFER_SIZE);
- if (bzerror != BZ_OK && bzerror != BZ_STREAM_END) {
- g_set_error_literal (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED,
- "failed to decompress");
- goto out;
- }
-
- /* write data */
- written = fwrite (buf, 1, size, f_out);
- if (written != size) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED_TO_WRITE,
- "only wrote %i/%i bytes", written, size);
- goto out;
- }
-
- /* is cancelled */
- ret = !g_cancellable_is_cancelled (cancellable);
- if (!ret) {
- g_set_error_literal (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_CANCELLED,
- "cancelled");
- goto out;
- }
- }
-
- /* failed to read */
- if (bzerror != BZ_STREAM_END) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED,
- "did not decompress file: %s", in);
- goto out;
- }
-
- /* success */
- ret = TRUE;
-out:
- if (b != NULL)
- BZ2_bzReadClose (&bzerror, b);
- if (f_in != NULL)
- fclose (f_in);
- if (f_out != NULL)
- fclose (f_out);
- return ret;
-}
-
-/**
- * zif_file_decompress:
- * @in: the filename to unpack
- * @out: the file to create
- * @cancellable: a #GCancellable which is used to cancel tasks, or %NULL
- * @completion: a #ZifCompletion to use for progress reporting
- * @error: a valid %GError
- *
- * Decompress files into a directory
- *
- * Return value: %TRUE if the file was decompressed
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_file_decompress (const gchar *in, const gchar *out, GCancellable *cancellable, ZifCompletion *completion, GError **error)
-{
- gboolean ret = FALSE;
-
- g_return_val_if_fail (in != NULL, FALSE);
- g_return_val_if_fail (out != NULL, FALSE);
-
- /* bz2 */
- if (g_str_has_suffix (in, "bz2")) {
- ret = zif_file_decompress_bz2 (in, out, cancellable, completion, error);
- goto out;
- }
-
- /* zlib */
- if (g_str_has_suffix (in, "gz")) {
- ret = zif_file_decompress_zlib (in, out, cancellable, completion, error);
- goto out;
- }
-
- /* no support */
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED,
- "no support to decompress file: %s", in);
-out:
- return ret;
-}
-
-/**
- * zif_file_untar:
- * @filename: the filename to unpack
- * @directory: the directory to unpack into
- * @error: a valid %GError
- *
- * Untar files into a directory
- *
- * Return value: %TRUE if the file was decompressed
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_file_untar (const gchar *filename, const gchar *directory, GError **error)
-{
- gboolean ret = FALSE;
- struct archive *arch = NULL;
- struct archive_entry *entry;
- int r;
- int retval;
- gchar *retcwd;
- gchar buf[PATH_MAX];
-
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (directory != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* save the PWD as we chdir to extract */
- retcwd = getcwd (buf, PATH_MAX);
- if (retcwd == NULL) {
- g_set_error_literal (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED,
- "failed to get cwd");
- goto out;
- }
-
- /* we can only read tar achives */
- arch = archive_read_new ();
- archive_read_support_format_all (arch);
- archive_read_support_compression_all (arch);
-
- /* open the tar file */
- r = archive_read_open_file (arch, filename, ZIF_BUFFER_SIZE);
- if (r) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED_TO_READ,
- "cannot open: %s", archive_error_string (arch));
- goto out;
- }
-
- /* switch to our destination directory */
- retval = chdir (directory);
- if (retval != 0) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED,
- "failed chdir to %s", directory);
- goto out;
- }
-
- /* decompress each file */
- for (;;) {
- r = archive_read_next_header (arch, &entry);
- if (r == ARCHIVE_EOF)
- break;
- if (r != ARCHIVE_OK) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED,
- "cannot read header: %s", archive_error_string (arch));
- goto out;
- }
- r = archive_read_extract (arch, entry, 0);
- if (r != ARCHIVE_OK) {
- g_set_error (error, ZIF_UTILS_ERROR, ZIF_UTILS_ERROR_FAILED,
- "cannot extract: %s", archive_error_string (arch));
- goto out;
- }
- }
-
- /* completed all okay */
- ret = TRUE;
-out:
- /* close the archive */
- if (arch != NULL) {
- archive_read_close (arch);
- archive_read_finish (arch);
- }
-
- /* switch back to PWD */
- retval = chdir (buf);
- if (retval != 0)
- egg_warning ("cannot chdir back!");
-
- return ret;
-}
-
-/**
- * zif_file_get_uncompressed_name:
- * @filename: the filename, e.g. /lib/dave.tar.gz
- *
- * Finds the uncompressed filename.
- *
- * Return value: the uncompressed file name, e.g. /lib/dave.tar, use g_free() to free.
- *
- * Since: 0.0.1
- **/
-gchar *
-zif_file_get_uncompressed_name (const gchar *filename)
-{
- guint len;
- gchar *tmp;
-
- g_return_val_if_fail (filename != NULL, NULL);
-
- /* remove compression extension */
- tmp = g_strdup (filename);
- len = strlen (tmp);
- if (len > 4 && g_str_has_suffix (tmp, ".gz"))
- tmp[len-3] = '\0';
- else if (len > 5 && g_str_has_suffix (tmp, ".bz2"))
- tmp[len-4] = '\0';
-
- /* return newly allocated string */
- return tmp;
-}
-
-/**
- * zif_file_is_compressed_name:
- * @filename: the filename, e.g. /lib/dave.tar.gz
- *
- * Finds out if the filename is compressed
- *
- * Return value: %TRUE if the file needs decompression
- *
- * Since: 0.0.1
- **/
-gboolean
-zif_file_is_compressed_name (const gchar *filename)
-{
- g_return_val_if_fail (filename != NULL, FALSE);
-
- if (g_str_has_suffix (filename, ".gz"))
- return TRUE;
- if (g_str_has_suffix (filename, ".bz2"))
- return TRUE;
-
- return FALSE;
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-zif_utils_test (EggTest *test)
-{
- gchar *package_id;
- gboolean ret;
- gchar *evr;
- gint val;
- const gchar *e;
- const gchar *v;
- const gchar *r;
- gchar *filename;
- GError *error;
- GCancellable *cancellable;
- ZifCompletion *completion;
-
- if (!egg_test_start (test, "ZifUtils"))
- return;
-
- cancellable = g_cancellable_new ();
- completion = zif_completion_new ();
-
- /************************************************************
- **************** NEVRA ******************
- ************************************************************/
- egg_test_title (test, "no epoch");
- package_id = zif_package_id_from_nevra ("kernel", 0, "0.0.1", "1", "i386", "fedora");
- if (g_strcmp0 (package_id, "kernel;0.0.1-1;i386;fedora") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect package_id '%s'", package_id);
- g_free (package_id);
-
- /************************************************************/
- egg_test_title (test, "epoch value");
- package_id = zif_package_id_from_nevra ("kernel", 2, "0.0.1", "1", "i386", "fedora");
- if (g_strcmp0 (package_id, "kernel;2:0.0.1-1;i386;fedora") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect package_id '%s'", package_id);
- g_free (package_id);
-
- /************************************************************/
- egg_test_title (test, "init");
- ret = zif_init ();
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "bool to text true (1)");
- ret = zif_boolean_from_text ("1");
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "bool to text true (2)");
- ret = zif_boolean_from_text ("TRUE");
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "bool to text false");
- ret = zif_boolean_from_text ("false");
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "bool to text blank");
- ret = zif_boolean_from_text ("");
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "convert evr");
- evr = g_strdup ("7:1.0.0-6");
- zif_package_convert_evr (evr, &e, &v, &r);
- if (g_strcmp0 (e, "7") == 0 && g_strcmp0 (v, "1.0.0") == 0 && g_strcmp0 (r, "6") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect evr '%s','%s','%s'", e, v, r);
- g_free (evr);
-
- /************************************************************/
- egg_test_title (test, "convert evr no epoch");
- evr = g_strdup ("1.0.0-6");
- zif_package_convert_evr (evr, &e, &v, &r);
- if (e == NULL && g_strcmp0 (v, "1.0.0") == 0 && g_strcmp0 (r, "6") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect evr '%s','%s','%s'", e, v, r);
- g_free (evr);
-
- /************************************************************/
- egg_test_title (test, "convert evr no epoch or release");
- evr = g_strdup ("1.0.0");
- zif_package_convert_evr (evr, &e, &v, &r);
- if (e == NULL && g_strcmp0 (v, "1.0.0") == 0 && r == NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect evr '%s','%s','%s'", e, v, r);
- g_free (evr);
-
- /************************************************************/
- egg_test_title (test, "compare same");
- val = zif_compare_evr ("1:1.0.2-3", "1:1.0.2-3");
- egg_test_assert (test, (val == 0));
-
- /************************************************************/
- egg_test_title (test, "compare right heavy");
- val = zif_compare_evr ("1:1.0.2-3", "1:1.0.2-4");
- egg_test_assert (test, (val == -1));
-
- /************************************************************/
- egg_test_title (test, "compare new release");
- val = zif_compare_evr ("1:1.0.2-4", "1:1.0.2-3");
- egg_test_assert (test, (val == 1));
-
- /************************************************************/
- egg_test_title (test, "compare new epoch");
- val = zif_compare_evr ("1:0.0.1-1", "1.0.2-2");
- egg_test_assert (test, (val == 1));
-
- /************************************************************/
- egg_test_title (test, "compare new version");
- val = zif_compare_evr ("1.0.2-1", "1.0.1-1");
- egg_test_assert (test, (val == 1));
-
- /************************************************************/
- egg_test_title (test, "get uncompressed name from compressed");
- filename = zif_file_get_uncompressed_name ("/dave/moo.sqlite.gz");
- egg_test_assert (test, (g_strcmp0 (filename, "/dave/moo.sqlite") == 0));
- g_free (filename);
-
- /************************************************************/
- egg_test_title (test, "get uncompressed name from uncompressed");
- filename = zif_file_get_uncompressed_name ("/dave/moo.sqlite");
- egg_test_assert (test, (g_strcmp0 (filename, "/dave/moo.sqlite") == 0));
- g_free (filename);
-
- /************************************************************/
- egg_test_title (test, "decompress gz");
- ret = zif_file_decompress ("../test/cache/fedora/cf940a26805152e5f675edd695022d890241aba057a4a4a97a0b46618a51c482-comps-rawhide.xml.gz",
- "/tmp/comps-rawhide.xml", cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else {
- egg_test_failed (test, "failed: %s", error->message);
- g_error_free (error);
- }
-
- /************************************************************/
- egg_test_title (test, "decompress bz2");
- ret = zif_file_decompress ("../test/cache/fedora/35d817e2bac701525fa72cec57387a2e3457bf32642adeee1e345cc180044c86-primary.sqlite.bz2",
- "/tmp/moo.sqlite", cancellable, completion, &error);
- if (ret)
- egg_test_success (test, NULL);
- else {
- egg_test_failed (test, "failed: %s", error->message);
- g_error_free (error);
- }
-
- g_object_unref (cancellable);
- g_object_unref (completion);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/backends/yum/libzif/zif-utils.h b/backends/yum/libzif/zif-utils.h
deleted file mode 100644
index 239eb11..0000000
--- a/backends/yum/libzif/zif-utils.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if !defined (__ZIF_H_INSIDE__) && !defined (ZIF_COMPILATION)
-#error "Only <zif.h> can be included directly."
-#endif
-
-#ifndef __ZIF_UTILS_H
-#define __ZIF_UTILS_H
-
-#include <gio/gio.h>
-#include <glib-object.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "zif-completion.h"
-
-G_BEGIN_DECLS
-
-#define ZIF_UTILS_ERROR (zif_utils_error_quark ())
-
-typedef enum {
- ZIF_UTILS_ERROR_FAILED,
- ZIF_UTILS_ERROR_FAILED_TO_READ,
- ZIF_UTILS_ERROR_FAILED_TO_WRITE,
- ZIF_UTILS_ERROR_CANCELLED,
- ZIF_UTILS_ERROR_LAST
-} ZifUtilsError;
-
-gboolean zif_init (void);
-void zif_debug_crash (void);
-GQuark zif_utils_error_quark (void);
-void zif_list_print_array (GPtrArray *array);
-gchar *zif_package_id_from_nevra (const gchar *name,
- guint epoch,
- const gchar *version,
- const gchar *release,
- const gchar *arch,
- const gchar *data);
-gboolean zif_boolean_from_text (const gchar *text);
-gint zif_compare_evr (const gchar *a,
- const gchar *b);
-gboolean zif_file_untar (const gchar *filename,
- const gchar *directory,
- GError **error);
-gboolean zif_file_decompress (const gchar *in,
- const gchar *out,
- GCancellable *cancellable,
- ZifCompletion *completion,
- GError **error);
-gchar *zif_file_get_uncompressed_name (const gchar *filename);
-gboolean zif_file_is_compressed_name (const gchar *filename);
-
-G_END_DECLS
-
-#endif /* __ZIF_UTILS_H */
-
diff --git a/backends/yum/libzif/zif.h b/backends/yum/libzif/zif.h
deleted file mode 100644
index aebba71..0000000
--- a/backends/yum/libzif/zif.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __ZIF_H
-#define __ZIF_H
-
-#define __ZIF_H_INSIDE__
-
-#include <zif-config.h>
-#include <zif-completion.h>
-#include <zif-string.h>
-#include <zif-depend.h>
-#include <zif-package.h>
-#include <zif-store-array.h>
-#include <zif-package-local.h>
-#include <zif-package-remote.h>
-#include <zif-store-local.h>
-#include <zif-store-remote.h>
-#include <zif-repos.h>
-#include <zif-utils.h>
-#include <zif-groups.h>
-#include <zif-download.h>
-#include <zif-lock.h>
-
-#undef __ZIF_H_INSIDE__
-
-#endif /* __ZIF_H */
-
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 579f3e7..c6e60d9 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -19,11 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+//#include <config.h>
#include <gio/gio.h>
#include <pk-backend.h>
#include <pk-backend-spawn.h>
#include <string.h>
+
+#ifdef HAVE_ZIF
#include <zif.h>
+#endif
#define PREUPGRADE_BINARY "/usr/bin/preupgrade"
#define YUM_REPOS_DIRECTORY "/etc/yum.repos.d"
@@ -36,6 +40,7 @@ typedef struct {
GFileMonitor *monitor;
GCancellable *cancellable;
gboolean use_zif;
+#ifdef HAVE_ZIF
ZifDownload *download;
ZifConfig *config;
ZifStoreLocal *store_local;
@@ -43,6 +48,7 @@ typedef struct {
ZifGroups *groups;
ZifCompletion *completion;
ZifLock *lock;
+#endif
GTimer *timer;
GVolumeMonitor *volume_monitor;
} PkBackendYumPrivate;
@@ -83,6 +89,8 @@ backend_yum_repos_changed_cb (GFileMonitor *monitor_, GFile *file, GFile *other_
pk_backend_repo_list_changed (backend);
}
+#ifdef HAVE_ZIF
+
static void
backend_completion_percentage_changed_cb (ZifCompletion *completion, guint percentage, PkBackend *backend)
{
@@ -459,6 +467,7 @@ backend_get_default_store_array_for_filter (PkBackend *backend, PkBitfield filte
out:
return store_array;
}
+#endif
/**
* backend_search_thread:
@@ -466,6 +475,7 @@ out:
static gboolean
backend_search_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
gboolean ret;
GPtrArray *store_array = NULL;
GPtrArray *array = NULL;
@@ -598,6 +608,7 @@ out:
g_ptr_array_unref (array);
backend_unlock (backend);
pk_backend_finished (backend);
+#endif
return TRUE;
}
@@ -694,6 +705,7 @@ backend_initialize (PkBackend *backend)
goto out;
}
+#ifdef HAVE_ZIF
/* it seems some people are not ready for the awesomeness */
priv->use_zif = g_key_file_get_boolean (key_file, "Backend", "UseZif", NULL);
if (!priv->use_zif)
@@ -763,6 +775,9 @@ backend_initialize (PkBackend *backend)
/* profile */
backend_profile ("read groups");
+#else
+ priv->use_zif = FALSE;
+#endif
out:
g_free (config_file);
if (key_file != NULL)
@@ -782,6 +797,7 @@ backend_destroy (PkBackend *backend)
g_object_unref (priv->spawn);
if (priv->monitor != NULL)
g_object_unref (priv->monitor);
+#ifdef HAVE_ZIF
if (priv->config != NULL)
g_object_unref (priv->config);
if (priv->download != NULL)
@@ -798,6 +814,7 @@ backend_destroy (PkBackend *backend)
g_object_unref (priv->lock);
if (priv->timer != NULL)
g_timer_destroy (priv->timer);
+#endif
if (priv->volume_monitor != NULL)
g_object_unref (priv->volume_monitor);
g_free (priv);
@@ -809,8 +826,10 @@ backend_destroy (PkBackend *backend)
static PkBitfield
backend_get_groups (PkBackend *backend)
{
+#ifdef HAVE_ZIF
GError *error = NULL;
- PkBitfield groups;
+#endif
+ PkBitfield groups = 0;
/* it seems some people are not ready for the awesomeness */
if (!priv->use_zif) {
@@ -841,6 +860,7 @@ backend_get_groups (PkBackend *backend)
goto out;
}
+#ifdef HAVE_ZIF
/* get the dynamic group list */
groups = zif_groups_get_groups (priv->groups, &error);
if (groups == 0) {
@@ -848,6 +868,7 @@ backend_get_groups (PkBackend *backend)
g_error_free (error);
goto out;
}
+#endif
/* add the virtual groups */
pk_bitfield_add (groups, PK_GROUP_ENUM_COLLECTIONS);
@@ -948,6 +969,7 @@ backend_cancel (PkBackend *backend)
static gboolean
backend_download_packages_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
gchar **package_ids = pk_backend_get_strv (backend, "package_ids");
const gchar *directory = pk_backend_get_string (backend, "directory");
GPtrArray *store_array = NULL;
@@ -1064,6 +1086,7 @@ out:
g_ptr_array_unref (packages);
if (store_array != NULL)
g_ptr_array_unref (store_array);
+#endif
return TRUE;
}
@@ -1107,6 +1130,7 @@ backend_get_depends (PkBackend *backend, PkBitfield filters, gchar **package_ids
static gboolean
backend_get_details_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
gboolean ret;
gchar **package_ids = pk_backend_get_strv (backend, "package_ids");
GPtrArray *store_array = NULL;
@@ -1236,6 +1260,7 @@ out:
pk_backend_finished (backend);
if (store_array != NULL)
g_ptr_array_unref (store_array);
+#endif
return TRUE;
}
@@ -1262,6 +1287,7 @@ backend_get_details (PkBackend *backend, gchar **package_ids)
static gboolean
backend_get_distro_upgrades_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
gboolean ret;
gchar *distro_id = NULL;
gchar *filename = NULL;
@@ -1359,6 +1385,7 @@ out:
g_key_file_free (file);
g_strfreev (groups);
g_strfreev (split);
+#endif
return TRUE;
}
@@ -1383,6 +1410,7 @@ backend_get_distro_upgrades (PkBackend *backend)
static gboolean
backend_get_files_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
gboolean ret;
gchar **package_ids = pk_backend_get_strv (backend, "package_ids");
GPtrArray *store_array = NULL;
@@ -1493,6 +1521,7 @@ out:
pk_backend_finished (backend);
if (store_array != NULL)
g_ptr_array_unref (store_array);
+#endif
return TRUE;
}
@@ -1503,11 +1532,9 @@ static void
backend_get_files (PkBackend *backend, gchar **package_ids)
{
gchar *package_ids_temp;
- gboolean ret;
/* check if we can use zif */
- ret = backend_is_all_installed (package_ids);
- if (ret && priv->use_zif) {
+ if (priv->use_zif) {
pk_backend_thread_create (backend, backend_get_files_thread);
return;
}
@@ -1539,6 +1566,7 @@ backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_id
static gboolean
backend_get_updates_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
PkBitfield filters = (PkBitfield) pk_backend_get_uint (backend, "filters");
GPtrArray *store_array = NULL;
ZifCompletion *completion_local;
@@ -1695,7 +1723,7 @@ out:
g_ptr_array_unref (result);
if (store_array != NULL)
g_ptr_array_unref (store_array);
-
+#endif
return TRUE;
}
@@ -1739,6 +1767,7 @@ backend_get_packages (PkBackend *backend, PkBitfield filters)
static gboolean
backend_get_update_detail_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
gchar **package_ids;
guint i;
guint j;
@@ -1842,6 +1871,7 @@ backend_get_update_detail_thread (PkBackend *backend)
out:
backend_unlock (backend);
pk_backend_finished (backend);
+#endif
return TRUE;
}
@@ -1951,6 +1981,7 @@ backend_install_signature (PkBackend *backend, PkSigTypeEnum type,
static gboolean
backend_refresh_cache_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
GPtrArray *store_array = NULL;
gboolean ret;
GError *error = NULL;
@@ -2014,7 +2045,7 @@ out:
pk_backend_finished (backend);
if (store_array != NULL)
g_ptr_array_unref (store_array);
-
+#endif
return TRUE;
}
@@ -2183,6 +2214,7 @@ backend_resolve (PkBackend *backend, PkBitfield filters, gchar **packages)
static gboolean
backend_get_repo_list_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
gboolean ret;
PkBitfield filters = (PkBitfield) pk_backend_get_uint (backend, "filters");
guint i;
@@ -2267,6 +2299,7 @@ out:
pk_backend_finished (backend);
if (array != NULL)
g_ptr_array_unref (array);
+#endif
return TRUE;
}
@@ -2294,6 +2327,7 @@ backend_get_repo_list (PkBackend *backend, PkBitfield filters)
static gboolean
backend_repo_enable_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
ZifStoreRemote *repo = NULL;
gboolean ret;
GError *error = NULL;
@@ -2355,6 +2389,7 @@ out:
g_free (warning);
if (repo != NULL)
g_object_unref (repo);
+#endif
return TRUE;
}
@@ -2451,6 +2486,7 @@ backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum pr
static gboolean
backend_get_categories_thread (PkBackend *backend)
{
+#ifdef HAVE_ZIF
gboolean ret;
guint i;
GPtrArray *array = NULL;
@@ -2536,6 +2572,7 @@ out:
g_ptr_array_unref (array);
if (stores != NULL)
g_ptr_array_unref (stores);
+#endif
return TRUE;
}
diff --git a/configure.ac b/configure.ac
index 653c320..f3af6ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -636,48 +636,21 @@ AC_DEFINE_UNQUOTED(DEFAULT_BACKEND, "$with_default_backend", [default backend pr
AC_SUBST(DEFAULT_BACKEND, "$with_default_backend")
if test x$enable_yum = xyes; then
- PKG_CHECK_MODULES(SQLITE, sqlite3)
- PKG_CHECK_MODULES(RPM, rpm)
- PKG_CHECK_MODULES(SOUP, libsoup-2.4)
-
- dnl ---------------------------------------------------------------------------
- dnl - libarchive
- dnl ---------------------------------------------------------------------------
- AC_CHECK_HEADERS(archive.h,
- HAVE_ARCHIVE_H="yes",
- HAVE_ARCHIVE_H="no")
- if test "x$HAVE_ARCHIVE_H" = "xyes"; then
- ARCHIVE_LIBS=-larchive
- AC_SUBST(ARCHIVE_LIBS)
- else
- AC_MSG_ERROR([Cannot find archive.h])
- fi
-
dnl ---------------------------------------------------------------------------
- dnl - libbzip2
+ dnl - Zif is an experimental library for direct metadata access
dnl ---------------------------------------------------------------------------
- AC_CHECK_HEADERS(bzlib.h,
- HAVE_BZLIB_H="yes",
- HAVE_BZLIB_H="no")
- if test "x$HAVE_BZLIB_H" = "xyes"; then
- BZLIB_LIBS=-lbz2
- AC_SUBST(BZLIB_LIBS)
+ AC_ARG_ENABLE(zif, AS_HELP_STRING([--enable-zif],[Build ZIF experimental code]),
+ enable_zif=$enableval,enable_zif=yes)
+ if test x$enable_zif = xyes; then
+ PKG_CHECK_MODULES(ZIF, zif,
+ build_zif=yes, build_zif=no)
else
- AC_MSG_ERROR([Cannot find bzlib.h])
+ build_zif=no
fi
-
- dnl ---------------------------------------------------------------------------
- dnl - zlib
- dnl ---------------------------------------------------------------------------
- AC_CHECK_HEADERS(zlib.h,
- HAVE_ZLIB_H="yes",
- HAVE_ZLIB_H="no")
- if test "x$HAVE_BZLIB_H" = "xyes"; then
- ZLIB_LIBS=-lz
- AC_SUBST(ZLIB_LIBS)
- else
- AC_MSG_ERROR([Cannot find zlib.h])
+ if test "x$build_zif" = "xyes"; then
+ AC_DEFINE([HAVE_ZIF], [1], [If Zif support should be enabled])
fi
+ AM_CONDITIONAL(PK_BUILD_ZIF, test $build_zif = "yes")
fi
if test x$enable_apt = xyes; then
@@ -902,6 +875,7 @@ echo "
SMART backend: ${enable_smart}
URPMI backend: ${enable_urpmi}
YUM backend: ${enable_yum}
+ (with zif): ${build_zif}
Zypp backend: ${enable_zypp}
Default backend: ${with_default_backend}
"
commit f28b67440608ae5eb7c19ad382e1c71c9bec269f
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 15:01:39 2010 +0100
yum: Attempt to use removable disk repos if they exist at backend startup
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 1faa5aa..579f3e7 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -44,6 +44,7 @@ typedef struct {
ZifCompletion *completion;
ZifLock *lock;
GTimer *timer;
+ GVolumeMonitor *volume_monitor;
} PkBackendYumPrivate;
static PkBackendYumPrivate *priv;
@@ -601,6 +602,47 @@ out:
}
/**
+ * backend_mount_add:
+ */
+static void
+backend_mount_add (GMount *mount, gpointer user_data)
+{
+ GFile *root;
+ GFile *repo;
+ GFile *dest;
+ gchar *root_path;
+ gchar *repo_path;
+ gboolean ret;
+ GError *error = NULL;
+
+ /* check if any installed media is an install disk */
+ root = g_mount_get_root (mount);
+ root_path = g_file_get_path (root);
+ repo_path = g_build_filename (root_path, "media.repo", NULL);
+ repo = g_file_new_for_path (repo_path);
+ dest = g_file_new_for_path ("/etc/yum.repos.d/packagekit-media.repo");
+
+ /* media.repo exists */
+ ret = g_file_query_exists (repo, NULL);
+ egg_warning ("checking for %s: %s", repo_path, ret ? "yes" : "no");
+ if (!ret)
+ goto out;
+
+ /* copy to the system repo dir */
+ ret = g_file_copy (repo, dest, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error);
+ if (!ret) {
+ egg_warning ("failed to copy: %s", error->message);
+ g_error_free (error);
+ }
+out:
+ g_free (root_path);
+ g_free (repo_path);
+ g_object_unref (dest);
+ g_object_unref (root);
+ g_object_unref (repo);
+}
+
+/**
* backend_initialize:
* This should only be run once per backend load, i.e. not every transaction
*/
@@ -612,6 +654,7 @@ backend_initialize (PkBackend *backend)
GError *error = NULL;
GKeyFile *key_file = NULL;
gchar *config_file = NULL;
+ GList *mounts;
/* create private area */
priv = g_new0 (PkBackendYumPrivate, 1);
@@ -623,6 +666,13 @@ backend_initialize (PkBackend *backend)
pk_backend_spawn_set_name (priv->spawn, "yum");
pk_backend_spawn_set_allow_sigkill (priv->spawn, FALSE);
+ /* coldplug the mounts */
+ priv->volume_monitor = g_volume_monitor_get ();
+ mounts = g_volume_monitor_get_mounts (priv->volume_monitor);
+ g_list_foreach (mounts, (GFunc) backend_mount_add, NULL);
+ g_list_foreach (mounts, (GFunc) g_object_unref, NULL);
+ g_list_free (mounts);
+
/* setup a file monitor on the repos directory */
file = g_file_new_for_path (YUM_REPOS_DIRECTORY);
priv->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, &error);
@@ -748,6 +798,8 @@ backend_destroy (PkBackend *backend)
g_object_unref (priv->lock);
if (priv->timer != NULL)
g_timer_destroy (priv->timer);
+ if (priv->volume_monitor != NULL)
+ g_object_unref (priv->volume_monitor);
g_free (priv);
}
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 2c5f54c..f90ce59 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -2962,7 +2962,14 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
# disable repos that are not contactable
for repo in self.yumbase.repos.listEnabled():
try:
- repo.repoXML
+ if not repo.mediaid:
+ repo.repoXML
+ else:
+ root = self.yumbase._media_find_root(repo.mediaid)
+ if not root:
+ self.yumbase.repos.disableRepo(repo.id)
+ self.message(MESSAGE_REPO_METADATA_DOWNLOAD_FAILED,
+ "Could not contact media source '%s', so it will be disabled" % repo.id)
except exceptions.IOError, e:
self.error(ERROR_NO_SPACE_ON_DEVICE, "Disk error: %s" % _to_unicode(e))
except yum.Errors.RepoError, e:
@@ -3268,15 +3275,8 @@ class PackageKitYumBase(yum.YumBase):
else:
raise PkError(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc()))
- def MediaGrabber(self, *args, **kwargs):
- """
- Handle physical media.
- """
- media_id = kwargs["mediaid"]
- disc_number = kwargs["discnum"]
- name = kwargs["name"]
- found = False
- print kwargs
+ def _media_find_root(self, media_id, disc_number=1):
+ """ returns the root "/media/Fedora Extras" or None """
# search all the disks
vm = gio.volume_monitor_get()
@@ -3302,7 +3302,17 @@ class PackageKitYumBase(yum.YumBase):
continue
if disc_number_tmp != disc_number:
continue
+ return root
+
+ # nothing remaining
+ return None
+ def MediaGrabber(self, *args, **kwargs):
+ """
+ Handle physical media.
+ """
+ root = self._media_find_root(kwargs["mediaid"], kwargs["discnum"])
+ if root:
# the actual copying is done by URLGrabber
ug = URLGrabber(checkfunc = kwargs["checkfunc"])
try:
@@ -3311,12 +3321,10 @@ class PackageKitYumBase(yum.YumBase):
range=kwargs["range"], copy_local=1)
except (IOError, URLGrabError), e:
pass
- else:
- found = True
- break;
# we have to send a message to the client
- if not found:
+ if not root:
+ name = kwargs["name"]
self.backend.media_change_required(MEDIA_TYPE_DISC, name, name)
self.backend.error(ERROR_MEDIA_CHANGE_REQUIRED,
"Insert media labeled '%s' or disable media repos" % name,
commit dd2e6df694436cea0fb83a6fafb6e6d62a46696b
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 14:58:44 2010 +0100
yum: The transaction root is not set at _init(), so we have to re-query the root when we start each action
diff --git a/backends/yum/libzif/zif-store-local.c b/backends/yum/libzif/zif-store-local.c
index 4dbc3a5..69c6a40 100644
--- a/backends/yum/libzif/zif-store-local.c
+++ b/backends/yum/libzif/zif-store-local.c
@@ -86,8 +86,6 @@ zif_store_local_set_prefix (ZifStoreLocal *store, const gchar *prefix, GError **
gchar *filename = NULL;
g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), FALSE);
- g_return_val_if_fail (store->priv->prefix == NULL, FALSE);
- g_return_val_if_fail (!store->priv->loaded, FALSE);
g_return_val_if_fail (prefix != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -99,6 +97,17 @@ zif_store_local_set_prefix (ZifStoreLocal *store, const gchar *prefix, GError **
goto out;
}
+ /* is the same */
+ if (g_strcmp0 (prefix, store->priv->prefix) == 0)
+ goto out;
+
+ /* empty cache */
+ if (store->priv->loaded) {
+ egg_debug ("abandoning cache");
+ g_ptr_array_set_size (store->priv->packages, 0);
+ store->priv->loaded = FALSE;
+ }
+
/* setup watch */
filename = g_build_filename (prefix, "var", "lib", "rpm", "Packages", NULL);
ret = zif_monitor_add_watch (store->priv->monitor, filename, &error_local);
@@ -109,6 +118,8 @@ zif_store_local_set_prefix (ZifStoreLocal *store, const gchar *prefix, GError **
goto out;
}
+ /* save new value */
+ g_free (store->priv->prefix);
store->priv->prefix = g_strdup (prefix);
out:
g_free (filename);
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 4070dae..1faa5aa 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -95,6 +95,34 @@ backend_completion_subpercentage_changed_cb (ZifCompletion *completion, guint su
}
/**
+ * backend_set_root:
+ */
+static gboolean
+backend_set_root (PkBackend *backend)
+{
+ gboolean ret = FALSE;
+ GError *error = NULL;
+ const gchar *root;
+
+ /* this backend does not support a relocatable root... yet */
+ root = pk_backend_get_root (backend);
+ if (g_strcmp0 (root, "/") != 0) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_INSTALL_ROOT_INVALID, "backend does not support this root: '%s'", root);
+ goto out;
+ }
+
+ /* try to set, or re-set root */
+ ret = zif_store_local_set_prefix (priv->store_local, root, &error);
+ if (!ret) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to set prefix: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+out:
+ return ret;
+}
+
+/**
* backend_profile:
*/
static void
@@ -456,6 +484,13 @@ backend_search_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* set the network state */
backend_setup_network (backend);
@@ -577,7 +612,6 @@ backend_initialize (PkBackend *backend)
GError *error = NULL;
GKeyFile *key_file = NULL;
gchar *config_file = NULL;
- const gchar *root;
/* create private area */
priv = g_new0 (PkBackendYumPrivate, 1);
@@ -589,13 +623,6 @@ backend_initialize (PkBackend *backend)
pk_backend_spawn_set_name (priv->spawn, "yum");
pk_backend_spawn_set_allow_sigkill (priv->spawn, FALSE);
- /* this backend does not support a relocatable root */
- root = pk_backend_get_root (backend);
- if (g_strcmp0 (root, "/") != 0) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_INSTALL_ROOT_INVALID, "backend does not support this root: '%s'", root);
- goto out;
- }
-
/* setup a file monitor on the repos directory */
file = g_file_new_for_path (YUM_REPOS_DIRECTORY);
priv->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, &error);
@@ -659,12 +686,6 @@ backend_initialize (PkBackend *backend)
/* ZifStoreLocal */
priv->store_local = zif_store_local_new ();
- ret = zif_store_local_set_prefix (priv->store_local, root, &error);
- if (!ret) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to set prefix: %s", error->message);
- g_error_free (error);
- goto out;
- }
/* profile */
backend_profile ("read local store");
@@ -897,6 +918,13 @@ backend_download_packages_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* set the network state */
backend_setup_network (backend);
@@ -1051,6 +1079,13 @@ backend_get_details_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* set the network state */
backend_setup_network (backend);
@@ -1320,6 +1355,13 @@ backend_get_files_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* set the network state */
backend_setup_network (backend);
@@ -1470,6 +1512,13 @@ backend_get_updates_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* profile */
backend_profile ("get lock");
@@ -1657,6 +1706,13 @@ backend_get_update_detail_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* get the data */
package_ids = pk_backend_get_strv (backend, "package_ids");
@@ -1856,6 +1912,13 @@ backend_refresh_cache_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* set the network state */
backend_setup_network (backend);
@@ -2087,6 +2150,13 @@ backend_get_repo_list_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* set the network state */
backend_setup_network (backend);
@@ -2186,6 +2256,13 @@ backend_repo_enable_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* set the network state */
backend_setup_network (backend);
@@ -2339,6 +2416,13 @@ backend_get_categories_thread (PkBackend *backend)
goto out;
}
+ /* set correct install root */
+ ret = backend_set_root (backend);
+ if (!ret) {
+ egg_warning ("failed to set root");
+ goto out;
+ }
+
/* set the network state */
backend_setup_network (backend);
commit 0d21ed15bdb4a6e62efcf602f01137d9e63ff7ab
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 14:57:57 2010 +0100
Fix up several daemon thinkos when a client tries to set a root other than '/'
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 4ceb925..fa0ae7d 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -98,7 +98,6 @@ struct PkEnginePrivate
#ifdef USE_SECURITY_POLKIT
PolkitAuthority *authority;
#endif
- gchar *sender;
gboolean locked;
PkNetworkEnum network_state;
};
@@ -962,7 +961,7 @@ out:
* pk_engine_set_root_internal:
**/
static gboolean
-pk_engine_set_root_internal (PkEngine *engine, const gchar *root)
+pk_engine_set_root_internal (PkEngine *engine, const gchar *root, const gchar *sender)
{
gboolean ret;
guint uid;
@@ -976,14 +975,14 @@ pk_engine_set_root_internal (PkEngine *engine, const gchar *root)
}
/* get uid */
- uid = pk_dbus_get_uid (engine->priv->dbus, engine->priv->sender);
+ uid = pk_dbus_get_uid (engine->priv->dbus, sender);
if (uid == G_MAXUINT) {
egg_warning ("failed to get the uid");
goto out;
}
/* get session */
- session = pk_dbus_get_session (engine->priv->dbus, engine->priv->sender);
+ session = pk_dbus_get_session (engine->priv->dbus, sender);
if (session == NULL) {
egg_warning ("failed to get the session");
goto out;
@@ -1034,7 +1033,7 @@ pk_engine_action_obtain_root_authorization_finished_cb (PolkitAuthority *authori
}
/* try to set the new root and save to database */
- ret = pk_engine_set_root_internal (state->engine, state->value1);
+ ret = pk_engine_set_root_internal (state->engine, state->value1, state->sender);
if (!ret) {
error = g_error_new_literal (PK_ENGINE_ERROR, PK_ENGINE_ERROR_CANNOT_SET_PROXY,
"setting the root failed");
@@ -1149,9 +1148,22 @@ pk_engine_set_root (PkEngine *engine, const gchar *root, DBusGMethodInvocation *
goto out;
}
+ /* '/' is the default root, which doesn't need additional authentication */
+ if (g_strcmp0 (root, "/") == 0) {
+ ret = pk_engine_set_root_internal (engine, root, sender);
+ if (ret) {
+ egg_debug ("using default root, so no need to authenticate");
+ dbus_g_method_return (context);
+ } else {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_CANNOT_SET_ROOT, "%s", "setting the root failed");
+ dbus_g_method_return_error (context, error);
+ }
+ goto out;
+ }
+
#ifdef USE_SECURITY_POLKIT
/* check subject */
- subject = polkit_system_bus_name_new (engine->priv->sender);
+ subject = polkit_system_bus_name_new (sender);
/* insert details about the authorization */
details = polkit_details_new ();
@@ -1179,14 +1191,14 @@ pk_engine_set_root (PkEngine *engine, const gchar *root, DBusGMethodInvocation *
egg_warning ("*** THERE IS NO SECURITY MODEL BEING USED!!! ***");
/* try to set the new root and save to database */
- ret = pk_engine_set_root_internal (engine, root);
+ ret = pk_engine_set_root_internal (engine, root, sender);
if (!ret) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_CANNOT_SET_ROOT, "%s", "setting the root failed");
dbus_g_method_return_error (context, error);
goto out;
}
- /* all okay, TODO: return only when done the polkit auth */
+ /* all okay */
dbus_g_method_return (context);
#endif
commit f8ffbcee30252b1dff776e5663bbc88174060e0f
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 12:10:21 2010 +0100
yum: Remove all the MediaManager implementations and write a small GIO based callback
diff --git a/backends/yum/Makefile.am b/backends/yum/Makefile.am
index a0af1a4..0c96ef1 100644
--- a/backends/yum/Makefile.am
+++ b/backends/yum/Makefile.am
@@ -4,7 +4,6 @@ dist_helper_DATA = \
licenses.txt \
yumBackend.py \
yumComps.py \
- yumMediaManager.py \
yumFilter.py
INCLUDES = \
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 13afbd8..2c5f54c 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -50,6 +50,7 @@ import time
import os.path
import logging
import socket
+import gio
import tarfile
import tempfile
@@ -58,7 +59,6 @@ import ConfigParser
from yumFilter import *
from yumComps import *
-from yumMediaManager import MediaManager
# Global vars
yumbase = None
@@ -3254,9 +3254,8 @@ class PackageKitYumBase(yum.YumBase):
self.missingGPGKey = None
self.dsCallback = DepSolveCallback(backend)
self.backend = backend
- # disable until we have a backend we can use by default
- # self.mediagrabber = self.MediaGrabber
- # Setup Repo GPG support callbacks
+ self.mediagrabber = self.MediaGrabber
+ # setup Repo GPG support callbacks
try:
self.repos.confirm_func = self._repo_gpg_confirm
self.repos.gpg_import_func = self._repo_gpg_import
@@ -3272,103 +3271,59 @@ class PackageKitYumBase(yum.YumBase):
def MediaGrabber(self, *args, **kwargs):
"""
Handle physical media.
-
- This module can be summarized like this:
- For all media:
- - Lock it
- - If not mounted: mount it
- - If it's the wanted media: break
- - If no media found: ask the user to insert it and loop again
- ....
- Release the media
"""
media_id = kwargs["mediaid"]
disc_number = kwargs["discnum"]
name = kwargs["name"]
- discs_s = ''
found = False
+ print kwargs
+
+ # search all the disks
+ vm = gio.volume_monitor_get()
+ mounts = vm.get_mounts()
+ for mount in mounts:
+ # is it mounted
+ root = mount.get_root().get_path()
+
+ # is it a media disc
+ discinfo = "%s/.discinfo" % root
+ if not os.path.exists(discinfo):
+ continue
- try:
- manager = MediaManager()
- except NotImplementedError, e:
- # yumRepo will catch this
- raise yum.Errors.MediaError, "media handling is not implemented"
-
- media = None
- found = False
-
- # loop over and over, retry because the user might insert disc #2 when we need disc #5
- while 1:
- # check for the needed media in every media provided by yumMediaManager
- for media in manager:
- # mnt now holds the mount point
- mnt = media.acquire()
- found = False
-
- # if not mounted skip this media for this loop
- if not mnt:
- continue
-
- # load ".discinfo" from the media and parse it
- if os.path.exists("%s/.discinfo" %(mnt,)):
- f = open("%s/.discinfo" %(mnt,), "r")
- lines = f.readlines()
- f.close()
- theid = lines[0].strip()
- discs_s = lines[3].strip()
-
- # if discs_s == ALL then no need to match disc number
- if discs_s != 'ALL':
- discs = map(lambda x: int(x), discs_s.split(","))
- samenum = disc_number in discs
- else:
- samenum = True
-
- # if the media is different or of different number skip it and loop over
- if media_id != theid or not samenum:
- continue
-
- # the actual copying is done by URLGrabber
- ug = URLGrabber(checkfunc = kwargs["checkfunc"])
- try:
- ug.urlgrab("%s/%s" %(mnt, kwargs["relative"]),
- kwargs["local"], text=kwargs["text"],
- range=kwargs["range"], copy_local=1)
- except (IOError, URLGrabError):
- pass
- else:
- found = True
-
- # if we found it end the for loop
- if found:
- break
+ # get the contents
+ f = open(discinfo, "r")
+ lines = f.readlines()
+ f.close()
+ media_id_tmp = lines[0].strip()
+ disc_number_tmp = int(lines[3].strip())
- # if we found it end the while loop
- if found:
- break
+ # check this is the right disk
+ if cmp(media_id_tmp, media_id) != 0:
+ continue
+ if disc_number_tmp != disc_number:
+ continue
- # construct human readable media_text
- if disc_number:
- media_text = "%s #%d" % (name, disc_number)
+ # the actual copying is done by URLGrabber
+ ug = URLGrabber(checkfunc = kwargs["checkfunc"])
+ try:
+ ug.urlgrab("%s/%s" % (root, kwargs["relative"]),
+ kwargs["local"], text=kwargs["text"],
+ range=kwargs["range"], copy_local=1)
+ except (IOError, URLGrabError), e:
+ pass
else:
- media_text = name
-
- # see http://lists.freedesktop.org/archives/packagekit/2009-May/004808.html
- # and http://cgit.freedesktop.org/packagekit/commit/?id=79e8736197b552a5ce206a712cd3b6c80cf2e86d
- self.backend.media_change_required(MEDIA_TYPE_DISC, name, media_text)
- self.backend.error(ERROR_MEDIA_CHANGE_REQUIRED,
- "Insert media labeled '%s' or disable media repos" % media_text,
- exit = False)
- break
+ found = True
+ break;
- # if we got a media object destruct it to release the media (which will unmount and unlock if needed)
- if media:
- del media
-
- # I guess we come here when the user in PK clicks cancel
+ # we have to send a message to the client
if not found:
- # yumRepo will catch this
+ self.backend.media_change_required(MEDIA_TYPE_DISC, name, name)
+ self.backend.error(ERROR_MEDIA_CHANGE_REQUIRED,
+ "Insert media labeled '%s' or disable media repos" % name,
+ exit=False)
raise yum.Errors.MediaError, "The disc was not inserted"
+
+ # yay
return kwargs["local"]
def _repo_gpg_confirm(self, keyData):
diff --git a/backends/yum/yumMediaManager.py b/backends/yum/yumMediaManager.py
deleted file mode 100644
index 735edc1..0000000
--- a/backends/yum/yumMediaManager.py
+++ /dev/null
@@ -1,104 +0,0 @@
-# Licensed under the GNU General Public License Version 2
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-# Copyright (C) 2009
-# Muayyad Saleh Alsadi <alsadi at ojuba.org>
-
-"""
-This is a module for dealing with removable media
-NOTE: releasing (unmounting and unlocking) is done when media is destructed
-"""
-
-class MediaDevice(object):
- """
- You should just use acquire() to get the mount point (the implementation is
- supposed to be smart enough to return mount point when it's already mounted)
- You don't need to manually call release(), just destruct MediaDevice object
- and the implementation should do that if needed.
- """
- def __init__(self, media_id):
- """
- media_id argument is the implementation-specific id, provided by MediaManager.
- """
- self._unmount_needed = False
- self._unlock_needed = False
- raise NotImplementedError()
-
- def __del__(self):
- """
- destruct the object, unmount and unlock if needed.
- no need to re-implement this method when you derive from this class.
- """
- if self._unmount_needed:
- self.unmount()
- if self._unlock_needed:
- self.unlock()
-
- def is_removable(self):
- raise NotImplementedError()
-
- def is_mounted(self):
- raise NotImplementedError()
-
- def is_locked(self):
- raise NotImplementedError()
-
- def get_mount_point(self):
- """return the mount point or None if not mounted"""
- raise NotImplementedError()
-
- def lock(self):
- """return True if lock is successfully acquired."""
- raise NotImplementedError()
-
- def unlock(self):
- """return True if it was able to release the lock successfully."""
- raise NotImplementedError()
-
- def mount(self):
- """
- mount the device and return the mount point.
- If it's already mounted, just return the mount point.
- """
- raise NotImplementedError()
-
- def unmount(self):
- """unmount the device and return True."""
- raise NotImplementedError()
-
- # no need to re-implement the following methods when you derive from this class
- def acquire(self):
- """
- return the mount point, lock and mount the device if needed
- """
- self.lock()
- return self.mount()
-
- def release(self):
- """
- unmount and release lock. no need to call this method, just destruct the object.
- """
- self.unlock()
- return self.unmount()
-
-class MediaManager (object):
- """Just iterate over an instance of this class to get MediaDevice objects"""
- def __init__(self):
- raise NotImplementedError()
-
- def __iter__(self):
- raise NotImplementedError()
-
diff --git a/backends/yum/yumMediaManagerDeviceKit.py b/backends/yum/yumMediaManagerDeviceKit.py
deleted file mode 100644
index 690c84b..0000000
--- a/backends/yum/yumMediaManagerDeviceKit.py
+++ /dev/null
@@ -1,152 +0,0 @@
-# Licensed under the GNU General Public License Version 2
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-# Copyright (C) 2009
-# Muayyad Saleh Alsadi <alsadi at ojuba.org>
-
-"""
-This is the DeviceKit implementation of MediaManager module for dealing with removable media
-
-it's used like this
-
- from yumMediaManagerDeviceKit import MediaManagerDeviceKit as MediaManager
- manager = MediaManager()
- media, found = None, False
- for media in manager:
- mnt = media.acquire() # get mount point, mount and lock if needed
- found = is_it_the_needed_media(mnt)
- if found: break
- if found: copy_files ..etc.
- if media: del media
-
-NOTE: releasing (unmounting and unlocking) is done when media is destructed
-"""
-
-#list:
-#dbus-send --system --print-reply --dest=org.freedesktop.DeviceKit.Disks
-#/org/freedesktop/DeviceKit/Disks
-#org.freedesktop.DeviceKit.Disks.EnumerateDevices
-#
-#filter:
-#dbus-send --system --print-reply --dest=org.freedesktop.DeviceKit.Disks
-#/org/freedesktop/DeviceKit/Disks/devices/sr0
-#org.freedesktop.DBus.Properties.Get
-#string:org.freedesktop.DeviceKit.Disks.Device string:"device-is-removable"
-#
-#mount:
-#dbus-send --system --print-reply --dest=org.freedesktop.DeviceKit.Disks
-#/org/freedesktop/DeviceKit/Disks/devices/sr0
-#org.freedesktop.DeviceKit.Disks.Device.FilesystemMount string:auto
-#array:string:
-
-import dbus
-import dbus.service
-from dbus.mainloop.glib import DBusGMainLoop
-from yumMediaManager import MediaManager, MediaDevice
-dbus_loop = DBusGMainLoop(set_as_default = True)
-bus = dbus.SystemBus()
-interface = 'org.freedesktop.DeviceKit.Disks'
-
-# TODO: catch some "except dbus.exceptions.DBusException"
-
-class MediaDeviceDeviceKit(MediaDevice):
- """
- You should just use acquire() to get the mount point (the implementation is
- supposed to be smart enough to return mount point when it's already mounted)
- You don't need to manually call release(), just destruct MediaDevice object
- and the implementation should do that if needed.
- """
- def __init__(self, media_id):
- """
- media_id argument is the implementation-specific id in our case it's udi in hal,
- it's provided by MediaManager.
- """
- self._unmount_needed = False
- self._unlock_needed = False
- self.__uid = media_id
- self.__dev = bus.get_object(interface, media_id)
-
- def get_device_property(self, key):
- return self.__dev.Get(interface+'.Device', key, dbus_interface="org.freedesktop.DBus.Properties")
-
- def is_removable(self):
- return bool(self.get_device_property('device-is-removable'))
-
- def is_mounted(self):
- return bool(self.get_device_property('device-is-mounted'))
-
- def is_locked(self):
- return False
-
- def get_mount_point(self):
- """
- return the mount point or None if not mounted
- """
- if not self.is_mounted():
- return None
- l=self.get_device_property('device-mount-paths')
- if l: return str(l[0]) or None
- return None
-
- def lock(self):
- """
- return True if lock is successfully acquired.
- """
- return False
-
- def unlock(self):
- """
- return True if it was able to release the lock successfully.
- """
- return False
-
- def mount(self):
- """
- mount the device and return the mount point.
- If it's already mounted, just return the mount point.
- """
- if self.is_mounted():
- return self.get_mount_point()
- r=None
- try:
- r = str(self.__dev.FilesystemMount('auto', dbus.Array(dbus.String()), dbus_interface = interface+".Device")) or None
- except dbus.exceptions.DBusException:
- pass
- return r
-
- def unmount(self):
- """
- unmount the device and return True.
- """
- try:
- self.__dev.FilesystemUnmount(dbus.Array(dbus.String()), dbus_interface = interface+".Device")
- except dbus.exceptions.DBusException:
- pass
- return not self.is_mounted()
-
-class MediaManagerDeviceKit(MediaManager):
- """Just iterate over an instance of this class to get MediaDevice objects"""
- def __init__(self):
- self.__dev = bus.get_object(interface, "/org/freedesktop/DeviceKit/Disks")
-
- def __iter__(self):
- #self.__close_tray_and_be_ready()
- # use volume.disc to restrict that to optical discs
- for i in self.__dev.EnumerateDevices(dbus_interface = interface):
- o = MediaDeviceDeviceKit(i)
- if o.is_removable():
- yield o
-
diff --git a/backends/yum/yumMediaManagerGIO.py b/backends/yum/yumMediaManagerGIO.py
deleted file mode 100644
index e71e8f3..0000000
--- a/backends/yum/yumMediaManagerGIO.py
+++ /dev/null
@@ -1,153 +0,0 @@
-# Licensed under the GNU General Public License Version 2
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-# Copyright (C) 2009
-# Muayyad Saleh Alsadi <alsadi at ojuba.org>
-
-"""
-This is the GIO implementation of MediaManager module for dealing with removable media
-
-it's used like this
-
- from yumMediaManagerGIO import MediaManagerGIO as MediaManager
- manager=MediaManager()
- media,found=None,False
- for media in manager:
- mnt=media.acquire() # get mount point, mount and lock if needed
- found=is_it_the_needed_media(mnt)
- if found: break
- if found: copy_files ..etc.
- if media: del media
-
-NOTE: releasing (unmounting and unlocking) is done when media is destructed
-"""
-import gio
-import glib
-import os.path
-
-from yumMediaManager import MediaManager,MediaDevice
-
-class MediaDeviceGIO(MediaDevice):
- """
- You should just use acquire() to get the mount point (the implementation is
- supposed to be smart enough to return mount point when it's already mounted)
- You don't need to manually call release(), just destruct MediaDevice object
- and the implementation should do that if needed.
- """
- def __init__(self,media_id):
- """
- media_id argument is the implementation-specific id
- in our case it's a tuble of device and volume in GIO,
- the tuble is provided by MediaManager.
- """
- self._unmount_needed = False
- self._unlock_needed = False
- self.__d = media_id[0]
- self.__v = media_id[1]
- self.__loop=glib.MainLoop()
-
- def is_removable(self):
- return self.__d.is_media_removable()
-
- def is_mounted(self):
- m=self.__v.get_mount()
- return bool(m and os.path.ismount(m.get_root().get_path()))
-
- def is_locked(self):
- # FIXME: there is no locks in GIO
- return False
-
- def get_mount_point(self):
- """
- return the mount point or None if not mounted
- """
- if not self.is_mounted(): return None
- return self.__v.get_mount().get_root().get_path()
-
- def lock(self):
- """
- return True if lock is successfully acquired.
- """
- # FIXME: there is no locks in GIO
- return False
-
- def unlock(self):
- """
- return True if it was able to release the lock successfully.
- """
- # FIXME: there is no locks in GIO
- return False
-
- def __mount_cb(self,src,res):
- "Internal method used for mounting"
- self.__mount_r=src.mount_finish (res)
- self.__loop.quit()
- def mount(self):
- """
- mount the device and return the mount point.
- If it's already mounted, just return the mount point.
- """
- if self.is_mounted():
- return self.get_mount_point()
- # do the actual mounting
- self.__mount_r=False
- self.__v.mount(gio.MountOperation(),self.__mount_cb)
- self.__loop.run()
- if not self.__mount_r: return None
- self._unmount_needed|=self.__mount_r
- # return Mount point
- return self.get_mount_point()
-
- def __unmount_cb(self,src,res):
- "Internal method used for unmounting"
- self.__unmount_r=src.unmount_finish (res)
- self.__loop.quit()
-
- def unmount(self):
- """
- unmount the device and return True.
- """
- m=self.__v.get_mount()
- if not m or not self.is_mounted():
- return True
- self.__unmount_r=False
- m.unmount(self.__unmount_cb)
- self.__loop.run()
- return self.__unmount_r
-
-class MediaManagerGIO(MediaManager):
- """Just iterate over an instance of this class to get MediaDevice objects"""
- def __init__(self):
- self.vm=gio.volume_monitor_get()
-
- def __iter__(self):
- l=filter(lambda d: d.is_media_removable(),self.vm.get_connected_drives())
- l2=[]
- # loop over devices with media
- for d in l:
- if not d.has_media():
- # skip devices without media
- l2.append(d)
- continue
- # a device could contain many volumes eg. a flash with two partitions
- for v in d.get_volumes():
- o=MediaDeviceGIO((d,v))
- yield o;
- # loop over devices without media (ie. need to close tray and mount)
- # FIXME: there is no way in GIO to close tray
- #for i in l2:
- # pass
-
diff --git a/backends/yum/yumMediaManagerHAL.py b/backends/yum/yumMediaManagerHAL.py
deleted file mode 100644
index a249e1d..0000000
--- a/backends/yum/yumMediaManagerHAL.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Licensed under the GNU General Public License Version 2
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-# Copyright (C) 2009
-# Muayyad Saleh Alsadi <alsadi at ojuba.org>
-
-"""
-This is the HAL implementation of MediaManager module for dealing with removable media
-This module is inteded to be a proof of concept and it is not supposed to be used in final release
-
-it's used like this
-
- from yumMediaManagerHAL import MediaManagerHAL as MediaManager
- manager = MediaManager()
- media, found = None, False
- for media in manager:
- mnt = media.acquire() # get mount point, mount and lock if needed
- found = is_it_the_needed_media(mnt)
- if found: break
- if found: copy_files ..etc.
- if media: del media
-
-NOTE: releasing (unmounting and unlocking) is done when media is destructed
-"""
-
-# one might use dbus-send command line tool to debug hal, like this:
-# dbus-send --system --print-reply --dest = org.freedesktop.Hal /org/freedesktop/Hal/Manager org.freedesktop.Hal.Manager.FindDeviceByCapability string:storage
-# dbus-send --system --print-reply --dest = org.freedesktop.Hal /org/freedesktop/Hal/Manager org.freedesktop.Hal.Manager.FindDeviceByCapability string:storage.cdrom | less
-# dbus-send --system --print-reply --dest = org.freedesktop.Hal /org/freedesktop/Hal/devices/storage_model_DVDRAM_GH20NS10 org.freedesktop.Hal.Device.GetProperty string:storage.removable
-# dbus-send --system --print-reply --dest = org.freedesktop.Hal /org/freedesktop/Hal/Manager org.freedesktop.Hal.Manager.FindDeviceByCapability string:volume
-# dbus-send --system --print-reply --dest = org.freedesktop.Hal /org/freedesktop/Hal/Manager org.freedesktop.Hal.Manager.FindDeviceByCapability string:volume.disc
-
-import dbus
-import dbus.service
-from dbus.mainloop.glib import DBusGMainLoop
-from yumMediaManager import MediaManager, MediaDevice
-dbus_loop = DBusGMainLoop(set_as_default = True)
-bus = dbus.SystemBus()
-interface = 'org.freedesktop.Hal.Device'
-
-class MediaDeviceHAL(MediaDevice):
- """
- You should just use acquire() to get the mount point (the implementation is
- supposed to be smart enough to return mount point when it's already mounted)
- You don't need to manually call release(), just destruct MediaDevice object
- and the implementation should do that if needed.
- """
- def __init__(self, media_id):
- """
- media_id argument is the implementation-specific id in our case it's udi in hal,
- it's provided by MediaManager.
- """
- self._unmount_needed = False
- self._unlock_needed = False
- self.__uid = media_id
- self.__dev = bus.get_object("org.freedesktop.Hal", media_id)
- storage_uid = self.__dev.GetPropertyString('block.storage_device', dbus_interface = interface)
- self.__storage = bus.get_object("org.freedesktop.Hal", storage_uid)
-
- def is_removable(self):
- return self.__storage.GetPropertyString('storage.removable', dbus_interface = interface)
-
- def is_mounted(self):
- return self.__dev.GetPropertyString('volume.is_mounted', dbus_interface = interface)
-
- def is_locked(self):
- return self.__dev.IsLockedByOthers(interface, dbus_interface = interface)
-
- def get_mount_point(self):
- """
- return the mount point or None if not mounted
- """
- if not self.is_mounted():
- return None
- return self.__dev.GetPropertyString('volume.mount_point', dbus_interface = interface) or None
-
- def lock(self):
- """
- return True if lock is successfully acquired.
- """
- # FIXME: it does not work, it returns None instead of True
- r = self.__dev.Lock('needed by Package Manager', dbus_interface = interface) != False
- # print r
- self._unlock_needed |= bool(r)
- return r
-
- def unlock(self):
- """
- return True if it was able to release the lock successfully.
- """
- try:
- return self.__dev.Unlock(dbus_interface = interface) != False
- except dbus.exceptions.DBusException:
- return False
-
- # two internal methods needed by mount()
- def __get_label(self):
- return self.__dev.GetPropertyString('volume.label', dbus_interface = interface)
-
- def __get_fstype(self):
- return self.__dev.GetPropertyString('volume.fstype', dbus_interface = interface)
-
- def mount(self):
- """
- mount the device and return the mount point.
- If it's already mounted, just return the mount point.
- """
- if self.is_mounted():
- return self.get_mount_point()
-
- try:
- r = self.__dev.Mount(self.__get_label(), self.__get_fstype(), dbus.Array(dbus.String()), dbus_interface = 'org.freedesktop.Hal.Device.Volume')
- except dbus.exceptions.DBusException:
- return None
-
- if r != 0:
- return None
-
- self._unmount_needed = True
- return self.get_mount_point() # return Mount point
-
- def unmount(self):
- """
- unmount the device and return True.
- """
- try:
- if not self.is_mounted():
- return True
- r = self.__dev.Unmount(dbus.Array(dbus.String()), dbus_interface = 'org.freedesktop.Hal.Device.Volume')
- except dbus.exceptions.DBusException:
- return False
- return r == 0
-
-class MediaManagerHAL(MediaManager):
- """Just iterate over an instance of this class to get MediaDevice objects"""
- def __init__(self):
- self.__dev = bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/Manager")
-
- def __close_tray_and_be_ready(self):
- for udi in self.__dev.FindDeviceByCapability('storage.cdrom', dbus_interface = 'org.freedesktop.Hal.Manager'):
- try:
- dev = bus.get_object("org.freedesktop.Hal", udi)
- dev.CloseTray(dbus.Array(dbus.String()), dbus_interface = 'org.freedesktop.Hal.Device.Storage')
- except dbus.exceptions.DBusException:
- continue
-
- def __iter__(self):
- self.__close_tray_and_be_ready()
- # use volume.disc to restrict that to optical discs
- for i in self.__dev.FindDeviceByCapability('volume', dbus_interface = 'org.freedesktop.Hal.Manager'):
- o = MediaDeviceHAL(i)
- if o.is_removable():
- yield o
-
diff --git a/backends/yum/yumMediaManagerOS.py b/backends/yum/yumMediaManagerOS.py
deleted file mode 100644
index 0a5a4c5..0000000
--- a/backends/yum/yumMediaManagerOS.py
+++ /dev/null
@@ -1,136 +0,0 @@
-# Licensed under the GNU General Public License Version 2
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-# Copyright (C) 2009
-# Muayyad Saleh Alsadi <alsadi at ojuba.org>
-
-"""
-This is the os.system implementation of MediaManager module for dealing with removable media
-This module is inteded to be a proof of concept and it is not supposed to be used in final release
-
-it's used like this
-
- from yumMediaManagerOS import MediaManagerOS as MediaManager
- manager=MediaManager()
- media,found=None,False
- for media in manager:
- mnt=media.acquire() # get mount point, mount and lock if needed
- found=is_it_the_needed_media(mnt)
- if found: break
- if found: copy_files ..etc.
- if media: del media
-
-NOTE: releasing (unmounting and unlocking) is done when media is destructed
-"""
-
-import re,sys, os, os.path
-from glob import glob
-from tempfile import mkdtemp
-from yumMediaManager import MediaManager,MediaDevice
-class MediaDeviceOS(MediaDevice):
- """
- You should just use acquire() to get the mount point (the implementation is
- supposed to be smart enough to return mount point when it's already mounted)
- You don't need to manually call release(), just destruct MediaDevice object
- and the implementation should do that if needed.
- """
- __ch_re=re.compile(r'\\(0\d\d)')
- def __init__(self,media_id):
- """
- media_id argument is the implementation-specific id
- in our case it's a the device file in /dev/
- """
- self._unmount_needed = False
- self._unlock_needed = False
- self.__d = media_id
-
- def is_removable(self):
- return True
-
- def is_mounted(self):
- return self.get_mount_point()!=None
-
- def is_locked(self):
- # FIXME: there is no locks in OS
- return False
-
- def get_mount_point(self):
- """
- return the mount point or None if not mounted
- """
- l=map(lambda i: i.split(), open('/proc/mounts','rt').readlines())
- d=filter(lambda i: len(i)==6 and i[0]==self.__d, l)
- if not d: return None
- mnt=self.__ch_re.sub(lambda m: chr(int(m.group(1),8)),d[0][1])
- if not os.path.ismount(mnt): return None
- return mnt
-
- def lock(self):
- """
- return True if lock is successfully acquired.
- """
- # FIXME: there is no locks in OS
- return False
-
- def unlock(self):
- """
- return True if it was able to release the lock successfully.
- """
- # FIXME: there is no locks in OS
- return False
-
- def mount(self):
- """
- mount the device and return the mount point.
- If it's already mounted, just return the mount point.
- """
- mnt=self.get_mount_point()
- if mnt!=None: return mnt
- # do the actual mounting
- mnt=mkdtemp(prefix='MediaRepo')
- r=os.system('mount -t udf,iso9660 "%s" "%s"' % (self.__d, mnt))
- if r:
- try: os.rmdir(mnt)
- except OSError: pass
- return None
- self._unmount_needed|=bool(r==0)
- # return Mount point
- return mnt
-
- def unmount(self):
- """
- unmount the device and return True.
- """
- mnt=self.get_mount_point()
- if mnt==None:
- return True
- r=os.system('umount "%s"' % (self.__d))
- if os.path.isdir(mnt):
- try: os.rmdir(mnt)
- except OSError: pass
- return bool(r==0)
-
-class MediaManagerOS(MediaManager):
- """Just iterate over an instance of this class to get MediaDevice objects"""
- def __init__(self):
- pass
-
- def __iter__(self):
- l=glob('/dev/sr[0-9]*')
- for d in l:
- o=MediaDeviceOS(d)
- yield o;
-
commit d6464be3475f3b505a0f62ba44994ace9034e0da
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 12:04:50 2010 +0100
Use the new PkTask API in pkcon so we can deal with Media and Eula queries
diff --git a/client/pk-console.c b/client/pk-console.c
index 34e4132..e8dc4dc 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -681,7 +681,7 @@ pk_console_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
}
/* get the results */
- results = pk_client_generic_finish (PK_CLIENT(task), res, &error);
+ results = pk_task_generic_finish (PK_TASK(task), res, &error);
if (results == NULL) {
/* TRANSLATORS: we failed to get any results, which is pretty fatal in my book */
g_print ("%s: %s\n", _("Fatal error"), error->message);
@@ -920,9 +920,9 @@ pk_console_download_packages (gchar **packages, const gchar *directory, GError *
}
/* do the async action */
- pk_client_download_packages_async (PK_CLIENT(task), package_ids, directory, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_download_packages_async (PK_TASK (task),package_ids, directory, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
out:
g_strfreev (package_ids);
return ret;
@@ -976,9 +976,9 @@ pk_console_get_requires (PkBitfield filters, gchar **packages, GError **error)
}
/* do the async action */
- pk_client_get_requires_async (PK_CLIENT(task), filters, package_ids, TRUE, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_get_requires_async (PK_TASK (task),filters, package_ids, TRUE, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
out:
g_strfreev (package_ids);
return ret;
@@ -1004,9 +1004,9 @@ pk_console_get_depends (PkBitfield filters, gchar **packages, GError **error)
}
/* do the async action */
- pk_client_get_depends_async (PK_CLIENT(task), filters, package_ids, FALSE, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_get_depends_async (PK_TASK (task),filters, package_ids, FALSE, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
out:
g_strfreev (package_ids);
return ret;
@@ -1032,9 +1032,9 @@ pk_console_get_details (gchar **packages, GError **error)
}
/* do the async action */
- pk_client_get_details_async (PK_CLIENT(task), package_ids, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_get_details_async (PK_TASK (task),package_ids, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
out:
g_strfreev (package_ids);
return ret;
@@ -1060,9 +1060,9 @@ pk_console_get_files (gchar **packages, GError **error)
}
/* do the async action */
- pk_client_get_files_async (PK_CLIENT(task), package_ids, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_get_files_async (PK_TASK (task),package_ids, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
out:
g_strfreev (package_ids);
return ret;
@@ -1088,9 +1088,9 @@ pk_console_get_update_detail (gchar **packages, GError **error)
}
/* do the async action */
- pk_client_get_update_detail_async (PK_CLIENT(task), package_ids, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_get_update_detail_async (PK_TASK (task),package_ids, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
out:
g_strfreev (package_ids);
return ret;
@@ -1421,9 +1421,9 @@ main (int argc, char *argv[])
goto out;
}
/* fire off an async request */
- pk_client_search_names_async (PK_CLIENT(task), filters, argv+3, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_search_names_async (PK_TASK (task),filters, argv+3, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (value, "details") == 0) {
if (details == NULL) {
@@ -1433,9 +1433,9 @@ main (int argc, char *argv[])
goto out;
}
/* fire off an async request */
- pk_client_search_details_async (PK_CLIENT(task), filters, argv+3, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_search_details_async (PK_TASK (task),filters, argv+3, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (value, "group") == 0) {
if (details == NULL) {
@@ -1445,9 +1445,9 @@ main (int argc, char *argv[])
goto out;
}
/* fire off an async request */
- pk_client_search_groups_async (PK_CLIENT(task), filters, argv+3, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_search_groups_async (PK_TASK (task),filters, argv+3, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (value, "file") == 0) {
if (details == NULL) {
@@ -1457,9 +1457,9 @@ main (int argc, char *argv[])
goto out;
}
/* fire off an async request */
- pk_client_search_files_async (PK_CLIENT(task), filters, argv+3, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_search_files_async (PK_TASK (task),filters, argv+3, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else {
/* TRANSLATORS: the search type was provided, but invalid */
error = g_error_new (1, 0, "%s", _("Invalid search type"));
@@ -1540,9 +1540,9 @@ main (int argc, char *argv[])
retval = PK_EXIT_CODE_SYNTAX_INVALID;
goto out;
}
- pk_client_rollback_async (PK_CLIENT(task), value, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_rollback_async (PK_TASK (task),value, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "update") == 0) {
if (value == NULL) {
@@ -1561,9 +1561,9 @@ main (int argc, char *argv[])
retval = PK_EXIT_CODE_SYNTAX_INVALID;
goto out;
}
- pk_client_resolve_async (PK_CLIENT(task), filters, argv+2, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_resolve_async (PK_TASK (task),filters, argv+2, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "repo-enable") == 0) {
if (value == NULL) {
@@ -1572,9 +1572,9 @@ main (int argc, char *argv[])
retval = PK_EXIT_CODE_SYNTAX_INVALID;
goto out;
}
- pk_client_repo_enable_async (PK_CLIENT(task), value, TRUE, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_repo_enable_async (PK_TASK (task),value, TRUE, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "repo-disable") == 0) {
if (value == NULL) {
@@ -1583,9 +1583,9 @@ main (int argc, char *argv[])
retval = PK_EXIT_CODE_SYNTAX_INVALID;
goto out;
}
- pk_client_repo_enable_async (PK_CLIENT(task), value, FALSE, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_repo_enable_async (PK_TASK (task),value, FALSE, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "repo-set-data") == 0) {
if (value == NULL || details == NULL || parameter == NULL) {
@@ -1599,9 +1599,9 @@ main (int argc, char *argv[])
(GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "repo-list") == 0) {
- pk_client_get_repo_list_async (PK_CLIENT(task), filters, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_get_repo_list_async (PK_TASK (task),filters, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "get-time") == 0) {
PkRoleEnum role;
@@ -1661,9 +1661,9 @@ main (int argc, char *argv[])
retval = PK_EXIT_CODE_SYNTAX_INVALID;
goto out;
}
- pk_client_what_provides_async (PK_CLIENT(task), filters, PK_PROVIDES_ENUM_ANY, argv+2, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_what_provides_async (PK_TASK (task),filters, PK_PROVIDES_ENUM_ANY, argv+2, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "get-details") == 0) {
if (value == NULL) {
@@ -1684,20 +1684,20 @@ main (int argc, char *argv[])
nowait = !pk_console_get_files (argv+2, &error);
} else if (strcmp (mode, "get-updates") == 0) {
- pk_client_get_updates_async (PK_CLIENT(task), filters, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_get_updates_async (PK_TASK (task),filters, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "get-categories") == 0) {
- pk_client_get_categories_async (PK_CLIENT(task), cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
-
- } else if (strcmp (mode, "get-packages") == 0) {
- pk_client_get_packages_async (PK_CLIENT(task), filters, cancellable,
+ pk_task_get_categories_async (PK_TASK (task),cancellable,
(PkProgressCallback) pk_console_progress_cb, NULL,
(GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ } else if (strcmp (mode, "get-packages") == 0) {
+ pk_task_get_packages_async (PK_TASK (task),filters, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+
} else if (strcmp (mode, "get-roles") == 0) {
text = pk_role_bitfield_to_string (roles);
g_strdelimit (text, ";", '\n');
@@ -1731,9 +1731,9 @@ main (int argc, char *argv[])
(GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else if (strcmp (mode, "refresh") == 0) {
- pk_client_refresh_cache_async (PK_CLIENT(task), FALSE, cancellable,
- (PkProgressCallback) pk_console_progress_cb, NULL,
- (GAsyncReadyCallback) pk_console_finished_cb, NULL);
+ pk_task_refresh_cache_async (PK_TASK (task),FALSE, cancellable,
+ (PkProgressCallback) pk_console_progress_cb, NULL,
+ (GAsyncReadyCallback) pk_console_finished_cb, NULL);
} else {
/* TRANSLATORS: The user tried to use an unsupported option on the command line */
commit b9bbcf001b6adcb6faf43f2ce1ca115aa541fe53
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 12:03:51 2010 +0100
glib: add sync versions of the new API in PkTask
diff --git a/lib/packagekit-glib2/pk-task-sync.c b/lib/packagekit-glib2/pk-task-sync.c
index 8da09d2..a6b9b9c 100644
--- a/lib/packagekit-glib2/pk-task-sync.c
+++ b/lib/packagekit-glib2/pk-task-sync.c
@@ -304,3 +304,851 @@ pk_task_install_files_sync (PkTask *task, gchar **files, GCancellable *cancellab
return results;
}
+/**
+ * pk_task_resolve_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @packages: package names to find
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Resolves a package name to a package-id.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_resolve_sync (PkTask *task, PkBitfield filters, gchar **packages, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_resolve_async (task, filters, packages, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_search_names_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @values: search values
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Searches for a package name.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_search_names_sync (PkTask *task, PkBitfield filters, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_search_names_async (task, filters, values, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_search_details_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @values: search values
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Searches for some package details.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_search_details_sync (PkTask *task, PkBitfield filters, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_search_details_async (task, filters, values, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_search_groups_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @values: search values
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Searches the group lists.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_search_groups_sync (PkTask *task, PkBitfield filters, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_search_groups_async (task, filters, values, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_search_files_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @values: search values
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Searches for specific files.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_search_files_sync (PkTask *task, PkBitfield filters, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_search_files_async (task, filters, values, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_get_details_sync:
+ * @task: a valid #PkTask instance
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Gets details about packages.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_get_details_sync (PkTask *task, gchar **package_ids, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_get_details_async (task, package_ids, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_get_update_detail_sync:
+ * @task: a valid #PkTask instance
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Gets details about updates.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_get_update_detail_sync (PkTask *task, gchar **package_ids, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_get_update_detail_async (task, package_ids, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_download_packages_sync:
+ * @task: a valid #PkTask instance
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @directory: the destination directory
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Downloads packages
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_download_packages_sync (PkTask *task, gchar **package_ids, const gchar *directory, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_download_packages_async (task, package_ids, directory, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_get_updates_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Gets the update lists.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_get_updates_sync (PkTask *task, PkBitfield filters, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_get_updates_async (task, filters, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_get_depends_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @recursive: if we should recurse to packages that depend on other packages
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Get the list of dependant packages.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_get_depends_sync (PkTask *task, PkBitfield filters, gchar **package_ids, gboolean recursive, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_get_depends_async (task, filters, package_ids, recursive, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_get_packages_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Gets the list of packages.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_get_packages_sync (PkTask *task, PkBitfield filters, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_get_packages_async (task, filters, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_get_requires_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @recursive: if we should return packages that depend on the ones we do
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Get the packages this package requires.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_get_requires_sync (PkTask *task, PkBitfield filters, gchar **package_ids, gboolean recursive, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_get_requires_async (task, filters, package_ids, recursive, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_what_provides_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @provides: a #PkProvidesEnum type
+ * @values: values to search for
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Find the package that provides some resource.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_what_provides_sync (PkTask *task, PkBitfield filters, PkProvidesEnum provides, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_what_provides_async (task, filters, provides, values, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_get_files_sync:
+ * @task: a valid #PkTask instance
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Get the files in a package.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_get_files_sync (PkTask *task, gchar **package_ids, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_get_files_async (task, package_ids, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_get_categories_sync:
+ * @task: a valid #PkTask instance
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Get the categories available.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_get_categories_sync (PkTask *task, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_get_categories_async (task, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_refresh_cache_sync:
+ * @task: a valid #PkTask instance
+ * @force: if the metadata should be deleted and re-downloaded even if it is correct
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Refresh the package cache.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_refresh_cache_sync (PkTask *task, gboolean force, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_refresh_cache_async (task, force, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_rollback_sync:
+ * @task: a valid #PkTask instance
+ * @transaction_id: The transaction ID of the old transaction
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Rollback to a previous package state.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_rollback_sync (PkTask *task, const gchar *transaction_id, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_rollback_async (task, transaction_id, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_get_repo_list_sync:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Get the list of available repositories.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_get_repo_list_sync (PkTask *task, PkBitfield filters, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_get_repo_list_async (task, filters, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
+/**
+ * pk_task_repo_enable_sync:
+ * @task: a valid #PkTask instance
+ * @repo_id: The software source ID
+ * @enabled: %TRUE or %FALSE
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @error: the #GError to store any failure, or %NULL
+ *
+ * Enable or disable a specific repo.
+ *
+ * Since: 0.6.5
+ **/
+PkResults *
+pk_task_repo_enable_sync (PkTask *task, const gchar *repo_id, gboolean enabled, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ PkTaskHelper *helper;
+ PkResults *results;
+
+ g_return_val_if_fail (PK_IS_TASK (task), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* create temp object */
+ helper = g_new0 (PkTaskHelper, 1);
+ helper->loop = g_main_loop_new (NULL, FALSE);
+ helper->error = error;
+
+ /* run async method */
+ pk_task_repo_enable_async (task, repo_id, enabled, cancellable, progress_callback, progress_user_data,
+ (GAsyncReadyCallback) pk_task_generic_finish_sync, helper);
+
+ g_main_loop_run (helper->loop);
+
+ results = helper->results;
+
+ /* free temp object */
+ g_main_loop_unref (helper->loop);
+ g_free (helper);
+
+ return results;
+}
+
diff --git a/lib/packagekit-glib2/pk-task-sync.h b/lib/packagekit-glib2/pk-task-sync.h
index e192e2a..666f83b 100644
--- a/lib/packagekit-glib2/pk-task-sync.h
+++ b/lib/packagekit-glib2/pk-task-sync.h
@@ -65,6 +65,151 @@ PkResults *pk_task_update_system_sync (PkTask *task,
gpointer progress_user_data,
GError **error);
+PkResults *pk_task_resolve_sync (PkTask *task,
+ PkBitfield filters,
+ gchar **packages,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_search_names_sync (PkTask *task,
+ PkBitfield filters,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_search_details_sync (PkTask *task,
+ PkBitfield filters,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_search_groups_sync (PkTask *task,
+ PkBitfield filters,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_search_files_sync (PkTask *task,
+ PkBitfield filters,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_get_details_sync (PkTask *task,
+ gchar **package_ids,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_get_update_detail_sync (PkTask *task,
+ gchar **package_ids,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_download_packages_sync (PkTask *task,
+ gchar **package_ids,
+ const gchar *directory,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_get_updates_sync (PkTask *task,
+ PkBitfield filters,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_get_depends_sync (PkTask *task,
+ PkBitfield filters,
+ gchar **package_ids,
+ gboolean recursive,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_get_packages_sync (PkTask *task,
+ PkBitfield filters,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_get_requires_sync (PkTask *task,
+ PkBitfield filters,
+ gchar **package_ids,
+ gboolean recursive,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_what_provides_sync (PkTask *task,
+ PkBitfield filters,
+ PkProvidesEnum provides,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_get_files_sync (PkTask *task,
+ gchar **package_ids,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_get_categories_sync (PkTask *task,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_refresh_cache_sync (PkTask *task,
+ gboolean force,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_rollback_sync (PkTask *task,
+ const gchar *transaction_id,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_get_repo_list_sync (PkTask *task,
+ PkBitfield filters,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
+PkResults *pk_task_repo_enable_sync (PkTask *task,
+ const gchar *repo_id,
+ gboolean enabled,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
G_END_DECLS
#endif /* __PK_TASK_SYNC_H */
commit 31217d5862df8aed1708cbc14b80eb57550de16e
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 12:03:24 2010 +0100
glib: Add some new PkTask methods that handle the Media and Eula callbacks for the application
diff --git a/lib/packagekit-glib2/pk-task.c b/lib/packagekit-glib2/pk-task.c
index fd0709e..c2fa44d 100644
--- a/lib/packagekit-glib2/pk-task.c
+++ b/lib/packagekit-glib2/pk-task.c
@@ -79,6 +79,16 @@ typedef struct {
GCancellable *cancellable;
PkProgressCallback progress_callback;
gpointer progress_user_data;
+ gboolean enabled;
+ gboolean force;
+ gboolean recursive;
+ gchar *directory;
+ gchar **packages;
+ gchar *repo_id;
+ gchar *transaction_id;
+ gchar **values;
+ PkBitfield filters;
+ PkProvidesEnum provides;
} PkTaskState;
G_DEFINE_TYPE (PkTask, pk_task, PK_TYPE_CLIENT)
@@ -144,8 +154,13 @@ pk_task_generic_state_finish (PkTaskState *state, const GError *error)
g_object_unref (state->cancellable);
if (state->results != NULL)
g_object_unref (state->results);
- g_strfreev (state->package_ids);
+ g_free (state->directory);
+ g_free (state->repo_id);
+ g_free (state->transaction_id);
g_strfreev (state->files);
+ g_strfreev (state->package_ids);
+ g_strfreev (state->packages);
+ g_strfreev (state->values);
g_object_unref (state->res);
g_object_unref (state->task);
g_slice_free (PkTaskState, state);
@@ -162,35 +177,101 @@ pk_task_do_async_action (PkTaskState *state)
/* do the correct action */
if (state->role == PK_ROLE_ENUM_INSTALL_PACKAGES) {
- /* start install async */
- egg_debug ("doing install");
pk_client_install_packages_async (PK_CLIENT(state->task), state->only_trusted, state->package_ids,
state->cancellable, state->progress_callback, state->progress_user_data,
(GAsyncReadyCallback) pk_task_ready_cb, state);
} else if (state->role == PK_ROLE_ENUM_UPDATE_PACKAGES) {
- /* start update async */
- egg_debug ("doing update");
pk_client_update_packages_async (PK_CLIENT(state->task), state->only_trusted, state->package_ids,
state->cancellable, state->progress_callback, state->progress_user_data,
(GAsyncReadyCallback) pk_task_ready_cb, state);
} else if (state->role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
- /* start remove async */
- egg_debug ("doing remove");
pk_client_remove_packages_async (PK_CLIENT(state->task), state->package_ids, state->allow_deps, state->autoremove,
state->cancellable, state->progress_callback, state->progress_user_data,
(GAsyncReadyCallback) pk_task_ready_cb, state);
} else if (state->role == PK_ROLE_ENUM_UPDATE_SYSTEM) {
- /* start update async */
- egg_debug ("doing update system");
pk_client_update_system_async (PK_CLIENT(state->task), state->only_trusted,
state->cancellable, state->progress_callback, state->progress_user_data,
(GAsyncReadyCallback) pk_task_ready_cb, state);
} else if (state->role == PK_ROLE_ENUM_INSTALL_FILES) {
- /* start install async */
- egg_debug ("doing install files");
pk_client_install_files_async (PK_CLIENT(state->task), state->only_trusted, state->files,
state->cancellable, state->progress_callback, state->progress_user_data,
(GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_RESOLVE) {
+ pk_client_resolve_async (PK_CLIENT(state->task), state->filters, state->packages,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_SEARCH_NAME) {
+ pk_client_search_names_async (PK_CLIENT(state->task), state->filters, state->values,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_SEARCH_DETAILS) {
+ pk_client_search_details_async (PK_CLIENT(state->task), state->filters, state->values,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_SEARCH_GROUP) {
+ pk_client_search_groups_async (PK_CLIENT(state->task), state->filters, state->values,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_SEARCH_FILE) {
+ pk_client_search_files_async (PK_CLIENT(state->task), state->filters, state->values,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_GET_DETAILS) {
+ pk_client_get_details_async (PK_CLIENT(state->task), state->package_ids,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_GET_UPDATE_DETAIL) {
+ pk_client_get_update_detail_async (PK_CLIENT(state->task), state->package_ids,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_DOWNLOAD_PACKAGES) {
+ pk_client_download_packages_async (PK_CLIENT(state->task), state->package_ids, state->directory,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_GET_UPDATES) {
+ pk_client_get_updates_async (PK_CLIENT(state->task), state->filters,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_GET_DEPENDS) {
+ pk_client_get_depends_async (PK_CLIENT(state->task), state->filters, state->package_ids, state->recursive,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_GET_PACKAGES) {
+ pk_client_get_packages_async (PK_CLIENT(state->task), state->filters,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_GET_REQUIRES) {
+ pk_client_get_requires_async (PK_CLIENT(state->task), state->filters, state->package_ids, state->recursive,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_WHAT_PROVIDES) {
+ pk_client_what_provides_async (PK_CLIENT(state->task), state->filters, state->provides, state->values,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_GET_FILES) {
+ pk_client_get_files_async (PK_CLIENT(state->task), state->package_ids,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_GET_CATEGORIES) {
+ pk_client_get_categories_async (PK_CLIENT(state->task),
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_REFRESH_CACHE) {
+ pk_client_refresh_cache_async (PK_CLIENT(state->task), state->force,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_ROLLBACK) {
+ pk_client_rollback_async (PK_CLIENT(state->task), state->transaction_id,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_GET_REPO_LIST) {
+ pk_client_get_repo_list_async (PK_CLIENT(state->task), state->filters,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
+ } else if (state->role == PK_ROLE_ENUM_REPO_ENABLE) {
+ pk_client_repo_enable_async (PK_CLIENT(state->task), state->repo_id, state->enabled,
+ state->cancellable, state->progress_callback, state->progress_user_data,
+ (GAsyncReadyCallback) pk_task_ready_cb, state);
} else {
g_assert_not_reached ();
}
@@ -811,16 +892,16 @@ out:
void
pk_task_install_packages_async (PkTask *task, gchar **package_ids, GCancellable *cancellable,
PkProgressCallback progress_callback, gpointer progress_user_data,
- GAsyncReadyCallback callback, gpointer user_data)
+ GAsyncReadyCallback callback_ready, gpointer user_data)
{
GSimpleAsyncResult *res;
PkTaskState *state;
PkTaskClass *klass = PK_TASK_GET_CLASS (task);
g_return_if_fail (PK_IS_TASK (task));
- g_return_if_fail (callback != NULL);
+ g_return_if_fail (callback_ready != NULL);
- res = g_simple_async_result_new (G_OBJECT (task), callback, user_data, pk_task_install_packages_async);
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
/* save state */
state = g_slice_new0 (PkTaskState);
@@ -1066,6 +1147,980 @@ pk_task_update_system_async (PkTask *task, GCancellable *cancellable,
}
/**
+ * pk_task_resolve_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @packages: package names to find
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Resolves a package name to a package-id.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_resolve_async (PkTask *task, PkBitfield filters, gchar **packages, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_RESOLVE;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->packages = g_strdupv (packages);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_search_names_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @values: search values
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Searches for a package name.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_search_names_async (PkTask *task, PkBitfield filters, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_SEARCH_NAME;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->values = g_strdupv (values);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_search_details_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @values: search values
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Searches for some package details.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_search_details_async (PkTask *task, PkBitfield filters, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_SEARCH_DETAILS;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->values = g_strdupv (values);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_search_groups_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @values: search values
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Searches the group lists.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_search_groups_async (PkTask *task, PkBitfield filters, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_SEARCH_GROUP;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->values = g_strdupv (values);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_search_files_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @values: search values
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Searches for specific files.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_search_files_async (PkTask *task, PkBitfield filters, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_SEARCH_FILE;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->values = g_strdupv (values);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_get_details_async:
+ * @task: a valid #PkTask instance
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Gets details about packages.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_get_details_async (PkTask *task, gchar **package_ids, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_GET_DETAILS;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->package_ids = g_strdupv (package_ids);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_get_update_detail_async:
+ * @task: a valid #PkTask instance
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Gets details about updates.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_get_update_detail_async (PkTask *task, gchar **package_ids, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_GET_UPDATE_DETAIL;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->package_ids = g_strdupv (package_ids);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_download_packages_async:
+ * @task: a valid #PkTask instance
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @directory: the destination directory
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Downloads packages
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_download_packages_async (PkTask *task, gchar **package_ids, const gchar *directory, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_DOWNLOAD_PACKAGES;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->package_ids = g_strdupv (package_ids);
+ state->directory = g_strdup (directory);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_get_updates_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Gets the update lists.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_get_updates_async (PkTask *task, PkBitfield filters, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_GET_UPDATES;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_get_depends_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @recursive: if we should recurse to packages that depend on other packages
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Get the list of dependant packages.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_get_depends_async (PkTask *task, PkBitfield filters, gchar **package_ids, gboolean recursive, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_GET_DEPENDS;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->package_ids = g_strdupv (package_ids);
+ state->recursive = recursive;
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_get_packages_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Gets the list of packages.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_get_packages_async (PkTask *task, PkBitfield filters, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_GET_PACKAGES;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_get_requires_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @recursive: if we should return packages that depend on the ones we do
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Get the packages this package requires.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_get_requires_async (PkTask *task, PkBitfield filters, gchar **package_ids, gboolean recursive, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_GET_REQUIRES;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->package_ids = g_strdupv (package_ids);
+ state->recursive = recursive;
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_what_provides_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @provides: a #PkProvidesEnum type
+ * @values: values to search for
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Find the package that provides some resource.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_what_provides_async (PkTask *task, PkBitfield filters, PkProvidesEnum provides, gchar **values, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_WHAT_PROVIDES;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->provides = provides;
+ state->values = g_strdupv (values);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_get_files_async:
+ * @task: a valid #PkTask instance
+ * @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Get the files in a package.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_get_files_async (PkTask *task, gchar **package_ids, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_GET_FILES;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->package_ids = g_strdupv (package_ids);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_get_categories_async:
+ * @task: a valid #PkTask instance
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Get the categories available.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_get_categories_async (PkTask *task, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_GET_CATEGORIES;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_refresh_cache_async:
+ * @task: a valid #PkTask instance
+ * @force: if the metadata should be deleted and re-downloaded even if it is correct
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Refresh the package cache.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_refresh_cache_async (PkTask *task, gboolean force, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_REFRESH_CACHE;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->force = force;
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_rollback_async:
+ * @task: a valid #PkTask instance
+ * @transaction_id: The transaction ID of the old transaction
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Rollback to a previous package state.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_rollback_async (PkTask *task, const gchar *transaction_id, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_ROLLBACK;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->transaction_id = g_strdup (transaction_id);
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_get_repo_list_async:
+ * @task: a valid #PkTask instance
+ * @filters: a bitfield of filters that can be used to limit the results
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Get the list of available repositories.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_get_repo_list_async (PkTask *task, PkBitfield filters, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_GET_REPO_LIST;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->filters = filters;
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
+ * pk_task_repo_enable_async:
+ * @task: a valid #PkTask instance
+ * @repo_id: The software source ID
+ * @enabled: %TRUE or %FALSE
+ * @cancellable: a #GCancellable or %NULL
+ * @progress_callback: the function to run when the progress changes
+ * @progress_user_data: data to pass to @progress_callback
+ * @callback: the function to run on completion
+ * @user_data: the data to pass to @callback
+ *
+ * Enable or disable a specific repo.
+ *
+ * Since: 0.6.5
+ **/
+void
+pk_task_repo_enable_async (PkTask *task, const gchar *repo_id, gboolean enabled, GCancellable *cancellable,
+ PkProgressCallback progress_callback, gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready, gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+ PkTaskState *state;
+
+ g_return_if_fail (PK_IS_TASK (task));
+ g_return_if_fail (callback_ready != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (task), callback_ready, user_data, pk_task_install_packages_async);
+
+ /* save state */
+ state = g_slice_new0 (PkTaskState);
+ state->role = PK_ROLE_ENUM_REPO_ENABLE;
+ state->res = g_object_ref (res);
+ state->task = g_object_ref (task);
+ if (cancellable != NULL)
+ state->cancellable = g_object_ref (cancellable);
+ state->progress_callback = progress_callback;
+ state->progress_user_data = progress_user_data;
+ state->ret = FALSE;
+ state->only_trusted = TRUE;
+ state->repo_id = g_strdup (repo_id);
+ state->enabled = enabled;
+ state->request = pk_task_generate_request_id ();
+
+ egg_debug ("adding state %p", state);
+ g_ptr_array_add (task->priv->array, state);
+
+ /* run task with callbacks */
+ pk_task_do_async_action (state);
+
+ g_object_unref (res);
+}
+
+/**
* pk_task_generic_finish:
* @task: a valid #PkTask instance
* @res: the #GAsyncResult
diff --git a/lib/packagekit-glib2/pk-task.h b/lib/packagekit-glib2/pk-task.h
index f128941..16f36df 100644
--- a/lib/packagekit-glib2/pk-task.h
+++ b/lib/packagekit-glib2/pk-task.h
@@ -123,6 +123,151 @@ void pk_task_update_system_async (PkTask *task,
gpointer progress_user_data,
GAsyncReadyCallback callback_ready,
gpointer user_data);
+void pk_task_resolve_async (PkTask *task,
+ PkBitfield filters,
+ gchar **packages,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_search_names_async (PkTask *task,
+ PkBitfield filters,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_search_details_async (PkTask *task,
+ PkBitfield filters,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_search_groups_async (PkTask *task,
+ PkBitfield filters,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_search_files_async (PkTask *task,
+ PkBitfield filters,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_get_details_async (PkTask *task,
+ gchar **package_ids,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_get_update_detail_async (PkTask *task,
+ gchar **package_ids,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_download_packages_async (PkTask *task,
+ gchar **package_ids,
+ const gchar *directory,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_get_updates_async (PkTask *task,
+ PkBitfield filters,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_get_depends_async (PkTask *task,
+ PkBitfield filters,
+ gchar **package_ids,
+ gboolean recursive,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_get_packages_async (PkTask *task,
+ PkBitfield filters,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_get_requires_async (PkTask *task,
+ PkBitfield filters,
+ gchar **package_ids,
+ gboolean recursive,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_what_provides_async (PkTask *task,
+ PkBitfield filters,
+ PkProvidesEnum provides,
+ gchar **values,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_get_files_async (PkTask *task,
+ gchar **package_ids,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_get_categories_async (PkTask *task,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_refresh_cache_async (PkTask *task,
+ gboolean force,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_rollback_async (PkTask *task,
+ const gchar *transaction_id,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_get_repo_list_async (PkTask *task,
+ PkBitfield filters,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
+void pk_task_repo_enable_async (PkTask *task,
+ const gchar *repo_id,
+ gboolean enabled,
+ GCancellable *cancellable,
+ PkProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GAsyncReadyCallback callback_ready,
+ gpointer user_data);
gboolean pk_task_user_accepted (PkTask *task,
guint request);
commit 0244fe8f011425fc36d74c69f17e339665e82c31
Author: Richard Hughes <richard at hughsie.com>
Date: Wed May 12 12:00:07 2010 +0100
Show the MediaChangeRequired signals in pkmon
diff --git a/client/pk-monitor.c b/client/pk-monitor.c
index b8430c4..c8f5b21 100644
--- a/client/pk-monitor.c
+++ b/client/pk-monitor.c
@@ -103,6 +103,29 @@ pk_monitor_message_cb (PkMessage *item, const gchar *transaction_id)
}
/**
+ * pk_monitor_media_change_required_cb:
+ **/
+static void
+pk_monitor_media_change_required_cb (PkMediaChangeRequired *item, const gchar *transaction_id)
+{
+ gchar *id;
+ gchar *text;
+ PkMediaTypeEnum type;
+
+ /* get data */
+ g_object_get (item,
+ "media-type", &type,
+ "media-id", &id,
+ "media-text", &text,
+ NULL);
+
+ g_print ("%s\tmedia-change-required: %s, %s, %s\n",
+ transaction_id, pk_media_type_enum_to_string (type), id, text);
+ g_free (id);
+ g_free (text);
+}
+
+/**
* pk_monitor_adopt_cb:
**/
static void
@@ -114,7 +137,8 @@ pk_monitor_adopt_cb (PkClient *_client, GAsyncResult *res, gpointer user_data)
PkExitEnum exit_enum;
gchar *transaction_id = NULL;
PkError *error_code = NULL;
- GPtrArray *array = NULL;
+ GPtrArray *message_array = NULL;
+ GPtrArray *media_array = NULL;
/* get the results */
results = pk_client_generic_finish (client, res, &error);
@@ -138,8 +162,12 @@ pk_monitor_adopt_cb (PkClient *_client, GAsyncResult *res, gpointer user_data)
g_print ("%s\texit code: %s\n", transaction_id, pk_exit_enum_to_string (exit_enum));
/* message */
- array = pk_results_get_message_array (results);
- g_ptr_array_foreach (array, (GFunc) pk_monitor_message_cb, transaction_id);
+ message_array = pk_results_get_message_array (results);
+ g_ptr_array_foreach (message_array, (GFunc) pk_monitor_message_cb, transaction_id);
+
+ /* media change required */
+ media_array = pk_results_get_media_change_required_array (results);
+ g_ptr_array_foreach (media_array, (GFunc) pk_monitor_media_change_required_cb, transaction_id);
/* check error code */
error_code = pk_results_get_error_code (results);
@@ -147,8 +175,10 @@ pk_monitor_adopt_cb (PkClient *_client, GAsyncResult *res, gpointer user_data)
g_print ("%s\terror code: %s, %s\n", transaction_id, pk_error_enum_to_string (pk_error_get_code (error_code)), pk_error_get_details (error_code));
out:
g_free (transaction_id);
- if (array != NULL)
- g_ptr_array_unref (array);
+ if (message_array != NULL)
+ g_ptr_array_unref (message_array);
+ if (media_array != NULL)
+ g_ptr_array_unref (media_array);
if (error_code != NULL)
g_object_unref (error_code);
if (progress != NULL)
commit 44d673b96eb1a76c2839d98bf9090aaf848dd563
Author: Adrien Bustany <abustany at gnome.org>
Date: Tue May 11 21:56:49 2010 -0400
PackageKit-Qt: Add Q_ENUMS to DaemonError
This commit adds the Q_ENUMS macro for the DaemonError enum defined in
client.h. This allows using Qt's meta-object system with the enum, for
example to convert numeric values into human readable form.
diff --git a/lib/packagekit-qt/src/client.h b/lib/packagekit-qt/src/client.h
index 3ee0417..64d6a7a 100644
--- a/lib/packagekit-qt/src/client.h
+++ b/lib/packagekit-qt/src/client.h
@@ -50,6 +50,7 @@ class Client : public QObject
{
Q_OBJECT
+ Q_ENUMS(DaemonError)
public:
/**
commit b9ab0467e24a91d3f13cfaa947726ecab976da40
Author: Richard Hughes <richard at hughsie.com>
Date: Tue May 11 13:53:25 2010 +0100
yum: Do not abort init when Yum.conf does not contain some required keys
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index f6bb16d..13afbd8 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -237,8 +237,20 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
config = ConfigParser.ConfigParser()
try:
config.read('/etc/PackageKit/Yum.conf')
+ except Exception, e:
+ raise PkError(ERROR_REPO_CONFIGURATION_ERROR, "Failed to load Yum.conf: %s" % _to_unicode(e))
+
+ # if this key does not exist, it's not fatal
+ try:
self.system_packages = config.get('Backend', 'SystemPackages').split(';')
+ except ConfigParser.NoOptionError, e:
+ self.system_packages = []
+ except Exception, e:
+ raise PkError(ERROR_REPO_CONFIGURATION_ERROR, "Failed to load Yum.conf: %s" % _to_unicode(e))
+ try:
self.infra_packages = config.get('Backend', 'InfrastructurePackages').split(';')
+ except ConfigParser.NoOptionError, e:
+ self.infra_packages = []
except Exception, e:
raise PkError(ERROR_REPO_CONFIGURATION_ERROR, "Failed to load Yum.conf: %s" % _to_unicode(e))
@@ -3219,6 +3231,8 @@ class PackageKitYumBase(yum.YumBase):
try:
config.read('/etc/PackageKit/Yum.conf')
disabled_plugins = config.get('Backend', 'DisabledPlugins').split(';')
+ except ConfigParser.NoOptionError, e:
+ disabled_plugins = []
except Exception, e:
raise PkError(ERROR_REPO_CONFIGURATION_ERROR, "Failed to load Yum.conf: %s" % _to_unicode(e))
disabled_plugins.append('refresh-packagekit')
commit 1ff93715b75be888a05d64f62022dfb6c80ae8c7
Author: Sebastian Heinlein <devel at glatzor.de>
Date: Mon May 10 05:57:48 2010 +0200
APT: Make sure to use format_string consequently on every output which
could contain multiple lines
diff --git a/backends/apt/aptBackend.py b/backends/apt/aptBackend.py
index 33577ee..474ac85 100755
--- a/backends/apt/aptBackend.py
+++ b/backends/apt/aptBackend.py
@@ -279,7 +279,7 @@ class DpkgInstallProgress(apt.progress.InstallProgress):
pkg = statusl[1].strip()
#print status
if status == "error":
- self.error(pkg, status)
+ self.error(pkg, format_string(status))
elif status == "conffile-prompt":
# we get a string like this:
# 'current-conffile' 'new-conffile' useredited distedited
@@ -586,7 +586,8 @@ class PackageKitAptBackend(PackageKitBaseBackend):
result_names.update(stdout.split())
self._emit_visible_packages_by_name(filters, result_names)
else:
- self.error(ERROR_INTERNAL_ERROR, "%s %s" % (stdout, stderr))
+ self.error(ERROR_INTERNAL_ERROR,
+ format_string("%s %s" % (stdout, stderr)))
# Search for installed files
filenames_regex = []
for filename in filenames:
@@ -909,8 +910,8 @@ class PackageKitAptBackend(PackageKitBaseBackend):
cve_url = ";;".join(get_cve_urls(changelog))
self.update_detail(pkg_id, updates, obsoletes, vendor_url,
bugzilla_url, cve_url, restart,
- update_text.replace("\n", ";"),
- changelog.replace("\n", ";"),
+ format_string(update_text),
+ format_string(changelog),
state, issued, updated)
def get_details(self, pkg_ids):
@@ -934,7 +935,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
license = "unknown"
group = self._get_package_group(pkg)
self.details(pkg_id, license, group,
- pkg.description.replace("\n", ";"),
+ format_string(pkg.description),
pkg.homepage.decode(DEFAULT_ENCODING),
pkg.packageSize)
@@ -1347,7 +1348,8 @@ class PackageKitAptBackend(PackageKitBaseBackend):
try:
ver.fetch_binary(dest, progress)
except Exception, error:
- self.error(ERROR_PACKAGE_DOWNLOAD_FAILED, error.message)
+ self.error(ERROR_PACKAGE_DOWNLOAD_FAILED,
+ format_string(error.message))
else:
self.files(id, os.path.join(dest,
os.path.basename(ver.filename)))
@@ -1441,7 +1443,8 @@ class PackageKitAptBackend(PackageKitBaseBackend):
deb = apt.debfile.DebPackage(path, self._cache)
packages.append(deb)
if not deb.check():
- self.error(ERROR_LOCAL_INSTALL_FAILED, deb._failureString)
+ self.error(ERROR_LOCAL_INSTALL_FAILED,
+ format_string(deb._failureString))
(install, remove, unauthenticated) = deb.required_changes
pklog.debug("Changes: Install %s, Remove %s, Unauthenticated "
"%s" % (install, remove, unauthenticated))
@@ -1466,17 +1469,18 @@ class PackageKitAptBackend(PackageKitBaseBackend):
except InstallTimeOutPKError, e:
self._recover()
#FIXME: should provide more information
- self.error(ERROR_INTERNAL_ERROR,
- "Transaction was cancelled since the installation "
- "of a package hung.\n"
- "This can be caused by maintainer scripts which "
- "require input on the terminal:\n%s" % e.message)
+ msg = "Transaction was cancelled since the installation " \
+ "of a package hung.\n" \
+ "This can be caused by maintainer scripts which " \
+ "require input on the terminal:\n%s" % e.message
+ self.error(ERROR_INTERNAL_ERROR, format_string(msg))
except PackageManagerFailedPKError, e:
self._recover()
- self.error(ERROR_INTERNAL_ERROR, "%s\n%s" % (e.message, e.output))
+ self.error(ERROR_INTERNAL_ERROR,
+ format_string("%s\n%s" % (e.message, e.output)))
except Exception, e:
self._recover()
- self.error(ERROR_INTERNAL_ERROR, e.message)
+ self.error(ERROR_INTERNAL_ERROR, format_string(e.message))
self.percentage(100)
def simulate_install_files(self, inst_files):
@@ -1494,7 +1498,8 @@ class PackageKitAptBackend(PackageKitBaseBackend):
deb = apt.debfile.DebPackage(path, self._cache)
pkgs.append(deb.pkgname)
if not deb.check():
- self.error(ERROR_LOCAL_INSTALL_FAILED, deb._failureString)
+ self.error(ERROR_LOCAL_INSTALL_FAILED,
+ format_string(deb._failureString))
self._emit_changes(pkgs)
@lock_cache
@@ -1863,24 +1868,26 @@ class PackageKitAptBackend(PackageKitBaseBackend):
try:
self._cache.commit(PackageKitFetchProgress(self, fetch_range),
PackageKitInstallProgress(self, install_range))
- except apt.cache.FetchFailedException, e:
+ except apt.cache.FetchFailedException, err:
self._open_cache(prange=(95,100))
- pklog.critical(format_string(e.message))
- self.error(ERROR_PACKAGE_DOWNLOAD_FAILED, format_string(e.message))
+ pklog.critical(format_string(err.message))
+ self.error(ERROR_PACKAGE_DOWNLOAD_FAILED,
+ format_string(err.message))
except apt.cache.FetchCancelledException:
self._open_cache(prange=(95,100))
- except InstallTimeOutPKError, e:
+ except InstallTimeOutPKError, err:
self._recover()
self._open_cache(prange=(95,100))
#FIXME: should provide more information
- self.error(ERROR_INTERNAL_ERROR,
- "Transaction was cancelled since the installation "
- "of a package hung.\n"
- "This can be caused by maintainer scripts which "
- "require input on the terminal:\n%s" % e.message)
- except PackageManagerFailedPKError, e:
+ msg = "Transaction was cancelled since the installation " \
+ "of a package hung.\n" \
+ "This can be caused by maintainer scripts which " \
+ "require input on the terminal:\n%s" % err.message
+ self.error(ERROR_INTERNAL_ERROR, format_string(msg))
+ except PackageManagerFailedPKError, err:
self._recover()
- self.error(ERROR_INTERNAL_ERROR, "%s\n%s" % (e.message, e.output))
+ self.error(ERROR_INTERNAL_ERROR,
+ format_string("%s\n%s" % (err.message, err.output)))
else:
return True
return False
commit 29cb4d24cbad83fc3df75ebf95da53ee1c0dd2fe
Author: Sebastian Heinlein <devel at glatzor.de>
Date: Mon May 10 05:51:52 2010 +0200
Python-Backend: Fix a typo in format_string
diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
index aa78aaa..4e5c341 100644
--- a/lib/python/packagekit/backend.py
+++ b/lib/python/packagekit/backend.py
@@ -744,7 +744,7 @@ def format_string(text, encoding='utf-8'):
Format a string to be used on stdout for communication with the daemon.
'''
if not isinstance(text, unicode):
- txt = unicode(text, encoding, errors='replace')
+ text = unicode(text, encoding, errors='replace')
return text.replace("\n", ";")
def _text_to_bool(text):
commit b37919f81ab5a8a5a9f01f3036368e8197773e66
Author: Sebastian Heinlein <devel at glatzor.de>
Date: Mon May 10 05:28:37 2010 +0200
APT: Adapt cherry picked patch for name searching to the 0.6 API
diff --git a/backends/apt/aptBackend.py b/backends/apt/aptBackend.py
index e48c0b1..33577ee 100755
--- a/backends/apt/aptBackend.py
+++ b/backends/apt/aptBackend.py
@@ -618,7 +618,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
if self._get_package_group(pkg) == group:
self._emit_visible_package(filters, pkg)
- def search_name(self, filters, values_string):
+ def search_name(self, filters, values):
"""
Implement the apt2-search-name functionality
"""
@@ -627,14 +627,12 @@ class PackageKitAptBackend(PackageKitBaseBackend):
if not search in text:
return False
return True
- pklog.info("Searching for package name: %s" % values_string)
+ pklog.info("Searching for package name: %s" % values)
self.status(STATUS_QUERY)
self.percentage(None)
self._check_init(progress=False)
self.allow_cancel(True)
- values = values_string.split(PACKAGE_IDS_DELIM)
-
for pkg_name in self._cache.keys():
if matches(values, pkg_name):
self._emit_all_visible_pkg_versions(filters,
commit 170ddbf3b3126f73be539af98ffba282da460169
Author: Sebastian Heinlein <devel at glatzor.de>
Date: Sat Mar 13 09:13:02 2010 +0100
APT: Allow to do an AND search for multiple package names
diff --git a/backends/apt/aptBackend.py b/backends/apt/aptBackend.py
index 21d2d82..e48c0b1 100755
--- a/backends/apt/aptBackend.py
+++ b/backends/apt/aptBackend.py
@@ -618,18 +618,25 @@ class PackageKitAptBackend(PackageKitBaseBackend):
if self._get_package_group(pkg) == group:
self._emit_visible_package(filters, pkg)
- def search_name(self, filters, search):
+ def search_name(self, filters, values_string):
"""
Implement the apt2-search-name functionality
"""
- pklog.info("Searching for package name: %s" % search)
+ def matches(searches, text):
+ for search in searches:
+ if not search in text:
+ return False
+ return True
+ pklog.info("Searching for package name: %s" % values_string)
self.status(STATUS_QUERY)
self.percentage(None)
self._check_init(progress=False)
self.allow_cancel(True)
+ values = values_string.split(PACKAGE_IDS_DELIM)
+
for pkg_name in self._cache.keys():
- if search in pkg_name:
+ if matches(values, pkg_name):
self._emit_all_visible_pkg_versions(filters,
self._cache[pkg_name])
commit 33a6f0ed9e56216a6cc7147c6d20912cd1d797d3
Author: Sebastian Heinlein <devel at glatzor.de>
Date: Sat Mar 13 08:58:02 2010 +0100
APT: use UTF-8 as default encoding and allow to write unicode to stdout.
This should finally fix all the encoding problems.
diff --git a/backends/apt/aptBackend.py b/backends/apt/aptBackend.py
index c8f551e..21d2d82 100755
--- a/backends/apt/aptBackend.py
+++ b/backends/apt/aptBackend.py
@@ -73,10 +73,6 @@ else:
pklog.debug("Use XAPIAN for the search")
XAPIAN_SUPPORT = True
-STDOUT_ENCODING = sys.stdout.encoding or sys.getfilesystemencoding()
-FS_ENCODING = sys.getfilesystemencoding()
-DEFAULT_ENCODING = locale.getpreferredencoding()
-
# SoftwareProperties is required to proivde information about repositories
try:
import softwareproperties.SoftwareProperties
@@ -162,12 +158,18 @@ HREF_CVE="http://web.nvd.nist.gov/view/vuln/detail?vulnId=%s"
SYNAPTIC_PIN_FILE = "/var/lib/synaptic/preferences"
+DEFAULT_ENCODING = "UTF-8"
+
# Required to get translated descriptions
try:
locale.setlocale(locale.LC_ALL, "")
except locale.Error:
pklog.debug("Failed to unset LC_ALL")
+# Allows to write unicode to stdout
+import codecs
+sys.stdout = codecs.getwriter(DEFAULT_ENCODING)(sys.stdout)
+
# Required to parse RFC822 time stamps
try:
locale.setlocale(locale.LC_TIME, "C")
@@ -674,7 +676,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
txt += pkg.candidate._translated_records.long_desc.lower()
except AttributeError:
pass
- if matches(values, unicode(txt, DEFAULT_ENCODING, "replace")):
+ if matches(values, txt.decode(DEFAULT_ENCODING, "replace")):
self._emit_visible_package(filters, pkg)
def get_distro_upgrades(self):
@@ -854,7 +856,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
obsoletes = ""
vendor_url = ""
restart = "none"
- update_text = ""
+ update_text = u""
state = ""
issued = ""
updated = ""
@@ -866,29 +868,27 @@ class PackageKitAptBackend(PackageKitBaseBackend):
changelog_raw = pkg.getChangelog()
# The internal download error string of python-apt ist not
# provided as unicode object
- try:
+ if not isinstance(changelog_raw, unicode):
changelog_raw = changelog_raw.decode(DEFAULT_ENCODING)
- except:
- pass
# Convert the changelog to markdown syntax
- changelog = ""
+ changelog = u""
for line in changelog_raw.split("\n"):
if line == "":
changelog += " \n"
else:
- changelog += " %s \n" % line
+ changelog += u" %s \n" % line
if line.startswith(pkg.candidate.source_name):
match = re.match(r"(?P<source>.+) \((?P<version>.*)\) "
"(?P<dist>.+); urgency=(?P<urgency>.+)",
line)
- update_text += "%s\n%s\n\n" % (match.group("version"),
- "=" * \
- len(match.group("version")))
+ update_text += u"%s\n%s\n\n" % (match.group("version"),
+ "=" * \
+ len(match.group("version")))
elif line.startswith(" "):
- update_text += " %s \n" % line
+ update_text += u" %s \n" % line
elif line.startswith(" --"):
#FIXME: Add %z for the time zone - requires Python 2.6
- update_text += " \n"
+ update_text += u" \n"
match = re.match("^ -- (?P<maintainer>.+) (?P<mail><.+>) "
"(?P<date>.+) (?P<offset>[-\+][0-9]+)$",
line)
@@ -904,9 +904,9 @@ class PackageKitAptBackend(PackageKitBaseBackend):
cve_url = ";;".join(get_cve_urls(changelog))
self.update_detail(pkg_id, updates, obsoletes, vendor_url,
bugzilla_url, cve_url, restart,
- format_string(update_text),
- format_string(changelog), state, issued,
- updated)
+ update_text.replace("\n", ";"),
+ changelog.replace("\n", ";"),
+ state, issued, updated)
def get_details(self, pkg_ids):
"""
@@ -929,8 +929,9 @@ class PackageKitAptBackend(PackageKitBaseBackend):
license = "unknown"
group = self._get_package_group(pkg)
self.details(pkg_id, license, group,
- format_string(pkg.description),
- pkg.homepage, pkg.packageSize)
+ pkg.description.replace("\n", ";"),
+ pkg.homepage.decode(DEFAULT_ENCODING),
+ pkg.packageSize)
@lock_cache
def update_system(self, only_trusted):
@@ -1093,7 +1094,9 @@ class PackageKitAptBackend(PackageKitBaseBackend):
#FIXME: There is no inconsitent state in PackageKit
enabled = repos.get_comp_download_state(comp)[0]
if not FILTER_DEVELOPMENT in filter_list:
- self.repo_detail(repo_id, description, enabled)
+ self.repo_detail(repo_id,
+ description.decode(DEFAULT_ENCODING),
+ enabled)
# Emit distro's virtual update repositories
for template in repos.distro.source_template.children:
repo_id = "%s_child_%s" % (repos.distro.id, template.name)
@@ -1104,7 +1107,9 @@ class PackageKitAptBackend(PackageKitBaseBackend):
#FIXME: There is no inconsitent state in PackageKit
enabled = repos.get_comp_child_state(template)[0]
if not FILTER_DEVELOPMENT in filter_list:
- self.repo_detail(repo_id, description, enabled)
+ self.repo_detail(repo_id,
+ description.decode(DEFAULT_ENCODING),
+ enabled)
# Emit distro's cdrom sources
for source in repos.get_cdrom_sources():
if FILTER_NOT_DEVELOPMENT in filter_list and \
@@ -1115,15 +1120,17 @@ class PackageKitAptBackend(PackageKitBaseBackend):
description = re.sub(r"</?b>", "", repos.render_source(source))
repo_id = "cdrom_%s_%s" % (source.uri, source.dist)
repo_id.join(map(lambda c: "_%s" % c, source.comps))
- self.repo_detail(repo_id, description, enabled)
+ self.repo_detail(repo_id, description.decode(DEFAULT_ENCODING),
+ enabled)
# Emit distro's virtual source code repositoriy
if not FILTER_NOT_DEVELOPMENT in filter_list:
repo_id = "%s_source" % repos.distro.id
enabled = repos.get_source_code_state() or False
#FIXME: no translation :(
- description = "%s %s - Source code" % (repos.distro.id,
+ description = "%s %s - Source code" % (repos.distro.id,
repos.distro.release)
- self.repo_detail(repo_id, description, enabled)
+ self.repo_detail(repo_id, description.decode(DEFAULT_ENCODING),
+ enabled)
# Emit third party repositories
for source in repos.get_isv_sources():
if FILTER_NOT_DEVELOPMENT in filter_list and \
@@ -1134,7 +1141,8 @@ class PackageKitAptBackend(PackageKitBaseBackend):
description = re.sub(r"</?b>", "", repos.render_source(source))
repo_id = "isv_%s_%s" % (source.uri, source.dist)
repo_id.join(map(lambda c: "_%s" % c, source.comps))
- self.repo_detail(repo_id, description, enabled)
+ self.repo_detail(repo_id, description.decode(DEFAULT_ENCODING),
+ enabled)
def repo_enable(self, repo_id, enable):
"""
@@ -1564,14 +1572,14 @@ class PackageKitAptBackend(PackageKitBaseBackend):
if not self._is_package_visible(pkg, filters):
return
else:
- summary = ""
+ summary = u""
if base_dependency.relation:
version = "%s%s" % (base_dependency.relation,
base_dependency.version)
else:
version = base_dependency.version
self.package("%s;%s;;" % (base_dependency.name, version),
- INFO_BLOCKED, summary)
+ INFO_BLOCKED, unicode(summary, DEFAULT_ENCODING))
def check_dependency(pkg, base_dep):
"""Check if the given apt.package.Package can satisfy the
@@ -1940,7 +1948,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
info = INFO_COLLECTION_AVAILABLE
else:
info = INFO_AVAILABLE
- self.package(id, info, version.summary)
+ self.package(id, info, unicode(version.summary, DEFAULT_ENCODING))
def _emit_all_visible_pkg_versions(self, filters, pkg):
"""Emit all available versions of a package."""
commit 2e613d4919a34f02142b3a7fde7aa12a3769ba2a
Author: Sebastian Heinlein <devel at glatzor.de>
Date: Thu Mar 4 07:14:07 2010 +0100
APT: Show a sub progress for package downloads
diff --git a/backends/apt/aptBackend.py b/backends/apt/aptBackend.py
index efd508d..c8f551e 100755
--- a/backends/apt/aptBackend.py
+++ b/backends/apt/aptBackend.py
@@ -328,22 +328,35 @@ class PackageKitFetchProgress(apt.progress.FetchProgress):
def __init__(self, backend, prange=(0,100), status=STATUS_DOWNLOAD):
self._backend = backend
apt.progress.FetchProgress.__init__(self)
- self.pstart = prange[0]
- self.pend = prange[1]
- self.pprev = None
+ self.start_progress = prange[0]
+ self.end_progress = prange[1]
+ self.last_progress = None
+ self.last_sub_progress = None
self.status = status
self.package_states = {}
- def pulse(self):
+ def pulse_items(self, items):
apt.progress.FetchProgress.pulse(self)
- progress = int(self.pstart + self.percent/100 * \
- (self.pend - self.pstart))
+ progress = int(self.start_progress + self.percent/100 * \
+ (self.end_progress - self.start_progress))
# A backwards running progress is reported as a not available progress
- if self.pprev > progress:
+ if self.last_progress > progress:
self._backend.percentage()
else:
self._backend.percentage(progress)
- self.pprev = progress
+ self.last_progress = progress
+ for item in items:
+ uri, desc, shortdesc, file_size, partial_size = item
+ try:
+ pkg = self._backend._cache[shortdesc]
+ except KeyError:
+ pass
+ else:
+ self._backend._emit_package(pkg, INFO_DOWNLOADING, True)
+ sub_progress = partial_size * 100 / file_size
+ if sub_progress > self.last_sub_progress:
+ self._last_sub_progress = sub_progress
+ self._backend.sub_percentage(sub_progress)
return True
def updateStatus(self, uri, descr, pkg_name, status):
@@ -368,7 +381,7 @@ class PackageKitFetchProgress(apt.progress.FetchProgress):
self._backend.allow_cancel(True)
def stop(self):
- self._backend.percentage(self.pend)
+ self._backend.percentage(self.end_progress)
self._backend.allow_cancel(False)
def mediaChange(self, medium, drive):
commit 37c8568c35d53d77439432aaa2813a523c2286dd
Author: Michael Meeks <michael.meeks at novell.com>
Date: Fri May 7 13:34:29 2010 +0100
Re-factor to pass PkBackend * around; hopefully we can GObject-ify that
and use it to store state on, that is currently static.
Very hacky 'root' implementation.
diff --git a/backends/zypp/TODO b/backends/zypp/TODO
index ea7db50..3146de0 100644
--- a/backends/zypp/TODO
+++ b/backends/zypp/TODO
@@ -5,6 +5,10 @@ progress reporting
+ but nothing more (?)
+ do we only notify on a 'sub' progress %age ?
+Root handling
+ + get_zypp needs to handle multiple roots properly /
+ more carefully.
+
package updating
+ re-test patch updating carefully
+ ensure no packages overlap with patches etc.
@@ -24,3 +28,8 @@ NEWEST handling
+ will require calculating 'newest' per package
+ which would make that method more efficient anyway
+PkBackend
+ + if/when this is switched to a GObject - we need to sub-class
+ and store our (currently) static pointers on it for elegance's
+ sake - also to allow 'destroy' to do a better job there.
+
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index fec6fb1..378bcdc 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -83,7 +83,7 @@ static void
backend_initialize (PkBackend *backend)
{
zypp_logging ();
- get_zypp ();
+ get_zypp (backend);
egg_debug ("zypp_backend_initialize");
EventDirector *eventDirector = new EventDirector (backend);
_eventDirectors [backend] = eventDirector;
@@ -131,11 +131,11 @@ backend_get_requires_thread (PkBackend *backend)
//pk_backend_set_percentage (backend, 0);
for (uint i = 0; package_ids[i]; i++) {
- zypp::sat::Solvable solvable = zypp_get_package_by_id (package_ids[i]);
+ zypp::sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]);
zypp::PoolItem package;
if (solvable.isSystem ()) {
- zypp::ResPool pool = zypp_build_pool (true);
+ zypp::ResPool pool = zypp_build_pool (backend, true);
gboolean found = FALSE;
gchar **id_parts = pk_package_id_split (package_ids[i]);
@@ -285,7 +285,7 @@ backend_get_depends_thread (PkBackend *backend)
}
zypp::ZYpp::Ptr zypp;
- zypp = get_zypp ();
+ zypp = get_zypp (backend);
egg_debug ("get_depends with filter '%s'", pk_filter_bitfield_to_string (_filters));
@@ -294,7 +294,7 @@ backend_get_depends_thread (PkBackend *backend)
gchar **id_parts = pk_package_id_split (package_ids[0]);
pk_backend_set_percentage (backend, 20);
// Load resolvables from all the enabled repositories
- zypp::ResPool pool = zypp_build_pool(true);
+ zypp::ResPool pool = zypp_build_pool (backend, true);
zypp::PoolItem pool_item;
gboolean pool_item_found = FALSE;
@@ -457,9 +457,9 @@ backend_get_details_thread (PkBackend *backend)
std::vector<zypp::sat::Solvable> *v;
std::vector<zypp::sat::Solvable> *v2;
std::vector<zypp::sat::Solvable> *v3;
- v = zypp_get_packages_by_name ((const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::package, TRUE);
- v2 = zypp_get_packages_by_name ((const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::patch, TRUE);
- v3 = zypp_get_packages_by_name ((const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::srcpackage, TRUE);
+ v = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::package, TRUE);
+ v2 = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::patch, TRUE);
+ v3 = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::srcpackage, TRUE);
v->insert (v->end (), v2->begin (), v2->end ());
v->insert (v->end (), v3->begin (), v3->end ());
@@ -631,13 +631,13 @@ backend_get_updates_thread (PkBackend *backend)
return FALSE;
}
- zypp::ResPool pool = zypp_build_pool (TRUE);
+ zypp::ResPool pool = zypp_build_pool (backend, TRUE);
pk_backend_set_percentage (backend, 40);
// check if the repositories may be dead (feature #301904)
warn_outdated_repos (backend, pool);
- std::set<zypp::PoolItem> *candidates = zypp_get_updates ();
+ std::set<zypp::PoolItem> *candidates = zypp_get_updates (backend);
pk_backend_set_percentage (backend, 80);
@@ -734,7 +734,7 @@ backend_install_files_thread (PkBackend *backend)
tmpRepo.setAutorefresh (true);
tmpRepo.setAlias ("PK_TMP_DIR");
tmpRepo.setName ("PK_TMP_DIR");
- zypp_build_pool(true);
+ zypp_build_pool (backend, true);
// add Repo to pool
@@ -759,7 +759,7 @@ backend_install_files_thread (PkBackend *backend)
// look for the packages and set them to toBeInstalled
std::vector<zypp::sat::Solvable> *solvables = 0;
- solvables = zypp_get_packages_by_name (rpmHeader->tag_name ().c_str (), zypp::ResKind::package, FALSE);
+ solvables = zypp_get_packages_by_name (backend, rpmHeader->tag_name ().c_str (), zypp::ResKind::package, FALSE);
zypp::PoolItem *item = NULL;
gboolean found = FALSE;
@@ -828,7 +828,7 @@ backend_get_update_detail_thread (PkBackend *backend)
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
for (uint i = 0; package_ids[i]; i++) {
- zypp::sat::Solvable solvable = zypp_get_package_by_id (package_ids[i]);
+ zypp::sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]);
zypp::Capabilities obs = solvable.obsoletes ();
@@ -913,11 +913,11 @@ backend_update_system_thread (PkBackend *backend)
pk_backend_set_percentage (backend, 0);
/* FIXME: support only_trusted */
- zypp::ResPool pool = zypp_build_pool (TRUE);
+ zypp::ResPool pool = zypp_build_pool (backend, TRUE);
pk_backend_set_percentage (backend, 40);
PkRestartEnum restart = PK_RESTART_ENUM_NONE;
- std::set<zypp::PoolItem> *candidates = zypp_get_updates ();
+ std::set<zypp::PoolItem> *candidates = zypp_get_updates (backend);
if (_updating_self) {
_updating_self = FALSE;
@@ -967,7 +967,7 @@ backend_install_packages_thread (PkBackend *backend)
pk_backend_set_percentage (backend, 0);
zypp::ZYpp::Ptr zypp;
- zypp = get_zypp ();
+ zypp = get_zypp (backend);
package_ids = pk_backend_get_strv (backend, "package_ids");
if (!pk_package_ids_check (package_ids)) {
@@ -978,7 +978,7 @@ backend_install_packages_thread (PkBackend *backend)
try
{
- zypp::ResPool pool = zypp_build_pool (TRUE);
+ zypp::ResPool pool = zypp_build_pool (backend, TRUE);
pk_backend_set_percentage (backend, 10);
std::vector<zypp::PoolItem> *items = new std::vector<zypp::PoolItem> ();
@@ -1118,7 +1118,7 @@ backend_remove_packages_thread (PkBackend *backend)
zypp::Target_Ptr target;
zypp::ZYpp::Ptr zypp;
- zypp = get_zypp ();
+ zypp = get_zypp (backend);
target = zypp->target ();
@@ -1204,11 +1204,11 @@ backend_resolve_thread (PkBackend *backend)
std::vector<zypp::sat::Solvable> *v;
/* Build a list of packages with this name */
- v = zypp_get_packages_by_name (package_ids[i], zypp::ResKind::package, TRUE);
+ v = zypp_get_packages_by_name (backend, package_ids[i], zypp::ResKind::package, TRUE);
if (!pk_bitfield_contain (_filters, PK_FILTER_ENUM_NOT_SOURCE)) {
std::vector<zypp::sat::Solvable> *src;
- src = zypp_get_packages_by_name (package_ids[i], zypp::ResKind::srcpackage, TRUE);
+ src = zypp_get_packages_by_name (backend, package_ids[i], zypp::ResKind::srcpackage, TRUE);
v->insert (v->end (), src->begin (), src->end ());
delete (src);
}
@@ -1285,35 +1285,35 @@ backend_find_packages_thread (PkBackend *backend)
q.setMatchSubstring();
switch (mode) {
- case SEARCH_TYPE_NAME:
- zypp_build_pool (TRUE); // seems to be necessary?
- q.addKind( zypp::ResKind::package );
- q.addKind( zypp::ResKind::srcpackage );
- q.addAttribute( zypp::sat::SolvAttr::name );
- // Note: The query result is NOT sorted packages first, then srcpackage.
- // If that's necessary you need to sort the vector accordongly or use
- // two separate queries.
- break;
- case SEARCH_TYPE_DETAILS:
- zypp_build_pool (TRUE); // seems to be necessary?
- q.addKind( zypp::ResKind::package );
- //q.addKind( zypp::ResKind::srcpackage );
- q.addAttribute( zypp::sat::SolvAttr::name );
- q.addAttribute( zypp::sat::SolvAttr::description );
- // Note: Don't know if zypp_get_packages_by_details intentionally
- // did not search in srcpackages.
- break;
- case SEARCH_TYPE_FILE:
- {
- // zypp_build_pool (TRUE); called by zypp_get_packages_by_file
- std::vector<zypp::sat::Solvable> * r = zypp_get_packages_by_file (search);
- v.swap( *r );
- delete r;
- // zypp_get_packages_by_file does strange things :)
- // Maybe it would be sufficient to simply query
- // zypp::sat::SolvAttr::filelist instead?
- }
- break;
+ case SEARCH_TYPE_NAME:
+ zypp_build_pool (backend, TRUE); // seems to be necessary?
+ q.addKind( zypp::ResKind::package );
+ q.addKind( zypp::ResKind::srcpackage );
+ q.addAttribute( zypp::sat::SolvAttr::name );
+ // Note: The query result is NOT sorted packages first, then srcpackage.
+ // If that's necessary you need to sort the vector accordongly or use
+ // two separate queries.
+ break;
+ case SEARCH_TYPE_DETAILS:
+ zypp_build_pool (backend, TRUE); // seems to be necessary?
+ q.addKind( zypp::ResKind::package );
+ //q.addKind( zypp::ResKind::srcpackage );
+ q.addAttribute( zypp::sat::SolvAttr::name );
+ q.addAttribute( zypp::sat::SolvAttr::description );
+ // Note: Don't know if zypp_get_packages_by_details intentionally
+ // did not search in srcpackages.
+ break;
+ case SEARCH_TYPE_FILE: {
+ // zypp_build_pool (TRUE); called by zypp_get_packages_by_file
+ std::vector<zypp::sat::Solvable> *r;
+ r = zypp_get_packages_by_file (backend, search);
+ v.swap( *r );
+ delete r;
+ // zypp_get_packages_by_file does strange things :)
+ // Maybe it would be sufficient to simply query
+ // zypp::sat::SolvAttr::filelist instead?
+ break;
+ }
};
if ( ! q.empty() ) {
@@ -1362,7 +1362,7 @@ backend_search_group_thread (PkBackend *backend)
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, 0);
- zypp::ResPool pool = zypp_build_pool(true);
+ zypp::ResPool pool = zypp_build_pool (backend, true);
pk_backend_set_percentage (backend, 30);
@@ -1493,8 +1493,8 @@ backend_get_files_thread (PkBackend *backend)
std::vector<zypp::sat::Solvable> *v;
std::vector<zypp::sat::Solvable> *v2;
- v = zypp_get_packages_by_name ((const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::package, TRUE);
- v2 = zypp_get_packages_by_name ((const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::srcpackage, TRUE);
+ v = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::package, TRUE);
+ v2 = zypp_get_packages_by_name (backend, (const gchar *)id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::srcpackage, TRUE);
v->insert (v->end (), v2->begin (), v2->end ());
@@ -1563,7 +1563,7 @@ backend_get_packages_thread (PkBackend *backend)
std::vector<zypp::sat::Solvable> v;
- zypp_build_pool (TRUE);
+ zypp_build_pool (backend, TRUE);
zypp::ResPool pool = zypp::ResPool::instance ();
for (zypp::ResPool::byKind_iterator it = pool.byKindBegin (zypp::ResKind::package); it != pool.byKindEnd (zypp::ResKind::package); it++) {
v.push_back (it->satSolvable ());
@@ -1592,7 +1592,7 @@ backend_update_packages_thread (PkBackend *backend)
package_ids = pk_backend_get_strv (backend, "package_ids");
PkRestartEnum restart = PK_RESTART_ENUM_NONE;
- delete zypp_get_updates (); // make sure _updating_self is set
+ delete zypp_get_updates (backend); // make sure _updating_self is set
if (_updating_self) {
egg_debug ("updating self and setting restart");
@@ -1600,7 +1600,7 @@ backend_update_packages_thread (PkBackend *backend)
_updating_self = FALSE;
}
for (guint i = 0; package_ids[i]; i++) {
- zypp::sat::Solvable solvable = zypp_get_package_by_id (package_ids[i]);
+ zypp::sat::Solvable solvable = zypp_get_package_by_id (backend, package_ids[i]);
zypp::PoolItem item = zypp::ResPool::instance ().find (solvable);
item.status ().setToBeInstalled (zypp::ResStatus::USER);
zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(item.resolvable ());
@@ -1781,7 +1781,7 @@ backend_what_provides_thread (PkBackend *backend)
if((provides == PK_PROVIDES_ENUM_HARDWARE_DRIVER) || g_ascii_strcasecmp("drivers_for_attached_hardware", search) == 0) {
// solver run
- zypp::ResPool pool = zypp_build_pool(true);
+ zypp::ResPool pool = zypp_build_pool (backend, true);
zypp::Resolver solver(pool);
solver.setIgnoreAlreadyRecommended (TRUE);
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index ba81c7b..0c2272c 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -83,7 +83,7 @@ class LookForArchUpdate : public zypp::resfilter::PoolItemFilterFunctor
* Initialize Zypp (Factory method)
*/
zypp::ZYpp::Ptr
-get_zypp ()
+get_zypp (PkBackend *backend)
{
static gboolean initialized = FALSE;
zypp::ZYpp::Ptr zypp = NULL;
@@ -91,9 +91,10 @@ get_zypp ()
try {
zypp = zypp::ZYppFactory::instance ().getZYpp ();
- // TODO: Make this threadsafe
+ /* TODO: we need to lifecycle manage this, detect changes
+ in the requested 'root' etc. */
if (!initialized) {
- zypp::filesystem::Pathname pathname("/");
+ zypp::filesystem::Pathname pathname(pk_backend_get_root (backend));
zypp->initializeTarget (pathname);
initialized = TRUE;
@@ -134,7 +135,7 @@ zypp_logging ()
}
gboolean
-zypp_is_changeable_media (const zypp::Url &url)
+zypp_is_changeable_media (PkBackend *backend, const zypp::Url &url)
{
gboolean is_cd = false;
try {
@@ -150,9 +151,9 @@ zypp_is_changeable_media (const zypp::Url &url)
}
zypp::ResPool
-zypp_build_pool (gboolean include_local)
+zypp_build_pool (PkBackend *backend, gboolean include_local)
{
- zypp::ZYpp::Ptr zypp = get_zypp ();
+ zypp::ZYpp::Ptr zypp = get_zypp (backend);
if (include_local) {
//FIXME have to wait for fix in zypp (repeated loading of target)
@@ -216,11 +217,16 @@ warn_outdated_repos(PkBackend *backend, const zypp::ResPool & pool)
}
}
+
+#if 0 // apparently unused
+/**
+ * Build and return a ResPool that contains only the local resolvables.
+ */
zypp::ResPool
-zypp_build_local_pool ()
+zypp_build_local_pool (PkBackend *backend)
{
zypp::sat::Pool pool = zypp::sat::Pool::instance ();
- zypp::ZYpp::Ptr zypp = get_zypp ();
+ zypp::ZYpp::Ptr zypp = get_zypp (backend);
try {
for (zypp::detail::RepositoryIterator it = pool.reposBegin (); it != pool.reposEnd (); it++){
@@ -242,6 +248,7 @@ zypp_build_local_pool ()
return zypp->pool ();
}
+#endif
zypp::target::rpm::RpmHeader::constPtr
zypp_get_rpmHeader (std::string name, zypp::Edition edition)
@@ -329,11 +336,12 @@ get_enum_group (std::string group)
}
std::vector<zypp::sat::Solvable> *
-zypp_get_packages_by_name (const gchar *package_name, const zypp::ResKind kind, gboolean include_local)
+zypp_get_packages_by_name (PkBackend *backend, const gchar *package_name,
+ const zypp::ResKind kind, gboolean include_local)
{
std::vector<zypp::sat::Solvable> *v = new std::vector<zypp::sat::Solvable> ();
- zypp::ResPool pool = zypp_build_pool (include_local);
+ zypp::ResPool pool = zypp_build_pool (backend, include_local);
for (zypp::ResPool::byIdent_iterator it = pool.byIdentBegin (kind, package_name);
it != pool.byIdentEnd (kind, package_name); it++) {
@@ -344,11 +352,11 @@ zypp_get_packages_by_name (const gchar *package_name, const zypp::ResKind kind,
}
std::vector<zypp::sat::Solvable> *
-zypp_get_packages_by_file (const gchar *search_file)
+zypp_get_packages_by_file (PkBackend *backend, const gchar *search_file)
{
std::vector<zypp::sat::Solvable> *v = new std::vector<zypp::sat::Solvable> ();
- zypp::ResPool pool = zypp_build_pool (TRUE);
+ zypp::ResPool pool = zypp_build_pool (backend, TRUE);
std::string file (search_file);
@@ -375,7 +383,7 @@ zypp_get_packages_by_file (const gchar *search_file)
}
zypp::sat::Solvable
-zypp_get_package_by_id (const gchar *package_id)
+zypp_get_package_by_id (PkBackend *backend, const gchar *package_id)
{
if (!pk_package_id_check(package_id)) {
// TODO: Do we need to do something more for this error?
@@ -383,8 +391,8 @@ zypp_get_package_by_id (const gchar *package_id)
}
gchar **id_parts = pk_package_id_split(package_id);
- std::vector<zypp::sat::Solvable> *v = zypp_get_packages_by_name (id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::package, TRUE);
- std::vector<zypp::sat::Solvable> *v2 = zypp_get_packages_by_name (id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::patch, TRUE);
+ std::vector<zypp::sat::Solvable> *v = zypp_get_packages_by_name (backend, id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::package, TRUE);
+ std::vector<zypp::sat::Solvable> *v2 = zypp_get_packages_by_name (backend, id_parts[PK_PACKAGE_ID_NAME], zypp::ResKind::patch, TRUE);
v->insert (v->end (), v2->begin (), v2->end ());
@@ -681,13 +689,13 @@ zypp_get_package_updates (std::string repo)
* Returns a set of all patches the could be installed
*/
static std::set<zypp::PoolItem> *
-zypp_get_patches ()
+zypp_get_patches (PkBackend *backend)
{
std::set<zypp::PoolItem> *patches = new std::set<zypp::PoolItem> ();
_updating_self = FALSE;
zypp::ZYpp::Ptr zypp;
- zypp = get_zypp ();
+ zypp = get_zypp (backend);
zypp->resolver ()->resolvePool ();
@@ -718,11 +726,11 @@ zypp_get_patches ()
}
std::set<zypp::PoolItem> *
-zypp_get_updates ()
+zypp_get_updates (PkBackend *backend)
{
typedef std::set<zypp::PoolItem>::iterator pi_it_t;
- std::set<zypp::PoolItem> *candidates = zypp_get_patches ();
+ std::set<zypp::PoolItem> *candidates = zypp_get_patches (backend);
if (!_updating_self) {
// exclude the patch-repository
@@ -788,7 +796,7 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force)
gboolean simulate = pk_backend_get_bool (backend, "hint:simulate");
try {
- zypp::ZYpp::Ptr zypp = get_zypp ();
+ zypp::ZYpp::Ptr zypp = get_zypp (backend);
if (force)
zypp->resolver ()->setForceResolve (force);
@@ -945,7 +953,7 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force)
exit:
/* reset the various options */
try {
- zypp::ZYpp::Ptr zypp = get_zypp ();
+ zypp::ZYpp::Ptr zypp = get_zypp (backend);
zypp->resolver ()->setForceResolve (FALSE);
if (type == UPDATE)
zypp->resolver ()->setIgnoreAlreadyRecommended (FALSE);
@@ -994,7 +1002,8 @@ zypp_build_package_id_capabilities (zypp::Capabilities caps)
gboolean
zypp_refresh_cache (PkBackend *backend, gboolean force)
{
- get_zypp (); //This call is needed as it calls initializeTarget which appears to properly setup the keyring
+ // This call is needed as it calls initializeTarget which appears to properly setup the keyring
+ get_zypp (backend);
if (!pk_backend_is_online (backend)) {
pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
return FALSE;
@@ -1031,7 +1040,7 @@ zypp_refresh_cache (PkBackend *backend, gboolean force)
// skip changeable meda (DVDs and CDs). Without doing this,
// the disc would be required to be physically present.
- if (zypp_is_changeable_media (*repo.baseUrlsBegin ()) == true)
+ if (zypp_is_changeable_media (backend, *repo.baseUrlsBegin ()) == true)
continue;
try {
diff --git a/backends/zypp/zypp-utils.h b/backends/zypp/zypp-utils.h
index de6ea70..540d9e1 100644
--- a/backends/zypp/zypp-utils.h
+++ b/backends/zypp/zypp-utils.h
@@ -76,20 +76,20 @@ extern gboolean _updating_self;
*/
extern gchar *_repoName;
-zypp::ZYpp::Ptr get_zypp ();
+zypp::ZYpp::Ptr get_zypp (PkBackend *backend);
/**
* Enable and rotate logging
*/
gboolean zypp_logging ();
-gboolean zypp_is_changeable_media (const zypp::Url &url);
+gboolean zypp_is_changeable_media (PkBackend *backend, const zypp::Url &url);
/**
* Build and return a ResPool that contains all local resolvables
* and ones found in the enabled repositories.
*/
-zypp::ResPool zypp_build_pool (gboolean include_local);
+zypp::ResPool zypp_build_pool (PkBackend *backend, gboolean include_local);
/**
* check and warns the user that a repository may be outdated
@@ -97,11 +97,6 @@ zypp::ResPool zypp_build_pool (gboolean include_local);
void warn_outdated_repos(PkBackend *backend, const zypp::ResPool & pool);
/**
- * Build and return a ResPool that contains only the local resolvables.
- */
-zypp::ResPool zypp_build_local_pool ();
-
-/**
* Return the rpmHeader of a package
*/
zypp::target::rpm::RpmHeader::constPtr zypp_get_rpmHeader (std::string name, zypp::Edition edition);
@@ -119,17 +114,18 @@ PkGroupEnum get_enum_group (std::string group);
/**
* Returns a list of packages that match the specified package_name.
*/
-std::vector<zypp::sat::Solvable> * zypp_get_packages_by_name (const gchar *package_name, const zypp::ResKind kind, gboolean include_local);
+std::vector<zypp::sat::Solvable> * zypp_get_packages_by_name (PkBackend *backend, const gchar *package_name,
+ const zypp::ResKind kind, gboolean include_local);
/**
* Returns a list of packages that owns the specified file.
*/
-std::vector<zypp::sat::Solvable> * zypp_get_packages_by_file (const gchar *search_file);
+std::vector<zypp::sat::Solvable> * zypp_get_packages_by_file (PkBackend *backend, const gchar *search_file);
/**
* Returns the Resolvable for the specified package_id.
*/
-zypp::sat::Solvable zypp_get_package_by_id (const gchar *package_id);
+zypp::sat::Solvable zypp_get_package_by_id (PkBackend *backend, const gchar *package_id);
/**
* Build a package_id from the specified resolvable. The returned
@@ -168,7 +164,7 @@ zypp::PoolItem zypp_find_arch_update_item (const zypp::ResPool & pool, zypp::Poo
* we can find. Also manages _updating_self to prioritise critical infrastructure
* updates.
*/
-std::set<zypp::PoolItem> * zypp_get_updates ();
+std::set<zypp::PoolItem> * zypp_get_updates (PkBackend *backend);
/**
* Sets the restart flag of a patch
commit 588c348dc342b99a997321577ecc146a464aba64
Author: Michael Meeks <michael.meeks at novell.com>
Date: Fri May 7 11:21:18 2010 +0100
Detect and advertise from /etc/meego-release
Thanks to: Peter J Zhu <peter.j.zhu at intel.com>
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 77f37cc..4ceb925 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -390,6 +390,19 @@ pk_engine_get_distro_id (PkEngine *engine)
goto out;
}
+ /* check for meego */
+ ret = g_file_get_contents ("/etc/meego-release", &contents, NULL, NULL);
+ if (ret) {
+ /* Meego release 1.0 (MeeGo) */
+ split = g_strsplit (contents, " ", 0);
+ if (split == NULL)
+ goto out;
+
+ /* complete! */
+ distro_id = g_strdup_printf ("meego;%s;%s", split[2], arch);
+ goto out;
+ }
+
/* check for foresight or foresight derivatives */
ret = g_file_get_contents ("/etc/distro-release", &contents, NULL, NULL);
if (ret) {
More information about the PackageKit-commit
mailing list