s390.tmpl 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <%page args="kernels, runtime_img, runtime_base, basearch, outroot, isolabel, extra_boot_args"/>
  2. <%
  3. configdir="tmp/config_files/s390"
  4. BOOTDIR="images"
  5. KERNELDIR=BOOTDIR
  6. INITRD_ADDRESS="0x02000000"
  7. LIVEDIR="LiveOS"
  8. LORAXDIR="usr/share/lorax/"
  9. MKS390IMAGE="/usr/bin/mk-s390image"
  10. # The assumption seems to be that there is only one s390 kernel, ever
  11. kernel = kernels[0]
  12. ## Don't allow spaces or escape characters in the iso label
  13. def valid_label(ch):
  14. return ch.isalnum() or ch == '_'
  15. isolabel = ''.join(ch if valid_label(ch) else '-' for ch in isolabel)
  16. from os.path import basename
  17. import os
  18. from pylorax.sysutils import joinpaths
  19. # Test the runtime_img, if it is > 4GiB we need to set -iso-level to 3
  20. if os.stat(joinpaths(inroot, runtime_img)).st_size >= 4*1024**3:
  21. isoargs = "-iso-level 3"
  22. else:
  23. isoargs = ""
  24. %>
  25. mkdir ${LIVEDIR}
  26. install ${runtime_img} ${LIVEDIR}/squashfs.img
  27. treeinfo stage2 mainimage ${LIVEDIR}/squashfs.img
  28. mkdir ${BOOTDIR}
  29. ## install bootloader (such as it is) and bootloader config
  30. install ${configdir}/redhat.exec ${BOOTDIR}
  31. install ${configdir}/generic.prm ${BOOTDIR}
  32. install ${configdir}/cdboot.prm ${BOOTDIR}
  33. install ${configdir}/generic.ins .
  34. ## configure bootloader
  35. replace @INITRD_LOAD_ADDRESS@ ${INITRD_ADDRESS} generic.ins
  36. replace @EXTRA@ '${extra_boot_args}' ${BOOTDIR}/generic.prm
  37. replace @ROOT@ 'root=live:CDLABEL=${isolabel|udev}' ${BOOTDIR}/cdboot.prm
  38. replace @EXTRA@ '${extra_boot_args}' ${BOOTDIR}/cdboot.prm
  39. ## install kernel
  40. installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/kernel.img
  41. installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
  42. ## s390 needs some extra boot config
  43. createaddrsize ${INITRD_ADDRESS} ${outroot}/${BOOTDIR}/initrd.img ${outroot}/${BOOTDIR}/initrd.addrsize
  44. ## s390 also has some special treeinfo data
  45. treeinfo images-${basearch} initrd.addrsize ${BOOTDIR}/initrd.addrsize
  46. treeinfo images-${basearch} generic.prm ${BOOTDIR}/generic.prm
  47. treeinfo images-${basearch} generic.ins generic.ins
  48. treeinfo images-${basearch} redhat.exec ${BOOTDIR}/redhat.exec
  49. treeinfo images-${basearch} cdboot.prm ${BOOTDIR}/cdboot.prm
  50. # Create optional product.img and updates.img
  51. <% filegraft=""; images=["product", "updates"] %>
  52. %for img in images:
  53. %if exists("%s/%s/" % (LORAXDIR, img)):
  54. installimg ${LORAXDIR}/${img}/ images/${img}.img
  55. treeinfo images-${basearch} ${img}.img images/${img}.img
  56. <% filegraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
  57. %endif
  58. %endfor
  59. # Add the license files
  60. %for f in glob("/usr/share/licenses/*-release/*"):
  61. install ${f} ${f|basename}
  62. <% filegraft += " {0}={1}/{0}".format(basename(f), outroot) %>
  63. %endfor
  64. ## Make a combined kernel+initrd image for the iso
  65. runcmd ${MKS390IMAGE} ${outroot}/${KERNELDIR}/kernel.img \
  66. ${outroot}/${BOOTDIR}/cdboot.img \
  67. -r ${outroot}/${KERNELDIR}/initrd.img \
  68. -p ${outroot}/${BOOTDIR}/cdboot.prm
  69. ## make boot.iso
  70. runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \
  71. -b ${BOOTDIR}/cdboot.img -c ${BOOTDIR}/boot.cat \
  72. -boot-load-size 4 -no-emul-boot \
  73. -R -J -V '${isolabel}' -graft-points \
  74. ${BOOTDIR}=${outroot}/${BOOTDIR} \
  75. ${LIVEDIR}=${outroot}/${LIVEDIR} \
  76. ${filegraft}
  77. treeinfo images-${basearch} boot.iso images/boot.iso