diff options
author | André Erdmann <dywi@mailerd.de> | 2013-09-11 15:37:23 +0200 |
---|---|---|
committer | André Erdmann <dywi@mailerd.de> | 2013-09-11 16:05:51 +0200 |
commit | dbd1695aa7a7ae169c8f266c2e655d85aded936d (patch) | |
tree | 3a7b4d096cf651c1a27d5164c994faa4fc35b5ef /bin | |
parent | add copyright note to roverlay/setupscript/*.py (diff) | |
download | R_overlay-dbd1695aa7a7ae169c8f266c2e655d85aded936d.tar.gz R_overlay-dbd1695aa7a7ae169c8f266c2e655d85aded936d.tar.bz2 R_overlay-dbd1695aa7a7ae169c8f266c2e655d85aded936d.zip |
move debug-scripts/, roverlay.py to bin/
The scripts in roverlay's repo (debug-scripts,scripts,"eggsecutables") are going
to be merged in bin/.
Additionally, this allows to call not-installed roverlay from roverlay, because
roverlay.py->bin/roverlay is now a wrapper script.
Diffstat (limited to 'bin')
l--------- | bin/debug/console | 1 | ||||
l--------- | bin/debug/descreader | 1 | ||||
l--------- | bin/debug/nosync-rforge | 1 | ||||
l--------- | bin/debug/print_config | 1 | ||||
l--------- | bin/debug/read_ebuild | 1 | ||||
-rwxr-xr-x | bin/invoke_pyscript.bash | 21 | ||||
-rw-r--r-- | bin/py/console.py | 48 | ||||
-rw-r--r-- | bin/py/descreader.py | 40 | ||||
-rwxr-xr-x | bin/py/main.py | 11 | ||||
-rw-r--r-- | bin/py/nosync-rforge.py | 70 | ||||
-rw-r--r-- | bin/py/print_config.py | 35 | ||||
-rw-r--r-- | bin/py/read_ebuild.py | 14 | ||||
-rwxr-xr-x | bin/py/roverlay-setup.py | 11 | ||||
-rwxr-xr-x | bin/py/roverlay-sh.py | 11 | ||||
-rwxr-xr-x | bin/py/roverlay-status.py | 6 | ||||
-rwxr-xr-x | bin/roverlay | 23 | ||||
l--------- | bin/roverlay-setup | 1 | ||||
l--------- | bin/roverlay-sh | 1 | ||||
-rwxr-xr-x | bin/roverlay-status | 21 |
19 files changed, 318 insertions, 0 deletions
diff --git a/bin/debug/console b/bin/debug/console new file mode 120000 index 0000000..c1f16ac --- /dev/null +++ b/bin/debug/console @@ -0,0 +1 @@ +../invoke_pyscript.bash
\ No newline at end of file diff --git a/bin/debug/descreader b/bin/debug/descreader new file mode 120000 index 0000000..c1f16ac --- /dev/null +++ b/bin/debug/descreader @@ -0,0 +1 @@ +../invoke_pyscript.bash
\ No newline at end of file diff --git a/bin/debug/nosync-rforge b/bin/debug/nosync-rforge new file mode 120000 index 0000000..c1f16ac --- /dev/null +++ b/bin/debug/nosync-rforge @@ -0,0 +1 @@ +../invoke_pyscript.bash
\ No newline at end of file diff --git a/bin/debug/print_config b/bin/debug/print_config new file mode 120000 index 0000000..c1f16ac --- /dev/null +++ b/bin/debug/print_config @@ -0,0 +1 @@ +../invoke_pyscript.bash
\ No newline at end of file diff --git a/bin/debug/read_ebuild b/bin/debug/read_ebuild new file mode 120000 index 0000000..c1f16ac --- /dev/null +++ b/bin/debug/read_ebuild @@ -0,0 +1 @@ +../invoke_pyscript.bash
\ No newline at end of file diff --git a/bin/invoke_pyscript.bash b/bin/invoke_pyscript.bash new file mode 100755 index 0000000..2ad5828 --- /dev/null +++ b/bin/invoke_pyscript.bash @@ -0,0 +1,21 @@ +#!/bin/bash +readonly SCRIPT=$(readlink -f "${BASH_SOURCE[0]?}") +readonly SCRIPT_NAME="${BASH_SOURCE[0]##*/}" +readonly SCRIPT_DIR="${SCRIPT%/*}" + +readonly PRJROOT="${SCRIPT_DIR%/*}" +readonly PYSCRIPT="${SCRIPT_DIR}/py/${SCRIPT_NAME%.*}.py" + +export PYTHONPATH="${PRJROOT}${PYTHONPATH:+:}${PYTHONPATH}" + + +cd "${PRJROOT}" || exit + +if [[ -x "${PYSCRIPT}" ]]; then + exec ${PYSCRIPT} "$@" +elif [[ -f "${PYSCRIPT}" ]]; then + exec ${PYTHON:-python} ${PYSCRIPT} "$@" +else + echo "script not found: ${PYSCRIPT}" 1>&2 + exit 9 +fi diff --git a/bin/py/console.py b/bin/py/console.py new file mode 100644 index 0000000..e91b075 --- /dev/null +++ b/bin/py/console.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +# +# runs roverlay consoles +# + +import argparse + +import roverlay.core +import roverlay.console.depres +import roverlay.console.remote + +CON_MAP = { + 'depres': roverlay.console.depres.DepresConsole, + 'remote': roverlay.console.remote.RemoteConsole, +} + +parser = argparse.ArgumentParser ( + description = "run roverlay consoles", +) + +parser.add_argument ( + 'mode', choices=frozenset ( CON_MAP ), nargs="?", + default='depres', help="select console type [%(default)s]", +) + +parser.add_argument ( + '--config', '-C', metavar='<file>', dest='config_file', + default=roverlay.core.locate_config_file ( False ), + help="config file [%(default)s]", +) + +parser.add_argument ( + '--log-all', default=False, action='store_true', + help="log everything to console", +) + +def main(): + arg_config = parser.parse_args() + con_cls = CON_MAP [arg_config.mode] + + if arg_config.log_all: + roverlay.core.force_console_logging() + + with con_cls ( config_file=arg_config.config_file )as con: + con.run_forever() + +if __name__ == '__main__': + main() diff --git a/bin/py/descreader.py b/bin/py/descreader.py new file mode 100644 index 0000000..2f1a3e9 --- /dev/null +++ b/bin/py/descreader.py @@ -0,0 +1,40 @@ +#!/usr/bin/python +# Usage: descreader [desc_file...] +# +from __future__ import print_function + +import sys + +import roverlay.core +import roverlay.rpackage.descriptionreader + + +def setup(): + roverlay.core.force_console_logging() + + config_file = roverlay.core.locate_config_file ( False ) + return roverlay.core.load_config_file ( + config_file, setup_logger=False, + extraconf={ + 'installed': False, + 'DESCRIPTION': { 'descfiles_dir': None, } + }, + ) + +# --- end of setup (...) --- + + +def main(): + D = roverlay.rpackage.descriptionreader.DescriptionReader + config = setup() + + for desc in D.parse_files ( *sys.argv[1:] ): + print ( desc ) + + +# --- end of main (...) --- + + +if __name__ == '__main__': + main() + diff --git a/bin/py/main.py b/bin/py/main.py new file mode 100755 index 0000000..a17ff80 --- /dev/null +++ b/bin/py/main.py @@ -0,0 +1,11 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# R overlay -- main script +# Copyright (C) 2012, 2013 André Erdmann <dywi@mailerd.de> +# Distributed under the terms of the GNU General Public License; +# either version 2 of the License, or (at your option) any later version. + +import roverlay.defaultscript + +if __name__ == '__main__': + roverlay.defaultscript.main ( False ) diff --git a/bin/py/nosync-rforge.py b/bin/py/nosync-rforge.py new file mode 100644 index 0000000..04bd5b5 --- /dev/null +++ b/bin/py/nosync-rforge.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# +# runs --no-sync for the R-Forge repo (or first cmdline arg) +# +# Usage: <prog> [<repo name> [<repo config file>]] +# + +import sys +import logging + +## initialize interface (main and remote) +import roverlay.core +import roverlay.interface.main + + +def main(): + ## repo to (no)sync + get_arg = lambda i, UNSET: sys.argv[i] if len ( sys.argv ) > i else UNSET + + REPO_IN_QUESTION = get_arg ( 1, None ) or 'R-Forge' + REPO_CONFIG = get_arg ( 2, None ) + + + ## log everything to console + roverlay.core.force_console_logging() + + MAIN_IF = roverlay.interface.main.MainInterface ( + config_file=roverlay.core.locate_config_file ( False ) + ) + + + REPO_IF = MAIN_IF.spawn_interface ( "remote" ) + if REPO_CONFIG: + REPO_IF.load_repo_file ( REPO_CONFIG ) + else: + REPO_IF.load_configured() + + REPO_IF.disable_sync() + + + ## sync repo and report status + REPO_IF.sync_named_repo ( REPO_IN_QUESTION, enable_sync=False ) + + repo = REPO_IF.get_repo_by_name ( REPO_IN_QUESTION ) + if repo is not None: + repo_status = repo.sync_status + repo_ready = repo.ready() + + print ( "--- snip ---" ) + print ( "repo: " + str ( repo ) ) + if not repo_ready: + print ( "{n} would be ignored!".format ( n=REPO_IN_QUESTION ) ) + print ( + "{n}.ready() = {r} (sync_status={s:d})".format ( + n=REPO_IN_QUESTION, r=repo_ready, s=repo_status, + ) + ) + + else: + print ( "no such repo: " + REPO_IN_QUESTION ) + + + ### switch to python console + #import code + #con = code.InteractiveConsole ( locals=locals() ) + #con.interact() +# --- end of main (...) --- + +if __name__ == '__main__': + main() diff --git a/bin/py/print_config.py b/bin/py/print_config.py new file mode 100644 index 0000000..19ed5dd --- /dev/null +++ b/bin/py/print_config.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +# Usage: print-config +# +from __future__ import print_function + +import sys + +import roverlay.core + + +def setup(): + roverlay.core.force_console_logging() + + config_file = roverlay.core.locate_config_file ( False ) + return roverlay.core.load_config_file ( + config_file, setup_logger=False, + extraconf={ + 'installed': False, + 'DESCRIPTION': { 'descfiles_dir': None, } + }, + ) + +# --- end of setup (...) --- + + +def main(): + config = setup() + sys.stdout.write ( config.visualize() ) + sys.stdout.flush() +# --- end of main (...) --- + + +if __name__ == '__main__': + main() + diff --git a/bin/py/read_ebuild.py b/bin/py/read_ebuild.py new file mode 100644 index 0000000..a279ebb --- /dev/null +++ b/bin/py/read_ebuild.py @@ -0,0 +1,14 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from __future__ import print_function + +import sys + +import roverlay.util.ebuildparser + +if __name__ == '__main__': + EP = roverlay.util.ebuildparser.SrcUriParser + for arg in sys.argv[1:]: + parser = EP.from_file ( arg ) + print ( [ str(k) for k in parser.iter_local_files(True) ] ) diff --git a/bin/py/roverlay-setup.py b/bin/py/roverlay-setup.py new file mode 100755 index 0000000..276bab9 --- /dev/null +++ b/bin/py/roverlay-setup.py @@ -0,0 +1,11 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# R overlay -- main script +# Copyright (C) 2013 André Erdmann <dywi@mailerd.de> +# Distributed under the terms of the GNU General Public License; +# either version 2 of the License, or (at your option) any later version. + +import roverlay.setupscript.runtime + +if __name__ == '__main__': + roverlay.setupscript.runtime.setup_main ( False ) diff --git a/bin/py/roverlay-sh.py b/bin/py/roverlay-sh.py new file mode 100755 index 0000000..0db2bc7 --- /dev/null +++ b/bin/py/roverlay-sh.py @@ -0,0 +1,11 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# R overlay -- main script +# Copyright (C) 2012, 2013 André Erdmann <dywi@mailerd.de> +# Distributed under the terms of the GNU General Public License; +# either version 2 of the License, or (at your option) any later version. + +import roverlay.defaultscript + +if __name__ == '__main__': + roverlay.defaultscript.run_shell_main ( False ) diff --git a/bin/py/roverlay-status.py b/bin/py/roverlay-status.py new file mode 100755 index 0000000..f49df1d --- /dev/null +++ b/bin/py/roverlay-status.py @@ -0,0 +1,6 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import roverlay.status + +if __name__ == '__main__': + roverlay.status.main ( False ) diff --git a/bin/roverlay b/bin/roverlay new file mode 100755 index 0000000..9368599 --- /dev/null +++ b/bin/roverlay @@ -0,0 +1,23 @@ +#!/bin/bash +# similar to invoke_pyscript.bash, but uses a fixed SCRIPT_NAME +# +readonly SCRIPT=$(readlink -f "${BASH_SOURCE[0]?}") +readonly SCRIPT_NAME="main" +readonly SCRIPT_DIR="${SCRIPT%/*}" + +readonly PRJROOT="${SCRIPT_DIR%/*}" +readonly PYSCRIPT="${SCRIPT_DIR}/py/${SCRIPT_NAME%.*}.py" + +export PYTHONPATH="${PRJROOT}${PYTHONPATH:+:}${PYTHONPATH}" + + +cd "${PRJROOT}" || exit + +if [[ -x "${PYSCRIPT}" ]]; then + exec ${PYSCRIPT} "$@" +elif [[ -f "${PYSCRIPT}" ]]; then + exec ${PYTHON:-python} ${PYSCRIPT} "$@" +else + echo "script not found: ${PYSCRIPT}" 1>&2 + exit 9 +fi diff --git a/bin/roverlay-setup b/bin/roverlay-setup new file mode 120000 index 0000000..3f5df48 --- /dev/null +++ b/bin/roverlay-setup @@ -0,0 +1 @@ +invoke_pyscript.bash
\ No newline at end of file diff --git a/bin/roverlay-sh b/bin/roverlay-sh new file mode 120000 index 0000000..3f5df48 --- /dev/null +++ b/bin/roverlay-sh @@ -0,0 +1 @@ +invoke_pyscript.bash
\ No newline at end of file diff --git a/bin/roverlay-status b/bin/roverlay-status new file mode 100755 index 0000000..2ad5828 --- /dev/null +++ b/bin/roverlay-status @@ -0,0 +1,21 @@ +#!/bin/bash +readonly SCRIPT=$(readlink -f "${BASH_SOURCE[0]?}") +readonly SCRIPT_NAME="${BASH_SOURCE[0]##*/}" +readonly SCRIPT_DIR="${SCRIPT%/*}" + +readonly PRJROOT="${SCRIPT_DIR%/*}" +readonly PYSCRIPT="${SCRIPT_DIR}/py/${SCRIPT_NAME%.*}.py" + +export PYTHONPATH="${PRJROOT}${PYTHONPATH:+:}${PYTHONPATH}" + + +cd "${PRJROOT}" || exit + +if [[ -x "${PYSCRIPT}" ]]; then + exec ${PYSCRIPT} "$@" +elif [[ -f "${PYSCRIPT}" ]]; then + exec ${PYTHON:-python} ${PYSCRIPT} "$@" +else + echo "script not found: ${PYSCRIPT}" 1>&2 + exit 9 +fi |