IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 移动开发 -> 高通拉取代码错误笔记 -> 正文阅读

[移动开发]高通拉取代码错误笔记

1.使用python2 repo init报如下错误:

repo init -u ssh://git@git.codeaurora.org:9222/external/private_LA.QSSI.12.0/la/system/manifest.git -b release -m caf_AU_LINUX_ANDROID_LA.QSSI.12.0.R1.11.00.00.782.007.xml --repo-url=git://codeaurora.org/tools/repo.git --repo-branch=aosp-new/stable

然后再使用python3的环境再执行一次命令:

python3.6 /bin/repo init -u ssh://git@git.codeaurora.org:9222/external/private_LA.QSSI.12.0/la/system/manifest.git -b release -m caf_AU_LINUX_ANDROID_LA.QSSI.12.0.R1.11.00.00.782.007.xml --repo-url=git://codeaurora.org/tools/repo.git --repo-branch=aosp-new/stable

repo init成功,一定要按这个顺序执行,先python2,后python3,如果先python3执行repo init也是会报如下错误:

?

2.修改sync_snap_v2.sh脚本拉取代码报repo init的错误,先按第一步repo init成功后再执行脚本的如下命令:

./sync_snap_v2.sh --workspace_path=/home/SENSETIME/liaokesen/SourceCode/Singapore/QRD8450 --image_type=la --tree_type=la_qssi --prop_opt=chipcode --common_oss_url=ssh://git@git.codeaurora.org:9222 --qssi_oss_manifest_git=external/private_LA.QSSI.12.0/la/system/manifest --qssi_au_tag=AU_LINUX_ANDROID_LA.QSSI.12.0.R1.11.00.00.782.007 --qssi_chipcode_path=/home/SENSETIME/liaokesen/SourceCode/Singapore/SM8450/snapdragon-premium-high-2021-spf-1-0_test_device/LA.QSSI.12.0.r1/LINUX/android /LA.QSSI.12.0.r1-00700-qssi.0-1/HY11_1/LINUX/android/

sync_snap_v2.sh内容:

#!/bin/bash
#Copyright (c) 2021 Qualcomm Technologies, Inc.
#All Rights Reserved.
#Confidential and Proprietary - Qualcomm Technologies, Inc.

#Possible location of sourcecode/prebuilts
#Code/prebuilt bins	Private CAF/CLO	 Public CAF/CLO	 Grease/chipcodeHF 	Chip code
#QSSI SI (OSS)		Yes		 Yes		 NA	 		NA
#QSSI (Prop)		NA		 NA		 Yes	 		Yes
#Vendor SI (OSS)	Yes		 Yes		 NA	 		NA
#Vendor SI(Prop)	NA		 NA		 Yes	 		Yes

#QSSI Tree
#No need to sync vendor sources/prebuilts
#QSSI OSS - can be private/public CAF/CLO
#QSSI prop(sources and prebuilts) - Grease/Chipcode/ChipcodeHF

#Vendor Tree
#Vendor SI OSS - can be private/public CAF/CLO
#Vendor SI prop(Sources/Prebuilts) - Grease/Chipcode/ChipcodeHF
#QSSI OSS - can be private/Public CAF/CLO
#QSSI prop(sources) - Grease/Chipcode/chipcodeHF
#QSSI prop(prebuilts) - NA

#Vendor standalone Tree
#Vendor SI OSS - can be private/public CAF/CLO
#Vendor SI prop(Sources/Prebuilts) - Grease/Chipcode/ChipcodeHF

#Single Tree
#Vendor SI OSS - can be private/public CAF/CLO
#Vendor SI prop(Sources/Prebuilts) - Grease/Chipcode/ChipcodeHF
#QSSI OSS - can be private/Public CAF/CLO
#QSSI prop(sources and prebuilts)- Grease/Chipcode/chipcodeHF

#Manifest Management
#QSSI Tree - single manaifest - no need of any local manifest(init CAF/CLO manifest and Grease/ChipcodeHF manifest in seperate directories)
#Vendor Tree - init Vendor and QSSI SI manifests(Vendor CAF/CLO, Vendor Grease/ChipcodeHF, QSSI CAF/CLO and QSSI Grease/ChipcodeHF) - ignore grease manifest incase of Chipcode
#Single Tree - init Vendor and QSSI SI manifests(Vendor CAF/CLO, Vendor Grease/chipcodeHF, QSSI CAF/CLO and QSSI Grease/ChipcodeHF) - ignore grease manifest incase of Chipcode

#Unsupported combo(expectation is both Vendor SI and QSSI SI prop content is sourced from same(Either grease/ChipcodeHF or Chipcode)
#Vendor prop from Chipcode +  QSSI prop from Grease/ChipcodeHF
#QSSI prop from Chipcode   +  Vendor prop from Grease/ChipcodeHF

set -o errexit  -o pipefail

m1=$1 ;


# Gets a value for a default name and inserts where that name is not
# currently defined.
remove_default() { # name < xml > xml
  local val name=$1 xml=$(cat)

  val=$(echo "$xml" | xmlstarlet sel -t -v "/manifest/default/@$name")
  if [ -n "$val" ]; then
    echo "$xml" | xmlstarlet ed -i "/manifest/*[not(self::remote|@$name)]"\
                                   -t attr -n "$name" -v "$val"
  fi
}

# Gets each default and inserts it where none is currently defined.
# Deletes all the defaults.
remove_defaults() { # < xml > xml
  local xml=$(cat)

  xml=$(echo "$xml" | remove_default "remote")
  xml=$(echo "$xml" | remove_default "revision")
  # xml=$(echo "$xml" | remove_default "sync-j") # doesn't like the '-'

  echo "$xml" | xmlstarlet ed -d "/manifest/default"
}

# Uses the original remote name to lookup and then replaces it with the
# conflict free remote name.
#   You can't insert if it already exists, update instead.
#   Ensure that we update all node types, not just projects.
update_remote() { # orig new < xml > xml
  local orig new

  orig=$1
  new=$2
  xmlstarlet ed -u "/manifest/remote[@name='$orig']/@name" -v "$new"\
                -u "/manifest/*[@remote='$orig']/@remote" -v "$new"
}



usage() {
  echo ""
  echo "USAGE:"
  echo "TBD"
  echo ""
  exit 1
}

qssi_oss_args_check () {

  if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
    return 0
  fi
  if [ "$tree_type" == $KERNEL_TREE_STANDALONE ]; then
    return 0
  fi

  echo "In QSSI OSS param check"

  if [ -z "$qssi_oss_manifest_git" ]; then
    echo "Pls supply QSSI OSS manifest Repo info"
    usage
  fi

  if [ -z "$qssi_oss_url" ]; then
    echo "Pls supply QSSI OSS server url"
    usage
  fi

 return 0
}

kernel_oss_args_check () {

  if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
    return 0
  fi
  if [ "$tree_type" == $QSSI_TREE_STANDALONE ]; then
    return 0
  fi

  echo "In KERNEL.PLATFORM OSS param check"

  if [ -z "$kernel_oss_manifest_git" ]; then
    echo "Pls supply Kernel OSS manifest Repo info"
    usage
  fi

  if [ -z "$kernel_oss_url" ]; then
    echo "Pls supply Kernel OSS server url"
    usage
  fi

 return 0
}

vendor_oss_args_check () {

  echo "In Vendor OSS param check"

  if [ -z "$vendor_oss_manifest_git" ]; then
    echo "Pls supply Vendor OSS manifest Repo info"
    usage
  fi

  if [ -z "$vendor_oss_url" ]; then
    echo "Pls supply Vendor OSS server url"
    usage
  fi

  if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
    return 0
  fi

  if [ -z "$qssi_oss_manifest_git" ]; then
    echo "Pls supply QSSI OSS manifest Repo info"
    usage
  fi

  if [ -z "$qssi_oss_url" ]; then
    echo "Pls supply QSSI OSS server url"
    usage
  fi

  return 0
}

qssi_chipcode_hf_args_check() {

  if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
    return 0
  fi

  if [ "$tree_type" == $KERNEL_TREE_STANDALONE ]; then
    return 0
  fi

  echo "In QSSI Chipcode History Format param check"

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
     echo "Proprietary content will be downloaded from 'Chipcode History Format'"

     if [ -z "$qssi_chipcode_hf_server" ]; then
        echo "Please supply QSSI ChipCode History Format Server."
        usage
     fi

     if [ -z "$qssi_chipcode_hf_manifest_git" ]; then
        echo "Please supply QSSI Manifest Git hosted on ChipCode History Format Server."
        usage
     fi

     if [ -z "$qssi_chipcode_hf_manifest_branch" ]; then
        echo "Please supply QSSI Manifest Branch hosted on ChipCode History Format Server."
        usage
     fi

     echo "QSSI Chipcode History Format Server: $qssi_chipcode_hf_server"
     echo "QSSI Manifest Git hosted on Chipcode History Format Server: $qssi_chipcode_hf_manifest_git"
     echo "QSSI Manifest Git branch hosted on Chipcode History Format Server: $qssi_chipcode_hf_manifest_branch"

  fi

  return 0
}

kernel_chipcode_hf_args_check() {

  if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
    return 0
  fi

  if [ "$tree_type" == $QSSI_TREE_STANDALONE ]; then
    return 0
  fi

  echo "In Kernel Chipcode History Format param check"

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
     echo "Proprietary content will be downloaded from 'Chipcode History Format'"

     if [ -z "$kernel_chipcode_hf_server" ]; then
        echo "Please supply Kernel ChipCode History Format Server."
        usage
     fi

     if [ -z "$kernel_chipcode_hf_manifest_git" ]; then
        echo "Please supply Kernel Manifest Git hosted on ChipCode History Format Server."
        usage
     fi

     if [ -z "$kernel_chipcode_hf_manifest_branch" ]; then
        echo "Please supply Kernel Manifest Branch hosted on ChipCode History Format Server."
        usage
     fi

     echo "Kernel Chipcode History Format Server: $kernel_chipcode_hf_server"
     echo "Kernel Manifest Git hosted on Chipcode History Format Server: $kernel_chipcode_hf_manifest_git"
     echo "Kernel Manifest Git branch hosted on Chipcode History Format Server: $kernel_chipcode_hf_manifest_branch"

  fi
}

vendor_chipcode_hf_args_check() {
  echo "In Vendor Chipcode History Format param check"

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
     echo "Proprietary content will be downloaded from 'Chipcode History Format'"

     if [ -z "$vendor_chipcode_hf_server" ]; then
        echo "Please supply Vendor ChipCode History Format Server."
        usage
     fi

     if [ -z "$vendor_chipcode_hf_manifest_git" ]; then
        echo "Please supply Vendor Manifest Git hosted on ChipCode History Format Server."
        usage
     fi

     if [ -z "$vendor_chipcode_hf_manifest_branch" ]; then
        echo "Please supply Vendor Manifest Branch hosted on ChipCode History Format Server."
        usage
     fi

     echo "Vendor Chipcode History Format Server: $vendor_chipcode_hf_server"
     echo "Vendor Manifest Git hosted on Chipcode History Format Server: $vendor_chipcode_hf_manifest_git"
     echo "Vendor Manifest Git branch hosted on Chipcode History Format Server: $vendor_chipcode_hf_manifest_branch"

     if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
       return 0
     fi

     if [ -z "$qssi_chipcode_hf_server" ]; then
        echo "Please supply QSSI ChipCode History Format Server."
        usage
     fi

     if [ -z "$qssi_chipcode_hf_manifest_git" ]; then
        echo "Please supply QSSI Manifest Git hosted on ChipCode History Format Server."
        usage
     fi

     if [ -z "$qssi_chipcode_hf_manifest_branch" ]; then
        echo "Please supply QSSI Manifest Branch hosted on ChipCode History Format Server."
        usage
     fi

     echo "QSSI Chipcode History Format Server: $qssi_chipcode_hf_server"
     echo "QSSI Manifest Git hosted on Chipcode History Format Server: $qssi_chipcode_hf_manifest_git"
     echo "QSSI Manifest Git branch hosted on Chipcode History Format Server: $qssi_chipcode_hf_manifest_branch"

     if [ -z "$kernel_chipcode_hf_server" ]; then
        echo "Please supply Kernel ChipCode History Format Server."
        usage
     fi

     if [ -z "$kernel_chipcode_hf_manifest_git" ]; then
        echo "Please supply Kernel Manifest Git hosted on ChipCode History Format Server."
        usage
     fi

     if [ -z "$kernel_chipcode_hf_manifest_branch" ]; then
        echo "Please supply Kernel Manifest Branch hosted on ChipCode History Format Server."
        usage
     fi

     echo "Kernel Chipcode History Format Server: $kernel_chipcode_hf_server"
     echo "Kernel Manifest Git hosted on Chipcode History Format Server: $kernel_chipcode_hf_manifest_git"
     echo "Kernel Manifest Git branch hosted on Chipcode History Format Server: $kernel_chipcode_hf_manifest_branch"


  fi

  return 0
}

qssi_chipcode_args_check() {

  if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
    return 0
  fi

  if [ "$tree_type" == $KERNEL_TREE_STANDALONE ]; then
    return 0
  fi

  echo "In QSSI Chipcode param check"

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
     echo "Proprietary content will be downloaded/copied from 'Chipcode'"

     if [ -z "$qssi_chipcode_path" ]; then
          echo "Please supply QSSI SI chipcode path"
       usage
     fi
     echo $qssi_chipcode_path
  fi

  return 0
}

kernel_chipcode_args_check() {

  if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
    return 0
  fi

  if [ "$tree_type" == $QSSI_TREE_STANDALONE ]; then
    return 0
  fi

  echo "In KERNEL PLATFORM Chipcode param check"

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
     echo "Proprietary content will be downloaded/copied from 'Chipcode'"

     if [ -z "$kernel_chipcode_path" ]; then
          echo "Please supply Kernel platform SI chipcode path"
       usage
     fi
     echo $kernel_chipcode_path
  fi

  return 0
}

vendor_chipcode_args_check() {
  echo "In Vendor Chipcode param check"

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
     echo "Proprietary content will be downloaded/copied from 'Chipcode'"

     if [ -z "$vendor_chipcode_path" ]; then
        echo "Please supply the Vendor SI chipcode content path."
        usage
     fi

    if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
      return 0
    fi

     echo $vendor_chipcode_path
     if [ -z "$qssi_chipcode_path" ]; then
        echo "Please supply the QSSI SI chipcode content path"
        usage
     fi

     echo $qssi_chipcode_path

  fi

  return 0
}

qssi_grease_args_check() {

  if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
    return 0
  fi

  if [ "$tree_type" == $KERNEL_TREE_STANDALONE ]; then
    return 0
  fi

  echo "In QSSI Grease param check"

  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
     echo "Proprietary content will be downloaded from 'Grease'"

     if [ -z "$grease_userid" ]; then
        grease_user=$grease_userid
     fi

     if [ -z "$grease_pass" ]; then
        grease_pass=$grease_pass
     fi

     if [ "$tree_type" == $QSSI_TREE_STANDALONE ]; then
       if ! [ -n "$qssi_au_tag" -o -n "$qssi_crm_label" ]; then
           echo "\nPlease supply the full AU TAG name or CRM label.\n"
           usage
       fi
     fi

     if [ -z "$qssi_grease_branch" ]; then
        qssi_grease_branch=$qssi_grease_branch
     fi

     if [ -z "$grease_server" ]; then
      grease_server=$grease_server
     fi
  fi

  return 0
}

kernel_grease_args_check() {

  if [ "$tree_type" == $VENDOR_TREE_STANDALONE ]; then
    return 0
  fi

  if [ "$tree_type" == $QSSI_TREE_STANDALONE ]; then
    return 0
  fi

  echo "In KERNEL PLATFORM Grease param check"

  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
     echo "Proprietary content will be downloaded from 'Grease'"

     if [ -z "$grease_userid" ]; then
        grease_user=$grease_userid
     fi

     if [ -z "$grease_pass" ]; then
        grease_pass=$grease_pass
     fi

     if [ "$tree_type" == $QSSI_TREE_STANDALONE ]; then
       if ! [ -n "$kernel_au_tag" -o -n "$kernel_crm_label" ]; then
           echo "\nPlease supply the full AU TAG name or CRM label.\n"
           usage
       fi
     fi

     if [ -z "$kernel_grease_branch" ]; then
        kernel_grease_branch=$kernel_grease_branch
     fi

     if [ -z "$grease_server" ]; then
      grease_server=$grease_server
     fi
  fi

  return 0
}

vendor_grease_args_check() {

  echo "In Vendor Grease param check"

  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
     echo "Proprietary content will be downloaded from 'Grease'"

     if [ -z "$grease_userid" ]; then
        echo "Please supply your grease username."
        usage
     fi

     if [ -z "$grease_pass" ]; then
        echo "Please supply your grease password."
        usage
     fi

     if ! [ -n "$vendor_au_tag" -o -n "$vendor_crm_label" ]; then
         echo "Please supply the full AU TAG name or CRM label."
         usage
     fi

     if [ -z "$vendor_grease_branch" ]; then
        echo "Please supply the Vendor SI branch name."
        usage
     fi

     if [ -z "$vendor_grease_branch" ]; then
        echo "Please supply the vendor SI branch name."
        usage
     fi
  fi
  return 0
}

#when groups are passed remove projects fetched
#from chipcode which do not belong to correct grp
remove_common_sys_prjs() {
  echo "Removing common sys projects..."
  file_name="common_sys_projects.txt"
  if [ ! -e "${qssi_chipcode_path}/${file_name}" ]; then
     echo "${qssi_chipcode_path}/${file_name} not found!"
     exit 1
  fi
  cp -f ${qssi_chipcode_path}/${file_name} $ROOT_PWD/
  for path in $(cat ${ROOT_PWD}/${file_name}); do
     echo "Deleting ${ROOT_PWD}/$path "
     rm -rf ${ROOT_PWD}/$path
  done
  rm -rf ${ROOT_PWD}/${file_name}
}


kernel_au_fnd_str="KERNEL.PLATFORM"
found_kernel_au=false
qssi_au_fnd_str="LA.QSSI"
COMBINED_MANIFEST=".repo/manifests/snap_combined_manifest.xml"
PREBUILT_HY11_PATH="vendor/qcom/proprietary/prebuilt_HY11"
PREBUILT_GREASE_PATH="vendor/qcom/proprietary/prebuilt_grease"
REPO_MANIFESTS=".repo/manifests/"
REPO_MANIFESTS_GIT=".repo/manifests.git"
PROP_PATH="vendor/qcom/proprietary/"
REPO_BACKUP_PATH=".repo_bak"
VENDOR_OSS_DIR_NAME="vendor_oss"
VENDOR_PROP_DIR_NAME="vendor_prop"
QSSI_OSS_DIR_NAME="qssi_oss"
QSSI_PROP_DIR_NAME="qssi_prop"
KERNEL_OSS_DIR_NAME="kernel_oss"
LE_OSS_DIR_NAME="le_oss"
KERNEL_PROP_DIR_NAME="kernel_prop"
LE_STANDALONE="le_standalone"
LE_COMBINED="le_tree"
LA_COMBINED_TREE="la_tree"
LE_APPS_PROC_PATH="apps_proc"
LA_COMBINED_TREE_GROUPS="la_tree_groups"
QSSI_TREE_STANDALONE="la_qssi"
VENDOR_TREE_STANDALONE="la_vendor"
KERNEL_TREE_STANDALONE="kernel_platform"
PROP_DEST_GREASE="grease"
PROP_DEST_CHIPCODE="chipcode"
PROP_DEST_CHIPCODE_HF="chipcode_hf"
KERNEL_PLATFORM_PATH="kernel_platform"
LE_IMAGE="le"
LA_IMAGE="la"
quiet=""
shallow_clone=false
groups=""
OPTIONAL_SYNC_ARG="--current-branch --no-tags --force-sync"
le_ksrc_path="src/kernel-5.10"

INPUT_OPTS=optional_sync_arg,image_type:,workspace_path:,tree_type:,prop_opt:,common_oss_url:,vendor_oss_manifest_git:,vendor_oss_url:,grease_server:,grease_userid:,grease_pass:,vendor_au_tag:,vendor_crm_label:,vendor_grease_branch:,vendor_chipcode_path:,qssi_oss_manifest_git:,qssi_oss_url:,qssi_au_tag:,qssi_crm_label:,qssi_grease_branch:,qssi_chipcode_path:,le_crmid:,le_oss_url:,le_oss_manifest_git:,le_chipcode_path:,kernel_oss_url:,kernel_oss_manifest_git:,kernel_au_tag:,kernel_grease_branch:,kernel_chipcode_path:,vendor_chipcode_hf_server:,vendor_chipcode_hf_manifest_git:,vendor_chipcode_hf_manifest_branch:,qssi_chipcode_hf_server:,qssi_chipcode_hf_manifest_git:,qssi_chipcode_hf_manifest_branch:,kernel_chipcode_hf_server:,kernel_chipcode_hf_manifest_git:,kernel_chipcode_hf_manifest_branch:,repo_url:,repo_branch:,groups:,shallow_clone:,quiet:,jobs:

