summaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorMaxim Sobolev <sobomax@FreeBSD.org>2000-08-02 07:10:24 +0000
committerMaxim Sobolev <sobomax@FreeBSD.org>2000-08-02 07:10:24 +0000
commitc978a0f2980310f5335c99733c249b3426a64946 (patch)
tree36073773c097f1fb2f8a74e22e25a8b86a67a068 /Tools
parentAdd missing md5 for n-47-c for alpha. (diff)
Add gnomedepends.py to our collection of helpfull scripts.
gnomedepends is a script, which analyses pkg/PLIST and gives an advice as to which GNOME ports should be listes in {RUN,LIB}_DEPENDS for the port to ensure correct removal of GNOME shared directories.
Notes
Notes: svn path=/head/; revision=31244
Diffstat (limited to 'Tools')
-rw-r--r--Tools/scripts/README37
-rwxr-xr-xTools/scripts/gnomedepends.py128
2 files changed, 164 insertions, 1 deletions
diff --git a/Tools/scripts/README b/Tools/scripts/README
index 4568a371a8f0..9c276ea51298 100644
--- a/Tools/scripts/README
+++ b/Tools/scripts/README
@@ -13,6 +13,8 @@ distclean - compare md5 sums of distfiles in ports/distfiles with currently
getpr - downloads a problem report from GNATS and attempts to extract
the patch, shar, uuencoded file from it.
this probably needs to be checked for potential security problems.
+gnomedepends - Analyse pkg/PLIST and give an advice as to which GNOME ports
+ should be listes in {RUN,LIB}_DEPENDS for this port
prpatch - just does `patch $1 < pr-patch' (pr-patch is created by getpr)
prdone - checks in the port, attempting to fill out the commit message using
information from the problem report and then takes you into edit-pr
@@ -61,6 +63,39 @@ doesn't have associated md5 entry (most likely outdated distfiles).
----------------------------------------------------------------------
+gnomedepends is a script, which analyses pkg/PLIST and gives an advice as to
+which GNOME ports should be listes in {RUN,LIB}_DEPENDS for the port to ensure
+correct removal of GNOME shared directories. Usage is simple:
+ % cd /usr/ports/CATEGORY/PORT
+ % gnomedepends.py
+ According to the contents of PLIST the port depends on the following GNOME
+ port(s):
+
+ /usr/ports/audio/gnomeaudio, for directories:
+ share/gnome/sounds
+
+ /usr/ports/sysutils/gnomecontrolcenter, for directories:
+ share/gnome/apps
+
+ /usr/ports/x11/gnomecore, for directories:
+ share/gnome/apps/Games
+
+ /usr/ports/x11/gnomelibs, for directories:
+ etc/sound/events
+ etc/sound
+ share/gnome/games
+ share/gnome/pixmaps
+ share/gnome
+
+The example above means that you need to have ${PORTSDIR}/audio/gnomeaudio,
+${PORTSDIR}/sysutils/gnomecontrolcenter, ${PORTSDIR}/x11/gnomecore and
+${PORTSDIR}/x11/gnomelibs listed in {RUN,LIB}_DEPENDS for this port.
+Please be warned, that the this only means that the ports listed by the script
+required for correct removal of GNOME shared directories, not for the port
+functionality, so actual {RUN,LIB}_DEPENDS may have more entries.
+
+----------------------------------------------------------------------
+
NOTE: These scripts need work and are *NOT* safe to use unless you know
what they do. Use at your own risk. Patches would be great, but
- I'd prefer they pass through me.
+ it is prefered they pass through maintainer of each particular script.
diff --git a/Tools/scripts/gnomedepends.py b/Tools/scripts/gnomedepends.py
new file mode 100755
index 000000000000..f886df5ce3d6
--- /dev/null
+++ b/Tools/scripts/gnomedepends.py
@@ -0,0 +1,128 @@
+#!/usr/local/bin/python
+#
+# gnomedepends
+# Analyse pkg/PLIST and give an advice as to which GNOME
+# ports should be listes in {RUN,LIB}_DEPENDS for this port
+#
+# ----------------------------------------------------------------------------
+# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp):
+# Maxim Sobolev <sobomax@FreeBSD.org wrote this file. As long as you retain
+# this notice you can do whatever you want with this stuff. If we meet some
+# day, and you think this stuff is worth it, you can buy me a beer in return.
+#
+# Maxim Sobolev
+# ----------------------------------------------------------------------------
+#
+# $FreeBSD$
+#
+# MAINTAINER= sobomax@FreeBSD.org
+#
+# TODO:
+# - analyse actual {RUN,LIB}_DEPENDS and give an advice about what should be
+# added;
+# - analyse results and remove redundant dependencies (for example if gnomecore
+# has gnomecontrolcenter listed as dependency, and it is found that the port
+# requires both gnomecontrolcenter and gnomecore do not list
+# gnomecontrolcenter then);
+# - parse ports/INDEX directly.
+#
+
+import os, os.path, sys, string, re
+
+def getcmdout(cmdline):
+ results = []
+ pipe = os.popen(cmdline)
+ buffer = pipe.readlines()
+ for result in buffer:
+ result = string.strip(result)
+ if len(result) > 0:
+ results.append(result)
+ pipe.close()
+ return results
+
+def readfile(filename):
+ file = open(filename)
+ result = file.readlines()
+ file.close()
+ return result
+
+def filter(lines, regobj):
+ results = []
+ for line in lines:
+ match = regobj.match(line)
+ if match != None:
+ result = string.strip(match.group(1))
+ try:
+ tmp = results.index(result)
+ except ValueError:
+ results.append(result)
+ return results
+
+gnomeports = getcmdout('cd /usr/ports && make search key=gnome | grep ^Path:')
+newgnomeports = []
+for i in gnomeports:
+ newgnomeports.append(string.split(i)[1])
+gnomeports = newgnomeports
+newgnomeports = []
+
+regobj = re.compile('^@dirrm (?P<dirname>\S+).*$')
+for portdir in gnomeports:
+ try:
+ lines = readfile(os.path.join(portdir, 'pkg/PLIST'))
+ lines = filter(lines, regobj)
+ if len(lines) > 0:
+ newgnomeports.append([portdir, lines])
+ except IOError:
+ pass
+gnomeports = newgnomeports
+newgnomeports = []
+
+try:
+ currplist = readfile('pkg/PLIST')
+except IOError, errmsg:
+ print errmsg
+ sys.exit(1)
+
+regobj = re.compile('^(?!@)(?P<dirname>\S+)/.*')
+currdirs = filter(currplist, regobj)
+regobj = re.compile('^@dirrm (?P<dirname>\S+).*$')
+currdirs.extend(filter(currplist, regobj))
+currportdir = os.getcwd()
+
+newcurrdirs = []
+for dir in currdirs:
+ incremental = ''
+ for component in string.split(dir, '/'):
+ if incremental != '':
+ incremental = incremental + '/'
+ incremental = incremental + component
+ try:
+ tmp = newcurrdirs.index(incremental)
+ except ValueError:
+ newcurrdirs.append(incremental)
+currdirs = newcurrdirs
+
+depends = []
+for gnomeport in gnomeports:
+ if (currportdir == gnomeport[0]):
+ continue
+ matches = []
+ for gnomedir in gnomeport[1]:
+ for dir in currdirs:
+ if (gnomedir == dir):
+ matches.append(dir)
+ if len(matches) > 0:
+ depends.append([gnomeport[0], matches])
+
+if len(depends) == 0:
+ sys.stdout.writelines(['No dependencies found (maybe it is not a GNOME port).\n'])
+ sys.exit(0)
+
+sys.stdout.writelines(['According to the contents of PLIST the port depends on the following GNOME\n', 'port(s):\n\n'])
+for depend in depends:
+ sys.stdout.writelines([depend[0], ', for directories:\n'])
+ for dir in depend[1]:
+ sys.stdout.writelines(['\t', dir, '\n'])
+ sys.stdout.writelines(['\n'])
+
+