diff options
Diffstat (limited to 'misc/portell/files/patch-aa')
-rw-r--r-- | misc/portell/files/patch-aa | 184 |
1 files changed, 143 insertions, 41 deletions
diff --git a/misc/portell/files/patch-aa b/misc/portell/files/patch-aa index cb19eaa06143..c090face2380 100644 --- a/misc/portell/files/patch-aa +++ b/misc/portell/files/patch-aa @@ -1,49 +1,151 @@ ---- portell.py.orig Mon Oct 22 07:18:32 2001 -+++ portell.py Mon Aug 4 16:34:27 2003 -@@ -11,8 +11,10 @@ - - try: - PORTELL_DB = os.environ['PORTELL_PATH'] +--- portell.py.orig Mon Aug 11 15:23:47 2003 ++++ portell.py Mon Aug 11 15:34:56 2003 +@@ -1,70 +1,78 @@ +-#! /usr/bin/env python
+-# portell.py
+-# Description: prints a port's descr-file from whatever directory you're in.
+-# Author: Ryan "gt3" Kulla
+-# Email: ambiod@sbcglobal.net
+-# Version: 0.1
+-# Usage: portell.py <portname>
+-
+-import sys, os, shelve
+-from string import join
+-
+-try:
+- PORTELL_DB = os.environ['PORTELL_PATH']
+-except KeyError:
+- PORTELL_DB = "/var/db/portell.db"
+-
+-PORTS_DIR = "/usr/ports/"
+-
+-def write_pathname(d, dirname, names):
+- dirname = join(dirname.split('/')[:5], '/') # chop port path subdirs
+- d[os.path.basename(dirname)] = dirname
+-
+-def update_db():
+- if os.access(PORTELL_DB, os.F_OK):
+- os.unlink(PORTELL_DB)
+- try:
+- d = shelve.open(PORTELL_DB)
+- os.chmod(PORTELL_DB, 0666)
+- except:
+- print "can't read or write %s. are you root?" % PORTELL_DB
+- sys.exit(0)
+- os.path.walk(PORTS_DIR, write_pathname, d)
+- d.close()
+-
+-def main():
+- if len(sys.argv) != 2:
+- print "usage: %s <portname>" % sys.argv[0]
+- sys.exit(0)
+-
+- if sys.argv[1] == '-u':
+- update_db()
+- sys.exit(0)
+- else:
+- portname = sys.argv[1]
+-
+- if not os.access(PORTELL_DB, os.F_OK):
+- print >> sys.stderr, "you need to create %s first." % PORTELL_DB
+- print >> sys.stderr, "type: %s -u" % sys.argv[0]
+- sys.exit(0)
+-
+- d = shelve.open(PORTELL_DB)
+-
+- if d.has_key(portname):
+- descr_path = d[portname] + "/pkg-descr"
+- match = descr_path
+- try:
+- descr_file = open(match, 'r').readlines()
+- print "%s reads:\n" % descr_path
+- for line in descr_file:
+- print line,
+- except IOError, errmsg:
+- print errmsg
+- else:
+- print >> sys.stderr, "can't find %s" % portname
+-
+- d.close()
+-
+-
+-if __name__=='__main__':
+- main()
++#! /usr/bin/env python ++# portell.py ++# Description: prints a port's descr-file from whatever directory you're in. ++# Author: Ryan "gt3" Kulla ++# Email: ambiod@sbcglobal.net ++# Version: 0.1 ++# Usage: portell.py <portname> ++ ++import sys, os, shelve ++from string import join ++ ++try: ++ PORTELL_DB = os.environ['PORTELL_PATH'] ++ if sys.version[:3] == '2.2': ++ PORTELL_DB = PORTELL_DB + ".db" ++ + PORTELL_DB_FILE = PORTELL_DB + ".db" - except KeyError: -- PORTELL_DB = "/var/db/portell.db" -+ PORTELL_DB = "/var/db/portell" ++except KeyError: ++ if sys.version[:3] == '2.2': ++ PORTELL_DB = "/var/db/portell.db" ++ else: ++ PORTELL_DB = "/var/db/portell" + PORTELL_DB_FILE = "/var/db/portell.db" - - PORTS_DIR = "/usr/ports/" - -@@ -23,13 +25,13 @@ - - - def update_db(): -- if os.access(PORTELL_DB, os.F_OK): -- os.unlink(PORTELL_DB) ++ ++PORTS_DIR = "/usr/ports/" ++ ++def write_pathname(d, dirname, names): ++ dirname = join(dirname.split('/')[:5], '/') # chop port path subdirs ++ d[os.path.basename(dirname)] = dirname ++ ++def update_db(): + if os.access(PORTELL_DB_FILE, os.F_OK): + os.unlink(PORTELL_DB_FILE) - try: -- d = shelve.open(PORTELL_DB) -- os.chmod(PORTELL_DB, 0666) -+ d = shelve.open(PORTELL_DB_FILE) ++ try: ++ d = shelve.open(PORTELL_DB) + os.chmod(PORTELL_DB_FILE, 0666) - except: -- print "can't read or write %s. are you root?" % PORTELL_DB ++ except: + print "can't read or write %s. are you root?" % PORTELL_DB_FILE - sys.exit(0) - os.path.walk(PORTS_DIR, write_pathname, d) - d.close() -@@ -46,12 +48,12 @@ - else: - portname = sys.argv[1] - -- if not os.access(PORTELL_DB, os.F_OK): -- print >> sys.stderr, "you need to create %s first." % PORTELL_DB ++ sys.exit(0) ++ os.path.walk(PORTS_DIR, write_pathname, d) ++ d.close() ++ ++def main(): ++ if len(sys.argv) != 2: ++ print "usage: %s <portname>" % sys.argv[0] ++ sys.exit(0) ++ ++ if sys.argv[1] == '-u': ++ update_db() ++ sys.exit(0) ++ else: ++ portname = sys.argv[1] ++ + if not os.access(PORTELL_DB_FILE, os.F_OK): + print >> sys.stderr, "you need to create %s first." % PORTELL_DB_FILE - print >> sys.stderr, "type: %s -u" % sys.argv[0] - sys.exit(0) - -- d = shelve.open(PORTELL_DB) -+ d = shelve.open(PORTELL_DB_FILE) - - if d.has_key(portname): - descr_path = d[portname] + "/pkg-descr" ++ print >> sys.stderr, "type: %s -u" % sys.argv[0] ++ sys.exit(0) ++ ++ d = shelve.open(PORTELL_DB) ++ ++ if d.has_key(portname): ++ descr_path = d[portname] + "/pkg-descr" ++ match = descr_path ++ try: ++ descr_file = open(match, 'r').readlines() ++ print "%s reads:\n" % descr_path ++ for line in descr_file: ++ print line, ++ except IOError, errmsg: ++ print errmsg ++ else: ++ print >> sys.stderr, "can't find %s" % portname ++ ++ d.close() ++ ++ ++if __name__=='__main__': ++ main() |