diff --git a/Functions/About/Config/authors.txt b/Functions/About/Config/authors.txt new file mode 100644 index 0000000..589e6f8 --- /dev/null +++ b/Functions/About/Config/authors.txt @@ -0,0 +1,8 @@ +$Id$ +This file records authoring information of CentOS Artwork Repository, +in alphabetical order. + +Ralph Angenendt +Marcus Moeller +Alain Reguera Delgado , 2009, 2010, 2011 +Karanbirn Singh diff --git a/Functions/About/Config/copying.txt b/Functions/About/Config/copying.txt new file mode 100644 index 0000000..0dce2aa --- /dev/null +++ b/Functions/About/Config/copying.txt @@ -0,0 +1,52 @@ +$Id$ +This file records copying information of CentOS Artwork Repository. + + + THE CENTOS ARTWORK REPOSITORY LICENSE + Version 1, 2011 + + Copyright © 2009-2011 Alain Reguera Delgado + Calle 39 e/ 44 y 46 No. 4426 Cienfuegos, Cuba. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + TERMS AND CONDITIONS FOR COPYING, + DISTRIBUTION AND MODIFICATION + + The CentOS Artwork Repository provides the file structure the + centos-art script needs to work as expected. The terms under + which such file structure is redistributed and/or modified + depends of the redistribution terms of the centos-art script + itself. + + The centos-art script is free software; you can redistribute + it and/or modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later + version. + + The centos-art script is distributed in the hope that it will + be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, + USA. + + The content produced inside The CentOS Artwork Repository + cannot enter in conflict with the redistribution terms of the + centos-art script, even both the centos-art script and the + content produced are quiet different types of work (e.g., the + centos-art script is a Bash program and the content produced + can take form of SVG files, PNG files, HTML files, and many + other open standards.). + + The content produced inside The CentOS Artwork Repository that + is marked with The CentOS Symbol, The CentOS Logo or The + CentOS Trademark is of internal use for The CentOS Project + only and you are not allowd to use it for your own purposes + without previous conversation with The CentOS Project. + However, if you are interested in studying such contents and + proposing your improvements, you are very welcome to do so. diff --git a/Functions/About/Config/history.txt b/Functions/About/Config/history.txt new file mode 100644 index 0000000..1b98ad5 --- /dev/null +++ b/Functions/About/Config/history.txt @@ -0,0 +1,136 @@ +$Id$ +This file records noteworthy changes of CentOS Artwork Repository. + + Copyright (C) 2009-2011 Alain Reguera Delgado + + Copying and distribution of this file, with or without modification, are + permitted in any medium without royalty provided the copyright notice and + this notice are preserved. + +------------------------------------------------------------------------------- +(2011) + + - Unify common arguments for all specific functionalities (e.g, --answer, + --quiet, --filter, etc.) and leave just specific arguments for specific + functions to parse. There is no need to duplicate common arguments + definitions inside every specific functionality. + + - The `.sed' translation files are no longer used, scalable vector + graphics are used instead. Translation messages take place by means of + xml2po and gettext. With xml2po translatable strings are retrived from + `.svg' files and stored inside gettext `.pot' and `.po' files for + translators to edit. Finally, xml2po is used again to build the temporal + design model translated instance which the final `.png' image is built + from. + + - The `trunk/Translation' directory structure is removed. The + `trunk/Locales' directory structure is used instead to store locale + information. + +------------------------------------------------------------------------------- +(2010) + + - Inside centos-art.sh script, functionalities start to get + identified and separated one from another. For example, when + images are rendered, there is no need to load manual + functionality. There are now common functionalities and specific + functionalities. Common functionalities are loaded when the + script is initiated and are available to specific + functionalities. + + - The directory structure is optimized to implements the corporate + identity concepts and the centos-art.sh script. The CentOS + Artwork Repository directory structure places the organizational + convenctions that centos-art.sh script needs to do what we + expect from it to do. + + - The following functionalities start to take form as part of + centos-art.sh script: + + `trunk/Scripts/Bash/Functions/Render/render.sh' + + To produce translated images using Inkscape and Sed + replacement commands. + + `trunk/Scripts/Bash/Functions/Manual/manual.sh' + + To produce documentation using Texinfo. Almost all + LaTeX-based documents were moved to Texinfo format and + handled by manual functionality. + + `trunk/Scripts/Bash/Functions/Locale/locale.sh' + + To translate centos-art.sh command-line interface messages + using gettext. + + `trunk/Scripts/Functions/Shell/shell.sh' + + To perform massive actions inside shell scripts. For + example, update top-commentaries massively. + + `trunk/Scripts/Functions/Svg/svg.sh' + + To perform massive actions inside SVG files. + + `trunk/Scripts/Functions/Html/html.sh' + + To perform massive actions inside HTML files. + + `trunk/Scripts/Functions/Path/path.sh' + + To automate manipulation of files, branches, and tags. + + `trunk/Scripts/Functions/About/about.sh' + + To print license, authors, history, copying, etc. + +------------------------------------------------------------------------------- +(2009) + + - The rendering script starts to evolve into centos-art.sh script, a + command-line interface to manipulate the CentOS Artwork Repository. + + - Corporate identity concepts taken from Wikipedia and related books are + introduced as development reference. The main goal of centos-art.sh + turns to: automate production of a monolithic corporate visual identity + structure based on CentOS Mission and CentOS Release Schema. + + - Alain Reguera Delgado is out of Internet for an undefined amount of + time, but continues developing CentOS Artwork Repository and its + automation tool (i.e., the centos-art.sh script) off-line. + + - Documentation begins to take form in LaTeX format. + +------------------------------------------------------------------------------- +(2008) + + - The CentOS Artwork Repository started at CentOS Developers + mailing list. + + - Alain Reguera Delgado shares ideas in a thread about Anaconda + progress slide images and the possibility of automating their + construction. + + - Ralph Angenendt rises up his hand asking: Do you have something + to show? + + - Alain Reguera Delgado posts a Bash script to produce slide + images in different languages ---together with the proposition + of creating a Subversion centralized repository where + translations and image production could be distributed inside + CentOS Community---. + + - Karanbirn Sighn considers the idea intresting and provides the + infrastructure to support the effort as the CentOS Artwork SIG. + + https://projects.centos.org/svn/artwork/ + https://projects.centos.org/trac/artwork/ + + - Alain Reguera Delagdo uploads the rendering script to CentOS + Artwork Repository. + + - Ralph Angenendt documents the rendering script. + + - With the rendering script and its documentation available, + translators start to download working copies of CentOS Artwork + Repository to produce slide images in their own languages. diff --git a/Functions/About/Config/license.txt b/Functions/About/Config/license.txt new file mode 100644 index 0000000..5b6e7c6 --- /dev/null +++ b/Functions/About/Config/license.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/Functions/About/about.sh b/Functions/About/about.sh new file mode 100755 index 0000000..77ea1d2 --- /dev/null +++ b/Functions/About/about.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# license.sh -- This function outputs centos-art.sh about messages. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function about { + + # Define command-line interface. + about_getActions + +} diff --git a/Functions/About/about_getActions.sh b/Functions/About/about_getActions.sh new file mode 100755 index 0000000..15d714b --- /dev/null +++ b/Functions/About/about_getActions.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# +# about_getActions.sh -- This function interpretes arguments passed to +# about functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function about_getActions { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="license,history,authors,copying" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + case "$1" in + + --license ) + ACTIONVAL="${FUNCCONFIG}/license.txt" + break + ;; + + --history ) + ACTIONVAL="${FUNCCONFIG}/history.txt" + break + ;; + + --authors ) + ACTIONVAL="${FUNCCONFIG}/authors.txt" + break + ;; + + --copying | * ) + ACTIONVAL="${FUNCCONFIG}/copying.txt" + break + ;; + + esac + done + + # Execute action name. + if [[ -f $ACTIONVAL ]];then + less $ACTIONVAL + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Functions/Brand/brandAnaconda.sh b/Functions/Brand/brandAnaconda.sh new file mode 100644 index 0000000..8b215eb --- /dev/null +++ b/Functions/Brand/brandAnaconda.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# +# brandAnaconda - Anaconda branding script. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function brandAnaconda { + + # Define file's source and target. + local ARTDIR=~/artwork/trunk/Identity/Themes/$(cli_getPathComponent '--theme')/Distro/Anaconda + local PIXMAP=/usr/share/anaconda/pixmaps + local SOURCE='' + local TARGET='' + + # Define list of files used as base to determine which files may + # need to be updated. Remove target from file path. Do not use + # basename command. We may need the directory structure (if any) + # under target, for further evaluation. + local FILES=$(find ${PIXMAP}/ | sort | uniq | sed "s!${PIXMAP}/!!g") + local FILE='' + + for FILE in $FILES;do + + # Define which file is release-specific, and specify the correct + # path on source. + case $FILE in + anaconda_header.png ) + SOURCE=$ARTDIR/Header/Img/$MAJOR_RELEASE/$FILE + TARGET=$PIXMAP/$FILE + ;; + + progress_first*.png | first*.png ) + SOURCE=$ARTDIR/Progress/Img/$MAJOR_RELEASE/$FILE + TARGET=$PIXMAP/$FILE + ;; + + rnotes | rnotes/?? | rnotes/??_?? ) + continue + ;; + + rnotes/??-*.png ) + FILE=$(basename $FILE | sed -r 's!-centos[0-9]+!!') + SOURCE=$ARTDIR/Progress/Img/$MAJOR_RELEASE/en/$FILE + TARGET=$PIXMAP/rnotes/$FILE + ;; + + rnotes/*/??-*.png ) + LANGUAGE=$(echo $FILE | sed -r 's!rnotes/(.+)/.*!\1!') + FILE=$(basename $FILE | sed -r 's!-centos[0-9]+!!') + SOURCE=$ARTDIR/Progress/Img/$MAJOR_RELEASE/$LANGUAGE/$FILE + TARGET=$PIXMAP/rnotes/$LANGUAGE/$FILE + ;; + + splash.png ) + SOURCE=$ARTDIR/Splash/Img/$MAJOR_RELEASE/$FILE + TARGET=$PIXMAP/$FILE + ;; + + syslinux-splash.png ) + TARGET=$PIXMAP/$FILE + FILE=$(echo $FILE | sed -r 's!\.png$!-16c.png!') + SOURCE=$ARTDIR/Prompt/Img/$MAJOR_RELEASE/$FILE + ;; + + * ) + TARGET=$PIXMAP/$FILE + SOURCE=$ARTDIR/$FILE + esac + + # Check if file exists on source. If file doesn't exist on the + # source it is not updated on target. Go to next file in the + # loop and check again. Only file names on source that match + # those in target are updated. + cli_checkFiles "$SOURCE" + + # File exists and will be installed on target. + cli_printMessage "$TARGET" "AsUpdatingLine" + + # Update file. + #cp $SOURCE $TARGET + + # Set file's access rights. + #chown root:root $TARGET + #chmod 755 $TARGET + #chcon system_u:object_r:usr_t $TARGET + +done +} diff --git a/Functions/Brand/brandFirstboot.sh b/Functions/Brand/brandFirstboot.sh new file mode 100755 index 0000000..cb785d7 --- /dev/null +++ b/Functions/Brand/brandFirstboot.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# +# brandFirstboot - Firstboot branding script. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function brandFirstboot { + + # Define file's source and target. + local ARTDIR=~/artwork/trunk/Identity/Themes/$(cli_getPathComponent '--theme')/Distro/Anaconda + local PIXMAP=/usr/share/firstboot/pixmaps + local SOURCE='' + local TARGET='' + + # Define list of files used as base to determine which files may + # need to be updated. Remove target from file path. Do not use + # basename command. We may need the directory structure (if any) + # under target, for further evaluation. + local FILES=$(find ${PIXMAP}/ | sort | uniq | sed "s!${PIXMAP}/!!g") + local FILE='' + + for FILE in $FILES;do + + # Define which file is release-specific, and specify the correct + # path on source. + case $FILE in + + splash-small.png ) + SOURCE=$ARTDIR/Firstboot/Img/$MAJOR_RELEASE/$FILE + TARGET=$PIXMAP/$FILE + ;; + + firstboot-left.png ) + SOURCE=$ARTDIR/Firstboot/Img/$FILE + TARGET=$PIXMAP/$FILE + ;; + + * ) + SOURCE=$ARTDIR/Firstboot/Img/$FILE + TARGET=$PIXMAP/$FILE + esac + + # Check if file exists on source. If file doesn't exist on the + # source it is not updated on target. Go to next file in the + # loop and check again. Only file names on source that match + # those in target are updated. + cli_checkFiles "$SOURCE" + + # File exists and will be installed on target. + cli_printMessage "$TARGET" "AsUpdatingLine" + + # Update file. + #cp $SOURCE $TARGET + + # Set file's access rights. + #chown root:root $TARGET + #chmod 755 $TARGET + #chcon system_u:object_r:usr_t $TARGET + + done +} diff --git a/Functions/Help/Config/manual-copyright-cc-by-sa.texi b/Functions/Help/Config/manual-copyright-cc-by-sa.texi new file mode 100755 index 0000000..8dab9f4 --- /dev/null +++ b/Functions/Help/Config/manual-copyright-cc-by-sa.texi @@ -0,0 +1,8 @@ +Copyright @copyright{} =COPYRIGHT_YEAR= =COPYRIGHT_HOLDER= + +Permission is granted to copy, distribute and/or modify this document +under the terms of the a Creative Commons Attribution–Share Alike 3.0 +Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available +at @url{http://creativecommons.org/licenses/by-sa/3.0/}. In accordance +with CC-BY-SA, if you distribute this document or an adaptation of it, +you must provide the URL for the original version. diff --git a/Functions/Help/Config/manual-copyright-gfdl.texi b/Functions/Help/Config/manual-copyright-gfdl.texi new file mode 100755 index 0000000..2a48f99 --- /dev/null +++ b/Functions/Help/Config/manual-copyright-gfdl.texi @@ -0,0 +1,8 @@ +Copyright @copyright{} =COPYRIGHT_YEAR= =COPYRIGHT_HOLDER= + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no +Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A +copy of the license is included in the section entitled ``GNU Free +Documentation License''. diff --git a/Functions/Help/Config/manual-index.texi b/Functions/Help/Config/manual-index.texi new file mode 100644 index 0000000..abe002c --- /dev/null +++ b/Functions/Help/Config/manual-index.texi @@ -0,0 +1,3 @@ +@node Index +@unnumbered Index +@printindex cp diff --git a/Functions/Help/Config/manual-intro.texi b/Functions/Help/Config/manual-intro.texi new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Functions/Help/Config/manual-intro.texi diff --git a/Functions/Help/Config/manual-menu.texi b/Functions/Help/Config/manual-menu.texi new file mode 100644 index 0000000..70362c8 --- /dev/null +++ b/Functions/Help/Config/manual-menu.texi @@ -0,0 +1,3 @@ +@menu +* Index:: +@end menu diff --git a/Functions/Help/Config/manual-nodes.texi b/Functions/Help/Config/manual-nodes.texi new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Functions/Help/Config/manual-nodes.texi diff --git a/Functions/Help/Config/manual-section.texi b/Functions/Help/Config/manual-section.texi new file mode 100644 index 0000000..fb39647 --- /dev/null +++ b/Functions/Help/Config/manual-section.texi @@ -0,0 +1,22 @@ +@subsection Goals + +@itemize +@item ... +@end itemize + +@subsection Description + +@itemize +@item ... +@end itemize + +@subsection Usage + +@itemize +@item ... +@end itemize + +@subsection See also + +@menu +@end menu diff --git a/Functions/Help/Config/manual.texi b/Functions/Help/Config/manual.texi new file mode 100644 index 0000000..3d05184 --- /dev/null +++ b/Functions/Help/Config/manual.texi @@ -0,0 +1,55 @@ +\input texinfo @c -*-texinfo-*- +@c $Id$ +@c -- Header -------------------------------------------------- + +@setfilename =FILENAME=.info +@settitle =TITLE= +@documentlanguage =LOCALE_LL= +@afourpaper +@finalout + +@c -- Summary description and copyright ----------------------- + +@copying +=DESCRIPTION= + +Copyright @copyright{} =COPYRIGHT_YEAR= =COPYRIGHT_HOLDER= + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no +Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A +copy of the license is included in the section entitled GNU Free +Documentation License. +@end copying + +@c -- Titlepage, contents, copyright --------------------------- + +@titlepage +@title =TITLE= +@subtitle =SUBTITLE= +@author =AUTHOR= +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage +@contents + +@c -- `Top' node and master menu ------------------------------- + +@ifnottex +@node Top +@top =TITLE= +@insertcopying +@end ifnottex +@include manual-menu.texi + +@c -- The body of the document -------------------------------- + +@include manual-nodes.texi + +@c -- The end of the document --------------------------------- + +@include manual-index.texi + +@bye diff --git a/Functions/Help/help.sh b/Functions/Help/help.sh new file mode 100755 index 0000000..6f17e68 --- /dev/null +++ b/Functions/Help/help.sh @@ -0,0 +1,132 @@ +#!/bin/bash +# +# help.sh -- This function provides documentation features to +# centos-art.sh script. Here we initialize documentation variables and +# call help_getArguments functions. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help { + + local ACTIONNAM='' + local ACTIONVAL='' + + # Define manuals base directory. This is the place where + # documentation manuals base directory structures are stored and + # organized in. + MANUAL_BASEDIR="${HOME}/artwork/trunk/Manual" + + # Define file name for documentation manual. This is the file used + # to initiate the structure of documentation manual. + MANUAL_NAME=repository + + # Define base name for documentation manual files (without + # extension). This is the main file name used to build texinfo + # related files (.info, .pdf, .xml, etc.). + MANUAL_BASEFILE="${MANUAL_BASEDIR}/${MANUAL_NAME}" + + # Interpret arguments and options passed through command-line. + help_getArguments + + # Redefine positional parameters using ARGUMENTS. At this point, + # option arguments have been removed from ARGUMENTS variable and + # only non-option arguments remain in it. + eval set -- "$ARGUMENTS" + + # Define action name. It does matter what option be passed to + # centos-art, there are many different actions to perform based on + # the option passed (e.g., `--edit', `--read', `--search', etc.). + # In that sake, we defined action name inside help_getArguments, + # at the moment of interpreting options. + + # Define default manual node shown when no argument is provided to + # help functionality. By default, the Top node of repository + # manual is called. + if [[ $ACTIONNAM == '' ]] && [[ $ACTIONVAL == '' ]];then + /usr/bin/info --node="Top" --file=${MANUAL_BASEFILE}.info.bz2 + fi + + # Define action value. As convenction, we use non-option arguments + # to define the action value (ACTIONVAL) variable. + for ACTIONVAL in "$@";do + + if [[ $ACTIONVAL == '--' ]];then + continue + fi + + # Check action value passed through the command-line using + # source directory definition as reference. + cli_checkRepoDirSource + + # Define documentation entry. + ENTRY=$(help_getEntry) + + # Define documentation entry directory. This is the directory + # where the entry file is stored. + ENTRY_DIR=$(dirname ${ENTRY} | sed -r 's!\.texi$!!') + + # Define documentation entry file (without extension). + ENTRY_FILE=$(basename ${ENTRY} | sed -r 's!\.texi$!!') + + # Define directory to store documentation entries. At this + # point, we need to take a desition about documentation + # design, in order to answer the question: How do we assign + # chapters, sections and subsections automatically, based on + # the repository structure? and also, how such design could + # be adapted to changes in the repository structure? + # + # One solution would be: represent the repository's directory + # structure as sections inside a chapter named Filesystem or + # something similar. Subsections and subsubsections will not + # have their own files, they all will be written inside the + # same section file that represents the repository directory. + MANUAL_CHAPTER_DIR=$(echo $ENTRY | cut -d / -f-7) + + # Define chapter name for the documentation entry we are + # working with. + MANUAL_CHAPTER_NAME=$(basename "$MANUAL_CHAPTER_DIR") + + # Set action preable. + cli_printActionPreamble "${MANUAL_BASEFILE}.texi" '' '' + + # Syncronize changes between repository and working copy. At + # this point, changes in the repository are merged in the + # working copy and changes in the working copy committed up to + # repository. + cli_syncroRepoChanges ${MANUAL_BASEDIR} + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Commit changes from working copy to central repository only. + # At this point, changes in the repository are not merged in + # the working copy, but chages in the working copy do are + # committed up to repository. + cli_commitRepoChanges ${MANUAL_BASEDIR} + + done +} diff --git a/Functions/Help/help_copyEntry.sh b/Functions/Help/help_copyEntry.sh new file mode 100755 index 0000000..707b541 --- /dev/null +++ b/Functions/Help/help_copyEntry.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# help_copyEntry.sh -- This function copies documentation entries and +# updates documentation structure to reflect changes. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_copyEntry { + + local ENTRY_SRC=${ENTRY} + local ENTRY_DST=${FLAG_TO} + local ENTRIES='' + local ENTRY='' + + # Print action message. + cli_printMessage "${ENTRY_DST}" 'AsCreatingLine' + + # Copy main documentation entry. + if [[ ! -f ${ENTRY_DST} ]];then + svn cp "${ENTRY_SRC}" "${ENTRY_DST}" --quiet + fi + + # Define target location of directory holding dependent + # documentation entries. + ENTRY_DST=$(echo ${ENTRY_DST} | sed -r 's!\.texi$!!') + + # Copy dependent documentation entries, if any. + if [[ ! -d ${ENTRY_DST} ]];then + cli_printMessage "${ENTRY_DST}" 'AsCreatingLine' + svn cp "${ENTRY_DIR}/${ENTRY_FILE}" "${ENTRY_DST}" --quiet + fi + + # Define list of files to process. + ENTRIES=$(cli_getFilesList "$(dirname ${ENTRY_DST})" "$(basename ${ENTRY_DST}).*\.texi") + + # Set action preamble. + cli_printActionPreamble "${ENTRIES}" '' '' + + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Print action message. + cli_printMessage "Updating manual menus, nodes and cross-references." 'AsResponseLine' + + # Redefine ENTRY variable in order to update documentation + # structure, taking recently created entries as reference. + for ENTRY in ${ENTRIES};do + + # Update menu and node definitions from manual sections to + # reflect the changes. + help_updateMenu + help_updateNodes + + # Update cross reference definitions from manual to reflect + # the changes. + help_restoreCrossReferences + + done + +} diff --git a/Functions/Help/help_deleteCrossReferences.sh b/Functions/Help/help_deleteCrossReferences.sh new file mode 100755 index 0000000..9152fc8 --- /dev/null +++ b/Functions/Help/help_deleteCrossReferences.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# +# help_deleteCrossReferences.sh -- This function looks inside +# texinfo source files, from section level on, and removes all cross +# referece definitions related to a documentation entry. Use this +# function in coordination with help_deleteEntry function, in order +# to keep cross reference information, inside the documentation +# manual, syncronized. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_deleteCrossReferences { + + local -a PATTERN + local -a REPLACE + local LOCATION='' + + # Define entry location. Verify first argument to make this + # function reusable. If no value is passed as first argument use + # entry global information value as default value instead. + if [[ "$1" != '' ]];then + LOCATION="$1" + else + LOCATION="$ENTRY" + fi + + # Build the node string using entry location. + local NODE=$(echo "$LOCATION" \ + | cut -d / -f8- \ + | tr '/' ' ' \ + | sed -r \ + -e "s/(chapter-intro\.texi|\.texi)$//" \ + -e 's! !( |\\n)!g') + + # Define regular expression patterns for texinfo cross reference + # commands. + PATTERN[0]="@(pxref|xref|ref)\{(${NODE})\}" + PATTERN[1]="^(\* ${NODE}:(.*)?:(.*)?)$" + + # Define replacement string for missing entries. It is convenient + # to keep missing entries in documentation for documentation team + # to know. Removing the missing cross reference may intorudce + # confussion. Imagine that! you are spending lots of hours in an + # article and suddenly one of your cross refereces disappears with + # no visible reason, with the next working copy update you + # perform. That's frustrating. Instead, when centos-art.sh script + # finds a missing cross reference it removes the link and remark + # the issue for you to act on it. + REPLACE[0]='--- @strong{'`gettext "Removed"`'}(\1:\2) ---' + REPLACE[1]='@comment --- '`gettext "Removed"`'(\1) ---' + + # Define list of entries to process. + local ENTRIES=$(cli_getFilesList "${MANUAL_BASEDIR}" '.*\.texi') + + # Set action preamble. + cli_printActionPreamble "$ENTRIES" '' '' + + # Update node-related cross references. The node-related cross + # reference definition, long ones specially, could require more + # than one line to be set. By default, GNU sed does not matches + # newline characters in the pattern space, so we need to make use + # of `label' feature and the `N' command in order to build a + # pattern space that includes the newline character in it. Here we + # use the `a' letter to name the label we use, followed by N + # command to add a newline to the pattern space, the s command to + # make the pattern replacement using the `g' flag to make it + # global and finaly the command `b' to branch label named `a'. + sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${ENTRIES} + + # Update menu-related cross references. Menu-related cross + # references hardly appear in more than one line, so there is no + # need to complicate the replacement command. + sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${ENTRIES} + +} diff --git a/Functions/Help/help_deleteEntry.sh b/Functions/Help/help_deleteEntry.sh new file mode 100755 index 0000000..ba5e0b8 --- /dev/null +++ b/Functions/Help/help_deleteEntry.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# +# help_deleteEntry.sh -- This function removes a documentation entry +# from documentation directory structure. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_deleteEntry { + + local ENTRY_SRC=${ENTRY} + local ENTRIES='' + local ENTRY='' + local ENTRY_DEP='' + + # Initiate list of entries to remove using the entry specified in + # the command line. + ENTRIES=${ENTRY_SRC} + + # Verify existence of dependent entries. Dependent entries are + # stored inside a directory with the same name of the entry you + # are trying to remove. + if [[ -d ${ENTRY_DIR}/${ENTRY_FILE} ]];then + + # Add dependent files to list of entries. + ENTRIES="${ENTRIES} $(cli_getFilesList "${ENTRY_DIR}/${ENTRY_FILE}" ".*\.texi")" + + # Add dependent directories to list of entries. Be aware of + # nested directories. + for ENTRY in ${ENTRIES};do + ENTRY_DEP=$(echo $ENTRY | sed -r "s/\.texi$//") + if [[ -d $ENTRY_DEP ]];then + ENTRIES="${ENTRIES} ${ENTRY_DEP}" + fi + done + + fi + + # Prepare list of entries for action preamble. + ENTRIES=$(echo ${ENTRIES} | tr ' ' "\n" | sort -r | uniq) + + # Print action preamble. + cli_printActionPreamble "$ENTRIES" 'doDelete' 'AsResponseLine' + + # Remove documentation entry using regular subversion commands. + # Do not use regular rm command here, use subversion del command + # instead. Otherwise, even the file is removed, it will be brought + # back when the final cli_commitRepoChange be executed. Remember + # there is a subversion update there, no matter what you remove + # using regular commands, when you do update the directory + # structure on the working copy the removed files (not removed in + # the repository, nor marked to be removed) are brought down to + # the working copy again. + svn del ${ENTRIES} --quiet + if [[ $? -ne 0 ]];then + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Print action message. + cli_printMessage "Updating manual menus, nodes and cross-references." 'AsResponseLine' + + # Process list of entries in order to update menus, nodes and + # cross references. Since we are verifying entry status before + # remove the we cannot update the information in the same loop we + # remove files. This would modify some file before be removed and + # that would stop script execution. Similary, if we do update + # menus, nodes and cross references before removing files it would + # be needed to remove farther status verification in order for the + # script to continue its execution. Thereby, I can't see a + # different way but removing files first using status verification + # and later go through entities list again to update menus, nodes + # and cross references from remaining files. + for ENTRY in ${ENTRIES};do + + # Use entry files only. Directories are used to store + # dependent entries. Directories are not considered entries on + # themselves. + if [[ ! -f $ENTRY ]];then + continue + fi + + # Update menu and node definitions from manual sections to + # reflect the changes. + help_updateMenu "remove-entry" + help_updateNodes + + # Update cross reference definitions from manual to reflect + # the changes. + help_deleteCrossReferences + + done + + # Remove entry menus and nodes from chapter definition to reflect + # the fact it has been removed. This is mainly applied when one + # of the chapters (e.g., trunk/, tags/, or branches/) is removed. + if [[ ! -d $MANUAL_CHAPTER_DIR ]];then + help_updateChaptersMenu 'remove-entry' + help_updateChaptersNodes + fi + +} diff --git a/Functions/Help/help_editEntry.sh b/Functions/Help/help_editEntry.sh new file mode 100755 index 0000000..6041267 --- /dev/null +++ b/Functions/Help/help_editEntry.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# +# help_editEntry.sh -- This function implements the edition flow of +# documentation entries inside the working copy. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_editEntry { + + # Verify chapter definition inside manual. + if [[ ! -d $MANUAL_CHAPTER_DIR ]];then + + # Print confirmation question. + cli_printMessage "`gettext "The following documentation chapter will be created:"`" + cli_printMessage "$MANUAL_CHAPTER_DIR" "AsResponseLine" + cli_printMessage "`gettext "Do you want to continue?"`" "AsYesOrNoRequestLine" + + # Update manual chapter related files. + help_updateChaptersFiles + + # Update manual chapter related menu. + help_updateChaptersMenu + + # Update manual chapter related nodes (based on chapter + # related menu). + help_updateChaptersNodes + + fi + + # Verify section definition inside chapters. + if [[ ! -f $ENTRY ]];then + + # Print confirmation question. + cli_printMessage "`gettext "The following documentation section will be created:"`" + cli_printMessage "$ENTRY" "AsResponseLine" + cli_printMessage "`gettext "Do you want to continue?"`" "AsYesOrNoRequestLine" + + # Update chapter section related menu. + help_updateMenu + + # Update chapter section related nodes (based on chapter + # section related menu). + help_updateNodes + + # Update old missing cross references. If for some reason a + # documentation entry is removed by mistake, and that mistake + # is fixing by adding the removed documentation entry back + # into the repository, rebuild the missing cross reference + # message to use the correct link to the documentation + # section. + help_restoreCrossReferences + + else + + # Print action message. + cli_printMessage "$ENTRY" 'AsUpdatingLine' + + fi + + # Use default text editor to edit the documentation entry. + eval $EDITOR $ENTRY + + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Rebuild output files to propagate recent changes. + help_updateOutputFiles + +} diff --git a/Functions/Help/help_getArguments.sh b/Functions/Help/help_getArguments.sh new file mode 100755 index 0000000..30adbbd --- /dev/null +++ b/Functions/Help/help_getArguments.sh @@ -0,0 +1,95 @@ +#!/bin/bash +# +# help_getArguments.sh -- This function interpretes arguments passed +# to `manual' functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_getArguments { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="filter:,quiet,answer:,dont-commit-changes,read,search,edit,update" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Define action to take for each option passed. + while true; do + case "$1" in + + --filter ) + FLAG_FILTER="$2" + shift 2 + ;; + + --quiet ) + FLAG_QUIET="true" + FLAG_DONT_COMMIT_CHANGES="true" + shift 1 + ;; + + --answer ) + FLAG_ANSWER="$2" + shift 2 + ;; + + --dont-commit-changes ) + FLAG_DONT_COMMIT_CHANGES="true" + shift 1 + ;; + + --read ) + ACTIONNAM="${FUNCNAM}_searchNode" + shift 1 + ;; + + --search ) + ACTIONNAM="${FUNCNAM}_searchIndex" + shift 1 + ;; + + --edit ) + ACTIONNAM="${FUNCNAM}_editEntry" + shift 1 + ;; + + --update ) + ACTIONNAM="${FUNCNAM}_updateOutputFiles" + shift 1 + ;; + + * ) + break + esac + done + + # Redefine ARGUMENTS variable using current positional parameters. + cli_doParseArgumentsReDef "$@" + +} diff --git a/Functions/Help/help_getEntry.sh b/Functions/Help/help_getEntry.sh new file mode 100755 index 0000000..ae68e99 --- /dev/null +++ b/Functions/Help/help_getEntry.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# help_getEntry.sh -- This function builds a documentation entry based +# on a location specified. Location specification can be both action +# value (ACTIONVAL) variable or a value passed as first positional +# parameter. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_getEntry { + + # Define variables as local to avoid conflicts outside. + local ENTRY='' + local LOCATION='' + + # Redefine location in order to make this function reusable not + # just for action value variable but whatever value passed as + # first possitional argument. + if [[ "$1" != '' ]];then + LOCATION="$1" + else + LOCATION="$ACTIONVAL" + fi + + # Define relative path of entry, from trunk directory on. + ENTRY=$(echo $LOCATION | sed -r "s!^${HOME}/artwork/!!") + + # Verify the entry relative path to find out which documentation + # manual we are acting on. As convenction, whatever documentation + # entry you provide outside trunk/Manuals/ directory structure is + # considered as you are documenting the repository directory + # structure. Otherwise, if an entry inside trunk/Manuals/ is + # provided, the directory structure provided is used as default + # documentation manual for actions like `--create' and `--update' + # to take place on. Other options like `--edit', `--delete' and + # `--read' cannot be applied to paths provided is inside + # trunk/Manuals/ such actions made manually. + if [[ ${ENTRY} =~ '\.texi$' ]];then + ENTRY=$(echo ${ENTRY} | sed 's!trunk/Manual/!!') + else + ENTRY=$(dirname Filesystem/${ENTRY})/$(basename $LOCATION).texi + fi + + # Re-define entry to set absolute path to manuals base directory + # structure. + ENTRY=${MANUAL_BASEDIR}/${ENTRY} + + # Output entry's absolute path. + echo ${ENTRY} + +} diff --git a/Functions/Help/help_getNode.sh b/Functions/Help/help_getNode.sh new file mode 100755 index 0000000..6aacfc5 --- /dev/null +++ b/Functions/Help/help_getNode.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# help_getNode.sh -- This function cleans up the action value +# (ACTIONVAL) directory to make a node name from it. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_getNode { + + local NODE=$(echo "$ACTIONVAL" \ + | sed -r "s!^${HOME}/artwork/!!" \ + | sed -r 's!/! !g' | sed -r 's!^[[:space:]]+!!') + + echo "$NODE" +} + diff --git a/Functions/Help/help_renameCrossReferences.sh b/Functions/Help/help_renameCrossReferences.sh new file mode 100755 index 0000000..c85b575 --- /dev/null +++ b/Functions/Help/help_renameCrossReferences.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# +# help_renameCrossReferences.sh -- This function replaces a node +# pattern with a node replacement and updates cross-reference +# definitions to reflect the changes. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_renameCrossReferences { + + local NODE='' + local COUNT=1 + local ENTRIES='' + local NODE_SRC='' + local NODE_DST='' + + # Define node pattern for source documenation entry. + NODE_SRC=$(echo "$ENTRY" \ + | cut -d / -f8- \ + | tr '/' ' ' \ + | sed -r \ + -e "s/(chapter-intro\.texi|\.texi)$//" \ + -e 's! !( |\\n)!g') + + # Define node replacement for target documentation entry. + NODE_DST=$(echo "$FLAG_TO" \ + | cut -d / -f8- \ + | tr '/' ' ' \ + | sed -r \ + -e "s/(chapter-intro\.texi|\.texi)$//") + + # Sanitate node replacement for target documentation entry to make + # use of regular expression positional markers, so the word + # separator character found by node pattern could be used. + for NODE in $NODE_DST;do + if [[ $COUNT -eq 1 ]];then + NODE_DST="${NODE}\\${COUNT}" + else + NODE_DST="${NODE_DST}$(echo "${NODE}\\${COUNT}")" + fi + COUNT=$(($COUNT + 1)) + done + + # Remove last positional marker from node replacement. + NODE_DST=$(echo $NODE_DST | sed -r 's!\\[[:digit:]]$!!') + + # Define list of entries to process. + ENTRIES=$(cli_getFilesList "${MANUAL_BASEDIR}" '.*\.texi') + + # Set action preamble. + cli_printActionPreamble "$ENTRIES" '' '' + + # Update node-related cross-references. The node-related cross + # reference definition, long ones specially, could require more + # than one line to be set. By default, GNU sed does not matches + # newline characters in the pattern space, so we need to make use + # of `label' feature and the `N' command in order to build a + # pattern space that includes the newline character in it. Here we + # use the `a' letter to name the label we use, followed by N + # command to add a newline to the pattern space, the s command to + # make the pattern replacement using the `g' flag to make it + # global and finaly the command `b' to branch label named `a'. + sed -r -i ":a;N;s!${NODE_SRC}!${NODE_DST}!g;ba" ${ENTRIES} + + # At this point, source documentation entry has been renamed from + # source to target documentation entry, but they are still + # commented. So, restore target documentation entries. + help_restoreCrossReferences "${FLAG_TO}" + +} diff --git a/Functions/Help/help_renameEntry.sh b/Functions/Help/help_renameEntry.sh new file mode 100755 index 0000000..492ccce --- /dev/null +++ b/Functions/Help/help_renameEntry.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# help_renameEntry.sh -- This function renames documentation entries +# and updates documentation structure to reflect changes. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_renameEntry { + + # Copy source documentation entry. + help_copyEntry + + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Delete source documentation entry. The source documentation + # entry has been copied already, so to create the rename effect + # delete it from repository filesystem. + help_deleteEntry + + # At this point, source documentation entry has been removed and + # all menu, nodes and cross-references have been commented. So, + # replace commented menu, nodes and cross-reference information + # from source to target documentation entry. + help_renameCrossReferences + +} diff --git a/Functions/Help/help_restoreCrossReferences.sh b/Functions/Help/help_restoreCrossReferences.sh new file mode 100755 index 0000000..bfd0357 --- /dev/null +++ b/Functions/Help/help_restoreCrossReferences.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# help_restoreCrossReferences.sh -- This function looks inside +# texinfo source files, from section level on, and restores any cross +# reference related to a documentation entry. This function is used in +# those cases where documentation entries are created/recreated to +# documentation structure. It is a verification that looks for +# matching documentation entries previously defined as removed by +# help_deleteCrossReferences function. The +# help_restoreCrossReferences function relays in the removed message +# format produced by help_deleteCrossReferences function, in order +# to return them back into the link format. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_restoreCrossReferences { + + local -a PATTERN + local -a REPLACE + local LOCATION='' + + # Define entry location. Verify first argument to make this + # function reusable. If no value is passed as first argument use + # entry global information value as default value instead. + if [[ "$1" != '' ]];then + LOCATION="$1" + else + LOCATION="$ENTRY" + fi + + # Build the node string using entry location. + local NODE=$(echo "$LOCATION" \ + | cut -d / -f8- \ + | tr '/' ' ' \ + | sed -r \ + -e "s/(chapter-intro\.texi|\.texi)$//" \ + -e 's! !( |\\n)!g') + + # Define regular expression patterns to match removed message + # format produced by message_removeCrossReferences function. + PATTERN[0]="--- @strong\{`gettext "Removed"`\}\((pxref|xref|ref):(${NODE})\) ---" + PATTERN[1]="^@comment --- `gettext "Removed"`\((\* ${NODE}:(.*)?:(.*)?)\) ---$" + + # Define replacement string to turn removed message back to cross + # reference link. + REPLACE[0]='@\1{\2}' + REPLACE[1]='\1' + + # Define list of entries to process. + local ENTRIES=$(cli_getFilesList "${MANUAL_BASEDIR}" '.*\.texi') + + # Set action preamble. + cli_printActionPreamble "$ENTRIES" '' '' + + # Update node-related cross references. The node-related cross + # reference definition, long ones specially, could require more + # than one line to be set. By default, GNU sed does not matches + # newline characters in the pattern space, so we need to make use + # of `label' feature and the `N' command in order to build a + # pattern space that includes the newline character in it. Here we + # use the `a' letter to name the label we use, followed by N + # command to add a newline to the pattern space, the s command to + # make the pattern replacement using the `g' flag to make it + # global and finaly the command `b' to branch label named `a'. + sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${ENTRIES} + + # Update menu-related cross references. Menu-related cross + # references hardly appear in more than one line, so there is no + # need to complicate the replacement command. + sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${ENTRIES} + +} diff --git a/Functions/Help/help_searchIndex.sh b/Functions/Help/help_searchIndex.sh new file mode 100644 index 0000000..e20715a --- /dev/null +++ b/Functions/Help/help_searchIndex.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# help_searchIndex.sh -- This function does an index search inside the +# info document. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_searchIndex { + + # Check flag filter. By default flag filter has the `.+' value + # which is not very descriptive in the sake of an index-search. + # So, when no value is passed through --filter option use top node + # as default value for index-search. + if [[ "$FLAG_FILTER" == '.+' ]];then + cli_printMessage "`gettext "Use the \\\`--filter' option to define the search pattern."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Print action message. + cli_printMessage "${MANUAL_BASEFILE}.info.bz2" 'AsReadingLine' + + # Execute info command to perform an index-search. + /usr/bin/info --index-search="$FLAG_FILTER" --file=${MANUAL_BASEFILE}.info.bz2 + +} diff --git a/Functions/Help/help_searchNode.sh b/Functions/Help/help_searchNode.sh new file mode 100755 index 0000000..0224c38 --- /dev/null +++ b/Functions/Help/help_searchNode.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# help_searchNode.sh -- This function does a node search inside the +# info document. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_searchNode { + + # Print action message. + cli_printMessage "${MANUAL_BASEFILE}.info.bz2" 'AsReadingLine' + + # Check entry inside documentation structure. If the entry + # exits use the info reader to open the info file at the + # specified node. Otherwise, ask the user for create it. + if [[ -f "$ENTRY" ]];then + /usr/bin/info --node="Filesystem $(help_getNode)" --file=${MANUAL_BASEFILE}.info.bz2 + else + help_editEntry + fi + +} diff --git a/Functions/Help/help_updateChaptersFiles.sh b/Functions/Help/help_updateChaptersFiles.sh new file mode 100755 index 0000000..9964589 --- /dev/null +++ b/Functions/Help/help_updateChaptersFiles.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# help_updateChaptersFiles.sh -- This function updates chapter related +# files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateChaptersFiles { + + # Define chapter's generic structure. + local CHAPTERBODY="\ + @node $MANUAL_CHAPTER_NAME + @chapter $MANUAL_CHAPTER_NAME + @cindex $(echo $MANUAL_CHAPTER_NAME | tr '[[:upper:]]' '[[:lower:]]') + @include $MANUAL_CHAPTER_NAME/chapter-intro.texi + @include $MANUAL_CHAPTER_NAME/chapter-menu.texi + @include $MANUAL_CHAPTER_NAME/chapter-nodes.texi" + + # Remove any space/tabs at the begining of @... lines. + CHAPTERBODY=$(echo "$CHAPTERBODY" | sed -r 's!^[[:space:]]+@!@!') + + # Create directory to store chapter files. + if [[ ! -d $MANUAL_CHAPTER_DIR ]];then + mkdir $MANUAL_CHAPTER_DIR + fi + + # Create files to store chapter information. If chapter files + # already exist, they will be re-written and any previous + # information inside them will be lost. + echo "$CHAPTERBODY" > $MANUAL_CHAPTER_DIR/chapter.texi + echo "" > $MANUAL_CHAPTER_DIR/chapter-menu.texi + echo "" > $MANUAL_CHAPTER_DIR/chapter-nodes.texi + + # Initialize chapter instroduction using template file. + cp ${FUNCCONFIG}/manual-cha-intro.texi $MANUAL_CHAPTER_DIR/chapter-intro.texi + +} diff --git a/Functions/Help/help_updateChaptersMenu.sh b/Functions/Help/help_updateChaptersMenu.sh new file mode 100755 index 0000000..c32d0c7 --- /dev/null +++ b/Functions/Help/help_updateChaptersMenu.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# +# help_updateChaptersMenu.sh - This function updates chapter menu. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateChaptersMenu { + + local ACTION=$1 + local MENUCHAPTERS='' + + # Build menu of chapters. The Index node is not included as other + # nodes are. The Index node is defined insde the master texinfo + # file (repository.texi). To create the final .info file + # correctly, the Index line in the menu should remain, even no + # other node exist. + if [[ -f ${MANUAL_BASEFILE}-menu.texi ]];then + MENUCHAPTERS=$(cat ${MANUAL_BASEFILE}-menu.texi \ + | egrep -v "^(@(end )?menu$|\* Index::.*)$") + fi + + # Re-defined menu of chapters based on action. + case $ACTION in + 'remove-entry' ) + # Remove chapter from menu. + MENUCHAPTERS=$(echo "${MENUCHAPTERS}" \ + | egrep -v "^\* ${MANUAL_CHAPTER_NAME}::[[:print:]]*$") + ;; + 'update-entry' | * ) + # Update chapter menu using texinfo format. + MENUCHAPTERS="${MENUCHAPTERS} + * ${MANUAL_CHAPTER_NAME}::" + ;; + esac + + # Remove opening spaces/tabs and empty line from the menu of + # chapters. Empty lines may occur the first time the menu of + # chapters is created. + MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \ + | egrep -v '^[[:space:]]*$') + + # Organize menu of chapters alphabetically and verify that no + # duplicated line be included on the list. + MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sort | uniq ) + + # Give format to final menu output. + MENUCHAPTERS="@menu + ${MENUCHAPTERS} + * Index:: + @end menu" + + # Strip opening space/tabs from final menu of chapters. + MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \ + | egrep -v '^[[:space:]]*$') + + # Dump organized menu of chapters into file. + echo "${MENUCHAPTERS}" > ${MANUAL_BASEFILE}-menu.texi + +} diff --git a/Functions/Help/help_updateChaptersNodes.sh b/Functions/Help/help_updateChaptersNodes.sh new file mode 100755 index 0000000..b678350 --- /dev/null +++ b/Functions/Help/help_updateChaptersNodes.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# help_updateChaptersNodes.sh - This function updates nodes of +# chapters based on menu of chapters. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateChaptersNodes { + + # Build list "nodes of chapters" based on menu of chapters. + local CHAPTERNODES=$(cat ${MANUAL_BASEFILE}-menu.texi \ + | egrep -v '^@(end )?menu$' \ + | egrep -v "^\* `gettext "Index"`::[[:print:]]*$" \ + | sed -r 's!^\* !!' | sed -r 's!::[[:print:]]*$!!g' \ + | sed -r 's! !_!g' | sort | uniq ) + + # Build list of texinfo inclusions to load chapters' nodes. + local FILENODE=$(\ + for CHAPTERNODE in ${CHAPTERNODES};do + + INCL=$(echo ${CHAPTERNODE} | sed -r "s!(${CHAPTERNODE})!\1/chapter\.texi!") + + # Output inclusion line using texinfo format. + echo "@include $INCL" + + done) + + # Dump organized nodes of chapters into file. + echo "$FILENODE" > ${MANUAL_BASEFILE}-nodes.texi + +} diff --git a/Functions/Help/help_updateMenu.sh b/Functions/Help/help_updateMenu.sh new file mode 100755 index 0000000..bbfb11c --- /dev/null +++ b/Functions/Help/help_updateMenu.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# +# help_updateMenu.sh -- This function updates menu lines inside +# texinfo chapters. If this function is called with the +# 'remove-entry' string as first argument, then the menu line related +# to the entry being processed is removed. If this function is called +# with the 'update-entry' string as first argument, then the menu line +# related to the entry being processed is added to the menu. If no +# argument is passed to this function, the 'update-entry' action is +# assumed. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateMenu { + + # Specify which action to do inside chapter's menu. + local ACTION="$1" + + # Build the menu node related to the entry being processed + # currently. + local MENUNODE=$(echo "$ENTRY" | cut -d / -f8- | tr '/' ' ' \ + | sed 's!\.texi$!!') + + # Give format to menu line using texinfo style. + local MENULINE="* ${MANUAL_CHAPTER_NAME} $MENUNODE::" + + # Define chapter's menu. Remove `@menu', `@end menu', and empty lines + # from output. + local MENU=$(cat $MANUAL_CHAPTER_DIR/chapter-menu.texi \ + | egrep -v '^[[:space:]]*$' | egrep -v '^@(end )?menu') + + # Re-defined chapter's menu based on action. + case $ACTION in + 'remove-entry' ) + # Remove menu line from chapter's menu. + MENU=$(echo "$MENU" | egrep -v "$MENULINE") + ;; + 'update-entry' | * ) + # Add menu line to chapter's menu. This is the default + # behaivour if no argument is passed to help_updateMenu + # function. + MENU="$MENU + $MENULINE" + ;; + esac + + # Organize menu alphabetically, remove empty and duplicated lines. + # At this point, empty line may occur the first time the menu is + # created, don't let them to scape. + MENU=$(echo "$MENU" | egrep -v '^[[:space:]]*$' | sort | uniq ) + + # Rebuild chapter's menu structure adding '@menu' and '@end menu' + # lines back in menu. + MENU="@menu + $MENU + @end menu" + + # Remove opening spaces/tabs from final menu structure. + MENU=$(echo "$MENU" | sed -r 's!^[[:space:]]+!!g') + + # Dump final menu structure back into chapter's menu file. + echo "$MENU" > $MANUAL_CHAPTER_DIR/chapter-menu.texi + +} diff --git a/Functions/Help/help_updateNodes.sh b/Functions/Help/help_updateNodes.sh new file mode 100755 index 0000000..432b9c7 --- /dev/null +++ b/Functions/Help/help_updateNodes.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# help_updateNodes.sh -- This function updates chapter's nodes +# definition using the chapter's menu as reference. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateNodes { + + # Retrive nodes' entries from chapter-menu.texi file. + local NODES=$(cat $MANUAL_CHAPTER_DIR/chapter-menu.texi \ + | sed -r 's!^\* !!' | sed -r 's!:{1,2}.*$!!g' \ + | egrep -v '^@(end )?menu$' | sed -r 's! !:!g' | sort | uniq) + + # Re-build node structure based on menu information. + for NODE in $NODES;do + + NODE=$(echo "${NODE}" | sed -r 's!:! !g') + SECT=$(echo "$NODE" | sed -r 's! !/!g' | sed "s!${MANUAL_CHAPTER_NAME}/!!") + INCL=$(echo "$NODE" | sed -r 's! !/!g').texi + CIND=$(echo "$NODE") + + # Create an empty directory to store texinfo files. + if [[ ! -d ${MANUAL_BASEDIR}/$(dirname "$INCL") ]];then + mkdir -p ${MANUAL_BASEDIR}/$(dirname "$INCL") + fi + + # Create texinfo section file using its template. + if [[ ! -f ${MANUAL_BASEDIR}/$INCL ]];then + cp ${FUNCCONFIG}/manual-section.texi ${MANUAL_BASEDIR}/$INCL + fi + + # Output node information based on texinfo menu. + echo "@node $NODE" + echo "@section `eval_gettext "The @file{\\\$SECT} Directory"`" + echo "@cindex $CIND" + echo "@include $INCL" + echo "" + + # Dump node information into chapter node file. + done > $MANUAL_CHAPTER_DIR/chapter-nodes.texi + +} + diff --git a/Functions/Help/help_updateOutputFileHtml.sh b/Functions/Help/help_updateOutputFileHtml.sh new file mode 100755 index 0000000..1f6fed4 --- /dev/null +++ b/Functions/Help/help_updateOutputFileHtml.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# help_updateOutputFileHtml.sh -- This function exports +# documentation manual to HTML format. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateOutputFileHtml { + + # Output action message. + cli_printMessage "${MANUAL_BASEFILE}-html" 'AsUpdatingLine' + + # Check html output directory + [[ ! -d ${MANUAL_BASEFILE}-html ]] && mkdir -p ${MANUAL_BASEFILE}-html + + # Add html output directory into directory stack to make it the + # current working directory. Otherwise texi2html may produce + # incorrect paths to images included. + pushd ${MANUAL_BASEFILE}-html > /dev/null + + # Update html files. Use texi2html to export from texinfo file + # format to html using CentOS Web default visual style. + texi2html ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}-html --split section \ + --nosec-nav \ + --css-include=${HOME}/artwork/trunk/Identity/Models/Css/Texi2html/stylesheet.css \ + -I=${HOME}/artwork + + # Apply html transformations. Html transformations rely on + # Texi2html default html output. The main goal of these html + # transformations is to build specific html structures that match + # specific css definitions. This way we extend the visual style of + # Texi2html default html output. + sed -r -i \ + -f ${HOME}/artwork/trunk/Identity/Models/Css/Texi2html/transformations.sed \ + ${MANUAL_BASEFILE}-html/*.html + + # Remove html output directory from directory stack. + popd > /dev/null + +} diff --git a/Functions/Help/help_updateOutputFileInfo.sh b/Functions/Help/help_updateOutputFileInfo.sh new file mode 100755 index 0000000..27b6d58 --- /dev/null +++ b/Functions/Help/help_updateOutputFileInfo.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# help_updateOutputFileInfo.sh -- This function exports +# documentation manual to info format. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateOutputFileInfo { + + # Output action message. + cli_printMessage "${MANUAL_BASEFILE}.info.bz2" 'AsUpdatingLine' + + # Update info file. + /usr/bin/makeinfo ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}.info + + # Compress info file. + if [[ $? -eq 0 ]];then + bzip2 -f ${MANUAL_BASEFILE}.info + fi + +} diff --git a/Functions/Help/help_updateOutputFilePdf.sh b/Functions/Help/help_updateOutputFilePdf.sh new file mode 100755 index 0000000..e142936 --- /dev/null +++ b/Functions/Help/help_updateOutputFilePdf.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# help_updateOutputFilePdf.sh -- This function exports documentation +# manual to PDF format. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateOutputFilePdf { + + # Output action message. + cli_printMessage "${MANUAL_BASEFILE}.pdf" 'AsUpdatingLine' + + # Update plaintext output directory. + /usr/bin/texi2pdf --quiet \ + ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}.pdf + +} diff --git a/Functions/Help/help_updateOutputFilePlaintext.sh b/Functions/Help/help_updateOutputFilePlaintext.sh new file mode 100755 index 0000000..d1b748d --- /dev/null +++ b/Functions/Help/help_updateOutputFilePlaintext.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# help_updateOutputFilePlaintext.sh -- This function exports +# documentation manual to plain-text format. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateOutputFilePlaintext { + + # Output action message. + cli_printMessage "${MANUAL_BASEFILE}.txt.bz2" 'AsUpdatingLine' + + # Update plaintext output directory. + /usr/bin/makeinfo --plaintext \ + ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}.txt + + # Compress plaintext output file. + if [[ -f ${MANUAL_BASEFILE}.txt ]];then + bzip2 ${MANUAL_BASEFILE}.txt --force + fi + +} diff --git a/Functions/Help/help_updateOutputFileXml.sh b/Functions/Help/help_updateOutputFileXml.sh new file mode 100755 index 0000000..e045b36 --- /dev/null +++ b/Functions/Help/help_updateOutputFileXml.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# help_updateOutputFileXml.sh -- This function exports documentation +# manual to XML format. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateOutputFileXml { + + # Print action message. + cli_printMessage "${MANUAL_BASEFILE}.xml" 'AsUpdatingLine' + + # Update xml output format. + /usr/bin/makeinfo --xml \ + ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}.xml \ + +} diff --git a/Functions/Help/help_updateOutputFiles.sh b/Functions/Help/help_updateOutputFiles.sh new file mode 100755 index 0000000..e170e22 --- /dev/null +++ b/Functions/Help/help_updateOutputFiles.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# help_updateOutputFiles.sh -- This function exports documentation +# manual to different output formats. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function help_updateOutputFiles { + + # Remove extension from manual's base file. This way it is + # possible to reuse the same filename on different types of files. + MANUAL_BASEFILE=$(echo ${MANUAL_BASEFILE} | sed -r 's!\.texi!!') + + # Add the working copy root directory to directory stack to make + # path construction correctly. Otherwise, makeinfo may produce + # paths incorrectly. + pushd ${HOME}/artwork > /dev/null + + help_updateOutputFileInfo + help_updateOutputFileHtml + help_updateOutputFileXml + help_updateOutputFilePdf + help_updateOutputFilePlaintext + + # Remove the working copy root directory from directory stack. + popd > /dev/null + +} diff --git a/Functions/Html/Config/output_forHeadingsToc.awk b/Functions/Html/Config/output_forHeadingsToc.awk new file mode 100644 index 0000000..bcc0f21 --- /dev/null +++ b/Functions/Html/Config/output_forHeadingsToc.awk @@ -0,0 +1,79 @@ +#!/usr/bin/gawk +# +# output_forHadingsToc.awk -- This file provides the output format +# required by html_updateHeadings.sh function, inside centos-art.sh +# script. +# +# Copyright (C) 2009-2010 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +BEGIN {FS=":"} + +{ + if ($1 == 0 && $2 == $3) { + opentags = "
  • " + closetags = "" + } + + if ($1 > 0 && $2 > $3) { + opentags = "
    • " + closetags = "" + } + + if ($1 > 0 && $2 == $3) { + opentags = "
    • " + closetags = "" + } + + if ($1 > 0 && $2 < $3) { + opentags = "" + for (i = 1; i <= ($3 - $2); i++) { + opentags = opentags "
    " + closetags = "" + } + opentags = opentags "
  • " + } + + printf "%s%s%s\n",opentags,$4,closetags + +} + +END { + + if ($1 > 0 && $2 >= $3 && $3 > 1) { + for (i = 1; i <= $3; i++) { + print "
" + } + } + + if ($1 > 0 && $2 >= $3 && $3 == 1) { + print "" + print "" + } + + if ($1 > 0 && $2 < $3) { + for (i = 1; i <= $2; i++) { + print "" + } + } + + print "" +} diff --git a/Functions/Html/html.sh b/Functions/Html/html.sh new file mode 100755 index 0000000..8b4cf95 --- /dev/null +++ b/Functions/Html/html.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# html.sh -- This function provides very basic HTML manipulations to +# help maintain html files inside the repository. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function html { + + # Define command-line interface. + html_getActions + +} diff --git a/Functions/Html/html_getActions.sh b/Functions/Html/html_getActions.sh new file mode 100755 index 0000000..6cd746d --- /dev/null +++ b/Functions/Html/html_getActions.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# html_getActions.sh -- This function interprets arguments passed to +# `html' functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function html_getActions { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="update-headings:" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Define action to take for each option passed. + while true; do + case "$1" in + + --update-headings ) + + # Define action value passed through the command-line. + ACTIONVAL="$2" + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_updateHeadings" + + # Rotate positional parameters. + shift 2 + ;; + + * ) + break + esac + done + + # Check action value. Be sure the action value matches the + # convenctions defined for source locations inside the working + # copy. + cli_checkRepoDirSource + + # Syncronize changes between the working copy and the central + # repository to bring down changes. + cli_syncroRepoChanges + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Syncronize changes between the working copy and the central + # repository to commit up changes. + cli_commitRepoChanges + +} diff --git a/Functions/Html/html_updateHeadings.sh b/Functions/Html/html_updateHeadings.sh new file mode 100644 index 0000000..b66e363 --- /dev/null +++ b/Functions/Html/html_updateHeadings.sh @@ -0,0 +1,169 @@ +#!/bin/bash +# +# html_updateHeadings.sh -- This function transforms html headings to +# to make them accessible (e.g., through a table of contents). +# +# - In order for this function to work, you need to put headings in +# just one line and they must have the following formats: +# +#

Title

+#

Title

+#

Title

+# +# In the above examples, h1 alternates from h1 to h6. Closing tag +# must be present and match the one opentaging. The value of and options are the md5sum of page +# location, plus the 'head-' string, plus the heading string. If +# heading title or page location changes, the values of and options will change too. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function html_updateHeadings { + + # Define variables as local to avoid conflicts outside. + local COUNT=0 + local FILE='' + local FILES='' + local PREVCOUNT=0 + local PATTERN='' + local -a FINAL + local -a TITLE + local -a MD5SM + local -a OPTNS + local -a LEVEL + local -a PARENT + local -a TOCENTRIES + local -a LINK + + # Define html heading regular expression pattern. Use parenthisis + # to save html action name, action value, and heading title. + PATTERN="(]>)(.*[^<])" + + # Define list of files to process. + FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}.*\.(xhtml|html|htm)") + + # Set action preamble. + cli_printActionPreamble "${FILES}" '' '' + + # Process list of files. + for FILE in $FILES;do + + # Verify list of html files. Are files really html files? If + # they don't, continue with the next one in the list. + if [[ ! $(file --brief $FILE) =~ '^(XHTML|HTML|XML)' ]];then + continue + fi + + # Output action message. + cli_printMessage $FILE 'AsUpdatingLine' + + # Define list of headings to process. When building the + # heading, it is required to change spaces characters from its + # current decimal output to something different (e.g., its + # \040 octal alternative). This is required because the space + # character is used as egrep default field separator and + # spaces can be present inside heading strings we don't want + # to separate. + for HEADING in $(egrep "$PATTERN" $FILE \ + | sed -r -e 's!^[[:space:]]+!!' -e "s! !\\\040!g");do + + # Define previous counter value using current counter + # value as reference. + if [[ $COUNT -ne 0 ]];then + PREVCOUNT=$(($COUNT-1)) + fi + + # Define initial heading information. + FIRST[$COUNT]=$(echo $HEADING | sed -r "s!\\\040! !g") + TITLE[$COUNT]=$(echo ${FIRST[$COUNT]} | sed -r "s!$PATTERN!\3!") + MD5SM[$COUNT]=$(echo "${FILE}${FIRST[$COUNT]}" | md5sum | sed -r 's![[:space:]]+-$!!') + OPTNS[$COUNT]=$(echo ${FIRST[$COUNT]} | sed -r "s!$PATTERN!\2!") + LEVEL[$COUNT]=$(echo ${FIRST[$COUNT]} | sed -r "s!$PATTERN!\1!") + PARENT[$COUNT]=${LEVEL[$PREVCOUNT]} + + # Transform heading information using initial heading + # information as reference. + if [[ ${OPTNS[$COUNT]} =~ '^$' ]];then + OPTNS[$COUNT]='' + elif [[ ${OPTNS[$COUNT]} =~ '^$' ]];then + OPTNS[$COUNT]='' + elif [[ ${OPTNS[$COUNT]} =~ '^$' ]];then + OPTNS[$COUNT]='' + fi + + # Build final html heading structure. + FINAL[$COUNT]=''${OPTNS[$COUNT]}${TITLE[$COUNT]}'' + + # Build html heading link structure. These links are used + # by the table of contents later. + LINK[$COUNT]=''${TITLE[$COUNT]}'' + + # Build table of contents entry with numerical + # identifications. The numerical identification is what we + # use to determine the correct position of each heading + # link on the table of content. + TOCENTRIES[$COUNT]="$COUNT:${LEVEL[$COUNT]}:${PARENT[$COUNT]}:${LINK[$COUNT]}" + + # Update heading information inside the current file being + # processed. Use the first and final heading information. + sed -i -r "s!${FIRST[$COUNT]}!${FINAL[$COUNT]}!" $FILE + + # Increase heading counter. + COUNT=$(($COUNT + 1)) + + done + + # Build the table of contents using heading numerical + # identifications as reference. The numerical identification + # describes the order of headings in one html file. This + # information is processed by awk to make the appropriate + # replacements. Finnally, the result is stored in the TOC + # variable. + TOC=$(echo '
' + echo "

`gettext "Table of contents"`

" + for TOCENTRY in "${TOCENTRIES[@]}";do + echo $TOCENTRY + done \ + | awk -f ${CLI_BASEDIR}/Functions/Html/Config/output_forHeadingsToc.awk) + + # Update table of contents inside the current file being + # processed. + sed -i -r '/
(.*)<\/div>/c'"$(echo -e $TOC)" $FILE + + # Reset counters. + COUNT=0 + PREVCOUNT=0 + + # Clean up variables to receive the next file. + unset FINAL + unset TITLE + unset MD5SM + unset OPTNS + unset LEVEL + unset PARENT + unset TOCENTRIES + unset LINK + + done + +} diff --git a/Functions/Locale/locale.sh b/Functions/Locale/locale.sh new file mode 100644 index 0000000..2f320f3 --- /dev/null +++ b/Functions/Locale/locale.sh @@ -0,0 +1,105 @@ +#!/bin/bash +# +# locale.sh -- This function provides internationalization features +# for centos-art.sh script through gettext standard processes. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale { + + local ACTIONNAM='' + local ACTIONVAL='' + + # Initialize default value to create/update machine object flag. + # The machine object flag (--dont-create-mo) controls whether + # centos-art.sh script does create/update the machine object + # related object or not. + local FLAG_DONT_CREATE_MO='false' + + # Interpret arguments and options passed through command-line. + locale_getArguments + + # Redefine positional parameters using ARGUMENTS. At this point, + # option arguments have been removed from ARGUMENTS variable and + # only non-option arguments remain in it. + eval set -- "$ARGUMENTS" + + # Define action name. It does matter what option be passed to + # centos-art, there are many different actions to perform based on + # the option passed (e.g., `--edit', `--read', `--search', etc.). + # In that sake, we defined action name inside document_getArguments, + # at the moment of interpreting options. + + # Define action value. As convenction, we use non-option arguments + # to define the action value (ACTIONVAL) variable. + for ACTIONVAL in "$@";do + + if [[ $ACTIONVAL == '--' ]];then + continue + fi + + # Check action value. Be sure the action value matches the + # convenctions defined for source locations inside the working + # copy. + cli_checkRepoDirSource + + # Define locales base directory where locale directory structures + # are stored in. + local BASEDIR="$(cli_getRepoTLDir)/Locales" + + # Define locales work directory. This is the place where + # locale files (e.g., .po, .pot, .mo), for a specific parent + # directories, are stored in. There is one locale work + # directory for each parent directory or said differently, + # each parent directory has a parallel directory under + # `trunk/Locales' to store its translation messages. + local WORKDIR=$(echo ${ACTIONVAL} \ + | sed -r -e 's!trunk/(Identity|Manuals|Scripts)!trunk/Locales/\1!') + + # Create work directory, if it doesn't exist. + if [[ ! -d $WORKDIR ]];then + mkdir -p $WORKDIR + fi + + # Syncronize changes between repository and working copy. At + # this point, changes in the repository are merged in the + # working copy and changes in the working copy committed up to + # repository. + cli_syncroRepoChanges "${WORKDIR}" + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Commit changes from working copy to central repository only. + # At this point, changes in the repository are not merged in + # the working copy, but chages in the working copy do are + # committed up to repository. + cli_commitRepoChanges "${WORKDIR}" + + done + +} diff --git a/Functions/Locale/locale_editMessages.sh b/Functions/Locale/locale_editMessages.sh new file mode 100755 index 0000000..5b95ee8 --- /dev/null +++ b/Functions/Locale/locale_editMessages.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# locale_editMessages.sh -- This function edits portable objects (.po) +# using default text editor. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_editMessages { + + local FILES='' + + # Define list of files to process. + if [[ ${WORKDIR} =~ 'trunk/Locales/Scripts' ]];then + FILES=$(cli_getFilesList "${WORKDIR}" ".*$(cli_getCurrentLocale)/${TEXTDOMAIN}\.po") + elif [[ ${WORKDIR} =~ 'trunk/Locales/.+' ]];then + FILES=$(cli_getFilesList "${WORKDIR}" ".*$(cli_getCurrentLocale)\.po") + else + cli_printMessage "`gettext "The path provided doesn't support localization."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Set action preamble. + cli_printActionPreamble "${FILES}" "doEdit" 'AsResponseLine' + + # Use default text editor to edit files. + eval ${EDITOR} ${FILES} + + # Update machine object (.mo) from portable object (.po). + locale_updateMessageBinary ${FILES} + +} diff --git a/Functions/Locale/locale_getArguments.sh b/Functions/Locale/locale_getArguments.sh new file mode 100644 index 0000000..332d5ec --- /dev/null +++ b/Functions/Locale/locale_getArguments.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# locale_getArguments.sh -- This function interprets arguments passed to +# `locale' functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_getArguments { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="filter:,quiet,answer:,dont-commit-changes,update,edit,dont-create-mo" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + case "$1" in + + --filter ) + FLAG_FILTER="$2" + shift 2 + ;; + + --quiet ) + FLAG_QUIET="true" + FLAG_DONT_COMMIT_CHANGES="true" + shift 1 + ;; + + --answer ) + FLAG_ANSWER="$2" + shift 2 + ;; + + --dont-commit-changes ) + FLAG_DONT_COMMIT_CHANGES="true" + shift 1 + ;; + + --update ) + ACTIONNAM="${FUNCNAM}_updateMessages" + shift 1 + ;; + + --edit ) + ACTIONNAM="${FUNCNAM}_editMessages" + shift 1 + ;; + + --dont-create-mo ) + FLAG_DONT_CREATE_MO="true" + shift 1 + ;; + + * ) + break + ;; + esac + done + + # Redefine ARGUMENTS variable using current positional parameters. + cli_doParseArgumentsReDef "$@" + +} diff --git a/Functions/Locale/locale_updateMessageBinary.sh b/Functions/Locale/locale_updateMessageBinary.sh new file mode 100755 index 0000000..a4907e2 --- /dev/null +++ b/Functions/Locale/locale_updateMessageBinary.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# locale_updateMessageBinary.sh -- This function creates/updates +# machine objects (.mo) from portable objects (.po). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_updateMessageBinary { + + # Verify machine object creation flag. + if [[ ${FLAG_DONT_CREATE_MO} == 'true' ]];then + return + fi + + local PO='' + local MO='' + local FILE='' + local FILES="$1" + + for FILE in $FILES;do + + # Verify existence of portable object. + cli_checkFiles "${FILE}" 'f' + + # Define absolute path to portable object. + PO=$FILE + + # Define absolute path to machine object. + MO=$(dirname ${PO})/LC_MESSAGES/$(basename ${PO} | sed -r 's!\.po$!.mo!') + + # Print action message. + if [[ -f ${MO} ]];then + cli_printMessage "${MO}" 'AsUpdatingLine' + else + cli_printMessage "${MO}" 'AsCreatingLine' + fi + + # Define directory used to store machine object. + MODIR=$(dirname ${MO}) + + # Create directory to store machine object, if it doesn't + # exist. + if [[ ! -d ${MODIR} ]];then + mkdir -p ${MODIR} + fi + + # Create machine object from portable object. + msgfmt --check ${PO} --output-file=${MO} + + done + +} diff --git a/Functions/Locale/locale_updateMessageMetadata.sh b/Functions/Locale/locale_updateMessageMetadata.sh new file mode 100755 index 0000000..edf3c85 --- /dev/null +++ b/Functions/Locale/locale_updateMessageMetadata.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# locale_updateMessageMetadata.sh -- This function sanitates .pot and +# .po files to use common translation markers inside top comment. +# Later, replacement of common translation markers is applied to set +# the final information. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id4 +# ---------------------------------------------------------------------- + +function locale_updateMessageMetadata { + + local COUNT=0 + local -a SRC + local -a DST + + # Retrive absolute path of portable object we'll work with. + local FILE="$1" + + # Define current locale. + local CURRENTLOCALE=$(cli_getCurrentLocale) + + # Define language name from current locale. + local LANGNAME=$(cli_getLangName ${CURRENTLOCALE}) + + # Check existence of file before work with it. + cli_checkFiles "${FILE}" 'f' + + # Define pattern lines. The pattern lines are put inside portable + # objects through xgettext and xml2po commands . + SRC[0]='Project-Id-Version:' + SRC[1]='Report-Msgid-Bugs-To:' + SRC[2]='Last-Translator:' + SRC[3]='Language-Team:' + + # Define replacement lines for pattern line. + DST[0]="\"Project-Id-Version: ${CLI_PROGRAM} (${CURRENTLOCALE})\\\n\"" + DST[1]="\"Report-Msgid-Bugs-To: =MAIL_DOCS=\\\n\"" + DST[2]="\"Last-Translator: CentOS Documentation SIG\\\n\"" + DST[3]="\"Language-Team: ${LANGNAME}\\\n\"" + + # Change pattern lines with their replacement lines. + while [[ $COUNT -lt ${#SRC[*]} ]];do + sed -i -r "/${SRC[$COUNT]}/c${DST[$COUNT]}" ${FILE} + COUNT=$(($COUNT + 1)) + done + + # Replace package information using gettext domain information. + sed -i -r "s/PACKAGE/${TEXTDOMAIN}/g" ${FILE} + + # Unset array variables to avoid undesired concatenations. + unset SRC + unset DST + +} diff --git a/Functions/Locale/locale_updateMessagePObjects.sh b/Functions/Locale/locale_updateMessagePObjects.sh new file mode 100755 index 0000000..830d88b --- /dev/null +++ b/Functions/Locale/locale_updateMessagePObjects.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# locale_updateMessagePObjects.sh --- This function verifies, +# initializes or updates portable objects from portable object +# templates. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_updateMessagePObjects { + + local FILE="$1" + + # Verify the portable object template. The portable object + # template is used to create the portable object. + cli_checkFiles "${FILE}.pot" 'f' + + # Verify existence of portable object. The portable object is the + # file translators edit in order to make translation works. + if [[ -f ${FILE}.po ]];then + + # Print action message. + cli_printMessage "${FILE}.po" 'AsUpdatingLine' + + # Update portable object merging both portable object and + # portable object template. + msgmerge --output="${FILE}.po" "${FILE}.po" "${FILE}.pot" --quiet + + else + + # Print action message. + cli_printMessage "${FILE}.po" 'AsCreatingLine' + + # Initiate portable object using portable object template. + # Do not print msginit sterr output, use centos-art action + # message instead. + msginit -i ${FILE}.pot -o ${FILE}.po --width=70 \ + --no-translator 2> /dev/null + + # Sanitate portable object metadata. This is the first time + # the portable object is created so some modifications are + # needed to customized metadata. + locale_updateMessageMetadata "${FILE}.po" + + fi + +} diff --git a/Functions/Locale/locale_updateMessageShell.sh b/Functions/Locale/locale_updateMessageShell.sh new file mode 100755 index 0000000..65154e9 --- /dev/null +++ b/Functions/Locale/locale_updateMessageShell.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# locale_updateMessageShell.sh -- This function parses shell scripts +# under action value, retrives translatable strings and +# creates/updates both portable object templates (.pot) and portable +# objects (.po). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_updateMessageShell { + + local FILE='' + local FILES='' + + # Define file name used as reference to create portable object + # templates (.pot), portable objects (.po) and machine objects + # (.mo). + FILE="${WORKDIR}/$(cli_getCurrentLocale)/${TEXTDOMAIN}" + + # Build list of files to process. + if [[ $ACTIONVAL =~ "^${CLI_BASEDIR}" ]];then + FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}\.sh") + else + cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Set action preamble. + cli_printActionPreamble "${FILES}" "doLocale" 'AsResponseLine' + + # Print action message. + cli_printMessage "${FILE}.pot" 'AsUpdatingLine' + + # Prepare directory structure to receive .po files. + if [[ ! -d $(dirname ${FILE}) ]];then + mkdir -p $(dirname ${FILE}) + fi + + # Retrive translatable strings from shell script files and create + # the portable object template (.pot) from them. + /usr/bin/xgettext --output=${FILE}.pot \ + --copyright-holder="CentOS Documentation SIG" \ + --width=70 --sort-by-file ${FILES} + + # Verify, initialize or update portable objects from portable + # object templates. + locale_updateMessagePObjects "${FILE}" + +} diff --git a/Functions/Locale/locale_updateMessageXml.sh b/Functions/Locale/locale_updateMessageXml.sh new file mode 100755 index 0000000..f0c6244 --- /dev/null +++ b/Functions/Locale/locale_updateMessageXml.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# locale_updateMessageXml.sh -- This function parses XML-based files +# (e.g., scalable vector graphics), retrives translatable strings and +# creates/update gettext portable objects. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_updateMessageXml { + + local FILE='' + local FILES='' + + # Define filename used to create both portable object templates + # (.pot) and portable objects (.po) files. + FILE="${WORKDIR}/$(cli_getCurrentLocale)" + + # Build list of files to process. + if [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Identity/.+" ]];then + FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}\.(svg|docbook)") + else + cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Set action preamble. + cli_printActionPreamble "${FILES}" "doLocale" 'AsResponseLine' + + # Print action message. + cli_printMessage "${FILE}.pot" 'AsUpdatingLine' + + # Prepare directory structure to receive .po files. + if [[ ! -d $(dirname ${FILE}) ]];then + mkdir -p $(dirname ${FILE}) + fi + + # Retrive translatable strings from XML-based files and + # create the portable object template (.pot) from them. + /usr/bin/xml2po ${FILES} | msgcat --output=${FILE}.pot --width=70 --sort-by-file - + + # Verify, initialize or merge portable objects from portable + # object templates. + locale_updateMessagePObjects "${FILE}" + +} diff --git a/Functions/Locale/locale_updateMessages.sh b/Functions/Locale/locale_updateMessages.sh new file mode 100755 index 0000000..d6d9a5e --- /dev/null +++ b/Functions/Locale/locale_updateMessages.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# locale_updateMessages.sh -- This function extracts translatable +# strings from both XML-based files (using xml2po) and shell scripts +# (using xgettext). Translatable strings are initially stored in +# portable objects templates (.pot) which are later merged into +# portable objects (.po) in order to be optionally converted as +# machine objects (.mo). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_updateMessages { + + local ACTIONNAM='' + + # Evaluate working directory to determine whether to use xml2po to + # extract translatable strings from XML-based files or to use + # xgettext to extract translatable strings from shell script + # files. + if [[ $WORKDIR =~ "^${BASEDIR}/(Identity|Manuals)/.+$" ]];then + + # Update translatable strings inside portable object templates + # for XML-based files (e.g., scalable vector graphics). + ACTIONNAM="${FUNCNAM}_updateMessageXml" + + elif [[ $WORKDIR =~ "^${BASEDIR}/Scripts/.+$" ]];then + + # Update translatable strings inside portable object templates + # for shell scripts (e.g., centos-art.sh script). + ACTIONNAM="${FUNCNAM}_updateMessageShell" + + else + cli_printMessage "`gettext "The path provided doesn't support localization."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Functions/Path/path.sh b/Functions/Path/path.sh new file mode 100755 index 0000000..4f3fe10 --- /dev/null +++ b/Functions/Path/path.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# path.sh -- This function provides file manipulations to aliviate +# path maintainance inside the repository. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function path { + + # Define deafult value to target flag. The target flag (--to) + # controls final destination used by copy related actions. + local FLAG_TO='' + + # Define default value to syncronization flag. The syncronization + # flag (--sync) controls whether centos-art.sh script calls itself + # to create/delete parallel directories at the moment of + # create/delte action itself. + local FLAG_SYNC='false' + + # Define command-line interface. + path_getActions + +} diff --git a/Functions/Path/path_doCopy.sh b/Functions/Path/path_doCopy.sh new file mode 100755 index 0000000..b49cb66 --- /dev/null +++ b/Functions/Path/path_doCopy.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# path_doCopy.sh -- This function duplicates files inside the working +# copy using subversion commands. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function path_doCopy { + + # Verify target directory. + cli_checkRepoDirTarget + + # Print action preamble. + cli_printActionPreamble "${FLAG_TO}" 'doCreate' 'AsResponseLine' + + # Verify relation between source and target locations. We cannot + # duplicate an entry if its parent directory doesn't exist as + # entry inside the working copy. + if [[ -f ${ACTIONVAL} ]];then + if [[ ! -d $(dirname "${FLAG_TO}") ]];then + mkdir -p $(dirname "${FLAG_TO}") + fi + svn add $(dirname "${FLAG_TO}") --quiet + fi + + # Print action message. + cli_printMessage "${FLAG_TO}" 'AsCreatingLine' + + # Copy parent directory. + svn copy ${ACTIONVAL} ${FLAG_TO} --quiet + + # Verify syncronization flag. + if [[ $FLAG_SYNC == 'true' ]];then + + # Copy parallel directories. + . /home/centos/bin/centos-art manual --copy="$ACTIONVAL" --to="$FLAG_TO" + . /home/centos/bin/centos-art render --copy="$ACTIONVAL" --to="$FLAG_TO" + . /home/centos/bin/centos-art locale --copy="$ACTIONVAL" --to="$FLAG_TO" + + fi + +} diff --git a/Functions/Path/path_doDelete.sh b/Functions/Path/path_doDelete.sh new file mode 100755 index 0000000..fad8ce4 --- /dev/null +++ b/Functions/Path/path_doDelete.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# path_doDelete.sh -- This function deletes files inside the working +# copy using subversion commands. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function path_doDelete { + + # Verify target directory. + cli_checkRepoDirTarget + + # Print action preamble. + cli_printActionPreamble "$ACTIONVAL" 'doDelete' 'AsResponseLine' + + # Syncronize parallel directories related to action value. + . /home/centos/bin/centos-art manual --delete="$ACTIONVAL" + . /home/centos/bin/centos-art render --delete="$ACTIONVAL" + . /home/centos/bin/centos-art locale --delete="$ACTIONVAL" + + # Print action message. + cli_printMessage "${ACTIONVAL}" 'AsDeletingLine' + + # Perform action. + svn del ${ACTIONVAL} --quiet + +} diff --git a/Functions/Path/path_getActions.sh b/Functions/Path/path_getActions.sh new file mode 100755 index 0000000..c63f2e2 --- /dev/null +++ b/Functions/Path/path_getActions.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# +# path_getActions.sh -- This function interpretes arguments passed to +# `path' functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function path_getActions { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="copy:,move:,delete:,to:,sync" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Define action to take for each option passed. + while true; do + case "$1" in + + --copy ) + + # Define action value passed through the command-line. + ACTIONVAL="$2" + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_doCopy" + + # Rotate positional parameters. + shift 2 + ;; + + --delete ) + + # Define action value passed through the command-line. + ACTIONVAL="$2" + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_doDelete" + + # Rotate positional parameters. + shift 2 + ;; + + --to ) + + # Redefine target flag. + FLAG_TO="$2" + + # Verify target directory. + cli_checkRepoDirTarget + + # Rotate positional parameters. + shift 2 + ;; + + --sync ) + + # Redefine syncronization flag. + FLAG_SYNC='true' + + # Rotate positional parameters. + shift 1 + ;; + + * ) + # Break options loop. + break + esac + done + + # Check action value (ACTIONVAL) passed through the command-line + # using source directory definition as reference. + cli_checkRepoDirSource + + # Syncronize changes between the working copy and the central + # repository to bring down changes. + cli_syncroRepoChanges "${ACTIOVAL} ${FLAG_TO}" + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Syncronize changes between the working copy and the central + # repository to commit up changes. + cli_commitRepoChanges "${ACTIOVAL} ${FLAG_TO}" + +} diff --git a/Functions/Prepare/prepare.sh b/Functions/Prepare/prepare.sh new file mode 100755 index 0000000..0618ea1 --- /dev/null +++ b/Functions/Prepare/prepare.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# prepare.sh -- This function prepares your workstation for using the +# centos-art command-line. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare { + + # Define packages flag. The package flag (--packages) controls + # whether package verification is performed or not. By default no + # package verification is done. + local FLAG_PACKAGES='false' + + # Define links flag. The link flag (--links) controls whether + # links verifications are performed or not. By default no link + # verification is done. + local FLAG_LINKS='false' + + # Define environment flag. The environment flag (--environment) + # controles whether verification of environment variables are + # performed or not. By default no verification of environment + # variables is done. + local FLAG_ENVIRONMENT='false' + + # Interpret arguments and options passed through command-line. + prepare_getArguments + + # Redefine positional parameters using ARGUMENTS. At this point, + # option arguments have been removed from ARGUMENTS variable and + # only non-option arguments remain in it. + eval set -- "$ARGUMENTS" + + # Define action name. It does matter what option be passed to + # centos-art, there are many different actions to perform based on + # the option passed (e.g., `--packages', `--links', + # `--environment', etc.). In that sake, we defined action name + # inside prepare_getArguments, at the moment of interpreting + # options. + + # Define action value. There is no action value in this function, + # but action name values only. There is no need for non-option + # arguments here since we are doing fixed verifications only in + # predifined paths. + + # Verify flags and execute actions accordingly. Start with + # packages, links and then environment. + prepare_doPackages + prepare_doLinks + prepare_doEnvironment + +} diff --git a/Functions/Prepare/prepare_doEnvironment.sh b/Functions/Prepare/prepare_doEnvironment.sh new file mode 100755 index 0000000..222b4fb --- /dev/null +++ b/Functions/Prepare/prepare_doEnvironment.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# prepare_doEnvironment.sh -- This function outputs a brief description +# of environment variables used by `centos-art.sh' script. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_doEnvironment { + + # Verify `--packages' option. + if [[ $FLAG_ENVIRONMENT == 'false' ]];then + return + fi + + # Print line separator. + cli_printMessage '-' 'AsSeparatorLine' + + # Print action message. + cli_printMessage "`gettext "Checking environment variables"`" 'AsResponseLine' + + # Print line separator. + cli_printMessage '-' 'AsSeparatorLine' + + local -a VARS + local -a INFO + local COUNT=0 + + # Define name of environment variables used by centos-art.sh + # script. + VARS[0]='EDITOR' + VARS[1]='TZ' + VARS[2]='TEXTDOMAIN' + VARS[3]='TEXTDOMAINDIR' + VARS[4]='LANG' + + # Define description of environment variables. + INFO[0]="`gettext "Default text editor"`" + INFO[1]="`gettext "Default time zone representation"`" + INFO[2]="`gettext "Default domain used to retrieve translated messages"`" + INFO[3]="`gettext "Default directory used to retrive translated messages"`" + INFO[4]="`gettext "Default locale information"`" + + until [[ $COUNT -eq ${#VARS[*]} ]];do + + # Let user to reduce output using regular expression as + # reference. + if [[ ${VARS[$COUNT]} =~ $FLAG_FILTER ]];then + + # Output list of environment variables using indirect + # expansion (what a beautiful feature!) to output variable + # value. + cli_printMessage "${INFO[$COUNT]}:" + cli_printMessage "${VARS[$COUNT]}=${!VARS[$COUNT]}" 'AsResponseLine' + + fi + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Functions/Prepare/prepare_doLinks.sh b/Functions/Prepare/prepare_doLinks.sh new file mode 100755 index 0000000..67ff049 --- /dev/null +++ b/Functions/Prepare/prepare_doLinks.sh @@ -0,0 +1,153 @@ +#!/bin/bash +# +# prepare_doLinks.sh -- This function installs the symbolic links your +# workstation needs to have in order for centos-art command to run +# correctly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_doLinks { + + # Verify `--links' option. + if [[ $FLAG_LINKS == 'false' ]];then + return + fi + + # Print line separator. + cli_printMessage '-' 'AsSeparatorLine' + + # Print action message. + cli_printMessage "`gettext "Checking symbolic links"`" 'AsResponseLine' + + # Print line separator. + cli_printMessage '-' 'AsSeparatorLine' + + local -a LINKS_SRC + local -a LINKS_DST + local USERFILES='' + local PALETTE='' + local BRUSH='' + local PATTERN='' + local FONT='' + local FILE='' + local COUNT=0 + + # Initialize file prefix. Since we are taking the same file names + # from different theme directory and putting them into the same + # directory structure it is required to identify them some way in + # that common directory structure. For this we use the theme path + # identifier. + local PREFIX='' + + # Define user-specific directory for Gimp. + local GIMP_USER_DIR=${HOME}/.$(rpm -q gimp | cut -d. -f-2) + + # Define user-specific directory for Inkscape. + local INKS_USER_DIR=${HOME}/.inkscape + + # Define both source and target location for centos-art command. + LINKS_SRC[0]=${HOME}/bin/$CLI_PROGRAM + LINKS_DST[0]=${CLI_BASEDIR}/init.sh + + # Define both source and target location for fonts. + local FONTS=$(cli_getFilesList "${HOME}/artwork/trunk/Identity/Fonts" 'denmark\.ttf') + for FONT in $FONTS;do + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.fonts/$(basename $FONT) + LINKS_DST[((++${#LINKS_DST[*]}))]=$FONT + done + + # Define both source and target location for Gimp and Inkscape + # palettes. + local PALETTES=$(cli_getFilesList "$HOME/artwork/trunk/Identity/Themes/Motifs/*/*/Palettes + ${HOME}/artwork/trunk/Identity/Palettes" ".+\.gpl") + for PALETTE in $PALETTES;do + if [[ $PALETTE =~ $(cli_getPathComponent '--theme-pattern') ]];then + PREFIX="$(cli_getPathComponent "$PALETTE" '--theme-name')-$(cli_getPathComponent "$PALETTE" '--theme-release')-" + fi + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_USER_DIR}/palettes/${PREFIX}$(basename $PALETTE) + LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_USER_DIR}/palettes/${PREFIX}$(basename $PALETTE) + LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE + done + + # Define both source and target location for Gimp brushes. + local BRUSHES=$(cli_getFilesList \ + "${HOME}/artwork/trunk/Identity/Themes/Motifs/*/*/Brushes" \ + ".+\.(gbr|gih)") + for BRUSH in $BRUSHES;do + PREFIX="$(cli_getPathComponent "$BRUSH" '--theme-name')-$(cli_getPathComponent "$BRUSH" '--theme-release')" + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_USER_DIR}/brushes/${PREFIX}-$(basename $BRUSH) + LINKS_DST[((++${#LINKS_DST[*]}))]=$BRUSH + done + + # Define both source and target location for Gimp patterns. + local PATTERNS=$(cli_getFilesList \ + "${HOME}/artwork/trunk/Identity/Themes/Motifs/*/*/Patterns" \ + ".+\.png") + for PATTERN in $PATTERNS;do + PREFIX="$(cli_getPathComponent "$PATTERN" '--theme-name')-$(cli_getPathComponent "$PATTERN" '--theme-release')" + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_USER_DIR}/patterns/${PREFIX}-$(basename $PATTERN) + LINKS_DST[((++${#LINKS_DST[*]}))]=$PATTERN + done + + # Define files inside user-specific directories that need to be + # removed in order to make a fresh installation of patterns, + # palettes and brushes using symbolic links from the repository. + USERFILES=$(cli_getFilesList "${HOME}/.fonts" '.+\.ttf'; + cli_getFilesList "${HOME}/bin" '.+\.sh'; + cli_getFilesList "${GIMP_USER_DIR}/palettes" '.+\.gpl'; + cli_getFilesList "${GIMP_USER_DIR}/brushes" '.+\.(gbr|gih)'; + cli_getFilesList "${GIMP_USER_DIR}/patterns" '.+\.png'; + cli_getFilesList "${INKS_USER_DIR}/palettes" '.+\.gpl') + + # Remove installed files inside user-specific directories. + if [[ "$USERFILES" != '' ]];then + cli_printActionPreamble "${USERFILES[*]}" 'doDelete' 'AsResponseLine' + for FILE in ${USERFILES[@]};do + cli_printMessage "${FILE}" 'AsDeletingLine' + rm -r $FILE + done + fi + + # Create symbolic links. In case the the symbolic link parent + # directory isn't created, it will be created in order to make + # the link creation possible. + cli_printActionPreamble "${LINKS_SRC[*]}" 'doCreate' 'AsResponseLine' + while [[ $COUNT -lt ${#LINKS_SRC[*]} ]];do + + if [[ -f ${LINKS_SRC[$COUNT]} ]];then + cli_printMessage "${LINKS_SRC[$COUNT]}" 'AsUpdatingLine' + else + cli_printMessage "${LINKS_SRC[$COUNT]}" 'AsCreatingLine' + fi + + if [[ ! -d $(dirname ${LINKS_SRC[$COUNT]}) ]];then + mkdir -p $(dirname ${LINKS_SRC[$COUNT]}) + fi + + ln ${LINKS_DST[$COUNT]} ${LINKS_SRC[$COUNT]} --symbolic --force + + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Functions/Prepare/prepare_doPackages.sh b/Functions/Prepare/prepare_doPackages.sh new file mode 100644 index 0000000..c119cc0 --- /dev/null +++ b/Functions/Prepare/prepare_doPackages.sh @@ -0,0 +1,108 @@ +#!/bin/bash +# +# prepare_doPackages.sh -- This function verifies the required +# packages your workstation needs to have installed in order for +# centos-art command to run correctly. If there is one or more missing +# packages, the `centos-art.sh' script asks you to confirm their +# installation through yum. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_doPackages { + + # Verify `--packages' option. + if [[ $FLAG_PACKAGES == 'false' ]];then + return + fi + + # Print line separator. + cli_printMessage '-' 'AsSeparatorLine' + + # Print action message. + cli_printMessage "`gettext "Checking required packages"`" 'AsResponseLine' + + # Print line separator. + cli_printMessage '-' 'AsSeparatorLine' + + local PACKAGE='' + local WARNING='' + local PACKAGES='' + local PACKAGES_THIRDS='' + local -a PACKAGES_MISSING + local RPM='/bin/rpm' + local YUM='/usr/bin/yum' + + # Check execution rights of package managers. + cli_checkFiles $RPM 'x' + cli_checkFiles $YUM 'x' + + # Define required packages needed by centos-art.sh script. + PACKAGES="inkscape ImageMagick netpbm netpbm-progs syslinux gimp + coreutils texinfo info tetex-latex tetex-fonts tetex-xdvi + tetex-dvips gettext texi2html gnome-doc-utils elinks + docbook-style-xsl docbook-utils docbook-dtds + docbook-style-dsssl docbook-simple docbook-utils-pdf + docbook-slides firefox sudo yum rpm" + + # Define packages from third party repositories (i.e., packages + # not included in CentOS [base] repository.) required by + # centos-art to work as expected. + PACKAGES_THIRDS="(inkscape|blender)" + + # Build list of missing packages. + for PACKAGE in $PACKAGES;do + $RPM -q --queryformat "%{NAME}\n" $PACKAGE --quiet + if [[ $? -ne 0 ]];then + PACKAGES_MISSING[((++${#PACKAGES_MISSING[*]}))]=$PACKAGE + fi + done + + # Is there any package missing? + if [[ ${#PACKAGES_MISSING[*]} -eq 0 ]];then + cli_printMessage "`gettext "The required packages has been already installed."`" + return + fi + + # At this point there is one or more missing packages that need to + # be installed in the workstation. Report this issue and specify + # which these packages are. + cli_printMessage "`ngettext "The following package needs to be installed" \ + "The following packages need to be installed" \ + "${#PACKAGES_MISSING[*]}"`:" + + # Build report of missing packages and remark those comming from + # third party repository. + for PACKAGE in ${PACKAGES_MISSING[@]};do + if [[ $PACKAGE =~ $PACKAGES_THIRDS ]];then + WARNING=" (`gettext "requires third party repository!"`)" + fi + cli_printMessage "${PACKAGE}${WARNING}" 'AsResponseLine' + done + + # Print confirmation request. + cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' + + # Use sudo to install the missing packages in your system through + # yum. + sudo ${YUM} install ${PACKAGES_MISSING[*]} + +} diff --git a/Functions/Prepare/prepare_getArguments.sh b/Functions/Prepare/prepare_getArguments.sh new file mode 100755 index 0000000..2644b0a --- /dev/null +++ b/Functions/Prepare/prepare_getArguments.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# +# prepare_getArguments.sh -- This function interpretes arguments passed +# to `prepare' functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_getArguments { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="quiet,answer:,packages,links,environment" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + case "$1" in + + --quiet ) + FLAG_QUIET="true" + FLAG_DONT_COMMIT_CHANGES="true" + shift 1 + ;; + + --answer ) + FLAG_ANSWER="$2" + shift 2 + ;; + + --packages ) + FLAG_PACKAGES="true" + shift 1 + ;; + + --links ) + FLAG_LINKS="true" + shift 1 + ;; + + --environment ) + FLAG_ENVIRONMENT="true" + shift 1 + ;; + + * ) + break + esac + done + +} diff --git a/Functions/Render/render.sh b/Functions/Render/render.sh new file mode 100644 index 0000000..959b549 --- /dev/null +++ b/Functions/Render/render.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# +# render.sh -- This function initializes rendition variables and +# actions to centos-art.sh script. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render { + + local ACTIONNAM='' + local ACTIONVAL='' + + # Initialize `--releasever' option. The release version option + # controls the release number used to produce release-specific + # content. By default no release number is used. + local FLAG_RELEASEVER='' + + # Initialize `--basearch' option. The base architecture option + # controls the architecture type used to produce + # architecture-specific content. By default no architecture type + # is used. + local FLAG_BASEARCH='' + + # Initialize `--theme-model' option. The theme model option + # specifies the the theme model name used to produce theme + # artistic motifs. + local FLAG_THEME_MODEL='Default' + + # Initialize `--convert' option. The convert option controls + # whether convert or not content produced by centos-art + # base-rendition. By default there is no content convertion. + local FLAG_CONVERT='' + + # Initialize `--rotate' option. The rotate option controls whether + # rotate or not image content produced by centos-art + # base-rendition. By default there is no content rotation. + local FLAG_ROTATE='' + + # Initialize `--resize' option. The resize option controls whether + # resize or not content produced by centos-art base-rendition. By + # default there is no content resizing. + local FLAG_RESIZE='' + + # Initialize `--group-by' option. The grouped-by option specifies + # whether grouping or not content produced by centos-art + # base-rendition. By default there is no content grouping. + local FLAG_GROUPED_BY='' + + # Interpret arguments and options passed through command-line. + render_getArguments + + # Redefine positional parameters using ARGUMENTS. At this point, + # option arguments have been removed from ARGUMENTS variable and + # only non-option arguments remain in it. + eval set -- "$ARGUMENTS" + + # Define action name. No matter what option be passed to + # centos-art, there is only one action to perform (i.e., the + # base-rendition flow). + ACTIONNAM="${FUNCNAME}_doBaseActions" + + # Define action value. We use non-option arguments to define the + # action value (ACTIONVAL) variable. + for ACTIONVAL in "$@";do + + if [[ $ACTIONVAL == '--' ]];then + continue + fi + + # Check action value. Be sure the action value matches the + # convenctions defined for source locations inside the working + # copy. + cli_checkRepoDirSource + + # Syncronize changes between repository and working copy. At + # this point, changes in the repository are merged in the + # working copy and changes in the working copy committed up to + # repository. + cli_syncroRepoChanges + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Commit changes from working copy to central repository only. + # At this point, changes in the repository are not merged in + # the working copy, but chages in the working copy do are + # committed up to repository. + cli_commitRepoChanges + + done + +} diff --git a/Functions/Render/render_checkSvgAbsref.sh b/Functions/Render/render_checkSvgAbsref.sh new file mode 100755 index 0000000..89b1b2a --- /dev/null +++ b/Functions/Render/render_checkSvgAbsref.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# render_checkSvgAbsref.sh -- This function retrives absolute files +# and checks their existence. In order for design templates to point +# different artistic motifs, design templates make use of external +# files that point to specific artistic motif background images. If +# such external files doesn't exist, print a message and stop script +# execution. We cannot continue without background information. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_checkSvgAbsref { + + local FILE='' + local ABSPATHS='' + local ABSPATH='' + + # Define absolute path of file we need to retrive absolute paths + # from. + FILE="$1" + + # Verify existence of file we need to retrive absolute paths from. + cli_checkFiles $FILE 'f' + + # Retrive absolute paths from file. + ABSPATHS=$(egrep "(sodipodi:absref|xlink:href)=\"${HOME}.+" $FILE \ + | sed -r "s,.+=\"(${HOME}.+)\".*,\1,") + + # Verify absolute paths retrived from file. + for ABSPATH in $ABSPATHS;do + cli_checkFiles "$ABSPATH" 'f' + done + +} diff --git a/Functions/Render/render_convertDocbookToXhtml.sh b/Functions/Render/render_convertDocbookToXhtml.sh new file mode 100755 index 0000000..e5f818a --- /dev/null +++ b/Functions/Render/render_convertDocbookToXhtml.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# render_convertDocbookToXhtml.sh -- This function produces XHTML +# output from docbook template instance using XSL stylesheets as +# reference. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_convertDocbookToXhtml { + + # Print action message. + if [[ -f ${FILE}.xhtml ]];then + cli_printMessage "${FILE}.xhtml" 'AsUpdatingLine' + else + cli_printMessage "${FILE}.xhtml" 'AsCreatingLine' + fi + + # Define list of XSL stylesheets. + local XSL='/usr/share/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl' + + # Produce xhtml output from docbook template instance using XSL + # stylesheets as reference. + xsltproc ${XSL} $INSTANCE > ${FILE}.xhtml + +} diff --git a/Functions/Render/render_convertGplToHex.sh b/Functions/Render/render_convertGplToHex.sh new file mode 100755 index 0000000..6715ad0 --- /dev/null +++ b/Functions/Render/render_convertGplToHex.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# render_convertGplToHex.sh -- This function takes one palette +# produced by Gimp (e.g., syslinux.gpl) as input and outputs the list +# of hexadecimal colors and their respective index position the +# `pnmtolss16' program needs (e.g., #RRGGBB=0 #RRGGBB=1 ... [all +# values in the same line]). +# +# Copyright 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_convertGplToHex { + + local COLOR='' + local COUNT=0 + local -a FILES + + # Define path to GPL palette. This is the .gpl file we use to + # retrive color information from. + local PALETTE_GPL="$1" + + # Define path to HEX palette. This is the palette used to stored + # the color information the `ppmtolss16' program needs. + local PALETTE_HEX="$2" + + # Define the number of colors this function should return. + local COLOR_NUMBER="$3" + + # Verify the number of colors this function should return. As + # convenction, we are producing images in 14 and 16 colors only to + # cover Grub and Syslinux images need respectively. + if [[ ! $COLOR_NUMBER =~ '^(14|16)$' ]];then + cli_printMessage "`eval_gettext "Reducing image to \\\`\\\$COLOR_NUMBER' colors is not supported."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Define list of colors from GPL palette. + local COLORS=$(render_getColors "$PALETTE_GPL") + + # Verify number of colors returned in the list. + if [[ ! $(echo "$COLORS" | wc -l) =~ $COLOR_NUMBER ]];then + cli_printMessage "`gettext "The palette doesn't have the correct number of colors."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Verify format of colors inside the list. + for COLOR in $COLORS;do + if [[ ! $COLOR =~ '^[0-9a-f]{6}$' ]];then + cli_printMessage "`eval_gettext "The \\\`\\\$COLOR' string isn't a valid color code."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + done + + # Create list of colors to be process by pnmtolss16 + echo "$COLORS" | nl | awk '{ printf "#%s=%d ", $2, $1 - 1 }' \ + > $PALETTE_HEX + + # Verify HEX palette existence. + cli_checkFiles "$PALETTE_PPM" 'f' + +} diff --git a/Functions/Render/render_convertGplToPpm.sh b/Functions/Render/render_convertGplToPpm.sh new file mode 100755 index 0000000..f8d6ce0 --- /dev/null +++ b/Functions/Render/render_convertGplToPpm.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# +# render_convertGplToPpm.sh -- This function takes one palette +# produced by Gimp (e.g., syslinux.gpl) as input and outputs one PPM +# file based on it (e.g., syslinux.ppm). +# +# Copyright 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_convertGplToPpm { + + local COLOR='' + local COUNT=0 + local -a FILES + + # Define path to GPL palette. This is the .gpl file we use to + # retrive color information from. + local PALETTE_GPL="$1" + + # Define path to PPM palette. This is the .ppm file we'll save + # color information to. + local PALETTE_PPM="$2" + + # Define the number of colors this function should return. + local COLOR_NUMBER="$3" + + # Verify the number of colors this function should return. As + # convenction, we are producing images in 14 and 16 colors only to + # cover Grub and Syslinux images need respectively. + if [[ ! $COLOR_NUMBER =~ '^(14|16)$' ]];then + cli_printMessage "`eval_gettext "Reducing image to \\\`\\\$COLOR_NUMBER' colors is not supported."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Define list of colors from GPL palette. + local COLORS=$(render_getColors "$PALETTE_GPL") + + # Verify number of colors returned in the list. + if [[ ! $(echo "$COLORS" | wc -l) =~ $COLOR_NUMBER ]];then + cli_printMessage "`gettext "The palette doesn't have the correct number of colors."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Verify format of colors inside the list. + for COLOR in $COLORS;do + if [[ ! $COLOR =~ '^[0-9a-f]{6}$' ]];then + cli_printMessage "`eval_gettext "The \\\`\\\$COLOR' string isn't a valid color code."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + done + + # Create temporal images (of 1x1 pixel each) for each color + # retrived from Gimp's palette. + for COLOR in $COLORS;do + FILES[$COUNT]=$(cli_getTemporalFile "color-${COUNT}.ppm") + ppmmake $(echo "$COLOR" \ + | sed -r 's!(.{2})(.{2})(.{2})!rgb:\1/\2/\3!') 1 1 \ + > ${FILES[$COUNT]} + COUNT=$(($COUNT + 1)) + done + + # Concatenate temporal images from left to right to create the PPM + # file. + pnmcat -lr ${FILES[*]} > $PALETTE_PPM + + # Remove temporal images. + rm ${FILES[*]} + + # Verify PPM palette existence. + cli_checkFiles "$PALETTE_PPM" 'f' + +} diff --git a/Functions/Render/render_convertHtmlToText.sh b/Functions/Render/render_convertHtmlToText.sh new file mode 100755 index 0000000..a84adbf --- /dev/null +++ b/Functions/Render/render_convertHtmlToText.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# render_convertHtmlToText.sh -- This function takes one HTML file +# and produces one plain-text file (i.e., without markup inside). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_convertHtml2Text { + + # Verify existence of HTML file. + cli_checkFiles ${FILE}.xhtml 'f' + + local COMMAND='' + local OPTIONS='' + + # Define the command path to text-based web browser and options + # used to produce plain-text files. Most of these programs have a + # dump option that print formatted plain-text versions of given + # HTML file to stdout. + if [[ -x '/usr/bin/lynx' ]];then + COMMAND='/usr/bin/lynx' + OPTIONS='-force_html -nolist -width 70 -dump' + elif [[ -x '/usr/bin/elinks' ]];then + COMMAND='/usr/bin/elinks' + OPTIONS='-force_html -no-numbering -no-references -width 70 -dump' + elif [[ -x '/usr/bin/w3m' ]];then + COMMAND='/usr/bin/w3m' + OPTIONS='-dump' + fi + + if [[ $COMMAND != '' ]];then + + # Print action message. + if [[ -f ${FILE}.txt ]];then + cli_printMessage "${FILE}.txt" 'AsUpdatingLine' + else + cli_printMessage "${FILE}.txt" 'AsCreatingLine' + fi + + # Convert from HTML to plain-text without markup. + ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt + + else + cli_printMessage "`gettext "No way to convert from HTML to plain-text found."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Functions/Render/render_convertPngTo.sh b/Functions/Render/render_convertPngTo.sh new file mode 100644 index 0000000..bd5e398 --- /dev/null +++ b/Functions/Render/render_convertPngTo.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# render_convertPngTo.sh -- This function provides post-rendition +# to convert images images produced by centos-art base-rendition. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_convertPngTo { + + # Get image formats. + local FORMATS=$(render_getConfigOption "$ACTION" '2-') + + # Check base file existence. + cli_checkFiles ${FILE}.png 'f' + + # Check image formats and do convertion. + if [[ "$FORMATS" != "" ]];then + for FORMAT in $FORMATS;do + cli_printMessage "${FILE}.${FORMAT}" "AsSavedAsLine" + convert -quality 85 ${FILE}.png ${FILE}.${FORMAT} + done + + fi + +} diff --git a/Functions/Render/render_copy.sh b/Functions/Render/render_copy.sh new file mode 100755 index 0000000..e54abe9 --- /dev/null +++ b/Functions/Render/render_copy.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# render_copy.sh -- This function duplicates rendition stuff. +# Rendition stuff is formed by design models, design images and +# pre-rendition configuration scripts (which includes translations +# files). This way, when we say to duplicate rendition stuff we are +# saying to duplicate these four directory structures (i.e., design +# models, design images, pre-rendition configuration scripts, and +# related translations files). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_copy { + + # Verify target directory. + cli_checkRepoDirTarget + + # Determine what directory structure we are duplicating. + +} diff --git a/Functions/Render/render_doBaseActions.sh b/Functions/Render/render_doBaseActions.sh new file mode 100755 index 0000000..231cae3 --- /dev/null +++ b/Functions/Render/render_doBaseActions.sh @@ -0,0 +1,238 @@ +#!/bin/bash +# +# render_do.sh -- This function performs base-rendition action +# for all files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doBaseActions { + + local -a FILES + local FILE='' + local OUTPUT='' + local TEMPLATE='' + local PARENTDIR='' + local EXTENSION='' + local TRANSLATION='' + local EXTERNALFILE='' + local EXTERNALFILES='' + local THIS_FILE_DIR='' + local NEXT_FILE_DIR='' + local COUNT=0 + + # Initialize post-rendition list of actions, the specification of + # what actions does centos-art execute immediatly after producing + # the base file in the same directory structure. + local -a POSTACTIONS + + # Initialize last-rendition list of actions, the specification of + # what actions does centos-art execute once all base files in the + # same directory structure have been produced, this is just + # immediatly before passing to produce the next directory + # structure. + local -a LASTACTIONS + + # Check theme model directory structure. + cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${FLAG_THEME_MODEL}" 'd' + + # Verify post-rendition actions passed from command-line and add + # them, if any, to post-rendition list of actions. + if [[ $FLAG_GROUPED_BY != '' ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]="groupSimilarFiles:${FLAG_GROUPED_BY}" + fi + + # Define the extension pattern for template files. This is the + # file extensions that centos-art will look for in order to build + # the list of files to process. The list of files to process + # contains the files that match this extension pattern. + EXTENSION='\.(svgz|svg|docbook)' + + # Redefine parent directory for current workplace. + PARENTDIR=$(basename "${ACTIONVAL}") + + # Define base location of template files. + render_getDirTemplate + + # Define list of files to process as array variable. This make + # posible to realize verifications like: is the current base + # directory equal to the next one in the list of files to process? + # This is used to know when centos-art.sh is leaving a directory + # structure and entering into another. This information is + # required in order for centos-art.sh to know when to apply + # last-rendition actions. + for FILE in $(cli_getFilesList "${TEMPLATE}" "${FLAG_FILTER}.*${EXTENSION}");do + FILES[((++${#FILES[*]}))]=$FILE + done + + # Set action preamble. + cli_printActionPreamble "${FILES[*]}" '' '' + + # Start processing the base rendition list of FILES. Fun part + # approching :-). + while [[ $COUNT -lt ${#FILES[*]} ]];do + + # Define base file. + FILE=${FILES[$COUNT]} + + # Define the base directory path for the current file being + # process. + THIS_FILE_DIR=$(dirname ${FILES[$COUNT]}) + + # Define the base directory path for the next file that will + # be process. + if [[ $(($COUNT + 1)) -lt ${#FILES[*]} ]];then + NEXT_FILE_DIR=$(dirname ${FILES[$(($COUNT + 1))]}) + else + NEXT_FILE_DIR='' + fi + + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Define final location of translation file. + TRANSLATION=$(dirname $FILE \ + | sed -r 's!/trunk/(Identity/)!/trunk/Locales/\1!')/$(cli_getCurrentLocale).po + + # Print final location of translation file. + if [[ ! -f "$TRANSLATION" ]];then + cli_printMessage "`gettext "None"`" "AsTranslationLine" + else + cli_printMessage "$TRANSLATION" 'AsTranslationLine' + fi + + # Define final location of template file. + TEMPLATE=${FILE} + + # Print final location of template file. + if [[ ! -f "$TEMPLATE" ]];then + cli_printMessage "`gettext "None"`" "AsDesignLine" + else + cli_printMessage "$TEMPLATE" 'AsDesignLine' + fi + + # Define final location of output directory. + render_getDirOutput + + # Get relative path to file. The path string (stored in FILE) + # has two parts: 1. the variable path and 2. the common path. + # The variable path is before the common point in the path + # string. The common path is after the common point in the + # path string. The common point is the name of the parent + # directory (stored in PARENTDIR). + # + # trunk/Locales/Identity/.../Firstboot/3/splash-small.svg + # -------------------------^| the |^------------^ + # variable path | common | common path + # -------------------------v| point | v------------v + # trunk/Identity/Themes/M.../Firstboot/Img/3/splash-small.png + # + # What we do here is remove the varibale path, the common + # point, and the file extension parts in the string holding + # the path retrived from design models directory structure. + # Then we use the common path as relative path to store the + # the final image file. + # + # The file extension is removed from the common path because + # it is set when we create the final image file. This + # configuration let us use different extensions for the same + # file name. + # + # When we render using renderImage function, the structure of + # files under the output directory will be the same used after + # the common point in the related design model directory + # structure. + FILE=$(echo ${FILE} \ + | sed -r "s!.*${PARENTDIR}/!!" \ + | sed -r "s/${EXTENSION}$//") + + # Define absolute path to final file (without extension). + FILE=${OUTPUT}/$(basename "${FILE}") + + # Define instance name from design model. + INSTANCE=$(cli_getTemporalFile ${TEMPLATE}) + + # Verify translation file existence and create template + # instance accordingly. + if [[ -f ${TRANSLATION} ]];then + + # Create translated instance from design model. + /usr/bin/xml2po -p ${TRANSLATION} ${TEMPLATE} > ${INSTANCE} + + # Remove .xml2po.mo temporal file. + if [[ -f ${PWD}/.xml2po.mo ]];then + rm ${PWD}/.xml2po.mo + fi + + else + # Create non-translated instance form design model. + /bin/cp ${TEMPLATE} ${INSTANCE} + fi + + # Apply translation markers replacements to template instance. + cli_replaceTMarkers ${INSTANCE} + + # Verify the extension of template instance and render content + # accordingly. + if [[ $INSTANCE =~ '\.(svgz|svg)$' ]];then + + # Perform base-rendition action for svg files. + render_doSvg + + # Perform post-rendition action for svg files. + render_doSvgPostActions + + # Perform last-rendition action for svg files. + render_doSvgLastActions + + elif [[ $INSTANCE =~ '\.docbook$' ]];then + + # Perform base-rendition action for docbook files. + render_doDocbook + + # Perform post-rendition action for docbook files. + #render_doDocbookPostActions + + # Perform base-rendition action for docbook files. + #render_doDocbookLastActions + + else + cli_printMessage "`gettext "The template file you try to render is not supported yet."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Remove template instance. + if [[ -f $INSTANCE ]];then + rm $INSTANCE + fi + + # Perform post-rendition actions for all files. + render_doPostActions + + # Perform last-rendition actions for all files. + render_doLastActions + + # Increment file counter. + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Functions/Render/render_doBrands.sh b/Functions/Render/render_doBrands.sh new file mode 100644 index 0000000..f9afa94 --- /dev/null +++ b/Functions/Render/render_doBrands.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# render_doBrands.sh -- This function provides last-rendition +# actions to produce CentOS brands. This function takes both The +# CentOS Symbol and The CentOS Type images and produces variation of +# them in different dimensions and formats using ImageMagick tool-set. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doBrands { + + local SOURCEFILE='' + local TARGETDIR='' + local TARGETFILE='' + local NEWFILE='' + + # Define absolute path to image file. + local FILE="$1" + + # Define height dimensions you want to produce brands for. + local SIZES="16 20 22 24 32 36 40 48 64 96 128 148 164 196 200 512" + + # Define image formats you want to produce brands for. + local FORMATS="png xpm pdf jpg tif" + + # Redefine absolute path to directory where final brand images + # will be stored. Notice how both final image directory and design + # model have the same name, this is intentional in order to keep + # images and design models related and organized inside their own + # directory structures. + local DIRNAME=$(cli_getRepoName "$FILE" 'd')/$(cli_getRepoName "$FILE" 'fd') + + # Check directory where final brand images will be stored. + if [[ ! -d $DIRNAME ]];then + mkdir -p ${DIRNAME} + fi + + for SIZE in ${SIZES};do + + # Redefine name of new file. + NEWFILE=${DIRNAME}/${SIZE} + + for FORMAT in ${FORMATS};do + + # Output action information. + cli_printMessage "${NEWFILE}.${FORMAT}" "AsCreatingLine" + + # Convert and resize to create new file. + convert -resize x${SIZE} ${FILE}.png ${NEWFILE}.${FORMAT} + + done + + # Create logo copy in 2 colors. + cli_printMessage "${NEWFILE}.xbm (`gettext "2 colors grayscale"`)" "AsCreatingLine" + convert -resize x${SIZE} -colorspace gray -colors 2 ${FILE}.png ${NEWFILE}.xbm + + # Create logo copy in emboss effect. + cli_printMessage "${NEWFILE}-emboss.png" "AsCreatingLine" + convert -resize x${SIZE} -emboss 1 ${FILE}.png ${NEWFILE}-emboss.png + + done + + # Output division line. + cli_printMessage '-' 'AsSeparatorLine' +} diff --git a/Functions/Render/render_doDm.sh b/Functions/Render/render_doDm.sh new file mode 100755 index 0000000..c7edb46 --- /dev/null +++ b/Functions/Render/render_doDm.sh @@ -0,0 +1,191 @@ +#!/bin/bash +# +# render_doDm.sh -- This function collects Display Manager (DM) +# required files and creates a tar.gz package that groups them all +# together. Use this function as last-rendition action for Gdm and Kdm +# base-rendition actions. +# +# Usage: +# +# ACTIONS[1]='LAST:renderDm:TYPE:RESOLUTION' +# +# Where: +# +# TYPE can be either `Gdm' or `Kdm'. These values correspond to the +# directory names used to store related design models. +# +# RESOLUTION represents the screen resolution tar.gz files are +# produced for (e.g., 800x600, 1024x768, 2048x1536, etc.). +# +# In order to produce tar.gz files correctly, both screen resolution +# definition inside pre-rendition configuration script and background +# name inside theme directory structure need to match one another. If +# one screen resolution is defined correctly, but there is no +# background information for it, the related tar.gz file is not +# produced and the next file in the list of files to process is +# evaluated. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doDm { + + local -a SRC + local -a DST + local DM='' + local TGZ='' + local COUNT=0 + local RESOLUTION='' + local RESOLUTIONS='' + + # Print separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Get display manager passed from render.conf.sh pre-rendition + # configuration script. + DM=$(render_getConfigOption "${ACTION}" '2') + + # Sanitate display manager passed from render.conf.sh + # pre-rendition configuration script. Whatever value be retrived + # as display manager configuration option is converted to + # uppercase in order to match either Gdm or Kdm design model + # directory structures. + DM=$(cli_getRepoName "$DM" 'd') + + # Get screen resolutions passed from render.conf.sh pre-rendition + # configuration script. + RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3') + + # Check screen resolutions passed from render.conf.sh + # pre-rendition configuration script. + if [[ "$RESOLUTIONS" == '' ]];then + cli_printMessage "`gettext "There is no resolution information to process."`" 'AsErrorLine' + cli_printMessage $(caller) "AsToKnowMoreLine" + fi + + # Define source files using absolute paths. + SRC[0]=$(cli_getRepoTLDir)/Identity/Brands/Img/symbol-resized-48.png + SRC[1]=${OUTPUT}/release.png + SRC[2]=${OUTPUT}/screenshot.png + SRC[3]=$(dirname $TEMPLATE)/GdmGreeterTheme.xml + SRC[4]=$(dirname $TEMPLATE)/GdmGreeterTheme.desktop + SRC[5]=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Backgrounds/Img/Png + SRC[6]=$(dirname $TEMPLATE)/icon-language.png + SRC[7]=$(dirname $TEMPLATE)/icon-reboot.png + SRC[8]=$(dirname $TEMPLATE)/icon-session.png + SRC[9]=$(dirname $TEMPLATE)/icon-shutdown.png + + # Define name used as temporal holder to build tar.gz file. + TGZ=$(cli_getPathComponent '--theme-name') + + # Define target files using relative paths. + DST[0]=${TGZ}/centos-symbol.png + DST[1]=${TGZ}/centos-release.png + DST[2]=${TGZ}/screenshot.png + DST[3]=${TGZ}/${TGZ}.xml + DST[4]=${TGZ}/GdmGreeterTheme.desktop + DST[5]=${TGZ}/background.png + DST[6]=${TGZ}/icon-language.png + DST[7]=${TGZ}/icon-reboot.png + DST[8]=${TGZ}/icon-session.png + DST[9]=${TGZ}/icon-shutdown.png + + # Move into the working directory. + pushd ${OUTPUT} > /dev/null + + # Create directory used as temporal holder to build tar.gz file. + if [[ ! -d ${TGZ} ]];then + mkdir ${TGZ} + fi + + for RESOLUTION in $RESOLUTIONS;do + + while [[ $COUNT -lt ${#SRC[*]} ]];do + + if [[ $COUNT -eq 5 ]];then + + # Redefine background information using resolution as + # reference. Avoid concatenation. + SRC[$COUNT]=$(echo "${SRC[$COUNT]}" | cut -d/ -f-13)/${RESOLUTION}-final.png + + # If background information defined inside + # pre-rendition configuration script doesn't match + # background information inside theme-specific + # backgrounds directory structure, try the next + # background definition. + if [[ ! -f ${SRC[$COUNT]} ]];then + continue 2 + fi + + elif [[ $COUNT =~ '^[6-9]$' ]];then + + # If display manager is Kdm, then increment counter and + # resume the next iteration. Icons aren't used on Kdm, + # so there's no need to have them inside it. + if [[ $DM =~ '^Kdm$' ]];then + COUNT=$(($COUNT + 1)) + continue + fi + + fi + + # Check existence of source files. + cli_checkFiles ${SRC[$COUNT]} + + # Copy files from source to target location. + cp ${SRC[$COUNT]} ${DST[$COUNT]} + + # Replace common translation markers from design model + # files with appropriate information. + if [[ $COUNT =~ '^(3|4)$' ]];then + cli_replaceTMarkers "${DST[$COUNT]}" + fi + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + + # Reset counter. + COUNT=0 + + # Print action message. + cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" "AsCreatingLine" + + # Create tar.gz file. + tar -czf "${RESOLUTION}.tar.gz" $TGZ + + done + + # Remove directory used as temporal holder to build targ.gz + # file. + rm -r $TGZ + + # Remove release-specific images. + cli_printMessage "${SRC[1]}" "AsDeletingLine" + rm ${SRC[1]} + cli_printMessage "${SRC[2]}" "AsDeletingLine" + rm ${SRC[2]} + + # Return to where we were initially. + popd > /dev/null + +} diff --git a/Functions/Render/render_doDocbook.sh b/Functions/Render/render_doDocbook.sh new file mode 100755 index 0000000..86f738d --- /dev/null +++ b/Functions/Render/render_doDocbook.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# render_doDocbook.sh -- This function performs base-rendition +# action for DocBook files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doDocbook { + + # Produce xhtml output from docbook template instance using XSL + # stylesheets as reference. + render_convertDocbookToXhtml + + # Produce plaintext output from html outout. + render_convertHtml2Text + +} diff --git a/Functions/Render/render_doGrub.sh b/Functions/Render/render_doGrub.sh new file mode 100644 index 0000000..4d4286e --- /dev/null +++ b/Functions/Render/render_doGrub.sh @@ -0,0 +1,110 @@ +#!/bin/bash +# +# render_doGrub.sh -- This function provides post-rendition +# action used to produce GRUB images. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doGrub { + + # Define number of colors the images will be produced on. + local COLOR_NUMBER='14' + + # Define options using those passed to actions from pre-rendition + # configuration script. These options are applied to pnmremap when + # doing color reduction, so any option available for pnmremap + # command can be passed to renderSyslinux functionality. + local OPTIONS=$(render_getConfigOption "$ACTION" '2-') + + # Check options passed to action. This is required in order to + # aviod using options used already in this script. For example + # -verbose and -mapfile options. + for OPTION in $OPTIONS;do + # Remove anything after equal sign inside option. + OPTION=$(echo -n $OPTION | cut -d'=' -f1) + if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then + cli_printMessage "`eval_gettext "The \\\$OPTION option is already used."`" + cli_printMessage "$(caller)" "AsToKnowMoreLine" + fi + done + + # Define file name prefix. + local PREFIX="-${COLOR_NUMBER}c" + + # Redefine file name prefix using options as reference. This is + # useful to differenciate final files produced using + # Floyd-Steinberg dithering and files which are not. + if [[ "$OPTIONS" =~ '-floyd' ]];then + PREFIX="${PREFIX}-floyd" + fi + + # Define theme-specific palettes directory. + local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Palettes + + # Define absolute path to GPL palette. This palettes should have + # 14 colors only. For more information on this see the GRUB's + # documentation. + local PALETTE_GPL=${PALETTES}/grub.gpl + + # Verify GPL palette existence. + cli_checkFiles $PALETTE_GPL 'f' + + # Define absolute path to PPM palette. The PPM palette is built + # from source palette (PALETTE_GPL) and provides the color + # information understood by `ppmremap', the program used to + # produce images in a specific amount of colors. + local PALETTE_PPM=$(cli_getTemporalFile "grub.ppm") + + # Create image in Netpbm superformat (PNM). The PNM image file is + # created from the PNG image rendered previously as centos-art + # base-rendition output. The PNM image is an intermediate format + # used to manipulate images through Netpbm tools. + cli_printMessage "${FILE}.pnm" "AsSavedAsLine" + pngtopnm -verbose \ + < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm + + # Print the path to GPL palette. + cli_printMessage "$PALETTE_GPL" 'AsPaletteLine' + + # Create PPM palette using GPL palette. + render_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLOR_NUMBER" + + # Reduce colors as specified in PPM palette. Here we use the PPM + # palette to enforce the color position in the image index and the + # Floyd-Steinberg dithering in order to improve color reduction. + cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine" + pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ + < ${FILE}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.ppm + + # Remove PPM palette. It is no longer needed. + if [[ -f ${PALETTE_PPM} ]];then + rm $PALETTE_PPM + fi + + # Create the 14 colors xpm.gz file. + cli_printMessage "${FILE}${PREFIX}.xpm.gz" "AsSavedAsLine" + ppmtoxpm \ + < ${FILE}${PREFIX}.ppm 2>>${FILE}.log > ${FILE}.xpm \ + && gzip --force ${FILE}.xpm \ + && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz + +} diff --git a/Functions/Render/render_doKsplash.sh b/Functions/Render/render_doKsplash.sh new file mode 100755 index 0000000..e8c08a4 --- /dev/null +++ b/Functions/Render/render_doKsplash.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# +# render_doKsplash.sh -- This function collects KDE splash +# (KSplash) required files and creates a tar.gz package that groups +# them all together. Use this function as last-rendition action for +# KSplash base-rendition action. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doKsplash { + + local -a SRC + local -a DST + local FONT='' + local COUNT=0 + + # Define font used to print bottom splash message. + FONT=$(cli_getRepoTLDir)/Identity/Fonts/DejaVuLGCSans-Bold.ttf + + # Check existence of font file. + cli_checkFiles "$FONT" 'f' + + # Define absolute source location of files. + SRC[0]="${OUTPUT}/splash_top.png" + SRC[1]="${OUTPUT}/splash_active_bar.png" + SRC[2]="${OUTPUT}/splash_inactive_bar.png" + SRC[3]="${OUTPUT}/splash_bottom.png" + SRC[4]="$(dirname $TEMPLATE)/Theme.rc" + + # Check absolute source location of files. + cli_checkFiles "${SRC[@]}" 'f' + + # Define relative target location of files. + DST[0]="${OUTPUT}/splash_top.png" + DST[1]="${OUTPUT}/splash_active_bar.png" + DST[2]="${OUTPUT}/splash_inactive_bar.png" + DST[3]="${OUTPUT}/splash_bottom.png" + DST[4]="${OUTPUT}/Theme.rc" + + # Print action message. + cli_printMessage "${OUTPUT}/Preview.png" 'AsCreatingLine' + + # Create `Preview.png' image. + convert -append ${SRC[0]} ${SRC[1]} ${SRC[3]} ${OUTPUT}/Preview.png + + # Add bottom text to Preview.png image. The text position was set + # inside an image of 400x300 pixels. If you change the final + # preview image dimension, you probably need to change the text + # position too. + mogrify -draw 'text 6,295 "KDE is up and running."' \ + -fill \#ffffff \ + -font $FONT \ + ${OUTPUT}/Preview.png + + # Copy `Theme.rc' file. + cp ${SRC[4]} ${DST[4]} + + # Apply common translation markers to Theme.rc file. + cli_replaceTMarkers "${DST[4]}" + +} diff --git a/Functions/Render/render_doLastActions.sh b/Functions/Render/render_doLastActions.sh new file mode 100755 index 0000000..9b35d4f --- /dev/null +++ b/Functions/Render/render_doLastActions.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# render_doLastActions.sh -- This function performs +# last-rendition actions for all files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doLastActions { + + local ACTION='' + + # Verify position of file being produced in the list of files been + # currently processed. + if [[ $THIS_FILE_DIR != $NEXT_FILE_DIR ]];then + + # At this point centos-art.sh should be producing the last + # file from the same unique directory structure, so, before + # producing images for the next directory structure lets + # execute last-rendition actions for the current directory + # structure. + for ACTION in "${LASTACTIONS[@]}"; do + + case "${ACTION}" in + + groupSimilarFiles:* ) + render_groupSimilarFiles + ;; + esac + + done + + fi + +} diff --git a/Functions/Render/render_doPostActions.sh b/Functions/Render/render_doPostActions.sh new file mode 100755 index 0000000..8fa8fb5 --- /dev/null +++ b/Functions/Render/render_doPostActions.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# render_doPostActions.sh -- This function performs +# post-rendition actions for all files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doPostActions { + + local ACTION='' + + for ACTION in "${POSTACTIONS[@]}"; do + + case "${ACTION}" in + + groupSimilarFiles:* ) + render_groupSimilarFiles + ;; + + esac + + done + +} diff --git a/Functions/Render/render_doSvg.sh b/Functions/Render/render_doSvg.sh new file mode 100644 index 0000000..54a678a --- /dev/null +++ b/Functions/Render/render_doSvg.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# render_doSvg.sh -- This function performs base-rendition +# action for SVG files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doSvg { + + # Define export id used inside design templates. This value + # defines the design area we want to export. + local EXPORTID='CENTOSARTWORK' + + # Check export id inside design templates. + grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null + if [[ $? -gt 0 ]];then + cli_printMessage "`eval_gettext "There is no export id (\\\$EXPORTID) inside \\\$TEMPLATE."`" "AsErrorLine" + cli_printMessage '-' 'AsSeparatorLine' + continue + fi + + # Check existence of external files. Inside design templates and + # their instances, external files are used to refere the + # background information required by the design template. If such + # background information is not available the image is produced + # without background information. This is something that need to + # be avoided. + render_checkSvgAbsref "$INSTANCE" + + # Render template instance using inkscape. Modify the inkscape + # output to reduce the amount of characters used in description + # column at final output. + cli_printMessage "$(inkscape $INSTANCE \ + --export-id=$EXPORTID --export-png=${FILE}.png | sed -r \ + -e "s!Area !`gettext "Area"`: !" \ + -e "s!Background RRGGBBAA:!`gettext "Background"`: RRGGBBAA!" \ + -e "s!Bitmap saved as:!`gettext "Saved as"`:!")" 'AsRegularLine' + +} diff --git a/Functions/Render/render_doSvgLastActions.sh b/Functions/Render/render_doSvgLastActions.sh new file mode 100644 index 0000000..0235f68 --- /dev/null +++ b/Functions/Render/render_doSvgLastActions.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# +# render_doSvgLastActions.sh -- This function performs +# last-rendition actions for SVG files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doSvgLastActions { + + local ACTION='' + + # Verify position of file being produced in the list of files been + # currently processed. + if [[ $THIS_FILE_DIR == $NEXT_FILE_DIR ]];then + return + fi + + # Define SVG-directory-specific last-rendition actions processing + # as local to this function. Otherwise it may confuse command-line + # last-rendition actions. + local -a LASTACTIONS + + # Add directory-specific last-rendition actions to the list of + # post actions and last actions. This is required in order to + # provide a predictable way of producing content inside the + # repository and save you the time of writing long option + # combinations each time you need to produce images inside the + # repository. + if [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Gdm/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Kdm/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then + LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderKsplash' + fi + + # At this point centos-art.sh should be producing the last file + # from the same unique directory structure, so, before producing + # images for the next directory structure lets execute + # last-rendition actions for the current directory structure. + for ACTION in "${LASTACTIONS[@]}"; do + + case "${ACTION}" in + + renderKsplash ) + render_doKsplash + ;; + + renderDm:* ) + render_doDm + ;; + + esac + + done + +} diff --git a/Functions/Render/render_doSvgPostActions.sh b/Functions/Render/render_doSvgPostActions.sh new file mode 100644 index 0000000..aecc36c --- /dev/null +++ b/Functions/Render/render_doSvgPostActions.sh @@ -0,0 +1,105 @@ +#!/bin/bash +# +# render_doSvgPostActions.sh -- This function performs +# post-rendition actions for SVG files. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doSvgPostActions { + + local ACTION='' + + # Define SVG-directory-specific post-rendition actions processing + # as local to this function. Otherwise it may confuse command-line + # post-rendition actions. + local -a POSTACTIONS + + # Execute SVG directory-specific post-rendition actions to the + # list of post actions and last actions. This is required in order + # to provide a predictable way of producing content inside the + # repository and save you the time of writing long option + # combinations each time you need to produce images inside the + # repository. + if [[ $TEMPLATE =~ "Backgrounds/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo: jpg' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='groupSimilarFiles: png jpg' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Syslinux/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderSyslinux' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderSyslinux:-floyd' + elif [[ $TEMPLATE =~ "Grub" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderGrub' + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderGrub:-floyd' + elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderKsplash' + fi + + # Verify svg-related post-rendition actions passed from + # command-line and add them, if any, to post-rendition list of + # actions. + if [[ $FLAG_CONVERT != '' ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]="convertPngTo:${FLAG_CONVERT}" + fi + if [[ $FLAG_ROTATE != '' ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]="rotatePngTo:${FLAG_ROTATE}" + fi + if [[ $FLAG_RESIZE != '' ]];then + POSTACTIONS[((++${#POSTACTIONS[*]}))]="resizePngTo:${FLAG_RESIZE}" + fi + + # Execute post-rendition actions. + for ACTION in "${POSTACTIONS[@]}"; do + + case "${ACTION}" in + + convertPngTo:* ) + render_convertPngTo + ;; + + rotatePngTo:* ) + render_rotatePngTo + ;; + + resizePngTo:* ) + render_resizePngTo + ;; + + renderSyslinux* ) + render_doSyslinux + ;; + + renderGrub* ) + render_doGrub + ;; + + renderBrands ) + render_doBrands + ;; + + groupSimilarFiles:* ) + render_groupSimilarFiles + ;; + + esac + + done + +} diff --git a/Functions/Render/render_doSyslinux.sh b/Functions/Render/render_doSyslinux.sh new file mode 100755 index 0000000..164c77b --- /dev/null +++ b/Functions/Render/render_doSyslinux.sh @@ -0,0 +1,189 @@ +#!/bin/bash +# +# render_doSyslinux.sh -- This function provides post-rendition +# action used to produce LSS16 images, the images used by isolinux. +# +# This function uses three different formats to handle the same color +# information. Initially, the color information is defined with GIMP +# (The GNU Image Manipulation Program) as a palette of color. This +# palette of colors contains 16 colors only and is saved in a file +# named `syslinux.gpl. +# +# The `syslinux.gpl' file is used to build two other files: the +# `syslinux.ppm' file and the `syslinux.hex' file. The `syslinux.ppm' +# file is used to reduce a full color PNG image to the amount of +# colors it specifies (i.e., 16 colors). Later, with the 16 color +# image already created, the `syslinux.hex' file is used to build the +# LSS16 image. +# +# In order to produce images in LSS16 format correctly, it is needed +# that both the `syslinux.ppm' and `syslinux.hex' files contain the +# same color information. This is, both `syslinux.ppm' and +# `syslinux.hex' shoud represent the same color values and the same +# color index. +# +# This function save you the work of preparing both `syslinux.ppm' and +# `syslinux.hex'. Instead, you only need to prepare the `syslinux.gpl' +# file with the color information you want to produce images. +# +# In order for this function to work, the `syslinux.gpl' file should +# have a format similar to the following: +# +# GIMP Palette +# Name: TreeFlower-4-Syslinux +# Columns: 16 +# # +# 10 22 40 0a1628 +# 9 28 52 091c34 +# 16 34 63 10223f +# 20 37 67 142543 +# 15 39 74 0f274a +# 12 45 85 0c2d55 +# 20 43 78 142b4e +# 255 255 255 ffffff +# 21 51 95 15335f +# 41 52 70 293446 +# 32 76 141 204c8d +# 77 90 107 4d5a6b +# 143 154 167 8f9aa7 +# 128 179 255 80b3ff +# 194 200 202 c2c8ca +# 231 241 255 e7f1ff +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doSyslinux { + + # Define number of colors the images will be produced on. + local COLOR_NUMBER='16' + + # Define options using those passed to actions from pre-rendition + # configuration script. These options are applied to pnmremap when + # doing color reduction, so any option available for pnmremap + # command can be passed to renderSyslinux functionality. + local OPTIONS=$(render_getConfigOption "$ACTION" '2-') + + # Check options passed to action. This is required in order to + # aviod using options already used in this script. For example + # -verbose and -mapfile options. + for OPTION in $OPTIONS;do + # Remove anything after equal sign inside option. + OPTION=$(echo $OPTION | cut -d'=' -f1) + if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then + cli_printMessage "`eval_gettext "The \\\$OPTION option is already used."`" + cli_printMessage "$(caller)" "AsToKnowMoreLine" + fi + done + + # Define default file name prefix for 16 colors images. + local PREFIX="-${COLOR_NUMBER}c" + + # Re-define 16 colors images default file name prefix using + # options as reference. This is useful to differenciate final + # files produced using Floyd-Steinberg dithering and final files + # which are not. + if [[ "$OPTIONS" =~ '-floyd' ]];then + PREFIX="${PREFIX}-floyd" + fi + + # Define theme-specific palettes directory. + local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Palettes + + # Define absolute path to GPL palette. The GPL palette defines the + # color information used to build syslinux images. This palette + # should be set to 16 colors and, as specified in isolinux + # documentation, the background color should be indexed on + # position 0 and the forground in position 7 (see + # /usr/share/doc/syslinux-X.XX/isolinux.doc, for more + # information.) + local PALETTE_GPL=${PALETTES}/syslinux.gpl + + # Verify GPL palette existence. + cli_checkFiles $PALETTE_GPL 'f' + + # Define absolute path to PPM palette. The PPM palette is built + # from source palette (PALETTE_GPL) and provides the color + # information understood by `ppmremap', the program used to + # produce images in a specific amount of colors. + local PALETTE_PPM=$(cli_getTemporalFile "syslinux.ppm") + + # Define the HEX palette. The HEX palette is built from source + # palette (PALETTE_GPL) and provides the color information in the + # format understood by `ppmtolss16', the program used to produce + # images in LSS16 format. The HEX palette stores just one line + # with the color information as described in isolinux + # documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the + # same line]) + local PALETTE_HEX=$(cli_getTemporalFile "syslinux.hex") + + # Create image in Netpbm superformat (PNM). The PNM image file is + # created from the PNG image rendered previously as centos-art + # base-rendition output. The PNM image is an intermediate format + # used to manipulate images through Netpbm tools. + cli_printMessage "${FILE}.pnm" "AsSavedAsLine" + pngtopnm -verbose \ + < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm + + # Print the path to GPL palette. + cli_printMessage "$PALETTE_GPL" 'AsPaletteLine' + + # Create PPM palette using GPL palette. + render_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLOR_NUMBER" + + # Create HEX palette using GPL palette. + render_convertGplToHex "$PALETTE_GPL" "$PALETTE_HEX" "$COLOR_NUMBER" + + # Reduce colors as specified in PPM palette. Here we use the PPM + # palette to enforce the color position in the image index and the + # Floyd-Steinberg dithering in order to improve color reduction. + cli_printMessage "${FILE}${PREFIX}.pnm" "AsSavedAsLine" + pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ + < ${FILE}.pnm 2>> ${FILE}.log > ${FILE}${PREFIX}.pnm + + # Create LSS16 image. + cli_printMessage "${FILE}${PREFIX}.lss" "AsSavedAsLine" + ppmtolss16 $(cat $PALETTE_HEX) \ + < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.lss + + # Remove HEX palette. It is no longer needed. + if [[ -f ${PALETTE_HEX} ]];then + rm $PALETTE_HEX + fi + + # Create the PPM image indexed to 16 colors. Also the colormap + # used in the LSS16 image is saved on ${FILE}.log; this is useful to + # verify the correct order of colors in the image index. + cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine" + lss16toppm -map \ + < ${FILE}${PREFIX}.lss 2>>${FILE}.log > ${FILE}${PREFIX}.ppm + + # Create the 16 colors PNG image. + cli_printMessage "${FILE}${PREFIX}.png" "AsSavedAsLine" + pnmtopng -verbose -palette=$PALETTE_PPM \ + < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.png + + # Remove PPM palette. It is no longer needed. + if [[ -f ${PALETTE_PPM} ]];then + rm $PALETTE_PPM + fi + +} diff --git a/Functions/Render/render_getArguments.sh b/Functions/Render/render_getArguments.sh new file mode 100644 index 0000000..48c975d --- /dev/null +++ b/Functions/Render/render_getArguments.sh @@ -0,0 +1,118 @@ +#!/bin/bash +# +# render_getArguments.sh -- This function interprets arguments passed to +# render functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getArguments { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="filter:,quiet,answer:,dont-commit-changes,releasever:,basearch:,convert:,rotate:,resize:,group-by:,theme-model:" + + # Redefine ARGUMENTS variable using getopt output. + cli_doParseArguments + + # Redefine positional parameters using ARGUMENTS variable. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + + case "$1" in + + --filter ) + FLAG_FILTER="$2" + shift 2 + ;; + + --quiet ) + FLAG_QUIET="true" + FLAG_DONT_COMMIT_CHANGES="true" + shift 1 + ;; + + --answer ) + FLAG_ANSWER="$2" + shift 2 + ;; + + --dont-commit-changes ) + FLAG_DONT_COMMIT_CHANGES="true" + shift 1 + ;; + + --releasever ) + FLAG_RELEASEVER="$2" + if [[ ! $FLAG_RELEASEVER =~ $(cli_getPathComponent '--release-pattern') ]];then + cli_printMessage "`gettext "The release version provided is not supported."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + shift 2 + ;; + + --basearch ) + FLAG_BASEARCH="$2" + if [[ ! $FLAG_BASEARCH =~ $(cli_getPathComponent '--architecture-pattern') ]];then + cli_printMessage "`gettext "The architecture provided is not supported."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + shift 2 + ;; + + --convert ) + FLAG_CONVERT="$2" + shift 2 + ;; + + --rotate ) + FLAG_ROTATE="$2" + shift 2 + ;; + + --resize ) + FLAG_RESIZE="$2" + shift 2 + ;; + + --group-by ) + FLAG_GROUPED_BY="$2" + shift 2 + ;; + + --theme-model ) + FLAG_THEME_MODEL=$(cli_getRepoName "$2" 'd') + shift 2 + ;; + + * ) + break + esac + done + + # Redefine ARGUMENTS variable using current positional parameters. + cli_doParseArgumentsReDef "$@" + +} diff --git a/Functions/Render/render_getColors.sh b/Functions/Render/render_getColors.sh new file mode 100755 index 0000000..da3e6ca --- /dev/null +++ b/Functions/Render/render_getColors.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# render_getColors.sh -- This function takes one palette produced by +# Gimp (e.g., syslinux.gpl) as input and outputs a list of colors as +# specified. +# +# Copyright 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getColors { + + # Define path to GPL palette. This is the .gpl file we use to + # retrive color information from. + local PALETTE_GPL="$1" + + # Retrive fourth column of information from GPL palette. The + # fourth column of GPL palette contains the palette commentary + # field. The palette commentary field can be anything, but for the + # sake of our own convenience we use it to store the color + # hexadecimal value. Notice that you can put your comments from + # the fifth column on. + local COLORS=$(sed -r '1,/^#/d' $PALETTE_GPL | awk '{ printf "%s\n", $4 }') + + # Output list of colors. + echo "$COLORS" + +} diff --git a/Functions/Render/render_getConfigOption.sh b/Functions/Render/render_getConfigOption.sh new file mode 100755 index 0000000..f5cdcd3 --- /dev/null +++ b/Functions/Render/render_getConfigOption.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# +# render_getConfigOption.sh -- This function standardizes the way +# action values are retrived from pre-rendition configuration files. +# Use this function whenever you need to retrive action values from +# pre-rendition configuration script. +# +# Usage: VAR=$(render_getConfigOption "ACTION" "FIELD") +# +# VAR is the name of the variable where we store the option named +# returned by render_getConfigOption. +# +# ACTION is the string definition set in the pre-rendition +# configuration script that holds the action name and its options +# fields. +# +# FIELD is the field number in the action string we want to retrive +# option from. By default options start from third field on. The first +# field is reserved for the action type (i.e., POST or LAST), and the +# second field is reserved for the action itself (e.g., convertPngTo, +# renderSyslinux, renderKsplash, etc.). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getConfigOption { + + local ACTION="$1" + local FIELD="$2" + local VALUE='' + + # Check action value. The action's value must be present in order + # for this function to work. It provides the string needed to + # retrive options from. + if [[ "$ACTION" == '' ]];then + cli_printMessage "`gettext "There is no action to work with."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Check field value. The field's value must match the cut's + # command specification of its -f option. + if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then + cli_printMessage "`gettext "The field specified is not valid."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Get option from pre-rendition configuration action definition. + VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD}) + + # Sanitate action value passed from pre-rendition configuration + # action definition. + VALUE=$(echo -n "${VALUE}" \ + | sed -r 's!^ *!!g' \ + | sed -r 's!( |,|;) *! !g' \ + | sed -r 's! *$!!g') + + # Output action value without trailing newline. + echo -n "$VALUE" + +} diff --git a/Functions/Render/render_getDirOutput.sh b/Functions/Render/render_getDirOutput.sh new file mode 100644 index 0000000..62f1b95 --- /dev/null +++ b/Functions/Render/render_getDirOutput.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# render_getDirOutput.sh -- This function defines the final +# absolute path the centos-art.sh script uses to store identity +# contents produced at rendition time. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getDirOutput { + + # Define base output directory using design model path as + # reference. + OUTPUT=$(dirname $FILE | sed -r \ + -e "s!/Models/${FLAG_THEME_MODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!" \ + -e "s!/Tpl!!") + + # By default rendered identity content is stored immediatly under + # identity entry structure, but if `Img/' directory exists use it + # instead. + if [[ -d "${OUTPUT}/Img" ]];then + OUTPUT=${OUTPUT}/Img + fi + + # Redefine base output directory to introduce specific information + # like release number, architecture, etc. + OUTPUT=${OUTPUT}/${FLAG_RELEASEVER}/${FLAG_BASEARCH} + + # Define whether to use or not locale-specific directory to store + # content, using current locale information as reference. As + # convenction, when we produce content in English language, we do + # not add a laguage-specific directory to organize content. + # However, when we produce language-specific content in a language + # different from English we do use language-specific directory to + # organize content. + if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then + OUTPUT=${OUTPUT}/$(cli_getCurrentLocale) + fi + + # Remove two or more consecutive slashes as well as the last + # remaining slash in the path. + OUTPUT=$(echo $OUTPUT | sed -r 's!/{2,}!/!g' | sed -r 's!/$!!') + + # Create final output directory, if it doesn't exist yet. + if [[ ! -d ${OUTPUT} ]];then + mkdir -p ${OUTPUT} + fi + +} diff --git a/Functions/Render/render_getDirTemplate.sh b/Functions/Render/render_getDirTemplate.sh new file mode 100644 index 0000000..08e598d --- /dev/null +++ b/Functions/Render/render_getDirTemplate.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# render_getDirTemplate.sh -- This function re-defines absolute +# path to artwork's related design templates directory. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getDirTemplate { + + # Initialize design models location using action value as + # reference. + TEMPLATE=$ACTIONVAL + + # Sanitate design models location. Be sure design models do + # always point to trunk directory structure. This is useful to let + # `centos-art.sh' script do rendition under branches directory + # structure, reusing design models under trunk directory + # structure. + TEMPLATE=$(echo "$TEMPLATE" | sed "s!/branches/!/trunk/!") + + # Sanitate design models location using or not Tpl/ directory. + if [[ -d $TEMPLATE/Tpl ]];then + # Using Tpl/ directory is an obsolete practice that should be + # avoided. The concept of Tpl/ directory per artwork directory + # has been replaced by a common design model directory + # structure where we centralize design models for all + # different artistic motifs. However, there are some cases + # that we may need to use Tpl/ directory still, so we verify + # its existence and use it if present. + TEMPLATE=$TEMPLATE/Tpl + else + # Redefine design model location based on theme model + # (FLAG_THEME_MODEL) variable value. The theme model variable is + # defined in the associated pre-rendition configuration script + # and can be used to set which design model to use among a + # list of different design models that we can choose from. + TEMPLATE=$(echo "$TEMPLATE" \ + | sed "s!Motifs/$(cli_getPathComponent "$TEMPLATE" '--theme')!Models/$FLAG_THEME_MODEL!") + fi + +} diff --git a/Functions/Render/render_groupSimilarFiles.sh b/Functions/Render/render_groupSimilarFiles.sh new file mode 100755 index 0000000..da066d5 --- /dev/null +++ b/Functions/Render/render_groupSimilarFiles.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# render_groupSimilarFiles.sh -- This function provides +# post-rendition action to group files inside directories named as +# their file extensions. For example: if the current file is a .png +# file, it is moved inside a Png/ directory; if the current file is a +# .jpg file, it is stored inside a Jpg/ directory, and so on. +# +# For this function to work correctly, you need to specify which file +# type you want to group. This is done in the post-rendition ACTIONS +# array inside the appropriate `render.conf.sh' pre-configuration +# script. This function cannot be used as last-rendition action. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_groupSimilarFiles { + + local SOURCE='' + local TARGET='' + + # Sanitate file types passed from render.conf.sh pre-rendition + # configuration script. + local FORMATS=$(render_getConfigOption "$ACTION" '2-') + + for FORMAT in $FORMATS;do + + # Redifine source file we want to move. + SOURCE=${FILE}.${FORMAT} + + # Define target directory where source file will be moved + # into. + TARGET=$(dirname "$FILE")/$(cli_getRepoName "$FORMAT" 'd') + + # Check existence of source file. + cli_checkFiles $SOURCE 'f' + + # Check existence of target directory. + if [[ ! -d $TARGET ]];then + mkdir -p $TARGET + fi + + # Redifine file path to add file and its type. + TARGET=${TARGET}/$(cli_getRepoName "$FILE" 'f').${FORMAT} + + # Move file into its final location. + cli_printMessage "$TARGET" 'AsMovedToLine' + mv ${SOURCE} ${TARGET} + + done + +} diff --git a/Functions/Render/render_resizePngTo.sh b/Functions/Render/render_resizePngTo.sh new file mode 100755 index 0000000..b4ad840 --- /dev/null +++ b/Functions/Render/render_resizePngTo.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# render_resizePngTo.sh -- This function provides post-rendition to +# resize images produced by centos-art base-rendition. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_resizePngTo { + + local SIZE='' + local SIZES=$(render_getConfigOption "$ACTION" '2-') + local SRC='' + local DST='' + + # Check base file existence. + cli_checkFiles ${FILE}.png 'f' + + # Check image degrees. + if [[ "$SIZES" != "" ]];then + + # Loop through image degrees and convert them using PNG file + # as base. + for SIZE in $SIZES;do + SRC=${FILE}.png + DST=${FILE}-resized-$(echo $SIZE | sed 's!%!!').png + cli_printMessage "$DST" "AsSavedAsLine" + convert -resize $SIZE ${SRC} ${DST} + done + + fi + +} diff --git a/Functions/Render/render_rotatePngTo.sh b/Functions/Render/render_rotatePngTo.sh new file mode 100644 index 0000000..29fa05c --- /dev/null +++ b/Functions/Render/render_rotatePngTo.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# +# render_rotatePngTo.sh -- This function provides post-rendition +# to convert images produced by centos-art base-rendition. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_rotatePngTo { + + local COUNT=1 + local DEGREE='' + local DEGREES=$(render_getConfigOption "$ACTION" '2-') + local SRC='' + local DST='' + + # Check base file existence. + cli_checkFiles ${FILE}.png 'f' + + # Check image degrees. + if [[ "$DEGREES" != "" ]];then + + # Loop through image degrees and convert them using PNG file + # as base. + for DEGREE in $DEGREES;do + SRC=${FILE}.png + DST=${FILE}-rotated-$(echo $DEGREE | sed 's!%!!').png + cli_printMessage "$DST" "AsSavedAsLine" + convert -rotate $DEGREE ${SRC} ${DST} + done + + fi + +} diff --git a/Functions/Shell/Config/tpl_forCopyright.sed b/Functions/Shell/Config/tpl_forCopyright.sed new file mode 100644 index 0000000..e8e5e2c --- /dev/null +++ b/Functions/Shell/Config/tpl_forCopyright.sed @@ -0,0 +1,38 @@ +# This file standardizes the look and feel of top comments used by +# scripts inside CentOS Artwork Repository. It contains the copyright +# note and the license under which the script is released. This files +# is used with the regular expression '.*\.sh$' only. +# --------------------------------------------------- +# $Id$ +# --------------------------------------------------- +/^# +Copyright .*$/a\ +# Copyright (C) =COPYRIGHT_YEAR== =COPYRIGHT_HOLDER=\ +# \ +# This program is free software; you can redistribute it and/or\ +# modify it under the terms of the GNU General Public License as\ +# published by the Free Software Foundation; either version 2 of the\ +# License, or (at your option) any later version.\ +# \ +# This program is distributed in the hope that it will be useful, but\ +# WITHOUT ANY WARRANTY; without even the implied warranty of\ +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\ +# General Public License for more details.\ +#\ +# You should have received a copy of the GNU General Public License\ +# along with this program; if not, write to the Free Software\ +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307\ +# USA.\ +# \ +# ---------------------------------------------------------------------- + +# Remove previous comments. +/^# +Copyright .*$/,/^# -+$/{ +d +} + +# Remove more than one space after comments. +s/^# +/# / + +# Define first line +1c\ +#!/bin/bash diff --git a/Functions/Shell/shell.sh b/Functions/Shell/shell.sh new file mode 100755 index 0000000..f7d573d --- /dev/null +++ b/Functions/Shell/shell.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# shell.sh -- This function provides very basic string manipulations +# to help you maintain Bash scripts inside repository. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function shell { + + # Define command-line interface. + shell_getActions + +} diff --git a/Functions/Shell/shell_getActions.sh b/Functions/Shell/shell_getActions.sh new file mode 100755 index 0000000..3f50c91 --- /dev/null +++ b/Functions/Shell/shell_getActions.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# +# shell_getActions.sh -- This function interpretes arguments passed to +# `shell' functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function shell_getActions { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="update-copyright:" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + + case "$1" in + + --update-copyright ) + + # Define action value. + ACTIONVAL="$2" + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_updateCopyright" + + # Rotate positional parameters. + shift 2 + ;; + + * ) + # Break options loop. + break + esac + done + + # Check action value. Be sure the action value matches the + # convenctions defined for source locations inside the working + # copy. + cli_checkRepoDirSource + + # Syncronize changes between the working copy and the central + # repository to bring down changes. + cli_syncroRepoChanges + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Syncronize changes between the working copy and the central + # repository to commit up changes. + cli_commitRepoChanges + +} diff --git a/Functions/Shell/shell_updateCopyright.sh b/Functions/Shell/shell_updateCopyright.sh new file mode 100755 index 0000000..42bbae1 --- /dev/null +++ b/Functions/Shell/shell_updateCopyright.sh @@ -0,0 +1,143 @@ +#!/bin/bash +# +# shell_updateTopComment.sh -- This function replaces top comment +# section inside shell scripts (*.sh) with one of many pre-defined +# templates available. Use this function to maintain shell scripts top +# comments inside repository. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function shell_updateCopyright { + + local FILE='' + local COUNT=0 + local FILES='' + local INSTANCE='' + local TEMPLATES='' + local -a TITLE + local -a VALUE + local -a PATTERN + local -a PATTERN_MSG + local -a DEFAULT + local -a MARKER + + # Define absolute path to template file. + TEMPLATE="${CLI_BASEDIR}/Functions/Shell/Config/tpl_forCopyright.sed" + + # Check template file existence. + cli_checkFiles $TEMPLATE 'f' + + # Define file name to template instance. + INSTANCE=$(cli_getTemporalFile $TEMPLATE) + + # Define copyright information. + TITLE[0]="`gettext "Copyright holder"`" + TITLE[1]="`gettext "Copyright year"`" + + # Define translation marker. These values are used inside + # template file. + MARKER[0]='=COPYRIGHT_HOLDER=' + MARKER[1]='=COPYRIGHT_YEAR=' + + # Define pattern. These values are used as regular + # expression patterns for user's input further verification. + PATTERN[0]='^([[:alnum:] _-.]+)?$' + PATTERN[1]='^([[:digit:]]{4})?$' + + # Define pattern message. These values are used as output + # message when user's input doesn't match the related pattern. + PATTERN_MSG[0]="`gettext "Try using alphanumeric characters."`" + PATTERN_MSG[1]="`gettext "Try using numeric characters."`" + + # Define default values. + DEFAULT[0]="The CentOS Project. `gettext "All rights reserved."`" + DEFAULT[1]=$(date +%Y) + + # Initialize values using user's input. + cli_printMessage "`gettext "Enter the information you want to apply:"`" + while [[ $COUNT -ne ${#TITLE[*]} ]];do + + # Request value. + cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' + read VALUE[$COUNT] + + # Sanitate values to exclude characters that could + # introduce possible markup malformations to final SVG files. + until [[ ${VALUE[$COUNT]} =~ ${PATTERN[$COUNT]} ]];do + cli_printMessage "${PATTERN_MSG[$COUNT]}" + cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' + read VALUE[$COUNT] + done + + # Set default value to empty values. + if [[ ${VALUE[$COUNT]} == '' ]];then + VALUE[$COUNT]=${DEFAULT[$COUNT]} + fi + + # Increase counter. + COUNT=$(($COUNT + 1)) + + done + + # Create template instance. + cp $TEMPLATE $INSTANCE + + # Check template instance. We cannot continue if template instance + # couldn't be created. + cli_checkFiles $INSTANCE 'f' + + # Reset counter. + COUNT=0 + + while [[ $COUNT -ne ${#TITLE[*]} ]];do + + # Apply translation marker replacement. + sed -r -i "s!${MARKER[$COUNT]}!${VALUE[$COUNT]}!g" $INSTANCE + + # Increase counter. + COUNT=$(($COUNT + 1)) + + done + + # Define list of files to process + FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}.*\.sh") + + # Set action preamble. + cli_printActionPreamble "${FILES}" '' '' + + # Process list of files. + for FILE in $FILES;do + + # Output action message. + cli_printMessage $FILE 'AsUpdatingLine' + + # Apply template instance to file. + sed -r -i -f $INSTANCE $FILE + + done + + # Remove template instance. + if [[ -f ${INSTANCE} ]];then + rm ${INSTANCE} + fi + +} diff --git a/Functions/Svg/Config/tpl_forMetadata.sed b/Functions/Svg/Config/tpl_forMetadata.sed new file mode 100644 index 0000000..48bd70d --- /dev/null +++ b/Functions/Svg/Config/tpl_forMetadata.sed @@ -0,0 +1,68 @@ +# This file is the metadata information used by CentOS Artwork SIG on +# its scalable vector graphics (SVG) files. This files is used with +# the regular expression '.*\.svg$' only. +# --------------------------------------------------- +# $Id$ +# --------------------------------------------------- +/\ + \ + \ + image/svg+xml\ + \ + \ + =TITLE=\ + =DATE=\ + \ + \ + =CREATOR=\ + \ + \ + \ + \ + =RIGHTS=\ + \ + \ + \ + \ + =PUBLISHER=\ + \ + \ + =IDENTIFIER=\ + =SOURCE=\ + =RELATION=\ + =LANGUAGE=\ + \ + \ +=KEYWORDS=\ + \ + \ + =COVERAGE=\ + =DESCRIPTION=\ + \ + \ + =CONTRIBUTOR=\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + diff --git a/Functions/Svg/svg.sh b/Functions/Svg/svg.sh new file mode 100755 index 0000000..8ae161e --- /dev/null +++ b/Functions/Svg/svg.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# svg.sh -- This function provides very basic SVG manipulations to +# help you to maintain svg files inside the repository. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg { + + # Define command-line interface. + svg_getActions + +} diff --git a/Functions/Svg/svg_getActions.sh b/Functions/Svg/svg_getActions.sh new file mode 100755 index 0000000..bca9556 --- /dev/null +++ b/Functions/Svg/svg_getActions.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# +# svg_getActions.sh -- This function interpretes arguments passed to +# `svg' functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_getActions { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="update-metadata:,vacuum-defs:" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + + case "$1" in + + --update-metadata ) + + # Define action value. + ACTIONVAL="$2" + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_updateMetadata" + + # Rotate positional parameters. + shift 2 + ;; + + --vacuum-defs ) + + # Define action value. + ACTIONVAL="$2" + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_vacuumDefs" + + # Rotate positional parameters. + shift 2 + ;; + + * ) + # Break options loop. + break + esac + done + + # Check action value. Be sure the action value matches the + # convenctions defined for source locations inside the working + # copy. + cli_checkRepoDirSource + + # Syncronize changes between the working copy and the central + # repository to bring down changes. + cli_syncroRepoChanges + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Syncronize changes between the working copy and the central + # repository to commit up changes. + cli_commitRepoChanges + +} diff --git a/Functions/Svg/svg_updateMetadata.sh b/Functions/Svg/svg_updateMetadata.sh new file mode 100755 index 0000000..502b6c1 --- /dev/null +++ b/Functions/Svg/svg_updateMetadata.sh @@ -0,0 +1,240 @@ +#!/bin/bash +# +# svg_updateMetadata.sh -- This function updates metadata values +# inside scalable vector graphic (SVG) files. First, we ask user to +# provide the information. If user doesn't provide the information, +# centos-art.sh script uses autogenerated values as default ---when +# possible--- taking as reference SVG file path. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_updateMetadata { + + local NAM='' + local URL='' + local KEYS='' + local FILE='' + local COUNT=0 + local FILES='' + local INSTANCE='' + local TEMPLATES='' + local -a TITLE + local -a VALUE + local -a PATTERN + local -a PATTERN_MSG + local -a MARKER + local -a DEFAULT + + # Define template file name. + TEMPLATE="${CLI_BASEDIR}/Functions/Svg/Config/tpl_forMetadata.sed" + + # Check template file existence. + cli_checkFiles $TEMPLATE 'f' + + # Define titles using Inkscape 0.46 metadata definition as reference. + TITLE[0]="`gettext "Title"`" + TITLE[1]="`gettext "Date"`" + TITLE[2]="`gettext "Creator"`" + TITLE[3]="`gettext "Rights"`" + TITLE[4]="`gettext "Publisher"`" + TITLE[5]="`gettext "Identifier"`" + TITLE[6]="`gettext "Source"`" + TITLE[7]="`gettext "Relation"`" + TITLE[8]="`gettext "Language"`" + TITLE[9]="`gettext "Keywords"`" + TITLE[10]="`gettext "Coverage"`" + TITLE[11]="`gettext "Description"`" + TITLE[12]="`gettext "Contributor"`" + + # Define markers. These values are used inside template. + MARKER[0]='=TITLE=' + MARKER[1]='=DATE=' + MARKER[2]='=CREATOR=' + MARKER[3]='=RIGHTS=' + MARKER[4]='=PUBLISHER=' + MARKER[5]='=IDENTIFIER=' + MARKER[6]='=SOURCE=' + MARKER[7]='=RELATION=' + MARKER[8]='=LANGUAGE=' + MARKER[9]='=KEYWORDS=' + MARKER[10]='=COVERAGE=' + MARKER[11]='=DESCRIPTION=' + MARKER[12]='=CONTRIBUTOR=' + + # Define pattern. These values are used as regular + # expression patterns for user's input further verification. + PATTERN[0]='^([[:alnum:] _-.]+)?$' + PATTERN[1]='^([0-9]{4}-(0[1-9]|1[0-2])-([0-2][1-9]|3[0-1]))?$' + PATTERN[2]=${PATTERN[0]} + PATTERN[3]=${PATTERN[0]} + PATTERN[4]=${PATTERN[0]} + PATTERN[5]='^(https://projects.centos.org/svn/artwork/[[:alnum:]/._-]+)?$' + PATTERN[6]=${PATTERN[5]} + PATTERN[7]=${PATTERN[5]} + PATTERN[8]='^([a-z]{2}(_[A-Z]{2})?)?$' + PATTERN[9]=${PATTERN[0]} + PATTERN[10]=${PATTERN[0]} + PATTERN[11]=${PATTERN[0]} + PATTERN[12]=${PATTERN[0]} + + # Define pattern message. These values are used as output + # message when user's input doesn't match the related pattern. + PATTERN_MSG[0]="`gettext "Try using alphanumeric characters."`" + PATTERN_MSG[1]="`gettext "Try using 'YYYY-MM-DD' date format."`" + PATTERN_MSG[2]=${PATTERN_MSG[0]} + PATTERN_MSG[3]=${PATTERN_MSG[0]} + PATTERN_MSG[4]=${PATTERN_MSG[0]} + PATTERN_MSG[5]="`gettext "Only locations under https://projects.centos.ort/svn/artwork are supported."`" + PATTERN_MSG[6]=${PATTERN_MSG[0]} + PATTERN_MSG[7]=${PATTERN_MSG[0]} + PATTERN_MSG[8]="`gettext "Try using 'LL' or 'LL_CC' locale format."`" + PATTERN_MSG[9]=${PATTERN_MSG[0]} + PATTERN_MSG[10]=${PATTERN_MSG[0]} + PATTERN_MSG[11]=${PATTERN_MSG[0]} + PATTERN_MSG[12]=${PATTERN_MSG[0]} + + # Define common default values. + DEFAULT[1]=$(date +%Y-%m-%d) + DEFAULT[2]="The CentOS Project" + DEFAULT[3]=${DEFAULT[2]} + DEFAULT[4]=${DEFAULT[2]} + DEFAULT[8]=$(cli_getCurrentLocale) + DEFAULT[10]=${DEFAULT[2]} + + # Initialize values using user's input. + cli_printMessage "`gettext "Enter metadata information you want to apply:"`" + while [[ $COUNT -ne ${#TITLE[*]} ]];do + + # Request value. + cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' + read VALUE[$COUNT] + + # Sanitate values to exclude characters that could + # introduce possible markup malformations to final SVG files. + until [[ ${VALUE[$COUNT]} =~ ${PATTERN[$COUNT]} ]];do + cli_printMessage "${PATTERN_MSG[$COUNT]}" + cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' + read VALUE[$COUNT] + done + + # Set default value to empty values. + if [[ ${VALUE[$COUNT]} == '' ]];then + VALUE[$COUNT]=${DEFAULT[$COUNT]} + fi + + # Increase counter. + COUNT=$(($COUNT + 1)) + + done + + # Build list of files to process. + FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}.*\.(svgz|svg)") + + # Set action preamble. + cli_printActionPreamble "${FILES}" '' '' + + # Process list of scalable vector graphics. + for FILE in $FILES;do + + # Output action message. + cli_printMessage $FILE 'AsUpdatingLine' + + # Build title from file path. + NAM=$(basename "$FILE") + + # Build url from file path. + URL=$(echo $FILE | sed 's!/home/centos!https://projects.centos.org/svn!') + + # Build keywords from file path. Do not include filename, it + # is already on title. + KEYS=$(dirname "$FILE" | cut -d/ -f6- | tr '/' '\n') + + # Build keywords using SVG standard format. Note that this + # information is inserted inside template file. The + # template file is a replacement set of sed commands + # so we need to escape the new line of each line using one + # backslash (\). As we are doing this inside bash, it is + # required to escape the backslash with another backslash so + # one of them passes literally to template file. + KEYS=$(\ + for KEY in $KEYS;do + echo " $KEY\\" + done) + + # Redefine template instance file name. + INSTANCE=$(cli_getTemporalFile $TEMPLATE) + + # Create template instance. + cp $TEMPLATE $INSTANCE + + # Check template instance. We cannot continue if the template + # instance couldn't be created. + cli_checkFiles $INSTANCE 'f' + + # Reset counter. + COUNT=0 + + while [[ $COUNT -ne ${#TITLE[*]} ]];do + + # Redefine file-specific values. + if [[ $COUNT -eq 0 ]];then + VALUE[$COUNT]=$NAM + elif [[ $COUNT -eq 5 ]];then + VALUE[$COUNT]=$URL + elif [[ $COUNT -eq 6 ]];then + VALUE[$COUNT]=$URL + elif [[ $COUNT -eq 7 ]];then + VALUE[$COUNT]=$URL + elif [[ $COUNT -eq 9 ]];then + VALUE[$COUNT]=$KEYS + fi + + # Apply translation marker replacement. + if [[ $COUNT -eq 9 ]];then + sed -i -r "/${MARKER[$COUNT]}/c\\${VALUE[$COUNT]}" $INSTANCE + else + sed -i -r "s!${MARKER[$COUNT]}!${VALUE[$COUNT]}!g" $INSTANCE + fi + + # Increase counter. + COUNT=$(($COUNT + 1)) + + done + + # Sanitate template instance. + sed -i -r -e 's/>$/>\\/g' $INSTANCE + + # Apply template instance to scalable vector graphic + # file. + sed -i -f $INSTANCE $FILE + + # Remove template instance. + if [[ -f $INSTANCE ]];then + rm $INSTANCE + fi + + # Sanitate scalable vector graphic. + sed -i -r '/^[[:space:]]*$/d' $FILE + + done + +} diff --git a/Functions/Svg/svg_vacuumDefs.sh b/Functions/Svg/svg_vacuumDefs.sh new file mode 100755 index 0000000..d69f438 --- /dev/null +++ b/Functions/Svg/svg_vacuumDefs.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# svg_vacuumDefs.sh -- This function removes all unused items from the +# defs section of the SVG file massively. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function svg_vacuumDefs { + + local FILE='' + local FILES='' + + # Build list of files to process. + FILES=$(cli_getFilesList "${ACTIONVAL}" "${FLAG_FILTER}.*\.(svgz|svg)") + + # Set action preamble. + cli_printActionPreamble "${FILES}" '' '' + + # Process list of files. + for FILE in $FILES;do + + # Output action message. + cli_printMessage "$FILE" 'AsUpdatingLine' + + # Vacuum unused svg definition using inkscape. + inkscape --vacuum-defs $FILE &> /dev/null + + done + +} diff --git a/Functions/cli.sh b/Functions/cli.sh new file mode 100644 index 0000000..e90b804 --- /dev/null +++ b/Functions/cli.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# +# cli.sh -- This function initiates centos-art command-line interface. +# Variables defined in this function are accesible by all other +# functions. The cli function is the first script executed by +# centos-art command-line onces invoked. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli { + + # Initialize global variables. + local FUNCNAM='' + local FUNCDIR='' + local FUNCDIRNAM='' + local FUNCSCRIPT='' + local FUNCCONFIG='' + local ARGUMENTS='' + + # Initialize default value to filter flag. The filter flag + # (--filter) is used mainly to reduce the number of files to + # process. The value of this variable is interpreted as + # egrep-posix regular expression. By default, everything matches. + local FLAG_FILTER='.+' + + # Initialize default value to verbosity flag. The verbosity flag + # (--quiet) controls whether centos-art.sh script prints messages + # or not. By default, all messages are printed out. + local FLAG_QUIET='false' + + # Initialize default value to answer flag. The answer flag + # (--answer) controls whether centos-art.sh script does or does + # not pass confirmation request points. By default, it doesn't. + local FLAG_ANSWER='false' + + # Initialize default value to don't commit changes flag. The don't + # commit changes flag (--dont-commit-changes) controls whether + # centos-art.sh script syncronizes changes between the central + # repository and the working copy. By default, it does. + local FLAG_DONT_COMMIT_CHANGES='false' + + # Redefine ARGUMENTS variable using current positional parameters. + cli_doParseArgumentsReDef "$@" + + # Define function directory (FUNCDIR). The directory path where + # functionalities are stored inside the repository. + FUNCDIR=${CLI_BASEDIR}/Functions + + # Define function name (FUNCNAM) variable from first command-line + # argument. As convenction we use the first argument to determine + # the exact name of functionality to call. + FUNCNAM=$(cli_getRepoName "$1" 'f') + + # Define function directory. + FUNCDIRNAM=$(cli_getRepoName "$FUNCNAM" 'd') + + # Define function file name. + FUNCSCRIPT=${FUNCDIR}/${FUNCDIRNAM}/${FUNCNAM}.sh + + # Check function script execution rights. + cli_checkFiles $FUNCSCRIPT 'x' + + # Define function configuration directory. The function + # configuration directory is used to store functionality's + # related files. + FUNCCONFIG=${FUNCDIR}/${FUNCDIRNAM}/Config + + # Remove the first argument passed to centos-art.sh command-line + # in order to build optional arguments inside functionalities. We + # start counting from second argument (inclusive) on. + shift 1 + + # Redefine ARGUMENTS using current positional parameters. + cli_doParseArgumentsReDef "$@" + + # Define default text editors used by centos-art.sh script. + if [[ ! "$EDITOR" =~ '/usr/bin/(vim|emacs|nano)' ]];then + EDITOR='/usr/bin/vim' + fi + + # Check text editor execution rights. + cli_checkFiles $EDITOR 'x' + + # Go for function initialization. Keep the cli_getFunctions + # function calling after all variables and arguments definitions. + cli_getFunctions + +} diff --git a/Functions/cli_checkFiles.sh b/Functions/cli_checkFiles.sh new file mode 100644 index 0000000..88c8bff --- /dev/null +++ b/Functions/cli_checkFiles.sh @@ -0,0 +1,127 @@ +#!/bin/bash +# +# cli_checkFiles.sh -- This function standardizes file verifications +# inside centos-art.sh script. If file verification fails in anyway, +# centos-art.sh script complains about it and ends up script +# execution. +# +# Usage: +# +# cli_checkFiles FILE [TYPE] +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_checkFiles { + + local FILE='' + local FILES="$1" + local TYPE="$2" + local MESSAGE='' + + # Check number of paramaters passed to cli_checkFiles function. At + # least one argument should be passed. + if [[ $# -lt 1 ]];then + cli_printMessage "${FUNCNAME}: `gettext "You need to provide one argument at least."`" 'AsErrorLine' + cli_printMessage "$(caller)" "AsToKnowMoreLine" + fi + + for FILE in $FILES;do + + # Check value passed as file to cli_checkFiles function. The + # file value cannot be empty nor have extrange values. + cli_checkPathComponent "$FILE" '--default' + + # Perform file verification using FILE and TYPE variables. + case $TYPE in + + d | directory ) + # File exists and is a directory + if [[ ! -d $FILE ]];then + MESSAGE="`eval_gettext "The directory \\\"\\\$FILE\\\" doesn't exist."`" + fi + ;; + + f | regular-file ) + # File exists and is a regular file. + if [[ ! -f $FILE ]];then + MESSAGE="`eval_gettext "The file \\\"\\\$FILE\\\" is not a regular file."`" + fi + ;; + + h | symbolic-link ) + # File exists and is a symbolic link. + if [[ ! -h $FILE ]];then + MESSAGE="`eval_gettext "The file \\\"\\\$FILE\\\" is not a symbolic link."`" + fi + ;; + + x | execution ) + # To exist, file should be executable. + if [[ ! -x $FILE ]];then + MESSAGE="`eval_gettext "The file \\\"\\\$FILE\\\" is not executable."`" + fi + ;; + + fh ) + # To exist, file should be a regular file or a symbolic link. + if [[ ! -f $FILE ]];then + if [[ ! -h $FILE ]];then + MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist."`" + fi + fi + ;; + + fd ) + # To exist, file should be a regular file or a directory. + if [[ ! -f $FILE ]];then + if [[ ! -d $FILE ]];then + MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist."`" + fi + fi + ;; + + isInWorkingCopy ) + # To exist, file should be inside the working copy. + if [[ ! $FILE =~ "^/home/centos/artwork/.+$" ]];then + MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist inside the working copy."`" + fi + ;; + + * ) + # File exists. + if [[ ! -a $FILE ]];then + MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist."`" + fi + + esac + + done + + # If file verification fails in anyway, output message information + # and end up script execution. Otherwise, continue with script + # normal flow. + if [[ "$MESSAGE" != '' ]];then + cli_printMessage "$MESSAGE" "AsErrorLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" + fi + +} diff --git a/Functions/cli_checkPathComponent.sh b/Functions/cli_checkPathComponent.sh new file mode 100755 index 0000000..673c068 --- /dev/null +++ b/Functions/cli_checkPathComponent.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# +# cli_checkPathComponent.sh -- This function checks parts/components +# from repository paths. Generally, the path information is passed to +# the function's first positional argument and the part/component we +# want to check is passed to the function's second positional +# argument. If the second argument is not passed, then the first +# argument is assumed to be the part/component we want to check, and +# the action value (ACTIONVAL) variable is used instead as source path +# information. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_checkPathComponent { + + local -a PATTERNS + local LOCATION='' + local OPTION='' + local MESSAGE='' + + # Define location which we retrive information from. + if [[ "$#" -eq 1 ]];then + LOCATION="$ACTIONVAL" + OPTION="$1" + elif [[ "$#" -eq 2 ]];then + LOCATION="$1" + OPTION="$2" + else + cli_printMessage "${FUNCNAME}: `gettext "Invalid arguments."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Define patterns. + PATTERNS[0]="^.+/$(cli_getPathComponent "${LOCATION}" '--release-pattern')/.*$" + PATTERNS[1]=$(cli_getPathComponent "${LOCATION}" '--release-architecture') + PATTERNS[2]=$(cli_getPathComponent "${LOCATION}" '--release-theme') + + # Identify which part of the release we want to output. + case "$OPTION" in + + '--release' ) + if [[ $LOCATION =~ ${PATTERN[0]} ]];then + MESSAGE="`eval_gettext "The release \\\`\\\$LOCATION' is not valid."`" + fi + ;; + + '--architecture' ) + if [[ $LOCATION =~ ${PATTERN[1]} ]];then + MESSAGE="`eval_gettext "The architecture \\\`\\\$LOCATION' is not valid."`" + fi + ;; + + '--theme' ) + if [[ $LOCATION =~ ${PATTERN[2]} ]];then + MESSAGE="`eval_gettext "The theme \\\`\\\$LOCATION' is not valid."`" + fi + ;; + + '--default' | * ) + if [[ $LOCATION == '' ]] \ + || [[ $LOCATION =~ '(\.\.(/)?)' ]] \ + || [[ ! $LOCATION =~ '^[A-Za-z0-9\.:/_-]+$' ]]; then + MESSAGE="`eval_gettext "The value \\\`\\\$LOCATION' is not valid."`" + fi + ;; + esac + + # Output message. + if [[ $MESSAGE != '' ]];then + cli_printMessage "$MESSAGE" 'AsErrorLine' + cli_printMessage "$(caller)" "AsToKnowMoreLine" + fi + +} diff --git a/Functions/cli_checkRepoDirSource.sh b/Functions/cli_checkRepoDirSource.sh new file mode 100755 index 0000000..666dc17 --- /dev/null +++ b/Functions/cli_checkRepoDirSource.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# +# cli_checkRepoDirSource.sh -- This function provides input validation +# to repository entries considered as source locations. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_checkRepoDirSource { + + # Check action value to be sure strage characters are kept far + # from path provided. + cli_checkPathComponent "$ACTIONVAL" '--default' + + # Redefine source value to build repository absolute path from + # repository top level on. As we are removing + # /home/centos/artwork/ from all centos-art.sh output (in order to + # save horizontal output space), we need to be sure that all + # strings begining with trunk/..., branches/..., and tags/... use + # the correct absolute path. That is, you can refer trunk's + # entries using both /home/centos/artwork/trunk/... or just + # trunk/..., the /home/centos/artwork/ part is automatically added + # here. + if [[ $ACTIONVAL =~ '^(trunk|branches|tags)' ]];then + ACTIONVAL=${HOME}/artwork/$ACTIONVAL + fi + + # Re-define source value to build repository absolute path from + # repository relative paths. This let us to pass repository + # relative paths as source value. Passing relative paths as + # source value may save us some typing; specially if we are stood + # a few levels up from the location we want to refer to as source + # value. There is no need to pass the absolute path to it, just + # refere it relatively. + if [[ -d ${ACTIONVAL} ]];then + + # Add directory to the top of the directory stack. + pushd "$ACTIONVAL" > /dev/null + + # Check directory existence inside the repository. + if [[ $(pwd) =~ "^${HOME}/artwork" ]];then + # Re-define source value using absolute path. + ACTIONVAL=$(pwd) + else + cli_printMessage "`eval_gettext "The location \\\`\\\$ACTIONVAL' is not valid."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Remove directory from the directory stack. + popd > /dev/null + + elif [[ -f ${ACTIONVAL} ]];then + + # Add directory to the top of the directory stack. + pushd "$(dirname "$ACTIONVAL")" > /dev/null + + # Check directory existence inside the repository. + if [[ $(pwd) =~ "^${HOME}/artwork" ]];then + # Re-define source value using absolute path. + ACTIONVAL=$(pwd)/$(basename "$ACTIONVAL") + else + cli_printMessage "`eval_gettext "The location \\\`\\\$ACTIONVAL' is not valid."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Remove directory from the directory stack. + popd > /dev/null + + else + + # At this there is no existent working copy entry, nor a valid + # url. The source value can only be considered as such if it + # is an existent working copy or valid url. So, print a + # message and stop script execution. + cli_printMessage "`eval_gettext "The location \\\`\\\$ACTIONVAL' is not valid."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + + fi + +} diff --git a/Functions/cli_checkRepoDirTarget.sh b/Functions/cli_checkRepoDirTarget.sh new file mode 100755 index 0000000..7d92673 --- /dev/null +++ b/Functions/cli_checkRepoDirTarget.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# +# cli_checkRepoDirTarget.sh -- This function provides input validation +# to repository entries considered as target location. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_checkRepoDirTarget { + + # Check target value before making an absolute path from it. + cli_checkPathComponent "$FLAG_TO" '--repo-directory' + + # Redefine target value to build repository absolute path from + # repository top level on. As we are removing + # /home/centos/artwork/ from all centos-art.sh output (in order to + # save horizontal output space), we need to be sure that all + # strings begining with trunk/..., branches/..., and tags/... use + # the correct absolute path. That is, you can refer trunk's + # entries using both /home/centos/artwork/trunk/... or just + # trunk/..., the /home/centos/artwork/ part is automatically added + # here. + if [[ $FLAG_TO =~ '^(trunk|branches|tags)/.+$' ]];then + FLAG_TO=${HOME}/artwork/$FLAG_TO + fi + + # Check target value. + if [[ -a ${FLAG_TO} ]];then + + # At this point target value does existent as working copy + # entry. We don't use existent locations as target. So, print + # a message and stop script execution. + cli_printMessage "`eval_gettext "The location \\\`\\\$FLAG_TO' already exists."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + + else + + # At this point existent locations inside working copy and + # invalid urls have been discarded. Assume a new target + # location has being specified. So, build the absolute path + # for it. + + # Add directory to the top of the directory stack. + pushd "$(dirname "$FLAG_TO")" > /dev/null + + # Check directory existence inside the repository. + if [[ $(pwd) =~ "^${HOME}/artwork" ]];then + # Re-define target value using absolute path. + FLAG_TO=$(pwd)/$(basename "$FLAG_TO") + fi + + # Remove directory from the directory stack. + popd > /dev/null + + # Verify target location. It is required that target location + # points to an entry under (trunk|branches|tags)/Identity/... + # directory structure *only*. Remember that Identity parent + # directory structure is the reference used to create parallel + # directories (i.e., documentation, configuration scripts, + # translations, etc.). We don't manipulate parallel + # directories with path ---or any other--- functionality + # directly. Consider manipulation of parallel directories as + # a consequence of a previous manipulation of Identity parent + # directory structure. + if [[ ! ${FLAG_TO} =~ '^.+/(trunk|branches|tags)/Identity/.+$' ]];then + cli_printMessage "`eval_gettext "cannot create \\\`\\\$FLAG_TO': It isn't an identity directory structure."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + fi + +} diff --git a/Functions/cli_commitRepoChanges.sh b/Functions/cli_commitRepoChanges.sh new file mode 100755 index 0000000..792d7d0 --- /dev/null +++ b/Functions/cli_commitRepoChanges.sh @@ -0,0 +1,146 @@ +#!/bin/bash +# +# cli_commitRepoChanges.sh -- This function realizes a subversion +# commit command agains the workgin copy in order to send local +# changes up to central repository. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_commitRepoChanges { + + # Verify `--dont-commit-changes' option. + if [[ $FLAG_DONT_COMMIT_CHANGES == 'true' ]];then + return + fi + + local -a FILES + local -a INFO + local -a FILESNUM + local COUNT=0 + local STATUSOUT='' + local PREDICATE='' + local CHNGTOTAL=0 + local LOCATIONS='' + + # Define source location the subversion status action will take + # place on. If arguments are provided use them as srouce location. + # Otherwise use action value as default source location. + if [[ "$@" != '' ]];then + LOCATIONS="$@" + else + LOCATIONS="$ACTIONVAL" + fi + + # Verify locations existence. It shoud exist as regular file or + # directory inside the repository working copy. + cli_checkFiles "$LOCATIONS" 'fd' + cli_checkFiles "$LOCATIONS" 'isInWorkingCopy' + + # Outout separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Check working copy. + cli_printMessage "`gettext "Checking changes in the working copy"`" 'AsResponseLine' + STATUSOUT=$(svn status ${LOCATIONS}) + + # Outout separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Define path fo files considered recent modifications from + # working copy up to central repository. + FILES[0]=$(echo "$STATUSOUT" | egrep "^M.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[1]=$(echo "$STATUSOUT" | egrep "^\?.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[2]=$(echo "$STATUSOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[3]=$(echo "$STATUSOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + + # Define description of files considered recent modifications from + # working copy up to central repository. + INFO[0]="`gettext "Modified"`" + INFO[1]="`gettext "Unversioned"`" + INFO[2]="`gettext "Deleted"`" + INFO[3]="`gettext "Added"`" + + while [[ $COUNT -ne ${#FILES[*]} ]];do + + # Define total number of files. Avoid counting empty line. + if [[ "${FILES[$COUNT]}" == '' ]];then + FILESNUM[$COUNT]=0 + else + FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l) + fi + + # Calculate total amount of changes. + CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]})) + + # Build report predicate. Use report predicate to show any + # information specific to the number of files found. For + # example, you can use this section to show warning messages, + # notes, and so on. By default we use the word `file' or + # `files' at ngettext's consideration followed by change + # direction. + PREDICATE[$COUNT]=`ngettext "file from the repository" \ + "files from the repository" $((${FILESNUM[$COUNT]} + 1))` + + # Output report line. + cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" 'AsRegularLine' + + # Increase counter. + COUNT=$(($COUNT + 1)) + + done + + # In case new unversioned files exist, ask the user to add them + # into the repository. This may happen when new documentation + # entries are created. + if [[ ${FILESNUM[1]} -gt 0 ]];then + + # Outout separator line. + cli_printMessage '-' 'AsSeparatorLine' + + cli_printMessage "`ngettext "The following file is unversioned" \ + "The following files are unversioned" ${FILESNUM[1]}`:" + for FILE in ${FILES[1]};do + cli_printMessage $FILE 'AsResponseLine' + done + cli_printMessage "`ngettext "Do you want to add it now?" \ + "Do you want to add them now?" ${FILESNUM[2]}`" 'AsYesOrNoRequestLine' + svn add ${FILES[1]} --quiet + fi + + # Check total amount of changes and, if any, check differences and + # commit them up to central repository. + if [[ $CHNGTOTAL -gt 0 ]];then + + # Outout separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Verify changes. + cli_printMessage "`gettext "Do you want to see changes now?"`" "AsYesOrNoRequestLine" + svn diff ${FILES[*]} | less + + # Commit changes. + cli_printMessage "`gettext "Do you want to commit changes now?"`" "AsYesOrNoRequestLine" + svn commit ${FILES[*]} + + fi + +} diff --git a/Functions/cli_doParseArguments.sh b/Functions/cli_doParseArguments.sh new file mode 100755 index 0000000..b6ad3d8 --- /dev/null +++ b/Functions/cli_doParseArguments.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# cli_doParseArguments.sh -- This function redefines arguments +# (ARGUMENTS) global variable using getopt(1) output. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_doParseArguments { + + # Reset positional parameters using optional arguments. + eval set -- "$ARGUMENTS" + + # Parse optional arguments using getopt. + ARGUMENTS=$(getopt -o "$ARGSS" -l "$ARGSL" -n $CLI_PROGRAM -- "$@") + + # Be sure getout parsed arguments successfully. + if [[ $? != 0 ]]; then + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Functions/cli_doParseArgumentsReDef.sh b/Functions/cli_doParseArgumentsReDef.sh new file mode 100755 index 0000000..e163b8c --- /dev/null +++ b/Functions/cli_doParseArgumentsReDef.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# cli_doParseArgumentsReDef.sh -- This function initiates/reset +# positional parameters based on `$@' variable. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_doParseArgumentsReDef { + + local ARG + + # Clean up arguments global variable. + ARGUMENTS='' + + # Fill up arguments global variable with current positional + # parameter information. To avoid interpretation problems, use + # single quotes to enclose each argument (ARG) from command-line + # idividually. + for ARG in "$@"; do + ARGUMENTS="$ARGUMENTS '$ARG'" + done + +} diff --git a/Functions/cli_getCopyrightInfo.sh b/Functions/cli_getCopyrightInfo.sh new file mode 100755 index 0000000..b376890 --- /dev/null +++ b/Functions/cli_getCopyrightInfo.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# cli_getCopyrightInfo.sh -- This function outputs the copyright +# information of content produced by the centos-art command-line +# interface. +# +# As I understand, the copyright exists to make people create more. +# The copyright gives creators the legal power over their creations +# and so the freedom to distribute them under the ethical terms the +# creator considers better. +# +# At this moment I don't feel very sure about this legal affairs, but +# need to decide what copyright information the centos-art will +# output. So, I'm taking the wiki (wiki.centos.org) copyright +# information as reference. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getCopyrightInfo { + + case "$1" in + + '--license' ) + + # Output default license name used by all image-based + # creations inside CentOS Artwork Repository. + echo "Creative Common Attribution-ShareAlike 3.0" + ;; + + '--license-url' ) + + # Ouput default license url used by all image-based + # creations inside CentOS Artwork Repository. + echo "http://creativecommons.org/licenses/by-sa/3.0/" + ;; + + '--copyright-year' ) + + # Output default copyright year. + date +%Y + ;; + + '--copyright-holder' | * ) + + # Output default copyright holder. + echo "The CentOS Project" + ;; + + esac + +} diff --git a/Functions/cli_getCountryCodes.sh b/Functions/cli_getCountryCodes.sh new file mode 100755 index 0000000..d32822d --- /dev/null +++ b/Functions/cli_getCountryCodes.sh @@ -0,0 +1,277 @@ +#!/bin/bash +# +# cli_getCountryCodes.sh -- This function outputs a list with country +# codes as defined in ISO3166 standard. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getCountryCodes { + + local FILTER="$(echo $1 | cut -d_ -f2)" + + COUNTRYCODES='AD + AE + AF + AG + AI + AL + AM + AN + AO + AQ + AR + AS + AT + AU + AW + AZ + BA + BB + BD + BE + BF + BG + BH + BI + BJ + BM + BN + BO + BR + BS + BT + BV + BW + BY + BZ + CA + CC + CD + CF + CG + CH + CI + CK + CL + CM + CN + CO + CR + CS + CU + CV + CX + CY + CZ + DE + DJ + DK + DM + DO + DZ + EC + EE + EG + EH + ER + ES + ET + FI + FJ + FK + FM + FO + FR + GA + GB + GD + GE + GF + GH + GI + GL + GM + GN + GP + GQ + GR + GS + GT + GU + GW + GY + HK + HM + HN + HR + HT + HU + ID + IE + IL + IN + IO + IQ + IR + IS + IT + JM + JO + JP + KE + KG + KH + KI + KM + KN + KP + KR + KW + KY + KZ + LA + LB + LC + LI + LK + LR + LS + LT + LU + LV + LY + MA + MC + MD + MG + MH + MK + ML + MM + MN + MO + MP + MQ + MR + MS + MT + MU + MV + MW + MX + MY + MZ + NA + NC + NE + NF + NG + NI + NL + NO + NP + NR + NU + NZ + OM + PA + PE + PF + PG + PH + PK + PL + PM + PN + PR + PS + PT + PW + PY + QA + RE + RO + RU + RW + SA + SB + SC + SD + SE + SG + SH + SI + SJ + SK + SL + SM + SN + SO + SR + ST + SV + SY + SZ + TC + TD + TF + TG + TH + TJ + TK + TL + TM + TN + TO + TR + TT + TV + TW + TZ + UA + UG + UM + US + UY + UZ + VA + VC + VE + VG + VI + VN + VU + WF + WS + YE + YT + ZA + ZM + ZW' + + if [[ $FILTER != '' ]];then + echo $COUNTRYCODES | egrep "$FILTER" + else + echo "$COUNTRYCODES" + fi + +} diff --git a/Functions/cli_getCountryName.sh b/Functions/cli_getCountryName.sh new file mode 100755 index 0000000..4c82e00 --- /dev/null +++ b/Functions/cli_getCountryName.sh @@ -0,0 +1,759 @@ +#!/bin/bash +# +# cli_getCountryName.sh -- This function reads one language locale +# code in the format LL_CC and outputs the name of its related +# country. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getCountryName { + + local LOCALECODE="$(echo $1 | cut -d_ -f2)" + local COUNTRYNAME="" + + case $LOCALECODE in + + 'AD' ) + COUNTRYNAME="`gettext "Andorra"`" + ;; + 'AE' ) + COUNTRYNAME="`gettext "United Arab Emirates"`" + ;; + 'AF' ) + COUNTRYNAME="`gettext "Afghanistan"`" + ;; + 'AG' ) + COUNTRYNAME="`gettext "Antigua and Barbuda"`" + ;; + 'AI' ) + COUNTRYNAME="`gettext "Anguilla"`" + ;; + 'AL' ) + COUNTRYNAME="`gettext "Albania"`" + ;; + 'AM' ) + COUNTRYNAME="`gettext "Armenia"`" + ;; + 'AN' ) + COUNTRYNAME="`gettext "Netherlands Antilles"`" + ;; + 'AO' ) + COUNTRYNAME="`gettext "Angola"`" + ;; + 'AQ' ) + COUNTRYNAME="`gettext "Antarctica"`" + ;; + 'AR' ) + COUNTRYNAME="`gettext "Argentina"`" + ;; + 'AS' ) + COUNTRYNAME="`gettext "Samoa (American)"`" + ;; + 'AT' ) + COUNTRYNAME="`gettext "Austria"`" + ;; + 'AU' ) + COUNTRYNAME="`gettext "Australia"`" + ;; + 'AW' ) + COUNTRYNAME="`gettext "Aruba"`" + ;; + 'AZ' ) + COUNTRYNAME="`gettext "Azerbaijan"`" + ;; + 'BA' ) + COUNTRYNAME="`gettext "Bosnia and Herzegovina"`" + ;; + 'BB' ) + COUNTRYNAME="`gettext "Barbados"`" + ;; + 'BD' ) + COUNTRYNAME="`gettext "Bangladesh"`" + ;; + 'BE' ) + COUNTRYNAME="`gettext "Belgium"`" + ;; + 'BF' ) + COUNTRYNAME="`gettext "Burkina Faso"`" + ;; + 'BG' ) + COUNTRYNAME="`gettext "Bulgaria"`" + ;; + 'BH' ) + COUNTRYNAME="`gettext "Bahrain"`" + ;; + 'BI' ) + COUNTRYNAME="`gettext "Burundi"`" + ;; + 'BJ' ) + COUNTRYNAME="`gettext "Benin"`" + ;; + 'BM' ) + COUNTRYNAME="`gettext "Bermuda"`" + ;; + 'BN' ) + COUNTRYNAME="`gettext "Brunei"`" + ;; + 'BO' ) + COUNTRYNAME="`gettext "Bolivia"`" + ;; + 'BR' ) + COUNTRYNAME="`gettext "Brazil"`" + ;; + 'BS' ) + COUNTRYNAME="`gettext "Bahamas"`" + ;; + 'BT' ) + COUNTRYNAME="`gettext "Bhutan"`" + ;; + 'BV' ) + COUNTRYNAME="`gettext "Bouvet Island"`" + ;; + 'BW' ) + COUNTRYNAME="`gettext "Botswana"`" + ;; + 'BY' ) + COUNTRYNAME="`gettext "Belarus"`" + ;; + 'BZ' ) + COUNTRYNAME="`gettext "Belize"`" + ;; + 'CA' ) + COUNTRYNAME="`gettext "Canada"`" + ;; + 'CC' ) + COUNTRYNAME="`gettext "Cocos (Keeling) Islands"`" + ;; + 'CD' ) + COUNTRYNAME="`gettext "Congo (Dem. Rep.)"`" + ;; + 'CF' ) + COUNTRYNAME="`gettext "Central African Rep."`" + ;; + 'CG' ) + COUNTRYNAME="`gettext "Congo (Rep.)"`" + ;; + 'CH' ) + COUNTRYNAME="`gettext "Switzerland"`" + ;; + 'CI' ) + COUNTRYNAME="`gettext "Co^te d'Ivoire"`" + ;; + 'CK' ) + COUNTRYNAME="`gettext "Cook Islands"`" + ;; + 'CL' ) + COUNTRYNAME="`gettext "Chile"`" + ;; + 'CM' ) + COUNTRYNAME="`gettext "Cameroon"`" + ;; + 'CN' ) + COUNTRYNAME="`gettext "China"`" + ;; + 'CO' ) + COUNTRYNAME="`gettext "Colombia"`" + ;; + 'CR' ) + COUNTRYNAME="`gettext "Costa Rica"`" + ;; + 'CS' ) + COUNTRYNAME="`gettext "Serbia and Montenegro"`" + ;; + 'CU' ) + COUNTRYNAME="`gettext "Cuba"`" + ;; + 'CV' ) + COUNTRYNAME="`gettext "Cape Verde"`" + ;; + 'CX' ) + COUNTRYNAME="`gettext "Christmas Island"`" + ;; + 'CY' ) + COUNTRYNAME="`gettext "Cyprus"`" + ;; + 'CZ' ) + COUNTRYNAME="`gettext "Czech Republic"`" + ;; + 'DE' ) + COUNTRYNAME="`gettext "Germany"`" + ;; + 'DJ' ) + COUNTRYNAME="`gettext "Djibouti"`" + ;; + 'DK' ) + COUNTRYNAME="`gettext "Denmark"`" + ;; + 'DM' ) + COUNTRYNAME="`gettext "Dominica"`" + ;; + 'DO' ) + COUNTRYNAME="`gettext "Dominican Republic"`" + ;; + 'DZ' ) + COUNTRYNAME="`gettext "Algeria"`" + ;; + 'EC' ) + COUNTRYNAME="`gettext "Ecuador"`" + ;; + 'EE' ) + COUNTRYNAME="`gettext "Estonia"`" + ;; + 'EG' ) + COUNTRYNAME="`gettext "Egypt"`" + ;; + 'EH' ) + COUNTRYNAME="`gettext "Western Sahara"`" + ;; + 'ER' ) + COUNTRYNAME="`gettext "Eritrea"`" + ;; + 'ES' ) + COUNTRYNAME="`gettext "Spain"`" + ;; + 'ET' ) + COUNTRYNAME="`gettext "Ethiopia"`" + ;; + 'FI' ) + COUNTRYNAME="`gettext "Finland"`" + ;; + 'FJ' ) + COUNTRYNAME="`gettext "Fiji"`" + ;; + 'FK' ) + COUNTRYNAME="`gettext "Falkland Islands"`" + ;; + 'FM' ) + COUNTRYNAME="`gettext "Micronesia"`" + ;; + 'FO' ) + COUNTRYNAME="`gettext "Faeroe Islands"`" + ;; + 'FR' ) + COUNTRYNAME="`gettext "France"`" + ;; + 'GA' ) + COUNTRYNAME="`gettext "Gabon"`" + ;; + 'GB' ) + COUNTRYNAME="`gettext "Britain (UK)"`" + ;; + 'GD' ) + COUNTRYNAME="`gettext "Grenada"`" + ;; + 'GE' ) + COUNTRYNAME="`gettext "Georgia"`" + ;; + 'GF' ) + COUNTRYNAME="`gettext "French Guiana"`" + ;; + 'GH' ) + COUNTRYNAME="`gettext "Ghana"`" + ;; + 'GI' ) + COUNTRYNAME="`gettext "Gibraltar"`" + ;; + 'GL' ) + COUNTRYNAME="`gettext "Greenland"`" + ;; + 'GM' ) + COUNTRYNAME="`gettext "Gambia"`" + ;; + 'GN' ) + COUNTRYNAME="`gettext "Guinea"`" + ;; + 'GP' ) + COUNTRYNAME="`gettext "Guadeloupe"`" + ;; + 'GQ' ) + COUNTRYNAME="`gettext "Equatorial Guinea"`" + ;; + 'GR' ) + COUNTRYNAME="`gettext "Greece"`" + ;; + 'GS' ) + COUNTRYNAME="`gettext "South Georgia and the South Sandwich Islands"`" + ;; + 'GT' ) + COUNTRYNAME="`gettext "Guatemala"`" + ;; + 'GU' ) + COUNTRYNAME="`gettext "Guam"`" + ;; + 'GW' ) + COUNTRYNAME="`gettext "Guinea-Bissau"`" + ;; + 'GY' ) + COUNTRYNAME="`gettext "Guyana"`" + ;; + 'HK' ) + COUNTRYNAME="`gettext "Hong Kong"`" + ;; + 'HM' ) + COUNTRYNAME="`gettext "Heard Island and McDonald Islands"`" + ;; + 'HN' ) + COUNTRYNAME="`gettext "Honduras"`" + ;; + 'HR' ) + COUNTRYNAME="`gettext "Croatia"`" + ;; + 'HT' ) + COUNTRYNAME="`gettext "Haiti"`" + ;; + 'HU' ) + COUNTRYNAME="`gettext "Hungary"`" + ;; + 'ID' ) + COUNTRYNAME="`gettext "Indonesia"`" + ;; + 'IE' ) + COUNTRYNAME="`gettext "Ireland"`" + ;; + 'IL' ) + COUNTRYNAME="`gettext "Israel"`" + ;; + 'IN' ) + COUNTRYNAME="`gettext "India"`" + ;; + 'IO' ) + COUNTRYNAME="`gettext "British Indian Ocean Territory"`" + ;; + 'IQ' ) + COUNTRYNAME="`gettext "Iraq"`" + ;; + 'IR' ) + COUNTRYNAME="`gettext "Iran"`" + ;; + 'IS' ) + COUNTRYNAME="`gettext "Iceland"`" + ;; + 'IT' ) + COUNTRYNAME="`gettext "Italy"`" + ;; + 'JM' ) + COUNTRYNAME="`gettext "Jamaica"`" + ;; + 'JO' ) + COUNTRYNAME="`gettext "Jordan"`" + ;; + 'JP' ) + COUNTRYNAME="`gettext "Japan"`" + ;; + 'KE' ) + COUNTRYNAME="`gettext "Kenya"`" + ;; + 'KG' ) + COUNTRYNAME="`gettext "Kyrgyzstan"`" + ;; + 'KH' ) + COUNTRYNAME="`gettext "Cambodia"`" + ;; + 'KI' ) + COUNTRYNAME="`gettext "Kiribati"`" + ;; + 'KM' ) + COUNTRYNAME="`gettext "Comoros"`" + ;; + 'KN' ) + COUNTRYNAME="`gettext "St Kitts and Nevis"`" + ;; + 'KP' ) + COUNTRYNAME="`gettext "Korea (North)"`" + ;; + 'KR' ) + COUNTRYNAME="`gettext "Korea (South)"`" + ;; + 'KW' ) + COUNTRYNAME="`gettext "Kuwait"`" + ;; + 'KY' ) + COUNTRYNAME="`gettext "Cayman Islands"`" + ;; + 'KZ' ) + COUNTRYNAME="`gettext "Kazakhstan"`" + ;; + 'LA' ) + COUNTRYNAME="`gettext "Laos"`" + ;; + 'LB' ) + COUNTRYNAME="`gettext "Lebanon"`" + ;; + 'LC' ) + COUNTRYNAME="`gettext "St Lucia"`" + ;; + 'LI' ) + COUNTRYNAME="`gettext "Liechtenstein"`" + ;; + 'LK' ) + COUNTRYNAME="`gettext "Sri Lanka"`" + ;; + 'LR' ) + COUNTRYNAME="`gettext "Liberia"`" + ;; + 'LS' ) + COUNTRYNAME="`gettext "Lesotho"`" + ;; + 'LT' ) + COUNTRYNAME="`gettext "Lithuania"`" + ;; + 'LU' ) + COUNTRYNAME="`gettext "Luxembourg"`" + ;; + 'LV' ) + COUNTRYNAME="`gettext "Latvia"`" + ;; + 'LY' ) + COUNTRYNAME="`gettext "Libya"`" + ;; + 'MA' ) + COUNTRYNAME="`gettext "Morocco"`" + ;; + 'MC' ) + COUNTRYNAME="`gettext "Monaco"`" + ;; + 'MD' ) + COUNTRYNAME="`gettext "Moldova"`" + ;; + 'MG' ) + COUNTRYNAME="`gettext "Madagascar"`" + ;; + 'MH' ) + COUNTRYNAME="`gettext "Marshall Islands"`" + ;; + 'MK' ) + COUNTRYNAME="`gettext "Macedonia"`" + ;; + 'ML' ) + COUNTRYNAME="`gettext "Mali"`" + ;; + 'MM' ) + COUNTRYNAME="`gettext "Myanmar (Burma)"`" + ;; + 'MN' ) + COUNTRYNAME="`gettext "Mongolia"`" + ;; + 'MO' ) + COUNTRYNAME="`gettext "Macao"`" + ;; + 'MP' ) + COUNTRYNAME="`gettext "Northern Mariana Islands"`" + ;; + 'MQ' ) + COUNTRYNAME="`gettext "Martinique"`" + ;; + 'MR' ) + COUNTRYNAME="`gettext "Mauritania"`" + ;; + 'MS' ) + COUNTRYNAME="`gettext "Montserrat"`" + ;; + 'MT' ) + COUNTRYNAME="`gettext "Malta"`" + ;; + 'MU' ) + COUNTRYNAME="`gettext "Mauritius"`" + ;; + 'MV' ) + COUNTRYNAME="`gettext "Maldives"`" + ;; + 'MW' ) + COUNTRYNAME="`gettext "Malawi"`" + ;; + 'MX' ) + COUNTRYNAME="`gettext "Mexico"`" + ;; + 'MY' ) + COUNTRYNAME="`gettext "Malaysia"`" + ;; + 'MZ' ) + COUNTRYNAME="`gettext "Mozambique"`" + ;; + 'NA' ) + COUNTRYNAME="`gettext "Namibia"`" + ;; + 'NC' ) + COUNTRYNAME="`gettext "New Caledonia"`" + ;; + 'NE' ) + COUNTRYNAME="`gettext "Niger"`" + ;; + 'NF' ) + COUNTRYNAME="`gettext "Norfolk Island"`" + ;; + 'NG' ) + COUNTRYNAME="`gettext "Nigeria"`" + ;; + 'NI' ) + COUNTRYNAME="`gettext "Nicaragua"`" + ;; + 'NL' ) + COUNTRYNAME="`gettext "Netherlands"`" + ;; + 'NO' ) + COUNTRYNAME="`gettext "Norway"`" + ;; + 'NP' ) + COUNTRYNAME="`gettext "Nepal"`" + ;; + 'NR' ) + COUNTRYNAME="`gettext "Nauru"`" + ;; + 'NU' ) + COUNTRYNAME="`gettext "Niue"`" + ;; + 'NZ' ) + COUNTRYNAME="`gettext "New Zealand"`" + ;; + 'OM' ) + COUNTRYNAME="`gettext "Oman"`" + ;; + 'PA' ) + COUNTRYNAME="`gettext "Panama"`" + ;; + 'PE' ) + COUNTRYNAME="`gettext "Peru"`" + ;; + 'PF' ) + COUNTRYNAME="`gettext "French Polynesia"`" + ;; + 'PG' ) + COUNTRYNAME="`gettext "Papua New Guinea"`" + ;; + 'PH' ) + COUNTRYNAME="`gettext "Philippines"`" + ;; + 'PK' ) + COUNTRYNAME="`gettext "Pakistan"`" + ;; + 'PL' ) + COUNTRYNAME="`gettext "Poland"`" + ;; + 'PM' ) + COUNTRYNAME="`gettext "St Pierre and Miquelon"`" + ;; + 'PN' ) + COUNTRYNAME="`gettext "Pitcairn"`" + ;; + 'PR' ) + COUNTRYNAME="`gettext "Puerto Rico"`" + ;; + 'PS' ) + COUNTRYNAME="`gettext "Palestine"`" + ;; + 'PT' ) + COUNTRYNAME="`gettext "Portugal"`" + ;; + 'PW' ) + COUNTRYNAME="`gettext "Palau"`" + ;; + 'PY' ) + COUNTRYNAME="`gettext "Paraguay"`" + ;; + 'QA' ) + COUNTRYNAME="`gettext "Qatar"`" + ;; + 'RE' ) + COUNTRYNAME="`gettext "Reunion"`" + ;; + 'RO' ) + COUNTRYNAME="`gettext "Romania"`" + ;; + 'RU' ) + COUNTRYNAME="`gettext "Russia"`" + ;; + 'RW' ) + COUNTRYNAME="`gettext "Rwanda"`" + ;; + 'SA' ) + COUNTRYNAME="`gettext "Saudi Arabia"`" + ;; + 'SB' ) + COUNTRYNAME="`gettext "Solomon Islands"`" + ;; + 'SC' ) + COUNTRYNAME="`gettext "Seychelles"`" + ;; + 'SD' ) + COUNTRYNAME="`gettext "Sudan"`" + ;; + 'SE' ) + COUNTRYNAME="`gettext "Sweden"`" + ;; + 'SG' ) + COUNTRYNAME="`gettext "Singapore"`" + ;; + 'SH' ) + COUNTRYNAME="`gettext "St Helena"`" + ;; + 'SI' ) + COUNTRYNAME="`gettext "Slovenia"`" + ;; + 'SJ' ) + COUNTRYNAME="`gettext "Svalbard and Jan Mayen"`" + ;; + 'SK' ) + COUNTRYNAME="`gettext "Slovakia"`" + ;; + 'SL' ) + COUNTRYNAME="`gettext "Sierra Leone"`" + ;; + 'SM' ) + COUNTRYNAME="`gettext "San Marino"`" + ;; + 'SN' ) + COUNTRYNAME="`gettext "Senegal"`" + ;; + 'SO' ) + COUNTRYNAME="`gettext "Somalia"`" + ;; + 'SR' ) + COUNTRYNAME="`gettext "Suriname"`" + ;; + 'ST' ) + COUNTRYNAME="`gettext "Sao Tome and Principe"`" + ;; + 'SV' ) + COUNTRYNAME="`gettext "El Salvador"`" + ;; + 'SY' ) + COUNTRYNAME="`gettext "Syria"`" + ;; + 'SZ' ) + COUNTRYNAME="`gettext "Swaziland"`" + ;; + 'TC' ) + COUNTRYNAME="`gettext "Turks and Caicos Islands"`" + ;; + 'TD' ) + COUNTRYNAME="`gettext "Chad"`" + ;; + 'TF' ) + COUNTRYNAME="`gettext "French Southern and Antarctic Lands"`" + ;; + 'TG' ) + COUNTRYNAME="`gettext "Togo"`" + ;; + 'TH' ) + COUNTRYNAME="`gettext "Thailand"`" + ;; + 'TJ' ) + COUNTRYNAME="`gettext "Tajikistan"`" + ;; + 'TK' ) + COUNTRYNAME="`gettext "Tokelau"`" + ;; + 'TL' ) + COUNTRYNAME="`gettext "Timor-Leste"`" + ;; + 'TM' ) + COUNTRYNAME="`gettext "Turkmenistan"`" + ;; + 'TN' ) + COUNTRYNAME="`gettext "Tunisia"`" + ;; + 'TO' ) + COUNTRYNAME="`gettext "Tonga"`" + ;; + 'TR' ) + COUNTRYNAME="`gettext "Turkey"`" + ;; + 'TT' ) + COUNTRYNAME="`gettext "Trinidad and Tobago"`" + ;; + 'TV' ) + COUNTRYNAME="`gettext "Tuvalu"`" + ;; + 'TW' ) + COUNTRYNAME="`gettext "Taiwan"`" + ;; + 'TZ' ) + COUNTRYNAME="`gettext "Tanzania"`" + ;; + 'UA' ) + COUNTRYNAME="`gettext "Ukraine"`" + ;; + 'UG' ) + COUNTRYNAME="`gettext "Uganda"`" + ;; + 'UM' ) + COUNTRYNAME="`gettext "US minor outlying islands"`" + ;; + 'US' ) + COUNTRYNAME="`gettext "United States"`" + ;; + 'UY' ) + COUNTRYNAME="`gettext "Uruguay"`" + ;; + 'UZ' ) + COUNTRYNAME="`gettext "Uzbekistan"`" + ;; + 'VA' ) + COUNTRYNAME="`gettext "Vatican City"`" + ;; + 'VC' ) + COUNTRYNAME="`gettext "St Vincent"`" + ;; + 'VE' ) + COUNTRYNAME="`gettext "Venezuela"`" + ;; + 'VG' ) + COUNTRYNAME="`gettext "Virgin Islands (UK)"`" + ;; + 'VI' ) + COUNTRYNAME="`gettext "Virgin Islands (US)"`" + ;; + 'VN' ) + COUNTRYNAME="`gettext "Vietnam"`" + ;; + 'VU' ) + COUNTRYNAME="`gettext "Vanuatu"`" + ;; + 'WF' ) + COUNTRYNAME="`gettext "Wallis and Futuna"`" + ;; + 'WS' ) + COUNTRYNAME="`gettext "Samoa (Western)"`" + ;; + 'YE' ) + COUNTRYNAME="`gettext "Yemen"`" + ;; + 'YT' ) + COUNTRYNAME="`gettext "Mayotte"`" + ;; + 'ZA' ) + COUNTRYNAME="`gettext "South Africa"`" + ;; + 'ZM' ) + COUNTRYNAME="`gettext "Zambia"`" + ;; + 'ZW' ) + COUNTRYNAME="`gettext "Zimbabwe"`" + ;; + * ) + COUNTRYNAME="`gettext "Unknown"`" + + esac + + echo $COUNTRYNAME + +} diff --git a/Functions/cli_getCurrentLocale.sh b/Functions/cli_getCurrentLocale.sh new file mode 100755 index 0000000..3a44fb3 --- /dev/null +++ b/Functions/cli_getCurrentLocale.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# cli_getCurrentLocale.sh -- This function checks LANG environment +# variable and returns the current locale information in the LL_CC +# format. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getCurrentLocale { + + local CURRENTLOCALE='' + local OPTION="$1" + + # Redefine current locale using LL_CC format. + CURRENTLOCALE=$(echo $LANG | sed -r 's!(^[a-z]{2,3}_[A-Z]{2}).+$!\1!') + + # Define centos-art.sh script default current locale. If + # centos-art.sh script doesn't support current system locale, use + # English language from United States as default current locale. + if [[ $CURRENTLOCALE == '' ]];then + CURRENTLOCALE='en_US' + fi + + # Output current locale. + case $OPTION in + + '--langcode-only' ) + echo "${CURRENTLOCALE}" | cut -d_ -f1 + ;; + + '--langcode-and-countrycode'| * ) + echo "${CURRENTLOCALE}" + ;; + esac +} diff --git a/Functions/cli_getFilesList.sh b/Functions/cli_getFilesList.sh new file mode 100755 index 0000000..034fe56 --- /dev/null +++ b/Functions/cli_getFilesList.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# +# cli_getFilesList.sh -- This function defines the list of FILES to +# process. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getFilesList { + + local LOCATION='' + local FILTER='' + local FILES='' + + # If first argument is provided to cli_getFilesList, use it as + # default location. Otherwise, if first argument is not provided, + # location takes the action value (ACTIONVAL) as default. + if [[ "$1" != '' ]];then + LOCATION="$1" + else + LOCATION="$ACTIONVAL" + fi + + # If second argument is provided to cli_getFilesList, use it as + # default extension to look for files. Otherwise, if second + # argument is not provided, use flag filter instead. + if [[ "$2" != '' ]];then + FILTER="$2" + else + FILTER="$FLAG_FILTER" + fi + + # Define filter as regular expression pattern. When we use regular + # expressions with find, regular expressions are evaluated against + # the whole file path. This way, when the regular expression is + # specified, we need to build it in a way that matches the whole + # path. Doing so, everytime we pass the `--filter' option in the + # command-line could be a tedious task. Instead, in the sake of + # reducing some typing, we prepare the regular expression here to + # match the whole path using the regular expression provided by + # the user as pattern. Do not use LOCATION variable as part of + # regular expresion so it could be possible to use path expansion. + # Using path expansion reduce the amount of places to find out + # things and so the time required to finish the task. + FILTER="^.+/${FILTER}$" + + # Define list of files to process. At this point we cannot verify + # whether the LOCATION is a directory or a file since path + # expansion coul be introduced to it. The best we can do is + # verifying exit status and go on. + FILES=$(find ${LOCATION} -regextype posix-egrep -regex "${FILTER}" | sort | uniq) + + # Output list of files to process. + if [[ $? -eq 0 ]];then + echo "$FILES" + fi + +} diff --git a/Functions/cli_getFunctions.sh b/Functions/cli_getFunctions.sh new file mode 100644 index 0000000..375b552 --- /dev/null +++ b/Functions/cli_getFunctions.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# cli_getFunctions.sh -- This function loads funtionalities supported by +# centos-art.sh script. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getFunctions { + + # Define variables as local to avoid conflicts outside. + local FUNCNAMCALL='' + local FUNCFILES='' + + # Build action-specifc script file list. + FUNCFILES=$(ls ${FUNCDIR}/${FUNCDIRNAM}/${FUNCNAM}*.sh) + + for FILE in $FUNCFILES;do + + if [[ -x ${FILE} ]];then + + # Initialize action-specific functions. + . $FILE + + # Export action-specific functions to current shell script + # environment. + FUNCNAMCALL=$(grep '^function ' $FILE | cut -d' ' -f2) + export -f $FUNCNAMCALL + + else + + cli_printMessage "`eval_gettext "The \\\$FILE hasn't execution rights."`" 'AsErrorLine' + cli_printMessage "$(caller)" "AsToKnowMoreLine" + + fi + + done + + # Execute action passed to centos-art.sh script. + if [[ $FUNCNAM != '' ]];then + eval $FUNCNAM + fi + +} diff --git a/Functions/cli_getLangCodes.sh b/Functions/cli_getLangCodes.sh new file mode 100755 index 0000000..2c46d9b --- /dev/null +++ b/Functions/cli_getLangCodes.sh @@ -0,0 +1,223 @@ +#!/bin/bash +# +# cli_getLangCodes.sh -- This function outputs a list with language +# codes as defined in ISO639 standard. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getLangCodes { + + local FILTER="$(echo $1 | cut -d_ -f1)" + + LANGCODES="aa + ab + ae + af + ak + am + an + ar + as + av + ay + az + ba + be + bg + bh + bi + bm + bn + bo + br + bs + ca + ce + ch + co + cr + cs + cu + cv + cy + da + de + dv + dz + ee + el + en + eo + es + et + eu + fa + ff + fi + fj + fo + fr + fy + ga + gd + gl + gn + gu + gv + ha + he + hi + ho + hr + ht + hu + hy + hz + ia + id + ie + ig + ii + ik + io + is + it + iu + ja + jv + ka + kg + ki + kj + kk + kl + km + kn + ko + kr + ks + ku + kv + kw + ky + la + lb + lg + li + ln + lo + lt + lu + lv + mg + mh + mi + mk + ml + mn + mo + mr + ms + mt + my + na + nb + nd + ne + ng + nl + nn + no + nr + nv + ny + oc + oj + om + or + os + pa + pi + pl + ps + pt + qu + rm + rn + ro + ru + rw + sa + sc + sd + se + sg + si + sk + sl + sm + sn + so + sq + sr + ss + st + su + sv + sw + ta + te + tg + th + ti + tk + tl + tn + to + tr + ts + tt + tw + ty + ug + uk + ur + uz + ve + vi + vo + wa + wo + xh + yi + yo + za + zh + zu" + + if [[ $FILTER != '' ]];then + echo "$LANGCODES" | egrep "$FILTER" | sed -r 's![[:space:]]+!!g' + else + echo "$LANGCODES" + fi + +} diff --git a/Functions/cli_getLangName.sh b/Functions/cli_getLangName.sh new file mode 100755 index 0000000..e49f116 --- /dev/null +++ b/Functions/cli_getLangName.sh @@ -0,0 +1,781 @@ +#!/bin/bash +# +# cli_getLangName.sh -- This function reads one language locale code +# in the format LL_CC and outputs its language name. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getLangName { + + local LANGCODE="$(echo "$1" | cut -d_ -f1 | tr '[:upper:]' '[:lower:]')" + local LANGNAME='' + + case $LANGCODE in + + 'aa' ) + LANGNAME="`gettext "Afar"`" + ;; + + 'ab' ) + LANGNAME="`gettext "Abkhazian"`" + ;; + + 'ae' ) + LANGNAME="`gettext "Avestan"`" + ;; + + 'af' ) + LANGNAME="`gettext "Afrikaans"`" + ;; + + 'ak' ) + LANGNAME="`gettext "Akan"`" + ;; + + 'am' ) + LANGNAME="`gettext "Amharic"`" + ;; + + 'an' ) + LANGNAME="`gettext "Aragonese"`" + ;; + + 'ar' ) + LANGNAME="`gettext "Arabic"`" + ;; + + 'as' ) + LANGNAME="`gettext "Assamese"`" + ;; + + 'av' ) + LANGNAME="`gettext "Avaric"`" + ;; + + 'ay' ) + LANGNAME="`gettext "Aymara"`" + ;; + + 'az' ) + LANGNAME="`gettext "Azerbaijani"`" + ;; + + 'ba' ) + LANGNAME="`gettext "Bashkir"`" + ;; + + 'be' ) + LANGNAME="`gettext "Byelorussian"`" + ;; + + 'bg' ) + LANGNAME="`gettext "Bulgarian"`" + ;; + + 'bh' ) + LANGNAME="`gettext "Bihari"`" + ;; + + 'bi' ) + LANGNAME="`gettext "Bislama"`" + ;; + + 'bm' ) + LANGNAME="`gettext "Bambara"`" + ;; + + 'bn' ) + LANGNAME="`gettext "Bengali"`" + ;; + + 'bo' ) + LANGNAME="`gettext "Tibetan"`" + ;; + + 'br' ) + LANGNAME="`gettext "Breton"`" + ;; + + 'bs' ) + LANGNAME="`gettext "Bosnian"`" + ;; + + 'ca' ) + LANGNAME="`gettext "Catalan"`" + ;; + + 'ce' ) + LANGNAME="`gettext "Chechen"`" + ;; + + 'ch' ) + LANGNAME="`gettext "Chamorro"`" + ;; + + 'co' ) + LANGNAME="`gettext "Corsican"`" + ;; + + 'cr' ) + LANGNAME="`gettext "Cree"`" + ;; + + 'cs' ) + LANGNAME="`gettext "Czech"`" + ;; + + 'cu' ) + LANGNAME="`gettext "Church Slavic"`" + ;; + + 'cv' ) + LANGNAME="`gettext "Chuvash"`" + ;; + + 'cy' ) + LANGNAME="`gettext "Welsh"`" + ;; + + 'da' ) + LANGNAME="`gettext "Danish"`" + ;; + + 'de' ) + LANGNAME="`gettext "German"`" + ;; + + 'dv' ) + LANGNAME="`gettext "Divehi"`" + ;; + + 'dz' ) + LANGNAME="`gettext "Dzongkha"`" + ;; + + 'ee' ) + LANGNAME="`gettext "E'we"`" + ;; + + 'el' ) + LANGNAME="`gettext "Greek"`" + ;; + + 'en' ) + LANGNAME="`gettext "English"`" + ;; + + 'eo' ) + LANGNAME="`gettext "Esperanto"`" + ;; + + 'es' ) + LANGNAME="`gettext "Spanish"`" + ;; + + 'et' ) + LANGNAME="`gettext "Estonian"`" + ;; + + 'eu' ) + LANGNAME="`gettext "Basque"`" + ;; + 'fa' ) + LANGNAME="`gettext "Persian"`" + ;; + + 'ff' ) + LANGNAME="`gettext "Fulah"`" + ;; + + 'fi' ) + LANGNAME="`gettext "Finnish"`" + ;; + + 'fj' ) + LANGNAME="`gettext "Fijian"`" + ;; + + 'fo' ) + LANGNAME="`gettext "Faroese"`" + ;; + + 'fr' ) + LANGNAME="`gettext "French"`" + ;; + + 'fy' ) + LANGNAME="`gettext "Frisian"`" + ;; + + 'ga' ) + LANGNAME="`gettext "Irish"`" + ;; + + 'gd' ) + LANGNAME="`gettext "Scots"`" + ;; + + 'gl' ) + LANGNAME="`gettext "Gallegan"`" + ;; + + 'gn' ) + LANGNAME="`gettext "Guarani"`" + ;; + + 'gu' ) + LANGNAME="`gettext "Gujarati"`" + ;; + + 'gv' ) + LANGNAME="`gettext "Manx"`" + ;; + + 'ha' ) + LANGNAME="`gettext "Hausa"`" + ;; + + 'he' ) + LANGNAME="`gettext "Hebrew"`" + ;; + + 'hi' ) + LANGNAME="`gettext "Hindi"`" + ;; + + 'ho' ) + LANGNAME="`gettext "Hiri Motu"`" + ;; + + 'hr' ) + LANGNAME="`gettext "Croatian"`" + ;; + + 'ht' ) + LANGNAME="`gettext "Haitian"`" + ;; + + 'hu' ) + LANGNAME="`gettext "Hungarian"`" + ;; + + 'hy' ) + LANGNAME="`gettext "Armenian"`" + ;; + + 'hz' ) + LANGNAME="`gettext "Herero"`" + ;; + + 'ia' ) + LANGNAME="`gettext "Interlingua"`" + ;; + + 'id' ) + LANGNAME="`gettext "Indonesian"`" + ;; + + 'ie' ) + LANGNAME="`gettext "Interlingue"`" + ;; + + 'ig' ) + LANGNAME="`gettext "Igbo"`" + ;; + + 'ii' ) + LANGNAME="`gettext "Sichuan Yi"`" + ;; + + 'ik' ) + LANGNAME="`gettext "Inupiak"`" + ;; + + 'io' ) + LANGNAME="`gettext "Ido"`" + ;; + + 'is' ) + LANGNAME="`gettext "Icelandic"`" + ;; + + 'it' ) + LANGNAME="`gettext "Italian"`" + ;; + + 'iu' ) + LANGNAME="`gettext "Inuktitut"`" + ;; + + 'ja' ) + LANGNAME="`gettext "Japanese"`" + ;; + + 'jv' ) + LANGNAME="`gettext "Javanese"`" + ;; + + 'ka' ) + LANGNAME="`gettext "Georgian"`" + ;; + + 'kg' ) + LANGNAME="`gettext "Kongo"`" + ;; + + 'ki' ) + LANGNAME="`gettext "Kikuyu"`" + ;; + + 'kj' ) + LANGNAME="`gettext "Kuanyama"`" + ;; + + 'kk' ) + LANGNAME="`gettext "Kazakh"`" + ;; + + 'kl' ) + LANGNAME="`gettext "Kalaallisut"`" + ;; + + 'km' ) + LANGNAME="`gettext "Khmer"`" + ;; + + 'kn' ) + LANGNAME="`gettext "Kannada"`" + ;; + + 'ko' ) + LANGNAME="`gettext "Korean"`" + ;; + + 'kr' ) + LANGNAME="`gettext "Kanuri"`" + ;; + + 'ks' ) + LANGNAME="`gettext "Kashmiri"`" + ;; + + 'ku' ) + LANGNAME="`gettext "Kurdish"`" + ;; + + 'kv' ) + LANGNAME="`gettext "Komi"`" + ;; + + 'kw' ) + LANGNAME="`gettext "Cornish"`" + ;; + + 'ky' ) + LANGNAME="`gettext "Kirghiz"`" + ;; + + 'la' ) + LANGNAME="`gettext "Latin"`" + ;; + + 'lb' ) + LANGNAME="`gettext "Letzeburgesch"`" + ;; + + 'lg' ) + LANGNAME="`gettext "Ganda"`" + ;; + + 'li' ) + LANGNAME="`gettext "Limburgish"`" + ;; + + 'ln' ) + LANGNAME="`gettext "Lingala"`" + ;; + + 'lo' ) + LANGNAME="`gettext "Lao"`" + ;; + + 'lt' ) + LANGNAME="`gettext "Lithuanian"`" + ;; + + 'lu' ) + LANGNAME="`gettext "Luba-Katanga"`" + ;; + + 'lv' ) + LANGNAME="`gettext "Latvian"`" + ;; + + 'mg' ) + LANGNAME="`gettext "Malagasy"`" + ;; + + 'mh' ) + LANGNAME="`gettext "Marshall"`" + ;; + + 'mi' ) + LANGNAME="`gettext "Maori"`" + ;; + + 'mk' ) + LANGNAME="`gettext "Macedonian"`" + ;; + + 'ml' ) + LANGNAME="`gettext "Malayalam"`" + ;; + + 'mn' ) + LANGNAME="`gettext "Mongolian"`" + ;; + + 'mo' ) + LANGNAME="`gettext "Moldavian"`" + ;; + + 'mr' ) + LANGNAME="`gettext "Marathi"`" + ;; + + 'ms' ) + LANGNAME="`gettext "Malay"`" + ;; + + 'mt' ) + LANGNAME="`gettext "Maltese"`" + ;; + + 'my' ) + LANGNAME="`gettext "Burmese"`" + ;; + + 'na' ) + LANGNAME="`gettext "Nauru"`" + ;; + + 'nb' ) + LANGNAME="`gettext "Norwegian Bokmaal"`" + ;; + + 'nd' ) + LANGNAME="`gettext "Ndebele, North"`" + ;; + + 'ne' ) + LANGNAME="`gettext "Nepali"`" + ;; + + 'ng' ) + LANGNAME="`gettext "Ndonga"`" + ;; + + 'nl' ) + LANGNAME="`gettext "Dutch"`" + ;; + + 'nn' ) + LANGNAME="`gettext "Norwegian Nynorsk"`" + ;; + + 'no' ) + LANGNAME="`gettext "Norwegian"`" + ;; + + 'nr' ) + LANGNAME="`gettext "Ndebele, South"`" + ;; + + 'nv' ) + LANGNAME="`gettext "Navajo"`" + ;; + + 'ny' ) + LANGNAME="`gettext "Chichewa"`" + ;; + + 'oc' ) + LANGNAME="`gettext "Occitan"`" + ;; + + 'oj' ) + LANGNAME="`gettext "Ojibwa"`" + ;; + + 'om' ) + LANGNAME="`gettext "(Afan) Oromo"`" + ;; + + 'or' ) + LANGNAME="`gettext "Oriya"`" + ;; + + 'os' ) + LANGNAME="`gettext "Ossetian; Ossetic"`" + ;; + + 'pa' ) + LANGNAME="`gettext "Panjabi; Punjabi"`" + ;; + + 'pi' ) + LANGNAME="`gettext "Pali"`" + ;; + + 'pl' ) + LANGNAME="`gettext "Polish"`" + ;; + + 'ps' ) + LANGNAME="`gettext "Pashto, Pushto"`" + ;; + + 'pt' ) + LANGNAME="`gettext "Portuguese"`" + ;; + + 'qu' ) + LANGNAME="`gettext "Quechua"`" + ;; + + 'rm' ) + LANGNAME="`gettext "Rhaeto-Romance"`" + ;; + + 'rn' ) + LANGNAME="`gettext "Rundi"`" + ;; + + 'ro' ) + LANGNAME="`gettext "Romanian"`" + ;; + + 'ru' ) + LANGNAME="`gettext "Russian"`" + ;; + + 'rw' ) + LANGNAME="`gettext "Kinyarwanda"`" + ;; + + 'sa' ) + LANGNAME="`gettext "Sanskrit"`" + ;; + + 'sc' ) + LANGNAME="`gettext "Sardinian"`" + ;; + + 'sd' ) + LANGNAME="`gettext "Sindhi"`" + ;; + + 'se' ) + LANGNAME="`gettext "Northern Sami"`" + ;; + + 'sg' ) + LANGNAME="`gettext "Sango; Sangro"`" + ;; + + 'si' ) + LANGNAME="`gettext "Sinhalese"`" + ;; + + 'sk' ) + LANGNAME="`gettext "Slovak"`" + ;; + + 'sl' ) + LANGNAME="`gettext "Slovenian"`" + ;; + + 'sm' ) + LANGNAME="`gettext "Samoan"`" + ;; + + 'sn' ) + LANGNAME="`gettext "Shona"`" + ;; + + 'so' ) + LANGNAME="`gettext "Somali"`" + ;; + + 'sq' ) + LANGNAME="`gettext "Albanian"`" + ;; + + 'sr' ) + LANGNAME="`gettext "Serbian"`" + ;; + + 'ss' ) + LANGNAME="`gettext "Swati; Siswati"`" + ;; + + 'st' ) + LANGNAME="`gettext "Sesotho; Sotho, Southern"`" + ;; + + 'su' ) + LANGNAME="`gettext "Sundanese"`" + ;; + + 'sv' ) + LANGNAME="`gettext "Swedish"`" + ;; + + 'sw' ) + LANGNAME="`gettext "Swahili"`" + ;; + + 'ta' ) + LANGNAME="`gettext "Tamil"`" + ;; + + 'te' ) + LANGNAME="`gettext "Telugu"`" + ;; + + 'tg' ) + LANGNAME="`gettext "Tajik"`" + ;; + + 'th' ) + LANGNAME="`gettext "Thai"`" + ;; + + 'ti' ) + LANGNAME="`gettext "Tigrinya"`" + ;; + + 'tk' ) + LANGNAME="`gettext "Turkmen"`" + ;; + + 'tl' ) + LANGNAME="`gettext "Tagalog"`" + ;; + + 'tn' ) + LANGNAME="`gettext "Tswana; Setswana"`" + ;; + + 'to' ) + LANGNAME="`gettext "Tonga (?)"`" + ;; + + 'tr' ) + LANGNAME="`gettext "Turkish"`" + ;; + + 'ts' ) + LANGNAME="`gettext "Tsonga"`" + ;; + + + 'tt' ) + LANGNAME="`gettext "Tatar"`" + ;; + + 'tw' ) + LANGNAME="`gettext "Twi"`" + ;; + + 'ty' ) + LANGNAME="`gettext "Tahitian"`" + ;; + + 'ug' ) + LANGNAME="`gettext "Uighur"`" + ;; + + 'uk' ) + LANGNAME="`gettext "Ukrainian"`" + ;; + + 'ur' ) + LANGNAME="`gettext "Urdu"`" + ;; + + 'uz' ) + LANGNAME="`gettext "Uzbek"`" + ;; + + 've' ) + LANGNAME="`gettext "Venda"`" + ;; + + 'vi' ) + LANGNAME="`gettext "Vietnamese"`" + ;; + + 'vo' ) + LANGNAME="`gettext "Volapuk; Volapuk"`" + ;; + + 'wa' ) + LANGNAME="`gettext "Walloon"`" + ;; + + 'wo' ) + LANGNAME="`gettext "Wolof"`" + ;; + + 'xh' ) + LANGNAME="`gettext "Xhosa"`" + ;; + + 'yi' ) + LANGNAME="`gettext "Yiddish (formerly ji)"`" + ;; + + 'yo' ) + LANGNAME="`gettext "Yoruba"`" + ;; + + 'za' ) + LANGNAME="`gettext "Zhuang"`" + ;; + + 'zh' ) + LANGNAME="`gettext "Chinese"`" + ;; + + 'zu' ) + LANGNAME="`gettext "Zulu"`" + ;; + + * ) + LANGNAME="`gettext "Unknown"`" + + esac + + echo $LANGNAME; +} + diff --git a/Functions/cli_getLocales.sh b/Functions/cli_getLocales.sh new file mode 100755 index 0000000..e72fc3d --- /dev/null +++ b/Functions/cli_getLocales.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# cli_getLocales.sh -- This function outputs/verifies locale codes in +# LL and LL_CC format. Combine both ISO639 and ISO3166 specification +# in order to build the final locale list. This function defines which +# translation locales are supported inside CentOS Artwork Repository. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getLocales { + + # Print locales supported by centos-art.sh script. + locale -a | egrep '^[a-z]{2,3}_[A-Z]{2}$' | sort | uniq + +} diff --git a/Functions/cli_getPathComponent.sh b/Functions/cli_getPathComponent.sh new file mode 100755 index 0000000..e71a058 --- /dev/null +++ b/Functions/cli_getPathComponent.sh @@ -0,0 +1,230 @@ +#!/bin/bash +# +# cli_getPathComponent.sh -- This function evaluates one repository +# path and output parts/components from it. Generally, the path +# information is passed to the function's first positional argument +# and the part/component we want to retrive is passed to the +# function's second positional argument. If second argument is not +# passed, then first argument is assumed to be the part/component we +# want to retrive, and action value (ACTIONVAL) variable is used +# instead as source path information. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getPathComponent { + + local -a PATTERN + local LOCATION='' + local OPTION='' + + # Define location which we retrive information from. + if [[ "$#" -eq 1 ]];then + LOCATION="$ACTIONVAL" + OPTION="$1" + elif [[ "$#" -eq 2 ]];then + LOCATION="$1" + OPTION="$2" + else + cli_printMessage "${FUNCNAM}: `gettext "Invalid arguments."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Define release pattern. + PATTERN[0]="(([[:digit:]]+)(\.([[:digit:]]+)){,1})" + + # Define architecture pattern. Make it match the architectures the + # CentOS distribution is able to be installed on. + PATTERN[1]="(i386|x86_64)" + + # Define theme pattern for trunk, branches, and tags directory + # structures. + # + # trunk: + # ------ + # Themes are made of `Models' and `Motifs'. `Models' controls the + # `Motifs' characteristcs and it is not rendereable. On the other + # hand, `Motifs' controls the theme visual style and do is + # renderable. Since we only need to know the theme name when we + # render something, we take the `Motifs' directory structure as + # reference to find out the theme name we are producing images + # for. + # + # `Motifs' are organized by names, so when we say `a theme name' + # we are really saying `the artistic motif name of a theme', but + # for short `theme name' is used instead. `Models' are also + # organized by names, but we do never use model names to name a + # thame. We always say the `theme models' or `the models of the + # theme` to refere the theme component that controls the + # characteristics of artistic motifs. We never name a thame as its + # model. We use artistic motifs name for such purpose. + # + # Inside artistic motif names, we organize different versions of + # the same artistic motif by means of numerical worklines. + # Worklines, inside trunk, have an integer numerical form and + # begin at `1'. They increment one unit each time a new/fresh + # visual style ---for the same artistic motif--- is conceived. + # + # For example, the Flame theme uses the flame filter of Gimp to + # produce different fractal patterns randomly. We use the flame + # filter to produce different visual styles under the same theme + # since all patterns we produce are based on the same pattern + # (i.e., the random fractal pattern of Gimp's flame filter). This + # way, if you no longer want to produce visual styles from flame + # filter, it is time to create a new artistic motif name for it. + # + # This schema is very convenient for designers and packagers, + # since different designers can create their own worklines and go + # on with them until CentOS distribution release date is close. At + # that time, a workline is selected and tagged for packaging. + # Translators and programmers can continue working indepently, and + # without affection, in their own directory structures. + # + # Example: + # +------> theme name + # |-->| + # trunk/.../Themes/Motifs/Flame/1 + # trunk/.../Themes/Motifs/Flame/2 + # trunk/.../Themes/Motifs/Flame/3 + # | + # +----> theme release version + # + # Sometimes we only need to retrive the theme name, but othertimes + # both the theme name and its work-line is required as well. + # + # branches: + # --------- + # The branch development line is treated just as trunk development + # line does, but we rarely use it since it could be confusing to + # know whether a tag was created from trunk or branches. + # + # Conceive an enumeration schema in order to differentiate + # branches from trunk is not convenient either, it would introduce + # an intermediate point to the final production of tags we would + # need to be aware of. Instead of such configuration, we prefer + # to go straightforward from trunk to tags. + # + # Intermediate branches for quality assurance might be good in + # some situations, but not when we produce themes. We need a + # simple structure, where we could design, render content (using + # centos-art.sh), and release for testing (through tags). If + # something goes wrong in the released tag, it would be fixed in + # trunk and later released in another tagged relase. + # + # Of course, care should be taken to avoid making of trunk + # development line a chaotic place. Everbody should know exactly + # what they are doing therein. We need to design protections to + # isolate possible damages and that way, we could know exactly + # what and where we need to concentrate in and put our time on. + # + # In resume, do not use branches if you don't need to. Use trunk + # development line instead. + # + # tags: + # ----- + # The tag frozen line is mainly used to perform theme releases. + # + # Example: + # +------> theme name + # |-->| + # tags/.../Themes/Motifs/Flame/1.0 + # trunk/.../Themes/Motifs/Flame/1 |--> minor update + # |----> major udpate + # + # Tags have the format X.Z, where X is the first number in the + # name (e.g., `1') and represents the trunk/branches artistic + # motif version. The Z represents the second number in the name + # (e.g., `0') which is the tag version itself. + # + # Tag versions start at `0' and increment one unit each time a new + # tag is created from the same artistic motif version. When a new + # tag is created for the same artistic motif version, the first + # number in the tag name remains intact. The first number in the + # tag name only changes when we create a new tag for a new + # artistic motif version. + # + # Consider the following relations: + # + # trunk/.../Themes/Motifs/Flame/1 + # tags/.../Themes/Motifs/Flame/1.0 + # tags/.../Themes/Motifs/Flame/1.1 + # tags/.../Themes/Motifs/Flame/1.2 + # + # trunk/.../Themes/Motifs/Flame/2 + # tags/.../Themes/Motifs/Flame/2.0 + # tags/.../Themes/Motifs/Flame/2.1 + # tags/.../Themes/Motifs/Flame/2.2 + # + # trunk/.../Themes/Motifs/TreeFlower/1 + # ... + # and so on. + # + # Tag versions are created to release fixes and improvements, Tags + # are immutable (i.e., once tags are created, they shouldn't be + # modified.). + PATTERN[2]="^.+/Identity/Themes/Motifs/(([A-Za-z0-9]+)/${PATTERN[0]})/.+$" + + # Identify which part of the release we want to output. + case "$OPTION" in + + '--release' ) + echo "$LOCATION" | sed -r "s!.*/${PATTERN[0]}/.*!\1!" + ;; + + '--release-major' ) + echo "$LOCATION" | sed -r "s!.*/${PATTERN[0]}/.*!\2!" + ;; + + '--release-minor' ) + echo "$LOCATION" | sed -r "s!.*/${PATTERN[0]}/.*!\4!" + ;; + + '--release-pattern' ) + echo "${PATTERN[0]}" + ;; + + '--architecture' ) + echo "$LOCATION" | sed -r "s!${PATTERN[1]}!\1!" + ;; + + '--architecture-pattern' ) + echo "${PATTERN[1]}" + ;; + + '--theme' ) + echo "$LOCATION" | sed -r "s!${PATTERN[2]}!\1!" + ;; + + '--theme-name' ) + echo "$LOCATION" | sed -r "s!${PATTERN[2]}!\2!" + ;; + + '--theme-release' ) + echo "$LOCATION" | sed -r "s!${PATTERN[2]}!\3!" + ;; + + '--theme-pattern' ) + echo "${PATTERN[2]}" + ;; + + esac + +} diff --git a/Functions/cli_getRepoName.sh b/Functions/cli_getRepoName.sh new file mode 100755 index 0000000..5d85cd3 --- /dev/null +++ b/Functions/cli_getRepoName.sh @@ -0,0 +1,153 @@ +#!/bin/bash +# +# cli_getRepoName.sh -- This function sets naming convenction. Inside +# CentOS Artowrk Repository, regular files are written in lower case +# and directories are written in lower case but with the first letter +# in upper case. Use this function to sanitate the name of regular +# files and directory components of paths you work with. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getRepoName { + + local NAME="$1" + local TYPE="$2" + local DIRS='' + local DIR='' + local CLEANDIRS='' + local PREFIXDIR='' + + case $TYPE in + + 'f' | 'basename' ) + + # Reduce the path passed to use just the non-directory + # part of it (i.e., the last component in the path; _not_ + # the last "real" directory in the path). + NAME=$(basename $NAME) + + # Clean value. + NAME=$(echo $NAME \ + | tr -s ' ' '_' \ + | tr '[:upper:]' '[:lower:]') + ;; + + 'd' | 'dirname' ) + + # Reduce path information passed to use just the directory + # part of it. Of course, this is applied only if there is + # a directory part in the path. However, if there is no + # directory part but there is a non-empty value in the + # path, assume that value as directory part and clean it + # up. + if [[ $NAME =~ '.+/.+' ]];then + + # When path information is reduced, we need to take + # into account that absolute path may be provided. + # Absolute paths include directory structures outside + # the repository directory structure we don't want to + # sanitate (e.g., /home/, /home/centos/, + # /home/centos/artwork, /home/centos/artwork/turnk/, + # trunk/, etc.). In these cases, it is required that + # those path component remain untouched. So, in the + # sake of keeping path components, outside repository + # directory structure untouched, we use the PREFIXDIR + # variable to temporarly store the prefix directory + # structure we don't want to sanitate. + PREFIXDIR=$(echo $NAME \ + | sed -r "s,^((${HOME}/artwork/)?(trunk|branches|tags)/).+$,\1,") + + # ... and remove it from the path information we do + # want to sanitate. + DIRS=$(dirname "$NAME" \ + | sed -r "s!^${PREFIXDIR}!!" \ + | tr '/' ' ') + + else + + # At this point, there is not directory part in the + # information passed, so use the value passed as + # directory part as such. + DIRS=$NAME + + fi + + for DIR in $DIRS;do + + # Sanitate directory component. + if [[ $DIR =~ '^[a-z]' ]];then + DIR=$(echo ${DIR} \ + | tr -s ' ' '_' \ + | tr '[:upper:]' '[:lower:]' \ + | sed -r 's/^([[:alpha:]])/\u\1/') + fi + + # Rebuild path using sanitated values. + CLEANDIRS="${CLEANDIRS}/$DIR" + + done + + # Redefine path using sanitated values. + NAME=$(echo ${CLEANDIRS} | sed -r "s!^/!!") + + # Add prefix directory information to sanitated path + # information. + if [[ "$PREFIXDIR" != '' ]];then + NAME=${PREFIXDIR}${NAME} + fi + ;; + + 'fd' | 'basename-to-dirname' ) + + # Retrive non-directory part. + NAME=$(cli_getRepoName $NAME 'f') + + # Retrive cleaned directory part from non-directory part. + NAME=$(cli_getRepoName $NAME 'd') + ;; + + 'df' | 'dirname-to-basename' ) + + # Retrive cleaned directory part from non-directory part. + NAME=$(cli_getRepoName $NAME 'd') + + # Retrive non-directory part. + NAME=$(cli_getRepoName $NAME 'f') + ;; + + 'dfd' | 'dirname-to-basename-to-dirname' ) + + # Retrive cleaned directory part from non-directory part. + NAME=$(cli_getRepoName $NAME 'd') + + # Retrive non-directory part. + NAME=$(cli_getRepoName $NAME 'f') + + # Retrive cleaned directory part from non-directory part. + NAME=$(cli_getRepoName $NAME 'd') + ;; + esac + + # Output clean path information. + echo $NAME + +} diff --git a/Functions/cli_getRepoParallelDirs.sh b/Functions/cli_getRepoParallelDirs.sh new file mode 100755 index 0000000..3fc047b --- /dev/null +++ b/Functions/cli_getRepoParallelDirs.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# cli_getRepoParallelDirs.sh -- This function returns the parallel +# directories related to the first positional paramenter passed as +# parent directory. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getRepoParallelDirs { + + local BOND='' + local TDIR='' + local -a PDIRS + + # Define bond string using first positional parameter as + # reference. + if [[ "$1" != '' ]];then + BOND="$1" + elif [[ "$ACTIONVAL" != '' ]];then + BOND="$ACTIONVAL" + else + cli_printMessage "${FUNCNAME}: `gettext "The bond string is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Define repository top level directory. + TDIR=$(cli_getRepoTLDir ${BOND}) + + # Define parallel directory base structures. + PDIRS[0]=Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${BOND}" '--relative') + PDIRS[1]=Scripts/Bash/Functions/Render/Config + PDIRS[2]=Locales + + # Redefine bond string without its top level directory structure. + BOND=$(echo $BOND | sed -r "s,^${TDIR}/(.+)$,\1,") + + # Concatenate repository top level directory, parallel directory + # base structure, and bond information; in order to produce the + # final parallel directory path. + for PDIR in "${PDIRS[@]}";do + echo ${TDIR}/${PDIR}/${BOND} + done + +} diff --git a/Functions/cli_getRepoStatus.sh b/Functions/cli_getRepoStatus.sh new file mode 100755 index 0000000..a7b42db --- /dev/null +++ b/Functions/cli_getRepoStatus.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# cli_getRepoStatus.sh -- This function requests the working copy +# using the svn status command and returns the first character in the +# output line, as described in svn help status, for the LOCATION +# specified. Use this function to perform verifications based a +# repository LOCATION status. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getRepoStatus { + + local LOCATION="$1" + local STATUS='' + + # Define regular expression pattern to retrive first column, + # returned by subversion status command. This column is one + # character column as describes `svn help status' command. + local PATTERN='^( |A|C|D|I|M|R|X|\?|!|~).+$' + + # Verify the file used as source to retrive its status + # information. We only use regular files or directories inside the + # working copy. + cli_checkFiles "$LOCATION" 'fd' + cli_checkFiles "$LOCATION" 'isInWorkingCopy' + + # Use subversion `status' command to retrive the first character + # in the output. Discard standard error output. + STATUS="$(svn status "$LOCATION" | sed -r "s/${PATTERN}/\1/" 2>/dev/null)" + + # Outout status information. + echo -n "$STATUS" + +} diff --git a/Functions/cli_getRepoTLDir.sh b/Functions/cli_getRepoTLDir.sh new file mode 100755 index 0000000..77c522d --- /dev/null +++ b/Functions/cli_getRepoTLDir.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# cli_getRepoTLDir.sh -- This function returns the repository top +# level absolute path. The repository top level absolute path may be +# /home/centos/artwork/trunk, /home/centos/artwork/branches, or +# /home/centos/artwork/tags. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getRepoTLDir { + + local PATTERN='' + local REPLACE='' + local LOCATION='' + + # Define location. If first argument is provided use it as default + # location. Otherwise, if first argument is not provided, + # location takes the action value (ACTIONVAL) as default. + if [[ "$1" != '' ]];then + LOCATION="$1" + else + LOCATION="$ACTIONVAL" + fi + + # Verify location. + if [[ $LOCATION =~ "^${HOME}/artwork/(trunk|branches|tags)/.+$" ]];then + case "$2" in + -r|--relative ) + PATTERN="^${HOME}/artwork/(trunk|branches|tags)/.+$" + REPLACE='\1' + ;; + -a|--absolute|* ) + PATTERN="^(${HOME}/artwork/(trunk|branches|tags))/.+$" + REPLACE='\1' + ;; + esac + else + cli_printMessage "${FUNCNAME}: `eval_gettext "The location \\\`\\\$LOCATION' is not valid."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Print location. + echo $LOCATION | sed -r "s!${PATTERN}!${REPLACE}!g" + +} diff --git a/Functions/cli_getTemporalFile.sh b/Functions/cli_getTemporalFile.sh new file mode 100755 index 0000000..faddedb --- /dev/null +++ b/Functions/cli_getTemporalFile.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# cli_getTemporalFile.sh -- This function returns the absolute path +# you need to use to create temporal files. Use this function whenever +# you need to create temporal files inside centos-art.sh script. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getTemporalFile { + + # Define base name for temporal file. This is required when svg + # instances are created previous to be parsed by inkscape in order + # to be exported as png. In such cases .svg file exention is + # required in order to avoid complains from inkscape. + local NAME="$(cli_getRepoName "$1" 'f')" + + # Check default base name for temporal file, it can't be an empty + # value. + if [[ "$NAME" == '' ]];then + cli_printMessage "${FUNCNAME}: `gettext "First argument cannot be empty."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Define source location where temporal files will be stored. + local TMPDIR='/tmp' + + # Define unique identifier for temporal file. + local UUID=$(cat /proc/sys/kernel/random/uuid) + + # Define absolute path for temporal file using the program name, + # the current locale, the unique identifier and the file name. + local TMPFILE="${TMPDIR}/${CLI_PROGRAM}-$(cli_getCurrentLocale)-${UUID}-${NAME}" + + # Output absolute path to final temporal file. + echo $TMPFILE + +} diff --git a/Functions/cli_printActionPreamble.sh b/Functions/cli_printActionPreamble.sh new file mode 100755 index 0000000..e811587 --- /dev/null +++ b/Functions/cli_printActionPreamble.sh @@ -0,0 +1,121 @@ +#!/bin/bash +# +# cli_printActionPreamble -- This function standardizes action +# preamble messages. Action preamble messages provides a confirmation +# message that illustrate what files will be affected in the action. +# +# Generally, actions are applied to parent directories. Each parent +# directory has parallel directories associated. If one parent +# directory is created/deleted, the parallel directories associated do +# need to be created/deleted too. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_printActionPreamble { + + local FILES="$1" + + # Verify amount of files to process. If there is no one then there + # is nothing else to do here. + if [[ "$FILES" == '' ]];then + return + fi + + local ACTION="$2" + local FORMAT="$3" + local FILE='' + local NEGATIVE='' + local POSITIVE='' + local COUNT=0 + + # Replace spaces by new line. + FILES=$(echo "$FILES" | sed -r "s! +!\n!g") + + # Redefine total number of directories. + COUNT=$(echo "$FILES" | wc -l) + + # Redefine preamble messages based on action. At this point seems + # to be some files to process so lets read ACTION to know what to + # do with them. + case $ACTION in + + 'doCreate' ) + if [[ $FILES == '' ]];then + NEGATIVE="`gettext "There is no entry to create."`" + else + POSITIVE="`ngettext "The following entry will be created" \ + "The following entries will be created" $COUNT`:" + fi + ;; + + 'doDelete' ) + if [[ $FILES == '' ]];then + NEGATIVE="`gettext "There is no file to delete."`" + else + POSITIVE="`ngettext "The following entry will be deleted" \ + "The following entries will be deleted" $COUNT`:" + fi + ;; + + 'doLocale' ) + if [[ $FILES == '' ]];then + NEGATIVE="`gettext "There is no file to locale."`" + else + POSITIVE="`ngettext "Translatable strings will be retrived from the following entry" \ + "Translatable strings will be retrived from the following entries" $COUNT`:" + fi + ;; + + 'doEdit' ) + if [[ $FILES == '' ]];then + NEGATIVE="`gettext "There is no file to edit."`" + else + POSITIVE="`ngettext "The following file will be edited" \ + "The following files will be edited" $COUNT`:" + fi + ;; + + * ) + # Check list of files to process. If we have an empty + # list of files, inform about that and stop the script + # execution. Otherwise, check all files in the list to be + # sure they are regular files. + if [[ "$FILES" == '' ]];then + NEGATIVE="`gettext "There is no file to process."`" + fi + ;; + + esac + + # Print preamble message. + if [[ $POSITIVE != '' ]] && [[ $NEGATIVE == '' ]];then + cli_printMessage "$POSITIVE" + for FILE in $FILES;do + cli_printMessage "$FILE" "$FORMAT" + done + cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' + elif [[ $POSITIVE == '' ]] && [[ $NEGATIVE != '' ]];then + cli_printMessage "$NEGATIVE" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Functions/cli_printMessage.sh b/Functions/cli_printMessage.sh new file mode 100755 index 0000000..9cf3ec3 --- /dev/null +++ b/Functions/cli_printMessage.sh @@ -0,0 +1,180 @@ +#!/bin/bash +# +# cli_printMessage.sh -- This function outputs information in +# predifined formats to standard error. This function is the standard +# way to output information inside centos-art.sh script. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_printMessage { + + # Verify `--quiet' option. + if [[ "$FLAG_QUIET" == 'true' ]];then + return + fi + + local MESSAGE="$1" + local FORMAT="$2" + + # Reduce paths inside output messages. The main purpose for + # this is to free horizontal space in output messages. + MESSAGE=$(echo "$MESSAGE" \ + | sed -r "s!${HOME}/artwork/(trunk|branches|tags)/!\1/!g") + + # Remove blank spaces from lines' begining. + MESSAGE=$(echo "$MESSAGE" | sed -r 's!^[[:space:]]+!!') + + # Define message formats. + case $FORMAT in + + 'AsUpdatingLine' ) + cli_printMessage "`gettext "Updating"`: $MESSAGE" + ;; + + 'AsDeletingLine' ) + cli_printMessage "`gettext "Deleting"`: $MESSAGE" + ;; + + 'AsCheckingLine' ) + cli_printMessage "`gettext "Checking"`: $MESSAGE" + ;; + + 'AsCreatingLine' ) + cli_printMessage "`gettext "Creating"`: $MESSAGE" + ;; + + 'AsReadingLine' ) + cli_printMessage "`gettext "Reading"`: $MESSAGE" + ;; + + 'AsSavedAsLine' ) + cli_printMessage "`gettext "Saved as"`: $MESSAGE" + ;; + + 'AsLinkToLine' ) + cli_printMessage "`gettext "Linked to"`: $MESSAGE" + ;; + + 'AsMovedToLine' ) + cli_printMessage "`gettext "Moved to"`: $MESSAGE" + ;; + + 'AsTranslationLine' ) + cli_printMessage "`gettext "Translation"`: $MESSAGE" + ;; + + 'AsDesignLine' ) + cli_printMessage "`gettext "Design"`: $MESSAGE" + ;; + + 'AsConfigurationLine' ) + cli_printMessage "`gettext "Configuration"`: $MESSAGE" + ;; + + 'AsPaletteLine' ) + cli_printMessage "`gettext "Palette"`: $MESSAGE" + ;; + + 'AsResponseLine' ) + cli_printMessage "--> $MESSAGE" + ;; + + 'AsRequestLine' ) + cli_printMessage "${MESSAGE}: " 'AsNoTrailingNewLine' + ;; + + 'AsErrorLine' ) + # This option is used to print error messsages. + echo "${CLI_PROGRAM}: ${MESSAGE}" > /dev/stderr + ;; + + 'AsToKnowMoreLine' ) + # This option receives the output of bash's caller built-in as + # message value and produces the documentation entry from it. + MESSAGE=$(dirname "$(echo $MESSAGE | cut -d ' ' -f2-)") + cli_printMessage '-' 'AsSeparatorLine' + cli_printMessage "`gettext "To know more, run the following command"`:" + cli_printMessage "centos-art manual --read='$MESSAGE'" + cli_printMessage '-' 'AsSeparatorLine' + exit # <-- ATTENTION: Do not remove this line. We use this + # option as convenction to end script + # execution. + ;; + + 'AsYesOrNoRequestLine' ) + + # Define positive answer. + local Y="`gettext "yes"`" + + # Define negative answer. + local N="`gettext "no"`" + + # Define default answer. + local ANSWER=${FLAG_ANSWER} + + if [[ $ANSWER == 'false' ]];then + + # Print the question. + cli_printMessage "$MESSAGE [${Y}/${N}]: " 'AsNoTrailingNewLine' + + # Redefine default answer based on user's input. + read ANSWER + + fi + + # Verify user's answer. Only positive answer let the script + # flow to continue. Otherwise, if something different from + # possitive answer is passed, the script terminates its + # execution immediatly. + if [[ ! ${ANSWER} =~ "^${Y}" ]];then + exit + fi + ;; + + 'AsSeparatorLine' ) + + # Define separator width. + local MAX=70 + + # Draw separator. + until [[ $MAX -eq 0 ]];do + printf "${MESSAGE}" > /dev/stderr + MAX=$(($MAX - 1)) + done + + # Output newline to end separator. + echo "" > /dev/stderr + ;; + + 'AsNoTrailingNewLine' ) + printf "$MESSAGE" > /dev/stderr + ;; + + 'AsRegularLine' | * ) + echo "$MESSAGE" \ + | awk -f ${CLI_BASEDIR}/Styles/output_forTwoColumns.awk \ + > /dev/stderr + ;; + + esac + +} diff --git a/Functions/cli_readFileContent.sh b/Functions/cli_readFileContent.sh new file mode 100644 index 0000000..ab4edaf --- /dev/null +++ b/Functions/cli_readFileContent.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# cli_readFileContent.sh -- This function outputs content of files, +# passed as first argument, to standard output as specified by second +# argument. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_readFileContent { + + local FILES="$1" + local PATTERN='Copyright (\(C\)|©) [0-9]+(-[0-9]+)? .+' + + # Verify existence of files but don't stop if it doesn't exist. + cli_checkFiles "$FILES" + + # Print content of files to standard output. + case "$2" in + + '--copyright-line' ) + cat "$FILES" | egrep "^ +${PATTERN}$" | head -n 1 | sed -r 's!^ +!!' + ;; + + '--last-line' ) + cat "$FILES" | tail -n 1 + ;; + + '--copyright-year' ) + if [[ $(cli_readFileContent "$FILES" '--copyright-line') =~ "^${PATTERN}$" ]];then + cli_readFileContent "$FILES" '--copyright-line' | cut -d' ' -f3 + fi + ;; + + '--copyright-holder' ) + if [[ $(cli_readFileContent "$FILES" '--copyright-line') =~ "^${PATTERN}$" ]];then + cli_readFileContent "$FILES" '--copyright-line' | cut -d' ' -f4- + fi + ;; + + '--all-lines' | * ) + cat "$FILES" + ;; + + esac + +} diff --git a/Functions/cli_replaceTMarkers.sh b/Functions/cli_replaceTMarkers.sh new file mode 100755 index 0000000..7024a39 --- /dev/null +++ b/Functions/cli_replaceTMarkers.sh @@ -0,0 +1,146 @@ +#!/bin/bash +# +# cli_replaceTMarkers.sh -- This function standardizes +# replacements for common translation markers. Raplacements are +# applied to temporal instances used to produce the final file. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_replaceTMarkers { + + # Initialize variables. + local -a SRC + local -a DST + local COUNT=0 + local COUNTSRC=0 + local COUNTDST=0 + local LOCATION='' + + # Define source location on which sed replacements take place. + LOCATION="$1" + + # Verify file source location. + cli_checkFiles "$LOCATION" 'f' + + # Define translation markers. The translation marker definition + # order is important. Note that when we render concept directory + # structure, we make two replacements to produce the final + # copyright note. First, we replace =COPYRIGHT= translation marker + # and later the =THEMENAME= translation maker (not the oposite). + SRC[0]='=COPYRIGHT_YEAR=' + SRC[1]='=COPYRIGHT_HOLDER=' + SRC[2]='=LICENSE=' + SRC[3]='=LICENSE_URL=' + SRC[4]='=THEME=' + SRC[5]='=THEMENAME=' + SRC[6]='=THEMERELEASE=' + SRC[7]='=RELEASE=' + SRC[8]='=MAJOR_RELEASE=' + SRC[9]='=MINOR_RELEASE=' + SRC[10]='=URL=' + SRC[11]='=ARCH=' + SRC[12]='=URL_WIKI=' + SRC[13]='=URL_LISTS=' + SRC[14]='=URL_FORUMS=' + SRC[15]='=URL_MIRRORS=' + SRC[16]='=URL_DOCS=' + SRC[17]='=MAIL_DOCS=' + SRC[18]='=LOCALE_LL=' + + # Define replacements for translation markers. + DST[0]="$(cli_getCopyrightInfo '--copyright-year')" + DST[1]="$(cli_getCopyrightInfo '--copyright-holder')" + DST[2]="$(cli_getCopyrightInfo '--license')" + DST[3]="$(cli_getCopyrightInfo '--license-url')" + DST[4]="$(cli_getPathComponent "$OUTPUT" '--theme')" + DST[5]="$(cli_getPathComponent "$OUTPUT" '--theme-name')" + DST[6]="$(cli_getPathComponent "$OUTPUT" '--theme-release')" + DST[7]="$(cli_getPathComponent "$FLAG_RELEASEVER" '--release')" + DST[8]="$(cli_getPathComponent "$FLAG_RELEASEVER" '--release-major')" + DST[9]="$(cli_getPathComponent "$FLAG_RELEASEVER" '--release-minor')" + DST[10]="http://www.centos.org/=LOCALE_LL=" + DST[11]="$(cli_getPathComponent "$FLAG_BASEARCH" '--architecture')" + DST[12]="http://wiki.centos.org/=LOCALE_LL=" + DST[13]="http://lists.centos.org/=LOCALE_LL=" + DST[14]="http://forums.centos.org/=LOCALE_LL=" + DST[15]="http://mirrors.centos.org/=LOCALE_LL=" + DST[16]="http://docs.centos.org/=LOCALE_LL=" + DST[17]="centos-docs@=LOCALE_LL=.centos.org" + if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then + DST[18]="$(cli_getCurrentLocale '--langcode-only')/" + else + DST[18]='' + fi + + # Do replacement of nested translation markers. + while [[ $COUNTDST -lt ${#DST[@]} ]];do + + # Verify existence of translation markers. If there is no + # translation marker on replacement, continue with the next + # one in the list. + if [[ ! ${DST[$COUNTDST]} =~ '=[A-Z_]+=' ]];then + # Increment destination counter. + COUNTDST=$(($COUNTDST + 1)) + # The current replacement value doesn't have translation + # marker inside, so skip it and evaluate the next + # replacement value in the list. + continue + fi + + while [[ $COUNTSRC -lt ${#SRC[*]} ]];do + + # Update replacements. + DST[$COUNTDST]=$(echo ${DST[$COUNTDST]} \ + | sed -r "s!${SRC[$COUNTSRC]}!${DST[$COUNTSRC]}!g") + + # Increment source counter. + COUNTSRC=$(($COUNTSRC + 1)) + + done + + # Reset source counter + COUNTSRC=0 + + # Increment destination counter. + COUNTDST=$(($COUNTDST + 1)) + + done + + # Apply replacements for translation markers. + while [[ ${COUNT} -lt ${#SRC[*]} ]];do + + # Use sed to replace translation markers inside the design + # model instance. + sed -r -i "s!${SRC[$COUNT]}!${DST[$COUNT]}!g" ${LOCATION} + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + + # Unset specific translation markers and specific replacement + # variables in order to clean them up. Otherwise, undesired values + # may ramain from one file to another. + unset SRC + unset DST + +} diff --git a/Functions/cli_syncroRepoChanges.sh b/Functions/cli_syncroRepoChanges.sh new file mode 100644 index 0000000..c3697ea --- /dev/null +++ b/Functions/cli_syncroRepoChanges.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# cli_syncroRepoChanges.sh -- This function syncronizes both central +# repository and working copy performing a subversion update command +# first and a subversion commit command later. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_syncroRepoChanges { + + # Verify don't commit changes flag. + if [[ $FLAG_DONT_COMMIT_CHANGES != 'false' ]];then + return + fi + + # Define source location the subversion update action will take + # place on. If arguments are provided use them as srouce location. + # Otherwise use action value as default source location. + if [[ "$@" != '' ]];then + LOCATIONS="$@" + else + LOCATIONS="$ACTIONVAL" + fi + + # Bring changes from the repository into the working copy. + cli_updateRepoChanges "$LOCATIONS" + + # Check changes in the working copy. + cli_commitRepoChanges "$LOCATIONS" + +} diff --git a/Functions/cli_updateRepoChanges.sh b/Functions/cli_updateRepoChanges.sh new file mode 100644 index 0000000..3c037e0 --- /dev/null +++ b/Functions/cli_updateRepoChanges.sh @@ -0,0 +1,114 @@ +#!/bin/bash +# +# cli_updateRepoChanges.sh -- This function realizes a subversion +# update command against the working copy in order to bring changes +# from the central repository into the working copy. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_updateRepoChanges { + + # Verify don't commit changes flag. + if [[ $FLAG_DONT_COMMIT_CHANGES != 'false' ]];then + return + fi + + local -a FILES + local -a INFO + local -a FILESNUM + local COUNT=0 + local UPDATEOUT='' + local PREDICATE='' + local CHNGTOTAL=0 + local LOCATIONS='' + + # Define source location the subversion update action will take + # place on. If arguments are provided use them as srouce location. + # Otherwise use action value as default source location. + if [[ "$@" != '' ]];then + LOCATIONS="$@" + else + LOCATIONS="$ACTIONVAL" + fi + + # Verify locations existence. It shoud exist as regular file or + # directory inside the repository working copy. + cli_checkFiles "$LOCATIONS" 'fd' + cli_checkFiles "$LOCATIONS" 'isInWorkingCopy' + + # Outout separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Update working copy and retrive update output. + cli_printMessage "`gettext "Bringing changes from the repository into the working copy"`" 'AsResponseLine' + UPDATEOUT=$(svn update ${LOCATIONS}) + + # Outout separator line. + cli_printMessage '-' 'AsSeparatorLine' + + # Define path of files considered recent modifications from + # central repository to working copy. + FILES[0]=$(echo "$UPDATEOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[1]=$(echo "$UPDATEOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[2]=$(echo "$UPDATEOUT" | egrep "^U.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[3]=$(echo "$UPDATEOUT" | egrep "^C.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + FILES[4]=$(echo "$UPDATEOUT" | egrep "^G.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") + + # Define description of files considered recent modifications from + # central repository to working copy. + INFO[0]="`gettext "Added"`" + INFO[1]="`gettext "Deleted"`" + INFO[2]="`gettext "Updated"`" + INFO[3]="`gettext "Conflicted"`" + INFO[4]="`gettext "Merged"`" + + while [[ $COUNT -ne ${#FILES[*]} ]];do + + # Define total number of files. Avoid counting empty line. + if [[ "${FILES[$COUNT]}" == '' ]];then + FILESNUM[$COUNT]=0 + else + FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l) + fi + + # Calculate total amount of changes. + CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]})) + + # Build report predicate. Use report predicate to show any + # information specific to the number of files found. For + # example, you can use this section to show warning messages, + # notes, and so on. By default we use the word `file' or + # `files' at ngettext's consideration followed by change + # direction. + PREDICATE[$COUNT]=`ngettext "file from the repository" \ + "files from the repository" $((${FILESNUM[$COUNT]} + 1))` + + # Output report line. + cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" 'AsRegularLine' + + # Increase counter. + COUNT=$(($COUNT + 1)) + + done + +} + diff --git a/Scripts/Bash/Cli/Functions/About/Config/authors.txt b/Scripts/Bash/Cli/Functions/About/Config/authors.txt deleted file mode 100644 index 589e6f8..0000000 --- a/Scripts/Bash/Cli/Functions/About/Config/authors.txt +++ /dev/null @@ -1,8 +0,0 @@ -$Id$ -This file records authoring information of CentOS Artwork Repository, -in alphabetical order. - -Ralph Angenendt -Marcus Moeller -Alain Reguera Delgado , 2009, 2010, 2011 -Karanbirn Singh diff --git a/Scripts/Bash/Cli/Functions/About/Config/copying.txt b/Scripts/Bash/Cli/Functions/About/Config/copying.txt deleted file mode 100644 index 0dce2aa..0000000 --- a/Scripts/Bash/Cli/Functions/About/Config/copying.txt +++ /dev/null @@ -1,52 +0,0 @@ -$Id$ -This file records copying information of CentOS Artwork Repository. - - - THE CENTOS ARTWORK REPOSITORY LICENSE - Version 1, 2011 - - Copyright © 2009-2011 Alain Reguera Delgado - Calle 39 e/ 44 y 46 No. 4426 Cienfuegos, Cuba. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - TERMS AND CONDITIONS FOR COPYING, - DISTRIBUTION AND MODIFICATION - - The CentOS Artwork Repository provides the file structure the - centos-art script needs to work as expected. The terms under - which such file structure is redistributed and/or modified - depends of the redistribution terms of the centos-art script - itself. - - The centos-art script is free software; you can redistribute - it and/or modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later - version. - - The centos-art script is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, - USA. - - The content produced inside The CentOS Artwork Repository - cannot enter in conflict with the redistribution terms of the - centos-art script, even both the centos-art script and the - content produced are quiet different types of work (e.g., the - centos-art script is a Bash program and the content produced - can take form of SVG files, PNG files, HTML files, and many - other open standards.). - - The content produced inside The CentOS Artwork Repository that - is marked with The CentOS Symbol, The CentOS Logo or The - CentOS Trademark is of internal use for The CentOS Project - only and you are not allowd to use it for your own purposes - without previous conversation with The CentOS Project. - However, if you are interested in studying such contents and - proposing your improvements, you are very welcome to do so. diff --git a/Scripts/Bash/Cli/Functions/About/Config/history.txt b/Scripts/Bash/Cli/Functions/About/Config/history.txt deleted file mode 100644 index 1b98ad5..0000000 --- a/Scripts/Bash/Cli/Functions/About/Config/history.txt +++ /dev/null @@ -1,136 +0,0 @@ -$Id$ -This file records noteworthy changes of CentOS Artwork Repository. - - Copyright (C) 2009-2011 Alain Reguera Delgado - - Copying and distribution of this file, with or without modification, are - permitted in any medium without royalty provided the copyright notice and - this notice are preserved. - -------------------------------------------------------------------------------- -(2011) - - - Unify common arguments for all specific functionalities (e.g, --answer, - --quiet, --filter, etc.) and leave just specific arguments for specific - functions to parse. There is no need to duplicate common arguments - definitions inside every specific functionality. - - - The `.sed' translation files are no longer used, scalable vector - graphics are used instead. Translation messages take place by means of - xml2po and gettext. With xml2po translatable strings are retrived from - `.svg' files and stored inside gettext `.pot' and `.po' files for - translators to edit. Finally, xml2po is used again to build the temporal - design model translated instance which the final `.png' image is built - from. - - - The `trunk/Translation' directory structure is removed. The - `trunk/Locales' directory structure is used instead to store locale - information. - -------------------------------------------------------------------------------- -(2010) - - - Inside centos-art.sh script, functionalities start to get - identified and separated one from another. For example, when - images are rendered, there is no need to load manual - functionality. There are now common functionalities and specific - functionalities. Common functionalities are loaded when the - script is initiated and are available to specific - functionalities. - - - The directory structure is optimized to implements the corporate - identity concepts and the centos-art.sh script. The CentOS - Artwork Repository directory structure places the organizational - convenctions that centos-art.sh script needs to do what we - expect from it to do. - - - The following functionalities start to take form as part of - centos-art.sh script: - - `trunk/Scripts/Bash/Functions/Render/render.sh' - - To produce translated images using Inkscape and Sed - replacement commands. - - `trunk/Scripts/Bash/Functions/Manual/manual.sh' - - To produce documentation using Texinfo. Almost all - LaTeX-based documents were moved to Texinfo format and - handled by manual functionality. - - `trunk/Scripts/Bash/Functions/Locale/locale.sh' - - To translate centos-art.sh command-line interface messages - using gettext. - - `trunk/Scripts/Functions/Shell/shell.sh' - - To perform massive actions inside shell scripts. For - example, update top-commentaries massively. - - `trunk/Scripts/Functions/Svg/svg.sh' - - To perform massive actions inside SVG files. - - `trunk/Scripts/Functions/Html/html.sh' - - To perform massive actions inside HTML files. - - `trunk/Scripts/Functions/Path/path.sh' - - To automate manipulation of files, branches, and tags. - - `trunk/Scripts/Functions/About/about.sh' - - To print license, authors, history, copying, etc. - -------------------------------------------------------------------------------- -(2009) - - - The rendering script starts to evolve into centos-art.sh script, a - command-line interface to manipulate the CentOS Artwork Repository. - - - Corporate identity concepts taken from Wikipedia and related books are - introduced as development reference. The main goal of centos-art.sh - turns to: automate production of a monolithic corporate visual identity - structure based on CentOS Mission and CentOS Release Schema. - - - Alain Reguera Delgado is out of Internet for an undefined amount of - time, but continues developing CentOS Artwork Repository and its - automation tool (i.e., the centos-art.sh script) off-line. - - - Documentation begins to take form in LaTeX format. - -------------------------------------------------------------------------------- -(2008) - - - The CentOS Artwork Repository started at CentOS Developers - mailing list. - - - Alain Reguera Delgado shares ideas in a thread about Anaconda - progress slide images and the possibility of automating their - construction. - - - Ralph Angenendt rises up his hand asking: Do you have something - to show? - - - Alain Reguera Delgado posts a Bash script to produce slide - images in different languages ---together with the proposition - of creating a Subversion centralized repository where - translations and image production could be distributed inside - CentOS Community---. - - - Karanbirn Sighn considers the idea intresting and provides the - infrastructure to support the effort as the CentOS Artwork SIG. - - https://projects.centos.org/svn/artwork/ - https://projects.centos.org/trac/artwork/ - - - Alain Reguera Delagdo uploads the rendering script to CentOS - Artwork Repository. - - - Ralph Angenendt documents the rendering script. - - - With the rendering script and its documentation available, - translators start to download working copies of CentOS Artwork - Repository to produce slide images in their own languages. diff --git a/Scripts/Bash/Cli/Functions/About/Config/license.txt b/Scripts/Bash/Cli/Functions/About/Config/license.txt deleted file mode 100644 index 5b6e7c6..0000000 --- a/Scripts/Bash/Cli/Functions/About/Config/license.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/Scripts/Bash/Cli/Functions/About/about.sh b/Scripts/Bash/Cli/Functions/About/about.sh deleted file mode 100755 index 77ea1d2..0000000 --- a/Scripts/Bash/Cli/Functions/About/about.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# license.sh -- This function outputs centos-art.sh about messages. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function about { - - # Define command-line interface. - about_getActions - -} diff --git a/Scripts/Bash/Cli/Functions/About/about_getActions.sh b/Scripts/Bash/Cli/Functions/About/about_getActions.sh deleted file mode 100755 index 15d714b..0000000 --- a/Scripts/Bash/Cli/Functions/About/about_getActions.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# -# about_getActions.sh -- This function interpretes arguments passed to -# about functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function about_getActions { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="license,history,authors,copying" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - case "$1" in - - --license ) - ACTIONVAL="${FUNCCONFIG}/license.txt" - break - ;; - - --history ) - ACTIONVAL="${FUNCCONFIG}/history.txt" - break - ;; - - --authors ) - ACTIONVAL="${FUNCCONFIG}/authors.txt" - break - ;; - - --copying | * ) - ACTIONVAL="${FUNCCONFIG}/copying.txt" - break - ;; - - esac - done - - # Execute action name. - if [[ -f $ACTIONVAL ]];then - less $ACTIONVAL - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Brand/brandAnaconda.sh b/Scripts/Bash/Cli/Functions/Brand/brandAnaconda.sh deleted file mode 100644 index 8b215eb..0000000 --- a/Scripts/Bash/Cli/Functions/Brand/brandAnaconda.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -# -# brandAnaconda - Anaconda branding script. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function brandAnaconda { - - # Define file's source and target. - local ARTDIR=~/artwork/trunk/Identity/Themes/$(cli_getPathComponent '--theme')/Distro/Anaconda - local PIXMAP=/usr/share/anaconda/pixmaps - local SOURCE='' - local TARGET='' - - # Define list of files used as base to determine which files may - # need to be updated. Remove target from file path. Do not use - # basename command. We may need the directory structure (if any) - # under target, for further evaluation. - local FILES=$(find ${PIXMAP}/ | sort | uniq | sed "s!${PIXMAP}/!!g") - local FILE='' - - for FILE in $FILES;do - - # Define which file is release-specific, and specify the correct - # path on source. - case $FILE in - anaconda_header.png ) - SOURCE=$ARTDIR/Header/Img/$MAJOR_RELEASE/$FILE - TARGET=$PIXMAP/$FILE - ;; - - progress_first*.png | first*.png ) - SOURCE=$ARTDIR/Progress/Img/$MAJOR_RELEASE/$FILE - TARGET=$PIXMAP/$FILE - ;; - - rnotes | rnotes/?? | rnotes/??_?? ) - continue - ;; - - rnotes/??-*.png ) - FILE=$(basename $FILE | sed -r 's!-centos[0-9]+!!') - SOURCE=$ARTDIR/Progress/Img/$MAJOR_RELEASE/en/$FILE - TARGET=$PIXMAP/rnotes/$FILE - ;; - - rnotes/*/??-*.png ) - LANGUAGE=$(echo $FILE | sed -r 's!rnotes/(.+)/.*!\1!') - FILE=$(basename $FILE | sed -r 's!-centos[0-9]+!!') - SOURCE=$ARTDIR/Progress/Img/$MAJOR_RELEASE/$LANGUAGE/$FILE - TARGET=$PIXMAP/rnotes/$LANGUAGE/$FILE - ;; - - splash.png ) - SOURCE=$ARTDIR/Splash/Img/$MAJOR_RELEASE/$FILE - TARGET=$PIXMAP/$FILE - ;; - - syslinux-splash.png ) - TARGET=$PIXMAP/$FILE - FILE=$(echo $FILE | sed -r 's!\.png$!-16c.png!') - SOURCE=$ARTDIR/Prompt/Img/$MAJOR_RELEASE/$FILE - ;; - - * ) - TARGET=$PIXMAP/$FILE - SOURCE=$ARTDIR/$FILE - esac - - # Check if file exists on source. If file doesn't exist on the - # source it is not updated on target. Go to next file in the - # loop and check again. Only file names on source that match - # those in target are updated. - cli_checkFiles "$SOURCE" - - # File exists and will be installed on target. - cli_printMessage "$TARGET" "AsUpdatingLine" - - # Update file. - #cp $SOURCE $TARGET - - # Set file's access rights. - #chown root:root $TARGET - #chmod 755 $TARGET - #chcon system_u:object_r:usr_t $TARGET - -done -} diff --git a/Scripts/Bash/Cli/Functions/Brand/brandFirstboot.sh b/Scripts/Bash/Cli/Functions/Brand/brandFirstboot.sh deleted file mode 100755 index cb785d7..0000000 --- a/Scripts/Bash/Cli/Functions/Brand/brandFirstboot.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# -# brandFirstboot - Firstboot branding script. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function brandFirstboot { - - # Define file's source and target. - local ARTDIR=~/artwork/trunk/Identity/Themes/$(cli_getPathComponent '--theme')/Distro/Anaconda - local PIXMAP=/usr/share/firstboot/pixmaps - local SOURCE='' - local TARGET='' - - # Define list of files used as base to determine which files may - # need to be updated. Remove target from file path. Do not use - # basename command. We may need the directory structure (if any) - # under target, for further evaluation. - local FILES=$(find ${PIXMAP}/ | sort | uniq | sed "s!${PIXMAP}/!!g") - local FILE='' - - for FILE in $FILES;do - - # Define which file is release-specific, and specify the correct - # path on source. - case $FILE in - - splash-small.png ) - SOURCE=$ARTDIR/Firstboot/Img/$MAJOR_RELEASE/$FILE - TARGET=$PIXMAP/$FILE - ;; - - firstboot-left.png ) - SOURCE=$ARTDIR/Firstboot/Img/$FILE - TARGET=$PIXMAP/$FILE - ;; - - * ) - SOURCE=$ARTDIR/Firstboot/Img/$FILE - TARGET=$PIXMAP/$FILE - esac - - # Check if file exists on source. If file doesn't exist on the - # source it is not updated on target. Go to next file in the - # loop and check again. Only file names on source that match - # those in target are updated. - cli_checkFiles "$SOURCE" - - # File exists and will be installed on target. - cli_printMessage "$TARGET" "AsUpdatingLine" - - # Update file. - #cp $SOURCE $TARGET - - # Set file's access rights. - #chown root:root $TARGET - #chmod 755 $TARGET - #chcon system_u:object_r:usr_t $TARGET - - done -} diff --git a/Scripts/Bash/Cli/Functions/Help/Config/manual-copyright-cc-by-sa.texi b/Scripts/Bash/Cli/Functions/Help/Config/manual-copyright-cc-by-sa.texi deleted file mode 100755 index 8dab9f4..0000000 --- a/Scripts/Bash/Cli/Functions/Help/Config/manual-copyright-cc-by-sa.texi +++ /dev/null @@ -1,8 +0,0 @@ -Copyright @copyright{} =COPYRIGHT_YEAR= =COPYRIGHT_HOLDER= - -Permission is granted to copy, distribute and/or modify this document -under the terms of the a Creative Commons Attribution–Share Alike 3.0 -Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available -at @url{http://creativecommons.org/licenses/by-sa/3.0/}. In accordance -with CC-BY-SA, if you distribute this document or an adaptation of it, -you must provide the URL for the original version. diff --git a/Scripts/Bash/Cli/Functions/Help/Config/manual-copyright-gfdl.texi b/Scripts/Bash/Cli/Functions/Help/Config/manual-copyright-gfdl.texi deleted file mode 100755 index 2a48f99..0000000 --- a/Scripts/Bash/Cli/Functions/Help/Config/manual-copyright-gfdl.texi +++ /dev/null @@ -1,8 +0,0 @@ -Copyright @copyright{} =COPYRIGHT_YEAR= =COPYRIGHT_HOLDER= - -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 or -any later version published by the Free Software Foundation; with no -Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A -copy of the license is included in the section entitled ``GNU Free -Documentation License''. diff --git a/Scripts/Bash/Cli/Functions/Help/Config/manual-index.texi b/Scripts/Bash/Cli/Functions/Help/Config/manual-index.texi deleted file mode 100644 index abe002c..0000000 --- a/Scripts/Bash/Cli/Functions/Help/Config/manual-index.texi +++ /dev/null @@ -1,3 +0,0 @@ -@node Index -@unnumbered Index -@printindex cp diff --git a/Scripts/Bash/Cli/Functions/Help/Config/manual-intro.texi b/Scripts/Bash/Cli/Functions/Help/Config/manual-intro.texi deleted file mode 100644 index e69de29..0000000 --- a/Scripts/Bash/Cli/Functions/Help/Config/manual-intro.texi +++ /dev/null diff --git a/Scripts/Bash/Cli/Functions/Help/Config/manual-menu.texi b/Scripts/Bash/Cli/Functions/Help/Config/manual-menu.texi deleted file mode 100644 index 70362c8..0000000 --- a/Scripts/Bash/Cli/Functions/Help/Config/manual-menu.texi +++ /dev/null @@ -1,3 +0,0 @@ -@menu -* Index:: -@end menu diff --git a/Scripts/Bash/Cli/Functions/Help/Config/manual-nodes.texi b/Scripts/Bash/Cli/Functions/Help/Config/manual-nodes.texi deleted file mode 100644 index e69de29..0000000 --- a/Scripts/Bash/Cli/Functions/Help/Config/manual-nodes.texi +++ /dev/null diff --git a/Scripts/Bash/Cli/Functions/Help/Config/manual-section.texi b/Scripts/Bash/Cli/Functions/Help/Config/manual-section.texi deleted file mode 100644 index fb39647..0000000 --- a/Scripts/Bash/Cli/Functions/Help/Config/manual-section.texi +++ /dev/null @@ -1,22 +0,0 @@ -@subsection Goals - -@itemize -@item ... -@end itemize - -@subsection Description - -@itemize -@item ... -@end itemize - -@subsection Usage - -@itemize -@item ... -@end itemize - -@subsection See also - -@menu -@end menu diff --git a/Scripts/Bash/Cli/Functions/Help/Config/manual.texi b/Scripts/Bash/Cli/Functions/Help/Config/manual.texi deleted file mode 100644 index 3d05184..0000000 --- a/Scripts/Bash/Cli/Functions/Help/Config/manual.texi +++ /dev/null @@ -1,55 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c $Id$ -@c -- Header -------------------------------------------------- - -@setfilename =FILENAME=.info -@settitle =TITLE= -@documentlanguage =LOCALE_LL= -@afourpaper -@finalout - -@c -- Summary description and copyright ----------------------- - -@copying -=DESCRIPTION= - -Copyright @copyright{} =COPYRIGHT_YEAR= =COPYRIGHT_HOLDER= - -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 or -any later version published by the Free Software Foundation; with no -Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A -copy of the license is included in the section entitled GNU Free -Documentation License. -@end copying - -@c -- Titlepage, contents, copyright --------------------------- - -@titlepage -@title =TITLE= -@subtitle =SUBTITLE= -@author =AUTHOR= -@page -@vskip 0pt plus 1filll -@insertcopying -@end titlepage -@contents - -@c -- `Top' node and master menu ------------------------------- - -@ifnottex -@node Top -@top =TITLE= -@insertcopying -@end ifnottex -@include manual-menu.texi - -@c -- The body of the document -------------------------------- - -@include manual-nodes.texi - -@c -- The end of the document --------------------------------- - -@include manual-index.texi - -@bye diff --git a/Scripts/Bash/Cli/Functions/Help/help.sh b/Scripts/Bash/Cli/Functions/Help/help.sh deleted file mode 100755 index 6f17e68..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash -# -# help.sh -- This function provides documentation features to -# centos-art.sh script. Here we initialize documentation variables and -# call help_getArguments functions. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help { - - local ACTIONNAM='' - local ACTIONVAL='' - - # Define manuals base directory. This is the place where - # documentation manuals base directory structures are stored and - # organized in. - MANUAL_BASEDIR="${HOME}/artwork/trunk/Manual" - - # Define file name for documentation manual. This is the file used - # to initiate the structure of documentation manual. - MANUAL_NAME=repository - - # Define base name for documentation manual files (without - # extension). This is the main file name used to build texinfo - # related files (.info, .pdf, .xml, etc.). - MANUAL_BASEFILE="${MANUAL_BASEDIR}/${MANUAL_NAME}" - - # Interpret arguments and options passed through command-line. - help_getArguments - - # Redefine positional parameters using ARGUMENTS. At this point, - # option arguments have been removed from ARGUMENTS variable and - # only non-option arguments remain in it. - eval set -- "$ARGUMENTS" - - # Define action name. It does matter what option be passed to - # centos-art, there are many different actions to perform based on - # the option passed (e.g., `--edit', `--read', `--search', etc.). - # In that sake, we defined action name inside help_getArguments, - # at the moment of interpreting options. - - # Define default manual node shown when no argument is provided to - # help functionality. By default, the Top node of repository - # manual is called. - if [[ $ACTIONNAM == '' ]] && [[ $ACTIONVAL == '' ]];then - /usr/bin/info --node="Top" --file=${MANUAL_BASEFILE}.info.bz2 - fi - - # Define action value. As convenction, we use non-option arguments - # to define the action value (ACTIONVAL) variable. - for ACTIONVAL in "$@";do - - if [[ $ACTIONVAL == '--' ]];then - continue - fi - - # Check action value passed through the command-line using - # source directory definition as reference. - cli_checkRepoDirSource - - # Define documentation entry. - ENTRY=$(help_getEntry) - - # Define documentation entry directory. This is the directory - # where the entry file is stored. - ENTRY_DIR=$(dirname ${ENTRY} | sed -r 's!\.texi$!!') - - # Define documentation entry file (without extension). - ENTRY_FILE=$(basename ${ENTRY} | sed -r 's!\.texi$!!') - - # Define directory to store documentation entries. At this - # point, we need to take a desition about documentation - # design, in order to answer the question: How do we assign - # chapters, sections and subsections automatically, based on - # the repository structure? and also, how such design could - # be adapted to changes in the repository structure? - # - # One solution would be: represent the repository's directory - # structure as sections inside a chapter named Filesystem or - # something similar. Subsections and subsubsections will not - # have their own files, they all will be written inside the - # same section file that represents the repository directory. - MANUAL_CHAPTER_DIR=$(echo $ENTRY | cut -d / -f-7) - - # Define chapter name for the documentation entry we are - # working with. - MANUAL_CHAPTER_NAME=$(basename "$MANUAL_CHAPTER_DIR") - - # Set action preable. - cli_printActionPreamble "${MANUAL_BASEFILE}.texi" '' '' - - # Syncronize changes between repository and working copy. At - # this point, changes in the repository are merged in the - # working copy and changes in the working copy committed up to - # repository. - cli_syncroRepoChanges ${MANUAL_BASEDIR} - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Commit changes from working copy to central repository only. - # At this point, changes in the repository are not merged in - # the working copy, but chages in the working copy do are - # committed up to repository. - cli_commitRepoChanges ${MANUAL_BASEDIR} - - done -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_copyEntry.sh b/Scripts/Bash/Cli/Functions/Help/help_copyEntry.sh deleted file mode 100755 index 707b541..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_copyEntry.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# -# help_copyEntry.sh -- This function copies documentation entries and -# updates documentation structure to reflect changes. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_copyEntry { - - local ENTRY_SRC=${ENTRY} - local ENTRY_DST=${FLAG_TO} - local ENTRIES='' - local ENTRY='' - - # Print action message. - cli_printMessage "${ENTRY_DST}" 'AsCreatingLine' - - # Copy main documentation entry. - if [[ ! -f ${ENTRY_DST} ]];then - svn cp "${ENTRY_SRC}" "${ENTRY_DST}" --quiet - fi - - # Define target location of directory holding dependent - # documentation entries. - ENTRY_DST=$(echo ${ENTRY_DST} | sed -r 's!\.texi$!!') - - # Copy dependent documentation entries, if any. - if [[ ! -d ${ENTRY_DST} ]];then - cli_printMessage "${ENTRY_DST}" 'AsCreatingLine' - svn cp "${ENTRY_DIR}/${ENTRY_FILE}" "${ENTRY_DST}" --quiet - fi - - # Define list of files to process. - ENTRIES=$(cli_getFilesList "$(dirname ${ENTRY_DST})" "$(basename ${ENTRY_DST}).*\.texi") - - # Set action preamble. - cli_printActionPreamble "${ENTRIES}" '' '' - - # Print separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Print action message. - cli_printMessage "Updating manual menus, nodes and cross-references." 'AsResponseLine' - - # Redefine ENTRY variable in order to update documentation - # structure, taking recently created entries as reference. - for ENTRY in ${ENTRIES};do - - # Update menu and node definitions from manual sections to - # reflect the changes. - help_updateMenu - help_updateNodes - - # Update cross reference definitions from manual to reflect - # the changes. - help_restoreCrossReferences - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_deleteCrossReferences.sh b/Scripts/Bash/Cli/Functions/Help/help_deleteCrossReferences.sh deleted file mode 100755 index 9152fc8..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_deleteCrossReferences.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -# -# help_deleteCrossReferences.sh -- This function looks inside -# texinfo source files, from section level on, and removes all cross -# referece definitions related to a documentation entry. Use this -# function in coordination with help_deleteEntry function, in order -# to keep cross reference information, inside the documentation -# manual, syncronized. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_deleteCrossReferences { - - local -a PATTERN - local -a REPLACE - local LOCATION='' - - # Define entry location. Verify first argument to make this - # function reusable. If no value is passed as first argument use - # entry global information value as default value instead. - if [[ "$1" != '' ]];then - LOCATION="$1" - else - LOCATION="$ENTRY" - fi - - # Build the node string using entry location. - local NODE=$(echo "$LOCATION" \ - | cut -d / -f8- \ - | tr '/' ' ' \ - | sed -r \ - -e "s/(chapter-intro\.texi|\.texi)$//" \ - -e 's! !( |\\n)!g') - - # Define regular expression patterns for texinfo cross reference - # commands. - PATTERN[0]="@(pxref|xref|ref)\{(${NODE})\}" - PATTERN[1]="^(\* ${NODE}:(.*)?:(.*)?)$" - - # Define replacement string for missing entries. It is convenient - # to keep missing entries in documentation for documentation team - # to know. Removing the missing cross reference may intorudce - # confussion. Imagine that! you are spending lots of hours in an - # article and suddenly one of your cross refereces disappears with - # no visible reason, with the next working copy update you - # perform. That's frustrating. Instead, when centos-art.sh script - # finds a missing cross reference it removes the link and remark - # the issue for you to act on it. - REPLACE[0]='--- @strong{'`gettext "Removed"`'}(\1:\2) ---' - REPLACE[1]='@comment --- '`gettext "Removed"`'(\1) ---' - - # Define list of entries to process. - local ENTRIES=$(cli_getFilesList "${MANUAL_BASEDIR}" '.*\.texi') - - # Set action preamble. - cli_printActionPreamble "$ENTRIES" '' '' - - # Update node-related cross references. The node-related cross - # reference definition, long ones specially, could require more - # than one line to be set. By default, GNU sed does not matches - # newline characters in the pattern space, so we need to make use - # of `label' feature and the `N' command in order to build a - # pattern space that includes the newline character in it. Here we - # use the `a' letter to name the label we use, followed by N - # command to add a newline to the pattern space, the s command to - # make the pattern replacement using the `g' flag to make it - # global and finaly the command `b' to branch label named `a'. - sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${ENTRIES} - - # Update menu-related cross references. Menu-related cross - # references hardly appear in more than one line, so there is no - # need to complicate the replacement command. - sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${ENTRIES} - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_deleteEntry.sh b/Scripts/Bash/Cli/Functions/Help/help_deleteEntry.sh deleted file mode 100755 index ba5e0b8..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_deleteEntry.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash -# -# help_deleteEntry.sh -- This function removes a documentation entry -# from documentation directory structure. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_deleteEntry { - - local ENTRY_SRC=${ENTRY} - local ENTRIES='' - local ENTRY='' - local ENTRY_DEP='' - - # Initiate list of entries to remove using the entry specified in - # the command line. - ENTRIES=${ENTRY_SRC} - - # Verify existence of dependent entries. Dependent entries are - # stored inside a directory with the same name of the entry you - # are trying to remove. - if [[ -d ${ENTRY_DIR}/${ENTRY_FILE} ]];then - - # Add dependent files to list of entries. - ENTRIES="${ENTRIES} $(cli_getFilesList "${ENTRY_DIR}/${ENTRY_FILE}" ".*\.texi")" - - # Add dependent directories to list of entries. Be aware of - # nested directories. - for ENTRY in ${ENTRIES};do - ENTRY_DEP=$(echo $ENTRY | sed -r "s/\.texi$//") - if [[ -d $ENTRY_DEP ]];then - ENTRIES="${ENTRIES} ${ENTRY_DEP}" - fi - done - - fi - - # Prepare list of entries for action preamble. - ENTRIES=$(echo ${ENTRIES} | tr ' ' "\n" | sort -r | uniq) - - # Print action preamble. - cli_printActionPreamble "$ENTRIES" 'doDelete' 'AsResponseLine' - - # Remove documentation entry using regular subversion commands. - # Do not use regular rm command here, use subversion del command - # instead. Otherwise, even the file is removed, it will be brought - # back when the final cli_commitRepoChange be executed. Remember - # there is a subversion update there, no matter what you remove - # using regular commands, when you do update the directory - # structure on the working copy the removed files (not removed in - # the repository, nor marked to be removed) are brought down to - # the working copy again. - svn del ${ENTRIES} --quiet - if [[ $? -ne 0 ]];then - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Print separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Print action message. - cli_printMessage "Updating manual menus, nodes and cross-references." 'AsResponseLine' - - # Process list of entries in order to update menus, nodes and - # cross references. Since we are verifying entry status before - # remove the we cannot update the information in the same loop we - # remove files. This would modify some file before be removed and - # that would stop script execution. Similary, if we do update - # menus, nodes and cross references before removing files it would - # be needed to remove farther status verification in order for the - # script to continue its execution. Thereby, I can't see a - # different way but removing files first using status verification - # and later go through entities list again to update menus, nodes - # and cross references from remaining files. - for ENTRY in ${ENTRIES};do - - # Use entry files only. Directories are used to store - # dependent entries. Directories are not considered entries on - # themselves. - if [[ ! -f $ENTRY ]];then - continue - fi - - # Update menu and node definitions from manual sections to - # reflect the changes. - help_updateMenu "remove-entry" - help_updateNodes - - # Update cross reference definitions from manual to reflect - # the changes. - help_deleteCrossReferences - - done - - # Remove entry menus and nodes from chapter definition to reflect - # the fact it has been removed. This is mainly applied when one - # of the chapters (e.g., trunk/, tags/, or branches/) is removed. - if [[ ! -d $MANUAL_CHAPTER_DIR ]];then - help_updateChaptersMenu 'remove-entry' - help_updateChaptersNodes - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_editEntry.sh b/Scripts/Bash/Cli/Functions/Help/help_editEntry.sh deleted file mode 100755 index 6041267..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_editEntry.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# -# help_editEntry.sh -- This function implements the edition flow of -# documentation entries inside the working copy. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_editEntry { - - # Verify chapter definition inside manual. - if [[ ! -d $MANUAL_CHAPTER_DIR ]];then - - # Print confirmation question. - cli_printMessage "`gettext "The following documentation chapter will be created:"`" - cli_printMessage "$MANUAL_CHAPTER_DIR" "AsResponseLine" - cli_printMessage "`gettext "Do you want to continue?"`" "AsYesOrNoRequestLine" - - # Update manual chapter related files. - help_updateChaptersFiles - - # Update manual chapter related menu. - help_updateChaptersMenu - - # Update manual chapter related nodes (based on chapter - # related menu). - help_updateChaptersNodes - - fi - - # Verify section definition inside chapters. - if [[ ! -f $ENTRY ]];then - - # Print confirmation question. - cli_printMessage "`gettext "The following documentation section will be created:"`" - cli_printMessage "$ENTRY" "AsResponseLine" - cli_printMessage "`gettext "Do you want to continue?"`" "AsYesOrNoRequestLine" - - # Update chapter section related menu. - help_updateMenu - - # Update chapter section related nodes (based on chapter - # section related menu). - help_updateNodes - - # Update old missing cross references. If for some reason a - # documentation entry is removed by mistake, and that mistake - # is fixing by adding the removed documentation entry back - # into the repository, rebuild the missing cross reference - # message to use the correct link to the documentation - # section. - help_restoreCrossReferences - - else - - # Print action message. - cli_printMessage "$ENTRY" 'AsUpdatingLine' - - fi - - # Use default text editor to edit the documentation entry. - eval $EDITOR $ENTRY - - # Print separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Rebuild output files to propagate recent changes. - help_updateOutputFiles - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_getArguments.sh b/Scripts/Bash/Cli/Functions/Help/help_getArguments.sh deleted file mode 100755 index 30adbbd..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_getArguments.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash -# -# help_getArguments.sh -- This function interpretes arguments passed -# to `manual' functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_getArguments { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="filter:,quiet,answer:,dont-commit-changes,read,search,edit,update" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Define action to take for each option passed. - while true; do - case "$1" in - - --filter ) - FLAG_FILTER="$2" - shift 2 - ;; - - --quiet ) - FLAG_QUIET="true" - FLAG_DONT_COMMIT_CHANGES="true" - shift 1 - ;; - - --answer ) - FLAG_ANSWER="$2" - shift 2 - ;; - - --dont-commit-changes ) - FLAG_DONT_COMMIT_CHANGES="true" - shift 1 - ;; - - --read ) - ACTIONNAM="${FUNCNAM}_searchNode" - shift 1 - ;; - - --search ) - ACTIONNAM="${FUNCNAM}_searchIndex" - shift 1 - ;; - - --edit ) - ACTIONNAM="${FUNCNAM}_editEntry" - shift 1 - ;; - - --update ) - ACTIONNAM="${FUNCNAM}_updateOutputFiles" - shift 1 - ;; - - * ) - break - esac - done - - # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_getEntry.sh b/Scripts/Bash/Cli/Functions/Help/help_getEntry.sh deleted file mode 100755 index ae68e99..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_getEntry.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# -# help_getEntry.sh -- This function builds a documentation entry based -# on a location specified. Location specification can be both action -# value (ACTIONVAL) variable or a value passed as first positional -# parameter. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_getEntry { - - # Define variables as local to avoid conflicts outside. - local ENTRY='' - local LOCATION='' - - # Redefine location in order to make this function reusable not - # just for action value variable but whatever value passed as - # first possitional argument. - if [[ "$1" != '' ]];then - LOCATION="$1" - else - LOCATION="$ACTIONVAL" - fi - - # Define relative path of entry, from trunk directory on. - ENTRY=$(echo $LOCATION | sed -r "s!^${HOME}/artwork/!!") - - # Verify the entry relative path to find out which documentation - # manual we are acting on. As convenction, whatever documentation - # entry you provide outside trunk/Manuals/ directory structure is - # considered as you are documenting the repository directory - # structure. Otherwise, if an entry inside trunk/Manuals/ is - # provided, the directory structure provided is used as default - # documentation manual for actions like `--create' and `--update' - # to take place on. Other options like `--edit', `--delete' and - # `--read' cannot be applied to paths provided is inside - # trunk/Manuals/ such actions made manually. - if [[ ${ENTRY} =~ '\.texi$' ]];then - ENTRY=$(echo ${ENTRY} | sed 's!trunk/Manual/!!') - else - ENTRY=$(dirname Filesystem/${ENTRY})/$(basename $LOCATION).texi - fi - - # Re-define entry to set absolute path to manuals base directory - # structure. - ENTRY=${MANUAL_BASEDIR}/${ENTRY} - - # Output entry's absolute path. - echo ${ENTRY} - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_getNode.sh b/Scripts/Bash/Cli/Functions/Help/help_getNode.sh deleted file mode 100755 index 6aacfc5..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_getNode.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# -# help_getNode.sh -- This function cleans up the action value -# (ACTIONVAL) directory to make a node name from it. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_getNode { - - local NODE=$(echo "$ACTIONVAL" \ - | sed -r "s!^${HOME}/artwork/!!" \ - | sed -r 's!/! !g' | sed -r 's!^[[:space:]]+!!') - - echo "$NODE" -} - diff --git a/Scripts/Bash/Cli/Functions/Help/help_renameCrossReferences.sh b/Scripts/Bash/Cli/Functions/Help/help_renameCrossReferences.sh deleted file mode 100755 index c85b575..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_renameCrossReferences.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# -# help_renameCrossReferences.sh -- This function replaces a node -# pattern with a node replacement and updates cross-reference -# definitions to reflect the changes. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_renameCrossReferences { - - local NODE='' - local COUNT=1 - local ENTRIES='' - local NODE_SRC='' - local NODE_DST='' - - # Define node pattern for source documenation entry. - NODE_SRC=$(echo "$ENTRY" \ - | cut -d / -f8- \ - | tr '/' ' ' \ - | sed -r \ - -e "s/(chapter-intro\.texi|\.texi)$//" \ - -e 's! !( |\\n)!g') - - # Define node replacement for target documentation entry. - NODE_DST=$(echo "$FLAG_TO" \ - | cut -d / -f8- \ - | tr '/' ' ' \ - | sed -r \ - -e "s/(chapter-intro\.texi|\.texi)$//") - - # Sanitate node replacement for target documentation entry to make - # use of regular expression positional markers, so the word - # separator character found by node pattern could be used. - for NODE in $NODE_DST;do - if [[ $COUNT -eq 1 ]];then - NODE_DST="${NODE}\\${COUNT}" - else - NODE_DST="${NODE_DST}$(echo "${NODE}\\${COUNT}")" - fi - COUNT=$(($COUNT + 1)) - done - - # Remove last positional marker from node replacement. - NODE_DST=$(echo $NODE_DST | sed -r 's!\\[[:digit:]]$!!') - - # Define list of entries to process. - ENTRIES=$(cli_getFilesList "${MANUAL_BASEDIR}" '.*\.texi') - - # Set action preamble. - cli_printActionPreamble "$ENTRIES" '' '' - - # Update node-related cross-references. The node-related cross - # reference definition, long ones specially, could require more - # than one line to be set. By default, GNU sed does not matches - # newline characters in the pattern space, so we need to make use - # of `label' feature and the `N' command in order to build a - # pattern space that includes the newline character in it. Here we - # use the `a' letter to name the label we use, followed by N - # command to add a newline to the pattern space, the s command to - # make the pattern replacement using the `g' flag to make it - # global and finaly the command `b' to branch label named `a'. - sed -r -i ":a;N;s!${NODE_SRC}!${NODE_DST}!g;ba" ${ENTRIES} - - # At this point, source documentation entry has been renamed from - # source to target documentation entry, but they are still - # commented. So, restore target documentation entries. - help_restoreCrossReferences "${FLAG_TO}" - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_renameEntry.sh b/Scripts/Bash/Cli/Functions/Help/help_renameEntry.sh deleted file mode 100755 index 492ccce..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_renameEntry.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# -# help_renameEntry.sh -- This function renames documentation entries -# and updates documentation structure to reflect changes. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_renameEntry { - - # Copy source documentation entry. - help_copyEntry - - # Print separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Delete source documentation entry. The source documentation - # entry has been copied already, so to create the rename effect - # delete it from repository filesystem. - help_deleteEntry - - # At this point, source documentation entry has been removed and - # all menu, nodes and cross-references have been commented. So, - # replace commented menu, nodes and cross-reference information - # from source to target documentation entry. - help_renameCrossReferences - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_restoreCrossReferences.sh b/Scripts/Bash/Cli/Functions/Help/help_restoreCrossReferences.sh deleted file mode 100755 index bfd0357..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_restoreCrossReferences.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# -# help_restoreCrossReferences.sh -- This function looks inside -# texinfo source files, from section level on, and restores any cross -# reference related to a documentation entry. This function is used in -# those cases where documentation entries are created/recreated to -# documentation structure. It is a verification that looks for -# matching documentation entries previously defined as removed by -# help_deleteCrossReferences function. The -# help_restoreCrossReferences function relays in the removed message -# format produced by help_deleteCrossReferences function, in order -# to return them back into the link format. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_restoreCrossReferences { - - local -a PATTERN - local -a REPLACE - local LOCATION='' - - # Define entry location. Verify first argument to make this - # function reusable. If no value is passed as first argument use - # entry global information value as default value instead. - if [[ "$1" != '' ]];then - LOCATION="$1" - else - LOCATION="$ENTRY" - fi - - # Build the node string using entry location. - local NODE=$(echo "$LOCATION" \ - | cut -d / -f8- \ - | tr '/' ' ' \ - | sed -r \ - -e "s/(chapter-intro\.texi|\.texi)$//" \ - -e 's! !( |\\n)!g') - - # Define regular expression patterns to match removed message - # format produced by message_removeCrossReferences function. - PATTERN[0]="--- @strong\{`gettext "Removed"`\}\((pxref|xref|ref):(${NODE})\) ---" - PATTERN[1]="^@comment --- `gettext "Removed"`\((\* ${NODE}:(.*)?:(.*)?)\) ---$" - - # Define replacement string to turn removed message back to cross - # reference link. - REPLACE[0]='@\1{\2}' - REPLACE[1]='\1' - - # Define list of entries to process. - local ENTRIES=$(cli_getFilesList "${MANUAL_BASEDIR}" '.*\.texi') - - # Set action preamble. - cli_printActionPreamble "$ENTRIES" '' '' - - # Update node-related cross references. The node-related cross - # reference definition, long ones specially, could require more - # than one line to be set. By default, GNU sed does not matches - # newline characters in the pattern space, so we need to make use - # of `label' feature and the `N' command in order to build a - # pattern space that includes the newline character in it. Here we - # use the `a' letter to name the label we use, followed by N - # command to add a newline to the pattern space, the s command to - # make the pattern replacement using the `g' flag to make it - # global and finaly the command `b' to branch label named `a'. - sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${ENTRIES} - - # Update menu-related cross references. Menu-related cross - # references hardly appear in more than one line, so there is no - # need to complicate the replacement command. - sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${ENTRIES} - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_searchIndex.sh b/Scripts/Bash/Cli/Functions/Help/help_searchIndex.sh deleted file mode 100644 index e20715a..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_searchIndex.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# -# help_searchIndex.sh -- This function does an index search inside the -# info document. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_searchIndex { - - # Check flag filter. By default flag filter has the `.+' value - # which is not very descriptive in the sake of an index-search. - # So, when no value is passed through --filter option use top node - # as default value for index-search. - if [[ "$FLAG_FILTER" == '.+' ]];then - cli_printMessage "`gettext "Use the \\\`--filter' option to define the search pattern."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Print action message. - cli_printMessage "${MANUAL_BASEFILE}.info.bz2" 'AsReadingLine' - - # Execute info command to perform an index-search. - /usr/bin/info --index-search="$FLAG_FILTER" --file=${MANUAL_BASEFILE}.info.bz2 - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_searchNode.sh b/Scripts/Bash/Cli/Functions/Help/help_searchNode.sh deleted file mode 100755 index 0224c38..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_searchNode.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# help_searchNode.sh -- This function does a node search inside the -# info document. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_searchNode { - - # Print action message. - cli_printMessage "${MANUAL_BASEFILE}.info.bz2" 'AsReadingLine' - - # Check entry inside documentation structure. If the entry - # exits use the info reader to open the info file at the - # specified node. Otherwise, ask the user for create it. - if [[ -f "$ENTRY" ]];then - /usr/bin/info --node="Filesystem $(help_getNode)" --file=${MANUAL_BASEFILE}.info.bz2 - else - help_editEntry - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateChaptersFiles.sh b/Scripts/Bash/Cli/Functions/Help/help_updateChaptersFiles.sh deleted file mode 100755 index 9964589..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateChaptersFiles.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# -# help_updateChaptersFiles.sh -- This function updates chapter related -# files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateChaptersFiles { - - # Define chapter's generic structure. - local CHAPTERBODY="\ - @node $MANUAL_CHAPTER_NAME - @chapter $MANUAL_CHAPTER_NAME - @cindex $(echo $MANUAL_CHAPTER_NAME | tr '[[:upper:]]' '[[:lower:]]') - @include $MANUAL_CHAPTER_NAME/chapter-intro.texi - @include $MANUAL_CHAPTER_NAME/chapter-menu.texi - @include $MANUAL_CHAPTER_NAME/chapter-nodes.texi" - - # Remove any space/tabs at the begining of @... lines. - CHAPTERBODY=$(echo "$CHAPTERBODY" | sed -r 's!^[[:space:]]+@!@!') - - # Create directory to store chapter files. - if [[ ! -d $MANUAL_CHAPTER_DIR ]];then - mkdir $MANUAL_CHAPTER_DIR - fi - - # Create files to store chapter information. If chapter files - # already exist, they will be re-written and any previous - # information inside them will be lost. - echo "$CHAPTERBODY" > $MANUAL_CHAPTER_DIR/chapter.texi - echo "" > $MANUAL_CHAPTER_DIR/chapter-menu.texi - echo "" > $MANUAL_CHAPTER_DIR/chapter-nodes.texi - - # Initialize chapter instroduction using template file. - cp ${FUNCCONFIG}/manual-cha-intro.texi $MANUAL_CHAPTER_DIR/chapter-intro.texi - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateChaptersMenu.sh b/Scripts/Bash/Cli/Functions/Help/help_updateChaptersMenu.sh deleted file mode 100755 index c32d0c7..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateChaptersMenu.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# -# help_updateChaptersMenu.sh - This function updates chapter menu. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateChaptersMenu { - - local ACTION=$1 - local MENUCHAPTERS='' - - # Build menu of chapters. The Index node is not included as other - # nodes are. The Index node is defined insde the master texinfo - # file (repository.texi). To create the final .info file - # correctly, the Index line in the menu should remain, even no - # other node exist. - if [[ -f ${MANUAL_BASEFILE}-menu.texi ]];then - MENUCHAPTERS=$(cat ${MANUAL_BASEFILE}-menu.texi \ - | egrep -v "^(@(end )?menu$|\* Index::.*)$") - fi - - # Re-defined menu of chapters based on action. - case $ACTION in - 'remove-entry' ) - # Remove chapter from menu. - MENUCHAPTERS=$(echo "${MENUCHAPTERS}" \ - | egrep -v "^\* ${MANUAL_CHAPTER_NAME}::[[:print:]]*$") - ;; - 'update-entry' | * ) - # Update chapter menu using texinfo format. - MENUCHAPTERS="${MENUCHAPTERS} - * ${MANUAL_CHAPTER_NAME}::" - ;; - esac - - # Remove opening spaces/tabs and empty line from the menu of - # chapters. Empty lines may occur the first time the menu of - # chapters is created. - MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \ - | egrep -v '^[[:space:]]*$') - - # Organize menu of chapters alphabetically and verify that no - # duplicated line be included on the list. - MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sort | uniq ) - - # Give format to final menu output. - MENUCHAPTERS="@menu - ${MENUCHAPTERS} - * Index:: - @end menu" - - # Strip opening space/tabs from final menu of chapters. - MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \ - | egrep -v '^[[:space:]]*$') - - # Dump organized menu of chapters into file. - echo "${MENUCHAPTERS}" > ${MANUAL_BASEFILE}-menu.texi - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateChaptersNodes.sh b/Scripts/Bash/Cli/Functions/Help/help_updateChaptersNodes.sh deleted file mode 100755 index b678350..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateChaptersNodes.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# help_updateChaptersNodes.sh - This function updates nodes of -# chapters based on menu of chapters. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateChaptersNodes { - - # Build list "nodes of chapters" based on menu of chapters. - local CHAPTERNODES=$(cat ${MANUAL_BASEFILE}-menu.texi \ - | egrep -v '^@(end )?menu$' \ - | egrep -v "^\* `gettext "Index"`::[[:print:]]*$" \ - | sed -r 's!^\* !!' | sed -r 's!::[[:print:]]*$!!g' \ - | sed -r 's! !_!g' | sort | uniq ) - - # Build list of texinfo inclusions to load chapters' nodes. - local FILENODE=$(\ - for CHAPTERNODE in ${CHAPTERNODES};do - - INCL=$(echo ${CHAPTERNODE} | sed -r "s!(${CHAPTERNODE})!\1/chapter\.texi!") - - # Output inclusion line using texinfo format. - echo "@include $INCL" - - done) - - # Dump organized nodes of chapters into file. - echo "$FILENODE" > ${MANUAL_BASEFILE}-nodes.texi - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateMenu.sh b/Scripts/Bash/Cli/Functions/Help/help_updateMenu.sh deleted file mode 100755 index bbfb11c..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateMenu.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# -# help_updateMenu.sh -- This function updates menu lines inside -# texinfo chapters. If this function is called with the -# 'remove-entry' string as first argument, then the menu line related -# to the entry being processed is removed. If this function is called -# with the 'update-entry' string as first argument, then the menu line -# related to the entry being processed is added to the menu. If no -# argument is passed to this function, the 'update-entry' action is -# assumed. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateMenu { - - # Specify which action to do inside chapter's menu. - local ACTION="$1" - - # Build the menu node related to the entry being processed - # currently. - local MENUNODE=$(echo "$ENTRY" | cut -d / -f8- | tr '/' ' ' \ - | sed 's!\.texi$!!') - - # Give format to menu line using texinfo style. - local MENULINE="* ${MANUAL_CHAPTER_NAME} $MENUNODE::" - - # Define chapter's menu. Remove `@menu', `@end menu', and empty lines - # from output. - local MENU=$(cat $MANUAL_CHAPTER_DIR/chapter-menu.texi \ - | egrep -v '^[[:space:]]*$' | egrep -v '^@(end )?menu') - - # Re-defined chapter's menu based on action. - case $ACTION in - 'remove-entry' ) - # Remove menu line from chapter's menu. - MENU=$(echo "$MENU" | egrep -v "$MENULINE") - ;; - 'update-entry' | * ) - # Add menu line to chapter's menu. This is the default - # behaivour if no argument is passed to help_updateMenu - # function. - MENU="$MENU - $MENULINE" - ;; - esac - - # Organize menu alphabetically, remove empty and duplicated lines. - # At this point, empty line may occur the first time the menu is - # created, don't let them to scape. - MENU=$(echo "$MENU" | egrep -v '^[[:space:]]*$' | sort | uniq ) - - # Rebuild chapter's menu structure adding '@menu' and '@end menu' - # lines back in menu. - MENU="@menu - $MENU - @end menu" - - # Remove opening spaces/tabs from final menu structure. - MENU=$(echo "$MENU" | sed -r 's!^[[:space:]]+!!g') - - # Dump final menu structure back into chapter's menu file. - echo "$MENU" > $MANUAL_CHAPTER_DIR/chapter-menu.texi - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateNodes.sh b/Scripts/Bash/Cli/Functions/Help/help_updateNodes.sh deleted file mode 100755 index 432b9c7..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateNodes.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# -# help_updateNodes.sh -- This function updates chapter's nodes -# definition using the chapter's menu as reference. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateNodes { - - # Retrive nodes' entries from chapter-menu.texi file. - local NODES=$(cat $MANUAL_CHAPTER_DIR/chapter-menu.texi \ - | sed -r 's!^\* !!' | sed -r 's!:{1,2}.*$!!g' \ - | egrep -v '^@(end )?menu$' | sed -r 's! !:!g' | sort | uniq) - - # Re-build node structure based on menu information. - for NODE in $NODES;do - - NODE=$(echo "${NODE}" | sed -r 's!:! !g') - SECT=$(echo "$NODE" | sed -r 's! !/!g' | sed "s!${MANUAL_CHAPTER_NAME}/!!") - INCL=$(echo "$NODE" | sed -r 's! !/!g').texi - CIND=$(echo "$NODE") - - # Create an empty directory to store texinfo files. - if [[ ! -d ${MANUAL_BASEDIR}/$(dirname "$INCL") ]];then - mkdir -p ${MANUAL_BASEDIR}/$(dirname "$INCL") - fi - - # Create texinfo section file using its template. - if [[ ! -f ${MANUAL_BASEDIR}/$INCL ]];then - cp ${FUNCCONFIG}/manual-section.texi ${MANUAL_BASEDIR}/$INCL - fi - - # Output node information based on texinfo menu. - echo "@node $NODE" - echo "@section `eval_gettext "The @file{\\\$SECT} Directory"`" - echo "@cindex $CIND" - echo "@include $INCL" - echo "" - - # Dump node information into chapter node file. - done > $MANUAL_CHAPTER_DIR/chapter-nodes.texi - -} - diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFileHtml.sh b/Scripts/Bash/Cli/Functions/Help/help_updateOutputFileHtml.sh deleted file mode 100755 index 1f6fed4..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFileHtml.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# -# help_updateOutputFileHtml.sh -- This function exports -# documentation manual to HTML format. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateOutputFileHtml { - - # Output action message. - cli_printMessage "${MANUAL_BASEFILE}-html" 'AsUpdatingLine' - - # Check html output directory - [[ ! -d ${MANUAL_BASEFILE}-html ]] && mkdir -p ${MANUAL_BASEFILE}-html - - # Add html output directory into directory stack to make it the - # current working directory. Otherwise texi2html may produce - # incorrect paths to images included. - pushd ${MANUAL_BASEFILE}-html > /dev/null - - # Update html files. Use texi2html to export from texinfo file - # format to html using CentOS Web default visual style. - texi2html ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}-html --split section \ - --nosec-nav \ - --css-include=${HOME}/artwork/trunk/Identity/Models/Css/Texi2html/stylesheet.css \ - -I=${HOME}/artwork - - # Apply html transformations. Html transformations rely on - # Texi2html default html output. The main goal of these html - # transformations is to build specific html structures that match - # specific css definitions. This way we extend the visual style of - # Texi2html default html output. - sed -r -i \ - -f ${HOME}/artwork/trunk/Identity/Models/Css/Texi2html/transformations.sed \ - ${MANUAL_BASEFILE}-html/*.html - - # Remove html output directory from directory stack. - popd > /dev/null - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFileInfo.sh b/Scripts/Bash/Cli/Functions/Help/help_updateOutputFileInfo.sh deleted file mode 100755 index 27b6d58..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFileInfo.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# help_updateOutputFileInfo.sh -- This function exports -# documentation manual to info format. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateOutputFileInfo { - - # Output action message. - cli_printMessage "${MANUAL_BASEFILE}.info.bz2" 'AsUpdatingLine' - - # Update info file. - /usr/bin/makeinfo ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}.info - - # Compress info file. - if [[ $? -eq 0 ]];then - bzip2 -f ${MANUAL_BASEFILE}.info - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFilePdf.sh b/Scripts/Bash/Cli/Functions/Help/help_updateOutputFilePdf.sh deleted file mode 100755 index e142936..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFilePdf.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# help_updateOutputFilePdf.sh -- This function exports documentation -# manual to PDF format. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateOutputFilePdf { - - # Output action message. - cli_printMessage "${MANUAL_BASEFILE}.pdf" 'AsUpdatingLine' - - # Update plaintext output directory. - /usr/bin/texi2pdf --quiet \ - ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}.pdf - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFilePlaintext.sh b/Scripts/Bash/Cli/Functions/Help/help_updateOutputFilePlaintext.sh deleted file mode 100755 index d1b748d..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFilePlaintext.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# help_updateOutputFilePlaintext.sh -- This function exports -# documentation manual to plain-text format. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateOutputFilePlaintext { - - # Output action message. - cli_printMessage "${MANUAL_BASEFILE}.txt.bz2" 'AsUpdatingLine' - - # Update plaintext output directory. - /usr/bin/makeinfo --plaintext \ - ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}.txt - - # Compress plaintext output file. - if [[ -f ${MANUAL_BASEFILE}.txt ]];then - bzip2 ${MANUAL_BASEFILE}.txt --force - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFileXml.sh b/Scripts/Bash/Cli/Functions/Help/help_updateOutputFileXml.sh deleted file mode 100755 index e045b36..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFileXml.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# help_updateOutputFileXml.sh -- This function exports documentation -# manual to XML format. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateOutputFileXml { - - # Print action message. - cli_printMessage "${MANUAL_BASEFILE}.xml" 'AsUpdatingLine' - - # Update xml output format. - /usr/bin/makeinfo --xml \ - ${MANUAL_BASEFILE}.texi --output=${MANUAL_BASEFILE}.xml \ - -} diff --git a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFiles.sh b/Scripts/Bash/Cli/Functions/Help/help_updateOutputFiles.sh deleted file mode 100755 index e170e22..0000000 --- a/Scripts/Bash/Cli/Functions/Help/help_updateOutputFiles.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# -# help_updateOutputFiles.sh -- This function exports documentation -# manual to different output formats. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function help_updateOutputFiles { - - # Remove extension from manual's base file. This way it is - # possible to reuse the same filename on different types of files. - MANUAL_BASEFILE=$(echo ${MANUAL_BASEFILE} | sed -r 's!\.texi!!') - - # Add the working copy root directory to directory stack to make - # path construction correctly. Otherwise, makeinfo may produce - # paths incorrectly. - pushd ${HOME}/artwork > /dev/null - - help_updateOutputFileInfo - help_updateOutputFileHtml - help_updateOutputFileXml - help_updateOutputFilePdf - help_updateOutputFilePlaintext - - # Remove the working copy root directory from directory stack. - popd > /dev/null - -} diff --git a/Scripts/Bash/Cli/Functions/Html/Config/output_forHeadingsToc.awk b/Scripts/Bash/Cli/Functions/Html/Config/output_forHeadingsToc.awk deleted file mode 100644 index bcc0f21..0000000 --- a/Scripts/Bash/Cli/Functions/Html/Config/output_forHeadingsToc.awk +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/gawk -# -# output_forHadingsToc.awk -- This file provides the output format -# required by html_updateHeadings.sh function, inside centos-art.sh -# script. -# -# Copyright (C) 2009-2010 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -BEGIN {FS=":"} - -{ - if ($1 == 0 && $2 == $3) { - opentags = "
  • " - closetags = "" - } - - if ($1 > 0 && $2 > $3) { - opentags = "
    • " - closetags = "" - } - - if ($1 > 0 && $2 == $3) { - opentags = "
    • " - closetags = "" - } - - if ($1 > 0 && $2 < $3) { - opentags = "" - for (i = 1; i <= ($3 - $2); i++) { - opentags = opentags "
    " - closetags = "" - } - opentags = opentags "
  • " - } - - printf "%s%s%s\n",opentags,$4,closetags - -} - -END { - - if ($1 > 0 && $2 >= $3 && $3 > 1) { - for (i = 1; i <= $3; i++) { - print "
" - } - } - - if ($1 > 0 && $2 >= $3 && $3 == 1) { - print "" - print "" - } - - if ($1 > 0 && $2 < $3) { - for (i = 1; i <= $2; i++) { - print "" - } - } - - print "
" -} diff --git a/Scripts/Bash/Cli/Functions/Html/html.sh b/Scripts/Bash/Cli/Functions/Html/html.sh deleted file mode 100755 index 8b4cf95..0000000 --- a/Scripts/Bash/Cli/Functions/Html/html.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# html.sh -- This function provides very basic HTML manipulations to -# help maintain html files inside the repository. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function html { - - # Define command-line interface. - html_getActions - -} diff --git a/Scripts/Bash/Cli/Functions/Html/html_getActions.sh b/Scripts/Bash/Cli/Functions/Html/html_getActions.sh deleted file mode 100755 index 6cd746d..0000000 --- a/Scripts/Bash/Cli/Functions/Html/html_getActions.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# -# html_getActions.sh -- This function interprets arguments passed to -# `html' functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function html_getActions { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="update-headings:" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Define action to take for each option passed. - while true; do - case "$1" in - - --update-headings ) - - # Define action value passed through the command-line. - ACTIONVAL="$2" - - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_updateHeadings" - - # Rotate positional parameters. - shift 2 - ;; - - * ) - break - esac - done - - # Check action value. Be sure the action value matches the - # convenctions defined for source locations inside the working - # copy. - cli_checkRepoDirSource - - # Syncronize changes between the working copy and the central - # repository to bring down changes. - cli_syncroRepoChanges - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Syncronize changes between the working copy and the central - # repository to commit up changes. - cli_commitRepoChanges - -} diff --git a/Scripts/Bash/Cli/Functions/Html/html_updateHeadings.sh b/Scripts/Bash/Cli/Functions/Html/html_updateHeadings.sh deleted file mode 100644 index b66e363..0000000 --- a/Scripts/Bash/Cli/Functions/Html/html_updateHeadings.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/bash -# -# html_updateHeadings.sh -- This function transforms html headings to -# to make them accessible (e.g., through a table of contents). -# -# - In order for this function to work, you need to put headings in -# just one line and they must have the following formats: -# -#

Title

-#

Title

-#

Title

-# -# In the above examples, h1 alternates from h1 to h6. Closing tag -# must be present and match the one opentaging. The value of and options are the md5sum of page -# location, plus the 'head-' string, plus the heading string. If -# heading title or page location changes, the values of and options will change too. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function html_updateHeadings { - - # Define variables as local to avoid conflicts outside. - local COUNT=0 - local FILE='' - local FILES='' - local PREVCOUNT=0 - local PATTERN='' - local -a FINAL - local -a TITLE - local -a MD5SM - local -a OPTNS - local -a LEVEL - local -a PARENT - local -a TOCENTRIES - local -a LINK - - # Define html heading regular expression pattern. Use parenthisis - # to save html action name, action value, and heading title. - PATTERN="(]>)(.*[^<])" - - # Define list of files to process. - FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}.*\.(xhtml|html|htm)") - - # Set action preamble. - cli_printActionPreamble "${FILES}" '' '' - - # Process list of files. - for FILE in $FILES;do - - # Verify list of html files. Are files really html files? If - # they don't, continue with the next one in the list. - if [[ ! $(file --brief $FILE) =~ '^(XHTML|HTML|XML)' ]];then - continue - fi - - # Output action message. - cli_printMessage $FILE 'AsUpdatingLine' - - # Define list of headings to process. When building the - # heading, it is required to change spaces characters from its - # current decimal output to something different (e.g., its - # \040 octal alternative). This is required because the space - # character is used as egrep default field separator and - # spaces can be present inside heading strings we don't want - # to separate. - for HEADING in $(egrep "$PATTERN" $FILE \ - | sed -r -e 's!^[[:space:]]+!!' -e "s! !\\\040!g");do - - # Define previous counter value using current counter - # value as reference. - if [[ $COUNT -ne 0 ]];then - PREVCOUNT=$(($COUNT-1)) - fi - - # Define initial heading information. - FIRST[$COUNT]=$(echo $HEADING | sed -r "s!\\\040! !g") - TITLE[$COUNT]=$(echo ${FIRST[$COUNT]} | sed -r "s!$PATTERN!\3!") - MD5SM[$COUNT]=$(echo "${FILE}${FIRST[$COUNT]}" | md5sum | sed -r 's![[:space:]]+-$!!') - OPTNS[$COUNT]=$(echo ${FIRST[$COUNT]} | sed -r "s!$PATTERN!\2!") - LEVEL[$COUNT]=$(echo ${FIRST[$COUNT]} | sed -r "s!$PATTERN!\1!") - PARENT[$COUNT]=${LEVEL[$PREVCOUNT]} - - # Transform heading information using initial heading - # information as reference. - if [[ ${OPTNS[$COUNT]} =~ '^$' ]];then - OPTNS[$COUNT]='' - elif [[ ${OPTNS[$COUNT]} =~ '^$' ]];then - OPTNS[$COUNT]='' - elif [[ ${OPTNS[$COUNT]} =~ '^$' ]];then - OPTNS[$COUNT]='' - fi - - # Build final html heading structure. - FINAL[$COUNT]=''${OPTNS[$COUNT]}${TITLE[$COUNT]}'' - - # Build html heading link structure. These links are used - # by the table of contents later. - LINK[$COUNT]=''${TITLE[$COUNT]}'' - - # Build table of contents entry with numerical - # identifications. The numerical identification is what we - # use to determine the correct position of each heading - # link on the table of content. - TOCENTRIES[$COUNT]="$COUNT:${LEVEL[$COUNT]}:${PARENT[$COUNT]}:${LINK[$COUNT]}" - - # Update heading information inside the current file being - # processed. Use the first and final heading information. - sed -i -r "s!${FIRST[$COUNT]}!${FINAL[$COUNT]}!" $FILE - - # Increase heading counter. - COUNT=$(($COUNT + 1)) - - done - - # Build the table of contents using heading numerical - # identifications as reference. The numerical identification - # describes the order of headings in one html file. This - # information is processed by awk to make the appropriate - # replacements. Finnally, the result is stored in the TOC - # variable. - TOC=$(echo '
' - echo "

`gettext "Table of contents"`

" - for TOCENTRY in "${TOCENTRIES[@]}";do - echo $TOCENTRY - done \ - | awk -f ${CLI_BASEDIR}/Functions/Html/Config/output_forHeadingsToc.awk) - - # Update table of contents inside the current file being - # processed. - sed -i -r '/
(.*)<\/div>/c'"$(echo -e $TOC)" $FILE - - # Reset counters. - COUNT=0 - PREVCOUNT=0 - - # Clean up variables to receive the next file. - unset FINAL - unset TITLE - unset MD5SM - unset OPTNS - unset LEVEL - unset PARENT - unset TOCENTRIES - unset LINK - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Locale/locale.sh b/Scripts/Bash/Cli/Functions/Locale/locale.sh deleted file mode 100644 index 2f320f3..0000000 --- a/Scripts/Bash/Cli/Functions/Locale/locale.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# -# locale.sh -- This function provides internationalization features -# for centos-art.sh script through gettext standard processes. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale { - - local ACTIONNAM='' - local ACTIONVAL='' - - # Initialize default value to create/update machine object flag. - # The machine object flag (--dont-create-mo) controls whether - # centos-art.sh script does create/update the machine object - # related object or not. - local FLAG_DONT_CREATE_MO='false' - - # Interpret arguments and options passed through command-line. - locale_getArguments - - # Redefine positional parameters using ARGUMENTS. At this point, - # option arguments have been removed from ARGUMENTS variable and - # only non-option arguments remain in it. - eval set -- "$ARGUMENTS" - - # Define action name. It does matter what option be passed to - # centos-art, there are many different actions to perform based on - # the option passed (e.g., `--edit', `--read', `--search', etc.). - # In that sake, we defined action name inside document_getArguments, - # at the moment of interpreting options. - - # Define action value. As convenction, we use non-option arguments - # to define the action value (ACTIONVAL) variable. - for ACTIONVAL in "$@";do - - if [[ $ACTIONVAL == '--' ]];then - continue - fi - - # Check action value. Be sure the action value matches the - # convenctions defined for source locations inside the working - # copy. - cli_checkRepoDirSource - - # Define locales base directory where locale directory structures - # are stored in. - local BASEDIR="$(cli_getRepoTLDir)/Locales" - - # Define locales work directory. This is the place where - # locale files (e.g., .po, .pot, .mo), for a specific parent - # directories, are stored in. There is one locale work - # directory for each parent directory or said differently, - # each parent directory has a parallel directory under - # `trunk/Locales' to store its translation messages. - local WORKDIR=$(echo ${ACTIONVAL} \ - | sed -r -e 's!trunk/(Identity|Manuals|Scripts)!trunk/Locales/\1!') - - # Create work directory, if it doesn't exist. - if [[ ! -d $WORKDIR ]];then - mkdir -p $WORKDIR - fi - - # Syncronize changes between repository and working copy. At - # this point, changes in the repository are merged in the - # working copy and changes in the working copy committed up to - # repository. - cli_syncroRepoChanges "${WORKDIR}" - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Commit changes from working copy to central repository only. - # At this point, changes in the repository are not merged in - # the working copy, but chages in the working copy do are - # committed up to repository. - cli_commitRepoChanges "${WORKDIR}" - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Locale/locale_editMessages.sh b/Scripts/Bash/Cli/Functions/Locale/locale_editMessages.sh deleted file mode 100755 index 5b95ee8..0000000 --- a/Scripts/Bash/Cli/Functions/Locale/locale_editMessages.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# locale_editMessages.sh -- This function edits portable objects (.po) -# using default text editor. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_editMessages { - - local FILES='' - - # Define list of files to process. - if [[ ${WORKDIR} =~ 'trunk/Locales/Scripts' ]];then - FILES=$(cli_getFilesList "${WORKDIR}" ".*$(cli_getCurrentLocale)/${TEXTDOMAIN}\.po") - elif [[ ${WORKDIR} =~ 'trunk/Locales/.+' ]];then - FILES=$(cli_getFilesList "${WORKDIR}" ".*$(cli_getCurrentLocale)\.po") - else - cli_printMessage "`gettext "The path provided doesn't support localization."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Set action preamble. - cli_printActionPreamble "${FILES}" "doEdit" 'AsResponseLine' - - # Use default text editor to edit files. - eval ${EDITOR} ${FILES} - - # Update machine object (.mo) from portable object (.po). - locale_updateMessageBinary ${FILES} - -} diff --git a/Scripts/Bash/Cli/Functions/Locale/locale_getArguments.sh b/Scripts/Bash/Cli/Functions/Locale/locale_getArguments.sh deleted file mode 100644 index 332d5ec..0000000 --- a/Scripts/Bash/Cli/Functions/Locale/locale_getArguments.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# -# locale_getArguments.sh -- This function interprets arguments passed to -# `locale' functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_getArguments { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="filter:,quiet,answer:,dont-commit-changes,update,edit,dont-create-mo" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - case "$1" in - - --filter ) - FLAG_FILTER="$2" - shift 2 - ;; - - --quiet ) - FLAG_QUIET="true" - FLAG_DONT_COMMIT_CHANGES="true" - shift 1 - ;; - - --answer ) - FLAG_ANSWER="$2" - shift 2 - ;; - - --dont-commit-changes ) - FLAG_DONT_COMMIT_CHANGES="true" - shift 1 - ;; - - --update ) - ACTIONNAM="${FUNCNAM}_updateMessages" - shift 1 - ;; - - --edit ) - ACTIONNAM="${FUNCNAM}_editMessages" - shift 1 - ;; - - --dont-create-mo ) - FLAG_DONT_CREATE_MO="true" - shift 1 - ;; - - * ) - break - ;; - esac - done - - # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" - -} diff --git a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageBinary.sh b/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageBinary.sh deleted file mode 100755 index a4907e2..0000000 --- a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageBinary.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageBinary.sh -- This function creates/updates -# machine objects (.mo) from portable objects (.po). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_updateMessageBinary { - - # Verify machine object creation flag. - if [[ ${FLAG_DONT_CREATE_MO} == 'true' ]];then - return - fi - - local PO='' - local MO='' - local FILE='' - local FILES="$1" - - for FILE in $FILES;do - - # Verify existence of portable object. - cli_checkFiles "${FILE}" 'f' - - # Define absolute path to portable object. - PO=$FILE - - # Define absolute path to machine object. - MO=$(dirname ${PO})/LC_MESSAGES/$(basename ${PO} | sed -r 's!\.po$!.mo!') - - # Print action message. - if [[ -f ${MO} ]];then - cli_printMessage "${MO}" 'AsUpdatingLine' - else - cli_printMessage "${MO}" 'AsCreatingLine' - fi - - # Define directory used to store machine object. - MODIR=$(dirname ${MO}) - - # Create directory to store machine object, if it doesn't - # exist. - if [[ ! -d ${MODIR} ]];then - mkdir -p ${MODIR} - fi - - # Create machine object from portable object. - msgfmt --check ${PO} --output-file=${MO} - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageMetadata.sh b/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageMetadata.sh deleted file mode 100755 index edf3c85..0000000 --- a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageMetadata.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageMetadata.sh -- This function sanitates .pot and -# .po files to use common translation markers inside top comment. -# Later, replacement of common translation markers is applied to set -# the final information. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id4 -# ---------------------------------------------------------------------- - -function locale_updateMessageMetadata { - - local COUNT=0 - local -a SRC - local -a DST - - # Retrive absolute path of portable object we'll work with. - local FILE="$1" - - # Define current locale. - local CURRENTLOCALE=$(cli_getCurrentLocale) - - # Define language name from current locale. - local LANGNAME=$(cli_getLangName ${CURRENTLOCALE}) - - # Check existence of file before work with it. - cli_checkFiles "${FILE}" 'f' - - # Define pattern lines. The pattern lines are put inside portable - # objects through xgettext and xml2po commands . - SRC[0]='Project-Id-Version:' - SRC[1]='Report-Msgid-Bugs-To:' - SRC[2]='Last-Translator:' - SRC[3]='Language-Team:' - - # Define replacement lines for pattern line. - DST[0]="\"Project-Id-Version: ${CLI_PROGRAM} (${CURRENTLOCALE})\\\n\"" - DST[1]="\"Report-Msgid-Bugs-To: =MAIL_DOCS=\\\n\"" - DST[2]="\"Last-Translator: CentOS Documentation SIG\\\n\"" - DST[3]="\"Language-Team: ${LANGNAME}\\\n\"" - - # Change pattern lines with their replacement lines. - while [[ $COUNT -lt ${#SRC[*]} ]];do - sed -i -r "/${SRC[$COUNT]}/c${DST[$COUNT]}" ${FILE} - COUNT=$(($COUNT + 1)) - done - - # Replace package information using gettext domain information. - sed -i -r "s/PACKAGE/${TEXTDOMAIN}/g" ${FILE} - - # Unset array variables to avoid undesired concatenations. - unset SRC - unset DST - -} diff --git a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessagePObjects.sh b/Scripts/Bash/Cli/Functions/Locale/locale_updateMessagePObjects.sh deleted file mode 100755 index 830d88b..0000000 --- a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessagePObjects.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# -# locale_updateMessagePObjects.sh --- This function verifies, -# initializes or updates portable objects from portable object -# templates. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_updateMessagePObjects { - - local FILE="$1" - - # Verify the portable object template. The portable object - # template is used to create the portable object. - cli_checkFiles "${FILE}.pot" 'f' - - # Verify existence of portable object. The portable object is the - # file translators edit in order to make translation works. - if [[ -f ${FILE}.po ]];then - - # Print action message. - cli_printMessage "${FILE}.po" 'AsUpdatingLine' - - # Update portable object merging both portable object and - # portable object template. - msgmerge --output="${FILE}.po" "${FILE}.po" "${FILE}.pot" --quiet - - else - - # Print action message. - cli_printMessage "${FILE}.po" 'AsCreatingLine' - - # Initiate portable object using portable object template. - # Do not print msginit sterr output, use centos-art action - # message instead. - msginit -i ${FILE}.pot -o ${FILE}.po --width=70 \ - --no-translator 2> /dev/null - - # Sanitate portable object metadata. This is the first time - # the portable object is created so some modifications are - # needed to customized metadata. - locale_updateMessageMetadata "${FILE}.po" - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageShell.sh b/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageShell.sh deleted file mode 100755 index 65154e9..0000000 --- a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageShell.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageShell.sh -- This function parses shell scripts -# under action value, retrives translatable strings and -# creates/updates both portable object templates (.pot) and portable -# objects (.po). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_updateMessageShell { - - local FILE='' - local FILES='' - - # Define file name used as reference to create portable object - # templates (.pot), portable objects (.po) and machine objects - # (.mo). - FILE="${WORKDIR}/$(cli_getCurrentLocale)/${TEXTDOMAIN}" - - # Build list of files to process. - if [[ $ACTIONVAL =~ "^${CLI_BASEDIR}" ]];then - FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}\.sh") - else - cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Set action preamble. - cli_printActionPreamble "${FILES}" "doLocale" 'AsResponseLine' - - # Print action message. - cli_printMessage "${FILE}.pot" 'AsUpdatingLine' - - # Prepare directory structure to receive .po files. - if [[ ! -d $(dirname ${FILE}) ]];then - mkdir -p $(dirname ${FILE}) - fi - - # Retrive translatable strings from shell script files and create - # the portable object template (.pot) from them. - /usr/bin/xgettext --output=${FILE}.pot \ - --copyright-holder="CentOS Documentation SIG" \ - --width=70 --sort-by-file ${FILES} - - # Verify, initialize or update portable objects from portable - # object templates. - locale_updateMessagePObjects "${FILE}" - -} diff --git a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageXml.sh b/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageXml.sh deleted file mode 100755 index f0c6244..0000000 --- a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessageXml.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageXml.sh -- This function parses XML-based files -# (e.g., scalable vector graphics), retrives translatable strings and -# creates/update gettext portable objects. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_updateMessageXml { - - local FILE='' - local FILES='' - - # Define filename used to create both portable object templates - # (.pot) and portable objects (.po) files. - FILE="${WORKDIR}/$(cli_getCurrentLocale)" - - # Build list of files to process. - if [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Identity/.+" ]];then - FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}\.(svg|docbook)") - else - cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Set action preamble. - cli_printActionPreamble "${FILES}" "doLocale" 'AsResponseLine' - - # Print action message. - cli_printMessage "${FILE}.pot" 'AsUpdatingLine' - - # Prepare directory structure to receive .po files. - if [[ ! -d $(dirname ${FILE}) ]];then - mkdir -p $(dirname ${FILE}) - fi - - # Retrive translatable strings from XML-based files and - # create the portable object template (.pot) from them. - /usr/bin/xml2po ${FILES} | msgcat --output=${FILE}.pot --width=70 --sort-by-file - - - # Verify, initialize or merge portable objects from portable - # object templates. - locale_updateMessagePObjects "${FILE}" - -} diff --git a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessages.sh b/Scripts/Bash/Cli/Functions/Locale/locale_updateMessages.sh deleted file mode 100755 index d6d9a5e..0000000 --- a/Scripts/Bash/Cli/Functions/Locale/locale_updateMessages.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# -# locale_updateMessages.sh -- This function extracts translatable -# strings from both XML-based files (using xml2po) and shell scripts -# (using xgettext). Translatable strings are initially stored in -# portable objects templates (.pot) which are later merged into -# portable objects (.po) in order to be optionally converted as -# machine objects (.mo). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_updateMessages { - - local ACTIONNAM='' - - # Evaluate working directory to determine whether to use xml2po to - # extract translatable strings from XML-based files or to use - # xgettext to extract translatable strings from shell script - # files. - if [[ $WORKDIR =~ "^${BASEDIR}/(Identity|Manuals)/.+$" ]];then - - # Update translatable strings inside portable object templates - # for XML-based files (e.g., scalable vector graphics). - ACTIONNAM="${FUNCNAM}_updateMessageXml" - - elif [[ $WORKDIR =~ "^${BASEDIR}/Scripts/.+$" ]];then - - # Update translatable strings inside portable object templates - # for shell scripts (e.g., centos-art.sh script). - ACTIONNAM="${FUNCNAM}_updateMessageShell" - - else - cli_printMessage "`gettext "The path provided doesn't support localization."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Path/path.sh b/Scripts/Bash/Cli/Functions/Path/path.sh deleted file mode 100755 index 4f3fe10..0000000 --- a/Scripts/Bash/Cli/Functions/Path/path.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# -# path.sh -- This function provides file manipulations to aliviate -# path maintainance inside the repository. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function path { - - # Define deafult value to target flag. The target flag (--to) - # controls final destination used by copy related actions. - local FLAG_TO='' - - # Define default value to syncronization flag. The syncronization - # flag (--sync) controls whether centos-art.sh script calls itself - # to create/delete parallel directories at the moment of - # create/delte action itself. - local FLAG_SYNC='false' - - # Define command-line interface. - path_getActions - -} diff --git a/Scripts/Bash/Cli/Functions/Path/path_doCopy.sh b/Scripts/Bash/Cli/Functions/Path/path_doCopy.sh deleted file mode 100755 index b49cb66..0000000 --- a/Scripts/Bash/Cli/Functions/Path/path_doCopy.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# -# path_doCopy.sh -- This function duplicates files inside the working -# copy using subversion commands. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function path_doCopy { - - # Verify target directory. - cli_checkRepoDirTarget - - # Print action preamble. - cli_printActionPreamble "${FLAG_TO}" 'doCreate' 'AsResponseLine' - - # Verify relation between source and target locations. We cannot - # duplicate an entry if its parent directory doesn't exist as - # entry inside the working copy. - if [[ -f ${ACTIONVAL} ]];then - if [[ ! -d $(dirname "${FLAG_TO}") ]];then - mkdir -p $(dirname "${FLAG_TO}") - fi - svn add $(dirname "${FLAG_TO}") --quiet - fi - - # Print action message. - cli_printMessage "${FLAG_TO}" 'AsCreatingLine' - - # Copy parent directory. - svn copy ${ACTIONVAL} ${FLAG_TO} --quiet - - # Verify syncronization flag. - if [[ $FLAG_SYNC == 'true' ]];then - - # Copy parallel directories. - . /home/centos/bin/centos-art manual --copy="$ACTIONVAL" --to="$FLAG_TO" - . /home/centos/bin/centos-art render --copy="$ACTIONVAL" --to="$FLAG_TO" - . /home/centos/bin/centos-art locale --copy="$ACTIONVAL" --to="$FLAG_TO" - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Path/path_doDelete.sh b/Scripts/Bash/Cli/Functions/Path/path_doDelete.sh deleted file mode 100755 index fad8ce4..0000000 --- a/Scripts/Bash/Cli/Functions/Path/path_doDelete.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# -# path_doDelete.sh -- This function deletes files inside the working -# copy using subversion commands. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function path_doDelete { - - # Verify target directory. - cli_checkRepoDirTarget - - # Print action preamble. - cli_printActionPreamble "$ACTIONVAL" 'doDelete' 'AsResponseLine' - - # Syncronize parallel directories related to action value. - . /home/centos/bin/centos-art manual --delete="$ACTIONVAL" - . /home/centos/bin/centos-art render --delete="$ACTIONVAL" - . /home/centos/bin/centos-art locale --delete="$ACTIONVAL" - - # Print action message. - cli_printMessage "${ACTIONVAL}" 'AsDeletingLine' - - # Perform action. - svn del ${ACTIONVAL} --quiet - -} diff --git a/Scripts/Bash/Cli/Functions/Path/path_getActions.sh b/Scripts/Bash/Cli/Functions/Path/path_getActions.sh deleted file mode 100755 index c63f2e2..0000000 --- a/Scripts/Bash/Cli/Functions/Path/path_getActions.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -# -# path_getActions.sh -- This function interpretes arguments passed to -# `path' functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function path_getActions { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="copy:,move:,delete:,to:,sync" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Define action to take for each option passed. - while true; do - case "$1" in - - --copy ) - - # Define action value passed through the command-line. - ACTIONVAL="$2" - - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_doCopy" - - # Rotate positional parameters. - shift 2 - ;; - - --delete ) - - # Define action value passed through the command-line. - ACTIONVAL="$2" - - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_doDelete" - - # Rotate positional parameters. - shift 2 - ;; - - --to ) - - # Redefine target flag. - FLAG_TO="$2" - - # Verify target directory. - cli_checkRepoDirTarget - - # Rotate positional parameters. - shift 2 - ;; - - --sync ) - - # Redefine syncronization flag. - FLAG_SYNC='true' - - # Rotate positional parameters. - shift 1 - ;; - - * ) - # Break options loop. - break - esac - done - - # Check action value (ACTIONVAL) passed through the command-line - # using source directory definition as reference. - cli_checkRepoDirSource - - # Syncronize changes between the working copy and the central - # repository to bring down changes. - cli_syncroRepoChanges "${ACTIOVAL} ${FLAG_TO}" - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Syncronize changes between the working copy and the central - # repository to commit up changes. - cli_commitRepoChanges "${ACTIOVAL} ${FLAG_TO}" - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare.sh deleted file mode 100755 index 0618ea1..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# prepare.sh -- This function prepares your workstation for using the -# centos-art command-line. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare { - - # Define packages flag. The package flag (--packages) controls - # whether package verification is performed or not. By default no - # package verification is done. - local FLAG_PACKAGES='false' - - # Define links flag. The link flag (--links) controls whether - # links verifications are performed or not. By default no link - # verification is done. - local FLAG_LINKS='false' - - # Define environment flag. The environment flag (--environment) - # controles whether verification of environment variables are - # performed or not. By default no verification of environment - # variables is done. - local FLAG_ENVIRONMENT='false' - - # Interpret arguments and options passed through command-line. - prepare_getArguments - - # Redefine positional parameters using ARGUMENTS. At this point, - # option arguments have been removed from ARGUMENTS variable and - # only non-option arguments remain in it. - eval set -- "$ARGUMENTS" - - # Define action name. It does matter what option be passed to - # centos-art, there are many different actions to perform based on - # the option passed (e.g., `--packages', `--links', - # `--environment', etc.). In that sake, we defined action name - # inside prepare_getArguments, at the moment of interpreting - # options. - - # Define action value. There is no action value in this function, - # but action name values only. There is no need for non-option - # arguments here since we are doing fixed verifications only in - # predifined paths. - - # Verify flags and execute actions accordingly. Start with - # packages, links and then environment. - prepare_doPackages - prepare_doLinks - prepare_doEnvironment - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doEnvironment.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doEnvironment.sh deleted file mode 100755 index 222b4fb..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doEnvironment.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# -# prepare_doEnvironment.sh -- This function outputs a brief description -# of environment variables used by `centos-art.sh' script. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_doEnvironment { - - # Verify `--packages' option. - if [[ $FLAG_ENVIRONMENT == 'false' ]];then - return - fi - - # Print line separator. - cli_printMessage '-' 'AsSeparatorLine' - - # Print action message. - cli_printMessage "`gettext "Checking environment variables"`" 'AsResponseLine' - - # Print line separator. - cli_printMessage '-' 'AsSeparatorLine' - - local -a VARS - local -a INFO - local COUNT=0 - - # Define name of environment variables used by centos-art.sh - # script. - VARS[0]='EDITOR' - VARS[1]='TZ' - VARS[2]='TEXTDOMAIN' - VARS[3]='TEXTDOMAINDIR' - VARS[4]='LANG' - - # Define description of environment variables. - INFO[0]="`gettext "Default text editor"`" - INFO[1]="`gettext "Default time zone representation"`" - INFO[2]="`gettext "Default domain used to retrieve translated messages"`" - INFO[3]="`gettext "Default directory used to retrive translated messages"`" - INFO[4]="`gettext "Default locale information"`" - - until [[ $COUNT -eq ${#VARS[*]} ]];do - - # Let user to reduce output using regular expression as - # reference. - if [[ ${VARS[$COUNT]} =~ $FLAG_FILTER ]];then - - # Output list of environment variables using indirect - # expansion (what a beautiful feature!) to output variable - # value. - cli_printMessage "${INFO[$COUNT]}:" - cli_printMessage "${VARS[$COUNT]}=${!VARS[$COUNT]}" 'AsResponseLine' - - fi - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinks.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinks.sh deleted file mode 100755 index 67ff049..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doLinks.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash -# -# prepare_doLinks.sh -- This function installs the symbolic links your -# workstation needs to have in order for centos-art command to run -# correctly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_doLinks { - - # Verify `--links' option. - if [[ $FLAG_LINKS == 'false' ]];then - return - fi - - # Print line separator. - cli_printMessage '-' 'AsSeparatorLine' - - # Print action message. - cli_printMessage "`gettext "Checking symbolic links"`" 'AsResponseLine' - - # Print line separator. - cli_printMessage '-' 'AsSeparatorLine' - - local -a LINKS_SRC - local -a LINKS_DST - local USERFILES='' - local PALETTE='' - local BRUSH='' - local PATTERN='' - local FONT='' - local FILE='' - local COUNT=0 - - # Initialize file prefix. Since we are taking the same file names - # from different theme directory and putting them into the same - # directory structure it is required to identify them some way in - # that common directory structure. For this we use the theme path - # identifier. - local PREFIX='' - - # Define user-specific directory for Gimp. - local GIMP_USER_DIR=${HOME}/.$(rpm -q gimp | cut -d. -f-2) - - # Define user-specific directory for Inkscape. - local INKS_USER_DIR=${HOME}/.inkscape - - # Define both source and target location for centos-art command. - LINKS_SRC[0]=${HOME}/bin/$CLI_PROGRAM - LINKS_DST[0]=${CLI_BASEDIR}/init.sh - - # Define both source and target location for fonts. - local FONTS=$(cli_getFilesList "${HOME}/artwork/trunk/Identity/Fonts" 'denmark\.ttf') - for FONT in $FONTS;do - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.fonts/$(basename $FONT) - LINKS_DST[((++${#LINKS_DST[*]}))]=$FONT - done - - # Define both source and target location for Gimp and Inkscape - # palettes. - local PALETTES=$(cli_getFilesList "$HOME/artwork/trunk/Identity/Themes/Motifs/*/*/Palettes - ${HOME}/artwork/trunk/Identity/Palettes" ".+\.gpl") - for PALETTE in $PALETTES;do - if [[ $PALETTE =~ $(cli_getPathComponent '--theme-pattern') ]];then - PREFIX="$(cli_getPathComponent "$PALETTE" '--theme-name')-$(cli_getPathComponent "$PALETTE" '--theme-release')-" - fi - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_USER_DIR}/palettes/${PREFIX}$(basename $PALETTE) - LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_USER_DIR}/palettes/${PREFIX}$(basename $PALETTE) - LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE - done - - # Define both source and target location for Gimp brushes. - local BRUSHES=$(cli_getFilesList \ - "${HOME}/artwork/trunk/Identity/Themes/Motifs/*/*/Brushes" \ - ".+\.(gbr|gih)") - for BRUSH in $BRUSHES;do - PREFIX="$(cli_getPathComponent "$BRUSH" '--theme-name')-$(cli_getPathComponent "$BRUSH" '--theme-release')" - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_USER_DIR}/brushes/${PREFIX}-$(basename $BRUSH) - LINKS_DST[((++${#LINKS_DST[*]}))]=$BRUSH - done - - # Define both source and target location for Gimp patterns. - local PATTERNS=$(cli_getFilesList \ - "${HOME}/artwork/trunk/Identity/Themes/Motifs/*/*/Patterns" \ - ".+\.png") - for PATTERN in $PATTERNS;do - PREFIX="$(cli_getPathComponent "$PATTERN" '--theme-name')-$(cli_getPathComponent "$PATTERN" '--theme-release')" - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_USER_DIR}/patterns/${PREFIX}-$(basename $PATTERN) - LINKS_DST[((++${#LINKS_DST[*]}))]=$PATTERN - done - - # Define files inside user-specific directories that need to be - # removed in order to make a fresh installation of patterns, - # palettes and brushes using symbolic links from the repository. - USERFILES=$(cli_getFilesList "${HOME}/.fonts" '.+\.ttf'; - cli_getFilesList "${HOME}/bin" '.+\.sh'; - cli_getFilesList "${GIMP_USER_DIR}/palettes" '.+\.gpl'; - cli_getFilesList "${GIMP_USER_DIR}/brushes" '.+\.(gbr|gih)'; - cli_getFilesList "${GIMP_USER_DIR}/patterns" '.+\.png'; - cli_getFilesList "${INKS_USER_DIR}/palettes" '.+\.gpl') - - # Remove installed files inside user-specific directories. - if [[ "$USERFILES" != '' ]];then - cli_printActionPreamble "${USERFILES[*]}" 'doDelete' 'AsResponseLine' - for FILE in ${USERFILES[@]};do - cli_printMessage "${FILE}" 'AsDeletingLine' - rm -r $FILE - done - fi - - # Create symbolic links. In case the the symbolic link parent - # directory isn't created, it will be created in order to make - # the link creation possible. - cli_printActionPreamble "${LINKS_SRC[*]}" 'doCreate' 'AsResponseLine' - while [[ $COUNT -lt ${#LINKS_SRC[*]} ]];do - - if [[ -f ${LINKS_SRC[$COUNT]} ]];then - cli_printMessage "${LINKS_SRC[$COUNT]}" 'AsUpdatingLine' - else - cli_printMessage "${LINKS_SRC[$COUNT]}" 'AsCreatingLine' - fi - - if [[ ! -d $(dirname ${LINKS_SRC[$COUNT]}) ]];then - mkdir -p $(dirname ${LINKS_SRC[$COUNT]}) - fi - - ln ${LINKS_DST[$COUNT]} ${LINKS_SRC[$COUNT]} --symbolic --force - - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackages.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackages.sh deleted file mode 100644 index c119cc0..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_doPackages.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash -# -# prepare_doPackages.sh -- This function verifies the required -# packages your workstation needs to have installed in order for -# centos-art command to run correctly. If there is one or more missing -# packages, the `centos-art.sh' script asks you to confirm their -# installation through yum. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_doPackages { - - # Verify `--packages' option. - if [[ $FLAG_PACKAGES == 'false' ]];then - return - fi - - # Print line separator. - cli_printMessage '-' 'AsSeparatorLine' - - # Print action message. - cli_printMessage "`gettext "Checking required packages"`" 'AsResponseLine' - - # Print line separator. - cli_printMessage '-' 'AsSeparatorLine' - - local PACKAGE='' - local WARNING='' - local PACKAGES='' - local PACKAGES_THIRDS='' - local -a PACKAGES_MISSING - local RPM='/bin/rpm' - local YUM='/usr/bin/yum' - - # Check execution rights of package managers. - cli_checkFiles $RPM 'x' - cli_checkFiles $YUM 'x' - - # Define required packages needed by centos-art.sh script. - PACKAGES="inkscape ImageMagick netpbm netpbm-progs syslinux gimp - coreutils texinfo info tetex-latex tetex-fonts tetex-xdvi - tetex-dvips gettext texi2html gnome-doc-utils elinks - docbook-style-xsl docbook-utils docbook-dtds - docbook-style-dsssl docbook-simple docbook-utils-pdf - docbook-slides firefox sudo yum rpm" - - # Define packages from third party repositories (i.e., packages - # not included in CentOS [base] repository.) required by - # centos-art to work as expected. - PACKAGES_THIRDS="(inkscape|blender)" - - # Build list of missing packages. - for PACKAGE in $PACKAGES;do - $RPM -q --queryformat "%{NAME}\n" $PACKAGE --quiet - if [[ $? -ne 0 ]];then - PACKAGES_MISSING[((++${#PACKAGES_MISSING[*]}))]=$PACKAGE - fi - done - - # Is there any package missing? - if [[ ${#PACKAGES_MISSING[*]} -eq 0 ]];then - cli_printMessage "`gettext "The required packages has been already installed."`" - return - fi - - # At this point there is one or more missing packages that need to - # be installed in the workstation. Report this issue and specify - # which these packages are. - cli_printMessage "`ngettext "The following package needs to be installed" \ - "The following packages need to be installed" \ - "${#PACKAGES_MISSING[*]}"`:" - - # Build report of missing packages and remark those comming from - # third party repository. - for PACKAGE in ${PACKAGES_MISSING[@]};do - if [[ $PACKAGE =~ $PACKAGES_THIRDS ]];then - WARNING=" (`gettext "requires third party repository!"`)" - fi - cli_printMessage "${PACKAGE}${WARNING}" 'AsResponseLine' - done - - # Print confirmation request. - cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' - - # Use sudo to install the missing packages in your system through - # yum. - sudo ${YUM} install ${PACKAGES_MISSING[*]} - -} diff --git a/Scripts/Bash/Cli/Functions/Prepare/prepare_getArguments.sh b/Scripts/Bash/Cli/Functions/Prepare/prepare_getArguments.sh deleted file mode 100755 index 2644b0a..0000000 --- a/Scripts/Bash/Cli/Functions/Prepare/prepare_getArguments.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# -# prepare_getArguments.sh -- This function interpretes arguments passed -# to `prepare' functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function prepare_getArguments { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="quiet,answer:,packages,links,environment" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - case "$1" in - - --quiet ) - FLAG_QUIET="true" - FLAG_DONT_COMMIT_CHANGES="true" - shift 1 - ;; - - --answer ) - FLAG_ANSWER="$2" - shift 2 - ;; - - --packages ) - FLAG_PACKAGES="true" - shift 1 - ;; - - --links ) - FLAG_LINKS="true" - shift 1 - ;; - - --environment ) - FLAG_ENVIRONMENT="true" - shift 1 - ;; - - * ) - break - esac - done - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render.sh b/Scripts/Bash/Cli/Functions/Render/render.sh deleted file mode 100644 index 959b549..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# -# render.sh -- This function initializes rendition variables and -# actions to centos-art.sh script. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render { - - local ACTIONNAM='' - local ACTIONVAL='' - - # Initialize `--releasever' option. The release version option - # controls the release number used to produce release-specific - # content. By default no release number is used. - local FLAG_RELEASEVER='' - - # Initialize `--basearch' option. The base architecture option - # controls the architecture type used to produce - # architecture-specific content. By default no architecture type - # is used. - local FLAG_BASEARCH='' - - # Initialize `--theme-model' option. The theme model option - # specifies the the theme model name used to produce theme - # artistic motifs. - local FLAG_THEME_MODEL='Default' - - # Initialize `--convert' option. The convert option controls - # whether convert or not content produced by centos-art - # base-rendition. By default there is no content convertion. - local FLAG_CONVERT='' - - # Initialize `--rotate' option. The rotate option controls whether - # rotate or not image content produced by centos-art - # base-rendition. By default there is no content rotation. - local FLAG_ROTATE='' - - # Initialize `--resize' option. The resize option controls whether - # resize or not content produced by centos-art base-rendition. By - # default there is no content resizing. - local FLAG_RESIZE='' - - # Initialize `--group-by' option. The grouped-by option specifies - # whether grouping or not content produced by centos-art - # base-rendition. By default there is no content grouping. - local FLAG_GROUPED_BY='' - - # Interpret arguments and options passed through command-line. - render_getArguments - - # Redefine positional parameters using ARGUMENTS. At this point, - # option arguments have been removed from ARGUMENTS variable and - # only non-option arguments remain in it. - eval set -- "$ARGUMENTS" - - # Define action name. No matter what option be passed to - # centos-art, there is only one action to perform (i.e., the - # base-rendition flow). - ACTIONNAM="${FUNCNAME}_doBaseActions" - - # Define action value. We use non-option arguments to define the - # action value (ACTIONVAL) variable. - for ACTIONVAL in "$@";do - - if [[ $ACTIONVAL == '--' ]];then - continue - fi - - # Check action value. Be sure the action value matches the - # convenctions defined for source locations inside the working - # copy. - cli_checkRepoDirSource - - # Syncronize changes between repository and working copy. At - # this point, changes in the repository are merged in the - # working copy and changes in the working copy committed up to - # repository. - cli_syncroRepoChanges - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Commit changes from working copy to central repository only. - # At this point, changes in the repository are not merged in - # the working copy, but chages in the working copy do are - # committed up to repository. - cli_commitRepoChanges - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_checkSvgAbsref.sh b/Scripts/Bash/Cli/Functions/Render/render_checkSvgAbsref.sh deleted file mode 100755 index 89b1b2a..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_checkSvgAbsref.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# render_checkSvgAbsref.sh -- This function retrives absolute files -# and checks their existence. In order for design templates to point -# different artistic motifs, design templates make use of external -# files that point to specific artistic motif background images. If -# such external files doesn't exist, print a message and stop script -# execution. We cannot continue without background information. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_checkSvgAbsref { - - local FILE='' - local ABSPATHS='' - local ABSPATH='' - - # Define absolute path of file we need to retrive absolute paths - # from. - FILE="$1" - - # Verify existence of file we need to retrive absolute paths from. - cli_checkFiles $FILE 'f' - - # Retrive absolute paths from file. - ABSPATHS=$(egrep "(sodipodi:absref|xlink:href)=\"${HOME}.+" $FILE \ - | sed -r "s,.+=\"(${HOME}.+)\".*,\1,") - - # Verify absolute paths retrived from file. - for ABSPATH in $ABSPATHS;do - cli_checkFiles "$ABSPATH" 'f' - done - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_convertDocbookToXhtml.sh b/Scripts/Bash/Cli/Functions/Render/render_convertDocbookToXhtml.sh deleted file mode 100755 index e5f818a..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_convertDocbookToXhtml.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# -# render_convertDocbookToXhtml.sh -- This function produces XHTML -# output from docbook template instance using XSL stylesheets as -# reference. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_convertDocbookToXhtml { - - # Print action message. - if [[ -f ${FILE}.xhtml ]];then - cli_printMessage "${FILE}.xhtml" 'AsUpdatingLine' - else - cli_printMessage "${FILE}.xhtml" 'AsCreatingLine' - fi - - # Define list of XSL stylesheets. - local XSL='/usr/share/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl' - - # Produce xhtml output from docbook template instance using XSL - # stylesheets as reference. - xsltproc ${XSL} $INSTANCE > ${FILE}.xhtml - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_convertGplToHex.sh b/Scripts/Bash/Cli/Functions/Render/render_convertGplToHex.sh deleted file mode 100755 index 6715ad0..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_convertGplToHex.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# -# render_convertGplToHex.sh -- This function takes one palette -# produced by Gimp (e.g., syslinux.gpl) as input and outputs the list -# of hexadecimal colors and their respective index position the -# `pnmtolss16' program needs (e.g., #RRGGBB=0 #RRGGBB=1 ... [all -# values in the same line]). -# -# Copyright 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_convertGplToHex { - - local COLOR='' - local COUNT=0 - local -a FILES - - # Define path to GPL palette. This is the .gpl file we use to - # retrive color information from. - local PALETTE_GPL="$1" - - # Define path to HEX palette. This is the palette used to stored - # the color information the `ppmtolss16' program needs. - local PALETTE_HEX="$2" - - # Define the number of colors this function should return. - local COLOR_NUMBER="$3" - - # Verify the number of colors this function should return. As - # convenction, we are producing images in 14 and 16 colors only to - # cover Grub and Syslinux images need respectively. - if [[ ! $COLOR_NUMBER =~ '^(14|16)$' ]];then - cli_printMessage "`eval_gettext "Reducing image to \\\`\\\$COLOR_NUMBER' colors is not supported."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Define list of colors from GPL palette. - local COLORS=$(render_getColors "$PALETTE_GPL") - - # Verify number of colors returned in the list. - if [[ ! $(echo "$COLORS" | wc -l) =~ $COLOR_NUMBER ]];then - cli_printMessage "`gettext "The palette doesn't have the correct number of colors."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Verify format of colors inside the list. - for COLOR in $COLORS;do - if [[ ! $COLOR =~ '^[0-9a-f]{6}$' ]];then - cli_printMessage "`eval_gettext "The \\\`\\\$COLOR' string isn't a valid color code."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - done - - # Create list of colors to be process by pnmtolss16 - echo "$COLORS" | nl | awk '{ printf "#%s=%d ", $2, $1 - 1 }' \ - > $PALETTE_HEX - - # Verify HEX palette existence. - cli_checkFiles "$PALETTE_PPM" 'f' - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_convertGplToPpm.sh b/Scripts/Bash/Cli/Functions/Render/render_convertGplToPpm.sh deleted file mode 100755 index f8d6ce0..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_convertGplToPpm.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# -# render_convertGplToPpm.sh -- This function takes one palette -# produced by Gimp (e.g., syslinux.gpl) as input and outputs one PPM -# file based on it (e.g., syslinux.ppm). -# -# Copyright 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_convertGplToPpm { - - local COLOR='' - local COUNT=0 - local -a FILES - - # Define path to GPL palette. This is the .gpl file we use to - # retrive color information from. - local PALETTE_GPL="$1" - - # Define path to PPM palette. This is the .ppm file we'll save - # color information to. - local PALETTE_PPM="$2" - - # Define the number of colors this function should return. - local COLOR_NUMBER="$3" - - # Verify the number of colors this function should return. As - # convenction, we are producing images in 14 and 16 colors only to - # cover Grub and Syslinux images need respectively. - if [[ ! $COLOR_NUMBER =~ '^(14|16)$' ]];then - cli_printMessage "`eval_gettext "Reducing image to \\\`\\\$COLOR_NUMBER' colors is not supported."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Define list of colors from GPL palette. - local COLORS=$(render_getColors "$PALETTE_GPL") - - # Verify number of colors returned in the list. - if [[ ! $(echo "$COLORS" | wc -l) =~ $COLOR_NUMBER ]];then - cli_printMessage "`gettext "The palette doesn't have the correct number of colors."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Verify format of colors inside the list. - for COLOR in $COLORS;do - if [[ ! $COLOR =~ '^[0-9a-f]{6}$' ]];then - cli_printMessage "`eval_gettext "The \\\`\\\$COLOR' string isn't a valid color code."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - done - - # Create temporal images (of 1x1 pixel each) for each color - # retrived from Gimp's palette. - for COLOR in $COLORS;do - FILES[$COUNT]=$(cli_getTemporalFile "color-${COUNT}.ppm") - ppmmake $(echo "$COLOR" \ - | sed -r 's!(.{2})(.{2})(.{2})!rgb:\1/\2/\3!') 1 1 \ - > ${FILES[$COUNT]} - COUNT=$(($COUNT + 1)) - done - - # Concatenate temporal images from left to right to create the PPM - # file. - pnmcat -lr ${FILES[*]} > $PALETTE_PPM - - # Remove temporal images. - rm ${FILES[*]} - - # Verify PPM palette existence. - cli_checkFiles "$PALETTE_PPM" 'f' - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_convertHtmlToText.sh b/Scripts/Bash/Cli/Functions/Render/render_convertHtmlToText.sh deleted file mode 100755 index a84adbf..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_convertHtmlToText.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# render_convertHtmlToText.sh -- This function takes one HTML file -# and produces one plain-text file (i.e., without markup inside). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_convertHtml2Text { - - # Verify existence of HTML file. - cli_checkFiles ${FILE}.xhtml 'f' - - local COMMAND='' - local OPTIONS='' - - # Define the command path to text-based web browser and options - # used to produce plain-text files. Most of these programs have a - # dump option that print formatted plain-text versions of given - # HTML file to stdout. - if [[ -x '/usr/bin/lynx' ]];then - COMMAND='/usr/bin/lynx' - OPTIONS='-force_html -nolist -width 70 -dump' - elif [[ -x '/usr/bin/elinks' ]];then - COMMAND='/usr/bin/elinks' - OPTIONS='-force_html -no-numbering -no-references -width 70 -dump' - elif [[ -x '/usr/bin/w3m' ]];then - COMMAND='/usr/bin/w3m' - OPTIONS='-dump' - fi - - if [[ $COMMAND != '' ]];then - - # Print action message. - if [[ -f ${FILE}.txt ]];then - cli_printMessage "${FILE}.txt" 'AsUpdatingLine' - else - cli_printMessage "${FILE}.txt" 'AsCreatingLine' - fi - - # Convert from HTML to plain-text without markup. - ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt - - else - cli_printMessage "`gettext "No way to convert from HTML to plain-text found."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_convertPngTo.sh b/Scripts/Bash/Cli/Functions/Render/render_convertPngTo.sh deleted file mode 100644 index bd5e398..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_convertPngTo.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# -# render_convertPngTo.sh -- This function provides post-rendition -# to convert images images produced by centos-art base-rendition. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_convertPngTo { - - # Get image formats. - local FORMATS=$(render_getConfigOption "$ACTION" '2-') - - # Check base file existence. - cli_checkFiles ${FILE}.png 'f' - - # Check image formats and do convertion. - if [[ "$FORMATS" != "" ]];then - for FORMAT in $FORMATS;do - cli_printMessage "${FILE}.${FORMAT}" "AsSavedAsLine" - convert -quality 85 ${FILE}.png ${FILE}.${FORMAT} - done - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_copy.sh b/Scripts/Bash/Cli/Functions/Render/render_copy.sh deleted file mode 100755 index e54abe9..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_copy.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# render_copy.sh -- This function duplicates rendition stuff. -# Rendition stuff is formed by design models, design images and -# pre-rendition configuration scripts (which includes translations -# files). This way, when we say to duplicate rendition stuff we are -# saying to duplicate these four directory structures (i.e., design -# models, design images, pre-rendition configuration scripts, and -# related translations files). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_copy { - - # Verify target directory. - cli_checkRepoDirTarget - - # Determine what directory structure we are duplicating. - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doBaseActions.sh b/Scripts/Bash/Cli/Functions/Render/render_doBaseActions.sh deleted file mode 100755 index 231cae3..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doBaseActions.sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/bash -# -# render_do.sh -- This function performs base-rendition action -# for all files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doBaseActions { - - local -a FILES - local FILE='' - local OUTPUT='' - local TEMPLATE='' - local PARENTDIR='' - local EXTENSION='' - local TRANSLATION='' - local EXTERNALFILE='' - local EXTERNALFILES='' - local THIS_FILE_DIR='' - local NEXT_FILE_DIR='' - local COUNT=0 - - # Initialize post-rendition list of actions, the specification of - # what actions does centos-art execute immediatly after producing - # the base file in the same directory structure. - local -a POSTACTIONS - - # Initialize last-rendition list of actions, the specification of - # what actions does centos-art execute once all base files in the - # same directory structure have been produced, this is just - # immediatly before passing to produce the next directory - # structure. - local -a LASTACTIONS - - # Check theme model directory structure. - cli_checkFiles "$(cli_getRepoTLDir)/Identity/Themes/Models/${FLAG_THEME_MODEL}" 'd' - - # Verify post-rendition actions passed from command-line and add - # them, if any, to post-rendition list of actions. - if [[ $FLAG_GROUPED_BY != '' ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]="groupSimilarFiles:${FLAG_GROUPED_BY}" - fi - - # Define the extension pattern for template files. This is the - # file extensions that centos-art will look for in order to build - # the list of files to process. The list of files to process - # contains the files that match this extension pattern. - EXTENSION='\.(svgz|svg|docbook)' - - # Redefine parent directory for current workplace. - PARENTDIR=$(basename "${ACTIONVAL}") - - # Define base location of template files. - render_getDirTemplate - - # Define list of files to process as array variable. This make - # posible to realize verifications like: is the current base - # directory equal to the next one in the list of files to process? - # This is used to know when centos-art.sh is leaving a directory - # structure and entering into another. This information is - # required in order for centos-art.sh to know when to apply - # last-rendition actions. - for FILE in $(cli_getFilesList "${TEMPLATE}" "${FLAG_FILTER}.*${EXTENSION}");do - FILES[((++${#FILES[*]}))]=$FILE - done - - # Set action preamble. - cli_printActionPreamble "${FILES[*]}" '' '' - - # Start processing the base rendition list of FILES. Fun part - # approching :-). - while [[ $COUNT -lt ${#FILES[*]} ]];do - - # Define base file. - FILE=${FILES[$COUNT]} - - # Define the base directory path for the current file being - # process. - THIS_FILE_DIR=$(dirname ${FILES[$COUNT]}) - - # Define the base directory path for the next file that will - # be process. - if [[ $(($COUNT + 1)) -lt ${#FILES[*]} ]];then - NEXT_FILE_DIR=$(dirname ${FILES[$(($COUNT + 1))]}) - else - NEXT_FILE_DIR='' - fi - - # Print separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Define final location of translation file. - TRANSLATION=$(dirname $FILE \ - | sed -r 's!/trunk/(Identity/)!/trunk/Locales/\1!')/$(cli_getCurrentLocale).po - - # Print final location of translation file. - if [[ ! -f "$TRANSLATION" ]];then - cli_printMessage "`gettext "None"`" "AsTranslationLine" - else - cli_printMessage "$TRANSLATION" 'AsTranslationLine' - fi - - # Define final location of template file. - TEMPLATE=${FILE} - - # Print final location of template file. - if [[ ! -f "$TEMPLATE" ]];then - cli_printMessage "`gettext "None"`" "AsDesignLine" - else - cli_printMessage "$TEMPLATE" 'AsDesignLine' - fi - - # Define final location of output directory. - render_getDirOutput - - # Get relative path to file. The path string (stored in FILE) - # has two parts: 1. the variable path and 2. the common path. - # The variable path is before the common point in the path - # string. The common path is after the common point in the - # path string. The common point is the name of the parent - # directory (stored in PARENTDIR). - # - # trunk/Locales/Identity/.../Firstboot/3/splash-small.svg - # -------------------------^| the |^------------^ - # variable path | common | common path - # -------------------------v| point | v------------v - # trunk/Identity/Themes/M.../Firstboot/Img/3/splash-small.png - # - # What we do here is remove the varibale path, the common - # point, and the file extension parts in the string holding - # the path retrived from design models directory structure. - # Then we use the common path as relative path to store the - # the final image file. - # - # The file extension is removed from the common path because - # it is set when we create the final image file. This - # configuration let us use different extensions for the same - # file name. - # - # When we render using renderImage function, the structure of - # files under the output directory will be the same used after - # the common point in the related design model directory - # structure. - FILE=$(echo ${FILE} \ - | sed -r "s!.*${PARENTDIR}/!!" \ - | sed -r "s/${EXTENSION}$//") - - # Define absolute path to final file (without extension). - FILE=${OUTPUT}/$(basename "${FILE}") - - # Define instance name from design model. - INSTANCE=$(cli_getTemporalFile ${TEMPLATE}) - - # Verify translation file existence and create template - # instance accordingly. - if [[ -f ${TRANSLATION} ]];then - - # Create translated instance from design model. - /usr/bin/xml2po -p ${TRANSLATION} ${TEMPLATE} > ${INSTANCE} - - # Remove .xml2po.mo temporal file. - if [[ -f ${PWD}/.xml2po.mo ]];then - rm ${PWD}/.xml2po.mo - fi - - else - # Create non-translated instance form design model. - /bin/cp ${TEMPLATE} ${INSTANCE} - fi - - # Apply translation markers replacements to template instance. - cli_replaceTMarkers ${INSTANCE} - - # Verify the extension of template instance and render content - # accordingly. - if [[ $INSTANCE =~ '\.(svgz|svg)$' ]];then - - # Perform base-rendition action for svg files. - render_doSvg - - # Perform post-rendition action for svg files. - render_doSvgPostActions - - # Perform last-rendition action for svg files. - render_doSvgLastActions - - elif [[ $INSTANCE =~ '\.docbook$' ]];then - - # Perform base-rendition action for docbook files. - render_doDocbook - - # Perform post-rendition action for docbook files. - #render_doDocbookPostActions - - # Perform base-rendition action for docbook files. - #render_doDocbookLastActions - - else - cli_printMessage "`gettext "The template file you try to render is not supported yet."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Remove template instance. - if [[ -f $INSTANCE ]];then - rm $INSTANCE - fi - - # Perform post-rendition actions for all files. - render_doPostActions - - # Perform last-rendition actions for all files. - render_doLastActions - - # Increment file counter. - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doBrands.sh b/Scripts/Bash/Cli/Functions/Render/render_doBrands.sh deleted file mode 100644 index f9afa94..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doBrands.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# -# render_doBrands.sh -- This function provides last-rendition -# actions to produce CentOS brands. This function takes both The -# CentOS Symbol and The CentOS Type images and produces variation of -# them in different dimensions and formats using ImageMagick tool-set. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doBrands { - - local SOURCEFILE='' - local TARGETDIR='' - local TARGETFILE='' - local NEWFILE='' - - # Define absolute path to image file. - local FILE="$1" - - # Define height dimensions you want to produce brands for. - local SIZES="16 20 22 24 32 36 40 48 64 96 128 148 164 196 200 512" - - # Define image formats you want to produce brands for. - local FORMATS="png xpm pdf jpg tif" - - # Redefine absolute path to directory where final brand images - # will be stored. Notice how both final image directory and design - # model have the same name, this is intentional in order to keep - # images and design models related and organized inside their own - # directory structures. - local DIRNAME=$(cli_getRepoName "$FILE" 'd')/$(cli_getRepoName "$FILE" 'fd') - - # Check directory where final brand images will be stored. - if [[ ! -d $DIRNAME ]];then - mkdir -p ${DIRNAME} - fi - - for SIZE in ${SIZES};do - - # Redefine name of new file. - NEWFILE=${DIRNAME}/${SIZE} - - for FORMAT in ${FORMATS};do - - # Output action information. - cli_printMessage "${NEWFILE}.${FORMAT}" "AsCreatingLine" - - # Convert and resize to create new file. - convert -resize x${SIZE} ${FILE}.png ${NEWFILE}.${FORMAT} - - done - - # Create logo copy in 2 colors. - cli_printMessage "${NEWFILE}.xbm (`gettext "2 colors grayscale"`)" "AsCreatingLine" - convert -resize x${SIZE} -colorspace gray -colors 2 ${FILE}.png ${NEWFILE}.xbm - - # Create logo copy in emboss effect. - cli_printMessage "${NEWFILE}-emboss.png" "AsCreatingLine" - convert -resize x${SIZE} -emboss 1 ${FILE}.png ${NEWFILE}-emboss.png - - done - - # Output division line. - cli_printMessage '-' 'AsSeparatorLine' -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doDm.sh b/Scripts/Bash/Cli/Functions/Render/render_doDm.sh deleted file mode 100755 index c7edb46..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doDm.sh +++ /dev/null @@ -1,191 +0,0 @@ -#!/bin/bash -# -# render_doDm.sh -- This function collects Display Manager (DM) -# required files and creates a tar.gz package that groups them all -# together. Use this function as last-rendition action for Gdm and Kdm -# base-rendition actions. -# -# Usage: -# -# ACTIONS[1]='LAST:renderDm:TYPE:RESOLUTION' -# -# Where: -# -# TYPE can be either `Gdm' or `Kdm'. These values correspond to the -# directory names used to store related design models. -# -# RESOLUTION represents the screen resolution tar.gz files are -# produced for (e.g., 800x600, 1024x768, 2048x1536, etc.). -# -# In order to produce tar.gz files correctly, both screen resolution -# definition inside pre-rendition configuration script and background -# name inside theme directory structure need to match one another. If -# one screen resolution is defined correctly, but there is no -# background information for it, the related tar.gz file is not -# produced and the next file in the list of files to process is -# evaluated. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doDm { - - local -a SRC - local -a DST - local DM='' - local TGZ='' - local COUNT=0 - local RESOLUTION='' - local RESOLUTIONS='' - - # Print separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Get display manager passed from render.conf.sh pre-rendition - # configuration script. - DM=$(render_getConfigOption "${ACTION}" '2') - - # Sanitate display manager passed from render.conf.sh - # pre-rendition configuration script. Whatever value be retrived - # as display manager configuration option is converted to - # uppercase in order to match either Gdm or Kdm design model - # directory structures. - DM=$(cli_getRepoName "$DM" 'd') - - # Get screen resolutions passed from render.conf.sh pre-rendition - # configuration script. - RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3') - - # Check screen resolutions passed from render.conf.sh - # pre-rendition configuration script. - if [[ "$RESOLUTIONS" == '' ]];then - cli_printMessage "`gettext "There is no resolution information to process."`" 'AsErrorLine' - cli_printMessage $(caller) "AsToKnowMoreLine" - fi - - # Define source files using absolute paths. - SRC[0]=$(cli_getRepoTLDir)/Identity/Brands/Img/symbol-resized-48.png - SRC[1]=${OUTPUT}/release.png - SRC[2]=${OUTPUT}/screenshot.png - SRC[3]=$(dirname $TEMPLATE)/GdmGreeterTheme.xml - SRC[4]=$(dirname $TEMPLATE)/GdmGreeterTheme.desktop - SRC[5]=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Backgrounds/Img/Png - SRC[6]=$(dirname $TEMPLATE)/icon-language.png - SRC[7]=$(dirname $TEMPLATE)/icon-reboot.png - SRC[8]=$(dirname $TEMPLATE)/icon-session.png - SRC[9]=$(dirname $TEMPLATE)/icon-shutdown.png - - # Define name used as temporal holder to build tar.gz file. - TGZ=$(cli_getPathComponent '--theme-name') - - # Define target files using relative paths. - DST[0]=${TGZ}/centos-symbol.png - DST[1]=${TGZ}/centos-release.png - DST[2]=${TGZ}/screenshot.png - DST[3]=${TGZ}/${TGZ}.xml - DST[4]=${TGZ}/GdmGreeterTheme.desktop - DST[5]=${TGZ}/background.png - DST[6]=${TGZ}/icon-language.png - DST[7]=${TGZ}/icon-reboot.png - DST[8]=${TGZ}/icon-session.png - DST[9]=${TGZ}/icon-shutdown.png - - # Move into the working directory. - pushd ${OUTPUT} > /dev/null - - # Create directory used as temporal holder to build tar.gz file. - if [[ ! -d ${TGZ} ]];then - mkdir ${TGZ} - fi - - for RESOLUTION in $RESOLUTIONS;do - - while [[ $COUNT -lt ${#SRC[*]} ]];do - - if [[ $COUNT -eq 5 ]];then - - # Redefine background information using resolution as - # reference. Avoid concatenation. - SRC[$COUNT]=$(echo "${SRC[$COUNT]}" | cut -d/ -f-13)/${RESOLUTION}-final.png - - # If background information defined inside - # pre-rendition configuration script doesn't match - # background information inside theme-specific - # backgrounds directory structure, try the next - # background definition. - if [[ ! -f ${SRC[$COUNT]} ]];then - continue 2 - fi - - elif [[ $COUNT =~ '^[6-9]$' ]];then - - # If display manager is Kdm, then increment counter and - # resume the next iteration. Icons aren't used on Kdm, - # so there's no need to have them inside it. - if [[ $DM =~ '^Kdm$' ]];then - COUNT=$(($COUNT + 1)) - continue - fi - - fi - - # Check existence of source files. - cli_checkFiles ${SRC[$COUNT]} - - # Copy files from source to target location. - cp ${SRC[$COUNT]} ${DST[$COUNT]} - - # Replace common translation markers from design model - # files with appropriate information. - if [[ $COUNT =~ '^(3|4)$' ]];then - cli_replaceTMarkers "${DST[$COUNT]}" - fi - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - - # Reset counter. - COUNT=0 - - # Print action message. - cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" "AsCreatingLine" - - # Create tar.gz file. - tar -czf "${RESOLUTION}.tar.gz" $TGZ - - done - - # Remove directory used as temporal holder to build targ.gz - # file. - rm -r $TGZ - - # Remove release-specific images. - cli_printMessage "${SRC[1]}" "AsDeletingLine" - rm ${SRC[1]} - cli_printMessage "${SRC[2]}" "AsDeletingLine" - rm ${SRC[2]} - - # Return to where we were initially. - popd > /dev/null - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doDocbook.sh b/Scripts/Bash/Cli/Functions/Render/render_doDocbook.sh deleted file mode 100755 index 86f738d..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doDocbook.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# render_doDocbook.sh -- This function performs base-rendition -# action for DocBook files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doDocbook { - - # Produce xhtml output from docbook template instance using XSL - # stylesheets as reference. - render_convertDocbookToXhtml - - # Produce plaintext output from html outout. - render_convertHtml2Text - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doGrub.sh b/Scripts/Bash/Cli/Functions/Render/render_doGrub.sh deleted file mode 100644 index 4d4286e..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doGrub.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# -# render_doGrub.sh -- This function provides post-rendition -# action used to produce GRUB images. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doGrub { - - # Define number of colors the images will be produced on. - local COLOR_NUMBER='14' - - # Define options using those passed to actions from pre-rendition - # configuration script. These options are applied to pnmremap when - # doing color reduction, so any option available for pnmremap - # command can be passed to renderSyslinux functionality. - local OPTIONS=$(render_getConfigOption "$ACTION" '2-') - - # Check options passed to action. This is required in order to - # aviod using options used already in this script. For example - # -verbose and -mapfile options. - for OPTION in $OPTIONS;do - # Remove anything after equal sign inside option. - OPTION=$(echo -n $OPTION | cut -d'=' -f1) - if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then - cli_printMessage "`eval_gettext "The \\\$OPTION option is already used."`" - cli_printMessage "$(caller)" "AsToKnowMoreLine" - fi - done - - # Define file name prefix. - local PREFIX="-${COLOR_NUMBER}c" - - # Redefine file name prefix using options as reference. This is - # useful to differenciate final files produced using - # Floyd-Steinberg dithering and files which are not. - if [[ "$OPTIONS" =~ '-floyd' ]];then - PREFIX="${PREFIX}-floyd" - fi - - # Define theme-specific palettes directory. - local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Palettes - - # Define absolute path to GPL palette. This palettes should have - # 14 colors only. For more information on this see the GRUB's - # documentation. - local PALETTE_GPL=${PALETTES}/grub.gpl - - # Verify GPL palette existence. - cli_checkFiles $PALETTE_GPL 'f' - - # Define absolute path to PPM palette. The PPM palette is built - # from source palette (PALETTE_GPL) and provides the color - # information understood by `ppmremap', the program used to - # produce images in a specific amount of colors. - local PALETTE_PPM=$(cli_getTemporalFile "grub.ppm") - - # Create image in Netpbm superformat (PNM). The PNM image file is - # created from the PNG image rendered previously as centos-art - # base-rendition output. The PNM image is an intermediate format - # used to manipulate images through Netpbm tools. - cli_printMessage "${FILE}.pnm" "AsSavedAsLine" - pngtopnm -verbose \ - < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm - - # Print the path to GPL palette. - cli_printMessage "$PALETTE_GPL" 'AsPaletteLine' - - # Create PPM palette using GPL palette. - render_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLOR_NUMBER" - - # Reduce colors as specified in PPM palette. Here we use the PPM - # palette to enforce the color position in the image index and the - # Floyd-Steinberg dithering in order to improve color reduction. - cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine" - pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < ${FILE}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.ppm - - # Remove PPM palette. It is no longer needed. - if [[ -f ${PALETTE_PPM} ]];then - rm $PALETTE_PPM - fi - - # Create the 14 colors xpm.gz file. - cli_printMessage "${FILE}${PREFIX}.xpm.gz" "AsSavedAsLine" - ppmtoxpm \ - < ${FILE}${PREFIX}.ppm 2>>${FILE}.log > ${FILE}.xpm \ - && gzip --force ${FILE}.xpm \ - && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doKsplash.sh b/Scripts/Bash/Cli/Functions/Render/render_doKsplash.sh deleted file mode 100755 index e8c08a4..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doKsplash.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# -# render_doKsplash.sh -- This function collects KDE splash -# (KSplash) required files and creates a tar.gz package that groups -# them all together. Use this function as last-rendition action for -# KSplash base-rendition action. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doKsplash { - - local -a SRC - local -a DST - local FONT='' - local COUNT=0 - - # Define font used to print bottom splash message. - FONT=$(cli_getRepoTLDir)/Identity/Fonts/DejaVuLGCSans-Bold.ttf - - # Check existence of font file. - cli_checkFiles "$FONT" 'f' - - # Define absolute source location of files. - SRC[0]="${OUTPUT}/splash_top.png" - SRC[1]="${OUTPUT}/splash_active_bar.png" - SRC[2]="${OUTPUT}/splash_inactive_bar.png" - SRC[3]="${OUTPUT}/splash_bottom.png" - SRC[4]="$(dirname $TEMPLATE)/Theme.rc" - - # Check absolute source location of files. - cli_checkFiles "${SRC[@]}" 'f' - - # Define relative target location of files. - DST[0]="${OUTPUT}/splash_top.png" - DST[1]="${OUTPUT}/splash_active_bar.png" - DST[2]="${OUTPUT}/splash_inactive_bar.png" - DST[3]="${OUTPUT}/splash_bottom.png" - DST[4]="${OUTPUT}/Theme.rc" - - # Print action message. - cli_printMessage "${OUTPUT}/Preview.png" 'AsCreatingLine' - - # Create `Preview.png' image. - convert -append ${SRC[0]} ${SRC[1]} ${SRC[3]} ${OUTPUT}/Preview.png - - # Add bottom text to Preview.png image. The text position was set - # inside an image of 400x300 pixels. If you change the final - # preview image dimension, you probably need to change the text - # position too. - mogrify -draw 'text 6,295 "KDE is up and running."' \ - -fill \#ffffff \ - -font $FONT \ - ${OUTPUT}/Preview.png - - # Copy `Theme.rc' file. - cp ${SRC[4]} ${DST[4]} - - # Apply common translation markers to Theme.rc file. - cli_replaceTMarkers "${DST[4]}" - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doLastActions.sh b/Scripts/Bash/Cli/Functions/Render/render_doLastActions.sh deleted file mode 100755 index 9b35d4f..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doLastActions.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# render_doLastActions.sh -- This function performs -# last-rendition actions for all files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doLastActions { - - local ACTION='' - - # Verify position of file being produced in the list of files been - # currently processed. - if [[ $THIS_FILE_DIR != $NEXT_FILE_DIR ]];then - - # At this point centos-art.sh should be producing the last - # file from the same unique directory structure, so, before - # producing images for the next directory structure lets - # execute last-rendition actions for the current directory - # structure. - for ACTION in "${LASTACTIONS[@]}"; do - - case "${ACTION}" in - - groupSimilarFiles:* ) - render_groupSimilarFiles - ;; - esac - - done - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doPostActions.sh b/Scripts/Bash/Cli/Functions/Render/render_doPostActions.sh deleted file mode 100755 index 8fa8fb5..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doPostActions.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# -# render_doPostActions.sh -- This function performs -# post-rendition actions for all files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doPostActions { - - local ACTION='' - - for ACTION in "${POSTACTIONS[@]}"; do - - case "${ACTION}" in - - groupSimilarFiles:* ) - render_groupSimilarFiles - ;; - - esac - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doSvg.sh b/Scripts/Bash/Cli/Functions/Render/render_doSvg.sh deleted file mode 100644 index 54a678a..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doSvg.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# -# render_doSvg.sh -- This function performs base-rendition -# action for SVG files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doSvg { - - # Define export id used inside design templates. This value - # defines the design area we want to export. - local EXPORTID='CENTOSARTWORK' - - # Check export id inside design templates. - grep "id=\"$EXPORTID\"" $INSTANCE > /dev/null - if [[ $? -gt 0 ]];then - cli_printMessage "`eval_gettext "There is no export id (\\\$EXPORTID) inside \\\$TEMPLATE."`" "AsErrorLine" - cli_printMessage '-' 'AsSeparatorLine' - continue - fi - - # Check existence of external files. Inside design templates and - # their instances, external files are used to refere the - # background information required by the design template. If such - # background information is not available the image is produced - # without background information. This is something that need to - # be avoided. - render_checkSvgAbsref "$INSTANCE" - - # Render template instance using inkscape. Modify the inkscape - # output to reduce the amount of characters used in description - # column at final output. - cli_printMessage "$(inkscape $INSTANCE \ - --export-id=$EXPORTID --export-png=${FILE}.png | sed -r \ - -e "s!Area !`gettext "Area"`: !" \ - -e "s!Background RRGGBBAA:!`gettext "Background"`: RRGGBBAA!" \ - -e "s!Bitmap saved as:!`gettext "Saved as"`:!")" 'AsRegularLine' - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doSvgLastActions.sh b/Scripts/Bash/Cli/Functions/Render/render_doSvgLastActions.sh deleted file mode 100644 index 0235f68..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doSvgLastActions.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# -# render_doSvgLastActions.sh -- This function performs -# last-rendition actions for SVG files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doSvgLastActions { - - local ACTION='' - - # Verify position of file being produced in the list of files been - # currently processed. - if [[ $THIS_FILE_DIR == $NEXT_FILE_DIR ]];then - return - fi - - # Define SVG-directory-specific last-rendition actions processing - # as local to this function. Otherwise it may confuse command-line - # last-rendition actions. - local -a LASTACTIONS - - # Add directory-specific last-rendition actions to the list of - # post actions and last actions. This is required in order to - # provide a predictable way of producing content inside the - # repository and save you the time of writing long option - # combinations each time you need to produce images inside the - # repository. - if [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Gdm/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderDm:Gdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Kdm/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderDm:Kdm:800x600 1024x768 1280x1024 1360x768 2048x1536 2560x1240' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then - LASTACTIONS[((++${#LASTACTIONS[*]}))]='renderKsplash' - fi - - # At this point centos-art.sh should be producing the last file - # from the same unique directory structure, so, before producing - # images for the next directory structure lets execute - # last-rendition actions for the current directory structure. - for ACTION in "${LASTACTIONS[@]}"; do - - case "${ACTION}" in - - renderKsplash ) - render_doKsplash - ;; - - renderDm:* ) - render_doDm - ;; - - esac - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doSvgPostActions.sh b/Scripts/Bash/Cli/Functions/Render/render_doSvgPostActions.sh deleted file mode 100644 index aecc36c..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doSvgPostActions.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# -# render_doSvgPostActions.sh -- This function performs -# post-rendition actions for SVG files. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doSvgPostActions { - - local ACTION='' - - # Define SVG-directory-specific post-rendition actions processing - # as local to this function. Otherwise it may confuse command-line - # post-rendition actions. - local -a POSTACTIONS - - # Execute SVG directory-specific post-rendition actions to the - # list of post actions and last actions. This is required in order - # to provide a predictable way of producing content inside the - # repository and save you the time of writing long option - # combinations each time you need to produce images inside the - # repository. - if [[ $TEMPLATE =~ "Backgrounds/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='convertPngTo: jpg' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='groupSimilarFiles: png jpg' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Syslinux/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderSyslinux' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderSyslinux:-floyd' - elif [[ $TEMPLATE =~ "Grub" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderGrub' - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderGrub:-floyd' - elif [[ $TEMPLATE =~ "Distro/$(cli_getPathComponent '--release-pattern')/Ksplash/.+\.svg$" ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]='renderKsplash' - fi - - # Verify svg-related post-rendition actions passed from - # command-line and add them, if any, to post-rendition list of - # actions. - if [[ $FLAG_CONVERT != '' ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]="convertPngTo:${FLAG_CONVERT}" - fi - if [[ $FLAG_ROTATE != '' ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]="rotatePngTo:${FLAG_ROTATE}" - fi - if [[ $FLAG_RESIZE != '' ]];then - POSTACTIONS[((++${#POSTACTIONS[*]}))]="resizePngTo:${FLAG_RESIZE}" - fi - - # Execute post-rendition actions. - for ACTION in "${POSTACTIONS[@]}"; do - - case "${ACTION}" in - - convertPngTo:* ) - render_convertPngTo - ;; - - rotatePngTo:* ) - render_rotatePngTo - ;; - - resizePngTo:* ) - render_resizePngTo - ;; - - renderSyslinux* ) - render_doSyslinux - ;; - - renderGrub* ) - render_doGrub - ;; - - renderBrands ) - render_doBrands - ;; - - groupSimilarFiles:* ) - render_groupSimilarFiles - ;; - - esac - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_doSyslinux.sh b/Scripts/Bash/Cli/Functions/Render/render_doSyslinux.sh deleted file mode 100755 index 164c77b..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_doSyslinux.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash -# -# render_doSyslinux.sh -- This function provides post-rendition -# action used to produce LSS16 images, the images used by isolinux. -# -# This function uses three different formats to handle the same color -# information. Initially, the color information is defined with GIMP -# (The GNU Image Manipulation Program) as a palette of color. This -# palette of colors contains 16 colors only and is saved in a file -# named `syslinux.gpl. -# -# The `syslinux.gpl' file is used to build two other files: the -# `syslinux.ppm' file and the `syslinux.hex' file. The `syslinux.ppm' -# file is used to reduce a full color PNG image to the amount of -# colors it specifies (i.e., 16 colors). Later, with the 16 color -# image already created, the `syslinux.hex' file is used to build the -# LSS16 image. -# -# In order to produce images in LSS16 format correctly, it is needed -# that both the `syslinux.ppm' and `syslinux.hex' files contain the -# same color information. This is, both `syslinux.ppm' and -# `syslinux.hex' shoud represent the same color values and the same -# color index. -# -# This function save you the work of preparing both `syslinux.ppm' and -# `syslinux.hex'. Instead, you only need to prepare the `syslinux.gpl' -# file with the color information you want to produce images. -# -# In order for this function to work, the `syslinux.gpl' file should -# have a format similar to the following: -# -# GIMP Palette -# Name: TreeFlower-4-Syslinux -# Columns: 16 -# # -# 10 22 40 0a1628 -# 9 28 52 091c34 -# 16 34 63 10223f -# 20 37 67 142543 -# 15 39 74 0f274a -# 12 45 85 0c2d55 -# 20 43 78 142b4e -# 255 255 255 ffffff -# 21 51 95 15335f -# 41 52 70 293446 -# 32 76 141 204c8d -# 77 90 107 4d5a6b -# 143 154 167 8f9aa7 -# 128 179 255 80b3ff -# 194 200 202 c2c8ca -# 231 241 255 e7f1ff -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doSyslinux { - - # Define number of colors the images will be produced on. - local COLOR_NUMBER='16' - - # Define options using those passed to actions from pre-rendition - # configuration script. These options are applied to pnmremap when - # doing color reduction, so any option available for pnmremap - # command can be passed to renderSyslinux functionality. - local OPTIONS=$(render_getConfigOption "$ACTION" '2-') - - # Check options passed to action. This is required in order to - # aviod using options already used in this script. For example - # -verbose and -mapfile options. - for OPTION in $OPTIONS;do - # Remove anything after equal sign inside option. - OPTION=$(echo $OPTION | cut -d'=' -f1) - if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then - cli_printMessage "`eval_gettext "The \\\$OPTION option is already used."`" - cli_printMessage "$(caller)" "AsToKnowMoreLine" - fi - done - - # Define default file name prefix for 16 colors images. - local PREFIX="-${COLOR_NUMBER}c" - - # Re-define 16 colors images default file name prefix using - # options as reference. This is useful to differenciate final - # files produced using Floyd-Steinberg dithering and final files - # which are not. - if [[ "$OPTIONS" =~ '-floyd' ]];then - PREFIX="${PREFIX}-floyd" - fi - - # Define theme-specific palettes directory. - local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Palettes - - # Define absolute path to GPL palette. The GPL palette defines the - # color information used to build syslinux images. This palette - # should be set to 16 colors and, as specified in isolinux - # documentation, the background color should be indexed on - # position 0 and the forground in position 7 (see - # /usr/share/doc/syslinux-X.XX/isolinux.doc, for more - # information.) - local PALETTE_GPL=${PALETTES}/syslinux.gpl - - # Verify GPL palette existence. - cli_checkFiles $PALETTE_GPL 'f' - - # Define absolute path to PPM palette. The PPM palette is built - # from source palette (PALETTE_GPL) and provides the color - # information understood by `ppmremap', the program used to - # produce images in a specific amount of colors. - local PALETTE_PPM=$(cli_getTemporalFile "syslinux.ppm") - - # Define the HEX palette. The HEX palette is built from source - # palette (PALETTE_GPL) and provides the color information in the - # format understood by `ppmtolss16', the program used to produce - # images in LSS16 format. The HEX palette stores just one line - # with the color information as described in isolinux - # documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the - # same line]) - local PALETTE_HEX=$(cli_getTemporalFile "syslinux.hex") - - # Create image in Netpbm superformat (PNM). The PNM image file is - # created from the PNG image rendered previously as centos-art - # base-rendition output. The PNM image is an intermediate format - # used to manipulate images through Netpbm tools. - cli_printMessage "${FILE}.pnm" "AsSavedAsLine" - pngtopnm -verbose \ - < ${FILE}.png 2>${FILE}.log > ${FILE}.pnm - - # Print the path to GPL palette. - cli_printMessage "$PALETTE_GPL" 'AsPaletteLine' - - # Create PPM palette using GPL palette. - render_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLOR_NUMBER" - - # Create HEX palette using GPL palette. - render_convertGplToHex "$PALETTE_GPL" "$PALETTE_HEX" "$COLOR_NUMBER" - - # Reduce colors as specified in PPM palette. Here we use the PPM - # palette to enforce the color position in the image index and the - # Floyd-Steinberg dithering in order to improve color reduction. - cli_printMessage "${FILE}${PREFIX}.pnm" "AsSavedAsLine" - pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ - < ${FILE}.pnm 2>> ${FILE}.log > ${FILE}${PREFIX}.pnm - - # Create LSS16 image. - cli_printMessage "${FILE}${PREFIX}.lss" "AsSavedAsLine" - ppmtolss16 $(cat $PALETTE_HEX) \ - < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.lss - - # Remove HEX palette. It is no longer needed. - if [[ -f ${PALETTE_HEX} ]];then - rm $PALETTE_HEX - fi - - # Create the PPM image indexed to 16 colors. Also the colormap - # used in the LSS16 image is saved on ${FILE}.log; this is useful to - # verify the correct order of colors in the image index. - cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine" - lss16toppm -map \ - < ${FILE}${PREFIX}.lss 2>>${FILE}.log > ${FILE}${PREFIX}.ppm - - # Create the 16 colors PNG image. - cli_printMessage "${FILE}${PREFIX}.png" "AsSavedAsLine" - pnmtopng -verbose -palette=$PALETTE_PPM \ - < ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.png - - # Remove PPM palette. It is no longer needed. - if [[ -f ${PALETTE_PPM} ]];then - rm $PALETTE_PPM - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_getArguments.sh b/Scripts/Bash/Cli/Functions/Render/render_getArguments.sh deleted file mode 100644 index 48c975d..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_getArguments.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -# -# render_getArguments.sh -- This function interprets arguments passed to -# render functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getArguments { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="filter:,quiet,answer:,dont-commit-changes,releasever:,basearch:,convert:,rotate:,resize:,group-by:,theme-model:" - - # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - - case "$1" in - - --filter ) - FLAG_FILTER="$2" - shift 2 - ;; - - --quiet ) - FLAG_QUIET="true" - FLAG_DONT_COMMIT_CHANGES="true" - shift 1 - ;; - - --answer ) - FLAG_ANSWER="$2" - shift 2 - ;; - - --dont-commit-changes ) - FLAG_DONT_COMMIT_CHANGES="true" - shift 1 - ;; - - --releasever ) - FLAG_RELEASEVER="$2" - if [[ ! $FLAG_RELEASEVER =~ $(cli_getPathComponent '--release-pattern') ]];then - cli_printMessage "`gettext "The release version provided is not supported."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - shift 2 - ;; - - --basearch ) - FLAG_BASEARCH="$2" - if [[ ! $FLAG_BASEARCH =~ $(cli_getPathComponent '--architecture-pattern') ]];then - cli_printMessage "`gettext "The architecture provided is not supported."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - shift 2 - ;; - - --convert ) - FLAG_CONVERT="$2" - shift 2 - ;; - - --rotate ) - FLAG_ROTATE="$2" - shift 2 - ;; - - --resize ) - FLAG_RESIZE="$2" - shift 2 - ;; - - --group-by ) - FLAG_GROUPED_BY="$2" - shift 2 - ;; - - --theme-model ) - FLAG_THEME_MODEL=$(cli_getRepoName "$2" 'd') - shift 2 - ;; - - * ) - break - esac - done - - # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_getColors.sh b/Scripts/Bash/Cli/Functions/Render/render_getColors.sh deleted file mode 100755 index da3e6ca..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_getColors.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# -# render_getColors.sh -- This function takes one palette produced by -# Gimp (e.g., syslinux.gpl) as input and outputs a list of colors as -# specified. -# -# Copyright 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getColors { - - # Define path to GPL palette. This is the .gpl file we use to - # retrive color information from. - local PALETTE_GPL="$1" - - # Retrive fourth column of information from GPL palette. The - # fourth column of GPL palette contains the palette commentary - # field. The palette commentary field can be anything, but for the - # sake of our own convenience we use it to store the color - # hexadecimal value. Notice that you can put your comments from - # the fifth column on. - local COLORS=$(sed -r '1,/^#/d' $PALETTE_GPL | awk '{ printf "%s\n", $4 }') - - # Output list of colors. - echo "$COLORS" - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_getConfigOption.sh b/Scripts/Bash/Cli/Functions/Render/render_getConfigOption.sh deleted file mode 100755 index f5cdcd3..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_getConfigOption.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# -# render_getConfigOption.sh -- This function standardizes the way -# action values are retrived from pre-rendition configuration files. -# Use this function whenever you need to retrive action values from -# pre-rendition configuration script. -# -# Usage: VAR=$(render_getConfigOption "ACTION" "FIELD") -# -# VAR is the name of the variable where we store the option named -# returned by render_getConfigOption. -# -# ACTION is the string definition set in the pre-rendition -# configuration script that holds the action name and its options -# fields. -# -# FIELD is the field number in the action string we want to retrive -# option from. By default options start from third field on. The first -# field is reserved for the action type (i.e., POST or LAST), and the -# second field is reserved for the action itself (e.g., convertPngTo, -# renderSyslinux, renderKsplash, etc.). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getConfigOption { - - local ACTION="$1" - local FIELD="$2" - local VALUE='' - - # Check action value. The action's value must be present in order - # for this function to work. It provides the string needed to - # retrive options from. - if [[ "$ACTION" == '' ]];then - cli_printMessage "`gettext "There is no action to work with."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Check field value. The field's value must match the cut's - # command specification of its -f option. - if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then - cli_printMessage "`gettext "The field specified is not valid."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Get option from pre-rendition configuration action definition. - VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD}) - - # Sanitate action value passed from pre-rendition configuration - # action definition. - VALUE=$(echo -n "${VALUE}" \ - | sed -r 's!^ *!!g' \ - | sed -r 's!( |,|;) *! !g' \ - | sed -r 's! *$!!g') - - # Output action value without trailing newline. - echo -n "$VALUE" - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_getDirOutput.sh b/Scripts/Bash/Cli/Functions/Render/render_getDirOutput.sh deleted file mode 100644 index 62f1b95..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_getDirOutput.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# render_getDirOutput.sh -- This function defines the final -# absolute path the centos-art.sh script uses to store identity -# contents produced at rendition time. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getDirOutput { - - # Define base output directory using design model path as - # reference. - OUTPUT=$(dirname $FILE | sed -r \ - -e "s!/Models/${FLAG_THEME_MODEL}!/Motifs/$(cli_getPathComponent "$ACTIONVAL" "--theme")!" \ - -e "s!/Tpl!!") - - # By default rendered identity content is stored immediatly under - # identity entry structure, but if `Img/' directory exists use it - # instead. - if [[ -d "${OUTPUT}/Img" ]];then - OUTPUT=${OUTPUT}/Img - fi - - # Redefine base output directory to introduce specific information - # like release number, architecture, etc. - OUTPUT=${OUTPUT}/${FLAG_RELEASEVER}/${FLAG_BASEARCH} - - # Define whether to use or not locale-specific directory to store - # content, using current locale information as reference. As - # convenction, when we produce content in English language, we do - # not add a laguage-specific directory to organize content. - # However, when we produce language-specific content in a language - # different from English we do use language-specific directory to - # organize content. - if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then - OUTPUT=${OUTPUT}/$(cli_getCurrentLocale) - fi - - # Remove two or more consecutive slashes as well as the last - # remaining slash in the path. - OUTPUT=$(echo $OUTPUT | sed -r 's!/{2,}!/!g' | sed -r 's!/$!!') - - # Create final output directory, if it doesn't exist yet. - if [[ ! -d ${OUTPUT} ]];then - mkdir -p ${OUTPUT} - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_getDirTemplate.sh b/Scripts/Bash/Cli/Functions/Render/render_getDirTemplate.sh deleted file mode 100644 index 08e598d..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_getDirTemplate.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# render_getDirTemplate.sh -- This function re-defines absolute -# path to artwork's related design templates directory. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getDirTemplate { - - # Initialize design models location using action value as - # reference. - TEMPLATE=$ACTIONVAL - - # Sanitate design models location. Be sure design models do - # always point to trunk directory structure. This is useful to let - # `centos-art.sh' script do rendition under branches directory - # structure, reusing design models under trunk directory - # structure. - TEMPLATE=$(echo "$TEMPLATE" | sed "s!/branches/!/trunk/!") - - # Sanitate design models location using or not Tpl/ directory. - if [[ -d $TEMPLATE/Tpl ]];then - # Using Tpl/ directory is an obsolete practice that should be - # avoided. The concept of Tpl/ directory per artwork directory - # has been replaced by a common design model directory - # structure where we centralize design models for all - # different artistic motifs. However, there are some cases - # that we may need to use Tpl/ directory still, so we verify - # its existence and use it if present. - TEMPLATE=$TEMPLATE/Tpl - else - # Redefine design model location based on theme model - # (FLAG_THEME_MODEL) variable value. The theme model variable is - # defined in the associated pre-rendition configuration script - # and can be used to set which design model to use among a - # list of different design models that we can choose from. - TEMPLATE=$(echo "$TEMPLATE" \ - | sed "s!Motifs/$(cli_getPathComponent "$TEMPLATE" '--theme')!Models/$FLAG_THEME_MODEL!") - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_groupSimilarFiles.sh b/Scripts/Bash/Cli/Functions/Render/render_groupSimilarFiles.sh deleted file mode 100755 index da066d5..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_groupSimilarFiles.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# -# render_groupSimilarFiles.sh -- This function provides -# post-rendition action to group files inside directories named as -# their file extensions. For example: if the current file is a .png -# file, it is moved inside a Png/ directory; if the current file is a -# .jpg file, it is stored inside a Jpg/ directory, and so on. -# -# For this function to work correctly, you need to specify which file -# type you want to group. This is done in the post-rendition ACTIONS -# array inside the appropriate `render.conf.sh' pre-configuration -# script. This function cannot be used as last-rendition action. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_groupSimilarFiles { - - local SOURCE='' - local TARGET='' - - # Sanitate file types passed from render.conf.sh pre-rendition - # configuration script. - local FORMATS=$(render_getConfigOption "$ACTION" '2-') - - for FORMAT in $FORMATS;do - - # Redifine source file we want to move. - SOURCE=${FILE}.${FORMAT} - - # Define target directory where source file will be moved - # into. - TARGET=$(dirname "$FILE")/$(cli_getRepoName "$FORMAT" 'd') - - # Check existence of source file. - cli_checkFiles $SOURCE 'f' - - # Check existence of target directory. - if [[ ! -d $TARGET ]];then - mkdir -p $TARGET - fi - - # Redifine file path to add file and its type. - TARGET=${TARGET}/$(cli_getRepoName "$FILE" 'f').${FORMAT} - - # Move file into its final location. - cli_printMessage "$TARGET" 'AsMovedToLine' - mv ${SOURCE} ${TARGET} - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_resizePngTo.sh b/Scripts/Bash/Cli/Functions/Render/render_resizePngTo.sh deleted file mode 100755 index b4ad840..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_resizePngTo.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# -# render_resizePngTo.sh -- This function provides post-rendition to -# resize images produced by centos-art base-rendition. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_resizePngTo { - - local SIZE='' - local SIZES=$(render_getConfigOption "$ACTION" '2-') - local SRC='' - local DST='' - - # Check base file existence. - cli_checkFiles ${FILE}.png 'f' - - # Check image degrees. - if [[ "$SIZES" != "" ]];then - - # Loop through image degrees and convert them using PNG file - # as base. - for SIZE in $SIZES;do - SRC=${FILE}.png - DST=${FILE}-resized-$(echo $SIZE | sed 's!%!!').png - cli_printMessage "$DST" "AsSavedAsLine" - convert -resize $SIZE ${SRC} ${DST} - done - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Render/render_rotatePngTo.sh b/Scripts/Bash/Cli/Functions/Render/render_rotatePngTo.sh deleted file mode 100644 index 29fa05c..0000000 --- a/Scripts/Bash/Cli/Functions/Render/render_rotatePngTo.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# -# render_rotatePngTo.sh -- This function provides post-rendition -# to convert images produced by centos-art base-rendition. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_rotatePngTo { - - local COUNT=1 - local DEGREE='' - local DEGREES=$(render_getConfigOption "$ACTION" '2-') - local SRC='' - local DST='' - - # Check base file existence. - cli_checkFiles ${FILE}.png 'f' - - # Check image degrees. - if [[ "$DEGREES" != "" ]];then - - # Loop through image degrees and convert them using PNG file - # as base. - for DEGREE in $DEGREES;do - SRC=${FILE}.png - DST=${FILE}-rotated-$(echo $DEGREE | sed 's!%!!').png - cli_printMessage "$DST" "AsSavedAsLine" - convert -rotate $DEGREE ${SRC} ${DST} - done - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Shell/Config/tpl_forCopyright.sed b/Scripts/Bash/Cli/Functions/Shell/Config/tpl_forCopyright.sed deleted file mode 100644 index e8e5e2c..0000000 --- a/Scripts/Bash/Cli/Functions/Shell/Config/tpl_forCopyright.sed +++ /dev/null @@ -1,38 +0,0 @@ -# This file standardizes the look and feel of top comments used by -# scripts inside CentOS Artwork Repository. It contains the copyright -# note and the license under which the script is released. This files -# is used with the regular expression '.*\.sh$' only. -# --------------------------------------------------- -# $Id$ -# --------------------------------------------------- -/^# +Copyright .*$/a\ -# Copyright (C) =COPYRIGHT_YEAR== =COPYRIGHT_HOLDER=\ -# \ -# This program is free software; you can redistribute it and/or\ -# modify it under the terms of the GNU General Public License as\ -# published by the Free Software Foundation; either version 2 of the\ -# License, or (at your option) any later version.\ -# \ -# This program is distributed in the hope that it will be useful, but\ -# WITHOUT ANY WARRANTY; without even the implied warranty of\ -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\ -# General Public License for more details.\ -#\ -# You should have received a copy of the GNU General Public License\ -# along with this program; if not, write to the Free Software\ -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307\ -# USA.\ -# \ -# ---------------------------------------------------------------------- - -# Remove previous comments. -/^# +Copyright .*$/,/^# -+$/{ -d -} - -# Remove more than one space after comments. -s/^# +/# / - -# Define first line -1c\ -#!/bin/bash diff --git a/Scripts/Bash/Cli/Functions/Shell/shell.sh b/Scripts/Bash/Cli/Functions/Shell/shell.sh deleted file mode 100755 index f7d573d..0000000 --- a/Scripts/Bash/Cli/Functions/Shell/shell.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# shell.sh -- This function provides very basic string manipulations -# to help you maintain Bash scripts inside repository. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function shell { - - # Define command-line interface. - shell_getActions - -} diff --git a/Scripts/Bash/Cli/Functions/Shell/shell_getActions.sh b/Scripts/Bash/Cli/Functions/Shell/shell_getActions.sh deleted file mode 100755 index 3f50c91..0000000 --- a/Scripts/Bash/Cli/Functions/Shell/shell_getActions.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# -# shell_getActions.sh -- This function interpretes arguments passed to -# `shell' functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function shell_getActions { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="update-copyright:" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - - case "$1" in - - --update-copyright ) - - # Define action value. - ACTIONVAL="$2" - - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_updateCopyright" - - # Rotate positional parameters. - shift 2 - ;; - - * ) - # Break options loop. - break - esac - done - - # Check action value. Be sure the action value matches the - # convenctions defined for source locations inside the working - # copy. - cli_checkRepoDirSource - - # Syncronize changes between the working copy and the central - # repository to bring down changes. - cli_syncroRepoChanges - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Syncronize changes between the working copy and the central - # repository to commit up changes. - cli_commitRepoChanges - -} diff --git a/Scripts/Bash/Cli/Functions/Shell/shell_updateCopyright.sh b/Scripts/Bash/Cli/Functions/Shell/shell_updateCopyright.sh deleted file mode 100755 index 42bbae1..0000000 --- a/Scripts/Bash/Cli/Functions/Shell/shell_updateCopyright.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/bash -# -# shell_updateTopComment.sh -- This function replaces top comment -# section inside shell scripts (*.sh) with one of many pre-defined -# templates available. Use this function to maintain shell scripts top -# comments inside repository. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function shell_updateCopyright { - - local FILE='' - local COUNT=0 - local FILES='' - local INSTANCE='' - local TEMPLATES='' - local -a TITLE - local -a VALUE - local -a PATTERN - local -a PATTERN_MSG - local -a DEFAULT - local -a MARKER - - # Define absolute path to template file. - TEMPLATE="${CLI_BASEDIR}/Functions/Shell/Config/tpl_forCopyright.sed" - - # Check template file existence. - cli_checkFiles $TEMPLATE 'f' - - # Define file name to template instance. - INSTANCE=$(cli_getTemporalFile $TEMPLATE) - - # Define copyright information. - TITLE[0]="`gettext "Copyright holder"`" - TITLE[1]="`gettext "Copyright year"`" - - # Define translation marker. These values are used inside - # template file. - MARKER[0]='=COPYRIGHT_HOLDER=' - MARKER[1]='=COPYRIGHT_YEAR=' - - # Define pattern. These values are used as regular - # expression patterns for user's input further verification. - PATTERN[0]='^([[:alnum:] _-.]+)?$' - PATTERN[1]='^([[:digit:]]{4})?$' - - # Define pattern message. These values are used as output - # message when user's input doesn't match the related pattern. - PATTERN_MSG[0]="`gettext "Try using alphanumeric characters."`" - PATTERN_MSG[1]="`gettext "Try using numeric characters."`" - - # Define default values. - DEFAULT[0]="The CentOS Project. `gettext "All rights reserved."`" - DEFAULT[1]=$(date +%Y) - - # Initialize values using user's input. - cli_printMessage "`gettext "Enter the information you want to apply:"`" - while [[ $COUNT -ne ${#TITLE[*]} ]];do - - # Request value. - cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' - read VALUE[$COUNT] - - # Sanitate values to exclude characters that could - # introduce possible markup malformations to final SVG files. - until [[ ${VALUE[$COUNT]} =~ ${PATTERN[$COUNT]} ]];do - cli_printMessage "${PATTERN_MSG[$COUNT]}" - cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' - read VALUE[$COUNT] - done - - # Set default value to empty values. - if [[ ${VALUE[$COUNT]} == '' ]];then - VALUE[$COUNT]=${DEFAULT[$COUNT]} - fi - - # Increase counter. - COUNT=$(($COUNT + 1)) - - done - - # Create template instance. - cp $TEMPLATE $INSTANCE - - # Check template instance. We cannot continue if template instance - # couldn't be created. - cli_checkFiles $INSTANCE 'f' - - # Reset counter. - COUNT=0 - - while [[ $COUNT -ne ${#TITLE[*]} ]];do - - # Apply translation marker replacement. - sed -r -i "s!${MARKER[$COUNT]}!${VALUE[$COUNT]}!g" $INSTANCE - - # Increase counter. - COUNT=$(($COUNT + 1)) - - done - - # Define list of files to process - FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}.*\.sh") - - # Set action preamble. - cli_printActionPreamble "${FILES}" '' '' - - # Process list of files. - for FILE in $FILES;do - - # Output action message. - cli_printMessage $FILE 'AsUpdatingLine' - - # Apply template instance to file. - sed -r -i -f $INSTANCE $FILE - - done - - # Remove template instance. - if [[ -f ${INSTANCE} ]];then - rm ${INSTANCE} - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Svg/Config/tpl_forMetadata.sed b/Scripts/Bash/Cli/Functions/Svg/Config/tpl_forMetadata.sed deleted file mode 100644 index 48bd70d..0000000 --- a/Scripts/Bash/Cli/Functions/Svg/Config/tpl_forMetadata.sed +++ /dev/null @@ -1,68 +0,0 @@ -# This file is the metadata information used by CentOS Artwork SIG on -# its scalable vector graphics (SVG) files. This files is used with -# the regular expression '.*\.svg$' only. -# --------------------------------------------------- -# $Id$ -# --------------------------------------------------- -/\ - \ - \ - image/svg+xml\ - \ - \ - =TITLE=\ - =DATE=\ - \ - \ - =CREATOR=\ - \ - \ - \ - \ - =RIGHTS=\ - \ - \ - \ - \ - =PUBLISHER=\ - \ - \ - =IDENTIFIER=\ - =SOURCE=\ - =RELATION=\ - =LANGUAGE=\ - \ - \ -=KEYWORDS=\ - \ - \ - =COVERAGE=\ - =DESCRIPTION=\ - \ - \ - =CONTRIBUTOR=\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - diff --git a/Scripts/Bash/Cli/Functions/Svg/svg.sh b/Scripts/Bash/Cli/Functions/Svg/svg.sh deleted file mode 100755 index 8ae161e..0000000 --- a/Scripts/Bash/Cli/Functions/Svg/svg.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# svg.sh -- This function provides very basic SVG manipulations to -# help you to maintain svg files inside the repository. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg { - - # Define command-line interface. - svg_getActions - -} diff --git a/Scripts/Bash/Cli/Functions/Svg/svg_getActions.sh b/Scripts/Bash/Cli/Functions/Svg/svg_getActions.sh deleted file mode 100755 index bca9556..0000000 --- a/Scripts/Bash/Cli/Functions/Svg/svg_getActions.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# -# svg_getActions.sh -- This function interpretes arguments passed to -# `svg' functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_getActions { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="update-metadata:,vacuum-defs:" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - - case "$1" in - - --update-metadata ) - - # Define action value. - ACTIONVAL="$2" - - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_updateMetadata" - - # Rotate positional parameters. - shift 2 - ;; - - --vacuum-defs ) - - # Define action value. - ACTIONVAL="$2" - - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_vacuumDefs" - - # Rotate positional parameters. - shift 2 - ;; - - * ) - # Break options loop. - break - esac - done - - # Check action value. Be sure the action value matches the - # convenctions defined for source locations inside the working - # copy. - cli_checkRepoDirSource - - # Syncronize changes between the working copy and the central - # repository to bring down changes. - cli_syncroRepoChanges - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Syncronize changes between the working copy and the central - # repository to commit up changes. - cli_commitRepoChanges - -} diff --git a/Scripts/Bash/Cli/Functions/Svg/svg_updateMetadata.sh b/Scripts/Bash/Cli/Functions/Svg/svg_updateMetadata.sh deleted file mode 100755 index 502b6c1..0000000 --- a/Scripts/Bash/Cli/Functions/Svg/svg_updateMetadata.sh +++ /dev/null @@ -1,240 +0,0 @@ -#!/bin/bash -# -# svg_updateMetadata.sh -- This function updates metadata values -# inside scalable vector graphic (SVG) files. First, we ask user to -# provide the information. If user doesn't provide the information, -# centos-art.sh script uses autogenerated values as default ---when -# possible--- taking as reference SVG file path. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_updateMetadata { - - local NAM='' - local URL='' - local KEYS='' - local FILE='' - local COUNT=0 - local FILES='' - local INSTANCE='' - local TEMPLATES='' - local -a TITLE - local -a VALUE - local -a PATTERN - local -a PATTERN_MSG - local -a MARKER - local -a DEFAULT - - # Define template file name. - TEMPLATE="${CLI_BASEDIR}/Functions/Svg/Config/tpl_forMetadata.sed" - - # Check template file existence. - cli_checkFiles $TEMPLATE 'f' - - # Define titles using Inkscape 0.46 metadata definition as reference. - TITLE[0]="`gettext "Title"`" - TITLE[1]="`gettext "Date"`" - TITLE[2]="`gettext "Creator"`" - TITLE[3]="`gettext "Rights"`" - TITLE[4]="`gettext "Publisher"`" - TITLE[5]="`gettext "Identifier"`" - TITLE[6]="`gettext "Source"`" - TITLE[7]="`gettext "Relation"`" - TITLE[8]="`gettext "Language"`" - TITLE[9]="`gettext "Keywords"`" - TITLE[10]="`gettext "Coverage"`" - TITLE[11]="`gettext "Description"`" - TITLE[12]="`gettext "Contributor"`" - - # Define markers. These values are used inside template. - MARKER[0]='=TITLE=' - MARKER[1]='=DATE=' - MARKER[2]='=CREATOR=' - MARKER[3]='=RIGHTS=' - MARKER[4]='=PUBLISHER=' - MARKER[5]='=IDENTIFIER=' - MARKER[6]='=SOURCE=' - MARKER[7]='=RELATION=' - MARKER[8]='=LANGUAGE=' - MARKER[9]='=KEYWORDS=' - MARKER[10]='=COVERAGE=' - MARKER[11]='=DESCRIPTION=' - MARKER[12]='=CONTRIBUTOR=' - - # Define pattern. These values are used as regular - # expression patterns for user's input further verification. - PATTERN[0]='^([[:alnum:] _-.]+)?$' - PATTERN[1]='^([0-9]{4}-(0[1-9]|1[0-2])-([0-2][1-9]|3[0-1]))?$' - PATTERN[2]=${PATTERN[0]} - PATTERN[3]=${PATTERN[0]} - PATTERN[4]=${PATTERN[0]} - PATTERN[5]='^(https://projects.centos.org/svn/artwork/[[:alnum:]/._-]+)?$' - PATTERN[6]=${PATTERN[5]} - PATTERN[7]=${PATTERN[5]} - PATTERN[8]='^([a-z]{2}(_[A-Z]{2})?)?$' - PATTERN[9]=${PATTERN[0]} - PATTERN[10]=${PATTERN[0]} - PATTERN[11]=${PATTERN[0]} - PATTERN[12]=${PATTERN[0]} - - # Define pattern message. These values are used as output - # message when user's input doesn't match the related pattern. - PATTERN_MSG[0]="`gettext "Try using alphanumeric characters."`" - PATTERN_MSG[1]="`gettext "Try using 'YYYY-MM-DD' date format."`" - PATTERN_MSG[2]=${PATTERN_MSG[0]} - PATTERN_MSG[3]=${PATTERN_MSG[0]} - PATTERN_MSG[4]=${PATTERN_MSG[0]} - PATTERN_MSG[5]="`gettext "Only locations under https://projects.centos.ort/svn/artwork are supported."`" - PATTERN_MSG[6]=${PATTERN_MSG[0]} - PATTERN_MSG[7]=${PATTERN_MSG[0]} - PATTERN_MSG[8]="`gettext "Try using 'LL' or 'LL_CC' locale format."`" - PATTERN_MSG[9]=${PATTERN_MSG[0]} - PATTERN_MSG[10]=${PATTERN_MSG[0]} - PATTERN_MSG[11]=${PATTERN_MSG[0]} - PATTERN_MSG[12]=${PATTERN_MSG[0]} - - # Define common default values. - DEFAULT[1]=$(date +%Y-%m-%d) - DEFAULT[2]="The CentOS Project" - DEFAULT[3]=${DEFAULT[2]} - DEFAULT[4]=${DEFAULT[2]} - DEFAULT[8]=$(cli_getCurrentLocale) - DEFAULT[10]=${DEFAULT[2]} - - # Initialize values using user's input. - cli_printMessage "`gettext "Enter metadata information you want to apply:"`" - while [[ $COUNT -ne ${#TITLE[*]} ]];do - - # Request value. - cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' - read VALUE[$COUNT] - - # Sanitate values to exclude characters that could - # introduce possible markup malformations to final SVG files. - until [[ ${VALUE[$COUNT]} =~ ${PATTERN[$COUNT]} ]];do - cli_printMessage "${PATTERN_MSG[$COUNT]}" - cli_printMessage "${TITLE[$COUNT]}" 'AsRequestLine' - read VALUE[$COUNT] - done - - # Set default value to empty values. - if [[ ${VALUE[$COUNT]} == '' ]];then - VALUE[$COUNT]=${DEFAULT[$COUNT]} - fi - - # Increase counter. - COUNT=$(($COUNT + 1)) - - done - - # Build list of files to process. - FILES=$(cli_getFilesList "$ACTIONVAL" "${FLAG_FILTER}.*\.(svgz|svg)") - - # Set action preamble. - cli_printActionPreamble "${FILES}" '' '' - - # Process list of scalable vector graphics. - for FILE in $FILES;do - - # Output action message. - cli_printMessage $FILE 'AsUpdatingLine' - - # Build title from file path. - NAM=$(basename "$FILE") - - # Build url from file path. - URL=$(echo $FILE | sed 's!/home/centos!https://projects.centos.org/svn!') - - # Build keywords from file path. Do not include filename, it - # is already on title. - KEYS=$(dirname "$FILE" | cut -d/ -f6- | tr '/' '\n') - - # Build keywords using SVG standard format. Note that this - # information is inserted inside template file. The - # template file is a replacement set of sed commands - # so we need to escape the new line of each line using one - # backslash (\). As we are doing this inside bash, it is - # required to escape the backslash with another backslash so - # one of them passes literally to template file. - KEYS=$(\ - for KEY in $KEYS;do - echo " $KEY\\" - done) - - # Redefine template instance file name. - INSTANCE=$(cli_getTemporalFile $TEMPLATE) - - # Create template instance. - cp $TEMPLATE $INSTANCE - - # Check template instance. We cannot continue if the template - # instance couldn't be created. - cli_checkFiles $INSTANCE 'f' - - # Reset counter. - COUNT=0 - - while [[ $COUNT -ne ${#TITLE[*]} ]];do - - # Redefine file-specific values. - if [[ $COUNT -eq 0 ]];then - VALUE[$COUNT]=$NAM - elif [[ $COUNT -eq 5 ]];then - VALUE[$COUNT]=$URL - elif [[ $COUNT -eq 6 ]];then - VALUE[$COUNT]=$URL - elif [[ $COUNT -eq 7 ]];then - VALUE[$COUNT]=$URL - elif [[ $COUNT -eq 9 ]];then - VALUE[$COUNT]=$KEYS - fi - - # Apply translation marker replacement. - if [[ $COUNT -eq 9 ]];then - sed -i -r "/${MARKER[$COUNT]}/c\\${VALUE[$COUNT]}" $INSTANCE - else - sed -i -r "s!${MARKER[$COUNT]}!${VALUE[$COUNT]}!g" $INSTANCE - fi - - # Increase counter. - COUNT=$(($COUNT + 1)) - - done - - # Sanitate template instance. - sed -i -r -e 's/>$/>\\/g' $INSTANCE - - # Apply template instance to scalable vector graphic - # file. - sed -i -f $INSTANCE $FILE - - # Remove template instance. - if [[ -f $INSTANCE ]];then - rm $INSTANCE - fi - - # Sanitate scalable vector graphic. - sed -i -r '/^[[:space:]]*$/d' $FILE - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Svg/svg_vacuumDefs.sh b/Scripts/Bash/Cli/Functions/Svg/svg_vacuumDefs.sh deleted file mode 100755 index d69f438..0000000 --- a/Scripts/Bash/Cli/Functions/Svg/svg_vacuumDefs.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# -# svg_vacuumDefs.sh -- This function removes all unused items from the -# defs section of the SVG file massively. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function svg_vacuumDefs { - - local FILE='' - local FILES='' - - # Build list of files to process. - FILES=$(cli_getFilesList "${ACTIONVAL}" "${FLAG_FILTER}.*\.(svgz|svg)") - - # Set action preamble. - cli_printActionPreamble "${FILES}" '' '' - - # Process list of files. - for FILE in $FILES;do - - # Output action message. - cli_printMessage "$FILE" 'AsUpdatingLine' - - # Vacuum unused svg definition using inkscape. - inkscape --vacuum-defs $FILE &> /dev/null - - done - -} diff --git a/Scripts/Bash/Cli/Functions/cli.sh b/Scripts/Bash/Cli/Functions/cli.sh deleted file mode 100644 index e90b804..0000000 --- a/Scripts/Bash/Cli/Functions/cli.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -# -# cli.sh -- This function initiates centos-art command-line interface. -# Variables defined in this function are accesible by all other -# functions. The cli function is the first script executed by -# centos-art command-line onces invoked. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli { - - # Initialize global variables. - local FUNCNAM='' - local FUNCDIR='' - local FUNCDIRNAM='' - local FUNCSCRIPT='' - local FUNCCONFIG='' - local ARGUMENTS='' - - # Initialize default value to filter flag. The filter flag - # (--filter) is used mainly to reduce the number of files to - # process. The value of this variable is interpreted as - # egrep-posix regular expression. By default, everything matches. - local FLAG_FILTER='.+' - - # Initialize default value to verbosity flag. The verbosity flag - # (--quiet) controls whether centos-art.sh script prints messages - # or not. By default, all messages are printed out. - local FLAG_QUIET='false' - - # Initialize default value to answer flag. The answer flag - # (--answer) controls whether centos-art.sh script does or does - # not pass confirmation request points. By default, it doesn't. - local FLAG_ANSWER='false' - - # Initialize default value to don't commit changes flag. The don't - # commit changes flag (--dont-commit-changes) controls whether - # centos-art.sh script syncronizes changes between the central - # repository and the working copy. By default, it does. - local FLAG_DONT_COMMIT_CHANGES='false' - - # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" - - # Define function directory (FUNCDIR). The directory path where - # functionalities are stored inside the repository. - FUNCDIR=${CLI_BASEDIR}/Functions - - # Define function name (FUNCNAM) variable from first command-line - # argument. As convenction we use the first argument to determine - # the exact name of functionality to call. - FUNCNAM=$(cli_getRepoName "$1" 'f') - - # Define function directory. - FUNCDIRNAM=$(cli_getRepoName "$FUNCNAM" 'd') - - # Define function file name. - FUNCSCRIPT=${FUNCDIR}/${FUNCDIRNAM}/${FUNCNAM}.sh - - # Check function script execution rights. - cli_checkFiles $FUNCSCRIPT 'x' - - # Define function configuration directory. The function - # configuration directory is used to store functionality's - # related files. - FUNCCONFIG=${FUNCDIR}/${FUNCDIRNAM}/Config - - # Remove the first argument passed to centos-art.sh command-line - # in order to build optional arguments inside functionalities. We - # start counting from second argument (inclusive) on. - shift 1 - - # Redefine ARGUMENTS using current positional parameters. - cli_doParseArgumentsReDef "$@" - - # Define default text editors used by centos-art.sh script. - if [[ ! "$EDITOR" =~ '/usr/bin/(vim|emacs|nano)' ]];then - EDITOR='/usr/bin/vim' - fi - - # Check text editor execution rights. - cli_checkFiles $EDITOR 'x' - - # Go for function initialization. Keep the cli_getFunctions - # function calling after all variables and arguments definitions. - cli_getFunctions - -} diff --git a/Scripts/Bash/Cli/Functions/cli_checkFiles.sh b/Scripts/Bash/Cli/Functions/cli_checkFiles.sh deleted file mode 100644 index 88c8bff..0000000 --- a/Scripts/Bash/Cli/Functions/cli_checkFiles.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash -# -# cli_checkFiles.sh -- This function standardizes file verifications -# inside centos-art.sh script. If file verification fails in anyway, -# centos-art.sh script complains about it and ends up script -# execution. -# -# Usage: -# -# cli_checkFiles FILE [TYPE] -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_checkFiles { - - local FILE='' - local FILES="$1" - local TYPE="$2" - local MESSAGE='' - - # Check number of paramaters passed to cli_checkFiles function. At - # least one argument should be passed. - if [[ $# -lt 1 ]];then - cli_printMessage "${FUNCNAME}: `gettext "You need to provide one argument at least."`" 'AsErrorLine' - cli_printMessage "$(caller)" "AsToKnowMoreLine" - fi - - for FILE in $FILES;do - - # Check value passed as file to cli_checkFiles function. The - # file value cannot be empty nor have extrange values. - cli_checkPathComponent "$FILE" '--default' - - # Perform file verification using FILE and TYPE variables. - case $TYPE in - - d | directory ) - # File exists and is a directory - if [[ ! -d $FILE ]];then - MESSAGE="`eval_gettext "The directory \\\"\\\$FILE\\\" doesn't exist."`" - fi - ;; - - f | regular-file ) - # File exists and is a regular file. - if [[ ! -f $FILE ]];then - MESSAGE="`eval_gettext "The file \\\"\\\$FILE\\\" is not a regular file."`" - fi - ;; - - h | symbolic-link ) - # File exists and is a symbolic link. - if [[ ! -h $FILE ]];then - MESSAGE="`eval_gettext "The file \\\"\\\$FILE\\\" is not a symbolic link."`" - fi - ;; - - x | execution ) - # To exist, file should be executable. - if [[ ! -x $FILE ]];then - MESSAGE="`eval_gettext "The file \\\"\\\$FILE\\\" is not executable."`" - fi - ;; - - fh ) - # To exist, file should be a regular file or a symbolic link. - if [[ ! -f $FILE ]];then - if [[ ! -h $FILE ]];then - MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist."`" - fi - fi - ;; - - fd ) - # To exist, file should be a regular file or a directory. - if [[ ! -f $FILE ]];then - if [[ ! -d $FILE ]];then - MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist."`" - fi - fi - ;; - - isInWorkingCopy ) - # To exist, file should be inside the working copy. - if [[ ! $FILE =~ "^/home/centos/artwork/.+$" ]];then - MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist inside the working copy."`" - fi - ;; - - * ) - # File exists. - if [[ ! -a $FILE ]];then - MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist."`" - fi - - esac - - done - - # If file verification fails in anyway, output message information - # and end up script execution. Otherwise, continue with script - # normal flow. - if [[ "$MESSAGE" != '' ]];then - cli_printMessage "$MESSAGE" "AsErrorLine" - cli_printMessage "$(caller)" "AsToKnowMoreLine" - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_checkPathComponent.sh b/Scripts/Bash/Cli/Functions/cli_checkPathComponent.sh deleted file mode 100755 index 673c068..0000000 --- a/Scripts/Bash/Cli/Functions/cli_checkPathComponent.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# -# cli_checkPathComponent.sh -- This function checks parts/components -# from repository paths. Generally, the path information is passed to -# the function's first positional argument and the part/component we -# want to check is passed to the function's second positional -# argument. If the second argument is not passed, then the first -# argument is assumed to be the part/component we want to check, and -# the action value (ACTIONVAL) variable is used instead as source path -# information. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_checkPathComponent { - - local -a PATTERNS - local LOCATION='' - local OPTION='' - local MESSAGE='' - - # Define location which we retrive information from. - if [[ "$#" -eq 1 ]];then - LOCATION="$ACTIONVAL" - OPTION="$1" - elif [[ "$#" -eq 2 ]];then - LOCATION="$1" - OPTION="$2" - else - cli_printMessage "${FUNCNAME}: `gettext "Invalid arguments."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Define patterns. - PATTERNS[0]="^.+/$(cli_getPathComponent "${LOCATION}" '--release-pattern')/.*$" - PATTERNS[1]=$(cli_getPathComponent "${LOCATION}" '--release-architecture') - PATTERNS[2]=$(cli_getPathComponent "${LOCATION}" '--release-theme') - - # Identify which part of the release we want to output. - case "$OPTION" in - - '--release' ) - if [[ $LOCATION =~ ${PATTERN[0]} ]];then - MESSAGE="`eval_gettext "The release \\\`\\\$LOCATION' is not valid."`" - fi - ;; - - '--architecture' ) - if [[ $LOCATION =~ ${PATTERN[1]} ]];then - MESSAGE="`eval_gettext "The architecture \\\`\\\$LOCATION' is not valid."`" - fi - ;; - - '--theme' ) - if [[ $LOCATION =~ ${PATTERN[2]} ]];then - MESSAGE="`eval_gettext "The theme \\\`\\\$LOCATION' is not valid."`" - fi - ;; - - '--default' | * ) - if [[ $LOCATION == '' ]] \ - || [[ $LOCATION =~ '(\.\.(/)?)' ]] \ - || [[ ! $LOCATION =~ '^[A-Za-z0-9\.:/_-]+$' ]]; then - MESSAGE="`eval_gettext "The value \\\`\\\$LOCATION' is not valid."`" - fi - ;; - esac - - # Output message. - if [[ $MESSAGE != '' ]];then - cli_printMessage "$MESSAGE" 'AsErrorLine' - cli_printMessage "$(caller)" "AsToKnowMoreLine" - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_checkRepoDirSource.sh b/Scripts/Bash/Cli/Functions/cli_checkRepoDirSource.sh deleted file mode 100755 index 666dc17..0000000 --- a/Scripts/Bash/Cli/Functions/cli_checkRepoDirSource.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# -# cli_checkRepoDirSource.sh -- This function provides input validation -# to repository entries considered as source locations. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_checkRepoDirSource { - - # Check action value to be sure strage characters are kept far - # from path provided. - cli_checkPathComponent "$ACTIONVAL" '--default' - - # Redefine source value to build repository absolute path from - # repository top level on. As we are removing - # /home/centos/artwork/ from all centos-art.sh output (in order to - # save horizontal output space), we need to be sure that all - # strings begining with trunk/..., branches/..., and tags/... use - # the correct absolute path. That is, you can refer trunk's - # entries using both /home/centos/artwork/trunk/... or just - # trunk/..., the /home/centos/artwork/ part is automatically added - # here. - if [[ $ACTIONVAL =~ '^(trunk|branches|tags)' ]];then - ACTIONVAL=${HOME}/artwork/$ACTIONVAL - fi - - # Re-define source value to build repository absolute path from - # repository relative paths. This let us to pass repository - # relative paths as source value. Passing relative paths as - # source value may save us some typing; specially if we are stood - # a few levels up from the location we want to refer to as source - # value. There is no need to pass the absolute path to it, just - # refere it relatively. - if [[ -d ${ACTIONVAL} ]];then - - # Add directory to the top of the directory stack. - pushd "$ACTIONVAL" > /dev/null - - # Check directory existence inside the repository. - if [[ $(pwd) =~ "^${HOME}/artwork" ]];then - # Re-define source value using absolute path. - ACTIONVAL=$(pwd) - else - cli_printMessage "`eval_gettext "The location \\\`\\\$ACTIONVAL' is not valid."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Remove directory from the directory stack. - popd > /dev/null - - elif [[ -f ${ACTIONVAL} ]];then - - # Add directory to the top of the directory stack. - pushd "$(dirname "$ACTIONVAL")" > /dev/null - - # Check directory existence inside the repository. - if [[ $(pwd) =~ "^${HOME}/artwork" ]];then - # Re-define source value using absolute path. - ACTIONVAL=$(pwd)/$(basename "$ACTIONVAL") - else - cli_printMessage "`eval_gettext "The location \\\`\\\$ACTIONVAL' is not valid."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Remove directory from the directory stack. - popd > /dev/null - - else - - # At this there is no existent working copy entry, nor a valid - # url. The source value can only be considered as such if it - # is an existent working copy or valid url. So, print a - # message and stop script execution. - cli_printMessage "`eval_gettext "The location \\\`\\\$ACTIONVAL' is not valid."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_checkRepoDirTarget.sh b/Scripts/Bash/Cli/Functions/cli_checkRepoDirTarget.sh deleted file mode 100755 index 7d92673..0000000 --- a/Scripts/Bash/Cli/Functions/cli_checkRepoDirTarget.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# -# cli_checkRepoDirTarget.sh -- This function provides input validation -# to repository entries considered as target location. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_checkRepoDirTarget { - - # Check target value before making an absolute path from it. - cli_checkPathComponent "$FLAG_TO" '--repo-directory' - - # Redefine target value to build repository absolute path from - # repository top level on. As we are removing - # /home/centos/artwork/ from all centos-art.sh output (in order to - # save horizontal output space), we need to be sure that all - # strings begining with trunk/..., branches/..., and tags/... use - # the correct absolute path. That is, you can refer trunk's - # entries using both /home/centos/artwork/trunk/... or just - # trunk/..., the /home/centos/artwork/ part is automatically added - # here. - if [[ $FLAG_TO =~ '^(trunk|branches|tags)/.+$' ]];then - FLAG_TO=${HOME}/artwork/$FLAG_TO - fi - - # Check target value. - if [[ -a ${FLAG_TO} ]];then - - # At this point target value does existent as working copy - # entry. We don't use existent locations as target. So, print - # a message and stop script execution. - cli_printMessage "`eval_gettext "The location \\\`\\\$FLAG_TO' already exists."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - - else - - # At this point existent locations inside working copy and - # invalid urls have been discarded. Assume a new target - # location has being specified. So, build the absolute path - # for it. - - # Add directory to the top of the directory stack. - pushd "$(dirname "$FLAG_TO")" > /dev/null - - # Check directory existence inside the repository. - if [[ $(pwd) =~ "^${HOME}/artwork" ]];then - # Re-define target value using absolute path. - FLAG_TO=$(pwd)/$(basename "$FLAG_TO") - fi - - # Remove directory from the directory stack. - popd > /dev/null - - # Verify target location. It is required that target location - # points to an entry under (trunk|branches|tags)/Identity/... - # directory structure *only*. Remember that Identity parent - # directory structure is the reference used to create parallel - # directories (i.e., documentation, configuration scripts, - # translations, etc.). We don't manipulate parallel - # directories with path ---or any other--- functionality - # directly. Consider manipulation of parallel directories as - # a consequence of a previous manipulation of Identity parent - # directory structure. - if [[ ! ${FLAG_TO} =~ '^.+/(trunk|branches|tags)/Identity/.+$' ]];then - cli_printMessage "`eval_gettext "cannot create \\\`\\\$FLAG_TO': It isn't an identity directory structure."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_commitRepoChanges.sh b/Scripts/Bash/Cli/Functions/cli_commitRepoChanges.sh deleted file mode 100755 index 792d7d0..0000000 --- a/Scripts/Bash/Cli/Functions/cli_commitRepoChanges.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash -# -# cli_commitRepoChanges.sh -- This function realizes a subversion -# commit command agains the workgin copy in order to send local -# changes up to central repository. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_commitRepoChanges { - - # Verify `--dont-commit-changes' option. - if [[ $FLAG_DONT_COMMIT_CHANGES == 'true' ]];then - return - fi - - local -a FILES - local -a INFO - local -a FILESNUM - local COUNT=0 - local STATUSOUT='' - local PREDICATE='' - local CHNGTOTAL=0 - local LOCATIONS='' - - # Define source location the subversion status action will take - # place on. If arguments are provided use them as srouce location. - # Otherwise use action value as default source location. - if [[ "$@" != '' ]];then - LOCATIONS="$@" - else - LOCATIONS="$ACTIONVAL" - fi - - # Verify locations existence. It shoud exist as regular file or - # directory inside the repository working copy. - cli_checkFiles "$LOCATIONS" 'fd' - cli_checkFiles "$LOCATIONS" 'isInWorkingCopy' - - # Outout separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Check working copy. - cli_printMessage "`gettext "Checking changes in the working copy"`" 'AsResponseLine' - STATUSOUT=$(svn status ${LOCATIONS}) - - # Outout separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Define path fo files considered recent modifications from - # working copy up to central repository. - FILES[0]=$(echo "$STATUSOUT" | egrep "^M.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[1]=$(echo "$STATUSOUT" | egrep "^\?.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[2]=$(echo "$STATUSOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[3]=$(echo "$STATUSOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - - # Define description of files considered recent modifications from - # working copy up to central repository. - INFO[0]="`gettext "Modified"`" - INFO[1]="`gettext "Unversioned"`" - INFO[2]="`gettext "Deleted"`" - INFO[3]="`gettext "Added"`" - - while [[ $COUNT -ne ${#FILES[*]} ]];do - - # Define total number of files. Avoid counting empty line. - if [[ "${FILES[$COUNT]}" == '' ]];then - FILESNUM[$COUNT]=0 - else - FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l) - fi - - # Calculate total amount of changes. - CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]})) - - # Build report predicate. Use report predicate to show any - # information specific to the number of files found. For - # example, you can use this section to show warning messages, - # notes, and so on. By default we use the word `file' or - # `files' at ngettext's consideration followed by change - # direction. - PREDICATE[$COUNT]=`ngettext "file from the repository" \ - "files from the repository" $((${FILESNUM[$COUNT]} + 1))` - - # Output report line. - cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" 'AsRegularLine' - - # Increase counter. - COUNT=$(($COUNT + 1)) - - done - - # In case new unversioned files exist, ask the user to add them - # into the repository. This may happen when new documentation - # entries are created. - if [[ ${FILESNUM[1]} -gt 0 ]];then - - # Outout separator line. - cli_printMessage '-' 'AsSeparatorLine' - - cli_printMessage "`ngettext "The following file is unversioned" \ - "The following files are unversioned" ${FILESNUM[1]}`:" - for FILE in ${FILES[1]};do - cli_printMessage $FILE 'AsResponseLine' - done - cli_printMessage "`ngettext "Do you want to add it now?" \ - "Do you want to add them now?" ${FILESNUM[2]}`" 'AsYesOrNoRequestLine' - svn add ${FILES[1]} --quiet - fi - - # Check total amount of changes and, if any, check differences and - # commit them up to central repository. - if [[ $CHNGTOTAL -gt 0 ]];then - - # Outout separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Verify changes. - cli_printMessage "`gettext "Do you want to see changes now?"`" "AsYesOrNoRequestLine" - svn diff ${FILES[*]} | less - - # Commit changes. - cli_printMessage "`gettext "Do you want to commit changes now?"`" "AsYesOrNoRequestLine" - svn commit ${FILES[*]} - - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_doParseArguments.sh b/Scripts/Bash/Cli/Functions/cli_doParseArguments.sh deleted file mode 100755 index b6ad3d8..0000000 --- a/Scripts/Bash/Cli/Functions/cli_doParseArguments.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# cli_doParseArguments.sh -- This function redefines arguments -# (ARGUMENTS) global variable using getopt(1) output. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_doParseArguments { - - # Reset positional parameters using optional arguments. - eval set -- "$ARGUMENTS" - - # Parse optional arguments using getopt. - ARGUMENTS=$(getopt -o "$ARGSS" -l "$ARGSL" -n $CLI_PROGRAM -- "$@") - - # Be sure getout parsed arguments successfully. - if [[ $? != 0 ]]; then - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_doParseArgumentsReDef.sh b/Scripts/Bash/Cli/Functions/cli_doParseArgumentsReDef.sh deleted file mode 100755 index e163b8c..0000000 --- a/Scripts/Bash/Cli/Functions/cli_doParseArgumentsReDef.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# -# cli_doParseArgumentsReDef.sh -- This function initiates/reset -# positional parameters based on `$@' variable. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_doParseArgumentsReDef { - - local ARG - - # Clean up arguments global variable. - ARGUMENTS='' - - # Fill up arguments global variable with current positional - # parameter information. To avoid interpretation problems, use - # single quotes to enclose each argument (ARG) from command-line - # idividually. - for ARG in "$@"; do - ARGUMENTS="$ARGUMENTS '$ARG'" - done - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getCopyrightInfo.sh b/Scripts/Bash/Cli/Functions/cli_getCopyrightInfo.sh deleted file mode 100755 index b376890..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getCopyrightInfo.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# -# cli_getCopyrightInfo.sh -- This function outputs the copyright -# information of content produced by the centos-art command-line -# interface. -# -# As I understand, the copyright exists to make people create more. -# The copyright gives creators the legal power over their creations -# and so the freedom to distribute them under the ethical terms the -# creator considers better. -# -# At this moment I don't feel very sure about this legal affairs, but -# need to decide what copyright information the centos-art will -# output. So, I'm taking the wiki (wiki.centos.org) copyright -# information as reference. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getCopyrightInfo { - - case "$1" in - - '--license' ) - - # Output default license name used by all image-based - # creations inside CentOS Artwork Repository. - echo "Creative Common Attribution-ShareAlike 3.0" - ;; - - '--license-url' ) - - # Ouput default license url used by all image-based - # creations inside CentOS Artwork Repository. - echo "http://creativecommons.org/licenses/by-sa/3.0/" - ;; - - '--copyright-year' ) - - # Output default copyright year. - date +%Y - ;; - - '--copyright-holder' | * ) - - # Output default copyright holder. - echo "The CentOS Project" - ;; - - esac - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getCountryCodes.sh b/Scripts/Bash/Cli/Functions/cli_getCountryCodes.sh deleted file mode 100755 index d32822d..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getCountryCodes.sh +++ /dev/null @@ -1,277 +0,0 @@ -#!/bin/bash -# -# cli_getCountryCodes.sh -- This function outputs a list with country -# codes as defined in ISO3166 standard. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getCountryCodes { - - local FILTER="$(echo $1 | cut -d_ -f2)" - - COUNTRYCODES='AD - AE - AF - AG - AI - AL - AM - AN - AO - AQ - AR - AS - AT - AU - AW - AZ - BA - BB - BD - BE - BF - BG - BH - BI - BJ - BM - BN - BO - BR - BS - BT - BV - BW - BY - BZ - CA - CC - CD - CF - CG - CH - CI - CK - CL - CM - CN - CO - CR - CS - CU - CV - CX - CY - CZ - DE - DJ - DK - DM - DO - DZ - EC - EE - EG - EH - ER - ES - ET - FI - FJ - FK - FM - FO - FR - GA - GB - GD - GE - GF - GH - GI - GL - GM - GN - GP - GQ - GR - GS - GT - GU - GW - GY - HK - HM - HN - HR - HT - HU - ID - IE - IL - IN - IO - IQ - IR - IS - IT - JM - JO - JP - KE - KG - KH - KI - KM - KN - KP - KR - KW - KY - KZ - LA - LB - LC - LI - LK - LR - LS - LT - LU - LV - LY - MA - MC - MD - MG - MH - MK - ML - MM - MN - MO - MP - MQ - MR - MS - MT - MU - MV - MW - MX - MY - MZ - NA - NC - NE - NF - NG - NI - NL - NO - NP - NR - NU - NZ - OM - PA - PE - PF - PG - PH - PK - PL - PM - PN - PR - PS - PT - PW - PY - QA - RE - RO - RU - RW - SA - SB - SC - SD - SE - SG - SH - SI - SJ - SK - SL - SM - SN - SO - SR - ST - SV - SY - SZ - TC - TD - TF - TG - TH - TJ - TK - TL - TM - TN - TO - TR - TT - TV - TW - TZ - UA - UG - UM - US - UY - UZ - VA - VC - VE - VG - VI - VN - VU - WF - WS - YE - YT - ZA - ZM - ZW' - - if [[ $FILTER != '' ]];then - echo $COUNTRYCODES | egrep "$FILTER" - else - echo "$COUNTRYCODES" - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getCountryName.sh b/Scripts/Bash/Cli/Functions/cli_getCountryName.sh deleted file mode 100755 index 4c82e00..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getCountryName.sh +++ /dev/null @@ -1,759 +0,0 @@ -#!/bin/bash -# -# cli_getCountryName.sh -- This function reads one language locale -# code in the format LL_CC and outputs the name of its related -# country. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getCountryName { - - local LOCALECODE="$(echo $1 | cut -d_ -f2)" - local COUNTRYNAME="" - - case $LOCALECODE in - - 'AD' ) - COUNTRYNAME="`gettext "Andorra"`" - ;; - 'AE' ) - COUNTRYNAME="`gettext "United Arab Emirates"`" - ;; - 'AF' ) - COUNTRYNAME="`gettext "Afghanistan"`" - ;; - 'AG' ) - COUNTRYNAME="`gettext "Antigua and Barbuda"`" - ;; - 'AI' ) - COUNTRYNAME="`gettext "Anguilla"`" - ;; - 'AL' ) - COUNTRYNAME="`gettext "Albania"`" - ;; - 'AM' ) - COUNTRYNAME="`gettext "Armenia"`" - ;; - 'AN' ) - COUNTRYNAME="`gettext "Netherlands Antilles"`" - ;; - 'AO' ) - COUNTRYNAME="`gettext "Angola"`" - ;; - 'AQ' ) - COUNTRYNAME="`gettext "Antarctica"`" - ;; - 'AR' ) - COUNTRYNAME="`gettext "Argentina"`" - ;; - 'AS' ) - COUNTRYNAME="`gettext "Samoa (American)"`" - ;; - 'AT' ) - COUNTRYNAME="`gettext "Austria"`" - ;; - 'AU' ) - COUNTRYNAME="`gettext "Australia"`" - ;; - 'AW' ) - COUNTRYNAME="`gettext "Aruba"`" - ;; - 'AZ' ) - COUNTRYNAME="`gettext "Azerbaijan"`" - ;; - 'BA' ) - COUNTRYNAME="`gettext "Bosnia and Herzegovina"`" - ;; - 'BB' ) - COUNTRYNAME="`gettext "Barbados"`" - ;; - 'BD' ) - COUNTRYNAME="`gettext "Bangladesh"`" - ;; - 'BE' ) - COUNTRYNAME="`gettext "Belgium"`" - ;; - 'BF' ) - COUNTRYNAME="`gettext "Burkina Faso"`" - ;; - 'BG' ) - COUNTRYNAME="`gettext "Bulgaria"`" - ;; - 'BH' ) - COUNTRYNAME="`gettext "Bahrain"`" - ;; - 'BI' ) - COUNTRYNAME="`gettext "Burundi"`" - ;; - 'BJ' ) - COUNTRYNAME="`gettext "Benin"`" - ;; - 'BM' ) - COUNTRYNAME="`gettext "Bermuda"`" - ;; - 'BN' ) - COUNTRYNAME="`gettext "Brunei"`" - ;; - 'BO' ) - COUNTRYNAME="`gettext "Bolivia"`" - ;; - 'BR' ) - COUNTRYNAME="`gettext "Brazil"`" - ;; - 'BS' ) - COUNTRYNAME="`gettext "Bahamas"`" - ;; - 'BT' ) - COUNTRYNAME="`gettext "Bhutan"`" - ;; - 'BV' ) - COUNTRYNAME="`gettext "Bouvet Island"`" - ;; - 'BW' ) - COUNTRYNAME="`gettext "Botswana"`" - ;; - 'BY' ) - COUNTRYNAME="`gettext "Belarus"`" - ;; - 'BZ' ) - COUNTRYNAME="`gettext "Belize"`" - ;; - 'CA' ) - COUNTRYNAME="`gettext "Canada"`" - ;; - 'CC' ) - COUNTRYNAME="`gettext "Cocos (Keeling) Islands"`" - ;; - 'CD' ) - COUNTRYNAME="`gettext "Congo (Dem. Rep.)"`" - ;; - 'CF' ) - COUNTRYNAME="`gettext "Central African Rep."`" - ;; - 'CG' ) - COUNTRYNAME="`gettext "Congo (Rep.)"`" - ;; - 'CH' ) - COUNTRYNAME="`gettext "Switzerland"`" - ;; - 'CI' ) - COUNTRYNAME="`gettext "Co^te d'Ivoire"`" - ;; - 'CK' ) - COUNTRYNAME="`gettext "Cook Islands"`" - ;; - 'CL' ) - COUNTRYNAME="`gettext "Chile"`" - ;; - 'CM' ) - COUNTRYNAME="`gettext "Cameroon"`" - ;; - 'CN' ) - COUNTRYNAME="`gettext "China"`" - ;; - 'CO' ) - COUNTRYNAME="`gettext "Colombia"`" - ;; - 'CR' ) - COUNTRYNAME="`gettext "Costa Rica"`" - ;; - 'CS' ) - COUNTRYNAME="`gettext "Serbia and Montenegro"`" - ;; - 'CU' ) - COUNTRYNAME="`gettext "Cuba"`" - ;; - 'CV' ) - COUNTRYNAME="`gettext "Cape Verde"`" - ;; - 'CX' ) - COUNTRYNAME="`gettext "Christmas Island"`" - ;; - 'CY' ) - COUNTRYNAME="`gettext "Cyprus"`" - ;; - 'CZ' ) - COUNTRYNAME="`gettext "Czech Republic"`" - ;; - 'DE' ) - COUNTRYNAME="`gettext "Germany"`" - ;; - 'DJ' ) - COUNTRYNAME="`gettext "Djibouti"`" - ;; - 'DK' ) - COUNTRYNAME="`gettext "Denmark"`" - ;; - 'DM' ) - COUNTRYNAME="`gettext "Dominica"`" - ;; - 'DO' ) - COUNTRYNAME="`gettext "Dominican Republic"`" - ;; - 'DZ' ) - COUNTRYNAME="`gettext "Algeria"`" - ;; - 'EC' ) - COUNTRYNAME="`gettext "Ecuador"`" - ;; - 'EE' ) - COUNTRYNAME="`gettext "Estonia"`" - ;; - 'EG' ) - COUNTRYNAME="`gettext "Egypt"`" - ;; - 'EH' ) - COUNTRYNAME="`gettext "Western Sahara"`" - ;; - 'ER' ) - COUNTRYNAME="`gettext "Eritrea"`" - ;; - 'ES' ) - COUNTRYNAME="`gettext "Spain"`" - ;; - 'ET' ) - COUNTRYNAME="`gettext "Ethiopia"`" - ;; - 'FI' ) - COUNTRYNAME="`gettext "Finland"`" - ;; - 'FJ' ) - COUNTRYNAME="`gettext "Fiji"`" - ;; - 'FK' ) - COUNTRYNAME="`gettext "Falkland Islands"`" - ;; - 'FM' ) - COUNTRYNAME="`gettext "Micronesia"`" - ;; - 'FO' ) - COUNTRYNAME="`gettext "Faeroe Islands"`" - ;; - 'FR' ) - COUNTRYNAME="`gettext "France"`" - ;; - 'GA' ) - COUNTRYNAME="`gettext "Gabon"`" - ;; - 'GB' ) - COUNTRYNAME="`gettext "Britain (UK)"`" - ;; - 'GD' ) - COUNTRYNAME="`gettext "Grenada"`" - ;; - 'GE' ) - COUNTRYNAME="`gettext "Georgia"`" - ;; - 'GF' ) - COUNTRYNAME="`gettext "French Guiana"`" - ;; - 'GH' ) - COUNTRYNAME="`gettext "Ghana"`" - ;; - 'GI' ) - COUNTRYNAME="`gettext "Gibraltar"`" - ;; - 'GL' ) - COUNTRYNAME="`gettext "Greenland"`" - ;; - 'GM' ) - COUNTRYNAME="`gettext "Gambia"`" - ;; - 'GN' ) - COUNTRYNAME="`gettext "Guinea"`" - ;; - 'GP' ) - COUNTRYNAME="`gettext "Guadeloupe"`" - ;; - 'GQ' ) - COUNTRYNAME="`gettext "Equatorial Guinea"`" - ;; - 'GR' ) - COUNTRYNAME="`gettext "Greece"`" - ;; - 'GS' ) - COUNTRYNAME="`gettext "South Georgia and the South Sandwich Islands"`" - ;; - 'GT' ) - COUNTRYNAME="`gettext "Guatemala"`" - ;; - 'GU' ) - COUNTRYNAME="`gettext "Guam"`" - ;; - 'GW' ) - COUNTRYNAME="`gettext "Guinea-Bissau"`" - ;; - 'GY' ) - COUNTRYNAME="`gettext "Guyana"`" - ;; - 'HK' ) - COUNTRYNAME="`gettext "Hong Kong"`" - ;; - 'HM' ) - COUNTRYNAME="`gettext "Heard Island and McDonald Islands"`" - ;; - 'HN' ) - COUNTRYNAME="`gettext "Honduras"`" - ;; - 'HR' ) - COUNTRYNAME="`gettext "Croatia"`" - ;; - 'HT' ) - COUNTRYNAME="`gettext "Haiti"`" - ;; - 'HU' ) - COUNTRYNAME="`gettext "Hungary"`" - ;; - 'ID' ) - COUNTRYNAME="`gettext "Indonesia"`" - ;; - 'IE' ) - COUNTRYNAME="`gettext "Ireland"`" - ;; - 'IL' ) - COUNTRYNAME="`gettext "Israel"`" - ;; - 'IN' ) - COUNTRYNAME="`gettext "India"`" - ;; - 'IO' ) - COUNTRYNAME="`gettext "British Indian Ocean Territory"`" - ;; - 'IQ' ) - COUNTRYNAME="`gettext "Iraq"`" - ;; - 'IR' ) - COUNTRYNAME="`gettext "Iran"`" - ;; - 'IS' ) - COUNTRYNAME="`gettext "Iceland"`" - ;; - 'IT' ) - COUNTRYNAME="`gettext "Italy"`" - ;; - 'JM' ) - COUNTRYNAME="`gettext "Jamaica"`" - ;; - 'JO' ) - COUNTRYNAME="`gettext "Jordan"`" - ;; - 'JP' ) - COUNTRYNAME="`gettext "Japan"`" - ;; - 'KE' ) - COUNTRYNAME="`gettext "Kenya"`" - ;; - 'KG' ) - COUNTRYNAME="`gettext "Kyrgyzstan"`" - ;; - 'KH' ) - COUNTRYNAME="`gettext "Cambodia"`" - ;; - 'KI' ) - COUNTRYNAME="`gettext "Kiribati"`" - ;; - 'KM' ) - COUNTRYNAME="`gettext "Comoros"`" - ;; - 'KN' ) - COUNTRYNAME="`gettext "St Kitts and Nevis"`" - ;; - 'KP' ) - COUNTRYNAME="`gettext "Korea (North)"`" - ;; - 'KR' ) - COUNTRYNAME="`gettext "Korea (South)"`" - ;; - 'KW' ) - COUNTRYNAME="`gettext "Kuwait"`" - ;; - 'KY' ) - COUNTRYNAME="`gettext "Cayman Islands"`" - ;; - 'KZ' ) - COUNTRYNAME="`gettext "Kazakhstan"`" - ;; - 'LA' ) - COUNTRYNAME="`gettext "Laos"`" - ;; - 'LB' ) - COUNTRYNAME="`gettext "Lebanon"`" - ;; - 'LC' ) - COUNTRYNAME="`gettext "St Lucia"`" - ;; - 'LI' ) - COUNTRYNAME="`gettext "Liechtenstein"`" - ;; - 'LK' ) - COUNTRYNAME="`gettext "Sri Lanka"`" - ;; - 'LR' ) - COUNTRYNAME="`gettext "Liberia"`" - ;; - 'LS' ) - COUNTRYNAME="`gettext "Lesotho"`" - ;; - 'LT' ) - COUNTRYNAME="`gettext "Lithuania"`" - ;; - 'LU' ) - COUNTRYNAME="`gettext "Luxembourg"`" - ;; - 'LV' ) - COUNTRYNAME="`gettext "Latvia"`" - ;; - 'LY' ) - COUNTRYNAME="`gettext "Libya"`" - ;; - 'MA' ) - COUNTRYNAME="`gettext "Morocco"`" - ;; - 'MC' ) - COUNTRYNAME="`gettext "Monaco"`" - ;; - 'MD' ) - COUNTRYNAME="`gettext "Moldova"`" - ;; - 'MG' ) - COUNTRYNAME="`gettext "Madagascar"`" - ;; - 'MH' ) - COUNTRYNAME="`gettext "Marshall Islands"`" - ;; - 'MK' ) - COUNTRYNAME="`gettext "Macedonia"`" - ;; - 'ML' ) - COUNTRYNAME="`gettext "Mali"`" - ;; - 'MM' ) - COUNTRYNAME="`gettext "Myanmar (Burma)"`" - ;; - 'MN' ) - COUNTRYNAME="`gettext "Mongolia"`" - ;; - 'MO' ) - COUNTRYNAME="`gettext "Macao"`" - ;; - 'MP' ) - COUNTRYNAME="`gettext "Northern Mariana Islands"`" - ;; - 'MQ' ) - COUNTRYNAME="`gettext "Martinique"`" - ;; - 'MR' ) - COUNTRYNAME="`gettext "Mauritania"`" - ;; - 'MS' ) - COUNTRYNAME="`gettext "Montserrat"`" - ;; - 'MT' ) - COUNTRYNAME="`gettext "Malta"`" - ;; - 'MU' ) - COUNTRYNAME="`gettext "Mauritius"`" - ;; - 'MV' ) - COUNTRYNAME="`gettext "Maldives"`" - ;; - 'MW' ) - COUNTRYNAME="`gettext "Malawi"`" - ;; - 'MX' ) - COUNTRYNAME="`gettext "Mexico"`" - ;; - 'MY' ) - COUNTRYNAME="`gettext "Malaysia"`" - ;; - 'MZ' ) - COUNTRYNAME="`gettext "Mozambique"`" - ;; - 'NA' ) - COUNTRYNAME="`gettext "Namibia"`" - ;; - 'NC' ) - COUNTRYNAME="`gettext "New Caledonia"`" - ;; - 'NE' ) - COUNTRYNAME="`gettext "Niger"`" - ;; - 'NF' ) - COUNTRYNAME="`gettext "Norfolk Island"`" - ;; - 'NG' ) - COUNTRYNAME="`gettext "Nigeria"`" - ;; - 'NI' ) - COUNTRYNAME="`gettext "Nicaragua"`" - ;; - 'NL' ) - COUNTRYNAME="`gettext "Netherlands"`" - ;; - 'NO' ) - COUNTRYNAME="`gettext "Norway"`" - ;; - 'NP' ) - COUNTRYNAME="`gettext "Nepal"`" - ;; - 'NR' ) - COUNTRYNAME="`gettext "Nauru"`" - ;; - 'NU' ) - COUNTRYNAME="`gettext "Niue"`" - ;; - 'NZ' ) - COUNTRYNAME="`gettext "New Zealand"`" - ;; - 'OM' ) - COUNTRYNAME="`gettext "Oman"`" - ;; - 'PA' ) - COUNTRYNAME="`gettext "Panama"`" - ;; - 'PE' ) - COUNTRYNAME="`gettext "Peru"`" - ;; - 'PF' ) - COUNTRYNAME="`gettext "French Polynesia"`" - ;; - 'PG' ) - COUNTRYNAME="`gettext "Papua New Guinea"`" - ;; - 'PH' ) - COUNTRYNAME="`gettext "Philippines"`" - ;; - 'PK' ) - COUNTRYNAME="`gettext "Pakistan"`" - ;; - 'PL' ) - COUNTRYNAME="`gettext "Poland"`" - ;; - 'PM' ) - COUNTRYNAME="`gettext "St Pierre and Miquelon"`" - ;; - 'PN' ) - COUNTRYNAME="`gettext "Pitcairn"`" - ;; - 'PR' ) - COUNTRYNAME="`gettext "Puerto Rico"`" - ;; - 'PS' ) - COUNTRYNAME="`gettext "Palestine"`" - ;; - 'PT' ) - COUNTRYNAME="`gettext "Portugal"`" - ;; - 'PW' ) - COUNTRYNAME="`gettext "Palau"`" - ;; - 'PY' ) - COUNTRYNAME="`gettext "Paraguay"`" - ;; - 'QA' ) - COUNTRYNAME="`gettext "Qatar"`" - ;; - 'RE' ) - COUNTRYNAME="`gettext "Reunion"`" - ;; - 'RO' ) - COUNTRYNAME="`gettext "Romania"`" - ;; - 'RU' ) - COUNTRYNAME="`gettext "Russia"`" - ;; - 'RW' ) - COUNTRYNAME="`gettext "Rwanda"`" - ;; - 'SA' ) - COUNTRYNAME="`gettext "Saudi Arabia"`" - ;; - 'SB' ) - COUNTRYNAME="`gettext "Solomon Islands"`" - ;; - 'SC' ) - COUNTRYNAME="`gettext "Seychelles"`" - ;; - 'SD' ) - COUNTRYNAME="`gettext "Sudan"`" - ;; - 'SE' ) - COUNTRYNAME="`gettext "Sweden"`" - ;; - 'SG' ) - COUNTRYNAME="`gettext "Singapore"`" - ;; - 'SH' ) - COUNTRYNAME="`gettext "St Helena"`" - ;; - 'SI' ) - COUNTRYNAME="`gettext "Slovenia"`" - ;; - 'SJ' ) - COUNTRYNAME="`gettext "Svalbard and Jan Mayen"`" - ;; - 'SK' ) - COUNTRYNAME="`gettext "Slovakia"`" - ;; - 'SL' ) - COUNTRYNAME="`gettext "Sierra Leone"`" - ;; - 'SM' ) - COUNTRYNAME="`gettext "San Marino"`" - ;; - 'SN' ) - COUNTRYNAME="`gettext "Senegal"`" - ;; - 'SO' ) - COUNTRYNAME="`gettext "Somalia"`" - ;; - 'SR' ) - COUNTRYNAME="`gettext "Suriname"`" - ;; - 'ST' ) - COUNTRYNAME="`gettext "Sao Tome and Principe"`" - ;; - 'SV' ) - COUNTRYNAME="`gettext "El Salvador"`" - ;; - 'SY' ) - COUNTRYNAME="`gettext "Syria"`" - ;; - 'SZ' ) - COUNTRYNAME="`gettext "Swaziland"`" - ;; - 'TC' ) - COUNTRYNAME="`gettext "Turks and Caicos Islands"`" - ;; - 'TD' ) - COUNTRYNAME="`gettext "Chad"`" - ;; - 'TF' ) - COUNTRYNAME="`gettext "French Southern and Antarctic Lands"`" - ;; - 'TG' ) - COUNTRYNAME="`gettext "Togo"`" - ;; - 'TH' ) - COUNTRYNAME="`gettext "Thailand"`" - ;; - 'TJ' ) - COUNTRYNAME="`gettext "Tajikistan"`" - ;; - 'TK' ) - COUNTRYNAME="`gettext "Tokelau"`" - ;; - 'TL' ) - COUNTRYNAME="`gettext "Timor-Leste"`" - ;; - 'TM' ) - COUNTRYNAME="`gettext "Turkmenistan"`" - ;; - 'TN' ) - COUNTRYNAME="`gettext "Tunisia"`" - ;; - 'TO' ) - COUNTRYNAME="`gettext "Tonga"`" - ;; - 'TR' ) - COUNTRYNAME="`gettext "Turkey"`" - ;; - 'TT' ) - COUNTRYNAME="`gettext "Trinidad and Tobago"`" - ;; - 'TV' ) - COUNTRYNAME="`gettext "Tuvalu"`" - ;; - 'TW' ) - COUNTRYNAME="`gettext "Taiwan"`" - ;; - 'TZ' ) - COUNTRYNAME="`gettext "Tanzania"`" - ;; - 'UA' ) - COUNTRYNAME="`gettext "Ukraine"`" - ;; - 'UG' ) - COUNTRYNAME="`gettext "Uganda"`" - ;; - 'UM' ) - COUNTRYNAME="`gettext "US minor outlying islands"`" - ;; - 'US' ) - COUNTRYNAME="`gettext "United States"`" - ;; - 'UY' ) - COUNTRYNAME="`gettext "Uruguay"`" - ;; - 'UZ' ) - COUNTRYNAME="`gettext "Uzbekistan"`" - ;; - 'VA' ) - COUNTRYNAME="`gettext "Vatican City"`" - ;; - 'VC' ) - COUNTRYNAME="`gettext "St Vincent"`" - ;; - 'VE' ) - COUNTRYNAME="`gettext "Venezuela"`" - ;; - 'VG' ) - COUNTRYNAME="`gettext "Virgin Islands (UK)"`" - ;; - 'VI' ) - COUNTRYNAME="`gettext "Virgin Islands (US)"`" - ;; - 'VN' ) - COUNTRYNAME="`gettext "Vietnam"`" - ;; - 'VU' ) - COUNTRYNAME="`gettext "Vanuatu"`" - ;; - 'WF' ) - COUNTRYNAME="`gettext "Wallis and Futuna"`" - ;; - 'WS' ) - COUNTRYNAME="`gettext "Samoa (Western)"`" - ;; - 'YE' ) - COUNTRYNAME="`gettext "Yemen"`" - ;; - 'YT' ) - COUNTRYNAME="`gettext "Mayotte"`" - ;; - 'ZA' ) - COUNTRYNAME="`gettext "South Africa"`" - ;; - 'ZM' ) - COUNTRYNAME="`gettext "Zambia"`" - ;; - 'ZW' ) - COUNTRYNAME="`gettext "Zimbabwe"`" - ;; - * ) - COUNTRYNAME="`gettext "Unknown"`" - - esac - - echo $COUNTRYNAME - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getCurrentLocale.sh b/Scripts/Bash/Cli/Functions/cli_getCurrentLocale.sh deleted file mode 100755 index 3a44fb3..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getCurrentLocale.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# -# cli_getCurrentLocale.sh -- This function checks LANG environment -# variable and returns the current locale information in the LL_CC -# format. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getCurrentLocale { - - local CURRENTLOCALE='' - local OPTION="$1" - - # Redefine current locale using LL_CC format. - CURRENTLOCALE=$(echo $LANG | sed -r 's!(^[a-z]{2,3}_[A-Z]{2}).+$!\1!') - - # Define centos-art.sh script default current locale. If - # centos-art.sh script doesn't support current system locale, use - # English language from United States as default current locale. - if [[ $CURRENTLOCALE == '' ]];then - CURRENTLOCALE='en_US' - fi - - # Output current locale. - case $OPTION in - - '--langcode-only' ) - echo "${CURRENTLOCALE}" | cut -d_ -f1 - ;; - - '--langcode-and-countrycode'| * ) - echo "${CURRENTLOCALE}" - ;; - esac -} diff --git a/Scripts/Bash/Cli/Functions/cli_getFilesList.sh b/Scripts/Bash/Cli/Functions/cli_getFilesList.sh deleted file mode 100755 index 034fe56..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getFilesList.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# -# cli_getFilesList.sh -- This function defines the list of FILES to -# process. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getFilesList { - - local LOCATION='' - local FILTER='' - local FILES='' - - # If first argument is provided to cli_getFilesList, use it as - # default location. Otherwise, if first argument is not provided, - # location takes the action value (ACTIONVAL) as default. - if [[ "$1" != '' ]];then - LOCATION="$1" - else - LOCATION="$ACTIONVAL" - fi - - # If second argument is provided to cli_getFilesList, use it as - # default extension to look for files. Otherwise, if second - # argument is not provided, use flag filter instead. - if [[ "$2" != '' ]];then - FILTER="$2" - else - FILTER="$FLAG_FILTER" - fi - - # Define filter as regular expression pattern. When we use regular - # expressions with find, regular expressions are evaluated against - # the whole file path. This way, when the regular expression is - # specified, we need to build it in a way that matches the whole - # path. Doing so, everytime we pass the `--filter' option in the - # command-line could be a tedious task. Instead, in the sake of - # reducing some typing, we prepare the regular expression here to - # match the whole path using the regular expression provided by - # the user as pattern. Do not use LOCATION variable as part of - # regular expresion so it could be possible to use path expansion. - # Using path expansion reduce the amount of places to find out - # things and so the time required to finish the task. - FILTER="^.+/${FILTER}$" - - # Define list of files to process. At this point we cannot verify - # whether the LOCATION is a directory or a file since path - # expansion coul be introduced to it. The best we can do is - # verifying exit status and go on. - FILES=$(find ${LOCATION} -regextype posix-egrep -regex "${FILTER}" | sort | uniq) - - # Output list of files to process. - if [[ $? -eq 0 ]];then - echo "$FILES" - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getFunctions.sh b/Scripts/Bash/Cli/Functions/cli_getFunctions.sh deleted file mode 100644 index 375b552..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getFunctions.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# -# cli_getFunctions.sh -- This function loads funtionalities supported by -# centos-art.sh script. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getFunctions { - - # Define variables as local to avoid conflicts outside. - local FUNCNAMCALL='' - local FUNCFILES='' - - # Build action-specifc script file list. - FUNCFILES=$(ls ${FUNCDIR}/${FUNCDIRNAM}/${FUNCNAM}*.sh) - - for FILE in $FUNCFILES;do - - if [[ -x ${FILE} ]];then - - # Initialize action-specific functions. - . $FILE - - # Export action-specific functions to current shell script - # environment. - FUNCNAMCALL=$(grep '^function ' $FILE | cut -d' ' -f2) - export -f $FUNCNAMCALL - - else - - cli_printMessage "`eval_gettext "The \\\$FILE hasn't execution rights."`" 'AsErrorLine' - cli_printMessage "$(caller)" "AsToKnowMoreLine" - - fi - - done - - # Execute action passed to centos-art.sh script. - if [[ $FUNCNAM != '' ]];then - eval $FUNCNAM - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getLangCodes.sh b/Scripts/Bash/Cli/Functions/cli_getLangCodes.sh deleted file mode 100755 index 2c46d9b..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getLangCodes.sh +++ /dev/null @@ -1,223 +0,0 @@ -#!/bin/bash -# -# cli_getLangCodes.sh -- This function outputs a list with language -# codes as defined in ISO639 standard. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getLangCodes { - - local FILTER="$(echo $1 | cut -d_ -f1)" - - LANGCODES="aa - ab - ae - af - ak - am - an - ar - as - av - ay - az - ba - be - bg - bh - bi - bm - bn - bo - br - bs - ca - ce - ch - co - cr - cs - cu - cv - cy - da - de - dv - dz - ee - el - en - eo - es - et - eu - fa - ff - fi - fj - fo - fr - fy - ga - gd - gl - gn - gu - gv - ha - he - hi - ho - hr - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - io - is - it - iu - ja - jv - ka - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ku - kv - kw - ky - la - lb - lg - li - ln - lo - lt - lu - lv - mg - mh - mi - mk - ml - mn - mo - mr - ms - mt - my - na - nb - nd - ne - ng - nl - nn - no - nr - nv - ny - oc - oj - om - or - os - pa - pi - pl - ps - pt - qu - rm - rn - ro - ru - rw - sa - sc - sd - se - sg - si - sk - sl - sm - sn - so - sq - sr - ss - st - su - sv - sw - ta - te - tg - th - ti - tk - tl - tn - to - tr - ts - tt - tw - ty - ug - uk - ur - uz - ve - vi - vo - wa - wo - xh - yi - yo - za - zh - zu" - - if [[ $FILTER != '' ]];then - echo "$LANGCODES" | egrep "$FILTER" | sed -r 's![[:space:]]+!!g' - else - echo "$LANGCODES" - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getLangName.sh b/Scripts/Bash/Cli/Functions/cli_getLangName.sh deleted file mode 100755 index e49f116..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getLangName.sh +++ /dev/null @@ -1,781 +0,0 @@ -#!/bin/bash -# -# cli_getLangName.sh -- This function reads one language locale code -# in the format LL_CC and outputs its language name. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getLangName { - - local LANGCODE="$(echo "$1" | cut -d_ -f1 | tr '[:upper:]' '[:lower:]')" - local LANGNAME='' - - case $LANGCODE in - - 'aa' ) - LANGNAME="`gettext "Afar"`" - ;; - - 'ab' ) - LANGNAME="`gettext "Abkhazian"`" - ;; - - 'ae' ) - LANGNAME="`gettext "Avestan"`" - ;; - - 'af' ) - LANGNAME="`gettext "Afrikaans"`" - ;; - - 'ak' ) - LANGNAME="`gettext "Akan"`" - ;; - - 'am' ) - LANGNAME="`gettext "Amharic"`" - ;; - - 'an' ) - LANGNAME="`gettext "Aragonese"`" - ;; - - 'ar' ) - LANGNAME="`gettext "Arabic"`" - ;; - - 'as' ) - LANGNAME="`gettext "Assamese"`" - ;; - - 'av' ) - LANGNAME="`gettext "Avaric"`" - ;; - - 'ay' ) - LANGNAME="`gettext "Aymara"`" - ;; - - 'az' ) - LANGNAME="`gettext "Azerbaijani"`" - ;; - - 'ba' ) - LANGNAME="`gettext "Bashkir"`" - ;; - - 'be' ) - LANGNAME="`gettext "Byelorussian"`" - ;; - - 'bg' ) - LANGNAME="`gettext "Bulgarian"`" - ;; - - 'bh' ) - LANGNAME="`gettext "Bihari"`" - ;; - - 'bi' ) - LANGNAME="`gettext "Bislama"`" - ;; - - 'bm' ) - LANGNAME="`gettext "Bambara"`" - ;; - - 'bn' ) - LANGNAME="`gettext "Bengali"`" - ;; - - 'bo' ) - LANGNAME="`gettext "Tibetan"`" - ;; - - 'br' ) - LANGNAME="`gettext "Breton"`" - ;; - - 'bs' ) - LANGNAME="`gettext "Bosnian"`" - ;; - - 'ca' ) - LANGNAME="`gettext "Catalan"`" - ;; - - 'ce' ) - LANGNAME="`gettext "Chechen"`" - ;; - - 'ch' ) - LANGNAME="`gettext "Chamorro"`" - ;; - - 'co' ) - LANGNAME="`gettext "Corsican"`" - ;; - - 'cr' ) - LANGNAME="`gettext "Cree"`" - ;; - - 'cs' ) - LANGNAME="`gettext "Czech"`" - ;; - - 'cu' ) - LANGNAME="`gettext "Church Slavic"`" - ;; - - 'cv' ) - LANGNAME="`gettext "Chuvash"`" - ;; - - 'cy' ) - LANGNAME="`gettext "Welsh"`" - ;; - - 'da' ) - LANGNAME="`gettext "Danish"`" - ;; - - 'de' ) - LANGNAME="`gettext "German"`" - ;; - - 'dv' ) - LANGNAME="`gettext "Divehi"`" - ;; - - 'dz' ) - LANGNAME="`gettext "Dzongkha"`" - ;; - - 'ee' ) - LANGNAME="`gettext "E'we"`" - ;; - - 'el' ) - LANGNAME="`gettext "Greek"`" - ;; - - 'en' ) - LANGNAME="`gettext "English"`" - ;; - - 'eo' ) - LANGNAME="`gettext "Esperanto"`" - ;; - - 'es' ) - LANGNAME="`gettext "Spanish"`" - ;; - - 'et' ) - LANGNAME="`gettext "Estonian"`" - ;; - - 'eu' ) - LANGNAME="`gettext "Basque"`" - ;; - 'fa' ) - LANGNAME="`gettext "Persian"`" - ;; - - 'ff' ) - LANGNAME="`gettext "Fulah"`" - ;; - - 'fi' ) - LANGNAME="`gettext "Finnish"`" - ;; - - 'fj' ) - LANGNAME="`gettext "Fijian"`" - ;; - - 'fo' ) - LANGNAME="`gettext "Faroese"`" - ;; - - 'fr' ) - LANGNAME="`gettext "French"`" - ;; - - 'fy' ) - LANGNAME="`gettext "Frisian"`" - ;; - - 'ga' ) - LANGNAME="`gettext "Irish"`" - ;; - - 'gd' ) - LANGNAME="`gettext "Scots"`" - ;; - - 'gl' ) - LANGNAME="`gettext "Gallegan"`" - ;; - - 'gn' ) - LANGNAME="`gettext "Guarani"`" - ;; - - 'gu' ) - LANGNAME="`gettext "Gujarati"`" - ;; - - 'gv' ) - LANGNAME="`gettext "Manx"`" - ;; - - 'ha' ) - LANGNAME="`gettext "Hausa"`" - ;; - - 'he' ) - LANGNAME="`gettext "Hebrew"`" - ;; - - 'hi' ) - LANGNAME="`gettext "Hindi"`" - ;; - - 'ho' ) - LANGNAME="`gettext "Hiri Motu"`" - ;; - - 'hr' ) - LANGNAME="`gettext "Croatian"`" - ;; - - 'ht' ) - LANGNAME="`gettext "Haitian"`" - ;; - - 'hu' ) - LANGNAME="`gettext "Hungarian"`" - ;; - - 'hy' ) - LANGNAME="`gettext "Armenian"`" - ;; - - 'hz' ) - LANGNAME="`gettext "Herero"`" - ;; - - 'ia' ) - LANGNAME="`gettext "Interlingua"`" - ;; - - 'id' ) - LANGNAME="`gettext "Indonesian"`" - ;; - - 'ie' ) - LANGNAME="`gettext "Interlingue"`" - ;; - - 'ig' ) - LANGNAME="`gettext "Igbo"`" - ;; - - 'ii' ) - LANGNAME="`gettext "Sichuan Yi"`" - ;; - - 'ik' ) - LANGNAME="`gettext "Inupiak"`" - ;; - - 'io' ) - LANGNAME="`gettext "Ido"`" - ;; - - 'is' ) - LANGNAME="`gettext "Icelandic"`" - ;; - - 'it' ) - LANGNAME="`gettext "Italian"`" - ;; - - 'iu' ) - LANGNAME="`gettext "Inuktitut"`" - ;; - - 'ja' ) - LANGNAME="`gettext "Japanese"`" - ;; - - 'jv' ) - LANGNAME="`gettext "Javanese"`" - ;; - - 'ka' ) - LANGNAME="`gettext "Georgian"`" - ;; - - 'kg' ) - LANGNAME="`gettext "Kongo"`" - ;; - - 'ki' ) - LANGNAME="`gettext "Kikuyu"`" - ;; - - 'kj' ) - LANGNAME="`gettext "Kuanyama"`" - ;; - - 'kk' ) - LANGNAME="`gettext "Kazakh"`" - ;; - - 'kl' ) - LANGNAME="`gettext "Kalaallisut"`" - ;; - - 'km' ) - LANGNAME="`gettext "Khmer"`" - ;; - - 'kn' ) - LANGNAME="`gettext "Kannada"`" - ;; - - 'ko' ) - LANGNAME="`gettext "Korean"`" - ;; - - 'kr' ) - LANGNAME="`gettext "Kanuri"`" - ;; - - 'ks' ) - LANGNAME="`gettext "Kashmiri"`" - ;; - - 'ku' ) - LANGNAME="`gettext "Kurdish"`" - ;; - - 'kv' ) - LANGNAME="`gettext "Komi"`" - ;; - - 'kw' ) - LANGNAME="`gettext "Cornish"`" - ;; - - 'ky' ) - LANGNAME="`gettext "Kirghiz"`" - ;; - - 'la' ) - LANGNAME="`gettext "Latin"`" - ;; - - 'lb' ) - LANGNAME="`gettext "Letzeburgesch"`" - ;; - - 'lg' ) - LANGNAME="`gettext "Ganda"`" - ;; - - 'li' ) - LANGNAME="`gettext "Limburgish"`" - ;; - - 'ln' ) - LANGNAME="`gettext "Lingala"`" - ;; - - 'lo' ) - LANGNAME="`gettext "Lao"`" - ;; - - 'lt' ) - LANGNAME="`gettext "Lithuanian"`" - ;; - - 'lu' ) - LANGNAME="`gettext "Luba-Katanga"`" - ;; - - 'lv' ) - LANGNAME="`gettext "Latvian"`" - ;; - - 'mg' ) - LANGNAME="`gettext "Malagasy"`" - ;; - - 'mh' ) - LANGNAME="`gettext "Marshall"`" - ;; - - 'mi' ) - LANGNAME="`gettext "Maori"`" - ;; - - 'mk' ) - LANGNAME="`gettext "Macedonian"`" - ;; - - 'ml' ) - LANGNAME="`gettext "Malayalam"`" - ;; - - 'mn' ) - LANGNAME="`gettext "Mongolian"`" - ;; - - 'mo' ) - LANGNAME="`gettext "Moldavian"`" - ;; - - 'mr' ) - LANGNAME="`gettext "Marathi"`" - ;; - - 'ms' ) - LANGNAME="`gettext "Malay"`" - ;; - - 'mt' ) - LANGNAME="`gettext "Maltese"`" - ;; - - 'my' ) - LANGNAME="`gettext "Burmese"`" - ;; - - 'na' ) - LANGNAME="`gettext "Nauru"`" - ;; - - 'nb' ) - LANGNAME="`gettext "Norwegian Bokmaal"`" - ;; - - 'nd' ) - LANGNAME="`gettext "Ndebele, North"`" - ;; - - 'ne' ) - LANGNAME="`gettext "Nepali"`" - ;; - - 'ng' ) - LANGNAME="`gettext "Ndonga"`" - ;; - - 'nl' ) - LANGNAME="`gettext "Dutch"`" - ;; - - 'nn' ) - LANGNAME="`gettext "Norwegian Nynorsk"`" - ;; - - 'no' ) - LANGNAME="`gettext "Norwegian"`" - ;; - - 'nr' ) - LANGNAME="`gettext "Ndebele, South"`" - ;; - - 'nv' ) - LANGNAME="`gettext "Navajo"`" - ;; - - 'ny' ) - LANGNAME="`gettext "Chichewa"`" - ;; - - 'oc' ) - LANGNAME="`gettext "Occitan"`" - ;; - - 'oj' ) - LANGNAME="`gettext "Ojibwa"`" - ;; - - 'om' ) - LANGNAME="`gettext "(Afan) Oromo"`" - ;; - - 'or' ) - LANGNAME="`gettext "Oriya"`" - ;; - - 'os' ) - LANGNAME="`gettext "Ossetian; Ossetic"`" - ;; - - 'pa' ) - LANGNAME="`gettext "Panjabi; Punjabi"`" - ;; - - 'pi' ) - LANGNAME="`gettext "Pali"`" - ;; - - 'pl' ) - LANGNAME="`gettext "Polish"`" - ;; - - 'ps' ) - LANGNAME="`gettext "Pashto, Pushto"`" - ;; - - 'pt' ) - LANGNAME="`gettext "Portuguese"`" - ;; - - 'qu' ) - LANGNAME="`gettext "Quechua"`" - ;; - - 'rm' ) - LANGNAME="`gettext "Rhaeto-Romance"`" - ;; - - 'rn' ) - LANGNAME="`gettext "Rundi"`" - ;; - - 'ro' ) - LANGNAME="`gettext "Romanian"`" - ;; - - 'ru' ) - LANGNAME="`gettext "Russian"`" - ;; - - 'rw' ) - LANGNAME="`gettext "Kinyarwanda"`" - ;; - - 'sa' ) - LANGNAME="`gettext "Sanskrit"`" - ;; - - 'sc' ) - LANGNAME="`gettext "Sardinian"`" - ;; - - 'sd' ) - LANGNAME="`gettext "Sindhi"`" - ;; - - 'se' ) - LANGNAME="`gettext "Northern Sami"`" - ;; - - 'sg' ) - LANGNAME="`gettext "Sango; Sangro"`" - ;; - - 'si' ) - LANGNAME="`gettext "Sinhalese"`" - ;; - - 'sk' ) - LANGNAME="`gettext "Slovak"`" - ;; - - 'sl' ) - LANGNAME="`gettext "Slovenian"`" - ;; - - 'sm' ) - LANGNAME="`gettext "Samoan"`" - ;; - - 'sn' ) - LANGNAME="`gettext "Shona"`" - ;; - - 'so' ) - LANGNAME="`gettext "Somali"`" - ;; - - 'sq' ) - LANGNAME="`gettext "Albanian"`" - ;; - - 'sr' ) - LANGNAME="`gettext "Serbian"`" - ;; - - 'ss' ) - LANGNAME="`gettext "Swati; Siswati"`" - ;; - - 'st' ) - LANGNAME="`gettext "Sesotho; Sotho, Southern"`" - ;; - - 'su' ) - LANGNAME="`gettext "Sundanese"`" - ;; - - 'sv' ) - LANGNAME="`gettext "Swedish"`" - ;; - - 'sw' ) - LANGNAME="`gettext "Swahili"`" - ;; - - 'ta' ) - LANGNAME="`gettext "Tamil"`" - ;; - - 'te' ) - LANGNAME="`gettext "Telugu"`" - ;; - - 'tg' ) - LANGNAME="`gettext "Tajik"`" - ;; - - 'th' ) - LANGNAME="`gettext "Thai"`" - ;; - - 'ti' ) - LANGNAME="`gettext "Tigrinya"`" - ;; - - 'tk' ) - LANGNAME="`gettext "Turkmen"`" - ;; - - 'tl' ) - LANGNAME="`gettext "Tagalog"`" - ;; - - 'tn' ) - LANGNAME="`gettext "Tswana; Setswana"`" - ;; - - 'to' ) - LANGNAME="`gettext "Tonga (?)"`" - ;; - - 'tr' ) - LANGNAME="`gettext "Turkish"`" - ;; - - 'ts' ) - LANGNAME="`gettext "Tsonga"`" - ;; - - - 'tt' ) - LANGNAME="`gettext "Tatar"`" - ;; - - 'tw' ) - LANGNAME="`gettext "Twi"`" - ;; - - 'ty' ) - LANGNAME="`gettext "Tahitian"`" - ;; - - 'ug' ) - LANGNAME="`gettext "Uighur"`" - ;; - - 'uk' ) - LANGNAME="`gettext "Ukrainian"`" - ;; - - 'ur' ) - LANGNAME="`gettext "Urdu"`" - ;; - - 'uz' ) - LANGNAME="`gettext "Uzbek"`" - ;; - - 've' ) - LANGNAME="`gettext "Venda"`" - ;; - - 'vi' ) - LANGNAME="`gettext "Vietnamese"`" - ;; - - 'vo' ) - LANGNAME="`gettext "Volapuk; Volapuk"`" - ;; - - 'wa' ) - LANGNAME="`gettext "Walloon"`" - ;; - - 'wo' ) - LANGNAME="`gettext "Wolof"`" - ;; - - 'xh' ) - LANGNAME="`gettext "Xhosa"`" - ;; - - 'yi' ) - LANGNAME="`gettext "Yiddish (formerly ji)"`" - ;; - - 'yo' ) - LANGNAME="`gettext "Yoruba"`" - ;; - - 'za' ) - LANGNAME="`gettext "Zhuang"`" - ;; - - 'zh' ) - LANGNAME="`gettext "Chinese"`" - ;; - - 'zu' ) - LANGNAME="`gettext "Zulu"`" - ;; - - * ) - LANGNAME="`gettext "Unknown"`" - - esac - - echo $LANGNAME; -} - diff --git a/Scripts/Bash/Cli/Functions/cli_getLocales.sh b/Scripts/Bash/Cli/Functions/cli_getLocales.sh deleted file mode 100755 index e72fc3d..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getLocales.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# cli_getLocales.sh -- This function outputs/verifies locale codes in -# LL and LL_CC format. Combine both ISO639 and ISO3166 specification -# in order to build the final locale list. This function defines which -# translation locales are supported inside CentOS Artwork Repository. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getLocales { - - # Print locales supported by centos-art.sh script. - locale -a | egrep '^[a-z]{2,3}_[A-Z]{2}$' | sort | uniq - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getPathComponent.sh b/Scripts/Bash/Cli/Functions/cli_getPathComponent.sh deleted file mode 100755 index e71a058..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getPathComponent.sh +++ /dev/null @@ -1,230 +0,0 @@ -#!/bin/bash -# -# cli_getPathComponent.sh -- This function evaluates one repository -# path and output parts/components from it. Generally, the path -# information is passed to the function's first positional argument -# and the part/component we want to retrive is passed to the -# function's second positional argument. If second argument is not -# passed, then first argument is assumed to be the part/component we -# want to retrive, and action value (ACTIONVAL) variable is used -# instead as source path information. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getPathComponent { - - local -a PATTERN - local LOCATION='' - local OPTION='' - - # Define location which we retrive information from. - if [[ "$#" -eq 1 ]];then - LOCATION="$ACTIONVAL" - OPTION="$1" - elif [[ "$#" -eq 2 ]];then - LOCATION="$1" - OPTION="$2" - else - cli_printMessage "${FUNCNAM}: `gettext "Invalid arguments."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Define release pattern. - PATTERN[0]="(([[:digit:]]+)(\.([[:digit:]]+)){,1})" - - # Define architecture pattern. Make it match the architectures the - # CentOS distribution is able to be installed on. - PATTERN[1]="(i386|x86_64)" - - # Define theme pattern for trunk, branches, and tags directory - # structures. - # - # trunk: - # ------ - # Themes are made of `Models' and `Motifs'. `Models' controls the - # `Motifs' characteristcs and it is not rendereable. On the other - # hand, `Motifs' controls the theme visual style and do is - # renderable. Since we only need to know the theme name when we - # render something, we take the `Motifs' directory structure as - # reference to find out the theme name we are producing images - # for. - # - # `Motifs' are organized by names, so when we say `a theme name' - # we are really saying `the artistic motif name of a theme', but - # for short `theme name' is used instead. `Models' are also - # organized by names, but we do never use model names to name a - # thame. We always say the `theme models' or `the models of the - # theme` to refere the theme component that controls the - # characteristics of artistic motifs. We never name a thame as its - # model. We use artistic motifs name for such purpose. - # - # Inside artistic motif names, we organize different versions of - # the same artistic motif by means of numerical worklines. - # Worklines, inside trunk, have an integer numerical form and - # begin at `1'. They increment one unit each time a new/fresh - # visual style ---for the same artistic motif--- is conceived. - # - # For example, the Flame theme uses the flame filter of Gimp to - # produce different fractal patterns randomly. We use the flame - # filter to produce different visual styles under the same theme - # since all patterns we produce are based on the same pattern - # (i.e., the random fractal pattern of Gimp's flame filter). This - # way, if you no longer want to produce visual styles from flame - # filter, it is time to create a new artistic motif name for it. - # - # This schema is very convenient for designers and packagers, - # since different designers can create their own worklines and go - # on with them until CentOS distribution release date is close. At - # that time, a workline is selected and tagged for packaging. - # Translators and programmers can continue working indepently, and - # without affection, in their own directory structures. - # - # Example: - # +------> theme name - # |-->| - # trunk/.../Themes/Motifs/Flame/1 - # trunk/.../Themes/Motifs/Flame/2 - # trunk/.../Themes/Motifs/Flame/3 - # | - # +----> theme release version - # - # Sometimes we only need to retrive the theme name, but othertimes - # both the theme name and its work-line is required as well. - # - # branches: - # --------- - # The branch development line is treated just as trunk development - # line does, but we rarely use it since it could be confusing to - # know whether a tag was created from trunk or branches. - # - # Conceive an enumeration schema in order to differentiate - # branches from trunk is not convenient either, it would introduce - # an intermediate point to the final production of tags we would - # need to be aware of. Instead of such configuration, we prefer - # to go straightforward from trunk to tags. - # - # Intermediate branches for quality assurance might be good in - # some situations, but not when we produce themes. We need a - # simple structure, where we could design, render content (using - # centos-art.sh), and release for testing (through tags). If - # something goes wrong in the released tag, it would be fixed in - # trunk and later released in another tagged relase. - # - # Of course, care should be taken to avoid making of trunk - # development line a chaotic place. Everbody should know exactly - # what they are doing therein. We need to design protections to - # isolate possible damages and that way, we could know exactly - # what and where we need to concentrate in and put our time on. - # - # In resume, do not use branches if you don't need to. Use trunk - # development line instead. - # - # tags: - # ----- - # The tag frozen line is mainly used to perform theme releases. - # - # Example: - # +------> theme name - # |-->| - # tags/.../Themes/Motifs/Flame/1.0 - # trunk/.../Themes/Motifs/Flame/1 |--> minor update - # |----> major udpate - # - # Tags have the format X.Z, where X is the first number in the - # name (e.g., `1') and represents the trunk/branches artistic - # motif version. The Z represents the second number in the name - # (e.g., `0') which is the tag version itself. - # - # Tag versions start at `0' and increment one unit each time a new - # tag is created from the same artistic motif version. When a new - # tag is created for the same artistic motif version, the first - # number in the tag name remains intact. The first number in the - # tag name only changes when we create a new tag for a new - # artistic motif version. - # - # Consider the following relations: - # - # trunk/.../Themes/Motifs/Flame/1 - # tags/.../Themes/Motifs/Flame/1.0 - # tags/.../Themes/Motifs/Flame/1.1 - # tags/.../Themes/Motifs/Flame/1.2 - # - # trunk/.../Themes/Motifs/Flame/2 - # tags/.../Themes/Motifs/Flame/2.0 - # tags/.../Themes/Motifs/Flame/2.1 - # tags/.../Themes/Motifs/Flame/2.2 - # - # trunk/.../Themes/Motifs/TreeFlower/1 - # ... - # and so on. - # - # Tag versions are created to release fixes and improvements, Tags - # are immutable (i.e., once tags are created, they shouldn't be - # modified.). - PATTERN[2]="^.+/Identity/Themes/Motifs/(([A-Za-z0-9]+)/${PATTERN[0]})/.+$" - - # Identify which part of the release we want to output. - case "$OPTION" in - - '--release' ) - echo "$LOCATION" | sed -r "s!.*/${PATTERN[0]}/.*!\1!" - ;; - - '--release-major' ) - echo "$LOCATION" | sed -r "s!.*/${PATTERN[0]}/.*!\2!" - ;; - - '--release-minor' ) - echo "$LOCATION" | sed -r "s!.*/${PATTERN[0]}/.*!\4!" - ;; - - '--release-pattern' ) - echo "${PATTERN[0]}" - ;; - - '--architecture' ) - echo "$LOCATION" | sed -r "s!${PATTERN[1]}!\1!" - ;; - - '--architecture-pattern' ) - echo "${PATTERN[1]}" - ;; - - '--theme' ) - echo "$LOCATION" | sed -r "s!${PATTERN[2]}!\1!" - ;; - - '--theme-name' ) - echo "$LOCATION" | sed -r "s!${PATTERN[2]}!\2!" - ;; - - '--theme-release' ) - echo "$LOCATION" | sed -r "s!${PATTERN[2]}!\3!" - ;; - - '--theme-pattern' ) - echo "${PATTERN[2]}" - ;; - - esac - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getRepoName.sh b/Scripts/Bash/Cli/Functions/cli_getRepoName.sh deleted file mode 100755 index 5d85cd3..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getRepoName.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash -# -# cli_getRepoName.sh -- This function sets naming convenction. Inside -# CentOS Artowrk Repository, regular files are written in lower case -# and directories are written in lower case but with the first letter -# in upper case. Use this function to sanitate the name of regular -# files and directory components of paths you work with. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getRepoName { - - local NAME="$1" - local TYPE="$2" - local DIRS='' - local DIR='' - local CLEANDIRS='' - local PREFIXDIR='' - - case $TYPE in - - 'f' | 'basename' ) - - # Reduce the path passed to use just the non-directory - # part of it (i.e., the last component in the path; _not_ - # the last "real" directory in the path). - NAME=$(basename $NAME) - - # Clean value. - NAME=$(echo $NAME \ - | tr -s ' ' '_' \ - | tr '[:upper:]' '[:lower:]') - ;; - - 'd' | 'dirname' ) - - # Reduce path information passed to use just the directory - # part of it. Of course, this is applied only if there is - # a directory part in the path. However, if there is no - # directory part but there is a non-empty value in the - # path, assume that value as directory part and clean it - # up. - if [[ $NAME =~ '.+/.+' ]];then - - # When path information is reduced, we need to take - # into account that absolute path may be provided. - # Absolute paths include directory structures outside - # the repository directory structure we don't want to - # sanitate (e.g., /home/, /home/centos/, - # /home/centos/artwork, /home/centos/artwork/turnk/, - # trunk/, etc.). In these cases, it is required that - # those path component remain untouched. So, in the - # sake of keeping path components, outside repository - # directory structure untouched, we use the PREFIXDIR - # variable to temporarly store the prefix directory - # structure we don't want to sanitate. - PREFIXDIR=$(echo $NAME \ - | sed -r "s,^((${HOME}/artwork/)?(trunk|branches|tags)/).+$,\1,") - - # ... and remove it from the path information we do - # want to sanitate. - DIRS=$(dirname "$NAME" \ - | sed -r "s!^${PREFIXDIR}!!" \ - | tr '/' ' ') - - else - - # At this point, there is not directory part in the - # information passed, so use the value passed as - # directory part as such. - DIRS=$NAME - - fi - - for DIR in $DIRS;do - - # Sanitate directory component. - if [[ $DIR =~ '^[a-z]' ]];then - DIR=$(echo ${DIR} \ - | tr -s ' ' '_' \ - | tr '[:upper:]' '[:lower:]' \ - | sed -r 's/^([[:alpha:]])/\u\1/') - fi - - # Rebuild path using sanitated values. - CLEANDIRS="${CLEANDIRS}/$DIR" - - done - - # Redefine path using sanitated values. - NAME=$(echo ${CLEANDIRS} | sed -r "s!^/!!") - - # Add prefix directory information to sanitated path - # information. - if [[ "$PREFIXDIR" != '' ]];then - NAME=${PREFIXDIR}${NAME} - fi - ;; - - 'fd' | 'basename-to-dirname' ) - - # Retrive non-directory part. - NAME=$(cli_getRepoName $NAME 'f') - - # Retrive cleaned directory part from non-directory part. - NAME=$(cli_getRepoName $NAME 'd') - ;; - - 'df' | 'dirname-to-basename' ) - - # Retrive cleaned directory part from non-directory part. - NAME=$(cli_getRepoName $NAME 'd') - - # Retrive non-directory part. - NAME=$(cli_getRepoName $NAME 'f') - ;; - - 'dfd' | 'dirname-to-basename-to-dirname' ) - - # Retrive cleaned directory part from non-directory part. - NAME=$(cli_getRepoName $NAME 'd') - - # Retrive non-directory part. - NAME=$(cli_getRepoName $NAME 'f') - - # Retrive cleaned directory part from non-directory part. - NAME=$(cli_getRepoName $NAME 'd') - ;; - esac - - # Output clean path information. - echo $NAME - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getRepoParallelDirs.sh b/Scripts/Bash/Cli/Functions/cli_getRepoParallelDirs.sh deleted file mode 100755 index 3fc047b..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getRepoParallelDirs.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# -# cli_getRepoParallelDirs.sh -- This function returns the parallel -# directories related to the first positional paramenter passed as -# parent directory. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getRepoParallelDirs { - - local BOND='' - local TDIR='' - local -a PDIRS - - # Define bond string using first positional parameter as - # reference. - if [[ "$1" != '' ]];then - BOND="$1" - elif [[ "$ACTIONVAL" != '' ]];then - BOND="$ACTIONVAL" - else - cli_printMessage "${FUNCNAME}: `gettext "The bond string is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Define repository top level directory. - TDIR=$(cli_getRepoTLDir ${BOND}) - - # Define parallel directory base structures. - PDIRS[0]=Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${BOND}" '--relative') - PDIRS[1]=Scripts/Bash/Functions/Render/Config - PDIRS[2]=Locales - - # Redefine bond string without its top level directory structure. - BOND=$(echo $BOND | sed -r "s,^${TDIR}/(.+)$,\1,") - - # Concatenate repository top level directory, parallel directory - # base structure, and bond information; in order to produce the - # final parallel directory path. - for PDIR in "${PDIRS[@]}";do - echo ${TDIR}/${PDIR}/${BOND} - done - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getRepoStatus.sh b/Scripts/Bash/Cli/Functions/cli_getRepoStatus.sh deleted file mode 100755 index a7b42db..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getRepoStatus.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# cli_getRepoStatus.sh -- This function requests the working copy -# using the svn status command and returns the first character in the -# output line, as described in svn help status, for the LOCATION -# specified. Use this function to perform verifications based a -# repository LOCATION status. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getRepoStatus { - - local LOCATION="$1" - local STATUS='' - - # Define regular expression pattern to retrive first column, - # returned by subversion status command. This column is one - # character column as describes `svn help status' command. - local PATTERN='^( |A|C|D|I|M|R|X|\?|!|~).+$' - - # Verify the file used as source to retrive its status - # information. We only use regular files or directories inside the - # working copy. - cli_checkFiles "$LOCATION" 'fd' - cli_checkFiles "$LOCATION" 'isInWorkingCopy' - - # Use subversion `status' command to retrive the first character - # in the output. Discard standard error output. - STATUS="$(svn status "$LOCATION" | sed -r "s/${PATTERN}/\1/" 2>/dev/null)" - - # Outout status information. - echo -n "$STATUS" - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getRepoTLDir.sh b/Scripts/Bash/Cli/Functions/cli_getRepoTLDir.sh deleted file mode 100755 index 77c522d..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getRepoTLDir.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# -# cli_getRepoTLDir.sh -- This function returns the repository top -# level absolute path. The repository top level absolute path may be -# /home/centos/artwork/trunk, /home/centos/artwork/branches, or -# /home/centos/artwork/tags. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getRepoTLDir { - - local PATTERN='' - local REPLACE='' - local LOCATION='' - - # Define location. If first argument is provided use it as default - # location. Otherwise, if first argument is not provided, - # location takes the action value (ACTIONVAL) as default. - if [[ "$1" != '' ]];then - LOCATION="$1" - else - LOCATION="$ACTIONVAL" - fi - - # Verify location. - if [[ $LOCATION =~ "^${HOME}/artwork/(trunk|branches|tags)/.+$" ]];then - case "$2" in - -r|--relative ) - PATTERN="^${HOME}/artwork/(trunk|branches|tags)/.+$" - REPLACE='\1' - ;; - -a|--absolute|* ) - PATTERN="^(${HOME}/artwork/(trunk|branches|tags))/.+$" - REPLACE='\1' - ;; - esac - else - cli_printMessage "${FUNCNAME}: `eval_gettext "The location \\\`\\\$LOCATION' is not valid."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Print location. - echo $LOCATION | sed -r "s!${PATTERN}!${REPLACE}!g" - -} diff --git a/Scripts/Bash/Cli/Functions/cli_getTemporalFile.sh b/Scripts/Bash/Cli/Functions/cli_getTemporalFile.sh deleted file mode 100755 index faddedb..0000000 --- a/Scripts/Bash/Cli/Functions/cli_getTemporalFile.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# -# cli_getTemporalFile.sh -- This function returns the absolute path -# you need to use to create temporal files. Use this function whenever -# you need to create temporal files inside centos-art.sh script. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getTemporalFile { - - # Define base name for temporal file. This is required when svg - # instances are created previous to be parsed by inkscape in order - # to be exported as png. In such cases .svg file exention is - # required in order to avoid complains from inkscape. - local NAME="$(cli_getRepoName "$1" 'f')" - - # Check default base name for temporal file, it can't be an empty - # value. - if [[ "$NAME" == '' ]];then - cli_printMessage "${FUNCNAME}: `gettext "First argument cannot be empty."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Define source location where temporal files will be stored. - local TMPDIR='/tmp' - - # Define unique identifier for temporal file. - local UUID=$(cat /proc/sys/kernel/random/uuid) - - # Define absolute path for temporal file using the program name, - # the current locale, the unique identifier and the file name. - local TMPFILE="${TMPDIR}/${CLI_PROGRAM}-$(cli_getCurrentLocale)-${UUID}-${NAME}" - - # Output absolute path to final temporal file. - echo $TMPFILE - -} diff --git a/Scripts/Bash/Cli/Functions/cli_printActionPreamble.sh b/Scripts/Bash/Cli/Functions/cli_printActionPreamble.sh deleted file mode 100755 index e811587..0000000 --- a/Scripts/Bash/Cli/Functions/cli_printActionPreamble.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash -# -# cli_printActionPreamble -- This function standardizes action -# preamble messages. Action preamble messages provides a confirmation -# message that illustrate what files will be affected in the action. -# -# Generally, actions are applied to parent directories. Each parent -# directory has parallel directories associated. If one parent -# directory is created/deleted, the parallel directories associated do -# need to be created/deleted too. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_printActionPreamble { - - local FILES="$1" - - # Verify amount of files to process. If there is no one then there - # is nothing else to do here. - if [[ "$FILES" == '' ]];then - return - fi - - local ACTION="$2" - local FORMAT="$3" - local FILE='' - local NEGATIVE='' - local POSITIVE='' - local COUNT=0 - - # Replace spaces by new line. - FILES=$(echo "$FILES" | sed -r "s! +!\n!g") - - # Redefine total number of directories. - COUNT=$(echo "$FILES" | wc -l) - - # Redefine preamble messages based on action. At this point seems - # to be some files to process so lets read ACTION to know what to - # do with them. - case $ACTION in - - 'doCreate' ) - if [[ $FILES == '' ]];then - NEGATIVE="`gettext "There is no entry to create."`" - else - POSITIVE="`ngettext "The following entry will be created" \ - "The following entries will be created" $COUNT`:" - fi - ;; - - 'doDelete' ) - if [[ $FILES == '' ]];then - NEGATIVE="`gettext "There is no file to delete."`" - else - POSITIVE="`ngettext "The following entry will be deleted" \ - "The following entries will be deleted" $COUNT`:" - fi - ;; - - 'doLocale' ) - if [[ $FILES == '' ]];then - NEGATIVE="`gettext "There is no file to locale."`" - else - POSITIVE="`ngettext "Translatable strings will be retrived from the following entry" \ - "Translatable strings will be retrived from the following entries" $COUNT`:" - fi - ;; - - 'doEdit' ) - if [[ $FILES == '' ]];then - NEGATIVE="`gettext "There is no file to edit."`" - else - POSITIVE="`ngettext "The following file will be edited" \ - "The following files will be edited" $COUNT`:" - fi - ;; - - * ) - # Check list of files to process. If we have an empty - # list of files, inform about that and stop the script - # execution. Otherwise, check all files in the list to be - # sure they are regular files. - if [[ "$FILES" == '' ]];then - NEGATIVE="`gettext "There is no file to process."`" - fi - ;; - - esac - - # Print preamble message. - if [[ $POSITIVE != '' ]] && [[ $NEGATIVE == '' ]];then - cli_printMessage "$POSITIVE" - for FILE in $FILES;do - cli_printMessage "$FILE" "$FORMAT" - done - cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' - elif [[ $POSITIVE == '' ]] && [[ $NEGATIVE != '' ]];then - cli_printMessage "$NEGATIVE" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/cli_printMessage.sh b/Scripts/Bash/Cli/Functions/cli_printMessage.sh deleted file mode 100755 index 9cf3ec3..0000000 --- a/Scripts/Bash/Cli/Functions/cli_printMessage.sh +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/bash -# -# cli_printMessage.sh -- This function outputs information in -# predifined formats to standard error. This function is the standard -# way to output information inside centos-art.sh script. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_printMessage { - - # Verify `--quiet' option. - if [[ "$FLAG_QUIET" == 'true' ]];then - return - fi - - local MESSAGE="$1" - local FORMAT="$2" - - # Reduce paths inside output messages. The main purpose for - # this is to free horizontal space in output messages. - MESSAGE=$(echo "$MESSAGE" \ - | sed -r "s!${HOME}/artwork/(trunk|branches|tags)/!\1/!g") - - # Remove blank spaces from lines' begining. - MESSAGE=$(echo "$MESSAGE" | sed -r 's!^[[:space:]]+!!') - - # Define message formats. - case $FORMAT in - - 'AsUpdatingLine' ) - cli_printMessage "`gettext "Updating"`: $MESSAGE" - ;; - - 'AsDeletingLine' ) - cli_printMessage "`gettext "Deleting"`: $MESSAGE" - ;; - - 'AsCheckingLine' ) - cli_printMessage "`gettext "Checking"`: $MESSAGE" - ;; - - 'AsCreatingLine' ) - cli_printMessage "`gettext "Creating"`: $MESSAGE" - ;; - - 'AsReadingLine' ) - cli_printMessage "`gettext "Reading"`: $MESSAGE" - ;; - - 'AsSavedAsLine' ) - cli_printMessage "`gettext "Saved as"`: $MESSAGE" - ;; - - 'AsLinkToLine' ) - cli_printMessage "`gettext "Linked to"`: $MESSAGE" - ;; - - 'AsMovedToLine' ) - cli_printMessage "`gettext "Moved to"`: $MESSAGE" - ;; - - 'AsTranslationLine' ) - cli_printMessage "`gettext "Translation"`: $MESSAGE" - ;; - - 'AsDesignLine' ) - cli_printMessage "`gettext "Design"`: $MESSAGE" - ;; - - 'AsConfigurationLine' ) - cli_printMessage "`gettext "Configuration"`: $MESSAGE" - ;; - - 'AsPaletteLine' ) - cli_printMessage "`gettext "Palette"`: $MESSAGE" - ;; - - 'AsResponseLine' ) - cli_printMessage "--> $MESSAGE" - ;; - - 'AsRequestLine' ) - cli_printMessage "${MESSAGE}: " 'AsNoTrailingNewLine' - ;; - - 'AsErrorLine' ) - # This option is used to print error messsages. - echo "${CLI_PROGRAM}: ${MESSAGE}" > /dev/stderr - ;; - - 'AsToKnowMoreLine' ) - # This option receives the output of bash's caller built-in as - # message value and produces the documentation entry from it. - MESSAGE=$(dirname "$(echo $MESSAGE | cut -d ' ' -f2-)") - cli_printMessage '-' 'AsSeparatorLine' - cli_printMessage "`gettext "To know more, run the following command"`:" - cli_printMessage "centos-art manual --read='$MESSAGE'" - cli_printMessage '-' 'AsSeparatorLine' - exit # <-- ATTENTION: Do not remove this line. We use this - # option as convenction to end script - # execution. - ;; - - 'AsYesOrNoRequestLine' ) - - # Define positive answer. - local Y="`gettext "yes"`" - - # Define negative answer. - local N="`gettext "no"`" - - # Define default answer. - local ANSWER=${FLAG_ANSWER} - - if [[ $ANSWER == 'false' ]];then - - # Print the question. - cli_printMessage "$MESSAGE [${Y}/${N}]: " 'AsNoTrailingNewLine' - - # Redefine default answer based on user's input. - read ANSWER - - fi - - # Verify user's answer. Only positive answer let the script - # flow to continue. Otherwise, if something different from - # possitive answer is passed, the script terminates its - # execution immediatly. - if [[ ! ${ANSWER} =~ "^${Y}" ]];then - exit - fi - ;; - - 'AsSeparatorLine' ) - - # Define separator width. - local MAX=70 - - # Draw separator. - until [[ $MAX -eq 0 ]];do - printf "${MESSAGE}" > /dev/stderr - MAX=$(($MAX - 1)) - done - - # Output newline to end separator. - echo "" > /dev/stderr - ;; - - 'AsNoTrailingNewLine' ) - printf "$MESSAGE" > /dev/stderr - ;; - - 'AsRegularLine' | * ) - echo "$MESSAGE" \ - | awk -f ${CLI_BASEDIR}/Styles/output_forTwoColumns.awk \ - > /dev/stderr - ;; - - esac - -} diff --git a/Scripts/Bash/Cli/Functions/cli_readFileContent.sh b/Scripts/Bash/Cli/Functions/cli_readFileContent.sh deleted file mode 100644 index ab4edaf..0000000 --- a/Scripts/Bash/Cli/Functions/cli_readFileContent.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# -# cli_readFileContent.sh -- This function outputs content of files, -# passed as first argument, to standard output as specified by second -# argument. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_readFileContent { - - local FILES="$1" - local PATTERN='Copyright (\(C\)|©) [0-9]+(-[0-9]+)? .+' - - # Verify existence of files but don't stop if it doesn't exist. - cli_checkFiles "$FILES" - - # Print content of files to standard output. - case "$2" in - - '--copyright-line' ) - cat "$FILES" | egrep "^ +${PATTERN}$" | head -n 1 | sed -r 's!^ +!!' - ;; - - '--last-line' ) - cat "$FILES" | tail -n 1 - ;; - - '--copyright-year' ) - if [[ $(cli_readFileContent "$FILES" '--copyright-line') =~ "^${PATTERN}$" ]];then - cli_readFileContent "$FILES" '--copyright-line' | cut -d' ' -f3 - fi - ;; - - '--copyright-holder' ) - if [[ $(cli_readFileContent "$FILES" '--copyright-line') =~ "^${PATTERN}$" ]];then - cli_readFileContent "$FILES" '--copyright-line' | cut -d' ' -f4- - fi - ;; - - '--all-lines' | * ) - cat "$FILES" - ;; - - esac - -} diff --git a/Scripts/Bash/Cli/Functions/cli_replaceTMarkers.sh b/Scripts/Bash/Cli/Functions/cli_replaceTMarkers.sh deleted file mode 100755 index 7024a39..0000000 --- a/Scripts/Bash/Cli/Functions/cli_replaceTMarkers.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash -# -# cli_replaceTMarkers.sh -- This function standardizes -# replacements for common translation markers. Raplacements are -# applied to temporal instances used to produce the final file. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_replaceTMarkers { - - # Initialize variables. - local -a SRC - local -a DST - local COUNT=0 - local COUNTSRC=0 - local COUNTDST=0 - local LOCATION='' - - # Define source location on which sed replacements take place. - LOCATION="$1" - - # Verify file source location. - cli_checkFiles "$LOCATION" 'f' - - # Define translation markers. The translation marker definition - # order is important. Note that when we render concept directory - # structure, we make two replacements to produce the final - # copyright note. First, we replace =COPYRIGHT= translation marker - # and later the =THEMENAME= translation maker (not the oposite). - SRC[0]='=COPYRIGHT_YEAR=' - SRC[1]='=COPYRIGHT_HOLDER=' - SRC[2]='=LICENSE=' - SRC[3]='=LICENSE_URL=' - SRC[4]='=THEME=' - SRC[5]='=THEMENAME=' - SRC[6]='=THEMERELEASE=' - SRC[7]='=RELEASE=' - SRC[8]='=MAJOR_RELEASE=' - SRC[9]='=MINOR_RELEASE=' - SRC[10]='=URL=' - SRC[11]='=ARCH=' - SRC[12]='=URL_WIKI=' - SRC[13]='=URL_LISTS=' - SRC[14]='=URL_FORUMS=' - SRC[15]='=URL_MIRRORS=' - SRC[16]='=URL_DOCS=' - SRC[17]='=MAIL_DOCS=' - SRC[18]='=LOCALE_LL=' - - # Define replacements for translation markers. - DST[0]="$(cli_getCopyrightInfo '--copyright-year')" - DST[1]="$(cli_getCopyrightInfo '--copyright-holder')" - DST[2]="$(cli_getCopyrightInfo '--license')" - DST[3]="$(cli_getCopyrightInfo '--license-url')" - DST[4]="$(cli_getPathComponent "$OUTPUT" '--theme')" - DST[5]="$(cli_getPathComponent "$OUTPUT" '--theme-name')" - DST[6]="$(cli_getPathComponent "$OUTPUT" '--theme-release')" - DST[7]="$(cli_getPathComponent "$FLAG_RELEASEVER" '--release')" - DST[8]="$(cli_getPathComponent "$FLAG_RELEASEVER" '--release-major')" - DST[9]="$(cli_getPathComponent "$FLAG_RELEASEVER" '--release-minor')" - DST[10]="http://www.centos.org/=LOCALE_LL=" - DST[11]="$(cli_getPathComponent "$FLAG_BASEARCH" '--architecture')" - DST[12]="http://wiki.centos.org/=LOCALE_LL=" - DST[13]="http://lists.centos.org/=LOCALE_LL=" - DST[14]="http://forums.centos.org/=LOCALE_LL=" - DST[15]="http://mirrors.centos.org/=LOCALE_LL=" - DST[16]="http://docs.centos.org/=LOCALE_LL=" - DST[17]="centos-docs@=LOCALE_LL=.centos.org" - if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then - DST[18]="$(cli_getCurrentLocale '--langcode-only')/" - else - DST[18]='' - fi - - # Do replacement of nested translation markers. - while [[ $COUNTDST -lt ${#DST[@]} ]];do - - # Verify existence of translation markers. If there is no - # translation marker on replacement, continue with the next - # one in the list. - if [[ ! ${DST[$COUNTDST]} =~ '=[A-Z_]+=' ]];then - # Increment destination counter. - COUNTDST=$(($COUNTDST + 1)) - # The current replacement value doesn't have translation - # marker inside, so skip it and evaluate the next - # replacement value in the list. - continue - fi - - while [[ $COUNTSRC -lt ${#SRC[*]} ]];do - - # Update replacements. - DST[$COUNTDST]=$(echo ${DST[$COUNTDST]} \ - | sed -r "s!${SRC[$COUNTSRC]}!${DST[$COUNTSRC]}!g") - - # Increment source counter. - COUNTSRC=$(($COUNTSRC + 1)) - - done - - # Reset source counter - COUNTSRC=0 - - # Increment destination counter. - COUNTDST=$(($COUNTDST + 1)) - - done - - # Apply replacements for translation markers. - while [[ ${COUNT} -lt ${#SRC[*]} ]];do - - # Use sed to replace translation markers inside the design - # model instance. - sed -r -i "s!${SRC[$COUNT]}!${DST[$COUNT]}!g" ${LOCATION} - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - - # Unset specific translation markers and specific replacement - # variables in order to clean them up. Otherwise, undesired values - # may ramain from one file to another. - unset SRC - unset DST - -} diff --git a/Scripts/Bash/Cli/Functions/cli_syncroRepoChanges.sh b/Scripts/Bash/Cli/Functions/cli_syncroRepoChanges.sh deleted file mode 100644 index c3697ea..0000000 --- a/Scripts/Bash/Cli/Functions/cli_syncroRepoChanges.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# cli_syncroRepoChanges.sh -- This function syncronizes both central -# repository and working copy performing a subversion update command -# first and a subversion commit command later. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_syncroRepoChanges { - - # Verify don't commit changes flag. - if [[ $FLAG_DONT_COMMIT_CHANGES != 'false' ]];then - return - fi - - # Define source location the subversion update action will take - # place on. If arguments are provided use them as srouce location. - # Otherwise use action value as default source location. - if [[ "$@" != '' ]];then - LOCATIONS="$@" - else - LOCATIONS="$ACTIONVAL" - fi - - # Bring changes from the repository into the working copy. - cli_updateRepoChanges "$LOCATIONS" - - # Check changes in the working copy. - cli_commitRepoChanges "$LOCATIONS" - -} diff --git a/Scripts/Bash/Cli/Functions/cli_updateRepoChanges.sh b/Scripts/Bash/Cli/Functions/cli_updateRepoChanges.sh deleted file mode 100644 index 3c037e0..0000000 --- a/Scripts/Bash/Cli/Functions/cli_updateRepoChanges.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -# -# cli_updateRepoChanges.sh -- This function realizes a subversion -# update command against the working copy in order to bring changes -# from the central repository into the working copy. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_updateRepoChanges { - - # Verify don't commit changes flag. - if [[ $FLAG_DONT_COMMIT_CHANGES != 'false' ]];then - return - fi - - local -a FILES - local -a INFO - local -a FILESNUM - local COUNT=0 - local UPDATEOUT='' - local PREDICATE='' - local CHNGTOTAL=0 - local LOCATIONS='' - - # Define source location the subversion update action will take - # place on. If arguments are provided use them as srouce location. - # Otherwise use action value as default source location. - if [[ "$@" != '' ]];then - LOCATIONS="$@" - else - LOCATIONS="$ACTIONVAL" - fi - - # Verify locations existence. It shoud exist as regular file or - # directory inside the repository working copy. - cli_checkFiles "$LOCATIONS" 'fd' - cli_checkFiles "$LOCATIONS" 'isInWorkingCopy' - - # Outout separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Update working copy and retrive update output. - cli_printMessage "`gettext "Bringing changes from the repository into the working copy"`" 'AsResponseLine' - UPDATEOUT=$(svn update ${LOCATIONS}) - - # Outout separator line. - cli_printMessage '-' 'AsSeparatorLine' - - # Define path of files considered recent modifications from - # central repository to working copy. - FILES[0]=$(echo "$UPDATEOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[1]=$(echo "$UPDATEOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[2]=$(echo "$UPDATEOUT" | egrep "^U.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[3]=$(echo "$UPDATEOUT" | egrep "^C.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - FILES[4]=$(echo "$UPDATEOUT" | egrep "^G.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,") - - # Define description of files considered recent modifications from - # central repository to working copy. - INFO[0]="`gettext "Added"`" - INFO[1]="`gettext "Deleted"`" - INFO[2]="`gettext "Updated"`" - INFO[3]="`gettext "Conflicted"`" - INFO[4]="`gettext "Merged"`" - - while [[ $COUNT -ne ${#FILES[*]} ]];do - - # Define total number of files. Avoid counting empty line. - if [[ "${FILES[$COUNT]}" == '' ]];then - FILESNUM[$COUNT]=0 - else - FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l) - fi - - # Calculate total amount of changes. - CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]})) - - # Build report predicate. Use report predicate to show any - # information specific to the number of files found. For - # example, you can use this section to show warning messages, - # notes, and so on. By default we use the word `file' or - # `files' at ngettext's consideration followed by change - # direction. - PREDICATE[$COUNT]=`ngettext "file from the repository" \ - "files from the repository" $((${FILESNUM[$COUNT]} + 1))` - - # Output report line. - cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" 'AsRegularLine' - - # Increase counter. - COUNT=$(($COUNT + 1)) - - done - -} - diff --git a/Scripts/Bash/Cli/Styles/output_forTwoColumns.awk b/Scripts/Bash/Cli/Styles/output_forTwoColumns.awk deleted file mode 100644 index 208e3dc..0000000 --- a/Scripts/Bash/Cli/Styles/output_forTwoColumns.awk +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/gawk -# -# output_forRendering.awk -- This file provides the output format for -# all rendering actions inside centos-art.sh script. -# -# Copyright (C) 2009-2010 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -BEGIN { FS=": " } - -{ - if ( $0 ~ /^-+$/ ) - print $0 - else - printf "%-15s\t%s\n", $1, $2 - -} - -END {} diff --git a/Scripts/Bash/Cli/Styles/renameFile.sh b/Scripts/Bash/Cli/Styles/renameFile.sh deleted file mode 100755 index 372db1e..0000000 --- a/Scripts/Bash/Cli/Styles/renameFile.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# -# renameFiles.sh -- Rename files names, inside svn repository, -# massively. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - - -if [ ! $# = 4 ];then - cli_printMessage "`gettext "Syntax: ./update-filenames.sh "`" - exit; -fi - -ROOTDIR="$1" -FILTER="$2" -PATTERN="$3" -VALUE="$4" - -for FILE in `find $ROOTDIR -regex $FILTER`;do - DIR=`dirname $FILE` - FILE=`basename $FILE` - svn mv $DIR/$FILE $DIR/`echo $FILE | sed -r "s!$PATTERN!$VALUE!"` -done diff --git a/Scripts/Bash/Cli/init.sh b/Scripts/Bash/Cli/init.sh deleted file mode 100755 index b1103c7..0000000 --- a/Scripts/Bash/Cli/init.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# -# init.sh -- This file is the centos-art initialization script, the -# first script the centos-art command executes. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -# Most paths are built from HOME variable on, so we need to make our -# best to make it contain a valid value before any path be built from -# it. Using HOME variable gives us some flexibility to store the -# repository filesystem in a location different from `/home/centos', -# the default home directory centos-art assumes if HOME variable is -# empty or malformed. -[[ ! $HOME =~ '^/home/[[:alnum:]]+' ]] && HOME='/home/centos' - -# Initialize personal information. -export CLI_PROGRAM='centos-art' -export CLI_VERSION='1.0 (beta)' -export CLI_BASEDIR="${HOME}/artwork/trunk/Scripts/Bash/Cli" - -# Initizalize internazionalization through gettext. -. gettext.sh -export TEXTDOMAIN=${CLI_PROGRAM}.sh -export TEXTDOMAINDIR=${HOME}/artwork/trunk/Locales/Scripts/Bash/Cli - -# Initialize common function scripts. -FILES=$(ls ${CLI_BASEDIR}/Functions/{cli,cli_*}.sh) -for FILE in ${FILES};do - if [[ -x ${FILE} ]];then - . ${FILE} - FUNCTION=$(grep '^function ' ${FILE} | cut -d' ' -f2) - export -f ${FUNCTION} - else - echo `gettext "The ${FILE} needs to have execution rights."` > /dev/stderr - exit - fi -done - -# Unset all variables not considered global in order to start cli -# execution with a clean environment. -unset FILE -unset FILES -unset FUNCTION - -# Initialize command-line interface. -cli "$@" diff --git a/Scripts/Python/centos-art/framework.py b/Scripts/Python/centos-art/framework.py deleted file mode 100755 index 92e512a..0000000 --- a/Scripts/Python/centos-art/framework.py +++ /dev/null @@ -1,90 +0,0 @@ -# framework - The CentOS Artwork Repository framework structure. -# -# Copyright (C) 2009-2010 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -#------------------------------------------------------------ -# $Id: framework.py 6045 2010-07-13 08:11:03Z al $ -#----------------------------------------------------------- -""" -The CentOS Artwork Repository framework structure. - -""" - -import string -import os -import re - -from repository import Repo - -class Framework: - """ - This structure provides attributes and methods needed by CentOS - artwork repository framework structures. - """ - - def __init__(self): - self.fw = {} - - def find(self,id): - """ - Return a dictionary object containing information about - frameworks. This function explores the repository structure - looking for framework directories. Framework directories are - defined as regular directories containing at least the - subdirectory `tpl/' in its first level. - """ - repo = Repo() - rootdir = str(repo.abspath + repo.workline[0]) - template = re.compile('^.*/tpl/?$') - for root, dirs, files in os.walk(rootdir): - if id in root and template.match(root): - print root - #pathid = self.getPathId(root) - #self.fw[pathid] = self.add(pathid) - - def getPathId(self, path): - """ - Return the framework's path id by cleaning up its string path. - """ - # Remove absolute path and workline from string path. - # Remove theme directory from string path. - # Remove template directory from string path. - pass - - def add(self, pathid): - """ - Return the framework's templates, translations and manuals paths. - """ - templates = str('trunk/' + pathid + '/tpl') - translations = str('trunk/Translations/' + pathid) - manuals = str('trunk/Manuals/' + pathid) - return (templates, translations, manuals) - - def list(self, id): - """ - Print available frameworks and its paths. - """ - self.find(id) - for k, v in self.fw.iteritems(): - pathid = k - templates, translations, manuals = v - print '%12s: %s' % ('Id', pathid) - print '%12s: %s' % ('Templates', templates) - print '%12s: %s' % ('Translations', translations) - print '%12s: %s' % ('Manuals', manuals) - print '-'*66 diff --git a/Scripts/Python/centos-art/init.py b/Scripts/Python/centos-art/init.py deleted file mode 100755 index 744776e..0000000 --- a/Scripts/Python/centos-art/init.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python -# -# centos-art-cli.py - The CentOS Artwork Repository ToolBox (art) -# command line interface. -# -# Copyright (C) 2009-2010 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -#------------------------------------------------------------ -# $Id: centos-art.py 6245 2010-08-12 14:44:19Z al $ -#----------------------------------------------------------- -""" -The CentOS Artwork Repository Toolbox (art) command line interface. - -This script provides a command line interface (cli) to operate local -working copies of CentOS Artwork Repository. Most of the actions this -script can perform relay on CentOS Artwork Repository files and -directories standard structure. The CentOS Artwork Repository standard -structure is described inside the `Repo' class as docstrings. The -`Repo' class is available in the repository.py file. - -In order to make this script available along CentOS Artwork Repository -you need create a link to the file art-cli.py inside /home/centos/bin/ -directory. For example: - - $ mkdir /home/centos/bin/ - $ cd /home/centos/bin/ - $ ln -s /home/centos/artwork/trunk/Scripts/Python/centos-art-cli.py centos-art - -Note that we used the `centos' lower-case word as username. This is a -convention[1] that let us create a common absolute path for people to -store the CentOS Artwork Repository working copy. - - [1:] Absolute paths are used Inkscape to import raster images - inside SVG files--well, to link them really. If everyone - downloading a working copy of CentOS Artwork Repository uses its - one absolute path there is no way to garantee that all images - imported inside SVG design templates will be displayed correctly - in all downloaded working copies. That is because, there is no way - to garantee that everyone's working copy is placed in the same - absolute path the raster image was imported the first time. So the - absolute path name convenction is needed. - -The centos-art-cli.py script let you to: - - * Render images and texts using common design models and - translations. - - * Navigate the repository structure. - - * Get information about repository structures. - - * Test themes. - -""" - -#from repository import Repo -from framework import Framework - -def main(): - fw = Framework() - fw.list('Brands') - -if __name__ == '__main__': main() diff --git a/Scripts/Python/centos-art/repository.py b/Scripts/Python/centos-art/repository.py deleted file mode 100755 index de71d4e..0000000 --- a/Scripts/Python/centos-art/repository.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (C) 2009-2010 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -#------------------------------------------------------------ -# $Id: repository.py 6036 2010-07-09 21:20:27Z al $ -#----------------------------------------------------------- -""" -The CentOS Artwork Repository. - -The CentOS Artwork Repository is a subversion-based file structure -organized to produce the CentOS project's corporate visual identity. -The CentOS Project corporate visual identity is the ``persona'' of the -organization known as The CentOS Project. - -The CentOS Project corporate visual identity plays a significant role -in the way the CentOS Project, as organization, presents itself to -both internal and external stakeholders. In general terms, the CentOS -Project corporate visual identity expresses the values and ambitions -of the CentOS Project organization, its business, and its -characteristics. The CentOS Project corporate visual identity -provides visibility, recognizability, reputation, structure and -identification to the CentOS Project organization by means of -corporate design, corporate communication, and corporate behaviour. - -The CentOS Project settles down its corporate visual identity on a -``monolithic corporate visual identity structure''. In this structure -The CentOS Project uses one unique name and one unique visual style in -all its manifestations. - -Inside CentOS Artwork Repository, visual manifestations are organized -in the categories: distributions, websites, and promotion. - -Inside CentOS Artwork Repository, corporate visual identity is -oraganized in the work lines: graphic-design, translations, and -programming (scripts). Each work line is a group of people that, based -on standard patterns, can work indepently and coordinated one another. - -In the structure just mentioned, graphic designers provide the design -models and visual styles (motifs) needed to cover each each visual -manifestation; translators create the language-specific contents; and -programmers gear everything together in order to produce specific -design models on various visual styles, languages, and major releases, -automatically. -""" - -class Repo: - """ - This class provides attributes and methods needed to implement the - base repository structure. - """ - - def __init__(self): - # Define repository's working copy absolute path. - self.abspath = '/home/centos/artwork/' - # Define repository's working line. - self.workline = ('trunk/', 'branches/', 'tags/') diff --git a/Styles/output_forTwoColumns.awk b/Styles/output_forTwoColumns.awk new file mode 100644 index 0000000..208e3dc --- /dev/null +++ b/Styles/output_forTwoColumns.awk @@ -0,0 +1,37 @@ +#!/usr/bin/gawk +# +# output_forRendering.awk -- This file provides the output format for +# all rendering actions inside centos-art.sh script. +# +# Copyright (C) 2009-2010 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +BEGIN { FS=": " } + +{ + if ( $0 ~ /^-+$/ ) + print $0 + else + printf "%-15s\t%s\n", $1, $2 + +} + +END {} diff --git a/Styles/renameFile.sh b/Styles/renameFile.sh new file mode 100755 index 0000000..372db1e --- /dev/null +++ b/Styles/renameFile.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# renameFiles.sh -- Rename files names, inside svn repository, +# massively. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + + +if [ ! $# = 4 ];then + cli_printMessage "`gettext "Syntax: ./update-filenames.sh "`" + exit; +fi + +ROOTDIR="$1" +FILTER="$2" +PATTERN="$3" +VALUE="$4" + +for FILE in `find $ROOTDIR -regex $FILTER`;do + DIR=`dirname $FILE` + FILE=`basename $FILE` + svn mv $DIR/$FILE $DIR/`echo $FILE | sed -r "s!$PATTERN!$VALUE!"` +done diff --git a/centos-art.sh b/centos-art.sh new file mode 100755 index 0000000..b1103c7 --- /dev/null +++ b/centos-art.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# init.sh -- This file is the centos-art initialization script, the +# first script the centos-art command executes. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +# Most paths are built from HOME variable on, so we need to make our +# best to make it contain a valid value before any path be built from +# it. Using HOME variable gives us some flexibility to store the +# repository filesystem in a location different from `/home/centos', +# the default home directory centos-art assumes if HOME variable is +# empty or malformed. +[[ ! $HOME =~ '^/home/[[:alnum:]]+' ]] && HOME='/home/centos' + +# Initialize personal information. +export CLI_PROGRAM='centos-art' +export CLI_VERSION='1.0 (beta)' +export CLI_BASEDIR="${HOME}/artwork/trunk/Scripts/Bash/Cli" + +# Initizalize internazionalization through gettext. +. gettext.sh +export TEXTDOMAIN=${CLI_PROGRAM}.sh +export TEXTDOMAINDIR=${HOME}/artwork/trunk/Locales/Scripts/Bash/Cli + +# Initialize common function scripts. +FILES=$(ls ${CLI_BASEDIR}/Functions/{cli,cli_*}.sh) +for FILE in ${FILES};do + if [[ -x ${FILE} ]];then + . ${FILE} + FUNCTION=$(grep '^function ' ${FILE} | cut -d' ' -f2) + export -f ${FUNCTION} + else + echo `gettext "The ${FILE} needs to have execution rights."` > /dev/stderr + exit + fi +done + +# Unset all variables not considered global in order to start cli +# execution with a clean environment. +unset FILE +unset FILES +unset FUNCTION + +# Initialize command-line interface. +cli "$@"