@@ -342,16 +342,44 @@ def getPythonVersionString():
342342 return _ ("Unknown" )
343343
344344
345- def getVersionFromOpkg (fileName ):
346- return next ((line [9 :].split ("+" )[0 ] for line in (fileReadLines (f"/var/lib/opkg/info/{ fileName } .control" , source = MODULE_NAME ) or []) if line .startswith ("Version:" )), _ ("Not Installed" ))
345+ def getRustVersion ():
346+ try :
347+ major , minor = pyversion .split ('.' )[:2 ]
348+ so_path = f"/usr/lib/python{ major } .{ minor } /site-packages/bcrypt/_bcrypt.cpython-{ major } { minor } -arm-linux-gnueabihf.so"
349+
350+ with open (so_path , "rb" ) as f :
351+ f .seek (428000 )
352+ content = f .read (20000 )
353+
354+ # Search for something like 'rustc-1.85.1' in the binary content
355+ match = search (rb'rustc-([0-9]+.[0-9]+(.[0-9]+)?)' , content )
356+ if match :
357+ return match .group (1 ).decode ("utf-8" )
358+ except :
359+ pass
360+
361+ return _ ("Unknown" )
347362
348363
349364def getFileCompressionInfo ():
350- result = Popen ("strings /bin/bash | grep '$Id: UPX.*Copyright'" , stdout = PIPE , shell = True , text = True )
351- # $Id: UPX 4.24 Copyright (C) 1996-2024 the UPX Team. All Rights Reserved. $
352- output = result .communicate ()[0 ]
353- parts = output .strip ().split () if result .returncode == 0 and output else []
354- return f"{ _ ("Enabled" )} ({ parts [1 ].lower ()} { parts [2 ]} )" if len (parts ) >= 3 else _ ("Disabled" )
365+ try :
366+ with open ("/bin/bash" , "rb" ) as f :
367+ f .seek (399000 )
368+ content = f .read (1000 )
369+
370+ # Search for something like 'Id: UPX 4.24 Copyright (C) 1996-2024 the UPX Team. All Rights Reserved.' in the binary content
371+ match = search (rb'Id: UPX.*Copyright' , content )
372+ if match :
373+ parts = match .group (0 ).decode ("utf-8" ).strip ().split ()
374+ return f"{ _ ("Enabled" )} ({ parts [1 ].lower ()} { parts [2 ]} )" if len (parts ) >= 3 else _ ("Disabled" )
375+ except :
376+ pass
377+
378+ return _ ("Disabled" )
379+
380+
381+ def getVersionFromOpkg (fileName ):
382+ return next ((line [9 :].split ("+" )[0 ] for line in (fileReadLines (f"/var/lib/opkg/info/{ fileName } .control" , source = MODULE_NAME ) or []) if line .startswith ("Version:" )), _ ("Not Installed" ))
355383
356384
357385# For modules that do "from About import about"
0 commit comments