aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/obs/data/build_rpm.sh
blob: a73d16467797bccc4e561ee7a750bfe0de0b4d9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh -ex

if ! [ -d /home/$BUILDUSER/rpmbuild/SOURCES ]; then
	set +x
	echo "ERROR: rpmdev-setuptree did not run"
	echo "If this is an rpm based system and you want to build the package"
	echo "here, run rpmdev-setuptree. Otherwise consider building the"
	echo "package in docker (-d)."
	exit 1
fi

yum_builddep="yum-builddep"
if [ -n "$INSIDE_DOCKER" ]; then
	yum_builddep="yum-builddep -y"
fi

spec="$(basename "$(find _temp/srcpkgs/"$PACKAGE" -name '*.spec')")"

su "$BUILDUSER" -c "cp _temp/srcpkgs/$PACKAGE/$spec ~/rpmbuild/SPECS"
su "$BUILDUSER" -c "cp _temp/srcpkgs/$PACKAGE/*.tar.* ~/rpmbuild/SOURCES"
su "$BUILDUSER" -c "cp _temp/srcpkgs/$PACKAGE/rpmlintrc ~/rpmbuild/SOURCES"
su "$BUILDUSER" -c "cp /obs/data/rpmmacros ~/.rpmmacros"

# Force refresh of package index data (OS#6038)
dnf makecache --refresh

$yum_builddep "/home/$BUILDUSER/rpmbuild/SPECS/$spec"

if [ -n "$INSIDE_DOCKER" ]; then
	ip link set eth0 down
fi

su "$BUILDUSER" -c "rpmbuild -bb ~/rpmbuild/SPECS/$spec"

# Make built rpms available outside of docker
if [ -n "$INSIDE_DOCKER" ]; then
	su "$BUILDUSER" -c "mv ~/rpmbuild/RPMS/*/*.rpm _temp/binpkgs/"
fi

# Show contents
cd _temp/binpkgs
for i in *.rpm; do
	rpm -qlp "$i"
done