-
Notifications
You must be signed in to change notification settings - Fork 152
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
Remove usage of grep, sed, find from functions.sh #1828
Comments
I'm wondering whether we could simply leverage python for anything that is not part bash, as kiwi depends on python anyway? |
The entire functions.sh needs a refactor. Please note most of the stuff is only there for backward compatibility with custom scripts that might use this methods. Ideally I would like to get rid of almost everything functions.sh provided. We added these methods to support users with common functions for simple setup tasks. In the end however, it has turned out that this causes a lot of maintenance effort as distributions changes all the time and there is actually no common way to setup a system for feature X. Looking back I think it was a mistake to offer it. There are many opportunities to roll out system configurations and way better tools like ansible and friends to do it. Integrating them in a kiwi image is pretty easy and moves the responsibility for the system setup to the right place. As it's hard to simply remove published stuff the code is there and gets worse while the distros changes. So from my perspective it would be really good if we can find a strategy to refactor/reduce the code from functions.sh into a state that is useful, stable and reliable. Thoughts ? |
I'm afraid this is going to be very hard as many
It is doable, but not super straight forward. I think what would make people really switch to Ansible or Salt, if you could include your playbook/state files in the image description directly.
My recommendation would be to start deprecating everything that does not provide meaningful functionality or is just there for legacy reasons and gate the rest using a test suite like I started introducing in #1827. |
Reorganize the code into more readable areas like methods present as helpers, methods for customers, methods which are distribution specific and also methods that are deprecated and give a good reason why they are deprecated when they get called. This is related to Issue #1828
yes I fully agree and I also like to the idea to gate the rest code via a test suite. In addition to your test suite draft I have created my idea of refactoring the code. As expected this will cause conflicts but I'm sure they can be solved relatively easy |
Reorganize the code into more readable areas like methods present as helpers, methods for customers, methods which are distribution specific and also methods that are deprecated and give a good reason why they are deprecated when they get called. This is related to Issue #1828
Fixed with #1861 |
Not really, that was just one tiny bit: ✦ ❯ rg 'sed|grep|find' kiwi/config/functions.sh|wc
34 238 1815 |
ok but if we keep this open as a generic issue to fix step by step I suggest that we add more structure, define a task list for the methods that should be fixed and allow to share work across people. It might also be a good idea to create a function test first then adapt. Here is the list to start with imho
|
That should be a must imho. |
@SamirPS Hi This is about the code you can find in https://github.com/OSInside/kiwi/blob/master/kiwi/config/functions.sh The idea here is to reduce the external requirements for tools called as part of this code. For example sed, find, grep ... if possible. The driver for the change is that with a reduced set of external tools you don't need them anymore in the environment and so you can build with less dependencies, smaller images The tough part here is to make changes without introducing regressions. Because of that @dcermak created an integration testing framework for the shell code which allows us to run the methods see their results, then refactor and expect the results to stay unchanged. If you would like to participate here it would be much appreciated as I don't expect us to have time for this one. I'm sure @dcermak will help you to get started especially on the testing area Thanks much |
Can you show me an example on how replace grep ? |
@SamirPS that really depends on the exact usage of grep, but usually you can switch to reading the file line by line and then regex matching each line with bash or sh. See e.g.: https://github.com/OSInside/kiwi/pull/1861/files Feel free to drop by in the |
I will try to solve this issue |
Hello @dcermak when are you available to talk about this issue ? |
@SamirPS You mentioned in #kiwi that you would like to replace find in: Line 203 in 29b1fe0
This shouldn't be too difficult, for f in $(ls -a .); do
if [ -d $f ]; then
# do something with $f
fi
done There is a catch with the above snippet though: it includes |
Sorry but i didn't have time to finish all, if someone want to take the lead, i let him |
Problem description
We are currently building very minimal container images and try to exclude as much as possible from them, for instance
sed
andgrep
. Unfortunately, that results in kiwi'sconfig.sh
failing as it relies onsed
andgrep
to exist.It would be nice if kiwi could work without
sed
andgrep
being present in the build root.OS and Software information
The text was updated successfully, but these errors were encountered: