Perl & Raku Appimages for the Busy (& Lazy) Working Programmer.

  for dcpm, by Philip Hood - hood@panix.com - 20210706

Raku
----

01. 

 For Appimages, see:

 https://en.wikipedia.org/wiki/AppImage
 https://appimage.org/
 https://www.appimagehub.com/browse

 notes: does anyone rememember simtel ?

 https://en.wikipedia.org/wiki/Simtel
   
 or: walnut creek ?

 https://en.wikipedia.org/wiki/Walnut_Creek_CDROM

02.

  Get a recent appimage for Raku and extract it.

 https://github.com/timo/rakudo-appimage/releases
 https://github.com/timo/rakudo-appimage/releases/download/2021.05/Rakudo-2021.05.glibc2.15-x86_64.AppImage

  ./Rakudo-2021.05.glibc2.15-x86_64.AppImage --appimage-extract


03.

  Examine extracted directory & see the AppRun, desktop & .DirIcon link to image files.

"
pk@pkx:~/stuff/appimage$ cd squashfs-root/
pk@pkx:~/stuff/appimage/squashfs-root$ ls -al
total 72
drwxr-xr-x 4 pk pk  4096 Jul  5 20:41 .
drwxrwxr-x 4 pk pk  4096 Jul  5 20:40 ..
-rwxrwxr-x 1 pk pk 30696 Jul  5 20:41 AppRun
-rw-rw-r-- 1 pk pk 19087 Jul  5 20:41 camelia_butterfly.png
lrwxrwxrwx 1 pk pk    21 Jul  5 20:41 .DirIcon -> camelia_butterfly.png
drwxr-xr-x 3 pk pk  4096 Jul  5 20:40 etc
-rw-rw-r-- 1 pk pk   234 Jul  5 20:41 Rakudo.desktop
drwxr-xr-x 6 pk pk  4096 Jul  5 20:40 usr
"

  note image format:
"
pk@pkx:~/stuff/appimage/squashfs-root$ file camelia_butterfly.png 
camelia_butterfly.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
"

04.
  
 Note format of the Rakudo.desktop file:

"
pk@pkx:~/stuff/appimage/squashfs-root$ cat Rakudo.desktop 
[Desktop Entry]
Name=Rakudo
Comment=Compiler and REPL for the Raku language
Exec=rakudo-appimage-launcher
Icon=camelia_butterfly
Terminal=true
Type=Application
StartupNotify=false
Categories=Development;
X-AppImage-Version=.glibc2.15
"

05.

 Check glibc version used to compile packaged rakudo binary:

"
pk@pkx:~/stuff/appimage/squashfs-root$ strings usr/rakudo/bin/rakudo | grep -i ^GLIBC | sort
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3.4
GLIBC_2.4
"

06.

 Hard code the launcher shows in Rakudo.desktop to something, for demo purposes.

"
#!/bin/bash
HERE="$(dirname "$(readlink -f "${0}")")"
cd $HERE/..
#env RAKUDO_HOME="$HERE/../rakudo/share/perl6" NQP_HOME="$HERE/../rakudo/share/nqp" LD_LIBRARY_PATH="$HERE/../rakudo/lib" "$HERE/../rakudo/bin/raku" "$@"
env RAKUDO_HOME="$HERE/../rakudo/share/perl6" NQP_HOME="$HERE/../rakudo/share/nqp" LD_LIBRARY_PATH="$HERE/../rakudo/lib" "$HERE/../rakudo/bin/raku" "$HERE/../../foo.raku"
"

"
pk@pkx:~/stuff/appimage/squashfs-root$ cat foo.raku
"Now is the winter of our discontent
Made glorious summer by this sun of York;
And all the clouds that lour'd upon our house
In the deep bosom of the ocean buried.
Now are our brows bound with victorious wreaths;
Our bruised arms hung up for monuments;
Our stern alarums changed to merry meetings,
Our dreadful marches to delightful measures.".split(/\n/).pick().say;
"

07.

 Testing running AppRun:

"
pk@pkx:~/stuff/appimage$ ./squashfs-root/AppRun 
Now is the winter of our discontent
pk@pkx:~/stuff/appimage$ ./squashfs-root/AppRun 
In the deep bosom of the ocean buried.
"

08.

  Get appimagetool:


"
pk@pkx:~/stuff/appimage$ wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
pk@pkx:~/stuff/appimage$ chmod 755 appimagetool-x86_64.AppImage
pk@pkx:~/stuff/appimage$ ls -al appimagetool-x86_64.AppImage
-rwxr-xr-x 1 pk pk 2172096 Jun  9 02:33 appimagetool-x86_64.AppImage
"

09.

  Run appimagetool over extracted directory.

"
pk@pkx:~/stuff/appimage$ ./appimagetool-x86_64.AppImage squashfs-root/
appimagetool, continuous build (commit 1681fd8), build  built on 2021-06-09 06:11:53 UTC
Using architecture x86_64
/home/pk/stuff/appimage/squashfs-root should be packaged as Rakudo-x86_64.AppImage
...
Generating squashfs...
Parallel mksquashfs: Using 4 processors
Creating 4.0 filesystem on Rakudo-x86_64.AppImage, block size 131072.
...
Success
...
"

10.

  See output:

"
pk@pkx:~/stuff/appimage$ ls -al Rakudo-x86_64.AppImage 
-rwxr-xr-x 1 pk pk 19821760 Jul  5 21:26 Rakudo-x86_64.AppImage
"


