summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-01-07 00:56:11 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-02-04 19:27:43 +0100
commit786769701fc0f0ec6f2906e7107241d0ed736a38 (patch)
tree64919960ca2dad732e295e8e2983afe14a1b1507
parentc8418a7c3da71975aa555d2748693749222cc759 (diff)
[WIP] libre: uboot4extlinux-sunxi: lower maintenance costsGNUtoo/u-boot-wip
- We can now do cross builds of u-boot: - We can now more easily work on the package as we don't need an ARM computer for that anymore. - It also enable people already using Parabola on x86 to more easily install, test, or repair u-boot for an ARM computer as users can simply install it on microSD cards without needing to use ARM chroots. - There is now an install script to install u-boot: - It makes things easier for users as it is more similar to grub-install than dd commands. - It also does many checks at the same time to avoid data loss. - The commands to split packages are now shared between all package_ functions. This lower maintenance. - How to add a new board has been made more clear. TODO: - Disable flashing on x86 and x86_64 (laptops with eMMC x86 SOCs) - Disable the installation when the bootloader has never been installed - Check the devicetree compatible for automatic updates? - Test on real hardware (lime2, pcduino-lite) - Build some infrastructure for users to report working boards and mention it here and on the wiki for adding official support for boards. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--libre/uboot4extlinux-sunxi/PKGBUILD608
-rwxr-xr-xlibre/uboot4extlinux-sunxi/install-uboot4extlinux.sh.in88
-rw-r--r--libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.hook.in11
-rw-r--r--libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.install35
-rw-r--r--libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.sh32
5 files changed, 491 insertions, 283 deletions
diff --git a/libre/uboot4extlinux-sunxi/PKGBUILD b/libre/uboot4extlinux-sunxi/PKGBUILD
index f3d069855..a23043d26 100644
--- a/libre/uboot4extlinux-sunxi/PKGBUILD
+++ b/libre/uboot4extlinux-sunxi/PKGBUILD
@@ -2,353 +2,465 @@
# Maintainer: 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>
+
+# To add a new board (that uses an Allwinner System On a Chip) you need:
+# - The package name. Example: uboot4extlinux-a20-olinuxino_micro
+# - The u-boot configuration. Example: A20-OLinuXino_MICRO_defconfig
+# - The name of the board(s). Example: A20 OLinuXino Micro
+# A single package / u-boot configuration sometimes support multiple
+# boards and the configuration name doesn't always have the boards names
+# in it. Example: uboot4extlinux-am335x_bone supports various BeagleBones,
+# the AM335x GP EVM and the EVM SK all in one u-boot binary and package.
+# - If relevant, the packages it replaces, if there are older u-boot packages
+# also supporting that board. Example:uboot-a20-olinuxino-micro
+#
+# Ideally we'd like to enable people to only add these 4 variables in this
+# package to add a new board.
+#
+# Ideally adding a new board should be as easy as adding a new line formatted
+# as CSV with things like the package name, u-boot configuration and so on.
+#
+# Unfortunately we didn't find how to dynamically define packages as
+# eval package_{$_pkgname}() { [...] } works but doesn't make that package
+# function visible to makepkg.
+#
+# So contributors wanting to add new boards will have to search for example
+# of the information mentioned above and add it in the PKGBUILD for their
+# boards.
+#
+# After adding a new board in this PKGBUILD, to get the board officially
+# supported by Parabola.you also need to create a page for it in the
+# Parabola wiki for that board and update the ARM installation guide to
+# point to it when relevant. Examples of that are available for other
+# boards in the ARM installation guide.
pkgbase=uboot4extlinux-sunxi
-pkgname=('uboot4extlinux-a10-olinuxino-lime'
- 'uboot4extlinux-a10s-olinuxino-m'
- 'uboot4extlinux-a13-olinuxino'
- 'uboot4extlinux-a13-olinuxinom'
- 'uboot4extlinux-a20-olinuxino-lime'
+pkgname=("${pkgbase}"
'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')
+ 'uboot4extlinux-a20-olinuxino-lime2-emmc')
+# 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')
+
pkgver=2020.04
pkgrel=1
-arch=('armv7h')
+arch=('armv7h' 'i686' 'x86_64')
url="http://git.denx.de/u-boot.git/"
license=('GPL')
makedepends=('bc' 'dtc' 'python' 'python2' 'swig')
+makedepends_i686+=('arm-none-eabi-gcc')
+makedepends_x86_64+=('arm-none-eabi-gcc')
backup=(boot/extlinux/extlinux.conf)
source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2"
- 'extlinux.conf')
+ 'extlinux.conf'
+ "${pkgbase}.hook.in"
+ "${pkgbase}.sh"
+ 'install-uboot4extlinux.sh.in')
sha256sums=('fe732aaf037d9cc3c0909bad8362af366ae964bbdac6913a34081ff4ad565372'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
'SKIP')
-boards=('A10-OLinuXino-Lime'
- 'A10s-OLinuXino-M'
- 'A13-OLinuXino'
- 'A13-OLinuXinoM'
- 'A20-OLinuXino-Lime'
- 'A20-OLinuXino-Lime2'
- 'A20-OLinuXino-Lime2-eMMC'
- 'A20-OLinuXino_MICRO'
- 'Bananapi'
- 'Bananapro'
- 'CHIP'
- 'Cubieboard'
- 'Cubieboard2'
- 'Cubietruck'
- 'Linksprite_pcDuino'
- 'Linksprite_pcDuino3'
- 'Linksprite_pcDuino3_Nano'
- 'orangepi_2'
- 'orangepi_one'
- 'orangepi_pc'
- 'orangepi_plus')
-
-build() {
- cd u-boot-${pkgver}
+_defconfigs=('A10-OLinuXino-Lime_defconfig'
+ 'A10s-OLinuXino-M_defconfig'
+ 'A13-OLinuXino_defconfig'
+ 'A13-OLinuXinoM_defconfig'
+ 'A20-OLinuXino-Lime_defconfig'
+ 'A20-OLinuXino-Lime2_defconfig'
+ 'A20-OLinuXino-Lime2-eMMC_defconfig'
+ 'A20-OLinuXino_MICRO_defconfig'
+ 'Bananapi_defconfig'
+ 'Bananapro_defconfig'
+ 'CHIP_defconfig'
+ 'Cubieboard_defconfig'
+ 'Cubieboard2_defconfig'
+ 'Cubietruck_defconfig'
+ 'Linksprite_pcDuino_defconfig'
+ 'Linksprite_pcDuino3_defconfig'
+ 'Linksprite_pcDuino3_Nano_defconfig'
+ 'orangepi_2_defconfig'
+ 'orangepi_one_defconfig'
+ 'orangepi_pc_defconfig'
+ 'orangepi_plus_defconfig')
+
+# Offset at which to install u-boot
+u_boot_with_spl_offset=8192
+
+case "$CARCH" in
+ armv7h) ARCH=arm;;
+ i686|x86_64) ARCH=arm;CROSS_COMPILE=arm-none-eabi-;;
+esac
+
+_get_target_destdir()
+{
+ _defconfig="$1"
+
+ _target_name="$(echo ${_defconfig} | sed 's/_defconfig$//' | awk '{print tolower($0)}')"
+
+ echo "build/uboot4extlinux-${_target_name}"
+}
+
+_build_uboot_target()
+{
+ _defconfig="$1"
+
+ unset CFLAGS CXXFLAGS LDFLAGS
- unset CFLAGS CXXFLAGS LDFLAGS
+ make "ARCH=${ARCH}" distclean
+ make "ARCH=${ARCH}" ${_defconfig}
- for i in ${boards[@]}; do
- mkdir -p ../bin_${i}
- make distclean
- make ${i}_defconfig
echo 'CONFIG_IDENT_STRING=" Parabola GNU/Linux-libre"' >> .config
- make EXTRAVERSION=-${pkgrel}
- mv -f u-boot-sunxi-with-spl.bin ../bin_${i}
+
+ if [ "$CARCH" = "armv7h" ]; then
+ make "ARCH=${ARCH}" EXTRAVERSION=-${pkgrel}
+ else
+ make "ARCH=${ARCH}" "CROSS_COMPILE=${CROSS_COMPILE}" \
+ EXTRAVERSION=-${pkgrel}
+ fi
+
+ _destdir="$(_get_target_destdir ${_deconfig})"
+
+ echo "==> Installing ${_defconfig} to ${_destdir}"
+ install -d ${_destdir}
+ mv -f u-boot-sunxi-with-spl.bin "${_destdir}"
+
+}
+
+build()
+{
+ cd u-boot-${pkgver}
+
+ # # Used to store the result for each "board"
+ # rm -rf build
+ # install -d build
+
+ _nr_targets=0
+ for _defconfig in ${_defconfigs[@]}; do
+ _nr_targets=$(expr ${_nr_targets} + 1)
done
+
+ _target_nr=0
+ for _defconfig in ${_defconfigs[@]}; do
+ _target_nr=$(expr ${_target_nr} + 1)
+ echo "==> Building ${_defconfig} [${_target_nr} of ${_nr_targets} targets]"
+
+ _build_uboot_target "${_defconfig}"
+ done
+}
+
+_check_uboot_target()
+{
+ _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}"
+
+ # This test comes from install-uboot4extlinux.sh.in
+ if [ $(expr ${_image_size} + ${_offset}) -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 ${_images} "\
+ "would overwrite that first partition (if it's present)."
+
+ false # Fail the test
+ fi
}
-package_uboot4extlinux-a10-olinuxino-lime() {
- pkgdesc="U-Boot with Extlinux support for A10 OLinuXino Lime"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+# TODO
+# check()
+# {
+# cd u-boot-${pkgver}
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_A10-OLinuXino-Lime/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+# for _defconfig in ${_defconfigs[@]}; do
+# _check_uboot_target "${_defconfig}"
+# done
+# }
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+_make_uboot_package()
+{
+ _pkgname="$1"
+
+ if [ -n "${pkgdir}" ] ; then
+ cd "u-boot-${pkgver}"
+ install -d "${pkgdir}/usr/lib/u-boot/${_pkgname}/"
+ echo "${_pkgname}" > "${pkgdir}/usr/lib/u-boot/${_pkgname}/README"
+
+ install -Dm644 "build/${_pkgname}/u-boot-sunxi-with-spl.bin" "${pkgdir}/usr/lib/u-boot/${_pkgname}"
+
+ 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"
+
+ install -d "${pkgdir}/usr/share/libalpm/hooks/"
+ sed < "$srcdir/install-uboot4extlinux.sh.in" > "${pkgdir}/usr/share/libalpm/hooks/uboot4extlinux.hook" \
+ -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"
+ fi
+}
+
+_make_pkgdesc()
+{
+ board_name="$1"
+ echo "U-Boot with Extlinux support for ${board_name}"
+}
+
+package_uboot4extlinux-sunxi()
+{
+ # We still need to notify users to update their bootloaders when not on the
+ # target systems, for instance to tell them how to install them but we need
+ # to disable the automatic installation (TODO)
+ install -d "${pkgdir}/usr/share/libalpm/scripts/"
+ install -m755 "$srcdir/${pkgname}.sh" "${pkgdir}/usr/share/libalpm/scripts/"
+
+ # This will need to be handled by users
+ # See the post install script
+ install -d "${pkgdir}/usr/lib/u-boot/${_pkgname}/"
+ install -Dm644 "${srcdir}/extlinux.conf" "${pkgdir}/usr/lib/u-boot/${_pkgname}/"
+}
+
+package_uboot4extlinux-a10-olinuxino-lime()
+{
+ pkgdesc=$(_make_pkgdesc "A10 OLinuXino Lime")
+
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
+
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-a10s-olinuxino-m() {
- pkgdesc="U-Boot with Extlinux support for A10s OLinuXino Micro"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
- replaces=('uboot4extlinux-a10s-olinuxino-micro')
+package_uboot4extlinux-a10s-olinuxino-m()
+{
+ pkgdesc=$(_make_pkgdesc "A10s OLinuXino Micro")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_A10s-OLinuXino-M/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ replaces=('uboot4extlinux-a10s-olinuxino-micro')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
+
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-a13-olinuxino() {
- pkgdesc="U-Boot with Extlinux support for A13 OLinuXino"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-a13-olinuxino()
+{
+ pkgdesc=$(_make_pkgdesc "A13 OLinuXino")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_A13-OLinuXino/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-a13-olinuxinom() {
- pkgdesc="U-Boot with Extlinux support for A13 OLinuXino Micro"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
- replaces=('uboot4extlinux-a13-olinuxino-micro')
+package_uboot4extlinux-a13-olinuxinom()
+{
+ pkgdesc=$(_make_pkgdesc "uboot4extlinux-a13-olinuxino-micro")
+
+ replaces=('uboot4extlinux-a13-olinuxino-micro')
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_A13-OLinuXinoM/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-a20-olinuxino-lime() {
- pkgdesc="U-Boot with Extlinux support for A20 OLinuXino Lime"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-a20-olinuxino-lime()
+{
+ pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_A20-OLinuXino-Lime/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-a20-olinuxino-lime2() {
- pkgdesc="U-Boot with Extlinux support for A20 OLinuXino Lime2"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-a20-olinuxino-lime2()
+{
+ pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime2")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_A20-OLinuXino-Lime2/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-a20-olinuxino-lime2-emmc() {
- pkgdesc="U-Boot with Extlinux support for A20 OLinuXino Lime2 with eMMC"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-a20-olinuxino-lime2-emmc()
+{
+ pkgdesc=$(_make_pkgdesc "A20 OLinuXino Lime2 with eMMC")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_A20-OLinuXino-Lime2-eMMC/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-a20-olinuxino_micro() {
- pkgdesc="U-Boot with Extlinux support for A20 OLinuXino Micro"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
- replaces=('uboot-a20-olinuxino-micro')
+package_uboot4extlinux-a20-olinuxino_micro()
+{
+ pkgdesc=$(_make_pkgdesc "uboot-a20-olinuxino-micro")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_A20-OLinuXino_MICRO/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ replaces=('uboot-a20-olinuxino-micro')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
+
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-bananapi() {
- pkgdesc="U-Boot with Extlinux support for Banana Pi"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-bananapi()
+{
+ pkgdesc=$(_make_pkgdesc "Banana Pi")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_Bananapi/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-bananapro() {
- pkgdesc="U-Boot with Extlinux support for Banana Pro"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-bananapro()
+{
+ pkgdesc=$(_make_pkgdesc "Banana Pro")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_Bananapro/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-chip() {
- pkgdesc="U-Boot with Extlinux support for C.H.I.P"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-chip()
+{
+ PKGDESC=$(_MAKE_PKGDESC "C.H.I.P")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_CHIP/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-cubieboard() {
- pkgdesc="U-Boot with Extlinux support for Cubieboard"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-cubieboard()
+{
+ pkgdesc=$(_make_pkgdesc "Cubieboard")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_Cubieboard/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-cubieboard2() {
- pkgdesc="U-Boot with Extlinux support for Cubieboard 2"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-cubieboard2()
+{
+ pkgdesc=$(_make_pkgdesc "Cubieboard 2")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_Cubieboard2/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-cubietruck() {
- pkgdesc="U-Boot with Extlinux support for Cubietruck"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-cubietruck()
+{
+ pkgdesc=$(_make_pkgdesc "Cubietruck")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_Cubietruck/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-linksprite_pcduino() {
- pkgdesc="U-Boot with Extlinux support for pcDuino"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
- replaces=('uboot4extlinux-pcduino')
+package_uboot4extlinux-linksprite_pcduino()
+{
+ pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino")
+
+ replaces=('uboot4extlinux-pcduino')
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_Linksprite_pcDuino/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-linksprite_pcduino3() {
- pkgdesc="U-Boot with Extlinux support for pcDuino3"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
- replaces=('uboot4extlinux-pcduino3')
+package_uboot4extlinux-linksprite_pcduino3()
+{
+ pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino3")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_Linksprite_pcDuino3/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ replaces=('uboot4extlinux-pcduino3')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
+
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-linksprite_pcduino3_nano() {
- pkgdesc="U-Boot with Extlinux support for pcDuino3 Nano"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
- replaces=('uboot4extlinux-pcduino3-nano')
+package_uboot4extlinux-linksprite_pcduino3_nano()
+{
+ pkgdesc=$(_make_pkgdesc "uboot4extlinux-pcduino3-nano")
+
+ replaces=('uboot4extlinux-pcduino3-nano')
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_Linksprite_pcDuino3_Nano/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-orangepi_2() {
- pkgdesc="U-Boot with Extlinux for Orange Pi 2"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-orangepi_2()
+{
+ pkgdesc=$(_make_pkgdesc "Orange Pi 2")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_orangepi_2/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-orangepi_one() {
- pkgdesc="U-Boot with Extlinux for Orange Pi One"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-orangepi_one()
+{
+ pkgdesc=$(_make_pkgdesc "Orange Pi One")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_orangepi_one/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-orangepi_pc() {
- pkgdesc="U-Boot with Extlinux for Orange Pi PC"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-orangepi_pc()
+{
+ pkgdesc=$(_make_pkgdesc "Orange Pi PC")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_orangepi_pc/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
-package_uboot4extlinux-orangepi_plus() {
- pkgdesc="U-Boot with Extlinux for Orange Pi Plus"
- install=${pkgbase}.install
- provides=('uboot4extlinux-sunxi')
- conflicts=('uboot-sunxi' 'uboot4extlinux-sunxi' 'uboot4grub-sunxi')
+package_uboot4extlinux-orangepi_plus()
+{
+ pkgdesc=$(_make_pkgdesc "Orange Pi Plus")
- install -d "${pkgdir}"/boot/extlinux
- install -d "${pkgdir}"/boot/u-boot/images/
- install -Dm644 bin_orangepi_plus/u-boot-sunxi-with-spl.bin "${pkgdir}"/boot/u-boot/images/
+ # utils-linux is needed for blkid for install-uboot4extlinux.sh
+ depends=("${pkgbase}" 'utils-linux')
- install -Dm644 extlinux.conf "${pkgdir}"/boot/extlinux
+ _make_uboot_package "${pkgname}"
}
diff --git a/libre/uboot4extlinux-sunxi/install-uboot4extlinux.sh.in b/libre/uboot4extlinux-sunxi/install-uboot4extlinux.sh.in
new file mode 100755
index 000000000..1a8759a11
--- /dev/null
+++ b/libre/uboot4extlinux-sunxi/install-uboot4extlinux.sh.in
@@ -0,0 +1,88 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2020 Denis 'GNUtoo' Carikli
+
+progname="install-uboot4extlinux.sh"
+u_boot_with_spl="@u_boot_with_spl@"
+u_boot_with_spl_offset=@u_boot_with_spl_offset@
+
+usage()
+{
+ echo "Usage: ${progname} [INSTALL_DEVICE]"
+}
+
+install_image()
+{
+ install_device="$1"
+ offset="$2"
+ image="$3"
+
+ # We need root permissions for now:
+ # - blkid is used to bypass caching and it needs root access
+ if [ "$(id -u)" != 0 ] ; then
+ echo "Error: This script needs to be run as root"
+ exit 1
+ fi
+
+ # We only support MBR for now
+ # It will also catch errors like /dev/sdb1 and mmcbk0p1 as they
+ # don't have the PTTYPE tag
+ PTTYPE="$(blkid --probe --match-tag PTTYPE ${install_device} | \
+ awk '{print $2}' | sed 's#^PTTYPE="##' | sed 's#"$##')"
+ if [ -z "${PTTYPE}" ] ; then
+ echo "Error: Could not find an (MBR) formating inside " \
+ "${install_device}"
+ echo " Possible causes:"
+ echo " - Maybe {instal_device} is a partition"
+ echo " - or Maybe it's completelyor unformated"
+ exit 1
+ elif [ "${PTTYPE}" != "dos" ] ; then
+ echo "Error: ${install_device} is not in MBR format"
+ echo " Currently, only the MBR format is supported"
+ exit 1
+ fi
+
+ # Check if offset > MBR partition table part end
+ if [ ${offset} -lt 512 ] ; then
+ echo "Error: The offset (${offset}) is < 512"
+ echo " offsets < 512 aren't supported (yet)"
+ exit 1
+ fi
+
+ # Get the image size
+ image_size="$(du --bytes --apparent-size ${image} | awk '{print $1}')"
+
+ # With MBR, most partitioning tools leave makes the first partition
+ # start at 1MiB. So we need to check if the bootloader doesn't end
+ # up overwriting the first partition.
+ if [ $(expr ${image_size} + ${offset}) -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 ${images} "\
+ "would overwrite that first partition (if it's present)."
+ echo " Please contact the Parabola developers " \
+ "so they could fix that issue"
+ exit 1
+ fi
+
+ # Copies with with a block size of 1 can be quite slow in practice
+ if [ "$(expr ${offset} % 512)" = 0] ; then
+ dd conv=notrunc "if=${image}" "of=${install_device}" \
+ bs=512 "seek=$(expr ${offset} / 512)"
+ else
+ echo "Warning: slow copy"
+ dd conv=notrunc "if=${image}" "of=${install_device}" \
+ bs=1 "seek=${offset}"
+ fi
+
+ sync "${install_device}"
+}
+
+if [ $# -ne 1 ] ; then
+ usage
+else
+ install_image "$1" "${u_boot_with_spl_offset}" "${u_boot_with_spl}"
+fi
diff --git a/libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.hook.in b/libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.hook.in
new file mode 100644
index 000000000..0f494eb9d
--- /dev/null
+++ b/libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.hook.in
@@ -0,0 +1,11 @@
+[Trigger]
+Type = Package
+Operation = Install
+Operation = Upgrade
+Target = @pkgname@
+
+[Action]
+Description = Test
+When = PostTransaction
+Exec = /usr/share/libalpm/scripts/uboot4extlinux-sunxi.sh
+NeedsTargets
diff --git a/libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.install b/libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.install
deleted file mode 100644
index 46f8304cd..000000000
--- a/libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.install
+++ /dev/null
@@ -1,35 +0,0 @@
-flash_instructions() {
- echo "# dd if=/boot/u-boot/images/u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8"
-}
-
-extlinux_warning() {
- echo "==> WARNING: Remember to set up your kernels in /boot/extlinux/extlinux.conf"
-}
-
-flash_uboot() {
- root=$(mount | awk '/ on \/ / { print $1; }')
- if [[ $root =~ ^/dev/mmcblk.*$ ]]; then
- root=${root:0:12}
- echo "A new U-Boot version needs to be flashed onto $root."
- echo "Do you want to do this now? [y|N]"
- read -r shouldwe
- if [[ $shouldwe =~ ^([yY][eE][sS]|[yY])$ ]]; then
- dd if=/boot/u-boot/images/u-boot-sunxi-with-spl.bin of=$root bs=1024 seek=8
- else
- echo "You can do this later by running:"
- flash_instructions
- fi
- else
- echo "Flash the new U-Boot version onto your boot device. For example:"
- flash_instructions
- fi
- extlinux_warning
-}
-
-post_install() {
- flash_uboot
-}
-
-post_upgrade() {
- flash_uboot
-}
diff --git a/libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.sh b/libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.sh
new file mode 100644
index 000000000..ab5d10e0a
--- /dev/null
+++ b/libre/uboot4extlinux-sunxi/uboot4extlinux-sunxi.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+post_install()
+{
+ install_script="$1"
+ pkgbase="$2"
+
+ root=$(mount | awk '/ on \/ / { print $1; }')
+ if [[ $root =~ ^/dev/mmcblk.*$ ]]; then
+ root=${root:0:12}
+ echo "A new U-Boot version needs to be installed into $root."
+ echo "Do you want to do this now? [y|N]"
+ read -r shouldwe
+ if [[ $shouldwe =~ ^([yY][eE][sS]|[yY])$ ]]; then
+ "${install_script}" "${root}"
+ else
+ echo "You can do this later by running:"
+ echo "# ${install_script} ${root}"
+ fi
+ else
+ echo "Flash the new U-Boot version onto your boot device. For example:"
+ echo "# ${install_script} ${root}"
+ fi
+
+ echo "==> WARNING: Remember to set up your kernels in /boot/extlinux/extlinux.conf"
+ echo " An example extlinux.conf is provided in /usr/lib/u-boot/${pkgbase}/"
+}
+
+pkgbase="uboot4extlinux-sunxi"
+pkgname="$(cat)"
+
+post_install "/usr/lib/u-boot/${pkgname}/install-uboot4extlinux.sh" "${pkgbase}"