bitbake-prserv-tool 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. do_migrate_localcount ()
  52. {
  53. df=`bitbake -R conf/migrate_localcount.conf -e | \
  54. grep ^LOCALCOUNT_DUMPFILE= | cut -f2 -d\"`
  55. if [ "x${df}" == "x" ];
  56. then
  57. echo "LOCALCOUNT_DUMPFILE is not defined!"
  58. return 1
  59. fi
  60. rm -f $df
  61. clean_cache
  62. echo "Exporting LOCALCOUNT to AUTOINCs..."
  63. bitbake -R conf/migrate_localcount.conf -p
  64. [ ! $? -eq 0 ] && echo "Exporting to file $df failed!" && exit 1
  65. if [ -e $df ];
  66. then
  67. echo "Exporting to file $df succeeded!"
  68. else
  69. echo "Exporting to file $df failed!"
  70. exit 1
  71. fi
  72. echo "Importing generated AUTOINC entries..."
  73. [ -e $df ] && do_import $df
  74. if [ ! $? -eq 0 ]
  75. then
  76. echo "Migration from LOCALCOUNT to AUTOINCs failed!"
  77. return 1
  78. fi
  79. echo "Migration from LOCALCOUNT to AUTOINCs succeeded!"
  80. return 0
  81. }
  82. [ $# -eq 0 ] && help && exit 1
  83. case $2 in
  84. *.conf|*.inc)
  85. ;;
  86. *)
  87. echo ERROR: $2 must end with .conf or .inc!
  88. exit 1
  89. ;;
  90. esac
  91. case $1 in
  92. export)
  93. do_export $2
  94. ;;
  95. import)
  96. do_import $2
  97. ;;
  98. migrate_localcount)
  99. do_migrate_localcount
  100. ;;
  101. *)
  102. help
  103. exit 1
  104. ;;
  105. esac