PKGBUILD 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. # U-Boot: sunXi
  2. # Maintainer: Isaac David <isacdaavid@at@isacdaavid@dot@info>
  3. # Contributor: André Silva <emulatorman@hyperbola.info>
  4. # Contributor: Timothy Redaelli <timothy.redaelli@gmail.com>
  5. # Contributor: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
  6. # Maintainer: Parabola Hackers <dev@lists.parabola.nu>
  7. # To add a new board (that uses an Allwinner System On a Chip) you need:
  8. #
  9. # 1. The u-boot configuration name. Example: `A20-OLinuXino_MICRO_defconfig`
  10. #
  11. # Remove the the `_defconfig` suffix and add this to the `_targets=()`
  12. # variable near the top of this PKGBUILD.
  13. #
  14. # 2. The name of the board(s). Example: `A20 OLinuXino Micro`.
  15. #
  16. # This is usually very similar to the u-boot configuration name, but
  17. # sometimes a single u-boot configuration supports multiple boards and the
  18. # configuration name doesn't always denote all board names. For example:
  19. # uboot4extlinux-am335x_bone supports various BeagleBones (the AM335x GP EVM
  20. # and the EVM SK).
  21. #
  22. # Add a `package_uboot4extlinux-*()` function to the bottom of this
  23. # PKGBUILD, following the existing pattern. The `*` in the function name
  24. # should be the above (1) configuration, but converted to all-lowercase.
  25. #
  26. # 3. (Optional) If relevant, the Parabola and/or Arch Linux ARM package names
  27. # that it replaces, if there are older u-boot packages also supporting that
  28. # board. Example: `uboot-a20-olinuxino-micro`
  29. #
  30. # After adding a new board in this PKGBUILD, you should also create a
  31. # 'Computers/' page on the Parabola wiki for that board, and update the relevant
  32. # sections of the 'ARM Installation Guide' to refer to it for any board-specific
  33. # details:
  34. #
  35. # * https://wiki.parabola.nu/ARM_Installation_Guide
  36. # * https://wiki.parabola.nu/Computers
  37. # Upstream u-boot-libre information ############################################
  38. _pkgname=u-boot-libre
  39. _pkgver=2021.07-r1 # {upstream_uboot_version}-{uboot-libre_suffix}
  40. url="https://libreboot.org/docs/maintain/#resourcesscriptsbuildreleaseu-boot-libre"
  41. license=('GPL')
  42. # According to the Libreboot maintainer, we are supposed to use
  43. # any of the mirrors in https://libreboot.org/download.html#https
  44. # and not use the rsync server. The rsync server is only supposed
  45. # to be used by mirrors as it has limited bandwith.
  46. _mirror="https://mirrors.mit.edu/libreboot/"
  47. source=("${_mirror}/${_pkgname}/${_pkgver}/${_pkgname}-${_pkgver}.tar.lz"{,.sig})
  48. # TODO: We also need to look into drivers/dma/MCD_tasks.c. The debian
  49. # version of u-boot removes it. It's some data that looks like
  50. # code, so while there is a valid license, we might lack
  51. # corresponding source code if it's really some code. The debian
  52. # commits might have more information about it.
  53. # Hardware information #########################################################
  54. pkgbase=uboot4extlinux-sunxi
  55. # These must match the "${target}_defconfig" `make` targets.
  56. _targets=('A10-OLinuXino-Lime'
  57. 'A10s-OLinuXino-M'
  58. 'A13-OLinuXino'
  59. 'A13-OLinuXinoM'
  60. 'A20-OLinuXino-Lime'
  61. 'A20-OLinuXino-Lime2'
  62. 'A20-OLinuXino-Lime2-eMMC'
  63. 'A20-OLinuXino_MICRO'
  64. 'Bananapi'
  65. 'Bananapro'
  66. 'CHIP'
  67. 'Cubieboard'
  68. 'Cubieboard2'
  69. 'Cubietruck'
  70. 'Linksprite_pcDuino'
  71. 'Linksprite_pcDuino3'
  72. 'Linksprite_pcDuino3_Nano'
  73. 'orangepi_2'
  74. 'orangepi_one'
  75. 'orangepi_pc'
  76. 'orangepi_plus')
  77. # Offset at which to install u-boot
  78. _offset=8192
  79. # Parabola package information #################################################
  80. pkgname=()
  81. for _target in "${_targets[@]}"; do
  82. pkgname+=("uboot4extlinux-${_target,,}")
  83. done
  84. pkgver="${_pkgver/-/.}"
  85. pkgrel='4'
  86. arch=('armv7h' 'i686' 'x86_64')
  87. makedepends=('bc' 'dtc' 'python' 'python-setuptools' 'swig')
  88. makedepends_i686+=('arm-none-eabi-gcc')
  89. makedepends_ppc64le+=('arm-none-eabi-gcc')
  90. makedepends_x86_64+=('arm-none-eabi-gcc')
  91. depends=(
  92. uboot-tools # duh
  93. util-linux # for `blkid` in our `install.sh.in`
  94. )
  95. source+=('0001-Fix-build-with-python-3.10.patch'
  96. 'extlinux.conf'
  97. 'install.sh.in'
  98. 'install.txt.gen'
  99. 'pacman-hook.hook.in')
  100. sha512sums=('75b97fd6ca5435311e3b6b12cb44003232b09d87bbccc35144c5f12a3b41892849d56446c8b31fd6ee50f60b45f741d29b5be7fa577cbae62c308196f4bb47a2'
  101. 'SKIP'
  102. '0f12e1705656edd28e0e1e3923b0b72a191fc4dd60ac4ab81473ce521343e65841561bf29c142310654ab8064c2c5ce0989499517f57278aadaac181bcfbe5c1'
  103. 'dcbcbc8d196c7dd7db1a8a30dfa8c9ece5d241580bdf593df5fa2de527f0dfea2bb76ff9bfe49fb1e9d631bd1e4b95c828a41cfb38dc2ddc9553e18a54a521f0'
  104. '9bb359773453dfed71c28790c85be0714f961230e9a2160b9e6c05678afaf98e4fe9f9283f6eb4593def4214f3dbfc5409b566b1d845350330859e8e5500b30f'
  105. 'f497ec67904e6c99723cdfec10f776a8672d52180a423605e84d11b7f35d1409eeb98efa2338c94681a2ea3ff1e5a636bc74bd562b3796334bf3c46445b6db51'
  106. '735e497d96c719a20dd145020110638ef2e3b84e39491e29a884d2684085c1a898b0f62dabfff9bd4ce83bc68febcf638de6ca35a6fa9b157be413b5138f7a07')
  107. validpgpkeys=('98CCDDF8E56047F475C044BDD0C62464FA8B4856') # Leah Rowe <info@minifree.org>
  108. # TODO: We need to fix the timestamps upstream to a valid date
  109. # (like the first January 1970 at 01:00:00 CET) or something derived
  110. # from the release version somehow. Else we have the build log spammed
  111. # with errors like that:
  112. # make: scripts/Makefile.extrawarn: Timestamp out of range;
  113. # substituting 1970-01-01 00:59:59.999999999
  114. # TODO: While we're at it we could export SOURCE_DATE_SPOCH to try to
  115. # make the u-boot package reproducible.
  116. prepare() {
  117. cd "${_pkgname}-${_pkgver}"
  118. patch -p1 -i ../0001-Fix-build-with-python-3.10.patch
  119. cd ..
  120. find "${_pkgname}-${_pkgver}" -print0 | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
  121. local _target
  122. for _target in "${_targets[@]}"; do
  123. cp -aT -- "${_pkgname}-${_pkgver}" "${_pkgname}-${_pkgver}-${_target,,}"
  124. done
  125. }
  126. build() {
  127. unset CFLAGS CXXFLAGS LDFLAGS
  128. local _make_vars=(
  129. ARCH='arm'
  130. EXTRAVERSION="-${_pkgver#*-}"
  131. )
  132. if [[ "$CARCH" != armv7h ]]; then
  133. _make_vars+=(CROSS_COMPILE='arm-none-eabi-')
  134. fi
  135. local _i=0 _n=${#_targets[@]}
  136. local _target
  137. for _target in "${_targets[@]}"; do
  138. printf '==> (%d/%d) %s\n' "$((++_i))" "$_n" "$_target"
  139. pushd "${_pkgname}-${_pkgver}-${_target,,}"
  140. # Configure
  141. make "${_make_vars[@]}" "${_target}_defconfig"
  142. echo 'CONFIG_IDENT_STRING=" Parabola GNU/Linux-libre"' >> .config
  143. # Build
  144. make "${_make_vars[@]}"
  145. popd
  146. done
  147. }
  148. check() {
  149. local _passing=true
  150. local _i=0 _n=${#_targets[@]}
  151. local _target
  152. for _target in "${_targets[@]}"; do
  153. printf '==> (%d/%d) %s\n' "$((++_i))" "$_n" "$_target"
  154. local _image_file _image_size
  155. _image_file="${_pkgname}-${_pkgver}-${_target,,}/u-boot-sunxi-with-spl.bin"
  156. _image_size="$(stat --format='%s' "$_image_file")"
  157. if [[ $((_offset + _image_size)) -gt $(( 1024 * 1024 )) ]]; then
  158. echo "Error: ${_image_file} is too big:"
  159. echo " offset: ${_offset}"
  160. echo " size: ${_image_size}"
  161. echo " By default, partitioing tools position the first partition at 1MiB."
  162. echo " The U-Boot image would overlap with that first partition."
  163. _passing=false
  164. fi
  165. done
  166. $_passing
  167. }
  168. _package() {
  169. # Install the u-boot binary.
  170. install -Dm644 \
  171. "${_pkgname}-${_pkgver}-${pkgname#uboot4extlinux-}/u-boot-sunxi-with-spl.bin" \
  172. "${pkgdir}/usr/lib/u-boot/${pkgname}/u-boot-sunxi-with-spl.bin"
  173. # Install Parabola's example config file.
  174. install -Dm644 \
  175. extlinux.conf \
  176. "${pkgdir}/usr/lib/u-boot/${pkgname}/extlinux.conf"
  177. # Install Parabola's installation script.
  178. install -Dm755 \
  179. <(sed <install.sh.in \
  180. -e "s|@uboot_file@|/usr/lib/u-boot/${pkgname}/u-boot-sunxi-with-spl.bin|g" \
  181. -e "s|@uboot_offset@|${_offset}|g") \
  182. "${pkgdir}/usr/lib/u-boot/${pkgname}/install.sh"
  183. # Install documentation for that installation script.
  184. install -Dm644 \
  185. <(./install.txt.gen "$pkgname" "/usr/lib/u-boot/${pkgname}/install.sh") \
  186. "${pkgdir}/usr/share/doc/u-boot/${pkgname}/install.txt"
  187. # Install a pacman hook that `cat`s that documentation.
  188. install -Dm644 \
  189. <(sed <pacman-hook.hook.in \
  190. -e "s|@pkgname[@]|${pkgname}|g") \
  191. "${pkgdir}/usr/share/libalpm/hooks/${pkgname}.hook"
  192. }
  193. package_uboot4extlinux-a10-olinuxino-lime() { pkgdesc="U-Boot with Extlinux support for A10 OLinuXino Lime" ; _package; }
  194. package_uboot4extlinux-a10s-olinuxino-m() { pkgdesc="U-Boot with Extlinux support for A10s OLinuXino Micro" ; _package; replaces=('uboot4extlinux-a10s-olinuxino-micro'); }
  195. package_uboot4extlinux-a13-olinuxino() { pkgdesc="U-Boot with Extlinux support for A13 OLinuXino" ; _package; }
  196. package_uboot4extlinux-a13-olinuxinom() { pkgdesc="U-Boot with Extlinux support for uboot4extlinux-a13-olinuxino-micro" ; _package; replaces=('uboot4extlinux-a13-olinuxino-micro'); }
  197. package_uboot4extlinux-a20-olinuxino-lime() { pkgdesc="U-Boot with Extlinux support for A20 OLinuXino Lime" ; _package; }
  198. package_uboot4extlinux-a20-olinuxino-lime2() { pkgdesc="U-Boot with Extlinux support for A20 OLinuXino Lime2" ; _package; }
  199. package_uboot4extlinux-a20-olinuxino-lime2-emmc() { pkgdesc="U-Boot with Extlinux support for A20 OLinuXino Lime2 with eMMC" ; _package; }
  200. package_uboot4extlinux-a20-olinuxino_micro() { pkgdesc="U-Boot with Extlinux support for uboot-a20-olinuxino-micro" ; _package; replaces=('uboot-a20-olinuxino-micro'); }
  201. package_uboot4extlinux-bananapi() { pkgdesc="U-Boot with Extlinux support for Banana Pi" ; _package; }
  202. package_uboot4extlinux-bananapro() { pkgdesc="U-Boot with Extlinux support for Banana Pro" ; _package; }
  203. package_uboot4extlinux-chip() { pkgdesc="U-Boot with Extlinux support for C.H.I.P" ; _package; }
  204. package_uboot4extlinux-cubieboard() { pkgdesc="U-Boot with Extlinux support for Cubieboard" ; _package; }
  205. package_uboot4extlinux-cubieboard2() { pkgdesc="U-Boot with Extlinux support for Cubieboard 2" ; _package; }
  206. package_uboot4extlinux-cubietruck() { pkgdesc="U-Boot with Extlinux support for Cubietruck" ; _package; }
  207. package_uboot4extlinux-linksprite_pcduino() { pkgdesc="U-Boot with Extlinux support for uboot4extlinux-pcduino" ; _package; replaces=('uboot4extlinux-pcduino'); }
  208. package_uboot4extlinux-linksprite_pcduino3() { pkgdesc="U-Boot with Extlinux support for uboot4extlinux-pcduino3" ; _package; replaces=('uboot4extlinux-pcduino3'); }
  209. package_uboot4extlinux-linksprite_pcduino3_nano() { pkgdesc="U-Boot with Extlinux support for uboot4extlinux-pcduino3-nano" ; _package; replaces=('uboot4extlinux-pcduino3-nano'); }
  210. package_uboot4extlinux-orangepi_2() { pkgdesc="U-Boot with Extlinux support for Orange Pi 2" ; _package; }
  211. package_uboot4extlinux-orangepi_one() { pkgdesc="U-Boot with Extlinux support for Orange Pi One" ; _package; }
  212. package_uboot4extlinux-orangepi_pc() { pkgdesc="U-Boot with Extlinux support for Orange Pi PC" ; _package; }
  213. package_uboot4extlinux-orangepi_plus() { pkgdesc="U-Boot with Extlinux support for Orange Pi Plus" ; _package; }