Guest User

Untitled

a guest
Aug 8th, 2023
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import os
  3. import subprocess
  4.  
  5. os.chdir("/var/lib/gtk-typeahead/")
  6.  
  7. proc = subprocess.Popen("dpkg -s libgtk-3-0", stdout = subprocess.PIPE, shell=True)
  8. out = proc.communicate()[0].decode()
  9.  
  10. gtk_ubuntu_version = out.split("\nVersion: ", 1)[1].split("\n")[0]
  11. gtk_real_version = gtk_ubuntu_version.split("ubuntu")[0].split("-")[0]
  12. major, minor, revision, rest = (gtk_real_version + ".").split(".", 4)
  13. int(major)
  14. int(minor)
  15. int(revision)
  16.  
  17. print(f"wget https://download.gnome.org/sources/gtk+/{major}.{minor}/gtk%2B-{major}.{minor}.{revision}.tar.xz -O gtk.tar.xz")
  18. os.system(f"wget https://download.gnome.org/sources/gtk+/{major}.{minor}/gtk%2B-{major}.{minor}.{revision}.tar.xz -O gtk.tar.xz")
  19. for i in os.listdir("./"):
  20.     if os.path.isdir(i):
  21.         raise Exception(f"{i} is a directory, unable to continue")
  22.    
  23. os.system("tar xf gtk.tar.xz")
  24.  
  25. extract_path = None
  26. for i in os.listdir("./"):
  27.     if os.path.isdir(i):
  28.         extract_path = i
  29.         break
  30.    
  31. os.chdir(extract_path)
  32. os.system("patch gtk/gtkfilechooserwidget.c /var/lib/gtk-typeahead/file-chooser__typeahead.patch")
  33. os.system("./configure")
  34. os.system("make")
  35. os.system("make install")
  36.  
  37. os.chdir("/var/lib/gtk-typeahead/")
  38.  
  39. assert "/" not in extract_path
  40. assert ".." not in extract_path
  41. assert "$" not in extract_path
  42.  
  43. os.system(f"rm -r {extract_path}")
  44.  
  45. if os.path.exists("typeahead-patch.version"):
  46.     os.remove("typeahead-patch.version")
  47.  
  48. with open("typeahead-patch.version", "w") as fhandle:
  49.     fhandle.write(gtk_ubuntu_version + "\n")
  50.  
Advertisement
Add Comment
Please, Sign In to add comment