Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/releng:master commit in: scripts/
Date: Sat, 31 Jul 2021 19:41:41
Message-Id: 1627760476.36db6e7c8748e2d346e1ef92362807b0c242df76.mattst88@gentoo
1 commit: 36db6e7c8748e2d346e1ef92362807b0c242df76
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jul 31 01:31:21 2021 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Sat Jul 31 19:41:16 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/releng.git/commit/?id=36db6e7c
7
8 scripts: Remove cruft
9
10 Presumably these were used once upon a time when catalyst builds were
11 done on infra-managed boxes (where puppet/chef made updating things
12 difficult).
13
14 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
15
16 scripts/backup_snapshot_repo | 10 -
17 scripts/cache-tools.py | 700 -------------------------------------------
18 scripts/run_catalyst | 2 -
19 scripts/run_official | 39 ---
20 scripts/run_snapshot | 2 -
21 scripts/stage_build.sh | 162 ----------
22 scripts/sudo_catalyst | 28 --
23 scripts/sudo_official | 46 ---
24 scripts/sudo_snapshot | 20 --
25 scripts/update_auto_tree | 14 -
26 scripts/update_official_tree | 14 -
27 scripts/update_snapshot_tree | 14 -
28 12 files changed, 1051 deletions(-)
29
30 diff --git a/scripts/backup_snapshot_repo b/scripts/backup_snapshot_repo
31 deleted file mode 100755
32 index 94b2828f..00000000
33 --- a/scripts/backup_snapshot_repo
34 +++ /dev/null
35 @@ -1,10 +0,0 @@
36 -#!/bin/bash
37 -
38 -# Start our rsyncs
39 -RSYNC_OPTS="--archive --delete --sparse --whole-file"
40 -
41 -if [ -e /release/repos/snapshot-tree/hooks/post-commit ]
42 -then
43 - echo "$(date): Starting rsync of trees from tmpfs to disk..." >> /var/log/snapshot-tree-backup.log
44 - rsync ${RSYNC_OPTS} /release/repos/snapshot-tree/* /release/repos/snapshot-tree-disk 2>&1 >> /var/log/snapshot-tree-backup.log || echo "$(date): rsync failed!" >> /var/log/snapshot-tree-backup.log
45 -fi
46
47 diff --git a/scripts/cache-tools.py b/scripts/cache-tools.py
48 deleted file mode 100755
49 index 03644503..00000000
50 --- a/scripts/cache-tools.py
51 +++ /dev/null
52 @@ -1,700 +0,0 @@
53 -#!/usr/bin/env python
54 -# Copyright 1999-2006 Gentoo Foundation
55 -# Distributed under the terms of the GNU General Public License v2
56 -# $Header: $
57 -#
58 -# Zac Medico <zmedico@g.o>
59 -#
60 -
61 -import errno, fpformat, os, sys, time
62 -
63 -if not hasattr(__builtins__, "set"):
64 - from sets import Set as set
65 -from itertools import chain
66 -
67 -def create_syncronized_func(myfunc, mylock):
68 - def newfunc(*pargs, **kwargs):
69 - mylock.acquire()
70 - try:
71 - myfunc(*pargs, **kwargs)
72 - finally:
73 - mylock.release()
74 - return myfunc
75 -
76 -class ConsoleUpdate(object):
77 -
78 - _synchronized_methods = ["append", "carriageReturn",
79 - "newLine", "reset", "update"]
80 -
81 - def __init__(self):
82 - self.offset = 0
83 - import sys
84 - self.stream = sys.stdout
85 - self.quiet = False
86 - import threading
87 - self._lock = threading.RLock()
88 - for method_name in self._synchronized_methods:
89 - myfunc = create_syncronized_func(
90 - getattr(self, method_name), self._lock)
91 - setattr(self, method_name, myfunc)
92 - # ANSI code that clears from the cursor to the end of the line
93 - self._CLEAR_EOL = None
94 - try:
95 - import curses
96 - try:
97 - curses.setupterm()
98 - self._CLEAR_EOL = curses.tigetstr('el')
99 - except curses.error:
100 - pass
101 - except ImportError:
102 - pass
103 - if not self._CLEAR_EOL:
104 - self._CLEAR_EOL = '\x1b[K'
105 -
106 - def acquire(self, **kwargs):
107 - return self._lock.acquire(**kwargs)
108 -
109 - def release(self):
110 - self._lock.release()
111 -
112 - def reset(self):
113 - self.offset = 0
114 -
115 - def carriageReturn(self):
116 - if not self.quiet:
117 - self.stream.write("\r")
118 - self.stream.write(self._CLEAR_EOL)
119 - self.offset = 0
120 -
121 - def newLine(self):
122 - if not self.quiet:
123 - self.stream.write("\n")
124 - self.stream.flush()
125 - self.reset()
126 -
127 - def update(self, msg):
128 - if not self.quiet:
129 - self.carriageReturn()
130 - self.append(msg)
131 -
132 - def append(self, msg):
133 - if not self.quiet:
134 - self.offset += len(msg)
135 - self.stream.write(msg)
136 - self.stream.flush()
137 -
138 -class ProgressCounter(object):
139 - def __init__(self):
140 - self.total = 0
141 - self.current = 0
142 -
143 -class ProgressAnalyzer(ProgressCounter):
144 - def __init__(self):
145 - self.start_time = time.time()
146 - self.currentTime = self.start_time
147 - self._samples = []
148 - self.sampleCount = 20
149 - def percentage(self, digs=0):
150 - if self.total > 0:
151 - float_percent = 100 * float(self.current) / float(self.total)
152 - else:
153 - float_percent = 0.0
154 - return fpformat.fix(float_percent,digs)
155 - def totalTime(self):
156 - self._samples.append((self.currentTime, self.current))
157 - while len(self._samples) > self.sampleCount:
158 - self._samples.pop(0)
159 - prev_time, prev_count = self._samples[0]
160 - time_delta = self.currentTime - prev_time
161 - if time_delta > 0:
162 - rate = (self.current - prev_count) / time_delta
163 - if rate > 0:
164 - return self.total / rate
165 - return 0
166 - def remaining_time(self):
167 - return self.totalTime() - self.elapsed_time()
168 - def elapsed_time(self):
169 - return self.currentTime - self.start_time
170 -
171 -class ConsoleProgress(object):
172 - def __init__(self, name="Progress", console=None):
173 - self.name = name
174 - self.analyzer = ProgressAnalyzer()
175 - if console is None:
176 - self.console = ConsoleUpdate()
177 - else:
178 - self.console = console
179 - self.time_format="%H:%M:%S"
180 - self.quiet = False
181 - self.lastUpdate = 0
182 - self.latency = 0.5
183 -
184 - def formatTime(self, t):
185 - return time.strftime(self.time_format, time.gmtime(t))
186 -
187 - def displayProgress(self, current, total):
188 - if self.quiet:
189 - return
190 -
191 - self.analyzer.currentTime = time.time()
192 - if self.analyzer.currentTime - self.lastUpdate < self.latency:
193 - return
194 - self.lastUpdate = self.analyzer.currentTime
195 - self.analyzer.current = current
196 - self.analyzer.total = total
197 -
198 - output = ((self.name, self.analyzer.percentage(1).rjust(4) + "%"),
199 - ("Elapsed", self.formatTime(self.analyzer.elapsed_time())),
200 - ("Remaining", self.formatTime(self.analyzer.remaining_time())),
201 - ("Total", self.formatTime(self.analyzer.totalTime())))
202 - self.console.update(" ".join([ x[0] + ": " + x[1] for x in output ]))
203 -
204 -class ProgressHandler(object):
205 - def __init__(self):
206 - self.curval = 0
207 - self.maxval = 0
208 - self.last_update = 0
209 - self.min_display_latency = 0.2
210 -
211 - def onProgress(self, maxval, curval):
212 - self.maxval = maxval
213 - self.curval = curval
214 - cur_time = time.time()
215 - if cur_time - self.last_update >= self.min_display_latency:
216 - self.last_update = cur_time
217 - self.display()
218 -
219 - def display(self):
220 - raise NotImplementedError(self)
221 -
222 -def open_file(filename=None):
223 - if filename is None:
224 - f = sys.stderr
225 - elif filename == "-":
226 - f = sys.stdout
227 - else:
228 - try:
229 - filename = os.path.expanduser(filename)
230 - f = open(filename, "a")
231 - except (IOError, OSError), e:
232 - sys.stderr.write("%s\n" % e)
233 - sys.exit(e.errno)
234 - return f
235 -
236 -def create_log(name="", logfile=None, loglevel=0):
237 - import logging
238 - log = logging.getLogger(name)
239 - log.setLevel(loglevel)
240 - handler = logging.StreamHandler(open_file(logfile))
241 - handler.setFormatter(logging.Formatter("%(levelname)s %(message)s"))
242 - log.addHandler(handler)
243 - return log
244 -
245 -def is_interrupt(e):
246 - if isinstance(e, (SystemExit, KeyboardInterrupt)):
247 - return True
248 - return hasattr(e, "errno") and e.errno == errno.EINTR
249 -
250 -def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, log,
251 - eclass_cache, cleanse_on_transfer_failure):
252 -
253 - cleanse_candidates = set(trg_cache.iterkeys())
254 - update_count = 0
255 -
256 - # Since the loop below is mission critical, we continue after *any*
257 - # exception that is not an interrupt.
258 -
259 - for x in valid_nodes_iterable:
260 - log.debug("%s mirroring" % x)
261 - if not cleanse_on_transfer_failure:
262 - cleanse_candidates.discard(x)
263 -
264 - try:
265 - entry = copy_dict(src_cache[x])
266 - except KeyError, e:
267 - log.error("%s missing source: %s" % (x, str(e)))
268 - del e
269 - continue
270 - except Exception, e:
271 - if is_interrupt(e):
272 - raise
273 - log.error("%s reading source: %s" % (x, str(e)))
274 - del e
275 - continue
276 -
277 - write_it = True
278 - trg = None
279 -
280 - try:
281 - trg = copy_dict(trg_cache[x])
282 - if long(trg["_mtime_"]) == long(entry["_mtime_"]) and \
283 - eclass_cache.is_eclass_data_valid(trg["_eclasses_"]) and \
284 - set(trg["_eclasses_"]) == set(entry["_eclasses_"]):
285 - write_it = False
286 - except KeyError:
287 - pass
288 - except Exception, e:
289 - if is_interrupt(e):
290 - raise
291 - log.error("%s reading target: %s" % (x, str(e)))
292 - del e
293 -
294 - if trg and not write_it:
295 - """ We don't want to skip the write unless we're really sure that
296 - the existing cache is identical, so don't trust _mtime_ and
297 - _eclasses_ alone."""
298 - for d in (entry, trg):
299 - if "EAPI" in d and d["EAPI"] in ("", "0"):
300 - del d["EAPI"]
301 - for k in set(chain(entry, trg)).difference(
302 - ("_mtime_", "_eclasses_")):
303 - if trg.get(k, "") != entry.get(k, ""):
304 - write_it = True
305 - break
306 -
307 - if write_it:
308 - update_count += 1
309 - log.info("%s transferring" % x)
310 - inherited = entry.get("INHERITED", None)
311 - if inherited:
312 - if src_cache.complete_eclass_entries:
313 - if not "_eclasses_" in entry:
314 - log.error("%s missing _eclasses_" % x)
315 - continue
316 - if not eclass_cache.is_eclass_data_valid(entry["_eclasses_"]):
317 - log.error("%s stale _eclasses_" % x)
318 - continue
319 - else:
320 - entry["_eclasses_"] = eclass_cache.get_eclass_data(entry["INHERITED"].split(), \
321 - from_master_only=True)
322 - if not entry["_eclasses_"]:
323 - log.error("%s stale _eclasses_" % x)
324 - continue
325 - try:
326 - trg_cache[x] = entry
327 - cleanse_candidates.discard(x)
328 - except Exception, e:
329 - if is_interrupt(e):
330 - raise
331 - log.error("%s writing target: %s" % (x, str(e)))
332 - del e
333 - else:
334 - cleanse_candidates.discard(x)
335 -
336 - if not trg_cache.autocommits:
337 - try:
338 - trg_cache.commit()
339 - except Exception, e:
340 - if is_interrupt(e):
341 - raise
342 - log.error("committing target: %s" % str(e))
343 - del e
344 -
345 - return update_count, cleanse_candidates
346 -
347 -def copy_dict(src, dest=None):
348 - """Some cache implementations throw cache errors when accessing the values.
349 - We grab all the values at once here so that we don't have to be concerned
350 - about exceptions later."""
351 - if dest is None:
352 - dest = {}
353 - for k, v in src.iteritems():
354 - dest[k] = v
355 - return dest
356 -
357 -class ListPackages(object):
358 - def __init__(self, portdb, log, shuffle=False):
359 - self._portdb = portdb
360 - self._log = log
361 - self._shuffle = shuffle
362 -
363 - def run(self):
364 - log = self._log
365 - cp_list = self._portdb.cp_list
366 - cp_all = self._portdb.cp_all()
367 - if self._shuffle:
368 - from random import shuffle
369 - shuffle(cp_all)
370 - else:
371 - cp_all.sort()
372 - cpv_all = []
373 - # Since the loop below is mission critical, we continue after *any*
374 - # exception that is not an interrupt.
375 - for cp in cp_all:
376 - log.debug("%s cp_list" % cp)
377 - try:
378 - cpv_all.extend(cp_list(cp))
379 - except Exception, e:
380 - if is_interrupt(e):
381 - raise
382 - self._log.error("%s cp_list: %s" % (cp, str(e)))
383 -
384 - self.cpv_all = cpv_all
385 -
386 -class MetadataGenerate(object):
387 - """When cache generation fails for some reason, cleanse the stale cache
388 - entry if it exists. This prevents the master mirror from distributing
389 - stale cache, and will allow clients to safely assume that all cache is
390 - valid. The mtime requirement is especially annoying due to bug #139134
391 - (timestamps of cache entries don't change when an eclass changes) and the
392 - interaction of timestamps with rsync."""
393 - def __init__(self, portdb, cpv_all, log):
394 - self._portdb = portdb
395 - self._cpv_all = cpv_all
396 - self._log = log
397 -
398 - def run(self, onProgress=None):
399 - log = self._log
400 - portdb = self._portdb
401 - cpv_all = self._cpv_all
402 - auxdb = portdb.auxdb[portdb.porttree_root]
403 - cleanse_candidates = set(auxdb.iterkeys())
404 -
405 - # Since the loop below is mission critical, we continue after *any*
406 - # exception that is not an interrupt.
407 - maxval = len(cpv_all)
408 - curval = 0
409 - if onProgress:
410 - onProgress(maxval, curval)
411 - while cpv_all:
412 - cpv = cpv_all.pop(0)
413 - log.debug("%s generating" % cpv)
414 - try:
415 - portdb.aux_get(cpv, ["EAPI"])
416 - # Cleanse if the above doesn't succeed (prevent clients from
417 - # receiving stale cache, and let them assume it is valid).
418 - cleanse_candidates.discard(cpv)
419 - except Exception, e:
420 - if is_interrupt(e):
421 - raise
422 - log.error("%s generating: %s" % (cpv, str(e)))
423 - del e
424 - curval += 1
425 - if onProgress:
426 - onProgress(maxval, curval)
427 -
428 - self.target_cache = auxdb
429 - self.dead_nodes = cleanse_candidates
430 -
431 -class MetadataTransfer(object):
432 - def __init__(self, portdb, cpv_all, forward, cleanse_on_transfer_failure,
433 - log):
434 - self._portdb = portdb
435 - self._cpv_all = cpv_all
436 - self._log = log
437 - self._forward = forward
438 - self._cleanse_on_transfer_failure = cleanse_on_transfer_failure
439 -
440 - def run(self, onProgress=None):
441 - log = self._log
442 - portdb = self._portdb
443 - cpv_all = self._cpv_all
444 - aux_cache = portdb.auxdb[portdb.porttree_root]
445 - import portage
446 - auxdbkeys = portage.auxdbkeys[:]
447 - metadbmodule = portdb.mysettings.load_best_module("portdbapi.metadbmodule")
448 - portdir_cache = metadbmodule(portdb.porttree_root, "metadata/cache",
449 - auxdbkeys)
450 -
451 - maxval = len(cpv_all)
452 - curval = 0
453 - if onProgress:
454 - onProgress(maxval, curval)
455 - class pkg_iter(object):
456 - def __init__(self, pkg_list, onProgress=None):
457 - self.pkg_list = pkg_list
458 - self.maxval = len(pkg_list)
459 - self.curval = 0
460 - self.onProgress = onProgress
461 - def __iter__(self):
462 - while self.pkg_list:
463 - yield self.pkg_list.pop()
464 - self.curval += 1
465 - if self.onProgress:
466 - self.onProgress(self.maxval, self.curval)
467 -
468 - if self._forward:
469 - src_cache = portdir_cache
470 - trg_cache = aux_cache
471 - else:
472 - src_cache = aux_cache
473 - trg_cache = portdir_cache
474 -
475 - """ This encapsulates validation of eclass timestamps and also fills in
476 - missing data (mtimes and/or paths) as necessary for the given cache
477 - format."""
478 - eclass_cache = portage.eclass_cache.cache(portdb.porttree_root)
479 -
480 - if not trg_cache.autocommits:
481 - trg_cache.sync(100)
482 -
483 - self.target_cache = trg_cache
484 - self.update_count, self.dead_nodes = mirror_cache(
485 - pkg_iter(cpv_all, onProgress=onProgress),
486 - src_cache, trg_cache, log, eclass_cache,
487 - self._cleanse_on_transfer_failure)
488 -
489 -class CacheCleanse(object):
490 - def __init__(self, auxdb, dead_nodes, log):
491 - self._auxdb = auxdb
492 - self._dead_nodes = dead_nodes
493 - self._log = log
494 - def run(self):
495 - auxdb = self._auxdb
496 - log = self._log
497 - for cpv in self._dead_nodes:
498 - try:
499 - log.info("%s cleansing" % cpv)
500 - del auxdb[cpv]
501 - except Exception, e:
502 - if is_interrupt(e):
503 - raise
504 - log.error("%s cleansing: %s" % (cpv, str(e)))
505 - del e
506 -
507 -def import_portage():
508 - try:
509 - from portage import data as portage_data
510 - except ImportError:
511 - import portage_data
512 - # If we're not already root or in the portage group, we make the gid of the
513 - # current process become portage_gid.
514 - if os.getgid() != 0 and portage_data.portage_gid not in os.getgroups():
515 - portage_data.portage_gid = os.getgid()
516 - portage_data.secpass = 1
517 -
518 - os.environ["PORTAGE_LEGACY_GLOBALS"] = "false"
519 - import portage
520 - del os.environ["PORTAGE_LEGACY_GLOBALS"]
521 - return portage
522 -
523 -def create_portdb(portdir=None, cachedir=None, config_root=None,
524 - target_root=None, profile=None, **kwargs):
525 -
526 - if cachedir is not None:
527 - os.environ["PORTAGE_DEPCACHEDIR"] = cachedir
528 - if config_root is None:
529 - config_root = os.environ.get("PORTAGE_CONFIGROOT", "/")
530 - if target_root is None:
531 - target_root = os.environ.get("ROOT", "/")
532 - if profile is None:
533 - profile = ""
534 -
535 - portage = import_portage()
536 - try:
537 - from portage import const as portage_const
538 - except ImportError:
539 - import portage_const
540 -
541 - # Disable overlays because we only generate metadata for the main repo.
542 - os.environ["PORTDIR_OVERLAY"] = ""
543 - conf = portage.config(config_profile_path=profile,
544 - config_incrementals=portage_const.INCREMENTALS,
545 - target_root=target_root,
546 - config_root=config_root)
547 -
548 - if portdir is None:
549 - portdir = conf["PORTDIR"]
550 -
551 - # The cannonical path is the key for portdb.auxdb.
552 - portdir = os.path.realpath(portdir)
553 - conf["PORTDIR"] = portdir
554 - conf.backup_changes("PORTDIR")
555 -
556 - portdb = portage.portdbapi(portdir,
557 - mysettings=conf)
558 -
559 - return portdb
560 -
561 -def parse_args(myargv):
562 - description = "This program will ensure that the metadata cache is up to date for entire portage tree."
563 - usage = "usage: cache-tools [options] --generate || --transfer"
564 - from optparse import OptionParser
565 - parser = OptionParser(description=description, usage=usage)
566 - parser.add_option("--portdir",
567 - help="location of the portage tree",
568 - dest="portdir")
569 - parser.add_option("--cachedir",
570 - help="location of the metadata cache",
571 - dest="cachedir")
572 - parser.add_option("--profile",
573 - help="location of the profile",
574 - dest="profile")
575 - parser.add_option("--generate",
576 - help="generate metadata as necessary to ensure that the cache is fully populated",
577 - action="store_true", dest="generate", default=False)
578 - parser.add_option("--shuffle",
579 - help="generate cache in random rather than sorted order (useful to prevent two separate instances from competing to generate metadata for the same packages simultaneously)",
580 - action="store_true", dest="shuffle", default=False)
581 - parser.add_option("--transfer",
582 - help="transfer metadata from portdir to cachedir or vice versa",
583 - action="store_true", dest="transfer", default=False)
584 - parser.add_option("--cleanse-on-transfer-failure",
585 - help="cleanse target cache when transfer fails for any reason (such as the source being unavailable)",
586 - action="store_true", dest="cleanse_on_transfer_failure", default=False)
587 - parser.add_option("--forward",
588 - help="forward metadata transfer flows from portdir to cachedir (default)",
589 - action="store_true", dest="forward", default=True)
590 - parser.add_option("--reverse",
591 - help="reverse metadata transfer flows from cachedir to portdir",
592 - action="store_false", dest="forward", default=True)
593 - parser.add_option("--logfile",
594 - help="send status messages to a file (default is stderr)",
595 - dest="logfile", default=None)
596 - parser.add_option("--loglevel",
597 - help="numeric log level (defauls to 0 and may range from 0 to 50 corresponding to the default levels of the python logging module)",
598 - dest="loglevel", default="0")
599 - parser.add_option("--reportfile",
600 - help="send a report to a file",
601 - dest="reportfile", default=None)
602 - parser.add_option("--spawn-outfile",
603 - help="redirect ouput of spawned processes to a file instead of stdout/stderr",
604 - dest="spawn_outfile", default=None)
605 - parser.add_option("--no-progress",
606 - action="store_false", dest="progress", default=True,
607 - help="disable progress output to tty")
608 - options, args = parser.parse_args(args=myargv)
609 -
610 - # Conversion to dict allows us to use **opts as function args later on.
611 - opts = {}
612 - all_options = ("portdir", "cachedir", "profile", "progress", "logfile",
613 - "loglevel", "generate", "transfer", "forward", "shuffle",
614 - "spawn_outfile", "reportfile", "cleanse_on_transfer_failure")
615 - for opt_name in all_options:
616 - v = getattr(options, opt_name)
617 - opts[opt_name] = v
618 - return opts
619 -
620 -def run_command(args):
621 - opts = parse_args(sys.argv[1:])
622 -
623 - if opts["spawn_outfile"]:
624 - fd = os.dup(1)
625 - sys.stdout = os.fdopen(fd, 'w')
626 - fd = os.dup(2)
627 - sys.stderr = os.fdopen(fd, 'w')
628 - f = open_file(opts["spawn_outfile"])
629 - os.dup2(f.fileno(), 1)
630 - os.dup2(f.fileno(), 2)
631 - del fd, f
632 -
633 - console = ConsoleUpdate()
634 - if not opts["progress"] or not sys.stdout.isatty():
635 - console.quiet = True
636 - job = None
637 - import signal, thread, threading
638 - shutdown_initiated = threading.Event()
639 - shutdown_complete = threading.Event()
640 - def shutdown_console():
641 - console.acquire()
642 - try:
643 - console.update("Interrupted.")
644 - console.newLine()
645 - console.quiet = True
646 - shutdown_complete.set()
647 - # Kill the main thread if necessary.
648 - # This causes the SIGINT signal handler to be invoked in the
649 - # main thread. The signal handler needs to be an actual
650 - # callable object (rather than something like signal.SIG_DFL)
651 - # in order to avoid TypeError: 'int' object is not callable.
652 - thread.interrupt_main()
653 - thread.exit()
654 - finally:
655 - console.release()
656 -
657 - def handle_interrupt(*args):
658 - if shutdown_complete.isSet():
659 - sys.exit(1)
660 - # Lock the console from a new thread so that the main thread is allowed
661 - # to cleanly complete any console interaction that may have been in
662 - # progress when this interrupt arrived.
663 - if not shutdown_initiated.isSet():
664 - thread.start_new_thread(shutdown_console, ())
665 - shutdown_initiated.set()
666 -
667 - signal.signal(signal.SIGINT, handle_interrupt)
668 - signal.signal(signal.SIGTERM, handle_interrupt)
669 -
670 - try:
671 - import datetime
672 - datestamp = str(datetime.datetime.now())
673 - time_begin = time.time()
674 - log = create_log(name="MetadataGenerate",
675 - logfile=opts["logfile"], loglevel=int(opts["loglevel"]))
676 - if opts["reportfile"]:
677 - reportfile = open_file(opts["reportfile"])
678 - portdb = create_portdb(**opts)
679 - try:
680 - os.nice(int(portdb.mysettings.get("PORTAGE_NICENESS", "0")))
681 - except (OSError, ValueError), e:
682 - log.error("PORTAGE_NICENESS failed: '%s'" % str(e))
683 - del e
684 -
685 - job = ListPackages(portdb, log, shuffle=opts["shuffle"])
686 - console.update("Listing packages in repository...")
687 - job.run()
688 - cpv_all = job.cpv_all
689 - total_count = len(cpv_all)
690 - if opts["generate"]:
691 - job = MetadataGenerate(portdb, cpv_all, log)
692 - name = "Cache generation"
693 - complete_msg = "Metadata generation is complete."
694 - elif opts["transfer"]:
695 - job = MetadataTransfer(portdb, cpv_all, opts["forward"],
696 - opts["cleanse_on_transfer_failure"], log)
697 - if opts["forward"]:
698 - name = "Forward transfer"
699 - complete_msg = "Forward metadata transfer is complete."
700 - else:
701 - name = "Reverse transfer"
702 - complete_msg = "Reverse metadata transfer is complete."
703 - else:
704 - sys.stderr.write("required options: --generate || --transfer\n")
705 - sys.exit(os.EX_USAGE)
706 - job.opts = opts
707 -
708 - onProgress = None
709 - if not console.quiet:
710 - ui = ConsoleProgress(name=name, console=console)
711 - progressHandler = ProgressHandler()
712 - onProgress = progressHandler.onProgress
713 - def display():
714 - ui.displayProgress(progressHandler.curval, progressHandler.maxval)
715 - progressHandler.display = display
716 -
717 - job.run(onProgress=onProgress)
718 -
719 - if not console.quiet:
720 - # make sure the final progress is displayed
721 - progressHandler.display()
722 -
723 - update_count = None
724 - if opts["transfer"]:
725 - update_count = job.update_count
726 - target_cache = job.target_cache
727 - dead_nodes = job.dead_nodes
728 - cleanse_count = len(dead_nodes)
729 - console.update("Cleansing cache...")
730 - job = CacheCleanse(target_cache, dead_nodes, log)
731 - job.run()
732 - console.update(complete_msg)
733 - console.newLine()
734 - time_end = time.time()
735 - if opts["reportfile"]:
736 - width = 20
737 - reportfile.write(name.ljust(width) + "%s\n" % datestamp)
738 - reportfile.write("Elapsed seconds".ljust(width) + "%f\n" % (time_end - time_begin))
739 - reportfile.write("Total packages".ljust(width) + "%i\n" % total_count)
740 - if update_count is not None:
741 - reportfile.write("Updated packages".ljust(width) + "%i\n" % update_count)
742 - reportfile.write("Cleansed packages".ljust(width) + "%i\n" % cleanse_count)
743 - reportfile.write(("-"*50)+"\n")
744 - except Exception, e:
745 - if not is_interrupt(e):
746 - raise
747 - del e
748 - handle_interrupt()
749 - sys.exit(0)
750 -
751 -if __name__ == "__main__":
752 - run_command(sys.argv[1:])
753
754 diff --git a/scripts/run_catalyst b/scripts/run_catalyst
755 deleted file mode 100755
756 index 997f6520..00000000
757 --- a/scripts/run_catalyst
758 +++ /dev/null
759 @@ -1,2 +0,0 @@
760 -#!/bin/bash
761 -sudo /release/bin/sudo_catalyst "$@"
762
763 diff --git a/scripts/run_official b/scripts/run_official
764 deleted file mode 100755
765 index dfb29f25..00000000
766 --- a/scripts/run_official
767 +++ /dev/null
768 @@ -1,39 +0,0 @@
769 -#!/bin/bash
770 -
771 -email_from="auto"
772 -email_to="releng@g.o"
773 -url="https://poseidon.amd64.dev.gentoo.org/snapshots"
774 -snapshot_uri="/release/webroot/snapshots"
775 -svn_repo="/release/repos/snapshot-tree"
776 -
777 -send_email() {
778 - subject="[Snapshot] ${1}"
779 -
780 - echo -e "From: ${email_from}\r\nTo: ${email_to}\r\nSubject: ${subject}\r\n\r\nA new snapshot has been built from revision `svnlook history ${svn_repo} | head -n 3 | tail -n 1 | sed -e 's:^ *::' -e 's: .*$::'` of ${svn_repo}. You can find it at ${url}.\r\n\r\n$(cat /release/snapshots/portage-${1}.tar.bz2.DIGESTS)\r\n" | /usr/sbin/sendmail -f ${email_from} ${email_to}
781 -}
782 -
783 -if [ "${email_from}" == "auto" ]
784 -then
785 - username="$(whoami)"
786 - if [ "${username}" == "root" ]
787 - then
788 - email_from="catalyst@×××××××××××××××××××××××××.org"
789 - else
790 - email_from="${username}@gentoo.org"
791 - fi
792 -fi
793 -
794 -sudo /release/bin/sudo_official "$@" && \
795 -echo "Starting rsync from /release/snapshots/portage-${1}.tar.bz2* to ${snapshot_uri}" && \
796 -rsync --archive --stats --progress /release/snapshots/portage-${1}.tar.bz2* \
797 - ${snapshot_uri}
798 -ret=$?
799 -
800 -if [ "${email_from}" == "none" ]
801 -then
802 - echo "Skipping email step as configured..."
803 -else
804 - [ $ret -eq 0 ] && send_email ${1}
805 -fi
806 -
807 -exit $ret
808
809 diff --git a/scripts/run_snapshot b/scripts/run_snapshot
810 deleted file mode 100755
811 index 20cc4609..00000000
812 --- a/scripts/run_snapshot
813 +++ /dev/null
814 @@ -1,2 +0,0 @@
815 -#!/bin/bash
816 -sudo /release/bin/sudo_snapshot "$@"
817
818 diff --git a/scripts/stage_build.sh b/scripts/stage_build.sh
819 deleted file mode 100755
820 index 46902c1e..00000000
821 --- a/scripts/stage_build.sh
822 +++ /dev/null
823 @@ -1,162 +0,0 @@
824 -#!/bin/bash
825 -
826 -PID=$$
827 -
828 -profile=
829 -version_stamp=
830 -subarch=
831 -stage1_seed=
832 -snapshot=
833 -config=/etc/catalyst/catalyst.conf
834 -email_from="catalyst@localhost"
835 -email_to="root@localhost"
836 -verbose=0
837 -
838 -usage() {
839 - msg=$1
840 -
841 - if [ -n "${msg}" ]; then
842 - echo -e "${msg}\n";
843 - fi
844 -
845 - cat <<EOH
846 -Usage:
847 - stage_build [-p|--profile <profile>] [-v|--version-stamp <stamp>]
848 - [-a|--arch <arch>] [-s|--stage1-seed <seed>] [--verbose]
849 - [-f|--email-from <from>] [-t|--email-to <to>] [-h|--help]
850 -
851 -Options:
852 - -p|--profile Sets the portage profile (required)
853 - -v|--version-stamp Sets the version stamp (required)
854 - -a|--arch Sets the 'subarch' in the spec (required)
855 - -s|--stage1-seed Sets the seed for the stage1 (required)
856 - -S|--snapshot Sets the snapshot name (if not given defaults to today's
857 - date)
858 - -c|--config catalyst config to use, defaults to catalyst default
859 - --verbose Send output of commands to console as well as log
860 - -f|--email-from Sets the 'From' on emails sent from this script (defaults
861 - to catalyst@localhost)
862 - -t|--email-to Sets the 'To' on emails sent from this script (defaults
863 - to root@localhost)
864 - -h|--help Show this message and quit
865 -
866 -Example:
867 - stage_build -p default-linux/x86/2006.1 -v 2007.0_pre -a i686 -s default/stage3-i686-2006.1
868 -EOH
869 -}
870 -
871 -send_email() {
872 - subject="[${subarch}] $1"
873 - body=$2
874 -
875 - echo -e "From: ${email_from}\r\nTo: ${email_to}\r\nSubject: ${subject}\r\n\r\nArch: ${subarch}\r\nProfile: ${profile}\r\nVersion stamp: ${version_stamp}\r\nStage1 seed: ${stage1_seed}\r\nSnapshot: ${snapshot}\r\n\r\n${body}\r\n" | /usr/sbin/sendmail -f ${email_from} ${email_to}
876 -}
877 -
878 -run_cmd() {
879 - cmd=$1
880 - logfile=$2
881 -
882 - if [ $verbose = 1 ]; then
883 - ${cmd} 2>&1 | tee ${logfile}
884 - else
885 - ${cmd} &> ${logfile}
886 - fi
887 -}
888 -
889 -# Parse args
890 -params=${#}
891 -while [ ${#} -gt 0 ]
892 -do
893 - a=${1}
894 - shift
895 - case "${a}" in
896 - -h|--help)
897 - usage
898 - exit 0
899 - ;;
900 - -p|--profile)
901 - profile=$1
902 - shift
903 - ;;
904 - -v|--version-stamp)
905 - version_stamp=$1
906 - shift
907 - ;;
908 - -a|--arch)
909 - subarch=$1
910 - shift
911 - ;;
912 - -f|--email-from)
913 - email_from=$1
914 - shift
915 - ;;
916 - -t|--email-to)
917 - email_to=$1
918 - shift
919 - ;;
920 - -s|--stage1-seed)
921 - stage1_seed=$1
922 - shift
923 - ;;
924 - -S|--snapshot)
925 - snapshot=$1
926 - shift
927 - ;;
928 - -c|--config)
929 - config=$1
930 - shift
931 - ;;
932 - --verbose)
933 - verbose=1
934 - ;;
935 - -*)
936 - echo "You have specified an invalid option: ${a}"
937 - usage
938 - exit 1
939 - ;;
940 - esac
941 -done
942 -
943 -# Make sure all required values were specified
944 -if [ -z "${profile}" ]; then
945 - usage "You must specify a profile."
946 - exit 1
947 -fi
948 -if [ -z "${version_stamp}" ]; then
949 - usage "You must specify a version stamp."
950 - exit 1
951 -fi
952 -if [ -z "${subarch}" ]; then
953 - usage "You must specify an arch."
954 - exit 1
955 -fi
956 -if [ -z "${stage1_seed}" ]; then
957 - usage "You must specify a stage1 seed."
958 - exit 1
959 -fi
960 -cd /tmp
961 -
962 -if [ -z "${snapshot}" ]; then
963 - snapshot=`date +%Y%m%d`
964 - run_cmd "catalyst -c ${config} -s '${snapshot}'" "/tmp/catalyst_build_snapshot.${PID}.log"
965 - if [ $? != 0 ]; then
966 - send_email "Catalyst build error - snapshot" "$(</tmp/catalyst_build_snapshot.${PID}.log)"
967 - exit 1
968 - fi
969 -fi
970 -
971 -for i in 1 2 3; do
972 - echo -e "subarch: ${subarch}\ntarget: stage${i}\nversion_stamp: ${version_stamp}\nrel_type: default\nprofile: ${profile}\nsnapshot: ${snapshot}" > stage${i}.spec
973 - if [ ${i} = 1 ]; then
974 - echo "source_subpath: ${stage1_seed}" >> stage${i}.spec
975 - else
976 - echo "source_subpath: default/stage$(expr ${i} - 1)-${subarch}-${version_stamp}" >> stage${i}.spec
977 - fi
978 - run_cmd "catalyst -a -c ${config} -f stage${i}.spec" "/tmp/catalyst_build_stage${i}.${PID}.log"
979 - if [ $? != 0 ]; then
980 - send_email "Catalyst build error - stage${i}" "$(tail -n 200 /tmp/catalyst_build_stage${i}.${PID}.log)\r\n\r\nFull build log at /tmp/catalyst_build_stage${i}.${PID}.log"
981 - exit 1
982 - fi
983 -done
984 -
985 -send_email "Catalyst build success" "Everything finished successfully."
986
987 diff --git a/scripts/sudo_catalyst b/scripts/sudo_catalyst
988 deleted file mode 100755
989 index 19ecc90a..00000000
990 --- a/scripts/sudo_catalyst
991 +++ /dev/null
992 @@ -1,28 +0,0 @@
993 -#!/bin/bash
994 -
995 -usage() {
996 - echo "Usage: $(basename ${0}) <arch> <target> <spec>"
997 - echo "Where arch is either amd64 or x86, target is default, dev, hardened,"
998 - echo "or uclibc, and spec is your spec file."
999 - echo
1000 -}
1001 -
1002 -if [ -z "$1" -o -z "$2" -o -z "$3" ]
1003 -then
1004 - usage
1005 -else
1006 - target="$(grep target ${3} | cut -d' ' -f2)"
1007 - /usr/bin/catalyst -c /etc/catalyst/${1}-${2}.conf -f ${3} ${4} ${5}
1008 -# && \
1009 -# case ${target} in
1010 -# stage*|grp*|livecd-stage2)
1011 -# echo "Cleaning out ${target} temp files"
1012 -# rel_type="$(grep rel_type ${3} | cut -d' ' -f2)"
1013 -# subarch="$(grep subarch ${3} | cut -d' ' -f2)"
1014 -# version="$(grep version ${3} | cut -d' ' -f2)"
1015 -# storedir="$(grep storedir /etc/catalyst/${1}-${2}.conf | cut -d\" -f2)"
1016 -# echo "Removing ${storedir}/tmp/${rel_type}/${target}-${subarch}-${version}"
1017 -# rm -rf ${storedir}/tmp/${rel_type}/${target}-${subarch}-${version}
1018 -# ;;
1019 -# esac
1020 -fi
1021
1022 diff --git a/scripts/sudo_official b/scripts/sudo_official
1023 deleted file mode 100755
1024 index 80e7ca04..00000000
1025 --- a/scripts/sudo_official
1026 +++ /dev/null
1027 @@ -1,46 +0,0 @@
1028 -#!/bin/bash
1029 -
1030 -tree="/release/trees/snapshot-tree"
1031 -portdir="${tree}/${1/_beta2/}/portage"
1032 -cache_args="--portdir=${portdir} --cachedir=/release/tmp/depcache"
1033 -
1034 -usage() {
1035 - echo "Usage: $(basename ${0}) <version>"
1036 -}
1037 -
1038 -if [ -z "${1}" ]
1039 -then
1040 - usage
1041 -else
1042 - cd ${tree}
1043 - echo "Clearing out old metadata cache"
1044 - rm -rf ${portdir}/metadata/cache
1045 - echo "Performing a svn up on ${tree}"
1046 - svn up || exit 1
1047 - mkdir -p ${portdir}/metadata/cache
1048 - echo "Recreating portage metadata cache"
1049 - cache-tools.py ${cache_args} --generate || exit 1
1050 - cache-tools.py ${cache_args} --transfer --reverse \
1051 - --cleanse-on-transfer-failure || exit 1
1052 - if [ ! -d ${portdir}/metadata/cache/sys-kernel ]
1053 - then
1054 - echo "Metadata update failed! Bailing out!"
1055 - exit 1
1056 - fi
1057 - catalyst -c /etc/catalyst/snapshot-official.conf -s ${1} \
1058 - -C portdir="${portdir}" || exit 1
1059 - for i in amd64 x86
1060 - do
1061 - for j in default dev hardened uclibc
1062 - do
1063 - cd /release/buildroot/${i}-${j}/snapshots
1064 - rm -f portage-official.tar.bz2 portage-${1}.tar.bz2*
1065 - ln -sf /release/snapshots/portage-${1}.tar.bz2 \
1066 - portage-official.tar.bz2
1067 - ln -sf /release/snapshots/portage-${1}.tar.bz2 \
1068 - portage-${1}.tar.bz2
1069 - ln -sf /release/snapshots/portage-${1}.tar.bz2.DIGESTS \
1070 - portage-${1}.tar.bz2.DIGESTS
1071 - done
1072 - done
1073 -fi
1074
1075 diff --git a/scripts/sudo_snapshot b/scripts/sudo_snapshot
1076 deleted file mode 100755
1077 index 1ba64855..00000000
1078 --- a/scripts/sudo_snapshot
1079 +++ /dev/null
1080 @@ -1,20 +0,0 @@
1081 -#!/bin/bash
1082 -usage() {
1083 - echo "Usage: $(basename ${0}) <version>"
1084 -}
1085 -if [ -z "${1}" ]
1086 -then
1087 - usage
1088 -else
1089 - catalyst -c /etc/catalyst/snapshot.conf -s ${1}
1090 - for i in amd64 x86
1091 - do
1092 - for j in default dev hardened uclibc
1093 - do
1094 - cd /release/buildroot/${i}-${j}/snapshots
1095 - rm -f portage-${1}.tar.bz2
1096 - ln -sf /release/snapshots/portage-${1}.tar.bz2 \
1097 - portage-${1}.tar.bz2
1098 - done
1099 - done
1100 -fi
1101
1102 diff --git a/scripts/update_auto_tree b/scripts/update_auto_tree
1103 deleted file mode 100755
1104 index 029ef703..00000000
1105 --- a/scripts/update_auto_tree
1106 +++ /dev/null
1107 @@ -1,14 +0,0 @@
1108 -#!/bin/bash
1109 -PORTDIR="/release/trees/portage-auto/"
1110 -TMPREPO=$(mktemp)
1111 -trap "rm -f $TMPREPO" EXIT
1112 -cat >$TMPREPO <<EOF
1113 -[DEFAULT]
1114 -main-repo = gentoo
1115 -
1116 -[gentoo]
1117 -location = $PORTDIR
1118 -sync-type = rsync
1119 -sync-uri = rsync://rsync.gentoo.org/gentoo-portage
1120 -EOF
1121 -PORTAGE_REPOSITORIES="$(cat $TMPREPO)" FEATURES="$FEATURES -news" emerge --sync -q
1122
1123 diff --git a/scripts/update_official_tree b/scripts/update_official_tree
1124 deleted file mode 100755
1125 index 55ecea0b..00000000
1126 --- a/scripts/update_official_tree
1127 +++ /dev/null
1128 @@ -1,14 +0,0 @@
1129 -#!/bin/bash
1130 -PORTDIR="/release/trees/portage-official/"
1131 -TMPREPO=$(mktemp)
1132 -trap "rm -f $TMPREPO" EXIT
1133 -cat >$TMPREPO <<EOF
1134 -[DEFAULT]
1135 -main-repo = gentoo
1136 -
1137 -[gentoo]
1138 -location = $PORTDIR
1139 -sync-type = rsync
1140 -sync-uri = rsync://rsync.gentoo.org/gentoo-portage
1141 -EOF
1142 -PORTAGE_REPOSITORIES="$(cat $TMPREPO)" FEATURES="$FEATURES -news" emerge --sync -q
1143
1144 diff --git a/scripts/update_snapshot_tree b/scripts/update_snapshot_tree
1145 deleted file mode 100755
1146 index 76cd00ea..00000000
1147 --- a/scripts/update_snapshot_tree
1148 +++ /dev/null
1149 @@ -1,14 +0,0 @@
1150 -#!/bin/bash
1151 -PORTDIR="/release/trees/portage-snapshot/"
1152 -TMPREPO=$(mktemp)
1153 -trap "rm -f $TMPREPO" EXIT
1154 -cat >$TMPREPO <<EOF
1155 -[DEFAULT]
1156 -main-repo = gentoo
1157 -
1158 -[gentoo]
1159 -location = $PORTDIR
1160 -sync-type = rsync
1161 -sync-uri = rsync://rsync.gentoo.org/gentoo-portage
1162 -EOF
1163 -PORTAGE_REPOSITORIES="$(cat $TMPREPO)" FEATURES="$FEATURES -news" emerge --sync -q