Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional make target - make patch #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wheldom01
Copy link

Updated to add the make patch target and the Runtime method to carry out the task.

Updated to add the make patch target and the Runtime method to carry out the task.
@sartak
Copy link
Contributor

sartak commented Nov 16, 2016

HI @wheldom01, thanks for your contribution. I love the idea and I'd love to get us to a place where we can use it. I have two primary concerns with your patch:

  • Sometimes we ship different patches for different versions of RT. See for example https://github.com/bestpractical/rt-extension-assetsql/tree/master/patches - How could we improve make patch to handle this? We'd be happy to establish and follow a naming convention if that's required.
  • sub RTxPatch has a couple small issues:
    • You concatenate together the shell command. I'm a little concerned that you're escaping shell characters, most importantly whitespace. For example if $RT::BasePath has a space in it. Without escaping, make patch may end up doing nothing (in the best case scenario), the wrong thing, or something that compromises security (very unlikely but still not worth exposing our users to). The standard way to deal with this is to use the list form of Perl's system() which avoids the shell entirely. You won't be able to specify < file.patch since that is a feature shells implement, but instead you can use the -i flag to patch to provide the file that way instead.
    • if ($_ =~ m/.patch/xms) { is perhaps more clearly and correctly written as if ($_ =~ m/\.patch$/) {. This checks if the filename ends in ".patch" rather than your version which checks if the file contains the string "patch" with any character preceding it.

Thanks very much! I look forward to hearing your feedback. :)

Best,
Shawn

@wheldom01
Copy link
Author

Hi Shawn,

I like your idea of being able to handle different versions of RT during
the patch process.
Looking at the example you gave the, first 2 scenarios seem straight
forward as they apply to a
single rt version.

However the one below may not be quite so :(

https://github.com/bestpractical/rt-extension-assetsql/blob/master/patches/rt-4.4.2-later.patch

I'm assuming that this patch applies to versions of rt >= 4.4.2 is that
correct?

If that is the case then how about the following as a directory naming
convention:

patches/4.4/ => Apply *.patch files to all 4.4 range
patches/4.4.4/ => Apply *.patch files to specific version only
patches/4.4.1-4.4.5/ => Apply *.patch files to all versions in range
patches/>4.4.1/ => Apply *.patch files to versions greater than
4.4.1 (i.e 4.4.2 and above)
patches/<4.4.3/ => Apply *.patch files to versions less than
4.4.3 (i.e 4.4.2 and below)

As for RTxPatch and system command concatenation, your suggestion is a
much better approach,
more than happy to fix that.

  • if ($_ =~ m/.patch/xms) { is perhaps more clearly and correctly
    Mmm that's a couple of typos on my part I would normally write:
    if ($_ =~ m/.patch\z/xms) {

again more than happy to change to your suggestion.

All the best

Martin

On 2016-11-16 16:12, Shawn M Moore wrote:

HI @wheldom01 [1], thanks for your contribution. I love the idea and
I'd love to get us to a place where we can use it. I have two primary
concerns with your patch:

Sometimes we ship different patches for different versions of RT. See
for example
https://github.com/bestpractical/rt-extension-assetsql/tree/master/patches

  • How could we improve make patch to handle this? We'd be happy to
    establish and follow a naming convention if that's required.
    *

sub RTxPatch has a couple small issues:
*

  • You concatenate together the shell command. I'm a little concerned
    that you're escaping shell characters, most importantly whitespace.
    For example if $RT::BasePath has a space in it. Without escaping, make
    patch may end up doing nothing (in the best case scenario), the wrong
    thing, or something that compromises security (very unlikely but still
    not worth exposing our users to). The standard way to deal with this
    is to use the list form of Perl's system() which avoids the shell
    entirely. You won't be able to specify < file.patch since that is a
    feature shells implement, but instead you can use the -i flag to patch
    to provide the file that way instead.

  • if ($_ =~ m/.patch/xms) { is perhaps more clearly and correctly
    written as if ($_ =~ m/.patch$/) {. This checks if the filename ends
    in ".patch" rather than your version which checks if the file contains
    the string "patch" with any character preceding it.

Thanks very much! I look forward to hearing your feedback. :)

Best,
Shawn

You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub [2], or mute the
thread [3].

Links:

[1] https://github.com/wheldom01
[2]
#4 (comment)
[3]
https://github.com/notifications/unsubscribe-auth/AOnrJO_hNffOanZhYtTejv7QkUmXZqu5ks5q-ytigaJpZM4Kx5Zz

Convert to use list style system call
Fixed regex matching for files ending .patch
Added functionality to apply patches to specific versions by organising
patches into directories with following naming i.e:
      >4.2          - Apply to RT versions after 4.2
      <4.4          - Apply to RT versions before 4.4
      4.4.1         - Apply to RT 4.4.1 only
      4.2-4.4       - Apply to RT versions between and including
Directories containing patches that don't meet the above naming convention are
applied to all RT versions
Directory structures can be nested
@wheldom01
Copy link
Author

Hi @sartak,

I've fixed the regex issue and converted the system command to use the list invocation method as you suggested.

I've also had a stab at the handling of patches for different RT versions. I'd be interested to hear your thoughts.

All the best

Martin

@wheldom01
Copy link
Author

Hi @sartak,

The final patch adds the ability to remove the relevant patches.

Best Regards

Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants