blob: 80028342b167a9e3a19b5fe8f19a53cf645dfd98 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/usr/bin/env bash
Brad Bishopc342db32019-05-15 21:57:59 -04002#
Patrick Williams92b42cb2022-09-03 06:53:57 -05003# Copyright OpenEmbedded Contributors
4#
Brad Bishopc342db32019-05-15 21:57:59 -04005# SPDX-License-Identifier: GPL-2.0-only
6#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007
8help ()
9{
10 base=`basename $0`
11 echo -e "Usage: $base command"
12 echo "Avaliable commands:"
13 echo -e "\texport <file.conf>: export and lock down the AUTOPR values from the PR service into a file for release."
14 echo -e "\timport <file.conf>: import the AUTOPR values from the exported file into the PR service."
15}
16
17clean_cache()
18{
19 s=`bitbake -e | grep ^CACHE= | cut -f2 -d\"`
Patrick Williamsb9af8752023-01-30 13:28:01 -060020 # Stop any active memory resident server
21 bitbake -m
22 # Remove cache entries since we want to trigger a full reparse
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 if [ "x${s}" != "x" ]; then
Patrick Williamsb9af8752023-01-30 13:28:01 -060024 rm -f ${s}/bb_cache*.dat.*
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 fi
26}
27
28do_export ()
29{
30 file=$1
31 [ "x${file}" == "x" ] && help && exit 1
32 rm -f ${file}
33
34 clean_cache
35 bitbake -R conf/prexport.conf -p
36 s=`bitbake -R conf/prexport.conf -e | grep ^PRSERV_DUMPFILE= | cut -f2 -d\"`
37 if [ "x${s}" != "x" ];
38 then
39 [ -e $s ] && mv -f $s $file && echo "Exporting to file $file succeeded!"
40 return 0
41 fi
42 echo "Exporting to file $file failed!"
43 return 1
44}
45
46do_import ()
47{
48 file=$1
49 [ "x${file}" == "x" ] && help && exit 1
50
51 clean_cache
52 bitbake -R conf/primport.conf -R $file -p
53 ret=$?
54 [ $ret -eq 0 ] && echo "Importing from file $file succeeded!" || echo "Importing from file $file failed!"
55 return $ret
56}
57
58do_migrate_localcount ()
59{
60 df=`bitbake -R conf/migrate_localcount.conf -e | \
61 grep ^LOCALCOUNT_DUMPFILE= | cut -f2 -d\"`
62 if [ "x${df}" == "x" ];
63 then
64 echo "LOCALCOUNT_DUMPFILE is not defined!"
65 return 1
66 fi
67
Patrick Williamsb9af8752023-01-30 13:28:01 -060068 rm -f $df
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069 clean_cache
70 echo "Exporting LOCALCOUNT to AUTOINCs..."
71 bitbake -R conf/migrate_localcount.conf -p
72 [ ! $? -eq 0 ] && echo "Exporting to file $df failed!" && exit 1
73
74 if [ -e $df ];
75 then
76 echo "Exporting to file $df succeeded!"
77 else
78 echo "Exporting to file $df failed!"
79 exit 1
80 fi
81
82 echo "Importing generated AUTOINC entries..."
83 [ -e $df ] && do_import $df
84
85 if [ ! $? -eq 0 ]
86 then
87 echo "Migration from LOCALCOUNT to AUTOINCs failed!"
88 return 1
89 fi
90
91 echo "Migration from LOCALCOUNT to AUTOINCs succeeded!"
92 return 0
93}
94
95[ $# -eq 0 ] && help && exit 1
96
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050097case $2 in
98*.conf|*.inc)
99 ;;
100*)
101 echo ERROR: $2 must end with .conf or .inc!
102 exit 1
103 ;;
104esac
105
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500106case $1 in
107export)
108 do_export $2
109 ;;
110import)
111 do_import $2
112 ;;
113migrate_localcount)
114 do_migrate_localcount
115 ;;
116*)
117 help
118 exit 1
119 ;;
120esac