Skip to content

Instantly share code, notes, and snippets.

@anupdhml
Created November 21, 2013 04:14
Show Gist options
  • Save anupdhml/7575998 to your computer and use it in GitHub Desktop.
Save anupdhml/7575998 to your computer and use it in GitHub Desktop.
Script combining cower, makepkg and pacman for Arch Linux, to download packages from AUR
#!/bin/bash
# A simple script combinig cower, makepkg and pacman
# Usage: aur_install.sh package1 package2...
# <[email protected]>
# folder to store the done packages
builds_folder="$HOME/builds"
done_folder_name="BUILT/"
ignore_folder_name="IGNORE/"
quit_on_error () {
ferr=$?;
msg=$1
if [ $ferr != 0 ]; then
echo "."
echo ". ### error $ferr: $msg"
echo ". ### bye"
echo "."
[ -d "$builds_folder" ] && echo "Check $builds_folder for residues"
exit $ferr;
fi
}
##############################################################################
# If $builds_folder is not there, files will be processed in the current dir
[ -d "$builds_folder" ] && echo "$builds_folder exists, so working there..." &&
cd $builds_folder
echo ""
# process the (given) arguments with cower
if [ "$#" -ne 0 ]
then
echo DOWNLOADING "$@"
cower -dd "$@"
quit_on_error "Error downloading packages $@"
echo ""
echo "------------------------------------------------------------"
fi
# make and install the packages based on cower's files (or the files that were already here)
for dir in $(ls -d */); do
# don't touch the done and ignore folder
[ "$dir" == "$done_folder_name" -o "$dir" == "$ignore_folder_name" ] && continue
echo ""
echo "ENTERING $dir..."
cd "$dir"
echo ""
echo "MAKING PACKAGE..."
echo ""
makepkg -fs
quit_on_error "Error making package for $dir"
echo ""
echo "INSTALLING PACKAGE..."
echo ""
sudo pacman --noconfirm -U *.pkg.*xz
quit_on_error "Error installing package for $dir"
cd ..
mkdir -p "$done_folder_name"
mv -v "$dir" "$done_folder_name"/
echo ""
echo "------------------------------------------------------------"
done
[ -d "$builds_folder" ] && echo "Check $builds_folder/$done_folder_name for built packages."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment