aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2009-04-30 21:52:45 +0000
committerfuzzyray <fuzzyray@gentoo.org>2009-04-30 21:52:45 +0000
commit86eaf5e03289e45a95514b4f6011157972016e9d (patch)
treec16903693f2030c7b01b346b29b265dc1a473888 /src/gensync
parentFix has_key() deprecation message. (Bug #232797) (diff)
downloadgentoolkit-0.2.4.tar.gz
gentoolkit-0.2.4.tar.bz2
gentoolkit-0.2.4.zip
Tagging the gentoolkit-0.2.4 releasegentoolkit-0.2.4
svn path=/tags/gentoolkit-0.2.4/; revision=564
Diffstat (limited to 'src/gensync')
-rw-r--r--src/gensync/AUTHORS5
-rw-r--r--src/gensync/ChangeLog12
-rw-r--r--src/gensync/Makefile24
-rw-r--r--src/gensync/README16
-rw-r--r--src/gensync/TODO4
-rw-r--r--src/gensync/bmg-gnome-current.syncsource18
-rw-r--r--src/gensync/bmg-main.syncsource18
-rwxr-xr-xsrc/gensync/gensync226
-rw-r--r--src/gensync/gensync.175
-rw-r--r--src/gensync/gensync.conf8
10 files changed, 406 insertions, 0 deletions
diff --git a/src/gensync/AUTHORS b/src/gensync/AUTHORS
new file mode 100644
index 0000000..389c51b
--- /dev/null
+++ b/src/gensync/AUTHORS
@@ -0,0 +1,5 @@
+Maintainer:
+Karl Trygve Kalleberg <karltk@gentoo.org>
+
+Original Author:
+Matthew Schick <matt@breakmygentoo.net>
diff --git a/src/gensync/ChangeLog b/src/gensync/ChangeLog
new file mode 100644
index 0000000..7ec2b86
--- /dev/null
+++ b/src/gensync/ChangeLog
@@ -0,0 +1,12 @@
+2004-09-10 Karl Trygve Kalleberg <karltk@gentoo.org>
+ * Fixed portage import, fixes #45079.
+ * Added all sources sync patch from Adam Ashley
+ <adam_ashley@softhome.net>, fixes #45079.
+ * Fixed config dir scanning, suggested by burrelln@colorado.edu,
+ fixes #47390.
+ * Applied config file parser fix by Mamoru KOMACHI <usata@gentoo.org>,
+ fixes #44777.
+
+2004-02-08 Karl Trygve Kalleberg <karltk@gentoo.org>
+ * Initial import
+
diff --git a/src/gensync/Makefile b/src/gensync/Makefile
new file mode 100644
index 0000000..d5b879a
--- /dev/null
+++ b/src/gensync/Makefile
@@ -0,0 +1,24 @@
+# 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 -d $(docdir)/deprecated/gensync
+ install -m 0755 gensync $(docdir)/deprecated/gensync/
+ install -m 0644 AUTHORS README TODO ChangeLog $(docdir)/deprecated/gensync/
+ install -m 0644 gensync.1 $(docdir)/deprecated/gensync/
+ install -m 0644 gensync.conf bmg-main.syncsource bmg-gnome-current.syncsource $(docdir)/deprecated/gensync/
diff --git a/src/gensync/README b/src/gensync/README
new file mode 100644
index 0000000..cf54dec
--- /dev/null
+++ b/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/src/gensync/TODO b/src/gensync/TODO
new file mode 100644
index 0000000..733a959
--- /dev/null
+++ b/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/src/gensync/bmg-gnome-current.syncsource b/src/gensync/bmg-gnome-current.syncsource
new file mode 100644
index 0000000..51dd908
--- /dev/null
+++ b/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/src/gensync/bmg-main.syncsource b/src/gensync/bmg-main.syncsource
new file mode 100644
index 0000000..8d74ca2
--- /dev/null
+++ b/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/src/gensync/gensync b/src/gensync/gensync
new file mode 100755
index 0000000..52f25ed
--- /dev/null
+++ b/src/gensync/gensync
@@ -0,0 +1,226 @@
+#!/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 sys
+import os
+import fileinput
+
+sys.path.insert(0, "/usr/lib/portage/pym")
+import portage
+
+try:
+ from portage.output import *
+except ImportError:
+ 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('=')
+ attrib = attrib.strip().strip('"')
+ 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("=")
+ attrib = attrib.strip().strip('"')
+ 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 and \
+ x.endswith(".syncsource"):
+ 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 get_all_sync_sources(self):
+ return self.sources
+
+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(" -a, --all-sources") + " - sync all know sources"
+ 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"
+ elif x in ["-a", "--all-sources"]:
+ cmd = "all-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()
+ elif cmd == "all-sources":
+ for repo in ssmgr.get_all_sync_sources():
+ 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/src/gensync/gensync.1 b/src/gensync/gensync.1
new file mode 100644
index 0000000..17d85fc
--- /dev/null
+++ b/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/src/gensync/gensync.conf b/src/gensync/gensync.conf
new file mode 100644
index 0000000..389e020
--- /dev/null
+++ b/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