Tag Archives: Developing

Creando un repositorio GIT a partir de las fuentes

De cara al desarrollo de aplicaciones es muy interesante tener algún software de control de versiones, tipo Subversion o GIT.

Os comento a modo de “chuleta” cómo hacer esto desde las fuentes.

Para ello, algunas consideraciones preliminares:

Servidor y SO: Linux myserver.com 2.6.18-194.3.1.el5 #1 SMP Sun May 2 04:17:42 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
Archivos de código: /soft/cds-invenio
Versión de GIT: git-1.6.6.2 (instalado desde las fuentes)

Asumo que la instalación de GIT es simple y podéis hacerla vosotros mismos sin ayuda. Hay muchísimos manuales indicando cómo hacerlo (usad google).

Una vez instalado GIT, procedemos:

# Creamos el archivo de configuracion del gitweb....
[root@aneto cds-invenio]#vi /etc/gitweb.conf
# ----------------------------------------------------------------------------
#
# gitweb.conf
#
# Configuration file for the web interface to GIT.
#
# This file is a Perl script that is executed by the gitweb interface
# after the defaults are set.  To override a setting, just uncomment
# it here and set it to the appropriate value.
#
 
# Core git executable to use.
# This can just be "git" if your webserver has a sensible PATH.
#our $GIT = "/path/to/git";
 
# Absolute fs-path which will be prepended to the project path.
# This is where your GIT repositories live in.
# ESTA VARIABLE ES FUNDAMENTAL!!!
our $projectroot = "/soft/git";
 
# Target of the home link on top of all pages.
#our $home_link = $my_uri || "/";
 
# String of the home link on top of all pages.
our $home_link_str = "view projects";
 
# Name of your site or organization to appear in page titles.
# Replace this with something more descriptive for clearer bookmarks.
#our $site_name = ""
 
# Filename of HTML text to include at top of each page.
# Must be an absolute filename (i.e., not relative to htdocs).
#our $site_header = "";
# HTML text to include at home page.
# Must be an absolute filename (i.e., not relative to htdocs).
#our $home_text = "/gitweb/indextext.html";
# Filename of HTML text to include at bottom of each page.
# Must be an absolute filename (i.e., not relative to htdocs).
#our $site_footer = "";
 
# URI of the stylesheet to use.
our $stylesheet = "/git/gitweb.css";
# URI of GIT logo (72x27 size).
our $logo = "/git/git-logo.png";
# URI of GIT favicon, assumed to be image/png type.
our $favicon = "/git/git-favicon.png";
 
# URI and label (title) of GIT logo link.
#our $logo_url = "http://git.or.cz/";
#our $logo_label = "git homepage";
 
# Source of projects list.
#our $projects_list = "";
 
# Show repository only if this file exists.
# Only effective if this variable evaluates to true.
#our $export_ok = "";
 
# Only allow viewing of repositories also shown on the overview page.
#our $strict_export = "";
 
# List of git base URLs used for URL to where fetch project from,
# i.e. full URL is "$git_base_url/$project"
#our @git_base_url_list = grep { $_ ne '' } ("/some/url");
# --------------------------------------------------------------------------------

Entonces añadimos al archivo de configuración de Apache algunas líneas útiles (el directorio /var/www/cgi-git/gitweb y /var/www/html/git deben existir):

[root@aneto cds-invenio]# vi /etc/httpd/conf/httpd.conf
# Añadir:
Alias /gitweb "/var/www/cgi-bin/gitweb/"
<Directory "/var/www/cgi-bin/gitweb">
            Options Indexes FollowSymlinks ExecCGI
            AllowOverride None
            Order allow,deny
            Allow from all
</Directory>
Alias /git "/var/www/html/git"
<Directory "/var/www/html/git">
            Options None
            AllowOverride None
            Order allow,deny
            Allow from all
</Directory>

Y procedemos a reinicar apache y crear el nuevo repositorio GIT…

[root@aneto cds-invenio]#/etc/init.d/httpd restart
 
[root@aneto cds-invenio]# cd /soft/cds-invenio
[root@aneto cds-invenio]# git init
[root@aneto cds-invenio]# git add .
[root@aneto cds-invenio]# git commit -m "inicialización del repositorio"

Una vez hecho esto, editamos algunos archivos de los que GIT ha creado (añadir información a ‘description’ y a ‘config’).

[root@aneto cds-invenio]# vi /soft/cds-invenio/description 
[root@aneto cds-invenio]# vi /soft/cds-invenio/config
--------------------------------------------------------
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        worktree = /soft/cds-invenio
        owner = "Miguel Martin"

A continuación clonamos sólo los datos de GIT en un fichero .git:

[root@aneto cds-invenio]# cd /soft/cds-invenio/
[root@aneto cds-invenio]# git clone --bare cdsinvenio cdsinvenio.git

Podemos probar a cargar en nuestro servidor esta url: http://myserver.com/cgi-bin/gitweb.cgi y ver si aparece algo… Puede que se produzcan fallos con gitweb.js si está en el directorio /cgi-bin/gitweb… si es el caso podemos editar gitweb.cgi y modificar la RUTA al gitweb.js.

# Editamos el gitweb.cgi porque hay fallos en el JS:
[root@aneto cds-invenio]# vi /var/www/cgi-bin/gitweb/gitweb.cgi
 
 # URI of stylesheets
 our @stylesheets = ("/var/www/cgi-bin/gitweb/gitweb.css");
 # URI of a single stylesheet, which can be overridden in GITWEB_CONFIG.
 our $stylesheet = undef;
 # URI of GIT logo (72x27 size)
 our $logo = "/var/www/cgi-bin/gitweb/git-logo.png";
 # URI of GIT favicon, assumed to be image/png type
 our $favicon = "/var/www/cgi-bin/gitweb/git-favicon.png";
 # URI of gitweb.js (JavaScript code for gitweb)
 our $javascript = "/git/gitweb.js";
 
 # URI and label (title) of GIT logo link
 #our $logo_url = "http://www.kernel.org/pub/software/scm/git/docs/";
 #our $logo_label = "git documentation";
 our $logo_url = "http://git-scm.com/";
 our $logo_label = "git homepage";

Y ahora copiamos el js a su lugar…

#Copiamos el Js a /var/www/html/git
cp /var/www/cgi-bin/gitweb.js /var/www/html/git/

# Hacemos un PUSH de todo…
[root@aneto teresa]# git push –all /soft/git/cdsinvenio.git

Y voilá! Nuestro repositorio git con todo accesible desde http://myserver.com/cgi-bin/gitweb.git

Algunos enlaces interesantes…
link 1 (en)
link 2 (en)
link 3 (es)
link 4 (es)