#/bin/bash ### ABB tag is the 256-bit number MAPPING_FILE=/opt/share/bb/mapping-bb-rs.xml function make_abb_tag () { DIVISOR=64 ABB_TAG_0="0" ABB_TAG_1="0" ABB_TAG_2="0" ABB_TAG_3="0" for ABB_ID in $ABB_ID_LIST do RESULT=$(($ABB_ID / $DIVISOR)) REMAINDER=$(($ABB_ID % $DIVISOR)) case $RESULT in 0) ABB_TAG_0=$(($ABB_TAG_0 | (1 << $REMAINDER))) ;; 1) ABB_TAG_1=$(($ABB_TAG_1 | (1 << $REMAINDER))) ;; 2) ABB_TAG_2=$(($ABB_TAG_2 | (1 << $REMAINDER))) ;; 3) ABB_TAG_3=$(($ABB_TAG_3 | (1 << $REMAINDER))) ;; esac done ABB_TAG=`printf "%016X%016X%016X%016X" $ABB_TAG_3 $ABB_TAG_2 $ABB_TAG_1 $ABB_TAG_0` retval=$ABB_TAG } function get_abb_id () { BB=$1 grep -q $BB $MAPPING_FILE if [ $? == 0 ] then ABB_ID=`grep "\"$BB\"" $MAPPING_FILE | awk '{print $3}' | sed -e "s/abb_id=\"\(.\+\)\".\+/\1/"` retval="$ABB_ID" else retval="X" fi } function usage () { echo "Usage : make_ABB_tag.sh [building block list file]" echo " If you input building block list, this program uses it." echo " Or this program uses the rpm db on the target" exit 1 } ################## ## main ## ################## case $# in 1) MAPPING_FILE=$1 if [ ! -e $MAPPING_FILE ] then echo "File not found : $MAPPING_FILE" exit 2 fi ABB_LIST=`rpm -qa --queryformat="%{NAME}\n"| grep building-blocks- | grep domain_API` ;; 2) MAPPING_FILE=$1 if [ ! -e $MAPPING_FILE ] then echo "File not found : $MAPPING_FILE" exit 2 fi if [ ! -e $2 ] then echo "File not found : $2" exit 3 fi ABB_LIST=`cat $2` ;; *) echo "##################" echo "Please check input" echo "##################" usage esac ABB_ID_LIST="" for API in $ABB_LIST do # echo $API get_abb_id $API if [ "$retval" != "X" ] then ABB_ID_LIST="$ABB_ID_LIST $retval" fi done make_abb_tag $ABB_ID_LIST echo $retval