echo "arg = $@"
if [ $1 == "-D" ] || [  $1 == "-T" ] || [  $1 == "-R" ] || [  $1 == "-R" ] || [  $1 == "-c" ] || [  $1 == "-A" ] || [  $1 == "-L" ]; then
  DIR="$(cd "$(dirname "$0")" && pwd)"
  echo "Using V1 sync method,calling sync_snap.sh from $DIR"
  $DIR/sync_snap.sh $@
else
  echo "Using V2 sync method"
  OPTIONS=$(getopt  --long $INPUT_OPTS -o '' -- "$@")
  eval set -- "$OPTIONS"

  while true ; do
    case "$1" in
       --workspace_path ) tree_dest_path="$2"; shift 2;;
       --image_type ) image_type="$2"; shift 2;;
       --tree_type ) tree_type=$2; shift 2;;
       --prop_opt ) prop_dest=$2; shift 2;;
       --common_oss_url )
         common_oss_url=$2
         vendor_oss_url=$2
         qssi_oss_url=$2
         kernel_oss_url=$2
         le_oss_url=$2
          shift 2;;
       --vendor_oss_url ) vendor_oss_url=$2; shift 2;;
       --vendor_oss_manifest_git ) vendor_oss_manifest_git=$2; shift 2;;
       --grease_server ) grease_server=$2;shift 2;;
       --grease_userid ) grease_userid=$2; shift 2;;
       --grease_pass ) grease_pass=$2; shift 2;;
       --vendor_au_tag ) vendor_au_tag=$2; shift 2;;
       --vendor_grease_branch ) vendor_grease_branch=$2;shift 2;;
       --vendor_chipcode_path ) vendor_chipcode_path=$2; shift 2;;
       --vendor_chipcode_hf_server ) vendor_chipcode_hf_server=$2; shift 2;;
       --vendor_chipcode_hf_manifest_git ) vendor_chipcode_hf_manifest_git=$2; shift 2;;
       --vendor_chipcode_hf_manifest_branch ) vendor_chipcode_hf_manifest_branch=$2; shift 2;;
       --qssi_oss_url ) qssi_oss_url=$2; shift 2;;
       --qssi_oss_manifest_git ) qssi_oss_manifest_git=$2; shift 2;;
       --qssi_au_tag ) qssi_au_tag=$2; shift 2;;
       --qssi_grease_branch ) qssi_grease_branch=$2;shift 2;;
       --qssi_chipcode_path ) qssi_chipcode_path=$2; shift 2;;
       --qssi_chipcode_hf_server ) qssi_chipcode_hf_server=$2; shift 2;;
       --qssi_chipcode_hf_manifest_git ) qssi_chipcode_hf_manifest_git=$2; shift 2;;
       --qssi_chipcode_hf_manifest_branch ) qssi_chipcode_hf_manifest_branch=$2; shift 2;;
       --kernel_oss_url ) kernel_oss_url=$2; shift 2;;
       --kernel_oss_manifest_git ) kernel_oss_manifest_git=$2; shift 2;;
       --kernel_au_tag ) kernel_au_tag=$2; shift 2;;
       --kernel_grease_branch ) kernel_grease_branch=$2;shift 2;;
       --kernel_chipcode_path ) kernel_chipcode_path=$2; shift 2;;
       --kernel_chipcode_hf_server ) kernel_chipcode_hf_server=$2; shift 2;;
       --kernel_chipcode_hf_manifest_git ) kernel_chipcode_hf_manifest_git=$2; shift 2;;
       --kernel_chipcode_hf_manifest_branch ) kernel_chipcode_hf_manifest_branch=$2; shift 2;;
       --le_oss_url ) le_oss_url=$2; shift 2;;
       --le_oss_manifest_git ) le_oss_manifest_git=$2; shift 2;;
       --le_crmid ) le_crmid=$2; shift 2;;
       --le_chipcode_path ) le_chipcode_path=$2; shift 2;;
       --repo_url ) repo_url=$2; shift 2;;
       --repo_branch ) repo_branch=$2; shift 2;;
       --groups ) groups=$2; shift 2;;
       --shallow_clone ) shallow_clone=$2; shift 2;;
       --jobs ) jobs=$2; shift 2;;
       --optional_sync_arg ) optional_sync_arg=$OPTIONAL_SYNC_ARG; shift;;
       -- ) shift; break;;
       *)echo "Error!!!";exit 1;;
    esac
  done
fi

echo "shallow_clone = $shallow_clone"
echo "common_oss_url = $common_oss_url"
echo "vendor_oss_url = $vendor_oss_url"
echo "qssi_oss_url = $qssi_oss_url"
echo "kernel_oss_url = $kernel_oss_url"
echo "le_oss_url = $le_oss_url"
if [ ! -z "$optional_sync_arg" ]; then
  echo "optional_sync_arguments = $optional_sync_arg"
fi


#If image name is not specified, treat default as LA image
if [ -z "$image_type" ]; then
  echo "Choosing default option: $tree_type sync"
  image_type=$LA_IMAGE
fi

if [ -z "$qssi_oss_url" ]; then
  qssi_oss_url="git://codeaurora.org"
fi

if [ -z "$vendor_oss_url" ]; then
  vendor_oss_url="git://codeaurora.org"
fi


if [ -z "$repo_branch" ]; then
  repo_branch="aosp-new/stable"
fi

if [ -z "$repo_url" ]; then
  repo_url="git://codeaurora.org/tools/repo.git"
fi

if [ -z "$jobs" ]; then
  echo "No input for jobs, defaulting to 8"
  jobs=8
fi

