Kaydet (Commit) 1878dac5 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

updater: handle windows path in cygwin correctly

This is a huge mess. Any windows executable does not understand
cygwin paths but for example the bash script only understands unix paths.

Additionally, os.path is unixpath so it is not able to correctly handle
windows paths. We therefore convert everything that we need to handle
to unix paths and only the few paths that are passed in the end to windows
executables back to the native format. We selected mixed mode
(windows path with forward slash) to allow the unix scripts to manipulate
paths.

Change-Id: Ic443415ff5e8277bf0bb8704bbafd35f50767288
Reviewed-on: https://gerrit.libreoffice.org/40755Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 954e4dc9
......@@ -8,9 +8,9 @@ import json
from tools import uncompress_file_to_dir, get_file_info, make_complete_mar_name
from config import parse_config
from signing import sign_mar_file
from path import UpdaterPath
from path import UpdaterPath, convert_to_unix, convert_to_native
current_dir_path = os.path.dirname(os.path.realpath(__file__))
current_dir_path = os.path.dirname(os.path.realpath(convert_to_unix(__file__)))
def main():
if len(sys.argv) < 5:
......@@ -34,14 +34,14 @@ def main():
config = parse_config(update_config)
tar_dir = os.path.join(workdir, "installation", product_name, "archive", "install", "en-US")
tar_dir = os.path.join(update_path.get_workdir(), "installation", product_name, "archive", "install", "en-US")
tar_file = os.path.join(tar_dir, os.listdir(tar_dir)[0])
uncompress_dir = uncompress_file_to_dir(tar_file, temp_dir)
mar_file = make_complete_mar_name(target_dir, filename_prefix)
subprocess.call([os.path.join(current_dir_path, 'make_full_update.sh'), mar_file, uncompress_dir])
path = os.path.join(current_dir_path, 'make_full_update.sh')
subprocess.call([path, convert_to_native(mar_file), convert_to_native(uncompress_dir)])
sign_mar_file(target_dir, config, mar_file, filename_prefix)
......
......@@ -9,6 +9,8 @@
import os
import errno
import subprocess
from sys import platform
def mkdir_p(path):
try:
......@@ -19,10 +21,22 @@ def mkdir_p(path):
else:
raise
def convert_to_unix(path):
if platform == "cygwin":
return subprocess.check_output(["cygpath", "-u", path]).decode("utf-8", "strict").rstrip()
else:
return path
def convert_to_native(path):
if platform == "cygwin":
return subprocess.check_output(["cygpath", "-m", path]).decode("utf-8", "strict").rstrip()
else:
return path
class UpdaterPath(object):
def __init__(self, workdir):
self._workdir = workdir
self._workdir = convert_to_unix(workdir)
def get_workdir(self):
return self._workdir
......@@ -41,6 +55,9 @@ class UpdaterPath(object):
def get_language_dir(self):
return os.path.join(self.get_mar_dir(), "language")
def get_workdir(self):
return self._workdir
def ensure_dir_exist(self):
mkdir_p(self.get_update_dir())
......
......@@ -2,10 +2,11 @@ from tools import make_complete_mar_name
import os
import subprocess
import path
def sign_mar_file(target_dir, config, mar_file, filename_prefix):
signed_mar_file = make_complete_mar_name(target_dir, filename_prefix + '_signed')
mar_executable = os.environ.get('MAR', 'mar')
subprocess.check_call([mar_executable, '-C', target_dir, '-d', config.certificate_path, '-n', config.certificate_name, '-s', mar_file, signed_mar_file])
subprocess.check_call([mar_executable, '-C', path.convert_to_native(target_dir), '-d', path.convert_to_native(config.certificate_path), '-n', config.certificate_name, '-s', path.convert_to_native(mar_file), path.convert_to_native(signed_mar_file)])
os.rename(signed_mar_file, mar_file)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment