PKGBUILD 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. # Maintainer (aur): Sam Mulvey (Refutationalist) <archlinux@sammulvey.com>
  2. # Contributor: Filipe Laíns (FFY00) <lains@archlinux.org>
  3. # Contributor: Chris Chapman (cman) <chris.chapman@aggiemail.usu.edu>
  4. # Build Options
  5. _build_stubdom=${build_stubdom:-false}
  6. _build_qemu=${build_qemu:-true}
  7. _boot_dir=${boot_dir:-/boot}
  8. _efi_dir=${efi_dir:-/boot}
  9. _efi_mountpoint=${efi_mountpoint:-/boot}
  10. # Check http://xenbits.xen.org/xen-extfiles/ for updates
  11. _gmp=4.3.2
  12. _grub=0.97
  13. _lwip=1.3.0
  14. _newlib=1.16.0
  15. _pciutils=2.2.9
  16. _polarssl=1.1.4
  17. _tpm_emulator=0.7.4
  18. _zlib=1.2.3
  19. pkgbase=xen
  20. pkgname=("xen" "xen-docs")
  21. pkgver=4.16.0
  22. pkgrel=3
  23. pkgdesc='Type-1 or bare-metal hypervisor'
  24. arch=('x86_64')
  25. url='https://xenproject.org/'
  26. license=('GPL2')
  27. options=(!buildflags)
  28. makedepends=(
  29. 'zlib' 'python' 'ncurses' 'openssl' 'libx11' 'libuuid.so' 'yajl' 'libaio' 'glib2' 'pkgconf'
  30. 'bridge-utils' 'iproute2' 'inetutils' 'acpica' 'lib32-glibc' 'gnutls'
  31. 'vde2' 'lzo' 'pciutils' 'sdl2' 'systemd-libs'
  32. 'systemd' 'wget' 'pandoc' 'valgrind' 'git' 'bin86' 'dev86' 'bison' 'gettext' 'flex' 'pixman' 'ocaml' 'ocaml-findlib' 'fig2dev'
  33. ) # last line from namcap, these depends are the xen depends
  34. _stubdom_makedepends=('cmake')
  35. _qemu_makedepends=('ninja')
  36. _source=(
  37. "https://downloads.xenproject.org/release/xen/$pkgver/$pkgname-$pkgver.tar.gz"{,.sig}
  38. "efi-xen.cfg"
  39. "xen.conf"
  40. "tmpfiles.conf"
  41. "xen-ucode-extract.sh"
  42. "xen-intel-ucode.hook"
  43. "xen-amd-ucode.hook"
  44. )
  45. validpgpkeys=('23E3222C145F4475FA8060A783FE14C957E82BD9') # Xen.org Xen tree code signing (signatures on the xen hypervisor and tools) <pgp@xen.org>
  46. # Follow the Xen securite mailing lists, and if a patch is applicable to our package
  47. # add the URL here.
  48. # Better yet, add the patch to abslibre :)
  49. _patches=(
  50. "xsa393.patch"
  51. "xsa394.patch"
  52. "xsa395.patch"
  53. )
  54. # Sources required for building stubdom
  55. _stubdom_source=(
  56. "http://xenbits.xen.org/xen-extfiles/gmp-$_gmp.tar.bz2"
  57. "http://xenbits.xen.org/xen-extfiles/grub-$_grub.tar.gz"
  58. "http://xenbits.xen.org/xen-extfiles/lwip-$_lwip.tar.gz"
  59. "http://xenbits.xen.org/xen-extfiles/newlib-$_newlib.tar.gz"
  60. "http://xenbits.xen.org/xen-extfiles/pciutils-$_pciutils.tar.bz2"
  61. "http://xenbits.xen.org/xen-extfiles/polarssl-$_polarssl-gpl.tgz"
  62. "http://xenbits.xen.org/xen-extfiles/tpm_emulator-$_tpm_emulator.tar.gz"
  63. "http://xenbits.xen.org/xen-extfiles/zlib-$_zlib.tar.gz"
  64. )
  65. # from cheap hack known as break_out_sums.sh
  66. _sha512sums=(
  67. "2869ed90d1779c9754d7f2397f5fc67a655304d9c32953ac20655ef96cb154521d8fce9f23915ac0c91f984dc54f72c67e5e619e2da318b5997748f44cf21b87" # xen-4.16.0.tar.gz
  68. "SKIP" # xen-4.16.0.tar.gz.sig
  69. "1bbcbcd9fb8344a207409ec9f0064a45b726416f043f902ca587f5e4fa58497a759be4ffd584fa32318e960aa478864cc05ec026c444e8d27ca8e3248bd67420" # efi-xen.cfg
  70. "ccaa2ff82e4203b11e5dec9aeccac2e165721d8067e0094603ecaa7a70b78c9eb9e2287a32687883d26b6ceae6f8d2ad7636ddf949eb658637b3ceaa6999711b" # xen.conf
  71. "53ba61587cc2e84044e935531ed161e22c36d9e90b43cab7b8e63bcc531deeefacca301b5dff39ce89210f06f1d1e4f4f5cf49d658ed5d9038c707e3c95c66ef" # tmpfiles.conf
  72. "a9230ec6ef9636ac3f3e4b72b1747ee8c4648a8bf4bd8dc3650365e34f1f67474429dbdd24996907d277b0ff5f235574643e781cb3ff37da954e899ddadbe0d6" # xen-ucode-extract.sh
  73. "7a832de9b35f4b77ee80d33310b23886f4d48d1d42c3d6ef6f8e2b428bec7332a285336864b61cfa01d9a14c2023674015beb7527bd5849b069f2be88e6500cd" # xen-intel-ucode.hook
  74. "99921b94a29fa7988c7fb5c17da8e598e777c972d6cae8c8643c991e5ff911a25525345ea8913945313d5c49fecf9da8cc3b83d47ab03928341e917b304370a9" # xen-amd-ucode.hook
  75. )
  76. _patch_sums=(
  77. "32efed25f988579be8266a6bc80ed7c09c408519c6b6c5264b7e032849e3accc7ddea19c5879c06d7e7b27308d06e114f6e3ca4f814d53b9be9d239fb09c71f1" # xsa393.patch
  78. "a0afa766e492a4dc921cd5c4c43c9ecbe87f79c07986504c8626ab7f06736147bdfa4637ea4c4abf17b9f1df31056bbcbb6c51a52e244e57467564c8ea06a52e" # xsa394.patch
  79. "0aafb55b88a7feefeb0162b2722efc8ad43edcdfc7926492e1d49945eafb8dda900f7da37b2d49fd4dbc2d0c9a068ad6e47674a6df108a58842275695ed73540" # xsa395.patch
  80. )
  81. _stub_sums=(
  82. "2e0b0fd23e6f10742a5517981e5171c6e88b0a93c83da701b296f5c0861d72c19782daab589a7eac3f9032152a0fc7eff7f5362db8fccc4859564a9aa82329cf" # gmp-4.3.2.tar.bz2
  83. "c2bc9ffc8583aeae71cee9ddcc4418969768d4e3764d47307da54f93981c0109fb07d84b061b3a3628bd00ba4d14a54742bc04848110eb3ae8ca25dbfbaabadb" # grub-0.97.tar.gz
  84. "1465b58279af1647f909450e394fe002ca165f0ff4a0254bfa9fe0e64316f50facdde2729d79a4e632565b4500cf4d6c74192ac0dd3bc9fe09129bbd67ba089d" # lwip-1.3.0.tar.gz
  85. "40eb96bbc6736a16b6399e0cdb73e853d0d90b685c967e77899183446664d64570277a633fdafdefc351b46ce210a99115769a1d9f47ac749d7e82837d4d1ac3" # newlib-1.16.0.tar.gz
  86. "2b3d98d027e46d8c08037366dde6f0781ca03c610ef2b380984639e4ef39899ed8d8b8e4cd9c9dc54df101279b95879bd66bfd4d04ad07fef41e847ea7ae32b5" # pciutils-2.2.9.tar.bz2
  87. "88da614e4d3f4409c4fd3bb3e44c7587ba051e3fed4e33d526069a67e8180212e1ea22da984656f50e290049f60ddca65383e5983c0f8884f648d71f698303ad" # polarssl-1.1.4-gpl.tgz
  88. "4928b5b82f57645be9408362706ff2c4d9baa635b21b0d41b1c82930e8c60a759b1ea4fa74d7e6c7cae1b7692d006aa5cb72df0c3b88bf049779aa2b566f9d35" # tpm_emulator-0.7.4.tar.gz
  89. "021b958fcd0d346c4ba761bcf0cc40f3522de6186cf5a0a6ea34a70504ce9622b1c2626fce40675bc8282cf5f5ade18473656abc38050f72f5d6480507a2106e" # zlib-1.2.3.tar.gz
  90. )
  91. # Simplify things for makepkg
  92. source=( "${_source[@]}" "${_patches[@]}" )
  93. sha512sums=( "${_sha512sums[@]}" "${_patch_sums[@]}" )
  94. for file in "${_patches[@]}"; do
  95. noextract+=( $(basename ${file}) )
  96. done
  97. # stubdom handling
  98. if [ "${_build_stubdom}" == "true" ]; then
  99. source=("${source[@]}" "${_stubdom_source[@]}")
  100. sha512sums=("${sha512sums[@]}" "${_stub_sums[@]}")
  101. # Add in automagic dependency in order to build vtpm and vtpmmgr stubdoms
  102. makedepends=( "${makedepends[@]}" "${_stubdom_makedepends[@]}" )
  103. for file in "${_stubdom_source[@]}"; do
  104. noextract+=( $(basename ${file}) )
  105. done
  106. _config_stubdom='--enable-stubdom'
  107. # make sure to build the stubdom package
  108. pkgname+=("xen-stubdom")
  109. else
  110. _config_stubdom='--disable-stubdom'
  111. fi
  112. if [ "${_build_qemu}" == "true" ]; then
  113. _config_qemu=""
  114. # qemu needs ninja to build as of 4.16.0
  115. makedepends=( "${makedepends[@]}" "${_qemu_makedepends[@]}" )
  116. pkgname+=("xen-qemu-builtin")
  117. else
  118. _config_qemu="--with-system-qemu=/usr/bin/qemu-system-x86_64"
  119. fi
  120. _common_make_flags=(
  121. "BOOT_DIR=${_boot_dir}"
  122. "EFI_DIR=${_efi_dir}"
  123. "EFI_MOUNTPOINT=${_efi_mountpoint}"
  124. "XEN_VENDORVERSION=-${pkgrel}-arch"
  125. )
  126. # TODO: Setup users, dirs, etc.
  127. prepare() {
  128. cd "${pkgbase}-${pkgver}"
  129. if [ "${_build_stubdom}" == "true" ]; then
  130. for file in "${_stubdom_source[@]}"; do
  131. cp ../$(basename ${file}) stubdom/
  132. done
  133. fi
  134. for patchurl in "${_patches[@]}"; do
  135. patch=$(basename $patchurl)
  136. echo "==> Applying security patch '${patch}'..."
  137. patch -p1 < "../${patch}"
  138. done
  139. # Fix Install Paths.
  140. sed 's,/var/run,/run,g' -i tools/hotplug/Linux/locking.sh
  141. sed 's,/var/run,/run,g' -i tools/misc/xenpvnetboot
  142. sed 's,/var/run,/run,g' -i tools/xenmon/xenbaked.c
  143. sed 's,/var/run,/run,g' -i tools/xenmon/xenmon.py
  144. sed 's,/var/run,/run,g' -i tools/pygrub/src/pygrub
  145. }
  146. build() {
  147. cd "${pkgbase}-${pkgver}"
  148. if [ "${_build_stubdom}" == "true" ]; then
  149. echo "NOTE: Xen build with stubdom support."
  150. fi
  151. if [ "${_build_qemu}" == "true" ]; then
  152. echo "NOTE: Xen build with integrated QEMU."
  153. fi
  154. ./configure \
  155. --prefix=/usr \
  156. --sbindir=/usr/bin \
  157. --libdir=/usr/lib \
  158. --with-rundir=/run \
  159. --enable-systemd \
  160. --disable-qemu-traditional \
  161. ${_config_stubdom} \
  162. ${_config_qemu} \
  163. --with-sysconfig-leaf-dir=conf.d \
  164. --with-system-ovmf=/usr/share/ovmf/x64/OVMF.fd \
  165. --with-system-seabios=/usr/share/qemu/bios-256k.bin
  166. make "${_common_make_flags[@]}"
  167. }
  168. package_xen() {
  169. pkgdesc='Type-1 or baremetal hypervisor'
  170. depends=(
  171. 'zlib' 'python' 'ncurses' 'openssl' 'libx11' 'libuuid.so' 'yajl' 'libaio' 'glib2' 'pkgconf'
  172. 'bridge-utils' 'iproute2' 'inetutils' 'acpica' 'lib32-glibc' 'gnutls'
  173. 'vde2' 'lzo' 'pciutils' 'sdl2'
  174. 'pixman' 'libseccomp' 'libpng' 'libjpeg-turbo' # inhereted depends because of build environment
  175. )
  176. optdepends=(
  177. 'edk2-ovmf: UEFI support'
  178. 'seabios: SeaBIOS payload support'
  179. 'xen-docs: HTML documentation and man pages'
  180. 'grub-xen-git: GRUB and pvgrub2 bootloader support'
  181. 'linux-headers: extract bootable non-zstd kernel for recent kernels'
  182. )
  183. if [ "${_build_qemu}" == "false" ]; then
  184. optdepends+=("qemu: HVM and PV support")
  185. fi
  186. install="xen.install"
  187. backup=(
  188. "etc/conf.d/xencommons"
  189. "etc/conf.d/xendomains"
  190. "etc/xen/efi-xen.cfg"
  191. "etc/xen/cpupool"
  192. "etc/xen/xl.conf"
  193. )
  194. cd "${pkgbase}-${pkgver}"
  195. make "${_common_make_flags[@]}" DESTDIR="$pkgdir" install
  196. rm -rf "$pkgdir"/var/run
  197. # Symlinks to prior installed versions are not The Arch Way, leave only the bare EFI binary
  198. (cd "${pkgdir}/${_efi_dir}" && mv "$(realpath xen.efi)" xen.efi)
  199. [ -d "$pkgdir"/etc/xen/scripts ] && backup+=($(find "$pkgdir"/etc/xen/scripts/ -type f | sed "s|^$pkgdir/||g"))
  200. mkdir -p "${pkgdir}/var/log/xen/console"
  201. # Continued: Trim hypervisor symlinks.
  202. (cd "${pkgdir}/${_boot_dir}" && mv "$(realpath xen.gz)" xen.gz)
  203. # Do all symlink removals after the directories have had the real
  204. # binaries moved overtop any symlinks. Note that dependening on
  205. # configuratation _efi_dir and _boot_dir may be the same directory, so
  206. # don't clean any of them until they've all been processed.
  207. find "${pkgdir}/${_efi_dir}" -type l -delete
  208. find "${pkgdir}/${_boot_dir}" -type l -delete
  209. # Remove syms.
  210. find "${pkgdir}/usr/lib/debug" -type f \( -name '*-syms*' -or -name '*\.map' \) -delete
  211. rmdir "${pkgdir}/usr/lib/debug/usr/lib/xen/boot"
  212. rmdir "${pkgdir}/usr/lib/debug/usr/lib/xen"
  213. rmdir "${pkgdir}/usr/lib/debug/usr/lib"
  214. rmdir "${pkgdir}/usr/lib/debug/usr"
  215. rmdir "${pkgdir}/usr/lib/debug"
  216. # Remove SysVinit files.
  217. rm -r "${pkgdir}/etc/init.d"
  218. # Install files for Arch Linux.
  219. install -D -m 0644 "${srcdir}/efi-xen.cfg" "${pkgdir}/etc/xen/efi-xen.cfg"
  220. install -D -m 0644 "${srcdir}/xen.conf" "${pkgdir}/usr/lib/modules-load.d/xen.conf"
  221. install -D -m 0644 "${srcdir}/tmpfiles.conf" "${pkgdir}/usr/lib/tmpfiles.d/${pkgbase}.conf"
  222. # microcode hooks
  223. mkdir -p "${pkgdir}/usr/share/libalpm/scripts" "${pkgdir}/usr/share/libalpm/hooks"
  224. install -m755 "${srcdir}/xen-ucode-extract.sh" "${pkgdir}/usr/share/libalpm/scripts"
  225. install -m644 "${srcdir}/xen-intel-ucode.hook" "${pkgdir}/usr/share/libalpm/hooks"
  226. install -m644 "${srcdir}/xen-amd-ucode.hook" "${pkgdir}/usr/share/libalpm/hooks"
  227. # Remove documentation (included in separate xen-docs package).
  228. rm -r "${pkgdir}/usr/share/doc"
  229. rm -r "${pkgdir}/usr/share/man"
  230. # remove potential stubdom files
  231. rm -r "${pkgdir}/usr/lib/xen/boot"
  232. # remove qemu
  233. if [ "${_build_qemu}" == "true" ]; then
  234. rm -r "${pkgdir}/usr/share/qemu-xen"
  235. rm -r \
  236. "${pkgdir}/usr/lib/xen/include/qemu-plugin.h" \
  237. "${pkgdir}/usr/lib/xen/bin/qemu-pr-helper" \
  238. "${pkgdir}/usr/lib/xen/bin/qemu-edid" \
  239. "${pkgdir}/usr/lib/xen/bin/elf2dmp" \
  240. "${pkgdir}/usr/lib/xen/bin/qemu-storage-daemon" \
  241. "${pkgdir}/usr/lib/xen/bin/qemu-nbd" \
  242. "${pkgdir}/usr/lib/xen/bin/qemu-io" \
  243. "${pkgdir}/usr/lib/xen/bin/qemu-img" \
  244. "${pkgdir}/usr/lib/xen/bin/qemu-system-i386" \
  245. "${pkgdir}/usr/lib/xen/libexec/virtiofsd" \
  246. "${pkgdir}/usr/lib/xen/libexec/qemu-bridge-helper" \
  247. "${pkgdir}/usr/lib/xen/libexec/virtfs-proxy-helper"
  248. fi
  249. }
  250. package_xen-docs() {
  251. pkgdesc="Xen hypervisor documentation and man pages"
  252. arch=("x86_64") # no reason to publish this package to 32-bit repos
  253. cd "${pkgbase}-${pkgver}"
  254. make "${_common_make_flags[@]}" DESTDIR="$pkgdir" install-docs
  255. }
  256. package_xen-stubdom() {
  257. pkgdesc="Xen hypervisor stubdom files"
  258. arch=("x86_64")
  259. depends=("xen")
  260. cd "${srcdir}/${pkgbase}-${pkgver}/stubdom"
  261. make DESTDIR="${pkgdir}" install
  262. }
  263. package_xen-qemu-builtin() {
  264. pkgdesc="Xen hypervisor QEMU components"
  265. arch=("x86_64")
  266. depends=("xen")
  267. cd "${srcdir}/${pkgbase}-${pkgver}/tools/qemu-xen-build"
  268. make DESTDIR="${pkgdir}" install
  269. }