Qualche tempo fa abbiamo scritto di un'utilità chiamata Fpm che aiuta a creare facilmente pacchetti Linux per più piattaforme Linux. Oggi parleremo di CheckInstall che viene utilizzato anche per creare pacchetti Linux dal codice sorgente.
Una breve introduzione a CheckInstall
Di solito, installiamo i pacchetti utilizzando i gestori di pacchetti della distribuzione. Ma se un'applicazione che desideri installare non è disponibile nei tuoi repository di distribuzione, non hai scelta, ma compila e installa manualmente te stesso dal codice sorgente.
La compilazione e l'installazione di applicazioni dal codice sorgente è un po' difficile per alcune persone, specialmente per i principianti. È qui che vengono in aiuto programmi come FPM e CheckInstall.
CheckInstall è un programma che compila un programma dal codice sorgente e crea un pacchetto nativo per la tua distribuzione Linux. In modo da poter installare i pacchetti utilizzando il sistema di gestione dei pacchetti della tua distribuzione (dpkg, rpm o installpkg).
Attualmente, CheckInstall crea pacchetti nativi per sistemi basati su DEB, sistemi basati su RPM e Slackware. In questo breve tutorial, discuteremo come creare pacchetti dal sorgente utilizzando il programma CheckInstall.
Installa CheckInstall in Linux
CheckInstall è disponibile nella maggior parte dei repository predefiniti della distribuzione Linux. Quindi, puoi installarlo usando i gestori di pacchetti.
Ad esempio, nei sistemi basati su Debian, puoi installarlo usando il seguente comando:
$ sudo apt-get install checkinstall
Su SUSE/openSUSE:
$ sudo zypper install checkinstall
Su CentOS, RHEL, Fedora:
Scarica e installa il file rpm di CheckInstall da questo link .
# wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/ikoinoba/CentOS_CentOS-6/x86_64/checkinstall-1.6.2-3.el6.1.x86_64.rpm
# yum install checkinstall-1.6.2-3.el6.1.x86_64.rpmScarica - EBook gratuito:"Gestione patch Linux®:mantenere aggiornati i sistemi Linux®"
Crea pacchetti dal sorgente usando CheckInstall
Ecco i semplici passaggi per creare un pacchetto DEB di ‘hello’
programma. Ho testato i seguenti passaggi in Ubuntu 16.04 LTS.
Per prima cosa scarica il tarball del programma "ciao".
$ wget http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
Estrai il tarball usando il comando:
$ tar -zxvf hello-2.10.tar.gz
Vai alla directory in cui hai estratto ciao tarball.
$ cd hello-2.10/
Esegui i seguenti comandi uno per uno per compilarlo.
$ ./configure
$ make
Ora, invece di digitare "make install"
comando per installare il programma, digitiamo il seguente comando:
$ sudo checkinstall --install=no
Questo comando creerà .deb
pacchetto, ma non lo installerà. Premi Y per creare una directory di documentazione del pacchetto denominata "doc-pak"
.
checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. The package documentation directory ./doc-pak does not exist. Should I create a default set of package docs? [y]: y Preparing package documentation...OK Please write a description for the package. End your description with an empty line or EOF. >> Simple Hello Program ## Type your Program name and hit ENTER key. >> ***************************************** **** Debian package creation selected *** ***************************************** This package will be built according to these values: 0 - Maintainer: [ [email protected] ] 1 - Summary: [ Simple Hello Program ] 2 - Name: [ hello ] 3 - Version: [ 2.10 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ hello-2.10 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ hello ] 12 - Conflicts: [ ] 13 - Replaces: [ ] Enter a number to change any of them or press ENTER to continue: ## Hit ENTER key [...] Building file list...OK Building Debian package...OK NOTE: The package will not be installed Erasing temporary files...OK Deleting temp dir...OK ********************************************************************** Done. The new package has been saved to /home/sk/hello-2.10/hello_2.10-1_amd64.deb You can install it in your system anytime using: dpkg -i hello_2.10-1_amd64.deb **********************************************************************
Ora puoi installare il .deb
appena creato pacchetto utilizzando dpkg
gestore dei pacchetti:
$ sudo dpkg -i hello_2.10-1_amd64.deb
Se esegui il comando precedente senza "--install=no"
flag, creerà automaticamente il pacchetto deb e lo installerà sul tuo sistema.
$ sudo checkinstall
Risultato di esempio:
checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. ***************************************** **** Debian package creation selected *** ***************************************** This package will be built according to these values: 0 - Maintainer: [ [email protected] ] 1 - Summary: [ Simple Hello Program ] 2 - Name: [ hello ] 3 - Version: [ 2.10 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ hello-2.10 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ hello ] 12 - Conflicts: [ ] 13 - Replaces: [ ] Enter a number to change any of them or press ENTER to continue: ##Press ENTER [...] Installing Debian package...OK Erasing temporary files...OK Writing backup package...OK OK Deleting temp dir...OK ********************************************************************** Done. The new package has been installed and saved to /home/sk/hello-2.10/hello_2.10-1_amd64.deb You can remove it from your system anytime using: dpkg -r hello **********************************************************************
Questo comando creerà il file .deb e lo installerà automaticamente sul tuo sistema. Puoi rimuovere il pacchetto di installazione in qualsiasi momento usando il comando:
$ sudo dpkg -r hello
VerificaInstalla creerà un .rpm
o un .deb
pacchetto automaticamente, a seconda del tipo di distribuzione Linux in uso. Se devi creare un pacchetto .rpm, segui i passaggi precedenti in qualsiasi sistema basato su RPM. Per i pacchetti Slackware, fallo sul sistema Slackware.
Per maggiori dettagli, vedere le pagine man:
$ man checkinstall
Oppure, controlla la sezione della guida.
$ checkinstall --help
Lettura correlata:
- Come convertire i pacchetti Linux con Alien
- Come creare pacchetti Debian dal sorgente