#! /bin/bash #---------------------------------------------------------------------------- # request-params-for-package-creation.sh # # Creation : 2008-08-17 starwarsfan # Last Update: $Id$ # # Copyright (c) 2001-2009 the eisfair team, team(at)eisfair(dot)org> # # 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. #---------------------------------------------------------------------------- # =========================================================================== # Ask for all necessary parameters to call mktarball script requestParamsForPackageCreation () { if [ -z "${choosenPackageToWorkOn}" ] then choosePackageToWorkOn rtc=$? if [ ${rtc} -eq ${EXECUTION_ABORTED_ON_REQUEST} ] then return elif [ ${rtc} -ne 0 ] then echo "Error during package selection." echo "Aborting..." return fi fi packageName=${choosenPackageToWorkOn} local leaveFunction=false # ---------------------------------------------------------------------- # Check if the package is a libdev package. If so, the folder on the # repository is different from the package name. So remove the extension # '-dev' because this package is located on the same folder as the # library itself. ${isLibdevPackage} is set on findSection() # if ${isLibdevPackage} # then packageFolder=`echo "${packageName}" | sed "s/-dev//g"` # else # packageFolder=${packageName} # fi versionNumber='' bugfixBranchCreation='' bugfixBranchCheckout='' mkPackageOutOfTag=false # ------------------------ # Ask for the release type echo "" echo "You want to create a release of package '${packageName}' from section '${sectionName}'" echo "" echo "What type of package do yo want to create?" choice2="A testing release" choice3="A stable release" choice4="A bugfix release" choice5="A package from an existing tag" PS3="Your choice: " select userInput in "${msgAbortOperation}" "${choice2}" "${choice3}" "${choice4}" "${choice5}" do case ${userInput} in "${msgAbortOperation}") leaveFunction=true break ;; "${choice2}") version="--testing" sourceDir=${trunkDir} additionalDir='' break ;; "${choice3}") echo "" echo "Do you want to create a MAJOR or a MINOR stable release? On a MAJOR release" echo "the first number is increased, MINOR and BUGFIX is reset to 0. On a MINOR" echo "release the MAJOR is not modified, the MINOR is set to the next even number" echo "and the BUGFIX is reset to 0." choice3_2="Create a stable MAJOR release" choice3_3="Create a stable MINOR release" PS3="Your choice: " select userInput in "${msgAbortOperation}" "${choice3_2}" "${choice3_3}" do case ${userInput} in "${msgAbortOperation}") leaveFunction=true break 2 ;; "${choice3_2}") version="--stable MAJOR" break ;; "${choice3_3}") version="--stable" break ;; *) echo "Please choose 1, 2 or 3! " ;; esac done sourceDir=${trunkDir} additionalDir='' break ;; "${choice4}") localFolder="${baseDir}/${branchesDir}/${sectionName}/${packageName}" sourceDir=${branchesDir} additionalDir='' echo "" echo "Please choose the bugfix branch to work on by entering its number:" PS3="Your choice: " # ------------------------------------------------------------------ # - Look only at folders, not at files. So 'ls -l' must be used. # '--full-time' is used to get same result on every system. # - Grep for directories # - Trim spaces to exactly one space # - Cut out the last entry --> the directory name # - Exclude '_ADMIN' and 'build' select actualFolder in `ls -l --full-time ${localFolder} | grep -E "^d" | tr -s [[:blank:]] | cut -d " " -f9 | grep -E -v "_ADMIN|build"` do ls -l --full-time ${localFolder} | grep -E "^d" | tr -s [[:blank:]] | cut -d " " -f9 | grep -E -v "_ADMIN|build" | grep "^${actualFolder}$" &> /dev/null if [ $? -eq 0 ] then major=`echo ${actualFolder} | cut -d "." -f1` minor=`echo ${actualFolder} | cut -d "." -f2` version="--bugfix --version ${major}.${minor}" break else echo "Please choose one of the listed entries by entering its number!" fi done additionalDir=${actualFolder} break ;; "${choice5}") localFolder="${baseDir}/${tagsDir}/${sectionName}/${packageName}" sourceDir=${tagsDir} additionalDir='' echo "" echo "Please choose the tag to use by entering its number. If the desired tag is not" echo "in this list, maybe you have to checkout it and try again." PS3="Your choice: " select actualFolder in `ls -l --full-time ${localFolder} | grep -E "^d" | tr -s [[:blank:]] | cut -d " " -f9 | grep -E -v "_ADMIN|build"` do ls -l --full-time ${localFolder} | grep -E "^d" | tr -s [[:blank:]] | cut -d " " -f9 | grep -E -v "_ADMIN|build" | grep "^${actualFolder}$" &> /dev/null if [ $? -eq 0 ] then major=`echo ${actualFolder} | cut -d "." -f1` minor=`echo ${actualFolder} | cut -d "." -f2` bugfix=`echo ${actualFolder} | cut -d "." -f3 | cut -d "_" -f1` version="--tag --version ${major}.${minor}.${bugfix}" targetSystem="--target `echo ${actualFolder} | cut -d "_" -f2`" break else echo "Please choose one of the listed entries by entering its number!" fi done additionalDir=${actualFolder} mkPackageOutOfTag=true break ;; *) echo "Please choose a number between 1 and 5: " ;; esac done # ----------------------------------------------------------- # User requested abort of operation in one of the steps above if ${leaveFunction} then return 0 fi if ! ${mkPackageOutOfTag} then # ----------------------------------------------------------------- # A package out of trunk or bugfix branch should be created, so ask # if a package with the same version number as the last one should # be created. By default this is _not_ used echo "" echo "Do you want to create the package with the same version number" echo "as the last one? Creation of bugfix branch and tag is disabled" echo -n "in that case. y/n/a [y]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'n'|'N'|'no'|'No') versionNumberUpdate='--update-version-number' myecho "The next version number will be used for this package." ;; *) versionNumberUpdate='' myecho "The same version number as for the last package will be used." ;; esac if [ -n "${versionNumberUpdate}" ] then # ----------------------------------------------------------------- # a package out of trunk or bugfix branch should be created, so ask # for additional params echo "" echo -n "Do you want to create a tag for this release? y/n/a [n]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'y'|'Y'|'yes'|'Yes') tagCreation='--create-tag' echo "" echo -n "Do you want to checkout the created tag of this release? y/n/a [n]: " read userInput case ${userInput} in 'y') tagCreation='' tagCheckout='--checkout-tag' ;; *) tagCheckout='' ;; esac # -------------------------------------------------------------------- # if the version to create is a stable, then ask for the bugfix branch if [ "${version}" == "--stable" -o "${version}" == "--stable MAJOR" ] then echo "" echo -n "Do you want to create the bugfix branch for this release? y/n/a [y]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'n'|'N'|'no'|'No') bugfixBranchCreation='' bugfixBranchCheckout='' ;; *) echo -n "Do you want to checkout the created bugfix branch of this release? y/n/a [y]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'n'|'N'|'no'|'No') bugfixBranchCreation='--create-bugfixbranch' bugfixBranchCheckout='' ;; *) # ----------------------------------------- # nothing to do because this is the default bugfixBranchCreation='' bugfixBranchCheckout='--checkout-bugfixbranch' ;; esac ;; esac fi ;; *) tagCheckout='' tagCreation='' ;; esac fi # ---------------------------------- # Ask for the target number to build requestBuildTarget release rtc=$? if [ ${rtc} -ne 0 ] then echo "" echo " Returned error number: ${rtc}" echo " Error description: ${returnCode[${rtc}]}" echo "" echo "Press return to continue" read a return fi else # ------------------------------------------------------------ # we create a package out of a tag, so disable the other steps tagCreation='' tagCheckout='' bugfixBranchCreation='' bugfixBranchCheckout='' fi # -------------------------------------------------------------------------- # If this is a lib package, ask if the libdev package should be created too. if [ "${sectionName}" == "lib" -a "${isLibdevPackage}" == false ] then echo "" echo "You choose to create a lib package and the corresponding libdev package " echo "is build on the same build turn." echo -n "Disable build of libdev package? y/n/a [n]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'y'|'Y'|'yes'|'Yes') withoutLibdevPackage='--without-libdev' myecho "The libdev package will _not_ be created." ;; *) withoutLibdevPackage='' ;; esac elif [ "${sectionName}" == "lib" -a "${isLibdevPackage}" == true ] then echo "" echo "You choose to create a libdev package. If you want to create it together with" echo "the appropriate lib package, then you must break the actual step and create" echo "the lib package first. There you can choose to create it together with the" echo "libdev package." echo "Break here or continue with creation of libdev package? " echo -n "[c] c(ontinue)/b(reak): " read userInput case ${userInput} in 'b') return ;; *) ;; esac fi # ----------------------- # Ask for the date to use date='' touch='' echo "" echo "Which date do you want to use for the tag inside of the package" echo "info file? If you choose 'now' then the actual timestamp will be used for" echo "touching the files. On the other cases you will be asked for this later." actualDate=`date +'%Y-%m-%d'` choice2="Now (with extension 'svn' right after the version number)" choice3="Now" choice4="Keep" choice5="Enter by hand" PS3="Your choice: " select userInput in "${msgAbortOperation}" "${choice2}" "${choice3}" "${choice4}" "${choice5}" do case ${userInput} in "${msgAbortOperation}") leaveFunction=true break ;; "${choice2}") date="--date svn" break ;; "${choice3}") date="--date ${actualDate}" touch="--touch `date +'%Y%m%d%H%M'`" break ;; "${choice4}") date="--date keep" break ;; "${choice5}") # ----------------------- # Ask for the date to use echo -n "Please enter date in the form YYYY-MM-DD or (a)bort: " while [ true ] do read userInput case ${userInput} in 'a'|'abort' ) leaveFunction=true break 2 ;; # ----------------- # check given value ????-??-?? ) # ------------------ # use the given date date="--date ${userInput}" myecho "Using given date '${userInput}'" break ;; * ) # ------------------- # unknown param given echo -n "Please use the form YYYY-MM-DD: " ;; esac done # --------------------------- # Ask for the touch-timestamp echo "Please enter timestamp for touching the files in the form YYYYMMDDhhmm." echo -n "If you enter nothing, touch wouldn't be used: " read userInput if [ -n "${userInput}" ] then touch="--touch ${userInput}" fi break ;; *) echo -n "Please enter a number from 1 to 4: " ;; esac done # ----------------------------------------------------------- # User requested abort of operation in one of the steps above if ${leaveFunction} then return 0 fi echo "" echo -n "Publish the package on the development eislist? y/n/a [y]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'n'|'N'|'no'|'No') publishDevelopmentVersion='--no-development-version' myecho "The package will _not_ be published on the development eislist." ;; *) publishDevelopmentVersion='' ;; esac echo "" echo -n "Publish the package on the testteam eislist? y/n/a [n]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'y'|'Y'|'yes'|'Yes') publishTestTeamVersion='--test-team-version' myecho "The package will be published on the testteam eislist." ;; *) publishTestTeamVersion='' ;; esac echo "" echo -n "Publish the package on the releases eislist? y/n/a [n]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'y'|'Y'|'yes'|'Yes') publishReleaseVersion='--release-version' myecho "The package will be published on the releases eislist." ;; *) publishReleaseVersion='' ;; esac # -------------------------------------------------------------------- # Commit of changes to the repo ist only on trunk or branches possible if ! ${mkPackageOutOfTag} then echo "" echo -n "Commit the modified files to the repository? y/n/a [n]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'y'|'Y'|'yes'|'Yes') commitToRepository='--commit' myecho "Modified files will be commited to the repository." ;; *) commitToRepository='' ;; esac else commitToRepository='' fi echo "" echo "" echo "=============================================================================" myecho "" myecho "Calling mktarball as follows:" myecho "${scriptMkTarball} ${version} ${tagCreation} ${tagCheckout} ${bugfixBranchCreation} ${bugfixBranchCheckout} ${targetSystem} ${withoutLibdevPackage} ${versionNumberUpdate} ${date} ${touch} ${publishDevelopmentVersion} ${publishTestTeamVersion} ${publishReleaseVersion} ${commitToRepository} ${packageName}" addCommandToHistory ${scriptMkTarball} ${version} ${tagCreation} ${tagCheckout} ${bugfixBranchCreation} ${bugfixBranchCheckout} ${targetSystem} ${withoutLibdevPackage} ${versionNumberUpdate} ${date} ${touch} ${publishDevelopmentVersion} ${publishTestTeamVersion} ${publishReleaseVersion} ${commitToRepository} ${packageName} ${scriptMkTarball} ${version} \ ${tagCreation} \ ${tagCheckout} \ ${bugfixBranchCreation} \ ${bugfixBranchCheckout} \ ${targetSystem} \ ${withoutLibdevPackage} \ ${versionNumberUpdate} \ ${date} \ ${touch} \ ${publishDevelopmentVersion} \ ${publishTestTeamVersion} \ ${publishReleaseVersion} \ ${commitToRepository} \ ${packageName} handleError "${scriptMkTarball}" $? }