File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/update-notifier.tar
Back
update-motd-hwe-eol 0000755 00000003501 15027402346 0010255 0 ustar 00 #!/bin/sh -e # # helper for update-motd # poor mans force if [ "$1" = "--force" ]; then NEED_EOL_CHECK=yes else if type systemd-detect-virt > /dev/null 2>&1 && systemd-detect-virt -q -c; then exit fi NEED_EOL_CHECK=no fi # check time when we did the last update check stamp="/var/lib/update-notifier/hwe-eol" # get list dir StateDir="/var/lib/apt/" ListDir="lists/" eval "$(apt-config shell StateDir Dir::State)" eval "$(apt-config shell ListDir Dir::State::Lists)" # get dpkg status file DpkgStatus="/var/lib/dpkg/status" eval "$(apt-config shell DpkgStatus Dir::State::status)" # get sources.list file EtcDir="etc/apt/" SourceList="sources.list" eval "$(apt-config shell EtcDir Dir::Etc)" eval "$(apt-config shell SourceList Dir::Etc::sourcelist)" # let the actual update be asynchronous to avoid stalling apt-get cleanup() { rm -f "$tmpfile"; } # check if we have a list file or sources.list that needs checking if [ -e "$stamp" ]; then if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" "/$DpkgStatus" -type f -newer "$stamp" -print -quit 2> /dev/null)" ]; then NEED_EOL_CHECK=yes fi else if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" -type f -print -quit 2> /dev/null)" ]; then NEED_EOL_CHECK=yes fi fi # only print status when running this script as a regular user if [ "$(id -u)" != 0 ] ; then [ "$NEED_EOL_CHECK" = "no" ] || /usr/bin/hwe-support-status || true exit fi tmpfile="" trap cleanup EXIT tmpfile=$(mktemp -p $(dirname "$stamp")) # output something for update-motd if [ "$NEED_EOL_CHECK" = "yes" ]; then { # the script may exit with status 10 when a HWE update is needed /usr/bin/hwe-support-status || true } > "$tmpfile" mv "$tmpfile" "$stamp" fi # output what we have (either cached or newly generated) cat "$stamp" backend_helper.py 0000755 00000011663 15027402346 0010061 0 ustar 00 #!/usr/bin/python3 import argparse import logging import os import subprocess import sys HAVE_APTDAEMON = False try: import aptdaemon.gtk3widgets done = aptdaemon.gtk3widgets.DOWNLOAD_DONE # shutup pyflakes HAVE_APTDAEMON = True except ImportError: pass # show updates def show_updates(): """ show updates using update-manager """ if os.path.exists("/usr/bin/update-manager"): cmd = ["update-manager", "--no-update"] res = subprocess.call(cmd) return (res == 0) else: logging.error("update-manager is not installed") # install all updates def _install_all_updates_aptdaemon(): from gi.repository import Gtk from aptdaemon import client, enums from aptdaemon.gtk3widgets import AptProgressDialog client = client.AptClient() trans = client.upgrade_system(safe_mode=True) dia = AptProgressDialog(trans) dia.connect("finished", Gtk.main_quit) dia.run() Gtk.main() return trans.exit == enums.EXIT_SUCCESS def _install_all_updates_synaptic(): cmd = ["/usr/bin/synaptic-pkexec", "--dist-upgrade-mode", "--non-interactive", "--hide-main-window", "-o", "Synaptic::AskRelated=true", ] return subprocess.call(cmd) def install_all_updates(): """ install all updates either with synaptic or aptdaemon """ if HAVE_APTDAEMON: return _install_all_updates_aptdaemon() else: return _install_all_updates_synaptic() # check updates def _check_updates_aptdaemon(): from gi.repository import Gtk from aptdaemon import client, enums from aptdaemon.gtk3widgets import AptProgressDialog client = client.AptClient() trans = client.update_cache() dia = AptProgressDialog(trans) dia.connect("finished", Gtk.main_quit) dia.run() Gtk.main() return trans.exit == enums.EXIT_SUCCESS def _check_updates_gtk(): cmd = ["/usr/bin/synaptic-pkexec", "--update-at-startup", "--non-interactive", "--hide-main-window", ] subprocess.call(cmd) def check_updates(): """ check for updates either with aptdaemon or synaptic """ if HAVE_APTDAEMON: return _check_updates_aptdaemon() else: return _check_updates_gtk() # start packagemanager def start_packagemanager(): if os.path.exists("/usr/bin/synaptic-pkexec"): cmd = ["/usr/bin/synaptic-pkexec"] return subprocess.call(cmd) elif os.path.exists("/usr/bin/software-center"): return subprocess.call(["/usr/bin/software-center"]) else: logging.error("neither synaptic nor software-center installed") # add cdrom def _add_cdrom_sp(mount_path): from gi.repository import Gtk import dbus import dbus.mainloop.glib bus = dbus.SystemBus(mainloop=dbus.mainloop.glib.DBusGMainLoop()) proxy = bus.get_object("com.ubuntu.SoftwareProperties", "/") backend = dbus.Interface(proxy, "com.ubuntu.SoftwareProperties") backend.AddCdromSource() backend.connect_to_signal( "SourcesListModified", Gtk.main_quit) backend.connect_to_signal( "CdromScanFailed", Gtk.main_quit) Gtk.main() if os.path.exists("/usr/bin/software-center"): subprocess.call(["/usr/bin/software-center"]) def _add_cdrom_synaptic(mount_path): cmd = ["/usr/bin/synaptic-pkexec", "--add-cdrom", mount_path] return subprocess.call(cmd) def add_cdrom(mount_path): if os.path.exists("/usr/bin/synaptic-pkexec"): _add_cdrom_synaptic(mount_path) else: _add_cdrom_sp(mount_path) if __name__ == "__main__": parser = argparse.ArgumentParser( description='backend helper for update-notifier') parser.add_argument( '--debug', default=False, action="store_true", help='extra debug output') subparser = parser.add_subparsers(title="Commands") # show_update - update-manager command = subparser.add_parser("show_updates") command.set_defaults(command="show_updates") # install_all - synaptic/aptdaemon install noninteractivly command = subparser.add_parser("install_all_updates") command.set_defaults(command="install_all_updates") # check_updates - synaptic --reload/aptdaemon reload command = subparser.add_parser("check_updates") command.set_defaults(command="check_updates") # start_pkgmanager command = subparser.add_parser("start_packagemanager") command.set_defaults(command="start_packagemanager") # add_cdrom command = subparser.add_parser("add_cdrom") command.add_argument("mount_path") command.set_defaults(command="add_cdrom") args = parser.parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.INFO) func_name = args.command f_kwargs = {} f = globals()[func_name] if args.command == "add_cdrom": f_kwargs["mount_path"] = args.mount_path res = f(**f_kwargs) if not res: sys.exit(1) package-data-downloader 0000755 00000027520 15027402346 0011141 0 ustar 00 #!/usr/bin/python3 # -*- coding: utf-8 -*- """Process new requests to download per-package data""" # Copyright (C) 2012 Canonical Ltd # # This program is free software; you can redistribute it and/or modify # it under the terms of version 3 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import glob import os import sys import subprocess import traceback import debian.deb822 import string import debconf from datetime import datetime import apt_pkg # avoid hanging forever (LP: #1243090) import socket socket.setdefaulttimeout(60) DATADIR = "/usr/share/package-data-downloads/" STAMPDIR = "/var/lib/update-notifier/package-data-downloads/" NOTIFIER_SOURCE_FILE = \ "/usr/share/update-notifier/package-data-downloads-failed" NOTIFIER_FILE = "/var/lib/update-notifier/user.d/data-downloads-failed" NOTIFIER_PERMANENT_SOURCE_FILE = NOTIFIER_SOURCE_FILE + '-permanently' NOTIFIER_PERMANENT_FILE = NOTIFIER_FILE + '-permanently' failures = [] permanent_failures = [] def create_or_update_stampfile(file): """Create or update the indicated stampfile, and remove failure flags""" try: with open(file, 'w'): pass # Ignore errors except Exception: traceback.print_exc(file=sys.stderr) os.utime(file, None) for ext in ('.failed', '.permanent-failure'): if os.path.exists(file + ext): os.unlink(file + ext) def mark_hook_failed(hook_name, permanent=False): """Create a stampfile recording that a hook failed We create separate stampfiles for failed hooks so we can keep track of how long the hook has been failing and if the failure should be considered permanent.""" if permanent: filename = hook_name + '.permanent-failure' else: filename = hook_name + '.failed' failure_file = os.path.join(STAMPDIR, filename) try: with open(failure_file, 'w'): pass # Ignore errors except Exception: traceback.print_exc(file=sys.stderr) for ext in ('', '.failed', '.permanent-failure'): stampfile = hook_name + ext if filename != stampfile \ and os.path.exists(os.path.join(STAMPDIR, stampfile)): os.unlink(os.path.join(STAMPDIR, stampfile)) def hook_is_permanently_failed(hook_name): """Check if this hook has been marked as permanently failing. If so, don't raise any more errors about it.""" failure_file = os.path.join(STAMPDIR, hook_name + '.permanent-failure') return os.path.exists(failure_file) def hook_aged_out(hook_name): """Check if this hook has been failing consistently for >= 3 days""" failure_file = os.path.join(STAMPDIR, hook_name + '.failed') try: hook_date = datetime.fromtimestamp(os.stat(failure_file).st_ctime) cur_time = datetime.now() d = cur_time - hook_date if d.days >= 3: return True except OSError: pass except Exception: traceback.print_exc(file=sys.stderr) return False def record_failure(hook): """Record that the named hook has failed""" if hook_aged_out(hook): permanent_failures.append(hook) else: failures.append(hook) def existing_permanent_failures(): """Return the list of all previously recorded permanent failures""" files = glob.glob(os.path.join(STAMPDIR, "*.permanent-failure")) return [os.path.splitext(os.path.basename(path))[0] for path in files] def trigger_update_notifier(failures, permanent=False): """Tell update-notifier that there were failed packages""" try: if permanent: with open(NOTIFIER_PERMANENT_SOURCE_FILE, 'r', encoding='utf-8') as f: input = f.read() output_file = open(NOTIFIER_PERMANENT_FILE, 'w', encoding='utf-8') else: with open(NOTIFIER_SOURCE_FILE, 'r', encoding='utf-8') as f: input = f.read() output_file = open(NOTIFIER_FILE, 'w', encoding='utf-8') except Exception: # Things failed and we can't even notify about it. Break the # trigger so that there's some error propagation, even if not # the most pleasant sort. traceback.print_exc(file=sys.stderr) sys.exit(1) packages = [os.path.basename(failure) for failure in failures] output_file.write( string.Template(input).substitute( {'packages': ", ".join(packages)})) output_file.close() def get_hook_file_names(): res = [] for relfile in os.listdir(DATADIR): # ignore files ending in .dpkg-* if (os.path.splitext(relfile)[1] and os.path.splitext(relfile)[1].startswith(".dpkg")): continue res.append(relfile) return res # we use apt-helper here as this gives us the exact same proxy behavior # as apt-get itself (environment/apt-config proxy settings/autodiscover) def download_file(uri, sha256_hashsum): """Download a URI and checks the given hashsum using apt-helper Returns: path to the downloaded file or None """ download_dir = os.path.join(STAMPDIR, "partial") dest_file = os.path.join(download_dir, os.path.basename(uri)) try: with open(dest_file, 'rb') as dest_file_obj: # apt_pkg can directly hash from file obj, let's use that instead # of hashlib real_sha256 = apt_pkg.sha256sum(dest_file_obj) if real_sha256 == sha256_hashsum: return dest_file else: os.remove(dest_file) except FileNotFoundError: pass ret = subprocess.call( ["/usr/lib/apt/apt-helper", "download-file", uri, dest_file, "SHA256:" + sha256_hashsum]) if ret != 0: if os.path.exists(dest_file): os.remove(dest_file) return None return dest_file def print_maybe(*args, **kwargs): """Version of print() that ignores failure""" try: print(*args, **kwargs) except OSError: pass def process_download_requests(): """Process requests to download package data files Iterate over /usr/share/package-data-downloads and download any package data specified in the contained file, then hand off to the indicated handler for further processing. Successful downloads are recorded in /var/lib/update-notifier/package-data-downloads to avoid unnecessary repeat handling. Failed downloads are reported to the user via the update-notifier interface.""" # Iterate through all the available hooks. If we get a failure # processing any of them (download failure, checksum failure, or # failure to run the hook script), record it but continue processing # the rest of the hooks since some of them may succeed. for relfile in get_hook_file_names(): stampfile = os.path.join(STAMPDIR, relfile) file = os.path.join(DATADIR, relfile) try: if not os.path.exists(NOTIFIER_FILE) and \ not os.path.exists(NOTIFIER_PERMANENT_FILE): hook_date = os.stat(file).st_mtime stamp_date = os.stat(stampfile).st_mtime if hook_date < stamp_date: continue elif os.path.exists(stampfile): continue except Exception as e: if not isinstance(e, OSError): traceback.print_exc(file=sys.stderr) hook = debian.deb822.Deb822() files = [] sums = [] for para in hook.iter_paragraphs(open(file)): if 'Script' in para: if not files: record_failure(relfile) break command = [para['Script']] if 'Should-Download' in para: db = debconf.DebconfCommunicator('update-notifier') try: should = db.get(para['Should-Download']) if should == "false": # Do nothing with this file. break except (DebconfError, KeyError): pass finally: db.shutdown() print_maybe("%s: processing..." % (relfile)) # Download each file and verify the sum try: downloaded = set() for i in range(len(files)): print_maybe("%s: downloading %s" % (relfile, files[i])) dest_file = download_file(files[i], sums[i]) if dest_file: command.append(dest_file) downloaded.add(dest_file) else: record_failure(relfile) break if relfile in failures + permanent_failures: break sys.stdout.flush() result = subprocess.call(command) if result: # There's no sense redownloading if the script fails permanent_failures.append(relfile) else: create_or_update_stampfile(stampfile) # cleanup for f in downloaded: os.remove(f) break except Exception: traceback.print_exc(file=sys.stderr) record_failure(relfile) # The 'script' is always the last stanza break # Not in a 'script' stanza, so we should have some urls try: files.append(para['Url']) sums.append(para['Sha256']) except Exception as e: print_maybe("%s: Error processing!" % (relfile)) if not isinstance(e, KeyError): traceback.print_exc(file=sys.stderr) record_failure(relfile) break previous_failures = existing_permanent_failures() # We only report about "permanent" failures when there are new ones, # but we want the whole list of permanently-failing hooks so when # we clobber the update-notifier file we don't lose information the # user may not have seen yet if permanent_failures: new_failures = False for failure in permanent_failures: if failure not in previous_failures: mark_hook_failed(failure, permanent=True) previous_failures.append(failure) new_failures = True if new_failures: trigger_update_notifier(previous_failures, permanent=True) # 2016-09-19 14:36 reset the list of permanent_failures as it caused # tests not to be idempotent permanent_failures.clear() if not previous_failures and os.path.exists(NOTIFIER_PERMANENT_FILE): os.unlink(NOTIFIER_PERMANENT_FILE) # Filter out new failure reports for permanently-failed packages our_failures = [x for x in failures if x not in previous_failures] # 2016-09-19 14:36 reset the list of permanent_failures as it caused # tests not to be idempotent failures.clear() if our_failures: for failure in our_failures: mark_hook_failed(failure) trigger_update_notifier(our_failures) elif os.path.exists(NOTIFIER_FILE): os.unlink(NOTIFIER_FILE) if __name__ == "__main__": process_download_requests() package-system-locked 0000755 00000000546 15027402346 0010656 0 ustar 00 #!/bin/sh # check if package system is locked # return 0 if unlocked, 2 if locked, 1 on error set -e for f in /var/lib/dpkg/lock /var/cache/apt/archives/lock \ /var/lib/apt/lists/lock /run/unattended-upgrades.lock; do [ -e $f ] || continue # fuser succeeds if there is at least one user if fuser $f; then exit 2 fi done exit 0 update-motd-updates-available 0000755 00000003276 15027402346 0012311 0 ustar 00 #!/bin/sh -e # # helper for update-motd NO_ESM_MESSAGES="" # poor mans force if [ "$1" = "--force" ]; then NEED_UPDATE_CHECK=yes else NEED_UPDATE_CHECK=no fi # check time when we did the last update check stamp="/var/lib/update-notifier/updates-available" # get list dir StateDir="/var/lib/apt/" ListDir="lists/" eval "$(apt-config shell StateDir Dir::State)" eval "$(apt-config shell ListDir Dir::State::Lists)" # get dpkg status file DpkgStatus="/var/lib/dpkg/status" eval "$(apt-config shell DpkgStatus Dir::State::status)" # get sources.list file EtcDir="etc/apt/" SourceList="sources.list" eval "$(apt-config shell EtcDir Dir::Etc)" eval "$(apt-config shell SourceList Dir::Etc::sourcelist)" # let the actual update be asynchronous to avoid stalling apt-get cleanup() { rm -f "$tmpfile"; } # check if we have a list file or sources.list that needs checking if [ -e "$stamp" ]; then if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" "/$DpkgStatus" -type f -newer "$stamp" -print -quit)" ]; then NEED_UPDATE_CHECK=yes fi else if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" -type f -print -quit)" ]; then NEED_UPDATE_CHECK=yes fi fi tmpfile="" trap cleanup EXIT tmpfile=$(mktemp -p $(dirname "$stamp")) # should we hide esm-related information in the output no_esm_file="/var/lib/update-notifier/hide-esm-in-motd" if [ -e "$no_esm_file" ]; then NO_ESM_MESSAGES="--no-esm-messages" fi # output something for update-motd if [ "$NEED_UPDATE_CHECK" = "yes" ]; then { echo "" /usr/lib/update-notifier/apt-check --human-readable "$NO_ESM_MESSAGES" echo "" } > "$tmpfile" mv "$tmpfile" "$stamp" chmod +r "$stamp" fi update-motd-fsck-at-reboot 0000755 00000005445 15027402346 0011546 0 ustar 00 #!/bin/sh # Authors: # Mads Chr. Olesen <mads@mchro.dk> # Kees Cook <kees@ubuntu.com> set -e # poor mans force if [ "$1" = "--force" ]; then NEEDS_FSCK_CHECK=yes else if [ "$(id -u)" != 0 ] ; then exit fi NEED_FSCK_CHECK=no fi # check time when we did the last check stamp="/var/lib/update-notifier/fsck-at-reboot" if [ -e "$stamp" ]; then stampt=$(stat -c %Y $stamp) else stampt=0 fi # check time when we last booted last_boot=$(date -d "now - $(awk '{print $1}' /proc/uptime) seconds" +%s) now=$(date +%s) if [ $(($stampt + 3600)) -lt $now ] || [ $stampt -gt $now ] \ || [ $stampt -lt $last_boot ] then #echo $stampt $now need update NEEDS_FSCK_CHECK=yes fi # output something for update-motd if [ -n "$NEEDS_FSCK_CHECK" ]; then { check_occur_any= ext_partitions=$(mount | awk '$5 ~ /^ext(2|3|4)$/ { print $1 }') for part in $ext_partitions; do dumpe2fs_out=$(dumpe2fs -h $part 2>/dev/null) mount_count=$(echo "$dumpe2fs_out" | grep "^Mount count:"|cut -d':' -f 2-) if [ -z "$mount_count" ]; then mount_count=0; fi max_mount_count=$(echo "$dumpe2fs_out" | grep "^Maximum mount count:"|cut -d':' -f 2-) if [ -z "$max_mount_count" ]; then max_mount_count=0; fi check_interval=$(echo "$dumpe2fs_out" | grep "^Check interval:" | cut -d':' -f 2- | cut -d'(' -f 1) if [ -z "$check_interval" ]; then check_interval=0; fi next_check_date=$(echo "$dumpe2fs_out" | grep "^Next check after:" | cut -d':' -f 2-) if [ -z "$next_check_interval" ]; then next_check_interval=0; fi next_check_tstamp=$(date -d "$next_check_date" +%s) #echo "next_check_date=\"$next_check_date\" next_check_tstamp=\"$next_check_tstamp\"" #echo "part=\"$part\" mount_count=\"$mount_count\" / max=\"$max_mount_count\" " check_occur= # Check based on mount counts? if [ "$max_mount_count" -gt 0 -a \ "$mount_count" -ge "$max_mount_count" ]; then check_occur=yes fi # Check based on time passed? if [ "$check_interval" -gt 0 -a \ "$next_check_tstamp" -lt "$now" ]; then check_occur=yes fi if [ -n "$check_occur" ]; then check_occur_any=yes mountpoint=$(mount | grep "^$part" | cut -d ' ' -f 3) pass=$(grep -v '^#' /etc/fstab | tr -s ' ' '\t' | cut -s -f 2,6 | grep -w "$mountpoint" | cut -f 2) if [ "$pass" = "0" ]; then echo "*** $part should be checked for errors ***" else echo "*** $part will be checked for errors at next reboot ***" fi fi done if [ -n "$check_occur_any" ]; then echo "" fi } > $stamp fi # output what we have (either cached or newly generated) cat $stamp apt_check.py 0000755 00000044433 15027402346 0007055 0 ustar 00 #!/usr/bin/python3 # nice apt-get -s -o Debug::NoLocking=true upgrade | grep ^Inst import apt import apt_pkg import os import sys from optparse import OptionParser import re import gettext import distro_info SYNAPTIC_PINFILE = "/var/lib/synaptic/preferences" OS_RELEASE_PATH = "/etc/os-release" PRO_ESM_CACHE_DIR = "/var/lib/ubuntu-advantage/apt-esm/" def _get_info_from_os_release(key): " get info directly from os-release file " if os.path.exists(OS_RELEASE_PATH): with open(OS_RELEASE_PATH) as f: search_res = re.search( r"{}=(?P<name>.*)".format(key), f.read() ) if search_res: return search_res.group("name") else: raise Exception( "Could not find {} in {}".format( key, OS_RELEASE_PATH ) ) else: raise Exception( "File {} was not found on the system".format( OS_RELEASE_PATH ) ) def get_distro(): " get distro name " return _get_info_from_os_release(key="UBUNTU_CODENAME") DISTRO = get_distro() ESM_INFRA_ORIGIN = "UbuntuESM" ESM_APPS_ORIGIN = "UbuntuESMApps" ESM_ORIGINS = (ESM_INFRA_ORIGIN, ESM_APPS_ORIGIN) def _(msg): return gettext.dgettext("update-notifier", msg) def _handleException(type, value, tb): sys.stderr.write("E: " + _("Unknown Error: '%s' (%s)") % (type, value)) sys.exit(-1) def get_distro_version(): " get distro version " return _get_info_from_os_release(key="VERSION_ID").replace('"', "") def clean(cache, depcache): " unmark (clean) all changes from the given depcache " # mvo: looping is too inefficient with the new auto-mark code # for pkg in cache.Packages: # depcache.MarkKeep(pkg) depcache.init() def saveDistUpgrade(cache, depcache): """ this function mimics a upgrade but will never remove anything """ depcache.upgrade(True) if depcache.del_count > 0: clean(cache, depcache) depcache.upgrade() def isSecurityUpgrade(ver): " check if the given version is a security update (or masks one) " security_pockets = [("Ubuntu", "%s-security" % DISTRO), (ESM_INFRA_ORIGIN, "%s-infra-security" % DISTRO), (ESM_APPS_ORIGIN, "%s-apps-security" % DISTRO), ("gNewSense", "%s-security" % DISTRO), ("Debian", "%s-updates" % DISTRO)] for (file, index) in ver.file_list: for origin, archive in security_pockets: if (file.archive == archive and file.origin == origin): return True return False def _isESMUpgrade(ver, esm_origin): " check if the given version is a security update (or masks one) " for (file, index) in ver.file_list: if file.origin == esm_origin and file.archive.startswith(DISTRO): return True return False def isESMAppsUpgrade(ver): " check if the given version is an ESM Apps upgrade " return _isESMUpgrade(ver, esm_origin=ESM_APPS_ORIGIN) def isESMInfraUpgrade(ver): " check if the given version is an ESM Infra upgrade " return _isESMUpgrade(ver, esm_origin=ESM_INFRA_ORIGIN) def write_package_names(outstream, cache, depcache): " write out package names that change to outstream " pkgs = [pkg for pkg in cache.packages if depcache.marked_install(pkg) or depcache.marked_upgrade(pkg)] outstream.write("\n".join([p.name for p in pkgs])) def is_esm_distro(): " check if the current distro is ESM or not " ubuntu_distro = distro_info.UbuntuDistroInfo() is_esm_supported = bool( DISTRO in ubuntu_distro.supported_esm() ) is_not_currently_supported = bool( DISTRO in ubuntu_distro.unsupported() ) return is_esm_supported and is_not_currently_supported def is_lts_distro(): " check if the current distro is LTS or not" return distro_info.UbuntuDistroInfo().is_lts(DISTRO) def _output_esm_package_count(outstream, service_type, esm_pkg_count): " output the number of packages upgrades related to esm service " if esm_pkg_count > 0: outstream.write("\n") outstream.write(gettext.dngettext("update-notifier", "%d of these updates " "is an ESM %s " "security update.", "%d of these updates " "are ESM %s " "security updates.", esm_pkg_count) % (esm_pkg_count, service_type)) def _output_esm_package_alert( outstream, service_type, disabled_pkg_count, is_esm=False ): " output the number of upgradable packages if esm service was enabled " outstream.write("\n") if disabled_pkg_count > 0: outstream.write("\n") if is_esm: distro_version = get_distro_version() esm_info_url = "https://ubuntu.com/{}".format( distro_version.replace(".", "-") ) learn_msg_suffix = "for Ubuntu {} at\n{}".format( distro_version, esm_info_url) else: learn_msg_suffix = "at https://ubuntu.com/esm" outstream.write(gettext.dngettext("update-notifier", "%i additional security " "update can be applied " "with ESM %s.\nLearn " "more about enabling ESM %s " "service %s", "%i additional security " "updates can be applied " "with ESM %s.\nLearn " "more about enabling " "ESM %s service %s", disabled_pkg_count) % (disabled_pkg_count, service_type, service_type, learn_msg_suffix)) else: outstream.write("\n") outstream.write(gettext.dgettext("update-notifier", "Enable ESM %s to " "receive additional future " "security updates.") % service_type) outstream.write("\n") outstream.write( gettext.dgettext("update-notifier", "See https://ubuntu.com/esm " "or run: sudo pro status") ) def _output_esm_service_status(outstream, have_esm_service, service_type): if have_esm_service: outstream.write(gettext.dgettext("update-notifier", "Expanded Security Maintenance for " "%s is enabled.") % service_type) else: outstream.write(gettext.dgettext("update-notifier", "Expanded Security Maintenance for " "%s is not enabled.") % service_type) outstream.write("\n\n") def write_human_readable_summary(outstream, upgrades, security_updates, esm_infra_updates, esm_apps_updates, have_esm_infra, have_esm_apps, disabled_esm_infra_updates, disabled_esm_apps_updates, hide_esm_messages=False): " write out human summary summary to outstream " esm_distro = is_esm_distro() lts_distro = is_lts_distro() if not hide_esm_messages: if have_esm_infra is not None and esm_distro: _output_esm_service_status( outstream, have_esm_infra, service_type="Infrastructure" ) if have_esm_apps is not None and lts_distro and not esm_distro: _output_esm_service_status( outstream, have_esm_apps, service_type="Applications" ) outstream.write( gettext.dngettext("update-notifier", "%i update can be applied immediately.", "%i updates can be applied immediately.", upgrades) % upgrades ) if not hide_esm_messages: _output_esm_package_count( outstream, service_type="Infra", esm_pkg_count=esm_infra_updates) _output_esm_package_count( outstream, service_type="Apps", esm_pkg_count=esm_apps_updates) if security_updates > 0: outstream.write("\n") outstream.write(gettext.dngettext("update-notifier", "%i of these updates is a " "standard security update.", "%i of these updates are " "standard security updates.", security_updates) % security_updates) if any([upgrades, security_updates, esm_infra_updates, esm_apps_updates]): outstream.write("\n") outstream.write(gettext.dgettext("update-notifier", "To see these additional updates " "run: apt list --upgradable")) if all( [ have_esm_apps is not None, not have_esm_apps, lts_distro, not esm_distro, not hide_esm_messages, ] ): _output_esm_package_alert( outstream, service_type="Apps", disabled_pkg_count=disabled_esm_apps_updates) if all( [ have_esm_infra is not None, not have_esm_infra, esm_distro, not hide_esm_messages, ] ): _output_esm_package_alert( outstream, service_type="Infra", disabled_pkg_count=disabled_esm_infra_updates, is_esm=True ) outstream.write("\n") def has_disabled_esm_security_update(esm_cache, pkg, esm_origin): " check if we have a disabled ESM security update " inst_ver = pkg.current_ver if not inst_ver: return False if pkg.name not in esm_cache: return False esm_update = esm_cache[pkg.name] for version in esm_update.version_list: for (file, index) in version.file_list: if file.origin == esm_origin: return True return False def has_disabled_esm_apps_security_update(esm_cache, pkg): " check if we have a disabled ESM Apps security update " return has_disabled_esm_security_update(esm_cache, pkg, ESM_APPS_ORIGIN) def has_disabled_esm_infra_security_update(esm_cache, pkg): " check if we have a disabled ESM Infra security update " return has_disabled_esm_security_update(esm_cache, pkg, ESM_INFRA_ORIGIN) def has_esm_service(cache, esm_origin): " check if we have an enabled ESM service in the machine " for file in cache.file_list: origin = file.origin if origin == esm_origin and file.archive.startswith(DISTRO): return True return False def get_apt_pkg_esm_cache(): """Get an apt_pkg cache with the ubuntu-advantage-tools esm data. Set the configuration to get the u-a-t cache, then set it back to an empty configuration state and init again so other calls to Cache work as expected. """ for key in apt_pkg.config.keys(): if re.match(r"^Acquire", key) is None: apt_pkg.config.clear(key) apt_pkg.config.set("Dir", PRO_ESM_CACHE_DIR) apt_pkg.init() try: esm_cache = apt_pkg.Cache(progress=None) except apt_pkg.Error: esm_cache = None for key in apt_pkg.config.keys(): apt_pkg.config.clear(key) apt_pkg.init() return esm_cache def init(): " init the system, be nice " # FIXME: do a ionice here too? os.nice(19) apt_pkg.init() def run(options=None): # we are run in "are security updates installed automatically?" # question mode if options.security_updates_unattended: res = apt_pkg.config.find_i("APT::Periodic::Unattended-Upgrade", 0) # print(res) sys.exit(res) # get caches try: cache = apt_pkg.Cache(apt.progress.base.OpProgress()) except SystemError as e: sys.stderr.write("E: " + _("Error: Opening the cache (%s)") % e) sys.exit(-1) depcache = apt_pkg.DepCache(cache) # read the synaptic pins too if os.path.exists(SYNAPTIC_PINFILE): depcache.read_pinfile(SYNAPTIC_PINFILE) depcache.init() if depcache.broken_count > 0: sys.stderr.write("E: " + _("Error: BrokenCount > 0")) sys.exit(-1) # do the upgrade (not dist-upgrade!) try: saveDistUpgrade(cache, depcache) except SystemError as e: sys.stderr.write("E: " + _("Error: Marking the upgrade (%s)") % e) sys.exit(-1) esm_cache = get_apt_pkg_esm_cache() # Check if we have ESM enabled or disabled; and if it exists in the # first place. have_esm_infra = has_esm_service(cache, esm_origin=ESM_INFRA_ORIGIN) have_esm_apps = has_esm_service(cache, esm_origin=ESM_APPS_ORIGIN) # analyze the ugprade upgrades = 0 security_updates = 0 esm_apps_updates = 0 esm_infra_updates = 0 disabled_esm_apps_updates = 0 disabled_esm_infra_updates = 0 # we need another cache that has more pkg details with apt.Cache() as aptcache: for pkg in cache.packages: if esm_cache: if has_disabled_esm_apps_security_update(esm_cache, pkg): disabled_esm_apps_updates += 1 if has_disabled_esm_infra_security_update(esm_cache, pkg): disabled_esm_infra_updates += 1 # skip packages that are not marked upgraded/installed if not (depcache.marked_install(pkg) or depcache.marked_upgrade(pkg)): continue # check if this is really a upgrade or a false positive # (workaround for ubuntu #7907) inst_ver = pkg.current_ver cand_ver = depcache.get_candidate_ver(pkg) if cand_ver == inst_ver: continue # check for security upgrades if isSecurityUpgrade(cand_ver): if have_esm_apps and isESMAppsUpgrade(cand_ver): esm_apps_updates += 1 elif have_esm_infra and isESMInfraUpgrade(cand_ver): esm_infra_updates += 1 else: security_updates += 1 upgrades += 1 continue # check to see if the update is a phased one try: from UpdateManager.Core.UpdateList import UpdateList ul = UpdateList(None) ignored = ul._is_ignored_phased_update( aptcache[pkg.get_fullname()]) if ignored: depcache.mark_keep(pkg) continue except ImportError: pass upgrades = upgrades + 1 # now check for security updates that are masked by a # candidate version from another repo (-proposed or -updates) for ver in pkg.version_list: if (inst_ver and apt_pkg.version_compare(ver.ver_str, inst_ver.ver_str) <= 0): continue if have_esm_apps and isESMAppsUpgrade(cand_ver): esm_apps_updates += 1 elif have_esm_infra and isESMInfraUpgrade(cand_ver): esm_infra_updates += 1 elif isSecurityUpgrade(ver): security_updates += 1 break # print the number of upgrades if options and options.show_package_names: write_package_names(sys.stderr, cache, depcache) elif options and options.readable_output: write_human_readable_summary(sys.stdout, upgrades, security_updates, esm_infra_updates, esm_apps_updates, have_esm_infra, have_esm_apps, disabled_esm_infra_updates, disabled_esm_apps_updates, options.hide_esm_messages) else: # print the number of regular upgrades and the number of # security upgrades sys.stderr.write("%s;%s" % (upgrades, security_updates)) # return the number of upgrades (if its used as a module) return(upgrades, security_updates) if __name__ == "__main__": # setup a exception handler to make sure that uncaught stuff goes # to the notifier sys.excepthook = _handleException # gettext APP = "update-notifier" DIR = "/usr/share/locale" gettext.bindtextdomain(APP, DIR) gettext.textdomain(APP) # check arguments parser = OptionParser() parser.add_option("-p", "--package-names", action="store_true", dest="show_package_names", help=_("Show the packages that are " "going to be installed/upgraded")) parser.add_option("", "--human-readable", action="store_true", dest="readable_output", help=_("Show human readable output on stdout")) parser.add_option("", "--no-esm-messages", action="store_true", dest="hide_esm_messages", help=_("Do not show esm related messages in human " "readable output")) parser.add_option("", "--security-updates-unattended", action="store_true", help=_("Return the time in days when security updates " "are installed unattended (0 means disabled)")) (options, args) = parser.parse_args() # run it init() run(options) cddistupgrader 0000755 00000001153 15027402346 0007501 0 ustar 00 #!/bin/sh # CDROM_MOUNT="$1" for d in "$CDROM_MOUNT"/dists/*/main/dist-upgrader/binary-all/; do if [ -d "$d" ]; then UPGRADER_DIR="$d" break fi done TAR=$(basename "$UPGRADER_DIR"/*.tar.gz) CODENAME=${TAR%.tar.gz} # get a tempdir TMPDIR=$(mktemp -t -d distupgrade.XXXXXX) cd $TMPDIR # extract the tar tar xzf "$UPGRADER_DIR"/"$TAR" # apply any patches needed before running the upgrade for apatch in /usr/share/update-notifier/upgrader-patches/*.diff; do if patch --dry-run < "$apatch"; then patch < "$apatch" fi done # run it "$TMPDIR"/"$CODENAME" --cdrom "$CDROM_MOUNT" apt-cdrom-check 0000755 00000004614 15027402346 0007443 0 ustar 00 #!/bin/sh # # helper to check if we actually have an ubuntu CD # # Returncode: # 0 - no ubuntu CD # 1 - CD with packages # 2 - dist-upgrader CD # 3 - aptoncd media # (if the returncodes change, make sure to update src/cdroms.c) # mount_point="$1" aptoncd_file="$mount_point/aptoncd.info" # sanity checks if [ -z "$mount_point" ]; then exit 0 fi if [ -f "$aptoncd_file" ]; then exit 3 fi if [ ! -d "$mount_point/ubuntu" ] && [ ! -f "$mount_point/cdromupgrade" ]; then exit 0 fi # check if there are "Packages" files on the cd (and ignore the # debian-installer dir) find "$mount_point/dists/" -name "Packages.gz" | grep -q -v debian-installer # 1 means "no lines were selected" in grep (no Packages file but the # debian-installer ones) if [ $? -eq 1 ]; then exit 0 fi # get some apt-config vars label_start=0 cdrom_id="" apt_dir="/" apt_state_dir="var/lib/apt/" apt_cdrom_list="cdrom.list" eval $(apt-config shell apt_dir Dir \ apt_state_dir Dir::State \ apt_cdrom_list Dir::State::cdroms) # identifying ... [afkdsjaf] line line=$(apt-cdrom -d="$1" -m ident|grep "\[.*\]") # remove the stuff before "Identifying... [dasjflkd]" -> "dasjflkd" line=${line%]*} cdrom_id=${line#*\[} if [ -z "$cdrom_id" ]; then # something bad happened here, we return "not yet scanned" as # fallback (because we are cheap) return 1 fi # [cdrom-id] -> cdrom-id if grep -s -q "$cdrom_id" $apt_dir$apt_state_dir$apt_cdrom_list; then # already in sources.list, ignore exit 0 fi # so this is a CD we don't know yet and it has packages. good! THIS_VERSION=$(lsb_release -sr) VERSION_ON_MEDIA=$(awk {'print $2'} "$mount_point/.disk/info") # now check if it contains a signed dist-upgrader for d in "$mount_point"/dists/*/main/dist-upgrader/binary-all/; do if [ -d "$d" ]; then # ok, we have one, now check the authentication GPG="gpgv --ignore-time-conflict --keyring /etc/apt/trusted.gpg" if $GPG "$d/"*.tar.gz.gpg "$d"/*.tar.gz; then # verified ok, we have a valid upgrader, if it was not ok, the # fallback to the end is ok because we still have packages on it if dpkg --compare-versions "$THIS_VERSION" lt "$VERSION_ON_MEDIA"; then exit 2 fi fi fi done # we got an ubuntu CD with packages if dpkg --compare-versions "$THIS_VERSION" lt "$VERSION_ON_MEDIA"; then exit 1 fi update-motd-reboot-required 0000755 00000000163 15027402346 0012026 0 ustar 00 #!/bin/sh -e # # helper for update-motd if [ -f /var/run/reboot-required ]; then cat /var/run/reboot-required fi list-oem-metapackages 0000755 00000002457 15027402346 0010661 0 ustar 00 #!/usr/bin/python3 import fnmatch import os import sys import apt import UbuntuDrivers.detect from gi.repository import GLib import apt_pkg STAMP_FILE = os.path.join( GLib.get_user_runtime_dir(), "ubuntu-drivers-oem.package-list" ) def any_oem_metapackages_installed(cache): installed_oem_packages = ( pkg for pkg in cache.packages if fnmatch.fnmatch(pkg.name, "oem-*-meta") and pkg.current_ver ) # Empty if there are no installed OEM packages return any((True for _ in installed_oem_packages)) def write_oem_metapackage_list(cache, filename): packages = UbuntuDrivers.detect.system_device_specific_metapackages( apt_cache=cache ) if not packages: return with open(STAMP_FILE, "w") as f: f.write("\n".join(packages)) if __name__ == "__main__": if os.path.exists(STAMP_FILE): sys.exit(0) try: cache = apt_pkg.Cache() except apt_pkg.Error: # broken things in sources.list, or corrupted list files print( "ERROR: Can't look into APT cache. Check your sources.list file(s), run `apt update` and try again", file=sys.stderr, ) sys.exit(0) if any_oem_metapackages_installed(cache): sys.exit(0) write_oem_metapackage_list(cache, STAMP_FILE)
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings