Skip to content
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

coreutils #81

Closed
Sblop opened this issue Jun 10, 2024 · 10 comments · Fixed by #82
Closed

coreutils #81

Sblop opened this issue Jun 10, 2024 · 10 comments · Fixed by #82

Comments

@Sblop
Copy link

Sblop commented Jun 10, 2024

Hi,

Thanks for a great tool. I have been using this for quite a long time, as I can selectively choose what to update.

With the latest version I have had a number of issues, and I have finally figured out that it is because coreutils was not installed.

Would it make sense to add a check for this, just like regctl?

I use this script on a qnap nas, and was able to download coreutils-timeout using opkg. :o)

Edit: I also had some problems with the "readarray" command, but turned out I could update bash, to solve this.

/B

@mag37
Copy link
Owner

mag37 commented Jun 10, 2024

Oh thank you for reporting! I'll look into adding a check for it.

And about readarray - you're right, its from bash 5.0.17, maybe I should look into changing that back to what it was before to make it compatible with older environments..

Did a change back in april: 86649fb

from:

IFS=$'\n' 
NoUpdates=($(sort <<<"${NoUpdates[*]}"))
GotUpdates=($(sort <<<"${GotUpdates[*]}"))
GotErrors=($(sort <<<"${GotErrors[*]}"))
unset IFS

to:

readarray -td '' NoUpdates < <(printf '%s\0' "${NoUpdates[@]}" | sort -z -n)
readarray -td '' GotUpdates < <(printf '%s\0' "${GotUpdates[@]}" | sort -z -n)
readarray -td '' GotErrors < <(printf '%s\0' "${GotErrors[@]}" | sort -z -n)

Could maybe use the old way still (was no issues) or rewrite it to something like mapfile or read -a. Might look into it in the future.

@mag37
Copy link
Owner

mag37 commented Jun 10, 2024

Just did a push to a new branch to solve the timeout / non-coreutils, so it wont try to timeout if the binary doesn't exist.
If you still have a machine where it breaks I'd be happy if you tested it :) otherwise thank you for the headsup, and I'll do some more testing myself before merging to main.

main...tfix

https://github.com/mag37/dockcheck/tree/tfix

@mag37
Copy link
Owner

mag37 commented Jun 11, 2024

Might test to re-write the sorting of arrays to something like this to make it compatible with more (and older) shells.

read -r -a NoUpdates <<< "$(sort <<<"${NoUpdates[*]}")"
read -r -a GotUpdates <<< "$(sort <<<"${GotUpdates[*]}")"
read -r -a GotErrors <<< "$(sort <<<"${GotErrors[*]}")"

But gotta do some more testing, just a thought atm.

@Sblop
Copy link
Author

Sblop commented Jun 11, 2024

Hi Mag37,
I am not a programmer by trade but I can understand the main sections etc and usually find out what the problem is, and with the help of prior experience and a bit of chatgpt get my stuff to work. I will be happy to try the dockcheck script in my enviroment, but how want to do the sorting I cannot assist with... unfortunately.
/B

@mag37
Copy link
Owner

mag37 commented Jun 11, 2024

I will be happy to try the dockcheck script in my enviroment, but how want to do the sorting I cannot assist with... unfortunately.

Yeah no worries, thank you. I'll do some more testing on the sorting :)

But I think the main issue - the timeout breakage, should be sorted in the branch I linked.

https://github.com/mag37/dockcheck/tree/tfix

So if you still got a machine without coreutils you could test that dockcheck.sh.

I'll push it to main as soon as I've done some more testing.

@Sblop
Copy link
Author

Sblop commented Jun 12, 2024

Hi again,
I have reverted from the updated bash version offered by opkg, as this beaks stuff on my qnap... I really need to get a proper server, as qnap makes sh*t happen....
Anyways, the build in bash version is:

GNU bash, version 3.2.57(1)-release (x86_64-QNAP-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.

I have removed coreutils-timeout. I am able to update containers without the timeout error, but in the top of the script i get this error, as descibed earlier:

[##################################################] 49/49
./dockcheck.sh: line 248: readarray: command not found
./dockcheck.sh: line 249: readarray: command not found
./dockcheck.sh: line 250: readarray: command not found

Containers on latest version:
xxx
xxx

but this is obviously expected.

@mag37
Copy link
Owner

mag37 commented Jun 12, 2024

Happy to hear the timeout-bit works at least!
What if you replace the line 248,249,250 with this in dockcheck.sh:

read -r -a NoUpdates <<< "$(sort <<<"${NoUpdates[*]}")"
read -r -a GotUpdates <<< "$(sort <<<"${GotUpdates[*]}")"
read -r -a GotErrors <<< "$(sort <<<"${GotErrors[*]}")"

Should work with older bash versions, I hope..
I'll need to do some more testing with it later - if it works I'll add it to the branch before merging to main.

@Sblop
Copy link
Author

Sblop commented Jun 12, 2024

This works perfect.

Would you like to update? y/[n]: n
[##################################################] 49/49

Containers on latest version:
xxx
xxx
xxx

Containers with updates available:
1) xxx
xxxx
5) xxx

Choose what containers to update.
Enter number(s) separated by comma, [a] for all - [q] to quit:

@mag37
Copy link
Owner

mag37 commented Jun 12, 2024

This works perfect.

Wonderful! Thank you for testing, I'll test further tonight and push it to main if all goes well :)
Thank you for your feedback.

@mag37
Copy link
Owner

mag37 commented Jun 12, 2024

I did settle on just using the old syntax for the array sorting, pushing it to main right now. Let me know if you hit any issues!

@mag37 mag37 linked a pull request Jun 12, 2024 that will close this issue
@mag37 mag37 closed this as completed in #82 Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants