Skip to content

Instantly share code, notes, and snippets.

@alenbasic
Last active October 19, 2015 22:16
Show Gist options
  • Save alenbasic/b3e6a2c600abc1be70ed to your computer and use it in GitHub Desktop.
Save alenbasic/b3e6a2c600abc1be70ed to your computer and use it in GitHub Desktop.
A simple AUR helper script. It moves and extracts a snapshot downloaded from the AUR to a build directory, allows you to compile it and when done moves the binary package to a bin folder and deletes the downloaded files
#!/bin/bash
# run this by sourcing it, i.e. "source aur -x" or ". aur -r"
# you can make it easier on yourself by making a alias
# for example, alias aurhelper="source /path/to/aurhelper.sh"
src_dir="/home/user/aur_packages/src/" # change these to whatever you'd like
bin_dir="/home/user/aur_packages/bin"
case "$1" in
-r)
echo "moving binary to $bin_dir"
mv -v *pkg.tar.xz "$bin_dir"
echo "moving to $aur_source_dir and removing $aur_package_dir directory and files..."
cd $aur_source_dir
remove_this_dir=$(echo $aur_package_dir)
rm -rf $remove_this_dir
unset aur_source_dir
unset aur_package_dir
echo "all files have been removed and temp variables unset"
;;
-x)
full_package_name="$2"
export aur_source_dir="$src_dir"
echo "moving and extracting files..."
mv "$full_package_name" "$aur_source_dir"
cd "$aur_source_dir"
file_list=$(tar -axvf $(basename "$full_package_name"))
rm "$(basename "$full_package_name")"
created_dir=$(echo $file_list | cut -f1 -d"/")
export aur_package_dir="$created_dir"
cd $aur_package_dir
echo "...and have gone into $(pwd)"
;;
*)
printf "AUR Helper Script\n\n"
echo "Options:"
echo " -x extracts the source file and then moves into the extracted directory"
printf " -r exits out of the directory and removes it and all its files\n\n"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment