#! /bin/bash #---------------------------------------------------------------------------- # get-path-to-package.sh - this function detects the real path to a given # package on the repository # # Creation : 2007-12-20 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. #---------------------------------------------------------------------------- # ============================================================================= # Determining the path from which the package should be created. # This depends on the package state to create, so a stable and testing comes # out of the trunk, a bugfix comes out of branches and a tag'ed version comes # out of tags. getPathToPackage () { echo -n "Determining path to the package '${package}': " # ----------------------------------------------- # Check the path to the package to create. # This depends on the state of package to create. if ${setBugfix} then # ------------------------------------------------------- # A version out of the bugfix branches should be created. # So set this as the folder to use in the next steps. if ${versionToSetGiven} then local idx=0 local actualFolder # ------------------------------------------------------------- # Loop over all directories on the bugfix branch of the package # and detect folders which names start with # '${givenMajor}.${givenMinor}.x_${targetToBuild}' for actualFolder in `ls -l --full-time ${baseDir}/${branchesDir}/${section}/${packageFolder}/ | grep -E "^d" | tr -s [[:blank:]] | cut -d " " -f9 | grep -E "^${givenMajor}.${givenMinor}.x_${targetToBuild}"` do myecho "Actual Folder: ${actualFolder}" idx=$((idx+1)) done # --------------------------------- # There must be exactly one folder! if [ ${idx} -eq 0 ] then echo "" echo -n "!!! The folder '${givenMajor}.${givenMinor}.x_${targetToBuild}' with the requested version " echo -n "'${givenVersion}' is not existing in the repository. Seems to be that there is no bugfix " echo -n "branch for this release of package '${package}' or you have not checked out the bugfix " echo "branch. Aborting." return ${FOLDER_NOT_FOUND} elif [ ${idx} -eq 1 ] then pathToPackage=${baseDir}/${branchesDir}/${section}/${packageFolder}/${actualFolder} else echo "" echo -n "!!! There are more than one folder '${givenMajor}.${givenMinor}.x' with the requested target " echo -n "number existing in the repository. Seems to be that there is another bugfix branch for " echo "this release of package '${package}'. Aborting." return ${FOLDER_NOT_FOUND} fi else # ---------------------------------- # At first search the latest version myecho "" myecho "Invoking findLatestVersion ${baseDir}/${branchesDir}/${section}/${packageFolder} ${findLatestParam}" findLatestVersion ${baseDir}/${branchesDir}/${section}/${packageFolder} ${findLatestParam} myecho "Result from findLatestVersion():" myecho "latestStable: ${latestStable}" myecho "latestTesting: ${latestTesting}" if [ -z "${latestStable}" ] then echo "" echo -n "!!! There is no bugfix branch existing for package ${package}. " echo "Possibly you have to check it out first. Aborting." return ${FOLDER_NOT_FOUND} else givenMajor=`echo ${latestStable} | cut -d "." -f1` givenMinor=`echo ${latestStable} | cut -d "." -f2` pathToPackage=${baseDir}/${branchesDir}/${section}/${packageFolder}/${latestStable} fi fi elif ${setTaged} then # --------------------------------------------------------------- # A version out of the tags should be created, so set this as the # folder to use in the next steps. if ${versionToSetGiven} then local idx=0 local actualFolder # ------------------------------------------------------------- # Loop over all directories on the bugfix branch of the package # and detect folders which names start with # '${givenMajor}.${givenMinor}.${givenBugfix}_${targetToBuild}' for actualFolder in `ls -l --full-time ${baseDir}/${tagsDir}/${section}/${packageFolder}/ | grep -E "^d" | tr -s [[:blank:]] | cut -d " " -f9 | grep -E "^${givenMajor}.${givenMinor}.${givenBugfix}_${targetToBuild}"` do myecho "Actual Folder: ${actualFolder}" idx=$((idx+1)) done # --------------------------------- # There must be exactly one folder! if [ ${idx} -eq 0 ] then echo "" echo "!!! The folder '${givenMajor}.${givenMinor}.${givenBugfix}_${targetToBuild}' with the \ requested version '${givenVersion}' is not existing in the repository. Seems to be that \ there is no bugfix branch for this release of package '${package}' or you have not \ checked out the bugfix branch. Aborting." return ${FOLDER_NOT_FOUND} elif [ ${idx} -eq 1 ] then pathToPackage=${baseDir}/${tagsDir}/${section}/${package}/${actualFolder} else echo "" echo "!!! There are more than one folder '${givenMajor}.${givenMinor}.x' with the requested target \ number existing in the repository. Seems to be that there is another bugfix branch for \ this release of package '${package}'. Aborting." return ${FOLDER_NOT_FOUND} fi else # ---------------------------------- # At first search the latest version myecho "" myecho "Invoking findLatestVersion ${baseDir}/${tagsDir}/${section}/${package} ${findLatestParam}" findLatestVersion ${baseDir}/${tagsDir}/${section}/${package} ${findLatestParam} myecho "Result from findLatestVersion():" myecho "latestStable: ${latestStable}" myecho "latestTesting: ${latestTesting}" if [ -z "${latestStable}" ] then echo "" echo -n "!!! There is no stable tag existing for package ${package}. Aborting." return ${FOLDER_NOT_FOUND} else givenMajor=`echo ${latestStable} | cut -d "." -f1` givenMinor=`echo ${latestStable} | cut -d "." -f2` givenBugfix=`echo ${latestStable} | cut -d "." -f3` pathToPackage=${baseDir}/${tagsDir}/${section}/${package}/${latestStable} fi fi else # ------------------------------------------------------------- # No type of package given, so try the package out of the trunk # ----------------------------------------------- # We have to create a stable or a testing version # both came out of the trunk pathToPackage=${baseDir}/${trunkDir}/${section}/${packageFolder} fi echo "Using path '${pathToPackage}'" return 0 }