IMPORTANT: Per accedir als fitxer de subversion: http://acacha.org/svn (sense password). Poc a poc s'aniran migrant els enllaços. Encara però funciona el subversion de la farga però no se sap fins quan... (usuari: prova i la paraula de pas 123456)

Tipus de repositoris

TODO:

This document summarises setting up a Debian package repository.

I have taken care to provide the most accurate information at the time of writing but should you find any mistakes, please fix them.

There are 2 kinds of repositories from user's perspective:

archive style


apt line


apt-pinning


secure APT

trivial archive


"deb http://example.org/debian ./"


No


Yes

official archive


"deb http://example.org/debian unstable main"


Yes


Yes

These have different meta-data structure, but both store actual package files. Many repository HOWTOs address creation of a "trivial archive". These are problematic since the "trivial archive" lacks support for apt-pinning and modern secure APT due to the collision of 2 types of Release files. (e.g., old "Debian Reference (sarge)" and "APT HOWTO (sarge)")

Even with an "official archive", you can create a much simpler archive than the real official one. This is explained in Debian Reference (lenny) using apt-ftparchive in apt-utils and dupload. All uploaded packages are located in a directory and no database server is needed. This may be good enough for people hosting a few packages.

For creating something similar to the official archive, there are some good packages to help you but they tend to require a database server.

apt-ftparchive

Creació de repositoris simples

Aquest executable forma part del paquet apt-utils:

$ which apt-ftparchive
/usr/bin/apt-ftparchive
$ dpkg -S /usr/bin/apt-ftparchive
apt-utils: /usr/bin/apt-ftparchive

Podem utilitzar aquesta eina per crear un repositori simple (tots els paquets en una mateixa carpeta del servidor).

El primer que necessitareu és disposar d'una carpeta om posar el repositori de paquets Debian. En el nostre cas la posem a:

$ sudo mkdir -p /var/www/custom_packages

Aquesta carpeta ha de ser accessible via web i per tant possiblement us caldrà tenir instal·lat un servidor web com Apache. Podeu utilitzar l'eina tasksel per instal·lar un sistema LAMP de forma senzilla.

$ sudo tasksel install lamp-server

Al haver creat la carpeta a /var/www aleshores serà publicada automàticament a la URL:

http://IP_SERVIDOR/custom_packages/

Per exemple, podeu entrar amb localhost:

http://localhost/custom_packages/

Ara necessitem el codi del paquet que vulguem pujar. Podem utilitzar l'exemple de l'article Creació de paquets Debian a la secció Creació_de_paquets_Debian#Creaci.C3.B3_d.27un_paquet_Debian._Servidor_d.27echos_.28echod.29. Els passos a seguir són:

$ cd
$ mkdir tmp
$ cd tmp
$ sudo apt-get install subversion
$ svn checkout https://svn.projectes.lafarga.cat/svn/iceupc/plinux/sessio10/
$ cd sessio10
$ cp -r echoDimoni echod-0.1
$ sudo apt-get install dh-make fakeroot build-essential devscripts debhelper
$ cd echod-0.1
$ dh_make -e creador.del.paquet@exemple.com --createorig

Seleccioneu s i premeu Enter. Creeu el paquet Debian i la resta de fitxers necessaris

$ fakeroot
# dpkg-buildpackage 
# exit

Ara tornem a la carpeta pare:

$ cd ..
$ mkdir torepository
$ cp echod_0.1-1.diff.gz echod_0.1-1.dsc echod_0.1-1_i386.changes echod_0.1-1_i386.deb  echod_0.1.orig.tar.gz torepository/
$ cd torepository/
$ apt-ftparchive packages . | gzip > Packages.gz 
$ apt-ftparchive sources . | gzip > Sources.gz 

Ara ho podem copiar tot al servidor web:

$ sudo cp * /var/www/custom_packages/

Ja podem provar el paquet:

$ sudo joe /etc/apt/sources.list

Afegiu la línia:

deb http://localhost/custom_packages/ ./

I proveu d'instal·lar el paquet amb:

$ sudo apt-get update
$ sudo apt-get install echod 

NOTA: Us sortiran missatges relacionats amb la seguretat i autenticació, això és degut a que no hem creat cap clau GPG per al repositori

Creació d'un repositori amb apt-ftparchive

TODO

Config files:

/etc/apt/apt-ftparchive.conf
/etc/apt/apt-custom-release.conf

Create tree layout under /path/to/myrepository:

dists
+-custom
  +-main
    |-binary-i386
    +-source  

Put binary deb files into binary-i386 Put source files into source

Create archive config file under /etc/apt/apt-ftparchive.conf:

Dir {
  ArchiveDir "/path/to/myrepository";
};

BinDirectory "dists/custom/main/binary-i386" {
  Packages "dists/custom/main/binary-i386/Packages";
  Contents "dists/custom/Contents-i386";
  SrcPackages "dists/custom/main/source/Sources";
};

Tree "dists/custom" {
  Sections "main";
  Architectures "i386 source";
};

Create release config file under /etc/apt/apt-custom-release.conf:

APT::FTPArchive::Release::Origin "myrepository";
APT::FTPArchive::Release::Label "myrepository";
APT::FTPArchive::Release::Suite "custom";
APT::FTPArchive::Release::Codename "custom";
APT::FTPArchive::Release::Architectures "i386 source";
APT::FTPArchive::Release::Components "main";
APT::FTPArchive::Release::Description "Custom debian packages for myrepository";
Script: /etc/apt/update-archive.sh: 

I ara executeu:

$ sudo apt-ftparchive generate apt-ftparchive.conf
$ sudo apt-ftparchive -c apt-custom-release.conf release /path/to/myrepository/dists/custom > /path/to/myrepository/dists/custom/Release

Add repository to /etc/apt/sources.list:

deb file:/path/to/myrepository/ custom main

Recursos:

script

IMPORTANT: Per que funcionin correctament el tema de les claus cal que existeixin els fitxers Packages.gz i Packages (comprimit i descomprimit)

$ cd /mnt/sdb1/UbuntuMirror/custompackages
$ cat update.sh
#!/bin/bash
CUSTOM_PACKAGES_PATH="/mnt/sdb1/UbuntuMirror/custompackages"
cd ${CUSTOM_PACKAGES_PATH}
/bin/rm -rf Packages Packages.gz Sources Sources.gz Release Release.gpg
/usr/bin/apt-ftparchive packages . > Packages
/bin/gzip -f -c Packages > Packages.gz
/usr/bin/apt-ftparchive sources . > Sources
/bin/gzip -f -c Sources > Sources.gz
/usr/bin/apt-ftparchive release . > Releasetmp
/bin/cp -f Releasetmp Release
/bin/rm -rf Releasetmp
#gpg --homedir .gnupg --output "Release.gpg" -ba "Release"
#/usr/bin/apt-ftparchive -c configuration_for_release release /home/debbuild/packages/dists/unstable 
#apt-ftparchive -c "$ArchiveDir/release.conf" release "$ArchiveDir/dists/etch" > "$ArchiveDir/dists/etch/Release"

# Sign the Release file:
# -b  Make a detached signature
# -a  Create ASCII armored output
#gpg --homedir /var/www/default/debian-nic/.gnupg --output "$ArchiveDir/dists/etch/Release.gpg" -ba "$ArchiveDir/dists/etch/Release"
gpg --homedir .gnupg --output "Release.gpg" -bas "Release"
cd -

Un exemple de fitxer Release correcte:


Si us dona l'error:

$ sudo apt-get update
W: No s'ha pogut obtenir http://www.iesebre.com/ubuntu/custompackages/./Release  Unable to find expected entry  Packages in Meta-index file (malformed Release file?)

E: No es poden baixar alguns fitxers índex, s'han ignorat o en el seu lloc s'han emprat els antics.

És que no apareixen els fitxers Packages al fitxer Release, per exemple:

Date: dg, 20 nov 2011 19:20:36 UTC
MD5Sum:
 46e1110bd30c85a1194c906004d87002              543 Packages.gz
 d41d8cd98f00b204e9800998ecf8427e                0 Release
 b747e99bbb9e3d0eb6fb204c621c68a7              880 Sources.gz
SHA1:
 47d5a477fed329f7f6bef7e5fee09e1a8dab6aa1              543 Packages.gz
 da39a3ee5e6b4b0d3255bfef95601890afd80709                0 Release
 71bce7897f4ceba472a618aa2ffb3d57bb2c8506              880 Sources.gz
SHA256:
 90a5bf90ceed9a6ecb2c0db1b33d52bd2f85d2118da7e05141682743b3564092              543 Packages.gz
 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855                0 Release
 91d05cd4c01fe8f045799eec46e58dae82878d7941f39232ee951ae244ab9b2d              880 Sources.gz

Al repositori heu de crear tant els Packages.gz comprimits com els no comprimits.

reprepro

Creació de la clau

Generate a DSA key to sign the archive

In this example the administrator of the repository will be the root user, use another user if you can!

cd /var/www/default/debian-nic
mkdir .gnupg
chown root:root .gnupg
chmod 0700 .gnupg
gpg  --homedir .gnupg --gen-key

Those are the info provided to generate the key:

kind of key 	(1) DSA and Elgamal (default)
DSA keypair size 	1024 bits
ELG-E keys size 	2048 bits
Key is valid for 	2y
Real name 	Niccolo Rigacci
Email address 	niccolo at rigacci.org
Comment 	Debian packages archive

The public key should be exported and published as an ASCII armored file:

cd /var/www/default/debian-nic
gpg --homedir .gnupg --list-keys
gpg --homedir .gnupg --export -a > debian-nic.key


--acacha 08:50, 20 nov 2011 (UTC)

Vegeu també

Enllaços externs