Blame Manuals/en/Html/Repository/repository_48.html

4c79b5
4c79b5
<html>
6414c4
09d4f2
6414c4
Copyright C 2009, 2010, 2011  Alain Reguera Delgado
4c79b5
4c79b5
Permission is granted to copy, distribute and/or modify this document
4c79b5
under the terms of the GNU Free Documentation License, Version 1.2 or
4c79b5
any later version published by the Free Software Foundation; with no
4c79b5
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
4c79b5
copy of the license is included in the section entitled GNU Free
4c79b5
Documentation License.  
4c79b5
-->
92fb7f
4c79b5
4c79b5
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
4c79b5
            Karl Berry  <karl@freefriends.org>
4c79b5
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
4c79b5
            and many others.
4c79b5
Maintained by: Many creative people <dev@texi2html.cvshome.org>
4c79b5
Send bugs and suggestions to <users@texi2html.cvshome.org>
4c79b5
4c79b5
-->
4c79b5
<head>
aaa0e9
<title>The CentOS Artwork Repository: 3.45 trunk/Scripts/Bash/Functions/Shell</title>
4c79b5
aaa0e9
<meta name="description" content="The CentOS Artwork Repository: 3.45 trunk/Scripts/Bash/Functions/Shell">
aaa0e9
<meta name="keywords" content="The CentOS Artwork Repository: 3.45 trunk/Scripts/Bash/Functions/Shell">
4c79b5
<meta name="resource-type" content="document">
4c79b5
<meta name="distribution" content="global">
4c79b5
<meta name="Generator" content="texi2html 1.76">
4c79b5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4c79b5
<style type="text/css">
4c79b5
1e9202
@import "/home/centos/artwork/trunk/Identity/Models/Css/Texi2html/common.css";
4c79b5
4c79b5
a.summary-letter {text-decoration: none}
4c79b5
pre.display {font-family: serif}
4c79b5
pre.format {font-family: serif}
4c79b5
pre.menu-comment {font-family: serif}
4c79b5
pre.menu-preformatted {font-family: serif}
4c79b5
pre.smalldisplay {font-family: serif; font-size: smaller}
4c79b5
pre.smallexample {font-size: smaller}
4c79b5
pre.smallformat {font-family: serif; font-size: smaller}
4c79b5
pre.smalllisp {font-size: smaller}
4c79b5
span.sansserif {font-family:sans-serif; font-weight:normal;}
4c79b5
ul.toc {list-style: none}
4c79b5
-->
4c79b5
</style>
4c79b5
4c79b5
4c79b5
</head>
4c79b5
4c79b5
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
4c79b5
4c79b5
01b527
[ < ]
01b527
[ > ]
4c79b5
   
4c79b5
[ << ]
4c79b5
[ Up ]
aaa0e9
[ >> ]
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
[Top]
4c79b5
[Contents]
aaa0e9
[Index]
4c79b5
[ ? ]
4c79b5
aaa0e9
01b527
aaa0e9

3.45 trunk/Scripts/Bash/Functions/Shell

2c8180
2c8180
01b527
273af8

3.45.1 Goals

e68a7a
aaa0e9

This section exists to organize files related to shell

035049
functionality of <tt>`centos-art.sh'</tt> script.
54b5a5

e68a7a
01b527
273af8

3.45.2 Description

60c152
aaa0e9

The shell functionality of <tt>`centos-art.sh'</tt> script helps

aaa0e9
you to maintain bash scripts inside repository. For example, suppose
aaa0e9
you've created many functionalities for <tt>`centos-art.sh'</tt> script,
aaa0e9
and you want to use a common copyright and license note for
aaa0e9
consistency in all your script files. If you have a bunch of files,
aaa0e9
doing this one by one wouldn't be a big deal. In contrast, if the
aaa0e9
amount of files grows, updating the copyright and license note for all
aaa0e9
of them would be a task rather tedious. The shell functionality
aaa0e9
exists to solve maintainance tasks just as the one previously
aaa0e9
mentioned.
54b5a5

aaa0e9

When you use shell functionality to update copyright inside

aaa0e9
script files, it is required that your script files contain (at least)
aaa0e9
the following top commentary structure:
273af8

