如何在 Ubuntu 16.10 或 17.04(64 位)上安装 Scratch 2?

如何在 Ubuntu 16.10 或 17.04(64 位)上安装 Scratch 2?

我需要在 Ubuntu 16.10/17.04 上使用离线 Scratch 2 安装 Adob​​e Air。Linux 多年来一直不支持 Air,因此有几种解决方法。其中一种方法在 Ubuntu 16.04 之前一直有效(使用 Air 二进制安装程序):

# 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

但在 16.10/17.4 上它以安装程序错误结束:

无法安装 Adob​​e AIR。系统上未找到用于创建 deb 包的 Debian 工具(例如 dpkg-deb 或 ar)。

这显然是错误的错误消息,因为dpkg-debar都已安装:

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

Adobe Air 安装日志文件来自/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

因此我找到了另一种通过 deb 包安装 Adob​​e Air 的方法(我以前不知道):

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

瞧!Adobe Air 已安装在 Ubuntu 16.10/17.04 上。
现在安装 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 

再次出现同样的错误:

无法安装 Adob​​e AIR。系统上未找到用于创建 deb 包的 Debian 工具(例如 dpkg-deb 或 ar)。

安装日志

[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

看起来未维护的 Adob​​e Air 无法再与新版本一起dpkg-deb运行ar

关于 Ubuntu 16.10/17.04 上的离线 Scratch 2 有任何提示吗?

答案1

我已经研究了几个小时了。首先,我尝试追踪Adobe Air Application Installer并找出内部发生了什么。

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

我发现了这一行:

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

似乎新的dpkg无法像上一个那样处理链接。可以通过将包装器脚本放置在例如~/air/bin/dpkg并在运行 Adob​​e Air 应用程序安装程序之前更改PATH变量来修复此问题。不幸的是,没有 sudo 就无法安装 Scratch,而更改PATHsudo 并不容易。

然后我发现了一个波兰不满意纳税人的论坛,他们正在解决类似的问题(他们需要在 Debian/Ubuntu 上运行财政部的一些 Air 应用程序):https://forum.dug.ne​​t.pl/viewtopic.php?pid=310108

在这个论坛深处,我发现了一些提示,如何在 Ubuntu 16.10/17.04 上运行 Scratch 2(甚至无需adobeair.deb安装)。

这是我的最终工作解决方案,已在全新安装上进行测试。

# 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

创建启动器:

$ 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

就是这样。第一次运行时间稍长一些,因为 Air 正在将 Scratch 2 应用程序解压到~/.appdata/edu.media.mit.Scratch2Editor文件夹中。

Scratch 2 在 Ubuntu 17.04 上运行

相关内容