Feeds

OpenBSD 4.9 incorpora el sistema /etc/rc.d

LibreSoft Planet - Wed, 2011-05-04 17:23
Algo de historia  

Como cualquier administrador de sistemas Unix sabe, init es el primer proceso en ejecución tras la carga del kernel, y da inicio a los demonios ("servicios") estándar del sistema. En el Unix original de Bell Labs, el proceso init arrancaba los servicios de userland mediante un único script de shell denominado /etc/rc. La Distribución de Berkeley añadió años después otro script denominado /etc/rc.local para arrancar otros servicios. 

Esto funcionó así durante años, hasta que Unix se fue fragmentando y, con la aparición del software empaquetado de terceros, la versión System V del Unix de AT&T introdujo un nuevo esquema de directorios en /etc/rc.d/ que contenía scripts de arranque/parada de servicios, ordenados por orden de arranque, con una letra-clave delante del nombre de fichero (S- arrancar servicios y K- detener el servicio). Por ejemplo: S19mysql inicia [S] el servicio mysql. Estos scripts (situados en /etc/init.d) se distribuyeron en niveles de ejecución (runlevels, descritos en /etc/inittab), asociando los scripts con enlaces simbólicos en cada nivel de ejecución (/etc/rc0.d, rc1.d, rc2.d, etc.). Los niveles de ejecución en cada directorio representan la parada, el reinicio, arranque en monousuario o multiusuario, etc. Este esquema, conocido como "System V" (o "SysV"), es, por ejemplo, el que adoptaron las distribuciones de Linux (con algunas diferencias entre ellas en cuanto a la ubicación de subdirectorios y scripts). Tenía la ventaja de evitar el peligro de que cualquier error de sintaxis introducido por un paquete pudiera abortar la ejecución del único script y por tanto dejar el sistema en un estado inconsistente. A cambio, introdujo cierto grado de complejidad en la gestión y mantenimiento de scripts de inicio, directorios, enlaces simbólicos, etc. 

Otros sistemas de tipo Unix, como los BSD, mantuvieron el esquema tradicional y simple de Unix, con solo uno o dos únicos ficheros rc y sin niveles de ejecución[*], si bien fueron incorporando algunos otros aspectos del esquema SysV de inicialización de los servicios del sistema. Por ejemplo, NetBSD incluyó un sistema de inicio System V similar al de Linux, con scripts individuales para controlar servicios, pero sin runlevels. FreeBSD, a su vez, integró en 2002 el sistema rc.d de NetBSD y actualmente cuenta con decenas de demonios de inicio que funcionan de forma análoga a SysV: 

$ /etc/rc.d/sshd restart

 

OpenBSD incorpora /etc/rc.d

 

OpenBSD, sin embargo, no había adoptado hasta ahora el subsistema de scripts individuales para controlar los servicios, lo que a veces causaba cierto pánico, como si les faltase algo esencial, a quienes desde el mundo Linux (u otros Unices)

entraban por primera vez en contacto con este sistema (aunque luego la cosa tampoco era tan grave, es cuestión de hábitos). La actual versión OpenBSD 4.8, publicada en noviembre de 2010, todavía utiliza únicamente dos scripts de inicio (/etc/rc y /etc/rc.local). En OpenBSD 4.9, que se publicará el próximo 1 de mayo, se ha implementado por primera vez esta funcionalidad mediante el directorio /etc/rc.d

Como suele ser habitual en OpenBSD, no se implementa algo hasta que se está seguro que se gana algo y que hay un modo sencillo y fiable de utilizarlo para el usuario final. El mecanismo es análogo al de otros sistemas de tipo Unix, pero más sencillo y con algunas sutiles e importantes diferencias que vale la pena conocer. Veámoslo. 


Descripción del nuevo subsistema /etc/rc.d de OpenBSD  

En /etc/rc.conf (donde se incluye las variables de configuración para el script rc)  nos encontraremos una nueva variable denominada rc_scripts: 

