From 9e30ed1515db8ae862dc08b9d72680344748d98b Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Mon, 5 May 2014 11:30:38 +1000 Subject: [PATCH] add site.less, for defining site-specific Less rules Admins can (either by hand, or in a separate RPM) overwrite the site.less symlink to point at their own custom Less rules, which will be included with Beaker's Less sources when generating CSS. Ideally this would just be a config option of extra filenames which are appended to the 'css' assets bundle. Unfortunately that doesn't work because webassets compiles each Less source file separately, which prevents the site Less rules from overriding or cross-referencing the Beaker ones. In future Less might support @import globs [1] which would allow us to @import site rules from a defined directory. But until then we have to do this ghost symlink hackery. [1] https://github.com/less/less.js/issues/1181 Bug: 1012224 Change-Id: I86f6d6987fd66988a46ec7372bbc3a249f015b46 --- Server/assets/site.less | 1 + Server/assets/style.less | 5 +++++ Server/bkr/server/assets.py | 2 ++ beaker.spec | 5 +++++ 4 files changed, 13 insertions(+) create mode 120000 Server/assets/site.less diff --git a/Server/assets/site.less b/Server/assets/site.less new file mode 120000 index 000000000..dc1dc0cde --- /dev/null +++ b/Server/assets/site.less @@ -0,0 +1 @@ +/dev/null \ No newline at end of file diff --git a/Server/assets/style.less b/Server/assets/style.less index 59c1ea375..38d92a179 100644 --- a/Server/assets/style.less +++ b/Server/assets/style.less @@ -135,3 +135,8 @@ input.tt-hint { @import "reserve-workflow.less"; @import "job-matrix.less"; @import "system.less"; + +// Site-specific styles. The beaker-server package creates site.less as +// a symlink to /dev/null if it doesn't exist. Admins can overwrite the symlink +// to point at their own custom LESS instead. +@import "site.less"; diff --git a/Server/bkr/server/assets.py b/Server/bkr/server/assets.py index 8f5fb868d..fee0ef45a 100644 --- a/Server/bkr/server/assets.py +++ b/Server/bkr/server/assets.py @@ -108,6 +108,8 @@ def list_asset_sources(source_dir): for bundle in env: for path in get_all_bundle_files(bundle, env): paths.append(os.path.relpath(path, source_dir)) + # site.less should be skipped because it's a symlink + paths.remove('site.less') # font-awesome is currently not managed by webassets because webassets # breaks on non-UTF8 input files paths.extend([ diff --git a/beaker.spec b/beaker.spec index 95bcfecff..e79f6a37f 100644 --- a/beaker.spec +++ b/beaker.spec @@ -352,6 +352,10 @@ chown root:root %{_localstatedir}/log/%{name}/*.log >/dev/null 2>&1 || : chmod go-w %{_localstatedir}/log/%{name}/*.log >/dev/null 2>&1 || : # Restart rsyslog so that it notices the config which we ship /sbin/service rsyslog condrestart >/dev/null 2>&1 || : +# Create symlink for site.less (this is ghosted so that other packages can overwrite it) +if [ ! -f %{_datadir}/bkr/server/assets/site.less ] ; then + ln -s /dev/null %{_datadir}/bkr/server/assets/site.less || : +fi %endif %if %{with labcontroller} @@ -469,6 +473,7 @@ rm -rf %{_var}/lib/beaker/osversion_data %attr(-,apache,root) %dir %{_datadir}/bkr %attr(-,apache,root) %{_datadir}/bkr/beaker-server.wsgi %attr(-,apache,root) %{_datadir}/bkr/server +%ghost %attr(0777,root,root) %{_datadir}/bkr/server/assets/site.less %attr(0660,apache,root) %config(noreplace) %{_sysconfdir}/%{name}/server.cfg %dir %{_localstatedir}/log/%{name} %dir %{_localstatedir}/cache/%{name}