Blame Manual/repository-html/repository_75.html

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

2.71 The <tt>`trunk/Scripts/Bash/Cli/Functions/Shell'</tt> Directory

632e8b
632e8b
9bfd15
632e8b

2.71.1 Goals

632e8b
9bfd15

This section exists to organize files related to shell

632e8b
functionality of <tt>`centos-art.sh'</tt> script.
632e8b

632e8b
9bfd15
632e8b

2.71.2 Description

632e8b
9bfd15

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

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

9bfd15

When you use shell functionality to update copyright inside

9bfd15
script files, it is required that your script files contain (at least)
9bfd15
the following top commentary structure:
632e8b

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

Figure 2.4: The functions script base comment structure

9bfd15
632e8b

9bfd15

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

9bfd15
Everything else in the file is left immutable.
632e8b

9bfd15

When you are updating copyright through shell

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

9bfd15
Caution

Caution

Be sure to add the long dash separator that matches

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

9bfd15
9bfd15

The copyright template instance is created from one copyright template

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

9bfd15

When you use shell functionality to update copyright, the first

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

9bfd15

When shell functionality uses its own default values, the final

9bfd15
copyright note looks like the following:
632e8b

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

Figure 2.5: The function script comment example

9bfd15
632e8b

9bfd15

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

9bfd15
attention how the copyright line was built, and how the license was
9bfd15
added into the top comment where previously was just three dots.
9bfd15
Everything else in the file was left immutable. 
632e8b

9bfd15

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

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

9bfd15

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

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

9bfd15
Important

Important

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

632e8b

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

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

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

632e8b
632e8b
9bfd15
632e8b

2.71.3 Usage

632e8b
632e8b
9bfd15
centos-art sh --update-copyright='path/to/dir'
9bfd15
centos-art sh --update-copyright='path/to/dir' --filter='regex'
9bfd15

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

9bfd15
under <samp>`path/to/dir'</samp> directory. 
632e8b

632e8b
632e8b
632e8b

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

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

632e8b
Warning

Warning

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

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

632e8b
9bfd15

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

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

632e8b

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

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

632e8b
9bfd15
632e8b

2.71.4 See also

632e8b
632e8b
9bfd15
2.61 The <tt>`trunk/Scripts/Bash'</tt> Directory  
632e8b
632e8b
632e8b
632e8b
632e8b
9bfd15
[ < ]
9bfd15
[ > ]
632e8b
   
632e8b
[ << ]
9bfd15
[ Up ]
9bfd15
[ >> ]
632e8b
632e8b

632e8b
 <font size="-1">
9bfd15
  This document was generated on March, 8 2011 using texi2html 1.76.
632e8b
 </font>
632e8b
 
632e8b
632e8b

632e8b
</body>
632e8b
</html>