Add kernel version dependency
[profile/ivi/intel-emgd-kmod.git] / packaging / intel-emgd-kmod.spec
1 #----------------------------------------------------------------------------
2 # Copyright (c) 2002-2010, Intel Corporation.
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
10 #
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 # THE SOFTWARE.
21 #----------------------------------------------------------------------------
22
23 %define debug_package %{nil}
24 %define kernel_number_str "%(/bin/rpm -q kernel-adaptation-intel-automotive --queryformat \"%{VERSION}-%{RELEASE}\"|grep -iv 'installed')"
25 %define kernel_number %(echo %{kernel_number_str})
26 %define kernel_version %{kernel_number}-adaptation-intel-automotive
27 %define modpath /lib/modules/%{kernel_version}/kernel/drivers/gpu/drm/emgd
28
29 Name: intel-emgd-kmod
30 Summary: Intel EMGD kernel module
31 Version: 2667
32 Release: 1%{?dist}
33 License: GPL v2
34 Vendor: Intel
35 Group: System Environment/Kernel
36 BuildRoot: %{_tmppath}/%{name}-%{version}
37 Source0: %{name}-%{version}.tar.gz
38 Source1: intel-emgd-kmod.service
39 Source2: intel-emgd-kmod.init
40 BuildRequires: kernel-adaptation-intel-automotive-devel, kmod, rpm
41 Requires: pciutils, kmod, kernel-adaptation-intel-automotive
42
43 %description
44 Intel EMGD kernel module for kernel
45
46 %if %{kernel_number_str} != ""
47 %package %{kernel_number}
48 Summary: Intel EMGD kernel module
49 Group: System Environment/Kernel
50 Requires: pciutils, kmod
51 Requires: kernel-adaptation-intel-automotive = %{kernel_number}
52
53 %description %{kernel_number}
54 Intel EMGD kernel module for kernel
55 %endif
56
57 %prep
58 %setup -q
59
60 %build
61 make
62
63 %install
64
65 mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system/
66 mkdir -p $RPM_BUILD_ROOT/usr/libexec/
67 install -m 755 -d $RPM_BUILD_ROOT%{modpath}
68 install -m 744 emgd.ko $RPM_BUILD_ROOT%{modpath}
69 install -m 755 -D %{SOURCE1} $RPM_BUILD_ROOT/usr/lib/systemd/system/
70 install -m 755 -D %{SOURCE2} $RPM_BUILD_ROOT/usr/libexec/
71
72 %clean  
73 rm -Rf $RPM_BUILD_ROOT
74
75 %post %{kernel_number}
76 ## create the dependency of kernel modules
77 /sbin/depmod -av %{kernel_version} >/dev/null 2>&1 
78
79 mkdir -p /usr/lib/systemd/system/basic.target.wants/
80 pushd /usr/lib/systemd/system/basic.target.wants/
81 ln -sf ../intel-emgd-kmod.service intel-emgd-kmod.service
82 popd
83
84 if [ -x /bin/systemctl ]; then
85     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
86     /bin/systemctl start intel-emgd-kmod.service > /dev/null 2>&1 || :
87 fi
88
89 %postun %{kernel_number}
90 /sbin/depmod -av %{kernel_version} >/dev/null 2>&1 
91 rm -f /usr/lib/systemd/system/basic.target.wants/intel-emgd-kmod.service
92 if [ -x /bin/systemctl ]; then
93     systemctl daemon-reload >/dev/null 2>&1 || :
94 fi
95
96 %preun %{kernel_number}
97 if [ -x /bin/systemctl ]; then
98     sytemctl stop intel-emgd-kmod.service >/dev/null 2>&1 || :
99 fi
100
101 %files %{kernel_number}
102 %defattr(-,root,root,-)
103 %{modpath}/emgd.ko
104 %{_libdir}/systemd/system/intel-emgd-kmod.service
105 /usr/libexec/intel-emgd-kmod.init