Ubuntu – How to install Scratch 2 on Ubuntu 16.10. or 17.04 (64bit)

16.1017.04adobe-airdpkgflash

I need to install Adobe Air on Ubuntu 16.10/17.04 with offline Scratch 2. Air is many years unsupported on Linux, so there are several workarounds. One which worked for me up to Ubuntu 16.04 (using Air binary installer):

# install i386 necessary libraries
$ sudo apt-get install libgtk2.0-0:i386 libstdc++6:i386 libxml2:i386 libxslt1.1:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386 libqt4-qt3support:i386 libgnome-keyring0:i386 libnss-mdns:i386 libnss3:i386
# install keyring
$ sudo apt-get install libgnome-keyring0:i386
# make keyring visible for Air
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgnome-keyring.so.0 /usr/lib/libgnome-keyring.so.0
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgnome-keyring.so.0.2.0 /usr/lib/libgnome-keyring.so.0.2.0 
# download Adobe Air installer
$ wget  http://airdownload.adobe.com/air/lin/download/2.6/AdobeAIRInstaller.bin
# run it
$ sudo chmod +x AdobeAIRInstaller.bin
$ sudo ./AdobeAIRInstaller.bin

but on 16.10/17.4 it ends with installator error:

Adobe AIR could not be installed. Debian tools for creating deb
packages (such as dpkg-deb or ar) were not found on the system.

Which is obviously false error message as dpkg-deb and ar are both installed:

$ dpkg-deb --version
Debian 'dpkg-deb' package management program version 1.18.10 (amd64).
$ ar --version
GNU ar (GNU Binutils for Ubuntu) 2.28

The Adobe Air install log file from /root/.appdata/Adobe/AIR/Logs/Install.log

[setup:2506][INFO] Runtime Installer begin with version 2.6.0.19170 on Linux x86
[setup:2506][INFO] Commandline is: 
[setup:2506][INFO] No installed runtime detected
[setup:2506][INFO] Relaunching with elevation
[setup:2506][INFO] Launching subprocess with commandline /tmp/air.hp19kU/setup -ei
[setup:2525][INFO] Runtime Installer begin with version 2.6.0.19170 on Linux x86
[setup:2525][INFO] Commandline is: -stdio /tmp/air.KWo9tt/channel -ei
[setup:2525][INFO] No installed runtime detected
[setup:2525][INFO] Starting silent runtime install. Installing runtime version 2.6.0.19170
[setup:2525][INFO] Session detected: GNOME
[setup:2525][ERR] Error occurred during rpm create operation; beginning rollback: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="dpkg-query: package 'adobe-certs' is not installed and no information is available;Use dpkg --info (= dpkg-deb --info) to examine archive files,;and dpkg --contents (= dpkg-deb --contents) to list their contents.Could not run the command : ar" errorID=5031]
[setup:2525][INFO] Rollback complete
[setup:2525][ERR] Exiting due to error: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="dpkg-query: package 'adobe-certs' is not installed and no information is available;Use dpkg --info (= dpkg-deb --info) to examine archive files,;and dpkg --contents (= dpkg-deb --contents) to list their contents.Could not run the command : ar" errorID=5031]
[setup:2525][ERR] Runtime Installer end with exit code 7
[setup:2506][ERR] Exiting due to error: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="dpkg-query: package 'adobe-certs' is not installed and no information is available;Use dpkg --info (= dpkg-deb --info) to examine archive files,;and dpkg --contents (= dpkg-deb --contents) to list their contents.Could not run the command : ar" errorID=5031]
[setup:2506][ERR] Runtime Installer end with exit code 7

So I found another way to install an Adobe Air via deb package (I didn't know before):

$ wget http://airdownload.adobe.com/air/lin/download/2.6/adobeair.deb
$ sudo dpkg -i adobeair.deb

And voilĂ ! Adobe Air is installed on Ubuntu 16.10/17.04.
Now install Scratch 2.

# Find the latest Scratch AIR file link from https://scratch.mit.edu/scratch2download/
$ wget https://scratch.mit.edu/scratchr2/static/sa/Scratch-456.0.1.air
$ sudo Adobe\ AIR\ Application\ Installer ./Scratch-456.0.1.air 

and again the same error:

Adobe AIR could not be installed. Debian tools for creating deb
packages (such as dpkg-deb or ar) were not found on the system.

Install.log

[Adobe AIR Application Installer:3197][INFO] Application Installer begin with version 2.6.0.19170 on Linux x86
[Adobe AIR Application Installer:3197][INFO] Commandline is: 
[Adobe AIR Application Installer:3197][INFO] Installed runtime (2.6.0.19170) located at /opt/Adobe AIR
[Adobe AIR Application Installer:3197][INFO] Unpackaging file:///home/administrator/Downloads/Scratch-456.0.1.air to /tmp/FlashTmp.LSCkv7
[Adobe AIR Application Installer:3197][INFO] Application signature verified
[Adobe AIR Application Installer:3197][INFO] Unpackaging/validation complete
[Adobe AIR Application Installer:3197][INFO] No app located for appID 'edu.media.mit.Scratch2Editor' and pubID ''
[Adobe AIR Application Installer:3197][INFO] Converting unpackaged application to a native installation package in /tmp/FlashTmp.RJSwfW
[Adobe AIR Application Installer:3197][ERR] Native installation package creation failed: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="Unhandled exception Error: Error creating the package Could not run the command : ar" errorID=5031]
[Adobe AIR Application Installer:3197][ERR] Application Installer end with exit code 7

Looks like an unmaintained Adobe Air cannot play with new dpkg-deb and ar anymore.

Any hints for offline Scratch 2 on Ubuntu 16.10/17.04?

Best Answer

I have been playing around with this couple of hours. First I tried to trace the Adobe Air Application Installer and find, what's happening inside.

$ sudo strace -s 500 -t -o air_scratch.txt Adobe\ AIR/Versions/1.0/Adobe\ AIR\ Application\ Installer ~/Downloads/Scratch-456.0.1.air 

And I found this line:

read(18, "dpkg-deb: error: treewalk root /tmp/FlashTmp.3TWnKI/build/DEBIAN is not a directory\n", 4096) = 84

It seems to new dpkg cannot handle links as the previous one. This can be fixed by wrapper script placed e.g. to ~/air/bin/dpkg and changing the PATH variable before running Adobe Air Application Installer. Unfortunately, the Scratch cannot be installed without sudo, and changing PATH for sudo is not so easy.

Then I found a polish forum of unhappy tax payers, which are solving similar problems (they need run some Air app from ministry of finance on Debian/Ubuntu): https://forum.dug.net.pl/viewtopic.php?pid=310108.

And deep inside this forum I found some hints, how to run Scratch 2 on Ubuntu 16.10/17.04 (even without adobeair.deb installation).

This is my final working solution, tested on clean installation.

# install necesary i386 libraries
$ sudo apt-get install libgtk2.0-0:i386 libstdc++6:i386 libxml2:i386 libxslt1.1:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386 libqt4-qt3support:i386 libgnome-keyring0:i386 libnss-mdns:i386 libnss3:i386

# make keyring visible for Adobe Air
$ sudo ln -s /usr/lib/i386-linux-gnu/libgnome-keyring.so.0 /usr/lib/libgnome-keyring.so.0
$ sudo ln -s /usr/lib/i386-linux-gnu/libgnome-keyring.so.0.2.0 /usr/lib/libgnome-keyring.so.0.2.0

# Download Adobe Air
cd ~/Downloads
wget http://airdownload.adobe.com/air/lin/download/2.6/AdobeAIRSDK.tbz2
$ sudo mkdir /opt/adobe-air-sdk
$ sudo tar jxf AdobeAIRSDK.tbz2 -C /opt/adobe-air-sdk

# Download Air runtime/SDK from Archlinux
wget https://aur.archlinux.org/cgit/aur.git/snapshot/adobe-air.tar.gz
$ sudo tar xvf adobe-air.tar.gz -C /opt/adobe-air-sdk
$ sudo chmod +x /opt/adobe-air-sdk/adobe-air/adobe-air

# Get actual scratch file URL from https://scratch.mit.edu/scratch2download/
$ sudo mkdir /opt/adobe-air-sdk/scratch
wget https://scratch.mit.edu/scratchr2/static/sa/Scratch-456.0.1.air
$ sudo cp Scratch-456.0.1.air /opt/adobe-air-sdk/scratch/
cp Scratch-456.0.1.air /tmp/
cd /tmp/
unzip /tmp/Scratch-456.0.1.air
$ sudo cp /tmp/icons/AppIcon128.png /opt/adobe-air-sdk/scratch/scratch.png

Create launcher:

$ cat << _EOF_ > /usr/share/applications/Scratch2.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=/opt/adobe-air-sdk/adobe-air/adobe-air /opt/adobe-air-sdk/scratch/Scratch-456.0.1.air
Icon=/opt/adobe-air-sdk/scratch/scratch.png
Terminal=false
Name=Scratch 2
Comment=Programming system and content development tool
Categories=Application;Education;Development;ComputerScience;
MimeType=application/x-scratch-project
_EOF_

$ chmod +x /usr/share/applications/Scratch2.desktop

And that's it. First run is a little bit longer, as the Air is unpacking Scratch 2 application to ~/.appdata/edu.media.mit.Scratch2Editor folder.

Scratch 2 running on Ubuntu 17.04