Expanded Release Notes

This post will be used to expand on the 0.1 release which did not have too much information on what was actually done. This will clear up what has currently been completed, what needs to be revised, and what the plan for the next release will be.

The asmcheck.sh script was created by Jon Masters. I have made modifications at specific points in the script, and will go over each of these modifications here.

The code below is required to be in asmcheck.sh, at the point in the file where the rpm has been extracted and you have access to the spec file.

        # These 2 variables are used to search through the spec file of the current package and find the ExcludeArch and ExclusiveArch lines.
        # If these are inside the file it will copy the architectures listed and format them.
        exclusive="$(grep 'ExclusiveArch:' $tmp_dir/SPECS/$package_name.spec | cut -d':' -f2 | sed 's/ *$//g' | sed 's/^ *//g' | tr ' ' ',')"
        exclude="$(grep 'ExcludeArch:' $tmp_dir/SPECS/$package_name.spec | cut -d':' -f2 | sed 's/ *$//g' | sed 's/^ *//g' | tr ' ' ',')"
        # The following if statements are used to the check the variables from above, if the variables found something, and checks the amount of commas in them.
        # If the number of commas is not the same as the database, it will add new commas to the end.
        if [ -n "$exclusive" ]; then
                #count commas and add some to the end
                count_exclu=0
                for i in {0..${#exclusive}};do
                        if [ ${exclusive:$i:$i} == "," ];then
                                count_exclu=$(($count_exclu+1))
                        fi
                done
                if [ $count_exclu -lt 12 ];then
                        addcomma=$((12-$count_exclu))
                        for i in {1..$addcomma};do
                                exclusive="$exclusive,"
                        done
                fi
        fi
        if [ -n "$exclude" ]; then
                #count commas and add some to the end
                count_exclu=0
                for i in {0..${#exclude}};do
                        if [ "${exclude:$i:$i}" == "," ];then
                                count_exclu=$(($count_exclu+1))
                        fi
                done
                if [ $count_exclu -lt 12 ];then
                        addcomma=$((12-$count_exclu))
                        for i in {1..$addcomma};do
                                exclude="$exclude,"
                        done
                fi
        fi

The following code below is a mix of Jon Masters’ code and my own. I simply added in some variables to collect the informaton I need and save it for later. Also throughout the script I supressed his output for debugging purposes.

        # --asmanalyser-- Edited to collect file names in variables
        asm_source=false 
        if [ $files_ext_idx -ne 0 ]
        then            
                asm_source=true
                asm_count=0
                #printf "\tAssembly source files:\n"
                for file in ${files_ext[@]}
                do
                        asm_files[$asm_count]=$file
                        asmcount=$(($asm_count+1))
                        #printf "\t\t$file\n"
                done
                #printf "\t\n"
        fi
        # --asmanalyser-- Edited to collect file names in variables
        asm_inline=false
        if [ $files_asm_idx -ne 0 ]
        then
                asm_inline=true
                asm_count=0
                tmp_idx=0;
                #printf "\tInline assembly usage:\n"
                for file in ${files_asm_names[@]}
                do
                        tmp_count=${files_asm_count[$tmp_idx]}
                        #printf "\t\t$file ($tmp_count)\n"
                        tmp_idx=$((tmp_idx+1))
                        asm_inline_files[$asm_count]=$file
                        asm_inline_num[$asm_count]=$tmp_count
                        asm_count=$(($asm_count+1))
                done
        fi

The final modifications to the asmcheck.sh include the output and the generation of csv files. This has been cleaned up a bit and is run from the function output. This function is called at the end of the file in order to use all the gathered data in the generated csv files. Below shows the separation of data between each table(accordering to the database plan).

There is a table below that has been left blank, that is because it will not be done in the script. The blank table, also known as the build table will be run in a python script using the Koji API. It will gather information by querying Koji to see where specific software has been built.

output(){
        # Output formats for the database tables
        # Package Table
        #echo "" > ./asm-package.csv
        printf "[-Packages-]\n"
        package="$(rpm -qp --queryformat '%{epoch},%{name},%{version},%{release},%{arch}' $source_package 2>/dev/null)"
        echo ",$package,$timestamp" | tee -a ./asm-package.csv

        # Build Table
        #echo "" > ./asm-build.csv
        # The build table will work by sending the packages to build on koji on each different arch
        # Exclusive Table
        # Issues with commas and spaces
        #echo "" > ./asm-exclusive.csv
        printf "[-Exclusive-]\n"
        if [ -n "$exclusive" ];then
                echo ",$exclusive" | tee -a ./asm-exclusive.csv
        fi

        # Exclude Table
        # Issues with commas and spaces
        #echo "" > ./asm-exclude.csv
        printf "[-Exclude-]\n"
        if [ -n "$exclude" ];then
                echo ",$exclude" | tee -a ./asm-exclude.csv
        fi

        # Assembly Table
        #echo "" > ./asm-assembly.csv
        printf "[-Assembly-]\n"
        randnum="$(shuf -i 1-99999 -n 1)"
        sfiles=$files_ext_idx
        inlinefiles=$files_asm_idx
        totalfiles=$total_asm
        echo ",$randnum,$sfiles,$inlinefiles,$totalfiles,$timestamp" | tee -a ./asm-assembly.csv

        # File Table
        #echo "" > ./asm-files.csv
        if $asm_source; then
                printf "[-Files-]\n"
                for file in ${asm_files[@]}; do
                        echo ",$randnum,$file,$timestamp" | tee -a ./asm-files.csv
                done
        fi
        # In-line table
        #echo "" > ./asm-inline.csv
        if $asm_inline; then
                printf "[-Inline Files-]\n"
                asm_count=0
                for file in ${asm_inline_files[@]}; do
                        echo ",$randnum,$file,${asm_inline_num[$asm_count]},$timestamp" | tee -a ./asm-inline.csv
                        asm_count=$(($asm_count+1))
                done
        fi
}
Advertisements

About oatleywillisa

Computer Networking Student
This entry was posted in SBR600. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s