From c76e633e3a803d414cdfca4547ae99cf07cc6f7a Mon Sep 17 00:00:00 2001 From: Liming Sun Date: Mon, 23 Mar 2020 11:07:54 -0400 Subject: [PATCH] Add RPM spec file rhel/rshim.spec.in for fedora This commit also moves the rshim binary to /usr/sbin and moves the man page to man8. Signed-off-by: Liming Sun --- configure.ac | 3 +- man/Makefile.am | 2 +- man/{rshim.1 => rshim.8} | 0 rhel/rshim.spec.in | 65 ++++++++++++++++++++++++++++++++++++++++ rshim.service | 2 +- rshim.spec.in | 14 +++++---- src/Makefile.am | 2 +- src/rshim_net.c | 2 +- src/rshim_pcie.c | 2 +- src/rshim_pcie_lf.c | 2 +- src/rshim_usb.c | 2 +- 11 files changed, 82 insertions(+), 14 deletions(-) rename man/{rshim.1 => rshim.8} (100%) create mode 100644 rhel/rshim.spec.in diff --git a/configure.ac b/configure.ac index dc8601a..0d61687 100644 --- a/configure.ac +++ b/configure.ac @@ -11,9 +11,10 @@ AM_PROG_CC_C_O AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([ Makefile + rshim.spec src/Makefile man/Makefile - rshim.spec + rhel/rshim.spec ]) AC_CANONICAL_HOST diff --git a/man/Makefile.am b/man/Makefile.am index 1400e7d..10b5fe6 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -2,4 +2,4 @@ # Copyright (C) 2019 Mellanox Technologies. All Rights Reserved. # -man1_MANS = rshim.1 +man8_MANS = rshim.8 diff --git a/man/rshim.1 b/man/rshim.8 similarity index 100% rename from man/rshim.1 rename to man/rshim.8 diff --git a/rhel/rshim.spec.in b/rhel/rshim.spec.in new file mode 100644 index 0000000..295c5e1 --- /dev/null +++ b/rhel/rshim.spec.in @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2019 Mellanox Technologies. All Rights Reserved. +# + +Name: rshim +Version: @VERSION@ +Release: 1%{?dist} +Summary: User-space driver for Mellanox BlueField SoC + +License: GPLv2 + +URL: https://github.com/mellanox/rshim-user-space +Source0: https://github.com/Mellanox/rshim-user-space/releases/download/%{name}-%{version}/%{name}-%{version}.tar.gz + +BuildRequires: gcc, autoconf, automake +BuildRequires: pkgconfig(libpci), pkgconfig(libusb-1.0), pkgconfig(fuse) +BuildRequires: systemd-units +BuildRequires: systemd-rpm-macros + +%description +This is the user-space driver to access the BlueField SoC via the rshim +interface. It provides ways to push boot stream, debug the target or login +via the virtual console or network interface. + +%prep +%setup -n %{name}-%{version} + +%build +./bootstrap.sh +%configure +make + +%install +%make_install +%__spec_install_post + +%post +%systemd_post rshim.service + +%preun +%systemd_preun rshim.service + +%postun +%systemd_postun_with_restart rshim.service + +%files +%license LICENSE +%doc README.md +%{_sbindir}/rshim +%{_unitdir}/rshim.service +%{_mandir}/man8/rshim.8.gz + +%changelog +* Mon Mar 23 2020 Liming Sun - 2.0.1-1 +- Rename bfrshim to rshim +- Remove rshim.spec since it's auto-generated from rshim.spec.in +- Fix warnings reported by coverity +- Add rhel/rshim.spec.in for fedora +- Move rshim to sbin and move man page to man8 + +* Fri Mar 13 2020 Liming Sun - 2.0-1 +- Update the spec file according to fedora packaging-guidelines + +* Mon Dec 16 2019 Liming Sun +- Initial packaging diff --git a/rshim.service b/rshim.service index 8a1ca2d..0cd9b61 100644 --- a/rshim.service +++ b/rshim.service @@ -9,7 +9,7 @@ After=network.target [Service] Restart=always Type=forking -ExecStart=-/usr/bin/rshim $OPTIONS +ExecStart=-/usr/sbin/rshim $OPTIONS KillMode=process ExecStop=/usr/bin/killall -SIGKILL rshim diff --git a/rshim.spec.in b/rshim.spec.in index b00dfd8..08554ae 100644 --- a/rshim.spec.in +++ b/rshim.spec.in @@ -34,13 +34,13 @@ tar -axf %{SOURCE0} -C %{name}-%{version} --strip-components 1 make %install -%makeinstall -C src INSTALL_DIR="%{buildroot}%{_bindir}" +%makeinstall -C src INSTALL_DIR="%{buildroot}%{_sbindir}" %if "%{with_systemd}" == "1" %{__install} -d %{buildroot}%{_unitdir} %{__install} -m 0644 rshim.service %{buildroot}%{_unitdir} %endif -%{__install} -d %{buildroot}%{_mandir}/man1 -%{__install} -m 0644 man/rshim.1 %{buildroot}%{_mandir}/man1 +%{__install} -d %{buildroot}%{_mandir}/man8 +%{__install} -m 0644 man/rshim.8 %{buildroot}%{_mandir}/man8 %__spec_install_post %post @@ -63,14 +63,16 @@ make %if "%{with_systemd}" == "1" %{_unitdir}/rshim.service %endif -%{_bindir}/rshim -%{_mandir}/man1/rshim.1.gz +%{_sbindir}/rshim +%{_mandir}/man8/rshim.8.gz %changelog -* Fri Mar 20 2020 Liming Sun - 2.0.1-1 +* Mon Mar 23 2020 Liming Sun - 2.0.1-1 - Rename bfrshim to rshim - Remove rshim.spec since it's auto-generated from rshim.spec.in - Fix some warnings reported by coverity +- Add file rhel/rshim.spec.in for fedora +- Move rshim to sbin and move man page to man8 * Fri Mar 13 2020 Liming Sun - 2.0-1 - Update the spec file according to fedora packaging-guidelines diff --git a/src/Makefile.am b/src/Makefile.am index a991b06..f3e4b05 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,7 @@ # Copyright (C) 2019 Mellanox Technologies. All Rights Reserved. # -bin_PROGRAMS = rshim +sbin_PROGRAMS = rshim rshim_SOURCES = rshim.c rshim_log.c rshim_net.c rshim_CPPFLAGS = -DHAVE_RSHIM_NET diff --git a/src/rshim_net.c b/src/rshim_net.c index 626d556..c60cc68 100644 --- a/src/rshim_net.c +++ b/src/rshim_net.c @@ -68,7 +68,7 @@ static int rshim_if_open(char *ifname, int index) memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); + strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); rc = ioctl(fd, TUNSETIFF, (void *) &ifr); if (rc < 0) { diff --git a/src/rshim_pcie.c b/src/rshim_pcie.c index e847576..8129dba 100644 --- a/src/rshim_pcie.c +++ b/src/rshim_pcie.c @@ -321,7 +321,7 @@ static int rshim_pcie_probe(struct pci_dev *pci_dev) bd = &dev->bd; bd->has_rshim = 1; bd->has_tm = 1; - strncpy(bd->dev_name, dev_name, sizeof(bd->dev_name) - 1); + strcpy(bd->dev_name, dev_name); bd->read_rshim = rshim_pcie_read; bd->write_rshim = rshim_pcie_write; bd->destroy = rshim_pcie_delete; diff --git a/src/rshim_pcie_lf.c b/src/rshim_pcie_lf.c index 44376cc..790d13f 100644 --- a/src/rshim_pcie_lf.c +++ b/src/rshim_pcie_lf.c @@ -506,7 +506,7 @@ static int rshim_pcie_probe(struct pci_dev *pci_dev) bd = &dev->bd; bd->has_rshim = 1; bd->has_tm = 1; - strncpy(bd->dev_name, dev_name, sizeof(bd->dev_name) - 1); + strcpy(bd->dev_name, dev_name); bd->read_rshim = rshim_pcie_read; bd->write_rshim = rshim_pcie_write; bd->destroy = rshim_pcie_delete; diff --git a/src/rshim_usb.c b/src/rshim_usb.c index 0d5fe39..2e71884 100644 --- a/src/rshim_usb.c +++ b/src/rshim_usb.c @@ -575,7 +575,7 @@ static int rshim_usb_probe_one(libusb_context *ctx, libusb_device *usb_dev) } bd = &dev->bd; - strncpy(bd->dev_name, dev_name, sizeof(bd->dev_name) - 1); + strcpy(bd->dev_name, dev_name); bd->read = rshim_usb_backend_read; bd->write = rshim_usb_backend_write; bd->cancel = rshim_usb_backend_cancel_req;