blob: 724799915531960246443089a2280554832e350a [file] [log] [blame]
Oliver Smith449dae82022-08-19 15:22:57 +02001#!/bin/sh -ex
2
3if ! [ -d /home/$BUILDUSER/rpmbuild/SOURCES ]; then
4 set +x
5 echo "ERROR: rpmdev-setuptree did not run"
6 echo "If this is an rpm based system and you want to build the package"
7 echo "here, run rpmdev-setuptree. Otherwise consider building the"
8 echo "package in docker (-d)."
9 exit 1
10fi
11
12yum_builddep="yum-builddep"
13if [ -n "$INSIDE_DOCKER" ]; then
14 yum_builddep="yum-builddep -y"
15fi
16
17spec="$(basename "$(find _temp/srcpkgs/"$PACKAGE" -name '*.spec')")"
18
19su "$BUILDUSER" -c "cp _temp/srcpkgs/$PACKAGE/$spec ~/rpmbuild/SPECS"
20su "$BUILDUSER" -c "cp _temp/srcpkgs/$PACKAGE/*.tar.* ~/rpmbuild/SOURCES"
21su "$BUILDUSER" -c "cp _temp/srcpkgs/$PACKAGE/rpmlintrc ~/rpmbuild/SOURCES"
Oliver Smith13b76cc2022-11-03 12:20:30 +010022su "$BUILDUSER" -c "cp /obs/data/rpmmacros ~/.rpmmacros"
Oliver Smith449dae82022-08-19 15:22:57 +020023
Oliver Smithcdd4eec2023-05-19 10:14:24 +020024# Force refresh of package index data (OS#6038)
Oliver Smith91a79bd2024-05-08 11:30:18 +020025if command -v dnf; then
26 dnf makecache --refresh
27else
28 yum clean expire-cache
29fi
30
31case "$DISTRO" in
32 centos:7)
33 # HACK: remove pkg-config as centos7 has pkgconfig instead
34 # (which will get pulled in automatically). This could be
35 # solved more elegantly, but we only build very few centos7
36 # packages, so let's not spend too much time on this. In OBS
37 # this is handled in the centos7 prjconf:
38 # https://build.opensuse.org/projects/CentOS:CentOS-7/prjconf
39 sed -i '/^BuildRequires:.*pkg-config/d' "/home/$BUILDUSER/rpmbuild/SPECS/$spec"
40 ;;
41esac
Oliver Smithcdd4eec2023-05-19 10:14:24 +020042
Oliver Smith449dae82022-08-19 15:22:57 +020043$yum_builddep "/home/$BUILDUSER/rpmbuild/SPECS/$spec"
44
Oliver Smith15777112023-10-05 18:47:11 +020045if [ -n "$INSIDE_DOCKER" ]; then
46 ip link set eth0 down
47fi
48
Oliver Smith449dae82022-08-19 15:22:57 +020049su "$BUILDUSER" -c "rpmbuild -bb ~/rpmbuild/SPECS/$spec"
50
51# Make built rpms available outside of docker
52if [ -n "$INSIDE_DOCKER" ]; then
53 su "$BUILDUSER" -c "mv ~/rpmbuild/RPMS/*/*.rpm _temp/binpkgs/"
54fi
Oliver Smith4fe56c02022-12-08 15:27:05 +010055
56# Show contents
57cd _temp/binpkgs
58for i in *.rpm; do
59 rpm -qlp "$i"
60done