11.

 Test:

"
pk@pkx:~/stuff/appimage$ ./Rakudo-x86_64.AppImage 
And all the clouds that lour'd upon our house
pk@pkx:~/stuff/appimage$ ./Rakudo-x86_64.AppImage 
In the deep bosom of the ocean buried.
"

12.

  Change the desktop file a bit and run appimagetool again and test.

"
pk@pkx:~/stuff/appimage$ cat squashfs-root/Rakudo.desktop 
[Desktop Entry]
Name=Rich_III_Test
Comment=Testing some appimage mods
Exec=rakudo-appimage-launcher
Icon=camelia_butterfly
Terminal=true
Type=Application
StartupNotify=false
Categories=Development;
X-AppImage-Version=.glibc2.
...
pk@pkx:~/stuff/appimage$ ./appimagetool-x86_64.AppImage squashfs-root/
...
pk@pkx:~/stuff/appimage$ ls -al Rich_III_Test-x86_64.AppImage 
-rwxr-xr-x 1 pk pk 19821760 Jul  5 21:30 Rich_III_Test-x86_64.AppImage
pk@pkx:~/stuff/appimage$ ./Rich_III_Test-x86_64.AppImage 
In the deep bosom of the ocean buried.
pk@pkx:~/stuff/appimage$ ./Rich_III_Test-x86_64.AppImage 
Made glorious summer by this sun of York;
"

Perl
----

13.

  Find a linux distribution with a pretty ubiqituous GLIBC version, as in the Raku version (shown above), so, maybe 2.15:

  Search google for: "glibc AND ubuntu AND 2.15"

  find: "Precise, 12.04"

  then search for: "precise ubuntu 12.04 live cd" and find: 

  https://cdimage.ubuntu.com/releases/12.04.5/release/source/ubuntu-12.04.5-src-1.list

  search glibc, find:

  /pool/main/e/eglibc/eglibc_2.15.orig.tar.gz

14.

  Get iso, make usb, and boot, check glibc version with: "ldd --version"

  https://cdimage.ubuntu.com/releases/12.04.5/release/ubuntu-12.04.5-dvd-amd64.iso

15.

  Get latest perl, compile and install in DESTDIR=AppDir

"
wget https://www.cpan.org/src/5.0/perl-5.34.0.tar.gz
pk@pkx:~/stuff/appimage$ gzip -dc perl-5.34.0.tar.gz | tar xvf -
pk@pkx:~/stuff/appimage/perl-5.34.0$ ./Configure -des

make
make install DESTDIR=AppDir

pk@pkx:~/stuff/appimage/perl-5.34.0/AppDir$ ls -al
total 20
drwxr-xr-x  3 pk pk  4096 Jul  5 22:21 .
drwxr-xr-x 27 pk pk 12288 Jul  5 22:21 ..
drwxr-xr-x  3 pk pk  4096 Jul  5 22:21 usr
" 

16.

  Create AppRun, desktop and image file in AppDir directory, make AppRun executable.

"
-rwxr-xr-x 1 pk pk  170 Jul  5 19:27 AppRun
-rw-rw-r-- 1 pk pk 19087 Jul  5 20:41 camelia_butterfly.png
lrwxrwxrwx 1 pk pk    21 Jul  5 20:41 .DirIcon -> camelia_butterfly.png
-rw-rw-r-- 1 pk pk  209 Jul  5 19:26 foo.desktop
-rw-rw-r-- 1 pk pk   49 Jul  5 19:26 foo.perl
"

17.

 Edit AppRun

"
pk@pkx:~/stuff/appimage$ cat AppDir/AppRun 
#!/bin/sh

ARCH=x86_64

HERE="$(dirname "$(readlink -f "${0}")")"
EXEC="${HERE}/usr/local/bin/perl"

export LD_LIBRARY_PATH=${HERE}/usr/lib
exec ${EXEC} ${HERE}/foo.perl
"

18.

 Edit foo.desktop

"
pk@pkx:~/stuff/appimage$ cat AppDir/foo.desktop
[Desktop Entry]
Name=Hello_Perl
Comment=Test Program
Exec=perl
Icon=camelia_butterfly
Terminal=true
Type=Application
StartupNotify=false
Categories=Development;
X-AppImage-Version=.glibc2.15
"
 

19.

  Edit foo.perl and test.

"
pk@pkx:~/stuff/appimage$ cat AppDir/foo.perl 

my @am = split /\n/, 
"Now is the winter of our discontent
Made glorious summer by this sun of York;
And all the clouds that lour'd upon our house
In the deep bosom of the ocean buried.
Now are our brows bound with victorious wreaths;
Our bruised arms hung up for monuments;
Our stern alarums changed to merry meetings,
Our dreadful marches to delightful measures."
;

print @am[ rand @am ];
print "\n";
"

"
pk@pkx:~/stuff/appimage$ AppDir/AppRun 
Now is the winter of our discontent
pk@pkx:~/stuff/appimage$ AppDir/AppRun 
Our dreadful marches to delightful measures.
"

20.

  Find appimagetool release w/ glibc version for OS.  See: https://github.com/AppImage/AppImageKit/releases

21.

  As in Step 09, run and test.
   
"
pk@pkx:~/stuff/appimage$ ./Hello_Perl-x86_64.AppImage 
And all the clouds that lour'd upon our house
pk@pkx:~/stuff/appimage$ ./Hello_Perl-x86_64.AppImage 
Our stern alarums changed to merry meetings,
"