osmith has uploaded this change for review.

View Change

obs: build_binpkg: no network during build

Simulate that we don't have network during package builds in gerrit
verifications, like it is the case when the packages will be built by
OBS.

Depends: osmo-epdg I2bb0b5f608cd5d9a24c2a367425c524447bd002c
Change-Id: I00282552e9988d66fdc269c6230f0e1432ace360
---
M scripts/obs/build_binpkg.py
M scripts/obs/data/build_binpkg.Dockerfile
M scripts/obs/data/build_deb.sh
M scripts/obs/data/build_rpm.sh
4 files changed, 24 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/76/34676/1
diff --git a/scripts/obs/build_binpkg.py b/scripts/obs/build_binpkg.py
index f3b4bcf..ae2fe53 100755
--- a/scripts/obs/build_binpkg.py
+++ b/scripts/obs/build_binpkg.py
@@ -76,6 +76,9 @@
env["RUN_SHELL_ON_ERROR"] = "1"
docker_args += ["-i", "-t"]

+ # Add capability needed for building without network
+ docker_args += ["--cap-add=NET_ADMIN"]
+
script_path = "data/build.sh"

if not distro.startswith("debian:") and not distro.startswith("ubuntu:"):
diff --git a/scripts/obs/data/build_binpkg.Dockerfile b/scripts/obs/data/build_binpkg.Dockerfile
index 4d4b185..55bfe0c 100644
--- a/scripts/obs/data/build_binpkg.Dockerfile
+++ b/scripts/obs/data/build_binpkg.Dockerfile
@@ -28,6 +28,7 @@
fakeroot \
git \
gnupg2 \
+ iproute2 \
&& \
apt-get clean \
;; \
@@ -40,6 +41,7 @@
gcc \
gcc-c++ \
glibc-devel \
+ iproute \
libtool \
make \
redhat-rpm-config \
diff --git a/scripts/obs/data/build_deb.sh b/scripts/obs/data/build_deb.sh
index 11eb36f..91fe2af 100755
--- a/scripts/obs/data/build_deb.sh
+++ b/scripts/obs/data/build_deb.sh
@@ -11,6 +11,9 @@

$apt_get update
$apt_get build-dep .
+
+ip link set eth0 down
+
su "$BUILDUSER" -c "dpkg-buildpackage -us -uc -j$JOBS"

# Show contents
diff --git a/scripts/obs/data/build_rpm.sh b/scripts/obs/data/build_rpm.sh
index 63c3638..4fe82bd 100755
--- a/scripts/obs/data/build_rpm.sh
+++ b/scripts/obs/data/build_rpm.sh
@@ -26,6 +26,8 @@

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

+ip link set eth0 down
+
su "$BUILDUSER" -c "rpmbuild -bb ~/rpmbuild/SPECS/$spec"

# Make built rpms available outside of docker

To view, visit change 34676. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I00282552e9988d66fdc269c6230f0e1432ace360
Gerrit-Change-Number: 34676
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>
Gerrit-MessageType: newchange