Question

I am using Arch Linux. I want to do the same thing like apt-get source coreutils; is it possible to download sources with Pacman? I didn't find a solution in the man pages.

How can I get the source code of a package?

Was it helpful?

Solution


2018 Update:

The abs tool described below has been deprecated and it along with its rsync endpoint have been dropped since mid 2017.

The asp tool now provides similar functionality. More information here.


As already mentioned you can use the ABS (Arch Build System):

Install it using pacman:

sudo pacman -S base-devel abs

First, download the ABS tree:

sudo abs

Then, get a specific package:

sudo abs [package_name]

Then copy the package, whose source you want to have, from the local abs tree (e.g. /var/abs/core/findutils) to another directory, e.g. /home/blabla/abs

Then run makepkg:

  • if you only want to get the sources and don't want to build the package you can run makepkg -od

  • otherwise run makepkg -s, which will then handle all the package's dependencies automatically

  • watch out becaouse makepkg will overwrite your modifications, use makepkg -e to build your local sources instead

If you want to install the package you've built, run

pacman -U name-of-package.xz

OTHER TIPS

  1. pacman -S asp
  2. say if you want the source code of the Linux command find

    1. find out which package the command find belongs to: pacman -Qo $(which find). The result is "/usr/bin/find is owned by findutils 4.4.2-3".
  3. asp export findutils

  4. cd findutils
    makepkg -o
    

Now you have your source code.

Edit: This answer is outdated due to changes on ABS.

You get the package sources from the Arch Linux SVN repository, called ABS.

First find the package online: http://www.archlinux.org/packages/?q=coreutils

Then, on the package details page, on the right side use the SVN links, e.g.: http://repos.archlinux.org/wsvn/packages/coreutils/trunk/

And there, you have a sweet "Download" button, in this case it leads to: http://repos.archlinux.org/wsvn/packages/coreutils/trunk/?op=dl&isdir=1

It is a little bit more complicated than apt-get source. But perhaps you find a tool on AUR that does the job for you, for example yaourt supports building from sources and exporting them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top