# rc.d(8) daemons scripts # started in the specified order and stopped in reverse order rc_scripts=

Incluimos en esa variable (o mejor, como se recomienda siempre, en /etc/rc.conf.local, un fichero opcional que sobreescribe las variables de /etc/rc.conf) los demonios que deseamos arrancar de inicio, por orden de arranque:

rc_scripts="dbus_daemon mysql apache2 freshclam clamd cupsd"

Los scripts de inicio de servicios residirán, como suele ser habitual, en el directorio /etc/rc.d. Pero una diferencia clave es que, aunque los scripts estén ahí situados, no arrancará nada automáticamente que no esté listado en la variable rc_scripts, siguiendo el principio de OpenBSD de evitar presumir automatismos predeterminados. Cada script responderá a las siguientes acciones:

  • start    Arranca el servicio si no está ya corriendo.
  • stop     Detiene el servicio.
  • reload   Ordena al demonio que recargue su configuración.
  • restart  Ejecuta una parada del demonio (stop), y a continuación lo inicia (start).
  • check    Devuelve 0 si el demonio está corriendo o 1 en caso contrario. 

Actualmente, este sistema solo se usa para demonios instalados desde paquetes, no para el sistema base de OpenBSD. Por ejemplo, para gestionar los estados del servicio "foobar", que habremos antes instalado desde ports o paquetes, basta ejecutar:

/etc/rc.d/foobar reload /etc/rc.d/foobar restart /etc/rc.d/foobar check /etc/rc.d/foobar stop

La última orden ("stop") se invoca también en un reinicio (reboot) o parada (shutdown) desde /etc/rc.shutdown, en orden inverso al que aparece en la variable en rc_scripts, antes de que se ejecute la orden "stop/reboot" para todo el sistema. No es necesario preocuparse por el orden de ejecución o por el significado de S17 al comienzo del nombre de los scripts.

Otra ventaja de esta implementación es lo extraordinariamente sencillos que es escribir esos scripts, frente a otras implementaciones que precisan scripts de decenas o incluso cientos de líneas. En su forma más simple:

daemon="/usr/local/sbin/foobard" . /etc/rc.d/rc.subr rc_cmd $1

Un ejemplo algo más complejo:

#!/bin/sh # # $OpenBSD: specialtopics.html,v 1.15 2011/03/21 21:37:38 ajacoutot Exp $ daemon="${TRUEPREFIX}/sbin/munin-node" . /etc/rc.d/rc.subr pexp="perl: ${daemon}" rc_pre() { install -d -o _munin /var/run/munin } rc_cmd $1

Como puede observarse, el script típico solo necesita definir el demonio, incluir /etc/rc.d/rc.subr y opcionalmente definir una expresión regular diferente a la predeterminada para pasársela a pkill(1) y pueda encontrar el proceso deseado (la expresión por defecto es "${daemon} ${daemon_flags}").

El nuevo script debe colocarse en ${PKGDIR} con extensión .rc, por ejemplo foobard.rc. TRUEPREFIX se sustituirá automáticamente en el momento de instalarlo.

La sencillez y limpieza es posible gracias al subsistema rc.subr(8), un script que contiene las rutinas internas y la lógica más compleja para controlar los demonios. Así y todo, es muy legible y contiene menos de 100 líneas. Existe también una plantilla para los desarrolladores de paquetes y ports que se distribuye en "/usr/ports/infrastructure/templates/rc.template".

Y eso es todo. Cualquier "port" o paquete que necesite instalar un demonio puede beneficiarse ahora de los scripts rc.d(8). Quizá el nuevo sistema no cubra todos los supuestos, pero cubre las necesidades de los desarrolladores de ports para mantener un sistema estándar y sencillo para arrancar servicios). En marzo de 2011, ya hay más de 90 ports de los más usados que los han implementado. Por supuesto, el viejo sistema sigue funcionando en paquetes no convertidos, pero es indudable que los desarrolladores de OpenBSD (especial mención para Antoine Jacuotot (jacuotot@) y Robert Nagy (robert@)) han logrado una vez más un buen balance entre simplicidad y funcionalidad. Por supuesto, para ampliar detalles, nunca debe eludirse leer las páginas correspondientes del manual: rc.subr(8), rc.d(8), rc.conf(8) y rc.conf.local(8) y la documentación web


Referencias


(*) Que BSD no implemente "/etc/inittab" o "telinit" no significa que no tenga niveles de ejecución (runlevels), simplemente es capaz de cambiar sus estados de inicio mediante otros procedimientos, sin necesidad de "/etc/inittab".

 
Categories: FLOSS Research

Brief study of the Android community

LibreSoft Planet - Mon, 2011-04-18 12:19

Libre software is changing the way applications are built by companies, while the traditional software development model does not pay attention to external contributions, libre software products developed by companies benefit from them. These external contributions are promoted creating communities around the project and will help the company to create a superior product with a lower cost than possible for traditional competitors. The company in exchange offers the product free to use under a libre software license.

Android is one of these products, it was created by Google a couple of years ago and it follows a single vendor strategy. As Dirk Riehle introduced some time ago it is a kind of a economic paradox that a company can earn money making its product available for free as open source. But companies are not NGOs, they don't give away money without expecting something in return, so where is the trick?

As a libre software project Android did not start from scratch, it uses software that would be unavailable for non-libre projects. Besides that, it has a community of external stakeholders that improve and test the latest version published, help to create new features and fix errors. It is true that Android is not a project driven by a community but driven by a single vendor, and Google does it in a very restricted way. For instance external developers have to sign a Grant of Copyright License and they do not even have a roadmap, Google publish the code after every release so there are big intervals of time where external developers do not have access to the latest code. Even with these barriers there are a significant part of the code that is being provided from external people, it is done directly for the project or reused from common dependencies (GIT provides ways to reuse changes done to remote repositories).


The figures above reflect the monthly number of commits done by people split up in two, in green colour commits from mail domains google.com or android.com, the study assumes that these persons are Google employees. On the other hand in grey colour the rest of commits done by other mail domains, these ones belong to different companies or volunteers.

According to the first figure (on the left), which shows the proportion of commits, during the first months that were very active (March and April 2009) the number of commits from external contributors was similar to the commits done by Google staff. The number of external commits is also big in October 2009, when the total amount of commits reached its maximum. Since April 2009 the monthly activity of the external contributors seems to be between 10% and 15%.

The figure on the left provides a interesting view of the total activity per month, two very interesting facts here: the highest peak of development was reached during late 2009 (more than 8K commits per month during two months). The second is the activity during the last months, as it was mentioned before the Google staff work in private repositories so until they publish the next version of Android, we won't see another peak of development (take into account that commits in GIT will modify the history when the code is published, thus the last months in the timeline will be overwritten during the next release)


More than 10% of the commits used by Google in Android were committed using mail domains different to google.com or android.com. At this point the question is: who did it?

(Since October 2008) # Commits Domain 69297 google.com 22786 android.com 8815 (NULL) 1000 gmail.com 762 nokia.com 576 motorola.com 485 myriadgroup.com 470 sekiwake.mtv.corp.google.com 422 holtmann.org 335 src.gnome.org 298 openbossa.org 243 sonyericsson.com 152 intel.com



Having a look at the name of the domains, it is very surprising that Nokia is one of the most active contributors. This is a real paradox, the company that states that Android is its main competition helps it!. One of the effects of using libre software licenses for your work is that even your competition can use your code, currently there are Nokia commits in the following repositories:

  • git://android.git.kernel.org/platform/external/dbus
  • git://android.git.kernel.org/platform/external/bluetooth/bluez


This study is a ongoing process that should become a scientific paper, if you have feedback please let us know.



CVSAnalY was used to get data from 171 GIT repositories (the Linux kernel was not included). Our tool allow us to store the metadata of all the repositories in one SQL database, which helped a lot. The study assumes that people working for Google use a domain @google.com or @android.com.

 

References:

Categories: FLOSS Research

AR interface in Android using phoneGap

LibreSoft Planet - Tue, 2011-03-29 06:51

Since 6 months ago we have evaluated the possibility to implement a new AR interface (based in our project ARviewer) using phoneGap. phoneGap is a mobile framework based in HTML5/JS that allow execute the same source code HTML5 in differents mobile platforms (iphone, android, blackberry). It seem a good way to create portable source code. Since 3 years ago I work in this project with Raúl Román, a crack coder!!

Currently using phoneGap is not possible obtain the stream camera in the webView widget. So, this part of the source code must be developed in the native platform. We find another problem. We could not put the webview transparent so it would look the camera in the background, and paint objects on top with HTML. In this case, we asked for this to David A. Lareo (Bcultura) and Julio Rabadán (Somms.net) and gave us some very interesting clues about this problem.

The solution is implemented in the source code that you can see below. It's necessary that our main view (R.layout.main) is the main view, for this we do 'setContentView' and later we add the main view of 'DroidGap' using 'addview' and 'getParent'. Once we have our view mixed with phonegap main view, we set the backgroundColor transparent.

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.init(); super.loadUrl("file:///android_asset/www/index.html"); setContentView(R.layout.main); RelativeLayout view = (RelativeLayout) findViewById(R.id.main_container); // appView is the WebView object View html = (View)appView.getParent(); html.setBackgroundColor(Color.TRANSPARENT); view.addView (html, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); appView.setBackgroundColor(Color.TRANSPARENT); }  

  Currently, we have started this project so I will post the full source code in this blog
Categories: FLOSS Research

Amarok Code Swarm

Paul Adams: Green Eggs and Ham - Fri, 2009-08-21 06:52

In my previous entry it was commented that it would be nice to see a code swarm for Amarok's history in SVN. Well... go on then.

Code Swarm is a tool which gives a time-based visualisation of activity in SVN. Whilst code swarm are often very pretty and fun to look at for 15 minutes, they are not very informative. Much of what appears is meaningless (e.g. the entry point of the particles) and some of it is ambiguous (e.g. the movement of particles).

Anyhow, I was surprised to see that someone hadn't already made one of these for Amarok. So, here it is:

Amarok Code Swarm from Paul Adams on Vimeo.

Categories: FLOSS Research

Amarok's SVN History - Community Network

Paul Adams: Green Eggs and Ham - Thu, 2009-08-20 09:08

I did not include a "who has worked with whom" community network graph in my previous post on the history of Amarok in SVN. This was largely because that blog post was written quite late and I didn't want to wait ages for the community network graph to be generated.

Well, now I have created it.


Click here for the complete, 8.1MB, 5111x3797 version

So, just to remind you... SVN accounts are linked if they have both worked on the same artifact at some point. The more artifacts they share, the closer together the SVN accounts are placed. The result of this is that the "core" community should appear closer to the middle of the graph.

Categories: FLOSS Research

Amarok's SVN History

Paul Adams: Green Eggs and Ham - Tue, 2009-08-18 17:25

So, as you might have recently seen, Amarok has now moved out of SVN. This was SVN r1002747 on 2009-07-26. Amarok first appeared in /trunk/kdeextragear-1/amarok on 2003-09-07 (r249141) thanks to an import from markey. It was migrated the to simplified extragear structure (/trunk/extragear/multimedia/amarok) at r409209 on 2005-05-04.

So, to mark this event I have created a green blob chart and a plot of daily commits and committers for the entire time Amarok was in SVN.

Simply right-click and download the green blobs to see them in their full-scale glory. I'm sorry the plot isn't too readable. It is caused by a recent day where there appears to be about 300 commits in Amarok; way above the average. I assume this is scripty gone mad again.

Categories: FLOSS Research

Archiving KDE Community Data

