Thank you, Tomas,

Great investigation.

Your suggested hack really fixed my issue.

On Mon, Jan 23, 2023 at 3:46 PM Tomas Korbar <tkorbar@redhat.com> wrote:
Hello,
since i encountered this in the past and postponed it, I did a bit of a digging and found this:
As you probably found out by now it is caused by package-notes being dependent
on environment variables that are expected to be present during package build.
See the actual package-notes file contents:
$ cat /usr/lib/rpm/redhat/redhat-package-notes
*link:
+ --package-metadata={\"type\":\"rpm\",\"name\":\"%:getenv(RPM_PACKAGE_NAME \",\"version\":\"%:getenv(RPM_PACKAGE_VERSION -%:getenv(RPM_PACKAGE_RELEASE \",\"architecture\":\"%:getenv(RPM_ARCH \",\"osCpe\":\"cpe:/o:fedoraproject:fedora:38\"}))))

I took a look at your test and found out that your test uses rpmbuild to perform
preparation of sources:
        rlRun "rpmbuild -bp libarchive.spec"
        rlRun "rpmbuild -bc libarchive.spec"
        rlRun "popd"

This probably executes configure in a way that configures linking to be
done with "-specs=/usr/lib/rpm/redhat/redhat-package-notes" option and thus
you now need the environment variables that the file mentions. These variables
are defined and exported before build stage in macro defined in file
/usr/lib/rpm/macros and if you would have executed the check phase with
rpmbuild command, you would propably face no issue (did not verify this).
Unfortunately the test performs check manually:
                rlRun "make check &> $TmpDir/make_check.log" 0 "Make check"
                rlRun -s "./libarchive_test"
                rlAssertGrep "Tests failed:[[:blank:]]* 0" $rlRun_LOG
and thus there are no environment variables.
This can be fixed by a little bit of a hack. Add this line:
rlRun 'eval "$(rpm --eval %___build_pre)"; cd ~/rpmbuild/BUILD/libarchive-*' 0 "setting environment"

before the make check and you are good to go. This causes
that needed environment variables will be defined.

I hope that this helps you or based on this information you will be able
to find a better solution.

Best Regards.


On Mon, Jan 23, 2023 at 2:00 PM Mamoru TASAKA <mtasaka@fedoraproject.org> wrote:
Mamoru TASAKA wrote on 2023/01/23 21:54:
> Lukas Javorsky wrote on 2023/01/23 21:39:
>> Hi,
>>
>> I've been looking at our upstreamed test [1] for libarchive package and it
>> started to fail since Fedora 37.
>>
>> The error is: "gcc: fatal error: environment variable 'RPM_ARCH' not defined
>> "
>>
>> Prior to the Fedora 37 the test was passing without any issue.
>>
>> Did anyone here had a similar problem?
>> Or could anyone help me find out what has changed so it's causing this
>> issue?
>>
>> [1]
>> https://src.fedoraproject.org/tests/libarchive/blob/main/f/Sanity/Basic-sanity-test-for-libarchive
>>
>> Thank you so much for your help
>
> Most possibly due to "package note".
>
> `rpmbuild -bc` defines  %{_package_note_flags}, embeds "-specs=/usr/lib/rpm/redhat/redhat-package-notes"
> to LDFLAGS, which needs "RPM_ARCH" environment. During rpmbuild process, this environment is provided,
> but then later "make" process does not define this automatically (because this process is not under
> "rpmbuild"), so embedded "-specs=/usr/lib/rpm/redhat/redhat-package-notes" LDFLAGS complains about
> missing environment.
>
> (Yes, I think this is annoying - sometimes rpmbuild fails with some reason, I try to fix compilation error
>   then try executing "make" locally, then I see linker complains about "'RPM_ARCH' not defined"...)
>
> I usually write "%_package_note_flags %nil" to ~/.rpmmacros, not sure if rpmbuild command line can
> undefine macros.
>

Or maybe changing to "rpmbuild --define '_package_note_flags %nil' -bc libarchive.spec" can fix the
issue you see.

Mamoru
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue


--
S pozdravom/ Best regards

Lukáš Javorský

Software Engineer, Core service - Databases

Red Hat

Purkyňova 115 (TPB-C)

612 00 Brno - Královo Pole

ljavorsk@redhat.com