Closed mizdebsk closed 7 years ago
%license macro - the same license can be reused for javadocs, it was not possible with %doc used for licenses
Do you have any idea how to do that? I don't see any way how to programatically access filelists. I though I could redefine %license macro to capture the licenses in some global variable, but RPM doesn't allow that (ironically, this can be done for %doc, but not for %license).
This should do the trick:
%files javadoc -f .mfiles-javadoc
%{_licensedir}/*
Or even better (will work even when there are no license files installed):
%install
install -d -m 755 %{buildroot}%{_licensedir}
%files javadoc -f .mfiles-javadoc
%{_licensedir}
%exclude %dir %{_licensedir}
That works, thanks.
It should also have %license
on %{_licensedir}
in order to have RPMFILE_LICENSE
flag set.
There are some limitations of this approach:
%{_licensedir}/$rpm_name
. On the other hand, this will save space, as the file will be installed only once if both javadoc and decalring package is installed.Solution with a macro that the user explicitly uses:
%generate_javadoc_package() \
%package javadoc \
Summary: Javadoc for %{?scl:%{pkg_name}}%{!?scl:%{name}} \
%description javadoc \
API documentation for %{?scl:%{pkg_name}}%{!?scl:%{name}}. \
%files javadoc -f .mfiles-javadoc \
%%license %{_licensedir} \
%exclude %dir %{_licensedir}
%mvn_install
Fully automatic "solution" (user doesn't specify anything):
%mvn_build
and %mvn_install -J
%mvn_install
, it's easy: %{?-J*:%global __javadoc_built 1}
%mvn_build
this would be more problematic, because we need to cature -j
/--skip-javadoc
. Rpm uses getopt
for parsing, which cannot be made to process long options. It can, at least, be made to ignore them by making the optstring qwertyuiopasdfghjklzxcvbnm-
. But to be able to get --skip-javadoc
we'd need to parse it with lua. Then it would register %global __javadoc_built 1
like in %mvn_install
%package(n) \
%{expand: %%global __has_package_%{lua: print(string.gsub(rpm.expand("%{1}"), '[-+]', '_'))} 1} \
%%package %**
%changelog \
%if (0%{?__javadoc_built:1} && 0%{!?__has_package_javadoc:1} && 0%{!?_without_javadoc:1}) \
%generate_javadoc_package \
%endif \
%%changelog
The first option (explicit macro invocation) seems fine to me. It has clear migration path and is safer than the other proposal.
Perhaps it could be improved a bit to make the macro more flexible:
_without_javadoc
- generate empty javadoc pkgAlso I would avoid word "Javadoc" in summary/description - it causes rpmlint warning.
Long time ago we tried to introduce experimental generator of javadoc subpackages (see 26ebe8d701f53159f10194b43e51891fa1864eda) aimed at reducing boilerplate code in spec files, but it wasn't successful for different reasons.
Since then we added several missing bits that can make it easier to implement such feature:
%mvn_install
.mfiles-javadoc
Therefore lets reconsider adding this feature.