From 310adc3795260225a327783882c3430b3cbd41fb Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jan 15 2014 21:21:06 +0000 Subject: Reorganize files related to prepare module. - Previsouly, the word "workplace" was used on function names to identify their purpose. This word differ from variable names which uses the "workdir" name. This update changes function names related to prepare module from "workplace" to "workdir" in order to be consequent in naming both function and variable names. - Add prepare_printUsage function. This function is called when no path is provided as argument in the command-line. - Previously, no verification was performed about the path information entered in the command-line. This update uses the tcar_printPath function to transform the path provided in the command-line into a valid path before using it. - Previously, both .conf.tpl and .conf file were considered as possible configuration files to be used as reference to build the working directory. This brings confusion about what files must be produced as part of the repository (e.g., documentation, localization) and what files shouldn't (e.g., design models). This update changes prepare_getWorkdir and prepare_getWorkdirConf function to retrieve .conf.tpl files only and exclude .conf files. --- diff --git a/Scripts/Modules/Prepare/prepare.sh b/Scripts/Modules/Prepare/prepare.sh index 770a804..d3e97d4 100755 --- a/Scripts/Modules/Prepare/prepare.sh +++ b/Scripts/Modules/Prepare/prepare.sh @@ -23,27 +23,32 @@ # ###################################################################### -# Standardize configuration tasks related to repository's workplace. +# Standardize configuration tasks related to the repository's +# workplace. # # When you install The CentOS Artwork Repository most of its content -# is in source format. In order to produce final content and make the -# connections between the produced components, you need to process the -# source formats somewhere inside your workstation. This module takes -# the first non-option argument passed in the command-line as the -# workplace where you are going to process source formats in your -# workstation. During the preparation process, this module creates the -# workplace directory structure, the workplace connection with The -# CentOS Artwork Repository using symbolic links, and images required -# to brand other images. -# -# This module should be the first module you run in your workstation -# after installing The CentOS Artwork Repository. +# is in source format (e.g., svgz, asciidoc, etc.). In order to +# produce final content and make the connections between the produced +# components, you need to process the source formats somewhere inside +# your workstation. The prepare module takes the first non-option +# argument passed in the command-line as the working directory where +# you are going to process source formats in your workstation. During +# the preparation process, the prepare command creates the directory +# structure, the connection with The CentOS Artwork Repository using +# symbolic links, and images required to brand other images. +# +# prepare must be the first command you run after installing The +# CentOS Artwork Repository in your workstation. function prepare { - prepare_getOptions + if [[ ${TCAR_SCRIPT_ARGUMENT} =~ '^ *$' ]];then + prepare_printUsage + else + prepare_getOptions + fi for TCAR_WORKDIR in ${TCAR_SCRIPT_ARGUMENT};do - prepare_setWorkplace + prepare_setWorkdir done } diff --git a/Scripts/Modules/Prepare/prepare_getWorkdir.sh b/Scripts/Modules/Prepare/prepare_getWorkdir.sh new file mode 100755 index 0000000..55b9d23 --- /dev/null +++ b/Scripts/Modules/Prepare/prepare_getWorkdir.sh @@ -0,0 +1,36 @@ +#!/bin/bash +###################################################################### +# +# tcar - The CentOS Artwork Repository automation tool. +# Copyright © 2014 The CentOS Artwork SIG +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Alain Reguera Delgado +# 39 Street No. 4426 Cienfuegos, Cuba. +# +###################################################################### + +# Transform absolute paths to configuration files inside The CentOS +# Artwork Repository to directory absolute paths inside the workplace. +function prepare_getWorkdir { + + local DIRECTORY=$1 + + echo ${DIRECTORY} \ + | sed -r -e "s!${TCAR_BASEDIR}/Models/!${TCAR_WORKDIR}/!" \ + -e 's!/[a-z]+\.conf\.tpl$!!' + +} diff --git a/Scripts/Modules/Prepare/prepare_getWorkdirConf.sh b/Scripts/Modules/Prepare/prepare_getWorkdirConf.sh new file mode 100755 index 0000000..df98235 --- /dev/null +++ b/Scripts/Modules/Prepare/prepare_getWorkdirConf.sh @@ -0,0 +1,33 @@ +#!/bin/bash +###################################################################### +# +# tcar - The CentOS Artwork Repository automation tool. +# Copyright © 2014 The CentOS Artwork SIG +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Alain Reguera Delgado +# 39 Street No. 4426 Cienfuegos, Cuba. +# +###################################################################### + +# Print configuration files (and their templates) to standard output. +function prepare_getWorkdirConf { + + local DIRECTORY=${1:-${TCAR_BASEDIR}/Models} + + tcar_getFilesList -p '.+\.conf\.tpl$' -t 'f' ${DIRECTORY} + +} diff --git a/Scripts/Modules/Prepare/prepare_getWorkplaceConf.sh b/Scripts/Modules/Prepare/prepare_getWorkplaceConf.sh deleted file mode 100755 index 6ac8bfe..0000000 --- a/Scripts/Modules/Prepare/prepare_getWorkplaceConf.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar - The CentOS Artwork Repository automation tool. -# Copyright © 2014 The CentOS Artwork SIG -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# Alain Reguera Delgado -# 39 Street No. 4426 Cienfuegos, Cuba. -# -###################################################################### - -# Print configuration files (and their templates) to standard output. -function prepare_getWorkplaceConf { - - local DIRECTORY=${1:-${TCAR_BASEDIR}/Models} - - tcar_getFilesList -p '.+\.conf(\.tpl)?$' -t 'f' ${DIRECTORY} - -} diff --git a/Scripts/Modules/Prepare/prepare_getWorkplaceDir.sh b/Scripts/Modules/Prepare/prepare_getWorkplaceDir.sh deleted file mode 100755 index 38be07f..0000000 --- a/Scripts/Modules/Prepare/prepare_getWorkplaceDir.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar - The CentOS Artwork Repository automation tool. -# Copyright © 2014 The CentOS Artwork SIG -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# Alain Reguera Delgado -# 39 Street No. 4426 Cienfuegos, Cuba. -# -###################################################################### - -# Transform absolute paths to configuration files inside The CentOS -# Artwork Repository to directory absolute paths inside the workplace. -function prepare_getWorkplaceDir { - - local DIRECTORY=$1 - - echo ${DIRECTORY} \ - | sed -r -e "s!${TCAR_BASEDIR}/Models/!${TCAR_WORKDIR}/!" \ - -e 's!/[a-z]+\.conf(\.tpl)?$!!' - -} diff --git a/Scripts/Modules/Prepare/prepare_printUsage.sh b/Scripts/Modules/Prepare/prepare_printUsage.sh new file mode 100755 index 0000000..a452b97 --- /dev/null +++ b/Scripts/Modules/Prepare/prepare_printUsage.sh @@ -0,0 +1,36 @@ +#!/bin/bash +###################################################################### +# +# tcar - The CentOS Artwork Repository automation tool. +# Copyright © 2014 The CentOS Artwork SIG +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Alain Reguera Delgado +# 39 Street No. 4426 Cienfuegos, Cuba. +# +###################################################################### + +# Describe options and most frequently used commands related to tcar +# script. +function prepare_printUsage { + + tcar_printMessage "`gettext "Usage"`: tcar prepare [--version] [--help] " --as-stdout-line=5 + tcar_printMessage ": [--debug] [--yes] [--quiet]" --as-stdout-line=5 + echo + + exit 0 + +} diff --git a/Scripts/Modules/Prepare/prepare_setWorkdir.sh b/Scripts/Modules/Prepare/prepare_setWorkdir.sh new file mode 100755 index 0000000..0d0ecde --- /dev/null +++ b/Scripts/Modules/Prepare/prepare_setWorkdir.sh @@ -0,0 +1,55 @@ +#!/bin/bash +###################################################################### +# +# tcar - The CentOS Artwork Repository automation tool. +# Copyright © 2014 The CentOS Artwork SIG +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Alain Reguera Delgado +# 39 Street No. 4426 Cienfuegos, Cuba. +# +###################################################################### + +# Create the repository's workplace. +function prepare_setWorkdir { + + TCAR_WORKDIR=$(tcar_printPath ${TCAR_WORKDIR}) + + local CONF='' + + if [[ -d ${TCAR_WORKDIR} ]];then + tcar_printMessage "`gettext "The workplace you provided already exist and will be removed."`" --as-stdout-line + tcar_printMessage "`gettext "Do you want to continue?"`" --as-yesornorequest-line + tcar_printMessage "${TCAR_WORKDIR}" --as-deleting-line + rm -r ${TCAR_WORKDIR} + fi + + tcar_printMessage "${TCAR_WORKDIR}" --as-creating-line + + for CONF in $(prepare_getWorkdirConf);do + local TCAR_WORKDIR_DIR=$(prepare_getWorkdir ${CONF}) + local TCAR_WORKDIR_LNK=${TCAR_WORKDIR_DIR}/render.conf + mkdir -p ${TCAR_WORKDIR_DIR} && ln -s ${CONF} ${TCAR_WORKDIR_LNK} + tcar_checkFiles -h ${TCAR_WORKDIR_LNK} + done + + if [[ -d ${TCAR_WORKDIR}/Brands ]];then + tcar_printMessage "`gettext "The workplace doesn't include images for branding other images."`" --as-stdout-line + tcar_printMessage "`gettext "Do you want to render them now?"`" --as-yesornorequest-line + prepare_setRenderEnvironment -o "render-type" -v "svg" ${TCAR_WORKDIR}/Brands + fi + +} diff --git a/Scripts/Modules/Prepare/prepare_setWorkplace.sh b/Scripts/Modules/Prepare/prepare_setWorkplace.sh deleted file mode 100755 index 84e4e1f..0000000 --- a/Scripts/Modules/Prepare/prepare_setWorkplace.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -###################################################################### -# -# tcar - The CentOS Artwork Repository automation tool. -# Copyright © 2014 The CentOS Artwork SIG -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# Alain Reguera Delgado -# 39 Street No. 4426 Cienfuegos, Cuba. -# -###################################################################### - -# Create the repository's workplace. -function prepare_setWorkplace { - - local CONF='' - - if [[ -d ${TCAR_WORKDIR} ]];then - tcar_printMessage "`gettext "The workplace you provided already exist and will be removed."`" --as-stdout-line - tcar_printMessage "`gettext "Do you want to continue?"`" --as-yesornorequest-line - tcar_printMessage "${TCAR_WORKDIR}" --as-deleting-line - rm -r ${TCAR_WORKDIR} - fi - - tcar_printMessage "${TCAR_WORKDIR}" --as-creating-line - - for CONF in $(prepare_getWorkplaceConf);do - local TCAR_WORKDIR_DIR=$(prepare_getWorkplaceDir ${CONF}) - local TCAR_WORKDIR_LNK=${TCAR_WORKDIR_DIR}/render.conf - mkdir -p ${TCAR_WORKDIR_DIR} && ln -s ${CONF} ${TCAR_WORKDIR_LNK} - tcar_checkFiles -h ${TCAR_WORKDIR_LNK} - done - - if [[ -d ${TCAR_WORKDIR}/Brands ]];then - tcar_printMessage "`gettext "The workplace doesn't include images for branding other images."`" --as-stdout-line - tcar_printMessage "`gettext "Do you want to render them now?"`" --as-yesornorequest-line - prepare_setRenderEnvironment -o "render-type" -v "svg" Brands - fi - -}