PKGBUILD 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. # To add a new board (that uses an Allwinner System On a Chip) you need:
  7. # - The package name. Example: uboot4extlinux-a20-olinuxino_micro
  8. # - The u-boot configuration. Example: A20-OLinuXino_MICRO_defconfig
  9. # - The name of the board(s). Example: A20 OLinuXino Micro
  10. # A single package / u-boot configuration sometimes support multiple
  11. # boards and the configuration name doesn't always have the boards names
  12. # in it. Example: uboot4extlinux-am335x_bone supports various BeagleBones,
  13. # the AM335x GP EVM and the EVM SK all in one u-boot binary and package.
  14. # - If relevant, the packages it replaces, if there are older u-boot packages
  15. # also supporting that board. Example:uboot-a20-olinuxino-micro
  16. #
  17. # Ideally we'd like to enable people to only add these 4 variables in this
  18. # package to add a new board. These 4 variables could go in something like
  19. # a CVS file that is parsed, but that would require to be able to dynamically
  20. # define packages, but even if eval package_{$_pkgname}() { [...] } works,
  21. # it doesn't make that package function visible to makepkg.
  22. #
  23. # Because of that, contributors wanting to add new boards will have to search
  24. # for example of the information mentioned above and add it in the PKGBUILD
  25. # for their boards.
  26. #
  27. # After adding a new board in this PKGBUILD, to get the board officially
  28. # supported by Parabola.you also need to create a page for it in the
  29. # Parabola wiki for that board and update the ARM installation guide to
  30. # point to it when relevant. Examples of that are available for other
  31. # boards in the ARM installation guide.
  32. pkgbase=uboot4extlinux-sunxi
  33. pkgname=("${pkgbase}"
  34. 'uboot4extlinux-a10-olinuxino-lime'
  35. 'uboot4extlinux-a10s-olinuxino-m'
  36. 'uboot4extlinux-a13-olinuxino'
  37. 'uboot4extlinux-a13-olinuxinom'
  38. 'uboot4extlinux-a20-olinuxino-lime'
  39. 'uboot4extlinux-a20-olinuxino-lime2'
  40. 'uboot4extlinux-a20-olinuxino-lime2-emmc'
  41. 'uboot4extlinux-a20-olinuxino_micro'
  42. 'uboot4extlinux-bananapi'
  43. 'uboot4extlinux-bananapro'
  44. 'uboot4extlinux-chip'
  45. 'uboot4extlinux-cubieboard'
  46. 'uboot4extlinux-cubieboard2'
  47. 'uboot4extlinux-cubietruck'
  48. 'uboot4extlinux-linksprite_pcduino'
  49. 'uboot4extlinux-linksprite_pcduino3'
  50. 'uboot4extlinux-linksprite_pcduino3_nano'
  51. 'uboot4extlinux-orangepi_2'
  52. 'uboot4extlinux-orangepi_one'
  53. 'uboot4extlinux-orangepi_pc'
  54. 'uboot4extlinux-orangepi_plus')
  55. pkgver=2021.07
  56. pkgrel=2
  57. arch=('armv7h' 'i686' 'x86_64')
  58. url="http://git.denx.de/u-boot.git/"
  59. license=('GPL')
  60. makedepends=('bc' 'dtc' 'python' 'python-setuptools' 'python2' 'swig')
  61. makedepends_i686+=('arm-none-eabi-gcc')
  62. makedepends_ppc64le+=('arm-none-eabi-gcc')
  63. makedepends_x86_64+=('arm-none-eabi-gcc')
  64. source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2"
  65. 'extlinux.conf'
  66. "${pkgbase}.hook.in"
  67. 'install-uboot4extlinux.sh.in'
  68. "generate-${pkgbase}-install-text.sh")
  69. sha256sums=('312b7eeae44581d1362c3a3f02c28d806647756c82ba8c72241c7cdbe68ba77e'
  70. 'SKIP'
  71. 'SKIP'
  72. 'SKIP'
  73. 'SKIP')
  74. _defconfigs=('A10-OLinuXino-Lime_defconfig'
  75. 'A10s-OLinuXino-M_defconfig'
  76. 'A13-OLinuXino_defconfig'
  77. 'A13-OLinuXinoM_defconfig'
  78. 'A20-OLinuXino-Lime_defconfig'
  79. 'A20-OLinuXino-Lime2_defconfig'
  80. 'A20-OLinuXino-Lime2-eMMC_defconfig'
  81. 'A20-OLinuXino_MICRO_defconfig'
  82. 'Bananapi_defconfig'
  83. 'Bananapro_defconfig'
  84. 'CHIP_defconfig'
  85. 'Cubieboard_defconfig'
  86. 'Cubieboard2_defconfig'
  87. 'Cubietruck_defconfig'
  88. 'Linksprite_pcDuino_defconfig'
  89. 'Linksprite_pcDuino3_defconfig'
  90. 'Linksprite_pcDuino3_Nano_defconfig'
  91. 'orangepi_2_defconfig'
  92. 'orangepi_one_defconfig'
  93. 'orangepi_pc_defconfig'
  94. 'orangepi_plus_defconfig')
  95. # Offset at which to install u-boot
  96. u_boot_with_spl_offset=8192
  97. case "$CARCH" in
  98. armv7h) ARCH=arm;;
  99. i686|ppc64le|x86_64) ARCH=arm;CROSS_COMPILE=arm-none-eabi-;;
  100. esac
  101. _nr_targets=0
  102. for _defconfig in ${_defconfigs[@]}; do
  103. _nr_targets=$(expr ${_nr_targets} + 1)
  104. done
  105. _get_target_name()
  106. {
  107. _defconfig="$1"
  108. echo ${_defconfig} | \
  109. sed 's/_defconfig$//' | \
  110. awk '{print tolower($0)}'
  111. }
  112. _get_target_destdir()
  113. {
  114. _defconfig="$1"
  115. _target_name="$(_get_target_name ${_defconfig})"
  116. echo "build/uboot4extlinux-${_target_name}"
  117. }
  118. _build_uboot_target()
  119. {
  120. _defconfig="$1"
  121. _destdir="$(_get_target_destdir ${_defconfig})"
  122. _target_name="$(_get_target_name ${_defconfig})"
  123. unset CFLAGS CXXFLAGS LDFLAGS
  124. make "ARCH=${ARCH}" distclean
  125. make "ARCH=${ARCH}" ${_defconfig}
  126. echo 'CONFIG_IDENT_STRING=" Parabola GNU/Linux-libre"' >> .config
  127. if [ "$CARCH" = "armv7h" ]; then
  128. make "ARCH=${ARCH}" EXTRAVERSION=-${pkgrel}
  129. else
  130. make "ARCH=${ARCH}" "CROSS_COMPILE=${CROSS_COMPILE}" \
  131. EXTRAVERSION=-${pkgrel}
  132. fi
  133. echo "==> Installing ${_target_name} to ${_destdir}"
  134. install -d ${_destdir}
  135. mv -f u-boot-sunxi-with-spl.bin "${_destdir}"
  136. }
  137. build()
  138. {
  139. cd u-boot-${pkgver}
  140. _target_nr=0
  141. for _defconfig in ${_defconfigs[@]}; do
  142. _target_nr=$(expr ${_target_nr} + 1)
  143. _target_name="$(_get_target_name ${_defconfig})"
  144. echo "==> Building ${_target_name} " \
  145. "[${_target_nr} of ${_nr_targets} targets]"
  146. _build_uboot_target "${_defconfig}"
  147. done
  148. }
  149. _check_uboot_target()
  150. {
  151. _defconfig="$1"
  152. _image="$(_get_target_destdir ${_defconfig})/u-boot-sunxi-with-spl.bin"
  153. _image_size="$(du --bytes --apparent-size ${_image} | awk '{print $1}')"
  154. _offset="${u_boot_with_spl_offset}"
  155. _image_end=$(expr ${_image_size} + ${_offset})
  156. # This test comes from install-uboot4extlinux.sh.in
  157. if [ ${_image_end} -gt $(expr 1024 \* 1024) ] ; then
  158. echo "Error: ${_image} is too big:"
  159. echo " offset: ${_offset}"
  160. echo " size: ${_image_size}"
  161. echo " By default, "\
  162. "partitioing tools makes the first partition start at 1MiB"
  163. echo " Instaling ${_image} "\
  164. "would overwrite that first partition (if it's present)."
  165. false # Fail the test
  166. fi
  167. }
  168. check()
  169. {
  170. cd u-boot-${pkgver}
  171. _target_nr=0
  172. for _defconfig in ${_defconfigs[@]}; do
  173. _target_nr=$(expr ${_target_nr} + 1)
  174. _target_name="$(_get_target_name ${_defconfig})"
  175. echo "==> Testing target ${_target_name} " \
  176. "[${_target_nr} of ${_nr_targets} targets]"
  177. _check_uboot_target "${_defconfig}"
  178. done
  179. }
  180. _make_uboot_package()
  181. {
  182. _pkgname="$1"
  183. if [ -n "${pkgdir}" ] ; then
  184. cd "u-boot-${pkgver}"
  185. # Install the u-boot binary
  186. install -d "${pkgdir}/usr/lib/u-boot/${_pkgname}/"
  187. install -Dm644 "build/${_pkgname}/u-boot-sunxi-with-spl.bin" \
  188. "${pkgdir}/usr/lib/u-boot/${_pkgname}"
  189. # Install the u-boot installation script
  190. sed < "${srcdir}/install-uboot4extlinux.sh.in" > \
  191. "${pkgdir}/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" \
  192. -e "s|@u_boot_with_spl[@]|/usr/lib/u-boot/${_pkgname}/u-boot-sunxi-with-spl.bin|g" \
  193. -e "s|@u_boot_with_spl_offset[@]|${u_boot_with_spl_offset}|g"
  194. chmod +x \
  195. "${pkgdir}/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh"
  196. # Install what is required for the pacman hook
  197. install -d "${pkgdir}/usr/share/libalpm/hooks/"
  198. sed < "${srcdir}/${pkgbase}.hook.in" > \
  199. "${pkgdir}/usr/share/libalpm/hooks/${_pkgname}.hook" \
  200. -e "s|@pkgname[@]|${_pkgname}|g"
  201. install -d "${pkgdir}/usr/share/doc/u-boot/${_pkgname}/"
  202. # If we install several uboot4extlinux, we need a way to clearly
  203. # separate each postinstall message. To do that we wrapped the
  204. # text in an ASCII art square, but doing that is complicated when
  205. # using sed as the package name as well as the installation script
  206. # path both have variable length.
  207. sh "${srcdir}/generate-${pkgbase}-install-text.sh" \
  208. "${_pkgname}" \
  209. "${pkgbase}" \
  210. "/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" > \
  211. "${pkgdir}/usr/share/doc/u-boot/${_pkgname}/install-uboot4extlinux.txt"
  212. fi
  213. }
  214. _make_pkgdesc()
  215. {
  216. board_name="$1"
  217. echo "U-Boot with Extlinux support for ${board_name}"
  218. }
  219. package_uboot4extlinux-sunxi()
  220. {
  221. pkgdesc="Scripts for managing U-Boot installations for computers with Allwinner System On a Chip"
  222. depends=('uboot-tools')
  223. # Users are expected to use this as a base for /boot/extlinux/extlinux.conf
  224. install -d "${pkgdir}/usr/lib/u-boot/${pkgname}/"
  225. install -Dm644 \
  226. "${srcdir}/extlinux.conf" \
  227. "${pkgdir}/usr/lib/u-boot/${pkgname}/"
  228. }
  229. package_uboot4extlinux-a10-olinuxino-lime()
  230. {
  231. pkgdesc=$(_make_pkgdesc "A10 OLinuXino Lime")
  232. # util-linux is needed for blkid for install-uboot4extlinux.sh
  233. depends=("${pkgbase}" 'util-linux')
  234. _make_uboot_package "${pkgname}"
  235. }
  236. package_uboot4extlinux-a10s-olinuxino-m()
  237. {
  238. pkgdesc=$(_make_pkgdesc "A10s OLinuXino Micro")
  239. replaces=('uboot4extlinux-a10s-olinuxino-micro')
  240. # util-linux is needed for blkid for install-uboot4extlinux.sh
  241. depends=("${pkgbase}" 'util-linux')
  242. _make_uboot_package "${pkgname}"
  243. }
  244. package_uboot4extlinux-a13-olinuxino()
  245. {
  246. pkgdesc=$(_make_pkgdesc "A13 OLinuXino")
  247. # util-linux is needed for blkid for install-uboot4extlinux.sh
  248. depends=("${pkgbase}" 'util-linux')
  249. _make_uboot_package "${pkgname}"
  250. }
  251. package_uboot4extlinux-a13-olinuxinom()
  252. {
  253. pkgdesc=$(_make_pkgdesc "uboot4extlinux-a13-olinuxino-micro")
  254. replaces=('uboot4extlinux-a13-olinuxino-micro')
  255. # util-linux is needed for blkid for install-uboot4extlinux.sh
  256. depends=("${pkgbase}" 'util-linux')
  257. _make_uboot_package "${pkgname}"
  258. }
  259. package_uboot4extlinux-a20-olinuxino-lime()
  260. {
  261. pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime")
  262. # util-linux is needed for blkid for install-uboot4extlinux.sh
  263. depends=("${pkgbase}" 'util-linux')
  264. _make_uboot_package "${pkgname}"
  265. }
  266. package_uboot4extlinux-a20-olinuxino-lime2()
  267. {
  268. pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime2")
  269. # util-linux is needed for blkid for install-uboot4extlinux.sh
  270. depends=("${pkgbase}" 'util-linux')
  271. _make_uboot_package "${pkgname}"
  272. }
  273. package_uboot4extlinux-a20-olinuxino-lime2-emmc()
  274. {
  275. pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime2 with eMMC")
  276. # util-linux is needed for blkid for install-uboot4extlinux.sh
  277. depends=("${pkgbase}" 'util-linux')
  278. _make_uboot_package "${pkgname}"
  279. }
  280. package_uboot4extlinux-a20-olinuxino_micro()
  281. {
  282. pkgdesc=$(_make_pkgdesc "uboot-a20-olinuxino-micro")
  283. replaces=('uboot-a20-olinuxino-micro')
  284. # util-linux is needed for blkid for install-uboot4extlinux.sh
  285. depends=("${pkgbase}" 'util-linux')
  286. _make_uboot_package "${pkgname}"
  287. }
  288. package_uboot4extlinux-bananapi()
  289. {
  290. pkgdesc=$(_make_pkgdesc "Banana Pi")
  291. # util-linux is needed for blkid for install-uboot4extlinux.sh
  292. depends=("${pkgbase}" 'util-linux')
  293. _make_uboot_package "${pkgname}"
  294. }
  295. package_uboot4extlinux-bananapro()
  296. {
  297. pkgdesc=$(_make_pkgdesc "Banana Pro")
  298. # util-linux is needed for blkid for install-uboot4extlinux.sh
  299. depends=("${pkgbase}" 'util-linux')
  300. _make_uboot_package "${pkgname}"
  301. }
  302. package_uboot4extlinux-chip()
  303. {
  304. pkgdesc=$(_make_pkgdesc "C.H.I.P")
  305. # util-linux is needed for blkid for install-uboot4extlinux.sh
  306. depends=("${pkgbase}" 'util-linux')
  307. _make_uboot_package "${pkgname}"
  308. }
  309. package_uboot4extlinux-cubieboard()
  310. {
  311. pkgdesc=$(_make_pkgdesc "Cubieboard")
  312. # util-linux is needed for blkid for install-uboot4extlinux.sh
  313. depends=("${pkgbase}" 'util-linux')
  314. _make_uboot_package "${pkgname}"
  315. }
  316. package_uboot4extlinux-cubieboard2()
  317. {
  318. pkgdesc=$(_make_pkgdesc "Cubieboard 2")
  319. # util-linux is needed for blkid for install-uboot4extlinux.sh
  320. depends=("${pkgbase}" 'util-linux')
  321. _make_uboot_package "${pkgname}"
  322. }
  323. package_uboot4extlinux-cubietruck()
  324. {
  325. pkgdesc=$(_make_pkgdesc "Cubietruck")
  326. # util-linux is needed for blkid for install-uboot4extlinux.sh
  327. depends=("${pkgbase}" 'util-linux')
  328. _make_uboot_package "${pkgname}"
  329. }
  330. package_uboot4extlinux-linksprite_pcduino()
  331. {
  332. pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino")
  333. replaces=('uboot4extlinux-pcduino')
  334. # util-linux is needed for blkid for install-uboot4extlinux.sh
  335. depends=("${pkgbase}" 'util-linux')
  336. _make_uboot_package "${pkgname}"
  337. }
  338. package_uboot4extlinux-linksprite_pcduino3()
  339. {
  340. pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino3")
  341. replaces=('uboot4extlinux-pcduino3')
  342. # util-linux is needed for blkid for install-uboot4extlinux.sh
  343. depends=("${pkgbase}" 'util-linux')
  344. _make_uboot_package "${pkgname}"
  345. }
  346. package_uboot4extlinux-linksprite_pcduino3_nano()
  347. {
  348. pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino3-nano")
  349. replaces=('uboot4extlinux-pcduino3-nano')
  350. # util-linux is needed for blkid for install-uboot4extlinux.sh
  351. depends=("${pkgbase}" 'util-linux')
  352. _make_uboot_package "${pkgname}"
  353. }
  354. package_uboot4extlinux-orangepi_2()
  355. {
  356. pkgdesc=$(_make_pkgdesc "Orange Pi 2")
  357. # util-linux is needed for blkid for install-uboot4extlinux.sh
  358. depends=("${pkgbase}" 'util-linux')
  359. _make_uboot_package "${pkgname}"
  360. }
  361. package_uboot4extlinux-orangepi_one()
  362. {
  363. pkgdesc=$(_make_pkgdesc "Orange Pi One")
  364. # util-linux is needed for blkid for install-uboot4extlinux.sh
  365. depends=("${pkgbase}" 'util-linux')
  366. _make_uboot_package "${pkgname}"
  367. }
  368. package_uboot4extlinux-orangepi_pc()
  369. {
  370. pkgdesc=$(_make_pkgdesc "Orange Pi PC")
  371. # util-linux is needed for blkid for install-uboot4extlinux.sh
  372. depends=("${pkgbase}" 'util-linux')
  373. _make_uboot_package "${pkgname}"
  374. }
  375. package_uboot4extlinux-orangepi_plus()
  376. {
  377. pkgdesc=$(_make_pkgdesc "Orange Pi Plus")
  378. # util-linux is needed for blkid for install-uboot4extlinux.sh
  379. depends=("${pkgbase}" 'util-linux')
  380. _make_uboot_package "${pkgname}"
  381. }