iSulad.spec 7.0 KB
Newer Older
L
lifeng68 已提交
1
%global _version 2.0.3
H
haozi007 已提交
2
%global _release 20200717.142859.git4c820d5f
O
overweight 已提交
3 4 5 6 7
%global is_systemd 1
%global debug_package %{nil}

Name:      iSulad
Version:   %{_version}
Z
zhuchunyi 已提交
8
Release:   %{_release}
O
overweight 已提交
9
Summary:   Lightweight Container Runtime Daemon
10
License:   Mulan PSL v2
L
LiuHao 已提交
11
URL:       isulad
L
LiFeng 已提交
12
Source:    iSulad-2.0.tar.gz
Z
zhuchunyi 已提交
13 14
BuildRoot: {_tmppath}/iSulad-%{version}
ExclusiveArch:  x86_64 aarch64
O
overweight 已提交
15 16 17

%ifarch x86_64 aarch64
Provides:       libhttpclient.so()(64bit)
L
LiuHao 已提交
18
Provides:       libisula.so()(64bit)
Z
Zhangxiaoyu 已提交
19
Provides:       libisulad_img.so()(64bit)
O
overweight 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32
%endif

%if 0%{?is_systemd}
# Systemd 230 and up no longer have libsystemd-journal
BuildRequires: pkgconfig(systemd)
Requires: systemd-units
%else
Requires(post): chkconfig
Requires(preun): chkconfig
# This is for /sbin/service
Requires(preun): initscripts
%endif

H
haozi007 已提交
33
BuildRequires: cmake gcc-c++ lxc lxc-devel lcr-devel yajl-devel clibcni-devel
W
wujing 已提交
34
BuildRequires: grpc grpc-plugins grpc-devel protobuf-devel
35
BuildRequires: libcurl libcurl-devel sqlite-devel libarchive-devel libtar-devel device-mapper-devel
H
haozi007 已提交
36
BuildRequires: http-parser-devel
W
wujing 已提交
37
BuildRequires: libseccomp-devel libcap-devel libselinux-devel libwebsockets libwebsockets-devel
H
haozi007 已提交
38
BuildRequires: systemd-devel git
O
overweight 已提交
39

H
haozi007 已提交
40
Requires:      iSulad-img lcr lxc clibcni
H
haozi007 已提交
41
Requires:      grpc protobuf
O
openeuler-iSula 已提交
42
Requires:      libcurl
O
overweight 已提交
43
Requires:      sqlite http-parser libseccomp
44
Requires:      libcap libselinux libwebsockets libarchive libtar device-mapper
H
haozi007 已提交
45
Requires:      systemd
O
overweight 已提交
46 47 48 49 50 51

%description
This is a umbrella project for gRPC-services based Lightweight Container
Runtime Daemon, written by C.

%prep
Z
zhuchunyi 已提交
52
%autosetup -c -n iSulad-%{version}
O
overweight 已提交
53 54 55 56 57 58 59 60 61 62 63

%build
mkdir -p build
cd build
%cmake -DDEBUG=OFF -DLIB_INSTALL_DIR=%{_libdir} -DCMAKE_INSTALL_PREFIX=/usr ../
%make_build

%install
rm -rf %{buildroot}
cd build
install -d $RPM_BUILD_ROOT/%{_libdir}
L
LiuHao 已提交
64
install -m 0644 ./src/libisula.so             %{buildroot}/%{_libdir}/libisula.so
L
lifeng68 已提交
65 66
install -m 0644 ./src/utils/http/libhttpclient.so  %{buildroot}/%{_libdir}/libhttpclient.so
install -m 0644 ./src/daemon/modules/image/libisulad_img.so   %{buildroot}/%{_libdir}/libisulad_img.so
O
overweight 已提交
67 68

install -d $RPM_BUILD_ROOT/%{_libdir}/pkgconfig
L
LiuHao 已提交
69
install -m 0640 ./conf/isulad.pc              %{buildroot}/%{_libdir}/pkgconfig/isulad.pc
O
overweight 已提交
70 71

install -d $RPM_BUILD_ROOT/%{_bindir}
L
LiuHao 已提交
72
install -m 0755 ./src/isula                  %{buildroot}/%{_bindir}/isula
73
install -m 0755 ./src/isulad-shim            %{buildroot}/%{_bindir}/isulad-shim
L
LiuHao 已提交
74
install -m 0755 ./src/isulad                  %{buildroot}/%{_bindir}/isulad
O
overweight 已提交
75

L
LiuHao 已提交
76
install -d $RPM_BUILD_ROOT/%{_includedir}/isulad
77
install -m 0644 ../src/client/libisula.h			%{buildroot}/%{_includedir}/isulad/libisula.h
78
install -m 0644 ../src/client/connect/isula_connect.h		%{buildroot}/%{_includedir}/isulad/isula_connect.h
L
lifeng68 已提交
79 80
install -m 0644 ../src/utils/cutils/utils_timestamp.h			%{buildroot}/%{_includedir}/isulad/utils_timestamp.h
install -m 0644 ../src/utils/cutils/error.h				%{buildroot}/%{_includedir}/isulad/error.h
L
lifeng68 已提交
81
install -m 0644 ../src/daemon/modules/runtime/engines/engine.h			%{buildroot}/%{_includedir}/isulad/engine.h
L
lifeng68 已提交
82
install -m 0644 ../src/daemon/modules/api/image_api.h         %{buildroot}/%{_includedir}/isulad/image_api.h
O
overweight 已提交
83 84 85 86 87

install -d $RPM_BUILD_ROOT/%{_sysconfdir}/isulad
install -m 0640 ../src/contrib/config/daemon.json           %{buildroot}/%{_sysconfdir}/isulad/daemon.json
install -m 0640 ../src/contrib/config/seccomp_default.json  %{buildroot}/%{_sysconfdir}/isulad/seccomp_default.json

L
LiuHao 已提交
88 89 90 91
install -d $RPM_BUILD_ROOT/%{_sysconfdir}/default/isulad
install -m 0640 ../src/contrib/config/config.json           %{buildroot}/%{_sysconfdir}/default/isulad/config.json
install -m 0640 ../src/contrib/config/systemcontainer_config.json           %{buildroot}/%{_sysconfdir}/default/isulad/systemcontainer_config.json
install -m 0550 ../src/contrib/sysmonitor/isulad-check.sh        %{buildroot}/%{_sysconfdir}/default/isulad/isulad-check.sh
O
overweight 已提交
92 93 94 95

mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysmonitor/process
cp ../src/contrib/sysmonitor/isulad-monit $RPM_BUILD_ROOT/etc/sysmonitor/process

L
LiuHao 已提交
96 97
install -d $RPM_BUILD_ROOT/%{_sysconfdir}/default/isulad/hooks
install -m 0640 ../src/contrib/config/hooks/default.json %{buildroot}/%{_sysconfdir}/default/isulad/hooks/default.json
O
overweight 已提交
98 99 100 101 102 103

install -d $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
install -p -m 0640 ../src/contrib/config/iSulad.sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/iSulad

%if 0%{?is_systemd}
install -d $RPM_BUILD_ROOT/%{_unitdir}
L
LiuHao 已提交
104
install -p -m 0640 ../src/contrib/init/isulad.service $RPM_BUILD_ROOT/%{_unitdir}/isulad.service
O
overweight 已提交
105 106
%else
install -d $RPM_BUILD_ROOT/%{_initddir}
L
LiuHao 已提交
107
install -p -m 0640 ../src/contrib/init/isulad.init $RPM_BUILD_ROOT/%{_initddir}/isulad.init
O
overweight 已提交
108 109 110 111 112
%endif

%clean
rm -rf %{buildroot}

L
LiuHao 已提交
113 114
%pre
# support update from lcrd to isulad, will remove in next version
H
haozi007 已提交
115
if [ "$1" = "2" ]; then
L
LiuHao 已提交
116 117 118 119 120 121 122 123 124
%if 0%{?is_systemd}
systemctl stop lcrd
systemctl disable lcrd
if [ -e %{_sysconfdir}/isulad/daemon.json ];then
    sed -i 's#/etc/default/lcrd/hooks#/etc/default/isulad/hooks#g' %{_sysconfdir}/isulad/daemon.json
fi
%else
/sbin/chkconfig --del lcrd
%endif
H
haozi007 已提交
125
fi
L
LiuHao 已提交
126

O
overweight 已提交
127
%post
L
LiuHao 已提交
128 129
if ! getent group isulad > /dev/null; then
    groupadd --system isulad
O
overweight 已提交
130 131 132 133
fi

