I want the build to work with either centos-repo or cgcs-centos-repo. In many places we will be testing for the existance centos-repo as the prefered path, then fall back to cgcs-centos-repo as an alternative. If neither are present, either exit or continue but assuming the new path is intended. NOTE: The patch_rebase_1/2/3/4 scripts remain broken, but I hope to salvage them one day. The current coding assumes content under centos-repo/cgcs-centos-repo is managed by a git, which is not currently true. Story: 2006387 Task: 36912 Change-Id: I8f694814c41957c5b37eb2e64b653b7d42f2e2c9 Signed-off-by: Scott Little <scott.little@windriver.com>
		
			
				
	
	
		
			159 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			159 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash
 | 
						|
 | 
						|
#
 | 
						|
# Update srpm_path for packages to be upgraded
 | 
						|
#
 | 
						|
 | 
						|
# For backward compatibility.  Old repo location or new?
 | 
						|
CENTOS_REPO=${MY_REPO}/centos-repo
 | 
						|
if [ ! -d ${CENTOS_REPO} ]; then
 | 
						|
    CENTOS_REPO=${MY_REPO}/cgcs-centos-repo
 | 
						|
    if [ ! -d ${CENTOS_REPO} ]; then
 | 
						|
        echo "ERROR: directory ${MY_REPO}/centos-repo not found."
 | 
						|
        exit 1
 | 
						|
    fi
 | 
						|
fi
 | 
						|
 | 
						|
usage () {
 | 
						|
    echo ""
 | 
						|
    echo "Step 2: Update srpm_path for packages to be upgraded"
 | 
						|
    echo ""
 | 
						|
    echo "Usage: "
 | 
						|
    echo "   patch_rebase_2 [--origin_branch <branch>] [--working_branch <branch>] [--upversion_data <file>]"
 | 
						|
    echo ""
 | 
						|
    echo "Assumes $(basename ${CENTOS_REPO}) already has a working_branch commit that sets the new symlinks."
 | 
						|
    echo ""
 | 
						|
    echo "The upversion_data file has data on all the src.rpm being updated in the format:"
 | 
						|
    echo "  export UPVERSION_DATA=$MY_WORKSPACE/upversion.log"
 | 
						|
    echo "  PKG=lighttpd"
 | 
						|
    echo "  OLD_SRC_RPM=lighttpd-1.4.41-1.el7.src.rpm"
 | 
						|
    echo "  NEW_SRC_RPM=lighttpd-1.4.41-2.el7.src.rpm"
 | 
						|
    echo "  SRPM_PATH=$MY_REPO/stx/integ/extended/lighttpd/centos/srpm_path"
 | 
						|
    echo "  echo \"\$PKG#\$SRPM_PATH##\$OLD_SRC_RPM#\$NEW_SRC_RPM\" > UPVERSION_DATA"
 | 
						|
    echo ""
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
TEMP=`getopt -o h --long origin_branch:,working_branch:,upversion_data:,help -n 'test.sh' -- "$@"`
 | 
						|
eval set -- "$TEMP"
 | 
						|
 | 
						|
ORIGIN_BRANCH=""
 | 
						|
WORKING_BRANCH=""
 | 
						|
UPVERSION_LOG=""
 | 
						|
HELP=0
 | 
						|
 | 
						|
while true ; do
 | 
						|
    case "$1" in
 | 
						|
        --origin_branch)  shift ; ORIGIN_BRANCH="$1" ; shift ;;
 | 
						|
        --working_branch) shift ; WORKING_BRANCH="$1" ; shift ;;
 | 
						|
        --upversion_data) shift ; UPVERSION_LOG="$1" ; shift ;;
 | 
						|
        -h|--help)        HELP=1 ; shift ;;
 | 
						|
        --)               shift ; break ;;
 | 
						|
        *)                usage; exit 1 ;;
 | 
						|
    esac
 | 
						|
done
 | 
						|
 | 
						|
if [ $HELP -eq 1 ]; then
 | 
						|
    usage
 | 
						|
    exit 0
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$UPVERSION_LOG" == "" ]; then
 | 
						|
   UPVERSION_LOG=$UPVERSION_DATA
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$UPVERSION_LOG" == "" ]; then
 | 
						|
   echo "ERROR: please specify location of upversion data"
 | 
						|
   usage
 | 
						|
   exit 1
 | 
						|
fi
 | 
						|
 | 
						|
