From 4cee3807ffe892199a4bf1249928a1d876494fe9 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sat, 24 Feb 2018 11:03:05 +0300 Subject: [PATCH 1/4] runanki.system: fix prefix at install time Currently the Makefile lets you choose your own PREFIX, but the installed runanki.system always hardcodes the prefix as /usr. Fix runanki.system at install time to install into the designated PREFIX. --- .gitignore | 1 + Makefile | 2 ++ tools/{runanki.system => runanki.system.in} | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) rename tools/{runanki.system => runanki.system.in} (59%) diff --git a/.gitignore b/.gitignore index ad6d9373d..9f0baff67 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ aqt/forms locale .idea +tools/runanki.system diff --git a/Makefile b/Makefile index 3e0d2a30d..a1e127342 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ install: rm -rf ${DESTDIR}${PREFIX}/share/anki mkdir -p ${DESTDIR}${PREFIX}/share/anki cp -av * ${DESTDIR}${PREFIX}/share/anki/ + sed -e 's:@PREFIX@:${PREFIX}:' tools/runanki.system.in > tools/runanki.system + chmod 755 tools/runanki.system cd ${DESTDIR}${PREFIX}/share/anki && (\ mv tools/runanki.system ${DESTDIR}${PREFIX}/local/bin/anki;\ test -d ${DESTDIR}${PREFIX}/share/pixmaps &&\ diff --git a/tools/runanki.system b/tools/runanki.system.in similarity index 59% rename from tools/runanki.system rename to tools/runanki.system.in index 786f6693e..9d39c3bbd 100755 --- a/tools/runanki.system +++ b/tools/runanki.system.in @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import sys -sys.path.append("/usr/share/anki") +sys.path.append("@PREFIX@/share/anki") import aqt aqt.run() From 08234805e0dda95c3b212cf226cca08f4ca156cd Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sat, 24 Feb 2018 11:06:22 +0300 Subject: [PATCH 2/4] Fix consistency between /usr and /usr/local By default the Makefile installs data into /usr/share (with default prefix /usr) but the binary is installed into /usr/local/bin (as if the prefix were /usr/local). Improve consistency by dropping "local" from the binary path. If the user wants to install into /usr/local he/she can do PREFIX=/usr/local --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a1e127342..acfdfa1f7 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ install: sed -e 's:@PREFIX@:${PREFIX}:' tools/runanki.system.in > tools/runanki.system chmod 755 tools/runanki.system cd ${DESTDIR}${PREFIX}/share/anki && (\ - mv tools/runanki.system ${DESTDIR}${PREFIX}/local/bin/anki;\ + mv tools/runanki.system ${DESTDIR}${PREFIX}/bin/anki;\ test -d ${DESTDIR}${PREFIX}/share/pixmaps &&\ mv anki.xpm anki.png ${DESTDIR}${PREFIX}/share/pixmaps/;\ mv anki.desktop ${DESTDIR}${PREFIX}/share/applications;\ @@ -25,7 +25,7 @@ install: uninstall: rm -rf ${DESTDIR}${PREFIX}/share/anki - rm -rf ${DESTDIR}${PREFIX}/local/bin/anki + rm -rf ${DESTDIR}${PREFIX}/bin/anki rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.xpm rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.png rm -rf ${DESTDIR}${PREFIX}/share/applications/anki.desktop From 87e9effc84d6abe81f34d7d42089c0fb24964737 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sat, 24 Feb 2018 11:14:56 +0300 Subject: [PATCH 3/4] Makefile: only install required files The previous Makefile is doing "cp *" and hence installing uninteresting files like the Makefile itself. Copy only the application-relevant files, and switch to using install for some of this where we can automatically create parent directories if required, solving issues when installing into an empty root. locale installation is optional; as before, locale files will be installed if they are present, but installation can also proceed without them. --- Makefile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index acfdfa1f7..a803e6d83 100644 --- a/Makefile +++ b/Makefile @@ -8,15 +8,14 @@ all: install: rm -rf ${DESTDIR}${PREFIX}/share/anki mkdir -p ${DESTDIR}${PREFIX}/share/anki - cp -av * ${DESTDIR}${PREFIX}/share/anki/ + cp -av anki aqt web ${DESTDIR}${PREFIX}/share/anki/ + -cp -av locale ${DESTDIR}${PREFIX}/share/anki/ sed -e 's:@PREFIX@:${PREFIX}:' tools/runanki.system.in > tools/runanki.system - chmod 755 tools/runanki.system - cd ${DESTDIR}${PREFIX}/share/anki && (\ - mv tools/runanki.system ${DESTDIR}${PREFIX}/bin/anki;\ - test -d ${DESTDIR}${PREFIX}/share/pixmaps &&\ - mv anki.xpm anki.png ${DESTDIR}${PREFIX}/share/pixmaps/;\ - mv anki.desktop ${DESTDIR}${PREFIX}/share/applications;\ - mv anki.1 ${DESTDIR}${PREFIX}/share/man/man1/) + install -m 0755 -D tools/runanki.system ${DESTDIR}${PREFIX}/bin/anki + install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/pixmaps anki.xpm anki.png + install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/applications anki.desktop + install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/man/man1 anki.1 + install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/doc/anki README.contributing README.development README.md LICENSE xdg-mime install anki.xml --novendor xdg-mime default anki.desktop application/x-anki xdg-mime default anki.desktop application/x-apkg From 954fc91d1f86efe1e90e374ed53f88fc42e4d009 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sat, 24 Feb 2018 11:16:37 +0300 Subject: [PATCH 4/4] Makefile: make xdg-mime calls non-fatal xdg-mime may not be available in the build root being used. Allow application installation to proceed anyway. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a803e6d83..a7ee26c83 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,9 @@ install: install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/applications anki.desktop install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/man/man1 anki.1 install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/doc/anki README.contributing README.development README.md LICENSE - xdg-mime install anki.xml --novendor - xdg-mime default anki.desktop application/x-anki - xdg-mime default anki.desktop application/x-apkg + -xdg-mime install anki.xml --novendor + -xdg-mime default anki.desktop application/x-anki + -xdg-mime default anki.desktop application/x-apkg @echo @echo "Install complete."