bitbake-prserv-tool 2.3 KB

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