Anki: improving memory

Non release banter
User avatar
francois
Contributor
Contributor
Posts: 6514
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Anki: improving memory

Post#16 by francois » 04 Nov 2023, 07:50

@rava:
If you get to work with it, please comment.
Prendre son temps, profiter de celui qui passe.

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

Anki: improving memory

Post#17 by rych » 04 Nov 2023, 09:02

francois, Before you started a new thread there had already been a module request thread for it Anki - Flash Card program to help studying ;-) where we had some discussion a bit similar to yours and some success. At least I successfully ran it in the end just to find out that I don't really like it. We of course can freely create multiple threads on the same topic or the same App, but I hope it's known how to find out previous threads on the same topic: https://www.google.com/search?q=site%3A ... s.org+Anki

User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Anki: improving memory

Post#18 by Rava » 04 Nov 2023, 09:55

francois wrote:
04 Nov 2023, 07:47
So in your case, you should work with the whole set of files.
And probably make an module out of it, since the binary itself is not enough.
And uncompressed into a folder it is rather large - 440 MB while the anki-23.10-linux-qt5.tar.zst itself is 121 MB.
Though how much can be trimmed off from the extracted anki-23.10-linux-qt5 remains to be seen.
francois wrote:
04 Nov 2023, 07:47
I get this now that I have installed it:
How did you install it?
Created a module out of the extracted anki-23.10-linux-qt5.tar.zst ?
Cheers!
Yours Rava

Kulle
Warlord
Warlord
Posts: 705
Joined: 28 Jan 2017, 10:39
Distribution: v4.0 64bit Xfce
Location: Berlin

Anki: improving memory

Post#19 by Kulle » 04 Nov 2023, 16:05

Hi Rava,
4 commands:

Code: Select all

wget https://github.com/ankitects/anki/releases/download/23.10/anki-23.10-linux-qt5.tar.zst
tar -I zstd -xf anki-23.10-linux-qt5.tar.zst
cd anki-23.10-linux-qt5
./anki
Worked for me (Porteux Xfce)

User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Anki: improving memory

Post#20 by Rava » 04 Nov 2023, 17:05

about making anki into a module, I ponder if using its install.sh to our advantage would work?

I browsed through it and found this:

Code: Select all

if [ "$PREFIX" = "" ]; then
	PREFIX=/usr/local
fi
that means, when I create an empty folder on a Linux file system, let's say the extracted folder is here
/mnt/sda2/tmp/anki-23.10-linux-qt5
and I create this folder as the target "fake root" for its install:
/mnt/sda2/tmp/anki-23.10-linux-qt5_rava
go into /mnt/sda2/tmp/anki-23.10-linux-qt5 and execute ./install.sh like so as root:

Code: Select all

PREFIX=/mnt/sda2/tmp/anki-23.10-linux-qt5_rava/usr/local  ./install.sh
it should move all files from /mnt/sda2/tmp/anki-23.10-linux-qt5 into /mnt/sda2/tmp/anki-23.10-linux-qt5_rava/usr/local ?
Your thoughts?

The full install.sh :

Code: Select all

#!/bin/bash

set -e

if [ "$(dirname "$(realpath "$0")")" != "$(realpath "$PWD")" ]; then
  echo "Please run from the folder install.sh is in."
  exit 1
fi

if [ "$PREFIX" = "" ]; then
	PREFIX=/usr/local
fi

rm -rf "$PREFIX"/share/anki "$PREFIX"/bin/anki
mkdir -p "$PREFIX"/share/anki
cp -av --no-preserve=owner,context -- * "$PREFIX"/share/anki/
mkdir -p "$PREFIX"/bin
ln -sf "$PREFIX"/share/anki/anki "$PREFIX"/bin/anki
# fix a previous packaging issue where we created this as a file
(test -f "$PREFIX"/share/applications && rm "$PREFIX"/share/applications)||true
mkdir -p "$PREFIX"/share/pixmaps
mkdir -p "$PREFIX"/share/applications
mkdir -p "$PREFIX"/share/man/man1
cd "$PREFIX"/share/anki && (\
mv -Z anki.xpm anki.png "$PREFIX"/share/pixmaps/;\
mv -Z anki.desktop "$PREFIX"/share/applications/;\
mv -Z anki.1 "$PREFIX"/share/man/man1/)

xdg-mime install anki.xml --novendor
xdg-mime default anki.desktop application/x-colpkg
xdg-mime default anki.desktop application/x-apkg
xdg-mime default anki.desktop application/x-ankiaddon

rm install.sh

echo "Install complete. Type 'anki' to run."
Not sure how to implement this line

Code: Select all

xdg-mime install anki.xml --novendor
I think it should be put into one of slackware's post-install scripts, yes?
Cheers!
Yours Rava

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

Anki: improving memory

Post#21 by rych » 05 Nov 2023, 01:17