aaa0e9
aaa0e9
 1| #!/bin/bash
aaa0e9
 2| #
aaa0e9
 3| # doSomething.sh -- The function description goes here.
aaa0e9
 4| # 
aaa0e9
 5| # Copyright
aaa0e9
 6| #
aaa0e9
 7| # ...
aaa0e9
 8| #
aaa0e9
 9| # ----------------------------------------------------------------------
aaa0e9
10| # $Id$
aaa0e9
11| # ----------------------------------------------------------------------
aaa0e9
12|
aaa0e9
13| function doSomething {
aaa0e9
14|     
aaa0e9
15| }
aaa0e9
aaa0e9

Figure 3.20: The functions script base comment structure

aaa0e9
4224f4

aaa0e9

Relevant lines in the above structure are lines from 5 to 9.

aaa0e9
Everything else in the file is left immutable.
54b5a5

aaa0e9

When you are updating copyright through shell

aaa0e9
functionality,  the <tt>`centos-art.sh'</tt> script replaces everything
aaa0e9
in-between line 5 --the first one matching <samp>`^# Copyright .+$'</samp>
aaa0e9
string-- and line 9--the first long dash separator matching <samp>`^#
aaa0e9
-+$'</samp>-- with the content of copyright template instance.
54b5a5

aaa0e9
Caution

Caution

Be sure to add the long dash separator that matches

aaa0e9
<samp>`^# -+$'</samp> regular expression before the function
aaa0e9
definition. Otherwise, if the <samp>`Copyright'</samp> line is present but no
aaa0e9
long dash separator exists, <tt>`centos-art.sh'</tt> will remove anything
aaa0e9
in-between the <samp>`Copyright'</samp> line and the end of file. This way you
aaa0e9
may lost your function definitions entirely.
aaa0e9

aaa0e9
aaa0e9

The copyright template instance is created from one copyright template

aaa0e9
stored in the <tt>`Config/tpl_forCopyright.sed'</tt> file.  The template
aaa0e9
instance is created once, and later removed when no longer needed. At
aaa0e9
this moment, when template instance is created, the
aaa0e9
<tt>`centos-art.sh'</tt> script takes advantage of automation in order to
aaa0e9
set copyright full name and date dynamically.
54b5a5

aaa0e9

When you use shell functionality to update copyright, the first

aaa0e9
thing <tt>`shell'</tt> functionality does is requesting copyright
aaa0e9
information to user, and later, if values were left empty (i.e., no
aaa0e9
value was typed before pressing RET key), the <tt>`shell'</tt>
aaa0e9
functionality uses its own default values.
e37211

aaa0e9

When shell functionality uses its own default values, the final

aaa0e9
copyright note looks like the following:
c6292c

aaa0e9
aaa0e9
 1| #!/bin/bash
aaa0e9
 2| #
aaa0e9
 3| # doSomthing.sh -- The function description goes here.
aaa0e9
 4| #
aaa0e9
 5| # Copyright (C) 2003, 2010 The CentOS Project
aaa0e9
 6| # 
aaa0e9
 7| # This program is free software; you can redistribute it and/or modify
aaa0e9
 8| # it under the terms of the GNU General Public License as published by
aaa0e9
 9| # the Free Software Foundation; either version 2 of the License, or
aaa0e9
10| # (at your option) any later version.
aaa0e9
11| # 
aaa0e9
12| # This program is distributed in the hope that it will be useful, but
aaa0e9
13| # WITHOUT ANY WARRANTY; without even the implied warranty of
aaa0e9
14| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
aaa0e9
15| # General Public License for more details.
aaa0e9
16| #
aaa0e9
17| # You should have received a copy of the GNU General Public License
aaa0e9
18| # along with this program; if not, write to the Free Software
aaa0e9
19| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
aaa0e9
20| # USA.
aaa0e9
21| #
aaa0e9
22| # ----------------------------------------------------------------------
aaa0e9
23| # $Id$
aaa0e9
24| # ----------------------------------------------------------------------
aaa0e9
25|
aaa0e9
26| function doSomething {
aaa0e9
27|
aaa0e9
28| }
aaa0e9
aaa0e9

Figure 3.21: The function script comment example

aaa0e9
749e81

aaa0e9

Relevant lines in the above structure are lines from 5 to 22. Pay

aaa0e9
attention how the copyright line was built, and how the license was
aaa0e9
added into the top comment where previously was just three dots.
aaa0e9
Everything else in the file was left immutable. 
3207df

aaa0e9

To change copyright information (i.e., full name or year information),

aaa0e9
run the shell functionality over the root directory containing
aaa0e9
the script files you want to update copyright in and enter the
aaa0e9
appropriate information when it be requested. You can run the
aaa0e9
shell functionality as many times as you need to.
3207df

aaa0e9

To change copyright license (i.e., the text in-between lines 7 and

aaa0e9
20), you need to edit the <tt>`Config/tpl_forCopyright.sed'</tt> file, set
aaa0e9
the appropriate information, and run the shell functionality
aaa0e9
once again for changes to take effect over the files you specify.
4224f4

aaa0e9
Important

Important

The <tt>`centos-art.sh'</tt> script is released as:

4224f4

aaa0e9
GNU GENERAL PUBLIC LICENSE
aaa0e9
Version 2, June 1991
035049
aaa0e9
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
aaa0e9
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
aaa0e9
aaa0e9

Do not change the license information under which <tt>`centos-art.sh'</tt>

aaa0e9
script is released. Instead, if you think a different license must be
aaa0e9
used, please share your reasons at CentOS Developers mailing list.
aaa0e9

c6292c
749e81
aaa0e9
035049

3.45.3 Usage

035049
035049
aaa0e9
centos-art sh --update-copyright='path/to/dir'
aaa0e9
centos-art sh --update-copyright='path/to/dir' --filter='regex'
aaa0e9

Use these commands to update copyright information in <samp>`.sh'</samp> files

aaa0e9
under <samp>`path/to/dir'</samp> directory. 
e37211

e37211
e68a7a
035049

When you provide <samp>`--filter='regex''</samp> argument, the list of files

035049
to process is reduced as specified in <samp>`regex'</samp> regular expression.
035049
Inside <tt>`centos-art.sh'</tt> script, the <samp>`regex'</samp> regular
035049
expression is used in combination with find command to look
035049
for files matching the regular expression path pattern.
035049

035049
Warning

Warning

In order for <samp>`regex'</samp> regular expression to match

035049
a file, the <samp>`regex'</samp> regular expresion must match the whole file
035049
path not just the file name. 
035049

035049
aaa0e9

For example, if you want to match all <tt>`render.conf.sh'</tt> files

aaa0e9
inside <tt>`path/to/dir'</tt>, use the .+/render.conf regular
aaa0e9
expression.  Later, <tt>`centos-art.sh'</tt> script uses this value inside
aaa0e9
^$REGEX\.sh$ expression in order to build the final regular
aaa0e9
expression (i.e., ^.+/render.conf\.sh$) that is evaluated
aaa0e9
against available file paths inside the list of files to process.
035049

035049

Exceptionally, when you provide <samp>`--filter='regex''</samp> in the way

035049
that <samp>`regex'</samp>, appended to <samp>`path/to/dir/'</samp> (i.e.
035049
<samp>`path/to/dir/regex'</samp>), matches a regular file; the
035049
<tt>`centos-art.sh'</tt> script uses the file matching as only file in the
035049
list of files to process. 
035049

e37211
aaa0e9
300762

3.45.4 See also

4c79b5
2c8180
aaa0e9
3.37 trunk/Scripts/Bash  
54b5a5
aaa0e9
3.38 trunk/Scripts/Bash/Functions  
2c8180
2c8180
4c79b5
4c79b5
4c79b5
aaa0e9
[ < ]
aaa0e9
[ > ]
4c79b5
   
4c79b5
[ << ]
01b527
[ Up ]
aaa0e9
[ >> ]
4c79b5
4c79b5

4c79b5
 <font size="-1">
92fb7f
  This document was generated on January, 5 2011 using texi2html 1.76.
4c79b5
 </font>
4c79b5
 
4c79b5
4c79b5

4c79b5
</body>
4c79b5
</html>