-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #570 from noironetworks/rpmbuild
Add support for ubi8 rpmbuild
- Loading branch information
Showing
5 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
ARG baseimage=noiro/opflexrpm-build-base:latest | ||
FROM $baseimage | ||
ARG branch="master" | ||
ARG buildversion="private" | ||
RUN mkdir -p /root/opflexrpms-$buildversion \ | ||
&& rm -f /root/opflexrpms/* \ | ||
&& git clone https://github.com/noironetworks/opflex -b $branch \ | ||
&& cd opflex \ | ||
&& pushd libopflex \ | ||
&& ./autogen.sh \ | ||
&& ./configure --with-buildversion=$buildversion \ | ||
&& make srpm \ | ||
&& make rpm \ | ||
&& cp *.rpm /root/opflexrpms-$buildversion \ | ||
&& export LIBOPFLEX_INSTALLS=`ls *.x86_64.rpm` \ | ||
&& rpm -i $LIBOPFLEX_INSTALLS \ | ||
&& popd \ | ||
&& pushd genie \ | ||
&& mvn compile exec:java \ | ||
&& popd \ | ||
&& pushd genie/target/libmodelgbp \ | ||
&& bash autogen.sh \ | ||
&& ./configure --with-buildversion=$buildversion \ | ||
libopflex_CFLAGS='none' libopflex_LIBS='none' \ | ||
&& make srpm \ | ||
&& ./configure --with-buildversion=$buildversion \ | ||
&& make rpm \ | ||
&& cp *.rpm /root/opflexrpms-$buildversion \ | ||
&& export MODELGBP_INSTALLS=`ls *.x86_64.rpm` \ | ||
&& rpm -i $MODELGBP_INSTALLS \ | ||
&& popd \ | ||
&& pushd agent-ovs \ | ||
&& ./autogen.sh \ | ||
&& ./configure --with-buildversion=$buildversion \ | ||
libopflex_CFLAGS='none' libopflex_LIBS='none' \ | ||
libmodelgbp_CFLAGS='none' libmodelgbp_LIBS='none' \ | ||
libofproto_CFLAGS='none' libofproto_LIBS='none' \ | ||
libopenvswitch_CFLAGS='none' libopenvswitch_LIBS='none' \ | ||
&& make srpm \ | ||
&& ./configure --with-buildversion=$buildversion \ | ||
&& make rpm \ | ||
&& cp *.rpm /root/opflexrpms-$buildversion \ | ||
&& popd \ | ||
&& cd /root \ | ||
&& cp ./rpmbuild-libuv/RPMS/x86_64/*.rpm ./opflexrpms-$buildversion \ | ||
&& cp ./rpmbuild-ovs/RPMS/noarch/*.rpm ./opflexrpms-$buildversion \ | ||
&& cp ./rpmbuild-ovs/RPMS/x86_64/*.rpm ./opflexrpms-$buildversion \ | ||
&& cp ./rpmbuild-prometheus/RPMS/x86_64/*.rpm ./opflexrpms-$buildversion \ | ||
&& cp ./rpmbuild-rapidjson/RPMS/x86_64/*.rpm ./opflexrpms-$buildversion \ | ||
&& tar czvf opflexrpms-$buildversion.tar.gz ./opflexrpms-$buildversion \ | ||
&& cd / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
ARG proxy | ||
RUN microdnf install --enablerepo codeready-builder-for-rhel-8-x86_64-rpms \ | ||
libtool pkgconfig autoconf automake make cmake file python3-six openssl-devel \ | ||
git gcc gcc-c++ boost-devel diffutils python3-devel libnetfilter_conntrack-devel \ | ||
wget which curl-devel procps zlib-devel libmnl-devel vi rpmdevtools rpmlint \ | ||
java-11-openjdk-devel checkpolicy graphviz groff selinux-policy-devel iproute-devel \ | ||
doxygen libuv-devel libnsl2-devel selinux-policy-targeted \ | ||
&& microdnf clean all | ||
RUN wget https://dlcdn.apache.org/maven/maven-3/3.9.7/binaries/apache-maven-3.9.7-bin.tar.gz \ | ||
&& tar zxvf apache-maven-3.9.7-bin.tar.gz \ | ||
&& rm apache-maven-3.9.7-bin.tar.gz | ||
RUN if [ ! -z "$proxy" ]; then \ | ||
mkdir -p /root/.m2 \ | ||
&& echo -e "\ | ||
<settings>\n\ | ||
<proxies>\n\ | ||
<proxy>\n\ | ||
<id>httpproxy</id>\n\ | ||
<active>true</active>\n\ | ||
<protocol>http</protocol>\n\ | ||
<host>$proxy</host>\n\ | ||
<port>80</port>\n\ | ||
<nonProxyHosts>localhost</nonProxyHosts>\n\ | ||
</proxy>\n\ | ||
<proxy>\n\ | ||
<id>httpsproxy</id>\n\ | ||
<active>true</active>\n\ | ||
<protocol>https</protocol>\n\ | ||
<host>$proxy</host>\n\ | ||
<port>80</port>\n\ | ||
<nonProxyHosts>localhost</nonProxyHosts>\n\ | ||
</proxy>\n\ | ||
</proxies>\n\ | ||
</settings>\n\ | ||
" > /root/.m2/settings.xml; \ | ||
fi | ||
ENV PATH=/apache-maven-3.9.7/bin:$PATH | ||
RUN pushd /root \ | ||
&& git clone https://github.com/noironetworks/3rdparty-rpm \ | ||
&& rpmdev-setuptree \ | ||
&& git clone https://github.com/openvswitch/ovs.git -b v2.12.0 \ | ||
&& pushd ovs \ | ||
&& cp ../3rdparty-rpm/noiro-openvswitch/noiro-openvswitch.spec /root/rpmbuild/SPECS \ | ||
&& patch -p1 < ../3rdparty-rpm/noiro-openvswitch/noiro-openvswitch.patch \ | ||
&& rm -f openvswitch*.tar.gz \ | ||
&& ./boot.sh \ | ||
&& ./configure \ | ||
&& make dist \ | ||
&& cp ./openvswitch*.tar.gz /root/rpmbuild/SOURCES \ | ||
&& rpmbuild -ba --without check --define '_topdir /root/rpmbuild' /root/rpmbuild/SPECS/noiro-openvswitch.spec --without=libcapng \ | ||
&& mv /root/rpmbuild /root/rpmbuild-ovs \ | ||
&& popd \ | ||
&& mkdir -p /root/rpmbuild-ovs/RPMS/ovn/x86_64 \ | ||
&& mv /root/rpmbuild-ovs/RPMS/x86_64/*ovn* /root/rpmbuild-ovs/RPMS/ovn/x86_64 \ | ||
&& rm -Rf /root/ovs | ||
RUN pushd /root \ | ||
&& rpmdev-setuptree \ | ||
&& git clone https://github.com/libuv/libuv.git -b v1.20.2 \ | ||
&& pushd libuv \ | ||
&& cp ../3rdparty-rpm/libuv.spec /root/rpmbuild/SPECS \ | ||
&& rm -f libuv*.tar.gz \ | ||
&& sh autogen.sh \ | ||
&& ./configure \ | ||
&& make dist \ | ||
&& cp libuv-1.20.2.tar.gz /root/rpmbuild/SOURCES/libuv-v1.20.2.tar.gz \ | ||
&& rpmbuild -ba --define '_topdir /root/rpmbuild' /root/rpmbuild/SPECS/libuv.spec \ | ||
&& mv /root/rpmbuild /root/rpmbuild-libuv \ | ||
&& popd \ | ||
&& rm -Rf /root/libuv | ||
RUN pushd /root \ | ||
&& rpmdev-setuptree \ | ||
&& git clone https://github.com/jupp0r/prometheus-cpp.git -b v1.0.1 \ | ||
&& pushd prometheus-cpp \ | ||
&& git submodule init \ | ||
&& git submodule update \ | ||
&& git apply ../3rdparty-rpm/prometheus/prometheus-cpp.patch \ | ||
&& mkdir _build \ | ||
&& popd \ | ||
&& mv prometheus-cpp prometheus-cpp-1.0.1 \ | ||
&& tar -czvf prometheus-cpp-1.0.1.tar.gz prometheus-cpp-1.0.1 \ | ||
&& mv prometheus-cpp-1.0.1.tar.gz /root/rpmbuild/SOURCES \ | ||
&& cp /root/3rdparty-rpm/prometheus-cpp.spec /root/rpmbuild/SPECS \ | ||
&& rpmbuild -ba --define '_topdir /root/rpmbuild' /root/rpmbuild/SPECS/prometheus-cpp.spec \ | ||
&& mv /root/rpmbuild /root/rpmbuild-prometheus \ | ||
&& popd \ | ||
&& rm -Rf /root/bin /root/doc /root/man /root/share /root/prometheus-cpp-1.0.1 | ||
RUN pushd /root \ | ||
&& rpmdev-setuptree \ | ||
&& wget https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz \ | ||
&& mv v1.1.0.tar.gz rpmbuild/SOURCES \ | ||
&& cp /root/3rdparty-rpm/rapidjson-devel.spec /root/rpmbuild/SPECS \ | ||
&& rpmbuild -ba --define '_topdir /root/rpmbuild' /root/rpmbuild/SPECS/rapidjson-devel.spec \ | ||
&& mv /root/rpmbuild /root/rpmbuild-rapidjson \ | ||
&& rm -Rf /root/3rdparty-rpm \ | ||
&& popd | ||
RUN export OVS_NOARCH_INSTALLS=`ls /root/rpmbuild-ovs/RPMS/noarch/*.rpm` \ | ||
&& export OVS_INSTALLS=`ls /root/rpmbuild-ovs/RPMS/x86_64/*.x86_64.rpm` \ | ||
&& export RAPIDJSON_INSTALLS=`ls /root/rpmbuild-rapidjson/RPMS/x86_64/*.x86_64.rpm` \ | ||
&& export PROMETHEUS_INSTALLS=`ls /root/rpmbuild-prometheus/RPMS/x86_64/*.x86_64.rpm` \ | ||
&& rpm -i $OVS_NOARCH_INSTALLS $OVS_INSTALLS $RAPIDJSON_INSTALLS $PROMETHEUS_INSTALLS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
The rpm build is completely containerized and has no host dependencies | ||
except the following repos that need to be enabled on the rhel8 host so | ||
the container can import them. Additionally the subscription manager | ||
on the host needs to be setup to run in container mode since the | ||
container itself will run as a non root user. | ||
|
||
Host repos to be enabled | ||
======================== | ||
|
||
repo id repo name | ||
codeready-builder-for-rhel-8-x86_64-rpms Red Hat CodeReady Linux Builder for RHEL 8 x86_64 (RPMs) | ||
epel Extra Packages for Enterprise Linux 8 - x86_64 | ||
rhel-8-for-x86_64-appstream-rpms Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) | ||
rhel-8-for-x86_64-baseos-rpms Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) | ||
|
||
When setup correectly the following will be seen on a yum repolist | ||
inside a container. | ||
|
||
[noiro@slave-06-rhel8 ~]$ podman run -it ubi8 sh | ||
sh-4.4# yum repolist | ||
Updating Subscription Management repositories. | ||
Unable to read consumer identity | ||
subscription-manager is operating in container mode. | ||
repo id repo name | ||
rhel-8-for-x86_64-appstream-rpms Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) | ||
rhel-8-for-x86_64-baseos-rpms Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) | ||
ubi-8-appstream-rpms Red Hat Universal Base Image 8 (RPMs) - AppStream | ||
ubi-8-baseos-rpms Red Hat Universal Base Image 8 (RPMs) - BaseOS | ||
ubi-8-codeready-builder-rpms Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder | ||
|
||
Usage | ||
===== | ||
|
||
There are 2 docker files and 2 build scripts corresponding to them. | ||
|
||
A. Dockerfile-opflexrpm-build-base / build_opflex_baserpm.sh | ||
invoked as ./build_opflex_baserpm.sh noiro latest proxy.esl.cisco.com | ||
|
||
The last argument is optional unless running on a lab vm that needs proxy in | ||
which case it would be the name of the proxy. | ||
This script will build noiro/opflexrpm-build-base:latest | ||
This image need not be build unless the opflex dependencies it installs within | ||
change. These rarely change. | ||
|
||
These dependencies are | ||
1. 3rdparty-rpm | ||
2. ovs | ||
3. libuv (built but not used because the system provided one compiles just fine) | ||
4. prometheus-cpp | ||
5. rapidjson | ||
|
||
B. Dockerfile-opflexrpm-build / build_opflexrpm.sh | ||
invoked as ./build_opflexrpm.sh noiro latest noiro/opflexrpm-build-base:latest master 1.1 | ||
3rd argument is the base image that was build in step A | ||
4th argument is optional to build a particular branch, default master | ||
5th argument is optional to build rpms with a particular build number, default private | ||
|
||
This script will build noiro/opflexrpm-build:latest and additionally copy all the opflexrpm | ||
artifacts to /root/opflexrpms.tar.gz inside the container and also copy them out of the | ||
container into the current directly. | ||
|
||
The result will be opflexrpms-1.1.tar.gz that can be posted to the customer for | ||
installing inside the openstack container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
# Usage ./build_opflex_baserpm.sh <docker_user> <docker_tag> <optional proxy> | ||
|
||
set -x | ||
|
||
if test "$#" -lt 2; then | ||
echo "Usage ./build_opflex_baserpm.sh <docker_user> <docker_tag> <optional proxy>" | ||
exit -1 | ||
fi | ||
|
||
DOCKER_USER=$1 | ||
DOCKER_TAG=$2 | ||
PROXY=$3 | ||
|
||
podman build --no-cache --build-arg proxy="$PROXY" -t "$DOCKER_USER"/opflexrpm-build-base:"$DOCKER_TAG" -f ./Dockerfile-opflexrpm-build-base . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
# Usage ./build_opflexrpm.sh <docker_user> <docker_tag> <baseimage> <branch> <buildversion> | ||
# branch default master | ||
# buildversion default private | ||
set -x | ||
|
||
if test "$#" -lt 3; then | ||
echo "Usage: ./build_opflexrpm.sh <docker_user> <docker_tag> <baseimage> <branch> <buildversion>" | ||
echo "branch default master" | ||
echo "buildversion default private" | ||
exit -1 | ||
fi | ||
|
||
DOCKER_USER=$1 | ||
DOCKER_TAG=$2 | ||
BASEIMAGE=$3 | ||
BRANCH=$4 | ||
BUILDVER=$5 | ||
|
||
if [ -z "$4" ]; then | ||
BRANCH="master" | ||
fi | ||
|
||
if [ -z "$5" ]; then | ||
BUILDVER="private" | ||
fi | ||
|
||
podman build --no-cache --build-arg baseimage="$BASEIMAGE" --build-arg branch="$BRANCH" \ | ||
--build-arg buildversion="$BUILDVER" -t "$DOCKER_USER"/opflexrpm-build:"$DOCKER_TAG" \ | ||
-f ./Dockerfile-opflexrpm-build . | ||
cid=$(podman create "$DOCKER_USER"/opflexrpm-build:"$DOCKER_TAG") | ||
podman cp "$cid:/root/opflexrpms-$BUILDVER.tar.gz" ./opflexrpms-"$BUILDVER".tar.gz | ||
podman rm "$cid" |