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

zsh: use libpcre2 instead of libpcre #22197

Merged
merged 2 commits into from
Oct 11, 2023
Merged

zsh: use libpcre2 instead of libpcre #22197

merged 2 commits into from
Oct 11, 2023

Conversation

oskarirauta
Copy link
Contributor

Changes:

  • use libpcre2 instead of libpcre
  • patch Src/Modules/pcre.c: source from mainstream's git (23.9.2023)
  • patch configure.ac and config.h.in: replace libpcre with libpcre2 and remove missing AC_PROG_LN
  • patch Src/Makefile.in: use LN_S instead of LN
  • patch Test/V07pcre.ztst: add some libpcre2 specific tests
  • use autoconf: git version no longer supports traditional configure script, so it was easier to patch configure.ac

Maintainer: @msva
Compile tested: x86_64, latest git
Run tested: x86_64, latest git

Description:
zsh is my favourite shell. I found issue #22006 which mentioned zsh and that's where idea originated.
Patch can be removed when official zsh is next time updated (might take quite some time)

@oskarirauta oskarirauta mentioned this pull request Sep 23, 2023
30 tasks
@BKPepe BKPepe self-assigned this Sep 23, 2023
Copy link
Member

@BKPepe BKPepe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In one your single commit, you are trying to split so many changes, which are not described anywhere and who knows why they are required and why do we need them.

Many things are really unrelated to use libpcre2 instead of pcre, which you tried to describe that in commit description. Please try to avoid that for the next time.

What I can suggest to you is to

  1. Split your commit into multiple ones (no need this time as you should stick only to changes related to libpcre2)
  2. Other changes should have separate patches as it is done in upstream repository.
    You can do that e.g. on GitHub when you go to each commit or PR and ammend to the end of the URL suffix .patch and that should be done here. Example: zsh-users/zsh@b62e911

@@ -20,6 +20,7 @@ PKG_LICENSE:=ZSH
PKG_LICENSE_FILES:=LICENCE
PKG_CPE_ID:=cpe:/a:zsh_project:zsh

PKG_FIXUP:=autoreconf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is required now? In the commit description, there is no such info on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from commit:

use autoconf: git version no longer supports traditional configure script, so it was easier to patch configure.ac

Provided patch is more or less a back port/cherry pick. As zsh's master no longer ships with configure script, instead uses auto-tools, there would had been a huge task of patching configure script that would also had been a huge task for reviewers to check what's changed. Zsh has supported auto-tools for quite some time.

from docs:

Packages that are using auto-tools should work with simply “PKG_FIXUP:=autoreconf”.

Why this is required now? In the commit description, there is no such info on this one.
This is required to use auto-tools over traditional configure script as said in documents.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks! Would it be possible to keep this in separate commit to have it clear and simple? This from my point should not be in one huge patch, which would be really hard to track changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we are not using master branch and we are using still the same version. Dont you forget to add something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To succeed, we are swapping from traditional configure to configure.ac which makes build process different (equal to master branch minus some bells and whistles not available on release version). It's been like this in autotools version for quite some time, but we haven't utilised it until now.

I could apply another huge patch to fix traditional configure, that would be other way around this, but wouldn't that make things even more complicated? I attempted it in the first place and found out pretty soon that changes required in traditional configure script would be massive and definitely break if it ever gets updated due to amount of changes. So, I sticked to with current autotools version, traditional isn't even supported anymore; whole script has been removed from master branch. Probably been outdated long ago.

utils/zsh/patches/010-use-libpcre2.patch Outdated Show resolved Hide resolved
utils/zsh/patches/010-use-libpcre2.patch Outdated Show resolved Hide resolved
@oskarirauta
Copy link
Contributor Author

oskarirauta commented Sep 24, 2023

@BKPepe

There is reason for every change that this patch makes. When next release of zsh comes out, patch will be incompatible and all changes it makes, are merged to that release, except LN_S stuff, which is more a problem with openwrt build system. Hopefully though this patch will be then obsolete on that as well and AC_PROG_LN is included in auto-tools macros.

Nevertheless, with this you get what you requested for zsh; libpcre2 instead of libpcre. I am happy with that as well, as I use zsh personally, and libpcre in my case was depend only for zsh; now I no longer have to install it at all.

Please, clarify if you have proposals for changes. Most of what I wrote here/explained was already in the commit, but pretty shortly. Do you want me to expand descriptions of changes? What about patch or Makefile? Do you have proposals for changes? For the moment, I am not sure if you want or how you would want me to change anything.

