@@ -38,7 +38,13 @@ def install_dependencies():
3838def clean_build ():
3939 """Clean previous build artifacts."""
4040 print ("Cleaning previous builds..." )
41- paths_to_clean = ["build" , "dist" , "__pycache__" , "appimagetool-extracted" , "squashfs-root" ]
41+ paths_to_clean = [
42+ "build" ,
43+ "dist" ,
44+ "__pycache__" ,
45+ "appimagetool-extracted" ,
46+ "squashfs-root" ,
47+ ]
4248
4349 for path in paths_to_clean :
4450 if os .path .exists (path ):
@@ -129,9 +135,9 @@ def build_cli():
129135def create_appimage ():
130136 """Create AppImage for better Linux distribution."""
131137 print ("\n Creating AppImage..." )
132-
138+
133139 # Get version from environment or use default
134- version = os .environ .get (' HBAT_VERSION' , ' 2.0.0' )
140+ version = os .environ .get (" HBAT_VERSION" , " 2.0.0" )
135141
136142 # Create AppDir structure
137143 appdir = Path ("HBAT.AppDir" )
@@ -183,7 +189,7 @@ def create_appimage():
183189
184190 with open (appdir / "usr" / "share" / "applications" / "hbat.desktop" , "w" ) as f :
185191 f .write (desktop_content )
186-
192+
187193 # Also create desktop file at root for appimagetool
188194 with open (appdir / "hbat.desktop" , "w" ) as f :
189195 f .write (desktop_content )
@@ -209,7 +215,7 @@ def create_appimage():
209215 # Download and extract appimagetool if not present
210216 appimagetool = "appimagetool-x86_64.AppImage"
211217 appimagetool_dir = "appimagetool-extracted"
212-
218+
213219 if not os .path .exists (appimagetool_dir ):
214220 if not os .path .exists (appimagetool ):
215221 print ("Downloading appimagetool..." )
@@ -222,13 +228,16 @@ def create_appimage():
222228 except Exception as e :
223229 print (f"Failed to download appimagetool: { e } " )
224230 return False
225-
231+
226232 # Extract appimagetool to avoid FUSE requirement
227233 print ("Extracting appimagetool..." )
228234 try :
229235 # Extract quietly to avoid verbose output
230- result = subprocess .run ([f"./{ appimagetool } " , "--appimage-extract" ],
231- capture_output = True , text = True )
236+ result = subprocess .run (
237+ [f"./{ appimagetool } " , "--appimage-extract" ],
238+ capture_output = True ,
239+ text = True ,
240+ )
232241 if result .returncode != 0 and "squashfs-root" not in result .stdout :
233242 print (f"Failed to extract appimagetool: { result .stderr } " )
234243 return False
@@ -246,13 +255,13 @@ def create_appimage():
246255 env = os .environ .copy ()
247256 env ["ARCH" ] = "x86_64"
248257 appimage_name = f"dist/HBAT-{ version } -x86_64.AppImage"
249-
258+
250259 # Check if desktop file exists at root (required by appimagetool)
251260 desktop_file = appdir / "hbat.desktop"
252261 if not desktop_file .exists ():
253262 print (f"Error: Desktop file not found at { desktop_file } " )
254263 return False
255-
264+
256265 # Use the extracted AppRun instead of the AppImage
257266 print (f"Building AppImage with { appimagetool_dir } /AppRun..." )
258267 result = subprocess .run (
@@ -261,12 +270,12 @@ def create_appimage():
261270 text = True ,
262271 env = env ,
263272 )
264-
273+
265274 if result .returncode != 0 :
266275 print (f"AppImage build failed: { result .stderr } " )
267276 print (f"stdout: { result .stdout } " )
268277 return False
269-
278+
270279 shutil .rmtree (appdir )
271280 print (f"✓ AppImage created successfully: HBAT-{ version } -x86_64.AppImage" )
272281 return True
@@ -278,9 +287,9 @@ def create_appimage():
278287def create_deb_package ():
279288 """Create .deb package for Debian/Ubuntu."""
280289 print ("\n Creating .deb package..." )
281-
290+
282291 # Get version from environment or use default
283- version = os .environ .get (' HBAT_VERSION' , ' 2.0.0' )
292+ version = os .environ .get (" HBAT_VERSION" , " 2.0.0" )
284293
285294 # Create debian package structure
286295 debdir = Path ("hbat-deb" )
@@ -349,7 +358,8 @@ def create_deb_package():
349358 # Build .deb package
350359 try :
351360 subprocess .run (
352- ["dpkg-deb" , "--build" , "hbat-deb" , f"dist/hbat_{ version } _amd64.deb" ], check = True
361+ ["dpkg-deb" , "--build" , "hbat-deb" , f"dist/hbat_{ version } _amd64.deb" ],
362+ check = True ,
353363 )
354364 shutil .rmtree (debdir )
355365 print (f"✓ .deb package created successfully: hbat_{ version } _amd64.deb" )
@@ -365,9 +375,9 @@ def main():
365375 """Main build function."""
366376 print ("HBAT Linux Build Script" )
367377 print ("=" * 40 )
368-
378+
369379 # Get version from environment or use default
370- version = os .environ .get (' HBAT_VERSION' , ' 2.0.0' )
380+ version = os .environ .get (" HBAT_VERSION" , " 2.0.0" )
371381 print (f"Building version: { version } " )
372382
373383 # Check we're in the right directory
0 commit comments