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?

  • 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 '18 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 '18 at 0:06
  • My apologies. Seem to have a recurring problem with LXDE and LMDE... – user8779 Feb 11 '18 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 '18 at 17:42
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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.