guysoft / CustomPiOS

A Raspberry Pi and other ARM devices distribution builder
GNU General Public License v3.0
497 stars 143 forks source link

Script ./src/make_custom_pi_os returns unexpected error #212

Closed VovaStelmashchuk closed 8 months ago

VovaStelmashchuk commented 9 months ago

I start works with repo and just flow the tuturial from ReadMe file. Clone the repo and try to execute ./src/make_custom_pi_os -g test the script returns the following error:

Settings:
making dstro in test
variant: raspios_lite_armhf
./src/make_custom_pi_os: line 36: MULTIPLE[@]: unbound variable

I have no idea, about how to fix the problem. Sure i can just remove the part of script which produce the problem, but the way doesn't look right for me.

for a in "${MULTIPLE[@]}"; do
    echo "  $a"
done

My envirment MacOs sonoma: Version 14.0 Processor: 2,4 GHz 8-Core Intel Core i9

guysoft commented 9 months ago

Not sure what is going on. Will try and reoroduce.

umlaeute commented 9 months ago

i cannot reproduce (on Debian/sid).

it might be interesting which bash you are using.

$ which bash
/usr/bin/bash

$ bash --version
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)

having said that: the ${MULTIPLE} variable seems to be unused, except for the problematic line https://github.com/guysoft/CustomPiOS/blob/63da54b86ab566c558e9084568d326413f6585d8/src/make_custom_pi_os#L34

so it probably is safe to remove that part of the script

umlaeute commented 9 months ago

i got hands of a macOS/BigSur machine, and i can now reproduce the problem.

$ which bash
/bin/bash

$ bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21)

in the bash changelogs i find

[...]
This document details the changes between this version, bash-5.2-alpha, and
the previous version, bash-5.1-release.
[...]
3. New Features in Bash
[...]
bb. Array references using `@' and `*' that are the value of nameref variables
    (declare -n ref='v[@]' ; echo $ref) no longer cause the shell to exit if
    set -u is enabled and the array (v) is unset.

so maybe this is just requiring a too-new-for-macOS bash version (for something that doesn't get used anyhow...)

OTOH, the incriminated lines where added in 2017, when the current release of bash was bash-4.4.

probably the relevant changelog entry is therefore:

This document details the changes between this version, bash-4.4-rc2, and
the previous version, bash-4.4-beta2.
[...]
3.  New Features in Bash

a.  Using ${a[@]} or ${a[*]} with an array without any assigned elements when
    the nounset option is enabled no longer throws an unbound variable error.
VovaStelmashchuk commented 9 months ago

My current bash 3.2.57, I make a clean setup and attech all my logs here:


➜  hacklab git clone https://github.com/guysoft/CustomPiOS.git
Cloning into 'CustomPiOS'...
remote: Enumerating objects: 4837, done.
remote: Counting objects: 100% (810/810), done.
remote: Compressing objects: 100% (272/272), done.
remote: Total 4837 (delta 590), reused 594 (delta 524), pack-reused 4027
Receiving objects: 100% (4837/4837), 1000.27 KiB | 4.15 MiB/s, done.
Resolving deltas: 100% (2589/2589), done.
➜  hacklab cd CustomPiOS
➜  CustomPiOS git:(devel) which bash
/bin/bash
➜  CustomPiOS git:(devel) bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin23)
Copyright (C) 2007 Free Software Foundation, Inc.
➜  CustomPiOS git:(devel) ./src/make_custom_pi_os -g test
Settings:
making dstro in test
variant: raspios_lite_armhf
./src/make_custom_pi_os: line 36: MULTIPLE[@]: unbound variable
➜  CustomPiOS git:(devel)
VovaStelmashchuk commented 9 months ago

@umlaeute you right, the error throws because i use the old version of bash, currently I update my bash and has the following output. Does the output correct ?

➜  CustomPiOS git:(devel) bash --version
GNU bash, version 5.2.15(1)-release (x86_64-apple-darwin23.0.0)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
➜  CustomPiOS git:(devel) ./src/make_custom_pi_os -g test
Settings:
making dstro in test
variant: raspios_lite_armhf
sed: 1: "config": command c expects \ followed by text
➜  CustomPiOS git:(devel) ✗
umlaeute commented 9 months ago

hmm, the new failure (assuming that i correctly read your output as a failure), appears to be somewhere in https://github.com/guysoft/CustomPiOS/blob/63da54b86ab566c558e9084568d326413f6585d8/src/dist_generators/dist_example_script#L22-L23

i don't see any obvious invocations of the c command of sed (and the ${DIST_NAME} variable should expand to test, so nothing wrong here either...)

do you have gsed installed? if not, can you also install it (brew install gnu-sed)?

VovaStelmashchuk commented 9 months ago

Thx, the problem fix, after I install gnu-sed. Now I have problem, with execute sudo ./test/src/build_dist, I have the following error, in build.log

++++ realpath -s /Users/vovastelmashchuk/Desktop/hacklab/CustomPiOS/src/build
realpath: illegal option -- s
usage: realpath [-q] [path ...]
+++ dirname
usage: dirname string [...]
++ BUILD_SCRIPT_PATH=
You have new mail in /var/mail/vovastelmashchuk

It's look like a new issue, can we discuss the issue here or close current discussion and open new github issue ? Also I think about pull request to project readme with MacOs specific instraction, some think like a pre-condition, min version of bash and gnu-sed

umlaeute commented 9 months ago

i agree it's probably a new issue.

otoh, it seems that CustomPiOS is probably just not usable on macOS right now.

guysoft commented 9 months ago

Indeed, you could use it via Docker. In general Docker tends to work better if you are on MacOS.

guysoft commented 8 months ago

You could install bash 5 using homebrew.

brew install bash

But then you need to put bash in your path:

/opt/homebrew/bin/bash --version
VovaStelmashchuk commented 8 months ago

Yep, I have bash 5 already on my machine. It fixes the issue. Thx.

guysoft commented 8 months ago

Thanks! If you have the time to document or post here in the wiki how to gets stuff working on mac that could help people in the future (or yourself too): https://github.com/guysoft/CustomPiOS/wiki/Building#building-from-os-x