Skip to content

Commit

Permalink
Refs #18539 - Introduce foreman_plugin_files in foreman.macros
Browse files Browse the repository at this point in the history
This allows plugins to use %files -f foreman_plugin_files and
automatically get the correct files section, based on the
foreman_bundlerd_file and foreman_precompile_plugin macros (and their
options).
  • Loading branch information
ekohl committed Aug 30, 2024
1 parent cf7f591 commit 133fd0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 1 addition & 10 deletions gem2rpm/foreman_plugin.spec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ find %{buildroot}%{gem_instdir}/<%= spec.bindir %> -type f | xargs chmod a+x
%foreman_precompile_plugin <%= precompile_flags.strip %>
<% end -%>
%files
%files -f foreman_plugin_files
%dir %{gem_instdir}
<% unless spec.executables.nil? or spec.executables.empty? -%>
<% for f in spec.executables -%>
Expand All @@ -153,18 +153,9 @@ find %{buildroot}%{gem_instdir}/<%= spec.bindir %> -type f | xargs chmod a+x
<% end -%>
%exclude %{gem_cache}
%{gem_spec}
%{foreman_bundlerd_plugin}
<% if has_assets || has_webpack -%>
%{foreman_assets_plugin}
%{foreman_assets_foreman}
<% end -%>
<% if has_cronjob -%>
%config(noreplace) %{_sysconfdir}/cron.d/%{gem_name}
<% end -%>
<% if has_webpack -%>
%{foreman_webpack_plugin}
%{foreman_webpack_foreman}
<% end -%>
<% if doc_subpackage -%>
%files doc
Expand Down
14 changes: 13 additions & 1 deletion packages/foreman/foreman/foreman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%global dynflow_sidekiq_service_name dynflow-sidekiq@
%global rake /usr/bin/rake

%global release 1
%global release 2
%global prereleasesource develop
%global prerelease %{?prereleasesource}

Expand Down Expand Up @@ -678,6 +678,7 @@ cat > %{buildroot}%{_sysconfdir}/rpm/macros.%{name}-plugin << EOF
# -n<plugin_name> Overrides default of gem_name
%%%{name}_bundlerd_file(n:) \\
mkdir -p %%{buildroot}%%{%{name}_bundlerd_dir} \\
echo %%{%{name}_bundlerd_dir}/%%{-n*}%%{!?-n:%%{gem_name}} >> %%%{name}_plugin_files \\
cat <<GEMFILE > %%{buildroot}%%{%{name}_bundlerd_dir}/%%{-n*}%%{!?-n:%%{gem_name}}.rb \\
gem '%%{-n*}%%{!?-n:%%{gem_name}}' \\
GEMFILE
Expand Down Expand Up @@ -707,6 +708,7 @@ chown foreman:foreman %%{foreman_dir}/tmp/restart_required_changed_plugins || :
# -a Prebuild apipie cache
# -s Precompile assets
%%%{name}_precompile_plugin(r:n:as) \\
touch %%%{name}_plugin_files \\
mkdir -p ./%{_datadir} \\
cp -r %%{%{name}_dir} ./%{_datadir} || echo 0 \\
mkdir -p ./%{_localstatedir}/lib/%{name} \\
Expand Down Expand Up @@ -735,16 +737,23 @@ popd \\
rm -rf ./usr \\
%%{?-a:mkdir -p %%{buildroot}%%{foreman_dir}/public/apipie-cache/plugin} \\
%%{?-a:ln -s %%{%{name}_apipie_cache_plugin} %%{buildroot}%%{%{name}_apipie_cache_foreman}} \\
%%{?-a:echo %%%%dir %%{buildroot}%%{%{name}_apipie_cache_plugin} >> %%%{name}_plugin_files} \\
%%{?-a:echo %%{buildroot}%%{%{name}_apipie_cache_foreman} >> %%%{name}_plugin_files} \\
%%{?-s:[ -e %%{buildroot}%%{%{name}_assets_plugin} ] && mkdir -p %%{buildroot}%%{foreman_dir}/public/assets} \\
%%{?-s:[ -e %%{buildroot}%%{%{name}_assets_plugin} ] && ln -s %%{%{name}_assets_plugin} %%{buildroot}%%{%{name}_assets_foreman}} \\
%%{?-s:[ -e %%{buildroot}%%{%{name}_assets_plugin} ] && echo %%%%dir %%{buildroot}%%{%{name}_assets_plugin} >> %%%{name}_plugin_files} \\
%%{?-s:[ -e %%{buildroot}%%{%{name}_assets_plugin} ] && echo %%{buildroot}%%{%{name}_assets_foreman} >> %%%{name}_plugin_files} \\
%%{?-s:[ -e %%{buildroot}%%{%{name}_webpack_plugin} ] && mkdir -p %%{buildroot}%%{foreman_dir}/public/webpack} \\
%%{?-s:[ -e %%{buildroot}%%{%{name}_webpack_plugin} ] && ln -s %%{%{name}_webpack_plugin} %%{buildroot}%%{%{name}_webpack_foreman}} \\
%%{?-s:[ -e %%{buildroot}%%{%{name}_webpack_plugin} ] && echo %%%%dir %%{buildroot}%%{%{name}_webpack_plugin} >> %%%{name}_plugin_files} \\
%%{?-s:[ -e %%{buildroot}%%{%{name}_webpack_plugin} ] && echo %%{buildroot}%%{%{name}_webpack_foreman} >> %%%{name}_plugin_files} \\
%%{?-s:rm -f %%{buildroot}%%{%{name}_webpack_plugin}/*.js.map} \\
%%{?-s:rm -f %%{buildroot}%%{gem_instdir}/public/webpack/foreman-vendor.*} \\
%%{?-s:rm -rf %%{buildroot}%%{gem_instdir}/public/webpack/fonts} \\
%%{?-s:rm -rf %%{buildroot}%%{gem_instdir}/public/webpack/images}
EOF

# TODO: exclude package.json & webpack above?

%clean
rm -rf %{buildroot}
Expand Down Expand Up @@ -863,6 +872,9 @@ exit 0
%systemd_postun %{name}.socket

%changelog
* Fri Aug 30 2024 Ewoud Kohl van Wijngaarden <[email protected]> - 3.13.0-0.2.develop
- Introduce foreman_plugin_files file to plugins to include

* Tue Aug 20 2024 Patrick Creech <[email protected]> - 3.13.0-0.1.develop
- Bump version to 3.13-develop

Expand Down

0 comments on commit 133fd0e

Please sign in to comment.