I used the next script from askububtu to automate the download of all installed packages in a fresh debian 9.3 LXDE installation.
#!/bin/bash
dpkg --get-selections | while read line
do
package=`echo $line | awk '{print $1}'`
mkdir $package
cd $package
apt-get -q source $package
cd ..
done
My problem is that I get some errors and it downloads a similar but not the wanted package:
sh: 1: dpkg-source: not found W: Download is performed unsandboxed as root as file 'libreoffice_5.2.7-1.dsc' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied) E: Unpack command 'dpkg-source --no-check -x libreoffice_5.2.7-1.dsc' failed. Reading package lists... Picking 'libreoffice' as source package instead of 'libreoffice-calc'
You can imagine that it downloads 300MB or so every 3-4 minutes (libreoffice) for many times (for almost every dependency of libreoffice)...
Does anyone has a better suggestion than that script to automate the source download of the packages used on my system?