25387863 Backport 17900980 to 11.3-SRU - update-manager crontab entry not removed s11u3-sru
authorMingrui Lyu <mingrui.lyu@oracle.com>
Wed, 08 Mar 2017 15:08:55 -0800
branchs11u3-sru
changeset 3526 f34cedd88b2d
parent 3520 1106d0037435
25387863 Backport 17900980 to 11.3-SRU - update-manager crontab entry not removed
src/pkg/manifests/package:pkg.p5m
src/pkg/manifests/package:pkg:update-manager.p5m
src/pkg/transforms/defaults
src/setup.py
src/svc/pkg5_include.sh
src/svc/svc-pkg-update
src/um/update-refresh.sh
--- a/src/pkg/manifests/package:pkg.p5m	Wed Feb 22 23:50:38 2017 +0530
+++ b/src/pkg/manifests/package:pkg.p5m	Wed Mar 08 15:08:55 2017 -0800
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 set name=pkg.fmri value=pkg:/package/pkg@$(PKGVERS)
@@ -241,6 +241,7 @@
 file path=usr/bin/pkgsurf
 dir  path=usr/lib
 file path=usr/lib/pkg.depotd mode=0755
+file path=usr/lib/update-refresh.sh mode=0755
 dir  path=usr/share
 dir  path=usr/share/lib
 dir  path=usr/share/lib/pkg
--- a/src/pkg/manifests/package:pkg:update-manager.p5m	Wed Feb 22 23:50:38 2017 +0530
+++ b/src/pkg/manifests/package:pkg:update-manager.p5m	Wed Mar 08 15:08:55 2017 -0800
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 set name=pkg.fmri value=pkg:/package/pkg/update-manager@$(PKGVERS)
@@ -48,8 +48,6 @@
 file path=usr/bin/pm-updatemanager
 dir  path=usr/lib
 file path=usr/lib/pm-checkforupdates mode=0755
-dir  path=usr/lib/update-manager
-file path=usr/lib/update-manager/update-refresh.sh mode=0755
 file path=usr/lib/updatemanagernotifier mode=0755
 dir  path=usr/share
 dir  path=usr/share/applications
--- a/src/pkg/transforms/defaults	Wed Feb 22 23:50:38 2017 +0530
+++ b/src/pkg/transforms/defaults	Wed Mar 08 15:08:55 2017 -0800
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 # Set some specific permissions
@@ -68,6 +68,7 @@
 
 # Add actuators
 <transform file path=(var|lib)/svc/manifest/.*\.xml -> add restart_fmri svc:/system/manifest-import:default>
+<transform file path=(var|lib)/svc/manifest/application/pkg/pkg-update.xml -> add disable_fmri svc:/application/pkg/update:default>
 <transform file path=etc/gconf/schemas/.*\.(entries|schemas) -> add restart_fmri svc:/application/desktop-cache/gconf-cache:default>
 <transform file path=usr/share/applications/.*\.desktop -> add restart_fmri svc:/application/desktop-cache/desktop-mime-cache:default>
 <transform file path=usr/share/icons/.* -> add restart_fmri svc:/application/desktop-cache/icon-cache:default>
--- a/src/setup.py	Wed Feb 22 23:50:38 2017 +0530
+++ b/src/setup.py	Wed Mar 08 15:08:55 2017 -0800
@@ -139,7 +139,6 @@
 help_dir = 'usr/share/gnome/help/package-manager'
 omf_dir = 'usr/share/omf/package-manager'
 startpage_dir = 'usr/share/package-manager/data/startpagebase'
-um_lib_dir = 'usr/lib/update-manager'
 um_share_dir = 'usr/share/update-manager'
 pm_share_dir = 'usr/share/package-manager'
 locale_dir = 'usr/share/locale'
@@ -174,11 +173,9 @@
                 ['updatemanagernotifier.py', 'updatemanagernotifier'],
                 ['launch.py', 'pm-launch'],
                 ['sysrepo.py', 'pkg.sysrepo'],
-                ['depot-config.py', "pkg.depot-config"]
+                ['depot-config.py', "pkg.depot-config"],
+                ['um/update-refresh.sh', 'update-refresh.sh']
                 ],
