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

Failing 01_update_platforms_check.sh on Fedora IoT #93

Closed
alcir opened this issue Jan 20, 2023 · 7 comments · Fixed by #94
Closed

Failing 01_update_platforms_check.sh on Fedora IoT #93

alcir opened this issue Jan 20, 2023 · 7 comments · Fixed by #94

Comments

@alcir
Copy link
Contributor

alcir commented Jan 20, 2023

I don't know if it is a duplicate of #90 and #71, so excuse me in advance:

On a fresh Fedora IoT 37 I always get

There are problems connecting with the following URLs:
https://ostree.fedoraproject.org/iot
https://ostree.fedoraproject.org/iot/mirrorlist

Also running /usr/lib/greenboot/check/wanted.d/01_update_platforms_check.sh by hand after the boot, it returns the same result.

I'm not a great bash expert, but I suspect that the double quotes around the ${UPDATE_PLATFORM_URLS[@]} will result in a single line containing all the UPDATE_PLATFORM_URLS making ineffective the for loop

for UPDATE_PLATFORM_URL in "${UPDATE_PLATFORM_URLS[@]}"; do

At the end of the day, the curl command is
curl -o /dev/null -Isw '%{http_code}\n' "https://ostree.fedoraproject.org/iot https://ostree.fedoraproject.org/iot/mirrorlist"
leading to a 000 HTTP_STATUS variable (that is curl: (3) URL using bad/illegal format or missing URL)

In short: if in such line I remove the double quotes
for UPDATE_PLATFORM_URL in ${UPDATE_PLATFORM_URLS[@]}; do
the script works as expected.

@pcdubs
Copy link
Member

pcdubs commented Jan 20, 2023

This regression happened recently with 84bbd67

@pcdubs
Copy link
Member

pcdubs commented Jan 20, 2023

@alcir did you want to open a RHBZ for this issue so we can track it for F38? (if not I can)

Thanks for finding it!

miabbott added a commit to miabbott/greenboot that referenced this issue Jan 20, 2023
See: https://github.com/koalaman/shellcheck/wiki/SC2048

In the case of the UPDATE_PLATFORM_URLS variable, we actually want to
split on whitespace since the array should just contain URLs.

Disable the Shellcheck directive for this array.

Closes: fedora-iot#93
@alcir
Copy link
Contributor Author

alcir commented Jan 20, 2023

@alcir did you want to open a RHBZ for this issue so we can track it for F38? (if not I can)

I will

@alcir
Copy link
Contributor Author

alcir commented Jan 20, 2023

It is already tracked
https://bugzilla.redhat.com/show_bug.cgi?id=2062455

@alcir
Copy link
Contributor Author

alcir commented Jan 20, 2023

Again, I'm not a bash expert, but instead of disable shellcheck, here

UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

we could actually populate the UPDATE_PLATFORM_URLS array simply in this way
UPDATE_PLATFORM_URLS=($(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*))
or
readarray -t UPDATE_PLATFORM_URLS < <(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

@miabbott
Copy link
Member

Again, I'm not a bash expert, but instead of disable shellcheck, here

UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

we could actually populate the UPDATE_PLATFORM_URLS array simply in this way
UPDATE_PLATFORM_URLS=($(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*))
or
readarray -t UPDATE_PLATFORM_URLS < <(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)

Could you make this same suggestion on the PR itself (#94)? Maintaining the context of the suggestion would make it easier to discuss.

@joeelliott76
Copy link

Yes that works for me, I also I made this that works as well using the tr command.

UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.' $REPOS_DIRECTORY/ | tr '\n' ' ')

miabbott added a commit to miabbott/greenboot that referenced this issue Feb 15, 2023
This updates the script to be more ShellCheck compliant around the
assignment of the UPDATE_PLATFORM_URLS variable and the check to see
if the varible is empty. The existing functionality remains unchanged.

Thanks to @alcir for the suggested changes!

Closes: fedora-iot#93
nullr0ute pushed a commit that referenced this issue Feb 16, 2023
This updates the script to be more ShellCheck compliant around the
assignment of the UPDATE_PLATFORM_URLS variable and the check to see
if the varible is empty. The existing functionality remains unchanged.

Thanks to @alcir for the suggested changes!

Closes: #93
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

Successfully merging a pull request may close this issue.

4 participants