#! /bin/bash #---------------------------------------------------------------------------- # request-params-for-filelist-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. #---------------------------------------------------------------------------- # =========================================================================== # requestParamsForFileListCreation () { 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} # ---------------------------------------------------------------------- # 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='LATEST' local leaveFunction=false # ------------------------ # Ask for the release type echo "" echo "You want to (re)create the file lists for package '${packageName}' from " echo "section '${sectionName}'." echo "" echo "For which development line do yo want to create the file lists?" choice2="For a stable or testing release, which means the trunk" choice3="For a bugfix release" PS3="Your choice: " select userInput in "${msgAbortOperation}" "${choice2}" "${choice3}" do case ${userInput} in "${msgAbortOperation}") leaveFunction=true break ;; "${choice2}") localFolder="${baseDir}/${trunkDir}/${sectionName}/${packageFolder}" break ;; "${choice3}") localFolder="${baseDir}/${branchesDir}/${sectionName}/${packageFolder}" echo "" echo "Please choose the bugfix branch to work on by entering its number:" 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 localFolder=${localFolder}/${actualFolder} break else echo "Please choose one of the listed entries by entering its number!" fi done break ;; *) echo -n "Please enter a 1 or 2: " ;; esac done # ----------------------------------------------------------- # User requested abort of operation in one of the steps above if ${leaveFunction} then return 0 fi # ------------------------------------------------------ # If it is a lib or a libdev package, a different folder # handling must be used case ${sectionName} in 'lib' ) if $isLibdevPackage then # ----------------------------------------------- # Get only the folder names which contains "-dev" determinedFolders=`ls -l --full-time ${localFolder} | grep -E "^d" | tr -s [[:blank:]] | cut -d " " -f9 | grep -E "*-dev*"` else # -------------------------------------------------- # Get all folders except "_ADMIN", "build" and those # which contains "-dev" determinedFolders=`ls -l --full-time ${localFolder} | grep -E "^d" | tr -s [[:blank:]] | cut -d " " -f9 | grep -E -v "_ADMIN|build|*-dev*"` fi ;; * ) # ------------------------------------------- # Get all folders except "_ADMIN" and "build" determinedFolders=`ls -l --full-time ${localFolder} | grep -E "^d" | tr -s [[:blank:]] | cut -d " " -f9 | grep -E -v "_ADMIN|build"` ;; esac # ---------------------------------------------------------------------- # This is the loop which reads the list of entered numbers and evaluates # them with the available folders. selectionLoop=true while ${selectionLoop} do unset availableFolders unset foldersToUse # ------------------------------------------------ # At first create the list of available folders # and ask the user to choose one ore more of them. idx=0 for currentFolder in "${msgAbortOperation}" ${determinedFolders} "All" do availableFolders[$idx]=${currentFolder} idx=$((idx+1)) echo "${idx}) ${currentFolder}" done echo -n "Please choose one ore more of the 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 idx2=0 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 folder selection" leaveFunction=true break 2 elif [ "${currentPartOfUserInput}" == ${idx} ] then # -------------------------------------------------- # User wants to create package for all known systems myecho "Creating file lists for all folders" idx2=0 for currentFolder in ${determinedFolders} do foldersToUse[$idx2]=${currentFolder} idx2=$((idx2+1)) done 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)) foldersToUse[$idx2]=${availableFolders[$runningNumber]} myecho "User choose '${runningNumber}' which is '${foldersToUse[$idx2]}'" idx2=$((idx2+1)) 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 during folder selection if ${leaveFunction} then return 0 fi commitAfterCreation=false if [ ${idx2} -gt 1 ] then echo "" echo -n "Do you want to commit the created file lists? y/n/a [y]: " read userInput case ${userInput} in 'a'|'A'|'abort'|'Abort') return 0 ;; 'n'|'N'|'no'|'No') commitParam='--no-svn' ;; *) # ---------------------------------------------------------- # There are more than one filelist to create, so commit them # in one commit after creation commitParam='--no-svn' commitAfterCreation=true ;; esac else commitParam='' fi echo "" echo "" echo "=============================================================================" myecho "" folderToCommit='' for currentFolder in ${foldersToUse[@]} do filesToCommit="${filesToCommit} ${localFolder}/${currentFolder}/_ADMIN/${packageName}-files.txt" myecho "Invoking '${scriptCreateList} ${commitParam} -p ${packageName} --path ${localFolder}/${currentFolder}'" addCommandToHistory ${scriptCreateList} ${commitParam} -p ${packageName} --path ${localFolder}/${currentFolder} ${scriptCreateList} ${commitParam} -p ${packageName} --path ${localFolder}/${currentFolder} handleError "${scriptCreateList}" $? done if ${commitAfterCreation} then myecho "Invoking 'svn ci ${filesToCommit} -m \"Automatic commit by ${scriptName}: File list(s) for '${packageName}' created.\"'" svn ci ${filesToCommit} -m "Automatic commit by ${scriptName}: File list(s) for '${packageName}' created." fi }