Creeu un repositori de paquets .deb a Sourceforge.net mitjançant l'eina Reprepro a Ubuntu


Reprepro és una petita eina de línia d'ordres per crear i gestionar fàcilment repositoris .deb. Avui mostrarem com crear fàcilment dipòsits de paquets de Debian amb repropro i com pengeu-lo a Sourceforge.net mitjançant l'ordre rsync.

Pas 1: instal·leu Reprepro i genereu la clau

Primer, instal·leu tots els paquets necessaris, utilitzant la següent comanda apt-get.

$ sudo apt-get install reprepro gnupg

Ara heu de generar una clau gpg amb gnupg, per fer-ho, apliqueu aquesta ordre.

$ gpg --gen-key

Us farà algunes preguntes, com ara el tipus de clau que voleu, quant de temps hauria de ser vàlida la clau, si no sabeu què respondre, feu clic a Retorn per a les opcions predeterminades (recomanat). ).

Per descomptat, us demanarà un nom d'usuari i una contrasenya, tingueu-los en compte, perquè els necessitarem més endavant.

gpg (GnuPG) 1.4.14; Copyright (C) 2013 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
        = key expires in n days
      w = key expires in n weeks
      m = key expires in n months
      y = key expires in n years
Key is valid for? (0) 
Key does not expire at all
Is this correct? (y/N) Y

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
    "Heinrich Heine (Der Dichter) <[email >"

Real name: ravisaive
Email address: [email 
Comment: tecmint
You selected this USER-ID:
    "Ravi Saive (tecmint) <[email >"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

+++++
gpg: key 2EB446DD marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   2048R/2EB446DD 2014-06-24
      Key fingerprint = D222 B1C9 342E 5911 02B1  9147 3BD6 7918 2EB4 46DD
uid                  Ravi Saive (tecmint) <[email >
sub   2048R/7EF2F750 2014-06-24

Ara es generarà la vostra clau, per comprovar si és així, executeu aquesta ordre com a privilegis d'arrel.

$ sudo gpg --list-keys
/home/ravisaive/.gnupg/pubring.gpg
----------------------------------
pub   2048R/2EB446DD 2014-06-24
uid                  ravisaive (tecmint) <[email >
sub   2048R/7EF2F750 2014-06-24

Pas 2: creeu un dipòsit de paquets i exporteu la clau

Ara començarem el treball per crear el repositori, primer heu de crear algunes carpetes, el nostre repositori estarà al directori /var/www/apt, així que creem algunes carpetes.

$ sudo su
# cd /var/www
# mkdir apt
# mkdir -p ./apt/incoming 
# mkdir -p ./apt/conf
# mkdir -p ./apt/key

Ara heu d'exportar la clau que heu creat a la carpeta del repositori, executeu.

# gpg --armor --export username [email  >> /var/www/apt/key/deb.gpg.key

Nota: substituïu el nom d'usuari pel nom d'usuari que heu introduït al pas anterior i [email  pel vostre correu electrònic.

Hem de crear un fitxer anomenat \distribucions dins de /var/www/apt/conf.

# touch /var/www/apt/conf/distributions

Afegiu aquestes línies següents al fitxer de distribucions i deseu el fitxer.

Origin: (yourname)
Label: (name of repository)
Suite: (stable or unstable)
Codename: (the codename for the distribution you are using, like trusty)
Version: (the version for the distribution you are using, like 14.04)
Architectures: (the repository packages  architecture, like i386 or amd64)
Components: (main restricted universe multiverse)
Description: (Some information about the repository)
SignWith: yes

A continuació, haurem de crear l'arbre del dipòsit, per fer-ho, executar aquestes ordres.

# reprepro --ask-passphrase -Vb /var/www/apt export
Created directory "/var/www/apt/db"
Exporting Trusty...
Created directory "/var/www/apt/dists"
Created directory "/var/www/apt/dists/Trusty"
Created directory "/var/www/apt/dists/Trusty/universe"
Created directory "/var/www/apt/dists/Trusty/universe/binary-i386"
FF5097B479C8220C ravisaive (tecmint) <[email > needs a passphrase
Please enter passphrase:
Successfully created '/var/www/apt/dists/Trusty/Release.gpg.new'
FF5097B479C8220C ravisaive (tecmint) <[email > needs a passphrase
Please enter passphrase:
Successfully created '/var/www/apt/dists/Trusty/InRelease.new'

Pas 3: afegiu paquets al repositori creat recentment

Ara prepareu els vostres paquets .deb per afegir-los al repositori. Aneu al directori /var/www/apt, ho heu de fer cada vegada que vulgueu afegir paquets.

# cd /var/www/apt
# reprepro --ask-passphrase -Vb . includedeb Trusty /home/ravisaive/packages.deb

Nota: Substituïu trusty pel nom en codi que heu introduït per al repositori al fitxer de distribucions i substituïu /home/username/package.deb pel camí del paquet; se li demanarà que entri la frase de contrasenya.

/home/ravisaive/packages.deb : component guessed as 'universe'
Created directory "./pool"
Created directory "./pool/universe"
Created directory "./pool/universe/o"
Created directory "./pool/universe/o/ojuba-personal-lock"
Exporting indices...
FF5097B479C8220C ravisaive (tecmint) <[email > needs a passphrase
Please enter passphrase:
Successfully created './dists/Trusty/Release.gpg.new'
FF5097B479C8220C ravisaive (tecmint) <[email > needs a passphrase
Please enter passphrase:
Successfully created './dists/Trusty/InRelease.new'

El vostre paquet s'afegeix al repositori per eliminar-lo.

# reprepro --ask-passphrase -Vb /var/www/apt remove trusty  package.deb

I, per descomptat, heu de modificar l'ordre amb el nom del vostre paquet i el nom en codi del dipòsit.

Pas 4: Carregueu el repositori a Sourceforge.net

Per carregar el dipòsit a Sourceforge.net, per descomptat, heu de tenir un compte en execució i un projecte en execució, suposem que voleu pujar el dipòsit a http://sourceforge. .net/projects/myfoo/testrepository on myfoo és el nom del vostre projecte (nom UNIX, no URL, no el títol) i testrepository és la carpeta on voleu pujar els fitxers. Ho farem amb rsync comandament.

# rsync -avP -e ssh /var/www/apt/ [email :/home/frs/project/myfoo/testrepository/

Nota: Substituïu el nom d'usuari pel vostre nom d'usuari a sourceforge.net i myfoo pel vostre nom UNIX del projecte i el repositori de proves amb la carpeta on voleu emmagatzemar els fitxers.

Ara que el vostre repositori està penjat a http://sourceforge.net/projects/myfoo/testrepository, per afegir-lo al vostre sistema instal·lat, primer heu d'importar la clau del repositori, estarà a < b>/var/www/apt/key/deb.gpg.key, però aquest és un camí local i els usuaris del vostre repositori no podran afegir-lo als seus sistemes, per això serem important la clau des de sourceforge.net.

$ sudo su
# wget -O - http://sourceforge.net/projects/myfoo/testrepository/apt/key/deb.gpg.key | apt-key add -

Ara podeu afegir el dipòsit fàcilment al vostre sistema, obrir /etc/apt/sources.list i afegir aquesta línia.

deb http://sourceforge.net/projects/myfoo/testrepository/apt/key/deb.gpg.key trusty main

Nota: Substituïu myfoo pel vostre projecte UNIX-Name, trusty amb el vostre nom de codi del dipòsit, testrepository amb la carpeta on heu penjat els fitxers i main amb els components del dipòsit que heu afegit al fitxer de distribucions.

A continuació, executeu el següent per actualitzar la llista de dipòsits.

$ sudo apt-get update

Enhorabona! El vostre repositori està actiu! Ara podeu instal·lar paquets fàcilment des d'ell si voleu.