> > `%dnl` already works for this purpose, doesn't it?
> 
> It doesn't, because this check happens before macro expansion.

This fails:

~~~
$ cat license-subpackages.spec
Summary: Demonstration package for mining licenses from subpackages
Name: license-subpackages
Version: 1
Release: 1%{?dist}
License: BSD-3-Clause AND MIT

%description
Using Lua and "metaprograming", it is possible to do magic with .spec files
such as collecting licenses from subpackages.


%if 0 # comment
%package foo
Summary: foo subpackage
License: BSD-3-Clause

%description foo
This foo subpackage

%files foo
%endif


%changelog
* Wed Mar 13 2024 Vít Ondruch <vondr...@redhat.com>
- Initial version

$ fedpkg --release f41 srpm
Failed to get repository name from Git url or pushurl
Failed to get ns from Git url or pushurl
error: parse error in expression:  0 # comment
error:                               ^
error: /home/vondruch/license-subpackages/license-subpackages.spec:12: bad %if 
condition:  0 # comment
error: query of specfile 
/home/vondruch/license-subpackages/license-subpackages.spec failed, can't parse

Could not execute srpm: Could not get n-v-r-e from 
/home/vondruch/license-subpackages/license-subpackages.spec

$ rpm -q rpm
rpm-4.19.1.1-1.fc40.x86_64
~~~

While this passes:

~~~
$ diff -u license-subpackages.spec{.orig,}
--- license-subpackages.spec.orig       2024-03-27 14:05:58.511376998 +0100
+++ license-subpackages.spec    2024-03-27 14:06:05.735409184 +0100
@@ -9,7 +9,7 @@
 such as collecting licenses from subpackages.
 
 
-%if 0 # comment
+%if 0 %dnl # comment
 %package foo
 Summary: foo subpackage
 License: BSD-3-Clause
~~~

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/2996#issuecomment-2022727660
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/2996/c2022727...@github.com>
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to