Add kernel version for emgd kernel driver
[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 kernel_version %(ls -d /lib/modules/*automotive|sed "s:/lib/modules/::")
24 %define modpath /lib/modules/%{kernel_version}/kernel/drivers/gpu/drm/emgd
25
26 Name: intel-emgd-kmod
27 Summary: Intel EMGD kernel module
28 Version: 2667
29 Release: 1%{?dist}
30 License: GPL v2
31 Vendor: Intel
32 Group: System Environment/Kernel
33 BuildRoot: %{_tmppath}/%{name}-%{version}
34 Source0: %{name}-%{version}.tar.gz
35 Source1: intel-emgd-kmod.service
36 Source2: intel-emgd-kmod.init
37 BuildRequires: kernel-adaptation-intel-automotive-devel, kmod
38 Requires: pciutils, kmod
39
40 %description
41 Intel EMGD kernel module for kernel
42
43 %prep
44 %setup -q
45
46 %build
47 make
48
49 %install
50
51 mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system/
52 mkdir -p $RPM_BUILD_ROOT/usr/libexec/
53 install -m 755 -d $RPM_BUILD_ROOT%{modpath}
54 install -m 744 emgd.ko $RPM_BUILD_ROOT%{modpath}
55 install -m 755 -D %{SOURCE1} $RPM_BUILD_ROOT/usr/lib/systemd/system/
56 install -m 755 -D %{SOURCE2} $RPM_BUILD_ROOT/usr/libexec/
57
58 %clean  
59 rm -Rf $RPM_BUILD_ROOT
60
61 %post 
62 ## create the dependency of kernel modules
63 /sbin/depmod -av %{kernel_version} >/dev/null 2>&1 
64
65 mkdir -p /usr/lib/systemd/system/basic.target.wants/
66 pushd /usr/lib/systemd/system/basic.target.wants/
67 ln -sf ../intel-emgd-kmod.service intel-emgd-kmod.service
68 popd
69
70 if [ -x /bin/systemctl ]; then
71     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
72     /bin/systemctl start intel-emgd-kmod.service > /dev/null 2>&1 || :
73 fi
74
75 %postun
76 /sbin/depmod -av %{kernel_version} >/dev/null 2>&1 
77 rm -f /usr/lib/systemd/system/basic.target.wants/intel-emgd-kmod.service
78 if [ -x /bin/systemctl ]; then
79     systemctl daemon-reload >/dev/null 2>&1 || :
80 fi
81
82 %preun
83 if [ -x /bin/systemctl ]; then
84     sytemctl stop intel-emgd-kmod.service >/dev/null 2>&1 || :
85 fi
86
87 %files 
88 %defattr(-,root,root,-)
89 %{modpath}/emgd.ko
90 %{_libdir}/systemd/system/intel-emgd-kmod.service
91 /usr/libexec/intel-emgd-kmod.init