Skip to content

firmware-selector: Hot fix on gen_overview_json.sh #225

Description

@akira25

I hot-fixed the file /usr/local/src/www/htdocs/buildbot/releases/gen_overview_json.sh. The firmware selector was malfunctioning, as this script didn't generate overview jsons for all versions correctly:

$ sudo ./gen_overview_json.sh                                                  
Processing ./1.4.0-snapshot-tunnel                                                                                                                          
jq: error (at ./1.4.0-snapshot-tunnel/targets/octeon/generic/profiles.json:0): Cannot index array with string "target"
Processing ./1.2.3-tunnel                                                                                                                                   
Processing ./1.4.0-notunnel                                                   
Processing ./1.3.1-notunnel                                                                                                                                 
jq: error (at ./1.3.1-notunnel/targets/ath25/generic/profiles.json:0): Cannot index array with string "target"                                              
Processing ./1.3.0-tunnel                                                                                                                                   
jq: error (at ./1.3.0-tunnel/targets/ath25/generic/profiles.json:0): Cannot index array with string "target"
Processing ./1.2.4-tunnel                                                                                                                                   
jq: error (at ./1.2.4-tunnel/targets/ath25/generic/profiles.json:0): Cannot index array with string "target"
Processing ./1.2.4-notunnel                                                                                                                                 
jq: error (at ./1.2.4-notunnel/targets/ath25/generic/profiles.json:0): Cannot index array with string "target"                                              Processing ./1.5.0-snapshot-notunnel                                                                                                                        
jq: error (at ./1.5.0-snapshot-notunnel/targets/octeon/generic/profiles.json:0): Cannot index array with string "target"                                    
Processing ./1.3.0-notunnel                                                                                                                                 jq: error (at ./1.3.0-notunnel/targets/ath25/generic/profiles.json:0): Cannot index array with string "target"                                              
Processing ./1.4.0-snapshot-notunnel                                                                                                                        
jq: error (at ./1.4.0-snapshot-notunnel/targets/octeon/generic/profiles.json:0): Cannot index array with string "target"                                    
Processing ./1.2.3-notunnel                                                                                                                                 
Processing ./1.4.0-tunnel                                                                                                                                   Processing ./1.5.0-snapshot-tunnel
jq: error (at ./1.5.0-snapshot-tunnel/targets/octeon/generic/profiles.json:0): Cannot index array with string "target"                                      
Processing ./1.3.1-tunnel                                                                                                                                   jq: error (at ./1.3.1-tunnel/targets/ath25/generic/profiles.json:0): Cannot index array with string "target"

Root cause was, that the find call did also find summary json files, that did not have the expected structure. This was fixed by introducing a mindepth-option in the call. The current state of the script is attaged below:

#!/bin/sh


for VERSION_PATH in $(find -L . -maxdepth 1 -type d -not -path '.'); do
  echo "Processing $VERSION_PATH"
  #jq -s '{ release: .[0].version_number, profiles: [.[] | .target as $target | .profiles | keys[] as $k | { id: ($k), titles: (.[$k] | .titles), target: $target }] }' $(find -L "$VERSION_PATH" -iname 'profiles.json') > $VERSION_PATH/.overview.json
  # Fix: in some dirs, there is an aggregated json already. Ignore that by setting a minimal depth
  jq -s '{ release: .[0].version_number, profiles: [.[] | .target as $target | .profiles | keys[] as $k | { id: ($k), titles: (.[$k] | .titles), target: $target }] }' $(find -L "$VERSION_PATH" -mindepth 4 -iname 'profiles.json') > $VERSION_PATH/.overview.json

# debugging print: uncomment and comment line above. Run script by piping stdout to /dev/null
#  for file in  $(find -L "$VERSION_PATH" -iname 'profiles.json'); do
#    # jq -s '{ release: .[0].version_number, profiles: [.[] | .target as $target | .profiles | keys[] as $k | { id: ($k), titles: (.[$k] | .titles), target: $target }] }' "$file"
#    # Fix: in some dirs, there is an aggregated json already. Ignore that by setting a minimal depth
#    jq -s '{ release: .[0].version_number, profiles: [.[] | .target as $target | .profiles | keys[] as $k | { id: ($k), titles: (.[$k] | .titles), target: $target }] }' $(find -L "$VERSION_PATH" -mindepth 4 -iname 'profiles.json') > $VERSION_PATH/.overview.json
#  done

done

@nicolasberens @pktpls I didn't find this script in the current ansible. Therefore this issue. Do we need to add this still, or did I overlook something?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions