[Rt-commit] rtir branch, 4.0/upgrade-rm-callback, created. 4.0.0-30-g976e0cb

Shawn Moore shawn at bestpractical.com
Thu Jan 26 15:57:14 EST 2017


The branch, 4.0/upgrade-rm-callback has been created
        at  976e0cbfac5b56eca97d252ba253d991b99ba45d (commit)

- Log -----------------------------------------------------------------
commit 976e0cbfac5b56eca97d252ba253d991b99ba45d
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Thu Jan 26 20:53:51 2017 +0000

    Remove stale callback on upgrade from RTIR 3.2.0
    
    RTIR 4.0 doesn't need the callback
    html/Callbacks/RTIR/Elements/EditCustomField/EditComponentName any
    longer, and so it was deleted from the package. But upgrades from 3.2.0
    would of course keep that file around, which caused errors in the admin
    UI for ticket custom fields:
    
    [10257] [Fri Jun 17 22:01:02 2016] [error]: Can't call method "QueueObj" on an undefined value at /opt/rt4/local/plugins/RT-IR/html/Callbacks/RTIR/Elements/EditCustomField/EditComponentName line 51.
    
    This uses a new (generic) feature added to Module::Install::RTx for the
    purpose of removing this file on upgrade.
    
    Fixes: I#32100

diff --git a/MANIFEST b/MANIFEST
index c92607e..09ee620 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -53,6 +53,7 @@ etc/upgrade/3.3.1/content
 etc/upgrade/3.3.2/content
 etc/upgrade/3.3.3/content
 etc/upgrade/3.3.4/content
+etc/upgrade/remove_files
 etc/upgrade/rtir-2.4-upgrade.pl.in
 html/Callbacks/RTIR/autohandler/SuccessfulLogin
 html/Callbacks/RTIR/Elements/Header/Head
diff --git a/Makefile.PL b/Makefile.PL
index 20763ab..0b05cc6 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,6 +1,6 @@
 use inc::Module::Install;
 
-RTx('RT-IR', { no_readme_generation => 1 });
+RTx('RT-IR', { no_readme_generation => 1, remove_files => 1 });
 license('GPL Version 2');
 author('Best Practical Solutions <sales at bestpractical.com>');
 all_from('lib/RT/IR.pm');
diff --git a/etc/upgrade/remove_files b/etc/upgrade/remove_files
new file mode 100644
index 0000000..1e34c38
--- /dev/null
+++ b/etc/upgrade/remove_files
@@ -0,0 +1,9 @@
+package Module::Install::RTx;
+
+ at remove_files = (
+    # RTIR 4.0.1
+    'html/Callbacks/RTIR/Elements/EditCustomField/EditComponentName',
+);
+
+1;
+
diff --git a/inc/Module/Install/RTx.pm b/inc/Module/Install/RTx.pm
index 80538d3..d1fb047 100644
--- a/inc/Module/Install/RTx.pm
+++ b/inc/Module/Install/RTx.pm
@@ -113,11 +113,29 @@ lexicons ::
 .
     }
 
+    my $remove_files;
+    if( $extra_args->{'remove_files'} ){
+        $self->include('Module::Install::RTx::Remove');
+        our @remove_files;
+        eval { require "etc/upgrade/remove_files" }
+          or print "No remove file located, no files to remove\n";
+        $remove_files = join ",", map {"q(\$(DESTDIR)$plugin_path/$name/$_)"} @remove_files;
+    }
+
     $self->include('Module::Install::RTx::Runtime') if $self->admin;
     $self->include_deps( 'YAML::Tiny', 0 ) if $self->admin;
     my $postamble = << ".";
 install ::
 \t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Iinc -MModule::Install::RTx::Runtime -e"RTxPlugin()"
+.
+
+    if( $remove_files ){
+        $postamble .= << ".";
+\t\$(NOECHO) \$(PERL) -MModule::Install::RTx::Remove -e \"RTxRemove([$remove_files])\"
+.
+    }
+
+    $postamble .= << ".";
 \t\$(NOECHO) \$(PERL) -MExtUtils::Install -e \"install({$args})\"
 .
 
@@ -279,4 +297,4 @@ sub _load_rt_handle {
 
 __END__
 
-#line 428
+#line 468
diff --git a/inc/Module/Install/RTx/Remove.pm b/inc/Module/Install/RTx/Remove.pm
new file mode 100644
index 0000000..ee45c4b
--- /dev/null
+++ b/inc/Module/Install/RTx/Remove.pm
@@ -0,0 +1,21 @@
+#line 1
+package Module::Install::RTx::Remove;
+
+use base 'Exporter';
+our @EXPORT = qw/RTxRemove/;
+
+use strict;
+
+#line 27
+
+sub RTxRemove {
+    my $remove_files = shift;
+
+    # Trying the naive unlink first. If issues are reported,
+    # look at ExtUtils::_unlink_or_rename for more cross-platform options.
+    foreach my $file (@$remove_files){
+        next unless -e $file;
+        print "Removing $file\n";
+        unlink($file) or warn "Could not unlink $file: $!";
+    }
+}

-----------------------------------------------------------------------


More information about the rt-commit mailing list