Blame Manual/Directories/trunk/Scripts/Functions/Prepare.texi

9c6e0d
@subsection Goals
9c6e0d
9c6e0d
This section exists to organize files related to @file{centos-art.sh}
5da4a8
script @samp{prepare} functionality.  The @samp{prepare} functionality
5da4a8
of @file{centos-art.sh} script helps you to prepare the workstation
5da4a8
configuration you are planning to use as host for your working copy of
5da4a8
CentOS Artwork Repository.
9c6e0d
9c6e0d
@subsection Description
9c6e0d
9c6e0d
The first time you download CentOS Artwork Repository you need to
9c6e0d
configure your workstation in order to use @file{centos-art.sh}
9c6e0d
script.  These preliminar configurations are based mainly on auxiliar
9c6e0d
RPM packages installation, symbolic links creations, and environment
5da4a8
variables definitions.  The @samp{prepare} functionality of
9c6e0d
@file{centos-art.sh} script guides you through this preliminar
9c6e0d
configuration process.  
9c6e0d
9c6e0d
If this is the first time you run @file{centos-art.sh} script, the
5da4a8
appropriate way to use its @samp{prepare} functionality is not using
9c6e0d
the @file{centos-art.sh} script directly, but the absolute path to
9c6e0d
@command{centos-art.sh} script instead (i.e.,
9c6e0d
@file{~/artwork/trunk/Scripts/Bash/centos-art.sh}).  This is necessary
9c6e0d
because @file{centos-art} symbolic link, under @file{~/bin/}
9c6e0d
directory, has not been created yet.
9c6e0d
9c6e0d
@subsubsection Packages
9c6e0d
9c6e0d
Installation of auxiliar RPM packages provides the software required
9c6e0d
to manipulate files inside the repository (e.g., image files,
9c6e0d
documentation files, translation files, script files, etc.). Most of
9c6e0d
RPM packages @command{centos-art.sh} script uses are shipped with
9c6e0d
CentOS distribution, and can be installed from CentOS base repository.
9c6e0d
The only exception is @samp{inkscape}, the package we use to
9c6e0d
manipulate SVG files.  The @samp{inkscape} package is not inside
9c6e0d
CentOS distribution so it needs to be installed from third party
9c6e0d
repositories.
9c6e0d
9c6e0d
@quotation
9c6e0d
@strong{Note} Configuration of third party repositories inside CentOS
9c6e0d
distribution is described in CentOS wiki, specifically in the
9c6e0d
following URL:
9c6e0d
@url{http://wiki.centos.org/AdditionalResources/Repositories}
9c6e0d
@end quotation
9c6e0d
9c6e0d
Before installing packages, the @file{centos-art.sh} script uses
9c6e0d
@command{sudo} to request root privileges to execute @command{yum}
9c6e0d
installation functionality.  If your user isn't defined as a
9c6e0d
privileged user---at least to run @command{yum} commands--- inside
9c6e0d
@file{/etc/sudoers} configuration file, you will not be able to
9c6e0d
perform package installation tasks as set in @file{centos-art.sh}
5da4a8
script @samp{prepare} functionality. 
9c6e0d
9c6e0d
Setting sudo privileges to users is an administrative task you have to
9c6e0d
do by yourself. If you don't have experience with @command{sudo}
9c6e0d
command, please read its man page running the command: @command{man
9c6e0d
sudo}. This reading will be very useful, and with some practice, you
9c6e0d
will be able to configure your users to have @command{sudo}
9c6e0d
privileges.
9c6e0d
9c6e0d
@subsubsection Links
9c6e0d
9c6e0d
Creation of symbolic links helps us to alternate between different
9c6e0d
implementations of @file{centos-art.sh} script-line (e.g.,
9c6e0d
@file{centos-art.sh}, for Bash implementation; @file{centos-art.py},
9c6e0d
for Python implementation; @file{centos-art.pl}, for Perl
9c6e0d
implementation; and so on for other implementations). The
9c6e0d
@file{centos-art.sh} script-line definition takes place inside your
9c6e0d
personal binary (@file{~/bin/}) directory in order to make the script
9c6e0d
implementation ---the one that @file{centos-art} links to--- available
9c6e0d
to @var{PATH} environment variable.
9c6e0d
9c6e0d
Creation of symbolic links helps us to reuse components from repository
9c6e0d
working copy. For example, color information files maintained inside
9c6e0d
your working copy must never be duplicated inside program-specific
9c6e0d
configuration directories that uses them in your workstation (e.g.,
9c6e0d
Gimp, Inkscape, etc.).  Instead, a symbolic link must be created for
9c6e0d
each one of them, from program-specific configuration directories to
9c6e0d
files in the working copy.  In this configuration, when someone
9c6e0d
commits changes to color information files up to central repository,
9c6e0d
they---the changes committed--- will be immediatly available to your
9c6e0d
programs the next time you update your working copy ---the place
9c6e0d
inside your workstation those color information files are stored---.
9c6e0d
9c6e0d
Creation of symbolic links helps us to make @file{centos-art.sh}
9c6e0d
script functionalities available outside @file{trunk/} repository
9c6e0d
directory structure, but at its same level in repository tree. This is
9c6e0d
useful if you need to use the ``render'' functionality of
9c6e0d
@command{centos-art.sh} under @file{branches/} repository directory
9c6e0d
structure as you usually do inside @file{trunk/} repository directory
9c6e0d
structure. As consequence of this configuration, automation scripts
9c6e0d
cannot be branched under @file{branches/Scripts} directory structure.
9c6e0d
9c6e0d
@subsubsection Environment variables
9c6e0d
9c6e0d
Definition of environemnt variables helps us to set default values to
9c6e0d
our user session life. The user session environment variable defintion
9c6e0d
takes place in the user's @file{~/.bash_profile} file.  The
5da4a8
@samp{prepare} functionality of @file{centos-art.sh} script doesn't
9c6e0d
modify your @file{~/.bash_profile} file.  
9c6e0d
5da4a8
The @samp{prepare} functionality of @file{centos-art.sh} script
9c6e0d
evaluates the following environment variables:
9c6e0d
9c6e0d
@table @env
9c6e0d
@item EDITOR
9c6e0d
Default text editor. 
9c6e0d
9c6e0d
The @file{centos-art.sh} script uses default text @env{EDITOR} to edit
9c6e0d
pre-commit subversion messages, translation files, configuration
9c6e0d
files, script files, and similar text-based files.
9c6e0d
9c6e0d
If @env{EDITOR} environment variable is not set, @file{centos-art.sh}
9c6e0d
script uses @file{/usr/bin/vim} as default text editor. Otherwise, the
9c6e0d
following values are recognized by @file{centos-art.sh} script:
9c6e0d
9c6e0d
@itemize
9c6e0d
@item @file{/usr/bin/vim}
9c6e0d
@item @file{/usr/bin/emacs}
9c6e0d
@item @file{/usr/bin/nano}
9c6e0d
@end itemize
9c6e0d
9c6e0d
If no one of these values is set in @env{EDITOR} environment variable,
9c6e0d
@file{centos-art.sh} uses @file{/usr/bin/vim} text editor by default. 
9c6e0d
9c6e0d
@item TEXTDOMAIN
9c6e0d
9c6e0d
Default domain used to retrieve translated messages.  This variable is
9c6e0d
set in @file{initFunctions.sh} and shouldn't be changed.
9c6e0d
9c6e0d
@item TEXTDOMAINDIR
9c6e0d
9c6e0d
Default directory used to retrieve translated messages.  This variable
9c6e0d
is set in @file{initFunctions.sh} and shouldn't be changed.
9c6e0d
9c6e0d
@item LANG
9c6e0d
9c6e0d
Default locale information.
9c6e0d
9c6e0d
This variable is initially set in the configuration process of CentOS
9c6e0d
distribution installer (i.e., Anaconda), specifically in the
9c6e0d
@samp{Language} step; or once installed using the
9c6e0d
@command{system-config-language} tool.
9c6e0d
9c6e0d
The @file{centos-art.sh} script uses the @var{LANG} environment
9c6e0d
variable to know in which language the script messages are printed
9c6e0d
out.
9c6e0d
9c6e0d
@item TZ
9c6e0d
9c6e0d
Default time zone representation.
9c6e0d
9c6e0d
This variable is initially set in the configuration process of CentOS
9c6e0d
distribution installer (i.e., Anaconda), specifically in the
9c6e0d
@samp{Date and time} step; or once installed using the
9c6e0d
@command{system-config-date} tool.
9c6e0d
9c6e0d
The @file{centos-art.sh} script doesn't use the @var{TZ} environment
9c6e0d
variable information at all. Instead, this variable is used by the
9c6e0d
system shell to show the time information according to your phisical
9c6e0d
location on planet Earth.  
9c6e0d
9c6e0d
Inside your computer, the time information is firstly set in the BIOS
9c6e0d
clock (which may need correction), and later in the configuration
9c6e0d
process of CentOS distribution installer (or later, by any of the
9c6e0d
related configuration tools inside CentOS distribution).  Generally,
9c6e0d
setting time information is a straight-forward task and configuration
9c6e0d
tools available do cover most relevant location. However, if you need
9c6e0d
a time precision not provided by the configuration tools available
9c6e0d
inside CentOS distribution then, using @var{TZ} variable may be
9c6e0d
necessary.
9c6e0d
9c6e0d
@quotation
9c6e0d
@strong{Convenction} In order to keep changes syncronized between
9c6e0d
central repository and its working copies: configure both repository
9c6e0d
server and workstations (i.e., the place where each working copy is
9c6e0d
set on) to use Coordinated Universal Time (UTC) as base time
9c6e0d
representation.  Later, correct the time information for your specific
9c6e0d
location using time zone correction.
9c6e0d
@end quotation
9c6e0d
9c6e0d
The format of @var{TZ} environment variable is described in
9c6e0d
@file{tzset(3)} manual page.
9c6e0d
9c6e0d
@end table
9c6e0d
5da4a8
@subsubsection Shell Script Files
5da4a8
5da4a8
The @code{shell} functionality of @file{centos-art.sh} script helps
5da4a8
you to maintain bash scripts inside repository. For example, suppose
5da4a8
you've created many functionalities for @file{centos-art.sh} script,
5da4a8
and you want to use a common copyright and license note for
5da4a8
consistency in all your script files. If you have a bunch of files,
5da4a8
doing this one by one wouldn't be a big deal. In contrast, if the
5da4a8
amount of files grows, updating the copyright and license note for all
5da4a8
of them would be a task rather tedious. The @code{shell} functionality
5da4a8
exists to solve maintainance tasks just as the one previously
5da4a8
mentioned.
5da4a8
5da4a8
When you use @code{shell} functionality to update copyright inside
5da4a8
script files, it is required that your script files contain (at least)
5da4a8
the following top commentary structure:
5da4a8
5da4a8
@verbatim
5da4a8
 1| #!/bin/bash
5da4a8
 2| #
5da4a8
 3| # doSomething.sh -- The function description goes here.
5da4a8
 4| # 
5da4a8
 5| # Copyright
5da4a8
 6| #
5da4a8
 7| # ...
5da4a8
 8| #
5da4a8
 9| # ----------------------------------------------------------------------
5da4a8
10| # $Id$
5da4a8
11| # ----------------------------------------------------------------------
5da4a8
12|
5da4a8
13| function doSomething {
5da4a8
14|     
5da4a8
15| }
5da4a8
@end verbatim
5da4a8
5da4a8
Relevant lines in the above structure are lines from 5 to 9.
5da4a8
Everything else in the file is left immutable.
5da4a8
5da4a8
When you are updating copyright through @code{shell}
5da4a8
functionality,  the @file{centos-art.sh} script replaces everything
5da4a8
in-between line 5 ---the first one matching @samp{^# Copyright .+$}
5da4a8
string--- and line 9---the first long dash separator matching @samp{^#
5da4a8
-+$}--- with the content of copyright template instance.
5da4a8
5da4a8
@quotation
5da4a8
@strong{Caution} Be sure to add the long dash separator that matches
5da4a8
@samp{^# -+$} regular expression @emph{before} the function
5da4a8
definition. Otherwise, if the @samp{Copyright} line is present but no
5da4a8
long dash separator exists, @file{centos-art.sh} will remove anything
5da4a8
in-between the @samp{Copyright} line and the end of file. This way you
5da4a8
may lost your function definitions entirely.
5da4a8
@end quotation
5da4a8
5da4a8
The copyright template instance is created from one copyright template
5da4a8
stored in the @file{Config/tpl_forCopyright.sed} file.  The template
5da4a8
instance is created once, and later removed when no longer needed. At
5da4a8
this moment, when template instance is created, the
5da4a8
@file{centos-art.sh} script takes advantage of automation in order to
5da4a8
set copyright full name and date dynamically.
5da4a8
5da4a8
When you use @code{shell} functionality to update copyright, the first
5da4a8
thing @file{shell} functionality does is requesting copyright
5da4a8
information to user, and later, if values were left empty (i.e., no
5da4a8
value was typed before pressing @key{RET} key), the @file{shell}
5da4a8
functionality uses its own default values.
5da4a8
5da4a8
When @code{shell} functionality uses its own default values, the final
5da4a8
copyright note looks like the following:
5da4a8
5da4a8
@verbatim
5da4a8
 1| #!/bin/bash
5da4a8
 2| #
5da4a8
 3| # doSomthing.sh -- The function description goes here.
5da4a8
 4| #
5da4a8
 5| # Copyright (C) 2003, 2010 The CentOS Project
5da4a8
 6| # 
5da4a8
 7| # This program is free software; you can redistribute it and/or modify
5da4a8
 8| # it under the terms of the GNU General Public License as published by
5da4a8
 9| # the Free Software Foundation; either version 2 of the License, or
5da4a8
10| # (at your option) any later version.
5da4a8
11| # 
5da4a8
12| # This program is distributed in the hope that it will be useful, but
5da4a8
13| # WITHOUT ANY WARRANTY; without even the implied warranty of
5da4a8
14| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5da4a8
15| # General Public License for more details.
5da4a8
16| #
5da4a8
17| # You should have received a copy of the GNU General Public License
5da4a8
18| # along with this program; if not, write to the Free Software
5da4a8
19| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
5da4a8
20| # USA.
5da4a8
21| #
5da4a8
22| # ----------------------------------------------------------------------
5da4a8
23| # $Id$
5da4a8
24| # ----------------------------------------------------------------------
5da4a8
25|
5da4a8
26| function doSomething {
5da4a8
27|
5da4a8
28| }
5da4a8
@end verbatim
5da4a8
5da4a8
Relevant lines in the above structure are lines from 5 to 22.  Pay
5da4a8
attention how the copyright line was built, and how the license was
5da4a8
added into the top comment where previously was just three dots.
5da4a8
Everything else in the file was left immutable. 
5da4a8
5da4a8
To change copyright information (i.e., full name or year information),
5da4a8
run the @code{shell} functionality over the root directory containing
5da4a8
the script files you want to update copyright in and enter the
5da4a8
appropriate information when it be requested. You can run the
5da4a8
@code{shell} functionality as many times as you need to.
5da4a8
5da4a8
To change copyright license (i.e., the text in-between lines 7 and
5da4a8
20), you need to edit the @file{Config/tpl_forCopyright.sed} file, set
5da4a8
the appropriate information, and run the @code{shell} functionality
5da4a8
once again for changes to take effect over the files you specify.
5da4a8
5da4a8
@quotation
5da4a8
@strong{Important} The @file{centos-art.sh} script is released as: 
5da4a8
5da4a8
@verbatim
5da4a8
GNU GENERAL PUBLIC LICENSE
5da4a8
Version 2, June 1991
5da4a8
5da4a8
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5da4a8
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
5da4a8
@end verbatim
5da4a8
5da4a8
Do not change the license information under which @file{centos-art.sh}
5da4a8
script is released. Instead, if you think a different license must be
5da4a8
used, please share your reasons at @email{centos-devel@@centos-art.sh,
5da4a8
CentOS Developers mailing list}.
5da4a8
5da4a8
See file
5da4a8
@url{file:///home/centos/artwork/trunk/Scripts/COPYING,trunk/Scripts/COPYING},
5da4a8
for a complete license description.
5da4a8
@end quotation
5da4a8
5da4a8
@subsubsection SVG Files
5da4a8
5da4a8
The @code{svg} functionality of @file{centos-art.sh} script helps you
5da4a8
to maintain scalable vector graphics (SVG) inside repository. For
5da4a8
example, suppose you've been working in CentOS default design models
5da4a8
under @file{trunk/Identity/Themes/Models/}, and you want to set common
5da4a8
metadata to all of them, and later remove all unused SVG defintions
5da4a8
from @samp{*.svg} files. Doing so file by file may be a tedious task,
5da4a8
so the @file{centos-art.sh} script provides the @code{svg}
5da4a8
functionality to aid you maintain such actions.
5da4a8
5da4a8
The metadata used is defined by Inkscape 0.46 using the SVG standard
5da4a8
markup. The @file{centos-art.sh} script replaces everything
5da4a8
in-between @code{<metadata} and @code{</metadata>} tags with a
5da4a8
predefined metadata template we've set for this purpose.
5da4a8
5da4a8
The metadata template was created using the metadata information of a
5da4a8
file which, using Inkscape 0.46, all metadata fields were set. This
5da4a8
created a complete markup representation of how SVG metadata would
5da4a8
look like. Later, we replaced every single static value with a
5da4a8
translation marker in the form @samp{=SOMETEXT=}, where
5da4a8
@code{SOMETEXT} is the name of its main opening tag. Later, we
5da4a8
transform the metadata template into a sed replacement set of commads
5da4a8
escaping new lines at the end of each line.
5da4a8
5da4a8
With metadata template in place, the @file{centos-art.sh} script uses
5da4a8
it to create a metadata template instance for the file being processed
5da4a8
currently.  The metadata template instance contains the metadata
5da4a8
portion of sed replacement commands with translation markers already
5da4a8
traduced.  In this action, instance creation, is where we take
5da4a8
advantage of automation and generate metadata values like title, date,
5da4a8
keywords, source, identifier, and relation dynamically, based on the
5da4a8
file path @file{centos-art.sh} script is currently creating metadata
5da4a8
information for.
5da4a8
5da4a8
With metadata template instance in place, the @file{centos-art.sh}
5da4a8
script uses it to replace real values inside all @samp{.svg} files
5da4a8
under the current location you're running the @file{centos-art.sh}
5da4a8
script on.  Default behaviour is to ask user to enter each metadatum
5da4a8
required, one by one. If user leaves metadatum empty, by pressing
5da4a8
@key{RET} key, @file{centos-art.sh} uses its default value.
5da4a8
5da4a8
Many of the no-longer-used gradients, patterns, and markers (more
5da4a8
precisely, those which you edited manually) remain in the
5da4a8
corresponding palettes and can be reused for new objects. However if
5da4a8
you want to optimize your document, use the @samp{Vacuum Defs} command
5da4a8
in @samp{File} menu. It will remove any gradients, patterns, or
5da4a8
markers which are not used by anything in the document, making the
5da4a8
file smaller. 
5da4a8
5da4a8
If you have one or two couple of files, removing unused definitions
5da4a8
using the graphical interface may be enough to you.  In contrast, if
5da4a8
you have dozens or even houndreds of scalable vector graphics files to
5da4a8
maintain it is not a fun task to use the graphical interface to remove
5da4a8
unused definitions editing those files one by one.
5da4a8
5da4a8
To remove unused definitions from several scalable vector graphics
5da4a8
files, the @file{centos-art.sh} script uses Inkscape command-line
5da4a8
interface, specifically with the @option{--vaccum-defs} option.
5da4a8
5da4a8
@subsubsection XHTML Files
5da4a8
9c6e0d
@subsection Usage
9c6e0d
9c6e0d
@table @command
9c6e0d
5da4a8
@item centos-art prepare --packages
9c6e0d
9c6e0d
Verify required packages your workstation needs in order to run the
9c6e0d
@file{centos-art.sh} script correctly.  If there are missing packages,
9c6e0d
the @file{centos-art.sh} script asks you to confirm their
9c6e0d
installation. When installing packages, the @file{centos-art.sh}
9c6e0d
script uses the @command{yum} application in order to achieve the
9c6e0d
task.
9c6e0d
9c6e0d
In case all packages required by @file{centos-art.sh} script are
9c6e0d
already installed in your workstation, the message @samp{The required
9c6e0d
packages are already installed.} is output for you to know. 
9c6e0d
5da4a8
@item centos-art prepare --links
9c6e0d
9c6e0d
Verify required links your workstation needs in order to run the
9c6e0d
centos-art command correctly.  If any required link is missing, the
9c6e0d
@command{centos-art.sh} script asks you to confirm their installation.
9c6e0d
To install required links, the @command{centos-art.sh} script uses the
9c6e0d
@command{ln} command.
9c6e0d
9c6e0d
In case all links required by @file{centos-art.sh} script are already
9c6e0d
created in your workstation, the message @samp{The required links are
9c6e0d
already installed.} is output for you to know. 
9c6e0d
9c6e0d
In case a regular file exists with the same name of a required link,
9c6e0d
the @file{centos-art.sh} script outputs the @samp{Already exists as
9c6e0d
regular file.} message when listing required links that will be
9c6e0d
installed. Of course, as there is already a regular file where must be
9c6e0d
a link, no link is created. In such cases the @file{centos-art.sh}
9c6e0d
script will fall into a continue installation request for that missing
9c6e0d
link.  To end this continue request you can answer @samp{No}, or
9c6e0d
remove the existent regular file to let @file{centos-art.sh} script
9c6e0d
install the link on its place.
9c6e0d
5da4a8
@item centos-art prepare --environment
5da4a8
@itemx centos-art prepare --environment --filter='regex'
9c6e0d
9c6e0d
Output a brief description of environment variables used by
9c6e0d
@file{centos-art.sh} script. 
9c6e0d
9c6e0d
If @samp{--filter} option is provided, output is reduced as defined in
9c6e0d
the @samp{regex} regular expression value. If @samp{--filter} option
9c6e0d
is specified but @samp{regex} value is not, the @file{centos-art.sh}
9c6e0d
script outputs information as if @samp{--filter} option had not been
9c6e0d
provided at all.  
9c6e0d
9c6e0d
@end table
9c6e0d
9c6e0d
@subsection See also
9c6e0d
9c6e0d
@menu
ed9de5
* Directories trunk Scripts::
5da4a8
* Directories trunk Scripts Functions::
9c6e0d
@end menu