mirror of
https://github.com/edu4rdshl/simpleaur.git
synced 2026-07-17 23:24:46 +00:00
Rewritten with the POSIX standard in mind for full compatibility
Also, some visual improvements have been added Rollback to not use the --noconfirm option
This commit is contained in:
parent
351030c45e
commit
f8e658703b
1 changed files with 49 additions and 40 deletions
89
simpleaur
89
simpleaur
|
|
@ -1,16 +1,25 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# install AUR packages
|
# install AUR packages
|
||||||
basebuilddir="$HOME/.simpleaur/Build"
|
basebuilddir="$HOME/.simpleaur/Build"
|
||||||
pacmanexist=$(which pacman 2> /dev/null)
|
pacmanexist=$(command -v pacman 2> /dev/null)
|
||||||
lockfile="$basebuilddir/simpleaur.lock"
|
lockfile="$basebuilddir/simpleaur.lock"
|
||||||
|
|
||||||
ctrl_c() {
|
ctrl_c() {
|
||||||
printf "\n\n\e[1;31m%-6s\e[m%s\n" "Keyboard Interrupt detected, removing lock file and leaving..."
|
printf "\\n\\e[1;31m%-6s\\e[m\\n" "Keyboard Interrupt detected, removing lock file and leaving..."
|
||||||
rm "$lockfile"
|
rm "$lockfile"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
trap ctrl_c SIGINT
|
trap ctrl_c 2
|
||||||
|
|
||||||
|
#Make sure that you are using an ArchLinux system
|
||||||
|
if [ -x "$pacmanexist" ]; then
|
||||||
|
printf ""
|
||||||
|
else
|
||||||
|
printf "\\n\\e[1;31m%-6s\\e[m\\n" "Error: You are not using ArchLinux, pacman was not found in ($PATH)"
|
||||||
|
rm "$lockfile"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
#Check if the base Build DIR exists, if not create it.
|
#Check if the base Build DIR exists, if not create it.
|
||||||
if [ ! -d "$basebuilddir" ]; then
|
if [ ! -d "$basebuilddir" ]; then
|
||||||
|
|
@ -19,43 +28,36 @@ fi
|
||||||
|
|
||||||
#Prevent two instances running at same time
|
#Prevent two instances running at same time
|
||||||
if [ -f "$lockfile" ]; then
|
if [ -f "$lockfile" ]; then
|
||||||
printf "\n\e[1;31m%-6s\e[m%s\n" "simpleaur is running, leaving."
|
printf "\\n\\e[1;31m%-6s\\e[m\\n" "simpleaur is running, leaving."
|
||||||
printf "\n\e[1;31m%-6s\e[m%s\n" "If you are sure that simpleaur is not running, delete [ '$lockfile' ]"
|
printf "\\n\\e[1;31m%-6s\\e[m\\n" "If you are sure that simpleaur is not running, delete [ '$lockfile' ]"
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
touch "$lockfile"
|
touch "$lockfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Make sure that you are using an ArchLinux system
|
if [ -z "$*" ] ; then
|
||||||
if [ -x "$pacmanexist" ]; then
|
printf "\\n\\e[1;31m%-6s\\e[m\\n" "Error: Please, pass AUR package(s) name(s) to simpleaur."
|
||||||
continue
|
|
||||||
else
|
|
||||||
printf "\n\e[1;31m%-6s\e[m%s\n" "Error: You are not using ArchLinux, pacman was not found in ($PATH)"
|
|
||||||
rm "$lockfile"
|
rm "$lockfile"
|
||||||
exit
|
exit
|
||||||
fi
|
else
|
||||||
|
|
||||||
if [[ "$@" ]]; then
|
|
||||||
cd "$basebuilddir" || exit
|
cd "$basebuilddir" || exit
|
||||||
else
|
|
||||||
printf "\n\e[1;31m%-6s\e[m%s\n" "Error: Please, pass AUR package(s) name(s) to simpleaur."
|
|
||||||
rm "$lockfile"
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the package was already downloaded and then download the PKGBUILDs accordly to user needs.
|
# Check if the package was already downloaded and then download the PKGBUILDs accordly to user needs.
|
||||||
for ipackage in "$@"; do
|
for ipackage in "$@"; do
|
||||||
if [ -d "$basebuilddir/$ipackage" ]; then
|
if [ -d "$basebuilddir/$ipackage" ]; then
|
||||||
printf "\n\e[1;32m%-6s\e[m\n%s\n" "PKGBUILD for [ '$ipackage' ] exist in the [ '$basebuilddir/$ipackage' ] directory, if you want to update the package because an update was found by simplecheck, then you need remove the existing directory to update the package, otherwise you are reinstaling the same package version that's already installed."
|
printf "\\n\\e[1;32m%-6s\\e[m\\n" "PKGBUILD for [ '$ipackage' ] exist in the [ '$basebuilddir/$ipackage' ] directory, if you want to update the package because an update was found by simplecheck, then you need remove the existing directory to update the package, otherwise you are reinstaling the same package version that's already installed."
|
||||||
read -p "Remove the [ '$basebuilddir/$ipackage' ] directory? [Y/n] " rmolddir
|
printf "\\n\\e[1;33m%-6s\\e[m" "Remove the [ '$basebuilddir/$ipackage' ] directory? [Y/n] "
|
||||||
if [ "$rmolddir" = "y" ]; then
|
read -r rmolddir
|
||||||
printf "\n\e[1;32m%-6s\e[m\n%s\n" "Info: removing the old directory..."
|
if [ "$rmolddir" = "y" ] || [ "$rmolddir" = "Y" ] ; then
|
||||||
|
printf "\\n\\e[1;32m%-6s\\e[m\\n" "Info: removing the old directory and getting the new sources..."
|
||||||
rm -rf "$basebuilddir/$ipackage"
|
rm -rf "$basebuilddir/$ipackage"
|
||||||
git clone "https://aur.archlinux.org/${ipackage}.git"
|
git clone "https://aur.archlinux.org/${ipackage}.git"
|
||||||
|
continue
|
||||||
elif [ "$rmolddir" = "n" ]; then
|
elif [ "$rmolddir" = "n" ]; then
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
printf "\n\e[1;32m%-6s\e[m\n%s\n" "Wrong option, continuing..."
|
printf "\\n\\e[1;33m%-6s\\e[m\\n" "Warning: Wrong option, continuing..."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
@ -63,47 +65,54 @@ for ipackage in "$@"; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# Check PKGBUILDs.
|
# Check PKGBUILDs.
|
||||||
for ipackage in "$@"; do
|
for ipackage in "$@"; do
|
||||||
cd "$basebuilddir/$ipackage"
|
cd "$basebuilddir/$ipackage" || exit
|
||||||
read -s -r -n 1 -p "View PKGBUILD for [ "$ipackage" ]? [Y/n] "$'\n' answer
|
printf "\\e[1;33m%-6s\\e[m" "View PKGBUILD for [ $ipackage ]? [Y/n] "
|
||||||
[[ "${answer,,}" =~ ^(yes|y)$ ]] && ${EDITOR} PKGBUILD
|
read -r answer
|
||||||
|
if [ "$answer" = "y" ] || [ "$answer" = "Y" ] ; then
|
||||||
|
${EDITOR} PKGBUILD
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
cd "$basebuilddir"
|
cd "$basebuilddir" || exit
|
||||||
|
|
||||||
# Install packages.
|
# Install packages.
|
||||||
for ipackage in "$@"; do
|
for ipackage in "$@"; do
|
||||||
#Check if PKGBUILD exist
|
#Check if PKGBUILD exist
|
||||||
if [ -f "$ipackage/PKGBUILD" ]; then
|
if [ -f "$ipackage/PKGBUILD" ]; then
|
||||||
cd "$ipackage"
|
cd "$ipackage" || exit
|
||||||
makepkg -srci --noconfirm
|
if makepkg -srci ; then
|
||||||
if [ "$?" -eq 0 ]; then
|
cd "$basebuilddir" || exit
|
||||||
cd "$basebuilddir"
|
printf "\\e[1;32m%-6s\\e[m\\n\\n" "The package [ $ipackage ] has been installed"
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
printf "\n\e[1;31m%-6s\e[m%s\n" "Info: Installation not completed."
|
printf "\\n\\e[1;31m%-6s\\e[m\\n" "Error: Installation not completed."
|
||||||
cd "$basebuilddir"
|
cd "$basebuilddir" || exit
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf "\n\e[1;31m%-6s\e[m%s\n" "Error: The PKGBUILD file for [ $ipackage ] does not exist, please check your internet connection and make sure that the AUR package name exists, you can use simplesearch for that."
|
printf "\\n\\e[1;31m%-6s\\e[m\\n" "Error: The PKGBUILD file for [ $ipackage ] does not exist, please check your internet connection and make sure that the AUR package name exists, you can use simplesearch for that."
|
||||||
printf "\n\e[1;32m%-6s\e[m\n%s\n" "Info: Removing the failed build directory..."
|
printf "\\n\\e[1;32m%-6s\\e[m\\n" "Info: Removing the failed build directory..."
|
||||||
rm -rf "$basebuilddir/$ipackage"
|
rm -rf "$basebuilddir/$ipackage"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
#Ask to the user if want to remove the directory created for git
|
#Ask to the user if want to remove the directory created for git
|
||||||
read -p "Remove previously compiled packages? [Y/n]? " yn
|
printf "\\e[1;33m%-6s\\e[m" "Remove previously compiled packages? [Y/n]? "
|
||||||
|
read -r yn
|
||||||
#Take the answer from the user input and decide what to do.
|
#Take the answer from the user input and decide what to do.
|
||||||
if [ "$yn" = "y" ]; then
|
if [ "$yn" = "y" ] || [ "$yn" = "Y" ] ; then
|
||||||
printf "\n\e[1;32m%-6s\e[m\n%s\n" "Info: Removing previously compiled packages..."
|
printf "\\n\\e[1;32m%-6s\\e[m\\n" "Info: Removing previously compiled packages..."
|
||||||
for ipackage in "$@"; do
|
for ipackage in "$@"; do
|
||||||
rm -rf "$basebuilddir/$ipackage"
|
rm -rf "$basebuilddir/$ipackage"
|
||||||
done
|
done
|
||||||
|
printf "\\e[1;32m%-6s\\e[m\\n" "Info: Instalation completed."
|
||||||
else
|
else
|
||||||
printf "\n\e[1;32m%-6s\e[m\n%s\n" "Info: Instalation completed."
|
printf "\\n\\e[1;32m%-6s\\e[m\\n" "Info: Instalation completed."
|
||||||
fi
|
fi
|
||||||
rm -f "$lockfile"
|
rm -f "$lockfile"
|
||||||
printf "\e[1;32m%-6s\e[m\n%s\n" "Finished."
|
|
||||||
exit
|
exit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue