Skip to content

Instantly share code, notes, and snippets.

@Rachniotov
Created October 27, 2021 04:41
Show Gist options
  • Save Rachniotov/615e48f525680dd31ae5206ec44d6c3b to your computer and use it in GitHub Desktop.
Save Rachniotov/615e48f525680dd31ae5206ec44d6c3b to your computer and use it in GitHub Desktop.
Automate AUR package installation without another package!

How to

  1. Make a new aur-install.sh file
  2. Paste the following code into the file
    #!/bin/bash
    
    if [ -z "$1" ]
    then
        echo "=================================================="
        echo "specify a package to install duhh"
        echo "=================================================="
        exit 1
    else
        if ! git clone "https://aur.archlinux.org/$1.git"
        then
            echo "=================================================="
            echo "FATAL: No such pacakge found on aur"
            echo "=================================================="
            exit 1
        else
            echo "=================================================="
            echo "Starting package build"
            echo "=================================================="
            cd $1
            if ! makepkg -si
            then
                echo "=================================================="
                echo "FATAL: Could not build the package, removing directory..."
                echo "=================================================="
                cd ..
                if ! rm -rf $1
                then
                    echo "=================================================="
                    echo "ERROR: Could not delete the source directory, you can delete it yourself tho"
                    echo "=================================================="
                    exit 1
                else
                    echo "=================================================="
                    echo "successfully removed dir $1"
                    echo "=================================================="
                    exit 0
                fi
                exit 1
            else
                echo "=================================================="
                echo "Sucessfully built package! Removing src directory"
                echo "=================================================="
                cd ..
                if ! rm -rf $1
                then
                    echo "=================================================="
                    echo "ERROR: Could not delete the source directory, you can delete it yourself tho"
                    echo "=================================================="
                    exit 1
                else
                    echo "=================================================="
                    echo "successfully installed $1!!"
                    echo "=================================================="
                    exit 0
                fi
            fi
        fi
    fi
  3. Open up a terminal and run chmod x+a aur-install.sh
  4. for installing a package, run ./aur-install.sh <packagename>

For making it an actual command, add a new alias in your .bashrc : alias aur-install="/path/to/aur-install"

@p0ryae
Copy link

p0ryae commented Oct 29, 2021

This is smart.

How about adding this to AUR and then making it run using a command instead of linking it to a file??

Will be more easier and cleaner!

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