Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fedora (rpm) packaging #140

Closed
5 tasks done
nsteinmetz opened this issue Apr 4, 2019 · 18 comments
Closed
5 tasks done

Add Fedora (rpm) packaging #140

nsteinmetz opened this issue Apr 4, 2019 · 18 comments

Comments

@nsteinmetz
Copy link

nsteinmetz commented Apr 4, 2019

Following #17, I create a dedicated issue for fedora/rpm packaging.

To enable repo:

(sudo) dnf copr enable cerenit/kubectx 
(sudo) dnf install kubectx

Work in progress is available here and soon on Github too.

@nsteinmetz
Copy link
Author

Upgraded for kubectx v0.7.0 just now

@TJM
Copy link

TJM commented Nov 12, 2019

Now that you have a spec file, how hard would it be to build for EPEL?

@nsteinmetz
Copy link
Author

By EPEL, you mean CentOS/RHEL ? I can add them as target on COPR and see what happens. I will try later today with the update to 0.7.1

It should work I think due to the minimal dependencies.

@nsteinmetz
Copy link
Author

It worked seamlessly with EPEL8 and failed with EPEL7. So I only kept EPEL8.

As I don't use CentOS/RHEL, I'll not investigate further EPEL7. If you have some patch to make it work also on EPEL7, I'd be happy to integrate it.

Files for shell completions are in /usr/share/kubectx.

@dougsland
Copy link

@nsteinmetz still not working? What's the error message?

@dougsland
Copy link

Just tested here, my suggestion patch to fix the issue in EL7:

$ git diff
diff --git a/kubectx.spec b/kubectx.spec
index b667e32..04bf640 100644
--- a/kubectx.spec
+++ b/kubectx.spec
@@ -1,6 +1,6 @@
Name: kubectx
Version: 0.7.1
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: kubectx and kubens ease managing kubernetes contexts / name spaces

License: ASL 2.0
@@ -9,6 +9,9 @@ Source0: %{url}/archive/v%{version}.tar.gz

BuildArch: noarch

+%prep
+%setup -q -n %{name}-%{version}
+
%description
kubectx is a utility to manage and switch between kubectl contexts.
kubens is a utility to switch between Kubernetes name spaces.
@@ -17,12 +20,12 @@ Requires: bash

%install
mkdir -p %{buildroot}/%{_bindir}
-mkdir -p %{buildroot}/%{_datadir}/licenses/%{name}
+mkdir -p %{buildroot}/%{_datadir}/licenses/%{name}-%{version}
mkdir -p %{buildroot}/%{_datadir}/%{name}
tar xzf %{_sourcedir}/v%{version}.tar.gz
install -p -m 755 %{name}-%{version}/kubectx %{buildroot}/%{_bindir}
install -p -m 755 %{name}-%{version}/kubens %{buildroot}/%{_bindir}
-install -p -m 644 %{name}-%{version}/LICENSE %{buildroot}/%{_datadir}/licenses/%{name}/
+install -p -m 644 %{name}-%{version}/LICENSE %{buildroot}/%{_datadir}/licenses/%{name}-%{version}/
install -p -m 644 %{name}-%{version}/completion/kubectx.bash %{buildroot}/%{_datadir}/%{name}/
install -p -m 644 %{name}-%{version}/completion/kubectx.fish %{buildroot}/%{_datadir}/%{name}/
install -p -m 644 %{name}-%{version}/completion/kubectx.zsh %{buildroot}/%{_datadir}/%{name}/
@@ -42,6 +45,9 @@ install -p -m 644 %{name}-%{version}/completion/kubens.zsh %{buildroot}/%{_datad
%{_datadir}/%{name}/kubens.zsh

%changelog
+* Tue Nov 26 2019 Douglas Schilling Landgraf dougsland@gmail.com - 0.7.1-2
+- Fix build for EL7
+

  • Upgrade to 0.7.1
  • Add shell complets to /usr/share/kubectx/

@dougsland
Copy link

$ cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)

[douglas@nuc01 kubectx-rpm]$ rpmbuild -ba ./kubectx.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.yT6Wua

  • umask 022
  • cd /home/douglas/rpmbuild/BUILD
  • cd /home/douglas/rpmbuild/BUILD
  • rm -rf kubectx-0.7.1
  • /usr/bin/gzip -dc /home/douglas/rpmbuild/SOURCES/v0.7.1.tar.gz
  • /usr/bin/tar -xf -
  • STATUS=0
  • '[' 0 -ne 0 ']'
  • cd kubectx-0.7.1
  • /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
  • exit 0
    Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.3hoHmq
  • umask 022
  • cd /home/douglas/rpmbuild/BUILD
  • '[' /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64 '!=' / ']'
  • rm -rf /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64
    ++ dirname /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64
  • mkdir -p /home/douglas/rpmbuild/BUILDROOT
  • mkdir /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64
  • cd kubectx-0.7.1
  • mkdir -p /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/bin
  • mkdir -p /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/share/licenses/kubectx-0.7.1
  • mkdir -p /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/share/kubectx
  • tar xzf /home/douglas/rpmbuild/SOURCES/v0.7.1.tar.gz
  • install -p -m 755 kubectx-0.7.1/kubectx /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/bin
  • install -p -m 755 kubectx-0.7.1/kubens /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/bin
  • install -p -m 644 kubectx-0.7.1/LICENSE /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/share/licenses/kubectx-0.7.1/
  • install -p -m 644 kubectx-0.7.1/completion/kubectx.bash /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/share/kubectx/
  • install -p -m 644 kubectx-0.7.1/completion/kubectx.fish /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/share/kubectx/
  • install -p -m 644 kubectx-0.7.1/completion/kubectx.zsh /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/share/kubectx/
  • install -p -m 644 kubectx-0.7.1/completion/kubens.bash /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/share/kubectx/
  • install -p -m 644 kubectx-0.7.1/completion/kubens.fish /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/share/kubectx/
  • install -p -m 644 kubectx-0.7.1/completion/kubens.zsh /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64//usr/share/kubectx/
  • /usr/lib/rpm/find-debuginfo.sh --strict-build-id -m --run-dwz --dwz-low-mem-die-limit 10000000 --dwz-max-die-limit 110000000 /home/douglas/rpmbuild/BUILD/kubectx-0.7.1
    /usr/lib/rpm/sepdebugcrcfix: Updated 0 CRC32s, 0 CRC32s did match.
  • /usr/lib/rpm/check-buildroot
  • /usr/lib/rpm/redhat/brp-compress
  • /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
  • /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
  • /usr/lib/rpm/redhat/brp-python-hardlink
  • /usr/lib/rpm/redhat/brp-java-repack-jars
    Processing files: kubectx-0.7.1-2.el7.noarch
    Executing(%license): /bin/sh -e /var/tmp/rpm-tmp.Iub8zG
  • umask 022
  • cd /home/douglas/rpmbuild/BUILD
  • cd kubectx-0.7.1
  • LICENSEDIR=/home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64/usr/share/licenses/kubectx-0.7.1
  • export LICENSEDIR
  • /usr/bin/mkdir -p /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64/usr/share/licenses/kubectx-0.7.1
  • cp -pr LICENSE /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64/usr/share/licenses/kubectx-0.7.1
  • exit 0
    Provides: kubectx = 0.7.1-2.el7
    Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
    Requires: /usr/bin/env
    Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64
    Wrote: /home/douglas/rpmbuild/SRPMS/kubectx-0.7.1-2.el7.src.rpm
    Wrote: /home/douglas/rpmbuild/RPMS/noarch/kubectx-0.7.1-2.el7.noarch.rpm
    Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.JWfKTt
  • umask 022
  • cd /home/douglas/rpmbuild/BUILD
  • cd kubectx-0.7.1
  • /usr/bin/rm -rf /home/douglas/rpmbuild/BUILDROOT/kubectx-0.7.1-2.el7.x86_64
  • exit 0

@nsteinmetz
Copy link
Author

@dougsland I was typing my answer when I saw your patch - thanks I'll add it in my package and let you know if copr package works :)

@nsteinmetz
Copy link
Author

On fedora, I needed to add the whole line %{_datadir}/licenses/%{name}-%{version}/LICENSE for licence file ; otherwise it claimed for an installed file which was not in the package at the end

%files
%license LICENSE
%{_bindir}/kubectx
%{_bindir}/kubens
%{_datadir}/licenses/%{name}-%{version}/LICENSE
%{_datadir}/%{name}/kubectx.bash
%{_datadir}/%{name}/kubectx.fish
%{_datadir}/%{name}/kubectx.zsh
%{_datadir}/%{name}/kubens.bash
%{_datadir}/%{name}/kubens.fish
%{_datadir}/%{name}/kubens.zsh

@dougsland
Copy link

On fedora, I needed to add the whole line %{_datadir}/licenses/%{name}-%{version}/LICENSE for licence file ; otherwise it claimed for an installed file which was not in the package at the end

%files
%license LICENSE
%{_bindir}/kubectx
%{_bindir}/kubens
%{_datadir}/licenses/%{name}-%{version}/LICENSE
%{_datadir}/%{name}/kubectx.bash
%{_datadir}/%{name}/kubectx.fish
%{_datadir}/%{name}/kubectx.zsh
%{_datadir}/%{name}/kubens.bash
%{_datadir}/%{name}/kubens.fish
%{_datadir}/%{name}/kubens.zsh

If it works, it works ;-) Glad to help. @nsteinmetz

@nsteinmetz
Copy link
Author

@dougsland sucess ! 🎉 Thanks a lot for your contribution !

@TJM if you're interested by EPEL7, it works from now thanks to @dougsland patch. EPEL8 was already working.

@TJM
Copy link

TJM commented Nov 26, 2019

@nsteinmetz Thanks! Do we need to do anything to get these packages into the EPEL repos, or am I just too early, maybe they need to propagate?

@dougsland
Copy link

hey @nsteinmetz let's bring the spec into the main repo, so more people is aware of the spec file. :) (Just my 2 cents)

@nsteinmetz
Copy link
Author

@TJM it won"t be in the official EPEL repo for now - you have to add the repo from here https://copr.fedorainfracloud.org/coprs/cerenit/kubectx/ - pick the one you expect to use to have the related repo file.

@dougsland you mean the main repo here or the main EPEL repo ? For the kubectx repo, @ahmetb said that he's not very interested in package management or expect a general solution to be implemeted (fpm based ?). At least, my repo could be mentionned as for other repo in the README section.

For the official EPEL repo, I don't know the process and I don't have a lot of freetime to invest in it nor a lot of interest to be honest. I use fedora only as laptop, for servers I'm more debian based. I use kubectx only on my laptop so...

But if you want to make the process, feel free to do so and take ownership on this.

@nsteinmetz
Copy link
Author

@dougsland I mirrored repo on github => https://github.com/nsteinmetz/kubectx-rpm - I can add you as collaborator on it or you can fork it if you prefer.

@dougsland
Copy link

@dougsland you mean the main repo here or the main EPEL repo ? For the kubectx repo,
@ahmetb said that he's not very interested in package management or expect a general solution to
be implemeted (fpm based ?). At least, my repo could be mentionned as for other repo in the
README section.

Okay, if @ahmetb is not interested in spec files, yeah we should have it in other github fork like you did. However, I would expect @ahmetb re-think about this topic, not only to get better support to RPM based distro in a single git tree but also more visibility to the project.

For the official EPEL repo, I don't know the process and I don't have a lot of freetime to invest in it
nor a lot of interest to be honest. I use fedora only as laptop, for servers I'm more debian based. I
use kubectx only on my laptop so...
But if you want to make the process, feel free to do so and take ownership on this.

I am not looking for ownership but I can contribute.

@nsteinmetz
Copy link
Author

nsteinmetz commented Nov 28, 2019

Cf #184 (comment)

Personally I don’t want to get to package management business for Linux, the space is vastly fragmented and I don’t use Linux myself. I’ve personally built a cross-platform package manager (see: krew.dev) so this is way too much for me to support reliably.
Although if there’s someone willing to sign up to do this in the long term (especially with something like fpm, that handles multiple pkg managers at once) I’d be happier.

@nsteinmetz
Copy link
Author

nsteinmetz commented Nov 16, 2020

For the record : I no longer maintain the rpm version - I switched to the krew plugin - if someone is interesed, repo is in archived mode and existing rpm will remain as long as possible but new builds will not be proposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants