3

Currently I am running Wheezy 32-bit, and recently I installed FreeSWITCH from the official repos. However, I realized that for the purpose I had in mind, I needed to rebuild FreeSWITCH myself, from source, which is somewhat newer than the binary release no. installed.

Just to be sure that I can reinstall/reuse the FreeSWITCH binaries from official repos at a later date, without having to fetch the package .deb files again (which took quite a while on my slow connection) — I wanted to thus uninstall, while keeping the package files in apt cache. How can I achieve this ?

Also, the FreeSWITCH package installation was done using a meta-package (i.e. “freeswitch-meta-vanilla”) which pulled in all the other FreeSWITCH package. Would I need to perform this uninstall differently ?

6
  • Note that this is cross-post (other one being in ask.debian.net). Hopefully, that is acceptable, as these are 2 unrelated websites. Decided to post here because I sensed much higher traffic and members here.
    – jay
    Commented Aug 22, 2013 at 2:48
  • jay - it's generally not acceptable to cross post on the various SE sites.
    – slm
    Commented Aug 22, 2013 at 3:22
  • cross post: ask.debian.net/questions/…
    – slm
    Commented Aug 22, 2013 at 3:24
  • @slm, thanks for commenting. I was aware of the no x-post thing on SE, but AFAIK, ask.debian.net is not an SE site. It just has a similar format, and I think has significantly lower traffic, thus slow to get answers on. Let me know if that sounds like an acceptable explanation.
    – jay
    Commented Aug 22, 2013 at 3:25
  • And as you can see, I did own-up and admit upfront that it was a cross-post ! :)
    – jay
    Commented Aug 22, 2013 at 3:26

2 Answers 2

2

I found this thread on the ubuntuforums titled: HOWTO: Make and restore apt cache backups.

apt's cache

When you install .deb files on Ubuntu/Debian they get stored in the following directory, /var/cache/apt/archives/. So you can copy them out of here at anytime if you want to keep them safe somewhere else. The files should be called FreeSWITCH*.deb.

dpkg-repack

You can also make use of a tool called dpkg-repack which will take an existing installed package and repackage it back into a .deb file.

dpkg-repack creates a .deb file out of a debian package that has already been installed. If any changes have been made to the package while it was unpacked (ie, files in /etc were modified), the new package will inherit the changes.

This utility can make it easy to copy packages from one computer to another, or to recreate packages that are installed on your system, but no longer available elsewhere, or to store the current state of a package before you upgrade it.

It can be installed like so, apt-get install dpkg-repack.

NOTE: When repackaging packages, the resulting .deb files will include any configuration files as they are on the system where the repackaging is being done, not the pristine versions of the config files that were originally included!

Example

Say I want to repackage the already installed bzip2 application.

$ sudo dpkg -l|grep bzip2
ii  bzip2                                     1.0.6-4                                   amd64        high-quality block-sorting file compressor - utilities

The following command will package it:

$ sudo dpkg-repack bzip2
dpkg-deb: warning: './dpkg-repack-16687/DEBIAN/control' contains user-defined field 'Original-Maintainer'
dpkg-deb: warning: ignoring 1 warning about the control file(s)

dpkg-deb: building package `bzip2' in `./bzip2_1.0.6-4_amd64.deb'.

You can confirm the contents of the .deb file like so:

$ sudo dpkg -c bzip2_1.0.6-4_amd64.deb |head -15
drwxr-xr-x root/root         0 2013-08-22 00:08 ./
drwxr-xr-x root/root         0 2013-08-22 00:08 ./bin/
-rwxr-xr-x root/root     31152 2012-08-03 12:30 ./bin/bunzip2
-rwxr-xr-x root/root      2140 2012-08-03 12:30 ./bin/bzdiff
-rwxr-xr-x root/root      4877 2012-08-03 12:30 ./bin/bzexe
-rwxr-xr-x root/root      3642 2012-08-03 12:30 ./bin/bzgrep
-rwxr-xr-x root/root     31152 2012-08-03 12:30 ./bin/bzcat
-rwxr-xr-x root/root     10376 2012-08-03 12:30 ./bin/bzip2recover
-rwxr-xr-x root/root      1297 2012-08-03 12:30 ./bin/bzmore
-rwxr-xr-x root/root     31152 2012-08-03 12:30 ./bin/bzip2
drwxr-xr-x root/root         0 2013-08-22 00:08 ./usr/
drwxr-xr-x root/root         0 2013-08-22 00:08 ./usr/share/
drwxr-xr-x root/root         0 2013-08-22 00:08 ./usr/share/man/
drwxr-xr-x root/root         0 2013-08-22 00:08 ./usr/share/man/man1/
-rw-r--r-- root/root      1873 2012-08-03 12:30 ./usr/share/man/man1/bzmore.1.gz
...
...
3
  • Excellent. Just what I needed. Thanks. Don't have enough reps to vote-up, but I am accepting this answer.
    – jay
    Commented Aug 22, 2013 at 4:59
  • @jay - glad it helped you out, thanks for the question.
    – slm
    Commented Aug 22, 2013 at 5:07
  • Move or hardlink, no need to copy. Everything that uses the cache just reads the directory listing. You can even share it with NFS: unix.stackexchange.com/questions/22024/… Commented Feb 4, 2015 at 2:50
1

Just uninstall with apt-get remove or whatever. This doesn't delete the downloaded files. The downloaded files are only removed if you run apt-get clean, use the “clean” command in aptitude, or do something similar in your package management tool.

If you want to be sure not to accidentally remove the packages, make a copy in another directory. You can inject the packages back into the download cache simply by copying the .deb files back.

4
  • Thanks @Gilles. I'd have loved to vote this one up, since it is so precise, to the point and relevant. Will upvote once I earn enough reputation. However, I wonder if I can just take the *.deb files from the apt cache on one server, place it in the apt cache of another server (same architecture, same Debian release), and expect to be able to use that cache to install files on this other server ? Would any intermediate steps are needed ?
    – jay
    Commented Aug 23, 2013 at 6:00
  • @jay Yes, that will work. There are even tools to automate that, such as apt-zip. The apt cache consists of whatever is in /var/cache/dpkg/apt, there's no other database to update if you want to add or remove something from the cache. Commented Aug 23, 2013 at 6:58
  • Excellent. "No other database of update" says it all.
    – jay
    Commented Aug 26, 2013 at 4:53
  • Or just dpkg -i the .deb files from wherever. (Then run aptitude if they need some dependencies to finish installing.) Commented Feb 4, 2015 at 2:52

This site is temporarily in read-only mode and not accepting new answers.

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