package Ġcom . github . ker ub istan . ker ub . utils . j unix . package manager . dpkg Ċ Ċ import Ġcom . github . ker ub istan . ker ub . host . execute Ċ import Ġcom . github . ker ub istan . ker ub . model . Software Package Ċ import Ġcom . github . ker ub istan . ker ub . model . Version Ċ import Ġorg . apache . ss hd . client . session . Client Session Ċ Ċ object ĠD pkg Ġ{ ĊĊ ĉ fun Ġlist R as b ian Packages ( session : ĠClient Session ): ĠList < Software Package > Ġ{ Ċĉ ĉ return Ġsession . execute ( Ċĉĉĉ ĉ " dpkg - query Ġ- W ") Ċĉĉĉ ĉ . trim () Ċĉĉĉ ĉ . lines (). map Ġ{ Ċĉĉ ĉ parse D pkg Output Line ( it ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ fun Ġlist Packages ( session : ĠClient Session ): ĠList < Software Package > Ġ{ Ċĉ ĉ return Ġsession . execute ( Ċĉĉĉ ĉ " dpkg - query Ġ- W Ġ-- show format Ġ'\ ${ Package }\\ t \ ${ Version }\\ n '") Ċĉĉĉ ĉ . trim () Ċĉĉĉ ĉ . lines (). map Ġ{ Ċĉĉ ĉ parse D pkg Output Line ( it ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġparse D pkg Output Line ( it : ĠString ): ĠSoftware Package Ġ{ Ċĉ ĉ val Ġsplit Ġ= Ġit . split ('\ t ') Ċĉ ĉ if Ġ( split . size Ġ!= Ġ 2 ) Ġ{ Ċĉĉ ĉ throw ĠIllegalArgumentException (" Does Ġnot Ġmatch Ġexpected Ġinput Ġfrom Ġd pkg - query : Ġ$ it ") Ċĉ ĉ } Ċĉ ĉ return ĠSoftware Package ( split [ 0 ], ĠVersion . from Version String ( split [ 1 ])) Ċ ĉ } ĊĊ Ċ }