Init: init libcareplus repo

Add libcareplus-0.1.4.tar.gz as the target source
Add libcareplus.spec

Signed-off-by: Ying Fang <fangying1@huawei.com>
This commit is contained in:
Ying Fang 2020-12-08 14:10:32 +08:00
parent 741587777f
commit 8d9f08938c
3 changed files with 198 additions and 0 deletions

BIN
libcareplus-0.1.4.tar.gz Normal file

Binary file not shown.

167
libcareplus.spec Normal file
View File

@ -0,0 +1,167 @@
Version: 0.1.4
Name: libcareplus
Summary: LibcarePlus tools
Release: 1%{?dist}
Group: Applications/System
License: GPLv2
Url: https://gitee.com/openeuler/libcareplus
Source0: %{name}-%{version}.tar.gz
Patch0001: src-Makefile-install-kpatch_gensrc-into-bindir.patch
ExclusiveArch: x86_64
BuildRequires: elfutils-libelf-devel libunwind-devel
%if 0%{with selinux}
BuildRequires: checkpolicy
BuildRequires: selinux-policy-devel
BuildRequires: /usr/share/selinux/devel/policyhelp
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%if 0%{with selinux}
Requires: libcare-selinux = %{version}-%{release}
%endif
%description
LibcarePlus userland tools
%if 0%{with selinux}
%package selinux
Summary: SELinux package for LibcarePlus/QEMU integration
Group: System Environment/Base
Requires(post): selinux-policy-base, policycoreutils
Requires(postun): policycoreutils
%description selinux
This package contains SELinux module required to allow for
LibcarePlus interoperability with the QEMU run by sVirt.
%endif
%package devel
Summary: LibcarePlus development package
Group: System Environment/Development Tools
%description devel
LibcarePlus devel files.
%prep
%setup -q
%autopatch -p1
%build
make -C src
%if 0%{with selinux}
make -C dist/selinux
%endif
%install
%{__rm} -rf %{buildroot}
make -C src install \
DESTDIR=%{buildroot} \
bindir=%{_bindir} \
libexecdir=%{_libexecdir}
%if 0%{with selinux}
make -C dist/selinux install \
DESTDIR=%{buildroot}
%endif
install -m 0644 -D dist/libcare.service %{buildroot}%{_unitdir}/libcare.service
install -m 0644 -D dist/libcare.socket %{buildroot}%{_unitdir}/libcare.socket
install -m 0644 -D dist/libcare.preset %{buildroot}%{_presetdir}/90-libcare.preset
%pre
/usr/sbin/groupadd libcare -r 2>/dev/null || :
/usr/sbin/usermod -a -G libcare qemu 2>/dev/null || :
%post
%systemd_post libcare.service
%systemd_post libcare.socket
if [ $1 -eq 1 ]; then
# First install
systemctl start libcare.socket
fi
if [ $1 -eq 2 ]; then
# Upgrade. Just stop it, we will be reactivated
# by a connect to /run/libcare.sock
systemctl stop libcare.service
fi
%preun
%systemd_preun libcare.service
%systemd_preun libcare.socket
%postun
%systemd_postun libcare.service
%systemd_postun libcare.socket
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%{_bindir}/libcare-ctl
%{_bindir}/libcare-client
%{_unitdir}/libcare.service
%{_unitdir}/libcare.socket
%{_presetdir}/90-libcare.preset
%files devel
%defattr(-,root,root)
%{_bindir}/libcare-cc
%{_bindir}/libcare-patch-make
%{_bindir}/kpatch_gensrc
%{_bindir}/kpatch_strip
%{_bindir}/kpatch_make
%if 0%{with selinux}
%files selinux
%defattr(-,root,root,-)
%attr(0600,root,root) %{_datadir}/selinux/packages/libcare.pp
%post selinux
. /etc/selinux/config
FILE_CONTEXT=/etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts
cp ${FILE_CONTEXT} ${FILE_CONTEXT}.pre
/usr/sbin/semodule -i %{_datadir}/selinux/packages/libcare.pp
# Load the policy if SELinux is enabled
if ! /usr/sbin/selinuxenabled; then
# Do not relabel if selinux is not enabled
exit 0
fi
/usr/sbin/fixfiles -C ${FILE_CONTEXT}.pre restore 2> /dev/null
rm -f ${FILE_CONTEXT}.pre
exit 0
%postun selinux
if [ $1 -eq 0 ]; then
. /etc/selinux/config
FILE_CONTEXT=/etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts
cp ${FILE_CONTEXT} ${FILE_CONTEXT}.pre
# Remove the module
/usr/sbin/semodule -n -r libcare > /dev/null 2>&1
/usr/sbin/fixfiles -C ${FILE_CONTEXT}.pre restore 2> /dev/null
fi
exit 0
%endif
%changelog
* Tue Dec 8 2020 Ying Fang <fangying1@huawei.com>
- Init the libcareplus package spec

View File

@ -0,0 +1,31 @@
From 9221bb4ccd3f448fde2923df4598df17488978a9 Mon Sep 17 00:00:00 2001
From: Ying Fang <fangying1@huawei.com>
Date: Tue, 8 Dec 2020 15:18:19 +0800
Subject: [PATCH] src/Makefile: install kpatch_gensrc into bindir
Signed-off-by: Ying Fang <fangying1@huawei.com>
---
src/Makefile | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index 72ec073..22eb623 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -98,10 +98,8 @@ install: all
$(INSTALL) -m 0755 libcare-client $(DESTDIR)/$(bindir)/libcare-client
$(INSTALL) -m 0755 libcare-cc $(DESTDIR)/$(bindir)/libcare-cc
$(INSTALL) -m 0755 libcare-patch-make $(DESTDIR)/$(bindir)/libcare-patch-make
-
- $(INSTALL) -d $(DESTDIR)/$(libexecdir)/libcare
- $(INSTALL) -m 0755 kpatch_gensrc $(DESTDIR)/$(libexecdir)/libcare/kpatch_gensrc
- $(INSTALL) -m 0755 kpatch_make $(DESTDIR)/$(libexecdir)/libcare/kpatch_make
- $(INSTALL) -m 0755 kpatch_strip $(DESTDIR)/$(libexecdir)/libcare/kpatch_strip
+ $(INSTALL) -m 0755 kpatch_gensrc $(DESTDIR)/$(bindir)/kpatch_gensrc
+ $(INSTALL) -m 0755 kpatch_make $(DESTDIR)/$(bindir)/kpatch_make
+ $(INSTALL) -m 0755 kpatch_strip $(DESTDIR)/$(bindir)/kpatch_strip
.PHONY: all clean test tests tests-gensrc tests-strip
--
2.25.4