]>
git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/blob - scripts/oe-check-sstate
3 # Query which tasks will be restored from sstate
5 # Copyright 2016 Intel Corporation
6 # Authored-by: Paul Eggleton <paul.eggleton@intel.com>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2 as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 scripts_path
= os
. path
. dirname ( os
. path
. realpath ( __file__
))
29 lib_path
= scripts_path
+ '/lib'
30 sys
. path
= sys
. path
+ [ lib_path
]
33 scriptpath
. add_bitbake_lib_path ()
37 def translate_virtualfns ( tasks
):
39 tinfoil
= bb
. tinfoil
. Tinfoil ()
41 tinfoil
. prepare ( False )
43 recipecaches
= tinfoil
. cooker
. recipecaches
46 ( mc
, fn
, taskname
) = bb
. runqueue
. split_tid ( task
)
47 if taskname
. endswith ( '_setscene' ):
48 taskname
= taskname
[:- 9 ]
49 outtasks
. append ( ' %s : %s ' % ( recipecaches
[ mc
]. pkg_fn
[ fn
], taskname
))
56 tmpdir
= tempfile
. mkdtemp ( prefix
= 'oe-check-sstate-' )
58 env
= os
. environ
. copy ()
59 if not args
. same_tmpdir
:
60 env
[ 'BB_ENV_EXTRAWHITE' ] = env
. get ( 'BB_ENV_EXTRAWHITE' , '' ) + ' TMPDIR_forcevariable'
61 env
[ 'TMPDIR_forcevariable' ] = tmpdir
64 output
= subprocess
. check_output (
65 'bitbake -n %s ' % ' ' . join ( args
. target
),
66 stderr
= subprocess
. STDOUT
,
70 task_re
= re
. compile ( 'NOTE: Running setscene task [0-9]+ of [0-9]+ \(([^)]+)\)' )
72 for line
in output
. decode ( 'utf-8' ). splitlines ():
73 res
= task_re
. match ( line
)
75 tasks
. append ( res
. group ( 1 ))
76 outtasks
= translate_virtualfns ( tasks
)
77 except subprocess
. CalledProcessError
as e
:
78 print ( 'ERROR: bitbake failed: \n %s ' % e
. output
. decode ( 'utf-8' ))
84 with
open ( args
. log
, 'wb' ) as f
:
88 with
open ( args
. outfile
, 'w' ) as f
:
90 f
. write ( ' %s \n ' % task
)
99 parser
= argparse_oe
. ArgumentParser ( description
= 'OpenEmbedded sstate check tool. Does a dry-run to check restoring the specified targets from shared state, and lists the tasks that would be restored. Set BB_SETSCENE_ENFORCE=1 in the environment if you wish to ensure real tasks are disallowed.' )
101 parser
. add_argument ( 'target' , nargs
= '+' , help = 'Target to check' )
102 parser
. add_argument ( '-o' , '--outfile' , help = 'Write list to a file instead of stdout' )
103 parser
. add_argument ( '-l' , '--log' , help = 'Write full log to a file' )
104 parser
. add_argument ( '-s' , '--same-tmpdir' , action
= 'store_true' , help = 'Use same TMPDIR for check (list will then be dependent on what tasks have executed previously)' )
106 parser
. set_defaults ( func
= check
)
108 args
= parser
. parse_args ()
110 ret
= args
. func ( args
)
114 if __name__
== "__main__" :
120 traceback
. print_exc ()