diff options
author | Vít Ondruch <vondruch@redhat.com> | 2023-03-08 16:46:07 +0100 |
---|---|---|
committer | Vít Ondruch <vondruch@redhat.com> | 2023-03-08 16:46:09 +0100 |
commit | b872a2d28a404289167868cd07cc3d44f75ac802 (patch) | |
tree | 4b36250518a8c776b6a3b592760b99deb75d93eb | |
parent | a2783c21290f5a38fee05111767873df386daf0a (diff) | |
download | darkfish-b872a2d28a404289167868cd07cc3d44f75ac802.tar.gz darkfish-b872a2d28a404289167868cd07cc3d44f75ac802.tar.xz darkfish-b872a2d28a404289167868cd07cc3d44f75ac802.zip |
Add dependency generator
This generates `rdoc-generator-fedora-darkfish-assets` dependency for
standard RubyGems doc locations, which contains symlinks to the assets.
-rw-r--r-- | rdoc-generator-fedora-darkfish.spec | 21 | ||||
-rw-r--r-- | rdoc_generator_fedora_darkfish.attr | 4 | ||||
-rw-r--r-- | rdoc_generator_fedora_darkfish.req | 23 |
3 files changed, 44 insertions, 4 deletions
diff --git a/rdoc-generator-fedora-darkfish.spec b/rdoc-generator-fedora-darkfish.spec index 8212b33..0891e2d 100644 --- a/rdoc-generator-fedora-darkfish.spec +++ b/rdoc-generator-fedora-darkfish.spec @@ -11,8 +11,10 @@ Summary: Darkfish RDoc Generator License: GPL-2.0-only AND Ruby AND BSD-3-Clause AND CC-BY-2.5 URL: https://ruby.github.io/rdoc Source0: https://rubygems.org/gems/rdoc-%{version}.gem -Source1: fedora_darkfish.rb -Source2: rubygems_plugin.rb +Source1: rdoc_generator_fedora_darkfish.attr +Source2: rdoc_generator_fedora_darkfish.req +Source3: fedora_darkfish.rb +Source4: rubygems_plugin.rb # Because the fonts are not embedded, do not refer to them in the font.css # file. Patch0: rdoc-6.4.0-Drop-the-font-URLs-from-css.patch @@ -47,6 +49,15 @@ generated for rubygem- packages on Fedora. %build %install +# Install dependency generators. +mkdir -p %{buildroot}%{_fileattrsdir} +install -m 644 %{SOURCE1} %{buildroot}%{_fileattrsdir} +install -m 755 %{SOURCE2} %{buildroot}%{_rpmconfigdir} +sed -i \ + -e 's|%%{name}|%{name}|' \ + -e 's|%%{_datadir}|%{_datadir}|' \ + %{buildroot}%{_rpmconfigdir}/*.req + pushd lib/rdoc/generator/template/ find . -mindepth 2 -type d \ -exec install -d %{buildroot}%{_datadir}/%{name}/{} \; @@ -59,8 +70,8 @@ rm %{buildroot}%{_datadir}/%{name}/{darkfish,json_index}/.document # Drop fonts. System fonts are going to be pulled in instead. rm -rf %{buildroot}%{_datadir}/%{name}/darkfish/fonts -install -p -m 644 %{SOURCE1} %{buildroot}%{_datadir}/%{name}/ -install -p -m 644 %{SOURCE2} %{buildroot}%{_datadir}/%{name}/ +install -p -m 644 %{SOURCE3} %{buildroot}%{_datadir}/%{name}/ +install -p -m 644 %{SOURCE4} %{buildroot}%{_datadir}/%{name}/ mkdir -p $(dirname %{buildroot}%{gem_plugin}) echo "require '%{_datadir}/%{name}/rubygems_plugin.rb'" > %{buildroot}%{gem_plugin} @@ -69,6 +80,8 @@ echo "require '%{_datadir}/%{name}/rubygems_plugin.rb'" > %{buildroot}%{gem_plug # Not test ATM. Not clear if there is actually something to test. %files +%{_fileattrsdir}/*.attr +%{_rpmconfigdir}/*.req %{gem_plugin} %{_datadir}/%{name}/darkfish/*.rhtml %{_datadir}/%{name}/fedora_darkfish.rb diff --git a/rdoc_generator_fedora_darkfish.attr b/rdoc_generator_fedora_darkfish.attr new file mode 100644 index 0000000..ed3dad5 --- /dev/null +++ b/rdoc_generator_fedora_darkfish.attr @@ -0,0 +1,4 @@ +%__rdoc_generator_fedora_darkfish_requires %{_rpmconfigdir}/rdoc_generator_fedora_darkfish.req +# In non-gem packages, the %%{gem_name} macro is not available and the macro +# stays unexpanded which leads to "invalid regex" error (rhbz#1154067). +%__rdoc_generator_fedora_darkfish_path ^%{?gem_name:%{gem_docdir}/rdoc}%{!?gem_name:this_should_never_match_anything}$ diff --git a/rdoc_generator_fedora_darkfish.req b/rdoc_generator_fedora_darkfish.req new file mode 100644 index 0000000..f3bd61b --- /dev/null +++ b/rdoc_generator_fedora_darkfish.req @@ -0,0 +1,23 @@ +#!/usr/bin/ruby + +module FedoraDarkfishAssetsReq + FEDORA_DARKFISH_ASSETS_DIR = '%{_datadir}/%{name}' + FEDORA_DARKFISH_ASSETS_DIR_REGEXP = Regexp.new "#{FEDORA_DARKFISH_ASSETS_DIR}/.*" + + # Go through all subdirectories and look for symlinks, which corresponds + # to fedora-darkfish template. In that case generate the require for such + # filename. + def self.requires + while filename = gets + filename.strip! + fedora_darkfish_asset = !!Dir.glob("#{filename}/**/*").find do |f| + File.symlink?(f) && File.readlink(f) =~ FEDORA_DARKFISH_ASSETS_DIR_REGEXP + end + puts '%{name}-assets' if fedora_darkfish_asset + end + end +end + +if __FILE__ == $0 + FedoraDarkfishAssetsReq::requires +end |