-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmacros.R-rpm
More file actions
62 lines (52 loc) · 2.03 KB
/
macros.R-rpm
File metadata and controls
62 lines (52 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# SPDX-License-Identifier: MIT
# Scripts
%__R_cmd %{_bindir}/R CMD
%__R_deps %{_rpmconfigdir}/R-deps.R
%__R_files %{_rpmconfigdir}/R-files.R
# Packages used for running test suites
%__R_whitelist testthat|tinytest|RUnit|testit
# Path to save files
%_R_files_prefix %{name}-%{version}-%{release}.%{_arch}
%R_files %{_builddir}/%{_R_files_prefix}-R-files
# libdir defined based on %{_target_cpu}
%_R_libdir %{lua:
local rlibdir = rpm.expand("%{_libdir}")
if rpm.expand("%{_target_cpu}") == "noarch" then
rlibdir = rpm.expand("%{_datadir}")
end
print(rlibdir .. "/R/library")
}
# either noarch or a .so is found, not both
%_R_libdir_check %{expand:
IS_NOARCH=1; [ "%{_target_cpu}" = "noarch" ] || IS_NOARCH=0
LIB_FOUND=1; find %{buildroot}%{_R_libdir}/%{__R_name}/libs -name "*.so" | grep -q '^' || LIB_FOUND=0
case $(($IS_NOARCH + $LIB_FOUND)) in
0)
echo "No libs/*.so found in archful package, did you mean BuildArch: noarch?"
exit 1 ;;
2)
echo "File(s) libs/*.so found in noarch package"
exit 1 ;;
esac
}
# Detect if R was bootstrapped for the purpose of waiving checks
%_R_bootstrap_check rpm -q R-core | grep -q bootstrap
%R_buildrequires %{expand:
echo %{__R_name}/DESCRIPTION | %__R_deps LinkingTo Depends Imports
%_R_bootstrap_check || echo %{__R_name}/DESCRIPTION | %__R_deps Suggests | grep -E "%{__R_whitelist}" || true
}
%R_install() %{expand:
mkdir -p %{buildroot}%{_R_libdir}
builddate=$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" -R)
( set -o pipefail && %__R_cmd INSTALL --built-timestamp="$builddate" %{**} -l %{buildroot}%{_R_libdir} %{__R_name} 2>&1 | tee install.log )
rm -f %{__R_name}/src/*.{o,so} %{buildroot}%{_R_libdir}/R.css
%_R_libdir_check
}
%R_save_files() %{expand:
%__R_files -b "%{buildroot}" -p "%{?1}%{!?1:%{_R_libdir}/%{__R_name}}" > "%{?2}%{!?2:%{R_files}}"
}
%R_check() %{expand:
export LANG=C.UTF-8
export _R_CHECK_FORCE_SUGGESTS_=0
%_R_bootstrap_check || %__R_cmd check -l %{buildroot}%{_R_libdir} --install=check:install.log --no-manual --ignore-vignettes %{__R_name} %{**}
}