|
7 | 7 |
|
8 | 8 | import os
|
9 | 9 | import shutil
|
| 10 | +import traceback |
10 | 11 |
|
11 | 12 | from kano.logging import logger
|
12 | 13 |
|
|
23 | 24 | purge, rclocal_executable, migrate_repository, get_users, run_for_every_user
|
24 | 25 | from kano_updater.paths import PYLIBS_DIR, PYFALLBACK_DIR, SOURCES_DIR, \
|
25 | 26 | OS_SOURCES_REFERENCE, REFERENCE_STRETCH_LIST, CMDLINE_TXT_PATH
|
| 27 | +from kano_updater.reporting import send_crash_report |
26 | 28 |
|
27 | 29 |
|
28 | 30 | STRETCH_MIGRATION_LIST = os.path.join(
|
@@ -908,22 +910,60 @@ def beta_370_to_beta_380(self, dummy_progress):
|
908 | 910 |
|
909 | 911 | self._bootconfig_set_value_helper("gpu_mem", "256")
|
910 | 912 |
|
911 |
| - new_apps = [ |
912 |
| - 'adventure', |
913 |
| - 'openttd', |
914 |
| - 'tux-paint', |
915 |
| - 'tux-typing', |
916 |
| - 'libreoffice', |
917 |
| - 'numpty-physics', |
918 |
| - 'gmail', |
919 |
| - 'google-drive', |
920 |
| - 'google-maps', |
921 |
| - 'wikipedia', |
922 |
| - 'whatsapp' |
923 |
| - ] |
924 |
| - |
925 |
| - for app in new_apps: |
926 |
| - run_cmd_log('kano-apps install --no-gui {app}'.format(app=app)) |
| 913 | + try: |
| 914 | + # Install 3rd party apps from Kano World using the App Store. |
| 915 | + # Before, the disk space requirement was part of the update itself. |
| 916 | + # Moved away from that model to install apps separately of the update |
| 917 | + # to minimise the requirement (divide and conquer). |
| 918 | + # However, the App Store does not check for disk space before |
| 919 | + # installing an app so account for this here naively. |
| 920 | + # Requirements (disk_req) in MB were made with apt on a clean system. |
| 921 | + |
| 922 | + from kano.utils.disk import get_free_space |
| 923 | + |
| 924 | + new_apps = [ |
| 925 | + {'kw_app': 'tux-paint', 'disk_req': 413}, |
| 926 | + {'kw_app': 'numpty-physics', 'disk_req': 2}, |
| 927 | + {'kw_app': 'gmail', 'disk_req': 1}, |
| 928 | + {'kw_app': 'google-drive', 'disk_req': 1}, |
| 929 | + {'kw_app': 'google-maps', 'disk_req': 1}, |
| 930 | + {'kw_app': 'wikipedia', 'disk_req': 1}, |
| 931 | + {'kw_app': 'whatsapp', 'disk_req': 1}, |
| 932 | + {'kw_app': 'adventure', 'disk_req': 5}, |
| 933 | + {'kw_app': 'openttd', 'disk_req': 21}, |
| 934 | + {'kw_app': 'tux-typing', 'disk_req': 26}, |
| 935 | + {'kw_app': 'libreoffice', 'disk_req': 385}, |
| 936 | + ] |
| 937 | + |
| 938 | + run_cmd_log('apt-get autoremove -y') |
| 939 | + |
| 940 | + for app in new_apps: |
| 941 | + run_cmd_log('apt-get clean') |
| 942 | + |
| 943 | + mb_free = get_free_space() |
| 944 | + mb_required = app['disk_req'] + 250 # MB buffer |
| 945 | + |
| 946 | + if mb_free > mb_required: |
| 947 | + run_cmd_log('kano-apps install --no-gui {app}'.format(app=app['kw_app'])) |
| 948 | + else: |
| 949 | + logger.warn( |
| 950 | + "Cannot install {app} as it requires {mb_required} but" |
| 951 | + " only has {mb_free}" |
| 952 | + .format( |
| 953 | + app=app['kw_app'], |
| 954 | + mb_required=mb_required, |
| 955 | + mb_free=mb_free |
| 956 | + ) |
| 957 | + ) |
| 958 | + except Exception as e: |
| 959 | + logger.error("Failed to install 3rd party apps", exception=e) |
| 960 | + send_crash_report( |
| 961 | + "PostUpdate 3.7 to 3.8 app install", |
| 962 | + "Failed with unexpected exception\n{}" |
| 963 | + .format(traceback.format_exc()) |
| 964 | + ) |
| 965 | + finally: |
| 966 | + run_cmd_log('apt-get clean') |
927 | 967 |
|
928 | 968 | # Tell kano-init to put the automatic logins up-to-date
|
929 | 969 | reconfigure_autostart_policy()
|
|
0 commit comments