Oliver Smith | 449dae8 | 2022-08-19 15:22:57 +0200 | [diff] [blame] | 1 | #!/bin/sh -ex |
| 2 | |
| 3 | if ! [ -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 |
| 10 | fi |
| 11 | |
| 12 | yum_builddep="yum-builddep" |
| 13 | if [ -n "$INSIDE_DOCKER" ]; then |
| 14 | yum_builddep="yum-builddep -y" |
| 15 | fi |
| 16 | |
| 17 | spec="$(basename "$(find _temp/srcpkgs/"$PACKAGE" -name '*.spec')")" |
| 18 | |
| 19 | su "$BUILDUSER" -c "cp _temp/srcpkgs/$PACKAGE/$spec ~/rpmbuild/SPECS" |
| 20 | su "$BUILDUSER" -c "cp _temp/srcpkgs/$PACKAGE/*.tar.* ~/rpmbuild/SOURCES" |
| 21 | su "$BUILDUSER" -c "cp _temp/srcpkgs/$PACKAGE/rpmlintrc ~/rpmbuild/SOURCES" |
Oliver Smith | 13b76cc | 2022-11-03 12:20:30 +0100 | [diff] [blame] | 22 | su "$BUILDUSER" -c "cp /obs/data/rpmmacros ~/.rpmmacros" |
Oliver Smith | 449dae8 | 2022-08-19 15:22:57 +0200 | [diff] [blame] | 23 | |
Oliver Smith | cdd4eec | 2023-05-19 10:14:24 +0200 | [diff] [blame] | 24 | # Force refresh of package index data (OS#6038) |
Oliver Smith | 91a79bd | 2024-05-08 11:30:18 +0200 | [diff] [blame] | 25 | if command -v dnf; then |
| 26 | dnf makecache --refresh |
| 27 | else |
| 28 | yum clean expire-cache |
| 29 | fi |
| 30 | |
| 31 | case "$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 | ;; |
| 41 | esac |
Oliver Smith | cdd4eec | 2023-05-19 10:14:24 +0200 | [diff] [blame] | 42 | |
Oliver Smith | 449dae8 | 2022-08-19 15:22:57 +0200 | [diff] [blame] | 43 | $yum_builddep "/home/$BUILDUSER/rpmbuild/SPECS/$spec" |
| 44 | |
Oliver Smith | 1577711 | 2023-10-05 18:47:11 +0200 | [diff] [blame] | 45 | if [ -n "$INSIDE_DOCKER" ]; then |
| 46 | ip link set eth0 down |
| 47 | fi |
| 48 | |
Oliver Smith | 449dae8 | 2022-08-19 15:22:57 +0200 | [diff] [blame] | 49 | su "$BUILDUSER" -c "rpmbuild -bb ~/rpmbuild/SPECS/$spec" |
| 50 | |
| 51 | # Make built rpms available outside of docker |
| 52 | if [ -n "$INSIDE_DOCKER" ]; then |
| 53 | su "$BUILDUSER" -c "mv ~/rpmbuild/RPMS/*/*.rpm _temp/binpkgs/" |
| 54 | fi |
Oliver Smith | 4fe56c0 | 2022-12-08 15:27:05 +0100 | [diff] [blame] | 55 | |
| 56 | # Show contents |
| 57 | cd _temp/binpkgs |
| 58 | for i in *.rpm; do |
| 59 | rpm -qlp "$i" |
| 60 | done |