bitbake-prserv-tool 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.conf>: export and lock down the AUTOPR values from the PR service into a file for release."
  8. echo -e "\timport <file.conf>: 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 to file $df failed!" && exit 1
  57. if [ -e $df ];
  58. then
  59. echo "Exporting to file $df succeeded!"
  60. else
  61. echo "Exporting to file $df failed!"
  62. exit 1
  63. fi
  64. echo "Importing generated AUTOINC entries..."
  65. [ -e $df ] && do_import $df
  66. if [ ! $? -eq 0 ]
  67. then
  68. echo "Migration from LOCALCOUNT to AUTOINCs failed!"
  69. return 1
  70. fi
  71. echo "Migration from LOCALCOUNT to AUTOINCs succeeded!"
  72. return 0
  73. }
  74. [ $# -eq 0 ] && help && exit 1
  75. case $2 in
  76. *.conf|*.inc)
  77. ;;
  78. *)
  79. echo ERROR: $2 must end with .conf or .inc!
  80. exit 1
  81. ;;
  82. esac
  83. case $1 in
  84. export)
  85. do_export $2
  86. ;;
  87. import)
  88. do_import $2
  89. ;;
  90. migrate_localcount)
  91. do_migrate_localcount
  92. ;;
  93. *)
  94. help
  95. exit 1
  96. ;;
  97. esac