volumio / Build

Buildscripts for Volumio System
GNU General Public License v2.0
113 stars 102 forks source link

Exit early if an unsupported device is passed in #446

Closed ashthespy closed 3 years ago

ashthespy commented 3 years ago

This should cover things as described by @xipmix -- or did I miss something?

/.../VolumioOS [master ↑1 +21 ~1 -0]$ ./build_docker.sh -b armv8 -d raspbberypi5
[ .... ] Running Volumio Image Builder -  
[ error ] No configuration found for <raspbberypi5> 
[ .. ] Build system currently supports 12 devices: [ mp1 nanopineo2 odroidc1 odroidc2 odroidc4 odroidn2 orangepilite raspberry rockpis tinkerboard x86_amd64 x86_i386 ]
/.../VolumioOS [master ↑1 +21 ~1 -0]$ ./build_docker.sh -d raspbberypi5
[ .... ] Running Volumio Image Builder -  
[ error ] No configuration found for <raspbberypi5> 
[ .. ] Build system currently supports 12 devices: [ mp1 nanopineo2 odroidc1 odroidc2 odroidc4 odroidn2 orangepilite raspberry rockpis tinkerboard x86_amd64 x86_i386 ]
/.../VolumioOS [master ↑1 +21 ~1 -0]$ ./build_docker.sh -b raspbberypi5
[ .... ] Running Volumio Image Builder -  
[ warn ] No device flag passed to builder, building only  
[ .. ] Checking whether we are running as root 
[ .. ] Creating log directory 
[ .. ] Setting default Volumio variant 
[ .... ] Creating raspbberypi5 rootfs  
[ .. ] Defaulting to release [ Buster ]
[ warn ] No base system configuration file found [ raspbberypi5.conf ]
/.../VolumioOS [master ↑1 +21 ~1 -0]$ ./build_docker.sh -b raspbberypi5 -d armv8
[ .... ] Running Volumio Image Builder -  
[ error ] No configuration found for <armv8> 
[ .. ] Build system currently supports 12 devices: [ mp1 nanopineo2 odroidc1 odroidc2 odroidc4 odroidn2 orangepilite raspberry rockpis tinkerboard x86_amd64 x86_i386 ]
/.../VolumioOS [master ↑1 +21 ~1 -0]$ ./build_docker.sh -b armv8
[ .... ] Running Volumio Image Builder -  
[ warn ] No device flag passed to builder, building only  
[ .. ] Checking whether we are running as root 
[ .. ] Creating log directory 
[ .. ] Setting default Volumio variant 
[ .... ] Creating armv8 rootfs  
[ .. ] Defaulting to release [ Buster ]
[ .. ] armv8 rootfs exists, cleaning it 
[ .... ] Setting up Multistrap environment  
[ .. ] Preparing rootfs apt-config 
[ .. ] Adding SecureApt keys to rootfs 
Executing: /tmp/apt-key-gpghome.48mm2JyMLt/gpg.1.sh --fetch-keys https://deb.nodesource.com/gpgkey/nodesource.gpg.key
gpg: requesting key from 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key'
gpg: key 1655A0AB68576280: public key "NodeSource <gpg@nodesource.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
Executing: /tmp/apt-key-gpghome.T5669FZxtc/gpg.1.sh --fetch-keys https://ftp-master.debian.org/keys/archive-key-10.asc
gpg: requesting key from 'https://ftp-master.debian.org/keys/archive-key-10.asc'
^C
gpg: signal Interrupt caught ... exiting
[ error ] Build script failed!! 

And this beauty that I actually ran :-D

/.../VolumioOS [master ↑1 +21 ~1 -0]$ ./build_docker.sh -b x64 -d x86_arm64 -v 0.00
[ .... ] Running Volumio Image Builder -  
[ error ] No configuration found for <x86_arm64> 
[ .. ] Build system currently supports 12 devices: [ mp1 nanopineo2 odroidc1 odroidc2 odroidc4 odroidn2 orangepilite raspberry rockpis tinkerboard x86_amd64 x86_i386 ]
volumio commented 3 years ago

@xipmix please confirm if this achieves what you would like to do, so we merge it

xipmix commented 3 years ago

I went down a similar road with a separate function but didn't include the BUILD check, because I guess I thought that specifying a bad device was handled already... I'm a bit surprised the -n $DEVICE check (and -n $BUILD) works with the variable unset, I would have written -n "$DEVICE". But clearly it does work, so from my perspective, merge away.

ashthespy commented 3 years ago

Good point, will quote it just to be consistent.. EDIT: Just did a little coffee time reading as I was curious why it was working as expected -- in [bash [[ doesn't need to be quoted in most cases](https://www.gnu.org/software/bash/manual/bash.html#index-_005b_005b), and will expand most without quoting. http://mywiki.wooledge.org/BashFAQ/031

#!/usr/bin/env bash
var="foo bar"
# unset
set=''

[ $var == "foo bar" ] && echo "[ var == : true"
[[ $var == "foo bar" ]] && echo "[[ var == : true"

[ -n $unset ] && echo "[  notnull: unset: true"
[[ -n $unset ]] && echo "[[ notnull: unset: true"

[ -n $set ] && echo "[  notnull: set:   true"
[[ -n $set ]] && echo "[[ notnull: set:   true"
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
$ bash main.sh
main.sh: line 6: [: too many arguments
[[ var == : true
[  notnull: unset: true
[  notnull: set:   true
exit status 1
ashthespy commented 3 years ago

Added the quotes for good measure and to be consistent.. RTM from my side!