Skip to content

Commit 783d2fa

Browse files
authored
Merge pull request #3231 from jimklimov/issue-1209
Update OBS packaging recipes with a preinstallimage helper
2 parents 8304a56 + 9fcb09e commit 783d2fa

File tree

5 files changed

+72
-3
lines changed

5 files changed

+72
-3
lines changed

docs/nut.dict

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 3603 utf-8
1+
personal_ws-1.1 en 3606 utf-8
22
AAC
33
AAS
44
ABI
@@ -1023,6 +1023,7 @@ Powervar
10231023
Powervar's
10241024
Powerwell
10251025
Prachi
1026+
Preinstall
10261027
Prereqs
10271028
PresentStatus
10281029
Priv
@@ -1996,6 +1997,7 @@ drvpath
19961997
drwxr
19971998
drwxrwx
19981999
ds
2000+
dsc
19992001
dsi
20002002
dsr
20012003
dsssl
@@ -2886,6 +2888,7 @@ pragma
28862888
pragmas
28872889
pre
28882890
preLaunchTask
2891+
preinstallimage
28892892
prepend
28902893
prepended
28912894
preprocess

scripts/obs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_preinstallimage

scripts/obs/Makefile.am

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,57 @@ EXTRA_DIST += \
9696

9797
SPELLCHECK_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

119170
CLEANFILES = *-spellchecked
171+
CLEANFILES += _preinstallimage
120172

121173
MAINTAINERCLEANFILES = Makefile.in .dirstamp

scripts/obs/README.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ For some historical and/or practical details see:
4848

4949
* https://github.com/networkupstools/nut/issues/1209
5050

51+
== Preinstall images
52+
53+
OBS builds can be sped up by use of `preinstallimage` recipes seen in the
54+
sibling or "upstream" build dependency repositories for a built project,
55+
if such image contains a subset of the packages that the current build
56+
aims to use.
57+
58+
TODO: Document actually getting PR builds to see such prepared images.
59+
60+
A recipe can be generated from current `nut.spec` and `nut.dsc` files
61+
via `make _preinstallimage` and uploaded into a dedicated package near
62+
the `nut` package in an OBS project.
63+
5164
== Other notes
5265

5366
The recipe files themselves would likely cross-pollinate with popular

scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ smf_registerInstance() {
810810
drivers=*|*,drivers=*)
811811
OTHERLIST="`upsconf_list_dev_drv_socket_checksum`" || OTHERLIST=""
812812
# Not double-quoting here to iterate the string tokens:
813-
for DEPDRV in `echo "${_MED}" | $SED -e 's/^\(.*,d\|d\)rivers=//' -e 's/,/ /g'` ; do
813+
for DEPDRV in `echo "${_MED}" | $SED -e 's/^drivers=//' -e 's/^.*,drivers=//' -e 's/,/ /g'` ; do
814814
case "${DEPDRV}" in
815815
*-*) # May be "drivername-upsname", where either sub-string
816816
# may have dashes inside too; try to find the right one:
@@ -1096,7 +1096,7 @@ systemd_registerInstance() {
10961096
drivers=*|*,drivers=*)
10971097
OTHERLIST="`upsconf_list_dev_drv_socket_checksum`" || OTHERLIST=""
10981098
# Not double-quoting here to iterate the string tokens:
1099-
for DEPDRV in `echo "${_MED}" | $SED -e 's/^\(.*,d\|d\)rivers=//' -e 's/,/ /g'` ; do
1099+
for DEPDRV in `echo "${_MED}" | $SED 's/^drivers=//' -e 's/^.*,drivers=//' -e 's/,/ /g'` ; do
11001100
case "${DEPDRV}" in
11011101
*-*) # May be "drivername-upsname", where either sub-string
11021102
# may have dashes inside too; try to find the right one:

0 commit comments

Comments
 (0)