Bug 2171154

Summary: 01_update_platforms_check.sh FAILURE due to array vs newline
Product: [Fedora] Fedora Reporter: Simon de Vlieger <sdevlieg>
Component: greenbootAssignee: Paul Whalen <pwhalen>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 37CC: cglombek, gmarr, miabbott, pbrobinson, pwhalen, user-cont-team+packit-fas
Target Milestone: ---   
Target Release: ---   
Hardware: aarch64   
OS: Linux   
Whiteboard:
Fixed In Version: greenboot-0.15.4-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-27 21:24:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1269538, 2115100    

Description Simon de Vlieger 2023-02-18 11:45:53 UTC
Sorry, this one was empty due to ~~bugzilla~~.

On my newly installed F37 IoT the script `01_update_platforms_check.sh` always fails. This is due to UPDATE_PLATFORM_URLS being treated as an array when it's not made to be one. This patch fixes this (but I couldn't find where to submit it):

```
--- 01_update_platforms_check.orig.sh	2023-02-18 11:42:51.542118526 +0000
+++ 01_update_platforms_check.sh	2023-02-18 11:35:51.707036576 +0000
@@ -5,7 +5,7 @@
 URLS_WITH_PROBLEMS=()

 get_update_platform_urls() {
-    UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)
+    mapfile -t UPDATE_PLATFORM_URLS < <(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*)
     if [[ -z $UPDATE_PLATFORM_URLS ]]; then
         echo "No update platforms found, this can be a mistake"
         exit 1
```

The output (with set +ex) of the original file shows where things go wrong:

```
[root@zmeya ~]# ./01_update_platforms_check.orig.sh
+ REPOS_DIRECTORY=/etc/ostree/remotes.d
+ URLS_WITH_PROBLEMS=()
+ [[ ! -d /etc/ostree/remotes.d ]]
+ get_update_platform_urls
++ grep -P -ho 'http[s]?.*' /etc/ostree/remotes.d/fedora-iot.conf
+ UPDATE_PLATFORM_URLS='https://ostree.fedoraproject.org/iot
https://ostree.fedoraproject.org/iot/mirrorlist'
+ [[ -z https://ostree.fedoraproject.org/iot
https://ostree.fedoraproject.org/iot/mirrorlist ]]
+ assert_update_platforms_are_responding
+ for UPDATE_PLATFORM_URL in "${UPDATE_PLATFORM_URLS[@]}"
++ curl -o /dev/null -Isw '%{http_code}\n' 'https://ostree.fedoraproject.org/iot
https://ostree.fedoraproject.org/iot/mirrorlist'
++ echo Unreachable
+ HTTP_STATUS='000
Unreachable'
+ [[ 000
Unreachable == 2* ]]
+ [[ 000
Unreachable == 3* ]]
+ URLS_WITH_PROBLEMS+=("$UPDATE_PLATFORM_URL")
+ [[ 1 -eq 0 ]]
+ echo 'There are problems connecting with the following URLs:'
There are problems connecting with the following URLs:
+ echo 'https://ostree.fedoraproject.org/iot
https://ostree.fedoraproject.org/iot/mirrorlist'
https://ostree.fedoraproject.org/iot
https://ostree.fedoraproject.org/iot/mirrorlist
+ exit 1
```

Comment 1 Micah Abbott 2023-02-18 15:06:13 UTC
This should be fixed with https://github.com/fedora-iot/greenboot/pull/94 + greenboot v0.15.4 (https://github.com/fedora-iot/greenboot/pull/95)

Expect new packages in Fedora early next week.

Comment 3 Micah Abbott 2023-02-23 16:47:27 UTC
*** Bug 2062455 has been marked as a duplicate of this bug. ***

Comment 4 Aoife Moloney 2023-11-23 01:16:56 UTC
This message is a reminder that Fedora Linux 37 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 37 on 2023-12-05.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '37'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 37 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.