Skip to content

Instantly share code, notes, and snippets.

@SanCampos
Last active November 9, 2017 23:51
Show Gist options
  • Save SanCampos/782911bf921522a825d2f7e918bf7fd2 to your computer and use it in GitHub Desktop.
Save SanCampos/782911bf921522a825d2f7e918bf7fd2 to your computer and use it in GitHub Desktop.
A script that automates package installations pulled with git (Usable for the AUR)
#!/bin/bash
# A script that automates package installations pulled with git
#Check if git url is present, exit if not
if ! [[ $1 =~ .+\/.+\.git ]]
then
echo -e "fatal: You must specift a git repository\n"
echo "usage: git-script.sh <git-url>"
exit
fi
#Fetch directory name from git clone url
GIT_CLONE_FILE=$(echo $1 | grep -Po "(?!.+\/)(?!\/).+")
#Remove .git extension
DIRECTORY_NAME=${GIT_CLONE_FILE::-4}
BUILD_DIRECTORY="$HOME/Builds"
FULL_DIRECTORY="$BUILD_DIRECTORY/$DIRECTORY_NAME"
#Go to said folder and clone git repo there
mkdir -p $BUILD_DIRECTORY
cd $BUILD_DIRECTORY
if ! sudo git clone $1
then
echo -e "fatal: git clone failed. Please check if git repo is valid"
exit
fi
#Set permission to makepkg
sudo chown $USER $FULL_DIRECTORY
#Build it boyo
cd $FULL_DIRECTORY
makepkg -si
@SanCampos
Copy link
Author

Usage: sudo bash git-build.sh <git-url>

Example: sudo bash git-build.sh https://aur.archlinux.org/android-studio.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment