@@ -96,6 +96,57 @@ EXTRA_DIST += \
9696
9797SPELLCHECK_SRC = README.adoc
9898
99+ # Produce an OBS preinstallimage recipe file from our SPEC and DSC resources,
100+ # to speed up PR and stable branch iteration builds (output of this processing
101+ # should be stored as a sibling OBS project "preinstallimage-nut" in the OBS
102+ # server). Note that syntax for "one-of-options" installation accepted by deb
103+ # and rpm tooling differs: for DEB we need to list them without parentheses
104+ # and without spaces around the pipe character. Parentheses around version
105+ # constraints seem to be confusing, but spaces around comparison operators
106+ # seem to be optional, at least for the recipe syntax parser.
107+ # You can debug stacks of calls here by adding `| tee -a /dev/stderr \` layers
108+ _preinstallimage : nut.spec nut.dsc Makefile
109+ @echo " GENERATE-RECIPE $@ " ; \
110+ (echo ' Name: preinstallimage-@PACKAGE_NAME@' ; \
111+ echo ' ### Start of "if RPM"' ; \
112+ echo ' %if 0%{?rhel_version} || 0%{?rhel} || 0%{?sle_version} || 0%{?suse_version} || 0%{?centos_version} || 0%{?centos} || 0%{?fedora_version} || 0%{?fedora} || 0%{?opensuse_version}' ; \
113+ cat nut.spec \
114+ | $(EGREP ) ' (% *(if|else|endif|define)|Requires:|Ignore:|Prefer:)' \
115+ | $(EGREP ) -v ' (%{name} = %{version}|%{_s*bindir}/|python-base)' \
116+ | $(SED ) -e ' s/^Requires:/BuildRequires:/' ; \
117+ echo ' %endif' ; \
118+ echo ' ### End of "if RPM"' ; \
119+ echo ' # ---- blank ----' ; \
120+ echo ' ### Start of "if DEB"' ; \
121+ echo ' %if 0%{?debian_version} || 0%{?debian} || 0%{?ubuntu_version} || 0%{?ubuntu}' ; \
122+ awk ' \
123+ /^Build-Depends(-Indep)? :/ { \
124+ inBD=1; \
125+ sub(/^Build-Depends(-Indep)? :[[:space:]]* /, " " ); \
126+ buf = (buf ? buf " ," : " " ) $$ 0; \
127+ next; \
128+ }; \
129+ inBD && /^[[:space:]]+/ { \
130+ buf = buf " " $$ 0; \
131+ next; \
132+ }; \
133+ inBD { inBD=0; next; }; \
134+ END { print buf }; \
135+ ' nut.dsc \
136+ | $(SED ) \
137+ -e ' s/[[:space:]]*//g' \
138+ -e ' s/,/\n/g' \
139+ -e ' s/(\([^)][^)]*\)\(>\|<\|=\|>=\|<=\|==\|!=\)\([^)][^)]*\))/\1\2\3/g' \
140+ -e ' s/\[[^]]*\]//g' \
141+ -e ' s/<[^>]*>//g' \
142+ -e ' s/:any\|:native//g' \
143+ | $(GREP ) -v ' ^\$$' \
144+ | awk ' NF { printf "BuildRequires: %s\n", $$0 }' ; \
145+ echo ' %endif' ; \
146+ echo ' ### End of "if DEB"' ; \
147+ ) > ' $@' .tmp && [ -s ' $@' .tmp ] && mv -f ' $@' .tmp ' $@'
148+
149+
99150# NOTE: Due to portability, we do not use a GNU percent-wildcard extension.
100151# We also have to export some variables that may be tainted by relative
101152# paths when parsing the other makefile (e.g. MKDIR_P that may be defined
@@ -117,5 +168,6 @@ spellcheck spellcheck-interactive spellcheck-sortdict:
117168 +$(MAKE ) $(AM_MAKEFLAGS ) -f $(top_builddir ) /docs/Makefile MKDIR_P=" $( MKDIR_P) " builddir=" $( builddir) " srcdir=" $( srcdir) " top_builddir=" $( top_builddir) " top_srcdir=" $( top_srcdir) " SPELLCHECK_SRC=" $( SPELLCHECK_SRC) " SPELLCHECK_SRCDIR=" $( srcdir) " SPELLCHECK_BUILDDIR=" $( builddir) " $@
118169
119170CLEANFILES = *-spellchecked
171+ CLEANFILES += _preinstallimage
120172
121173MAINTAINERCLEANFILES = Makefile.in .dirstamp
0 commit comments