Compare commits
9 Commits
master
...
new-proced
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
860c870ac0 | ||
|
|
4c57479e6a | ||
|
|
3c0c0c5288 | ||
|
|
821411dbe6 | ||
|
|
636b1a21b2 | ||
|
|
4d08604828 | ||
|
|
ddd7d1be65 | ||
|
|
36065b7dc1 | ||
|
|
49ca81b662 |
2
AUTHORS
Normal file
2
AUTHORS
Normal file
@@ -0,0 +1,2 @@
|
||||
Stefano Salvi <stefano@salvi.mn.it>
|
||||
Michele Giacomoli <michele.giacomoli@gmail.com>
|
||||
@@ -1,8 +1,6 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Luglio 2018 - Stefano Salvi stefano@salvi.mn.it
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
@@ -65,20 +63,41 @@
|
||||
## libasound.so
|
||||
##
|
||||
|
||||
import argparse
|
||||
import errno
|
||||
import gi
|
||||
import os, errno
|
||||
import hashlib
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import threading
|
||||
import urllib.request
|
||||
import time
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import argparse
|
||||
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import GLib, Gtk, Gdk, GObject
|
||||
|
||||
DESKTOP_FILE = '''[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Scratch 2
|
||||
Comment=Ide visuale per bambini
|
||||
Exec=/opt/adobe-air-sdk/bin/adl -nodebug /opt/adobe-air-sdk/scratch/META-INF/AIR/application.xml /opt/adobe-air-sdk/scratch
|
||||
Icon=/opt/adobe-air-sdk/scratch/icons/AppIcon128.png
|
||||
Terminal=false
|
||||
NoDisplay=false
|
||||
StartupNotify=true
|
||||
Categories=Development;
|
||||
Keywords=ide;coding;
|
||||
MimeType=application/x-scratch-project;
|
||||
'''
|
||||
|
||||
AIR_SHA256 = "58912fc6797bcbab49de1f4accb4743a72e7b20384bae1babf9242ac88007501"
|
||||
SCRATCH_VERSION = "458.0.1"
|
||||
SCRATCH_SHA256 = "b48abfae6e29d112986e7870bacd15ba5cbd67c1e28dcec1bc2d7dfe00a5a56d"
|
||||
|
||||
class ShowActionDialog(Gtk.Dialog):
|
||||
def __init__(self, parent, message):
|
||||
Gtk.Dialog.__init__(self, "Installazione", parent, 0)
|
||||
@@ -118,7 +137,7 @@ class MyWindow(Gtk.Window):
|
||||
self.add(vbox)
|
||||
|
||||
frame = Gtk.Frame();
|
||||
frame.set_label("Adobe AIR")
|
||||
frame.set_label("Adobe AIR SDK")
|
||||
vbox1 = Gtk.Box(orientation='vertical',spacing=6)
|
||||
frame.add(vbox1)
|
||||
vbox.pack_start(frame, False, False, 0)
|
||||
@@ -135,10 +154,10 @@ class MyWindow(Gtk.Window):
|
||||
hbox.pack_start(airFromDisk, False, False, 0)
|
||||
|
||||
filter = Gtk.FileFilter()
|
||||
filter.set_name("bin files")
|
||||
filter.add_pattern("*.bin")
|
||||
filter.set_name("tbz2 files")
|
||||
filter.add_pattern("*.tbz2")
|
||||
self.fileButtonAir = Gtk.FileChooserButton ();
|
||||
self.fileButtonAir.set_title("Seleziona l'installer di Adobe Air")
|
||||
self.fileButtonAir.set_title("Seleziona l'SDK di Adobe Air")
|
||||
self.fileButtonAir.add_filter(filter)
|
||||
self.fileButtonAir.set_current_folder(self.tempdir)
|
||||
self.fileButtonAir.set_sensitive(False)
|
||||
@@ -154,7 +173,7 @@ class MyWindow(Gtk.Window):
|
||||
vbox1.pack_start(hbox, False, False, 0)
|
||||
|
||||
self.scratchFromNet = Gtk.RadioButton.new_with_label_from_widget(None, "Scarica dalla rete")
|
||||
self.scratchFromNet.connect("toggled", self.on_sctarch_button_toggled)
|
||||
self.scratchFromNet.connect("toggled", self.on_scratch_button_toggled)
|
||||
hbox.pack_start(self.scratchFromNet, False, False, 0)
|
||||
|
||||
scratchFromFile = Gtk.RadioButton.new_with_label_from_widget(self.scratchFromNet, "Installa da file")
|
||||
@@ -186,7 +205,7 @@ class MyWindow(Gtk.Window):
|
||||
def on_air_button_toggled (self, button):
|
||||
self.fileButtonAir.set_sensitive(not button.get_active())
|
||||
|
||||
def on_sctarch_button_toggled (self, button):
|
||||
def on_scratch_button_toggled (self, button):
|
||||
self.fileButtonScratch.set_sensitive(not button.get_active())
|
||||
|
||||
def error_message(self, message, isinfo = False):
|
||||
@@ -258,6 +277,9 @@ class MyWindow(Gtk.Window):
|
||||
return False
|
||||
return True
|
||||
|
||||
def check_sha256(self, filename, hash):
|
||||
return hashlib.sha256(contents).hexdigest() == hash
|
||||
|
||||
def get_url(self, url, basemessage):
|
||||
GLib.idle_add(self.show_action_message, basemessage)
|
||||
message = "";
|
||||
@@ -288,14 +310,26 @@ class MyWindow(Gtk.Window):
|
||||
if self.airFromNet.get_active():
|
||||
if not self.create_scratch_downoad_directory():
|
||||
return False
|
||||
self.air_installer_file = self.tempdir + "/AdobeAIRInstaller.bin"
|
||||
return self.download_file("http://airdownload.adobe.com/air/lin/download/2.6/AdobeAIRInstaller.bin" ,self.air_installer_file ,"Scarico Adobe Air dalla rete")
|
||||
self.air_installer_file = self.tempdir + "/AdobeAIRSDK.tbz2"
|
||||
if not self.download_file("http://airdownload.adobe.com/air/lin/download/2.6/AdobeAIRSDK.tbz2" ,self.air_installer_file ,"Scarico Adobe Air dalla rete"):
|
||||
return False
|
||||
Glib.idle_add(self.show_action_message, "Verifica checksum file AIR")
|
||||
if not self.check_sha256(self.scrathFile, SCRATCH_SHA256):
|
||||
Glib.idle_add(self.error_message, "Verifica checksum file AIR: FAIL!")
|
||||
return False
|
||||
Glib.idle_add(self.append_action_message, "Verifica checksum file AIR: OK")
|
||||
return True
|
||||
else:
|
||||
self.air_installer_file = self.fileButtonAir.get_filename()
|
||||
if self.air_installer_file == None:
|
||||
GLib.idle_add(self.error_message, "Non hai scelto il file con il pacchetto AIR di Scratch")
|
||||
GLib.idle_add(self.error_message, "Non hai scelto il file con il file AIR SDK")
|
||||
return False
|
||||
else:
|
||||
Glib.idle_add(self.show_action_message, "Verifica checksum file Scratch")
|
||||
if not self.check_sha256(self.scrathFile, SCRATCH_SHA256):
|
||||
Glib.idle_add(self.error_message, "Verifica checksum file Scratch: FAIL!")
|
||||
return False
|
||||
Glib.idle_add(self.append_action_message, "Verifica checksum file Scratch: OK")
|
||||
GLib.idle_add(self.show_action_message, "Installo Air dal file" + self.air_installer_file)
|
||||
return True
|
||||
|
||||
@@ -313,15 +347,27 @@ class MyWindow(Gtk.Window):
|
||||
# GLib.idle_add(self.show_action_message, "Installo la versione " + m.group(1) + " dall'indirizzo " + m.group(2))
|
||||
# self.scrathFile = self.tempdir + "/" + m.group(2).split('/')[-1]
|
||||
# return self.download_file(m.group(2), self.scrathFile,"Scarico Scratch 2 dalla rete")
|
||||
GLib.idle_add(self.show_action_message, "Installo la versione 442 Di Scratch 2")
|
||||
self.scrathFile = self.tempdir + "/Scratch-455.air"
|
||||
return self.download_file("http://cdn.scratch.mit.edu/scratchr2/static/sa/Scratch-455.air", self.scrathFile, "Scarico Scratch 2 dalla rete")
|
||||
GLib.idle_add(self.show_action_message, "Installo la versione 458 Di Scratch 2")
|
||||
self.scrathFile = self.tempdir + "/Scratch-458.0.1.air"
|
||||
if not self.download_file("https://scratch.mit.edu/scratchr2/static/sa/Scratch-458.0.1.air", self.scrathFile, "Scarico Scratch 2 dalla rete"):
|
||||
return False
|
||||
Glib.idle_add(self.show_action_message, "Verifica checksum file Scratch")
|
||||
if not self.check_sha256(self.scrathFile, SCRATCH_SHA256):
|
||||
Glib.idle_add(self.error_message, "Verifica checksum file Scratch: FAIL!")
|
||||
return False
|
||||
Glib.idle_add(self.append_action_message, "Verifica checksum file Scratch: OK")
|
||||
return True
|
||||
else:
|
||||
self.scrathFile = self.fileButtonScratch.get_filename()
|
||||
if self.scrathFile == None:
|
||||
GLib.idle_add(self.error_message, "Non hai scelto il file con il pacchetto AIR di Scratch")
|
||||
return False
|
||||
else:
|
||||
Glib.idle_add(self.show_action_message, "Verifica checksum file Scratch")
|
||||
if not self.check_sha256(self.scrathFile, SCRATCH_SHA256):
|
||||
Glib.idle_add(self.error_message, "Verifica checksum file Scratch: FAIL!")
|
||||
return False
|
||||
Glib.idle_add(self.append_action_message, "Verifica checksum file Scratch: OK")
|
||||
GLib.idle_add(self.show_action_message, "Installo Scratch2 dal file" + self.scrathFile)
|
||||
return True
|
||||
|
||||
@@ -334,7 +380,7 @@ class MyWindow(Gtk.Window):
|
||||
"--xauthority=" + os.environ['XAUTHORITY'] ], stdout=subprocess.PIPE ,stderr=subprocess.STDOUT)
|
||||
while True:
|
||||
line = inst.stdout.readline().decode('utf-8')
|
||||
print (line)
|
||||
print (line, end='')
|
||||
GLib.idle_add(self.append_action_message, line)
|
||||
if line == '' and inst.poll() != None:
|
||||
break
|
||||
@@ -347,7 +393,7 @@ class MyWindow(Gtk.Window):
|
||||
# sys.stdout.write(char)
|
||||
# GLib.idle_add(self.append_action_message, char)
|
||||
if inst.returncode == 1:
|
||||
GLib.idle_add(self.error_message, "Il file di installazione di Adobe Air " + self.air_installer_file + " non esiste o non è leggibile")
|
||||
GLib.idle_add(self.error_message, "Il file SDK di Adobe Air " + self.air_installer_file + " non esiste o non è leggibile")
|
||||
elif inst.returncode == 2:
|
||||
GLib.idle_add(self.error_message, "Il file di installazione di Scratch2 " + self.scrathFile + " non esiste o non è leggibile")
|
||||
elif inst.returncode == 3:
|
||||
@@ -390,11 +436,11 @@ def check_os():
|
||||
def subprocess_call(command, new_env={}):
|
||||
new_env['PATH'] = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
|
||||
print(command)
|
||||
return subprocess.call(command.split(' '), env=new_env)
|
||||
return subprocess.call(shlex.split(command), env=new_env)
|
||||
|
||||
def real_install(air_installer, scratch2_installer, xauthority):
|
||||
if not os.access(air_installer, os.R_OK):
|
||||
print("Il file di installazione di Adobe Air " + air_installer + " non esiste o non è leggibile")
|
||||
print("Il file SDK di Adobe Air " + air_installer + " non esiste o non è leggibile")
|
||||
sys.exit(1)
|
||||
if not os.access(scratch2_installer, os.R_OK):
|
||||
print("Il file di installazione di Scratch2 " + scratch2_installer + " non esiste o non è leggibile")
|
||||
@@ -402,13 +448,14 @@ def real_install(air_installer, scratch2_installer, xauthority):
|
||||
print ("Installer di Air: " + air_installer)
|
||||
print ("Installer di Scratch: " + scratch2_installer)
|
||||
# Rende eseguibile l'installer di Air
|
||||
os.chmod(air_installer, 0o755)
|
||||
# os.chmod(air_installer, 0o755)
|
||||
# Recupera versione e architettura
|
||||
ver = subprocess.check_output(['/usr/bin/lsb_release', '-rs']).decode("utf-8")
|
||||
arch = subprocess.check_output(['/bin/uname', '-m'])
|
||||
arch = subprocess.check_output(['/bin/uname', '-m']).decode("utf-8")
|
||||
|
||||
dependencies = ''
|
||||
|
||||
# import pdb; pdb.set_trace()
|
||||
# Cascata di if per le varie versioni/architetture
|
||||
if ver == "12.04\n" or ver == "13\n":
|
||||
if arch == "x86_64\n":
|
||||
@@ -467,8 +514,8 @@ def real_install(air_installer, scratch2_installer, xauthority):
|
||||
subprocess_call("ln -sf /usr/lib/i386-linux-gnu/libgnome-keyring.so.0.2.0 /usr/lib/libgnome-keyring.so.0.2.0")
|
||||
elif ver == "18.04\n":
|
||||
if arch == "x86_64\n":
|
||||
dependencies = "libxt6:i386 libnspr4:i386 libgtk2.0-0:i386 libstdc++6:i386 libnss3:i386 libnss-mdns:i386 libxml2:i386 libxslt1.1:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386 libgnome-keyring0:i386 libxaw7"
|
||||
# dependencies = "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"
|
||||
# dependencies = "libxt6:i386 libnspr4:i386 libgtk2.0-0:i386 libstdc++6:i386 libnss3:i386 libnss-mdns:i386 libxml2:i386 libxslt1.1:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386 libgnome-keyring0:i386 libxaw7"
|
||||
dependencies = "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"
|
||||
subprocess_call("ln -sf /usr/lib/x86_64-linux-gnu/libgnome-keyring.so.0 /usr/lib/libgnome-keyring.so.0")
|
||||
subprocess_call("ln -sf /usr/lib/x86_64-linux-gnu/libgnome-keyring.so.0.2.0 /usr/lib/libgnome-keyring.so.0.2.0")
|
||||
else:
|
||||
@@ -481,16 +528,35 @@ def real_install(air_installer, scratch2_installer, xauthority):
|
||||
|
||||
environment = { 'DISPLAY':':0', 'XAUTHORITY': xauthority, 'PATH':'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' }
|
||||
subprocess_call("/bin/bash -c env")
|
||||
if subprocess_call("/usr/bin/apt-get -q -y install " + dependencies) != 0:
|
||||
# if subprocess_call("/usr/bin/apt-get -q -y install " + dependencies) != 0:
|
||||
if subprocess_call("/usr/bin/apt-get update") != 0:
|
||||
print("Installazione delle dipendenze fallita")
|
||||
sys.exit(4)
|
||||
if subprocess_call("/usr/bin/apt-get -y install " + dependencies) != 0:
|
||||
print("Installazione delle dipendenze fallita")
|
||||
sys.exit(4)
|
||||
# import pdb; pdb.set_trace()
|
||||
if subprocess_call(air_installer, environment) != 0:
|
||||
print("Installazione di Adobe Air dal file " + air_installer + " fallita")
|
||||
os.makedirs("/opt", exist_ok=True)
|
||||
if "adobe-air-sdk" in os.listdir("/opt"):
|
||||
shutil.rmtree("/opt/adobe-air-sdk")
|
||||
os.mkdir("/opt/adobe-air-sdk")
|
||||
if subprocess_call("/bin/tar jxf " + air_installer + " -C /opt/adobe-air-sdk", environment) != 0:
|
||||
print("Installazione di Adobe Air SDK dal file " + air_installer + " fallita")
|
||||
sys.exit(5)
|
||||
if subprocess.call([ "/usr/bin/Adobe AIR Application Installer" , scratch2_installer ], env=environment) != 0:
|
||||
os.mkdir("/opt/adobe-air-sdk/scratch")
|
||||
# import pdb; pdb.set_trace()
|
||||
if subprocess_call( "/usr/bin/unzip -o " + scratch2_installer + " -d /opt/adobe-air-sdk/scratch/", environment) != 0:
|
||||
print("Installazione di Scratch2 dal file " + scratch2_installer + " fallita")
|
||||
sys.exit(6)
|
||||
try:
|
||||
with open("/usr/share/applications/Scratch2.desktop", "w") as f:
|
||||
f.write(DESKTOP_FILE)
|
||||
os.chmod("/usr/share/applications/Scratch2.desktop", 0o644)
|
||||
except Exception as e:
|
||||
import pdb; pdb.set_trace()
|
||||
print("Installazione di Scratch2 dal file " + scratch2_installer + " fallita")
|
||||
sys.exit(6)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user