Kulle wrote:
04 Nov 2023, 16:05
Worked for me
For me too: see the old thread: Anki - Flash Card program to help studying ;-) (Post by rych #94779) where we ran it under root as well, either with the Qt6 or Qt5. No need to "install.sh". No need to turn the bundle into a module. If you want to have it compressed then keep it as the archive (or .squashfs) and expand (or mount) it just before use. I'm going to redirect that thread to here so that people don't post there by mistake: the community have chosen to continue, after some duplication, the Anki discussion here for some reason :)

User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Anki: improving memory

Post#22 by Rava » 05 Nov 2023, 13:57

Anyone suggestions for the parameters for creating a .squashfs out of the extracted tar ?
Cheers!
Yours Rava

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

Anki: improving memory

Post#23 by rych » 05 Nov 2023, 15:17

Rava wrote:
05 Nov 2023, 13:57
Anyone suggestions for the parameters for creating a .squashfs
We talked about this one year ago:

why modules (Post by rych #91468)
why modules (Post by rych #91537)

Of course you first extract tar into a folder and then apply a simple command

Code: Select all

mksquashfs $1 $1.sqfs -noappend -comp zstd -b 256K
: see those posts for more. Then you mount the .sqfs container (read-only) as needed. Settings and program data are written into your home directory -- make sure you save those changes separately

User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Anki: improving memory

Post#24 by Rava » 05 Nov 2023, 17:12

^
Thanks. :good: And one could experiment with the block size, if e.g. -b 512K would make the resulting file significantly smaller.
I will browse the two posts and make me a help.mksquashfs script that will outline the basics.

User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Anki: improving memory

Post#25 by Rava » 06 Nov 2023, 03:42

^ How embarrassing, I totally forgot my participation in the why modules thread.

Anyhow, now I did it. Done 3 instances of creating a .sqfs file:

Code: Select all

mksquashfs anki-23.10-linux-qt5 anki-23.10-linux-qt5-128K.sqfs -noappend -comp zstd -b 128K
# and
mksquashfs anki-23.10-linux-qt5 anki-23.10-linux-qt5-256K.sqfs -noappend -comp zstd -b 256K
# and
mksquashfs anki-23.10-linux-qt5 anki-23.10-linux-qt5-512K.sqfs -noappend -comp zstd -b 512K
Results:

Code: Select all

root@rava:/8/tmp# /bin/ls -o --time-style=long-iso --quoting-style=shell *.sqfs| cut -c 19-$(expr 18 + $(tput cols))
153780224 2023-11-06 04:37 anki-23.10-linux-qt5-128K.sqfs
149106688 2023-11-06 04:34 anki-23.10-linux-qt5-256K.sqfs
157491200 2023-11-06 04:35 anki-23.10-linux-qt5-512K.sqfs
Seems the standard of using -b 256K gives the best results.

Added in 7 minutes 20 seconds:
And now for thinking of a way to robust mount and umount that (since it is only a mount, one could use /tmp/ as base folder for the creation of the folder to be mounted into, and also the base for the symlink to the binary in that folder), and also to create the needed symlinks into e.g. /usr/local/bin .

And when umounting it, also delete the created symlinks to the binary. And while I am at it, I make it so that the module name is allowed to have whitespace.

At least I can carry on with the debugging attempts from my very own posts in why modules; so no need to start from scratch. :ROFL:

rych
Warlord
Warlord
Posts: 787
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

Anki: improving memory

Post#26 by rych » 06 Nov 2023, 15:42

Rava wrote:
06 Nov 2023, 03:50
to robust mount
In the same place where you keep those .sqfs compressed images (won't call them modules as that name is taken), why not make a namesake folder unless it exists already and simply:

Code: Select all

mount HugeSoftware.sqfs HugeSoftware
(more details, like scripts and context menu entries in why modules (Post by rych #91537))

On restart those unmount automatically.

In my experiments I found, unsurprisingly as this is the whole promise of SquashFS, that reading from such a mounted compressed image feels faster than decompressing the whole archive all at once and work with all its extracted data as usual via ext4 -- not to mention the time and SIZE such expansion would take

User avatar
francois
Contributor
Contributor
Posts: 6514
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Anki: improving memory

Post#27 by francois » 06 Nov 2023, 22:00

@rych:
Thanks for the info.
Prendre son temps, profiter de celui qui passe.

User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Anki: improving memory

Post#28 by Rava » 06 Nov 2023, 23:15

About the why modules thread: I re-read it and for some reason you not implemented the small changes to make your script work with filenames containing whitespace.
rych wrote:
06 Nov 2023, 15:42
In my experiments I found, unsurprisingly as this is the whole promise of SquashFS, that reading from such a mounted compressed image feels faster than decompressing the whole archive all at once and work with all its extracted data as usual via ext4 -- not to mention the time and SIZE such expansion would take
Therefore, in my view, it would be a good thing when you have a script that does extract the filename (=filename sans .sqfs)
mkdir /tmp/filename
mount /path/to/filename.sqfs /tmp/filename
ln -s /tmp/filename/BINARY /usr/local/bin/BINARY

and for the reverse:
killall BINARY
rm /usr/local/bin/BINARY
umount /tmp/filename

Why use /tmp instead of the folder where the .sqfs sits?

because that would be unnecessary writing to a folder that is meant as temp. Since it is only a mount point it will take no space in /tmp/ (aside from the very small space a folder takes)

And finally: to make it more robust. What if the user tries moving or renaming /path/to/filename.sqfs while it is mounted? Would the umount part still find the folder to umount? But when it's always the same base folder /tmp/ and for the same .sqfs compressed image always the same mount point ( /tmp/filename/ ) umounting should be more reliable.

What I cannot envision is how to determine which symlinks to create when there are more than one binary in /tmp/filename/ to be found.
Cheers!
Yours Rava

User avatar
francois
Contributor
Contributor
Posts: 6514
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Anki: improving memory

Post#29 by francois » 08 Nov 2023, 22:27

@rava:
Did you used the software? :)
Prendre son temps, profiter de celui qui passe.

User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Anki: improving memory

Post#30 by Rava » 08 Nov 2023, 23:15

francois wrote:
08 Nov 2023, 22:27
@rava:
Did you used the software? :)
I would if I knew where to get the learning packages or whatever you call it.
Cheers!
Yours Rava

Post Reply