Advertisement
Guest User

PKGBUILD

a guest
Jan 28th, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.88 KB | None | 0 0
  1. # Maintainer: Sergio Tridente <tioduke at gmail dot com >
  2.  
  3. pkgname=qemu-user-static
  4. pkgver=2.2
  5. pkgrel=1
  6. pkgdesc="A generic and open source processor emulator which achieves a good emulation speed by using dynamic translation, statically linked."
  7. arch=('i686' 'x86_64')
  8. license=('GPL2' 'LGPL2.1')
  9. url="http://wiki.qemu.org/Index.html"
  10. depends=()
  11. optdepends=('binfmt-support: to allow handling foreign ELF binaries and executing them via qemu')
  12. conflicts=()
  13. _arch=i386
  14. [ "$CARCH" = 'x86_64' ] && _arch=amd64
  15. _debsrc=${pkgname}_${pkgver}+dfsg-5exp_${_arch}.deb
  16. source=(http://ftp.debian.org/debian/pool/main/q/qemu/${_debsrc})
  17. sha1sums=('86ea920478b210421daf50535da1a2e73f6dc602')
  18. [ "$CARCH" = 'i686' ] && sha1sums=('f9e43d972ea8e6162bba95ed8b90fe7f5922b84d')
  19.  
  20. prepare() {
  21.   cd "$srcdir"
  22.   ar p ${_debsrc} data.tar.xz | bsdtar xf -
  23. }
  24.  
  25. package() {
  26.   cd "$pkgdir"
  27.   mkdir -p "$pkgdir"/usr/bin/
  28.   mkdir -p "$pkgdir"/usr/share/man/
  29.   mkdir -p "$pkgdir"/var/lib/binfmts/
  30.  
  31.   cp "$srcdir"/usr/bin/* "$pkgdir"/usr/bin/
  32.   cp "$srcdir"/usr/share/man/man1 "$pkgdir"/usr/share/man/ -r
  33.  
  34.   create_binfmts
  35. }
  36.  
  37. create_binfmts() {
  38.   aarch64_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
  39.   aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  40.   alpha_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90'
  41.   alpha_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
  42.   arm_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'
  43.   arm_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
  44.   armeb_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28'
  45.   armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  46.   cris_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x4c\x00'
  47.   cris_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
  48.   m68k_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04'
  49.   m68k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  50.   microblaze_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xba\xab'
  51.   microblaze_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  52.   mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
  53.   mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  54.   mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
  55.   mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
  56.   ppc_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14'
  57.   ppc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  58.   ppc64_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
  59.   ppc64_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  60.   ppc64abi32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
  61.   ppc64abi32_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  62.   s390x_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16'
  63.   s390x_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  64.   sh4_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
  65.   sh4_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
  66.   sh4eb_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a'
  67.   sh4eb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  68.   sparc_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02'
  69.   sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  70.   sparc32plus_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12'
  71.   sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  72.   sparc64_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b'
  73.   sparc64_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  74.  
  75.   # Drop support for emulating amd64 on i386, http://bugs.debian.org/604712
  76.   fmts="aarch64 alpha arm armeb cris m68k microblaze mips mipsel ppc ppc64 ppc64abi32 s390x sh4 sh4eb sparc sparc32plus sparc64"
  77.  
  78.   for fmt in $fmts ; do
  79.     eval "magic=\"\$${fmt}_magic\" mask=\"\$${fmt}_mask\""
  80.     cat >> "${pkgdir}/var/lib/binfmts/qemu-$fmt" << EOF
  81. package qemu-user-static
  82. interpreter /usr/bin/qemu-$fmt-static
  83. credentials yes
  84. offset 0
  85. magic $magic
  86. mask $mask
  87. EOF
  88.   done
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement