Last active
February 7, 2019 08:16
-
-
Save bartosh/3d11e2e4c71626e470f8df2b7592a741 to your computer and use it in GitHub Desktop.
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
#!/bin/sh -e | |
VERSION=1.14.0~alpha.2 | |
# prepare minimal debian directory | |
BUILD_DIR=$(mktemp -d --suffix=-kubeadm-build -p .) | |
cd $BUILD_DIR | |
mkdir debian | |
cat <<EOF > debian/control | |
Source: kubeadm | |
Section: misc | |
Priority: optional | |
Maintainer: Kubernetes Authors <kubernetes-dev+release@googlegroups.com> | |
Standards-Version: 3.9.8 | |
Homepage: https://kubernetes.io | |
Package: kubeadm | |
Architecture: amd64 | |
Depends: kubelet (>= $VERSION), kubectl (>= $VERSION) | |
Description: Kubernetes Cluster Bootstrapping Tool | |
The Kubernetes command line tool for bootstrapping a Kubernetes cluster. | |
EOF | |
cat <<EOF > debian/rules | |
#!/usr/bin/make -f | |
%: | |
dh \$@ | |
EOF | |
chmod +x debian/rules | |
cat <<EOF > debian/changelog | |
kubeadm ($VERSION) unstable; urgency=medium | |
* Test build. | |
-- Kubernetes Authors <kubernetes-dev+release@googlegroups.com> $(date -R) | |
EOF | |
cat <<EOF > debian/install | |
../_output/bin/kubeadm usr/bin | |
../build/debs/10-kubeadm.conf etc/systemd/system/kubelet.service.d/ | |
EOF | |
echo 9 > debian/compat | |
cp ../build/debs/postinst debian/ | |
# generate rpm spec | |
cat <<EOF > kubeadm.spec | |
Name: kubeadm | |
Version: $VERSION | |
Release: 00 | |
License: ASL 2.0 | |
Summary: Container Cluster Manager - Kubernetes Cluster Bootstrapping Tool | |
Requires: kubelet >= $VERSION | |
Requires: kubectl >= $VERSION | |
URL: https://kubernetes.io | |
%description | |
Command-line utility for deploying a Kubernetes cluster. | |
%install | |
install -m 755 -d %{buildroot}%{_bindir} | |
install -m 755 -d %{buildroot}%{_sysconfdir}/systemd/system/ | |
install -m 755 -d %{buildroot}%{_sysconfdir}/systemd/system/kubelet.service.d/ | |
install -p -m 755 -t %{buildroot}%{_bindir} ../_output/bin/kubeadm | |
install -p -m 644 -t %{buildroot}%{_sysconfdir}/systemd/system/kubelet.service.d/ ../build/rpms/10-kubeadm.conf | |
%files | |
%{_bindir}/kubeadm | |
%{_sysconfdir}/systemd/system/kubelet.service.d/10-kubeadm.conf | |
EOF | |
# generate build script | |
cat <<EOF > ./build-kubeadm-deb.sh | |
apt-get update | |
apt-get install -y rsync dpkg-dev debhelper rpm | |
cd /opt/k8s/ | |
useradd -m --uid $(id -u $USER) --gid $(id -g $USER) $USER | |
su $USER -c "PATH=$PATH make WHAT=cmd/kubeadm" | |
cd $BUILD_DIR | |
su $USER -c 'dpkg-buildpackage -b' | |
echo 'deb content:' | |
dpkg -c ../kubeadm_${VERSION}_*.deb | |
su $USER -c "rpmbuild --define '_builddir .' -bb kubeadm.spec" | |
su $USER -c "mv \$(find /home/$USER/rpmbuild/ -name kubeadm-${VERSION}-*.rpm) .." | |
echo 'rpm content:' | |
rpm -qlp ../kubeadm-${VERSION}-*.rpm | |
EOF | |
cd .. | |
# run the build | |
docker run -it --rm -v$(pwd):/opt/k8s golang:1.11.5-stretch /bin/bash /opt/k8s/$BUILD_DIR/build-kubeadm-deb.sh | |
# cleanup | |
rm -rf $BUILD_DIR | |
rm kubeadm_${VERSION}_*.buildinfo | |
rm kubeadm_${VERSION}_*.changes | |
echo | |
echo "result packages are in $(pwd):" | |
ls -la kubeadm*${VERSION}*[rpm,deb] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment