APT: Installazione e uso

APT (Advanced Packaging Tool) è un tool che permette di eseguire operazioni avanzate sulla gestione dei package da installare, upgradare o da rimuovere.
Nato dal team di Debian, viene installato di default nella suddetta distribuzione ma può essere utilizzato anche in altre distribuzioni come RedHat tramite un porting di nome apt-rpm.

Le differenze fra APT adottato dalle distribuzioni rpm compatibili e quello originale di Debian per i pacchetti .deb sono minime ed in entrambi i casi risulta essere una valida alternativa a tools come rpmfind o up2date per l'handling dei package di un sistema.
Di seguito è riportato un mini how-to sull'uso di apt con un confronto fra la distribuzione originale e il porting:

Installazione
REDHAT:
Installazione  da RPM per RedHat...
[root@pluto root]# rpm -ihv apt-0.5.4cnc9-fr1.i386.rpm
warning: apt-0.5.4cnc9-fr1.i386.rpm: V3 DSA signature: NOKEY, key ID e42d547b
Preparing...                ########################################### [100%]
   1:apt                    ########################################### [100%]
[root@pluto root]# rpm -ihv apt-devel-0.5.4cnc9-fr1.i386.rpm
warning: apt-devel-0.5.4cnc9-fr1.i386.rpm: V3 DSA signature: NOKEY, key ID e42d547b
Preparing...                ########################################### [100%]
   1:apt-devel              ########################################### [100%]

[root@pluto root]# rpm -qil apt
[...]
File di configurazione
/etc/apt
/etc/apt/apt.conf
/etc/apt/preferences
/etc/apt/rpmpriorities
/etc/apt/sources.list
/etc/apt/vendors.list
Binari
/usr/bin/apt-cache
/usr/bin/apt-cdrom
/usr/bin/apt-config
/usr/bin/apt-extracttemplates
/usr/bin/apt-get
/usr/bin/apt-sortpkgs
/usr/bin/genbasedir
/usr/bin/genpkglist
/usr/bin/gensrclist
Librerie...
/usr/lib/apt
/usr/lib/apt/methods
/usr/lib/apt/methods/bzip2
/usr/lib/apt/methods/cdrom
/usr/lib/apt/methods/copy
/usr/lib/apt/methods/file
/usr/lib/apt/methods/ftp
/usr/lib/apt/methods/gpg
/usr/lib/apt/methods/gzip
/usr/lib/apt/methods/http
/usr/lib/apt/methods/rsh
/usr/lib/apt/methods/ssh
/usr/lib/libapt-inst-libc6.3-5.so.1.0
/usr/lib/libapt-inst-libc6.3-5.so.1.0.0
/usr/lib/libapt-pkg-libc6.3-5.so.3.3
/usr/lib/libapt-pkg-libc6.3-5.so.3.3.0
Docs e manuali...
/usr/share/doc/apt-0.5.4cnc9
/usr/share/doc/apt-0.5.4cnc9/AUTHORS
/usr/share/doc/apt-0.5.4cnc9/AUTHORS.RPM
/usr/share/doc/apt-0.5.4cnc9/COPYING
/usr/share/doc/apt-0.5.4cnc9/COPYING.GPL
/usr/share/doc/apt-0.5.4cnc9/README.RPM
/usr/share/doc/apt-0.5.4cnc9/README.make
/usr/share/doc/apt-0.5.4cnc9/RPM-GPG-KEY
/usr/share/doc/apt-0.5.4cnc9/TODO
/usr/share/doc/apt-0.5.4cnc9/examples
/usr/share/doc/apt-0.5.4cnc9/examples/apt.conf
/usr/share/doc/apt-0.5.4cnc9/examples/configure-index
/usr/share/doc/apt-0.5.4cnc9/examples/sources.list
/usr/share/man/man5/apt.conf.5.gz
/usr/share/man/man5/apt_preferences.5.gz
/usr/share/man/man5/sources.list.5.gz
/usr/share/man/man5/vendors.list.5.gz
/usr/share/man/man8/apt-cache.8.gz
/usr/share/man/man8/apt-cdrom.8.gz
/usr/share/man/man8/apt-config.8.gz
/usr/share/man/man8/apt-get.8.gz
/usr/share/man/man8/apt.8.gz
Directory di appoggio
/var/cache/apt
/var/cache/apt/archives
/var/cache/apt/archives/partial
/var/cache/apt/genpkglist
/var/cache/apt/gensrclist
/var/state/apt
/var/state/apt/lists
/var/state/apt/lists/partial


