--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/checkforupdates.py Fri Jul 03 20:55:59 2009 +0100
@@ -0,0 +1,86 @@
+#!/usr/bin/python2.4
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+import os
+import sys
+import gettext
+
+import pkg.client.api as api
+import pkg.client.api_errors as api_errors
+import pkg.client.progress as progress
+import pkg.misc as misc
+import pkg.gui.misc as gui_misc
+from pkg.client import global_settings
+
+UPDATES_AVAILABLE = 0
+NO_UPDATES_AVAILABLE = 1
+ERROR_OCCURRED = 2
+PKG_CLIENT_NAME="updatemanagernotifier"
+
+
+# Put _() in the global namespace
+import __builtin__
+__builtin__._ = gettext.gettext
+
+def check_for_updates(image_directory):
+ os.nice(20)
+ global_settings.client_name = PKG_CLIENT_NAME
+ pr = progress.NullProgressTracker()
+
+ api_obj = gui_misc.get_api_object(image_directory, pr, None)
+ api_obj.refresh()
+
+ pkg_upgradeable = None
+ for pkg, state in misc.get_inventory_list(api_obj.img, [],
+ all_known=True, all_versions=False):
+ if state["upgradable"] and state["state"] == "installed":
+ pkg_upgradeable = pkg
+ break
+
+ if pkg_upgradeable != None:
+ if debug:
+ print "Updates Available"
+ sys.exit(UPDATES_AVAILABLE)
+ else:
+ if debug:
+ print "No updates Available"
+ sys.exit(NO_UPDATES_AVAILABLE)
+
+###############################################################################
+#-----------------------------------------------------------------------------#
+# Main
+#-----------------------------------------------------------------------------#
+
+def main(image_directory):
+ check_for_updates(image_directory)
+ return ERROR_OCCURRED
+
+if __name__ == '__main__':
+ debug = False
+ if len(sys.argv) != 2:
+ print "One argument, image directory must be specified"
+ sys.exit(ERROR_OCCURRED)
+ image_dir = sys.argv[1]
+ main(image_dir)
--- a/src/pkgdefs/SUNWipkg-um/prototype Fri Jul 03 19:46:45 2009 +0100
+++ b/src/pkgdefs/SUNWipkg-um/prototype Fri Jul 03 20:55:59 2009 +0100
@@ -17,6 +17,7 @@
d none usr/lib 755 root bin
d none usr/lib/update-manager 755 root bin
f none usr/lib/update-manager/update-refresh.sh 755 root bin
+f none usr/lib/um-checkforupdates 755 root bin
f none usr/lib/updatemanagernotifier 755 root bin
d none usr/share 755 root sys
d none usr/share/applications 755 root other
--- a/src/setup.py Fri Jul 03 19:46:45 2009 +0100
+++ b/src/setup.py Fri Jul 03 20:55:59 2009 +0100
@@ -163,6 +163,7 @@
lib_dir: [
['depot.py', 'pkg.depotd'],
['updatemanagernotifier.py', 'updatemanagernotifier'],
+ ['checkforupdates.py', 'um-checkforupdates'],
['launch.py', 'pm-launch'],
],
svc_method_dir: [
--- a/src/updatemanagernotifier.py Fri Jul 03 19:46:45 2009 +0100
+++ b/src/updatemanagernotifier.py Fri Jul 03 20:55:59 2009 +0100
@@ -19,11 +19,12 @@
#
# CDDL HEADER END
#
-# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
import os
+import subprocess
import errno
import sys
import time
@@ -47,7 +48,6 @@
except ImportError:
print "SUNWpython-notify package must be installed"
sys.exit(1)
-import pkg.client.image as image
import pkg.client.progress as progress
import pkg.misc as misc
import pkg.gui.misc as gui_misc
@@ -63,12 +63,12 @@
IMAGE_DIRECTORY_DEFAULT = "/"
LASTCHECK_DIR_NAME = os.path.join(os.path.expanduser("~"),'.updatemanager/notify')
IMAGE_DIR_COMMAND = "svcprop -p update/image_dir svc:/application/pkg/update"
+CHECK_FOR_UPDATES = "/usr/lib/um-checkforupdates"
ICON_LOCATION = "/usr/share/update-manager/icons"
NOTIFY_ICON_NAME = "notify_update"
GKSU_PATH = "/usr/bin/gksu"
UPDATEMANAGER = "pm-updatemanager"
-PKG_CLIENT_NAME="updatemanagernotifier"
UPDATEMANAGER_PREFERENCES = "/apps/updatemanager/preferences"
START_DELAY_PREFERENCES = "/apps/updatemanager/preferences/start_delay"
@@ -92,7 +92,6 @@
class UpdateManagerNotifier:
def __init__(self):
os.nice(20)
- global_settings.client_name = PKG_CLIENT_NAME
try:
self.application_dir = os.environ["UPDATE_MANAGER_NOTIFIER_ROOT"]
except KeyError:
@@ -274,9 +273,10 @@
self.last_check_time = time.time()
# Add random delay so that servers will not be hit
# all at once
- random_delay = random.randint(0, 1800)
if debug:
- print "random_delay in do_next_check", random_delay
+ random_delay = 0
+ else:
+ random_delay = random.randint(0, 1800)
gobject.timeout_add(random_delay * 1000, self.check_for_updates)
def check_for_updates(self):
@@ -285,24 +285,12 @@
print "image_directory: %s" % image_directory
if len(image_directory) == 0:
image_directory = IMAGE_DIRECTORY_DEFAULT
- api_obj = gui_misc.get_api_object(image_directory,
- self.pr, None)
- api_obj.refresh()
-
- pkg_upgradeable = None
- for pkg, state in misc.get_inventory_list(api_obj.img, [],
- all_known=True, all_versions=False):
- if state["upgradable"] and state["state"] == "installed":
- pkg_upgradeable = pkg
- break
-
- if debug == True:
- if pkg_upgradeable != None:
- print "Packages to be updated"
- else:
- print "No packages to be updated"
+ return_code = subprocess.call([CHECK_FOR_UPDATES,
+ image_directory])
+ if debug:
+ print "return from subprocess is %d" % return_code
self.set_last_check_time()
- if pkg_upgradeable != None:
+ if return_code == 0:
self.show_status_icon(True)
else:
self.show_status_icon(False)
@@ -420,7 +408,6 @@
gtk.gdk.get_default_root_window().property_change(atom,
"INTEGER", 16, gtk.gdk.PROP_MODE_REPLACE, atom_args)
-
###############################################################################
#-----------------------------------------------------------------------------#
# Main