if [ "$1" = "1" ]; then
%if 0%{?is_systemd}
L
LiuHao 已提交
134 135
systemctl enable isulad
systemctl start isulad
O
overweight 已提交
136
%else
L
LiuHao 已提交
137
/sbin/chkconfig --add isulad
O
overweight 已提交
138 139 140
%endif
elif [ "$1" = "2" ]; then
%if 0%{?is_systemd}
L
LiuHao 已提交
141 142 143 144 145 146
# support update from lcrd to isulad, will remove in next version
if [ -e %{_unitdir}/lcrd.service.rpmsave ]; then
    mv %{_unitdir}/lcrd.service.rpmsave %{_unitdir}/isulad.service
    sed -i 's/lcrd/isulad/g' %{_unitdir}/isulad.service
fi
systemctl status isulad | grep 'Active:' | grep 'running'
O
overweight 已提交
147
if [ $? -eq 0 ]; then
L
LiuHao 已提交
148 149 150
  systemctl restart isulad
else
  systemctl start isulad
O
overweight 已提交
151 152
fi
%else
L
LiuHao 已提交
153
/sbin/service isulad status | grep 'Active:' | grep 'running'
O
overweight 已提交
154
if [ $? -eq 0 ]; then
L
LiuHao 已提交
155
  /sbin/service isulad restart
O
overweight 已提交
156 157 158 159
fi
%endif
fi

L
LiuHao 已提交
160 161
if ! getent group isulad > /dev/null; then
    groupadd --system isulad
O
overweight 已提交
162 163 164 165
fi

%preun
%if 0%{?is_systemd}
L
LiuHao 已提交
166
%systemd_preun isulad
O
overweight 已提交
167 168
%else
if [ $1 -eq 0 ] ; then
L
LiuHao 已提交
169 170
    /sbin/service isulad stop >/dev/null 2>&1
    /sbin/chkconfig --del isulad
O
overweight 已提交
171 172 173 174 175
fi
%endif

%postun
%if 0%{?is_systemd}
L
LiuHao 已提交
176
%systemd_postun_with_restart isulad
O
overweight 已提交
177 178
%else
if [ "$1" -ge "1" ] ; then
L
LiuHao 已提交
179
    /sbin/service isulad condrestart >/dev/null 2>&1 || :
O
overweight 已提交
180 181 182 183 184
fi
%endif

%files
%attr(0600,root,root) %{_sysconfdir}/sysmonitor/process/isulad-monit
L
LiuHao 已提交
185
%attr(0550,root,root) %{_sysconfdir}/default/isulad/isulad-check.sh
O
overweight 已提交
186
%defattr(0640,root,root,0750)
Z
zhuchunyi 已提交
187
%{_sysconfdir}/isulad
O
overweight 已提交
188 189 190 191
%{_sysconfdir}/isulad/*
%{_sysconfdir}/default/*
%defattr(-,root,root,-)
%if 0%{?is_systemd}
L
LiuHao 已提交
192 193
%{_unitdir}/isulad.service
%attr(0640,root,root) %{_unitdir}/isulad.service
O
overweight 已提交
194
%else
L
LiuHao 已提交
195 196
%{_initddir}/isulad.init
%attr(0640,root,root) %{_initddir}/isulad.init
O
overweight 已提交
197
%endif
L
LiuHao 已提交
198
%{_includedir}/isulad/*
O
overweight 已提交
199
%attr(0755,root,root) %{_libdir}/pkgconfig
L
LiuHao 已提交
200
%attr(0640,root,root) %{_libdir}/pkgconfig/isulad.pc
O
overweight 已提交
201 202 203 204 205 206 207 208 209
%defattr(0550,root,root,0750)
%{_bindir}/*
%{_libdir}/*
%attr(0640,root,root) %{_sysconfdir}/sysconfig/iSulad
%attr(0640,root,root) %{_sysconfdir}/isulad/daemon.json

%config(noreplace,missingok) %{_sysconfdir}/sysconfig/iSulad
%config(noreplace,missingok) %{_sysconfdir}/isulad/daemon.json
%if 0%{?is_systemd}
L
LiuHao 已提交
210
%config(noreplace,missingok) %{_unitdir}/isulad.service
O
overweight 已提交
211
%else
L
LiuHao 已提交
212
%config(noreplace,missingok) %{_initddir}/isulad.init
O
overweight 已提交
213
%endif