6

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?

1 Answer 1

8
  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>
2
  • It doesn't download the history :c E.g. I stumbled upon a packaging bug (apparently i3-wm archlinux packagers included some broken patch), so I need to bisect it to make sure it's the patch that causes the problem. But git logfatal: not a git repository (or any of the parent directories): 🤷‍♂️
    – Hi-Angel
    Feb 15, 2023 at 8:14
  • Oh, I found in docs for asp: turns out using checkout (as in asp checkout i3-wm) fixes that. The files will be located under the repos/ dir.
    – Hi-Angel
    Feb 15, 2023 at 8:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .