iSulad.spec 6.7 KB
Newer Older
L
LiuHao 已提交
1 2
%global _version 1.1.9
%global _release 20200117.155343.git2978558a
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
Z
zhuchunyi 已提交
12 13 14
Source:    iSulad-1.0.tar.gz
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
O
openeuler-iSula 已提交
33
BuildRequires: grpc grpc-devel protobuf-devel
O
openeuler-iSula 已提交
34
BuildRequires: libcurl libcurl-devel sqlite-devel
O
overweight 已提交
35 36 37 38 39 40
BuildRequires: http-parser-devel libevhtp-devel libevent-devel
BuildRequires: libseccomp-devel libcap-devel libwebsockets libwebsockets-devel
BuildRequires: systemd-devel git

Requires:      iSulad-kit lcr lxc clibcni
Requires:      grpc protobuf yajl
O
openeuler-iSula 已提交
41
Requires:      libcurl
O
overweight 已提交
42 43 44 45 46 47 48 49 50
Requires:      sqlite http-parser libseccomp
Requires:      libcap libwebsockets
Requires:      libevhtp libevent systemd

%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 71
install -m 0755 ./src/isula                  %{buildroot}/%{_bindir}/isula
install -m 0755 ./src/isulad                  %{buildroot}/%{_bindir}/isulad
O
overweight 已提交
72

L
LiuHao 已提交
73 74 75 76 77 78 79
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 已提交
80 81 82 83 84

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

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

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

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

%clean
rm -rf %{buildroot}

L
LiuHao 已提交
110 111 112 113 114 115 116 117 118 119 120 121
%pre
# support update from lcrd to isulad, will remove in next version
%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

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

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

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

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

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

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