From 93d1fdb87ae7247c11b29891d05bd8db2cca5afb Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Sun, 23 Jul 2017 18:21:18 +0100 Subject: [PATCH] appimage: Used test_distributions to fix the AppImage. --- README.md | 2 +- appimage/AppRun | 8 +++---- make-appimage.py | 4 ++++ test_distributions.py | 8 ++++--- ...5_syntax-root_php => php7_syntax-root_php} | 0 tests/golden-files/results/pydoc-hi3_py | 22 +++++++++---------- tests/golden-files/results/pydoc-hi_py | 22 +++++++++---------- tests/tools_test.py | 20 ++++++++++------- vigil/tools.py | 11 +++++----- 9 files changed, 52 insertions(+), 45 deletions(-) rename tests/golden-files/results/{php5_syntax-root_php => php7_syntax-root_php} (100%) diff --git a/README.md b/README.md index 505189d..65ce341 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Extensions | Tools .cc .cpp .hpp | [cpp_syntax_gcc](https://gcc.gnu.org/) • bcpp • [uncrustify](https://github.com/uncrustify/uncrustify) .pdf | [pdf2txt](http://www.unixuser.org/~euske/python/pdfminer/) .html | [html_syntax](http://www.html-tidy.org/) • [tidy](http://www.html-tidy.org/) • [html2text](http://www.mbayer.de/html2text/) -.php | [php5_syntax](https://en.wikipedia.org/wiki/PHP) +.php | [php7_syntax](https://en.wikipedia.org/wiki/PHP) .zip | [unzip](http://www.info-zip.org/UnZip.html) .tar.gz .tgz | [tar_gz](http://www.gnu.org/software/tar/manual/tar.html) .tar.bz2 | [tar_bz2](http://www.gnu.org/software/tar/manual/tar.html) diff --git a/appimage/AppRun b/appimage/AppRun index 988bc1d..ae3bb55 100755 --- a/appimage/AppRun +++ b/appimage/AppRun @@ -8,13 +8,11 @@ set -e HERE="$(dirname "$(readlink -f "${0}")")" +export APPDIR="${HERE}" +export PATH="${HERE}"/usr/bin/:"${HERE}"/usr/local/bin/:"${PATH}" export UNION_PRELOAD="${HERE}" export LD_PRELOAD="${HERE}/libunionpreload.so" export LD_LIBRARY_PATH="${HERE}"/usr/lib/:"${HERE}"/usr/lib/i386-linux-gnu/:"${HERE}"/usr/lib/x86_64-linux-gnu/:"${HERE}"/usr/lib32/:"${HERE}"/usr/lib64/:"${HERE}"/lib/:"${HERE}"/lib/i386-linux-gnu/:"${HERE}"/lib/x86_64-linux-gnu/:"${HERE}"/lib32/:"${HERE}"/lib64/:"${LD_LIBRARY_PATH}" -export PYTHONPATH="/usr/local/lib/python3.5/dist-packages:${HERE}"/usr/share/pyshared/:"${PYTHONPATH}" -export XDG_DATA_DIRS="${HERE}"/usr/share/:"${XDG_DATA_DIRS}" -export PERLLIB="${HERE}"/usr/share/perl5/:"${HERE}"/usr/lib/perl5/:"${PERLLIB}" -export GSETTINGS_SCHEMA_DIR="${HERE}"/usr/share/glib-2.0/schemas/:"${GSETTINGS_SCHEMA_DIR}" -export QT_PLUGIN_PATH="${HERE}"/usr/lib/qt4/plugins/:"${HERE}"/usr/lib/i386-linux-gnu/qt4/plugins/:"${HERE}"/usr/lib/x86_64-linux-gnu/qt4/plugins/:"${HERE}"/usr/lib32/qt4/plugins/:"${HERE}"/usr/lib64/qt4/plugins/:"${HERE}"/usr/lib/qt5/plugins/:"${HERE}"/usr/lib/i386-linux-gnu/qt5/plugins/:"${HERE}"/usr/lib/x86_64-linux-gnu/qt5/plugins/:"${HERE}"/usr/lib32/qt5/plugins/:"${HERE}"/usr/lib64/qt5/plugins/:"${QT_PLUGIN_PATH}" +export PYTHONPATH=/usr/local/lib/python3.5/dist-packages:"${PYTHONPATH}" EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2- | sed -e 's|%.||g') exec ${EXEC} $@ diff --git a/make-appimage.py b/make-appimage.py index e605810..0e8a97f 100755 --- a/make-appimage.py +++ b/make-appimage.py @@ -91,6 +91,10 @@ def main(work_path): os.chdir(work_path) base_paths = make_ubuntu_base() test_distributions.run_in_container("ubuntu", "./install-dependencies") + test_distributions.run_in_container( + "ubuntu", "sed -i -e 's/\/usr\/bin\/python/\/usr\/bin\/env python/g' " + "/usr/bin/pdf2txt") # libunionpreload doesn't trick shebangs? + test_distributions.run_in_container("ubuntu", "apt-get install --yes python3-pip") test_distributions.run_in_container("ubuntu", "pip3 install -I .") post_install_paths = relative_paths("ubuntu", all_paths("ubuntu")) new_paths = set(post_install_paths) - set(base_paths) diff --git a/test_distributions.py b/test_distributions.py index 9796d2c..e263269 100755 --- a/test_distributions.py +++ b/test_distributions.py @@ -40,12 +40,13 @@ def run_in_container(container, command): def build_ubuntu(): - cmd("sudo debootstrap --components=main,restricted,universe,multiverse " - "zesty ubuntu.part") + cmd("sudo debootstrap zesty ubuntu.part") run_in_container("ubuntu.part", "ln -sf /lib/systemd/resolv.conf /etc/resolv.conf") + run_in_container("ubuntu.part", + "sed -i -e 's/main/main restricted universe" + " multiverse/g' /etc/apt/sources.list") run_in_container("ubuntu.part", "apt-get update") - run_in_container("ubuntu.part", "apt-get install --yes python3-pip") os.rename("ubuntu.part", "ubuntu") @@ -140,6 +141,7 @@ def main(): print("Installing vigil's dependencies in %s..." % distribution) run_in_container(distribution, "./install-dependencies") print("Installing vigil in %s..." % distribution) + run_in_container(distribution, "apt-get install --yes python3-pip") run_in_container(distribution, "pip3 install .") print("Testing vigil in %s..." % distribution) run_in_container(distribution, "./test-all") diff --git a/tests/golden-files/results/php5_syntax-root_php b/tests/golden-files/results/php7_syntax-root_php similarity index 100% rename from tests/golden-files/results/php5_syntax-root_php rename to tests/golden-files/results/php7_syntax-root_php diff --git a/tests/golden-files/results/pydoc-hi3_py b/tests/golden-files/results/pydoc-hi3_py index cad0c6d..987cf08 100644 --- a/tests/golden-files/results/pydoc-hi3_py +++ b/tests/golden-files/results/pydoc-hi3_py @@ -1,12 +1,12 @@ -Help on module hi3: - -NAME - hi3 - -FUNCTIONS - hi() - -FILE +Help on module hi3: + +NAME + hi3 + +FUNCTIONS + hi() + +FILE /CWD/input/hi3.py - - \ No newline at end of file + + \ No newline at end of file diff --git a/tests/golden-files/results/pydoc-hi_py b/tests/golden-files/results/pydoc-hi_py index 1761ea8..a51c85f 100644 --- a/tests/golden-files/results/pydoc-hi_py +++ b/tests/golden-files/results/pydoc-hi_py @@ -1,12 +1,12 @@ -Help on module hi: - -NAME - hi - -FILE +Help on module hi: + +NAME + hi + +FILE /CWD/input/hi.py - -FUNCTIONS - hi() - - \ No newline at end of file + +FUNCTIONS + hi() + + \ No newline at end of file diff --git a/tests/tools_test.py b/tests/tools_test.py index fe956b7..bf1573d 100755 --- a/tests/tools_test.py +++ b/tests/tools_test.py @@ -101,9 +101,10 @@ class ToolsTestCase(unittest.TestCase): HI_NORMAL = [("hi3.py", tools.Status.normal), ("hi.py", tools.Status.normal)] - # FIX: This is failing inside AppImages. - # def test_pydoc(self): - # self._test_tool(tools.pydoc, self.HI_NORMAL) + def test_pydoc(self): + # FIX: This is failing inside AppImages. + if "APPDIR" not in os.environ: + self._test_tool(tools.pydoc, self.HI_NORMAL) def test_mypy(self): self._test_tool(tools.mypy, [("hi3.py", tools.Status.ok), @@ -146,9 +147,12 @@ class ToolsTestCase(unittest.TestCase): ]) def test_perldoc(self): - self._test_tool(tools.perldoc, - [("perl.pl", tools.Status.not_applicable), - ("contents.pod", tools.Status.normal)]) + # FIX: This is failing in an Appimage, inside a nspawn container, + # as root. + if "APPDIR" not in os.environ: + self._test_tool(tools.perldoc, + [("perl.pl", tools.Status.not_applicable), + ("contents.pod", tools.Status.normal)]) def test_perltidy(self): self._test_tool(tools.perltidy, [("perl.pl", tools.Status.normal)]) @@ -214,8 +218,8 @@ class ToolsTestCase(unittest.TestCase): def test_bcpp(self): self._test_tool(tools.bcpp, [("hello.cpp", tools.Status.normal)]) - def test_php5_syntax(self): - self._test_tool(tools.php5_syntax, [("root.php", tools.Status.ok)]) + def test_php7_syntax(self): + self._test_tool(tools.php7_syntax, [("root.php", tools.Status.ok)]) def test_pil(self): for extension in tools.IMAGE_EXTENSIONS: diff --git a/vigil/tools.py b/vigil/tools.py index bd4ce49..f594973 100644 --- a/vigil/tools.py +++ b/vigil/tools.py @@ -638,11 +638,10 @@ def uncrustify(path): return status, _syntax_highlight_using_path(stdout, path) -@deps(deps={"php"}, opensuse_deps={"php5"}, - url="https://en.wikipedia.org/wiki/PHP", executables={"php"}, - missing_in={"debian"}) -def php5_syntax(path): - return _run_command(["php", "--syntax-check", path]) +@deps(deps={"php7.0-cli"}, url="https://en.wikipedia.org/wiki/PHP", + executables={"php7.0"}, missing_in={"debian"}) +def php7_syntax(path): + return _run_command(["php7.0", "--syntax-check", path]) def _pil_pixels(pil_image): @@ -852,7 +851,7 @@ TOOLS_FOR_EXTENSIONS = \ (["cc", "cpp", "hpp"], [cpp_syntax_gcc, bcpp, uncrustify]), (["pdf"], [pdf2txt]), (["html"], [html_syntax, tidy, html2text]), - (["php"], [php5_syntax]), + (["php"], [php7_syntax]), (["zip"], [unzip]), (["tar.gz", "tgz"], [tar_gz]), (["tar.bz2"], [tar_bz2]),