-        um_lib_dir: [
-                ['um/update-refresh.sh', 'update-refresh.sh'],
-        ],
         svc_method_dir: [
                 ['svc/svc-pkg-depot', 'svc-pkg-depot'],
                 ['svc/svc-pkg-mdns', 'svc-pkg-mdns'],
@@ -241,7 +238,7 @@
 
 MANPAGE_OUTPUT_ROOT = "man/nroff"
 
-man1_files = [ 
+man1_files = [
     MANPAGE_OUTPUT_ROOT + '/man1/' + f
     for f in [
         'packagemanager.1',
--- a/src/svc/pkg5_include.sh	Wed Feb 22 23:50:38 2017 +0530
+++ b/src/svc/pkg5_include.sh	Wed Mar 08 15:08:55 2017 -0800
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright (c) 2008, 2013 Oracle and/or its affiliates.  All rights reserved.
+# Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 CP=/usr/bin/cp
@@ -34,6 +34,7 @@
 SLEEP=/usr/bin/sleep
 SVCADM=/usr/sbin/svcadm
 SVCPROP=/usr/bin/svcprop
+PKG=/usr/bin/pkg
 
 #
 # Check whether the supplied exit code is 0, printing an error message
@@ -86,6 +87,19 @@
 }
 
 #
+# Check whether the supplied pkg is installed.
+#
+# Usage:
+# check_installation <fmri>
+#
+function check_installation {
+
+	typeset PACKAGE_FMRI=$1
+	$PKG list -q $PACKAGE_FMRI
+	return $?
+}
+
+#
 # Update cron with a new crontab file.  We pass what we expect the
 # current crontab looks like in order to verify that the content hasn't
 # changed since we made our modifications.  Note that between the time
@@ -190,8 +204,10 @@
 	acquire_crontab_lock
 	$CRONTAB -l > $current_crontab
 	$GREP "${cmd}" $current_crontab > /dev/null 2>&1
-	check_failure $? "command $cmd did not exist in crontab" $fmri \
-	    degrade
+	if [ ! -z $fmri ]; then
+		check_failure $? "command $cmd did not exist in crontab" $fmri \
+	    	degrade
+	fi
 
 	$GREP -v "${cmd}" $current_crontab > $new_crontab
 
--- a/src/svc/svc-pkg-update	Wed Feb 22 23:50:38 2017 +0530
+++ b/src/svc/svc-pkg-update	Wed Mar 08 15:08:55 2017 -0800
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2008, 2013 Oracle and/or its affiliates.  All rights reserved.
+# Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 # An SMF method script for
 # svc:/application/pkg/update:default
@@ -28,7 +28,7 @@
 . /lib/svc/share/smf_include.sh
 . /lib/svc/share/pkg5_include.sh
 
-REFRESH_PROG="/usr/lib/update-manager/update-refresh.sh"
+REFRESH_PROG="/usr/lib/update-refresh.sh"
 SCHEDULE='30 0,9,12,18,21 * * *'
 
 case $SMF_METHOD in
--- a/src/um/update-refresh.sh	Wed Feb 22 23:50:38 2017 +0530
+++ b/src/um/update-refresh.sh	Wed Mar 08 15:08:55 2017 -0800
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 #
@@ -39,6 +39,8 @@
 # via a popup and notification panel icon.
 #
 
+. /lib/svc/share/pkg5_include.sh
+
 fmri=svc:/application/pkg/update
 
 #
@@ -47,6 +49,16 @@
 # user has modified that, then use the times as they specified.
 #
 cronentry=$(crontab -l | grep update-refresh.sh)
+# If update-manager is already removed, we should remove the crontab
+# entry as well as the script itself and return
+check_installation "package/pkg/update-manager"
+if [ $? -ne 0 ]; then
+	if [ ! -z "$cronentry" ]; then
+		remove_cronjob "" "/usr/lib/update-refresh.sh" 
+		exit 0
+	fi
+fi
+
 if [[ $cronentry == "30 0,9,12,18,21 * * * "* ]]; then
 	# When did we last run, and how many times have we tried since?
 	lastrun=$(svcprop -p update/lastrun $fmri 2> /dev/null)