Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script ./src/make_custom_pi_os returns unexpected error #212

Closed
VovaStelmashchuk opened this issue Oct 20, 2023 · 12 comments
Closed

Script ./src/make_custom_pi_os returns unexpected error #212

VovaStelmashchuk opened this issue Oct 20, 2023 · 12 comments

Comments

@VovaStelmashchuk
Copy link

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
Copy link
Owner

guysoft commented Oct 22, 2023

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

@umlaeute
Copy link
Contributor

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

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

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

@umlaeute
Copy link
Contributor

umlaeute commented Oct 23, 2023

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
Copy link
Author

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
Copy link
Author

@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
Copy link
Contributor

umlaeute commented Oct 23, 2023

hmm, the new failure (assuming that i correctly read your output as a failure), appears to be somewhere in

${SED} -i "s/export DIST_NAME=.*/export DIST_NAME=${DIST_NAME}/g" config
${SED} -i "s/example/${DIST_NAME,,}/g" config

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
Copy link
Author

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
Copy link
Contributor

i agree it's probably a new issue.

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

@guysoft
Copy link
Owner

guysoft commented Oct 23, 2023

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

@guysoft
Copy link
Owner

guysoft commented Oct 31, 2023

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
Copy link
Author

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

@guysoft
Copy link
Owner

guysoft commented Oct 31, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants