Archive

Posts Tagged ‘apt’

Debian/Ubuntu: replicar lista de paquetes a otra máquina

October 4, 2013 2 comments

Si alguna vez compraste una nueva máquina y quisiste instalar la lista de programas instalados en tu anterior, sin tener una técnica especial para hacerlo, entenderás porque me interesa mucho esta técnica en Ubuntu para automatizar el proceso…

Primero, en nuestra máquina “antigua”, usamos apt-get para generar una lista de todos los paquetes instalados en un archivo llamado paquetes.txt:

dpkg --get-selections | grep -v deinstall > paquetes.txt

Después, en la nueva máquina, actualizamos la lista de fuentes de paquetes y usamos apt-get para instalar desde nuestro archivo (que podemos copiar por un comando scp o simplemente enviárselo por correo):

apt-get update
dpkg --set-selections < paquetes.txt
apt-get -u dselect-upgrade

Y ya está! Solo hay que dejarlo descargar.

Si, además, quieres recuperar todo lo que tenías de personal en la otra máquina, puedes también copiar tu carpeta home con el siguiente comando desde la nueva máquina:

cd; rsync -avz usuario@maquina-anterior:/home/usuario/ .

Para que funcione sin problema, vale mejor guardar el mismo nombre de usuario que usabas en la máquina anterior. Sino podría generar problemas de permisos.
Se recomienda primero recuperar la carpeta de usuarios y *después* instalar los paquetes. Así, la instalación tomará en cuenta los posibles parámetros importantes al momento de arrancar estas aplicaciones.

Packaging applications for Debian

December 1, 2005 Leave a comment
This article was first written in December 2005 for the BeezNest technical
website (http://glasnost.beeznest.org/articles/313).

To do the best use of Debian’s superior package management system (APT), the application must be packaged, in the form of one or several .deb files. Packaging has many, many advantages, you just couldn’t believe.

As Debian is all about Free Software, it is clear that the preferred source for a package be the upstream source package. That way, submitting patches upstream is as simple as possible as they are naturally available to the World. Anyway, even then, there are still many ways to package an application.

To achieve our goals, we often have to (re-)package or backport applications. We also often submit improvements or bugfixes to existing packages, as a continuous goal to contribute to the Free Software Community, and Debian in particular.

We packaged several programs, of which Exact, IPblocker, XAMS, AND, Configurator for GNOME (COG), MnoGoSearch, p910nd, DCL, Dokeos, Plume.

We also contributed to the well-known backports of GNOME 2.2 for Woody, OpenOffice.org for Woody, OpenOffice.org 2.0 for Sarge, and yet several others.

This rubric will tell you some of the techniques we use to do it all. We hope you’ll join us soon…

HOWTO Keep a network of Debians up-to-date

August 20, 2005 Leave a comment
This article was first written in August 2005 for the BeezNest technical
website (http://glasnost.beeznest.org/articles/289).

Due to the unrivaled apt tools, Debian is probably the easiest GNU/Linux distribution to keep up-to-date, at least when you have a fast Internet connection.

In a network of many machines, the goal is slightly different though: you probably want to take as little bandwidth as possible away from users.

cron-apt

The first part of the solution, and the easiest to setup, is to install package cron-apt which will download the packages early in the morning from cron, when users are not at work. No need to configure anything, it works out of the box to do the equivalent of an (apt-get) update and download the packages, without installing anything for you. You keep control. You can configure it to make it install some or all updates if you want.

apt-proxy

The second part is to setup a proxy specialized in getting Debian packages for you, only once for all machines. This proxy is apt-proxy. The second machine requesting the same package will take only a fraction of the time needed to download it from the Internet. It will also spare your Internet connection quota, so even for a few Debian machines, it may prove useful. You only need some spare disk space on a Debian machine on your network to use it (it is also performance-hungry when working). It is slightly trickier to setup, because you need to carefully define your sources. Here is a proposed configuration for it:

[DEFAULT]
;; All times are in seconds, but you can add a suffix
;; for minutes(m), hours(h) or days(d)

;; Server IP to listen on
;address = 192.168.0.254

;; Server port to listen on
port = 9999

;; Control files (Packages/Sources/Contents) refresh rate
;;
;; Minimum time between attempts to refresh a file
min_refresh_delay = 1h

;; Minimum age of a file before attempting an update (NOT YET IMPLEMENTED)
;min_age = 23h

;; Uncomment to make apt-proxy continue downloading even if all
;; clients disconnect.  This is probably not a good idea on a
;; dial up line.
;; complete_clientless_downloads = 1
complete_clientless_downloads = 1

;; Debugging settings.
;; for all debug information use this:
;; debug = all:9
debug = all:4 db:0

;; Debugging remote python console
;; Do not enable in an untrusted environment
;telnet_port = 9998
;telnet_user = apt-proxy
;telnet_password = secret

;; Network timeout when retrieving from backend servers
timeout = 15

;; Cache directory for apt-proxy
cache_dir = /var/cache/apt-proxy

;; Use passive FTP? (default=on)
;passive_ftp = on

;; Use HTTP proxy?
;http_proxy = host:port

;; Enable HTTP pipelining within apt-proxy (for test purposes)
;disable_pipelining=0

;;--------------------------------------------------------------
;; Cache housekeeping

;; Time to perform periodic housekeeping:
;;  - delete files that have not been accessed in max_age
;;  - scan cache directories and update internal tables
cleanup_freq = 1d

;; Maximum age of files before deletion from the cache (seconds)
max_age = 120d

;; Maximum number of versions of a .deb to keep per distribution
max_versions = 3

;; Add HTTP backends dynamicaly if not already defined? (default=on)
;dynamic_backends = on

;;---------------------------------------------------------------
;;---------------------------------------------------------------
;; Backend servers
;;
;; Place each server in its own [section]

[debian]
;; The main Debian archive
;; You can override the default timeout like this:
;timeout = 30

;; Rsync server used to rsync the Packages file (NOT YET IMPLEMENTED)
;;rsyncpackages = rsync://ftp.de.debian.org/debian

;; Backend servers, in order of preference
backends =
        ftp://ftp.skynet.be/debian
        ftp://ftp.belnet.be/debian
        http://ftp.de.debian.org/debian
        http://ftp2.de.debian.org/debian
        ftp://ftp.uk.debian.org/debian

[debian-non-US]
;; Debian debian-non-US archive
;timeout will be the global value
backends =
        ftp://ftp.skynet.be/debian-non-US
        ftp://ftp.belnet.be/debian-non-US
        http://ftp.uk.debian.org/debian-non-US
        http://ftp.de.debian.org/debian-non-US
        ftp://ftp.uk.debian.org/debian

[security]
;; Debian security archive
backends =
        ftp://ftp.skynet.be/debian-security
        ftp://ftp.belnet.be/debian-security
        http://security.debian.org/debian-security
        http://ftp2.de.debian.org/debian-security

;[apt-proxy]
;; Apt-proxy new versions
;backends = http://apt-proxy.sourceforge.net/apt-proxy

;[backports.org]
;; backports.org
;backends = http://backports.org/debian

[blackdown]
;; Blackdown Java
backends =
;       ftp://ftp.easynet.be/blackdown/debian
;       http://ftp.gwdg.de/pub/languages/java/linux/debian
        ftp://ftp.tux.org/java/debian/

;[debian-people]
;; people.debian.org
;backends = http://people.debian.org

;[emdebian]
;; The Emdebian project
;backends = http://emdebian.sourceforge.net/emdebian

;[rsync]
;; An example using an rsync server.  This is not recommended
;; unless http is not available, because rsync is only more
;; efficient for transferring uncompressed files and puts much
;; more overhead on the server.  See the rsyncpackages parameter
;; for a way of rsyncing just the Packages files.
;backends = rsync://ftp.uk.debian.org/debian

[java]
backends =
        ftp://ftp2.skynet.be/pub/ftp.blackdown.org/debian

[multimedia]
backends =
        ftp://ftp.nerim.net/debian-marillat

[bxlug]
backends =
        http://apt.bxlug.be/

An example matching sources.list file for Sarge would be:

# See sources.list(5) for more information, especialy
# Remember that you can only use http, ftp or file URIs
# CDROMs are managed through the apt-cdrom tool.

# Standard Debian sources (with contrib and non-free)
deb http://apt-proxy:9999/debian/ sarge main contrib non-free
deb-src http://apt-proxy:9999/debian/ sarge main contrib non-free

# Debian Security updates
deb http://apt-proxy:9999/security/ sarge/updates main contrib non-free

# BxLUG sources
deb http://apt.bxlug.be/ experimental-sarge/
deb http://apt.bxlug.be/sarge/ main/
deb http://apt.bxlug.be/sarge/ contrib/
deb http://apt.bxlug.be/sarge/ non-free/
deb http://apt.bxlug.be/sarge/ not-debian/

# Multimedia stuff from Marillat
deb http://apt-proxy:9999/multimedia/ sarge main

# Java gcc-3.2
deb http://apt-proxy:9999/java/ sarge non-free

apticron

To be kept informed (by e-mail) of available updates, just install the package of that name.

Special note about web proxies

Using a general-purpose web proxy is generally a bad idea, because they are not meant to store large files. If you want to do it anyway, you just need to define the matching environment variable amongst these: HTTP_PROXY, HTTPS_PROXY, FTP_PROXY.

HOWTO Clean packages on a Debian system

July 2, 2005 3 comments
This article was first written in July 2005 for the BeezNest technical
website (http://glasnost.beeznest.org/articles/282).

A Debian system can take more and more disk space as you install new packages. Let’s see how we can detect which packages are no longer used (unsused/obsolete/transitional) and clean them if we are sure we don’t need them anymore.

First, it is good to know that when you use apt (apt-get, aptitude, dselect, synaptic, …) the files downloaded are stored in /var/cache/apt/archives, and never cleaned. To clean them, use the following:

  • to clean obsolete packages (packages of version which would not be installed if requested now)
$ sudo apt-get autoclean
  • to empty all /var/cache/apt/archives/*.deb
$ sudo apt-get clean

If using aptitude, it keeps a track of packages taken to fulfill dependencies to other packages, so not installed explicitely, which allows to remove packages when the package that needed it is removed.If using another apt tool, it does not keep such information, so there are probably dependencies left after a removal.

To keep track anyway of these dependencies, Debian provides the debfoster tool.

To detect such orphaned packages, Debian provides the deborphan tool.

When used without parameters, it only lists the libraries on which no package depends.

$ deborphan

I suggest using the following parameters, which list all orphaned packages, with their respective sizes (works only starting from Sarge).

$ deborphan -az

And I personally sort them to first remove the biggest ones.

$ deborphan -az | sort -n

There are lots of locales supported by Debian packages, which may take up quite a lot of disk space. The Debian tool localepurge permits to wipe the unused locales.

When upgrading from one Debian release to another, some packages maybe left without being of any use, and are pretty difficult to track. To detect them, Debian provides the apt-show-versions tool.

There are also many transitional dummy packages that exist only for the upgrade to happen smoothly. To detect them:

$ dpkg -l|grep dummy
$ dpkg -l|grep transitional
$ dpkg -l|grep obsolete

Using Debian’s superior package management system (APT)

January 9, 2005 Leave a comment
This article was first written in January 2005 for the BeezNest technical
website (http://glasnost.beeznest.org/articles/197).

The Debian GNU/Linux FAQ – Chapter 6 – Basics of the Debian package management system

Tips on working with Packaging Commands on Debian Linux

Debian package management, distributions and the /etc/apt/sources.list file

Creating custom kernels with Debian’s kernel-package system

Debian’s APT is probably the best packaging system available today. The last relevant drawback, packages signing, has been fixed recently, and will be part of Etch and following.

In the meanwhile, let’s try to approach the «Beast».

APT is «just» a set of frontends to the underlying dpkg

So, some of the manipulations done using APT may benefit of using dpkg directly instead. For example, manipulating an already installed package or a package which is already available on the local filesystem.

APT is a set of tools including, but not limited to: apt-get, apt-cache and aptitude. Their main role is to search and retrieve packages and their dependencies and pass them to dpkg. Their configuration files are stored in /etc/apt/ on your favorite OS.

The sources of the packages are listed in /etc/apt/sources.list, which is therefore mandatory.

Using apt is pretty simple, once you get some basic rules: Use apt-get for retrieving (downloading or copying from a CD or other supported media), installing and removing packages. Use apt-cache for information about packages, like their existence or not in Debian, their names, descriptions, version numbers available, … Use aptitude for enhanced features over apt-get, which it basically builds upon.

But let’s see in practise

Searching a package based on keywords in the name or description of the package:

$ apt-cache search keyword1 keyword2

Check the package version available (from sources in sources.list)

$ apt-cache policy package_name

Show more information about the same package [1

]

$ apt-cache show package_name

Install it and all of its dependencies

$ sudo apt-get install package_name

[1] the same for a package already installed would be dpkg -l package_name

Categories: English, OSS Solutions, Tech Crunch Tags: ,
%d bloggers like this: