bitbake-prserv-tool 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/usr/bin/env bash
  2. help ()
  3. {
  4. base=`basename $0`
  5. echo -e "Usage: $base command"
  6. echo "Avaliable commands:"
  7. echo -e "\texport <file>: export and lock down the AUTOPR values from the PR service into a file for release."
  8. echo -e "\timport <file>: import the AUTOPR values from the exported file into the PR service."
  9. }
  10. clean_cache()
  11. {
  12. s=`bitbake -e | grep ^CACHE= | cut -f2 -d\"`
  13. if [ "x${s}" != "x" ]; then
  14. rm -rf ${s}
  15. fi
  16. }
  17. do_export ()
  18. {
  19. file=$1
  20. [ "x${file}" == "x" ] && help && exit 1
  21. rm -f ${file}
  22. clean_cache
  23. bitbake -R conf/prexport.conf -p
  24. s=`bitbake -R conf/prexport.conf -e | grep ^PRSERV_DUMPFILE= | cut -f2 -d\"`
  25. if [ "x${s}" != "x" ];
  26. then
  27. [ -e $s ] && mv -f $s $file && echo "Exporting to file $file succeeded!"
  28. return 0
  29. fi
  30. echo "Exporting to file $file failed!"
  31. return 1
  32. }
  33. do_import ()
  34. {
  35. file=$1
  36. [ "x${file}" == "x" ] && help && exit 1
  37. clean_cache
  38. bitbake -R conf/primport.conf -R $file -p
  39. ret=$?
  40. [ $ret -eq 0 ] && echo "Importing from file $file succeeded!" || echo "Importing from file $file failed!"
  41. return $ret
  42. }
  43. do_migrate_localcount ()
  44. {
  45. df=`bitbake -R conf/migrate_localcount.conf -e | \
  46. grep ^LOCALCOUNT_DUMPFILE= | cut -f2 -d\"`
  47. if [ "x${df}" == "x" ];
  48. then
  49. echo "LOCALCOUNT_DUMPFILE is not defined!"
  50. return 1
  51. fi
  52. rm -rf $df
  53. clean_cache
  54. echo "Exporting LOCALCOUNT to AUTOINCs..."
  55. bitbake -R conf/migrate_localcount.conf -p
  56. [ ! $? -eq 0 ] && echo "Exporting failed!" && exit 1
  57. echo "Importing generated AUTOINC entries..."
  58. [ -e $df ] && do_import $df
  59. if [ ! $? -eq 0 ]
  60. then
  61. echo "Migration from LOCALCOUNT to AUTOINCs failed!"
  62. return 1
  63. fi
  64. echo "Migration from LOCALCOUNT to AUTOINCs succeeded!"
  65. return 0
  66. }
  67. [ $# -eq 0 ] && help && exit 1
  68. case $1 in
  69. export)
  70. do_export $2
  71. ;;
  72. import)
  73. do_import $2
  74. ;;
  75. migrate_localcount)
  76. do_migrate_localcount
  77. ;;
  78. *)
  79. help
  80. exit 1
  81. ;;
  82. esac