17900980 update-manager crontab entry not removed on uninstall s12b116
authorMingrui Lyu <mingrui.lyu@oracle.com>
Wed, 11 Jan 2017 14:44:44 -0800
changeset 3481 2b5ed2799a6a
parent 3480 f49f488bcdad
child 3499 b86ff72d0f9c
17900980 update-manager crontab entry not removed on uninstall
src/cronjob-removal.sh
src/pkg/manifests/package:pkg.p5m
src/setup.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cronjob-removal.sh	Wed Jan 11 14:44:44 2017 -0800
@@ -0,0 +1,16 @@
+#!/bin/ksh
+# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+#
+   
+#
+# This script is run to remove a cron job.
+# Packages that needs to remove cron job that cannot be removed 
+# during package update can add a hardlink in the new manifest
+# to this script with the same path as the cron job executable.
+# The script will remove the cron job during its first scheduled
+# execution.
+#
+                   
+. /lib/svc/share/pkg5_include.sh
+
+remove_cronjob "" `basename $0` 
--- a/src/pkg/manifests/package:pkg.p5m	Fri Jan 06 13:38:48 2017 -0800
+++ b/src/pkg/manifests/package:pkg.p5m	Wed Jan 11 14:44:44 2017 -0800
@@ -273,7 +273,9 @@
 file path=usr/bin/pkgsign
 file path=usr/bin/pkgsurf
 dir  path=usr/lib
+file path=usr/lib/cronjob-removal.sh mode=0755
 file path=usr/lib/pkg.depotd mode=0755 pkg.depend.bypass-generate=.*six.*
+link path=usr/lib/update-refresh.sh target=cronjob-removal.sh
 dir  path=usr/share
 dir  path=usr/share/lib
 dir  path=usr/share/lib/pkg
--- a/src/setup.py	Fri Jan 06 13:38:48 2017 -0800
+++ b/src/setup.py	Wed Jan 11 14:44:44 2017 -0800
@@ -154,6 +154,8 @@
 # together if the os supports it and otherwise copied.
 hardlink_modules = []
 
+symlink_modules = [('cronjob-removal.sh', 'usr/lib/update-refresh.sh')]
+
 scripts_sunos = {
         scripts_dir: [
                 ['client.py', 'pkg'],
@@ -172,7 +174,8 @@
         lib_dir: [
                 ['depot.py', 'pkg.depotd'],
                 ['sysrepo.py', 'pkg.sysrepo'],
-                ['depot-config.py', "pkg.depot-config"]
+                ['depot-config.py', 'pkg.depot-config'],
+                ['cronjob-removal.sh', 'cronjob-removal.sh'],
                 ],
         svc_method_dir: [
                 ['svc/svc-pkg-depot', 'svc-pkg-depot'],
@@ -744,6 +747,7 @@
                 """
 
                 _install.run(self)
+
                 for o_src, o_dest in hardlink_modules:
                         for e in [".py", ".pyc"]:
                                 src = util.change_root(self.root_dir, o_src + e)
@@ -777,6 +781,10 @@
                                     os.stat(dst_path).st_mode
                                     | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
 
+                for target, o_dest in symlink_modules:
+                        dest = util.change_root(self.root_dir, o_dest)
+                        file_util.copy_file(target, dest, link="sym", update=True)
+
 class install_lib_func(_install_lib):
         """Remove the target files prior to the standard install_lib procedure
         if the build_py module has determined that they've actually changed.
@@ -873,7 +881,7 @@
         cddl_re = re.compile(b"\n(#\s*\n)?^[^\n]*CDDL HEADER START.+"
             b"CDDL HEADER END[^\n]*$(\n#\s*$)?", re.MULTILINE|re.DOTALL)
 
-        # Look for shebang line to replace with arch-specific Python executable. 
+        # Look for shebang line to replace with arch-specific Python executable.
         shebang_re = re.compile('^#!.*python[0-9]\.[0-9]')
         first_buf = True