Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa |
es:howtos:misc:anatomy_of_a_slackbuild [2020/01/19 17:52 (UTC)] – [Anatomía de un Slackbuild] rramp | es:howtos:misc:anatomy_of_a_slackbuild [2020/04/26 20:17 (UTC)] (actual) – Traducción completa. Comentarios y sugerencias son bienvenidos rramp |
---|
<!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> | <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> |
| |
<note>En proceso de traducción. --- //[[wiki:user:rramp|rramp]] 2020/01/13 16:26 (UTC)//</note> | |
====== Anatomía de un Slackbuild ====== | ====== Anatomía de un Slackbuild ====== |
| |
| |
En los días anteriores a Windows en Unix, un shell o Bourne Shell (Stephen Bourne, Bell Labs) fue una forma de comunicarse con el sistema. | En los días anteriores a Windows en Unix, un shell o Bourne Shell (Stephen Bourne, Bell Labs) fue una forma de comunicarse con el sistema. |
En reconocimiento a Stephen Bourne, Brian Fox lanzó una nueva versi{on en 1989 y la llamó *B**ourne **a**gain **Sh**ell (bash). | En reconocimiento a Stephen Bourne, Brian Fox lanzó una nueva versión en 1989 y la llamó *B**ourne **a**gain **Sh**ell (bash). |
| |
Si abrís una terminal en Slackware - es decir ''Menu -> System -> Console'' y tipeando en el $ prompt: | Si abrís una terminal en Slackware - es decir ''Menu -> System -> Console'' y tipeando en el $ prompt: |
| |
| |
In the same way the variable TAG is set to ''SBo'' and when the package is created this shows it's a "slackbuilt" package. If you look at packages in other repositories, you will see in the name eg ''chromium-77.0.3865.75-x86_64-1alien'' that the package is by Alien Bob. | De la misma forma la variable TAG es configurada a ''SBo'' y cuando el paquete es creado esto muestra esto es un paquete "slackbuilt". Si miras en los repositorio de los paquetes, deberías ver en el nombre del paquete que es de Alien Bob, por ejemplo ''chromium-77.0.3865.75-x86_64-1alien''. |
| |
The next block of code is as follows: | El próximo bloque de código es como sigue: |
| |
<code> | <code> |
</code> | </code> |
| |
In computer programming languages such as php, python and others including bash there are common practices and logic. One common principle is the procedure of having a test in code. A test is applied and of course there will be a result depending on the outcome. An example of a | En un lenguaje de programación tales como php, python y otros incluyendo bash hay algunas practicas comunes y lógicas. Un principio común es |
bash "if" block statement is: | el procedimiento de tener una prueba de código. |
| Una evaluación es aplicada y por supuesto que habrá una salida dependiendo del resultado. Un ejemplo de una sentencia "if" en un script bash es: |
| |
<code> | <code> |
if[ test condition] | if[ condición a evaluar] |
then | then |
code to be executed depending on result | código a ser ejecutado dependiendo del resultado |
fi | fi |
| |
</code> | </code> |
| |
In the above block, quite simply the "if" is the start of an If test condition and "fi" denotes the end of a If test condition. | En el bloque anterior, simplemente el "if" es el comienzo de una condición de prueba If y "fi" denota el final de una condición de prueba If. |
| |
Going back to bash for a minute you can set a bash variable like so | Volviendo al bash por un minuto, se puede establecer una variable bash de la siguiente manera |
<code> | <code> |
ARCH=something | ARCH=something |
</code> | </code> |
and you can get the value of a variable and see what value the variable "ARCH" contains by putting a dollar sign in In front of it like so: | y podes obtener el valor de una variables y ver el valor de la variable "ARCH" colocando un signo dolar de la siguiente forma: |
<code> | <code> |
echo $ARCH | echo $ARCH |
</code> | </code> |
| |
A -z flag can be used in an "if" statement to see if a string is empty. So lets have a look at the first line again and work out what it means. | Una bandera (flag) -z puede ser utilizada en una sentencia "if" para ver si una cadena de texto esta vaciá. Así que echemos un vistazo a la primera línea de nuevo y averigüemos lo que significa. |
| |
<code> | <code> |
</code> | </code> |
| |
In the above we don't need to see the value of ARCH; as long as we can access its value and be able to use it in the script. So the first part before the "then" simply equates to , if the value of the variable ARCH is expressed as a string and its value is empty, do something. ARCH could represent a string value of the architecture of the PC the script is running on. | En lo anterior no necesitamos ver el valor de ARCH; siempre y cuando podamos acceder a su valor y ser capaces de usarlo en el script. Así que la primera parte antes del "then" simplemente equivale a, si el valor de la variable ARCH se expresa como una cadena y su valor está vacío, haz algo. ARCH podría representar un valor de cadena de la arquitectura del PC en el que se está ejecutando el script. |
| |
Another common algorithm is called in for instance php is the "switch statement" . This put in its simplest terms is a list and the test is to see if a certain value you have can be found in that list. If its not found you can place on the line last in the list would you would like to do, if nothing is matched. | Otro algoritmo común es llamado, por ejemplo, php es la "sentencia switch". |
| En términos simples, es una lista con condiciones que se va evaluando. Si ninguna de las condiciones se cumple en las últimas líneas puede colocar lo que le gustaría hacer. |
| |
In bash its in principle the same idea but its referred to as "case statement" .In principle you can put anything you like in the case block, but if you think about the fact we want to find out the "architecture" of a computer and already know there are only certain possibilities then it makes sense to try out a couple of known possibilities in the list first and if there is no match do something to get an answer. arm and i586 are of course two types of computer architecture. | En bash en principio es la misma idea, pero se le llama "sentencia case". |
| Podes colocar lo que desees en los bloques case, pero si piensas en el hecho de que queremos averiguar la "arquitectura" de un ordenador y ya sabemos que sólo hay ciertas posibilidades, entonces tiene sentido probar primero un par de posibilidades conocidas en la lista y, si no hay ninguna coincidencia, hacer algo para obtener una respuesta. arm y i586 son dos tipos de arquitecturas de computadoras. |
| |
Now if you try out this code in a terminal window: | Ahora, si pruebas este código en una ventana de terminal: |
| |
<code> | <code> |
</code> | </code> |
| |
it should display the architecture of you PC, in my case its x86_64. | Esto muestra la arquitectura de tu PC, en mi caso es x86_64. |
| |
So to summarize regarding the block of code. First an "if" statement is run to see if the variable "ARCH" is empty. If there is a value for the ARCH variable nothing in the block of the "if" and inner "case" will run;but if an empty string is found (ARCH has no value) a "case statement" is run(within the if block of code) to find a match.If a match was found the variable ARCH would be set to the value of the match found, and the execution of the case would come to a stop. If the ARCH variable was empty and no match was found in the case list , then the bottom line comes int play which is: | Así que para resumir con respecto al bloque de código. Primero una sentencia "if" se ejecuta para ver si la variable "ARCH" está vacía. Si hay un valor para la variable ARCH, nada en el bloque de "if" y "case" interno se ejecutará; pero si una cadena vacía es encontrada (ARCH no tiene valor) una "sentencia case" es ejecutada (dentro del bloque de código if) para buscar una coincidencia. Si se encuentra una coincidencia la variable ARCH sera asignada con el valor de la coincidencia y la ejecución del case se detendría. Si la variable ARCH estaba vacía y no coincide con la lista, entonces entra en juego la línea que dice: |
| |
<code>uname -m </code> is used to get a result and ARCH set to the result. | <code>uname -m </code> |
| es usado para obtener el resultado y la variable ARCH es fijada con el resultado. |
| |
Don't be fazed by the question mark in i?86 ,the question mark is a place holder that allows for possibilities via regex. it could be "3" (i386) , "6"( i686) etc. | |
| |
Next block of code | No te preocupes por el signo de interrogación en i?86, el signo de interrogación es un lugar que permite posibilidades a través de regex. |
| Podría ser "3" (i386), "6"( i686), etc. |
| |
| Próximo bloque de código |
| |
<code> | <code> |
</code> | </code> |
| |
Before we go into this let me have a look in my slackware file system and see whats there at /tmp/SBo.Taking a quick look at the image will give you a clue that the slackbuild works, by using the /tmp/SBo/ directory and creates a directory with the syntax package-packagename.So if we now have a look at the code above. CWD (current working directory) is a variable and is set to the value of pwd. If you run that in a terminal window, it will tell you where you in a bash context where you are working from.{{ howtos:misc:tmp_Sbo.gif }} | Antes de entrar en esto, déjame echar un vistazo a mi sistema de archivos de Slackware y ver qué hay en /tmp/SBo. |
| Echando un vistazo rápido a la imagen te dará una pista de que el slackbuild funciona, usando el directorio /tmp/SBo/ y crea un directorio con la sintaxis package-packagename. Así que si ahora echamos un vistazo al código anterior. |
| CWD (directorio de trabajo actual) es una variable y es configurada al valor de pwd. Si lo ejecutas en una ventana del terminal, te dirá dónde estás en un contexto bash desde el que estás trabajando. |
| {{ howtos:misc:tmp_Sbo.gif }} |
| |
TMP is going to be set to /tmp/SBo. | TMP se va a establecer en /tmp/SBo. |
Now lets have a look at | Ahora echemos un vistazo a |
| |
<code> | <code> |
PKG=$TMP/package-$PRGNAM | PKG=$TMP/package-$PRGNAM |
</code> | </code> |
| |
You might guess PKG is going to be set for latex2html to : | Se podría suponer que la PKG se va a fijar para el látex2html a: |
<code> | <code> |
/tmp/SBo/package-latex2html | /tmp/SBo/package-latex2html |
</code> | </code> |
| |
If you look closely at the image (taking into account /tmp/SBo/ at top of image) you will see exactly that in the image.OUTPUT is set to /tmp \\ | Si se mira de cerca la imagen (tomando en cuenta /tmp/SBo/ en la parte superior de la imagen) verás exactamente que en la imagen. OUTPUT está ajustado a /tmp\\ |
| |
Next block of code: | Próximo bloque de código: |
<code> | <code> |
if [ "$ARCH" = "i586" ]; then | if [ "$ARCH" = "i586" ]; then |
| |
</code> | </code> |
Probably we need, before we look at the rest of the code for latex2html slackbuild to introduce some basic concepts. | Probablemente, antes de mirar el resto del código del slackbuild latex2html para introducir necesitemos algunos conceptos básicos. |
| |
Historically computer software is installed in a three step process called configure, make, make install. Configure gets ready to build the software , see if everything needed is there and builds a new make file. A make file is a file that contains instructions to build a program. | Históricamente el software para computadoras es instalado en un un proceso de tres pasos llamado configure, make and make install. |
| configure se utiliza para preparar la construcción del software, comprueba que todo lo necesario está en el sistema y crea un archivo para make. Un archivo para make es un archivo que contiene instrucciones para compilar un programa. |
| |
You can from the command line install software just using configure, make and make install. A slackbuild does the job of creating a package so that the process of installing is more manageable and reliable fashion. When you have a slackbuild downloaded on your system should there be a new release of source code its a simple matter of putting that source in your unpacked slackbuild and a quick edit to the slackbuild script. | A partir de la línea de comandos se puede instalar software solamente usando configure, make and make install. Un slackbuild hace el trabajo de crear el paquete para que el proceso de instalación sea más manejable y confiable de moda. Cuando usted tiene un slackbuild descargado en su sistema, si hay una nueva versión del código fuente es una simple cuestión de poner esa fuente en su slackbuild desempaquetado y una rápida edición del script de slackbuild. |
| |
| El código fuente de los programas informáticos está escrito en lenguajes de "alto nivel", pero se convierte en una forma que el ordenador puede entender fácilmente. El código escrito en el lenguaje C implica que un compilador de C lo convierte a binario. |
| |
Computer program source are written in “high level “ languages but are converted into a form that the computer can readily understand.Code written in the C language involves a C compiler converted it to binary. | El objetivo de cualquier sistema que instale un programa, es que debe implicar el concepto de hacerlo "a la medida" del ordenador que se está instalando. Obviamente eso va a implicar la arquitectura del ordenador. |
| Durante el proceso de compilación el sistema puede ser ajustado pasando opciones de variables. |
| |
The whole goal of any system installing a program, is that it should involve the concept of making it “tailor made” for the computer its being installed. Obviously that is going to involve the computer Architecture. | Así que ahora echemos un vistazo al bloque de código de arriba. El bloque de código es simplemente un "bloque de if, else", donde el código se ejecuta de arriba a abajo y asciende a -si la arquitectura es i586 pongan SLKFLAGS a .. si no vayan a la siguiente línea. |
During the compile process the system can be tweaked by passing in options from variables. | |
| |
So lets now have a look at the block of code above. The block of code is simply an "if , else block" , where the code is executed top to bottom and amounts to -if the architecture is i586 set SLKFLAGS to .. if not go to next line. | CFLAGS y CXXFLAGS son variables que contienen valores que pueden ser pasados en tiempo de compilación. Veremos más tarde que la variable SLKFLAGS se utilizará para establecerlas. |
| |
CFLAGS and CXXFLAGS are variables holding values that can be passed in at compile time. We will see later that the variable SLKFLAGS will be used to set them. | Próximo bloque de código: |
| |
Next block of code: | |
| |
<code> | <code> |
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; | -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; |
</code> | </code> |
| set -e: esto detiene la ejecución del script si hay un error al ejecutar este código siguiendo este comando\\ |
| rm -rf $PKG: esto borra algún directorio previo (y contenido) de |
| rm -rf $PKG: this deletes any previous directory (and contents) of package-latex2html en /tmp/SBo/package-latex2html \\ |
| |
set -e: this stops the execution of the script if there is an error executing this code following this command \\ | package-latex2html at of /tmp/SBo/package-latex2html \\ |
rm -rf $PKG: this deletes any previous directory (and contents) of package-latex2html at of /tmp/SBo/package-latex2html \\ | mkdir -p $TMP $PKG $OUTPUT :mkdir con la bandera (flag) " -p " crea directorios, pero sólo si no existen ya.\\ |
mkdir -p $TMP $PKG $OUTPUT :mkdir with the " -p " flag creates directories, but only if they don't exist already.\\ | |
| |
that would be /tmp/SBo , /tmp/Sbo/package-latex2html, /tmp \\ | que serían /tmp/SBo , /tmp/Sbo/package-latex2html, /tmp \\ |
| |
| Es improbable que el directorio SBo no exista a menos que no se hayan ejecutado otros slackbuilds en el pasado. /tmp debería estar ahí por defecto con la instalación de slackware. |
| |
Its unlikely that the SBo directory doesn't exist unless no other slackbuilds have been run in the past . /tmp should be there as default with the slackware installation. \\ | cd $tmp : mueve el lugar donde Bash está trabajando de a /tmp/SBo \\ |
cd $tmp : moves location where bash is working from to /tmp/SBo \\ | |
| |
rm -rf $PRGNAM-$VERSION will get rid of any previous directory entries(maybe failed) for latex2html-2019.2 \\ | rm -rf $PRGNAM-$VERSION se deshará de cualquier entrada previa del directorio (tal vez fallida) para latex2html-2019.2.\\ |
| |
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz : This equated to unpacking of latex2html-2019.2.tar.gz , which would be inside the unpacked slackbuild from slackbuilds.org namely "latex2html".\\ | tar xvf $CWD/$PRGNAM-$VERSION.tar.gz : Esto equivalía a desempacar de latex2html-2019.2.tar.gz , el cual estaría en el interior del slackbuild de slackbuilds.org llamado "latex2html".\\ |
| |
cd $PRGNAM-$VERSION : This is a "change directory" command. The bash shell will now be working from the context that is located inside the unpacked source, which is located $CWD. i.e We are back to the unpacked slackbuild but, inside the unpacked source. | cd $PRGNAM-$VERSION : Este es el comando para "cambiar de directorio". El shell bash funcionara ahora desde el contexto que se encuentra dentro de la fuente desempacada, que se encuentra en $CWD. Es decir, estamos desempacando el slackbuild pero dentro de la fuente desempacada. |
| |
chown -R root:root . : Notice the dot , with a space at the end of the line; this means all in current directory. -R is permission recursive. So here we are giving ownership to root and group root. | chown -R root:root . : Note el punto, con un espacio al final de la línea; esto significa todo en el directorio actual. -R es recursivo. Así que aquí estamos dando propiedad a root y al grupo root. |
<code> | <code> |
find -L . \ | find -L . \ |
</code> | </code> |
| |
If i understand the above block of code correctly its using the "find" on the basis of permissions and following symbolic links using the "-L flag". If i understand this correctly its basically setting directories to 755 in order to enable a "cd" into them and files so that root can read write. If this is true I might have expected | Si entiendo correctamente el bloque de código anterior, está usando la "búsqueda" en base a los permisos y siguiendo los enlaces simbólicos usando "-L flag". Si entiendo esto correctamente, es básicamente establecer los directorios a 755 para habilitar un "cd" en ellos y los archivos para que root pueda leer y escribir. Si esto es cierto, podría haber esperado: |
<code> | <code> |
-type d -exec chmod 775 {} | -type d -exec chmod 775 {} |
</code> | </code> |
| Para directorio y |
For directories and | |
<code> | <code> |
-type f -exec chmod 644 {} | -type f -exec chmod 644 {} |
| |
</code> | </code> |
For files. | para archivos. |
Next block of code: | |
| Próximo bloque de código: |
<code> | <code> |
CFLAGS="$SLKCFLAGS" \ | CFLAGS="$SLKCFLAGS" \ |
--prefix=/usr \ | --prefix=/usr \ |
--libdir=/usr/lib${LIBDIRSUFFIX} \ | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
| A test is applied and of course there will be a result depending on the outcome. An example of a |
| bash "if" block statement is: |
--sysconfdir=/etc \ | --sysconfdir=/etc \ |
--localstatedir=/var \ | --localstatedir=/var \ |
</code> | </code> |
| |
A couple of things to say here , the use of "\" is a way of using a long command over several lines. We have already mentioned CFLAGS and CXXFLAGS. We also previously mentioned the variable SLKFLAGS and here we use it to set the value of CFLAGS and CXXFLAGS. | Un par de cosas para decir aquí, el uso de "\" es una forma de usar un comando largo sobre varias líneas. Ya se mencionó CFLAGS y CXXFLAGS. |
| A couple of things to say here , the use of "\" is a way of using a long command over several lines. We have already mentioned CFLAGS and CXXFLAGS. |
| También hemos mencionado anteriormente la variable SLKFLAGS y aquí la usamos para establecer el valor de CFLAGS y CXXFLAGS. |
| |
In this latex2html slackbuild script we also utilize a three step process of configure, make, make install. | En este script slackbuild latex2html también utilizamos un proceso de tres pasos de configurar, make, make install. |
But what about the likes of --enable-eps , where does that come from ? | Pero, ¿qué pasa con los tipos de --enable-eps, ¿de dónde viene eso? |
| |
Well if you take the source code [[https://github.com/latex2html/latex2html/archive/v2019.2/latex2html-2019.2.tar.gz | latex2html source]]unpack it ( a quick way is right click , open with Ark) cd into it and run : | Bueno, si tomas el código fuente de [[https://github.com/latex2html/latex2html/archive/v2019.2/latex2html-2019.2.tar.gz | latex2html source]] desempaquetas ( una forma rápida es hacer click con el botón derecho, abrir con Ark) ingresar al directorio y ejecutar: |
| |
| |
</code> | </code> |
| |
Then you will get some useful information from the developers. It tells you the option and how you can enable some of them. | Entonces obtendrá información útil de los desarrolladores. Te dice la opción y cómo puedes habilitar algunas de ellas. |
| |
<code> | <code> |
</code> | </code> |
| |
Here, make, make install are carried out.Note DESTDIR is a flag to say where the package will go. \\ | Aquí, make, make install se llevan a cabo. Note que DESTDIR es una bandera que indica dónde irá el paquete.\\ |
| |
$PKG equates to /tmp/SBo/package-latex2html | $PKG equates to /tmp/SBo/package-latex2html |
| |
Next Block of code:\\ | Proximo bloque de código:\\ |
| |
<code> | <code> |
| |
</code> | </code> |
| Las dos primeras líneas de este bloque están un poco llenas: |
| |
The first two lines of this block are a bit of a mouth-full: | |
<code> | <code> |
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ |
</code> | </code> |
| |
We can however pick out key words that are commands and that can help to make some sense of it. | Sin embargo, podemos elegir palabras clave que son órdenes y que pueden ayudar a darle algún sentido. "find" es una poderosa utilidad, con más de 50 opciones, localizada en /usr/bin/find. Básicamente hace lo que dice en la lata. Con la opción -print0 separa lo que encuentra con "\000" - en una palabra NULL. |
ind" located at /usr/bin/find is a powerful utility that has around 50 options. It basically does what it says on the can.With the -print0 option it separates what it finds with "\000" - in a word NULL. | La tuberia "|" es usada para pasar los resultados de un comando a otro; en este caso xargs tiene un flag (bandera) -0. Esta opción es para que xargs acepte la entrada que tiene /000 entre ellos. ELF es un formato ejecutable y enlazable. |
| |
The "|" or pipe is used to pass the results of a command to another;in this case xargs which has a flag -0. This option is for xargs to accept input that has /000 between them. ELF is is Executable & Linkable Format. | Para dar una respuesta sucinta las dos líneas están eliminando los símbolos de depuración y otras cosas innecesarias para que los binarios sean más pequeños, más rápidos y ocupen menos memoria. |
| |
To give a succinct answer the two lines are removing debugging symbols and other unnecessary stuff to make the binaries smaller, faster and take up less memory. | |
| |
<code> | <code> |
</code> | </code> |
| |
Here we are preparing a directory which will be called "latex2html-2019.2" located at /usr/doc. This is so we an put relevant documentation into a directory relevantly called, so that a user can access documentation on the package. | Aquí estamos preparando un directorio que se llamara "latex2html-2019.2" localizado en /usr/doc. |
The next lines put files such as README.md into the /usr/doc/latex2html-2019.2 directory. | Esto es así para que pongamos la documentación relevante en un directorio. De esta forma, un usuario puede acceder a la documentación del paquete. |
| Las siguientes líneas ponen archivos como README.md en el directorio /usr/doc/latex2html-2019.2. |
| |
<code> | <code> |
</code> | </code> |
| |
That line goes back to the original directory that Latex2html.SlackBuild was run from ( i previously quoted Desktop) opens up the SlackBuild with "cat" command and copies it to the documentation directory. | Esa línea vuelve al directorio original que Latex2html. SlackBuild fue ejecutado desde (yo previamente ingrese al Desktop) abre el SlackBuild con el comando "cat" y lo copia al directorio de documentación. |
Now before I submitted latex2html to slackbuilds obviously I did some testing and found that when the package was installed it had a fairly comprehensive output of what it could do just using: | |
| |
| Ahora, antes de enviar latex2html a slackbuilds, obviamente hice algunas pruebas y encontré que cuando el paquete fue instalado tenía una salida bastante completa de lo que podía hacer simplemente usando: |
<code> | <code> |
$ latex2html --help | $ latex2html --help |
</code> | </code> |
| |
Also I had access to a comprehensive manual in pdf format; so in my case I did not write code for man pages. Instead I simply put a copy of "manual.pdf" into the /usr/doc/latex2html-2019.2 directory. | |
| También tuve acceso a un completo manual en formato pdf; así que en mi caso no escribí código para las páginas de manual. En su lugar, simplemente puse una copia de "manual.pdf" en el directorio /usr/doc/latex2html-2019.2. |
| |
| |
| |
//Si enseñas matemáticas no te impide incrustar un poco de inglés.// | //Si enseñas matemáticas no te impide incrustar un poco de inglés.// |
| |
Una plantilla en blanco puede ser obtenida de: [[https://slackbuilds.org/templates/]] | Una plantilla en blanco puede ser obtenida de: [[https://slackbuilds.org/templates/]] |
| |