[Fuego] Regards: Raspberry-pi build deployment scripts

Unnati Somvanshi <[email protected]> Fri, 16 Oct 2020 18:19:38 +0530
Newsgroups dev.linux.lists.fuego
Message-ID <CACSNn7Qn_PSL_pL7tENDt_gMC4Bz_MZv=MpqWV477sch5Xxw6Q@mail.gmail.com>
Hi Tim,

As discussed at the last meeting I have attached the  RPI build deployment
scripts, Please find the attachment and let us know if you have any
questions regarding the same.

Thanks & Regards
Unnati

-- 






This
message contains confidential information and is intended only 
for the
individual(s) named. If you are not the intended
recipient, you are 
notified that disclosing, copying, distributing or taking any
action in 
reliance on the contents of this mail and attached file/s is strictly
prohibited. Please notify the
sender immediately and delete this e-mail 
from your system. E-mail transmission
cannot be guaranteed to be secured or 
error-free as information could be
intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain
viruses. The sender therefore does 
not accept liability for any errors or
omissions in the contents of this 
message, which arise as a result of e-mail
transmission.
rpi_code_checkout_build.sh (application/x-shellscript, 1.8 KB)
#Change to the specific job workspace based on specific build number

cd ${JENKINS_HOME}/jobs/pipeline/BUILD_${JOB_NAME}_${BUILD_NUMBER}/arch/arm/configs/

#Checking the configuration of ipv6 and PRIO_SCHED modules in bcm2709_defconfig file 

if grep -i CONFIG_IPV6=y "bcm2709_defconfig"; then

        echo "congiguration is already set "
fi        

        
if grep -i CONFIG_RT_PRIO_SCHED=y "bcm2709_defconfig"; then

        echo "congiguration is already set"       

fi

if grep -i CONFIG_IPV6=m "bcm2709_defconfig"; then

        sed -i -- 's/CONFIG_IPV6=m/CONFIG_IPV6=y/g' bcm2709_defconfig
else
        echo "CONFIG_IPV6=y" >> bcm2709_defconfig
        echo "configuration change successfully in bcm2709_defconfig"
fi


if grep -i CONFIG_RT_PRIO_SCHED=m "bcm2709_defconfig"; then

        sed -i -- 's/CONFIG_RT_PRIO_SCHED=m/CONFIG_RT_PRIO_SCHED=y/g' bcm2709_defconfig  
else
        echo "CONFIG_RT_PRIO_SCHED=y" >> bcm2709_defconfig
        echo "configuration change successfully in bcm2709_defconfig"
       
fi


#Change to the current workspace

cd ${JENKINS_HOME}/jobs/pipeline/BUILD_${JOB_NAME}_${BUILD_NUMBER}

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig

#Appending the CONFIG_LOCALVERSION with Build_Number in .config file
if grep -i 'CONFIG_LOCALVERSION="-v7"' ".config"; then

        sed -i -- 's/CONFIG_LOCALVERSION="-v7"/CONFIG_LOCALVERSION="'-v7-${BUILD_NUMBER}'"/g' .config
        echo "configuration change successfully in .config file"
else
        
        echo "failed"
fi

make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

mkdir -p ../modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../modules modules_install

#Writing the job name and build number into the input file
echo "${JOB_NAME}_${BUILD_NUMBER}" > /var/lib/jenkins/jobs/pipeline/input.txt
rpi_post_build.sh (application/x-shellscript, 809 B)
#Reading the rpi_code_checkout_build_number from the input.txt file 
line=$(head -n 1 /var/lib/jenkins/jobs/pipeline/input.txt)
echo "$line"

#Reading the ipaddress from the rpi board file
ipadd=$(cat /fuego-ro/boards/rpi.board | grep "IPADDR" | cut -f 2 -d '"') 
echo "$ipadd"
 
# Move to the proper directory build by rpi checkout
cd $JENKINS_HOME/jobs/pipeline/BUILD_$line

# Renaming kernel image to kernel7
mv arch/arm/boot/zImage arch/arm/boot/kernel7.img

# Copying kernel image to RPI board
sshpass -p raspberry scp -o 'StrictHostKeyChecking no' arch/arm/boot/kernel7.img pi@$ipadd:/tmp/kernel7.img

# Prepare zip file of kernel modules
cd ../modules
rm -rf modules.tgz || true
tar -czf modules.tgz *

# Copying kernel modules to the RPI board
sshpass -p "raspberry" scp ./modules.tgz pi@$ipadd:/tmp/
rpi_deploy_verify.sh (application/x-shellscript, 1.2 KB)
#Reading ipaddress from the rpi board file

ipadd=$(cat /fuego-ro/boards/rpi.board | grep "IPADDR" | cut -f 2 -d '"')
echo  "$ipadd"


# Copy kernel image to /boot on RPI board 
sshpass -p "raspberry" ssh pi@$ipadd "sudo cp /tmp/kernel7.img /boot/"


# Unzip modules on the RPI board
sshpass -p "raspberry" ssh pi@$ipadd "cd /; sudo tar -xzf /tmp/modules.tgz"

#sync

sshpass -p "raspberry" ssh pi@$ipadd "sync;sync;sync"

#sudo reboot
sshpass -p "raspberry" ssh pi@$ipadd "sudo reboot" || true

#wait time
sleep 120

#ssh pi board
updated_ver=$(sshpass -p "raspberry" ssh pi@$ipadd "uname -r")

#exit from the rpi board  
sshpass -p "raspberry" ssh pi@$ipadd "exit"

#Reading the rpi_code_checkout_build_number from the input.txt file 
line=$(head -n 1 /var/lib/jenkins/jobs/pipeline/input.txt)
echo "$line"


# Move to the proper directory build by rpi checkout
cd $JENKINS_HOME/jobs/pipeline/BUILD_$line

current_ver=$(strings vmlinux | grep "Linux version" | awk -F " " '{print $3}')

echo "$current_ver"

#Comparing the required_version to current_version
      
 if [ "$(printf '%s\n' "$updated_ver" "$current_ver" | sort -V | head -n1)" = "$updated_ver" ]; then 
        echo "==Passed==Greater than or equal"
 else
        echo "==Failed==Less than"
 fi