4

I have developed a script that needs to download the source code of some Ubuntu packages installed. In order to do that I do the following:

  1. give dpkg --get-selections to have the list of packages installed;
  2. for each package I do dpkg -s <package name> in order to grep the Version.
  3. Once I have package name and version I simply do the following: apt-get source <package name>=<package version> to download the code

The problem is that this works 95% of time because there are situation in which it didn't work. Usually the problem is the version. For example, if I have:

apt-get source host=1:9.9.5.dfsg-3ubuntu0.5
apt-get source p7zip-full=9.20.1~dfsg.1-4+deb7u1build0.14.04.1

it didn't work. I need to do something like this:

apt-get source host=1:9.9.5.dfsg
apt-get source p7zip-full=9.20.1~dfsg.1-4+deb

and there are others. In general, I am unable to find a way to get a version <version> that when I give the command:

apt-get source <package name>=<version>

it works 100% of time. Do someone of you know how to address this issue?

muru
  • 197,895
  • 55
  • 485
  • 740
  • It would be easier to answer your question if you focused just on one package/version, and give the command you ran that didn't work and the output from that command. As it is, I've put a general answer up, but it might not be your specific problem. :) – dpb Feb 18 '18 at 20:20

1 Answers1

1

Without more data, I suspect that the package has been upgraded since the time when you collected your list. The archives do not keep complete sources for all versions ever published.

Mostly (ignoring some timing concerns), they just keep the latest versions ("trusty-updates", "xenial-updates", etc), and the original version for each release in the release pocket ("trusty", "xenial", etc). This is what the apt-get source command references.

Now, not all hope is lost. Look at this answer. If you look at (for example), the acpi package and click on 'view full publishing history' in the upper right corner, you will see that Launchpad keeps everything it has published. So, you can find older versions in this way, and even look into the launchpad API to see if that data can be accessed in a programmatic way.

dpb
  • 7,069