From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.77) (envelope-from ) id 1SoHcG-0001DW-Ei for garchives@archives.gentoo.org; Mon, 09 Jul 2012 17:19:20 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 74F62E0330; Mon, 9 Jul 2012 17:19:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 365EAE0330 for ; Mon, 9 Jul 2012 17:19:03 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6AFF31B4005 for ; Mon, 9 Jul 2012 17:19:02 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 30D7AE5433 for ; Mon, 9 Jul 2012 17:19:01 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1341851208.2a93dae11e32165040f1e9af3dd2e49d647c0e05.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: / X-VCS-Repository: proj/R_overlay X-VCS-Files: README main.py roverlay.py X-VCS-Directories: / X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 2a93dae11e32165040f1e9af3dd2e49d647c0e05 X-VCS-Branch: master Date: Mon, 9 Jul 2012 17:19:01 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: f4558013-588b-479a-b996-9d40bb52ef33 X-Archives-Hash: dbcb343a251cca7e6edfacce8ed3b3b0 commit: 2a93dae11e32165040f1e9af3dd2e49d647c0e05 Author: Andr=C3=A9 Erdmann mailerd de> AuthorDate: Mon Jul 9 16:26:48 2012 +0000 Commit: Andr=C3=A9 Erdmann mailerd de> CommitDate: Mon Jul 9 16:26:48 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/R_overlay.git= ;a=3Dcommit;h=3D2a93dae1 move main.py -> roverlay.py modified: README typechange: main.py renamed: main.py -> roverlay.py --- README | 2 +- main.py | 242 +-----------------------------------------= ------ main.py =3D> roverlay.py | 0 3 files changed, 2 insertions(+), 242 deletions(-) diff --git a/README b/README index 542fa30..e9a9f6f 100644 --- a/README +++ b/README @@ -9,7 +9,7 @@ There is currently no "R overlay" script, only modules th= at implement functional =20 Real tests are scheduled for July 10 - July 30. =20 -A main script is available. See ./main.py --help for usage. +A main script is available. See ./roverlay.py --help for usage. =20 =20 =3D=3D Configuration =3D=3D diff --git a/main.py b/main.py deleted file mode 100755 index ce1189f..0000000 --- a/main.py +++ /dev/null @@ -1,241 +0,0 @@ -#!/usr/bin/env python - -import os -import sys - -# roverlay modules will be imported later - -HIDE_EXCEPTIONS =3D False - -class DIE ( object ): - NOP =3D os.EX_OK - ERR =3D 1 - BAD_USAGE =3D os.EX_USAGE - ARG =3D 9 - CONFIG =3D os.EX_CONFIG - OV_CREATE =3D 20 - SYNC =3D 30 - CMD_LEFTOVER =3D 90 - IMPORT =3D 91 - UNKNOWN =3D 95 - INTERRUPT =3D 130 - - @staticmethod - def die ( msg=3DNone, code=3DNone ): - code =3D DIE.ERR if code is None else code - if msg is not None: - sys.stderr.write ( msg + "\n" ) -# else: -# sys.stderr.write ( "died.\n" ) - sys.exit ( code ) - # --- end of die (...) --- - -# --- DIE: exit codes --- -die =3D DIE.die - - -if __name__ !=3D '__main__': - die ( "Please don't import this script...", DIE.BAD_USAGE ) - - -# get args -# imports roverlay.argutil (deleted when done) - - -try: - import roverlay.argutil -except ImportError: - if HIDE_EXCEPTIONS: - die ( "Cannot import roverlay modules!", DIE.IMPORT ) - else: - raise - -COMMAND_DESCRIPTION =3D { - 'sync' : 'sync repos', - 'create' : 'create the overlay ' - '(implies sync, override with --nosync)', -# 'depres_console' : 'run an interactive depres console; TODO/REMOVE', - 'nop' : 'does nothing', -} - -commands, config_file, additional_config, extra_opts =3D \ - roverlay.argutil.parse_argv ( - CMD_DESC=3DCOMMAND_DESCRIPTION, - DEFAULT_CONFIG=3D"R-overlay.conf" - ) - -OPTION =3D extra_opts.get - -del roverlay.argutil - -# -- load config - -# imports: roverlay, roverlay.config.entryutil (if --help-config) - -try: - import roverlay -except ImportError: - if HIDE_EXCEPTIONS: - die ( "Cannot import roverlay modules!", DIE.IMPORT ) - else: - raise - -try: - conf =3D roverlay.load_config_file ( - config_file, - extraconf=3Dadditional_config - ) - del config_file, additional_config -except: - if HIDE_EXCEPTIONS: - die ( "Cannot load config file {!r}.".format ( config_file ), DIE.CONF= IG ) - else: - raise - -if OPTION ( 'list_config' ): - try: - from roverlay.config.entryutil import list_entries - print ( "=3D=3D main config file =3D=3D\n" ) - print ( list_entries() ) - except: - raise - die ( "Cannot list config entries!" ) - - EXIT_AFTER_CONFIG =3D True - -if OPTION ( 'print_config' ): - try: - conf.visualize ( into=3Dsys.stdout ) - except: - die ( "Cannot print config!" ) - EXIT_AFTER_CONFIG =3D True - - -if 'EXIT_AFTER_CONFIG' in locals() and EXIT_AFTER_CONFIG: - sys.exit ( os.EX_OK ) - - -# -- determine commands to run -# (TODO) could replace this section when adding more actions -# imports roverlay.remote, roverlay.overlay.creator - -actions =3D set ( filter ( lambda x : x !=3D 'nop', commands ) ) - -if 'sync' in actions and OPTION ( 'nosync' ): - die ( "sync command blocked by --nosync opt.", DIE.ARG ) - -del commands - - -if not actions: - # this happens if a command is nop - die ( "Nothing to do!", DIE.NOP ) - - -# -- import roverlay modules - -try: - from roverlay.remote import RepoList - from roverlay.overlay.creator import OverlayCreator -except ImportError: - if HIDE_EXCEPTIONS: - die ( "Cannot import roverlay modules!", DIE.IMPORT ) - else: - raise - - - -# -- run methods (and some vars) -# imports: nothing - -actions_done =3D set() -set_action_done =3D actions_done.add - -def optionally ( call, option, *args, **kw ): - if OPTION ( option ): - return call ( *args, **kw ) -# --- end of optionally (...) --- - -#repo_list =3D None -#overlay =3D None -def run_sync(): - if "sync" in actions_done: return - try: - # set up the repo list - global repo_list - repo_list =3D RepoList ( - sync_enabled =3D not OPTION ( 'nosync' ), - force_distroot =3D OPTION ( 'force_distroot' ) - ) - - ## extra_opts->distdir ... TODO - if 'distdirs' in extra_opts: - repo_list.add_distdirs ( OPTION ( 'distdirs' ) ) - else: - # default repo list - repo_list.load() - - ## this runs _nosync() or _sync(), depending on extra_opts->nosync - repo_list.sync() - - set_action_done ( "sync" ) - - except KeyboardInterrupt: - die ( "Interrupted", DIE.INTERRUPT ) - except: - if HIDE_EXCEPTIONS: - die ( - "nosync() failed!" if OPTION ( "nosync" ) \ - else "sync() failed!", - DIE.SYNC - ) - else: - raise -# --- end of run_sync() --- - -def run_overlay_create(): - if "create" in actions_done: return - #run_sync() - try: - global overlay - overlay =3D OverlayCreator() - # explicitly allow overlay writing (FIXME: remove that in OverlayCreat= or) - overlay.can_write_overlay =3D OPTION ( 'write_overlay' ) - - repo_list.add_packages ( overlay.add_package ) - - overlay.run ( close_when_done=3DTrue ) - - optionally ( overlay.write_overlay, 'write_overlay' ) - optionally ( overlay.show_overlay, 'show_overlay' ) - if OPTION ( 'print_stats' ): print ( "\n" + overlay.stats_str() ) - - set_action_done ( "create" ) - - except KeyboardInterrupt: - die ( "Interrupted", DIE.INTERRUPT ) - except: - if HIDE_EXCEPTIONS: - die ( "Overlay creation failed.", DIE.OV_CREATE ) - else: - raise - finally: - if 'overlay' in locals() and not overlay.closed: - # This is important 'cause it unblocks remaining ebuild creation - # jobs/threads, specifically waiting EbuildJobChannels in depres. - # It also writes the deps_unresolved file - overlay.close() -# --- end of run_overlay_create() --- - -# -- run - -# always run sync 'cause commands =3D {create,sync} and create implies (= no)sync -run_sync() - -if 'create' in actions: run_overlay_create() - -if len ( actions ) > len ( actions_done ): - die ( - "Some actions (out of %r) could not be performed!" % actions, - DIE.CMD_LEFTOVER - ) diff --git a/main.py b/main.py new file mode 120000 index 0000000..34b2545 --- /dev/null +++ b/main.py @@ -0,0 +1 @@ +roverlay.py \ No newline at end of file diff --git a/main.py b/roverlay.py similarity index 100% copy from main.py copy to roverlay.py