dracut conf: Add ipmi_ssif to initrd
[ta/image-provision.git] / image-provision.spec
1 # Copyright 2019 Nokia
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 Name:       image-provision
16 Version:    %{_version}
17 Release:    3%{?dist}
18 Summary:    Contains dracut modules used for provisioning master image from a boot CD.
19 License:    %{_platform_licence}
20 Source0:    %{name}-%{version}.tar.gz
21 Vendor:     %{_platform_vendor}
22 BuildArch:  noarch
23
24 BuildRequires: rsync
25 Requires: cloud-init, dracut, coreutils, parted, gzip, iproute, util-linux, findutils, kmod, kbd, iscsi-initiator-utils, qemu-img-ev, gdisk, tar, wget, curl, glibc, hw-detector
26
27 %description
28 This RPM contains dracut modules. They are used for provisioning master image from a boot CD.
29
30 %prep
31 %autosetup
32
33 %build
34
35 %install
36 mkdir -p %{buildroot}/usr/lib/dracut/modules.d/
37 mkdir -p %{buildroot}/etc/
38
39 rsync -av dracut/modules/00installmedia %{buildroot}/usr/lib/dracut/modules.d/
40 rsync -av dracut/modules/00readfloppyconf %{buildroot}/usr/lib/dracut/modules.d/
41 rsync -av dracut/modules/00readcdconf %{buildroot}/usr/lib/dracut/modules.d/
42 rsync -av dracut/modules/00netconfig %{buildroot}/usr/lib/dracut/modules.d/
43 rsync -av dracut/conf/dracut-provision.conf  %{buildroot}/etc/
44
45 %files
46 %defattr(0755,root,root)
47 /etc/dracut-provision.conf
48 /usr/lib/dracut/modules.d/00installmedia
49 /usr/lib/dracut/modules.d/00readfloppyconf
50 /usr/lib/dracut/modules.d/00readcdconf
51 /usr/lib/dracut/modules.d/00netconfig
52
53 %pre
54
55 %post
56 # Get the lateset kernel version, and prepare provisioning initrd based on it.
57 KVER=`ls --sort=v /boot/vmlinuz-* |grep -v rescue| tail -n1 |awk -F '/boot/vmlinuz-' '{print $2}'`
58 /usr/bin/dracut --nostrip --local --keep -f /boot/initrd-provisioning.img -M --nofscks --nomdadmconf --tmpdir /tmp --libdirs "/lib /lib64  /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64" --conf /etc/dracut-provision.conf --kver $KVER --confdir /usr/lib/dracut/dracut.conf.d/
59
60 #Disable network service. This is delaying boot due to dhcp retries. Normally ifcfg is good enough for single tries.
61 /bin/systemctl --no-reload disable network.service >/dev/null 2>&1 || :
62
63 # Diabling cloud-init services as we don't need any metadata quiery as done by cloud-init.
64 # We use cloud-init libraries to do growpart and resizefs. So  we need clould-init packages still.
65 #/bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || :
66 #/bin/systemctl --no-reload disable cloud-final.service  >/dev/null 2>&1 || :
67 #/bin/systemctl --no-reload disable cloud-init.service   >/dev/null 2>&1 || :
68 #/bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || :
69
70 # This is a temporary fix, for udev net rename rules. The guest image choosen as base image, removes the below file.
71 # When we build our own guest image, we can remove this fix from here.
72 if [ -h /etc/udev/rules.d/80-net-name-slot.rules ];then
73   unlink /etc/udev/rules.d/80-net-name-slot.rules
74 fi
75
76 grep -q "net.ifnames=0" /etc/default/grub
77 if [[ $? == 0 ]];then
78   sed -i 's/net.ifnames=0 //' /etc/default/grub
79   grub2-mkconfig > /etc/grub2.cfg
80 fi
81
82
83 echo "%{_name} has been succesfully installed"
84
85 %preun
86
87 %postun
88
89 %clean
90 rm -rf %{buildroot}
91
92 # TIPS:
93 # File /usr/lib/rpm/macros contains useful variables which can be used for example to define target directory for man page.