| |
@@ -3,11 +3,22 @@
|
| |
# SPDX-License-Identifier: GPL-2.0+
|
| |
|
| |
import argparse
|
| |
+ import datetime
|
| |
import os
|
| |
import shutil
|
| |
import subprocess
|
| |
import tempfile
|
| |
|
| |
+ ORPHAN_REASON = """Retired orphaned package, because it was orphaned for
|
| |
+ more than six weeks.
|
| |
+ """
|
| |
+
|
| |
+ ORPHAN_DEPENDENT_REASON = """Retired because it depends on {package}, which was
|
| |
+ retired, because it was orphaned for more than six weeks.
|
| |
+ """
|
| |
+
|
| |
+ ORPHAN_NOT_BUILT = """Retired orphaned package, because it was not built."""
|
| |
+
|
| |
|
| |
def retire(pkg, branch, reason, dryrun=False):
|
| |
def run(cmd, cwd):
|
| |
@@ -38,10 +49,28 @@
|
| |
"epel7", "el6", "el5"])
|
| |
parser.add_argument("--reasonfile", default=None)
|
| |
parser.add_argument("--reason", default=None)
|
| |
+ parser.add_argument("--orphan", default=False, action="store_true",
|
| |
+ help="Use reason for orphaned packages")
|
| |
+ parser.add_argument(
|
| |
+ "--orphan-dependent", default=None,
|
| |
+ help="Use reason for package depending on orphaned package")
|
| |
+ parser.add_argument("--unbuilt-orphan", default=False, action="store_true",
|
| |
+ help="Use reason for unbuilt orphaned package")
|
| |
parser.add_argument("pkg", nargs="+")
|
| |
args = parser.parse_args()
|
| |
|
| |
- if args.reasonfile is None and args.reason is None:
|
| |
+ if args.reasonfile is not None:
|
| |
+ with open(args.reasonfile, "rb") as reasonfile:
|
| |
+ reason = reasonfile.read()
|
| |
+ elif args.reason:
|
| |
+ reason = args.reason
|
| |
+ elif args.orphan:
|
| |
+ reason = ORPHAN_REASON
|
| |
+ elif args.orphan_dependent:
|
| |
+ reason = ORPHAN_DEPENDENT_REASON.format(package=args.orphan_dependent)
|
| |
+ elif args.unbuilt_orphan:
|
| |
+ reason = ORPHAN_NOT_BUILT
|
| |
+ else:
|
| |
reasonfile = tempfile.NamedTemporaryFile(delete=False)
|
| |
filename = reasonfile.name
|
| |
childpid = os.fork()
|
| |
@@ -51,13 +80,13 @@
|
| |
os.waitpid(childpid, 0)
|
| |
reason = reasonfile.read()
|
| |
os.unlink(filename)
|
| |
- elif args.reasonfile is not None:
|
| |
- with open(args.reasonfile, "rb") as reasonfile:
|
| |
- reason = reasonfile.read()
|
| |
- else:
|
| |
- reason = args.reason
|
| |
- if reason[-1] != "\n":
|
| |
- reason += "\n"
|
| |
+
|
| |
+ date = datetime.datetime.now().strftime("%Y-%m-%d: ")
|
| |
+ if not reason.startswith(date):
|
| |
+ reason = date + reason
|
| |
+
|
| |
+ if reason[-1] != "\n":
|
| |
+ reason += "\n"
|
| |
|
| |
errors = {}
|
| |
for pkg in args.pkg:
|
| |