| |
@@ -231,3 +231,39 @@
|
| |
# https://dev.mysql.com/downloads/mysql/5.1.html
|
| |
Source: mysql-5.1.31.tar.gz
|
| |
....
|
| |
+
|
| |
+ == Do not conditionalize Sources
|
| |
+
|
| |
+ When building an SRPM, it is critical that all of the sources are present, irrespective of the platform on which the SRPM is generated. For example, the following code *does not work* (the way you might expect):
|
| |
+
|
| |
+ ....
|
| |
+ %if 0%{?fedora} < 35
|
| |
+ Source1: mysource-old.tar.bz2
|
| |
+ Patch1: oldpatch.patch
|
| |
+ %else
|
| |
+ Source1: mysource-ng.tar.bz2
|
| |
+ Patch1: ngpatch.patch
|
| |
+ %endif
|
| |
+ ....
|
| |
+
|
| |
+ If you were to build this SRPM from a Fedora 34 host (`rpmbuild -bs mysource.spec`), the resulting SRPM would carry `mysource-old.tar.bz2` and `oldpatch.patch`. However, if you then try to use this SRPM to build for Fedora 35, the operation would fail because `mysource-ng.tar.bz2` is not available.
|
| |
+
|
| |
+ The correct behavior is to always carry all of the sources that might be used in the build and then conditionalize the *usage* of them instead. For example:
|
| |
+
|
| |
+ ```
|
| |
+ Source1: mysource-old.tar.bz2
|
| |
+ Source2: mysource-ng.tar.bz2
|
| |
+
|
| |
+ Patch1: oldpatch.patch
|
| |
+ Patch2: ngpatch.patch
|
| |
+ ...
|
| |
+ %prep
|
| |
+ ...
|
| |
+ %if 0%{?fedora} < 35
|
| |
+ tar xf %{SOURCE1}
|
| |
+ %patch1 -p1
|
| |
+ %else
|
| |
+ tar xf %{SOURCE2}
|
| |
+ %patch2 -p1
|
| |
+ %endif
|
| |
+ ```
|
| |
\ No newline at end of file
|
| |
IMO, it is bad practice to use
tar
in specfiles. What do you all think about amending this example to use the proper%setup
invocation?