diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2023-02-26 22:14:00 -0500 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2023-03-07 23:45:11 -0500 |
commit | 24115924fcc2337e380f9cf8aa02dd7cf9855f6d (patch) | |
tree | e6ca165e08332b27685d0dac695d25318a7ee120 | |
parent | b2cce6d8a9be0b5e5c630d8c63186953563394a0 (diff) |
[uboot4extlinux-sunxi]: refactor/housekeeping
-rw-r--r-- | libre-testing/uboot4extlinux-sunxi/PKGBUILD | 664 |
1 files changed, 255 insertions, 409 deletions
diff --git a/libre-testing/uboot4extlinux-sunxi/PKGBUILD b/libre-testing/uboot4extlinux-sunxi/PKGBUILD index 78a8e04eb..0578eb176 100644 --- a/libre-testing/uboot4extlinux-sunxi/PKGBUILD +++ b/libre-testing/uboot4extlinux-sunxi/PKGBUILD @@ -1,5 +1,5 @@ # U-Boot: sunXi -# Maintainer: Isaac David <isacdaavid@at@isacdaavid@dot@info> +# Contributor: Isaac David <isacdaavid@at@isacdaavid@dot@info> # Contributor: André Silva <emulatorman@hyperbola.info> # Contributor: Timothy Redaelli <timothy.redaelli@gmail.com> # Contributor: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> @@ -35,80 +35,73 @@ # boards in the ARM installation guide. -_pkgbase=u-boot-libre -_pkgbase=${_pkgbase/-libre/} # FIXME: The current libreboot uboot depends on 'python2' +_upstream_name=u-boot-libre +_upstream_name=${_upstream_name/-libre/} # FIXME: non-FSDG - The current libreboot uboot depends on 'python2' pkgbase=uboot4extlinux-sunxi -pkgname=("${pkgbase}" - 'uboot4extlinux-a10-olinuxino-lime' - 'uboot4extlinux-a10s-olinuxino-m' - 'uboot4extlinux-a13-olinuxino' - 'uboot4extlinux-a13-olinuxinom' - 'uboot4extlinux-a20-olinuxino-lime' - 'uboot4extlinux-a20-olinuxino-lime2' - 'uboot4extlinux-a20-olinuxino-lime2-emmc' - 'uboot4extlinux-a20-olinuxino_micro' - 'uboot4extlinux-bananapi' - 'uboot4extlinux-bananapro' - 'uboot4extlinux-chip' - 'uboot4extlinux-cubieboard' - 'uboot4extlinux-cubieboard2' - 'uboot4extlinux-cubietruck' - 'uboot4extlinux-linksprite_pcduino' - 'uboot4extlinux-linksprite_pcduino3' - 'uboot4extlinux-linksprite_pcduino3_nano' - 'uboot4extlinux-orangepi_2' - 'uboot4extlinux-orangepi_one' - 'uboot4extlinux-orangepi_pc' - 'uboot4extlinux-orangepi_plus') -pkgname=(uboot4extlinux-teres-i) - -# We have a ${pkgver}-${pkgrel} that looks like that: -# '2021.07-r1.parabola3' and all the individual components are needed: +pkgname=(uboot4extlinux-a10-olinuxino-lime + uboot4extlinux-a10s-olinuxino-m + uboot4extlinux-a13-olinuxino + uboot4extlinux-a13-olinuxinom + uboot4extlinux-a20-olinuxino-lime + uboot4extlinux-a20-olinuxino-lime2 + uboot4extlinux-a20-olinuxino-lime2-emmc + uboot4extlinux-a20-olinuxino_micro + uboot4extlinux-bananapi + uboot4extlinux-bananapro + uboot4extlinux-chip + uboot4extlinux-cubieboard + uboot4extlinux-cubieboard2 + uboot4extlinux-cubietruck + uboot4extlinux-linksprite_pcduino + uboot4extlinux-linksprite_pcduino3 + uboot4extlinux-linksprite_pcduino3_nano + uboot4extlinux-orangepi_2 + uboot4extlinux-orangepi_one + uboot4extlinux-orangepi_pc + uboot4extlinux-orangepi_plus) +pkgname=(uboot4extlinux-teres_i) # WIP teres + + +# We have a ${pkgver}-${pkgrel} like: '2021.07-r1.parabola3'. +# All of the individual components are needed: # - '2021.07' corresponds to the upstream u-boot version. It is needed # to know which u-boot version source code is used. -# - 'r1' corresponds to the u-boot-libre revision. Without it it would +# - 'r1' corresponds to the u-boot-libre revision. Without that, it would # be impossible to fix bugs inside the u-boot-libre deblob script. -# - .parabola3 is the Parabola package revision. Without it it would be -# impossible to fix bugs inside this PKGBUILD. -# As for the '-r1', it cannot go inside pkgver, else we end up with an -# error like that when running makepkg: -# ==> ERROR: pkgver is not allowed to contain colons, forward slashes, -# hyphens or whitespace. -# so it was moved in pkgrel. -_uboot_ver="2021.07" # version of the upstream u-boot source code -_uboot_ver=2023.01 # FIXME: The current libreboot uboot depends on 'python2' -_ubootlibre_rev="r1" # revision of the u-boot-libre deblob script +# - .parabola3 is the Parabola package revision. Without that, it would +# be impossible to fix bugs inside this PKGBUILD. +# As for the '-r1', it cannot go inside pkgver, becasue pkgver is not +# allowed to contain hyphens. So it is in pkgrel instead. +_uboot_ver=2021.07 # version of the upstream u-boot source code +_uboot_ver=2023.01 # FIXME: non-FSDG - The current libreboot uboot depends on 'python2' +_ubootlibre_rev=r1 # revision of the u-boot-libre deblob script pkgver=${_uboot_ver} pkgrel=${_ubootlibre_rev}.parabola1 arch=(aarch64 armv7h x86_64) # TODO: package for armv7h and aarch64 repos -url="https://libreboot.org/docs/maintain/#resourcesscriptsbuildreleaseu-boot-libre" -url="http://www.denx.de/wiki/U-Boot/WebHome" # FIXME: The current libreboot uboot depends on 'python2' -license=('GPL') +url=https://libreboot.org/docs/maintain/#resourcesscriptsbuildreleaseu-boot-libre +url=http://www.denx.de/wiki/U-Boot/WebHome # FIXME: non-FSDG - The current libreboot uboot depends on 'python2' +license=(GPL) makedepends=(bc dtc python python-setuptools swig) -# makedepends_i686+=('arm-none-eabi-gcc') -# makedepends_ppc64le+=('arm-none-eabi-gcc') -# makedepends_x86_64+=('arm-none-eabi-gcc') -makedepends_i686+=('aarch64-linux-gnu-gcc') -makedepends_ppc64le+=('aarch64-linux-gnu-gcc') -makedepends_x86_64+=('aarch64-linux-gnu-gcc' 'or1k-elf-gcc') - -# According to the Libreboot maintainer, we are supposed to use -# any of the mirrors in https://libreboot.org/download.html#https -# and not use the rsync server. The rsync server is only supposed -# to be used by mirrors as it has limited bandwith. +# makedepends_i686+=('arm-none-eabi-gcc') # WIP teres +# makedepends_ppc64le+=('arm-none-eabi-gcc') # WIP teres +# makedepends_x86_64+=('arm-none-eabi-gcc') # WIP teres +makedepends_i686+=('aarch64-linux-gnu-gcc') # WIP teres +makedepends_ppc64le+=('aarch64-linux-gnu-gcc') # WIP teres +makedepends_x86_64+=('aarch64-linux-gnu-gcc' 'or1k-elf-gcc') # WIP teres + _tfa_ver=2.8 _crust_ver=0.5 -_mirror="https://mirrors.mit.edu/libreboot" # use a mirror per libreboot's request -source=("$_mirror/$_pkgbase/$_uboot_ver-$_ubootlibre_rev/$_pkgbase-$_uboot_ver-$_ubootlibre_rev.tar") -source=(ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2{,.sig} # FIXME: The current libreboot uboot depends on 'python2' +_mirror=https://mirrors.mit.edu/libreboot # use a mirror per libreboot's request +source=(${_mirror}/${_upstream_name}/${_uboot_ver}-${_ubootlibre_rev}/${_upstream_name}-${_uboot_ver}-${_ubootlibre_rev}.tar) +source=(ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2{,.sig} # FIXME: non-FSDG - The current libreboot uboot depends on 'python2' https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/snapshot/trusted-firmware-a-${_tfa_ver}.tar.gz crust-${_crust_ver}.tar.gz::https://github.com/crust-firmware/crust/archive/refs/tags/v${_crust_ver}.tar.gz) -source+=('extlinux.conf' - "${pkgbase}.hook.in" - 'install-uboot4extlinux.sh.in' - "generate-${pkgbase}-install-text.sh") +source+=(extlinux.conf + ${pkgbase}.hook.in + install-uboot4extlinux.sh.in + generate-${pkgbase}-install-text.sh) # TODO: the libreboot uboot source-ball checksum doesn't correspond to the one in # tests/u-boot-libre.sha512. This means that the tarball is not @@ -118,9 +111,8 @@ source+=('extlinux.conf' # │ +drwxrwxr-x [...] 0 1969-12-31 23:00:00.000000 u-boot-libre-2021.07-r1/ # │ --rw-r--r-- [...] 16576 1969-12-31 23:00:00.000000 u-boot-libre-2021.07-r1/.azure-pipelines.yml # │ +-rw-rw-r-- [...] 16576 1969-12-31 23:00:00.000000 u-boot-libre-2021.07-r1/.azure-pipelines.yml -# I've not checked if some files were added or not but at least it -# shows only diffs like the one above, and it doesn't show any file -# content diff. +# I've not checked if some files were added or not but at least it shows +# only diffs like the one above, and it doesn't show any file content diff. # TODO: Check the signatures of the released files, not just the content # TODO: We also need to look into drivers/dma/MCD_tasks.c. The debian # version of u-boot removes it. It's some data that looks like @@ -128,7 +120,7 @@ source+=('extlinux.conf' # corresponding source code if it's really some code. The debian # commits might have more information about it. # sha512sums=('4fd4cb762efd6b3e1eede883ee44cbf16f787de7f9bd8d6f9a98d69a22fd75519cce4b9ff713b205d34854597d2f9d6053dabc6097e55cb5be7c7ce71dae2ef6') -sha256sums=('69423bad380f89a0916636e89e6dcbd2e4512d584308d922d1039d1e4331950f' +sha256sums=('69423bad380f89a0916636e89e6dcbd2e4512d584308d922d1039d1e4331950f' # FIXME: non-FSDG - The current libreboot uboot depends on 'python2' 'SKIP' 'df4e0f3803479df0ea4cbf3330b59731bc2efc2112c951f9adb3685229163af9' '8b23b2649bbd19dfb84ae00b2419539b8236c6ae9a380beff7dffafd3f41f31b') @@ -139,6 +131,7 @@ sha256sums+=('490d231b23ed369f1515a5da07fca54d8626c97c5883c9748711078b2c518705' validpgpkeys=('1A3C7F70E08FAB1707809BBF147C39FF9634B72C') # Thomas Rini +# armv7h boards _defconfigs=('A10-OLinuXino-Lime_defconfig' 'A10s-OLinuXino-M_defconfig' 'A13-OLinuXino_defconfig' @@ -160,480 +153,333 @@ _defconfigs=('A10-OLinuXino-Lime_defconfig' 'orangepi_one_defconfig' 'orangepi_pc_defconfig' 'orangepi_plus_defconfig') +# aarch64 boards _defconfigs=(teres_i_defconfig) # WIP teres -# Offset at which to install u-boot -u_boot_with_spl_offset=8192 +# Byte-offset at which to install the bootloader +BOOTLOADER_BYTE_OFFSET=8192 +# Prepare the cross-compilation environment case "$CARCH" in - aarch64|armv7h) ARCH=arm;; - i686|ppc64le|x86_64) ARCH=arm;CROSS_COMPILE=arm-none-eabi-;; + aarch64|armv7h) ARCH=arm;; + i686|ppc64le|x86_64) ARCH=arm;CROSS_COMPILE=arm-none-eabi-;; esac case "$CARCH" in i686|ppc64le|x86_64) ARCH=arm ; CROSS_COMPILE=aarch64-linux-gnu- ;; # WIP teres esac -_nr_targets=0 -for _defconfig in ${_defconfigs[@]}; do - _nr_targets=$(expr ${_nr_targets} + 1) -done +## helpers ## -_get_target_name() +_get_target_name() # (defconfig) { - _defconfig="$1" - - echo ${_defconfig} | \ - sed 's/_defconfig$//' | \ - awk '{print tolower($0)}' + local defconfig=${1/_defconfig/} ; printf ${defconfig,,} ; } -_get_target_destdir() +_get_target_destdir() # (defconfig) { - _defconfig="$1" - _target_name="$(_get_target_name ${_defconfig})" + local defconfig=$1 + local target_name=$(_get_target_name ${defconfig}) - echo "build/uboot4extlinux-${_target_name}" + # NOTE: this path is relative to "${srcdir}"/${_upstream_name}-${_uboot_ver}/ + printf "build/uboot4extlinux-${target_name}" } _build_A64_firmware() { ## compile trusted-firmware-a ## - cd "$srcdir"/trusted-firmware-a-$_tfa_ver + local tfa_srcdir="${srcdir}"/trusted-firmware-a-${_tfa_ver} + local tfa_outdir="${tfa_srcdir}"/build/sun50i_a64/release/ + cd "${tfa_srcdir}" + + echo " -> Building trusted-firmware-a" make PLAT=sun50i_a64 - cp "${BL31/bl31.bin/bl31\/bl31.elf}" "${srcdir}"/${_pkgbase}-${_uboot_ver} + cp "${tfa_outdir}"/bl31/bl31.elf "${srcdir}"/${_upstream_name}-${_uboot_ver} - export BL31="$srcdir"/trusted-firmware-a-$_tfa_ver/build/sun50i_a64/release/bl31.bin + export BL31="${tfa_outdir}"/bl31.bin ## compile crust ## - # SCP firmwar curretly FTBS + local crust_srcdir="${srcdir}"/crust-${_crust_ver} + local crust_outdir="${crust_srcdir}"/build/scp + + # FIXME: SCP firmware currently FTBS # /usr/lib/gcc/or1k-elf/12.2.0/../../../../or1k-elf/bin/ld: # warning: build/scp/scp.elf has a LOAD segment with RWX permissions # https://github.com/crust-firmware/crust/issues/212 - export SCP=/dev/null ; return ; - export ARCH='or1k' - export CROSS_COMPILE='or1k-elf-' + export ARCH=or1k + export CROSS_COMPILE=or1k-elf- - cd "$srcdir"/crust-$_crust_ver - make pine64_plus_defconfig # yes, this is also for A64 + cd "${crust_srcdir}" + echo " -> Building crust" + make pine64_plus_defconfig # yes, this is for generic A64 make scp - export SCP=/dev/null - export ARCH='arm' - export CROSS_COMPILE="aarch64-linux-gnu-" + + ## disable crust ## + +# export SCP=/dev/null + export ARCH=arm + export CROSS_COMPILE=aarch64-linux-gnu- } -_build_uboot_target() +_build_uboot_target() # (defconfig) { - _defconfig="$1" - _destdir="$(_get_target_destdir ${_defconfig})" - _target_name="$(_get_target_name ${_defconfig})" + local defconfig=$1 + local destdir="$( _get_target_destdir ${defconfig})" + local target_name=$(_get_target_name ${defconfig}) # unset CFLAGS CXXFLAGS LDFLAGS # WIP teres - *FLAGS in build() - ## compile uboot ## + ## compile uboot ## - cd "${srcdir}"/${_pkgbase}-${_uboot_ver} + cd "${srcdir}"/${_upstream_name}-${_uboot_ver} -# make "ARCH=${ARCH}" distclean # WIP teres - make distclean # WIP teres -# make "ARCH=${ARCH}" ${_defconfig} # WIP teres - make "$_defconfig" # WIP teres + echo " -> Building ${_upstream_name}" +# make "ARCH=${ARCH}" distclean # WIP teres + make distclean # WIP teres +# make "ARCH=${ARCH}" ${defconfig} # WIP teres + make "${defconfig}" # WIP teres - echo 'CONFIG_IDENT_STRING=" Parabola GNU/Linux-libre"' >> .config + echo 'CONFIG_IDENT_STRING=" Parabola GNU/Linux-libre"' >> .config (( PYTHON_IS_TOO_FINICKY_ABOUT_VERSION_NUMBERS )) && # WIP teres - case "$CARCH" in - armv7h|armv8h) - make EXTRAVERSION="-${_ubootlibre_rev/r/}" ;; - i686|ppc64le|x86_64) - make EXTRAVERSION="-${_ubootlibre_rev/r/}" ;; - *) - esac \ + case "$CARCH" in + armv7h|armv8h ) make EXTRAVERSION="-${_ubootlibre_rev/r/}" ;; + i686|ppc64le|x86_64) make EXTRAVERSION="-${_ubootlibre_rev/r/}" ;; + esac \ || # WIP teres - PYTHON_IS_TOO_FINICKY_ABOUT_VERSION_NUMBERS - if [ "$CARCH" = "armv7h" ]; then - make "ARCH=${ARCH}" EXTRAVERSION=-${pkgrel} - else - make "ARCH=${ARCH}" "CROSS_COMPILE=${CROSS_COMPILE}" \ - EXTRAVERSION=-${pkgrel} - fi - - echo "==> Installing ${_target_name} to ${_destdir}" - install -d ${_destdir} - mv -f u-boot-sunxi-with-spl.bin "${_destdir}" -} + if [ "$CARCH" = "armv7h" ]; then + make "ARCH=${ARCH}" EXTRAVERSION=-${pkgrel} + else + make "ARCH=${ARCH}" "CROSS_COMPILE=${CROSS_COMPILE}" \ + EXTRAVERSION=-${pkgrel} + fi -# TODO: We need to fix the timestamps upstream to a valid date -# (like the first January 1970at 01:00:00 CET) or something derived -# from the release version somehow. Else we have the build log spammed -# with errors like that: -# make: scripts/Makefile.extrawarn: Timestamp out of range; -# substituting 1970-01-01 00:59:59.999999999 -# TODO: While we're at it we could export SOURCE_DATE_SPOCH to try to -# make the u-boot package reporducible. -prepare() -{ - cd "${srcdir}"/${_pkgbase}-${_uboot_ver} - - find -print0 | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" + echo " -> Installing ${target_name} to ${destdir}" + install -d ${destdir} + mv -f u-boot-sunxi-with-spl.bin "${destdir}" } -build() +_check_uboot_target() # (defconfig) { -# cd "${_pkgbase}-${_pkgver}-${_pkgrel}" # WIP teres - `cd` is in _build_uboot_target() - - # both uboot and the 64-bit firmwares FTBS with the default CFLAGS and LDFLAGS - # * Assembler messages: Error: unrecognized option -march=x86-64 - # * cc1: error: unknown value 'x86-64' for '-march' - # * cc1: error: '-fcf-protection=full' is not supported for this target - export CFLAGS+=' -march=armv8-a -mtune=cortex-a53 -fcf-protection=check' - # * aarch64-linux-gnu-ld.bfd: unrecognized option '-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' - unset LDFLAGS - # * aarch64-linux-gnu-ld.bfd: warning: bl31.elf has a LOAD segment with RWX permissions - # * aarch64-linux-gnu-ld.bfd: warning: u-boot-spl has a LOAD segment with RWX permissions - export LDFLAGS=' --no-warn-rwx-segments' + cd "${srcdir}"/${_upstream_name}-${_uboot_ver} - [[ "${CROSS_COMPILE}" =~ ^aarch64 ]] && _build_A64_firmware || : # TODO: hackish + local defconfig=$1 + local image=$(_get_target_destdir ${defconfig})/u-boot-sunxi-with-spl.bin + local image_size=$(du --bytes --apparent-size ${image} | cut -d ' ' -f 1) + local offset=${BOOTLOADER_BYTE_OFFSET} + local image_end=$(( image_size + offset )) - _target_nr=0 - for _defconfig in ${_defconfigs[@]}; do - _target_nr=$(expr ${_target_nr} + 1) - _target_name="$(_get_target_name ${_defconfig})" + # NOTE: This check corresponds to a check in install-uboot4extlinux.sh.in + if (( image_end >= 1024 * 1024 )) ; then + echo "Error: ${image} is too large:" + echo " offset: ${offset}" + echo " size: ${image_size}" + echo " Typically, partitioning tools begin partitioning at 1MiB." + echo " Installing ${image} may overwrite an existing partition." - echo "==> Building ${_target_name} " \ - "[${_target_nr} of ${_nr_targets} targets]" - _build_uboot_target "${_defconfig}" - done + false # Fail the check + fi } -_check_uboot_target() +_package() # (pkg_name "board_name") { - _defconfig="$1" - _image="$(_get_target_destdir ${_defconfig})/u-boot-sunxi-with-spl.bin" - _image_size="$(du --bytes --apparent-size ${_image} | awk '{print $1}')" - _offset="${u_boot_with_spl_offset}" - _image_end=$(expr ${_image_size} + ${_offset}) - - # This test comes from install-uboot4extlinux.sh.in - if [ ${_image_end} -gt $(expr 1024 \* 1024) ] ; then - echo "Error: ${_image} is too big:" - echo " offset: ${_offset}" - echo " size: ${_image_size}" - echo " By default, "\ - "partitioing tools makes the first partition start at 1MiB" - echo " Instaling ${_image} "\ - "would overwrite that first partition (if it's present)." - - false # Fail the test - fi -} + local pkg_name=$1 + local board_name="$2" + local lib_dir=/usr/lib/u-boot/${pkg_name} + local hooks_dir="${pkgdir}"/usr/share/libalpm/hooks + local docs_dir="${pkgdir}"/usr/share/doc/u-boot/${pkg_name} + local install_dir="${pkgdir}"${lib_dir} + local bin_name=u-boot-sunxi-with-spl.bin + local install_script=install-uboot4extlinux.sh + local install_text=install-uboot4extlinux.txt -check() -{ - cd "${srcdir}"/${_pkgbase}-${_uboot_ver} + pkgdesc="U-Boot with Extlinux support for ${board_name}" + depends=("${pkgbase}=${pkgver}-${pkgrel}") + depends+=(util-linux) # $install_script needs 'util-linux' for `blkid` - _target_nr=0 - for _defconfig in ${_defconfigs[@]}; do - _target_nr=$(expr ${_target_nr} + 1) - _target_name="$(_get_target_name ${_defconfig})" + cd "${srcdir}"/${_upstream_name}-${_uboot_ver} - echo "==> Testing target ${_target_name} " \ - "[${_target_nr} of ${_nr_targets} targets]" - _check_uboot_target "${_defconfig}" - done -} + # Install the u-boot binary + install -d "${install_dir}"/ + install -Dm644 build/${pkg_name}/${bin_name} "${install_dir}" -_make_uboot_package() -{ - _pkgname="$1" - - if [ -n "${pkgdir}" ] ; then - cd "${srcdir}"/${_pkgbase}-${_uboot_ver} - - # Install the u-boot binary - install -d "${pkgdir}/usr/lib/u-boot/${_pkgname}/" - install -Dm644 "build/${_pkgname}/u-boot-sunxi-with-spl.bin" \ - "${pkgdir}/usr/lib/u-boot/${_pkgname}" - - # Install the u-boot installation script - sed < "${srcdir}/install-uboot4extlinux.sh.in" > \ - "${pkgdir}/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" \ - -e "s|@u_boot_with_spl[@]|/usr/lib/u-boot/${_pkgname}/u-boot-sunxi-with-spl.bin|g" \ - -e "s|@u_boot_with_spl_offset[@]|${u_boot_with_spl_offset}|g" - chmod +x \ - "${pkgdir}/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" - - # Install what is required for the pacman hook - install -d "${pkgdir}/usr/share/libalpm/hooks/" - sed < "${srcdir}/${pkgbase}.hook.in" > \ - "${pkgdir}/usr/share/libalpm/hooks/${_pkgname}.hook" \ - -e "s|@pkgname[@]|${_pkgname}|g" - - install -d "${pkgdir}/usr/share/doc/u-boot/${_pkgname}/" - # If we install several uboot4extlinux, we need a way to clearly - # separate each postinstall message. To do that we wrapped the - # text in an ASCII art square, but doing that is complicated when - # using sed as the package name as well as the installation script - # path both have variable length. - sh "${srcdir}/generate-${pkgbase}-install-text.sh" \ - "${_pkgname}" \ - "${pkgbase}" \ - "/usr/lib/u-boot/${_pkgname}/install-uboot4extlinux.sh" > \ - "${pkgdir}/usr/share/doc/u-boot/${_pkgname}/install-uboot4extlinux.txt" - fi -} + # Install the u-boot installation script + sed < "${srcdir}"/${install_script}.in \ + > "${install_dir}"/${install_script} \ + -e "s|@u_boot_with_spl[@]|${lib_dir}/${bin_name}|g" \ + -e "s|@u_boot_with_spl_offset[@]|${BOOTLOADER_BYTE_OFFSET}|g" + chmod +x "${install_dir}"/${install_script} -_make_pkgdesc() -{ - board_name="$1" + # Install what is required for the pacman hook + install -d "${hooks_dir}"/ + sed < "${srcdir}/"${pkgbase}.hook.in \ + > "${hooks_dir}"/${pkg_name}.hook \ + -e "s|@pkgname[@]|${pkg_name}|g" - echo "U-Boot with Extlinux support for ${board_name}" + # If we install several uboot4extlinux, we need a way to clearly + # separate each postinstall message. To do that we wrapped the + # text in an ASCII art square, but doing that is complicated when + # using sed as the package name as well as the installation script + # path both have variable length. + install -d "${docs_dir}"/ + sh "${srcdir}"/generate-${pkgbase}-install-text.sh \ + ${pkg_name} ${pkgbase} ${lib_dir}/${install_script} \ + > "${docs_dir}"/${install_text} } -package_uboot4extlinux-sunxi() -{ - pkgdesc="Scripts for managing U-Boot installations for computers with Allwinner System On a Chip" - - depends=('uboot-tools') - # Users are expected to use this as a base for /boot/extlinux/extlinux.conf - install -d "${pkgdir}/usr/lib/u-boot/${pkgname}/" - install -Dm644 \ - "${srcdir}/extlinux.conf" \ - "${pkgdir}/usr/lib/u-boot/${pkgname}/" -} +## business ## -package_uboot4extlinux-a10-olinuxino-lime() +prepare() { - pkgdesc=$(_make_pkgdesc "A10 OLinuXino Lime") + cd "${srcdir}"/${_upstream_name}-${_uboot_ver} - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname}" + # TODO: We need to fix the timestamps upstream to a valid date + # (like the first January 1970at 01:00:00 CET) or something derived + # from the release version somehow. Else we have the build log spammed + # with errors like that: + # make: scripts/Makefile.extrawarn: Timestamp out of range; + # substituting 1970-01-01 00:59:59.999999999 + # TODO: While we're at it we could export SOURCE_DATE_SPOCH to try to + # make the u-boot package reporducible. + find -print0 | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" } -package_uboot4extlinux-a10s-olinuxino-m() +build() { - pkgdesc=$(_make_pkgdesc "A10s OLinuXino Micro") - - replaces=('uboot4extlinux-a10s-olinuxino-micro') +# cd "${_upstream_name}-${_pkgver}-${_pkgrel}" # WIP teres - `cd` is in _build_uboot_target() - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') + # both uboot and the 64-bit firmwares FTBS with the default CFLAGS and LDFLAGS + # * Assembler messages: Error: unrecognized option -march=x86-64 + # * cc1: error: unknown value 'x86-64' for '-march' + # * cc1: error: '-fcf-protection=full' is not supported for this target + export CFLAGS+=' -march=armv8-a -mtune=cortex-a53 -fcf-protection=check' + # * aarch64-linux-gnu-ld.bfd: unrecognized option '-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' + unset LDFLAGS + # * aarch64-linux-gnu-ld.bfd: warning: bl31.elf has a LOAD segment with RWX permissions + # * aarch64-linux-gnu-ld.bfd: warning: u-boot-spl has a LOAD segment with RWX permissions + export LDFLAGS='--no-warn-rwx-segments' - _make_uboot_package "${pkgname}" -} + [[ "${CROSS_COMPILE}" =~ ^aarch64 ]] && _build_A64_firmware || : # TODO: hackish -package_uboot4extlinux-a13-olinuxino() -{ - pkgdesc=$(_make_pkgdesc "A13 OLinuXino") + local defconfig + local target_n=0 + local target_name - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') + for defconfig in ${_defconfigs[*]}; do + target_n=$(( target_n + 1 )) + target_name="$(_get_target_name ${defconfig})" - _make_uboot_package "${pkgname}" + echo "==> Building target (${target_n} of ${#_defconfigs[*]}): ${target_name}" + _build_uboot_target "${defconfig}" + done } -package_uboot4extlinux-a13-olinuxinom() +check() { - pkgdesc=$(_make_pkgdesc "uboot4extlinux-a13-olinuxino-micro") + cd "${srcdir}"/${_upstream_name}-${_uboot_ver} - replaces=('uboot4extlinux-a13-olinuxino-micro') + local defconfig + local target_n=0 + local target_name - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') + for defconfig in ${_defconfigs[*]}; do + target_n=$(( target_n + 1 )) + target_name="$(_get_target_name ${defconfig})" - _make_uboot_package "${pkgname}" + echo "==> Testing target (${target_n} of ${#_defconfigs[*]}): ${target_name}" + _check_uboot_target "${defconfig}" + done } -package_uboot4extlinux-a20-olinuxino-lime() +package_uboot4extlinux-sunxi() { - pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime") + local pkgdesc="Scripts for managing U-Boot installations for computers with Allwinner System On a Chip" + local depends=('uboot-tools') - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') + local dest_dir="${pkgdir}"/usr/lib/u-boot/${pkgname} - _make_uboot_package "${pkgname}" + # Users are expected to use this as an example for /boot/extlinux/extlinux.conf + install -d "${dest_dir}"/ + install -Dm644 "${srcdir}"/extlinux.conf "${dest_dir}"/extlinux.conf } -package_uboot4extlinux-a20-olinuxino-lime2() -{ - pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime2") - - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname}" -} +package_uboot4extlinux-a10-olinuxino-lime() { _package ${pkgname} "A10 OLinuXino Lime" ; } -package_uboot4extlinux-a20-olinuxino-lime2-emmc() +package_uboot4extlinux-a10s-olinuxino-m() { - pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime2 with eMMC") + replaces=('uboot4extlinux-a10s-olinuxino-micro') - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname}" + _package ${pkgname} "A10s OLinuXino Micro" } -package_uboot4extlinux-a20-olinuxino_micro() -{ - pkgdesc=$(_make_pkgdesc "uboot-a20-olinuxino-micro") - - replaces=('uboot-a20-olinuxino-micro') - - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') +package_uboot4extlinux-a13-olinuxino() { _package ${pkgname} "A13 OLinuXino" ; } - _make_uboot_package "${pkgname}" -} - -package_uboot4extlinux-bananapi() +package_uboot4extlinux-a13-olinuxinom() { - pkgdesc=$(_make_pkgdesc "Banana Pi") - - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') + replaces=('uboot4extlinux-a13-olinuxino-micro') - _make_uboot_package "${pkgname}" + _package ${pkgname} "A13 OLinuXino Micro" } -package_uboot4extlinux-bananapro() -{ - pkgdesc=$(_make_pkgdesc "Banana Pro") +package_uboot4extlinux-a20-olinuxino-lime() { _package ${pkgname} "A20 OLinuXino Lime" ; } - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') +package_uboot4extlinux-a20-olinuxino-lime2() { _package ${pkgname} "A20 OLinuXino Lime2" ; } - _make_uboot_package "${pkgname}" -} +package_uboot4extlinux-a20-olinuxino-lime2-emmc() { _package ${pkgname} "A20 OLinuXino Lime2 with eMMC" ; } -package_uboot4extlinux-chip() +package_uboot4extlinux-a20-olinuxino_micro() { - pkgdesc=$(_make_pkgdesc "C.H.I.P") + replaces=('uboot-a20-olinuxino-micro') - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname}" + _package ${pkgname} "A20 OLinuXino Micro" } -package_uboot4extlinux-cubieboard() -{ - pkgdesc=$(_make_pkgdesc "Cubieboard") +package_uboot4extlinux-bananapi() { _package ${pkgname} "Banana Pi" ; } - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') +package_uboot4extlinux-bananapro() { _package ${pkgname} "Banana Pro" ; } - _make_uboot_package "${pkgname}" -} +package_uboot4extlinux-chip() { _package ${pkgname} "C.H.I.P" ; } -package_uboot4extlinux-cubieboard2() -{ - pkgdesc=$(_make_pkgdesc "Cubieboard 2") +package_uboot4extlinux-cubieboard() { _package ${pkgname} "Cubieboard" ; } - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') +package_uboot4extlinux-cubieboard2() { _package ${pkgname} "Cubieboard 2" ; } - _make_uboot_package "${pkgname}" -} - -package_uboot4extlinux-cubietruck() -{ - pkgdesc=$(_make_pkgdesc "Cubietruck") - - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname}" -} +package_uboot4extlinux-cubietruck() { _package ${pkgname} "Cubietruck" ; } package_uboot4extlinux-linksprite_pcduino() { - pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino") - - replaces=('uboot4extlinux-pcduino') + replaces=('uboot4extlinux-pcduino') - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname}" + _package ${pkgname} "pcduino" } package_uboot4extlinux-linksprite_pcduino3() { - pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino3") - - replaces=('uboot4extlinux-pcduino3') - - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') + replaces=('uboot4extlinux-pcduino3') - _make_uboot_package "${pkgname}" + _package ${pkgname} "pcduino3" } package_uboot4extlinux-linksprite_pcduino3_nano() { - pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino3-nano") + replaces=('uboot4extlinux-pcduino3-nano') - replaces=('uboot4extlinux-pcduino3-nano') - - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname}" + _package ${pkgname} "pcduino3-nano" } -package_uboot4extlinux-orangepi_2() -{ - pkgdesc=$(_make_pkgdesc "Orange Pi 2") +package_uboot4extlinux-orangepi_2() { _package ${pkgname} "Orange Pi 2" ; } - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') +package_uboot4extlinux-orangepi_one() { _package ${pkgname} "Orange Pi One" ; } - _make_uboot_package "${pkgname}" -} +package_uboot4extlinux-orangepi_pc() { _package ${pkgname} "Orange Pi PC" ; } -package_uboot4extlinux-orangepi_one() -{ - pkgdesc=$(_make_pkgdesc "Orange Pi One") - - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') +package_uboot4extlinux-orangepi_plus() { _package ${pkgname} "Orange Pi Plus" ; } - _make_uboot_package "${pkgname}" -} - -package_uboot4extlinux-orangepi_pc() -{ - pkgdesc=$(_make_pkgdesc "Orange Pi PC") - - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname}" -} - -package_uboot4extlinux-orangepi_plus() -{ - pkgdesc=$(_make_pkgdesc "Orange Pi Plus") - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname}" -} - -package_uboot4extlinux-teres-i() -{ - pkgdesc=$(_make_pkgdesc "A64 OLIMEX Teres") - # util-linux is needed for blkid for install-uboot4extlinux.sh - depends=("${pkgbase}" 'util-linux') - - _make_uboot_package "${pkgname/-i/_i}" -} +package_uboot4extlinux-teres_i() { _package ${pkgname} "A64 OLIMEX Teres" ; } |