Paul Adams: Green Eggs and Ham - Sun, 2009-08-16 08:23

So me and my number crunching have been quiet for a couple of months now. Since handing in my thesis I have been busier than ever. One of the things keeping me busy has been to make good on a promise I made a while back...

I have, for some time, promised to create a historical archive of how KDE "looked" in the past. To achieve this I have created SVN logs for each calendar month of KDE's history and ran various scripts that I have against them. Here's a few examples for August 1998....

Community Network

A community network graph is a representation of who was working with whom in the given month. You may remember that I have shown these off once or twice before. The nodes are SVN accounts and they share an edge when they have shared an artefact in SVN. The more artefacts that the pair have shared, the closer they are placed together. The result is that the community's more central contributors should appear towards the middle of the plot.

Your browser does not support SVG.

The Green Blobs

Yes, they're back! For the uninitiated the green blobs are representation of who committed in a given week. Read the chart from top to bottom and left to right. The date of the first commit and the % of weeks used are also given.

Commits and Committers

I have also gathered basic number of commits and committers per day and created plots, like this...

Your browser does not support SVG. So, I now have a few things to do:
  • Firstly, I need to find a place where I can store all these images and the source data where they are easily accessible. They will go online somewhere.
  • Secondly, I need to keep taking logs and keeping this archive up-to-date.
  • I also need to create a sensible means for generating SVG versions of the Green Blobs. This was an issue raised back at Akademy in Glasgow and still hasn't been addressed. I'm generally moving all of my visualisations to SVG these days.

In time I will add visualisations for things like email activity as well. If you have any ideas of aspects of the community you want visualised just let me know and I'll see what I can do. In particular, if you want me to run these jobs for your "bit" of KDE (e.g. Amarok, KOffice), just give me a shout and I'll see if I can make time. Better still, why not lend me a hand? Once I have hosting for the visualisations I will be putting all my scripts up with them. Finally.

Whilst the historical data has been visualised for interest, I hope that the new charts, as they are produced, will be helpful for all sorts of activities: from community management and coordination to marketing. Oh... and research, of course.

Categories: FLOSS Research

OSS, Akademy and ICSM 2009

Paul Adams: Green Eggs and Ham - Mon, 2009-06-01 16:15

I've just arrived in Sweden for the 5th International Conference on Open Source Systems - OSS2009. This year the conference is being held in Skövde, Sweden. This year's keynote speakers will be Stormy Peters and Brian Behlendorf. I'm particularly keen to meet with Stormy who I haven't seen since GUADEC in Birmingham; it would be good to talk before GCDS.

I like OSS. It is a friendly crowd who turn up and the conference always has a good mix of "the usual suspects" and new faces. One of those new faces for this year is Celeste Lyn Paul of KDE Usability fame. Her paper, "A survey of usability practices in Free/Libre/Open Source Software" is presented on Friday. My paper, "Reassessing Brooks' Law for the Free Software Community", will get its outing on Thursday.

In my paper I present a new approach to assessing the role of Brooks' Law and its relevance to Free Software development. This is really a "work in progress" paper. At least it was when I wrote it....

... and having subsequently finished this work I have recently received confirmation that my full paper on this topic has been accepted as a full paper to the International Conference on Software Maintenance. This gives me a great opportunity to start adding to my "I'm going to..." banners.

I'm putting together tentative plans to hold a workshop at Akademy on software quality issues. The idea is for this to be a joint workshop for both KDE and GNOME and a showcase for some of the more import results from SQO-OSS, FLOSSMETRICS and QUALOSS EC-funded research projects. If you are interested in this, please let me know. Unless there is enough up-front support, it will be hard to arrange this.

Edit: Co-Author Fail

One of my co-author's has correctly pointed out that I have used "I" where I should have written "us" and failed to give credit to my co-authors. I apologise unreservedly to Andrea Capiluppi and Cornelia Boldyreff. I am not worthy.

Categories: FLOSS Research
Syndicate content