Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/next/external/cache/sources/wl/include/epivers.sh
Views: 3959
#! /bin/bash1#2# Create the epivers.h file from epivers.h.in3#4# Epivers.h version support svn/sparse/gclient workspaces5#6# $Id: epivers.sh 389101 2013-03-05 17:23:14Z $7#8# Version generation works off of svn property HeadURL, if9# not set it keys its versions from current svn workspace or10# via .gclient_info deps contents11#12# GetCompVer.py return value and action needed13# i. trunk => use current date as version string14# ii. local => use SVNURL expanded by HeadURL keyword15# iii. <tag> => use it as as is16# (some components can override and say give me native ver)17# iv. empty =>18# a) If TAG is specified use it19# a) If no TAG is specified use date20#21# Contact: Prakash Dhavali22# Contact: hnd-software-scm-list23#2425# If the version header file already exists, increment its build number.26# Otherwise, create a new file.27if [ -f epivers.h ]; then2829# If REUSE_VERSION is set, epivers iteration is not incremented30# This can be used precommit and continuous integration projects31if [ -n "$REUSE_VERSION" ]; then32echo "Previous epivers.h exists. Skipping version increment"33exit 034fi3536build=$(grep EPI_BUILD_NUMBER epivers.h | sed -e "s,.*BUILD_NUMBER[ ]*,,")37build=$(expr ${build} + 1)38echo build=${build}39sed -e "s,.*_BUILD_NUMBER.*,#define EPI_BUILD_NUMBER ${build}," \40< epivers.h > epivers.h.new41cp -p epivers.h epivers.h.prev42mv epivers.h.new epivers.h43exit 04445else # epivers.h doesn't exist4647SVNCMD=${SVNCMD:-"svn --non-interactive"}48SRCBASE=${SRCBASE:-..}49NULL=/dev/null50[ -z "$VERBOSE" ] || NULL=/dev/stderr5152# Check for the in file, if not there we're in the wrong directory53if [ ! -f epivers.h.in ]; then54echo "ERROR: No epivers.h.in found"55exit 156fi5758# Following SVNURL should be expanded on checkout59SVNURL='$HeadURL: http://svn.sj.broadcom.com/svn/wlansvn/proj/tags/AARDVARK/AARDVARK_REL_6_30_254/src/include/epivers.sh $'6061# .gclient_info is created by gclient checkout/sync steps62# and contains "DEPS='<deps-url1> <deps-url2> ..." entry63GCLIENT_INFO=${GCLIENT_INFO:-${SRCBASE}/../.gclient_info}6465# In gclient, derive SVNURL from gclient_info file66if [ -s "${GCLIENT_INFO}" ]; then67source ${GCLIENT_INFO}68if [ -z "$DEPS" ]; then69echo "ERROR: DEPS entry missing in $GCLIENT_INFO"70exit 171else72for dep in $DEPS; do73SVNURL=${SVNURL:-$dep}74# Set SVNURL to first DEPS with /tags/ (if any)75if [[ $dep == */tags/* ]]; then76SVNURL=$dep77echo "INFO: Found gclient DEPS: $SVNURL"78break79fi80done81fi82elif [ -f "${GCLIENT_INFO}" ]; then83echo "ERROR: $GCLIENT_INFO exists, but it is empty"84exit 185fi8687# If SVNURL isn't expanded, extract it from svn info88if echo "$SVNURL" | egrep -vq 'HeadURL.*epivers.sh.*|http://.*/DEPS'; then89[ -n "$VERBOSE" ] && \90echo "DBG: SVN URL ($SVNURL) wasn't expanded. Getting it from svn info"91SVNURL=$($SVNCMD info epivers.sh 2> $NULL | egrep "^URL:")92fi9394if echo "${TAG}" | grep -q "_BRANCH_\|_TWIG_"; then95branchtag=$TAG96else97branchtag=""98fi99100# If this is a tagged build, use the tag to supply the numbers101# Tag should be in the form102# <NAME>_REL_<MAJ>_<MINOR>103# or104# <NAME>_REL_<MAJ>_<MINOR>_RC<RCNUM>105# or106# <NAME>_REL_<MAJ>_<MINOR>_RC<RCNUM>_<INCREMENTAL>107108MERGERLOG=${SRCBASE}/../merger_sources.log109GETCOMPVER=getcompver.py110GETCOMPVER_NET=/projects/hnd_software/gallery/src/tools/build/$GETCOMPVER111GETCOMPVER_NET_WIN=Z:${GETCOMPVER_NET}112113#114# If there is a local copy GETCOMPVER use it ahead of network copy115#116if [ -s "$GETCOMPVER" ]; then117GETCOMPVER_PATH="$GETCOMPVER"118elif [ -s "${SRCBASE}/../src/tools/build/$GETCOMPVER" ]; then119GETCOMPVER_PATH="${SRCBASE}/../src/tools/build/$GETCOMPVER"120elif [ -s "$GETCOMPVER_NET" ]; then121GETCOMPVER_PATH="$GETCOMPVER_NET"122elif [ -s "$GETCOMPVER_NET_WIN" ]; then123GETCOMPVER_PATH="$GETCOMPVER_NET_WIN"124fi125126#127# If $GETCOMPVER isn't found, fetch it from SVN128# (this should be very rare)129#130if [ ! -s "$GETCOMPVER_PATH" ]; then131[ -n "$VERBOSE" ] && \132echo "DBG: Fetching $GETCOMPVER from trunk"133134$SVNCMD export -q \135^/proj/trunk/src/tools/build/${GETCOMPVER} \136${GETCOMPVER} 2> $NULL137138GETCOMPVER_PATH=$GETCOMPVER139fi140141# Now get tag for src/include from automerger log142[ -n "$VERBOSE" ] && \143echo "DBG: python $GETCOMPVER_PATH $MERGERLOG src/include"144145COMPTAG=$(python $GETCOMPVER_PATH $MERGERLOG src/include 2> $NULL | sed -e 's/[[:space:]]*//g')146147echo "DBG: Component Tag String Derived = $COMPTAG"148149# Process COMPTAG values150# Rule:151# If trunk is returned, use date as component tag152# If LOCAL_COMPONENT is returned, use SVN URL to get native tag153# If component is returned or empty, assign it to SVNTAG154# GetCompVer.py return value and action needed155# i. trunk => use current date as version string156# ii. local => use SVNURL expanded by HeadURL keyword157# iii. <tag> => use it as as is158# iv. empty =>159# a) If TAG is specified use it160# a) If no TAG is specified use SVNURL from HeadURL161162SVNURL_VER=false163164if [ "$COMPTAG" == "" ]; then165SVNURL_VER=true166elif [ "$COMPTAG" == "LOCAL_COMPONENT" ]; then167SVNURL_VER=true168elif [ "$COMPTAG" == "trunk" ]; then169SVNTAG=$(date '+TRUNKCOMP_REL_%Y_%m_%d')170else171SVNTAG=$COMPTAG172fi173174# Given SVNURL path conventions or naming conventions, derive SVNTAG175# TO-DO: SVNTAG derivation logic can move to a central common API176# TO-DO: ${SRCBASE}/tools/build/svnurl2tag.sh177if [ "$SVNURL_VER" == "true" ]; then178case "${SVNURL}" in179*_BRANCH_*)180SVNTAG=$(echo $SVNURL | tr '/' '\n' | awk '/_BRANCH_/{printf "%s",$1}')181;;182*_TWIG_*)183SVNTAG=$(echo $SVNURL | tr '/' '\n' | awk '/_TWIG_/{printf "%s",$1}')184;;185*_REL_*)186SVNTAG=$(echo $SVNURL | tr '/' '\n' | awk '/_REL_/{printf "%s",$1}')187;;188*/branches/*)189SVNTAG=${SVNURL#*/branches/}190SVNTAG=${SVNTAG%%/*}191;;192*/proj/tags/*|*/deps/tags/*)193SVNTAG=${SVNURL#*/tags/*/}194SVNTAG=${SVNTAG%%/*}195;;196*/trunk/*)197SVNTAG=$(date '+TRUNKURL_REL_%Y_%m_%d')198;;199*)200SVNTAG=$(date '+OTHER_REL_%Y_%m_%d')201;;202esac203echo "DBG: Native Tag String Derived from URL: $SVNTAG"204else205echo "DBG: Native Tag String Derived: $SVNTAG"206fi207208TAG=${SVNTAG}209210# Normalize the branch name portion to "D11" in case it has underscores in it211branch_name=$(expr match "$TAG" '\(.*\)_\(BRANCH\|TWIG\|REL\)_.*')212TAG=$(echo $TAG | sed -e "s%^$branch_name%D11%")213214# Split the tag into an array on underbar or whitespace boundaries.215IFS="_ " tag=(${TAG})216unset IFS217218tagged=1219if [ ${#tag[*]} -eq 0 ]; then220tag=($(date '+TOT REL %Y %m %d 0 %y'));221# reconstruct a TAG from the date222TAG=${tag[0]}_${tag[1]}_${tag[2]}_${tag[3]}_${tag[4]}_${tag[5]}223tagged=0224fi225226# Allow environment variable to override values.227# Missing values default to 0228#229maj=${EPI_MAJOR_VERSION:-${tag[2]:-0}}230min=${EPI_MINOR_VERSION:-${tag[3]:-0}}231rcnum=${EPI_RC_NUMBER:-${tag[4]:-0}}232233# If increment field is 0, set it to date suffix if on TOB234if [ -n "$branchtag" ]; then235[ "${tag[5]:-0}" -eq 0 ] && echo "Using date suffix for incr"236today=${EPI_DATE_STR:-$(date '+%Y%m%d')}237incremental=${EPI_INCREMENTAL_NUMBER:-${tag[5]:-${today:-0}}}238else239incremental=${EPI_INCREMENTAL_NUMBER:-${tag[5]:-0}}240fi241origincr=${EPI_INCREMENTAL_NUMBER:-${tag[5]:-0}}242build=${EPI_BUILD_NUMBER:-0}243244# Strip 'RC' from front of rcnum if present245rcnum=${rcnum/#RC/}246247# strip leading zero off the number (otherwise they look like octal)248maj=${maj/#0/}249min=${min/#0/}250rcnum=${rcnum/#0/}251incremental=${incremental/#0/}252origincr=${origincr/#0/}253build=${build/#0/}254255# some numbers may now be null. replace with with zero.256maj=${maj:-0}257min=${min:-0}258259rcnum=${rcnum:-0}260incremental=${incremental:-0}261origincr=${origincr:-0}262build=${build:-0}263264if [ -n "$EPI_VERSION_NUM" ]; then265vernum=$EPI_VERSION_NUM266elif [ ${tagged} -eq 1 ]; then267# vernum is 32chars max268vernum=$(printf "0x%02x%02x%02x%02x" ${maj} ${min} ${rcnum} ${origincr})269else270vernum=$(printf "0x00%02x%02x%02x" ${tag[7]} ${min} ${rcnum})271fi272273# make sure the size of vernum is under 32 bits.274# Otherwise, truncate. The string will keep full information.275vernum=${vernum:0:10}276277# build the string directly from the tag, irrespective of its length278# remove the name , the tag type, then replace all _ by .279tag_ver_str=${TAG/${tag[0]}_}280tag_ver_str=${tag_ver_str/${tag[1]}_}281tag_ver_str=${tag_ver_str//_/.}282283# record tag type284tagtype=285286if [ "${tag[1]}" = "BRANCH" -o "${tag[1]}" = "TWIG" ]; then287tagtype=" (TOB)"288echo "tag type: $tagtype"289fi290291echo "Effective version string: $tag_ver_str"292293if [ "$(uname -s)" == "Darwin" ]; then294# Mac does not like 2-digit numbers so convert the number to single295# digit. 5.100 becomes 5.1296if [ $min -gt 99 ]; then297minmac=$(expr $min / 100)298else299minmac=$min300fi301epi_ver_dev="${maj}.${minmac}.0"302else303epi_ver_dev="${maj}.${min}.${rcnum}"304fi305306# Finally get version control revision number of <SRCBASE> (if any)307vc_version_num=$($SVNCMD info ${SRCBASE} 2> $NULL | awk -F': ' '/^Last Changed Rev: /{printf "%s", $2}')308309# OK, go do it310echo "maj=${maj}, min=${min}, rc=${rcnum}, inc=${incremental}, build=${build}"311312sed \313-e "s;@EPI_MAJOR_VERSION@;${maj};" \314-e "s;@EPI_MINOR_VERSION@;${min};" \315-e "s;@EPI_RC_NUMBER@;${rcnum};" \316-e "s;@EPI_INCREMENTAL_NUMBER@;${incremental};" \317-e "s;@EPI_BUILD_NUMBER@;${build};" \318-e "s;@EPI_VERSION@;${maj}, ${min}, ${rcnum}, ${incremental};" \319-e "s;@EPI_VERSION_STR@;${tag_ver_str};" \320-e "s;@EPI_VERSION_TYPE@;${tagtype};" \321-e "s;@VERSION_TYPE@;${tagtype};" \322-e "s;@EPI_VERSION_NUM@;${vernum};" \323-e "s;@EPI_VERSION_DEV@;${epi_ver_dev};" \324-e "s;@VC_VERSION_NUM@;r${vc_version_num};" \325< epivers.h.in > epivers.h326327# In shared workspaces across different platforms, ensure that328# windows generated file is made platform neutral without CRLF329if uname -s | egrep -i -q "cygwin"; then330dos2unix epivers.h > $NULL 2>&1331fi332fi # epivers.h333334335