From: "Nirbheek Chauhan" <nirbheek@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gnome:master commit in: scripts/
Date: Sat, 12 Mar 2011 20:10:41 +0000 (UTC) [thread overview]
Message-ID: <9047508d670f1be0481b9e4b8c133b96214fb54c.nirbheek@gentoo> (raw)
commit: 9047508d670f1be0481b9e4b8c133b96214fb54c
Author: Nirbheek Chauhan <nirbheek <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 12 20:07:50 2011 +0000
Commit: Nirbheek Chauhan <nirbheek <AT> gentoo <DOT> org>
CommitDate: Sat Mar 12 20:10:31 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gnome.git;a=commit;h=9047508d
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=4 sw=4 et tw=0 :
+#
+# Author(s): Nirbheek Chauhan <nirbheek@gentoo.org>
+# 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 <base|good|bad|ugly> <version> [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 = sys.argv[1]
+GSTLIBVER = sys.argv[2]
+GSTCOREVER = ''
+GSTBASEVER = ''
+if len(sys.argv) == 5:
+ GSTCOREVER = sys.argv[3]
+ GSTBASEVER = sys.argv[4]
+elif len(sys.argv) == 4:
+ GSTCOREVER = sys.argv[3]
+
+##################
+## Parse Config ##
+##################
+PORTDIR = portage.settings["PORTDIR"]
+portage.portdb.porttrees = [PORTDIR]
+GSTPREFIX = 'gst-plugins-'
+GSTECLASS = GSTPREFIX + GSTLIB
+GSTLIB = 'media-libs/' + GSTPREFIX + GSTLIB
+GSTPLUGIN_CPVS = []
+GSTCAT = 'media-plugins'
+GSTLIBS = {'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 = portage.pkgsplit(cpv)[-2:]
+ if pv[1] == '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=None):
+ if not ver:
+ return portage.catsplit(cpv)[-1]
+ else:
+ return get_p(cpv) + '-' + ver
+
+def get_cpv(cp, ver=None):
+ 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 = ''
+ 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 = '%s-[-0-9._rpe]\+' % dep
+ new_dep = '%s-%s' % (dep, GSTLIBS[dep])
+ # We need a space at the end for further appending
+ sed_cmd += '-e "s|%s|%s|g" ' % (old_dep, new_dep)
+ if not sed_cmd:
+ # Nothing to do...
+ return
+ # In-place edit
+ sed_cmd = 'sed %s -i %s' % (sed_cmd, ebuild)
+ subprocess.check_call(sed_cmd, shell=True)
+
+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].split():
+ return False
+ return True
+
+################
+## Begin Work ##
+################
+
+print_colorize("green", "Getting a list of all gst-plugins ...")
+for cp in portage.portdb.cp_all(categories=[GSTCAT]):
+ cpv = 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 = get_ebuild(cpv)
+ new_ebuild = get_ebuild(get_cpv(cp, GSTLIBVER))
+ print_colorize("green", "Copying %s to %s ..." % (old_ebuild, new_ebuild))
+ 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=True, stdout=subprocess.PIPE)
+ try:
+ subprocess.check_call('diff -u %s %s' % (old_ebuild, new_ebuild), shell=True)
+ 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 == 2:
+ raise e
+ subprocess.check_call('ebuild %s manifest' % new_ebuild, shell=True)
+ print_colorize("green", "Running cvs add ...")
+ subprocess.check_call('cvs add %s' % new_ebuild, shell=True)
next reply other threads:[~2011-03-12 20:10 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-12 20:10 Nirbheek Chauhan [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-04-03 19:42 [gentoo-commits] proj/gnome:master commit in: scripts/ Matt Turner
2020-04-03 19:42 Matt Turner
2020-03-28 8:31 Mart Raudsepp
2020-03-10 22:05 Matt Turner
2019-02-07 11:58 Mart Raudsepp
2018-04-25 10:32 Mart Raudsepp
2018-01-10 3:25 Mart Raudsepp
2012-04-01 21:14 Nirbheek Chauhan
2012-04-01 19:12 Nirbheek Chauhan
2011-08-18 6:23 Nirbheek Chauhan
2011-07-12 21:15 Nirbheek Chauhan
2011-05-21 18:38 Nirbheek Chauhan
2011-05-19 12:35 Gilles Dartiguelongue
2011-04-13 9:57 Nirbheek Chauhan
2011-04-09 6:29 Nirbheek Chauhan
2011-03-28 16:15 Nirbheek Chauhan
2011-03-28 15:04 Nirbheek Chauhan
2011-03-26 1:58 Nirbheek Chauhan
2011-03-23 21:59 Nirbheek Chauhan
2011-03-23 21:59 Nirbheek Chauhan
2011-03-23 21:59 Nirbheek Chauhan
2011-03-23 19:21 Gilles Dartiguelongue
2011-03-23 10:39 Gilles Dartiguelongue
2011-03-20 8:11 Nirbheek Chauhan
2011-03-18 9:59 Nirbheek Chauhan
2011-03-18 8:23 Nirbheek Chauhan
2011-03-17 17:12 Nirbheek Chauhan
2011-03-15 13:08 Nirbheek Chauhan
2011-03-14 18:41 Nirbheek Chauhan
2011-03-04 15:40 Nirbheek Chauhan
2011-02-18 4:40 Nirbheek Chauhan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9047508d670f1be0481b9e4b8c133b96214fb54c.nirbheek@gentoo \
--to=nirbheek@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox