Download the .debs from a package
Good links:
https://help.ubuntu.com/community/AptGet/Howto
http://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html
http://www.cyberciti.biz/howto/question/linux/apt-get-cheat-sheet.php
WAY1: For new apt 0.8 and newer we have have “apt-get download”
List your version
apt-get
OUTPUT FOR ME: 0.9.7.8
cd /tmp
mkdir downloaded
cd downloaded
To download the gddescue deb
apt-get download gddrescue
apt-get download –print-uris gddrescue
the printuris method doesn’t download the program just give you the url(or uri of the location)
to verify the download is good
NOTE: for both I say gddrescue.deb but the actual file name is longer gddrescue_1.16-1_armel.deb
dpkg –contents gddrescue.deb
dpkg –info gddrescue
if the package was bad both of those would return errors
WAY2: Before apt 0.8
List the repository url (can see every from cat /etc/apt/sources.list)
To get the front part of the url/uri
apt-cache policy gddrescue
OUTPUT: trimmed most of the lines out “500 http://mirrors.kernel.org/debian/ wheezy/main armel Packages”
Note if several repositories are listed with their URLs the system default(the one that will be used by apt-get install) is the one with **** infront
To get the back part of the url/uri
apt-cache show gddrescue
OUTPUT: trimmed most of the lines out “Filename: pool/main/g/gddrescue/gddrescue_1.16-1_armel.deb”
To get the url, append the filename portion to the repository line:http://mirrors.kernel.org/debian/pool/main/g/gddrescue/gddrescue_1.16-1_armel.deb
to download
wget http://mirrors.kernel.org/debian/pool/main/g/gddrescue/gddrescue_1.16-1_armel.deb
Note for a https url, wget needs to verify the cert but cant it will ask you to put the –no-check-certificate option in between wget and the https url
That should of downloaded the file to verify the download is good
dpkg –contents gddrescue.deb
dpkg –info gddrescue.deb
If the package was bad both of those would return errors
To get the first dependencys
To get every immediate dependency just list all of the Dependencys directly associated to the package with –info and look for the Depends line:
dpkg –info gddrescue.deb
Or similarly if the file is not yet downloaded apt-cache show gddrescue will list them
OUTPUT: Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.4.0), libstdc++6 (>= 4.4.0)
Then repeat either method from above to download the dependencies
For example: apt-get download libc6; apt-get download libgcc1; apt-get download libstdc++6;
How to list every dependency
To see the dependency of every program and list their dependencies and so on, do this:
A program has to be downloaded
apt-get install apt-rdepends
And then run against a package like so to see every dependency
apt-rdepends gddrescue
OUTPUT:
Reading package lists… Done
Building dependency tree
Reading state information… Done
gddrescue
Depends: libc6 (>= 2.4)
Depends: libgcc1 (>= 1:4.4.0)
Depends: libstdc++6 (>= 4.4.0)
libc6
Depends: libc-bin (= 2.13-38)
Depends: libgcc1
libc-bin
libgcc1
Depends: gcc-4.7-base (= 4.7.2-5)
Depends: libc6 (>= 2.4)
PreDepends: multiarch-support
gcc-4.7-base
multiarch-support
Depends: libc6 (>= 2.3.6-2)
libstdc++6
Depends: gcc-4.7-base (= 4.7.2-5)
Depends: libc6 (>= 2.11)
Depends: libgcc1 (>= 1:4.4.0)
PreDepends: multiarch-support
DOWNLOAD EVERY DEPENDENCY: (this generates a folder with the name of the package and downloads everything into it)
Then download them one by one with either method from above… Or generate a simple script that picks out the package names like so:
Copy these 6 lines and paste them into your shell – dont forget to change the PKGNAME variable to name of the package you want to download:
PKGNAME=”gddrescue“
mkdir $PKGNAME; cd $PKGNAME;
apt-rdepends $PKGNAME | cut -d”:” -f2 | cut -d”(” -f1 >& outtemp1
tr -d ‘ ‘ < outtemp1 > outtemp2
echo “Going to download:”; cat outtemp2;
for i in `cat outtemp2`; do echo “===downloading $i====”; apt-get download $i; done; rm outtemp1 outtemp2;
ALL LIST OF URIS: (Note this doesnt generate any folders, but the results go into a results file in the current directory)
To get just the URIs/URLS use this script (Again change PKGNAME to match your needs), this might be useful if you want to download from another system:
PKGNAME=”gddrescue“
apt-rdepends $PKGNAME | cut -d”:” -f2 | cut -d”(” -f1 >& outtemp1
tr -d ‘ ‘ < outtemp1 > outtemp2
echo “Going to download:”; cat outtemp2;
for i in `cat outtemp2`; do apt-get download –print-uris $i | cut -d”‘” -f2 | tee -a results-$PKGNAME.txt; done; rm outtemp1 outtemp2;
OUTPUT IS TOO LONG TO INCLUDE.
WAY 3:
NOTE: For these I don’t use gddrescue but I use a variable $PACKAGE_NAME which can be replaced with any package name.
We will find out and dumb the .deb file from an apt-get repository into downloaded.
cd /tmp
mkdir downloaded
cd downloaded
Replace $PACKAGE_NAME with package name
Simple form: apt-get install –reinstall –print-uris -qq $PACKAGE_NAME
Sometimes this will list the dependencies as well. I would download those as well and make a note to install them before installing the actual program.
wget the file, replace $URL with the results of the above command.
wget $URL
Get the name of the downloaded file:
ls -lisah
Double check if they correct by looking into contents of the downloaded file, replace $DOWNLOADED_FILE with file that was just downloaded:
dpkg –contents $DOWNLOADED_FILE
Another Way
Found @ some online forum long time, forgot to keep the link, but many thanks to mystery person:
wget $(apt-get install –reinstall –print-uris -qq $PACKAGE_NAME | cut -d”‘” -f2 | grep “/${PACKAGE_NAME}_”)
If you dont know the package name of it run “which commandname” followed by “dpkg -S results” to get the package name
Example of output for gddrescue, the link is always within single quotes: # apt-get install –reinstall –print-uris -qq gddrescue
‘http://mirrors.kernel.org/debian/pool/main/g/gddrescue/gddrescue_1.16-1_armel.deb’ gddrescue_1.16-1_armel.deb 88676 MD5Sum:aa182fd7f1aab79a56ba4709ce8b0473