if [ "$image_type" == $LE_IMAGE ]; then
  echo "Initiating sync process for LE image"

  ROOT_PWD=$tree_dest_path
  if [ -z "$le_chipcode_path" ]; then
    echo "Pls pass LE image chipcode path Eg: /test/path/to/le_chipcode_path/LE.UM.4.3.1.r1-03200-genericarmv8-64.0-1/apps_proc/"
    exit 1
  fi

  if [ -z "$le_crmid" ]; then
    echo "Pls pass LE CRM ID: Eg: LE.UM.4.3.1.r1-03100-genericarmv8-64.0"
    exit 1
  fi

  if [ ! -d "$le_chipcode_path" ]
  then
    echo "LE Image chipcode PATH le_chipcode_path DOES NOT exists"
    exit 1
  fi

  mkdir -p $ROOT_PWD
  rm -rf $ROOT_PWD/$LE_APPS_PROC_PATH/.repo/local_manifests
  rm -rf $ROOT_PWD/$LE_APPS_PROC_PATH/$LE_OSS_DIR_NAME $ROOT_PWD/$LE_APPS_PROC_PATH/$KERNEL_OSS_DIR_NAME
  mkdir -p $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH

  if [ -d $ROOT_PWD/$LE_APPS_PROC_PATH/.repo ]; then
    pushd $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_MANIFESTS
    git reset --hard
    pushd $ROOT_PWD/$LE_APPS_PROC_PATH
  fi

  if [ -d $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH/.repo ]; then
    pushd $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH/$REPO_MANIFESTS
    git reset --hard
    mv $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH/.repo $ROOT_PWD/
    pushd $ROOT_PWD/$LE_APPS_PROC_PATH
  fi

  if [ "$tree_type" == $LE_STANDALONE ] || [ "$tree_type" == $LE_COMBINED ]
  then

    echo "Copying LE chipcode path folder(apps_proc)"
    cp -r $le_chipcode_path $ROOT_PWD
    echo "LE chipcode content(apps_proc folder) copied"

    pushd $ROOT_PWD/$LE_APPS_PROC_PATH
    mkdir -p $ROOT_PWD/$LE_APPS_PROC_PATH/$LE_OSS_DIR_NAME
    mkdir -p $ROOT_PWD/$LE_APPS_PROC_PATH/$KERNEL_OSS_DIR_NAME
    echo " repo init LE manifest"
    echo "repo init command = repo init -u $le_oss_url/$le_oss_manifest_git.git -b release -m $le_crmid.xml --repo-url=$repo_url --repo-branch=$repo_branch "
    python3.6 /bin/repo init -u $le_oss_url/$le_oss_manifest_git.git -b release -m $le_crmid.xml --repo-url=$repo_url --repo-branch=$repo_branch
    echo "LE manifest repo init done"

    le_oss_manifest=$ROOT_PWD/$LE_APPS_PROC_PATH/.repo/manifests/$le_crmid.xml
    qremote="cafle"
    echo "LE CAF manifest = $kernel_oss_manifest, qremote = $qremote"
    xml1=$(cat "$le_oss_manifest" | remove_defaults)

    echo "Getting remotes"
    m1remotes=($(cat "$le_oss_manifest" |\
             xmlstarlet sel -t -m '/manifest/remote' -v '@name' -o ' '\
             ))
    echo "replacing remotes"
    for m1remote in "${m1remotes[@]}"; do
      echo "m1remote = "$m1remote""
      if [ "$m1remote" == "caf" ]; then
        xml1=$(echo "$xml1" | update_remote "$m1remote" "$qremote")
      fi
      done
      rm -rf $ROOT_PWD/$LE_APPS_PROC_PATH/lecafmanifest.xml
      {
        echo '<?xml version="1.0" encoding="UTF-8"?>
          <manifest>'

        echo "$xml1" | xmlstarlet sel -t -c '/manifest/*[not(self::project)]'
        echo "$xml1" | xmlstarlet sel -t -c "/manifest/project"

        echo '</manifest>'
      } |  xmlstarlet fo >> $ROOT_PWD/$LE_APPS_PROC_PATH/lecafmanifest.xml

    echo " LE caf manifest processing is done"
    mv $ROOT_PWD/$LE_APPS_PROC_PATH/lecafmanifest.xml $ROOT_PWD/$LE_APPS_PROC_PATH/.repo/manifests/$le_crmid.xml


    if [ "$tree_type" == $LE_COMBINED ]; then
      if [ -d $ROOT_PWD/$LE_APPS_PROC_PATH/.repo ]; then
        rm -rf $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH/.repo
        mv $ROOT_PWD/$LE_APPS_PROC_PATH/.repo $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH/
      fi

      pushd $ROOT_PWD/$LE_APPS_PROC_PATH/$KERNEL_OSS_DIR_NAME

      if grep -qF "$kernel_au_fnd_str" $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH/.repo/manifests/$le_crmid.xml;then
        echo "Found KERNEL SI AU TAG in LE Manifest"
        kernel_au_tag=$(xmlstarlet sel -T -t -m  "//refs/image[@project='kernelplatform/manifest']" -v "@tag" -nl $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH/.repo/manifests/$le_crmid.xml)
        echo "Kernel AU TAG = $kernel_au_tag"
      else
        echo "Didn't find KERNEL SI AU TAG in LE  manifest"
        if [ -z "$kernel_au_tag" ]; then
          echo "Not able to find a way to fetch kernel AU TAG, exiting"
          exit 1
        fi
      fi

      echo "kernel AU TAG = $kernel_au_tag"
      kernel_oss_au_xml="caf_$kernel_au_tag.xml"
      [ "$kernel_oss_url" == "https://git.codelinaro.org" ] && kernel_oss_au_xml="$kernel_au_tag.xml"
      echo " repo init KERNEL PLATFORM manifest"
      ARGS="-u $kernel_oss_url/$kernel_oss_manifest_git.git -b release -m $kernel_oss_au_xml --repo-url=$repo_url --repo-branch=$repo_branch"
      if [ "$kernel_oss_url" == "https://git.codelinaro.org" ]; then
         ARGS="--depth=1 $ARGS"
      fi
      echo "repo init $ARGS"
      python3.6 /bin/repo init $ARGS
      echo "KERNEL PLATFORM  manifest repo init done"

      if [ -d $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH/.repo ];then
        mv $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_BACKUP_PATH/.repo $ROOT_PWD/$LE_APPS_PROC_PATH/
      fi

      mkdir -p $ROOT_PWD/$LE_APPS_PROC_PATH/.repo/local_manifests

      kernel_oss_manifest=$ROOT_PWD/$LE_APPS_PROC_PATH/$KERNEL_OSS_DIR_NAME/.repo/manifests/$kernel_oss_au_xml
      qremote="cafk"
      echo "kernel OSS manifest = $kernel_oss_manifest, qremote = $qremote"
      xml1=$(cat "$kernel_oss_manifest" | remove_defaults)

      echo "Getting remotes"
      m1remotes=($(cat "$kernel_oss_manifest" |\
               xmlstarlet sel -t -m '/manifest/remote' -v '@name' -o ' '\
               ))
      echo "replacing remotes"
      for m1remote in "${m1remotes[@]}"; do
        xml1=$(echo "$xml1" | update_remote "$m1remote" "$qremote")
      done
      rm -rf $ROOT_PWD/$LE_APPS_PROC_PATH/kcafmanifest.xml
      {
        echo '<?xml version="1.0" encoding="UTF-8"?>
          <manifest>'

        echo "$xml1" | xmlstarlet sel -t -c '/manifest/*[not(self::project)]'
        echo "$xml1" | xmlstarlet sel -t -c "/manifest/project"

        echo '</manifest>'
      } |  xmlstarlet fo >> $ROOT_PWD/$LE_APPS_PROC_PATH/kcafmanifest.xml

      echo " kernel caf manifest processing is done"
      mv $ROOT_PWD/$LE_APPS_PROC_PATH/kcafmanifest.xml $ROOT_PWD/$LE_APPS_PROC_PATH/.repo/local_manifests/
      echo "copying kernel platform proprietary content"
      mkdir -p  $ROOT_PWD/$LE_APPS_PROC_PATH/$KERNEL_PLATFORM_PATH
      cp -r $kernel_chipcode_path/* $ROOT_PWD/$LE_APPS_PROC_PATH/$KERNEL_PLATFORM_PATH/
      echo "Completed copying kernel platform proprietary content"
    fi
    rm -rf $ROOT_PWD/$LE_APPS_PROC_PATH/$KERNEL_OSS_DIR_NAME
    rm -rf $ROOT_PWD/$LE_APPS_PROC_PATH/$LE_OSS_DIR_NAME
    echo "Tree sync initiated"
    pushd $ROOT_PWD/$LE_APPS_PROC_PATH
    sleep 2
    repo manifest > $COMBINED_MANIFEST
    echo "Combined Manifest generated"
    if [ ! -z "$optional_sync_arg" ]; then
      echo "repo sync -j${jobs} $optional_sync_arg"
      python3.6 /bin/repo sync -j${jobs} $optional_sync_arg
    else
      echo "python3.6 /bin/repo sync -j${jobs}"
      python3.6 /bin/repo sync -j${jobs}
    fi
    if [ "$tree_type" == $LE_COMBINED ]; then
      le_ksrc_path=$(xmlstarlet sel -T -t -m  "//refs/image[@project='kernelplatform/manifest']" -v "@src_path" -nl $ROOT_PWD/$LE_APPS_PROC_PATH/$REPO_MANIFESTS/$le_crmid.xml)
      echo "le_ksrc_path=$le_ksrc_path"
      mkdir -p $ROOT_PWD/$LE_APPS_PROC_PATH/$le_ksrc_path
      mv $ROOT_PWD/$LE_APPS_PROC_PATH/$KERNEL_PLATFORM_PATH $ROOT_PWD/$LE_APPS_PROC_PATH/$le_ksrc_path/
    fi
    echo "python3.6 /bin/repo sync successful"
  fi
  echo "Completed sync process for LE image, exiting"
  exit 0
fi

echo "Initiating sync process for LA image:$tree_type"

echo "tree_type = $tree_type"

if [ -z "$tree_type" ]; then
  if [ -z "$prop_dest" ]; then
    if [ -z "$tree_dest_path" ]; then
      echo "Falling back to legacy sync model"
      if [ -z "$vendor_oss_manifest_git" ]; then
        echo "legacy sync: public CAF"
        $PWD/sync_all.sh -a $vendor_au_tag -b $vendor_grease_branch -u $grease_userid -p $grease_pass -s $grease_server
      else
        echo "legacy sync: private CAF"
        $PWD/sync_all.sh -a $vendor_au_tag -b $vendor_grease_branch -u $grease_userid -p $grease_pass -s $grease_server -c $vendor_oss_manifest_git -l $vendor_oss_url
      fi
      exit 0
    fi
  fi
fi

echo "using enhanced AIM sync model"

if [ -z "$tree_type" ]; then
  echo "Please input tree type(vendor Tree(vt)/QSSI Tree(qt)/Single Tree(st))"
  usage
fi

if [ -z "$prop_dest" ]; then
  echo "Please input source code/prebuilt location(Grease(gr)/Chipcode(ch))"
  usage
fi

#Pick up the arguments based on Tree type
#check, if req is to sync QSSI SI STANDALONE Tree
if [ "$tree_type" == $QSSI_TREE_STANDALONE ]; then
  echo "Selected tree type is 'QSSI Tree'"

  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
     if qssi_grease_args_check
        then echo "success"
        else echo " failure"
     fi
  fi

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
     if qssi_chipcode_args_check
        then echo "success"
        else echo " failure"
     fi
  fi

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
     if qssi_chipcode_hf_args_check
        then echo "success"
        else echo " failure"
     fi
  fi

  if qssi_oss_args_check
     then echo "success"
     else echo " failure"
  fi

fi

#Pick up the arguments based on Tree type
#check, if req is to sync KERNEL SI STANDALONE Tree
if [ "$tree_type" == $KERNEL_TREE_STANDALONE ]; then
  echo "Selected tree type is 'Kernel Platform Tree'"

  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
     if kernel_grease_args_check
        then echo "success"
        else echo " failure"
     fi
  fi

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
     if kernel_chipcode_args_check
        then echo "success"
        else echo " failure"
     fi
  fi

  if kernel_oss_args_check
     then echo "success"
     else echo " failure"
  fi

fi

#check, if the req is to sync Vendor Tree
if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ] || [ "$tree_type" == $VENDOR_TREE_STANDALONE ]
then
  echo "Selected tree type is 'LA_COMBINED_TREE/LA_COMBINED_TREE_GROUPS/VENDOR_STANDALONE'"

  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
     if qssi_grease_args_check
     then
       if kernel_grease_args_check
       then
        if vendor_grease_args_check
          then
          echo "QSSI and Vendor Grease args check success"
          else echo "Vendor Grease args check failure"
        fi
        else echo "QSSI Grease args check failure"
       fi
     fi
  fi

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
     if qssi_chipcode_args_check
       then
       if vendor_chipcode_args_check
       then
         echo "QSSI and Vendor Grease args check success"
         else echo "Vendor Grease args check failure"
       fi
       else echo "QSSI Grease args check failure"
    fi
  fi

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
     if qssi_chipcode_hf_args_check
     then
       if kernel_chipcode_hf_args_check
       then
         if vendor_chipcode_hf_args_check
         then
           echo "QSSI, Kernel and Vendor Chipcode HF args check success"
         else echo "Vendor Chipcode HF args check failure"
         fi
       else echo "Kernel Chipcode HF args check failure"
       fi
     else echo "QSSI Chipcode HF args check failure"
     fi
  fi

  if qssi_oss_args_check
  then
    if qssi_oss_args_check
    then
      if vendor_oss_args_check
      then
        echo "QSSI and Vendor OSS args check success"
        else echo "Vendor OSS args check failure"
      fi
      else echo "QSSI OSS args check failure"
    fi
  fi
fi

if $shallow_clone; then
    if ! repo init --help | grep -q '\-\-depth'; then
        echo "Current version of repo doesn't support shallow clone."
        echo "Please upgrade repo to use this option"
        usage
    fi
fi

platform=android
if [ -z "$vendor_oss_manifest_git" ]; then
  vendor_oss_manifest_git=la/vendor/manifest
fi

if [ -z "$qssi_oss_manifest_git" ]; then
  qssi_oss_manifest_git=la/system/manifest
fi

if [ -z "$vendor_grease_manifest_git" ]; then
  vendor_grease_manifest_git=la/vendor/manifest
fi

if [ -z "$qssi_grease_manifest_git" ]; then
  qssi_grease_manifest_git=la/system/manifest
fi

if [ -z "$kernel_grease_manifest_git" ]; then
  kernel_grease_manifest_git=kernelplatform/manifest
fi

if [ -z "$kernel_oss_manifest_git" ]; then
  kernel_oss_manifest_git=kernelplatform/manifest
fi


#clean up the repo folders
if [ -z "$tree_dest_path" ]; then
  echo "Please supply the workspace PATH"
      exit 1
fi

echo "Current directory $PWD"
echo "Dest path $tree_dest_path"
if [ ! -d "$tree_dest_path" ]
then
    echo "Directory $tree_dest_path DOES NOT exists,creating the destination path"
    mkdir -p $tree_dest_path
fi

ROOT_PWD=$tree_dest_path

if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
  if [ "$tree_type" == $QSSI_TREE_STANDALONE ] || [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
    then
    if [ ! -d "$qssi_chipcode_path" ]
    then
      echo "QSSI SI chipcode PATH qssi_chipcode_path DOES NOT exists"
      exit 1
    fi
  fi
  if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ] || [ "$tree_type" == $VENDOR_TREE_STANDALONE ]
    then
    if [ ! -d "$vendor_chipcode_path" ]
      then
      echo "Vendor SI chipcode PATH vendor_chipcode_path DOES NOT exists"
      exit 1
    fi
  fi
fi


mkdir -p $ROOT_PWD
rm -rf $ROOT_PWD/.repo/local_manifests
rm -rf $ROOT_PWD/$QSSI_OSS_DIR_NAME $ROOT_PWD/$QSSI_PROP_DIR_NAME $ROOT_PWD/$VENDOR_OSS_DIR_NAME $ROOT_PWD/$VENDOR_PROP_DIR_NAME $ROOT_PWD/$KERNEL_OSS_DIR_NAME $ROOT_PWD/$KERNEL_PROP_DIR_NAME
mkdir -p $ROOT_PWD/$REPO_BACKUP_PATH
pushd $ROOT_PWD
rm -rf $ROOT_PWD/prebuilt_*



if [ -d $ROOT_PWD/.repo ]; then
  pushd $ROOT_PWD/$REPO_MANIFESTS
  git reset --hard
  pushd $ROOT_PWD
fi

if [ -d $ROOT_PWD/$REPO_BACKUP_PATH/.repo ]; then
  pushd $ROOT_PWD/$REPO_BACKUP_PATH/$REPO_MANIFESTS
  git reset --hard
  mv $ROOT_PWD/$REPO_BACKUP_PATH/.repo $ROOT_PWD/
  pushd $ROOT_PWD
fi


#check, if the req is to sync QSSI standalone Tree
if [ "$tree_type" == $QSSI_TREE_STANDALONE ]; then

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
    qssi_chipcode_hf_fetch_url="https://${qssi_chipcode_hf_server}/"
    qssi_chipcode_hf_mf_url="${qssi_chipcode_hf_fetch_url}${qssi_chipcode_hf_manifest_git}"
  else
    qssi_grease_fetch_url="ssh://${grease_userid}@${grease_server}:29418/"
    qssi_grease_mf_url="${qssi_grease_fetch_url}${qssi_grease_manifest_git}"
  fi

  mkdir -p $ROOT_PWD/$QSSI_OSS_DIR_NAME
  if [[ "$prop_dest" == $PROP_DEST_GREASE || "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]]; then
    mkdir -p $ROOT_PWD/$QSSI_PROP_DIR_NAME
  fi
  qssi_oss_au_xml="caf_${qssi_au_tag}.xml"
  [ "$qssi_oss_url" == "https://git.codelinaro.org" ] && qssi_oss_au_xml="${qssi_au_tag}.xml"
  pushd $ROOT_PWD
  echo " repo init QSSI OSS"
  ARGS="-u $qssi_oss_url/$qssi_oss_manifest_git.git -b release -m $qssi_oss_au_xml --repo-url=$repo_url --repo-branch=$repo_branch"
  if [ "$qssi_oss_url" == "https://git.codelinaro.org" ]; then
     ARGS="--depth=1 $ARGS"
  fi
  echo "repo init $ARGS"
  #python2.7 /bin/repo init $ARGS
  python3.6 /bin/repo init -u ssh://git@git.codeaurora.org:9222/external/private_LA.QSSI.12.0/la/system/manifest.git -b release -m caf_AU_LINUX_ANDROID_LA.QSSI.12.0.R1.11.00.00.782.007.xml --repo-url=git://codeaurora.org/tools/repo.git --repo-branch=aosp-new/stable
  echo "QSSI SI OSS repo init done"

  if [ -d $ROOT_PWD/.repo ]; then
    rm -rf $ROOT_PWD/$REPO_BACKUP_PATH/.repo
    mv $ROOT_PWD/.repo $ROOT_PWD/$REPO_BACKUP_PATH/
  fi

  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
    pushd $ROOT_PWD/$QSSI_PROP_DIR_NAME
    echo " repo init QSSI SI PROP"
    qssi_grease_mf_name="${qssi_au_tag}.xml"
    echo " repo init -u $qssi_grease_mf_url \
            -m $qssi_grease_mf_name \
            -b $qssi_grease_branch \
            --repo-url=$repo_url \
            --repo-branch=$repo_branch"

    python3.6 /bin/repo init -u $qssi_grease_mf_url \
            -m $qssi_grease_mf_name \
            -b $qssi_grease_branch \
            --repo-url=$repo_url \
            --repo-branch=$repo_branch
    echo "QSSI SI PROP repo init done"
  elif [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
    pushd $ROOT_PWD/$QSSI_PROP_DIR_NAME
    echo " repo init QSSI SI PROP"
    qssi_chipcode_hf_mf_name="${qssi_au_tag}.xml"
    echo " repo init --no-clone-bundle -u $qssi_chipcode_hf_mf_url \
            -m $qssi_chipcode_hf_mf_name \
            -b $qssi_chipcode_hf_manifest_branch \
            --repo-url=$repo_url \
            --repo-branch=$repo_branch"

    python3.6 /bin/repo init --no-clone-bundle -u $qssi_chipcode_hf_mf_url \
            -m $qssi_chipcode_hf_mf_name \
            -b $qssi_chipcode_hf_manifest_branch \
            --repo-url=$repo_url \
            --repo-branch=$repo_branch
    echo "QSSI SI PROP repo init done"
  fi
  pushd $ROOT_PWD
fi

#check, if the req is to sync KERNEL SI standalone  Tree
if [ "$tree_type" == $KERNEL_TREE_STANDALONE ]; then
  found_kernel_au=true
  if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
    kernel_chipcode_hf_fetch_url="https://${kernel_chipcode_hf_server}/"
    kernel_chipcode_hf_mf_url="${kernel_chipcode_hf_fetch_url}${kernel_chipcode_hf_manifest_git}"
  else
    kernel_grease_fetch_url="ssh://${grease_userid}@${grease_server}:29418/"
    kernel_grease_mf_url="${kernel_grease_fetch_url}${kernel_grease_manifest_git}"
  fi

  mkdir -p $ROOT_PWD/$KERNEL_OSS_DIR_NAME
  if [[ "$prop_dest" == $PROP_DEST_GREASE || "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]]; then
    mkdir -p $ROOT_PWD/$KERNEL_PROP_DIR_NAME
  fi
  pushd $ROOT_PWD
  kernel_oss_au_xml="caf_$kernel_au_tag.xml"
  [ "$kernel_oss_url" == "https://git.codelinaro.org" ] && kernel_oss_au_xml="$kernel_au_tag.xml"
  echo " repo init KERNEL SI OSS"
  ARGS="-u $kernel_oss_url/$kernel_oss_manifest_git.git -b release -m $kernel_oss_au_xml --repo-url=$repo_url --repo-branch=$repo_branch"
  if [ "$kernel_oss_url" == "https://git.codelinaro.org" ]; then
     ARGS="--depth=1 $ARGS"
  fi
  echo "repo init $ARGS"
  python3.6 /bin/repo init $ARGS
  echo "QSSI SI OSS repo init done"

if [ -d $ROOT_PWD/.repo ]; then
  rm -rf $ROOT_PWD/$REPO_BACKUP_PATH/.repo
  mv $ROOT_PWD/.repo $ROOT_PWD/$REPO_BACKUP_PATH/
fi

  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
    pushd $ROOT_PWD/$KERNEL_PROP_DIR_NAME
    echo " repo init KERNEL SI PROP"
    kernel_grease_mf_name="${kernel_au_tag}.xml"
    echo " repo init -u $kernel_grease_mf_url \
            -m $kernel_grease_mf_name \
            -b $kernel_grease_branch \
            --repo-url=$repo_url \
            --repo-branch=$repo_branch"

    python3.6 /bin/repo init -u $kernel_grease_mf_url \
            -m $kernel_grease_mf_name \
            -b $kernel_grease_branch \
            --repo-url=$repo_url \
            --repo-branch=$repo_branch
    echo "KERNEL SI PROP python3.6 /bin/repo init done"
  elif [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
    pushd $ROOT_PWD/$KERNEL_PROP_DIR_NAME
    echo " python3.6 /bin/repo init KERNEL SI PROP"
    kernel_chipcode_hf_mf_name="${kernel_au_tag}.xml"
    echo " python3.6 /bin/repo init --no-clone-bundle -u $kernel_chipcode_hf_mf_url \
            -m $kernel_chipcode_hf_mf_name \
            -b $kernel_chipcode_hf_manifest_branch \
            --repo-url=$repo_url \
            --repo-branch=$repo_branch"

    python3.6 /bin/repo init --no-clone-bundle -u $kernel_chipcode_hf_mf_url \
            -m $kernel_chipcode_hf_mf_name \
            -b $kernel_chipcode_hf_manifest_branch \
            --repo-url=$repo_url \
            --repo-branch=$repo_branch
    echo "KERNEL SI PROP python3.6 /bin/repo init done"

  fi
  pushd $ROOT_PWD
fi

#check, if the req is to sync Vendor/Vendor standalone Tree
if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ] || [ "$tree_type" == $VENDOR_TREE_STANDALONE ]
then
  mkdir -p $ROOT_PWD/$QSSI_OSS_DIR_NAME
  mkdir -p $ROOT_PWD/$VENDOR_OSS_DIR_NAME
  mkdir -p $ROOT_PWD/$KERNEL_OSS_DIR_NAME
  if [[ "$prop_dest" == $PROP_DEST_GREASE || "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]]; then
    mkdir -p $ROOT_PWD/$VENDOR_PROP_DIR_NAME
    mkdir -p $ROOT_PWD/$QSSI_PROP_DIR_NAME
    mkdir -p $ROOT_PWD/$KERNEL_PROP_DIR_NAME
  fi

  pushd $ROOT_PWD
  vendor_oss_au_xml="caf_$vendor_au_tag.xml"
  [ "$vendor_oss_url" == "https://git.codelinaro.org" ] && vendor_oss_au_xml="$vendor_au_tag.xml"
  echo " python3.6 /bin/repo init Vendor SI OSS"
  ARGS="-u $vendor_oss_url/$vendor_oss_manifest_git.git -b release -m $vendor_oss_au_xml --repo-url=$repo_url --repo-branch=$repo_branch"
  if [ ! -z $groups ] && [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
    ARGS="$ARGS -g $groups"
  fi
  if [ "$vendor_oss_url" == "https://git.codelinaro.org" ]; then
     ARGS="--depth=1 $ARGS"
  fi
  echo "python3.6 /bin/repo init $ARGS"
  python3.6 /bin/repo init $ARGS
  echo "Vendor SI OSS init done"
  if [ -d $ROOT_PWD/.repo ]; then
    rm -rf $ROOT_PWD/$REPO_BACKUP_PATH/.repo
    mv $ROOT_PWD/.repo $ROOT_PWD/$REPO_BACKUP_PATH/
  fi
  echo "Get QSSI AU_TAG"
  qssi_au_tag=$(xmlstarlet sel -T -t -m  "//refs/image[@project='la/system/manifest']" -v "@tag" -nl $ROOT_PWD/$REPO_BACKUP_PATH/.repo/manifests/$vendor_oss_au_xml)

  if grep -qF "$kernel_au_fnd_str" $ROOT_PWD/$REPO_BACKUP_PATH/.repo/manifests/$vendor_oss_au_xml;then
    echo "Found KERNEL SI AU TAG in vendor SI Manifest"
    kernel_au_tag=$(xmlstarlet sel -T -t -m  "//refs/image[@project='kernelplatform/manifest']" -v "@tag" -nl $ROOT_PWD/$REPO_BACKUP_PATH/.repo/manifests/$vendor_oss_au_xml)
    echo "Kernel AU TAG = $kernel_au_tag"
    found_kernel_au=true
  else
    echo "Didn't find KERNEL SI AU TAG in Vendor SI manifest"
  fi

  echo "found_kernel_au = $found_kernel_au"

  echo "QSSI_AU_TAG=$qssi_au_tag"

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
    vendor_chipcode_hf_fetch_url="https://${vendor_chipcode_hf_server}/"
    vendor_fetch_mf_url="${vendor_chipcode_hf_fetch_url}${vendor_chipcode_hf_manifest_git}"
    vendor_mf_branch="${vendor_chipcode_hf_manifest_branch}"
  else
    vendor_grease_fetch_url="ssh://${grease_userid}@${grease_server}:29418/"
    vendor_fetch_mf_url="${vendor_grease_fetch_url}${vendor_grease_manifest_git}"
    vendor_mf_branch="${vendor_grease_branch}"
  fi

  if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
  then
    if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
      qssi_chipcode_hf_fetch_url="https://${qssi_chipcode_hf_server}/"
      qssi_fetch_mf_url="${qssi_chipcode_hf_fetch_url}${qssi_chipcode_hf_manifest_git}"
      qssi_mf_branch="${qssi_chipcode_hf_manifest_branch}"
    else
      qssi_grease_fetch_url="ssh://${grease_userid}@${grease_server}:29418/"
      qssi_fetch_mf_url="${qssi_grease_fetch_url}${qssi_grease_manifest_git}"
      qssi_mf_branch="${qssi_grease_branch}"
    fi
    echo "QSSI_AU_TAG before processing=$qssi_au_tag"

    pushd $ROOT_PWD/$QSSI_OSS_DIR_NAME
    qssi_oss_au_xml="caf_$qssi_au_tag.xml"
    [ "$qssi_oss_url" == "https://git.codelinaro.org" ] && qssi_oss_au_xml="$qssi_au_tag.xml"
    echo " python3.6 /bin/repo init QSSI OSS"
    ARGS="-u $qssi_oss_url/$qssi_oss_manifest_git.git -b release -m $qssi_oss_au_xml --repo-url=$repo_url --repo-branch=$repo_branch"
    if [ ! -z $groups ] && [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
        ARGS="$ARGS -g $groups"
    fi
    if [ "$qssi_oss_url" == "https://git.codelinaro.org" ]; then
        ARGS="--depth=1 $ARGS"
    fi
    echo "python3.6 /bin/repo init $ARGS"
    python3.6 /bin/repo init $ARGS
    echo "QSSI OSS python3.6 /bin/repo init done"

    if [ "$found_kernel_au" = true ] ; then
      if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
        kernel_chipcode_hf_fetch_url="https://${kernel_chipcode_hf_server}/"
        kernel_fetch_mf_url="${kernel_chipcode_hf_fetch_url}${kernel_chipcode_hf_manifest_git}"
        kernel_mf_branch="${kernel_chipcode_hf_manifest_branch}"
      else
        kernel_grease_fetch_url="ssh://${grease_userid}@${grease_server}:29418/"
        kernel_fetch_mf_url="${kernel_grease_fetch_url}${kernel_grease_manifest_git}"
        kernel_mf_branch="${kernel_grease_branch}"
      fi
      echo "kernel_AU_TAG before processing=$kernel_au_tag"

      pushd $ROOT_PWD/$KERNEL_OSS_DIR_NAME
      kernel_oss_au_xml="caf_$kernel_au_tag.xml"
      [ "$kernel_oss_url" == "https://git.codelinaro.org" ] && kernel_oss_au_xml="$kernel_au_tag.xml"
      echo " python3.6 /bin/repo init KERNEL SI OSS"
      ARGS="-u $kernel_oss_url/$kernel_oss_manifest_git.git -b release -m $kernel_oss_au_xml --repo-url=$repo_url --repo-branch=$repo_branch"
      if [ ! -z $groups ] && [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
        ARGS="$ARGS -g $groups"
      fi
      if [ "$kernel_oss_url" == "https://git.codelinaro.org" ]; then
        ARGS="--depth=1 $ARGS"
      fi
      echo "python3.6 /bin/repo init $ARGS"
      python3.6 /bin/repo init $ARGS
      echo "KERNEL SI OSS python3.6 /bin/repo init done"
    fi
  fi

  if [[ "$prop_dest" == $PROP_DEST_GREASE || "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]]; then
    pushd $ROOT_PWD/$VENDOR_PROP_DIR_NAME
    echo " python3.6 /bin/repo init Vendor SI PROP"
    vendor_mf_name="${vendor_au_tag}.xml"
    ARGS="-u $vendor_fetch_mf_url \
          -m $vendor_mf_name \
          -b $vendor_mf_branch \
          --repo-url=$repo_url \
          --repo-branch=$repo_branch"
    if [ ! -z $groups ] && [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
      ARGS="$ARGS -g $groups"
    fi
    echo "python3.6 /bin/repo init $ARGS"
    python3.6 /bin/repo init $ARGS
    echo "Vendor SI PROP python3.6 /bin/repo init done"

    if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
    then
      pushd $ROOT_PWD/$QSSI_PROP_DIR_NAME
      echo " python3.6 /bin/repo init QSSI SI PROP"
      qssi_mf_name="${qssi_au_tag}.xml"
      ARGS="-u $qssi_fetch_mf_url \
            -m $qssi_mf_name \
            -b $qssi_mf_branch \
            --repo-url=$repo_url \
            --repo-branch=$repo_branch"
      if [ ! -z $groups ] && [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
        ARGS="$ARGS -g $groups"
      fi
      echo "python3.6 /bin/repo init $ARGS"
      python3.6 /bin/repo init $ARGS
      echo "QSSI SI PROP python3.6 /bin/repo init done"
      if [ "$found_kernel_au" = true ] ; then
        pushd $ROOT_PWD/$KERNEL_PROP_DIR_NAME
        echo " python3.6 /bin/repo init KERNEL SI PROP"
        kernel_mf_name="${kernel_au_tag}.xml"
        ARGS="-u $kernel_fetch_mf_url \
              -m $kernel_mf_name \
              -b $kernel_mf_branch \
              --repo-url=$repo_url \
              --repo-branch=$repo_branch"
        if [ ! -z $groups ] && [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
          ARGS="$ARGS -g $groups"
        fi
        echo "python3.6 /bin/repo init $ARGS"
        python3.6 /bin/repo init $ARGS
        echo "KERNEL SI PROP python3.6 /bin/repo init done"
      fi
    fi
  fi
  pushd $ROOT_PWD
fi

if [ "$tree_type" == $QSSI_TREE_STANDALONE ] || [ "$tree_type" == $KERNEL_TREE_STANDALONE ] || [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
then
  # Since the defaults will likely conflict (like remote), delete them.
  # Must remove the defaults before updating so that the default remote
  # is updated correctly.
  pushd $ROOT_PWD
  if [ "$tree_type" == $QSSI_TREE_STANDALONE ] || [ "$tree_type" == $KERNEL_TREE_STANDALONE ]
  then
    if [ -d $ROOT_PWD/$REPO_BACKUP_PATH/.repo ];then
      mv $ROOT_PWD/$REPO_BACKUP_PATH/.repo $ROOT_PWD/
    fi
  fi
  echo "calling remove defaults"

  if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
  then
    qssi_oss_au_xml="caf_$qssi_au_tag.xml"
    [ "$qssi_oss_url" == "https://git.codelinaro.org" ] && qssi_oss_au_xml="$qssi_au_tag.xml"
    qssi_oss_manifest=$ROOT_PWD/$QSSI_OSS_DIR_NAME/.repo/manifests/$qssi_oss_au_xml
    qremote="cafq"
    echo "qssi OSS manifest = $qssi_oss_manifest, qremote = $qremote"
    xml1=$(cat "$qssi_oss_manifest" | remove_defaults)

    echo "Getting remotes"
    m1remotes=($(cat "$qssi_oss_manifest" |\
                 xmlstarlet sel -t -m '/manifest/remote' -v '@name' -o ' '\
                 ))
    echo "replacing remotes"
    for m1remote in "${m1remotes[@]}"; do
          xml1=$(echo "$xml1" | update_remote "$m1remote" "$qremote")
    done
    rm -rf $ROOT_PWD/qcafmanifest.xml
    {
      echo '<?xml version="1.0" encoding="UTF-8"?>
            <manifest>'

      echo "$xml1" | xmlstarlet sel -t -c '/manifest/*[not(self::project)]'
      echo "$xml1" | xmlstarlet sel -t -c "/manifest/project"

      echo '</manifest>'
    } |  xmlstarlet fo >> $ROOT_PWD/qcafmanifest.xml

    echo " qssi caf manifest processing is done"
    mv $ROOT_PWD/qcafmanifest.xml $ROOT_PWD/$QSSI_OSS_DIR_NAME/.repo/manifests/$qssi_oss_au_xml

    if [ "$found_kernel_au" = true ] ; then
      kernel_oss_au_xml="caf_$kernel_au_tag.xml"
      [ "$kernel_oss_url" == "https://git.codelinaro.org" ] && kernel_oss_au_xml="$kernel_au_tag.xml"
      kernel_oss_manifest=$ROOT_PWD/$KERNEL_OSS_DIR_NAME/.repo/manifests/$kernel_oss_au_xml
      qremote="cafk"
      echo "kernel OSS manifest = $kernel_oss_manifest, qremote = $qremote"
      xml1=$(cat "$kernel_oss_manifest" | remove_defaults)

      echo "Getting remotes"
      m1remotes=($(cat "$kernel_oss_manifest" |\
                 xmlstarlet sel -t -m '/manifest/remote' -v '@name' -o ' '\
                 ))
      echo "replacing remotes"
      for m1remote in "${m1remotes[@]}"; do
          xml1=$(echo "$xml1" | update_remote "$m1remote" "$qremote")
      done
      rm -rf $ROOT_PWD/kcafmanifest.xml
      {
        echo '<?xml version="1.0" encoding="UTF-8"?>
            <manifest>'

        echo "$xml1" | xmlstarlet sel -t -c '/manifest/*[not(self::project)]'
        echo "$xml1" | xmlstarlet sel -t -c "/manifest/project"

        echo '</manifest>'
      } |  xmlstarlet fo >> $ROOT_PWD/kcafmanifest.xml

      echo " kernel caf manifest processing is done"
      mv $ROOT_PWD/kcafmanifest.xml $ROOT_PWD/$KERNEL_OSS_DIR_NAME/.repo/manifests/$kernel_oss_au_xml
    fi
  fi

  if [[ "$prop_dest" == $PROP_DEST_GREASE  || "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]]; then
    if [ "$tree_type" == $QSSI_TREE_STANDALONE ] || [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
    then
      qssi_grease_manifest=$ROOT_PWD/$QSSI_PROP_DIR_NAME/.repo/manifests/${qssi_au_tag}.xml
      qremote="greaseq"
      echo "QSSI Grease manifest = $qssi_grease_manifest, qremote = $qremote"
      xml1=$(cat "$qssi_grease_manifest" | remove_defaults)

      echo "Getting remotes"
      m1remotes=($(cat "$qssi_grease_manifest" |\
                 xmlstarlet sel -t -m '/manifest/remote' -v '@name' -o ' '\
                 ))
      echo "replacing remotes"
      for m1remote in "${m1remotes[@]}"; do
          xml1=$(echo "$xml1" | update_remote "$m1remote" "$qremote")
      done
      rm -rf $ROOT_PWD/qgreasemanifest.xml
      {
        echo '<?xml version="1.0" encoding="UTF-8"?>
              <manifest>'

        echo "$xml1" | xmlstarlet sel -t -c '/manifest/*[not(self::project)]'
        echo "$xml1" | xmlstarlet sel -t -c "/manifest/project"

        echo '</manifest>'
      } |  xmlstarlet fo >> $ROOT_PWD/qgreasemanifest.xml

      echo " qssi grease manifest processing is done"
      mv $ROOT_PWD/qgreasemanifest.xml $ROOT_PWD/$QSSI_PROP_DIR_NAME/.repo/manifests/${qssi_au_tag}.xml
    fi

    if [ "$found_kernel_au" = true ] ; then
      kernel_grease_manifest=$ROOT_PWD/$KERNEL_PROP_DIR_NAME/.repo/manifests/${kernel_au_tag}.xml
      qremote="greasek"
      echo "Kernel Grease manifest = $kernel_grease_manifest, qremote = $qremote"
      xml1=$(cat "$kernel_grease_manifest" | remove_defaults)

      echo "Getting remotes"
      m1remotes=($(cat "$kernel_grease_manifest" |\
                 xmlstarlet sel -t -m '/manifest/remote' -v '@name' -o ' '\
                 ))
      echo "replacing remotes"
      for m1remote in "${m1remotes[@]}"; do
          xml1=$(echo "$xml1" | update_remote "$m1remote" "$qremote")
      done
      rm -rf $ROOT_PWD/kgreasemanifest.xml
      {
        echo '<?xml version="1.0" encoding="UTF-8"?>
            <manifest>'

        echo "$xml1" | xmlstarlet sel -t -c '/manifest/*[not(self::project)]'
        echo "$xml1" | xmlstarlet sel -t -c "/manifest/project"

        echo '</manifest>'
      } |  xmlstarlet fo >> $ROOT_PWD/kgreasemanifest.xml

      echo "Kernel grease manifest processing is done"
      mv $ROOT_PWD/kgreasemanifest.xml $ROOT_PWD/$KERNEL_PROP_DIR_NAME/.repo/manifests/${kernel_au_tag}.xml
    fi
    if [ "$tree_type" == $QSSI_TREE_STANDALONE ] || [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
    then
      if [[ "$prop_dest" == $PROP_DEST_GREASE ]];then
        echo "getting prebuilts for QSSI"
        # Test Grease Gerrit server connection
        set +e
        ssh -p 29418 ${grease_userid}@${grease_server}
        if [ $? -ne 127 ]; then
          echo "Please check your grease user name and password for correctness."
          usage
        fi
        set -e
        pushd $ROOT_PWD
        qssi_cdr_customer=$(dirname ${qssi_grease_branch})
        qssi_tar_file_gz="prebuilt_${qssi_cdr_customer}_${qssi_au_tag}.tar.gz"
        qssi_tar_file_xz="prebuilt_${qssi_cdr_customer}_${qssi_au_tag}.tar.xz"
        qssi_parent_branch=`echo ${qssi_grease_branch} | cut -d '/' -f2`
        qssi_tar_file_on_server_gz="https://${grease_server}/binaries/outgoing/${qssi_cdr_customer}/${qssi_parent_branch}/${qssi_tar_file_gz}"
        qssi_tar_file_on_server_xz="https://${grease_server}/binaries/outgoing/${qssi_cdr_customer}/${qssi_parent_branch}/${qssi_tar_file_xz}"
        ( wget --continue --no-check-certificate --user=$grease_userid \
         --password=$grease_pass $qssi_tar_file_on_server_gz ||
        wget --continue --no-check-certificate --user=$grease_userid \
         --password=$grease_pass $qssi_tar_file_on_server_xz)
        if [ "$found_kernel_au" = true ] ; then
          echo "getting QSSI prebuilts for Kernel platform"
          #Todo: KERNEL_PLATFORM has no binary shippable
        fi
      fi
    fi
  fi
fi #IF NOT VENDOR_TREE_STANDALONE

if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ] || [ "$tree_type" == $VENDOR_TREE_STANDALONE ]
then
  if [ -d $ROOT_PWD/$REPO_BACKUP_PATH/.repo ];then
    mv $ROOT_PWD/$REPO_BACKUP_PATH/.repo $ROOT_PWD/
  fi

  echo "Initializing local manifest"
  mkdir -p $ROOT_PWD/.repo/local_manifests
  if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
  then
    qssi_oss_au_xml="caf_${qssi_au_tag}.xml"
    [ "$qssi_oss_url" == "https://git.codelinaro.org" ] && qssi_oss_au_xml="${qssi_au_tag}.xml"
    if [ "$qssi_oss_url" == "https://git.codelinaro.org" ]; then
       cp $ROOT_PWD/$QSSI_OSS_DIR_NAME/.repo/manifests/$qssi_oss_au_xml $ROOT_PWD/.repo/local_manifests/cloq_$qssi_oss_au_xml
    else
       cp $ROOT_PWD/$QSSI_OSS_DIR_NAME/.repo/manifests/$qssi_oss_au_xml $ROOT_PWD/.repo/local_manifests/
    fi
    echo "QSSI OSS Manifest copied as local manifest to local_manifests"
    if [ "$found_kernel_au" = true ] ; then
      kernel_oss_au_xml="caf_${kernel_au_tag}.xml"
      [ "$kernel_oss_url" == "https://git.codelinaro.org" ] && kernel_oss_au_xml="${kernel_au_tag}.xml"
      if [ "$kernel_oss_url" == "https://git.codelinaro.org" ]; then
         cp $ROOT_PWD/$KERNEL_OSS_DIR_NAME/.repo/manifests/$kernel_oss_au_xml $ROOT_PWD/.repo/local_manifests/clok_$kernel_oss_au_xml
      else
         cp $ROOT_PWD/$KERNEL_OSS_DIR_NAME/.repo/manifests/$kernel_oss_au_xml $ROOT_PWD/.repo/local_manifests/
      fi
      echo "KERNEL OSS Manifest copied as local manifest to local_manifests"
    fi
  fi

  if [[ "$prop_dest" == $PROP_DEST_GREASE || "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]]; then
    vendor_grease_manifest=$ROOT_PWD/$VENDOR_PROP_DIR_NAME/.repo/manifests/${vendor_au_tag}.xml
    qremote="greasev"
    echo "Vendor Grease manifest = $vendor_grease_manifest, qremote = $qremote"
    xml1=$(cat "$vendor_grease_manifest" | remove_defaults)

    echo "Getting remotes"
    m1remotes=($(cat "$vendor_grease_manifest" |\
                 xmlstarlet sel -t -m '/manifest/remote' -v '@name' -o ' '\
                 ))
    echo "replacing remotes"
    for m1remote in "${m1remotes[@]}"; do
          xml1=$(echo "$xml1" | update_remote "$m1remote" "$qremote")
    done
    rm -rf $ROOT_PWD/vgreasemanifest.xml
    {
      echo '<?xml version="1.0" encoding="UTF-8"?>
            <manifest>'

      echo "$xml1" | xmlstarlet sel -t -c '/manifest/*[not(self::project)]'
      echo "$xml1" | xmlstarlet sel -t -c "/manifest/project"

      echo '</manifest>'
    } |  xmlstarlet fo >> $ROOT_PWD/vgreasemanifest.xml

    echo " vendor grease manifest processing is done"
    mv $ROOT_PWD/vgreasemanifest.xml $ROOT_PWD/$VENDOR_PROP_DIR_NAME/.repo/manifests/${vendor_au_tag}.xml

    cp $ROOT_PWD/$VENDOR_PROP_DIR_NAME/.repo/manifests/${vendor_au_tag}.xml $ROOT_PWD/.repo/local_manifests/
    echo "Vendor Grease Manifest copied as local manifest to Vendor"

    if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
    then
      cp $ROOT_PWD/$QSSI_PROP_DIR_NAME/.repo/manifests/${qssi_au_tag}.xml $ROOT_PWD/.repo/local_manifests/
      echo "QSSI Grease Manifest copied as local manifest to Vendor"
      if [ "$found_kernel_au" = true ] ; then
        cp $ROOT_PWD/$KERNEL_PROP_DIR_NAME/.repo/manifests/${kernel_au_tag}.xml $ROOT_PWD/.repo/local_manifests/
        echo "Kernel Grease Manifest copied as local manifest to Vendor"
      fi
    fi

    if [[ "$prop_dest" == $PROP_DEST_GREASE ]];then
      echo "getting prebuilts"
      # Test Grease Gerrit server connection
      set +e
      ssh -p 29418 ${grease_userid}@${grease_server}
      if [ $? -ne 127 ]; then
        echo "Please check your grease user name and password for correctness."
        usage
      fi
      set -e
      pushd $ROOT_PWD
      vendor_cdr_customer=$(dirname ${vendor_grease_branch})
      vendor_tar_file_gz="prebuilt_${vendor_cdr_customer}_${vendor_au_tag}.tar.gz"
      vendor_tar_file_xz="prebuilt_${vendor_cdr_customer}_${vendor_au_tag}.tar.xz"
      vendor_parent_branch=`echo ${vendor_grease_branch} | cut -d '/' -f2`
      vendor_tar_file_on_server_gz="https://${grease_server}/binaries/outgoing/${vendor_cdr_customer}/${vendor_parent_branch}/${vendor_tar_file_gz}"
      vendor_tar_file_on_server_xz="https://${grease_server}/binaries/outgoing/${vendor_cdr_customer}/${vendor_parent_branch}/${vendor_tar_file_xz}"
     ( wget --continue --no-check-certificate --user=$grease_userid \
         --password=$grease_pass $vendor_tar_file_on_server_gz ||
       wget --continue --no-check-certificate --user=$grease_userid \
         --password=$grease_pass $vendor_tar_file_on_server_xz)
    fi
  fi

  # Move old prebuilt dirs
  prebuilt_dirs="$ROOT_PWD/$PREBUILT_HY11_PATH $ROOT_PWD/$PREBUILT_GREASE_PATH"
  datetime="$(date +%F_%H.%M.%S)"
  for dir in $prebuilt_dirs; do
      if [ -d "$dir" ]; then
          mv $dir ${dir}.$datetime
      fi
  done

  pushd $ROOT_PWD
  if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
    echo "Getting chipcode content, takes several minutes"
    mkdir -p  $ROOT_PWD/vendor/qcom
    cp -r $vendor_chipcode_path/$PROP_PATH $ROOT_PWD/vendor/qcom/
    if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
    then
      cp -r $qssi_chipcode_path/$PROP_PATH/* $ROOT_PWD/$PROP_PATH/
      if [ "$found_kernel_au" = true ] ; then
         if kernel_chipcode_args_check
         then
           mkdir -p  $ROOT_PWD/$KERNEL_PLATFORM_PATH
           cp -r $kernel_chipcode_path/* $ROOT_PWD/$KERNEL_PLATFORM_PATH/
         fi
      fi
      if [ ! -z $groups ] && [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
          remove_common_sys_prjs
      fi
    fi
  fi
  rm -rf $ROOT_PWD/$VENDOR_PROP_DIR_NAME
  rm -rf $ROOT_PWD/$VENDOR_OSS_DIR_NAME
  rm -rf $ROOT_PWD/$QSSI_OSS_DIR_NAME
  rm -rf $ROOT_PWD/$QSSI_PROP_DIR_NAME
  rm -rf $ROOT_PWD/$KERNEL_OSS_DIR_NAME
  rm -rf $ROOT_PWD/$KERNEL_PROP_DIR_NAME
  echo "Tree sync initiated"
  pushd $ROOT_PWD
  sleep 2
  repo manifest > $COMBINED_MANIFEST
  echo "Combined Manifest generated"
  if [ ! -z "$optional_sync_arg" ]; then
    echo "python3.6 /bin/repo sync -j${jobs} $optional_sync_arg"
    python3.6 /bin/repo sync -j${jobs} $optional_sync_arg
  else
    echo "python3.6 /bin/repo sync -j${jobs}"
    python3.6 /bin/repo sync -j${jobs}
  fi
  echo "python3.6 /bin/repo sync successful"

  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
    echo "extracting prebuilts"
    if [ -e prebuilt_${vendor_cdr_customer}_${vendor_au_tag}.tar.gz ]; then
      tar -zxvf prebuilt_${vendor_cdr_customer}_${vendor_au_tag}.tar.gz
    else
      tar -xvf prebuilt_${vendor_cdr_customer}_${vendor_au_tag}.tar.xz
    fi
    if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
    then
      if [ -e prebuilt_${qssi_cdr_customer}_${qssi_au_tag}.tar.gz ]; then
        tar -zxvf prebuilt_${qssi_cdr_customer}_${qssi_au_tag}.tar.gz
      else
        tar -xvf prebuilt_${qssi_cdr_customer}_${qssi_au_tag}.tar.xz
      fi
    fi
  fi

  if [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]
  then
    if [ "$tree_type" == $LA_COMBINED_TREE ]; then
      echo "LA_COMBINED_TREE is ready"
    fi
    if [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
      echo "LA_COMBINED_TREE with groups option is ready"
    fi
  else
    echo "VENDOR_STANDALONE_TREE is ready"
  fi

fi #"$tree_type" = $LA_COMBINED_TREE

if [ "$tree_type" == $QSSI_TREE_STANDALONE ]; then
  mkdir -p $ROOT_PWD/.repo/local_manifests
  if [[ "$prop_dest" == $PROP_DEST_GREASE || "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]]; then

    cp $ROOT_PWD/$QSSI_PROP_DIR_NAME/.repo/manifests/${qssi_au_tag}.xml $ROOT_PWD/.repo/local_manifests/
    echo "QSSI Grease Manifest copied as local manifest to Vendor"
  fi

  pushd $ROOT_PWD
  # Move old prebuilt dirs
  prebuilt_dirs="$ROOT_PWD/$PREBUILT_HY11_PATH $ROOT_PWD/$PREBUILT_GREASE_PATH"
  datetime="$(date +%F_%H.%M.%S)"
  for dir in $prebuilt_dirs; do
      if [ -d "$dir" ]; then
          mv $dir ${dir}.$datetime
      fi
  done

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
    echo "Getting chipcode content, takes several minutes"
    mkdir -p  $ROOT_PWD/vendor/qcom
    cp -r $qssi_chipcode_path/$PROP_PATH/ $ROOT_PWD/vendor/qcom/
  fi
  echo "QSSI_tree code sync initiated"
  pushd $ROOT_PWD
  sleep 2
  python3.6 /bin/repo manifest > $COMBINED_MANIFEST
  echo "Combined Manifest generated"
  if [ ! -z "$optional_sync_arg" ]; then
    echo "python3.6 /bin/repo sync -j${jobs} $optional_sync_arg"
    python3.6 /bin/repo sync -j${jobs} $optional_sync_arg
  else
    echo "python3.6 /bin/repo sync -j${jobs}"
    python3.6 /bin/repo sync -j${jobs}
  fi
  echo "python3.6 /bin/repo sync successful"


  if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
    echo "extracting prebuilts"
    if [ -e prebuilt_${qssi_cdr_customer}_${qssi_au_tag}.tar.gz ]; then
      tar -zxvf prebuilt_${qssi_cdr_customer}_${qssi_au_tag}.tar.gz
    else
      tar -xvf prebuilt_${qssi_cdr_customer}_${qssi_au_tag}.tar.xz
    fi
  fi
  rm -rf $ROOT_PWD/$QSSI_PROP_DIR_NAME
  rm -rf $ROOT_PWD/$QSSI_OSS_DIR_NAME
  echo "QSSI_STANDALONE_TREE is ready"
fi #"$tree_type" = $QSSI_TREE_STANDALONE

if [ "$tree_type" == $KERNEL_TREE_STANDALONE ]; then
  mkdir -p $ROOT_PWD/.repo/local_manifests
  if [[ "$prop_dest" == $PROP_DEST_GREASE || "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]]; then

    cp $ROOT_PWD/$KERNEL_PROP_DIR_NAME/.repo/manifests/${kernel_au_tag}.xml $ROOT_PWD/.repo/local_manifests/
    echo "KERNEL SI Grease Manifest copied as local manifest to Vendor"
  fi

  pushd $ROOT_PWD
  # Move old prebuilt dirs
  prebuilt_dirs="$ROOT_PWD/$PREBUILT_HY11_PATH $ROOT_PWD/$PREBUILT_GREASE_PATH"
  datetime="$(date +%F_%H.%M.%S)"
  for dir in $prebuilt_dirs; do
      if [ -d "$dir" ]; then
          mv $dir ${dir}.$datetime
      fi
  done

  if [ "$prop_dest" == $PROP_DEST_CHIPCODE ]; then
    echo "Getting chipcode content, takes several minutes"
    mkdir -p  $ROOT_PWD/$KERNEL_PLATFORM_PATH
    cp -r $kernel_chipcode_path/* $ROOT_PWD/$KERNEL_PLATFORM_PATH/
  fi
  pushd $ROOT_PWD
  sleep 2
  repo manifest > $COMBINED_MANIFEST
  echo "Combined Manifest generated"
  if [ ! -z "$optional_sync_arg" ]; then
    echo "python3.6 /bin/repo sync -j${jobs} $optional_sync_arg"
    python3.6 /bin/repo sync -j${jobs} $optional_sync_arg
  else
    echo "python3.6 /bin/repo sync -j${jobs}"
    python3.6 /bin/repo sync -j${jobs}
  fi
  echo "python3.6 /bin/repo sync successful"

  # commenting this part as there are no binary deliverables
  #if [ "$prop_dest" == $PROP_DEST_GREASE ]; then
  #  echo "extracting prebuilts"
  #  if [ -e prebuilt_${kernel_cdr_customer}_${kernel_au_tag}.tar.gz ]; then
  #    tar -zxvf prebuilt_${kernel_cdr_customer}_${kernel_au_tag}.tar.gz
  #  else
  #    tar -xvf prebuilt_${kernel_cdr_customer}_${kernel_au_tag}.tar.xz
  #  fi
  #fi
  rm -rf $ROOT_PWD/$KERNEL_PROP_DIR_NAME
  rm -rf $ROOT_PWD/$KERNEL_OSS_DIR_NAME
  echo "KERNEL_STANDALONE_TREE is ready"
fi #"$tree_type" = $KERNEL_TREE_STANDALONE

if [ "$prop_dest" == $PROP_DEST_CHIPCODE_HF ]; then
   if [ "$tree_type" == $QSSI_TREE_STANDALONE ] || [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
      cp -rf $ROOT_PWD/system_prebuilt_dir/vendor/qcom/proprietary/prebuilt_HY11 $ROOT_PWD/vendor/qcom/proprietary/
      rm -rf $ROOT_PWD/system_prebuilt_dir || true
   fi
   if [ "$tree_type" == $KERNEL_TREE_STANDALONE ] || [ "$tree_type" == $LA_COMBINED_TREE ] || [ "$tree_type" == $LA_COMBINED_TREE_GROUPS ]; then
      if [ -d "$ROOT_PWD/kernel_prebuilt_dir" ]; then
         cp -rf $ROOT_PWD/kernel_prebuilt_dir/kernel_platform/qcom/proprietary/prebuilt_HY11 $ROOT_PWD/kernel_platform/qcom/proprietary/
         rm -rf $ROOT_PWD/kernel_prebuilt_dir || true
      fi
   fi
fi

  移动开发 最新文章
Vue3装载axios和element-ui
android adb cmd
【xcode】Xcode常用快捷键与技巧
Android开发中的线程池使用
Java 和 Android 的 Base64
Android 测试文字编码格式
微信小程序支付
安卓权限记录
知乎之自动养号
【Android Jetpack】DataStore
上一篇文章      下一篇文章      查看所有文章
加:2021-12-16 17:47:32  更:2021-12-16 17:49:22 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 8:56:54-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码