4

I am trying to download some packages for an offline installation using apt-get download but for some reason, apt-rdepends includes packages that don't exist. This is the command I am using:

apt-get download $(apt-rdepends libboost1.55-all-dev | grep -v "^ ")

This is the output I get:

E: Can't select candidate version from package libstdc++-dev as it has no candidate
E: Can't select candidate version from package debconf-2.0 as it has no candidate
E: Can't select candidate version from package libc-dev as it has no candidate
E: Can't select candidate version from package python-celementtree as it has no candidate
E: Can't select candidate version from package python-elementtree as it has no candidate

But apt keeps complaining that there are packages without candidates. I want to ignore those errors and download the packages and their dependencies anyway. I cannot seem to find a flag that will let me ignore the apt-get errors. How do I do this?

4

Since apt-rdepends doesn't provide a way to ignore packages, a wrapper is necessary to remove packages that can't be satisfied from the download list. A relatively portable way to automate this without having to first install an interpreter like Perl/Python is to use the BASH script below.

getdepends.sh:

 #!/bin/bash
 export MAXPARAMETERS=255

 function array_contains_find_index() {
     local n=$#
     local i=0
     local value=${!n}

     for (( i=1; i < n; i++ )) {
         if [ "${!i}" == "${value}" ]; then
             echo "REMOVING $i: ${!i} = ${value}"
             return $i
         fi
     }
     return $MAXPARAMETERS
 }

 LIST=( $( apt-rdepends $1 | grep -v "^ " ) )
 echo ${LIST[*]}
 read -n1 -r -p "... Packages that will be downloaded (Continue or CTRL+C) ..."

 RESULTS=( $( apt-get download ${LIST[*]} |& cut -d' ' -f 8 ) )
 LISTLEN=${#LIST[@]}

 while [ ${#RESULTS[@]} -gt 0 ]; do
     for (( i=0; i < $LISTLEN; i++ )); do
         array_contains_find_index ${RESULTS[@]} ${LIST[$i]}
         ret=$?

         if (( $ret != $MAXPARAMETERS )); then
             unset LIST[$i]
         fi
     done

     FULLRESULTS=$( apt-get download ${LIST[*]} 2>&1  )
     RESULTS=( $( echo $FULLRESULTS |& cut -d' ' -f 11 | sed -r "s/'(.*?):(.*$)/\1/g" ) )
 done

 apt-get download ${LIST[*]}

To run the script:

 ./getdepends.sh [package name]

A commented version I wrote with more logging functionality is available on pastebin here:

http://pastebin.com/kj2evSt7

1

I just faced a similar issue with linux-image-4.13.0-16-generic on artful: apt-get download $(apt-rdepends linux-image-4.13.0-16-generic | grep -v "^ ") complains that there's no debconf-2.0. You can find out what packages provide that: https://packages.ubuntu.com/artful/debconf-2.0. For example it is provided by debconf package. Then you can fix the above with:

apt-get download $(apt-rdepends linux-image-4.13.0-16-generic | grep -v "^ " | sed 's/debconf-2.0/debconf/g')

This worked for me.

0

May be this procedure will work for you. But OSes on both source and target computers should be the same as much as possible.

1) Create somewhere on your source computer temporary folder for downloaded files and enter into it:

source_comp# mkdir libboost
source_comp# cd libboost

2) Get a list of http addresses for packages needed to install it:

source_comp# apt-get -y --print-uris install libboost1.55-all-dev | grep "'" | cut -f1 -d' ' | tr -d "'" > packet-list.txt

4) Get a list of additional packages needed to build it:

source_comp# apt-get -s build-dep libboost1.55-all-dev | grep "^ " > build-dep.txt

5) Get a list of http addresses for these packages:

source_comp# apt-get -y --print-uris install `cat build-dep.txt` | cut -f1 -d' ' | tr -d "'" | sort | uniq > build-dep-urls.txt

6) Download all packages

source_comp# wget --input-file packet-list.txt
source_comp# wget --input-file build-dep-urls.txt

7) Copy all your deb files from this folder on the source computer to the default folder for apt archives on the target computer (using scp, for example):

target_comp# scp user@source_comp:/path_to_libboost/*.deb /var/cache/apt/archives/

and update local cache repository ignoring warnings and errors:

target_comp# apt-get update

8) Now you need to install all infrastructure for building a packet:

target_comp# apt-get build-dep libboost1.55-all-dev

9) And finally the packet itself:

target_comp# apt-get install libboost1.55-all-dev

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.