bitbake-prserv-tool 1.6 KB

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