blob: 46df1aa17d2f51b374cd04f2ed53d57d64d3e5c4 [file] [log] [blame]
Jackie Huangb573a2b2019-11-15 16:41:46 +08001#!/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.
18set -e -o pipefail
19
20help_info () {
21cat << ENDHELP
22This script is used to genereate package-index and output the path
23of rpm packages and index files, it must be ran after build_oran.sh
24Usage:
25$(basename $0) [-w WORKSPACE_DIR] [-n] [-h]
26where:
27 -w WORKSPACE_DIR is the path for the project
28 -n dry-run only for bitbake
29 -h this help info
30ENDHELP
31}
32
33echo_info () {
34 echo "INFO: $1"
35}
36
37echo_error () {
38 echo "ERROR: $1"
39}
40
41echo_cmd () {
42 echo
43 echo_info "$1"
44 echo "CMD: ${RUN_CMD}"
45}
46
47DRYRUN=""
48RECIPE_LIST=""
49SCRIPTS_DIR=`dirname $0`
50SCRIPTS_DIR=`readlink -f $SCRIPTS_DIR`
51
52while 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
65done
66
67if [ -z ${WORKSPACE} ]; then
68 echo_info "No workspace specified, assume './workspace'"
69 WORKSPACE=`readlink -f workspace`
70fi
71
72if [ ! -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
78fi
79
80SRC_WRL_DIR=${WORKSPACE}/src_wrl1018
81SRC_ORAN_DIR=${WORKSPACE}/src_oran
82PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf
83RPM_REPO_LIST=${SRC_ORAN_DIR}/rtp/scripts/rpm_repo_list.txt
84RPM_DEPLOY_DIR=${PRJ_BUILD_DIR}/tmp-glibc/deploy/rpm
85RPM_REPODATA=${RPM_DEPLOY_DIR}/repodata
86
87echo_info "For wrlinux1018 source: ${SRC_WRL_DIR}"
88echo_info "For oran layer source: ${SRC_ORAN_DIR}"
89echo_info "For build project: ${PRJ_BUILD_DIR}"
90
91# Source the build env
92cd ${SRC_WRL_DIR}
93. ./environment-setup-x86_64-wrlinuxsdk-linux
94set ${PRJ_BUILD_DIR}
95. ./oe-init-build-env ${PRJ_BUILD_DIR}
96
97mkdir -p logs
98TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
99
100RECIPE_LIST=`grep -v '^#' ${RPM_REPO_LIST}|awk '{print $1}'|sort|uniq`
101RPM_PKG_LIST=`grep -v '^#' ${RPM_REPO_LIST}|awk '{print $2}'|sort|uniq`
102
103if [ -z "${RECIPE_LIST}" ]; then
104 echo_info "The recipes list is empty, nothing to do!!"
105 exit 0
106fi
107
108# Build the recipes
109RUN_CMD="bitbake ${DRYRUN} ${RECIPE_LIST}"
110echo_cmd "Build the recipes: '${RECIPE_LIST}'"
111bitbake ${DRYRUN} ${RECIPE_LIST} 2>&1|tee logs/bitbake_recipes_${TIMESTAMP}.log
112
113# Build the package-index
114RUN_CMD="bitbake ${DRYRUN} package-index"
115echo_cmd "Build the package-index'"
116bitbake ${DRYRUN} package-index 2>&1|tee logs/bitbake_package-index_${TIMESTAMP}.log
117
118echo_info "Build succeeded"
119
120echo_info "Package index files"
121find ${RPM_REPODATA}
122
123echo_info "RPM files"
124for i in ${RPM_PKG_LIST}; do
125 readlink -f ${RPM_DEPLOY_DIR}/*/$i
126done