Add layer meta-stx-oran and distro poky-stx-oran
[pti/rtp.git] / scripts / build_inf.sh
index 2985c82..7ae268e 100755 (executable)
@@ -30,18 +30,20 @@ SRC_YP_BRANCH="warrior"
 
 SRC_ORAN_URL="https://gerrit.o-ran-sc.org/r/pti/rtp"
 
+SRC_STX_URL="https://opendev.org/starlingx/meta-starlingx"
+
 SRC_YP_URL="\
-    git://git.yoctoproject.org/poky \
-    git://git.openembedded.org/meta-openembedded \
-    git://git.yoctoproject.org/meta-virtualization \
-    git://git.yoctoproject.org/meta-cloud-services \
-    git://git.yoctoproject.org/meta-security \
-    git://git.yoctoproject.org/meta-intel \
-    git://git.yoctoproject.org/meta-selinux \
-    https://github.com/intel-iot-devkit/meta-iot-cloud \
-    git://git.openembedded.org/meta-python2 \
-    https://git.yoctoproject.org/git/meta-dpdk \
-    git://git.yoctoproject.org/meta-anaconda \
+    git://git.yoctoproject.org/poky;commit=HEAD \
+    git://git.openembedded.org/meta-openembedded;commit=HEAD \
+    git://git.openembedded.org/meta-python2;commit=HEAD \
+    git://git.yoctoproject.org/meta-virtualization;commit=HEAD \
+    git://git.yoctoproject.org/meta-cloud-services;commit=HEAD \
+    git://git.yoctoproject.org/meta-security;commit=HEAD \
+    git://git.yoctoproject.org/meta-intel;commit=HEAD \
+    git://git.yoctoproject.org/meta-selinux;commit=HEAD \
+    git://git.yoctoproject.org/meta-dpdk;commit=HEAD \
+    git://git.yoctoproject.org/meta-anaconda;commit=HEAD \
+    git://github.com/intel-iot-devkit/meta-iot-cloud;commit=HEAD \
 "
 
 SUB_LAYER_META_OE="\
@@ -57,7 +59,13 @@ SUB_LAYER_META_OE="\
 "
 
 SUB_LAYER_META_CLOUD_SERVICES="meta-openstack"
-SUB_LAYER_META_SECURITY="meta-security-compliance"
+SUB_LAYER_STX="\
+    meta-stx-cloud \
+    meta-stx-distro \
+    meta-stx-flock \
+    meta-stx-integ \
+    meta-stx-virt \
+"
 
 # For anaconda build
 SUB_LAYER_META_OE_ANACONDA="\
@@ -79,16 +87,16 @@ TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
 help_info () {
 cat << ENDHELP
 Usage:
-$(basename $0) [-w WORKSPACE_DIR] [-b BSP] [-n] [-h] [-r Yes|No] [-s] [-e EXTRA_CONF]
+$(basename $0) [-w WORKSPACE_DIR] [-b BSP] [-n] [-u] [-h] [-r Yes|No] [-e EXTRA_CONF]
 where:
     -w WORKSPACE_DIR is the path for the project
     -b BPS is one of supported BSP: "${SUPPORTED_BSP}"
        (default is intel-corei7-64 if not specified.)
     -n dry-run only for bitbake
+    -u update the repo if it exists
     -h this help info
     -e EXTRA_CONF is the pat for extra config file
     -r whether to inherit rm_work (default is Yes)
-    -s whether to skip update the repo if already exists
 examples:
 $0
 $0 -w workspace_1234 -r no -e /path/to/extra_local.conf
@@ -160,6 +168,7 @@ clone_update_repo () {
     REPO_BRANCH=$1
     REPO_URL=$2
     REPO_NAME=$3
+    REPO_COMMIT=$4
 
     if [ -d ${REPO_NAME}/.git ]; then
         if [ "${SKIP_UPDATE}" == "Yes" ]; then
@@ -175,6 +184,14 @@ clone_update_repo () {
         RUN_CMD="git clone --branch ${REPO_BRANCH} ${REPO_URL} ${REPO_NAME}"
         echo_cmd "Cloning the source of repo '${REPO_NAME}':"
         ${RUN_CMD}
+
+        if [ -n "${REPO_COMMIT}" ]; then
+            cd ${REPO_NAME}
+            RUN_CMD="git checkout -b ${REPO_BRANCH}-${REPO_COMMIT} ${REPO_COMMIT}"
+            echo_cmd "Checkout the repo ${REPO_NAME} to specific commit: ${REPO_COMMIT}"
+            ${RUN_CMD}
+            cd -
+        fi
     fi
 }
 
@@ -191,11 +208,11 @@ source_env () {
 
 DRYRUN=""
 EXTRA_CONF=""
-SKIP_UPDATE="No"
+SKIP_UPDATE="Yes"
 RM_WORK="Yes"
 BSP="intel-corei7-64"
 
-while getopts "w:b:e:r:nsh" OPTION; do
+while getopts "w:b:e:r:unh" OPTION; do
     case ${OPTION} in
         w)
             WORKSPACE=`readlink -f ${OPTARG}`
@@ -209,9 +226,9 @@ while getopts "w:b:e:r:nsh" OPTION; do
         n)
             DRYRUN="-n"
             ;;
-        s)
-            SKIP_UPDATE="Yes"
-            ;;
+        u)
+            SKIP_UPDATE="No"
+           ;;
         r)
             check_yn_rm_work ${OPTARG}
             ;;
@@ -236,6 +253,7 @@ fi
 #########################################################################
 SRC_LAYER_DIR=${WORKSPACE}/src_layers
 SRC_ORAN_DIR=${SRC_LAYER_DIR}/oran
+SRC_STX_DIR=${SRC_LAYER_DIR}/meta-starlingx
 PRJ_BUILD_DIR=${WORKSPACE}/prj_oran_stx
 PRJ_BUILD_DIR_ANACONDA=${WORKSPACE}/prj_oran_inf_anaconda
 PRJ_SHARED_DIR=${WORKSPACE}/prj_shared
@@ -275,10 +293,9 @@ prepare_src () {
         echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}"
         mkdir -p ${SRC_ORAN_DIR}/rtp
         cd ${SRC_ORAN_DIR}/rtp
-        rm -rf meta-oran meta-stx scripts
-        ln -sf ${CLONED_ORAN_REPO}/meta-oran meta-oran
-        ln -sf ${CLONED_ORAN_REPO}/meta-stx meta-stx
+        rm -rf meta-stx-oran scripts
         ln -sf ${CLONED_ORAN_REPO}/scripts scripts
+        ln -sf ${CLONED_ORAN_REPO}/meta-stx-oran meta-stx-oran
     else
         echo_info "Cloning oran layer:"
         cd ${SRC_ORAN_DIR}
@@ -289,29 +306,35 @@ prepare_src () {
 
     cd ${SRC_LAYER_DIR}
     for layer_url in ${SRC_YP_URL}; do
-        layer_name=$(basename ${layer_url})
-        clone_update_repo ${SRC_YP_BRANCH} ${layer_url} ${layer_name}
+        layer_name=$(basename ${layer_url%%;commit*})
+        layer_commit=$(basename ${layer_url##*;commit=})
+        clone_update_repo ${SRC_YP_BRANCH} ${layer_url%%;commit*} ${layer_name} ${layer_commit}
     done
 
+    echo_info "Cloning or update meta-starlingx layers:"
+    clone_update_repo ${SRC_STX_BRANCH} ${SRC_STX_URL} $(basename ${SRC_STX_URL})
+
     echo_step_end
 
-    # Apply meta patches
-    for l in $(ls -1 ${SRC_META_PATCHES}); do
-        msg_step="Apply meta patches for ${l}"
-        echo_step_start
-        cd ${SRC_LAYER_DIR}/${l}
-
-        # backup current branch
-        local_branch=$(git rev-parse --abbrev-ref HEAD)
-        git branch -m "${local_branch}_${TIMESTAMP}"
-        git checkout ${local_branch}
-
-        for p in $(ls -1 ${SRC_META_PATCHES}/${l}); do
-            echo_info "Apllying patch: ${SRC_META_PATCHES}/${l}/${p}"
-            git am ${SRC_META_PATCHES}/${l}/${p}
-        done
-        echo_step_end
-    done
+# Not andy meta-patch is needed for the time being, but new ones may be needed and added
+# sometime in the future, so just leave these code commented out here.
+#    # Apply meta patches
+#    for l in $(ls -1 ${SRC_META_PATCHES}); do
+#        msg_step="Apply meta patches for ${l}"
+#        echo_step_start
+#        cd ${SRC_LAYER_DIR}/${l}
+#
+#        # backup current branch
+#        local_branch=$(git rev-parse --abbrev-ref HEAD)
+#        git branch -m "${local_branch}_${TIMESTAMP}"
+#        git checkout -b ${local_branch} ${local_branch##*-}
+#
+#        for p in $(ls -1 ${SRC_META_PATCHES}/${l}); do
+#            echo_info "Apllying patch: ${SRC_META_PATCHES}/${l}/${p}"
+#            git am ${SRC_META_PATCHES}/${l}/${p}
+#        done
+#        echo_step_end
+#    done
 }
 
 add_layer_stx_build () {
@@ -320,8 +343,8 @@ add_layer_stx_build () {
 
     source_env ${PRJ_BUILD_DIR}
     SRC_LAYERS=""
-    for layer_url in ${SRC_YP_URL}; do
-        layer_name=$(basename ${layer_url})
+    for layer_url in ${SRC_YP_URL} ${SRC_STX_URL}; do
+        layer_name=$(basename ${layer_url%%;commit*})
         case ${layer_name} in
         poky)
             continue
@@ -337,10 +360,9 @@ add_layer_stx_build () {
                 SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}/${sub_layer}"
             done
             ;;
-        meta-security)
-            SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}"
-            for sub_layer in ${SUB_LAYER_META_SECURITY}; do
-                SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/${layer_name}/${sub_layer}"
+        meta-starlingx)
+            for sub_layer in ${SUB_LAYER_STX}; do
+                SRC_LAYERS="${SRC_LAYERS} ${SRC_STX_DIR}/${sub_layer}"
             done
             ;;
         *)
@@ -349,8 +371,8 @@ add_layer_stx_build () {
 
         esac
     done
+    SRC_LAYERS="${SRC_LAYERS} ${SRC_ORAN_DIR}/rtp/meta-stx-oran"
 
-    SRC_LAYERS="${SRC_LAYERS} ${SRC_ORAN_DIR}/rtp/meta-stx"
 
     for src_layer in ${SRC_LAYERS}; do
         RUN_CMD="bitbake-layers add-layer ${src_layer}"
@@ -369,12 +391,14 @@ add_configs_stx_build () {
     echo_info "Adding the following extra configs into local.conf"
     cat ${SRC_CONFIGS}/local-stx.conf | \
         sed -e "s/@BSP@/${BSP}/" | tee -a conf/local.conf
+    cat ${SRC_CONFIGS}/local-mirrors.conf | tee -a conf/local.conf
 
     echo "DL_DIR = '${PRJ_SHARED_DL_DIR}'" | tee -a conf/local.conf
     echo "SSTATE_DIR = '${PRJ_SHARED_SS_DIR}'" | tee -a conf/local.conf
 
     if [ "${RM_WORK}" == "Yes" ]; then
         echo "INHERIT += 'rm_work'" | tee -a conf/local.conf
+        echo "RM_WORK_EXCLUDE += '${IMG_STX}'" | tee -a conf/local.conf
     fi
 
 
@@ -427,7 +451,9 @@ add_layer_anaconda_build () {
     done
     SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/meta-intel"
     SRC_LAYERS="${SRC_LAYERS} ${SRC_LAYER_DIR}/meta-anaconda"
-    SRC_LAYERS="${SRC_LAYERS} ${SRC_ORAN_DIR}/rtp/meta-stx"
+    SRC_LAYERS="${SRC_LAYERS} ${SRC_STX_DIR}/meta-stx-distro"
+    SRC_LAYERS="${SRC_LAYERS} ${SRC_STX_DIR}/meta-stx-integ"
+    SRC_LAYERS="${SRC_LAYERS} ${SRC_ORAN_DIR}/rtp/meta-stx-oran"
 
     for src_layer in ${SRC_LAYERS}; do
         RUN_CMD="bitbake-layers add-layer ${src_layer}"
@@ -448,12 +474,14 @@ add_configs_anaconda_build () {
         sed -e "s/@BSP@/${BSP}/" \
             -e "s|@TARGET_BUILD@|${PRJ_BUILD_DIR}|" \
             | tee -a conf/local.conf
+    cat ${SRC_CONFIGS}/local-mirrors.conf | tee -a conf/local.conf
 
     echo "DL_DIR = '${PRJ_SHARED_DL_DIR}'" | tee -a conf/local.conf
     echo "SSTATE_DIR = '${PRJ_SHARED_SS_DIR}'" | tee -a conf/local.conf
 
     if [ "${RM_WORK}" == "Yes" ]; then
         echo "INHERIT += 'rm_work'" | tee -a conf/local.conf
+        echo "RM_WORK_EXCLUDE += '${IMG_ANACONDA}'" | tee -a conf/local.conf
     fi
 
     if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then