12-16-2020, 02:58 PM | #1 |
Member
Posts: 10
Karma: 10
Join Date: Dec 2020
Device: Android/PC
|
AppImage -- clean packaging
Just wanted to report it's quite easy to create a portable AppImage from an isolated calibre install (once you know what to do, that is), with multi-binary support included. That is, after following these steps, you get a compressed AppImage which can be called as /usr/local/bin/calibre, .../ebook-viewer, .../ebook-meta etc (busybox-style).
All in all, packaging calibre didn't require much hacking, so I'm hopeful this recipe should work for future upgrades. 1. Follow the official isolated install instructions (I'm unpacking to /tmp, use /opt or ~/calibre-bin depending on your circumstances): Code:
wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sh /dev/stdin install_dir=/tmp isolated=y Code:
cd /tmp/calibre ln -s resources/images/apple-touch-icon.png calibre.png cat >AppRun <<'EOF' #!/bin/sh mybin=$(cd "$APPDIR"; mybin=$(basename "$ARGV0"); if test -x "$mybin"; then echo "$mybin"; else echo calibre; fi) "$APPDIR/$mybin" "$@" EOF chmod +x AppRun # desktop file as seen in Debian; only Icon= and Exec= really matter cat >calibre.desktop <<'EOF' [Desktop Entry] Version=1.0 Type=Application Name=calibre GenericName=calibre E-book library management Exec=calibre %F Icon=calibre Categories=Office; X-GNOME-UsesNotifications=true MimeType=text/plain;application/x-mobipocket-subscription;application/vnd.openxmlformats-officedocument.wordprocessingml.document;text/html;application/x-cbc;application/ereader;application/oebps-package+xml;image/vnd.djvu;application/x-sony-bbeb;application/vnd.ms-word.document.macroenabled.12;text/rtf;text/x-markdown;application/pdf;application/x-cbz;application/x-cbr;application/x-mobi8-ebook;text/fb2+xml;application/vnd.oasis.opendocument.text;application/epub+zip;application/x-mobipocket-ebook;application/xhtml+xml; EOF Code:
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -o /tmp/appimagetool chmod +x /tmp/appimagetool /tmp/appimagetool /tmp/calibre/ /usr/local/bin/calibre-x86_64.AppImage Code:
(for f in *; do test -x "$f" && test -f "$f" && sudo ln -sf /usr/local/bin/calibre-x86_64.AppImage /usr/local/bin/"$f"; done) cd rm -rf /tmp/calibre-installer-cache/ /tmp/calibre /usr/local/bin/AppRun Upgrading is as simple as following the same instructions exactly. To view current version, use `calibre --version`. In case something goes wrong, use `calibre --appimage-extract` and retry. |
12-16-2020, 09:23 PM | #2 |
creator of calibre
Posts: 44,419
Karma: 24044628
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Why create an appimage at all??
|
Advert | |
|
12-17-2020, 12:16 AM | #3 |
Member
Posts: 10
Karma: 10
Join Date: Dec 2020
Device: Android/PC
|
If you mean one could create a /opt/calibre.squashfs, and have it auto mounted from fstab, then yes -- but it's easier to use an executable appimage on ANY linux install. Like when you're not on your own computer...
If you mean "why save space at all", then -- with SSDs, space is a reasonable concern once again. Also, live USB sticks. Actually I don't see the point of filling up storage with uncompressed binaries and data files in general. One could convert to live ("frugal") installs completely, but even in this case, keeping big applications separate simplifies updating, and also minimizes the live FS image. |
12-17-2020, 12:06 PM | #4 |
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
If you need to save space that badly, use a filesystem that supports native compression. Or use a distro package, mine is 86 mb and not even optimized for size (it has 3 copies of every python file, including two versions of optimized bytecode).
If your goal is simply to enable people that want a portable one-click redistributable because appimage, then that's great and I wish you the best of luck... But the correct medium for that is "wherever people go looking for curated collections of appimages". Publishing a do-it-yourself guide here accomplishes nothing, since the only people who would be helped by it are the people who don't want to build an installer executable themselves, by hand. They want the output executable. Kovid has repeatedly rejected recommendations to change the current official distribution format provided by https://calibre-ebook.com on the grounds that tarballs are usable via the current simple instructions, on any Linux distro, without engaging in wrapper fads. None of these wrapper fads add any value that calibre is interested in, and most of them reduce value by requiring complex supporting infrastructure to be installed first (flatpak, snap) and inherently try but fail to sandbox the program and accomplish nothing other than preventing resources such as shell completion, easy access to command line tools, desktop files for *all* the gui programs, proper use of the icon themes, and more, from being installed as intended and usable for the entire system. It's beautiful that third-party distributors want to make calibre available for their specific use cases. But that's not really Kovid's job, so you're best off publishing this yourself on flathub, the snap store, or in your case, I guess wherever people publish appimages. |
12-17-2020, 04:51 PM | #5 | |||||
Member
Posts: 10
Karma: 10
Join Date: Dec 2020
Device: Android/PC
|
I'll try to stay as on-topic as possible. I've searched for appimage recipes, I've found few results, but some other people having problems. It's in the interest of everyone "on the internet" (including me, searching at a later time) to document a solution somewhere in visible search results.
I'm not requesting any changes to the setup process, as I know all too well what a friendly / open-minded response I would run into. As I said in my initial post, I'm just here to report / document something that I spent time on, and which is not easy to figure out based on current search results. Quote:
Quote:
Quote:
Quote:
Most people don't want unsupervised installs (e.g. wget+sh), since you don't know what it does to your system, it provides no security in transferring the packages (wget+sh + MITM/hacked website etc) and it may pollute the filesystem with artifacts if the uninstallation fails (or is buggy). Quote:
Anyway, thank you for your thoughtful input. It's getting annoying to deal with endless reCAPTCHAs on top of reCAPTCHAs for the same IP on this forum, so I doubt I'll be here much longer. |
|||||
Advert | |
|
12-17-2020, 09:34 PM | #6 |
creator of calibre
Posts: 44,419
Karma: 24044628
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
What a load of nonsense. The calibre installation includes desktop files. Do a proper installation instead of an isolated one and you will find them.
And distro packages are outdated only in outdated distros, and have to do with the distros' outdated packaging policies, not calibre's installation scripts. And wget, with https + sh from upstream is FAR MORE secure than downloading some random dude on the internets repackaging of those binaries in random "application format" of the week. This wget + sh bad meme always makes me laugh. |
12-17-2020, 11:54 PM | #7 | ||||
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
Also, I am a contributor to calibre. I know a great deal about the installation scripts, because I wrote part of them. They're very clean and package-able, and I obsessively tweak them whenever I can make them even more clean and package-able. You don't seem to know ANYTHING about how distros work, so I'll give you a hint: Debian unstable packages the very latest 5.7.2, but Debian's official release of Debian will never upgrade calibre, clean or not, because they are STABLE, and they define that as "does not change, for good or ill", and upgrading to a new version of calibre would constitute change. I'm told most people like this "stable" thing. If they're not using Debian stable, they're using CentOS, RHEL, Ubuntu, or Windows 7 (still), because they don't like the entire world changing every other week. Heck -- the official calibre guidance on updating says: Quote:
Yeah, well, that's exactly the problem, isn't it? The one you "wrote by hand", with the comment "desktop file as seen in Debian", is the one which calibre's own code creates in src/calibre/linux.py, as invoked by either distro packaging (python setup.py install), or via /opt/calibre/calibre_postinstall. Obviously, doing the isolated install does not try to write desktop files, shell completions, icon themes, etc. into the non-isolated /usr/share. Per your choice. So now, there are none to inspect. Oh well. It's not like an appimage can own files in /usr/share/bash-completion/completions, and the appimage spec explicitly refuses to support multiple .desktop file entry points in one appimage. ... Did you think Debian just invented the desktop file out of whole cloth? Quote:
Code:
wget URL -O installer.sh less installer.sh sh installer.sh Per https://calibre-ebook.com/download you may even manually verify the tarball it retrieves using the PGP signature from https://calibre-ebook.com/signatures, and manually untar it, then execute the calibre_postinstall program to set up system integration. Quote:
The reCAPTCHAs sound odd, I've never gotten a reCAPTCHA once in all my years of using this forum -- including the old days when I visited every single day for years, and the vast periods of time in which I abandoned the forum, then sporadically returned with gaps of up to a year. |
||||
12-18-2020, 01:49 AM | #8 | |||
Member
Posts: 10
Karma: 10
Join Date: Dec 2020
Device: Android/PC
|
Well, I guess we're offtopic, and I'm reacquainting myself to the pleasures of dealing with calibre's human interface. Thanks for the reminder.
Quote:
I also particularly like this on the calibre install page: "You can uninstall calibre by running sudo calibre-uninstall. Alternately, simply deleting the installation directory will remove 99% of installed files" Meaning, if my system hangs, or if there's a bug, I have to trust a non-distribution script to pick up its own trash, without any proper recourse to forcibly remove everything it "improved" on my system. Quote:
And yeah, I know I can run Debian testing / Sid / Ubuntu non-LTS (giving up maintainability and control over key system setup), or switch to Arch or Void or worse and give up the wealth of Debian packaging. No thanks. Quote:
|
|||
12-18-2020, 02:11 AM | #9 | ||||||
creator of calibre
Posts: 44,419
Karma: 24044628
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
||||||
12-18-2020, 02:32 AM | #10 | |||||||||
Member
Posts: 10
Karma: 10
Join Date: Dec 2020
Device: Android/PC
|
Quote:
Quote:
Quote:
Quote:
Quote:
Anyway, who am I kidding, calibre even uses BINARY files, instead of scripts, to set up paths. Hence, ebook-viewer vs bin/ebook-viewer. Wonderfully non-discoverable and opaque. I *suppose* it's just a matter of setting up LD_LIBRARY_PATH, but who knows, there's stuff both in lib/ and libexec/. Quote:
Quote:
Quote:
Anyway, the point was that with a clean isolated install process, one can easily generate an appimage, and that image can serve many needs / whims, including my very specialized ones. Quote:
|
|||||||||
12-18-2020, 02:36 AM | #11 | ||||
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
Code:
staging_root=/tmp/calibre-staging-root/usr # xdg-utils requires various directories to exist rather than creating them, even ones it doesn't even use mkdir -p "$staging_root"/share/{applications,desktop-directories,icons/hicolor,mime/packages} XDG_DATA_DIRS="$staging_root"/share XDG_UTILS_INSTALL_MODE=system /opt/calibre/calibre_postinstall --root="$staging_root" Linux distro packagers would know this as analogous to $DESTDIR. Quote:
Quote:
As for switching to Arch "or worse", we have more AUR packages than Debian has packages, period. The supposed wealth of having sheer quantity of package numbers? Firmly on our side. And unlike Debian we don't cheat by splitting every software project into 6+ different subpackages, thereby padding out their package count with stuff that isn't distinctive. (Debian does this due to policy demanding the default install of a program not include development headers or docs, and further splitting many packges to enable minimal disk usage for unused features.) But I don't see the problem here. You have an AppImage suitable for your personal use, if not anyone else's. There were certain... inefficiencies... in your understanding of calibre's current installer, which resulted in you not realizing how easy it is to get things like desktop files, but now you know, and you sort of worked around it already anyway. Quote:
If you're not going to trust some random dude, but go to all the effort of setting up an appimage build recipe *and* downloading calibre's binary tarball, why not just stick with the tarball, manually extracted? The AppImage recipe provides nothing in addition to the tarball, other than a manually copied .desktop file, which could be used without AppImage... This entire thing seems to be some sort of paranoia that the calibre-uninstall script, which is fairly well behaved, is somehow very untrustworthy and leaves "trash" behind. |
||||
12-18-2020, 02:47 AM | #12 | |
Member
Posts: 10
Karma: 10
Join Date: Dec 2020
Device: Android/PC
|
Quote:
I didn't request any changes to the default install, I didn't even badmouth it before all these nice exchanges. Because I know what to expect. I just posted a packaging report so others, or me at a later time, can find information easily. |
|
12-18-2020, 02:52 AM | #13 | |||
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
Quote:
I don't much care about the binary installer, but as I mentioned above it's not hard to just pass --root to it (and play Freedesktop XDG-utils games for overriding their default target). So I don't see how this is ideologically a battle between ideologies. Given the files are dynamically generated from up to date info, I don't see much point in shipping them again and having postinstall merely copy them. It sounds more complex, essentially busywork. Quote:
The binary version is based on https://github.com/kovidgoyal/calibr...nux/launcher.c I'm not sure why this is especially evil, to use C launchers instead of shellscripts. Why is it supposed to be discoverable? Is a C program that *isn't* a launcher also supposed to be discoverable without disassembling? |
|||
12-18-2020, 02:52 AM | #14 | ||
creator of calibre
Posts: 44,419
Karma: 24044628
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
Quote:
Good bye and good luck. |
||
12-18-2020, 03:20 AM | #15 | |
Member
Posts: 10
Karma: 10
Join Date: Dec 2020
Device: Android/PC
|
Quote:
Thanks for all the info. I'm not sure if the install script is documented officially (I tried backporting to a PPA a long time ago when I still believed in Ubuntu), but if not, this is very useful. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Update Advice for Calibre AppImage? | Ces33 | Devices | 10 | 05-22-2020 11:07 PM |
Koreader AppImage | roger64 | KOReader | 3 | 04-12-2018 10:20 AM |
Short Fiction Martinez, Brian: A Good Clean, A Harsh Clean. v1. PDF, 13th Dec 2010 | BrianMartinez | Other Books | 0 | 12-13-2010 09:27 PM |
Short Fiction Martinez, Brian: A Good Clean, A Harsh Clean. v1. 13th Dec 2010 | BrianMartinez | Kindle Books | 0 | 12-13-2010 09:25 PM |
Short Fiction Martinez, Brian: A Good Clean, A Harsh Clean. v1. 13th Dec 2010 | BrianMartinez | ePub Books | 0 | 12-13-2010 09:23 PM |