Maybe separate libpcre2 and auto-tools fix to different patches?

@oskarirauta oskarirauta force-pushed the zsh branch 2 times, most recently from b03626b to 807bcb1 Compare September 24, 2023 16:48
@oskarirauta
Copy link
Contributor Author

@BKPepe

Patch splitted to 2 patches. Commit message expanded.

@oskarirauta oskarirauta requested a review from BKPepe September 24, 2023 17:42
@BKPepe
Copy link
Member

BKPepe commented Sep 24, 2023 via email

@oskarirauta
Copy link
Contributor Author

oskarirauta commented Sep 24, 2023

@BKPepe

Just answered to all the questions as explanatory as possible :)
I was kinda hoping for all requirements today.. I'm off to work in few hours and nature of my work might require that I ain't back home until friday night.

I have possibility to work with my laptop through a vpn connection, but it's way better locally. Especially when I don't know if I have short days, or do they go past 16 hours.. If I am not answering briefly, then I just don't have time; bare patiently, and I'll get back on topic as soon as I am able to. But surely, if there's not much changes necessary, I probably can use my breaks to do some work; Only change that I think might be in place, is patch to that test file.. I just patched that as well, since it was relevant even when it's unnecessary for result.

@oskarirauta
Copy link
Contributor Author

@msva

You should also review this..

@msva
Copy link
Contributor

msva commented Sep 26, 2023

