diff options
| author | karltk <karltk@gentoo.org> | 2004-02-27 10:17:14 +0000 |
|---|---|---|
| committer | karltk <karltk@gentoo.org> | 2004-02-27 10:17:14 +0000 |
| commit | 95490bd11fabf4a616c72c41c14a93a4bbb60181 (patch) | |
| tree | 59bd02ff7cd77eae6551b2cce42bb071a2f66e56 /trunk/src/gensync | |
| parent | bae7b3e9549d5c4fd55e93bc318d776908733ab7 (diff) | |
| download | gentoolkit-95490bd11fabf4a616c72c41c14a93a4bbb60181.tar.gz | |
Late commit...
svn path=/; revision=88
Diffstat (limited to 'trunk/src/gensync')
| -rw-r--r-- | trunk/src/gensync/AUTHORS | 5 | ||||
| -rw-r--r-- | trunk/src/gensync/ChangeLog | 2 | ||||
| -rw-r--r-- | trunk/src/gensync/Makefile | 25 | ||||
| -rw-r--r-- | trunk/src/gensync/README | 16 | ||||
| -rw-r--r-- | trunk/src/gensync/TODO | 4 | ||||
| -rw-r--r-- | trunk/src/gensync/bmg-gnome-current.syncsource | 18 | ||||
| -rw-r--r-- | trunk/src/gensync/bmg-main.syncsource | 18 | ||||
| -rwxr-xr-x | trunk/src/gensync/gensync | 207 | ||||
| -rw-r--r-- | trunk/src/gensync/gensync.1 | 75 | ||||
| -rw-r--r-- | trunk/src/gensync/gensync.conf | 8 |
10 files changed, 378 insertions, 0 deletions
diff --git a/trunk/src/gensync/AUTHORS b/trunk/src/gensync/AUTHORS new file mode 100644 index 0000000..389c51b --- /dev/null +++ b/trunk/src/gensync/AUTHORS @@ -0,0 +1,5 @@ +Maintainer: +Karl Trygve Kalleberg <karltk@gentoo.org> + +Original Author: +Matthew Schick <matt@breakmygentoo.net> diff --git a/trunk/src/gensync/ChangeLog b/trunk/src/gensync/ChangeLog new file mode 100644 index 0000000..8343792 --- /dev/null +++ b/trunk/src/gensync/ChangeLog @@ -0,0 +1,2 @@ +2004-02-08 Karl Trygve Kalleberg <karltk@gentoo.org> + * Initial import diff --git a/trunk/src/gensync/Makefile b/trunk/src/gensync/Makefile new file mode 100644 index 0000000..6462b1e --- /dev/null +++ b/trunk/src/gensync/Makefile @@ -0,0 +1,25 @@ +# Copyright 2004 Karl Trygve Kalleberg <karltk@gentoo.org> +# Copyright 2004 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# +# $Header$ + +include ../../makedefs.mak + +.PHONY: all +all: + +dist: + mkdir -p ../../$(distdir)/src/gensync/ + cp Makefile AUTHORS README TODO ChangeLog \ + gensync gensync.1 gensync.conf \ + bmg-main.syncsource bmg-gnome-current.syncsource \ + ../../$(distdir)/src/gensync/ + +install: all + install -m 0755 gensync $(bindir)/ + install -d $(docdir)/gensync + install -m 0644 {AUTHORS,README,TODO,ChangeLog} $(docdir)/gensync/ + install -m 0644 gensync.1 $(mandir)/ + install -d $(DESTDIR)/etc/gensync + install -m 0644 gensync.conf {bmg-main,bmg-gnome-current}.syncsource $(DESTDIR)/etc/gensync/ diff --git a/trunk/src/gensync/README b/trunk/src/gensync/README new file mode 100644 index 0000000..cf54dec --- /dev/null +++ b/trunk/src/gensync/README @@ -0,0 +1,16 @@ + +Package : gensync +Version : 0.1.0 +Author : See AUTHORS + +MOTIVATION + +Gensync handles rsyncing to multiple sync sources. + +MECHANICS + +N/A + +IMPROVEMENTS + +N/A diff --git a/trunk/src/gensync/TODO b/trunk/src/gensync/TODO new file mode 100644 index 0000000..733a959 --- /dev/null +++ b/trunk/src/gensync/TODO @@ -0,0 +1,4 @@ +- Add using cvs to sync +- Update portage cache after sync +- Add overlay dirs defined in /etc/conf.d/gensync to /etc/make.conf +- Sync up with Marius on the multiple overlay code diff --git a/trunk/src/gensync/bmg-gnome-current.syncsource b/trunk/src/gensync/bmg-gnome-current.syncsource new file mode 100644 index 0000000..51dd908 --- /dev/null +++ b/trunk/src/gensync/bmg-gnome-current.syncsource @@ -0,0 +1,18 @@ + +# This id must be unique among all the ids in /etc/gensync/*.syncsource +id="bmg-gnome-current" + +# This is a human-readable description of the source +description="BreakMyGentoo GNOME current" + +# The rsync url +rsync="rsync://rsync.breakmygentoo.net/gnome-current" + +# By default, the overlay directory is set to ${base_overlay}/${id}, +# where base_overlay is picked from /etc/gensync/gensync.conf +# +# You may specify a different relative path, such as +overlay="bmg-gnome-current.alternative" +# +# Or an entirely new absolute path (remeber to create the path first) +#overlay="/my/absolute/path" diff --git a/trunk/src/gensync/bmg-main.syncsource b/trunk/src/gensync/bmg-main.syncsource new file mode 100644 index 0000000..8d74ca2 --- /dev/null +++ b/trunk/src/gensync/bmg-main.syncsource @@ -0,0 +1,18 @@ + +# This id must be unique among all the ids in /etc/gensync/*.syncsource +id="bmg-main" + +# This is a human-readable description of the source +description="BreakMyGentoo main tree" + +# The rsync url +rsync="rsync://rsync.breakmygentoo.net/bmg-overlay" + +# By default, the overlay directory is set to ${base_overlay}/${id}, +# where base_overlay is picked from /etc/gensync/gensync.conf +# +# You may specify a different relative path, such as +overlay="bmg-main.alternative" +# +# Or an entirely new absolute path (remeber to create the path first) +#overlay="/my/absolute/path" diff --git a/trunk/src/gensync/gensync b/trunk/src/gensync/gensync new file mode 100755 index 0000000..99c696b --- /dev/null +++ b/trunk/src/gensync/gensync @@ -0,0 +1,207 @@ +#!/usr/bin/python +# +# Simple program to rsync from various 3rd party ebuild servers. +# +# +# Copyright (c) 2004, Matthew Schick <matt@breakmygentoo.net> (original author) +# Copyright (c) 2004, Gentoo Technologies, Inc +# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> +# +# Distributed under the terms of the GNU General Public License v2 + +__author__ = "Matt Schick <matt@breakmygentoo.net>, Karl Trygve Kalleberg <karltk@gentoo.org>" +__email__ = "karltk@gentoo.org" +__version__ = "0.1.0" +__productname__ = "gensync" +__description__ = "Gentoo Overlay Sync Tool" + + +import fileinput +import portage +import sys +import os +from output import * + +class ConfigDefaults: + def __init__(self): + self.rsync_timeout = 0 + self.base_overlay = "/usr/local/overlays" + self.confdir = '/etc/gensync' + self._init_from_file() + self._setup_rsync() + def _init_from_file(self): + try: + ins = open("/etc/gensync/gensync.conf") + for x in ins.readlines(): + # Skip line if it's a comment or not well-formed + if x.find("=") == -1 or \ + (len(x) and x[0] == "#"): + continue + (attrib, value) = x.split() + value = value.strip().strip('"') + if attrib == "rsync_timeout": + self.rsync_timeout = value + elif attrib == "base_overlay": + self.base_overlay = value + except: + pass + + def _setup_rsync(self): + if self.rsync_timeout == 0: + try: + self.rsync_timeout = portage.settings["RSYNC_TIMEOUT"] + except: + self.rsync_timeout = 180 + self.rsync_command = "/usr/bin/rsync " + \ + "-rlptDvz --progress " + \ + "--delete --delete-after " + \ + "--timeout=" + str(self.rsync_timeout) + " " \ + "--exclude='distfiles/*' " + \ + "--exclude='local/*' " + \ + "--exclude='packages/*' " + +Config = ConfigDefaults() + +class SyncSource: + """Contains all details about an upstream rsync source.""" + def __init__(self,filename): + self.id = "#unset#" + self.name = "#unset#" + self.url = "#unset#" + self.overlay = "#unset#" + self._init_from_file(filename) + + if self.overlay == "#unset#": + self.overlay = Config.base_overlay + "/" + self.id + elif len(self.overlay) and self.overlay[0] != "/": + self.overlay = Config.base_overlay + "/" + self.overlay + elif len(self.overlay) and self.overlay[0] == "/": + pass + else: + print "Malformed overlay, '" + self.overlay + "'" + sys.exit(-2) + + def _init_from_file(self, filename): + """Loads configuration settings from a .syncsource file.""" + ins = open(filename) + for x in ins.readlines(): + # Skip line if it's a comment or not well-formed + if x.find("=") == -1 or \ + (len(x) and x[0] == "#"): + continue + attrib,value = x.split("=") + value = value.strip().strip('"') + if attrib == "id": + self.id = value + elif attrib == "description": + self.name = value + elif attrib == "rsync": + self.url = value + elif attrib == "overlay": + self.overlay = value + def perform_sync(self): + """Syncs with upstream source.""" + cmd = Config.rsync_command + self.url +"/* " + self.overlay + exitcode = portage.spawn(cmd, portage.settings, free=1) + + def dump(self,ous=sys.stdout): + ous.write("id =\"%s\"\n" % (self.id) + \ + "name =\"%s\"\n" % (self.name) + \ + "rsync =\"%s\"\n" % (self.url) + \ + "overlay=\"%s\"\n\n" % (self.overlay)) + +class SyncSourceManager: + """Holds information on all known upstream rsync sources.""" + def __init__(self): + self.sources = [] + self._load_source_info() + def _load_source_info(self): + for x in os.listdir(Config.confdir): + if x.rfind(".syncsource") > 0: + ss = SyncSource(Config.confdir + "/" + x) + self.sources.append(ss) + def list_sources(self): + for x in self.sources: + x.dump() + def get_sync_source(self, source_id): + for x in self.sources: + if x.id == source_id: + return x + return None + +def print_version(): + print __productname__ + "(" + __version__ + ") - " + \ + __description__ + print "Author(s): " + __author__ + +def print_usage(): + print white("Usage: ") + turquoise(__productname__) + \ + yellow(" <options> ") + green("repo-id-1 repo-id-2 ...") + print "where " + yellow("<options>") + " is one of" + print yellow(" -l, --list-sources") + " - list known rsync sources" + print yellow(" -C, --no-color") + " - turn off colours" + print yellow(" -h, --help") + " - this help screen" + print yellow(" -V, --version") + " - display version info" + + +def parse_args(cliargs): + + cmd = "sync-sources" + args = [] + options = [] + + for x in cliargs: + if x in ["-V", "--version"]: + cmd = "print-version" + break + elif x in ["-h", "--help"]: + cmd = "print-usage" + break + elif x in ["-C", "--no-color"]: + options.append("nocolor") + break + elif x in ["-l", "--list-sources"]: + cmd = "list-sources" + else: + args.append(x) + return (cmd, args, options) + +def main(): + + # Setup colors, as per system defaults + if (not sys.stdout.isatty()) or \ + (portage.settings["NOCOLOR"] in ["yes","true"]): + nocolor() + + # Parse arguments + (cmd, args, options) = parse_args(sys.argv[1:]) + + # Turn off color, if specified by cmdline switch + if "nocolor" in options: + nocolor() + + # Initialise sync source manager + ssmgr = SyncSourceManager() + + # Perform selected command + if cmd == "list-sources": + ssmgr.list_sources() + elif cmd == "print-version": + print_version() + elif cmd == "print-usage": + print_usage() + elif cmd == "sync-sources": + for x in args: + repo = ssmgr.get_sync_source(x) + if repo: + print "Syncing '%s' into '%s'" % \ + (repo.id, repo.overlay) + repo.perform_sync() + else: + print red("Unknown command '" + cmd + "'") + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + print "Operation aborted by user keypress!" diff --git a/trunk/src/gensync/gensync.1 b/trunk/src/gensync/gensync.1 new file mode 100644 index 0000000..17d85fc --- /dev/null +++ b/trunk/src/gensync/gensync.1 @@ -0,0 +1,75 @@ +.TH gensync 1 "0.1.0" "Gentoolkit" "Gentoo Administration" +.SH "NAME" +.LP +gensync \- Gentoo: Overlay Sync Tool +.SH "SYNTAX" +.LP +gensync [\fIoption\fP] <\fIrepo-id-1 repo-id-2 ...\fP> + +.SH "DESCRIPTION" + +.LP + +\fIgensync\fR synchronises your machine against an upstream repository +of ebuild files, called a sync source. Normally, Portage will only +synchronise against the main Portage tree maintained by the Gentoo +project. However, there exist development trees with auxiliary ebuild +files that may occasionally be of interest to the adventurous power +user, such as the \fIbreakmygentoo.net\fR sync source. + +This tool can be used to synchronise against these alternative sync +sources. + +.SH "OPTIONS" +.LP +\fB\-l\fR +.br +\fB--list-sources\fB +.IP +List available sync sources known to \fIgensync\fR. + +.LP +\fB\-V\fR +.br +\fB--version\fB +.IP +Display version information and exit. + +.LP +\fB\-C\fR +.br +\fB--no-color\fB +.IP +Turn off colors. + +.LP +\fB\-h\fR +.br +\fB\--help\fR +.IP +Display help. + +.SH "CONFIGURATION FILES" +.LP +\fB/etc/gensync/gensync.conf\fR +.IP +The main configuration file, commented and self-explanatory + +.LP +\fB/etc/gensync/*.syncsource\fR +.IP +Per-sync source configuration files, describing the sync source to +\fIgensync\fR. + + +.SH "SEE ALSO" +.LP +The rest of the utilities in \fIapp-portage/gentoolkit-dev\fR, such as +\fIechangelog\fR, \fIebump\fR and \fIego\fR. + +.SH "AUTHORS" +.LP +Matthew Schick <matt@breakmygentoo.net> (original author) +.br +Karl Trygve Kalleberg <karltk@gentoo.org> + diff --git a/trunk/src/gensync/gensync.conf b/trunk/src/gensync/gensync.conf new file mode 100644 index 0000000..389e020 --- /dev/null +++ b/trunk/src/gensync/gensync.conf @@ -0,0 +1,8 @@ + +# By default, we ask Portage about the preferred timeout +#rsync_timeout = 180 + +# Normally, each sync source will be placed under +# ${base_overlay}/${syncsource-id}, where the 'syncsource-id' is a unique +# identifier, specified inside the individual .syncsource file +base_overlay = /usr/local/overlays |
