Jackie Huang | b573a2b | 2019-11-15 16:41:46 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2019 Wind River Systems, Inc. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Ensure we fail the job if any steps fail. |
| 18 | set -e -o pipefail |
| 19 | |
| 20 | help_info () { |
| 21 | cat << ENDHELP |
| 22 | This script is used to genereate package-index and output the path |
| 23 | of rpm packages and index files, it must be ran after build_oran.sh |
| 24 | Usage: |
| 25 | $(basename $0) [-w WORKSPACE_DIR] [-n] [-h] |
| 26 | where: |
| 27 | -w WORKSPACE_DIR is the path for the project |
| 28 | -n dry-run only for bitbake |
| 29 | -h this help info |
| 30 | ENDHELP |
| 31 | } |
| 32 | |
| 33 | echo_info () { |
| 34 | echo "INFO: $1" |
| 35 | } |
| 36 | |
| 37 | echo_error () { |
| 38 | echo "ERROR: $1" |
| 39 | } |
| 40 | |
| 41 | echo_cmd () { |
| 42 | echo |
| 43 | echo_info "$1" |
| 44 | echo "CMD: ${RUN_CMD}" |
| 45 | } |
| 46 | |
| 47 | DRYRUN="" |
| 48 | RECIPE_LIST="" |
| 49 | SCRIPTS_DIR=`dirname $0` |
| 50 | SCRIPTS_DIR=`readlink -f $SCRIPTS_DIR` |
| 51 | |
| 52 | while getopts "w:nh" OPTION; do |
| 53 | case ${OPTION} in |
| 54 | w) |
| 55 | WORKSPACE=`readlink -f ${OPTARG}` |
| 56 | ;; |
| 57 | n) |
| 58 | DRYRUN="-n" |
| 59 | ;; |
| 60 | h) |
| 61 | help_info |
| 62 | exit |
| 63 | ;; |
| 64 | esac |
| 65 | done |
| 66 | |
| 67 | if [ -z ${WORKSPACE} ]; then |
| 68 | echo_info "No workspace specified, assume './workspace'" |
| 69 | WORKSPACE=`readlink -f workspace` |
| 70 | fi |
| 71 | |
| 72 | if [ ! -d ${WORKSPACE} ]; then |
| 73 | echo_error "The workspace ${WORKSPACE} doesn't exist!!" |
| 74 | echo_error "You need to run build_oran.sh to create a valid worksapce and build image first." |
| 75 | echo_error "Then run this script with -w option to specify the correct path of the worksapce." |
| 76 | help_info |
| 77 | exit 1 |
| 78 | fi |
| 79 | |
| 80 | SRC_WRL_DIR=${WORKSPACE}/src_wrl1018 |
| 81 | SRC_ORAN_DIR=${WORKSPACE}/src_oran |
| 82 | PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf |
| 83 | RPM_REPO_LIST=${SRC_ORAN_DIR}/rtp/scripts/rpm_repo_list.txt |
| 84 | RPM_DEPLOY_DIR=${PRJ_BUILD_DIR}/tmp-glibc/deploy/rpm |
| 85 | RPM_REPODATA=${RPM_DEPLOY_DIR}/repodata |
| 86 | |
| 87 | echo_info "For wrlinux1018 source: ${SRC_WRL_DIR}" |
| 88 | echo_info "For oran layer source: ${SRC_ORAN_DIR}" |
| 89 | echo_info "For build project: ${PRJ_BUILD_DIR}" |
| 90 | |
| 91 | # Source the build env |
| 92 | cd ${SRC_WRL_DIR} |
| 93 | . ./environment-setup-x86_64-wrlinuxsdk-linux |
| 94 | set ${PRJ_BUILD_DIR} |
| 95 | . ./oe-init-build-env ${PRJ_BUILD_DIR} |
| 96 | |
| 97 | mkdir -p logs |
| 98 | TIMESTAMP=`date +"%Y%m%d_%H%M%S"` |
| 99 | |
| 100 | RECIPE_LIST=`grep -v '^#' ${RPM_REPO_LIST}|awk '{print $1}'|sort|uniq` |
| 101 | RPM_PKG_LIST=`grep -v '^#' ${RPM_REPO_LIST}|awk '{print $2}'|sort|uniq` |
| 102 | |
| 103 | if [ -z "${RECIPE_LIST}" ]; then |
| 104 | echo_info "The recipes list is empty, nothing to do!!" |
| 105 | exit 0 |
| 106 | fi |
| 107 | |
| 108 | # Build the recipes |
| 109 | RUN_CMD="bitbake ${DRYRUN} ${RECIPE_LIST}" |
| 110 | echo_cmd "Build the recipes: '${RECIPE_LIST}'" |
| 111 | bitbake ${DRYRUN} ${RECIPE_LIST} 2>&1|tee logs/bitbake_recipes_${TIMESTAMP}.log |
| 112 | |
| 113 | # Build the package-index |
| 114 | RUN_CMD="bitbake ${DRYRUN} package-index" |
| 115 | echo_cmd "Build the package-index'" |
| 116 | bitbake ${DRYRUN} package-index 2>&1|tee logs/bitbake_package-index_${TIMESTAMP}.log |
| 117 | |
| 118 | echo_info "Build succeeded" |
| 119 | |
| 120 | echo_info "Package index files" |
| 121 | find ${RPM_REPODATA} |
| 122 | |
| 123 | echo_info "RPM files" |
| 124 | for i in ${RPM_PKG_LIST}; do |
| 125 | readlink -f ${RPM_DEPLOY_DIR}/*/$i |
| 126 | done |