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

Adding error handling and validation for the user input and the commands #4030

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

0danteh
Copy link

@0danteh 0danteh commented Dec 10, 2023

In this commit, I have applied changes about the overall functionality and error-prevention in this regard. Here's a guide at what I have applied the changes to:

  • It defines a usage function that prints a message explaining how to use the script and exits with an error code.
  • It checks if the user has provided three arguments: maintainer, category, and pkgbuild. If not, it calls the usage function.
  • It assigns the arguments to variables with the same names.
  • It checks if the pkgbuild file exists and is readable. If not, it prints an error message and exits with an error code.
  • It checks if the pkgbuild file is valid by using the makepkg utility. If not, it prints an error message and exits with an error code.
  • It defines a cleanup function that removes a temporary file and sets a trap to call it on exit.
  • It creates a temporary file and writes the maintainer and pkgbuild information to it.
    -It generates a package archive from the temporary file by using the makepkg utility. If it fails, it prints an error message and exits with an error code.
  • It sources the temporary file to get the package name, version, and release variables.
  • It checks if the package already exists in the AUR by using the curl and grep commands. If not, it uploads the package archive to the AUR by using the aurpublish utility. If it fails, it prints an error message and exits with an error code. If the package already exists, it prints a warning message.

I hope you will like it, I wish you all a great day!

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