From b653667f62a3dcc6331e6d68f06b1c584c30348e Mon Sep 17 00:00:00 2001
From: Michael Prokop <mika@debian.org>
Date: Fri, 20 Jun 2025 18:34:57 +0200
Subject: Apply workaround for boost/BH usage
Message-ID: <2025-06-20T19-49-03@devnull.michael-prokop.at>

Otherwise, the BH package fails its check for the boost library:

| Error in stan_model(model_code = stancode, verbose = TRUE) :
|   Boost not found; call install.packages('BH')

Thanks: Dirk Eddelbuettel <edd@debian.org> for debugging assistance + initial patch
Closes: #1108078
---
 debian/patches/bh_1108078.patch | 32 ++++++++++++++++++++++++++++++++
 debian/patches/series           |  1 +
 2 files changed, 33 insertions(+)
 create mode 100644 debian/patches/bh_1108078.patch

diff --git a/debian/patches/bh_1108078.patch b/debian/patches/bh_1108078.patch
new file mode 100644
index 0000000..5b5c059
--- /dev/null
+++ b/debian/patches/bh_1108078.patch
@@ -0,0 +1,32 @@
+Description: Disable check for boost lib to work around #1108078
+Last-Update: 2025-06-20
+---
+
+diff --git R/options.R R/options.R
+index 5a6a845..61f3922 100644
+--- a/R/options.R
++++ b/R/options.R
+@@ -65,7 +65,7 @@ init_rstan_opt_env <- function(e) {
+ #   boost_dir <- dir(stan_lib_path, pattern = 'boost.*')
+   # boost lib path
+ #   boost_lib_path <- file.path(stan_lib_path, boost_dir)
+-  boost_lib_path <- system.file('include', package = 'BH')
++  boost_lib_path <- "" # system.file('include', package = 'BH')
+   eigen_lib_path <- system.file('include', package = 'RcppEigen')
+ #   eigen_dir <- dir(stan_lib_path, pattern = 'eigen.*')
+ #   eigen_lib_path <- file.path(stan_lib_path, eigen_dir)
+diff --git R/rstan.R R/rstan.R
+index 89a0d89..5dec7a7 100644
+--- a/R/rstan.R
++++ b/R/rstan.R
+@@ -149,8 +149,8 @@ stan_model <- function(file,
+     old.boost_lib <- rstan_options(boost_lib = boost_lib)
+     on.exit(rstan_options(boost_lib = old.boost_lib))
+   }
+-  if (!file.exists(rstan_options("boost_lib")))
+-    stop("Boost not found; call install.packages('BH')")
++# if (!file.exists(rstan_options("boost_lib")))
++#   stop("Boost not found; call install.packages('BH')")
+
+   if (!is.null(eigen_lib)) {
+     old.eigen_lib <- rstan_options(eigen_lib = eigen_lib)
diff --git a/debian/patches/series b/debian/patches/series
index 8127843..584d9e4 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 fix_library_locations.patch
 unversioned_bh.patch
 remove-stanheaders-in-deps.patch
+bh_1108078.patch
--
2.50.0

