Change working directory before executing install/update/uninstall script

This commit is contained in:
Disassembler 2019-10-14 08:23:45 +02:00
parent ecfa225187
commit ecb09001d4
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499

View File

@ -194,9 +194,14 @@ class PkgMgr:
def run_script(self, app, script): def run_script(self, app, script):
# Runs script for an app, if the script is present # Runs script for an app, if the script is present
script_path = os.path.join(REPO_CACHE_DIR, 'apps', app, script) script_dir = os.path.join(REPO_CACHE_DIR, 'apps', app)
script_path = os.path.join(script_dir, script)
if os.path.exists(script_path): if os.path.exists(script_path):
# Change working directory, so the script doesn't have to figure out paths to packaged files
cwd = os.getcwd()
os.chdir(script_dir)
subprocess.run(script_path, check=True) subprocess.run(script_path, check=True)
os.chdir(cwd)
def register_app(self, app, metadata): def register_app(self, app, metadata):
# Register installed app in list of installed apps # Register installed app in list of installed apps