1#!/usr/bin/env bash 2# 3# Copyright OpenEmbedded Contributors 4# 5# SPDX-License-Identifier: GPL-2.0-only 6# 7 8help () 9{ 10 base=`basename $0` 11 echo -e "Usage: $base command" 12 echo "Avaliable commands:" 13 echo -e "\texport <file.conf>: export and lock down the AUTOPR values from the PR service into a file for release." 14 echo -e "\timport <file.conf>: import the AUTOPR values from the exported file into the PR service." 15} 16 17clean_cache() 18{ 19 s=`bitbake -e | grep ^CACHE= | cut -f2 -d\"` 20 # Stop any active memory resident server 21 bitbake -m 22 # Remove cache entries since we want to trigger a full reparse 23 if [ "x${s}" != "x" ]; then 24 rm -f ${s}/bb_cache*.dat.* 25 fi 26} 27 28do_export () 29{ 30 file=$1 31 [ "x${file}" == "x" ] && help && exit 1 32 rm -f ${file} 33 34 clean_cache 35 bitbake -R conf/prexport.conf -p 36 s=`bitbake -R conf/prexport.conf -e | grep ^PRSERV_DUMPFILE= | cut -f2 -d\"` 37 if [ "x${s}" != "x" ]; 38 then 39 [ -e $s ] && mv -f $s $file && echo "Exporting to file $file succeeded!" 40 return 0 41 fi 42 echo "Exporting to file $file failed!" 43 return 1 44} 45 46do_import () 47{ 48 file=$1 49 [ "x${file}" == "x" ] && help && exit 1 50 51 clean_cache 52 bitbake -R conf/primport.conf -R $file -p 53 ret=$? 54 [ $ret -eq 0 ] && echo "Importing from file $file succeeded!" || echo "Importing from file $file failed!" 55 return $ret 56} 57 58[ $# -eq 0 ] && help && exit 1 59 60case $2 in 61*.conf|*.inc) 62 ;; 63*) 64 echo ERROR: $2 must end with .conf or .inc! 65 exit 1 66 ;; 67esac 68 69case $1 in 70export) 71 do_export $2 72 ;; 73import) 74 do_import $2 75 ;; 76*) 77 help 78 exit 1 79 ;; 80esac 81