Last active
November 9, 2017 23:51
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
sudo bash git-build.sh <git-url>
Example:
sudo bash git-build.sh https://aur.archlinux.org/android-studio.git