Commits

Martin Tournoij committed 5154e31

Update for python 3 compat

  • Participants
  • Parent commits 0b2c376
  • Tags version_1.2

Comments (0)

Files changed (3)

+Make a pkg-plist for a FreeBSD port. Try to be as "automatic" as possible. 
+
+That's all it does ;-) 
+
+You can find it at the FreeBSD ports collection at ports-mgmt/pkg-plist
+
+Basic usage
+-----------
+1. Make your port, build it with `PREFIX` set to `/var/tmp/ptest` or another
+   empty directory of your choice
+2. cd to your port's directory (e.g. `/usr/ports/cat/port` or `~/myport`)
+3. Run this
 #!/usr/bin/env python
+# vim:ts=2:sts=2:sw=2:noexpandtab:fileencoding=utf-8:
 #
 # plist.py:
 # Make a pkg-plist file for a FreeBSD port, with as little (or none!) manual
 # intervention as possible.
 #
-# Martin Tournoij <martin@arp242.net>
-# http://code.google.com/p/pkg-plist/
+# Copyright © 2006-2012 Martin Tournoij <martin@arp242.net>
+# For detailed copyright, see the end of this file
 #
-# You are free to use, modify, and distribute as you see fit. There are no
-# restrictions.
+# http://code.arp242.net/pkg-plist/
 #
 
 import getopt
 import subprocess
 import sys
 
-
 def Usage():
-	print "pkg-plist 1.1 by Martin Tournoij <martin@arp242.net>"
-	print "http://code.google.com/p/pkg-plist/"
-	print ""
-	print "Usage: %s [-hdn] [-p portdir] [-x prefix]" % sys.argv[0]
-	print ""
-	print "  -h, --help\t\tPrint this help message and exit"
-	print "  -x, --prefix\t\tTemporary prefix to use (Default: /var/tmp/ptest)"
-	print "  -p, --portdir\t\tPort directory (Default: current directory)"
-	print "  -d, --noportdocs\tDo not prefix entries in %%DOCSDIR%% with %%PORTDOCS%%"
-	print "  -e, --noportexamples\tDo not prefix entries in %%EXAMPLESSDIR%%"
-	print "\t\t\twith %%PORTEAMPLES%%"
-	print "  -i, --ignoredoc\tIgnore all entries in %%DOCSDIR%% (if you use"
-	print "  \t\t\tPORTDOCS in the Makefile)"
-	print "  -s, --skip\t\tSkip these variables. Comma separated w/o spaces"
-	print ""
-	print "Basic usage:"
-	print "  1) Make your port, build it with PREFIX set to /var/tmp/ptest or"
-	print "     another *empty* directory of your choice"
-	print "  2) cd to your port's directory (e.g. /usr/ports/cat/port or ~/myport)"
-	print "  3) Run this"
-	print ""
+	print("pkg-plist 1.2 by Martin Tournoij <martin@arp242.net>")
+	print("http://code.arp242.net/pkg-plist/")
+	print("")
+	print("Usage: %s [-hdn] [-p portdir] [-x prefix]" % sys.argv[0])
+	print("")
+	print("  -h, --help\t\tPrint this help message and exit")
+	print("  -x, --prefix\t\tTemporary prefix to use (Default: /var/tmp/ptest)")
+	print("  -p, --portdir\t\tPort directory (Default: current directory)")
+	print("  -d, --noportdocs\tDo not prefix entries in %%DOCSDIR%% with %%PORTDOCS%%")
+	print("  -e, --noportexamples\tDo not prefix entries in %%EXAMPLESSDIR%%")
+	print("\t\t\twith %%PORTEAMPLES%%")
+	print("  -i, --ignoredoc\tIgnore all entries in %%DOCSDIR%% (if you use")
+	print("  \t\t\tPORTDOCS in the Makefile)")
+	print("  -s, --skip\t\tSkip these variables. Comma separated w/o spaces")
+	print("")
+	print("Basic usage:")
+	print("  1) Make your port, build it with PREFIX set to /var/tmp/ptest or")
+	print("     another *empty* directory of your choice")
+	print("  2) cd to your port's directory (e.g. /usr/ports/cat/port or ~/myport)")
+	print("  3) Run this")
+	print("")
 
 def GetOptions():
 	"""
 				'ignoredoc', 'skip'])
 	except getopt.GetoptError:
 		msg, opt = sys.exc_info()[1]
-		print msg + "\n"
+		print(msg + "\n")
 		Usage()
 		sys.exit()
 
 
 	# Check for a valid portdir and make prefix if needed
 	if not os.path.exists('%s/Makefile' % defaults['portdir']):
-		print 'Error: Unable to find a Makefile in the portdir "%s"' % defaults['portdir']
+		print('Error: Unable to find a Makefile in the portdir "%s"' % defaults['portdir'])
 		Usage()
 		sys.exit(1)
 
 		try:
 			os.makedirs(defaults['prefix'])
 		except IOError:
-			print 'Error: Unable to create prefix directory "%s"\n%s' % (mkdir, sys.exc_info()[1])
+			print('Error: Unable to create prefix directory "%s"\n%s' % (mkdir, sys.exc_info()[1]))
 			sys.exit(1)
 
 	# Get portsdir
 	defaults['portsdir'] = subprocess.Popen(['make', '-V', 'PORTSDIR'],
-		stdout=subprocess.PIPE).communicate()[0].strip()
+		stdout=subprocess.PIPE).communicate()[0].strip().decode()
 
 	return defaults
 
 		plist_sub = subprocess.Popen(['make', '-V', 'PLIST_SUB'],
 			stdout=subprocess.PIPE).communicate()[0].strip()
 	except OSError:
-		print "Problems running make -V:\n%s" % sys.exc_info()[1]
+		print("Problems running make -V:\n%s" % sys.exc_info()[1])
 		sys.exit(1)
 
 	vars = []
-	for v in plist_sub.split(' '):
+	for v in plist_sub.decode().split(' '):
 		if not v:
 			continue
 		try:
 	dirlist.reverse()
 
 	for f in filelist:
-		print ReplaceSub(f, vars, options)
+		print(ReplaceSub(f, vars, options))
 
 	for d in dirlist:
-		print ReplaceSub(d, vars, options, dir=True)
+		print(ReplaceSub(d, vars, options, dir=True))
 
 if __name__ == '__main__':
 	try:
 		main()
 	except KeyboardInterrupt:
 		sys.exit(0)
+
+#
+# The MIT License (MIT)
+#
+# Copyright © 2006-2012 Martin Tournoij
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.

File pkg-plist.gwiki

-*pkg-plist*
-Martin Tournoij <martin@arp242.net>
-_pkg-plist 1.1_
-= NAME =
-pkg-plist - Automatically generate a pkg-list
-= SYNOPSIS =
-pkg-plist [-hdn] [-p portdir] [-x prefix]
-= DESCRIPTION =
-  _-h_, _--help_
-      Print help message and exit
-  -_x_, _--prefix_
-      Temporary prefix to use (Default: /var/tmp/ptest)
-  _-p_, _--portdir_
-      Port directory (Default: current directory)
-  _-d_, _--noportdocs_
-      Do not prefix entries in %%DOCSDIR%% with %%PORTDOCS%%
-  _-e_, --noportexamples
-      Do not prefix entries in %%EXAMPLESSDIR%% with %%PORTEAMPLES%%
-  _-i_, _--ignoredoc_
-      Ignore all entries in %%DOCSDIR%% (if you use PORTDOCS in the Makefile)
-  _-s_, _--skip_
-      Skip these variables. Comma separated w/o spaces
-      The following variables are always skipped:
-      LIB32DIR, XAWVER, OSREL, PREFIX, X11BASE, and any varaible with a
-      value of 1 or less characters.
-= AUTHORS =
- * Martin Tournoij <mailto:martin@arp242.net>
-You are free to use, modify, and redistribute pkg-plist as you see fit. There
-are no restrictions.