Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] common: support disabling python shebang rewriting
@ 2024-04-18  1:58 classabbyamp
  2024-04-18  2:35 ` classabbyamp
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: classabbyamp @ 2024-04-18  1:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 805 bytes --]

There is a new pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages py-ver-ignore
https://github.com/void-linux/void-packages/pull/49886

common: support disabling python shebang rewriting
Ghidra's embedded jython contains scripts with shebangs like `#!/usr/bin/env python`. These seem to be designed to be run by jython, *not* the system python, and as such, they should not have their shebangs changed to `#!/usr/bin/python2`. This adds support for disabling that hook in cases like this.

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**



A patch file from https://github.com/void-linux/void-packages/pull/49886.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-py-ver-ignore-49886.patch --]
[-- Type: text/x-diff, Size: 3737 bytes --]

From 8588355945b57d708006ba0ca25ae3b6a832d46f Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 17 Apr 2024 21:51:01 -0400
Subject: [PATCH 1/2] common: support disabling python shebang rewriting

useful if there are special python-containing shebangs that should not
be rewritten, for example with Ghidra's embedded jython.
---
 Manual.md                                                    | 4 +++-
 common/hooks/post-install/04-create-xbps-metadata-scripts.sh | 2 +-
 common/hooks/pre-pkg/03-rewrite-python-shebang.sh            | 4 ++++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Manual.md b/Manual.md
index 34c737e6df427d..53a2cc8a1510fc 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1250,7 +1250,7 @@ package accordingly. Additionally, the following functions are available:
 - *vopt_feature()* `vopt_feature <option> <property>`
 
   Same as `vopt_bool`, but uses `-D<property=enabled` and
-	`-D<property>=disabled` respectively. 
+	`-D<property>=disabled` respectively.
 
 The following example shows how to change a source package that uses GNU
 configure to enable a new build option to support PNG images:
@@ -1630,6 +1630,8 @@ In most cases version is inferred from shebang, install path or build style.
 Only required for some multi-language
 applications (e.g., the application is written in C while the command is
 written in Python) or just single Python file ones that live in `/usr/bin`.
+If `python_version` is set to `ignore`, python-containing shebangs will not be rewritten.
+Use this only if a package should not be using a system version of python.
 
 Also, a set of useful variables are defined to use in the templates:
 
diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
index 69e318a560819e..f21017f8361e6d 100644
--- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
+++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
@@ -272,7 +272,7 @@ _EOF
 		fi
 	fi
 
-	if [ -n "$python_version" ]; then
+	if [ -n "$python_version" ] && [ "$python_version" != ignore ]; then
 		pycompile_version=${python_version}
 	fi
 
diff --git a/common/hooks/pre-pkg/03-rewrite-python-shebang.sh b/common/hooks/pre-pkg/03-rewrite-python-shebang.sh
index 07162ad2c69bea..47c7a996a501be 100644
--- a/common/hooks/pre-pkg/03-rewrite-python-shebang.sh
+++ b/common/hooks/pre-pkg/03-rewrite-python-shebang.sh
@@ -12,6 +12,10 @@ hook() {
 		pyver="$python_version"
 	fi
 
+	if [ "$python_version" = ignore ]; then
+		return
+	fi
+
 	if [ -n "$pyver" ]; then
 		default_shebang="#!/usr/bin/python${pyver%.*}"
 	fi

From 94f4aa586f74a4d8248fe77382af2704ddd2fd6c Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 17 Apr 2024 21:52:59 -0400
Subject: [PATCH 2/2] ghidra: don't rewrite python shebangs

---
 srcpkgs/ghidra/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ghidra/template b/srcpkgs/ghidra/template
index f6544fc69f8776..a0b7cc8e565f1a 100644
--- a/srcpkgs/ghidra/template
+++ b/srcpkgs/ghidra/template
@@ -1,7 +1,7 @@
 # Template file for 'ghidra'
 pkgname=ghidra
 version=11.0.3
-revision=1
+revision=2
 _dex_ver=2.1
 _yajsw_ver=13.09
 archs="x86_64* aarch64*"
@@ -69,7 +69,7 @@ skiprdeps="/usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/animals
  /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/sharedReturn
  /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/switch
  /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/write"
-python_version=2 # Jython 2.7.2 stuff
+python_version=ignore # jython, not system python 2
 nocross=yes
 
 post_extract() {

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: common: support disabling python shebang rewriting
  2024-04-18  1:58 [PR PATCH] common: support disabling python shebang rewriting classabbyamp
@ 2024-04-18  2:35 ` classabbyamp
  2024-04-18  4:38 ` classabbyamp
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: classabbyamp @ 2024-04-18  2:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 414 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/49886#issuecomment-2062886340

Comment:
> example scripts that would probably be better left unmodified

maybe it would make sense to have this as a separate variable for patterns to ignore?

```sh
python_shebang_ignore="/usr/libexec/ghidra/Ghidra/Features/Python/data/jython-2.7.3/*"
```
for example

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: common: support disabling python shebang rewriting
  2024-04-18  1:58 [PR PATCH] common: support disabling python shebang rewriting classabbyamp
  2024-04-18  2:35 ` classabbyamp
@ 2024-04-18  4:38 ` classabbyamp
  2024-04-18 11:38 ` fanyx
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: classabbyamp @ 2024-04-18  4:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 544 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/49886#issuecomment-2062886340

Comment:
> example scripts that would probably be better left unmodified

maybe it would make sense to have this as a separate variable for patterns to ignore?

```sh
python_shebang_ignore="/usr/libexec/ghidra/Ghidra/Features/Python/data/jython-2.7.3/*"
```
for example

edit: with the current hook, I'm not sure I see a way to do this without massively increasing the time spent running the hook.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: common: support disabling python shebang rewriting
  2024-04-18  1:58 [PR PATCH] common: support disabling python shebang rewriting classabbyamp
  2024-04-18  2:35 ` classabbyamp
  2024-04-18  4:38 ` classabbyamp
@ 2024-04-18 11:38 ` fanyx
  2024-04-18 16:26 ` classabbyamp
  2024-04-24  3:51 ` [PR PATCH] [Merged]: " classabbyamp
  4 siblings, 0 replies; 6+ messages in thread
From: fanyx @ 2024-04-18 11:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

New comment by fanyx on void-packages repository

https://github.com/void-linux/void-packages/pull/49886#issuecomment-2063660622

Comment:
> maybe it would make sense to have this as a separate variable for patterns to ignore?
> 
> ```shell
> python_shebang_ignore="/usr/libexec/ghidra/Ghidra/Features/Python/data/jython-2.7.3/*"
> ```

this solution *feels* very clean

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: common: support disabling python shebang rewriting
  2024-04-18  1:58 [PR PATCH] common: support disabling python shebang rewriting classabbyamp
                   ` (2 preceding siblings ...)
  2024-04-18 11:38 ` fanyx
@ 2024-04-18 16:26 ` classabbyamp
  2024-04-24  3:51 ` [PR PATCH] [Merged]: " classabbyamp
  4 siblings, 0 replies; 6+ messages in thread
From: classabbyamp @ 2024-04-18 16:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 262 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/49886#issuecomment-2064448355

Comment:
maybe, but it would require checking every path against (multiple) globs, from what i can tell, which could be slow

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PR PATCH] [Merged]: common: support disabling python shebang rewriting
  2024-04-18  1:58 [PR PATCH] common: support disabling python shebang rewriting classabbyamp
                   ` (3 preceding siblings ...)
  2024-04-18 16:26 ` classabbyamp
@ 2024-04-24  3:51 ` classabbyamp
  4 siblings, 0 replies; 6+ messages in thread
From: classabbyamp @ 2024-04-24  3:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

There's a merged pull request on the void-packages repository

common: support disabling python shebang rewriting
https://github.com/void-linux/void-packages/pull/49886

Description:
Ghidra's embedded jython contains scripts with shebangs like `#!/usr/bin/env python`. These seem to be designed to be run by jython, *not* the system python, and as such, they should not have their shebangs changed to `#!/usr/bin/python2`. This adds support for disabling that hook in cases like this.

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-24  3:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18  1:58 [PR PATCH] common: support disabling python shebang rewriting classabbyamp
2024-04-18  2:35 ` classabbyamp
2024-04-18  4:38 ` classabbyamp
2024-04-18 11:38 ` fanyx
2024-04-18 16:26 ` classabbyamp
2024-04-24  3:51 ` [PR PATCH] [Merged]: " classabbyamp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).