Well, I looked over the patch (unfortunately, I don't have enough spare time at the moment for full careful analysis).
And it looks kinda ok. At least, I didn't noticed any suspicious code.

But unfortunately, at the moment, I dont't even have a device to test it on (that patched version works fine).

I'll try to at least check that it builds correctly at next holidays.

@oskarirauta
Copy link
Contributor Author

I am running with it. Builds and runs. Good luck.

@oskarirauta
Copy link
Contributor Author

@BKPepe

Have you had a chance yet to check this?

@BKPepe
Copy link
Member

BKPepe commented Sep 29, 2023

There is reason for every change that this patch makes. When next release of zsh comes out, patch will be incompatible and all changes it makes, are merged to that release, except LN_S stuff, which is more a problem with openwrt build system. Hopefully though this patch will be then obsolete on that as well and AC_PROG_LN is included in auto-tools macros.

Yes, I bet that there is a reason for that, but it should be described in the patch itself that people will know, why it was required. Hiding it (not exactly, but you got the point) in multiple changes in one huge commit is not good idea.

Nevertheless, with this you get what you requested for zsh; libpcre2 instead of libpcre. I am happy with that as well, as I use zsh personally, and libpcre in my case was depend only for zsh; now I no longer have to install it at all.

Yeah, I do not have installed libpcre anymore either!

Please, clarify if you have proposals for changes. Most of what I wrote here/explained was already in the commit, but pretty shortly. Do you want me to expand descriptions of changes? What about patch or Makefile? Do you have proposals for changes? For the moment, I am not sure if you want or how you would want me to change anything.

One option is to move it from commit description to patch's commit description or have it on both places.

About patches - because it is a really huge diff, I havent look at it so far. Quite busy with other things.
Honestly, still curious why do we need to have them, because the version is same and what was backported is only libpcre2 support.🤔🤔

@oskarirauta
Copy link
Contributor Author

oskarirauta commented Sep 29, 2023

Please, clarify if you have proposals for changes. Most of what I wrote here/explained was already in the commit, but pretty shortly. Do you want me to expand descriptions of changes? What about patch or Makefile? Do you have proposals for changes? For the moment, I am not sure if you want or how you would want me to change anything.

One option is to move it from commit description to patch's commit description or have it on both places.

Yes, but make a concrete proposal with example that I can apply from here. That way you get it just the way you want, because you already know what this does and so on, so you know what you want there to read; instead of me guessing what that might be.

About patches - because it is a really huge diff, I havent look at it so far. Quite busy with other things. Honestly, still curious why do we need to have them, because the version is same and what was backported is only libpcre2 support.🤔🤔

Depends where you look at it from; smaller than some of my private kernel patches....
But I'll help you here, take source and patch it. Then download current/latest git sources of zsh and compare with diff both versions of Src/Modules/pcre.c since it's the only actual source code file that has changed, other changes regard only compiling. If they haven't updated it further, you should see that patched file is identical to one on git source.
If you don't trust me, this will lift that burden and move it to zsh team.

I am also quite busy, and soon this branch get's old enough to have conflicts with repo and I absolutely don't have more time on my timeline for this. One solution would be to switch to current git source and only use my autotools patch, but I know what is the opinion on using trunk versions.

Why we need them? Simple. It is on newer version than current release version being used. There haven't yet released a version that has this. And autotools patch is just to fix missing macro.

@oskarirauta oskarirauta force-pushed the zsh branch 3 times, most recently from 762403e to ce93a22 Compare September 29, 2023 19:17
@oskarirauta
Copy link
Contributor Author

@BKPepe

Patches updated with commentary and signed off.

@oskarirauta oskarirauta requested a review from BKPepe September 29, 2023 19:19
@msva
Copy link
Contributor

msva commented Oct 1, 2023

actually, patches aren't yet correct git-formatted patches, but it is no my business, if any, so it's on @BKPepe to review that part :-D

@oskarirauta
Copy link
Contributor Author

@msva looks like it's a no go.

@Ansuel
Copy link
Member

Ansuel commented Oct 4, 2023

@oskarirauta you are welcome my guy

https://gist.github.com/Ansuel/5f0901837fc65c01025f2c62002166a3 (patch are to refresh but they are not with correct formal)

the tar they generate include some files that are ignored by gitingore... very stupid thing honestly and they should really fix this...

Also the second patch... should be reported in openwrt main repo as it seems ""easy"" to fix... @mpratt14 maybe can help? (autotools missing macro @ln@)

@mcprat
Copy link
Contributor

mcprat commented Oct 4, 2023

in the autotools patches called "relocatable" we end up hardcoding the paths anyway...

would it be better to just have LN_S exported from rules.mk?

@Ansuel
Copy link
Member

Ansuel commented Oct 4, 2023

@mpratt14 from what i can see the problem is that the aclocal.m4 is not getting loaded correctly... AC_PROG_LN is a non standard macro and is present in aclocal.m4 but is not getting evaluated???

@Ansuel
Copy link
Member

Ansuel commented Oct 4, 2023

@mpratt14 this is the zsh aclocal.m4 https://github.com/zsh-users/zsh/blob/master/aclocal.m4

@mcprat
Copy link
Contributor

mcprat commented Oct 4, 2023

maybe, I'm bad with the m4 files so I wouldn't know without really digging deep

I just happened to notice a coincidence that in rules.mk we define LN but not LN_S and it's also not exported...its a simple enough definition so I don't know a reason we shouldn't just export it

@Ansuel
Copy link
Member

Ansuel commented Oct 4, 2023

Nope adding export LN on rules.mk doesn't fix it

@mcprat
Copy link
Contributor

mcprat commented Oct 4, 2023

just a guess, maybe the aclocal.m4 should be renamed because it's getting deleted before autoreconf

@Ansuel
Copy link
Member

Ansuel commented Oct 4, 2023

just a guess, maybe the aclocal.m4 should be renamed because it's getting deleted before autoreconf

yes that is exactly the problem... aclocal is getting wiped... i see normally acinclude should be used... but renaming it doesn't fix it... now i'm checking makefile.in

@Ansuel
Copy link
Member

Ansuel commented Oct 4, 2023

I'm getting so triggered by these stupid thing....

@mcprat
Copy link
Contributor

mcprat commented Oct 4, 2023

add a hook to Hooks/Prepare/Post instead of patching that rename

maybe the makefile is listing aclocal.m4 in a list of local m4 files and that needs a patch?

@Ansuel
Copy link
Member

Ansuel commented Oct 4, 2023

@mpratt14 very fun indeed... for some reason renaming and patching the file is not liked by zsh build system... But i found the real cause...

Yes we were right from the start but it's not autoreconf that deleted the file... it's this bad boy https://github.com/openwrt/openwrt/blob/main/include/autotools.mk#L81 that by default remove aclocal.m4...

problem is that zsh used the default name to include custom macro and this is getting removed... so zsh fault and openwrt deleting files...

by setting the variable empty everything compile correctly as the macro are correctly referenced...

@Ansuel
Copy link
Member

Ansuel commented Oct 4, 2023

@BKPepe took care of improving this... For me this is ready.
@oskarirauta thanks for creating the cherry-pick patch. Please check if you are ok with the change I added on top of yours.

@mcprat
Copy link
Contributor

mcprat commented Oct 5, 2023

@Ansuel I hate to be this picky, but there's a typo in your makefile comment

@oskarirauta
Copy link
Contributor Author

oskarirauta commented Oct 5, 2023 via email

@Ansuel
Copy link
Member

Ansuel commented Oct 5, 2023

@mpratt14 np but where? aclocak ?


I updated, can you recheck.

@oskarirauta ok @BKPepe for me it's ok to merge.

In preparation to PCRE2 fixup, use autoreconf PKG_FIXUP as a better
configure system instead of configure script. This is needed to reduce
upcoming patch to migrate to PCRE2 library.

To correctly use autoreconf it's needed to declare empty
PKG_REMOVE_FILES.

zsh include custom macro in the default aclocal.m4
When autoreconf PKG_FIXUP is used, if PKG_REMOVE_FILES is not defined,
it's set to remove the file aclocal.m4 by default resulting in problem
with the custom macro AC_PROG_LN.

Signed-off-by: Oskari Rauta <[email protected]>
[ split to 2 commit, add PKG_REMOVE_FILES, reword commit description ]
Signed-off-by: Christian Marangi <[email protected]>
@oskarirauta
Copy link
Contributor Author

@Ansuel I finally got a chance to check. LGTM.

@mcprat
Copy link
Contributor

mcprat commented Oct 5, 2023

@mpratt14 np but where? aclocak ?

yeah that

@oskarirauta
Copy link
Contributor Author

@neheb

@@ -0,0 +1,648 @@
From fabdb4164288b21f1323f783d257212e5aacecd4 Mon Sep 17 00:00:00 2001
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding this patch, I think we can do it even more better.

I am not sure, why it is labeled as hack, when it seems by quick looking at this patch that it contains actually at least four commits from upstream, so we can do it as patch series as this is rather backport than hack.

Hack in my opinion is something, which is not included in upstream and won't be.

  1. https://github.com/zsh-users/zsh/commit/b62e911341c8ec7446378b477c47da4256053dc0.patch
  2. https://github.com/zsh-users/zsh/commit/f3f371deb376478176866fd770fbcf9bc0d0609f.patch
  3. https://github.com/zsh-users/zsh/commit/b4d1c756f50909b4a13e5c8fe5f26f71e9d54f63.patch
  4. https://github.com/zsh-users/zsh/commit/10bdbd8b5b0b43445aff23dcd412f25cf6aa328a.patch

Yeah, we need to remove the things, which we need, but still it will look better. :-)

Btw. Yes, I need to admit that this is a big improvement than it was, but it could be even better. 💪

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BKPepe indeed... that was my original idea and was blocked by the pkg fixup... Took care of backporting the patch and now it's much cleaner and direct... just 5 backport patch not touched (aside from the changelog commented out)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See @oskarirauta you should learn from this guy. :) 👏 👏 Awesome work as always.

Backport PCRE2 patches from upstream and move package to PCRE2 library
as PCRE is EOL and won't receive any security update anymore.

Patch are backported with minimal change, only the Changelog change is
commented out as it would conflict and makes no sense to adapt for the
purpose of backport patches.

Signed-off-by: Christian Marangi <[email protected]>
@BKPepe
Copy link
Member

BKPepe commented Oct 10, 2023

CI passed, thank you @Ansuel, let's give it time until evening, so someone can go through it. If no objections, otherwise I will merge this.

@BKPepe BKPepe merged commit b158d62 into openwrt:master Oct 11, 2023
@mcprat
Copy link
Contributor

mcprat commented Oct 11, 2023

by the way, someone should inform the zsh developers that having a macro file in-project named "aclocal.m4" is deprecated and they should rename it or have an "m4" directory.

@Koston-0xDEADBEEF
Copy link

someone should tell openwrt people that zsh developers value backwards compatibility over changing file naming

@Ansuel
Copy link
Member

Ansuel commented Oct 13, 2023

bold to say this to the openwrt project itself where the base is to support old and deprecated devices...

also 2012... https://lists.gnu.org/archive/html/automake-patches/2012-12/msg00079.html

@oskarirauta oskarirauta deleted the zsh branch October 13, 2023 20:29
@mcprat
Copy link
Contributor

mcprat commented Oct 14, 2023

one can have both backwards compatibility AND the new method, we don't have to choose one...

would a symlink named aclocal.m4 targeting a different named macro file work?

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.

6 participants