#! /bin/bash #---------------------------------------------------------------------------- # determine-property-files.sh # # Creation : 2008-01-22 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. #---------------------------------------------------------------------------- #exec 2> /tmp/mktarball-new-trace$$.log #set -x # --------------------------------------------------------------------------- # This function will detect the path to the property files of a package. # Actually these are the files # - _ADMIN/-version.txt - the actual version is stored here # - _ADMIN/-settings.txt - the destination system " " # - _ADMIN/-state.txt - the actual package state # - var/install/packages/ - the package info file # # The function needs at least three parameters: # 1st: The path to the package # 2nd: The package name # 3rd++: Folders to check. These are the entries out of one of the array # values from -global-settings.txt # # As a result the these variables are set: # ${versionFile} - the version file including the full path # ${packageInfoFile} - the package info file including the full path # ${settingsFile} - the settings file including the full path # ${stateFile} - the state file including the full path # # If the version file could not be found, it will be created using the # function createVersionfile() and the global variables ${givenMajor}, # ${givenMinor} and ${givenBugfix}. If they are not set, '0.0.0' is used. # # If one of the other files could not be found, the function returns a error. # # All occouring errors including the speaking description and the package # name are added to the global variable ${failedBuilds} # --------------------------------------------------------------------------- determinePropertyFiles () { # ------------------------------------- # At least two parameters must be given if [ ${#} -lt 3 ] then return ${REQUIRED_PARAMETERS_MISSING} fi myecho "Now inside of function 'determinePropertyFiles ()'..." # ----------------------------------------------------------- # The first parameter is the path to the package, the second # parameter is the package name. These parameters are shifted # for the following while loop. local pathToPackage=$1 shift local package=$1 shift # ------------------------------ # Now loop over the other params idx=1 while [ ${#} -ne 0 ] do local actualFolder=$1 shift myecho "Checking content of base package folder '${actualFolder}'..." if [ ! -d "${pathToPackage}/${actualFolder}" ] then # ------------------------------------------------------- # Actual Folder out of list on settings.txt not found, so # skip build steps for this target failedBuilds="${failedBuilds} ${package} (${FOLDER_NOT_FOUND}: ${actualFolder});" myecho "!!! ${returnCode[$FOLDER_NOT_FOUND]}, skipping this package" return ${FOLDER_NOT_FOUND} fi # ------------------------------------------------------------------- # Determine the different package property files. # The files out of the first folder are used. If more than one folder # is given, then the files out of the second folder will be used. # # If no files are found on the first two folders, then every other # folder is checked for these files until they are found. If the # files are not available the function returns a error. if [ ${idx} -le 2 ] then # ----------------------------------------------------------- # This is the first or the second check loop, which means the # check loop for the first or second folder on the actual # target. Assume we use the files out of these folders. if [ -f "${pathToPackage}/${actualFolder}/_ADMIN/${package}-version.txt" ] then versionFile=${pathToPackage}/${actualFolder}/_ADMIN/${package}-version.txt fi if [ -f "${pathToPackage}/${actualFolder}/_ADMIN/${package}-settings.txt" ] then settingsFile=${pathToPackage}/${actualFolder}/_ADMIN/${package}-settings.txt fi if [ -f "${pathToPackage}/${actualFolder}/_ADMIN/${package}-state.txt" ] then stateFile=${pathToPackage}/${actualFolder}/_ADMIN/${package}-state.txt fi if [ -f "${pathToPackage}/${actualFolder}/var/install/packages/${package}" ] then packageInfoFile=${pathToPackage}/${actualFolder}/var/install/packages/${package} fi # ----------------------------------------------------------- # Remember the path to the folder of the versionfile. This is # used to create a version file if no one can be found in the # folders examined on the 'else' part of this 'if' block versionFilePathForNotExistingVersionFile=${pathToPackage}/${actualFolder}/_ADMIN/${package}-version.txt else # ------------------------------------------------------------ # This is the third or higher check loop on the actual target. # If no files set up till now, try the ones out of the actual # folder. if [ -f "${pathToPackage}/${actualFolder}/_ADMIN/${package}-version.txt" ] && [ -z "${versionFile}" ] then versionFile=${pathToPackage}/${actualFolder}/_ADMIN/${package}-version.txt fi if [ -f "${pathToPackage}/${actualFolder}/_ADMIN/${package}-settings.txt" ] && [ -z "${settingsFile}" ] then settingsFile=${pathToPackage}/${actualFolder}/_ADMIN/${package}-settings.txt fi if [ -f "${pathToPackage}/${actualFolder}/_ADMIN/${package}-state.txt" ] && [ -z "${stateFile}" ] then stateFile=${pathToPackage}/${actualFolder}/_ADMIN/${package}-state.txt fi if [ -f "${pathToPackage}/${actualFolder}/var/install/packages/${package}" ] && [ -z "${packageInfoFile}" ] then packageInfoFile=${pathToPackage}/${actualFolder}/var/install/packages/${package} fi fi idx=`expr ${idx} + 1` # ------------------------ # End of folder check loop done ### ================================================================= ### Part 2: ### 2.2: Check settings, state a.s.o. ### ================================================================= # ------------------------------------------------------- # Check if a version file, settings file, status file and # package info file is available. myecho "Checking package setup files..." if [ ! -f "${settingsFile}" ] then failedBuilds="${failedBuilds} ${package} (${SETTINGS_FILE_NOT_FOUND}: ${actualTargetNumber});" myecho "!!! ${returnCode[$SETTINGS_FILE_NOT_FOUND]}, skipping this package" return ${SETTINGS_FILE_NOT_FOUND} fi if [ ! -f "${stateFile}" ] then failedBuilds="${failedBuilds} ${package} (${STATE_FILE_NOT_FOUND}: ${actualTargetNumber});" myecho "!!! ${returnCode[$STATE_FILE_NOT_FOUND]}, skipping this package" return ${STATE_FILE_NOT_FOUND} fi if [ ! -f "${packageInfoFile}" ] then failedBuilds="${failedBuilds} ${package} (${PACKAGE_INFO_FILE_NOT_FOUND}: ${actualTargetNumber});" myecho "!!! ${returnCode[$PACKAGE_INFO_FILE_NOT_FOUND]}, skipping this package" return ${PACKAGE_INFO_FILE_NOT_FOUND} fi if [ ! -f "${versionFile}" ] then # ------------------- # Create version file myecho "Versionfile is not existing, calling " myecho "'createVersionfile ${versionFilePathForNotExistingVersionFile} ${package} ${givenMajor:=0}.${givenMinor:=0}.${givenBugfix:=0}' to create it." createVersionfile ${versionFilePathForNotExistingVersionFile} ${package} ${givenMajor:=0}.${givenMinor:=0}.${givenBugfix:=0} versionFile=${versionFilePathForNotExistingVersionFile} # failedBuilds="${failedBuilds} ${package} (${VERSION_FILE_NOT_FOUND}: ${actualTargetNumber});" # myecho "!!! ${returnCode[$VERSION_FILE_NOT_FOUND]}, skipping this package" # continue fi myecho "Function 'determinePropertyFiles ()' finished" }