DEBIAN:
Debian prevede l'installazione e configurazione di apt al momento dell'installazione della distribuzione, comunque di seguito è riportato un esempio di installazione di apt tramite dpkg tools.

pluto:~#dpkg -i apt_0.5.4_i386.deb apt-utils_0.5.4_i386.deb
Selecting previously deselected package apt.
(Reading database ... 6163 files and directories currently installed.)
Unpacking apt (from apt_0.5.4_i386.deb) ...
touch: creating `/var/lib/apt/lists/partial/.delete-me-later': No such file or directory
Selecting previously deselected package apt-utils.
Unpacking apt-utils (from apt-utils_0.5.4_i386.deb) ...
Setting up apt (0.5.4) ...

Setting up apt-utils (0.5.4) ...

pluto:~# dpkg -L apt
Binari
/.
/usr
/usr/bin
/usr/bin/apt-cache
/usr/bin/apt-cdrom
/usr/bin/apt-config
/usr/bin/apt-get
Librerie
/usr/lib
/usr/lib/apt
/usr/lib/apt/methods
/usr/lib/apt/methods/bzip2
/usr/lib/apt/methods/cdrom
/usr/lib/apt/methods/copy
/usr/lib/apt/methods/file
/usr/lib/apt/methods/ftp
/usr/lib/apt/methods/gzip
/usr/lib/apt/methods/http
/usr/lib/apt/methods/rsh
/usr/lib/apt/methods/ssh
/usr/lib/dpkg
/usr/lib/dpkg/methods
/usr/lib/dpkg/methods/apt
/usr/lib/dpkg/methods/apt/desc.apt
/usr/lib/dpkg/methods/apt/install
/usr/lib/dpkg/methods/apt/names
/usr/lib/dpkg/methods/apt/setup
/usr/lib/dpkg/methods/apt/update
/usr/lib/libapt-pkg-libc6.2-3-2.so.3.2.0
Docs, manuali e info
/usr/share
/usr/share/doc
/usr/share/doc/apt
/usr/share/doc/apt/guide.text.gz
/usr/share/doc/apt/changelog.gz
/usr/share/doc/apt/guide.html
/usr/share/doc/apt/guide.html/index.html
/usr/share/doc/apt/guide.html/ch1.html
/usr/share/doc/apt/guide.html/ch2.html
/usr/share/doc/apt/guide.html/ch3.html
/usr/share/doc/apt/guide.html/ch4.html
/usr/share/doc/apt/guide.html/footnotes.html
/usr/share/doc/apt/guide.it.html
/usr/share/doc/apt/guide.it.html/index.html
/usr/share/doc/apt/guide.it.html/ch1.html
/usr/share/doc/apt/guide.it.html/ch2.html
/usr/share/doc/apt/guide.it.html/ch3.html
/usr/share/doc/apt/guide.it.html/ch4.html
/usr/share/doc/apt/guide.it.html/footnotes.html
/usr/share/doc/apt/offline.html
/usr/share/doc/apt/offline.html/index.html
/usr/share/doc/apt/offline.html/ch1.html
/usr/share/doc/apt/offline.html/ch2.html
/usr/share/doc/apt/offline.html/ch3.html
/usr/share/doc/apt/copyright
/usr/share/doc/apt/.dhelp
/usr/share/doc/apt/examples
/usr/share/doc/apt/examples/apt.conf
/usr/share/doc/apt/examples/sources.list
/usr/share/doc/apt/examples/configure-index.gz
/usr/share/doc/apt/guide.it.text.gz
/usr/share/doc/apt/offline.text.gz
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/apt-get.8.gz
/usr/share/man/man8/apt-config.8.gz
/usr/share/man/man8/apt.8.gz
/usr/share/man/man8/apt-cache.8.gz
/usr/share/man/man8/apt-cdrom.8.gz
/usr/share/man/man5
/usr/share/man/man5/apt_preferences.5.gz
/usr/share/man/man5/vendors.list.5.gz
/usr/share/man/man5/apt.conf.5.gz
/usr/share/man/man5/sources.list.5.gz
File di Configurazione
/etc
/etc/apt
Directory di appoggio per il download dei file
/var
/var/cache
/var/cache/apt
/var/cache/apt/archives
/var/cache/apt/archives/partial
Directory di appoggio per lo storage di informazione riguardante i pacchetti
/var/lib
/var/lib/apt
/var/lib/apt/lists
/var/lib/apt/lists/partial
/usr/lib/libapt-pkg-libc6.2-3-2.so.3.2



Configurazione
REDHAT:
I file di configurazione principali sono:
- /etc/apt/apt.conf  modificabile sia direttamente con un editor come vi oppure tramite l'utility apt-config e contiene tutte le informazioni di carattere generale (Es: opzioni per lo scaricamento, oppure la lista di rpm a cui è permessa una molteplice installazione etc..)
- /etc/apt/sources.list che contiene gli indirizzi dei vari repository da cui scaricare i package.

Visualizzazione della configurazione di default  tramite l'utility apt-config:

[root@pluto root]# apt-config dump
APT "";
APT::Architecture "i386";
APT::Get "";
APT::Get::Download-Only "false";
APT::Get::Show-Upgraded "true";
Dir "/";
Dir::State "var/state/apt/";
Dir::State::lists "lists/";
Dir::State::cdroms "cdroms.list";
Dir::Cache "var/cache/apt/";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";
Dir::Etc "etc/apt/";
Dir::Etc::sourcelist "sources.list";
Dir::Etc::vendorlist "vendors.list";
Dir::Etc::vendorparts "vendors.list.d";
Dir::Etc::main "apt.conf";
Dir::Etc::parts "apt.conf.d";
Dir::Etc::preferences "preferences";
Dir::Bin "";
Dir::Bin::methods "/usr/lib/apt/methods";
Dir::Bin::rpm "/bin/rpm";
RPM "";
RPM::Ignore "";
RPM::Ignore:: "gpg-pubkey";
RPM::Allow-Duplicated "";
RPM::Allow-Duplicated:: "kernel";
RPM::Allow-Duplicated:: "kernel-smp";
RPM::Allow-Duplicated:: "kernel-bigmem";
RPM::Allow-Duplicated:: "kernel-BOOT";
RPM::Allow-Duplicated:: "kernel-debug";
RPM::Allow-Duplicated:: "kernel-source";
RPM::Allow-Duplicated:: "gpg-pubkey";
RPM::Allow-Duplicated:: "alsa-kernel";
RPM::Allow-Duplicated:: "alsa-kernel-smp";
RPM::Source "";
RPM::Source::Build-Command "rpmbuild --rebuild";
Acquire "";
Acquire::Retries "0";
Acquire::DistroID "Conectiva";
Acquire::CDROM "";
Acquire::CDROM::Mount "/mnt/cdrom";
Acquire::CDROM::Copy-All "true";


DEBIAN:
Le utility e i file di configurazione sono praticamente identici, tranne per alcune differenze.
Il dump della configurazione di default risulta essere più ristretta quella di debian:

pluto:/etc/apt# apt-config  dump
APT "";
APT::Architecture "i386";
Dir "/";
Dir::State "var/lib/apt/";
Dir::State::lists "lists/";
Dir::State::cdroms "cdroms.list";
Dir::State::userstatus "status.user";
Dir::State::status "/var/lib/dpkg/status";
Dir::Cache "var/cache/apt/";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";
Dir::Etc "etc/apt/";
Dir::Etc::sourcelist "sources.list";
Dir::Etc::vendorlist "vendors.list";
Dir::Etc::vendorparts "vendors.list.d";
Dir::Etc::main "apt.conf";
Dir::Etc::parts "apt.conf.d";
Dir::Etc::preferences "preferences";
Dir::Bin "";
Dir::Bin::methods "/usr/lib/apt/methods";
Dir::Bin::dpkg "/usr/bin/dpkg";
DPkg "";
DPkg::Pre-Install-Pkgs "";
DPkg::Pre-Install-Pkgs:: "/usr/sbin/dpkg-preconfigure --apt || true";

Inoltre debian mette a disposizione un tool in più per configurare apt:
apt-setup, che permette di richiamare un menu pseudo-grafico per la configurazione step-by-step come quella che si presenta l'installazione della distribuzione.
Esempio:




Esempi d'uso
Anche nell'uso le due distribuzioni si differiscono solo per pochi particolari come l'output di alcuni comandi:

Aggiornamento della cache, operazione essenziale per le interrogazioni sul db dei rpm disponibili e delle loro caratteristiche e al primo uso di apt.
[root@pluto apt]# apt-get update
Ign http://apt.freshrpms.net redhat/8.0/en/i386 release
Get:1 http://apt.freshrpms.net redhat/8.0/en/i386/os pkglist [1276kB]
Get:2 http://apt.freshrpms.net redhat/8.0/en/i386/os release [108B]                                     Get:3 http://apt.freshrpms.net redhat/8.0/en/i386/updates pkglist [295kB]                            Get:4 http://apt.freshrpms.net redhat/8.0/en/i386/updates release [113B]                             Get:5 http://apt.freshrpms.net redhat/8.0/en/i386/freshrpms pkglist [110kB]                         Get:6 http://apt.freshrpms.net redhat/8.0/en/i386/freshrpms release [125B]                          Get:7 http://apt.freshrpms.net redhat/8.0/en/i386/os srclist [152kB]                                      Get:8 http://apt.freshrpms.net redhat/8.0/en/i386/updates srclist [15.3kB]                             Get:9 http://apt.freshrpms.net redhat/8.0/en/i386/freshrpms srclist [26.7kB]                          Fetched 1875kB in 1m37s (19.2kB/s)                                                                                  Reading Package Lists... Done
Collecting File Provides... Done

Con debian:
pluto:~# pt-get update
Get:1 http://security.debian.org stable/updates/main Packages [101kB]          
Hit http://non-us.debian.org stable/non-US/main Packages                      
Hit http://non-us.debian.org stable/non-US/main Release                        
Hit http://non-us.debian.org stable/non-US/main Sources                        
Hit http://non-us.debian.org stable/non-US/main Release                        
Get:2 http://security.debian.org stable/updates/main Release [110B]            
Hit ftp://ftp2.it.debian.org stable/main Packages                              
Hit ftp://ftp2.it.debian.org stable/main Release                              
Hit ftp://ftp2.it.debian.org stable/main Sources                              
Hit ftp://ftp2.it.debian.org stable/main Release
Fetched 101kB in 15s (6737B/s)
Reading Package Lists... Done
Building Dependency Tree... Done

Ricerca di un rpm
[root@pluto apt]# apt-cache search ether
[...]
star - An archiving tool with ACL support
tar - A GNU file archiving program.
tcl - Tcl scripting language development environment
cvs - A version control system.
ethereal - Network traffic analyzer
ethereal-gnome - Red Hat Gnome integration for ethereal and ethereal-usermode

installazione di un RPM
[root@pluto apt]# apt-get install nmap
Reading Package Lists... Done
Collecting File Provides... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
  nmap
0 packages upgraded, 1 newly installed, 0 removed and 26 not upgraded.
Need to get 273kB of archives. After unpacking 866kB will be used.
Get:1 http://apt.freshrpms.net redhat/8.0/en/i386/os nmap 2:3.00-1 [273kB]
Fetched 273kB in 18s (14.6kB/s)                                                                                                            
Executing RPM (-Uvh)...
Preparing...                ########################################### [100%]
   1:nmap                   ########################################### [100%]

Installazione di pacchetti .deb
pluto:~# apt-get install  fortune-it
Reading Package Lists... Done
Building Dependency Tree... Done
E: Couldn't find package fortune-it
pluto:~# apt-get install  fortunes-it
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  fortune-mod
The following NEW packages will be installed:
  fortune-mod fortunes-it
0 packages upgraded, 2 newly installed, 0 to remove and 4  not upgraded.
Need to get 464kB of archives. After unpacking 1235kB will be used.
Do you want to continue? [Y/n] y
Get:1 ftp://ftp2.it.debian.org stable/main fortunes-it 1.51-4 [426kB]
91% [Query]                                                                                                                     11.8kB/s 3s
Get:2 ftp://ftp2.it.debian.org stable/main fortune-mod 9708-25 [38.3kB]                                                                    
Fetched 464kB in 1m13s (6302B/s)                                                                                                          
Selecting previously deselected package fortunes-it.
(Reading database ... 6253 files and directories currently installed.)
Unpacking fortunes-it (from .../fortunes-it_1.51-4_all.deb) ...
Selecting previously deselected package fortune-mod.
Unpacking fortune-mod (from .../fortune-mod_9708-25_i386.deb) ...
Setting up fortunes-it (1.51-4) ...

Il pacchetto fortunes-it ha installato un gruppo di fortunes
potenzialmente offensivi. Vuoi cancellarli? [s/N]n
The fortunes-it package is installed with the set of potentially
offensive fortunes. Do you want to remove these? [y/N] n

Setting up fortune-mod (9708-25) ...

pluto:~#


Un po di statistiche
[root@pluto apt]# apt-cache stats
Total Package Names : 7677 (307k)
  Normal Packages: 1660
  Pure Virtual Packages: 1245
  Single Virtual Packages: 4403
  Mixed Virtual Packages: 1
  Missing: 368
Total Distinct Versions: 1861 (89.3k)
Total Dependencies: 25403 (711k)
Total Ver/File relations: 2186 (35.0k)
Total Provides Mappings: 7262 (145k)
Total Globbed Strings: 50 (899)
Total Dependency Version space: 13.0k
Total Slack space: 83.0k
Total Space Accounted for: 1372k
Info relative ad un package
[root@pluto apt]# apt-cache showpkg licq
Package: licq
Versions:
1.2.0a-2(/var/state/apt/lists/apt.freshrpms.net_redhat_8.0_en_i386_base_pkglist.os)

Reverse Depends:
  licq-text,licq 1.2.0a
  licq-qt,licq 1.2.0a
  licq-kde,licq 1.2.0a
  licq-gnome,licq 1.2.0a
Dependencies:
1.2.0a-2 - htmlview (0 (null)) /usr/bin/desktop-file-install (0 (null)) /bin/sh (0 (null)) /usr/bin/perl (0 (null)) libcrypto.so.2 (0 (null)) libc.so.6 (0 (null)) libc.so.6(GLIBC_2.0) (0 (null)) libc.so.6(GLIBC_2.1) (0 (null)) libc.so.6(GLIBC_2.1.2) (0 (null)) libc.so.6(GLIBC_2.1.3) (0 (null)) libdl.so.2 (0 (null)) libdl.so.2(GLIBC_2.0) (0 (null)) libdl.so.2(GLIBC_2.1) (0 (null)) libgcc_s.so.1 (0 (null)) libgcc_s.so.1(GCC_3.0) (0 (null)) libm.so.6 (0 (null)) libnsl.so.1 (0 (null)) libpthread.so.0 (0 (null)) libpthread.so.0(GLIBC_2.0) (0 (null)) libpthread.so.0(GLIBC_2.1) (0 (null)) libssl.so.2 (0 (null)) libstdc++.so.5 (0 (null)) libstdc++.so.5(GLIBCPP_3.2) (0 (null)) perl(IO::Handle) (0 (null)) perl(strict) (0 (null)) licq-data (3 1.6)
Provides:
1.2.0a-2 - licq_rms.so
Reverse Provides:

Privacy Policy