2 # Copyright 1999-2013 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
5 from __future__ import print_function
8 from os import path as osp
9 pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")
10 sys.path.insert(0, pym_path)
12 portage._internal_caller = True
14 if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv:
16 print("You must specify directories with hardlink-locks to clean.")
17 print("You may optionally specify --force, which will remove all")
18 print("of the locks, even if we can't establish if they are in use.")
19 print("Please attempt cleaning without force first.")
21 print("%s %s/.locks" % (sys.argv[0], portage.settings["DISTDIR"]))
22 print("%s --force %s/.locks" % (sys.argv[0], portage.settings["DISTDIR"]))
27 if "--force" in sys.argv[1:]:
30 for x in sys.argv[1:]:
34 for y in portage.locks.hardlock_cleanup(x, remove_all_locks=force):
39 if e.errno in (errno.ENOENT, errno.ENOTDIR):
40 print("!!! %s is not a directory or does not exist" % x)