PKGBUILD 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. # U-Boot: sunXi
  2. # Contributor: 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. # - The package name. Example: uboot4extlinux-a20-olinuxino_micro
  9. # - The u-boot configuration. Example: A20-OLinuXino_MICRO_defconfig
  10. # - The name of the board(s). Example: A20 OLinuXino Micro
  11. # A single package / u-boot configuration sometimes support multiple
  12. # boards and the configuration name doesn't always have the boards names
  13. # in it. Example: uboot4extlinux-am335x_bone supports various BeagleBones,
  14. # the AM335x GP EVM and the EVM SK all in one u-boot binary and package.
  15. # - If relevant, the packages it replaces, if there are older u-boot packages
  16. # also supporting that board. Example:uboot-a20-olinuxino-micro
  17. #
  18. # Ideally we'd like to enable people to only add these 4 variables in this
  19. # package to add a new board. These 4 variables could go in something like
  20. # a CVS file that is parsed, but that would require to be able to dynamically
  21. # define packages, but even if eval package_{$_pkgname}() { [...] } works,
  22. # it doesn't make that package function visible to makepkg.
  23. #
  24. # Because of that, contributors wanting to add new boards will have to search
  25. # for example of the information mentioned above and add it in the PKGBUILD
  26. # for their boards.
  27. #
  28. # After adding a new board in this PKGBUILD, to get the board officially
  29. # supported by Parabola.you also need to create a page for it in the
  30. # Parabola wiki for that board and update the ARM installation guide to
  31. # point to it when relevant. Examples of that are available for other
  32. # boards in the ARM installation guide.
  33. _upstream_name=u-boot-libre
  34. pkgbase=uboot4extlinux-sunxi
  35. pkgname=("${pkgbase}"
  36. 'uboot4extlinux-a10-olinuxino-lime'
  37. 'uboot4extlinux-a10s-olinuxino-m'
  38. 'uboot4extlinux-a13-olinuxino'
  39. 'uboot4extlinux-a13-olinuxinom'
  40. 'uboot4extlinux-a20-olinuxino-lime'
  41. 'uboot4extlinux-a20-olinuxino-lime2'
  42. 'uboot4extlinux-a20-olinuxino-lime2-emmc'
  43. 'uboot4extlinux-a20-olinuxino_micro'
  44. 'uboot4extlinux-bananapi'
  45. 'uboot4extlinux-bananapro'
  46. 'uboot4extlinux-chip'
  47. 'uboot4extlinux-cubieboard'
  48. 'uboot4extlinux-cubieboard2'
  49. 'uboot4extlinux-cubietruck'
  50. 'uboot4extlinux-linksprite_pcduino'
  51. 'uboot4extlinux-linksprite_pcduino3'
  52. 'uboot4extlinux-linksprite_pcduino3_nano'
  53. 'uboot4extlinux-orangepi_2'
  54. 'uboot4extlinux-orangepi_one'
  55. 'uboot4extlinux-orangepi_pc'
  56. 'uboot4extlinux-orangepi_plus')
  57. _uboot_ver=2022.04 # version of the upstream u-boot source code
  58. _ubootlibre_rev=r1 # revision of the u-boot-libre deblob script
  59. pkgver="${_uboot_ver}"
  60. pkgrel="${_ubootlibre_rev}.parabola3"
  61. arch=('armv7h' 'i686' 'x86_64')
  62. url="https://libreboot.org/docs/maintain/#resourcesscriptsbuildreleaseu-boot-libre"
  63. license=('GPL')
  64. makedepends=('bc' 'dtc' 'python' 'python-setuptools' 'python2' 'swig')
  65. makedepends_i686+=('arm-none-eabi-gcc')
  66. makedepends_ppc64le+=('arm-none-eabi-gcc')
  67. makedepends_x86_64+=('arm-none-eabi-gcc')
  68. _mirror="https://mirrors.mit.edu/libreboot/" # use a mirror per libreboot's request
  69. source=("${_mirror}/${_upstream_name}/${_uboot_ver}-${_ubootlibre_rev}/${_upstream_name}-${_uboot_ver}-${_ubootlibre_rev}.tar.xz")
  70. source+=('extlinux.conf'
  71. "${pkgbase}.hook.in"
  72. 'install-uboot4extlinux.sh.in'
  73. "generate-${pkgbase}-install-text.sh")
  74. # TODO: this checksum doesn't correspond to the one in
  75. # tests/u-boot-libre.sha512. This means that the tarball is not
  76. # reproducible yet. According to diffoscope, the only changes so
  77. # far seems to be some permissions changes:
  78. # │ -drwxr-xr-x [...] 0 1969-12-31 23:00:00.000000 u-boot-libre-2021.07-r1/
  79. # │ +drwxrwxr-x [...] 0 1969-12-31 23:00:00.000000 u-boot-libre-2021.07-r1/
  80. # │ --rw-r--r-- [...] 16576 1969-12-31 23:00:00.000000 u-boot-libre-2021.07-r1/.azure-pipelines.yml
  81. # │ +-rw-rw-r-- [...] 16576 1969-12-31 23:00:00.000000 u-boot-libre-2021.07-r1/.azure-pipelines.yml
  82. # I've not checked if some files were added or not but at least it
  83. # shows only diffs like the one above, and it doesn't show any file
  84. # content diff.
  85. # TODO: Check the signatures of the released files, not just the content
  86. # TODO: We also need to look into drivers/dma/MCD_tasks.c. The debian
  87. # version of u-boot removes it. It's some data that looks like
  88. # code, so while there is a valid license, we might lack
  89. # corresponding source code if it's really some code. The debian
  90. # commits might have more information about it.
  91. sha512sums=('b816667988210c4f5e0e219fcf633fe0c599ced74568a2924afc8df14bede52ce0c9615ff27eae3ecf194d41a87d04231f099c90beece18028ee5890a3911669')
  92. sha512sums+=('dcbcbc8d196c7dd7db1a8a30dfa8c9ece5d241580bdf593df5fa2de527f0dfea2bb76ff9bfe49fb1e9d631bd1e4b95c828a41cfb38dc2ddc9553e18a54a521f0'
  93. '766b28c45218746672d3e802c16f2c1283d708b43edf0a42cb569c1cfa6d6d3f318d5da91efcc832303dcc2175ee23528d15891010c187dea4c6828e82596be3'
  94. '1ecb7b932bb0b097cac2cdfabbf7faa1601a556b49782f68109be07e49bff62d4515d6492ad1c72f471cdc7b4e1c2d8750e3494fcb0fc93108e6e5bd4e82aedb'
  95. 'b0e8b0ec7f742778ffed486cf529d56d550db48354a4251867078fda8e5a28c8938f6c005225042744c1117a6abb3843e632234b8fd73d8bfdd9c590b0165e4c')
  96. # supported boards
  97. _defconfigs=('A10-OLinuXino-Lime_defconfig'
  98. 'A10s-OLinuXino-M_defconfig'
  99. 'A13-OLinuXino_defconfig'
  100. 'A13-OLinuXinoM_defconfig'
  101. 'A20-OLinuXino-Lime_defconfig'
  102. 'A20-OLinuXino-Lime2_defconfig'
  103. 'A20-OLinuXino-Lime2-eMMC_defconfig'
  104. 'A20-OLinuXino_MICRO_defconfig'
  105. 'Bananapi_defconfig'
  106. 'Bananapro_defconfig'
  107. 'CHIP_defconfig'
  108. 'Cubieboard_defconfig'
  109. 'Cubieboard2_defconfig'
  110. 'Cubietruck_defconfig'
  111. 'Linksprite_pcDuino_defconfig'
  112. 'Linksprite_pcDuino3_defconfig'
  113. 'Linksprite_pcDuino3_Nano_defconfig'
  114. 'orangepi_2_defconfig'
  115. 'orangepi_one_defconfig'
  116. 'orangepi_pc_defconfig'
  117. 'orangepi_plus_defconfig')
  118. # Offset at which to install u-boot
  119. u_boot_with_spl_offset=8192
  120. _nr_targets=0
  121. for _defconfig in ${_defconfigs[@]}; do
  122. _nr_targets=$(expr ${_nr_targets} + 1)
  123. done
  124. _get_target_name()
  125. {
  126. _defconfig="$1"
  127. echo ${_defconfig} | \
  128. sed 's/_defconfig$//' | \
  129. awk '{print tolower($0)}'
  130. }
  131. _get_target_destdir()
  132. {
  133. _defconfig="$1"
  134. _target_name="$(_get_target_name ${_defconfig})"
  135. echo "build/uboot4extlinux-${_target_name}"
  136. }
  137. _build_uboot_target()
  138. {
  139. _defconfig="$1"
  140. _destdir="$(_get_target_destdir ${_defconfig})"
  141. _target_name="$(_get_target_name ${_defconfig})"
  142. unset CFLAGS CXXFLAGS LDFLAGS
  143. local make_vars=( ARCH=arm )
  144. make ${make_vars[*]} distclean
  145. make ${make_vars[*]} ${_defconfig}
  146. make_vars+=( EXTRAVERSION=-${pkgrel} )
  147. [[ "$CARCH" != armv7h ]] && make_vars+=( CROSS_COMPILE=arm-none-eabi- ) || :
  148. echo 'CONFIG_IDENT_STRING=" Parabola GNU/Linux-libre"' >> .config
  149. make ${make_vars[*]}
  150. echo "==> Installing ${_target_name} to ${_destdir}"
  151. install -d ${_destdir}
  152. mv -f u-boot-sunxi-with-spl.bin "${_destdir}"
  153. }
  154. # TODO: We need to fix the timestamps upstream to a valid date
  155. # (like the first January 1970at 01:00:00 CET) or something derived
  156. # from the release version somehow. Else we have the build log spammed
  157. # with errors like that:
  158. # make: scripts/Makefile.extrawarn: Timestamp out of range;
  159. # substituting 1970-01-01 00:59:59.999999999
  160. # TODO: While we're at it we could export SOURCE_DATE_SPOCH to try to
  161. # make the u-boot package reporducible.
  162. prepare()
  163. {
  164. cd "${srcdir}"/u-boot-v${_uboot_ver}-${_ubootlibre_rev}
  165. find -print0 | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
  166. }
  167. build()
  168. {
  169. cd "${srcdir}"/u-boot-v${_uboot_ver}-${_ubootlibre_rev}
  170. _target_nr=0
  171. for _defconfig in ${_defconfigs[@]}; do
  172. _target_nr=$(expr ${_target_nr} + 1)
  173. _target_name="$(_get_target_name ${_defconfig})"
  174. echo "==> Building ${_target_name} " \
  175. "[${_target_nr} of ${_nr_targets} targets]"
  176. _build_uboot_target "${_defconfig}"
  177. done
  178. }
  179. _check_uboot_target()
  180. {
  181. _defconfig="$1"
  182. _image="$(_get_target_destdir ${_defconfig})/u-boot-sunxi-with-spl.bin"
  183. _image_size="$(du --bytes --apparent-size ${_image} | awk '{print $1}')"
  184. _offset="${u_boot_with_spl_offset}"
  185. _image_end=$(expr ${_image_size} + ${_offset})
  186. # This test comes from install-uboot4extlinux.sh.in
  187. if [ ${_image_end} -gt $(expr 1024 \* 1024) ] ; then
  188. echo "Error: ${_image} is too big:"
  189. echo " offset: ${_offset}"
  190. echo " size: ${_image_size}"
  191. echo " By default, "\
  192. "partitioing tools makes the first partition start at 1MiB"
  193. echo " Instaling ${_image} "\
  194. "would overwrite that first partition (if it's present)."
  195. false # Fail the test
  196. fi
  197. }
  198. check()
  199. {
  200. cd "${srcdir}"/u-boot-v${_uboot_ver}-${_ubootlibre_rev}
  201. _target_nr=0
  202. for _defconfig in ${_defconfigs[@]}; do
  203. _target_nr=$(expr ${_target_nr} + 1)
  204. _target_name="$(_get_target_name ${_defconfig})"
  205. echo "==> Testing target ${_target_name} " \
  206. "[${_target_nr} of ${_nr_targets} targets]"
  207. _check_uboot_target "${_defconfig}"
  208. done
  209. }
  210. _make_uboot_package()
  211. {
  212. _pkgname="$1"
  213. if [ -n "${pkgdir}" ] ; then
  214. cd "${srcdir}"/u-boot-v${_uboot_ver}-${_ubootlibre_rev}
  215. # Install the u-boot binary
  216. install -d "${pkgdir}/usr/lib/u-boot/${_pkgname}/"
  217. install -Dm644 "build/${_pkgname}/u-boot-sunxi-with-spl.bin" \
  218. "${pkgdir}/usr/lib/u-boot/${_pkgname}"
  219. # Install the u-boot installation script
  220. sed < "${srcdir}/install-uboot4extlinux.sh.in" > \
  221. "${pkgdir}/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" \
  222. -e "s|@u_boot_with_spl[@]|/usr/lib/u-boot/${_pkgname}/u-boot-sunxi-with-spl.bin|g" \
  223. -e "s|@u_boot_with_spl_offset[@]|${u_boot_with_spl_offset}|g"
  224. chmod +x \
  225. "${pkgdir}/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh"
  226. # Install what is required for the pacman hook
  227. install -d "${pkgdir}/usr/share/libalpm/hooks/"
  228. sed < "${srcdir}/${pkgbase}.hook.in" > \
  229. "${pkgdir}/usr/share/libalpm/hooks/${_pkgname}.hook" \
  230. -e "s|@pkgname[@]|${_pkgname}|g"
  231. install -d "${pkgdir}/usr/share/doc/u-boot/${_pkgname}/"
  232. # If we install several uboot4extlinux, we need a way to clearly
  233. # separate each postinstall message. To do that we wrapped the
  234. # text in an ASCII art square, but doing that is complicated when
  235. # using sed as the package name as well as the installation script
  236. # path both have variable length.
  237. sh "${srcdir}/generate-${pkgbase}-install-text.sh" \
  238. "${_pkgname}" \
  239. "${pkgbase}" \
  240. "/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" > \
  241. "${pkgdir}/usr/share/doc/u-boot/${_pkgname}/install-uboot4extlinux.txt"
  242. fi
  243. }
  244. _make_pkgdesc()
  245. {
  246. board_name="$1"
  247. echo "U-Boot with Extlinux support for ${board_name}"
  248. }
  249. package_uboot4extlinux-sunxi()
  250. {
  251. pkgdesc="Scripts for managing U-Boot installations for computers with Allwinner System On a Chip"
  252. depends=('uboot-tools')
  253. # Users are expected to use this as a base for /boot/extlinux/extlinux.conf
  254. install -d "${pkgdir}/usr/lib/u-boot/${pkgname}/"
  255. install -Dm644 \
  256. "${srcdir}/extlinux.conf" \
  257. "${pkgdir}/usr/lib/u-boot/${pkgname}/"
  258. }
  259. package_uboot4extlinux-a10-olinuxino-lime()
  260. {
  261. pkgdesc=$(_make_pkgdesc "A10 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-a10s-olinuxino-m()
  267. {
  268. pkgdesc=$(_make_pkgdesc "A10s OLinuXino Micro")
  269. replaces=('uboot4extlinux-a10s-olinuxino-micro')
  270. # util-linux is needed for blkid for install-uboot4extlinux.sh
  271. depends=("${pkgbase}" 'util-linux')
  272. _make_uboot_package "${pkgname}"
  273. }
  274. package_uboot4extlinux-a13-olinuxino()
  275. {
  276. pkgdesc=$(_make_pkgdesc "A13 OLinuXino")
  277. # util-linux is needed for blkid for install-uboot4extlinux.sh
  278. depends=("${pkgbase}" 'util-linux')
  279. _make_uboot_package "${pkgname}"
  280. }
  281. package_uboot4extlinux-a13-olinuxinom()
  282. {
  283. pkgdesc=$(_make_pkgdesc "uboot4extlinux-a13-olinuxino-micro")
  284. replaces=('uboot4extlinux-a13-olinuxino-micro')
  285. # util-linux is needed for blkid for install-uboot4extlinux.sh
  286. depends=("${pkgbase}" 'util-linux')
  287. _make_uboot_package "${pkgname}"
  288. }
  289. package_uboot4extlinux-a20-olinuxino-lime()
  290. {
  291. pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime")
  292. # util-linux is needed for blkid for install-uboot4extlinux.sh
  293. depends=("${pkgbase}" 'util-linux')
  294. _make_uboot_package "${pkgname}"
  295. }
  296. package_uboot4extlinux-a20-olinuxino-lime2()
  297. {
  298. pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime2")
  299. # util-linux is needed for blkid for install-uboot4extlinux.sh
  300. depends=("${pkgbase}" 'util-linux')
  301. _make_uboot_package "${pkgname}"
  302. }
  303. package_uboot4extlinux-a20-olinuxino-lime2-emmc()
  304. {
  305. pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime2 with eMMC")
  306. # util-linux is needed for blkid for install-uboot4extlinux.sh
  307. depends=("${pkgbase}" 'util-linux')
  308. _make_uboot_package "${pkgname}"
  309. }
  310. package_uboot4extlinux-a20-olinuxino_micro()
  311. {
  312. pkgdesc=$(_make_pkgdesc "uboot-a20-olinuxino-micro")
  313. replaces=('uboot-a20-olinuxino-micro')
  314. # util-linux is needed for blkid for install-uboot4extlinux.sh
  315. depends=("${pkgbase}" 'util-linux')
  316. _make_uboot_package "${pkgname}"
  317. }
  318. package_uboot4extlinux-bananapi()
  319. {
  320. pkgdesc=$(_make_pkgdesc "Banana Pi")
  321. # util-linux is needed for blkid for install-uboot4extlinux.sh
  322. depends=("${pkgbase}" 'util-linux')
  323. _make_uboot_package "${pkgname}"
  324. }
  325. package_uboot4extlinux-bananapro()
  326. {
  327. pkgdesc=$(_make_pkgdesc "Banana Pro")
  328. # util-linux is needed for blkid for install-uboot4extlinux.sh
  329. depends=("${pkgbase}" 'util-linux')
  330. _make_uboot_package "${pkgname}"
  331. }
  332. package_uboot4extlinux-chip()
  333. {
  334. pkgdesc=$(_make_pkgdesc "C.H.I.P")
  335. # util-linux is needed for blkid for install-uboot4extlinux.sh
  336. depends=("${pkgbase}" 'util-linux')
  337. _make_uboot_package "${pkgname}"
  338. }
  339. package_uboot4extlinux-cubieboard()
  340. {
  341. pkgdesc=$(_make_pkgdesc "Cubieboard")
  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-cubieboard2()
  347. {
  348. pkgdesc=$(_make_pkgdesc "Cubieboard 2")
  349. # util-linux is needed for blkid for install-uboot4extlinux.sh
  350. depends=("${pkgbase}" 'util-linux')
  351. _make_uboot_package "${pkgname}"
  352. }
  353. package_uboot4extlinux-cubietruck()
  354. {
  355. pkgdesc=$(_make_pkgdesc "Cubietruck")
  356. # util-linux is needed for blkid for install-uboot4extlinux.sh
  357. depends=("${pkgbase}" 'util-linux')
  358. _make_uboot_package "${pkgname}"
  359. }
  360. package_uboot4extlinux-linksprite_pcduino()
  361. {
  362. pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino")
  363. replaces=('uboot4extlinux-pcduino')
  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-linksprite_pcduino3()
  369. {
  370. pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino3")
  371. replaces=('uboot4extlinux-pcduino3')
  372. # util-linux is needed for blkid for install-uboot4extlinux.sh
  373. depends=("${pkgbase}" 'util-linux')
  374. _make_uboot_package "${pkgname}"
  375. }
  376. package_uboot4extlinux-linksprite_pcduino3_nano()
  377. {
  378. pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino3-nano")
  379. replaces=('uboot4extlinux-pcduino3-nano')
  380. # util-linux is needed for blkid for install-uboot4extlinux.sh
  381. depends=("${pkgbase}" 'util-linux')
  382. _make_uboot_package "${pkgname}"
  383. }
  384. package_uboot4extlinux-orangepi_2()
  385. {
  386. pkgdesc=$(_make_pkgdesc "Orange Pi 2")
  387. # util-linux is needed for blkid for install-uboot4extlinux.sh
  388. depends=("${pkgbase}" 'util-linux')
  389. _make_uboot_package "${pkgname}"
  390. }
  391. package_uboot4extlinux-orangepi_one()
  392. {
  393. pkgdesc=$(_make_pkgdesc "Orange Pi One")
  394. # util-linux is needed for blkid for install-uboot4extlinux.sh
  395. depends=("${pkgbase}" 'util-linux')
  396. _make_uboot_package "${pkgname}"
  397. }
  398. package_uboot4extlinux-orangepi_pc()
  399. {
  400. pkgdesc=$(_make_pkgdesc "Orange Pi PC")
  401. # util-linux is needed for blkid for install-uboot4extlinux.sh
  402. depends=("${pkgbase}" 'util-linux')
  403. _make_uboot_package "${pkgname}"
  404. }
  405. package_uboot4extlinux-orangepi_plus()
  406. {
  407. pkgdesc=$(_make_pkgdesc "Orange Pi Plus")
  408. # util-linux is needed for blkid for install-uboot4extlinux.sh
  409. depends=("${pkgbase}" 'util-linux')
  410. _make_uboot_package "${pkgname}"
  411. }