Blame Scripts/Functions/cli_printCopyrightInfo.sh

1971b4
#!/bin/bash
1971b4
#
bb4664
# cli_printCopyrightInfo.sh -- This function standardizes the
bb4664
# copyright information used by centos-art.sh script.
83fca7
#
bb4664
# As far as I understand, the copyright exists to make people create
bb4664
# more.  The copyright gives creators the legal power over their
bb4664
# creations and so the freedom to distribute them under the ethical
bb4664
# terms the creator considers better.  At this moment I don't feel
bb4664
# very confident about this legal affairs and their legal
bb4664
# implications, but I need to decide what copyright information the
bb4664
# centos-art.sh script will print out. So, in that sake, I'll assume
bb4664
# the same copyright information used by The CentOS Wiki
bb4664
# (http://wiki.centos.org/) as reference.
93aaae
#
2d3646
# Copyright (C) 2009, 2010, 2011 The CentOS Project
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
1971b4
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1971b4
# General Public License for more details.
1971b4
#
1971b4
# You should have received a copy of the GNU General Public License
1971b4
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
1971b4
# ----------------------------------------------------------------------
1971b4
# $Id$
1971b4
# ----------------------------------------------------------------------
1971b4
380069
function cli_printCopyrightInfo {
1971b4
bb4664
    # Define short options.
bb4664
    local ARGSL=''
bb4664
bb4664
    # Define long options.
bb4664
    local ARGSL='license,license-url,coyright,copyright-year,copyright-year-last,copyright-year-first,copyright-year-list,copyright-year-range,copyright-holder'
bb4664
bb4664
    # Initialize arguments with an empty value and set it as local
bb4664
    # variable to this function scope.
bb4664
    local ARGUMENTS=''
bb4664
bb4664
    # Redefine ARGUMENTS variable using current positional parameters. 
793c4c
    cli_parseArgumentsReDef "$@"
bb4664
bb4664
    # Redefine ARGUMENTS variable using getopt output.
793c4c
    cli_parseArguments
bb4664
bb4664
    # Redefine positional parameters using ARGUMENTS variable.
bb4664
    eval set -- "$ARGUMENTS"
bb4664
bb4664
    # Look for options passed through positional parameters.
bb4664
    while true; do
bb4664
bb4664
        case "$1" in
bb4664
bb4664
            --license )
bb4664
bb4664
                # Print out the name of the license used by to release
bb4664
                # the content produced by centos-art.sh script, inside
bb4664
                # CentOS Artwork Repository.
bb4664
                echo "Creative Common Attribution-ShareAlike 3.0"
bb4664
                shift 2
bb4664
                break
bb4664
                ;;
bb4664
bb4664
            --license-url )
bb4664
bb4664
                # Print out the url of the license used by to release
bb4664
                # the content produced by centos-art.sh script, inside
bb4664
                # CentOS Artwork Repository.
bb4664
                cli_printUrl --cc-sharealike
bb4664
                shift 2
bb4664
                break
bb4664
                ;;
bb4664
bb4664
            --copyright-year-first )
bb4664
bb4664
                # The former year when I (as part of The CentOS
bb4664
                # Project) started to consolidate The CentOS Project
bb4664
                # Corporate Visual Identity through the CentOS Artwork
bb4664
                # Repository.
bb4664
                echo '2009'
bb4664
                shift 2
bb4664
                break
bb4664
                ;;
bb4664
bb4664
            --copyright-year|--copyright-year-last )
bb4664
bb4664
                # The last year when The CentOS Project stopped
bb4664
                # working in its Corporate Visual Identity through the
bb4664
                # CentOS Artwork Repository. That is something that I
bb4664
                # hope does never happen, so assume the current year
bb4664
                # as last working year.
bb4664
                date +%Y
bb4664
                shift 2
bb4664
                break
bb4664
                ;;
bb4664
bb4664
            --copyright-year-range )
bb4664
bb4664
                local FIRST_YEAR=$(cli_printCopyrightInfo '--copyright-year-first')
bb4664
                local LAST_YEAR=$(cli_printCopyrightInfo '--copyright-year-last')
bb4664
                echo "${FIRST_YEAR}-${LAST_YEAR}"
bb4664
                shift 2
bb4664
                break
bb4664
                ;;
bb4664
bb4664
            --copyright-year-list )
bb4664
bb4664
                local FIRST_YEAR=$(cli_printCopyrightInfo '--copyright-year-first')
bb4664
                local LAST_YEAR=$(cli_printCopyrightInfo '--copyright-year-last')
bb4664
bb4664
                # Define full copyright year string based on first and
bb4664
                # last year.
bb4664
                local FULL_YEAR=$(\
bb4664
                    while [[ ${FIRST_YEAR} -le ${LAST_YEAR} ]];do
bb4664
                        echo -n "${FIRST_YEAR}, "
bb4664
                        FIRST_YEAR=$(($FIRST_YEAR + 1))
bb4664
                    done)
bb4664
bb4664
                # Prepare full copyright year string and print it out. 
bb4664
                echo "${FULL_YEAR}" | sed 's!, *$!!'
bb4664
                shift 2
bb4664
                break
bb4664
                ;;
1d5701
    
bb4664
            --copyright-holder )
1d5701
            
bb4664
                # Output default copyright holder.
bb4664
                echo "The CentOS Project"
bb4664
                shift 2
bb4664
                break
bb4664
                ;;
bb4664
bb4664
            --copyright )
bb4664
bb4664
                local YEAR=$(cli_printCopyrightInfo '--copyright-year-last')
bb4664
                local HOLDER=$(cli_printCopyrightInfo '--copyright-holder')
bb4664
                echo "Copyright © $YEAR $HOLDER"
bb4664
                shift 2
bb4664
                break
bb4664
                ;;
bb4664
bb4664
            -- )
bb4664
                cli_printMessage "`gettext "At least one option is required."`" --as-error-line
bb4664
                shift 1
bb4664
                break
bb4664
                ;;
bb4664
bb4664
        esac
bb4664
bb4664
    done
1971b4
1971b4
}