Páginas

Mostrando entradas con la etiqueta Gentoo. Mostrar todas las entradas
Mostrando entradas con la etiqueta Gentoo. Mostrar todas las entradas

viernes, 13 de julio de 2012

Instalar flash x86_64

Fuente: http://forums.gentoo.org/viewtopic-t-195629.html

Si al intentar instalar adobe-flash en Gentoo este aparece como masked se debe a que primero debe aceptarse la licencia (software propietario), al archivo /etc/portage/package.license:

>=www-plugins/adobe-flash-11.2.202.236 AdobeFlash-10.3

Esto es posible hacerlo de la manera tradicional, agregando la línea anterior al archivo package.license o utilizando --auntoumask-write
# emerge -av adobe-flash --autounmask-write

Mantenimiento del fichero world.
Algunos paquetes no se agregan al fichero world, por razones diferentes. La función de la utilidad regenworld tiene es regenerar el fichero world a partir de los paquetes instalados:

# regenworld
add to world: app-emulation/emul-linux-x86-baselibs
add to world: media-sound/alsa-utils
add to world: app-portage/ufed
add to world: app-text/mupdf
add to world: www-plugins/adobe-flash

Please review differences between old and new files, and replace
the old file if desired.

  old: /var/lib/portage/world  new: /var/lib/portage/world.whfb96.tmp
# cp /var/lib/portage/world.whfb96.tmp /var/lib/portage/world.

Sacando información al sistema
$ emerge --info
Utilidades eix
El website de los usuarios linux de Monovár (Alicante)
Fuente: http://www.monovarlinux.org nos describe como podemos desinstalar gnome o kde con la ayuda de eix:.
# emerge eix

Analizando portage

# eix-update

Listar todos los paquetes pertenecientes a la categoría gnome-base 

# eix -C gnome-base -–only-names –-installed


Eliminar todos los paquetes de gnome-base y gnome-extra utilizando emerge y eix:

emerge -C `eix -C gnome-base –only-names –installed`
emerge -C `eix -C gnome-extra –only-names –installed`
revdep-rebuild

El mismo concepto es aplicable a otros entornos gráficos como kde:

emerge -C `eix -C kde-base –only-names –installed`
emerge -C `eix -C kde-misc –only-names –installed`
revdep-rebuild

Linux es genial!.

Acelerar optimizar sistema

Fuentes:
http://wiki.sabayon.org/index.php?title=How_to_optimize_and_accelerate_your_system
http://www.linuxeando.org/foros/index.php?topic=729.0

Optimizar y acelerar sistema gentoo.

Muchas por no decir todas estas reglas serán aplicables (seguramente), a casi todas las distribuciones Linux, aunque tengo que decir que la mayoría no las necesitará porque los programadores y mantenedores de esas distros (las basadas en Red Hat y Debian, por ejemplo), las incorporan por defecto. Ubuntu, Debian, Centos, etc. Desde el portátil que escribo (Dell Inspiron con Ubuntu 8.04 preinstalado en sda2 y gentoo en sda3)  he podido comprobar que esta optimización no es necesaria en ubuntu.

$ ls -l /dev/disk/by-label

total 0
lrwxrwxrwx 1 root root 10 jul 13 07:41 boot -> ../../sda1
lrwxrwxrwx 1 root root 10 jul 13 07:40 datos -> ../../sda9
lrwxrwxrwx 1 root root 10 jul 13 08:09 gentoo_h -> ../../sda7
lrwxrwxrwx 1 root root 10 jul 13 08:09 gentoo_r -> ../../sda3
lrwxrwxrwx 1 root root 10 jul 13 07:40 ubuntu_h -> ../../sda6
lrwxrwxrwx 1 root root 10 jul 13 07:40 ubuntu_r -> ../../sda2

He instalado (en otro disco duro pero en esta misma máquina), la distribución Centos 6.2 incluida en Linux Magazine del mes de March 2012 que me enviaron de regalo después de pasar el examen LPIC-1 y la verdad viene optimizada al máximo y con mucho software pre-instalado. Centos es una maravilla de distro para usuario final y extremadamente potente y segura en Servidores, con mucha documentación en diferentes idiomas.

El mérito de este artículo es de los chicos de Saboyan (derivada de Gentoo). Vease la url en la parte superior.

Detales de mi máquina:

$ uname -a
Linux zeus 3.3.8-gentoo #1 SMP Thu Jul 12 04:19:51 CEST 2012 x86_64 Intel(R) Core(TM)2 Duo CPU T5750 @ 2.00GHz GenuineIntel GNU/Linux.

$ cat /proc/meminfo|grep -i memtotal
MemTotal:        4045372 kB

Disco duro, Sata II 500 Gb 5400 RPM. 5MB memoria interna (un disco normalito).

Arrancar servicios Openrc en paralelo

Cambiar
# vi /etc/rc.conf

rc_parallel="YES"
rc_logger="NO"

Los servicios necesarios del sistema no deben desactivarse pero otros si. Puede conocerlos con la utilidad
# rc-update show
Rendimiento del disco duro:
# vi /etc/conf.d/hdparm
hda_args="-a16 -c1 -k1 -u1 -S0"
cdrom0_args="-c1 -k1 -u1

Agrego hdparm al arranque del sistema:
# rc-update add hdparm boot

preload es un demonio readhead adaptado que supervisa los programas más utilizados. Parte de esos programas los almacena en cache y aumentar la velocidad de carga:

# emerge -av preload
# rc-update add preload default

Los archivos temporales se borran durante el apagado, se puede colocar sus lugares de almacenamiento en la memoria RAM. Esto reduce el número de operaciones de disco , haciendo más rápido programas que utilizan carpetas temporales.

# vi /etc/fstab

 tmp     /tmp      tmpfs rw,mode=1777 0 0
 vartmp  /var/tmp  tmpfs rw,mode=1777 0 0


Retraso de la repetición del teclado, sin recompilar X11:
# vi /etc/X11/xorg.conf

Por defecto el tiempo de repetición de 500 milisegundos, y el tiempo de respuesta por defecto de 30 milisegundos. Esto cambia a 530 y 0, respectivamente.
....
Section "InputDevice"
Identifier "logitech"
Driver "kbd"
  Option "AutoRepeat" "530 0"
EndSection

En este sistema específico no implementé el resto de optimizaciones. Por si fuera útil incluyo los archivos /etc/sysctl.conf y /root/rules.sh (firewall) y como arrancarlo al iniciar el sistema.
Archivo /etc/sysctl.conf.

# cat /etc/sysctl.conf |grep ^[^#] | colorlog.pl
kernel.printk = 4 4 1 7
fs.inotify.max_ ser_watches = 524288
vm.mmap_min_add  = 65536
fs.file-max = 1 384
kernel.threads- ax = 2048
net.ipv4.conf.e h0.arp_ignore = 1
net.ipv4.conf.e h0.arp_announce = 2
net.ipv4.conf.a l.arp_ignore = 1
net.ipv4.conf.d fault.rp_filter = 1
net.ipv4.ip_for ard = 0
net.ipv4.icmp_e ho_ignore_broadcasts = 1
net.ipv4.conf.a l.rp_filter = 1
net.ipv4.conf.a l.send_redirects = 0
net.ipv4.conf.a l.accept_redirects = 0
net.ipv4.conf.a l.accept_source_route = 0
net.ipv4.conf.a l.arp_announce = 1
vm.swappiness = 5
Un firewall básico para un host con iptables.
# ls -l /root/rules.sh 
-rwx------ 1 root root 1229 jul 12 07:08 /root/rules.sh
# cat /root/rules.sh 

IPT=/sbin/iptables

# Flush old rules, old custom tables
echo " * flushing old rules"
$IPT --flush
$IPT --delete-chain

# Set default policies for all three default chains
echo " * setting default policies"
$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT ACCEPT

# Enable free use of loopback interfaces
echo " * allowing loopback devices"
$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT

# All TCP sessions should begin with SYN
$IPT -A INPUT -p tcp ! --syn -m state --state NEW -j DROP

# Allow established and related packets
$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Open the following ports
echo " * allowing ssh on port 22"
$IPT -A INPUT -p tcp --dport 22  -m state --state NEW -j ACCEPT

echo " * allowing dns on port 53"
$IPT -A INPUT -p udp -m udp --dport 53 -j ACCEPT

echo " * allowing http on port 80"
$IPT -A INPUT -p tcp --dport 80  -m state --state NEW -j ACCEPT

echo " * allowing https on port 443"
$IPT -A INPUT -p tcp --dport 443 -m state --state NEW -j ACCEPT

echo " * allowing ping responses"
$IPT -A INPUT -p ICMP --icmp-type 8 -j ACCEPT

# DROP everything else and Log it
$IPT -A INPUT -j LOG
$IPT -A INPUT -j DROP
#
# Save settings
#
echo " * saving settings"

Ejecutar script:

# /root/rules.sh
 * flushing old rules
 * setting default policies
 * allowing loopback devices
 * allowing ssh on port 22
 * allowing dns on port 53
 * allowing http on port 80
 * allowing https on port 443
 * allowing ping responses
 * saving settings

Guardar la configuración actual:
# /etc/init.d/iptables save
iptables      | * Saving iptables state ...                                 [ ok ]

Iniciar iptables con el sistema:
# rc-update add iptables default
 * service iptables added to runlevel default

Linux es genial!.

miércoles, 6 de junio de 2012

hwclock rtc

Al poner en marcha mi Gentoo linux un mensaje de error entre los mensajes de diagnóstico del sistema (dmesg), advierte de la imposibilidad de acceder al reloj de la máquina:

hwclock: Cannot access the Hardware Clock via any known method.
hwclock from util-linux 2.20.1
hwclock: Open of /dev/rtc failed: No such file or directory
No usable clock interface found.
hwclock: Use the --debug option to see the details of our search for an access method.



Es debido a que el kernel no fué compilado con soporte RTC. Para comprobarlo:

# zgrep RTC /proc/config.gz > rtc
# cat rtc

Para establecer rtc recompilo el kernel:
# make menuconfig

La sección de configuración que interesa para tal propósito está en
 - Device Drivers
    - RTC

Después de activar la opción es hora de compilarlo e instalarlo.
# make && make modules_install && make install
# cp arch/x86_64/boot/bzimage /boot/kernel-3.2.12-gentoo

Reiniciar.
Todo resuelto.





Linux es genial!.

domingo, 3 de junio de 2012

Parametro USE

Parámetros USE

fuente: http://www.gentoo.org/doc/es/handbook/

Mientras esté instalando Gentoo o cualquier otra distribución, tomará varias decisiones dependiendo del entorno en el que esté trabajando. Una instalación para un servidor es distinta a una para una estación de trabajo.

Estas diferencias dependen de los paquetes instalados y de las características para las que ciertos paquetes tienen soporte. Si no va a utilizar KDE, no se moleste en compilar paquetes con soporte para KDE si podrían funcionar perfectamente sin él.

Un parámetro USE es una palabra clave que incorpora información de soporte y dependencias para un concepto en concreto. Si define un determinado parámetro USE, Portage sabrá que el usuario desea soporte para la palabra clave escogida. Por supuesto, también altera las dependencias de un paquete. 

Definiendo correctamente las palabras clave, conseguirá un sistema confeccionado específicamente para sus necesidades. El archivo /etc/portage/package.use almacena parámetros USE locales mientras /etc/make.conf se utiliza para parámetros USE globales.

# emerge -av fbreader



Este mensaje nos advierte de que fbreader (lector de ebooks), solo utiliza qt4 o gtk. Por tanto, la solución pasa por teclear desde la línea de comandos como root:

# echo "app-text/fbreader gtk -qt4 -debug" >> /etc/portage/package.use

Si modifica su fichero package.use tiene que ejecutar lo siguiente, de modo que Gentoo recalcula si alguna de las aplicaciones necesita recompilarse para soportar el nuevo USE.

# emerge -DuvN world

revdep-rebuild (paquete gentoolkit), es el reconstructor de dependencias inversas de Gentoo. Realizará una búsqueda de todos los ebuilds instalados que no funcionen a causa de alguna actualización de un paquete del cual dependan.

# revdep-rebuild


Linux es genial!.

sábado, 2 de junio de 2012

equery

Listando archivos instalados en formato de arbol:

fuente: http://www.gentoo.org/doc/es/

equery puede listar todos los archivos instalados por un ebuild con el módulo de files. Trate --tree para conseguir leer la estructura de directorios. filter para encontrar sólo un determinado tipo de archivo filter=conf . Un ejemplo con gentoolkit:

# equery files --tree gentoolkit
 

 * Searching for gentoolkit ...
 * Contents of app-portage/gentoolkit-0.3.0.5:
 /etc
   > /eclean
      + distfiles.exclude
      + packages.exclude
   > /env.d
      + 99gentoolkit-env
   > /revdep-rebuild
      + 99revdep-rebuild
 /usr
   > /bin
      + eclean
      + eclean-dist -> eclean
      + eclean-pkg -> eclean
      + enalyze
      + epkginfo
      + equery
      + eread
      + eshowkw
      + euse
      + glsa-check
      + revdep-rebuild -> revdep-rebuild.sh
      + revdep-rebuild.py
      + revdep-rebuild.sh

             .........


            + eclean.1.bz2
            + enalyze.1.bz2
            + epkginfo.1.bz2
            + equery.1.bz2
            + eread.1.bz2
            + eshowkw.1.bz2
            + euse.1.bz2
            + glsa-check.1.bz2
            + revdep-rebuild.1.bz2
 /var
   > /cache
      > /revdep-rebuild
         + .keep_app-portage_gentoolkit-0

# rm -f /var/cache/revdep-rebuild/*.rr

glsa-check es principalmente una herramienta de verificación que le sigue la pista a los diversos GLSAs (Advertencia de Seguridad de Gentoo Linux, Gentoo Linux Security Advisory).

# glsa-check -l
[A] means this GLSA was marked as applied (injected),
[U] means the system is not affected and
[N] indicates that the system might be affected.

Linux es genial!.

martes, 24 de abril de 2012

PH5 PDO Gentoo

Compilar PHP5 con soporte  Data Objects (PDO)

El carrito de compra de ejemplo está alojado en un hosting gratuito sin publicidad 3 base de datos mysql, etc.. y este es el enlace que te envía a la página de registro 00webhost.com

Después de realizar un ejercicio carrito de compra propuesto por Ricardo Gutierréz (programador PHP), un mensaje de error alerta que el objeto PDO no se encuentra al ejecutar uno de los archivos en mi servidor apache local. El ejercicio lo he subido al servidor gratuito 00webhost.com, desactivado, por supuesto, el pago por paypal. El código y video está disponible en vimeo. Carrito compra funcionando

 Por defecto al compilar php5 (Gentoo) pdo viene desactivado:
# emerge -av php


[ebuild   R    ] dev-lang/php-5.3.10  USE="apache2 berkdb bzip2 cgi cli crypt ctype exif fileinfo filter fpm gd gdbm hash iconv ipv6 json ldap mysql nls phar posix postgres readline session simplexml spell sqlite ssl tokenizer truetype unicode xml zlib -bcmath -calendar -cdb -cjk -curl -curlwrappers -debug -doc -embed -enchant -firebird -flatfile (-frontbase) -ftp -gmp -imap -inifile -intl -pdo -iodbc -kerberos -kolab -ldap-sasl -libedit -mhash -mssql -mysqli -mysqlnd -oci8-instant-client -odbc -pcntl -pic -qdbm -recode -sharedmem -snmp -soap -sockets -sqlite3 -suhosin (-sybase-ct) -sysvipc -threads -tidy -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl -zip"

Agregamos al archivo /etc/portage/package.use lo siguiente:
# vi /etc/portage/package.use

=dev-lang/php-5.3.10 apache2 berkdb bzip2 cgi cli crypt ctype exif fileinfo filter fpm gd g   dbm hash iconv ipv6 json ldap mysql nls phar posix postgres readline session simplexml spel   l sqlite ssl tokenizer truetype unicode xml zlib pdo -bcmath -calendar -cdb -cjk -curl* -cu   rlwrappers* -debug -doc -embed -enchant -firebird -flatfile (-frontbase) -ftp* -gmp -imap -   inifile -intl -iodbc -kerberos -kolab -ldap-sasl -libedit -mhash -mssql -mysqli* -mysqlnd -   oci8-instant-client -odbc -pcntl -pic -qdbm -recode -sharedmem -snmp -soap -sockets -sqlite   3 -suhosin (-sybase-ct) -sysvipc -threads -tidy -wddx -xmlreader -xmlrpc -xmlwriter -xpm -x   sl -zip (-adabas%) (-birdstep%) (-db2%) (-dbmaker%) (-empress%) (-empress-bcs%) (-esoob%) (   -gd-external%) (-interbase%) (-oci8%) (-sapdb%) (-sharedext%) (-solid%)
:wq

Nuestro sistema está preparado para recompilar php con pdo enable:

Calculating dependencies... done!
[ebuild   R    ] dev-lang/php-5.3.10  USE="apache2 berkdb bzip2 cgi cli crypt ctype exif fileinfo filter fpm gd gdbm hash iconv ipv6 json ldap mysql nls pdo phar posix postgres readline session simplexml spell sqlite ssl tokenizer truetype unicode xml zlib -bcmath -calendar -cdb -cjk -curl -curlwrappers -debug -doc -embed -enchant -firebird -flatfile (-frontbase) -ftp -gmp -imap -inifile -intl -iodbc -kerberos -kolab -ldap-sasl -libedit -mhash -mssql -mysqli -mysqlnd -oci8-instant-client -odbc -pcntl -pic -qdbm -recode -sharedmem -snmp -soap -sockets -sqlite3 -suhosin (-sybase-ct) -sysvipc -threads -tidy -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl -zip" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB

Would you like to merge these packages? [Yes/No] y

Al finalizar la compilación un mensaje informa de que deben actualizarse algunos archivos de configuración del sistema. Una de las herramientas utilzadas para ello es update-etc:


Reiniciar apache:

# /etc/init.d/apache2 restart
 * Stopping apache2 ...                                             [ ok ]
 * Starting apache2 ...                                               [ ok

Linux es genial!.

jueves, 15 de marzo de 2012

Actualizar gcc 4.6.2


Instalando gcc-4.6.2 en mi gentoo amd64 para añadir soporte de optimizaciones para nuevos procesadores en mi caso AMD-FX-4100 Bulldozer (family 14), flags  -march=btver1 -mtune=btver1 
En estos momentos el paquete aparece boqueado por missing keyword. Desmascarar (unmask) como sigue:

# echo "sys-devel/gcc">> /etc/portage/package.unmask
# echo "sys-devel/gcc **>> /etc/portage/package.keywords

De momento he enmascarado las anteriores versiones de gcc:

# vi /etc/package.mask
>sys-devel/gcc-4.5.3-r2
=sys-devel/gcc-4.5.3-r2
=sys-devel/gcc-4.5.3-r1
=sys-devel/gcc-4.4.6-r1
=sys-devel/gcc-4.4.5
=sys-devel/gcc-4.4.4-r2
=sys-devel/gcc-4.3.3-r1
=sys-devel/gcc-4.3.6-r1
=sys-devel/gcc-4.3.4
=sys-devel/gcc-4.1.2
=sys-devel/gcc-3.4.6-r2

Hago un emerge:

# emerge -av gcc

These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild NS #] sys-devel/gcc-4.6.2 [4.5.3-r2] USE="cxx fortran gtk mudflap (multilib) nls nptl openmp (-altivec) -bootstrap -build -doc (-fixed-point) -gcj -go -graphite (-hardened) (-libffi) (-libssp) -multislot -nocxx -nopie -nossp -objc -objc++ -objc-gc -test -vanilla" 0 kB
Total: 1 package (1 in new slot), Size of downloads: 0 kB
Would you like to merge these packages? [Yes/No] y

# Modificar la version del compilador:

# gcc-config -l
 [1] x86_64-pc-linux-gnu-4.5.3 *
 [2] x86_64-pc-linux-gnu-4.6.2

# gcc-config 2
# env-update && source /etc/profile

Reconstruir libtool:
# emerge --oneshot libtool

Solo es necesario si se actualiza desde una version anterior a 4.1:
# revdep-rebuild --library libstdc++.so.5 

# gcc-config -l
 [1] x86_64-pc-linux-gnu-4.5.3 
 [2] x86_64-pc-linux-gnu-4.6.2 *

Agregar las flags al fichero make.conf
# vi /etc/make.conf
CFLAGS="-O2 -pipe -fomit-frame-pointer -march=bdver1 -mtune=bdver1 -mcx16 -msahf -maes -mpclmul -mpopcnt -mabm -mlwp -mavx"
CXXFLAGS="${CFLAGS}"


Continuará...


Linux es genial!.

martes, 13 de diciembre de 2011

PHP Vim

Función para la correcta visualización de acentos y caracteres especiales:

Vim se ha convertido en mi editor favorito, sin quitar mérito a otros editores como Emacs (el monstruo de los editores de Linux y el preferido por los programadores, altamente configurable, rápido y potente, IDE utilizando plugins, etc..), jedit, gedit, komodo, etc. Para editar archivos de texto cualquier editor vale, pero, ¿y si queremos un IDE para programar en ruby, php, html, etc con función de autocompletado, explorador de archivos y poder abrir una terminal desde vim ?.
Vi con algunos plugins será suficiente:
NERD_tree Navegador de archivos:
La página de descarga es: http://www.vim.org/scrits/script.php?script_id=1658

Descomprimir el archivo NERD_tree.zip dentro del directorio ~/.vim
Asegúrese de comprobar que el archivo NERD_tree.vim esta en ~/.vim/plugin y NERD_tree.txt
en ~/.vim/doc.

Gentoo utiliza /var/www/localhost/htdocs como directorio predeterminado. El archivo
de configuración de vim y agregar está linea:

# vi /etc/vim/vimrc.local
" Teclado rápido para abrir explorador de archivos NERTree
map ex :NERDTree /var/www/localhost/htdocs

Conque es un plugin para vi que permite abrir una terminal sin salir de vi.
La página de descarga es:
http://www.vim.org/scripts/script.php?script_id=2771

Después de descargar el plugin debe abrirse con vi, acto seguido teclear
:so %

En este momento puede abrir una terminal desde vi:
:ConqueTermSplit bash

Utilizar teclas rápidas desde vi pasa por agregar al archivo de configuración
/etc/vim/vimrc.local:

# vi /etc/vim/vimrc.local
" Crear alias para abrir terminal dentro de vi
" la primera linea abre un terminal
" la segunda abre un terminal vertical (V).
map ct :ConqueTermSplit bash
map cv :ConqueTermVSplit bash

" mapeo para editar el fichero a traves del
" interprete de php
autocmd FileType php noremap :w!:!/usr/bin/php %

" mapeo para pasear la sintaxis del fichero
" a traves del interprete de php en modo lint
autocmd FileType php noremap :!/usr/bin/php -l %

" Activar autocompletado php y html
" ctrl + x para autocomplete
" ctrl +o muestra opciones de autocomplete
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags

Luego al abrir un archivo .php, para activar el autocompletado:
Ctrl + z y Ctrl + o.

Es importante saber que para movernos por las diferentes por las diferentes ventanas
utilzaremos las teclas Ctrl + w seguido de la tecla de dirección hacia la ventana que
queremos movernos, (Der, Izq, Arriba o Abajo).

Por último el plugin Tag List. Un plugin para el navegador de código fuente de Vim
y proporciona una visión general de la estructura de archivos de código fuente para
los diferentes lenguajes de programación. El link de descarga:

http://www.vim.org/scripts/script.php?script_id=273

Descomprimir el archivo taglist_45.zip en el directorio ~/.vim
Compruebe el archivo principal y la documentación:

plugin/taglit.vim
doc/taglis.txt

$ cd ~/.vim/doc
$ ~/.vim/doc $ ls -l
total 168
-rw-r--r-- 1 carlos users 27142 Nov 30 07:55 conque_term.txt
-rw-r--r-- 1 carlos users 50021 Dec  1  2009 NERD_tree.txt
-rwxr-xr-x 1 carlos users 69366 May 24  2007 taglist.txt
-rw-r--r-- 1 carlos users 10673 Dec 13 14:18 tags

Iniciar vim y dentro de vim en modo comando (Esc):
:helptags .  <--- no olvidar el punto. Este comando procesa la ayuda del archivo tatglist.


Linux es genial!.

domingo, 13 de noviembre de 2011

Instalar ruby on rails

Instalar ruby rails en plataforma de desarrollo gentoo.
http://www.rubyonrails.org.es/
http://www.guateonrails.com Javier Alvarez.

Si están aprendiendo Ruby on Rails este es un sitio de visita obligada y visualicen los videos del sitio, excelentemente sencillos. Guateonrails.

Ruby es un lenguaje de programación interpretado que funciona con cualquier sistema operativo, aunque con los sistemas tipo Unix es que mejor se integra.


Instalar ruby:

# emerge -av ruby

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] app-admin/eselect-ruby-20100603  2 kB
[ebuild  N     ] dev-lang/ruby-1.8.7_p352  USE="berkdb gdbm ipv6 ncurses readline ssl -debug -doc -examples -libedit -rubytests -socks5 -threads -tk -xemacs" 4,112 kB

Total: 2 packages (2 new), Size of downloads: 4,114 kB

Would you like to merge these packages? [Yes/No] y

Instalar rubygems:

# emerge -av rubygems

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] dev-ruby/rubygems-1.3.7-r1  USE="-doc -server" RUBY_TARGETS="ruby18 -jruby -ree18" 285 kB

Total: 1 package (1 new), Size of downloads: 285 kB

Would you like to merge these packages? [Yes/No] y

Al finalzar la instalación un mensaje nos advierte:

 * To switch between available Ruby profiles, execute as root:
 * eselect ruby set ruby(18|19|...)

Procedemos:

# eselect ruby list
Available Ruby profiles:
  [1]   ruby18 (with Rubygems) *
# eselect ruby set ruby18
Successfully switched to profile:
  ruby18

Averiguar versión instalada:                
# gem -v
1.3.7

Instalar rails a través de Rubygem:

 # gem18 install rails --include-dependencies
INFO:  `gem install -y` is now default and will be removed
INFO:  use --ignore-dependencies to install only the gems you list
Building native extensions.  This could take a while...
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
...

En un futuro para actualizar Rails solo tendremos que teclear:

# gem update rails --include-dependencies

# emerge -av sqlite3-ruby

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] virtual/rubygems-1  RUBY_TARGETS="(ruby18)" 0 kB
[ebuild  N     ] dev-ruby/rake-0.8.7-r5  USE="-bash-completion -doc -test" RUBY_TARGETS="ruby18 -jruby -ree18" 101 kB
[ebuild  N     ] dev-ruby/hoe-2.8.0  USE="-doc -test" RUBY_TARGETS="ruby18 -jruby -ree18" 114 kB
[ebuild  N     ] dev-ruby/rake-compiler-0.7.5  USE="-test" RUBY_TARGETS="ruby18 -jruby -ree18" 26 kB
[ebuild  N     ] dev-ruby/sqlite3-ruby-1.3.2  USE="-doc -test" RUBY_TARGETS="ruby18 -ree18" 55 kB

Total: 5 packages (5 new), Size of downloads: 295 kB

Would you like to merge these packages? [Yes/No]

Instalar el paquete mysql de gems:

# gem install mysql
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
Installing RDoc documentation for mysql-2.8.1...

Verificar instalación y versión de rails:

# rails --version
Rails 3.1.1

Creando un esqueleto:
 $ rails new ~/code/ruby/weblog rails server
      create
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Enter your password to install the bundled RubyGems to your system:
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2)
Using multi_json (1.0.3)
Using activesupport (3.1.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.1)
Using erubis (2.7.0)
Using rack (1.3.5)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.3)
Using actionpack (3.1.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.1)
Using arel (2.2.1)
Using tzinfo (0.3.31)
Using activerecord (3.1.1)
Using activeresource (3.1.1)
Using bundler (1.0.21)
Installing coffee-script-source (1.1.3)
Installing execjs (1.2.9)
Installing coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.1)
Using rdoc (3.11)
Using thor (0.14.6)
Using railties (3.1.1)
Installing coffee-rails (3.1.1)
Installing jquery-rails (1.0.17)
Using rails (3.1.1)
Installing sass (3.1.10)
Installing sass-rails (3.1.4)
Installing sqlite3 (1.3.4) with native extensions
Installing uglifier (1.0.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Comprobar dependencias:

$ bundle - Ruby
Using rake (0.9.2.2)
Using multi_json (1.0.3)
Using activesupport (3.1.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.1)
Using erubis (2.7.0)
Using rack (1.3.5)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.3)
Using actionpack (3.1.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.1)
Using arel (2.2.1)
Using tzinfo (0.3.31)
Using activerecord (3.1.1)
Using activeresource (3.1.1)
Using bundler (1.0.21)
Using coffee-script-source (1.1.3)
Using execjs (1.2.9)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.1)
Using rdoc (3.11)
Using thor (0.14.6)
Using railties (3.1.1)
Using coffee-rails (3.1.1)
Using jquery-rails (1.0.17)
Using rails (3.1.1)
Using sass (3.1.10)
Using sass-rails (3.1.4)
Using sqlite3 (1.3.4)
Using uglifier (1.0.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

$ bundle show

Gems included by the bundle:
  * actionmailer (3.1.1)
  * actionpack (3.1.1)
  * activemodel (3.1.1)
  * activerecord (3.1.1)
  * activeresource (3.1.1)
  * activesupport (3.1.1)
  * arel (2.2.1)
  * builder (3.0.0)
  * bundler (1.0.21)
  * coffee-rails (3.1.1)
  * coffee-script (2.2.0)
  * coffee-script-source (1.1.3)
  * erubis (2.7.0)
  * execjs (1.2.9)
  * hike (1.2.1)
  * i18n (0.6.0)
  * jquery-rails (1.0.17)
  * json (1.6.1)
  * mail (2.3.0)
  * mime-types (1.17.2)
  * multi_json (1.0.3)
  * polyglot (0.3.3)
  * rack (1.3.5)
  * rack-cache (1.1)
  * rack-mount (0.8.3)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.1.1)
  * railties (3.1.1)
  * rake (0.9.2.2)
  * rdoc (3.11)
  * sass (3.1.10)
  * sass-rails (3.1.4)
  * sprockets (2.0.3)
  * sqlite3 (1.3.4)
  * thor (0.14.6)
  * tilt (1.3.3)
  * treetop (1.4.10)
  * tzinfo (0.3.31)
  * uglifier (1.0.4)

$ bundle check
The Gemfile's dependencies are satisfied


$ bundle update
Fetching source index for http://rubygems.org/
Enter your password to install the bundled RubyGems to your system:
Using rake (0.9.2.2)
Using multi_json (1.0.3)
Using activesupport (3.1.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.1)
Using erubis (2.7.0)
Using rack (1.3.5)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.3)
Using actionpack (3.1.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.1)
Using arel (2.2.1)
Using tzinfo (0.3.31)
Using activerecord (3.1.1)
Using activeresource (3.1.1)
Using bundler (1.0.21)
Using coffee-script-source (1.1.3)
Using execjs (1.2.9)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.1)
Using rdoc (3.11)
Using thor (0.14.6)
Using railties (3.1.1)
Using coffee-rails (3.1.1)
Installing jquery-rails (1.0.18)
Using rails (3.1.1)
Using sass (3.1.10)
Installing sass-rails (3.1.5)
Using sqlite3 (1.3.4)
Installing uglifier (1.1.0)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem

Corregir error formato fecha:

# cd /usr/lib64/ruby/gems/1.8/specifications
# vim jquery-rails-1.0.17.gemspec

 cambiar:

 s.date = %q{2001-11-09 00.00.00 000000000Z}
por:
 s.date = %q{2011-11-13}

$ rails new ~/code/ruby/weblog
$ cd code/ruby/weblog/
$ bundle show

Corigiendo errores:

$ rails server
/usr/lib64/ruby/gems/1.8/gems/execjs-1.2.9/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

$ sudo gem install 'execjs'
Password:

Successfully installed execjs-1.2.9
1 gem installed
Installing ri documentation for execjs-1.2.9...
Installing RDoc documentation for execjs-1.2.9...

$ sudo gem install 'therubyracer'
Fetching: libv8-3.3.10.2-x86_64-linux.gem (100%)
Fetching: therubyracer-0.9.9.gem (100%)
Building native extensions.  This could take a while...
Successfully installed libv8-3.3.10.2-x86_64-linux
Successfully installed therubyracer-0.9.9
2 gems installed
Installing ri documentation for libv8-3.3.10.2-x86_64-linux...
Installing ri documentation for therubyracer-0.9.9...
Installing RDoc documentation for libv8-3.3.10.2-x86_64-linux...
Installing RDoc documentation for therubyracer-0.9.9...

$ sudo gem install 'libv8'
Fetching: libv8-3.3.10.2-x86-linux.gem (100%)
Successfully installed libv8-3.3.10.2-x86-linux
1 gem installed
Installing ri documentation for libv8-3.3.10.2-x86-linux...
Installing RDoc documentation for libv8-3.3.10.2-x86-linux...


Añadir las siguientes líneas al archivo ~/code/ruby/weblog/config/boot.rb:

$ cd ~/code/ruby/weblog/config
$ vim boot.rb

 require 'rubygems'
 require 'execjs'
 require 'v8'

Iniciar el servidor:

$ cd ~/code/ruby/weblog
$ rails server
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-11-13 16:50:49] INFO  WEBrick 1.3.1
[2011-11-13 16:50:49] INFO  ruby 1.8.7 (2011-06-30) [x86_64-linux]
[2011-11-13 16:50:49] INFO  WEBrick::HTTPServer#start: pid=10759 port=3000


Abrir firefox y teclear:
http://localhost:3000

Instalar jruby:
echo ">=dev-util/jay-1.1.1-r2 java" >> /etc/portage/package.use

# emerge -av jruby
These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] dev-java/javatoolkit-0.3.0-r6  17 kB
[ebuild  N     ] dev-java/ant-core-1.8.1  USE="-doc -source" 5,740 kB
[ebuild  N     ] dev-java/ant-nodeps-1.8.1  0 kB
[ebuild  N     ] dev-java/jcodings-1.0.4  USE="-source" 89 kB
[ebuild  N     ] dev-java/xml-commons-external-1.3.04  USE="-doc -source" 645 kB
[ebuild  N     ] dev-java/joda-time-1.6  USE="-doc -examples -source -test" 1,242 kB
[ebuild  N     ] dev-java/constantine-0.7  USE="-source -test" 65 kB
[ebuild  N     ] dev-java/bcel-5.2-r2  USE="-doc -findbugs -source" 256 kB
[ebuild   R    ] dev-util/jay-1.1.1-r2  USE="java* -mono" 0 kB
[ebuild  N     ] dev-java/jline-1.0  USE="-source -test" 453 kB
[ebuild  N     ] dev-java/javacup-0.11a_beta20060608  USE="-doc -source" 280 kB
[ebuild  N     ] dev-java/xjavac-20110814  3 kB
[ebuild  N     ] dev-java/xml-commons-resolver-1.2  USE="-doc -source" 257 kB
[ebuild  N     ] dev-java/touchgraph-graphlayout-1.22  USE="-source" 199 kB
[ebuild  N     ] dev-java/jgraph-5.12.0.4  USE="-doc -examples -source" 3,380 kB
[ebuild  N     ] dev-java/junit-3.8.2-r1  USE="-doc -source" 451 kB
[ebuild  N     ] dev-java/java-getopt-1.0.13  USE="-doc -source" 45 kB
[ebuild  N     ] dev-java/log4j-1.2.16  USE="-doc -javamail -jms -jmx -source" 2,727 kB
[ebuild  N     ] dev-java/jakarta-oro-2.0.8-r2  USE="-doc -examples -source" 338 kB
[ebuild  N     ] dev-java/commons-logging-1.1.1  USE="-avalon-framework -avalon-logkit -doc -log4j -servletapi -source -test" 187 kB
[ebuild  N     ] dev-java/bytelist-1.0.6  USE="-source -test" 15 kB
[ebuild  N     ] dev-java/jffi-1.0.0  USE="-source -test" 1,590 kB
[ebuild  N     ] dev-java/xalan-serializer-2.7.1  USE="-doc -source" 6,138 kB
[ebuild  N     ] dev-java/nailgun-0.7.1  USE="-doc -source -test" 1,455 kB
[ebuild  N     ] dev-java/jgrapht-0.7.3  USE="-doc -source -test" 1,113 kB
[ebuild  N     ] dev-java/jnr-x86asm-0.1  USE="-doc -source" 82 kB
[ebuild  N     ] dev-java/jvyamlb-0.2.5  USE="-source -test" 1,727 kB
[ebuild  N     ] dev-java/xerces-2.9.1  USE="-doc -examples -source" 1,672 kB
[ebuild  N     ] dev-java/xalan-2.7.1  USE="-doc -source" 0 kB
[ebuild  N     ] dev-java/bsf-2.4.0-r1  USE="-doc -examples -javascript -python -source -tcl" 293 kB
[ebuild  N     ] dev-java/ant-owanttask-1.1-r12  10 kB
[ebuild  N     ] dev-java/asm-3.2  USE="-doc -source" 832 kB
[ebuild  N     ] dev-java/jaffl-0.5.1  USE="-doc -source -test" 546 kB
[ebuild  N     ] dev-java/joni-1.1.4  USE="-source" 118 kB
[ebuild  N     ] dev-java/jnr-posix-1.1.4  USE="-source -test" 191 kB
[ebuild  N     ] dev-java/jnr-netdb-1.0.1  USE="-doc -source -test" 656 kB
[ebuild  N     ] dev-java/jruby-1.5.6  USE="ssl -bsf -doc -source -test" 10,905 kB
[ebuild   R    ] dev-ruby/rubygems-1.3.7-r1  USE="-doc -server" RUBY_TARGETS="jruby* -ree18 -ruby18*" 0 kB
[ebuild  NS    ] virtual/rubygems-2 [1] RUBY_TARGETS="(jruby)" 0 kB
[ebuild  N     ] dev-ruby/bouncy-castle-java-1.5.0146.1  USE="-test" RUBY_TARGETS="jruby" 1,945 kB
[ebuild  N     ] dev-ruby/jruby-openssl-0.7.4  USE="-doc -test" RUBY_TARGETS="(jruby)" 609 kB

Total: 41 packages (38 new, 1 in new slot, 2 reinstalls), Size of downloads: 46,250 kB

Would you like to merge these packages? [Yes/No] y

MySQL para Ruby:

# emerge -av dev-ruby/dbd-mysql

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] dev-ruby/mysql-ruby-2.8.2  USE="-test" RUBY_TARGETS="ruby18 -ree18" 32 kB
[ebuild  N     ] dev-ruby/deprecated-2.0.1-r1  USE="-test" RUBY_TARGETS="ruby18 -jruby (-ruby19)" 13 kB
[ebuild  N     ] dev-ruby/ruby-postgres-0.7.9.20080128-r2  USE="-test" RUBY_TARGETS="ruby18 -ree18" 32 kB
[ebuild  N     ] dev-ruby/ruby-dbi-0.4.3  USE="mysql postgres sqlite -examples -odbc -sqlite3 -test" RUBY_TARGETS="ruby18" 80 kB
[ebuild  N     ] dev-ruby/dbd-mysql-0.4.4  USE="-test" RUBY_TARGETS="ruby18" 56 kB
[ebuild  N     ] dev-ruby/dbd-pg-0.3.8  USE="-test" 64 kB
[ebuild  N     ] dev-ruby/dbd-sqlite-0.1.2  USE="-test" 52 kB

Total: 7 packages (7 new), Size of downloads: 327 kB

Would you like to merge these packages? [Yes/No] y

>>> Verifying ebuild manifests

>>> Starting parallel fetch
....

$ sudo gem install mysql
Password: 
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
Installing RDoc documentation for mysql-2.8.1..

Iniciar un nuevo proyecto Ruby on Rails utilizando MysQL:
$ rails new webservmysql -d mysql
 create  
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
...

$ cd webservmysl

En otra terminal:
MySQL debe estar iniciado:
# /etc/initd/mysql start

$ mysql -u root -p
Enter password:




mysql> CREATE DATABASE webservmysql;
Query OK, 1 row affected (0.00 sec)

mysql> use webservmysql;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> show tables;

+------------------------+
| Tables_in_webservmysql |
+------------------------+
| schema_migrations      |
+------------------------+
1 row in set (0.00 sec)


El archivo database.yml se verá así:
carlos@hypatia ~/code/webservmysql/config $ vi database.yml


Crear un modelo y migrar la base de datos (creará la tabla Persona):

carlos@hypatia ~/code/webservmysql $ rails g model Persona nombre:string      invoke  active_record
      create    db/migrate/20111127091342_create_personas.rb
      create    app/models/persona.rb
      invoke    test_unit
      create      test/unit/persona_test.rb
      create      test/fixtures/personas.yml
carlos@hypatia ~/code/webservmysql $ rake db:migrate
==  CreatePersonas: migrating =================================================
-- create_table(:personas)
   -> 1.6301s
==  CreatePersonas: migrated (1.6303s) ========================================

Ahora si volvemos la terminal anterior y nuevamente hacemos un show tables veremos la tabla persona ya creada:

mysql> show tables;
+------------------------+
| Tables_in_webservmysql |
+------------------------+
| personas               |
| schema_migrations      |
+------------------------+
2 rows in set (0.00 sec)





Linux es genial!.

sábado, 12 de noviembre de 2011

Mover usr a otra particion

Mover /usr a una partición independiente. Todo el proceso lo he realizado en un terminal desde gentoo.
Las etiquetas permiten la identificación de las particiones:

# tune2fs -L usr_gentoo /dev/sda8
tune2fs 1.41.14 (22-Dec-2010)

Sacando información del disco duro, hay varias maneras de conseguirlo:
# blkid
/dev/sda1: LABEL="boot" UUID="3bb6187d-1918-4512-96f3-2ed42fc50c19" TYPE="ext2"
/dev/sda2: LABEL="squeeze" UUID="33b01f6e-1e74-4225-84b5-a66c568b38aa" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda3: LABEL="gentoo" UUID="86fd2e13-119f-4efb-aedd-aa5ebd7c77a8" TYPE="ext4"
/dev/sda5: UUID="afa7c31e-c8bf-41f5-a340-78da2c230362" TYPE="swap"
/dev/sda6: LABEL="squeeze_home" UUID="cd3805eb-25b6-4ba4-b99e-7575407f05be" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda7: LABEL="data" UUID="1ddcb07d-b322-4039-837b-48f3daef1426" TYPE="ext3"
/dev/sda8: LABEL="usr_gentoo" UUID="18536501-37ee-4f40-a362-2d9173c43856" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda9: UUID="a7163b55-b4c6-4e31-bf2b-8aeb6a34bdca" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda10: LABEL="home_gentoo" UUID="bff4d21b-d8cb-422d-8c91-b35c4e43ffbf" TYPE="ext3"
/dev/sda11: LABEL="portage" UUID="a0c335fb-2c70-43d3-9138-ff638e360f36" TYPE="reiserfs"

# ls -l /dev/disk/by-label/
total 0
lrwxrwxrwx 1 root root 10 Nov 12 18:54 boot -> ../../sda1
lrwxrwxrwx 1 root root 10 Nov 12 18:29 data -> ../../sda7
lrwxrwxrwx 1 root root 10 Nov 12 18:29 gentoo -> ../../sda3
lrwxrwxrwx 1 root root 11 Nov 12 18:29 home_gentoo -> ../../sda10
lrwxrwxrwx 1 root root 11 Nov 12 18:29 portage -> ../../sda11
lrwxrwxrwx 1 root root 10 Nov 12 18:54 squeeze -> ../../sda2
lrwxrwxrwx 1 root root 10 Nov 12 18:54 squeeze_home -> ../../sda6
lrwxrwxrwx 1 root root 10 Nov 12 18:36 usr_gentoo -> ../../sda8

# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0000bac9

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      210943      104448   83  Linux
/dev/sda2          210944    51410943    25600000   83  Linux
/dev/sda3        51410944   112850943    30720000   83  Linux
/dev/sda4       112852990   976771071   431959041    5  Extended
Partition 4 does not start on physical sector boundary.
/dev/sda5       112855040   117049343     2097152   82  Linux swap / Solaris
/dev/sda6       117051392   137531391    10240000   83  Linux
/dev/sda7       137533440   485693439   174080000   83  Linux
/dev/sda8       485695488   527927295    21115904   83  Linux
/dev/sda9       527929344   550371327    11220992   83  Linux
/dev/sda10      550373376   574251007    11938816   83  Linux
/dev/sda11      574259553   606453749    16097098+  83  Linux
Partition 11 does not start on physical sector boundary.

# cd /
# mkdir usr_nuevo
# mount -v -t ext3 /dev/sda8 /usr_nuevo/
# rm -rf /usr_nuevo/*
# cp -dpR /usr/* /usr_nuevo/
# umount /usr_nuevo
# mv /usr /usr_antiguo
# mkdir /usr
# mount /dev/sda8 /usr
# mount -a

Agregar entrada a /etc/fstab:
# vi /etc/fstab
# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed; notail increases performance of ReiserFS (at the expense of storage
# efficiency).  It's safe to drop the noatime options if you want and to
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#
#                                          

 # NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
/dev/sda1     /boot          ext2       noauto              1 2
/dev/sda3     /              ext4       noatime             1 1
/dev/sda5     none           swap       sw                  0 0
/dev/sda8     /usr           ext3       auto,noatime        0 1
/dev/sda10    /home          ext3       defaults,noatime    0 2
/dev/sda11    /usr/portage   reiserfs   defaults           0 0
/dev/sda7     /media/data    ext3       defaults,noatime   0 0
/dev/cdrom    /mnt/cdrom     auto       noauto,ro           0 0
#/dev/fd0     /mnt/floppy    auto       noauto             0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for
# POSIX shared memory (shm_open, shm_unlink).
# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
#  use almost no memory if not populated with files)
 shm          /dev/shm    tmpfs     nodev,nosuid,noexec     0 0


Comprobando:
# mount
rootfs on / type rootfs (rw)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
udev on /dev type tmpfs (rw,nosuid,relatime,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)
/dev/sda3 on / type ext4 (rw,noatime,commit=0)
rc-svcdir on /lib64/rc/init.d type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1024k,mode=755)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)
/dev/sda8 on /usr type ext3 (rw,noatime,commit=0)
/dev/sda10 on /home type ext3 (rw,noatime,commit=0)
/dev/sda11 on /usr/portage type reiserfs (rw)
/dev/sda7 on /media/data type ext3 (rw,noatime,commit=0)
usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85)

Es el momento de reiniciar el sistema. He reiniciado y todo funciona perfectamente.
Puede borrar el directorio /usr_antiguo.
# rm -rf /usr_antiguo

Linux es genial!.

domingo, 6 de noviembre de 2011

PostgreSQL


Instalar PostgreSQL, phppgadmin en Gentoo.

Fuente: http://www.gentoo.org/doc/es/postgres-howto.xml
http://www.codigolibre.org


En mi sistema gentoo-linux actual tengo instalado el servidor web apache, el gestor de base de datos mysql y php. Instalar postgresql y phppgadmin, crear la base de datos sacademico y ejecutar un script para importar la estructura de las tablas y los datos, así lo hice:

Añadir al fichero /etc/make.conf la use postgres
# emerge -av postgresql-server

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   N   ] dev-db/postgresql-server-9.0.5  USE="nls pam xml -doc -perl -pg_legacytimestamp -python (-selinux) -tcl -uuid" LINGUAS="en es -af -cs -de -fa -fr -hr -hu -it -ko -nb -pl -pt_BR -ro -ru -sk -sl -sv -tr -zh_CN -zh_TW" 0 kB

Total: 1 package (1 install), Size of downloads: 14,015 kB

Would you like to merge these packages? [Yes/No]

Editar el fichero /etc/conf.d/postgresql-9.0, para el idioma castellano PG_INITDB_OPTS="--locale=es_ES.UTF-8":
# vim /etc/conf.d/postgresql-9.0

# Location of configuration files
 PGDATA="/etc/postgresql-9.0/"

 # Where the data directory is located/to be created
 DATA_DIR="/var/lib/postgresql/9.0/data"

 # Additional options to pass to initdb.
 # See 'man initdb' for available options.
 PG_INITDB_OPTS="--locale=en_US.UTF-8"

Crear el cluster de base de datos y almacenar los ficheros relacionados con el servidor en PGDATA y DATA_DIR.
# emerge --config dev-db/postgresql-server:9.0

Cambiando 'trust' a 'password' para las conexiones a localhost
vim /etc/postgresql-9.0/pg_hba.conf
# "local" is for Unix domain socket connections only
 local   all             all                        trust
 # IPv4 local connections:
 host    all             all       127.0.0.1/32     trust
 # IPv6 local connections:
host    all             all        ::1/128          trust

Agregar usuario al grupo postgres:
# gpasswd -a carlos postgres

Iniciar el servidor
# /etc/init.d/postgresql-9.0 start
 * Caching service dependencies ...           [ ok ]
 * Starting PostgreSQL ...                    [ ok ]

Abrir una conexión al servidor y cambiar la contraseña:
# psql -U postgres
psql (9.0.3)
Type "help" for help.

postgres=# \password
Enter new password:
Enter it again:
postgres=# \q

Crear un usuario y su password:
# su - postgres
 psql -U postgres
postgres@hypatia ~ $ createuser sacademico -Ws

Clave: kikla
postgres@hypatia ~ $ createdb sacademico


Enlace al script:

enlace_descarga_dhypatia.sql

*Insertar el script bdhypatia.sql:
postgres@hypatia:~$psql sacademico < bdhypatia.sql -U postgres

# /etc/init.d/postgresql-9.0 reload
postgresql-9.0 | * Reloading PostgreSQL configuration ...  [ ok ]

Iniciar postgresql con el sistema:
# rc-update add postgresql-9.0 default
 * service postgresql-9.0 added to runlevel default

Instalar phppgadmin

# emerge -av phppgadmin
Recompila php con soporte postgres e instala phppgadmin.

Para poder logearnos via navegador (/http://localhost/phppgadmin y no recibir un mensaje login failed será necesario editar el fichero /var/www/localhost/htdocs/phppgadmin/conf/config.inc.php y agregar 'localhost':
# vim /var/www/localhost/htdocs/phppgadmin/conf/config.inc.php

// use 'localhost' for TCP/IP connection on this computer
   $conf['servers'][0]['host'] = 'localhost';

# /etc/init.d/postgresql-9.0 reload



Linux es genial!.

viernes, 4 de noviembre de 2011

Fortune


Instalar fortune en Gentoo

# emerge -av fortune-mod

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] games-misc/fortune-mod-1.99.1-r2  USE="-offensive" 1,770 kB

Total: 1 package (1 new), Size of downloads: 1,770 kB

Would you like to merge these packages? [Yes/No]

Utilizaremos este codigo para llamar fortune desde /etc/bash/bashrc. Agregar al final del archivo:
# vim /etc/bash/bashrc

if [ $TERM != "dumb" ]; then
 fortune
fi

Al abrir una terminal comprobamos el resultado:

Instalar FBReader.

FBReader es un e-book reader. Soporta los principales formatos e-book y nos permitirá leer ebook's desde nuestro pc. Para Gentoo y gnome:
# echo "app-text/fbreader gtk -debug -qt4"
# emerge -av fbreader

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] app-text/fbreader-0.12.10  USE="gtk -debug -qt4" 0 kB

Total: 1 package (1 install), Size of downloads: 2,383 kB
Would you like to merge these packages? [Yes/No] y


Linux es genial!.