summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-08-04 05:11:58 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-08-04 06:02:46 +0200
commit1878dac5e1a839bd4c07cae0f85cf62dd7474e45 (patch)
tree1205d1d4c4b55b31fe07a55e9676eac4a8b073aa
parent954e4dc962374058e056b6682ff8ba33a2ecc9dc (diff)
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/40755 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rwxr-xr-xbin/update/create_full_mar.py10
-rw-r--r--bin/update/path.py19
-rw-r--r--bin/update/signing.py3
3 files changed, 25 insertions, 7 deletions
diff --git a/bin/update/create_full_mar.py b/bin/update/create_full_mar.py
index 38919542d6a4..48686be21e45 100755
--- a/bin/update/create_full_mar.py
+++ b/bin/update/create_full_mar.py
@@ -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)
diff --git a/bin/update/path.py b/bin/update/path.py
index 1bc14d70d940..0fe0fd5eb04f 100644
--- a/bin/update/path.py
+++ b/bin/update/path.py
@@ -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())
diff --git a/bin/update/signing.py b/bin/update/signing.py
index e6ac2832d844..c0b43ce91536 100644
--- a/bin/update/signing.py
+++ b/bin/update/signing.py
@@ -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)