arran4 / arrans_overlay_workflow_builder

1 stars 0 forks source link

Switch to using a recursive structure to build layers for extracting nested archives, rather than just a 2 parse system where names could align #4

Open arran4 opened 2 months ago

arran4 commented 2 months ago

Since I am building a tree of "unpack this to get this, rename this to get this" I should instead of using a complex set of loops and ifs and praying that the names align, recursively descend it to create a series of actions, ie:

It will reduce complexity and be more readable plus filename alignment issues will be greatly reduced especially con converging and expanding packages (or where the same manual page is stored in multiple files:)

[[- range $pname, $prog := .Programs ]]
[[- range $keyword, $binary := $prog.Binary ]]
  [[- if ne $prog.InstalledFilename (index $binary 1) ]]
    [[- if gt (len $binary) 2 ]]
                echo '  if use [[ $keyword ]]; then'
                echo "    mv \"${{ env.[[ join (filterEmpty $pname "appimage_archived_name" $keyword) "_" ]] }}\" \"${{ env.[[ join (filterEmpty $pname "appimage_installed_name" ) "_" ]] }}\"  || die \"Can't move archived file\""
                echo '  fi'
    [[- else ]]
                echo '  if use [[ $keyword ]]; then'
                echo "    cp \"\${DISTDIR}/\${P}-${{ env.[[ join (filterEmpty $pname "release_name" $keyword) "_" ]] }}\" \"${{ env.[[ join (filterEmpty $pname "appimage_installed_name" ) "_" ]] }}\"  || die \"Can't copy downloaded file\""
                echo '  fi'
    [[- end ]]
  [[- end ]]
arran4 commented 2 months ago

Unrelated to above, but definitely related to: https://github.com/arran4/arrans_overlay/pull/5

It would definitely reduce complexity. I will probably do it when I have more energy & focus when there are more users. I need to work on other things right now.