Get Source for Arch Linux Package?

1

In Debian based distributions you can run apt-get source <package_name> to fetch the source code for a package. What is the equivalent for pacman on Arch Linux?

Drew Chapin

Posted 2018-08-18T22:27:57.923

Reputation: 4 839

Answers

3

  1. Install the Arch Build Source Management Tool (i.e. the asp command, formerly abs).

    sudo pacman -S asp
    
  2. Download the PKGBUILD

    asp export <package_name>
    
  3. Download the PKGBUILD source files

    cd <package_name>
    makepkg -do
    

    -d, --nodeps
    Do not perform any dependency checks. This will let you override and ignore any dependencies required. There is a good chance this option will break the build process if all of the dependencies are not installed.

    -o, --nobuild
    Download and extract files, run the prepare() function, but do not build them. Useful with the --noextract option if you wish to tweak the files in $srcdir/ before building.

    You may need to add --skippgpcheck if you get this error

    ==> ERROR: One or more PGP signatures could not be verified!

  4. Source will be be in src sub-directory.


If you find that you're doing this frequently, you could add a function to your ~/.bashrc or ~/.bash_profile

function get-source()
{
    asp export $1 && \
    pushd $1 && \
    makepkg -do --skippgpcheck && \
    pushd src
}

Then you can just run

get-source <package_name>

Drew Chapin

Posted 2018-08-18T22:27:57.923

Reputation: 4 839