1

I used the next script from askububtu to automate the download of all installed packages in a fresh debian 9.3 LXDE installation.

From here:

#!/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?

4
  • Debian Tag: Questions specific to the Debian official distribution (stable, testing, or unstable); if you are using a derivative of Debian (e.g. Mint, Ubuntu, Kali, etc), then use that distribution’s tag instead. Not Debian then...
    – user8779
    Feb 10, 2018 at 23:55
  • @arochester I am using Debian... If you read the post this is clear... I just found that script on askubuntu and supposes that if it works for ubuntu will work for me too (on my Debian LXDE 9.3)...
    – koleygr
    Feb 11, 2018 at 0:06
  • My apologies. Seem to have a recurring problem with LXDE and LMDE...
    – user8779
    Feb 11, 2018 at 17:19
  • @arochester... No problem, It was an opportunity for me to learn about LMDE too :) (Even if a debian user has almost never a reason to move away of debian)
    – koleygr
    Feb 11, 2018 at 17:42

1 Answer 1

2

There’s a fundamental problem with the script you’re using: it’s based on binary packages, not source packages. That’s why you’re downloading the LibreOffice source multiple times: there are many binary packages built from the same source package...

Another problem is that you don’t have dpkg-source installed, so the source packages can’t be extracted.

I would use something like this instead:

#!/bin/bash
dpkg-query -f '${Source}\n' -W | cut -d\  -f1 | sort -u | while read package
do
    mkdir $package
    pushd $package
    apt-get -q source $package
    popd
done

If you don’t want to extract the source, add -d to the apt-get line, that will avoid the dpkg-source errors.

2
  • Thankd @Stephen... I will test it and come back to accept it and to upvote...
    – koleygr
    Feb 10, 2018 at 20:42
  • perfect! Thanks again! I will link your answer as a comment in askubuntu too (Is it ok?)
    – koleygr
    Feb 10, 2018 at 20:50

You must log in to answer this question.

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