Enable BytesWarnings.
[portage.git] / bin / fixpackages
1 #!/usr/bin/python -bb
2 # Copyright 1999-2014 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 from __future__ import print_function
6
7 import os
8 import sys
9
10 from os import path as osp
11 pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")
12 sys.path.insert(0, pym_path)
13 import portage
14 portage._internal_caller = True
15 from portage import os
16 from portage.output import EOutput
17 from portage.util._argparse import ArgumentParser
18 from textwrap import wrap
19 from portage._global_updates import _global_updates
20 mysettings = portage.settings
21 mytrees = portage.db
22 mtimedb = portage.mtimedb
23
24 description = """The fixpackages program performs package move updates on
25         configuration files, installed packages, and binary packages."""
26 description = " ".join(description.split())
27
28 parser = ArgumentParser(description=description)
29 parser.parse_args()
30
31 if mysettings['ROOT'] != "/":
32         out = EOutput()
33         msg = "The fixpackages program is not intended for use with " + \
34                 "ROOT != \"/\". Instead use `emaint --fix movebin` and/or " + \
35                 "`emaint --fix moveinst."
36         for line in wrap(msg, 72):
37                 out.eerror(line)
38         sys.exit(1)
39
40 try:
41         os.nice(int(mysettings.get("PORTAGE_NICENESS", "0")))
42 except (OSError, ValueError) as e:
43         portage.writemsg("!!! Failed to change nice value to '%s'\n" % \
44                 mysettings["PORTAGE_NICENESS"])
45         portage.writemsg("!!! %s\n" % str(e))
46         del e
47
48 _global_updates(mytrees, mtimedb["updates"], if_mtime_changed=False)
49
50 print()
51 print("Done.")
52 print()