Skip to content

Commit

Permalink
Build Multi-arch rpms
Browse files Browse the repository at this point in the history
  • Loading branch information
mkumatag committed Apr 7, 2017
1 parent 1355357 commit 809e37f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
3 changes: 1 addition & 2 deletions rpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ RUN rpmdev-setuptree
USER root
ADD entry.sh /root/
COPY ./ /root/rpmbuild/SPECS
CMD ["/root/entry.sh"]

ENTRYPOINT ["/root/entry.sh"]
9 changes: 5 additions & 4 deletions rpm/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ docker build -t kubelet-rpm-builder .
echo "Cleaning output directory..."
sudo rm -rf output/*
mkdir -p output
docker run -ti --rm -v $PWD/output/:/root/rpmbuild/RPMS/ kubelet-rpm-builder
docker run -ti --rm -v $PWD/output/:/root/rpmbuild/RPMS/ kubelet-rpm-builder $1
sudo chown -R $USER $PWD/output

echo
echo "----------------------------------------"
echo
echo "RPMs written to: $PWD/output/x86_64/"
ls $PWD/output/x86_64/
echo "RPMs written to: "
ls $PWD/output/*/
echo
echo "Yum repodata written to: $PWD/output/x86_64/yum/"
echo "Yum repodata written to: "
ls $PWD/output/*/repodata/
33 changes: 28 additions & 5 deletions rpm/entry.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
#!/bin/sh
# Entrypoint for the build container to create the rpms and yum repodata:
# Usage: ./entry.sh GOARCH/RPMARCH,GOARCH/RPMARCH,....

set -e
# Download sources if not already available
cd /root/rpmbuild/SPECS && spectool -gf kubelet.spec

/usr/bin/rpmbuild --define "_sourcedir /root/rpmbuild/SPECS/" -bb /root/rpmbuild/SPECS/kubelet.spec
declare -a ARCHS

mkdir -p /root/rpmbuild/RPMS/x86_64/
createrepo -o /root/rpmbuild/RPMS/x86_64/ /root/rpmbuild/RPMS/x86_64
if [ $# -gt 0 ]; then
IFS=','; ARCHS=($1); unset IFS;
else
#GOARCH/RPMARCH
ARCHS=(
amd64/x86_64
arm/armhfp
arm64/aarch64
ppc64le/ppc64le
s390x/s390x
)
fi

for ARCH in ${ARCHS[@]}; do
IFS=/ read GOARCH RPMARCH<<< ${ARCH}; unset IFS;
SRC_PATH="/root/rpmbuild/SOURCES/${RPMARCH}"
mkdir -p ${SRC_PATH}
cp -r /root/rpmbuild/SPECS/* ${SRC_PATH}
echo "Building RPM's for ${GOARCH}....."
sed -i "s/\%global ARCH.*/\%global ARCH ${GOARCH}/" ${SRC_PATH}/kubelet.spec
# Download sources if not already available
cd ${SRC_PATH} && spectool -gf kubelet.spec
/usr/bin/rpmbuild --target ${RPMARCH} --define "_sourcedir ${SRC_PATH}" -bb ${SRC_PATH}/kubelet.spec
mkdir -p /root/rpmbuild/RPMS/${RPMARCH}
createrepo -o /root/rpmbuild/RPMS/${RPMARCH}/ /root/rpmbuild/RPMS/${RPMARCH}
done
9 changes: 5 additions & 4 deletions rpm/kubelet.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%global KUBE_VERSION 1.6.0
%global CNI_RELEASE 0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff
%global RPM_RELEASE 0
%global ARCH amd64

Name: kubelet
Version: %{KUBE_VERSION}
Expand All @@ -9,12 +10,12 @@ Summary: Container cluster management
License: ASL 2.0

URL: https://kubernetes.io
Source0: https://dl.k8s.io/v%{KUBE_VERSION}/bin/linux/amd64/kubelet
Source0: https://dl.k8s.io/v%{KUBE_VERSION}/bin/linux/%{ARCH}/kubelet
Source1: kubelet.service
Source2: https://dl.k8s.io/v%{KUBE_VERSION}/bin/linux/amd64/kubectl
Source3: https://dl.k8s.io/v%{KUBE_VERSION}/bin/linux/amd64/kubeadm
Source2: https://dl.k8s.io/v%{KUBE_VERSION}/bin/linux/%{ARCH}/kubectl
Source3: https://dl.k8s.io/v%{KUBE_VERSION}/bin/linux/%{ARCH}/kubeadm
Source4: 10-kubeadm.conf
Source5: https://dl.k8s.io/network-plugins/cni-amd64-%{CNI_RELEASE}.tar.gz
Source5: https://dl.k8s.io/network-plugins/cni-%{ARCH}-%{CNI_RELEASE}.tar.gz


BuildRequires: curl
Expand Down

0 comments on commit 809e37f

Please sign in to comment.