a zf @s,ddlZddlZddlZGdddeZdS)Nc@s.eZdZd ddZddZddZd d ZdS) ComponentNFcCs||_||_d|_g|_g|_|rtj|jd}tj|s@||d}|sft d|jdn |d|_||d|_tj|jd}tj|rt |d}| |_Wdn1s0Y||d |_|j|j|jd }t |d 0}| tj|d d d| dWdn1s40Ynpt |d}t| }Wdn1sp0Y|st d|jd|d|_|d|_|d|_dS)Npkg5zprint-value-COMPONENT_NAMEz Component returns empty name at .rzprint-package-namesz pkg5.fmrisrzprint-required-packages)namefmris dependencieswT) sort_keysindent z&Component pkg5 data is empty for path rrr)debugpathrsupplied_packagesrequired_packagesosjoinisfilerun_make ValueErroropenread splitlineswritejsondumpsloads)selfrrZcomponent_pkg5_fileZcomponent_nameZcomponent_pkg5_fmris_filefdatar!;/jenkins/jobs/oi-userland/workspace/tools/bass/component.py__init__#s@    , , .  zComponent.__init__cCs*d}t|j}t|j}||r&d}|S)NFT)setrr intersection)r componentresults1s2r!r!r"requiredLs    zComponent.requiredcCsg}|jrtd||tjdd|gtjtj|dd}|\}}|D]}||qJ|jr~|j dkr~td|j ||S)NzExecuting 'gmake %s' in %sgmakez-sT)stdoutstderrcwduniversal_newlinesrz exit: %d, %s) rlogger subprocessPopenPIPE communicaterappendrstrip returncode)rrtargetsr'procr,r-outr!r!r"rVs     zComponent.run_makecCs6d|j}|dd|j7}|dd|j7}|S)NzComponent: Path: %s z Provides Package(s): %s z z Required Package(s): %s )rrrr)rr'r!r!r"__str__ms zComponent.__str__)NF)__name__ __module__ __qualname__r#r*rr;r!r!r!r"r"s ) r)rr1robjectrr!r!r!r"s