Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import shutil
import stat
import sys
import sysconfig

from setuptools import setup
from setuptools.command.develop import develop
Expand All @@ -12,21 +14,36 @@
long_description = f.read()


def get_bin_path() -> str:
return sysconfig.get_path('scripts')

def get_datarootdir() -> str:
# Getting datarootdir directly will ignore venv
return os.path.join(sys.prefix, 'share')

def post_install():
path = '/usr/local/bin/woeusbgui' # I give up, I have no clue how to get bin path that is used by pip
shutil.copy2(this_directory + '/WoeUSB/woeusbgui', path) # I'll just hard code it until someone finds better way
bin_path = get_bin_path()
shutil.copy2(this_directory + '/WoeUSB/woeusbgui', os.path.join(bin_path, 'woeusbgui'))

datarootdir_path = get_datarootdir()

actions_path = os.path.join(datarootdir_path, "polkit-1/actions")
os.makedirs(actions_path, exist_ok=True)
shutil.copy2(this_directory + '/miscellaneous/com.github.woeusb.woeusb-ng.policy', actions_path)

icons_path = os.path.join(datarootdir_path, 'icons/WoeUSB-ng')
os.makedirs(icons_path, exist_ok=True)

shutil.copy2(this_directory + '/miscellaneous/com.github.woeusb.woeusb-ng.policy', "/usr/share/polkit-1/actions")
icon_path = os.path.join(icons_path, 'icon.ico')
shutil.copy2(this_directory + '/WoeUSB/data/icon.ico', icon_path)

try:
os.makedirs('/usr/share/icons/WoeUSB-ng')
except FileExistsError:
pass
applications_path = os.path.join(datarootdir_path, 'applications')
os.makedirs(applications_path, exist_ok=True)

shutil.copy2(this_directory + '/WoeUSB/data/icon.ico', '/usr/share/icons/WoeUSB-ng/icon.ico')
shutil.copy2(this_directory + '/miscellaneous/WoeUSB-ng.desktop', "/usr/share/applications/WoeUSB-ng.desktop")
desktopfile_path = os.path.join(applications_path, 'WoeUSB-ng.desktop')
shutil.copy2(this_directory + '/miscellaneous/WoeUSB-ng.desktop', desktopfile_path)

os.chmod('/usr/share/applications/WoeUSB-ng.desktop',
os.chmod(desktopfile_path,
stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IEXEC) # 755


Expand Down