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