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.60) (envelope-from ) id 1PyV9G-0007wp-JO for garchives@archives.gentoo.org; Sat, 12 Mar 2011 20:10:50 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ECF28E05B9; Sat, 12 Mar 2011 20:10:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id ADC6EE05B9 for ; Sat, 12 Mar 2011 20:10:42 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id ECF871B4010 for ; Sat, 12 Mar 2011 20:10:41 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 3D9998006A for ; Sat, 12 Mar 2011 20:10:41 +0000 (UTC) From: "Nirbheek Chauhan" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Nirbheek Chauhan" Message-ID: <9047508d670f1be0481b9e4b8c133b96214fb54c.nirbheek@gentoo> Subject: [gentoo-commits] proj/gnome:master commit in: scripts/ X-VCS-Repository: proj/gnome X-VCS-Files: scripts/gst-plugins-bump.py X-VCS-Directories: scripts/ X-VCS-Committer: nirbheek X-VCS-Committer-Name: Nirbheek Chauhan X-VCS-Revision: 9047508d670f1be0481b9e4b8c133b96214fb54c Date: Sat, 12 Mar 2011 20:10:41 +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: X-Archives-Hash: 16cd2550fb977c6c3b8b76f1eb0ef33e commit: 9047508d670f1be0481b9e4b8c133b96214fb54c Author: Nirbheek Chauhan gentoo org> AuthorDate: Sat Mar 12 20:07:50 2011 +0000 Commit: Nirbheek Chauhan gentoo org> CommitDate: Sat Mar 12 20:10:31 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gnome.git;a=3D= commit;h=3D9047508d scripts/gst-plugins-bump.py: add a script to bump gst-plugins-* packages * Automatic removal script coming soon --- scripts/gst-plugins-bump.py | 157 +++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 157 insertions(+), 0 deletions(-) diff --git a/scripts/gst-plugins-bump.py b/scripts/gst-plugins-bump.py new file mode 100755 index 0000000..998f536 --- /dev/null +++ b/scripts/gst-plugins-bump.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python2 +# vim: set sts=3D4 sw=3D4 et tw=3D0 : +# +# Author(s): Nirbheek Chauhan +# License: MIT +# +# Bump gstreamer plugins to the version specified +# You must have your cvs directory as PORTDIR +# + +import os +import shutil +import subprocess +import sys + +import portage +from portage.output import colorize + +def usage(): + print "Usage: $0 [core version] [base= version]" + print "" + print " If core/base version is unspecified or blank, it's assumed = to be the same" + +if len(sys.argv) < 3 or len(sys.argv) > 5: + usage() + sys.exit(1) + +################### +## Configuration ## +################### +GSTLIB =3D sys.argv[1] +GSTLIBVER =3D sys.argv[2] +GSTCOREVER =3D '' +GSTBASEVER =3D '' +if len(sys.argv) =3D=3D 5: + GSTCOREVER =3D sys.argv[3] + GSTBASEVER =3D sys.argv[4] +elif len(sys.argv) =3D=3D 4: + GSTCOREVER =3D sys.argv[3] + +################## +## Parse Config ## +################## +PORTDIR =3D portage.settings["PORTDIR"] +portage.portdb.porttrees =3D [PORTDIR] +GSTPREFIX =3D 'gst-plugins-' +GSTECLASS =3D GSTPREFIX + GSTLIB +GSTLIB =3D 'media-libs/' + GSTPREFIX + GSTLIB +GSTPLUGIN_CPVS =3D [] +GSTCAT =3D 'media-plugins' +GSTLIBS =3D {'media-libs/gstreamer': GSTCOREVER, + 'media-libs/gst-plugins-base': GSTBASEVER, + GSTLIB: GSTLIBVER,} + +############### +## Functions ## +############### +def print_colorize(color, text): + print colorize(color, " * ") + text + +def get_p(pkg): + "pkg must contain at least the package name" + if not portage.isjustname(pkg): + return portage.catpkgsplit(pkg)[1] + return portage.catsplit(pkg)[-1] + +def get_v(cpv): + "cpv can be anything" + if portage.isjustname(cpv): + raise Exception('Input (%s) has no version!' % cpv) + pv =3D portage.pkgsplit(cpv)[-2:] + if pv[1] =3D=3D 'r0': + return pv[0] + else: + return '%s-%s' % (pv[0], pv[1]) + +def get_cp(cpv): + "cpv must contain package and category" + return portage.pkgsplit(cpv)[0] + +def get_pv(cpv, ver=3DNone): + if not ver: + return portage.catsplit(cpv)[-1] + else: + return get_p(cpv) + '-' + ver + +def get_cpv(cp, ver=3DNone): + if ver: + return '%s-%s' % (cp, ver) + else: + # Return the latest one instead + return portage.portdb.xmatch('match-all', cp)[-1] + +def get_ebuild_dir(cpv): + return os.path.join(PORTDIR, get_cp(cpv)) + +def get_ebuild(cpv): + return os.path.join(get_pv(cpv)+'.ebuild') + +def edit_gstdeps(ebuild): + # Editing files is hard, let's just use sed + sed_cmd =3D '' + for dep in GSTLIBS.keys(): + # Ignore if wanted-version is empty + if not GSTLIBS[dep]: + continue + # FIXME: This is an approximate regexp for matching versions + old_dep =3D '%s-[-0-9._rpe]\+' % dep + new_dep =3D '%s-%s' % (dep, GSTLIBS[dep]) + # We need a space at the end for further appending + sed_cmd +=3D '-e "s|%s|%s|g" ' % (old_dep, new_dep) + if not sed_cmd: + # Nothing to do... + return + # In-place edit + sed_cmd =3D 'sed %s -i %s' % (sed_cmd, ebuild) + subprocess.check_call(sed_cmd, shell=3DTrue) + +def isgstplugin(cpv): + if not cpv.startswith('%s/%s' % (GSTCAT, GSTPREFIX)): + return False + # Does it inherit GSTECLASS? + if not GSTECLASS in portage.portdb.aux_get(cpv, ['INHERITED'])[0].sp= lit(): + return False + return True + +################ +## Begin Work ## +################ + +print_colorize("green", "Getting a list of all gst-plugins ...") +for cp in portage.portdb.cp_all(categories=3D[GSTCAT]): + cpv =3D get_cpv(cp) + if not isgstplugin(cpv): + continue + print_colorize("green", "Current package is %s" % cpv) + GSTPLUGIN_CPVS.append(cpv) + os.chdir(get_ebuild_dir(cpv)) + old_ebuild =3D get_ebuild(cpv) + new_ebuild =3D get_ebuild(get_cpv(cp, GSTLIBVER)) + print_colorize("green", "Copying %s to %s ..." % (old_ebuild, new_eb= uild)) + shutil.copyfile(old_ebuild, new_ebuild) + print_colorize("green", "Editing gstreamer deps and keywords. A diff= will follow ...") + edit_gstdeps(new_ebuild) + subprocess.check_call('ekeyword ~all %s' % new_ebuild, shell=3DTrue,= stdout=3Dsubprocess.PIPE) + try: + subprocess.check_call('diff -u %s %s' % (old_ebuild, new_ebuild)= , shell=3DTrue) + except subprocess.CalledProcessError as e: + # diff returns: + # 0 if files don't differ + # 1 if they differ + # 2 if something went wrong + if e.returncode =3D=3D 2: + raise e + subprocess.check_call('ebuild %s manifest' % new_ebuild, shell=3DTru= e) + print_colorize("green", "Running cvs add ...") + subprocess.check_call('cvs add %s' % new_ebuild, shell=3DTrue)