x86.tmpl 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <%page args="kernels, runtime_img, runtime_base, basearch, inroot, outroot, product, isolabel"/>
  2. <%
  3. configdir="tmp/config_files/x86"
  4. SYSLINUXDIR="usr/share/syslinux"
  5. PXEBOOTDIR="images/pxeboot"
  6. STAGE2IMG="images/install.img"
  7. BOOTDIR="isolinux"
  8. KERNELDIR=PXEBOOTDIR
  9. LORAXDIR="usr/share/lorax/"
  10. ## Don't allow spaces or escape characters in the iso label
  11. def valid_label(ch):
  12. return ch.isalnum() or ch == '_'
  13. isolabel = ''.join(ch if valid_label(ch) else '-' for ch in isolabel)
  14. import os
  15. from os.path import basename
  16. from pylorax.sysutils import joinpaths
  17. # Test the runtime_img, if it is > 4GiB we need to set -iso-level to 3
  18. if os.stat(joinpaths(inroot, runtime_img)).st_size >= 4*1024**3:
  19. isoargs = "-iso-level 3"
  20. else:
  21. isoargs = ""
  22. %>
  23. mkdir images
  24. install ${runtime_img} ${STAGE2IMG}
  25. treeinfo stage2 mainimage images/${runtime_base}
  26. ## install bootloader and config files
  27. mkdir ${BOOTDIR}
  28. install ${SYSLINUXDIR}/isolinux.bin ${BOOTDIR}
  29. install ${SYSLINUXDIR}/vesamenu.c32 ${BOOTDIR}
  30. install ${SYSLINUXDIR}/ldlinux.c32 ${BOOTDIR}
  31. install ${SYSLINUXDIR}/libcom32.c32 ${BOOTDIR}
  32. install ${SYSLINUXDIR}/libutil.c32 ${BOOTDIR}
  33. install ${configdir}/isolinux.cfg ${BOOTDIR}
  34. install ${configdir}/boot.msg ${BOOTDIR}
  35. install ${configdir}/grub.conf ${BOOTDIR}
  36. install usr/share/anaconda/boot/syslinux-splash.png ${BOOTDIR}/splash.png
  37. install boot/memtest* ${BOOTDIR}/memtest
  38. ## configure bootloader
  39. replace @VERSION@ ${product.version} ${BOOTDIR}/grub.conf ${BOOTDIR}/isolinux.cfg ${BOOTDIR}/*.msg
  40. replace @PRODUCT@ '${product.name}' ${BOOTDIR}/grub.conf ${BOOTDIR}/isolinux.cfg ${BOOTDIR}/*.msg
  41. replace @ROOT@ 'inst.stage2=hd:LABEL=${isolabel|udev}' ${BOOTDIR}/isolinux.cfg
  42. ## install kernels
  43. mkdir ${KERNELDIR}
  44. %for kernel in kernels:
  45. %if product.useUEK:
  46. <%
  47. if_uek_kernel = kernel['path'].find("uek")
  48. %>
  49. %if if_uek_kernel == -1:
  50. <% continue %>
  51. %endif
  52. %endif
  53. %if kernel.flavor:
  54. ## i386 PAE
  55. installkernel images-xen ${kernel.path} ${KERNELDIR}/vmlinuz-${kernel.flavor}
  56. installinitrd images-xen ${kernel.initrd.path} ${KERNELDIR}/initrd-${kernel.flavor}.img
  57. %else:
  58. ## normal i386, x86_64
  59. installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/vmlinuz
  60. installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
  61. %endif
  62. %endfor
  63. hardlink ${KERNELDIR}/vmlinuz ${BOOTDIR}
  64. hardlink ${KERNELDIR}/initrd.img ${BOOTDIR}
  65. %if basearch == 'x86_64':
  66. treeinfo images-xen kernel ${KERNELDIR}/vmlinuz
  67. treeinfo images-xen initrd ${KERNELDIR}/initrd.img
  68. %endif
  69. ## WHeeeeeeee, EFI.
  70. <% efiargs=""; efigraft=""; efiarch32=None; efiarch64=None %>
  71. %if exists("boot/efi/EFI/*/gcdia32.efi"):
  72. <% efiarch32 = 'IA32' %>
  73. %endif
  74. %if exists("boot/efi/EFI/*/gcdx64.efi"):
  75. <% efiarch64 = 'X64' %>
  76. %endif
  77. %if (efiarch32 or efiarch64) and basearch != 'i386':
  78. <%
  79. efigraft="EFI/BOOT={0}/EFI/BOOT".format(outroot)
  80. images = [("images/efiboot.img", "-isohybrid-gpt-basdat")]
  81. if domacboot:
  82. images.append(("images/macboot.img", "-isohybrid-gpt-hfsplus"))
  83. %>
  84. %for img, hybrid in images:
  85. <%
  86. efiargs += " -eltorito-alt-boot -e {0} -no-emul-boot {1}".format(img, hybrid)
  87. efigraft += " {0}={1}/{0}".format(img,outroot)
  88. %>
  89. treeinfo images-${basearch} ${img|basename} ${img}
  90. %endfor
  91. <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch32=efiarch32, efiarch64=efiarch64, isolabel=isolabel"/>
  92. %endif
  93. # Create optional product.img and updates.img
  94. <% filegraft=""; images=["product", "updates"]; compressargs=""; %>
  95. %if basearch == 'i386':
  96. # Limit the amount of memory xz uses on i386
  97. <% compressargs="--xz -9 --memlimit-compress=3700MiB" %>
  98. %endif
  99. %for img in images:
  100. %if exists("%s/%s/" % (LORAXDIR, img)):
  101. installimg ${compressargs} ${LORAXDIR}/${img}/ images/${img}.img
  102. treeinfo images-${basearch} ${img}.img images/${img}.img
  103. <% filegraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
  104. %endif
  105. %endfor
  106. # Inherit iso-graft/ if it exists from external templates
  107. <%
  108. import os
  109. if os.path.exists(workdir + "/iso-graft"):
  110. filegraft += " " + workdir + "/iso-graft"
  111. %>
  112. # Add the license files
  113. %for f in glob("/usr/share/licenses/*-release/*"):
  114. install ${f} ${f|basename}
  115. <% filegraft += " {0}={1}/{0}".format(basename(f), outroot) %>
  116. %endfor
  117. ## make boot.iso
  118. runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \
  119. -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \
  120. -b ${BOOTDIR}/isolinux.bin -c ${BOOTDIR}/boot.cat \
  121. -boot-load-size 4 -boot-info-table -no-emul-boot \
  122. ${efiargs} -R -J -V '${isolabel}' \
  123. -graft-points \
  124. .discinfo=${outroot}/.discinfo \
  125. ${STAGE2IMG}=${outroot}/${STAGE2IMG} \
  126. ${BOOTDIR}=${outroot}/${BOOTDIR} \
  127. ${KERNELDIR}=${outroot}/${KERNELDIR} \
  128. ${efigraft} ${filegraft}
  129. treeinfo images-${basearch} boot.iso images/boot.iso