if [ ! -f "$UPVERSION_LOG" ]; then
 | 
						|
   echo "File not found: '$UPVERSION_LOG'"
 | 
						|
   exit 1
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$ORIGIN_BRANCH" == "" ] && [ "$WORKING_BRANCH" == "" ]; then
 | 
						|
   ORIGIN_BRANCH=$PATCH_SOURCE_BRANCH
 | 
						|
   WORKING_BRANCH=$MY_PATCH_BRANCH
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$ORIGIN_BRANCH" == "" ] && [ "$WORKING_BRANCH" == "" ]; then
 | 
						|
   ORIGIN_BRANCH=$SOURCE_BRANCH
 | 
						|
   WORKING_BRANCH=$MY_BRANCH
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$ORIGIN_BRANCH" == "" ]; then
 | 
						|
   echo "ERROR: please specify a origin branch"
 | 
						|
   usage
 | 
						|
   exit 1
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$WORKING_BRANCH" == "" ]; then
 | 
						|
   echo "ERROR: please specify a working branch"
 | 
						|
   usage
 | 
						|
   exit 1
 | 
						|
fi
 | 
						|
 | 
						|
# One step back to see the old symlinks
 | 
						|
cd $MY_REPO
 | 
						|
 | 
						|
FAILED=""
 | 
						|
for dat in $(cat $UPVERSION_LOG); do
 | 
						|
   name=$(echo $dat | awk -F '#' '{print $1}')
 | 
						|
   srpm_path=$(echo $dat | awk -F '#' '{print $2}')
 | 
						|
   old_src_rpm=$(echo $dat | awk -F '#' '{print $4}')
 | 
						|
   new_src_rpm=$(echo $dat | awk -F '#' '{print $5}')
 | 
						|
 | 
						|
   (
 | 
						|
   cd $(dirname $srpm_path)
 | 
						|
   CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
 | 
						|
   if [ "$CURRENT_BRANCH" != "$WORKING_BRANCH" ]; then
 | 
						|
      git checkout $WORKING_BRANCH
 | 
						|
      if [ $? -ne 0 ]; then
 | 
						|
         git checkout $ORIGIN_BRANCH
 | 
						|
         if [ $? -ne 0 ]; then
 | 
						|
            echo "ERROR: Can't checkout branch '$ORIGIN_BRANCH' in directory '$(pwd)'"
 | 
						|
            exit 1
 | 
						|
         fi
 | 
						|
 | 
						|
         git checkout -b $WORKING_BRANCH
 | 
						|
         if [ $? -ne 0 ]; then
 | 
						|
            echo "ERROR: failed to 'git checkout -b $WORKING_BRANCH' from '$(pwd)'"
 | 
						|
            exit 1
 | 
						|
         else
 | 
						|
            echo "created branch '$WORKING_BRANCH' at '$(pwd)'"
 | 
						|
         fi
 | 
						|
      fi
 | 
						|
   fi
 | 
						|
 | 
						|
   sed -i "s#$old_src_rpm#$new_src_rpm#" $srpm_path
 | 
						|
   if [ $? -ne 0 ]; then
 | 
						|
      echo "ERROR: sed failed '$old_src_rpm' -> '$new_src_rpm'"
 | 
						|
      exit 1
 | 
						|
   else
 | 
						|
      echo "updated $srpm_path: '$old_src_rpm' -> '$new_src_rpm'"
 | 
						|
   fi
 | 
						|
 | 
						|
   exit 0
 | 
						|
   )
 | 
						|
 | 
						|
   if [ $? -ne 0 ]; then
 | 
						|
      echo "ERROR: failed while working on package '$name' at '$srpm_path'"
 | 
						|
      exit 1
 | 
						|
   fi
 | 
						|
done
 | 
						|
 | 
						|
echo ""
 | 
						|
for d in $(for dat in $(cat $UPVERSION_LOG); do srpm_path=$(echo $dat | awk -F '#' '{print $2}'); ( cd $(dirname $srpm_path); git rev-parse --show-toplevel ); done | sort --unique); do
 | 
						|
   (
 | 
						|
    cd $d
 | 
						|
    echo "cd $d"
 | 
						|
    for f in $(git status --porcelain | grep 'srpm_path$' | awk '{print $2}'); do 
 | 
						|
        echo "git add $f";
 | 
						|
    done
 | 
						|
    echo "git commit -m 'srpm_path updates for patch $PATCH_ID'"
 | 
						|
   )
 | 
						|
done
 | 
						|
echo ""
 |