Sorry Actual behaviour is different.
When I've executed above commands I've already had changed `%__spec_check_pre` 
in /usr/lib/rpm/redhat/macros.

<details>
<summary>Result with defined %bcond_with</summary>

```spec
%bcond_with     check

Summary:        bcond test
Name:           test
Version:        1
Release:        1
License:        foo

%description
bcond test.

%prep

# Add handle --{with|without} check
%define __spec_check_pre \
        %{!?with_check:echo "%%check disabled."; exit 0} \
        %{___build_pre}

%check
echo "%{name} package test suite"
exit 1

%files
```

```console
[tkloczko@pers-jacek SPECS]$ rpmbuild -bi test.spec
warning: source_date_epoch_from_changelog set but %changelog is missing
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.4hXN9D
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ RPM_EC=0
++ jobs -p
+ exit 0
Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.XMbSqT
%check disabled.
Processing files: test-1-1.x86_64
Checking for unpackaged file(s): /usr/lib/rpm/check-files 
/home/tkloczko/rpmbuild/BUILDROOT/test-1-1.x86_64
```
</details>

Which is as expected

<details>
<summary>Result with defined %bcondout_with</summary>

```spec
%bcond_without  check

Summary:        bcond test
Name:           test
Version:        1
Release:        1
License:        foo

%description
bcond test.

%prep

# Add handle --{with|without} check
%define __spec_check_pre \
        %{!?with_check:echo "%%check disabled."; exit 0} \
        %{___build_pre}

%check
echo "%{name} package test suite"
exit 1

%files
```

```console
[tkloczko@pers-jacek SPECS]$ rpmbuild -bi test.spec
warning: source_date_epoch_from_changelog set but %changelog is missing
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.wJqF1l
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ RPM_EC=0
++ jobs -p
+ exit 0
Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.pKu6HS
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ echo 'test package test suite'
test package test suite
+ exit 1
error: Bad exit status from /var/tmp/rpm-tmp.pKu6HS (%check)
```
</details>

Which is as expected as well.

<details>
<summary>Result without defined bcond</summary>

```spec
Summary:        bcond test
Name:           test
Version:        1
Release:        1
License:        foo

%description
bcond test.

%prep

# Add handle --{with|without} check
%define __spec_check_pre \
        %{!?with_check:echo "%%check disabled."; exit 0} \
        %{___build_pre}

%check
echo "%{name} package test suite"
exit 1

%files
```

```console
[tkloczko@pers-jacek SPECS]$ rpmbuild -bi test.spec
warning: source_date_epoch_from_changelog set but %changelog is missing
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.KZbK71
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ RPM_EC=0
++ jobs -p
+ exit 0
Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.6PTPuy
%check disabled.
Processing files: test-1-1.x86_64
Checking for unpackaged file(s): /usr/lib/rpm/check-files 
/home/tkloczko/rpmbuild/BUILDROOT/test-1-1.x86_64
```
</details>

Incorrect result because without define `%bcond_{with|without} check` such 
solution should not be disabling %check.

In other words it is not issue with %__spec_check_pre redefinition but above 
approach with globally redefines %__spec_check_pre does not work as expected 
(which is not rpm issue).

Q: how to modify above to have expected behaviour? 🤔 


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

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

Reply via email to