bitbake-prserv-tool 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. if [ "x${s}" != "x" ]; then
  19. rm -rf ${s}
  20. fi
  21. }
  22. do_export ()
  23. {
  24. file=$1
  25. [ "x${file}" == "x" ] && help && exit 1
  26. rm -f ${file}
  27. clean_cache
  28. bitbake -R conf/prexport.conf -p
  29. s=`bitbake -R conf/prexport.conf -e | grep ^PRSERV_DUMPFILE= | cut -f2 -d\"`
  30. if [ "x${s}" != "x" ];
  31. then
  32. [ -e $s ] && mv -f $s $file && echo "Exporting to file $file succeeded!"
  33. return 0
  34. fi
  35. echo "Exporting to file $file failed!"
  36. return 1
  37. }
  38. do_import ()
  39. {
  40. file=$1
  41. [ "x${file}" == "x" ] && help && exit 1
  42. clean_cache
  43. bitbake -R conf/primport.conf -R $file -p
  44. ret=$?
  45. [ $ret -eq 0 ] && echo "Importing from file $file succeeded!" || echo "Importing from file $file failed!"
  46. return $ret
  47. }
  48. do_migrate_localcount ()
  49. {
  50. df=`bitbake -R conf/migrate_localcount.conf -e | \
  51. grep ^LOCALCOUNT_DUMPFILE= | cut -f2 -d\"`
  52. if [ "x${df}" == "x" ];
  53. then
  54. echo "LOCALCOUNT_DUMPFILE is not defined!"
  55. return 1
  56. fi
  57. rm -rf $df
  58. clean_cache
  59. echo "Exporting LOCALCOUNT to AUTOINCs..."
  60. bitbake -R conf/migrate_localcount.conf -p
  61. [ ! $? -eq 0 ] && echo "Exporting to file $df failed!" && exit 1
  62. if [ -e $df ];
  63. then
  64. echo "Exporting to file $df succeeded!"
  65. else
  66. echo "Exporting to file $df failed!"
  67. exit 1
  68. fi
  69. echo "Importing generated AUTOINC entries..."
  70. [ -e $df ] && do_import $df
  71. if [ ! $? -eq 0 ]
  72. then
  73. echo "Migration from LOCALCOUNT to AUTOINCs failed!"
  74. return 1
  75. fi
  76. echo "Migration from LOCALCOUNT to AUTOINCs succeeded!"
  77. return 0
  78. }
  79. [ $# -eq 0 ] && help && exit 1
  80. case $2 in
  81. *.conf|*.inc)
  82. ;;
  83. *)
  84. echo ERROR: $2 must end with .conf or .inc!
  85. exit 1
  86. ;;
  87. esac
  88. case $1 in
  89. export)
  90. do_export $2
  91. ;;
  92. import)
  93. do_import $2
  94. ;;
  95. migrate_localcount)
  96. do_migrate_localcount
  97. ;;
  98. *)
  99. help
  100. exit 1
  101. ;;
  102. esac