From 1cd1737508b04756eff949ca6e5c9dd6d571fed2 Mon Sep 17 00:00:00 2001 From: "Kun(llfl)" Date: Sat, 8 Apr 2023 18:14:57 +0800 Subject: [PATCH] optimize spec file Signed-off-by: Kun(llfl) --- 1001-build-without-ath9k-drivers.patch | 31 ++++ ipxe.spec | 189 ++++++++++++------------- 2 files changed, 123 insertions(+), 97 deletions(-) create mode 100644 1001-build-without-ath9k-drivers.patch diff --git a/1001-build-without-ath9k-drivers.patch b/1001-build-without-ath9k-drivers.patch new file mode 100644 index 0000000..da681e8 --- /dev/null +++ b/1001-build-without-ath9k-drivers.patch @@ -0,0 +1,31 @@ +From 213a28d4f8a778e96eddf3b043c1e73de57ed928 Mon Sep 17 00:00:00 2001 +Message-Id: <213a28d4f8a778e96eddf3b043c1e73de57ed928.1681009156.git.llfl@linux.alibaba.com> +From: "Kun(llfl)" +Date: Sun, 9 Apr 2023 10:56:09 +0800 +Subject: [PATCH] build without ath9k drivers + +ath9k drivers are too big for an Option ROM, and ipxe devs say it doesn't make sense anyways. Details in the link below: + +http://lists.ipxe.org/pipermail/ipxe-devel/2012-March/001290.html + +Signed-off-by: Kun(llfl) +--- + src/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Makefile b/src/Makefile +index 4c4abf1..773832a 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -110,7 +110,7 @@ SRCDIRS_INSEC += net/80211 + SRCDIRS_INSEC += drivers/net/rtl818x + SRCDIRS_INSEC += drivers/net/ath + SRCDIRS_INSEC += drivers/net/ath/ath5k +-SRCDIRS_INSEC += drivers/net/ath/ath9k ++#SRCDIRS_INSEC += drivers/net/ath/ath9k + + # NON_AUTO_SRCS lists files that are excluded from the normal + # automatic build system. +-- +2.39.0 + diff --git a/ipxe.spec b/ipxe.spec index 6d3c802..7b428af 100644 --- a/ipxe.spec +++ b/ipxe.spec @@ -1,64 +1,61 @@ -%define anolis_release 2 +%define anolis_release 3 -# ROMS we want for QEMU with format PCIID:QEMUNAME +# We don't want to ship debuginfo packages for this package +# because they are firmwares of ROMS, and we should not +# treat them as a normal program. +%global debug_package %{nil} + +# QEMU ROMS with format VENDORID:DEVICEID-QEMUNAME %global qemuroms \\\ - 8086100e:e1000 \\\ - 10ec8139:rtl8139 \\\ - 1af41000:virtio \\\ - 808610d3:e1000e + 8086:100e-e1000 \\\ + 8086:10d3-e1000e \\\ + 10ec:8139-rtl8139 \\\ + 1af4:1000-virtio # We only build the ROMs if on an EFI build host. The resulting # binary RPM will be noarch, so other archs will still be able # to use the binary ROMs. %global buildarches x86_64 aarch64 -# debugging firmwares does not go the same way as a normal program. -# moreover, all architectures providing debuginfo for a single noarch -# package is currently clashing in koji, so don't bother. -%global debug_package %{nil} - -# Upstream don't do "releases" :-( So we're going to use the date +# Upstream don't have "releases" verion. So we're going to use the date # as the version, and a GIT hash as the release. Generate new GIT # snapshots using the folowing commands: # -# $ hash=`git log -1 --format='%h'` +# $ git_hash=`git log -1 --format='%h'` # $ date=`git log -1 --format='%cd' --date=short | tr -d -` -# $ git archive --prefix ipxe-${date}-git${hash}/ ${hash} | xz -7e > ipxe-${date}-git${hash}.tar.xz +# $ git archive --prefix ipxe-${date}-git${git_hash}/ ${git_hash} | xz -7e > ipxe-${date}-git${git_hash}.tar.xz # # And then change these two: -%global hash 64113751 +%global git_hash 64113751 %global date 20220210 Name: ipxe -Version: %{date}.git%{hash} +Version: %{date}.git%{git_hash} Release: %{anolis_release}%{?dist} Summary: A network boot loader License: GPLv2 with additional permissions and BSD URL: http://ipxe.org/ -Source0: %{name}-%{date}-git%{hash}.tar.xz +Source0: https://github.com/%{name}/%{name}/%{name}-%{date}-git%{git_hash}.tar.xz # Enable IPv6 for qemu's config # Sent upstream: http://lists.ipxe.org/pipermail/ipxe-devel/2015-November/004494.html Patch0001: 0001-build-customize-configuration.patch Patch0002: 0002-Use-spec-compliant-timeouts.patch +Patch1001: 1001-build-without-ath9k-drivers.patch -BuildRequires: perl-interpreter -BuildRequires: perl-Getopt-Long -BuildRequires: perl-FindBin -BuildRequires: perl-lib -%ifarch x86_64 -BuildRequires: syslinux -%endif +BuildRequires: binutils-devel gcc make +BuildRequires: perl-FindBin perl-Getopt-Long perl-interpreter perl-lib +BuildRequires: edk2-tools BuildRequires: mtools BuildRequires: xorriso -BuildRequires: edk2-tools BuildRequires: xz-devel -BuildRequires: gcc -BuildRequires: binutils-devel -BuildRequires: make + +%ifarch x86_64 +BuildRequires: syslinux +%endif Obsoletes: gpxe <= 1.0.1 @@ -82,28 +79,22 @@ BuildArch: noarch Obsoletes: gpxe-roms-qemu <= 1.0.1 %description bootimgs-x86 -iPXE is an open source network bootloader. It provides a direct -replacement for proprietary PXE ROMs, with many extra features such as -DNS, HTTP, iSCSI, etc. +iPXE is a network bootloader that is open-source and offers a direct alternative to proprietary PXE ROMs. Additionally, it comes with various additional features such as DNS, HTTP, iSCSI, and more. This package contains the iPXE boot images in USB, CD, floppy, and PXE UNDI formats. %description roms -iPXE is an open source network bootloader. It provides a direct -replacement for proprietary PXE ROMs, with many extra features such as -DNS, HTTP, iSCSI, etc. +iPXE is a network bootloader that is open-source and offers a direct alternative to proprietary PXE ROMs. Additionally, it comes with various additional features such as DNS, HTTP, iSCSI, and more. This package contains the iPXE roms in .rom format. - %description roms-qemu -iPXE is an open source network bootloader. It provides a direct -replacement for proprietary PXE ROMs, with many extra features such as -DNS, HTTP, iSCSI, etc. +iPXE is a network bootloader that is open-source and offers a direct alternative to proprietary PXE ROMs. Additionally, it comes with various additional features such as DNS, HTTP, iSCSI, and more. This package contains the iPXE ROMs for devices emulated by QEMU, in .rom format. + %endif %ifarch aarch64 @@ -112,72 +103,67 @@ Summary: ARM Network boot loader images in bootable USB and GRUB formats BuildArch: noarch %description bootimgs-aarch64 -iPXE is an open source network bootloader. It provides a direct -replacement for proprietary PXE ROMs, with many extra features such as -DNS, HTTP, iSCSI, etc. +iPXE is a network bootloader that is open-source and offers a direct alternative to proprietary PXE ROMs. Additionally, it comes with various additional features such as DNS, HTTP, iSCSI, and more. This package contains the iPXE ARM boot images in USB and GRUB formats. + %endif %description -iPXE is an open source network bootloader. It provides a direct -replacement for proprietary PXE ROMs, with many extra features such as -DNS, HTTP, iSCSI, etc. +iPXE is a network bootloader that is open-source and offers a direct alternative to proprietary PXE ROMs. Additionally, it comes with various additional features such as DNS, HTTP, iSCSI, and more. %prep -%autosetup -n %{name}-%{date}-git%{hash} -p1 -# ath9k drivers are too big for an Option ROM, and ipxe devs say it doesn't -# make sense anyways -# http://lists.ipxe.org/pipermail/ipxe-devel/2012-March/001290.html -rm -rf src/drivers/net/ath/ath9k +%autosetup -n %{name}-%{date}-git%{git_hash} -p1 %build cd src - -make_ipxe() { - make %{?_smp_mflags} \ +ipxe_build() { + %make_build \ + GITVERSION=%{git_hash} \ NO_WERROR=1 V=1 \ - GITVERSION=%{hash} \ "$@" } %ifarch x86_64 -make_ipxe bin-x86_64-efi/ipxe.efi \ - bin-x86_64-efi/snponly.efi +ipxe_build bin-x86_64-efi/ipxe.efi \ + bin-x86_64-efi/snponly.efi -make_ipxe ISOLINUX_BIN=/usr/share/syslinux/isolinux.bin \ - bin/undionly.kpxe bin/ipxe.{dsk,iso,usb,lkrn} \ - allroms +ipxe_build ISOLINUX_BIN=/usr/share/syslinux/isolinux.bin \ + bin/undionly.kpxe bin/ipxe.dsk bin/ipxe.iso bin/ipxe.usb bin/ipxe.lkrn \ + allroms # build roms with efi support for qemu mkdir bin-combined -for romstr in %{qemuroms}; do - rom=$(echo "$romstr" | cut -d ":" -f 1) - - make_ipxe CONFIG=qemu bin/${rom}.rom - make_ipxe CONFIG=qemu bin-x86_64-efi/${rom}.efidrv - vid="0x${rom%%????}" - did="0x${rom#????}" - EfiRom -f "$vid" -i "$did" --pci23 \ - -ec bin-x86_64-efi/${rom}.efidrv \ - -o bin-combined/${rom}.eficrom +for rom in %{qemuroms}; do + pci_id=$(echo "$rom" | cut -d "-" -f 1) + vendor_id=${pci_id%:*} + device_id=${pci_id#*:} + + ipxe_build CONFIG=qemu bin/${vendor_id}${device_id}.rom + ipxe_build CONFIG=qemu bin-x86_64-efi/${vendor_id}${device_id}.efidrv + + EfiRom -f "0x$vendor_id" -i "0x$device_id" --pci23 \ + -ec bin-x86_64-efi/${vendor_id}${device_id}.efidrv \ + -o bin-combined/${vendor_id}${device_id}.eficrom util/catrom.pl \ - bin/${rom}.rom \ - bin-combined/${rom}.eficrom \ - > bin-combined/${rom}.rom - EfiRom -d bin-combined/${rom}.rom - # truncate to at least 256KiB - truncate -s \>256K bin-combined/${rom}.rom - # verify rom fits in 256KiB - test $(stat -c '%s' bin-combined/${rom}.rom) -le $((256 * 1024)) + bin/${vendor_id}${device_id}.rom \ + bin-combined/${vendor_id}${device_id}.eficrom \ + > bin-combined/${vendor_id}${device_id}.rom + EfiRom -d bin-combined/${vendor_id}${device_id}.rom + + # truncate to 256KiB and verify + truncate -s \>256K bin-combined/${vendor_id}${device_id}.rom + test $(stat -c '%s' bin-combined/${vendor_id}${device_id}.rom) -le $((256 * 1024)) done %endif %ifarch aarch64 -make_ipxe bin-arm64-efi/snponly.efi -make_ipxe bin-arm64-efi/ipxe.efi +ipxe_build bin-arm64-efi/snponly.efi + +ipxe_build bin-arm64-efi/ipxe.efi + %endif %install @@ -186,53 +172,59 @@ mkdir -p %{buildroot}/%{_datadir}/%{name}/ mkdir -p %{buildroot}/%{_datadir}/%{name}.efi/ pushd src/bin/ -cp -a undionly.kpxe ipxe.{iso,usb,dsk,lkrn} %{buildroot}/%{_datadir}/%{name}/ +install -m 0644 -p undionly.kpxe %{buildroot}/%{_datadir}/%{name}/ +install -m 0644 -p ipxe.iso %{buildroot}/%{_datadir}/%{name}/ +install -m 0644 -p ipxe.usb %{buildroot}/%{_datadir}/%{name}/ +install -m 0644 -p ipxe.dsk %{buildroot}/%{_datadir}/%{name}/ +install -m 0644 -p ipxe.lkrn %{buildroot}/%{_datadir}/%{name}/ for img in *.rom; do if [ -e $img ]; then - cp -a $img %{buildroot}/%{_datadir}/%{name}/ + install -m 0644 -p $img %{buildroot}/%{_datadir}/%{name}/ echo %{_datadir}/%{name}/$img >> ../../rom.list fi done popd -cp -a src/bin-x86_64-efi/ipxe.efi %{buildroot}/%{_datadir}/%{name}/ipxe-x86_64.efi -cp -a src/bin-x86_64-efi/snponly.efi %{buildroot}/%{_datadir}/%{name}/ipxe-snponly-x86_64.efi +install -m 0644 -p src/bin-x86_64-efi/ipxe.efi %{buildroot}/%{_datadir}/%{name}/ipxe-x86_64.efi +install -m 0644 -p src/bin-x86_64-efi/snponly.efi %{buildroot}/%{_datadir}/%{name}/ipxe-snponly-x86_64.efi mkdir -p %{buildroot}%{_datadir}/%{name}/qemu/ -for romstr in %{qemuroms}; do - # the roms supported by qemu will be packaged separatedly - # remove from the main rom list and add them to qemu.list - rom=$(echo "$romstr" | cut -d ":" -f 1) - qemuname=$(echo "$romstr" | cut -d ":" -f 2) - sed -i -e "/\/${rom}.rom/d" rom.list - echo %{_datadir}/%{name}/${rom}.rom >> qemu.rom.list +for rom in %{qemuroms}; do + # qemu roms should be installed in a separate package + # so add a qemu.list file with the roms to be installed + pci_id=$(echo "$rom" | cut -d "-" -f 1) + qemuname=$(echo "$rom" | cut -d "-" -f 2) + vendor_id=${pci_id%:*} + device_id=${pci_id#*:} + + sed -i -e "/\/${vendor_id}${device_id}.rom/d" rom.list + echo %{_datadir}/%{name}/${vendor_id}${device_id}.rom >> qemu.rom.list - cp src/bin-combined/${rom}.rom %{buildroot}/%{_datadir}/%{name}.efi/ - echo %{_datadir}/%{name}.efi/${rom}.rom >> qemu.rom.list + install -m 0644 -p src/bin-combined/${vendor_id}${device_id}.rom %{buildroot}/%{_datadir}/%{name}.efi/ + echo %{_datadir}/%{name}.efi/${vendor_id}${device_id}.rom >> qemu.rom.list # Set up symlinks with expected qemu firmware names - ln -s ../../ipxe/${rom}.rom %{buildroot}%{_datadir}/%{name}/qemu/pxe-${qemuname}.rom - ln -s ../../ipxe.efi/${rom}.rom %{buildroot}%{_datadir}/%{name}/qemu/efi-${qemuname}.rom + ln -s ../../ipxe/${vendor_id}${device_id}.rom %{buildroot}%{_datadir}/%{name}/qemu/pxe-${qemuname}.rom + ln -s ../../ipxe.efi/${vendor_id}${device_id}.rom %{buildroot}%{_datadir}/%{name}/qemu/efi-${qemuname}.rom done -# endif x86_64 %endif %ifarch aarch64 mkdir -p %{buildroot}/%{_datadir}/%{name}/arm64-efi -cp -a src/bin-arm64-efi/snponly.efi %{buildroot}/%{_datadir}/%{name}/arm64-efi/snponly.efi -cp -a src/bin-arm64-efi/ipxe.efi %{buildroot}/%{_datadir}/%{name}/arm64-efi/ipxe.efi +install -m 0644 -p src/bin-arm64-efi/snponly.efi %{buildroot}/%{_datadir}/%{name}/arm64-efi/snponly.efi +install -m 0644 -p src/bin-arm64-efi/ipxe.efi %{buildroot}/%{_datadir}/%{name}/arm64-efi/ipxe.efi %endif %ifarch x86_64 %files bootimgs-x86 %license COPYING COPYING.GPLv2 COPYING.UBDL %dir %{_datadir}/%{name} +%{_datadir}/%{name}/ipxe.dsk %{_datadir}/%{name}/ipxe.iso %{_datadir}/%{name}/ipxe.usb -%{_datadir}/%{name}/ipxe.dsk %{_datadir}/%{name}/ipxe.lkrn %{_datadir}/%{name}/ipxe-x86_64.efi %{_datadir}/%{name}/undionly.kpxe @@ -258,6 +250,9 @@ cp -a src/bin-arm64-efi/ipxe.efi %{buildroot}/%{_datadir}/%{name}/arm64-efi/ipxe %endif %changelog +* Sat Apr 8 2023 Kun(llfl) - 20220210.git64113751-3 +- optimize spec file + * Tue Mar 07 2023 happy_orange - 20220210.git64113751-2 - change the path of license files -- Gitee