iSulad.spec 6.8 KB
Newer Older
1
%global _version 1.1.11
L
LiuHao 已提交
2
%global _release 20200213.091554.git2cbd4087
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
BuildRequires: http-parser-devel libevhtp-devel libevent-devel
BuildRequires: libseccomp-devel libcap-devel libwebsockets libwebsockets-devel
BuildRequires: systemd-devel git

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

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

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

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

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

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

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