8000 Improvement: runnable if no wget; readable if no terminal or no Unicode; a bit more tips for users; clean code by pzhlkj6612 · Pull Request #7 · yusuphwickama/wickerscripts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improvemen 10000 t: runnable if no wget; readable if no terminal or no Unicode; a bit more tips for users; clean code #7

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

pzhlkj6612
Copy link

Hello! I'm from your answer on unix.stackexchange.com 1 . The pkgdownload script is a very useful tool. Thanks for your effort!

Summary

I read your code and try improving it for the following points:

  • Let the user run apt update before apt search <package> if error occurs.
  • Use "curl" for the connectivity check if no "wget" found, or completely skip that check if we found neither "wget" nor "curl".
  • Make the output more readable during docker build or other non-terminal environment.
  • Make the output string looks better in non-Unicode-supported environment.
  • Make the script exit with non-zero code if error occurs.
  • Clean and simplify the code.

Please read commit message of my commits for details.

Thank you!

Comparison

20241212-wickerscripts-pkgdownload-comparison

Test

No "wget" found and non-terminal environment

Dockerfile:

FROM ubuntu:22.04

RUN apt update

COPY --chmod=775 ./pkgdownload /pkgdownload

RUN /pkgdownload python3-venv

During docker build:

#8 [4/4] RUN /pkgdownload python3-venv
#8 1.041 /pkgdownload: line 47: wget: command not found
#8 1.043 tput: No value for $TERM and no -T specified
#8 1.044 tput: No value for $TERM and no -T specified
#8 1.044 No connection, check your internet and try again
#8 DONE 1.1s

After applying my patches:

#8 [4/4] RUN /pkgdownload python3-venv
#8 1.012 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#8 1.012 |  P a c k a g e  D o w n l o a d e r  v 1.4  |
#8 1.012 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#8 1.012 ------------- Created by Wick3rman ------------
#8 1.012
#8 1.016 [+] Created directory python3-venv
#8 1.019 [-] Found 3 dependencies for: python3-venv
#8 1.856 [-] Added python3.10-venv to dependency list
#8 3.562 [-] Added ...
#8 17.15 [++] Checking for child dependencies
#8 18.89 [-] Added debconf to dependency list
#8 24.11 [-] Added ...
#8 24.14 [-] Downloading: python3.10-venv [o]
#8 25.49 [-] Downloading: ...
#8 79.14 [-] Packaging downloaded packages to python3-venv.tar.gz [o]
#8 79.37 [-] Removing original directory [o]
#8 79.38 [-] Operations completed in 1m 18s
#8 DONE 79.4s

non-Unicode-supported environment

After installing "wget" and "ca-certificates", we can download packages:

#9 68.92 [-] Downloading: python3-venv [\u2714]
#9 68.92 tput: No value for $TERM and no -T specified
#9 68.92 tput: No value for $TERM and no -T specified
#9 68.92 [-] Packaging downloaded packages to python3-venv.tar.gz
#9 69.14 tput: No value for $TERM and no -T specified
#9 69.14 tput: No value for $TERM and no -T specified
#9 69.14 tput: No value for $TERM and no -T specified
#9 69.15 tput: No value for $TERM and no -T specified
#9 69.15 tput: No value for $TERM and no -T specified
#9 69.15 [-] Packaging downloaded packages to python3-venv.tar.gz [\u2714]
#9 69.15 [-] Removing original directory
#9 69.15 tput: No value for $TERM and no -T specified
#9 69.15 tput: No value for $TERM and no -T specified
#9 69.15 tput: No value for $TERM and no -T specified
#9 69.15 [-] Removing original directory  [\u2714]
#9 69.16 tput: No value for $TERM and no -T specified
#9 69.16 tput: No value for $TERM and no -T specified
#9 69.16 tput: No value for $TERM and no -T specified
#9 69.16 tput: No value for $TERM and no -T specified
#9 69.16 [-] Operations completed in 1m 8s
#9 DONE 69.2s

Please note these [\u2714] . To match the "x" char for errors, here I use the "o" char to replace (Tic-tac-toe).

Footnotes

  1. answer 472562 § How to download package not install it with apt-get command? - Unix & Linux Stack Exchange

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 this pull request may close these issues.

1 participant
0