Skip to content

allow any posix-compliant PATCH(1) #30481

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

Open
dimpase opened this issue Aug 31, 2020 · 24 comments
Open

allow any posix-compliant PATCH(1) #30481

dimpase opened this issue Aug 31, 2020 · 24 comments

Comments

@dimpase
Copy link
Member

dimpase commented Aug 31, 2020

currently we require GNU patch, version at least 2.7 (from 2009).
In particular, BSD patch does not know about --no-backup-if-mismatch, something that Sage used. An equivalent, and known to BSD patch as well as GNU patch, option is --posix.

So we could use --posix and change spkg-configure to accept BSD patch too.
I am not sure what's needed to be checked, besides that --posix is accepted. Something to learn from https://savannah.gnu.org/forum/forum.php?forum_id=7361 ?

Depends on #30668

CC: @thierry-FreeBSD @orlitzky

Component: build: configure

Author: Dima Pasechnik

Branch/Commit: u/dimpase/config/acceptposixpatch @ e0fcafc

Issue created by migration from https://trac.sagemath.org/ticket/30481

@dimpase dimpase added this to the sage-9.3 milestone Aug 31, 2020
@orlitzky
Copy link
Contributor

comment:1

Sounds good to me. Additionally we could check to see if the system patch supports a --posix flag. If it does, we should pass it; otherwise we may simply assume that the implementation respects POSIX (and does not create backups).

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 13, 2021

comment:2

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Feb 13, 2021
@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

comment:3

need to check whether an oldish macOS patch (GNU patch 2.5.8, it says) is OK.


New commits:

9bfbc41update for autoconf 2.71
2791d92Merge branch 'u/dimpase/ticket/30668' of trac.sagemath.org:sage into u/dimpase/config/acceptposixpatch
e0fcafcaccept any POSIX-compatible patch(1)

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

Branch: u/dimpase/config/acceptposixpatch

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

Dependencies: #30668

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

Author: Dima Pasechnik

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

Commit: e0fcafc

@orlitzky
Copy link
Contributor

comment:4

This will actually only find a non-POSIX patch, since the --posix option only exists in non-conforming implementations =)

I think printf "" | patch --posix might be a more reliable test of support for the --posix flag. And if --posix is not supported, we should assume that "patch" conforms, i.e.

  1. Find "patch" with AC_PATH_PROG
  2. Try printf "" | ${PATCH} --posix. If it works, set SAGE_PATCH_ARGS="--posix".
  3. Rename build/bin/sage-apply-patches with an .in suffix and add it to AC_CONFIG_FILES
  4. Set patch_args="@SAGE_PATCH_ARGS@" in build/bin/sage-apply-patches.in.

That way, if --posix is supported, we use it. Otherwise, we assume POSIX conformance.

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

comment:5

meanwhile I am finding out that we cannot call patch
with --posix option, as it doesn't allow file creation.
So the patch in psutil spkg does not apply.

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

comment:6

on the other hand I see no harm in just dropping --no-backup-if-mismatch as it doesn't buy us anything.

@orlitzky
Copy link
Contributor

comment:7

Replying to @dimpase:

meanwhile I am finding out that we cannot call patch
with --posix option, as it doesn't allow file creation.
So the patch in psutil spkg does not apply.

What's the problem with file creation?

The --posix docs for GNU patch mention that it will become impossible to remove files (you can only empty them), but don't say anything about file creation.

It may be important: if we start to accept any "patch", then we have to be prepared for one that follows the POSIX behavior. In other words, if the patches we ship only work with GNU/BSD patch, then we should probably check for one of those and not for any POSIX-compatible patch. (In that case, we can still test for the backup flag with printf "" | patch --no-backup-if-mismatch)

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 27, 2021

comment:8

Relaxing the spkg-configure.m4 of patch sounds to me like asking for trouble. Recall the insanity that had to be worked around in #30403?

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

comment:9

Replying to @orlitzky:

Replying to @dimpase:

meanwhile I am finding out that we cannot call patch
with --posix option, as it doesn't allow file creation.
So the patch in psutil spkg does not apply.

What's the problem with file creation?

The --posix docs for GNU patch mention that it will become impossible to remove files (you can only empty them), but don't say anything about file creation.

I suppose it's due to the way patch --posix determines the filename to patch, and gathers it's /dev/null, oops.
(this is what GNU patch does, I didn't look at what's BSD patch does.)

It may be important: if we start to accept any "patch", then we have to be prepared for one that follows the POSIX behavior. In other words, if the patches we ship only work with GNU/BSD patch, then we should probably check for one of those and not for any POSIX-compatible patch. (In that case, we can still test for the backup flag with printf "" | patch --no-backup-if-mismatch)

I agree, some more testing is needed.

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

comment:10

Replying to @mkoeppe:

Relaxing the spkg-configure.m4 of patch sounds to me like asking for trouble. Recall the insanity that had to be worked around in #30403?

I don't think it's so hard, it's just an executable after all.
And as a bonus we can just get rid of Sage's patch spkg, after this is done.

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 27, 2021

comment:11

There are no problems with Sage's patch spkg, please don't create new problems

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 27, 2021

comment:12

And until someone is sufficiently invested in a *BSD port to actually set up automatic testing, as discussed several times, let's please not use any BSD platform as motivation for changes like this.

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

comment:13

Replying to @mkoeppe:

There are no problems with Sage's patch spkg, please don't create new problems

my primary issue with patch is that it's part of the Sage's toolchain, and as such 1st in line to be kicked out.

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 27, 2021

comment:14

comment 11 covers this.

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

comment:15

Replying to @mkoeppe:

comment 11 covers this.

How? I don't see why we need to keep toolchain components vendored.

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 27, 2021

comment:16

We are not vendoring it. We are providing a fallback installation script for the benefit of users who don't have it on their machines. It is working well: It installs correctly and has not caused other maintenance issues. (That's in contrast to the problematic gcc package - which is a fallback that works sometimes but not always; and requires relatively frequent upgrades.) So, let's please not solve nonexisting problems.

@dimpase
Copy link
Member Author

dimpase commented Jun 27, 2021

comment:17

so far one outcome is that --no-backup-if-mismatch may be just dropped (this option is just cosmetic), and in fact native macOS patch, which is GNU patch 2.5.8, may be used just as well.

I gather that the fallback is simply not needed, just as it's not needed for tar (tar used to be a Sage spkg).

Whether BSD patch should be allowed is another question.

Oh, and iml spkg has a patch for a non-existing file, something I found out using --posix option :-)

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe mkoeppe removed this from the sage-9.5 milestone Dec 18, 2021
@mkoeppe mkoeppe added this to the sage-9.6 milestone Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 1, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
@dimpase
Copy link
Member Author

dimpase commented Apr 14, 2025

@jhpalmieri - it seems we can just drop the requirement that the option --no-backup-if-mismatch is supported, we can accept Apple patch. The only place patch is invoked with this option is build/bin/sage-apply-patches, and this is only used in sage-spkg for applying patches supplied with spkgs. Otherwise it should work, I think.

@jhpalmieri
Copy link
Member

Note that Apple's current version of patch supports --no-backup-if-mismatch, according to their man page (which is dated April 2022). Could we just test to see whether the system's patch supports that option and if so, use it?

Otherwise, a brief skim of the discussion here suggests that we need to test whether the version of patch supports --posix or is already posix-compliant.

@dimpase
Copy link
Member Author

dimpase commented Apr 14, 2025

--posix option is meaningless for us, it's too restrictive. For me "/usr/bin/patch -h" on macOS does not show that no-backup-if... option, so we need to check on "real" files?

@dimpase dimpase mentioned this issue Apr 15, 2025
5 tasks
vbraun pushed a commit to vbraun/sage that referenced this issue Apr 21, 2025
sagemathgh-39943: remove patch spkg
    
every system we support has a decent enough version of patch. So we just
purge it, like we did with tar a while ago.

This will fix sagemath#39941 and sagemath#30481

<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39943
Reported by: Dima Pasechnik
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 1, 2025
sagemathgh-39943: remove patch spkg
    
every system we support has a decent enough version of patch. So we just
purge it, like we did with tar a while ago.

This will fix sagemath#39941 and sagemath#30481

<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39943
Reported by: Dima Pasechnik
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 4, 2025
sagemathgh-39943: remove patch spkg
    
every system we support has a decent enough version of patch. So we just
purge it, like we did with tar a while ago.

This will fix sagemath#39941 and sagemath#30481

<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39943
Reported by: Dima Pasechnik
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 5, 2025
sagemathgh-39943: remove patch spkg
    
every system we support has a decent enough version of patch. So we just
purge it, like we did with tar a while ago.

This will fix sagemath#39941 and sagemath#30481

<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39943
Reported by: Dima Pasechnik
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 6, 2025
sagemathgh-39943: remove patch spkg
    
every system we support has a decent enough version of patch. So we just
purge it, like we did with tar a while ago.

This will fix sagemath#39941 and sagemath#30481

<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39943
Reported by: Dima Pasechnik
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue May 9, 2025
sagemathgh-39943: remove patch spkg
    
every system we support has a decent enough version of patch. So we just
purge it, like we did with tar a while ago.

This will fix sagemath#39941 and sagemath#30481

<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39943
Reported by: Dima Pasechnik
Reviewer(s): Tobias Diez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants