Trabajando en un repo de Debian

Actualización: Parece ser que ya lo han subido al repo oficial ^_^ , así que no tiene sentido mantener este.

Tras pasar las últimas horas dando palos de ciego he podido montar un repo de Debian, empaquetar M.A.R.S. y subirlo, la idea es hacer una recopilación de juegos libres que no estén en los repos oficiales (intentaría mandarlos ahí pero carezco de la constancia para mantenerlos y no es plan).

Teneis el repo en codigoparallevar.com/debian/ y la clave pública usada para firmar es la de siempre 0x453125AC

Y ya va siendo hora de parar por hoy...

ps: Por ahora solo soporta amd64 y no tiene permitido el listado de entradas de directorio, ya lo puliré. La configuración sería esta:

1
2
deb http://codigoparallevar.com/debian/ unstable/$(ARCH)/
deb-src http://codigoparallevar.com/debian/ unstable/source/

Editing files in place

Reading the rsync(1) manpages, the option --inplace documentation alerts of:

In-use binaries cannot be updated (either the OS will prevent this from happening, or binaries that attempt to swap-in their data will misbehave or crash).

Some time ago I tried to write a program which would modify it's own binary to save data (without a specific motivation), but it resulted in errors when modifing it's binary while in use, also, it's possible (in POSIX systems) to delete files used in that moment. The read of the option above showed a viable path to do this, so here is the program which modifies it's own binary to save a number, it does this by loading the file in memory, unlinking it and creating a new one... probably the memory address location could be done in a more sofisticated manner, but it's only a test program.

May give a warning at compile-time, memmem doesn't get away well with volatile values, but this property is needed to make sure that structure is not optimized out.

Editando archivos en uso

Leyendo el manual de rsync(1), en la documentación de la opción --inplace avisa de que:

In-use binaries cannot be updated (either the OS will prevent this from happening, or binaries that attempt to swap-in their data will misbehave or crash).

Resulta que hace un tiempo había intentado hacer un programa que modificara su propio binario para guardar datos (sin ningún motivo concreto), pero resultaba en errores al modificar el propio archivo mientras aún estaba en uso, además es posible (en sistemas POSIX) eliminar archivos en uso. La lectura de la opción de antes encendió una bombilla, he aquí ese programa que modifica su binario para guardar un número, lo hace cargando su propio archivo en memoria, eliminando el archivo y creando uno nuevo... probablemente la localización del punto en memoria se podía hacer de una forma más sofisticada, pero es solo un programilla de prueba.

Pueden dar warning al compilar, parece que no se porta muy bien con los

CM sin agentes de servidor? Prueba ansible

Hace unas semanas había hechado un vistazo a algunas herramientas de gestión de la onfiguración como chef, puppet y salt, pero lo dejé cuando vi que requerían un servicio en el servidor donde se instalaran.

Pues bien, resulta que este sábado, en el hackmeeting se habló de ansible, una herramienta para este propósito escrita en python. Me perdí la charla pero hoy le heché un vistazo a la página web

Ansible is a radically simple IT orchestration engine that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.

Eso suena muy, muy bien, ando probándolo y por ahora anda genial, quizá es lo que estabas buscando :P.

Server-side-agentless CM? Check ansible

Some weeks ago I looked at some configuration management tools like chef, puppet and salt, but I gave up when noticed that a server side agent was required.

Fast-forward to this saturday, at the hackmeeting there was a talk about ansible, a tool for this purpose written in python. I didn't attended the talk but today I looked the website

Ansible is a radically simple IT orchestration engine that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.

That looks really, really good, I'm testing it now and works great, it may be what you where looking for :P.

Detecting errors on flight with emacs

The “classic” editors like Emacs and VIM may seem a far surpased thing when nowadays IDEs like NetBeans or Eclipse can detect errors on the code without having to wait to manually compile it to find them (even though this happens mostly with Java, for some strange reason...), nevertheless the modularity of these editors allows to do this fairly simply.

Emacs includes by defaun a “minor-mode” named flymake which allows to do this but some configurations may be needed depending on the language, the Emacs wiki describes how to do i for a number of languages.

But, what if the language is not supported, like Flex or assembler? The solution is simply to write a Makefile with a check-syntax entry which runs the compiling/assembling command on the $(CHK_SOURCES) files, for example:

1
2
3
4
AS=nasm -g

check-syntax:
    $(AS) $(CHK_SOURCES) -o /dev/null
When activating flymake-mode, it may disable itself automatically because it interprets

Detectando errores al vuelo con emacs

Los editores “clásicos” como Emacs y VIM pueden parecer cosa del pasado cuando hoy en día IDEs como NetBeans o Eclipse detectan errores en el código sin necesidad esperar a compilarlo para encontrarlo (aunque esto se de sobre todo con Java, por algún extraño motivo...), sin embargo la extensionalidad de estos editores permite replicar esto sin grandes problemas.

Emacs incluye por defecto un “minor-mode” llamado flymake que permite hacerlo, aunque haya que hacer unas pequeñas configuraciones dependiendo del lenguaje, la Wiki de Emacs describe como hacerlo para unos cuantos lenguajes.

Pero, y si el lenguaje no está soportado, como Flex o ensamblador? La solución es sencilla, solo habrá que crear un Makefile con una entrada check-syntax que lance el comando adecuado sobre los archivos $(CHK_SOURCES), por ejemplo:

1
2
3
4
AS=nasm -g

check-syntax:
    $(AS) $(CHK_SOURCES) -o /dev/null

Detectando el lenguaje de un texto

A veces puede resultar útil detectar el lenguaje de un texto, en los sistemas NIX es habitual tener un directorio con listas de palabras habituales de varios idiomas, simplemente comparando la proporción de palabras de un texto que cae en esa lista a través de los distintos lenguajes da un número que parece* bastante significativo acerca de que idioma se trata.

Por ejemplo, probando esta aproximación sobre el texto traducido (en Markdown, sin convertir a HTML) de la entrevista de Snowden para Der Spiegel muestra los siguientes resultados:

1
2
3
4
5
6
7
$ python lang.py entrevista-de-edward-snowden-para-der-spiegel.txt
entrevista-de-edward-snowden-para-der-spiegel.txt [2341]

58.61%  spanish
51.60%  galician
29.18%  american-english
29.09%  british-english

Hacerlo sobre el texto de la GPLv3 (en inglés) resulta en:

1
2
3
4
5
6
7
$ python lang.py LICENSE
LICENSE [5251]

98.36%  american-english
98.15%  british-english
12.82%  spanish
10.68%  galician
Newer posts Older posts