blob: 0db73d8cf3db5e01131269815d3e3be46f055cfb [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001#!/bin/bash
2###############################################################################
3#
4# <:copyright-BRCM:2016:proprietary:standard
5#
6# Broadcom Ltd. Proprietary and Confidential.(c) 2016 Broadcom Ltd.
7# All Rights Reserved
8#
9# This program is the proprietary software of Broadcom Ltd. and/or its
10# licensors, and may only be used, duplicated, modified or distributed pursuant
11# to the terms and conditions of a separate, written license agreement executed
12# between you and Broadcom Ltd. (an "Authorized License"). Except as set forth in
13# an Authorized License, Broadcom Ltd. grants no license (express or implied), right
14# to use, or waiver of any kind with respect to the Software, and Broadcom Ltd.
15# expressly reserves all rights in and to the Software and all intellectual
16# property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE
17# NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY
18# BROADCOM LTD AND DISCONTINUE ALL USE OF THE SOFTWARE.
19#
20# Except as expressly set forth in the Authorized License,
21#
22# 1. This program, including its structure, sequence and organization,
23# constitutes the valuable trade secrets of Broadcom Ltd., and you shall use
24# all reasonable efforts to protect the confidentiality thereof, and to
25# use this information only in connection with your use of Broadcom Ltd.
26# integrated circuit products.
27#
28# 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29# AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
30# WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
31# RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND
32# ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT,
33# FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
34# COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE
35# TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF USE OR
36# PERFORMANCE OF THE SOFTWARE.
37#
38# 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
39# ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL,
40# INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY
41# WAY RELATING TO YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN
42# IF BROADCOM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES;
43# OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
44# SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE LIMITATIONS
45# SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY
46# LIMITED REMEDY.
47# :>
48#
49###############################################################################
50
51# This script is called from the main Makefile.
52# Prerequisites:
53# 1. BAL standalone or ofpal_of_agent binaries are built.
54# 2. Environment variables defined:
55# - SRC_RELEASE_FILE_PREFIX : source release file prefix (string)
56# - INCLUDE_MAPLE_SDK_RELEASE : include maple SDK release (if set, then Maple SDK release is included, and its zip actually contains BAL's code, without OMCI and SDN-PAL).
57
58if [[ "$SRC_RELEASE_FILE_PREFIX" == "" ]]; then
59 echo SRC_RELEASE_FILE_PREFIX variable must be set
60 exit -1
61fi
62
63TMP_DIR=/tmp/bal_src_release/`date +%d_%m_%Y_%H_%M_%S`
64
65BAL_RELEASE_PREFIX=bal.$SRC_RELEASE_FILE_PREFIX
66SDN_PAL_RELEASE_PREFIX=sdn_pal.$SRC_RELEASE_FILE_PREFIX
67OMCI_RELEASE_PREFIX=omci.$SRC_RELEASE_FILE_PREFIX
68
69BAL_RELEASE_DIR=$TMP_DIR/bal/$SRC_RELEASE_FILE_PREFIX
70SDN_PAL_RELEASE_DIR=$TMP_DIR/sdn_pal/$SRC_RELEASE_FILE_PREFIX
71OMCI_RELEASE_DIR=$TMP_DIR/omci/$SRC_RELEASE_FILE_PREFIX
72
73BAL_SRC_RELEASE_FILE=$BAL_RELEASE_PREFIX.tar.gz
74SDN_PAL_SRC_RELEASE_FILE=$SDN_PAL_RELEASE_PREFIX.tar.gz
75OMCI_SRC_RELEASE_FILE=$OMCI_RELEASE_PREFIX.tar.gz
76
77CP="cp -R --parents"
78
79if [ -d build/core ]; then
80 SUBSYSTEM=core
81elif [ -d build/agent ]; then
82 SUBSYSTEM=agent
83else
84 echo Neither build/core nor build/agent subdirectories exist
85 exit -1
86fi
87
88if [ ! -f build/$SUBSYSTEM/src/common/include/bal_model_ids.h ]; then
89 echo Generated BAL header files are missing. Build BAL first
90 exit -1
91fi
92
93if [ ! -f build/$SUBSYSTEM/src/lib/libomcisvc/omci_model_ids.h ]; then
94 echo Generated OMCI SVC header files are missing. Build OMCI SVC first
95 exit -1
96fi
97
98mkdir -p $BAL_RELEASE_DIR
99mkdir -p $SDN_PAL_RELEASE_DIR
100mkdir -p $OMCI_RELEASE_DIR
101
102# Copy auto-generated files first, as we will need to do "make clean" afterwards (because some 3rdparty libraries have binaries in the source directories and we need to clean those).
103# 1. BAL
104mkdir -p $BAL_RELEASE_DIR/src/common/include
105cp \
106 build/$SUBSYSTEM/src/common/include/bal_model_ids.h \
107 build/$SUBSYSTEM/src/common/include/bal_model_types.h \
108 $BAL_RELEASE_DIR/src/common/include
109
110mkdir -p $BAL_RELEASE_DIR/src/lib/libobjmsg
111cp \
112 build/$SUBSYSTEM/src/lib/libobjmsg/bal_model_funcs.c \
113 build/$SUBSYSTEM/src/lib/libobjmsg/bal_obj_msg_pack_unpack.c \
114 build/$SUBSYSTEM/src/lib/libobjmsg/bal_model_funcs.h \
115 build/$SUBSYSTEM/src/lib/libobjmsg/bal_obj_msg_pack_unpack.h \
116 $BAL_RELEASE_DIR/src/lib/libobjmsg
117
118mkdir -p $BAL_RELEASE_DIR/src/lib/libbalapicli
119cp \
120 build/$SUBSYSTEM/src/lib/libbalapicli/bal_api_cli_helpers.h \
121 build/$SUBSYSTEM/src/lib/libbalapicli/bal_api_cli_helpers.c \
122 build/$SUBSYSTEM/src/lib/libbalapicli/bal_api_cli_handlers.c \
123 $BAL_RELEASE_DIR/src/lib/libbalapicli
124
125# 2. OMCI
126# Copy auto-generated files to the sources directory
127mkdir -p $OMCI_RELEASE_DIR/src/lib/libomcisvc
128cp \
129 build/$SUBSYSTEM/src/lib/libomcisvc/omci_model_ids.h \
130 build/$SUBSYSTEM/src/lib/libomcisvc/omci_model_types.h \
131 build/$SUBSYSTEM/src/lib/libomcisvc/omci_model_funcs.h \
132 build/$SUBSYSTEM/src/lib/libomcisvc/omci_model_funcs.c \
133 build/$SUBSYSTEM/src/lib/libomcisvc/omci_cli_handlers.c \
134 build/$SUBSYSTEM/src/lib/libomcisvc/omci_cli_helpers.h \
135 build/$SUBSYSTEM/src/lib/libomcisvc/omci_cli_helpers.c \
136 $OMCI_RELEASE_DIR/src/lib/libomcisvc
137
138# Clean
139make clean
140make clean BUILD_NC_AGENT=y
141
142# Now recreate the subsystem directory (wiped out by the make clean), because the archive artifacts from the build will go there
143mkdir -p build/$SUBSYSTEM
144
145# Now main copy
146
147# 1. BAL
148
149# Copy only relevant sources.
150for file in `find mk -maxdepth 1 -type f`; do cp -L --parents $file $BAL_RELEASE_DIR; done
151$CP 3rdparty/bcm-sdk/make $BAL_RELEASE_DIR/
152$CP 3rdparty/bcm-sdk/Makefile $BAL_RELEASE_DIR/
153$CP 3rdparty/bcm-sdk/Makefile.sdk $BAL_RELEASE_DIR/
154$CP 3rdparty/bcm-sdk/make_ing_dir.sh $BAL_RELEASE_DIR/
155$CP 3rdparty/bcm-sdk/rc $BAL_RELEASE_DIR/
156$CP 3rdparty/bcm-sdk/*.patch $BAL_RELEASE_DIR/
157$CP 3rdparty/bcm-sdk/sh $BAL_RELEASE_DIR/
158$CP 3rdparty/linenoise $BAL_RELEASE_DIR/
159$CP 3rdparty/maple/Makefile $BAL_RELEASE_DIR/
160$CP branch.info $BAL_RELEASE_DIR/
161chmod +w $BAL_RELEASE_DIR/branch.info
162echo PERFORCE_REVISION=$BUILD_PERFORCE_REVISION >> $BAL_RELEASE_DIR/branch.info
163$CP COPYRIGHT $BAL_RELEASE_DIR/
164$CP doxygen $BAL_RELEASE_DIR/
165$CP Makefile $BAL_RELEASE_DIR/
166$CP README* $BAL_RELEASE_DIR/
167$CP mk/boards $BAL_RELEASE_DIR/
168$CP mk/core/Makefile* $BAL_RELEASE_DIR/
169$CP mk/core/modules.core.bal $BAL_RELEASE_DIR/
170$CP mk/agent/modules.agent.bal $BAL_RELEASE_DIR/
171$CP scripts $BAL_RELEASE_DIR/
172$CP src/common $BAL_RELEASE_DIR/
173$CP src/core $BAL_RELEASE_DIR/
174$CP src/apps/bal_cli $BAL_RELEASE_DIR/
175$CP src/datamodel/bal.objset $BAL_RELEASE_DIR/
176$CP src/lib/common $BAL_RELEASE_DIR/
177$CP src/lib/libbalapi $BAL_RELEASE_DIR/
178$CP src/lib/libbalapicli $BAL_RELEASE_DIR/
179$CP src/lib/libobjmsg $BAL_RELEASE_DIR/
180$CP src/lib/librscmgr $BAL_RELEASE_DIR/
181$CP src/lib/libtopology $BAL_RELEASE_DIR/
182$CP src/lib/libutils $BAL_RELEASE_DIR/
183$CP src/lib/libcmdline $BAL_RELEASE_DIR/
184$CP tools $BAL_RELEASE_DIR/
185
186# The following file will indicate a release build
187touch $BAL_RELEASE_DIR/.release_build
188
189# Add write permission to all the copied files
190find $BAL_RELEASE_DIR -type f | xargs -d '\n' chmod +w
191
192# Remove codegen_templates and .ccache
193find $BAL_RELEASE_DIR -name codegen_templates | xargs rm -rf
194find $BAL_RELEASE_DIR -name .ccache | xargs rm -rf
195
196cd $BAL_RELEASE_DIR/..
197tar -czf $BAL_SRC_RELEASE_FILE $SRC_RELEASE_FILE_PREFIX
198cd - > /dev/null
199mv $TMP_DIR/bal/$BAL_SRC_RELEASE_FILE .
200echo ./$BAL_SRC_RELEASE_FILE created
201
202# 2. SDN-PAL
203
204# Copy only relevant sources.
205for file in `find mk -maxdepth 1 -type f`; do cp --parents $file $SDN_PAL_RELEASE_DIR; done
206$CP 3rdparty/loci $SDN_PAL_RELEASE_DIR/
207$CP 3rdparty/libxml2 $SDN_PAL_RELEASE_DIR/
208$CP 3rdparty/libxslt $SDN_PAL_RELEASE_DIR/
209$CP 3rdparty/libgpg-error $SDN_PAL_RELEASE_DIR/
210$CP 3rdparty/libgcrypt $SDN_PAL_RELEASE_DIR/
211$CP 3rdparty/libssh $SDN_PAL_RELEASE_DIR/
212$CP 3rdparty/libcurl $SDN_PAL_RELEASE_DIR/
213$CP 3rdparty/libnetconf $SDN_PAL_RELEASE_DIR/
214$CP 3rdparty/indigo $SDN_PAL_RELEASE_DIR/
215$CP 3rdparty/openyuma $SDN_PAL_RELEASE_DIR/
216$CP 3rdparty/yang/BBF $SDN_PAL_RELEASE_DIR/
217$CP 3rdparty/yang/IANA $SDN_PAL_RELEASE_DIR/
218$CP 3rdparty/yang/IETF $SDN_PAL_RELEASE_DIR/
219$CP 3rdparty/pyang $SDN_PAL_RELEASE_DIR/
220$CP 3rdparty/netopeer $SDN_PAL_RELEASE_DIR/
221$CP mk/agent/Makefile* $SDN_PAL_RELEASE_DIR/
222$CP mk/agent/modules.agent.sdn_pal $SDN_PAL_RELEASE_DIR/
223$CP src/agent $SDN_PAL_RELEASE_DIR/
224$CP src/netconf $SDN_PAL_RELEASE_DIR/
225$CP src/ofpal $SDN_PAL_RELEASE_DIR/
226
227# Add write permission to all the copied files
228find $SDN_PAL_RELEASE_DIR -type f | xargs -d '\n' chmod +w
229
230# Remove .ccache
231find $SDN_PAL_RELEASE_DIR -name .ccache | xargs rm -rf
232
233cd $SDN_PAL_RELEASE_DIR/..
234tar -czf $SDN_PAL_SRC_RELEASE_FILE $SRC_RELEASE_FILE_PREFIX
235cd - > /dev/null
236mv $TMP_DIR/sdn_pal/$SDN_PAL_SRC_RELEASE_FILE .
237echo ./$SDN_PAL_SRC_RELEASE_FILE created
238
239# 3. OMCI
240
241# Copy only relevant sources.
242$CP mk/core/modules.core.omci $OMCI_RELEASE_DIR/
243$CP mk/agent/modules.agent.omci $OMCI_RELEASE_DIR/
244$CP src/datamodel/omci* $OMCI_RELEASE_DIR/
245$CP src/lib/libomcistack $OMCI_RELEASE_DIR/
246$CP src/lib/libomcisvc $OMCI_RELEASE_DIR/
247
248# Remove OCS OMCI stack from modules.*.omci
249sed -i '/3rdparty\/ocs_omci/d' $OMCI_RELEASE_DIR/mk/core/modules.core.omci
250sed -i '/3rdparty\/ocs_omci/d' $OMCI_RELEASE_DIR/mk/agent/modules.agent.omci
251
252# Add write permission to all the copied files
253find $OMCI_RELEASE_DIR -type f | xargs -d '\n' chmod +w
254
255# Remove codegen_templates and .ccache
256find $OMCI_RELEASE_DIR -name codegen_templates | xargs rm -rf
257find $OMCI_RELEASE_DIR -name .ccache | xargs rm -rf
258
259# Add a flag to OMCI SVC's Makefile, so that when OMCI package is extracted, builds will include real OMCI SVC, not stubs.
260echo "USE_BCM_OMCI_SVC_IN_RELEASE=y" >> $OMCI_RELEASE_DIR/src/lib/libomcisvc/Makefile.config.omci
261
262cd $OMCI_RELEASE_DIR/..
263tar -czf $OMCI_SRC_RELEASE_FILE $SRC_RELEASE_FILE_PREFIX
264cd - > /dev/null
265mv $TMP_DIR/omci/$OMCI_SRC_RELEASE_FILE .
266echo ./$OMCI_SRC_RELEASE_FILE created
267
268# If INCLUDE_MAPLE_SDK_RELEASE is defined, then we create a maple release that will wrap the BAL release.
269if [[ "$INCLUDE_MAPLE_SDK_RELEASE" != "" ]]; then
270 OLD_DIR=`pwd`
271 BAL_MAPLE_RELEASE_DIR=$TMP_DIR/bal_maple_release
272 ./3rdparty/maple/cur/scripts/rel_delivery.sh $MAPLE_REL_DELIVERY_PREFIX
273 BCM68620_ZIP_FILE=`ls ./3rdparty/maple/cur/SW-BCM68620*.zip`
274 mkdir -p $BAL_MAPLE_RELEASE_DIR/bcm68620_release
275 unzip $BCM68620_ZIP_FILE -d $BAL_MAPLE_RELEASE_DIR/bcm68620_release
276
277 cd $BAL_MAPLE_RELEASE_DIR
278 ln -s bcm68620_release/release/docs docs
279
280 mkdir -p bal_release
281 cd $BAL_RELEASE_DIR
282 $CP . $BAL_MAPLE_RELEASE_DIR/bal_release/
283 cd $BAL_MAPLE_RELEASE_DIR/bal_release/3rdparty/maple
284 ln -s ../../../bcm68620_release cur
285
286 cd $BAL_MAPLE_RELEASE_DIR
287 zip -y -r `basename $BCM68620_ZIP_FILE` ./*
288 cd $OLD_DIR
289 mv $BAL_MAPLE_RELEASE_DIR/`basename $BCM68620_ZIP_FILE` .
290 echo `basename ./$BCM68620_ZIP_FILE` created
291fi
292
293echo Instructions of how to extract and compile source release packages exist in `ls README*` files
294
295rm -rf $TMP_DIR
296