Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1854  / 2 Years ago, tue, august 16, 2022, 9:20:09

When running sudo apt-get update -q, sometimes I see things like



Err:23 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu precise/main i386 Packages
Could not connect to ppa.launchpad.net:80 (91.189.95.83), connection timed out
Err:24 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu precise/main Translation-en
Unable to connect to ppa.launchpad.net:http:


or like



W: http://us-central1.gce.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)


But echo $? tells me that apt-get update -q succeeded. How can I get the error/warning status to be fatal, and make apt-get update fail with a non-zero exit code?


More From » apt

 Answers
7

As mentioned by @Terrance, this question is very close to that other question apt-get update exit status (in Unix & Linux StackExchange).



FYI I've just posted there another solution that can also be combined with the travis_retry Travis CI command (which might be the intended use case of the OP):



exec {fd}>&2 # copy stderr to some unused fd
travis_retry bash -o pipefail -c "sudo apt-get update -y -q 2>&1 | tee /dev/fd/$fd | ( ! grep -q -e '^Err:' -e '^E:' )"
exec {fd}>&- # close file descriptor

[#9258] Tuesday, August 16, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
erettor

Total Points: 303
Total Questions: 121
Total Answers: 103

Location: Colombia
Member since Mon, May 2, 2022
2 Years ago
;