siemens / kas

Setup tool for bitbake based projects
MIT License
353 stars 144 forks source link

add jq utility support to parse template files in json format #65

Closed karadaganil closed 2 years ago

karadaganil commented 2 years ago

Hi all, Sometimes, we need to adjust template file before copying to target. In isar building, we do that in method do_install_prepend(). branch adding/removing/updating is too simple with utility "jq".

Sample for deleting branch "vol_resize"

       awk '$1 == "\"vol_resize\""{m=1;next} \
            m==1 && /},[[:blank:]]*$/{m=0;next} \
            m != 1' ${WORKDIR}/installer.conf > ${WORKDIR}/installer.conf.new

       -- vs -- 

       jq 'del(.vol_resize)' ${WORKDIR}/installer.conf > ${WORKDIR}/installer.conf.new
jan-kiszka commented 2 years ago

Please check https://github.com/siemens/kas/blob/master/CONTRIBUTING.md carefully and then submit the patch to the mailing list.

The patch commit should furthermore explain why Isar's templating isn't sufficient. And it should target Dockerfile.isar if the extension is Isar-specific.

karadaganil commented 2 years ago

Sorry for missing sign-off message. I am new on github. I could not push my work-branch due to error [1]. I will check all. thanks for quick return.

[1] remote: Permission to siemens/kas.git denied to karadaganil. fatal: unable to access 'https://github.com/siemens/kas.git/': The requested URL returned error: 403

karadaganil commented 2 years ago

p.s. I passed the failure I shared, via pushing to https://github.com/karadaganil/kas/.

jan-kiszka commented 2 years ago

You can't push to github as you are not member of the project - if that is what you tried and got the error for. If we were following the pull request workflow here, then forking the repo into your own namespace and sending a pull request from there would have been the right approach.

karadaganil commented 2 years ago

Thanks. I see then fix it.

Our motivation behind the jq, is to use a simple way while editing a json data. That is too complex with awk, sed and grep. Also, the utilities cannot tolerate minor changes (stay line in file, before x, after y, how to finish) on data.

karadaganil commented 2 years ago

I dont mean that there is a problem on isar templating. Our use-case needs to remove a branch(fixed content) from a template file. The content could not be distributed in template file. But, distributed now.

we use the kas-container in our isar-building on local environment. Now it does not support jq by default.

How should I continue? close the PR then open a new one for Dockerfile.isar

jan-kiszka commented 2 years ago

Please send the patch to the mailing list, explaining again what you want to do and why other means (templating, using a python function etc.) do not work well enough. Make the case as clear as possible so that we can assess whether the additional dependency is justified.

karadaganil commented 2 years ago

I think we can ignore the details to focus on jq support on kas-container. I would like to get this support by default. if we are on the same page, I will prepare a new PR request from https://github.com/karadaganil/kas/tree/add_jq_support

henning-schild commented 2 years ago

I think the example does not qualify for adding the tool to the containers. If that is just a debian package the tool should become a "Build-Depends" and the code should go into "debian/rules". Or you enter the buildchroot if you really need to do this in do_install and not in debian/rules. If it is an image recipe you should make use of IMAGER_INSTALL

karadaganil commented 2 years ago

Hi guys, Thanks for all replies. There is no agreement on that. it is being closed.

henning-schild commented 2 years ago

Hi guys, Thanks for all replies. There is no agreement on that. it is being closed.

Maybe i did not get the need or my suggestions will work for your recipe. If you still think it is valid please keep proposing it with a reasoning or maybe a test-case/example. The given example does not seem like it justifies bloat in the container.