From 5b31a0623bcaa52d3b662108464f3abc2c3046ba Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Sat, 24 Apr 2021 14:12:51 -0400 Subject: [PATCH 1/7] docs: mention shebang rewrite in the formula cookbook --- docs/Formula-Cookbook.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 0796ec2ff2..13b2a792cc 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -750,6 +750,10 @@ ln_s libexec/"name", bin The symlinks created by [`install_symlink`](https://rubydoc.brew.sh/Pathname#install_symlink-instance_method) are guaranteed to be relative. `ln_s` will only produce a relative symlink when given a relative path. +### Rewriting a script shebang + +In some cases, the formula goal is to install a script written in an interpreted language, such as Python or Perl, and use it as an executable. Homebrew provides utilities to rewrite the shebang of a script so its path matches the interpreter dependency. For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb) uses such utility. + ### Handling files that should persist over formula upgrades For example, Ruby 1.9’s gems should be installed to `var/lib/ruby/` so that gems don’t need to be reinstalled when upgrading Ruby. You can usually do this with symlink trickery, or (ideally) a configure option. From a313b2d34fd667e8eacbe2846dd593336962a8c4 Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Sun, 25 Apr 2021 13:06:39 -0400 Subject: [PATCH 2/7] Update docs/Formula-Cookbook.md Co-authored-by: Rylan Polster --- docs/Formula-Cookbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 13b2a792cc..012ca418db 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -752,7 +752,7 @@ The symlinks created by [`install_symlink`](https://rubydoc.brew.sh/Pathname#ins ### Rewriting a script shebang -In some cases, the formula goal is to install a script written in an interpreted language, such as Python or Perl, and use it as an executable. Homebrew provides utilities to rewrite the shebang of a script so its path matches the interpreter dependency. For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb) uses such utility. +In some cases, the formula goal is to install a script written in an interpreted language, such as Python or Perl, to be used as an executable. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script to point to the correct interpreter path. For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb#L16) uses such utility. ### Handling files that should persist over formula upgrades From 539b2105d463ccf28ddf6868df113e645b31cae8 Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Mon, 26 Apr 2021 16:11:08 -0400 Subject: [PATCH 3/7] Update Formula-Cookbook.md --- docs/Formula-Cookbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 012ca418db..e724ca1609 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -752,7 +752,7 @@ The symlinks created by [`install_symlink`](https://rubydoc.brew.sh/Pathname#ins ### Rewriting a script shebang -In some cases, the formula goal is to install a script written in an interpreted language, such as Python or Perl, to be used as an executable. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script to point to the correct interpreter path. For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb#L16) uses such utility. +In some cases, the formula goal is to install a script written in an interpreted language, such as Python or Perl, to be used as an executable. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script. This replaces the original interpreter path with the one installed by Homebrew. This guarantees that the interpreter dependency was correctly installed and is present at execution time. For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb#L16) uses such utility. ### Handling files that should persist over formula upgrades From 87d9af7b4a2c8c47ec5df174f7b3fe399d4bd382 Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Mon, 26 Apr 2021 20:34:33 -0400 Subject: [PATCH 4/7] Update Formula-Cookbook.md --- docs/Formula-Cookbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index e724ca1609..23e42dac33 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -752,7 +752,7 @@ The symlinks created by [`install_symlink`](https://rubydoc.brew.sh/Pathname#ins ### Rewriting a script shebang -In some cases, the formula goal is to install a script written in an interpreted language, such as Python or Perl, to be used as an executable. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script. This replaces the original interpreter path with the one installed by Homebrew. This guarantees that the interpreter dependency was correctly installed and is present at execution time. For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb#L16) uses such utility. +In some cases, the formula goal is to install a script written in an interpreted language, such as Python or Perl, to be used as an executable. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script. This replaces the original interpreter path with the one installed by Homebrew. This guarantees that the interpreter dependency was correctly installed and is present at execution time. For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb#L16) uses such utility. Note that it is necessary to include the utility in the formula, for example with Python one must use `include Language::Python::Shebang`. ### Handling files that should persist over formula upgrades From 5ed94c0d00f18410b681c03c11cc3805dd2848e4 Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Mon, 26 Apr 2021 20:43:46 -0400 Subject: [PATCH 5/7] Update docs/Formula-Cookbook.md Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> --- docs/Formula-Cookbook.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 23e42dac33..965c41b559 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -752,7 +752,9 @@ The symlinks created by [`install_symlink`](https://rubydoc.brew.sh/Pathname#ins ### Rewriting a script shebang -In some cases, the formula goal is to install a script written in an interpreted language, such as Python or Perl, to be used as an executable. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script. This replaces the original interpreter path with the one installed by Homebrew. This guarantees that the interpreter dependency was correctly installed and is present at execution time. For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb#L16) uses such utility. Note that it is necessary to include the utility in the formula, for example with Python one must use `include Language::Python::Shebang`. +Some formulae install executable scripts written in an interpreted language such as Python or Perl. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script. This replaces a script's original interpreter path with the one installed by Homebrew and guarantees that the correct interpreter is used at execution time. + +For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb#L16) uses such utility. Note that it is necessary to include the utility in the formula, for example with Python one must use `include Language::Python::Shebang`. ### Handling files that should persist over formula upgrades From 665b86453fcc3f8e21a5e1cf11c159f81c40b926 Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Tue, 27 Apr 2021 11:39:32 -0400 Subject: [PATCH 6/7] Update Formula-Cookbook.md --- docs/Formula-Cookbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 965c41b559..ab23a8ff46 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -752,7 +752,7 @@ The symlinks created by [`install_symlink`](https://rubydoc.brew.sh/Pathname#ins ### Rewriting a script shebang -Some formulae install executable scripts written in an interpreted language such as Python or Perl. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script. This replaces a script's original interpreter path with the one installed by Homebrew and guarantees that the correct interpreter is used at execution time. +Some formulae install executable scripts written in an interpreted language such as Python or Perl. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script. This replaces a script's original interpreter path with the one the formula depends on. This guarantees that the correct interpreter is used at execution time. It is only needed when the build system doesn't already do it (e.g., often when using `pip` or Perl `ExtUtils::MakeMaker`). For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb#L16) uses such utility. Note that it is necessary to include the utility in the formula, for example with Python one must use `include Language::Python::Shebang`. From 24873242141f4a79feb5dac9c2fb098304b6b168 Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Tue, 27 Apr 2021 13:09:57 -0400 Subject: [PATCH 7/7] Update docs/Formula-Cookbook.md Co-authored-by: Rylan Polster --- docs/Formula-Cookbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index ab23a8ff46..46d2a2832f 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -752,7 +752,7 @@ The symlinks created by [`install_symlink`](https://rubydoc.brew.sh/Pathname#ins ### Rewriting a script shebang -Some formulae install executable scripts written in an interpreted language such as Python or Perl. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script. This replaces a script's original interpreter path with the one the formula depends on. This guarantees that the correct interpreter is used at execution time. It is only needed when the build system doesn't already do it (e.g., often when using `pip` or Perl `ExtUtils::MakeMaker`). +Some formulae install executable scripts written in an interpreted language such as Python or Perl. Homebrew provides a `rewrite_shebang` method to rewrite the shebang of a script. This replaces a script's original interpreter path with the one the formula depends on. This guarantees that the correct interpreter is used at execution time. This isn't required if the build system already handles it (e.g. often with `pip` or Perl `ExtUtils::MakeMaker`). For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb#L16) uses such utility. Note that it is necessary to include the utility in the formula, for example with Python one must use `include Language::Python::Shebang`.