iSulad.spec 6.8 KB
Newer Older
L
LiFeng 已提交
1
%global _version 2.0.0
2
%global _release 20200321.032232.gitaec8336d
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 10
Summary:   Lightweight Container Runtime Daemon
License:   Mulan PSL v1
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)
O
overweight 已提交
19 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

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

W
WangFengTu 已提交
39
Requires:      iSulad-img lcr lxc clibcni
O
overweight 已提交
40
Requires:      grpc protobuf yajl
O
openeuler-iSula 已提交
41
Requires:      libcurl
O
overweight 已提交
42
Requires:      sqlite http-parser libseccomp
W
wujing 已提交
43
Requires:      libcap libselinux libwebsockets
H
haozi007 已提交
44
Requires:      systemd
O
overweight 已提交
45 46 47 48 49 50

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

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

%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 已提交
63
install -m 0644 ./src/libisula.so             %{buildroot}/%{_libdir}/libisula.so
O
overweight 已提交
64 65 66
install -m 0644 ./src/http/libhttpclient.so  %{buildroot}/%{_libdir}/libhttpclient.so

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

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

L
LiuHao 已提交
74 75 76 77 78 79 80
install -d $RPM_BUILD_ROOT/%{_includedir}/isulad
install -m 0644 ../src/libisula.h                        %{buildroot}/%{_includedir}/isulad/libisula.h
install -m 0644 ../src/connect/client/isula_connect.h    %{buildroot}/%{_includedir}/isulad/isula_connect.h
install -m 0644 ../src/container_def.h                  %{buildroot}/%{_includedir}/isulad/container_def.h
install -m 0644 ../src/types_def.h                      %{buildroot}/%{_includedir}/isulad/types_def.h
install -m 0644 ../src/error.h                          %{buildroot}/%{_includedir}/isulad/error.h
install -m 0644 ../src/engines/engine.h                 %{buildroot}/%{_includedir}/isulad/engine.h
O
overweight 已提交
81 82 83 84 85

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 已提交
86 87 88 89
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 已提交
90 91 92 93

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

L
LiuHao 已提交
94 95
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 已提交
96 97 98 99 100 101

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 已提交
102
install -p -m 0640 ../src/contrib/init/isulad.service $RPM_BUILD_ROOT/%{_unitdir}/isulad.service
O
overweight 已提交
103 104
%else
install -d $RPM_BUILD_ROOT/%{_initddir}
L
LiuHao 已提交
105
install -p -m 0640 ../src/contrib/init/isulad.init $RPM_BUILD_ROOT/%{_initddir}/isulad.init
O
overweight 已提交
106 107 108 109 110
%endif

%clean
rm -rf %{buildroot}

L
LiuHao 已提交
111 112
%pre
# support update from lcrd to isulad, will remove in next version
H
haozi007 已提交
113
if [ "$1" = "2" ]; then
L
LiuHao 已提交
114 115 116 117 118 119 120 121 122
%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 已提交
123
fi
L
LiuHao 已提交
124

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

if [ "$1" = "1" ]; then
%if 0%{?is_systemd}
L
LiuHao 已提交
132 133
systemctl enable isulad
systemctl start isulad
O
overweight 已提交
134
%else
L
LiuHao 已提交
135
/sbin/chkconfig --add isulad
O
overweight 已提交
136 137 138
%endif
elif [ "$1" = "2" ]; then
%if 0%{?is_systemd}
L
LiuHao 已提交
139 140 141 142 143 144
# 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 已提交
145
if [ $? -eq 0 ]; then
L
LiuHao 已提交
146 147 148
  systemctl restart isulad
else
  systemctl start isulad
O
overweight 已提交
149 150
fi
%else
L
LiuHao 已提交
151
/sbin/service isulad status | grep 'Active:' | grep 'running'
O
overweight 已提交
152
if [ $? -eq 0 ]; then
L
LiuHao 已提交
153
  /sbin/service isulad restart
O
overweight 已提交
154 155 156 157
fi
%endif
fi

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

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

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

%files
%attr(0600,root,root) %{_sysconfdir}/sysmonitor/process/isulad-monit
L
LiuHao 已提交
183
%attr(0550,root,root) %{_sysconfdir}/default/isulad/isulad-check.sh
O
overweight 已提交
184
%defattr(0640,root,root,0750)
Z
zhuchunyi 已提交
185
%{_sysconfdir}/isulad
O
overweight 已提交
186 187 188 189
%{_sysconfdir}/isulad/*
%{_sysconfdir}/default/*
%defattr(-,root,root,-)
%if 0%{?is_systemd}
L
LiuHao 已提交
190 191
%{_unitdir}/isulad.service
%attr(0640,root,root) %{_unitdir}/isulad.service
O
overweight 已提交
192
%else
L
LiuHao 已提交
193 194
%{_initddir}/isulad.init
%attr(0640,root,root) %{_initddir}/isulad.init
O
overweight 已提交
195
%endif
L
LiuHao 已提交
196
%{_includedir}/isulad/*
O
overweight 已提交
197
%attr(0755,root,root) %{_libdir}/pkgconfig
L
LiuHao 已提交
198
%attr(0640,root,root) %{_libdir}/pkgconfig/isulad.pc
O
overweight 已提交
199 200 201 202 203 204 205 206 207
%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 已提交
208
%config(noreplace,missingok) %{_unitdir}/isulad.service
O
overweight 已提交
209
%else
L
LiuHao 已提交
210
%config(noreplace,missingok) %{_initddir}/isulad.init
O
overweight 已提交
211
%endif