[packagekit] packagekit: Branch 'master' - 6 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Tue Jan 29 09:56:17 PST 2008
TODO | 2 -
backends/dummy/pk-backend-dummy.c | 31 +++++++++++++++++------
backends/opkg/pk-backend-opkg.c | 14 +++++++++-
libpackagekit/pk-enum.c | 1
libpackagekit/pk-enum.h | 1
src/pk-runner.c | 8 ++++++
waf-light | 50 ++++++++++++++++++--------------------
wscript | 1
8 files changed, 71 insertions(+), 37 deletions(-)
New commits:
commit 142f6ab72b9fc71b78e01664a9dda88b2fe26153
Merge: 44054cc... 130dadd...
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jan 29 17:53:57 2008 +0000
Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit
commit 130daddad64d38df94016b309d46dcd229f6c7df
Author: Thomas Wood <thomas at openedhand.com>
Date: Tue Jan 29 12:23:15 2008 +0000
opkg: forward opkg messages through PackageKit
diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
index a4d54f7..ff8f3a4 100644
--- a/backends/opkg/pk-backend-opkg.c
+++ b/backends/opkg/pk-backend-opkg.c
@@ -61,6 +61,14 @@ extern opkg_download_progress_callback opkg_cb_download_progress;
int
opkg_debug (opkg_conf_t *conf, message_level_t level, char *msg)
{
+ PkBackend *backend;
+ backend = pk_backend_thread_get_backend (thread);
+
+ if (level == OPKG_NOTICE)
+ pk_backend_message (backend, PK_MESSAGE_ENUM_NOTICE, msg);
+ if (level == OPKG_ERROR)
+ pk_backend_message (backend, PK_MESSAGE_ENUM_WARNING, msg);
+
if (level != 1)
return 0;
commit 5c5a30d8156665bd1ac2d71a19467c292effae8a
Author: Thomas Wood <thomas at openedhand.com>
Date: Tue Jan 29 12:11:13 2008 +0000
opkg: protect against incorrect percentage reports
diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
index cd57ea0..a4d54f7 100644
--- a/backends/opkg/pk-backend-opkg.c
+++ b/backends/opkg/pk-backend-opkg.c
@@ -362,7 +362,11 @@ pk_opkg_refresh_cache_progress_cb (int progress, char *url)
/* set the percentage as a fraction of the current progress plus the
* progress we have already recorded */
- pk_backend_set_percentage (backend, total_progress + (progress / sources_list_count));
+ if (total_progress + (progress / sources_list_count) > 100)
+ return;
+
+ pk_backend_set_percentage (backend,
+ total_progress + (progress / sources_list_count));
}
commit 44054cc5d3f50b2ff55164597db35daa96ae4e7e
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Jan 27 13:58:18 2008 +0000
update to latest waf version
diff --git a/waf-light b/waf-light
index c1f1f4b..d69938d 100755
--- a/waf-light
+++ b/waf-light
@@ -31,11 +31,13 @@ POSSIBILITY OF SUCH DAMAGE.
"""
import os, sys
+if sys.hexversion<0x203000f: raise "Waf needs Python >= 2.3"
+
if 'PSYCOWAF' in os.environ:
- try: import psyco; psyco.full()
- except: pass
+ try:import psyco;psyco.full()
+ except:pass
-VERSION="1.3.0"
+VERSION="1.3.2"
REVISION="x"
INSTALL="x"
cwd=os.getcwd()
@@ -43,8 +45,7 @@ j=os.path.join
def decode(s):
out=[]
- app=out.append
- s='!!!!!'.join(s.split('z'))
+ a=out.append
d=divmod
p1,p2=d(len(s),5)
stop=5*p1
@@ -58,54 +59,51 @@ def decode(s):
x,p=d(x,256)
x,o=d(x,256)
m,n=d(x,256)
- app(chr(m)+chr(n)+chr(o)+chr(p))
+ a(chr(m)+chr(n)+chr(o)+chr(p))
if p2:
- while len(p4)<5: p4=p4+'!'
+ p4+=(5-len(p4))*'!'
x=52200625L*u(p4,0)+614125*u(p4,1)+7225*u(p4,2)+85*u(p4,3)+u(p4,4)
x,p=d(x,256)
x,o=d(x,256)
m,n=d(x,256)
- app(chr(m))
- if p2>2:app(chr(n))
- if p2>3:app(chr(o))
+ a(chr(m))
+ if p2>2:a(chr(n))
+ if p2>3:a(chr(o))
return ''.join(out)
def err(m):
- print m; sys.exit(1)
+ print '\033[91mError: %s\033[0m'%m
+ sys.exit(1)
def unpack_wafdir(dir):
f=open(sys.argv[0],'rb')
- c="Error: corrupted (%d)"
+ c="corrupted waf (%d)"
while 1:
line=f.readline()
- if not line: err("\033[91mError: waf-light must be run from a folder containing wafadmin\033[0m")
+ if not line: err("waf-light must be run from a folder containing wafadmin")
if line=='#==>\n':
txt=f.readline()
if not txt: err(c%1)
if f.readline()!='#<==\n': err(c%2)
break
if not txt: err(c%3)
- txt=decode(txt[1:])
+ try: txt=decode(txt[1:-1].replace('z', '!!!!!'))
+ except: err(c%4)
import shutil, tarfile
try: shutil.rmtree(dir)
except OSError: pass
- try: os.makedirs(dir)
- except OSError: err("Error: could not unpack waf-local into %s\
-Install waf system-wide or move waf into a writeable directory"%dir)
+ try: os.makedirs(j(dir, 'wafadmin', 'Tools'))
+ except OSError: err("cannot unpack waf-local into %s Install waf system-wide or move waf into a writeable directory"%dir)
os.chdir(dir)
tmp='t.tbz2'
- f=open(tmp,'wb')
- f.write(txt)
- f.close()
+ t=open(tmp,'wb');t.write(txt);t.close()
t=tarfile.open(tmp)
for x in t: t.extract(x)
t.close()
- os.chmod('wafadmin',0755)#TODO
- os.chmod('wafadmin%sTools'%os.sep,0755)
os.unlink(tmp)
os.chdir(cwd)
@@ -119,13 +117,13 @@ def find_lib():
#devs use $WAFDIR
w=test(os.environ.get('WAFDIR',''))
- if w:return w
+ if w: return w
#waf-light
- if name=='waf-light':
+ if os.path.basename(name)=='waf-light':
w=test(base)
if w:return w
- err("\033[91mwaf-light in use, wafadmin not found -> export WAFDIR=/folder\033[0m")
+ err("waf-light in use, wafadmin not found -> export WAFDIR=/folder")
dir="/lib/waf-%s-%s/" % (VERSION, REVISION)
for i in [INSTALL,'/usr','/usr/local','/opt']:
@@ -148,7 +146,7 @@ if "-vv" in sys.argv: print "wafdir is %s"%wafdir
w=j(wafdir,'wafadmin')
t=j(w,'Tools')
-sys.path=[w, t]+sys.path
+sys.path.extend([w,t])
import Params, Scripting
Params.g_tooldir=[t]
diff --git a/wscript b/wscript
index e7ee389..62fffed 100644
--- a/wscript
+++ b/wscript
@@ -36,6 +36,7 @@ def set_options(opt):
opt.add_option('--enable-gcov', action="store_true", help="compile with gcov support (gcc only)", dest="gcov", default=False)
opt.add_option('--enable-gprof', action="store_true", help="compile with gprof support (gcc only)", dest="gprof", default=False)
+ opt.tool_options("gcc")
opt.sub_options('backends')
def configure(conf):
commit 5c5b508bd7cdf7bd08eb8daa7e3edfe53cf7817d
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Jan 27 13:43:12 2008 +0000
update TODO
diff --git a/TODO b/TODO
index fabb1fa..d7ece24 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
Order of no particular importance:
-* Add cancelling (present tense) as a status and assign it from ->cancel
-
* Find out why yum doesn't output some package status calls.
* Lots of the functions are not well commented with gtk-doc. Most
commit c80675c9a616b297041e6900d4f9619651f7aea8
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Jan 27 13:11:50 2008 +0000
add a cancelling state, as cancelling might actually take some time
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 18dd942..96e408e 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -76,6 +76,24 @@ backend_get_filters (PkBackend *backend, PkEnumList *elist)
}
/**
+ * backend_cancel_timeout:
+ */
+static gboolean
+backend_cancel_timeout (gpointer data)
+{
+ PkBackend *backend = (PkBackend *) data;
+
+ /* we can now cancel again */
+ signal_timeout = 0;
+
+ /* now mark as finished */
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED,
+ "The task was stopped successfully");
+ pk_backend_finished (backend);
+ return FALSE;
+}
+
+/**
* backend_cancel:
*/
static void
@@ -85,11 +103,10 @@ backend_cancel (PkBackend *backend)
/* cancel the timeout */
if (signal_timeout != 0) {
g_source_remove (signal_timeout);
- signal_timeout = 0;
- /* now mark as finished */
- pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED,
- "The task was stopped successfully");
- pk_backend_finished (backend);
+
+ /* emulate that it takes us a few ms to cancel */
+ pk_backend_set_status (backend, PK_STATUS_ENUM_CANCEL);
+ g_timeout_add (1500, backend_cancel_timeout, backend);
}
}
@@ -124,9 +141,7 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
"While the goals of the program are for ease of use and simple easy to "
"understand tools, Scribus offers support for professional publishing "
"features, such as CMYK color, easy PDF creation, Encapsulated Postscript "
-"import/export and creation of color separations.", "http://live.gnome.org/GnomePowerManager",
- 11214665
- );
+"import/export and creation of color separations.", "http://live.gnome.org/GnomePowerManager", 11214665);
pk_backend_finished (backend);
}
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index e3760df..7c86a76 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -65,6 +65,7 @@ static PkEnumMatch enum_status[] = {
{PK_STATUS_ENUM_COMMIT, "commit"},
{PK_STATUS_ENUM_REQUEST, "request"},
{PK_STATUS_ENUM_FINISHED, "finished"},
+ {PK_STATUS_ENUM_CANCEL, "cancel"},
{0, NULL},
};
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 0074691..57d5cdd 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -97,6 +97,7 @@ typedef enum {
PK_STATUS_ENUM_COMMIT,
PK_STATUS_ENUM_REQUEST,
PK_STATUS_ENUM_FINISHED,
+ PK_STATUS_ENUM_CANCEL,
PK_STATUS_ENUM_UNKNOWN
} PkStatusEnum;
diff --git a/src/pk-runner.c b/src/pk-runner.c
index 506db6e..9cbe68e 100644
--- a/src/pk-runner.c
+++ b/src/pk-runner.c
@@ -218,6 +218,12 @@ pk_runner_cancel (PkRunner *runner, gchar **error_text)
return FALSE;
}
+ /* have we already been marked as finished? */
+ if (runner->priv->finished == TRUE) {
+ *error_text = g_strdup ("Already finished");
+ return FALSE;
+ }
+
/* check to see if we have an action */
if (runner->priv->role == PK_ROLE_ENUM_UNKNOWN) {
*error_text = g_strdup ("No role");
@@ -229,6 +235,8 @@ pk_runner_cancel (PkRunner *runner, gchar **error_text)
*error_text = g_strdup ("Tried to cancel a runner that is not safe to kill");
return FALSE;
}
+
+ /* actually run the method */
runner->priv->backend->desc->cancel (runner->priv->backend);
return TRUE;
}
More information about the PackageKit
mailing list