From 3d996a84cc754cea106ac490099f3cd24f546be8 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 12 Feb 2023 21:02:31 +0900 Subject: [PATCH] Takes the environment variable `DESTDIR` in `rake install` If the environment variable `DESTDIR` is set, the writing destination is `//...`. It is assumed to be used for package work. --- doc/guides/compile.md | 4 ++++ lib/mruby/build.rb | 1 + tasks/install.rake | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/guides/compile.md b/doc/guides/compile.md index 03450cd6a..08dedbf9d 100644 --- a/doc/guides/compile.md +++ b/doc/guides/compile.md @@ -595,6 +595,9 @@ The `PREFIX` environment variable affects all build targets and changes the `/us The `MRuby::Build#install_prefix` can be set for each individual build target. In this case, the environment variable `PREFIX` is ignored. +Also, if the environment variable `DESTDIR` is set, it will prepend to the path obtained by `install_prefix` to determine the final write directory. +This is intended for temporary file expansion by the user's package work. + --- To summarize: @@ -602,6 +605,7 @@ To summarize: - The default value of the environment variable `PREFIX` is `/usr/local`. - For the "host" build target, the default value of `MRuby::Build#install_prefix` is ``. - For a build target other than "host", the default value of `MRuby::Build#install_prefix` is `/mruby/`. +- If the environment variable `DESTDIR` is set, the actual write directory is `/`. ## Tips diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index cfae8c8a1..71aed7667 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -9,6 +9,7 @@ module MRuby autoload :Presym, "mruby/presym" INSTALL_PREFIX = ENV['PREFIX'] || ENV['INSTALL_PREFIX'] || '/usr/local' + INSTALL_DESTDIR = ENV['DESTDIR'] || '' class << self def targets diff --git a/tasks/install.rake b/tasks/install.rake index ccb0c1a3c..234bec8d8 100644 --- a/tasks/install.rake +++ b/tasks/install.rake @@ -13,7 +13,7 @@ task "install:bin" MRuby.each_target do |build| next if build.internal? - prefix = build.install_prefix + prefix = File.join(MRuby::INSTALL_DESTDIR, build.install_prefix) task "install:full" => "install:full:#{build.name}"