3
from __future__ import print_function
6
warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning)
9
from DistUpgrade.DistUpgradeVersion import VERSION
11
from UpdateManager.Core.MetaRelease import MetaReleaseCore
12
from UpdateManager.Core.DistUpgradeFetcherCore import DistUpgradeFetcherCore
13
from optparse import OptionParser
20
from DistUpgrade.utils import init_proxy
23
NO_RELEASE_AVAILABLE=1
25
if __name__ == "__main__":
27
#FIXME: Workaround a bug in optparser which doesn't handle unicode/str
28
# correctly, see http://bugs.python.org/issue4391
29
# Should be resolved by Python3
30
gettext.bindtextdomain("update-manager", "/usr/share/locale")
31
gettext.textdomain("update-manager")
32
translation = gettext.translation("update-manager", fallback=True)
33
if sys.version >= '3':
34
_ = translation.gettext
36
_ = translation.ugettext
39
locale.setlocale(locale.LC_ALL, "")
45
# when run as "check-new-release" we go into "check only" mode
46
check_only = sys.argv[0].endswith("check-new-release")
48
parser = OptionParser()
49
parser.add_option ("-V", "--version", action="store_true",
50
dest="show_version", default=False,
51
help=_("Show version and exit"))
52
parser.add_option ("-d", "--devel-release", action="store_true",
53
dest="devel_release", default=False,
54
help=_("Check if upgrading to the latest devel release "
56
parser.add_option ("-p", "--proposed", action="store_true",
57
dest="proposed_release", default=False,
58
help=_("Try upgrading to the latest release using "
59
"the upgrader from $distro-proposed"))
60
parser.add_option ("-m", "--mode", default="server",
62
help=_("Run in a special upgrade mode.\n"
63
"Currently 'desktop' for regular upgrades of "
64
"a desktop system and 'server' for server "
65
"systems are supported."))
66
parser.add_option ("-f", "--frontend", default="DistUpgradeViewText",
68
help=_("Run the specified frontend"))
69
parser.add_option ("-s","--sandbox", action="store_true", default=False,
70
help=_("Test upgrade with a sandbox aufs overlay"))
71
parser.add_option ("-c", "--check-dist-upgrade-only", action="store_true",
73
help=_("Check only if a new distribution release is "
74
"available and report the result via the "
76
parser.add_option ("-q", "--quiet", default=False, action="store_true",
79
(options, args) = parser.parse_args()
82
if options.show_version:
83
print("%s: version %s" % (os.path.basename(sys.argv[0]), VERSION))
87
print(_("Checking for a new Ubuntu release"))
89
m = MetaReleaseCore(useDevelopmentRelease=options.devel_release,
90
useProposed=options.proposed_release)
91
# this will timeout eventually
95
# make sure to inform the user if his distro is no longer supported
96
# this will make it appear in motd (that calls do-release-upgrade in
97
# chech-new-release mode)
98
if m.no_longer_supported is not None:
99
url = "http://www.ubuntu.com/releaseendoflife"
100
print(_("Your Ubuntu release is not supported anymore."))
101
print(_("For upgrade information, please visit:\n"
102
"%(url)s\n") % { 'url' : url })
104
# now inform about a new release
105
if m.new_dist is None:
106
if not options.quiet:
107
print(_("No new release found"))
108
sys.exit(NO_RELEASE_AVAILABLE)
110
if m.new_dist.upgrade_broken:
111
if not options.quiet:
112
print(_("Release upgrade not possible right now"))
113
print(_("The release upgrade can not be performed currently, "
114
"please try again later. The server reported: '%s'") % m.new_dist.upgrade_broken)
115
sys.exit(NO_RELEASE_AVAILABLE)
118
if options.check_dist_upgrade_only:
119
print(_("New release '%s' available.") % m.new_dist.version)
120
print(_("Run 'do-release-upgrade' to upgrade to it."))
121
sys.exit(RELEASE_AVAILABLE)
123
progress = apt.progress.text.AcquireProgress()
124
fetcher = DistUpgradeFetcherCore(new_dist=m.new_dist,
126
fetcher.run_options += ["--mode=%s" % options.mode,
127
"--frontend=%s" % options.frontend,
130
fetcher.run_options.append("--sandbox")