#!/bin/sh # sync a CVS-to-GIT mirror on sourceware.org # Take a package name and map that to the parameters needed to invoke # mirror-cvs-to-git. Then, push any changes from the temporary git # repository to the destination one. PATH=$HOME/bin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin export PATH ME=$(basename "$0") die() { echo >&2 "$ME: $@"; exit 1; } filter_stderr() { # Usage: filter-stderr EGREP_REGEXP 'command' regex=$1 cmd=$2 (exec 3>&1; eval "$cmd" 2>&1 >&3 | grep -E -v "$regex" 1>&2) } verbose= case $# in 0) ;; *) case $1 in --verbose) verbose=--verbose; shift;; esac;; esac binutils_exclude=' blt cgen contrib dejagnu expat expect gdb itcl iwidgets libdecnumber libgloss libgui mmalloc newlib proto-toplev rda readline sid sim tcl tix tk utils winsup ' gdb_exclude=' binutils blt cgen contrib dejagnu elfcpp expat expect gas gdb/gdbtk gold gprof itcl iwidgets ld libgloss libgui mmalloc newlib proto-toplev rda sid tcl tix tk utils winsup ' newlib_exclude=' bfd binutils blt cgen cpu dejagnu elfcpp expat expect gas gdb gold gprof include intl itcl iwidgets ld libdecnumber libgui libiberty mmalloc opcodes proto-toplev rda readline sid sim tcl tix tk utils winsup ' repo=$1 case $repo in gdb) exclude=$gdb_exclude # CAUTION: m= # Note how here, m is not set, yet it is for binutils and newlib. cvs_mod=src url=/cvs/src f=gdb/gdb-demangle.h,v g=/git/gdb.git;; binutils) exclude=$binutils_exclude m=binutils cvs_mod=src url=/cvs/src f=binutils/arlex.l,v g=/git/binutils.git;; cluster) cvs_mod=cluster url=/cvs/cluster f=gfs/gfs_mkfs/mkfs_gfs.h,v g=/git/cluster.git;; newlib) exclude=$newlib_exclude m=newlib cvs_mod=src url=/cvs/src f=newlib/testsuite/lib/newlib.exp,v g=/git/newlib.git;; automake) cvs_mod=automake url=/cvs/automake f=lib/Automake/RuleDef.pm,v g=/git/automake.git;; dm|device-mapper) cvs_mod=device-mapper url=/cvs/dm f=dmsetup/dmsetup.c,v g=/git/dm.git ;; lvm|lvm2) cvs_mod=LVM2 url=/cvs/lvm2 f=tools/lvm.c,v g=/git/lvm2.git ;; libc) cvs_mod=libc url=sourceware.org::glibc-cvs f=manual/libc.texinfo,v g=/git/glibc.git ;; glibc-ports) cvs_mod=ports url=sourceware.org::glibc-cvs f=bare/brdinit.c,v g=/git/glibc-ports.git ;; *) die "Usage: $ME package_name" ;; esac exclude=$(printf %s "$exclude"|tr '\012' ' '|sed 's/ $//') test -z "$m" && m=$cvs_mod tmp_repo=$HOME/mirror-git-to-cvs/repo/$m mirror_cmd="mirror-cvs-to-git \ $verbose \ --exclude='$exclude' \ --rsync-url=$url \ --module=$cvs_mod \ --git-dir=$tmp_repo \ --state-dir=$HOME/mirror-git-to-cvs/.state/$m \ --key-file=$f \ --user-map=$HOME/mirror-git-to-cvs/git-user-map/$m" mirror_re=$(printf %s ' no patchset for tag raeburn |Skipping #CVSPS_NO_BRANCH |branch #CVSPS_NO_BRANCH not found |\* UNKNOWN LINE \* Branches: |revision .* is tagged but not present ' |tr -d '\012') filter_stderr "$mirror_re" "$mirror_cmd" # Push unconditionally. Otherwise, at least the initial # run fails to push. # case $? in # 0) exit 0 ;; # nothing rsync'd, no push required # 1) ;; # fall through # *) exit 1 ;; # esac push_re=$(printf %s ' Everything up-to-date |^To /git/\S+\.git$ |^ \x{7}\.\.\x{7} \S+ -> \S+$ |^updating .refs/heads/master.$ |^Branch \S+ already exists\.$ |^Removing duplicate objects:.*done\.$ |^Delta compression using up to 4 threads\.$ |^Generating pack\.\.\.$ |^Done counting \d+ objects\.$ |^Deltifying \d+ objects\.\.\.$ |^Total \d+ \(delta \d+\), |^refs/heads/master: \x{40} -> \x{40}$ |^ +\d+% \(1/\d+\) done |^ from \x{40}$ |^ to \x{40}$ |((Compress|Count|Writ)ing objects:) ' |tr -d '\012' \ |sed 's/\\S/[^[:space:]]/g;s/\\d/[0-9]/g;s/\\x/[[:xdigit:]]/g') case $repo in libc|glibc-ports) spec='refs/heads/*:refs/heads/cvs/*';; *) spec='refs/heads/*:refs/heads/*';; esac push_cmd="GIT_DIR=$tmp_repo/.git git push --force --tags $g +'$spec'" # Push to the public git repo. filter_stderr "$push_re" "$push_cmd" exit 0