mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 23:55:23 +00:00
spec: indent %if to make it easier to see conditions
Nested conditionals are hard to read if they are not indented. We can't add arbitrary whitespace to everything in spec files, but we CAN add spaces before %if and %define. Use this trick, plus a fancy sed script that rewrites a spec file into a C file, so we can use cppi to keep our spec file nice. For reference, the sed script converts code like: |# RHEL-5 builds are client-only for s390, ppc |%if 0%{?rhel} == 5 | %ifnarch %{ix86} x86_64 ia64 | %define client_only 1 | %endif |%endif into the following for cppi: |// # RHEL-5 builds are client-only for s390, ppc |#if a // 0%{?rhel} == 5 |# if a // %{ix86} x86_64 ia64 |# define client_only 1 |# endif |#endif and errors from 'make syntax-check' look like: spec_indentation cppi: mingw-libvirt.spec.in: line 130: not properly indented maint.mk: incorrect preprocessor indentation * libvirt.spec.in: Add some indentation to make it easier to follow various conditionals. * mingw-libvirt-spec.in: Likewise. * cfg.mk (sc_spec_indentation): New syntax check to enforce it.
This commit is contained in:
parent
790f912b46
commit
c8f79c9b29
19
cfg.mk
19
cfg.mk
@ -1,5 +1,5 @@
|
||||
# Customize Makefile.maint. -*- makefile -*-
|
||||
# Copyright (C) 2008-2012 Red Hat, Inc.
|
||||
# Copyright (C) 2008-2013 Red Hat, Inc.
|
||||
# Copyright (C) 2003-2008 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@ -623,6 +623,23 @@ sc_preprocessor_indentation:
|
||||
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
|
||||
fi
|
||||
|
||||
# Enforce similar spec file indentation style, by running cppi on a
|
||||
# (comment-only) C file that mirrors the same layout as the spec file.
|
||||
sc_spec_indentation:
|
||||
@if cppi --version >/dev/null 2>&1; then \
|
||||
for f in $$($(VC_LIST_EXCEPT) | grep '\.spec\.in$$'); do \
|
||||
sed -e 's|#|// #|; s|%ifn*\(arch\)* |#if a // |' \
|
||||
-e 's/%\(else\|endif\|define\)/#\1/' \
|
||||
-e 's/^\( *\)\1\1\1#/#\1/' \
|
||||
-e 's|^\( *[^#/ ]\)|// \1|; s|^\( */[^/]\)|// \1|' $$f \
|
||||
| cppi -a -c 2>&1 | sed "s|standard input|$$f|"; \
|
||||
done | { if grep . >&2; then false; else :; fi; } \
|
||||
|| { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
|
||||
exit 1; }; \
|
||||
else \
|
||||
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
|
||||
fi
|
||||
|
||||
sc_copyright_format:
|
||||
@require='Copyright .*Red 'Hat', Inc\.' \
|
||||
containing='Copyright .*Red 'Hat \
|
||||
|
@ -886,7 +886,7 @@ The Libxl driver plugin for the libvirtd daemon, providing
|
||||
an implementation of the hypervisor driver APIs using
|
||||
Libxl
|
||||
%endif
|
||||
%endif
|
||||
%endif # %{with_driver_modules}
|
||||
|
||||
|
||||
|
||||
@ -1007,7 +1007,7 @@ Requires: xen
|
||||
Server side daemon and driver required to manage the virtualization
|
||||
capabilities of XEN
|
||||
%endif
|
||||
%endif
|
||||
%endif # %{with_libvirtd}
|
||||
|
||||
%package client
|
||||
Summary: Client side library and utilities of the libvirt library
|
||||
@ -1565,9 +1565,7 @@ if test $1 -eq 1 && test ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ;
|
||||
ln -s ../default.xml %{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml
|
||||
fi
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%if %{with_libvirtd}
|
||||
%if %{with_systemd}
|
||||
%triggerun -- libvirt < 0.9.4
|
||||
%{_bindir}/systemd-sysv-convert --save libvirtd >/dev/null 2>&1 ||:
|
||||
@ -1579,7 +1577,7 @@ fi
|
||||
/sbin/chkconfig --del libvirtd >/dev/null 2>&1 || :
|
||||
/bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || :
|
||||
%endif
|
||||
%endif
|
||||
%endif # %{with_libvirtd}
|
||||
|
||||
%preun client
|
||||
|
||||
@ -1856,7 +1854,7 @@ fi
|
||||
%defattr(-, root, root)
|
||||
%{_libdir}/%{name}/connection-driver/libvirt_driver_libxl.so
|
||||
%endif
|
||||
%endif
|
||||
%endif # %{with_driver_modules}
|
||||
|
||||
%if %{with_qemu_tcg}
|
||||
%files daemon-qemu
|
||||
@ -1882,7 +1880,7 @@ fi
|
||||
%files daemon-xen
|
||||
%defattr(-, root, root)
|
||||
%endif
|
||||
%endif
|
||||
%endif # %{with_libvirtd}
|
||||
|
||||
%if %{with_sanlock}
|
||||
%files lock-sanlock
|
||||
|
Loading…
Reference in New Issue
Block a user