#! /bin/bash # ---------------------------------------------------------------------------- # request-params-for-new-package.sh # # Creation : 2008-08-17 starwarsfan # Last Update: $Id$ # # Copyright (c) 2001-2011 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 create-package script requestParamsForNewPackage () { baseDir=$1 sectionFile=$2 local leaveFunction=false echo "" echo "Please choose the number of one of the following sections. The new package " echo "will be created in this section." echo "" # listSections ${baseDir}/${trunkDir}/_ADMIN/${sectionFile} -a -nolibs listSections ${baseDir}/${trunkDir}/_ADMIN/${sectionFile} -a rtc=$? if [ ${rtc} -eq ${EXECUTION_ABORTED_ON_REQUEST} ] then return elif [ ${rtc} -ne 0 ] then echo "Error during extraction of sections out of section file" echo "Aborting..." exit 1 fi echo "" echo -n "Check in the new package structure into the repository? y/n/a [y]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'n'|'N'|'no'|'No') commitToRepository='' ;; *) commitToRepository='--commit' myecho "The package will be commited to the repository." ;; esac echo "" echo -n "Insert the new package into the folder list? y/n/a [y]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'n'|'N'|'no'|'No') setfolderlist='' ;; *) setfolderlist='--update-folderlist' myecho "The package will be inserted into the folder list." ;; esac # ---------------------------------------------------------------------- # This is the loop which reads the list of entered numbers and evaluates # them with the available destination systems. echo "" echo "What is (or which are) the destination system(s) for the new package?" selectionLoop=true while ${selectionLoop} do targetSystems='' unset systemTags # -------------------------------------------------------- # At first create the list of system tags and ask the user # to choose one ore more of them. idx=0 for currentSystemTag in "${msgAbortOperation}" ${knownSystemTags} "All" do systemTags[$idx]=${currentSystemTag} idx=$((idx+1)) echo "${idx}) ${currentSystemTag}" done echo "Please choose one ore more of the" echo -n "given numbers separated by space: " # ------------------------------------------------------- # Now read the userinput and check if he just hits return read userInput if [ "${userInput}" == "" ] then echo "" echo "You entered nothing! Please choose out of the following list." echo "" else # ---------------------------------------------------- # The user entered something. Now evaluate this input. # --------------------------------------------------------------- # Assume everything is ok and the while-loop should not run again selectionLoop=false # ----------------------- # Loop over the userinput for currentPartOfUserInput in ${userInput} do # --------------------------------------------------- # At first check if the current userinput is a number expr ${currentPartOfUserInput} + 0 &> /dev/null if [ $? -lt 3 ] && [ -n "${currentPartOfUserInput}" ] then # ------------------------------- # Userinput is a number, so go on if [ "${currentPartOfUserInput}" == "1" ] then # ------------------------------------- # User choose to abort actual operation myecho "Aborting system tag selection" leaveFunction=true break 2 elif [ "${currentPartOfUserInput}" == ${idx} ] then # -------------------------------------------------- # User wants to create package for all known systems myecho "Creating package for all known system tags" targetSystems=${knownSystemTags} break 2 elif [ ${currentPartOfUserInput} -lt 1 -o ${currentPartOfUserInput} -gt ${idx} ] then echo "" echo "You entered a number which is not in the given range!" echo "" # ------------------ # Restart while-loop selectionLoop=true break else runningNumber=$((currentPartOfUserInput-1)) myecho "User choose '${runningNumber}' which is '${systemTags[$runningNumber]}'" targetSystems="${targetSystems} ${systemTags[$runningNumber]}" fi else # ------------------------------------------ # Userinput is _not_ a number, so once again echo "" echo "You entered something different than one ore more of the given numbers!" echo "" # ------------------ # Restart while-loop selectionLoop=true break fi done fi done # ----------------------------------------------------------- # User requested abort of operation in one of the steps above if ${leaveFunction} then return 0 fi # ------------------------------ # Set section name for admin gui sectionName=${choosenSection} choosenSectionToWorkOn=${choosenSection} echo "" if [ "${choosenSection}" == "lib" -o "${choosenSection}" == "libdev" ] then echo "" echo "You choose the section '${choosenSection}'," echo "so you want to create a lib-package. Because of this the script creates two" echo "separate packages, the plain lib-package on section 'lib' and the libdev-" echo "package on section 'libdev'." echo "" echo "What is the name of the library?" echo "Please enter only the library name, the script generates the full package" echo "name. E. g. if you enter 'apr', the resulting package names are 'libapr'" echo "and 'libapr-dev'." echo "Hit to abort package creation." echo -n "Name of the library: " read libraryName if [ -z "${libraryName}" ] then return 0 fi # --------------------------------------------------------------------- # Set up proper package name by adding "lib" before given package name. # The sed-command removes this string if it is already given. libraryName=lib`echo "${libraryName}" | sed 's#^lib##'` choosenPackageToWorkOn=${libraryName} echo "" echo "What is the exact version number of the library?" echo -n "Please enter in the form '1.2.3' ( to abort): " read libraryVersion if [ -z "${libraryVersion}" ] then return 0 fi echo "" echo "" echo "=============================================================================" myecho "Invoking '${scriptCreateLibPackage} --version ${libraryVersion} ${commitToRepository} ${setfolderlist} ${libraryName} ${targetSystems}'" ${scriptCreateLibPackage} --version ${libraryVersion} ${commitToRepository} ${setfolderlist} ${libraryName} ${targetSystems} handleError "${scriptCreateLibPackage}" $? else echo "The final question: " echo -n "What is the name of the new package ( to abort)? " read packageName if [ -z "${packageName}" ] then return 0 fi choosenPackageToWorkOn=${packageName} echo "" echo "" echo "=============================================================================" myecho "Invoking '${scriptCreatePackage} --section ${choosenSection} ${commitToRepository} ${setfolderlist} ${packageName} ${targetSystems}'" ${scriptCreatePackage} --section ${choosenSection} ${commitToRepository} ${setfolderlist} ${packageName} ${targetSystems} handleError "${scriptCreatePackage}" $? fi }