Arch-specific builds, aarch64 support
[ta/ipa-deployer.git] / ipa-deployer.spec
1 Name: ipa-deployer
2 Version: %{_version}
3 Release: 1%{?dist}
4 Summary: Deployment image for ironic python agent
5
6 License: %{_platform_licence}
7 Source0: %{name}-%{version}.tar.gz
8 Vendor:  %{_platform_vendor}
9
10 BuildRequires: qemu-img-ev which sudo PyYAML e2fsprogs genisoimage wget kernel python2-ironic-python-agent python-ironic-lib python-devel xz python-pip gdisk dosfstools util-linux
11 %ifarch x86_64 amd64
12 BuildRequires: syslinux
13 %endif
14
15 %define dib_selinuxfile elements/rpm-distro/cleanup.d/99-selinux-fixfiles-restore
16 %define dib_epel elements/epel/pre-install.d/05-rpm-epel-release
17 %ifarch x86_64 amd64
18 %define centos_cloudimg https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1801-01.qcow2
19 %define centos_mirror http://mirror.centos.org/centos/7
20 %else
21 %define centos_cloudimg https://cloud.centos.org/altarch/7/images/aarch64/CentOS-7-aarch64-GenericCloud-1708.qcow2.xz
22 %define centos_cloudimg_xz 1
23 %define centos_mirror http://mirror.centos.org/altarch/7
24 %define dib_block_device_efi 1
25 %endif
26 %define centos_efibootimg %{centos_mirror}/os/%{_arch}/images/efiboot.img
27 %define centos_efidir %{centos_mirror}/os/%{_arch}/EFI
28
29 %description
30 Deployment image for ironic python agent image
31
32 %prep
33 %autosetup
34
35 %build
36 sudo pip install diskimage-builder==2.26.1
37 sudo rm -rf %{python2_sitelib}/diskimage_builder/%{dib_selinuxfile} %{_datarootdir}ยง/diskimage-builder/%{dib_selinuxfile} %{python2_sitelib}/diskimage_builder/elements/epel/pre-install.d/05-rpm-epel-release
38 cp /etc/yum.conf work/local.repo
39 wget --progress=dot:giga %{centos_cloudimg} -O CentOS.qcow2%{?centos_cloudimg_xz:.xz}
40 %if 0%{?centos_cloudimg_xz:1}
41 unxz CentOS.qcow2.xz
42 %endif
43 url=%{centos_efidir}/
44 wget --progress=dot:giga %{centos_efibootimg} -O efiboot.img
45 cut_dirs=$(echo $url | sed -re 's|.*://[^/]+/(.+)|\1|' -e 's|/$||' | grep -o / | wc -l)
46 wget -N -r --no-host-directories --no-verbose --cut-dirs=${cut_dirs} --reject index.html* --no-parent $url
47 DIB_DEBUG_TRACE=1 \
48   ELEMENTS_PATH="${PWD}/work/dib-ipa-element/" \
49   DIB_LOCAL_IMAGE="file://${PWD}/CentOS.qcow2" \
50   DIB_YUM_REPO_CONF="work/local.repo" \
51   DIB_LOCAL_REPO="/usr/localrepo/" \
52   break=after-error /usr/bin/disk-image-create  --install-type package localrepo centos7 virtmedia-netconf ironic-agent %{?dib_block_device_efi:block-device-efi}
53
54 if [[ $? == 0 ]]; then
55   work/iso-image-create -o ./ironic-deploy.iso -i ./image.initramfs -k ./image.vmlinuz -e ./efiboot.img -E ./EFI
56 else
57   echo "Failed to run disk-image-create"
58 fi
59
60 %install
61 mkdir -p %{buildroot}/opt/images/
62 rsync -av ironic-deploy.iso %{buildroot}/opt/images/
63
64 %files
65 %defattr(0755,root,root)
66 /opt/images/