Accepting request 887313 from devel:languages:ocaml

- Remove ocaml_native_compiler flag, assume native target
  This flag puts too much burden on pkgs that use ocaml, but build
  with their buildsystem instead of using dune

- Use bcond suse_ocaml_use_rpm_license_macro for license in filelist
- Add suse prefix to ocaml_native_compiler to avoid conflict
- Create Provides/Requires only for rpm variants which understand fileattrs
- Fix syntax for chmod of .cmxs
- Add conditional to disable debug_package macro when building with broken rpm variants

OBS-URL: https://build.opensuse.org/request/show/887313
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/ocaml-rpm-macros?expand=0&rev=13
This commit is contained in:
Dominique Leuenberger 2021-04-22 16:03:29 +00:00 committed by Git OBS Bridge
commit 9f61a9726f
2 changed files with 71 additions and 51 deletions

View File

@ -1,3 +1,19 @@
-------------------------------------------------------------------
Wed Apr 21 12:34:56 UTC 2021 - ohering@suse.de
- Remove ocaml_native_compiler flag, assume native target
This flag puts too much burden on pkgs that use ocaml, but build
with their buildsystem instead of using dune
-------------------------------------------------------------------
Fri Apr 9 09:09:09 UTC 2021 - ohering@suse.de
- Use bcond suse_ocaml_use_rpm_license_macro for license in filelist
- Add suse prefix to ocaml_native_compiler to avoid conflict
- Create Provides/Requires only for rpm variants which understand fileattrs
- Fix syntax for chmod of .cmxs
- Add conditional to disable debug_package macro when building with broken rpm variants
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Feb 9 09:09:09 UTC 2021 - ohering@suse.de Tue Feb 9 09:09:09 UTC 2021 - ohering@suse.de

View File

@ -17,38 +17,31 @@
Name: ocaml-rpm-macros Name: ocaml-rpm-macros
Version: 20210209 Version: 20210421
Release: 0 Release: 0
Summary: RPM macros for building OCaml source packages Summary: RPM macros for building OCaml source packages
License: GPL-2.0-only License: GPL-2.0-only
Group: Development/Languages/OCaml Group: Development/Languages/OCaml
BuildRoot: %_tmppath/%name-%version-build
ExclusiveArch: %arm aarch64 %ix86 ppc ppc64 ppc64le riscv64 s390x x86_64
URL: https://build.opensuse.org/project/show/devel:languages:ocaml URL: https://build.opensuse.org/project/show/devel:languages:ocaml
Source0: ocaml-ocaml.rpm.prov_req.attr.sh Source0: ocaml-ocaml.rpm.prov_req.attr.sh
Source1: ocaml-findlib.rpm.prov_req.attr.sh Source1: ocaml-findlib.rpm.prov_req.attr.sh
# Some rpm variants know about license, but can only use them in plain file context
%bcond_without suse_ocaml_use_rpm_license_macro
# Some rpm variants are unable to create proper debuginfo and/or debugsource packages
%bcond_without suse_ocaml_opt_debug_package
# Some rpm variants fail to build even this innocent package...
%define debug_package %{nil}
%define ocaml_standard_library %{_libdir}/ocaml %define ocaml_standard_library %{_libdir}/ocaml
%define do_opt 0
# macros to be set in prjconf: # macros to be set in prjconf:
#Macros: #Macros:
#_with_ocaml_force_enable_ocaml_opt 1
#_with_ocaml_force_disable_ocaml_opt 1
#_with_ocaml_make_testsuite 1 #_with_ocaml_make_testsuite 1
#:Macros #:Macros
%bcond_with ocaml_force_enable_ocaml_opt
%bcond_with ocaml_force_disable_ocaml_opt
%bcond_with ocaml_make_testsuite %bcond_with ocaml_make_testsuite
%if %{with ocaml_force_enable_ocaml_opt}
%define do_opt 1
%endif
%if %{without ocaml_force_enable_ocaml_opt}
%ifarch %{arm} aarch64 %{ix86} ppc ppc64 ppc64le riscv64 s390x x86_64
%define do_opt 1
%endif
%endif
# #
%if %{with ocaml_force_disable_ocaml_opt}
%define do_opt 0
%endif
# #
%description %description
@ -63,30 +56,45 @@ in ocaml spec files.
%build %build
%install %install
# map ocamlobjinfo output to rpm Provides/Requires > files.fileattrs
# this tag name MUST match what ocaml.spec uses internally if test -d '%{_rpmconfigdir}/fileattrs'
tag="suseocaml" then
# Generating dependencies can currently only be done by rpm versions
# which support "fileattrs", because it is easy to add new hooks.
mkdir -vp %{buildroot}%{_rpmconfigdir}/fileattrs mkdir -vp %{buildroot}%{_rpmconfigdir}/fileattrs
tee %{buildroot}%{_rpmconfigdir}/fileattrs/${tag}.attr <<_EOF_
%%__${tag}_provides %%{_rpmconfigdir}/${tag}.sh --provides # Map ocamlobjinfo output to rpm Provides/Requires
%%__${tag}_requires %%{_rpmconfigdir}/${tag}.sh --requires # This tag name MUST match what ocaml.spec uses internally
tag="suseocaml"
file_attr="%{_rpmconfigdir}/fileattrs/${tag}.attr"
file_sh="%{_rpmconfigdir}/${tag}.sh"
attr_sh="%%{_rpmconfigdir}/${tag}.sh"
tee %{buildroot}${file_sh} < %{SOURCE0}
tee %{buildroot}${file_attr} <<_EOF_
%%__${tag}_provides ${attr_sh} --provides
%%__${tag}_requires ${attr_sh} --requires
%%__${tag}_magic ^(ELF|Objective caml|OCaml) .*$ %%__${tag}_magic ^(ELF|Objective caml|OCaml) .*$
%%__${tag}_path .(cma|cmi|cmo|cmx|cmxa|cmxs)$ %%__${tag}_path .(cma|cmi|cmo|cmx|cmxa|cmxs)$
%%__${tag}_flags magic_and_path %%__${tag}_flags magic_and_path
_EOF_ _EOF_
# echo "${file_attr}" >> files.fileattrs
tee %{buildroot}%{_rpmconfigdir}/${tag}.sh < %{SOURCE0} echo "%%attr(755,root,root) ${file_sh}" >> files.fileattrs
# map findlib names to rpm Provides/Requires # Map findlib names to rpm Provides/Requires
tag="suseocamlfind" tag="suseocamlfind"
mkdir -vp %{buildroot}%{_rpmconfigdir}/fileattrs file_attr="%{_rpmconfigdir}/fileattrs/${tag}.attr"
tee %{buildroot}%{_rpmconfigdir}/fileattrs/${tag}.attr <<_EOF_ file_sh="%{_rpmconfigdir}/${tag}.sh"
%%__${tag}_provides %%{_rpmconfigdir}/${tag}.sh -prov attr_sh="%%{_rpmconfigdir}/${tag}.sh"
%%__${tag}_requires %%{_rpmconfigdir}/${tag}.sh -req tee %{buildroot}${file_sh} < %{SOURCE1}
tee %{buildroot}${file_attr} <<_EOF_
%%__${tag}_provides ${attr_sh} -prov
%%__${tag}_requires ${attr_sh} -req
%%__${tag}_path ^%{ocaml_standard_library}/.*/META$|^%{ocaml_standard_library}/META$ %%__${tag}_path ^%{ocaml_standard_library}/.*/META$|^%{ocaml_standard_library}/META$
_EOF_ _EOF_
echo "${file_attr}" >> files.fileattrs
echo "%%attr(755,root,root) ${file_sh}" >> files.fileattrs
fi
# #
tee %{buildroot}%{_rpmconfigdir}/${tag}.sh < %{SOURCE1}
# install OCaml macros # install OCaml macros
mkdir -vp %{buildroot}%{_rpmmacrodir} mkdir -vp %{buildroot}%{_rpmmacrodir}
@ -108,20 +116,17 @@ tee %{buildroot}%{_rpmmacrodir}/macros.%{name} <<'_EOF_'
# the .dwz files contains identical contents, which leads to identical # the .dwz files contains identical contents, which leads to identical
# checksums, which leads to file conflicts due to identical symlinks # checksums, which leads to file conflicts due to identical symlinks
%%ocaml_standard_library %{ocaml_standard_library} %%ocaml_standard_library %{ocaml_standard_library}
%if %{do_opt} %if %{without suse_ocaml_opt_debug_package}
%%ocaml_preserve_bytecode \ # Obviously, handling presence or absence of debug information works only when being built in a SUSE system.
%%define _lto_cflags %%{nil} \
%%{nil}
%%ocaml_native_compiler 1
%%_find_debuginfo_dwz_opts %%{nil}
%else
%%ocaml_preserve_bytecode \
%%undefine _build_create_debug \
%%define __arch_install_post export NO_BRP_STRIP_DEBUG=true \
%%define _lto_cflags %%{nil} \
%%{nil}
%%ocaml_native_compiler 0
%endif %endif
%%ocaml_preserve_bytecode \
%if %{without suse_ocaml_opt_debug_package}
%%define debug_package %%{nil} \
%%define __debug_install_post %%{nil} \
%endif
%%define _lto_cflags %%{nil} \
%%{nil}
%%_find_debuginfo_dwz_opts %%{nil}
# Create file list for base pkg and base-devel pkg # Create file list for base pkg and base-devel pkg
# Files with known extensions or names are written to 'files' or 'files.devel' # Files with known extensions or names are written to 'files' or 'files.devel'
@ -157,14 +162,14 @@ tee %{buildroot}%{_rpmmacrodir}/macros.%{name} <<'_EOF_'
LICENSE.txt \\\ LICENSE.txt \\\
;\ ;\
do\ do\
%if 0%{?suse_version} > 1315 %if %{with suse_ocaml_use_rpm_license_macro}
license_macro='license' ;\ license_macro='license' ;\
%else %else
license_macro='doc' ;\ license_macro='doc' ;\
%endif %endif
test -f "${license}" && echo "%%%%${license_macro} ${license}" >> '%%{name}.files.license' ;\ test -f "${license}" && echo "%%%%${license_macro} ${license}" >> '%%{name}.files.license' ;\
done ;\ done ;\
find %%{buildroot}%%{ocaml_standard_library} -name '*.cmxs' -exec chmod -v a-x '{}' +\ find %%{buildroot}%%{ocaml_standard_library} -name '*.cmxs' -exec chmod -v a-x '{}' + ;\
find %%{buildroot}%%{ocaml_standard_library} ! -type d | awk\\\ find %%{buildroot}%%{ocaml_standard_library} ! -type d | awk\\\
-v "buildroot=%%{buildroot}"\\\ -v "buildroot=%%{buildroot}"\\\
-v "ocaml_standard_library=%%{ocaml_standard_library}"\\\ -v "ocaml_standard_library=%%{ocaml_standard_library}"\\\
@ -528,9 +533,8 @@ ocaml setup.ml -configure \\\
# #
_EOF_ _EOF_
%files %files -f files.fileattrs
%defattr(-,root,root,-)
%{_rpmmacrodir}/* %{_rpmmacrodir}/*
%{_rpmconfigdir}/fileattrs
%attr(755,root,root) %{_rpmconfigdir}/*.sh
%changelog %changelog