On Tue, 27 Feb 2018 01:18:16 -0500,
Andreas Grapentin wrote:
> 
> Hi,
> 
> in the light of my attempts to create a riscv64 parabola port, I would
> like to see the following changes made to librechroot.
> 
> The patch removes the hard-coded arm cross arch checks in favour of a
> more general approach, that works for more architectures. As a side
> effect, this now also would behave correctly when creating x86 chroots
> on arm, although why anyone would choose to do this is beyond me.
> 
> Looks OK?
> 
> Cheers,
> Andreas
> 
> ---
>  src/chroot-tools/librechroot | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
> index 27e17bd..750f34c 100755
> --- a/src/chroot-tools/librechroot
> +++ b/src/chroot-tools/librechroot
> @@ -69,17 +69,21 @@ hack_arch_nspawn_flags() {
>               CARCH="$(uname -m)"
>       fi
>  
> -     if [[ "$CARCH" == armv7h ]] && ! setarch armv7l /bin/true 2>/dev/null; 
> then
> -             # We're running an ARM chroot on a non-ARM processor
> +     case $CARCH in
> +             armv7h) _setarch=armv7l ; _qemuarch=arm    ;;
> +             *)      _setarch=$CARCH ; _qemuarch=$CARCH ;;
> +     esac

 1. These variables should be declared local.

 2. No need to _underscore them.

 3. I'd like it to reference a complete interpreter, rather than
    Qemu's processor family name.

Something like:

        local setarch interpreter
        case "$CARCH" in
                armv7h) setarch=armv7l; interpreter=/usr/bin/qemu-arm-static    
;;
                *)      setarch=$CARCH; interpreter=/usr/bin/qemu-$CARCH-static 
;;
        esac

> +     if ! setarch $_setarch /bin/true 2>/dev/null; then
> +             # We're running a cross-arch chroot
>  
>               # Make sure that qemu-static is set up with binfmt_misc
>               if [[ -z $(grep -l -xF \
> -                          -e 'interpreter /usr/bin/qemu-arm-static' \
> +                          -e "interpreter /usr/bin/qemu-$_qemuarch-static" \
>                            -r -- /proc/sys/fs/binfmt_misc 2>/dev/null \
>                          | xargs -r grep -xF 'enabled') ]]
>               then
> -                     error 'Cannot cross-compile for ARM on x86'
> -                     plain 'This requires a binfmt_misc entry for 
> qemu-arm-static.'
> +                     error 'Cannot cross-compile for %s on %s' $CARCH 
> $(uname -m)
> +                     plain 'This requires a binfmt_misc entry for 
> qemu-%s-static.' $_qemuarch

`$CARCH`, `$(uname -m)`, and `$_qemuarch` should be quoted.

>                       prose 'Such a binfmt_misc entry is provided by the %s
>                              package.  If you have it installed, but still see
>                              this message, you may need to restart %s.' \
> @@ -88,13 +92,13 @@ hack_arch_nspawn_flags() {
>               fi
>  
>               # Let qemu/binfmt_misc do its thing
> -             arch_nspawn_flags+=(-f /usr/bin/qemu-arm-static -s)
> +             arch_nspawn_flags+=(-f /usr/bin/qemu-$_qemuarch-static -s)
>  
>               # The -any packages are built separately for ARM from
>               # x86, so if we use the same CacheDir as the x86 host,
>               # then there will be PGP errors.
> -             mkdir -p /var/cache/pacman/pkg-arm
> -             arch_nspawn_flags+=(-c /var/cache/pacman/pkg-arm)
> +             mkdir -p /var/cache/pacman/pkg-$CARCH
> +             arch_nspawn_flags+=(-c /var/cache/pacman/pkg-$CARCH)
>       fi
>  }
>  
> -- 
> 2.16.2

The rest of it LGTM.

-- 
Happy hacking,
~ Luke Shumaker
_______________________________________________
Dev mailing list
[email protected]
https://lists.parabola.nu/mailman/listinfo/dev

Reply via email to