Build-Depends: debhelper (>> 9.0),
po-debconf (>= 0.5.0),
dpkg-dev (>= 1.10),
- python-all-dev (>= 2.6.6-6~),
-X-Python-Version: >= 2.6
+ python3-all-dev,
+ dh-python,
+X-Python3-Version: >= 3.4
Standards-Version: 3.9.4
Homepage: http://www.linuxfoundation.org/collaborate/workgroups/lsb
Vcs-Git: git://anonscm.debian.org/collab-maint/lsb.git
psmisc,
rsync,
alien (>= 8.36),
- ${python:Depends},
+ ${python3:Depends},
${misc:Depends},
${depends},
lsb-base (>= ${source:Version}),
Architecture: all
Priority: optional
Multi-Arch: foreign
-Depends: ${python:Depends},
+Depends: ${python3:Depends},
${misc:Depends}
Recommends: apt
Suggests: lsb
--- /dev/null
+usr/share/pyshared/lsb_release.py usr/lib/python2.7/dist-packages/lsb_release.py
+usr/share/pyshared/lsb_release.py usr/lib/python3/dist-packages/lsb_release.py
derives_from_ubuntu := $(shell (dpkg-vendor --derives-from Ubuntu && echo "yes") || echo "no")
-PY2VERSIONS=$(shell pyversions -vr)
PY3VERSIONS=$(shell [ -x /usr/bin/py3versions ] && py3versions -vr)
%:
- dh $@ --with python2
+ dh $@ --with python3
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
dh_clean
rm -f *.py[co]
rm -f debian/lsb-base.maintscript
+ rm -rf __pycache__
+ rm -rf test/__pycache__
-override_dh_auto_test: $(PY2VERSIONS:%=test-python%) $(PY3VERSIONS:%=test-python%)
-
-test-python2.6:
- # Tests are not backported to python2.6, sorry.
+override_dh_auto_test: $(PY3VERSIONS:%=test-python%)
test-python%:
PATH=test/:$${PATH} PYTHONPATH=. python$* test/test_lsb_release.py -vv
PYTHONPATH=. python$* test/test_initdutils.py -vv
+ rm -rf __pycache__
+ rm -rf test/__pycache__
+ rm -f test/debian_version_*
-override_dh_python2:
- dh_python2
- dh_python2 /usr/lib/lsb
+override_dh_python3:
+ dh_python3
+ dh_python3 /usr/lib/lsb
override_dh_install:
dh_install
import re, sys, os
import pickle
-try:
- from io import StringIO
-except ImportError:
- from cStringIO import StringIO
+from io import StringIO
class RFC822Parser(dict):
"A dictionary-like object."
inheaders = RFC822Parser(strob=headerlines)
headers = {}
- for header, body in inheaders.iteritems():
+ for header, body in inheaders.items():
# Ignore empty headers
if not body.strip():
continue
if header in ('Default-Start', 'Default-Stop'):
- headers[header] = map(int, body.split())
+ headers[header] = list(map(int, body.split()))
elif header in ('Required-Start', 'Required-Stop', 'Provides',
'Should-Start', 'Should-Stop'):
headers[header] = body.split()
if facility.startswith('$'): continue
for (scriptname, pri) in entries.items():
start, stop = pri
- print >> fh, "%(scriptname)s %(facility)s %(start)d %(stop)d" % locals()
+ print("%(scriptname)s %(facility)s %(start)d %(stop)d" % locals(), file=fh)
fh.close()
def load_facilities():
facilities = {}
if os.path.exists(FACILITIES):
- for line in open(FACILITIES).xreadlines():
+ for line in open(FACILITIES):
try:
scriptname, name, start, stop = line.strip().split()
facilities.setdefault(name, {})[scriptname] = (int(start),
int(stop))
except ValueError as x:
- print >> sys.stderr, 'Invalid facility line', line
+ print('Invalid facility line', line, file=sys.stderr)
return facilities
if os.path.exists(DEPENDS):
independs = RFC822Parser(fileob=open(DEPENDS))
- for initfile, facilities in independs.iteritems():
+ for initfile, facilities in independs.items():
depends[initfile] = facilities.split()
return depends
return
fh = open(DEPENDS, 'w')
- for initfile, facilities in depends.iteritems():
- print >> fh, '%s: %s' % (initfile, ' '.join(facilities))
+ for initfile, facilities in depends.items():
+ print('%s: %s' % (initfile, ' '.join(facilities)), file=fh)
fh.close()
# filemap entries are mappings, { (package, filename) : instloc }
fh.close()
if __name__ == '__main__':
- print (scan_initfile('init-fragment'))
+ print(scan_initfile('init-fragment'))
-#!/usr/bin/python
+#!/usr/bin/python3
import sys, re, os, initdutils
else:
initfile = os.path.join('/etc/init.d', initfile)
else:
- print >> sys.stderr, 'Usage: %s /etc/init.d/<init-script>' % sys.argv[0]
+ print('Usage: %s /etc/init.d/<init-script>' % sys.argv[0], file=sys.stderr)
sys.exit(1)
# Default priorities
startpri = 5
for facility in reqstart:
if facility not in facilities:
- print >> sys.stderr, 'Missing required start facility', facility
+ print('Missing required start facility', facility, file=sys.stderr)
sys.exit(1)
else:
- for script, pri in facilities[facility].iteritems():
+ for script, pri in facilities[facility].items():
if script != initfile:
start, stop = pri
startpri = max(startpri, start+1)
for facility in shouldstart:
if facility not in facilities:
- print >> sys.stderr, 'Missing should-start facility', facility, '(ignored)'
+ print('Missing should-start facility', facility, '(ignored)', file=sys.stderr)
else:
- for script, pri in facilities[facility].iteritems():
+ for script, pri in facilities[facility].items():
if script != initfile:
start, stop = pri
startpri = max(startpri, start+1)
stoppri = 95
for facility in reqstop:
if facility not in facilities:
- print >> sys.stderr, 'Missing required stop facility', facility
+ print('Missing required stop facility', facility, file=sys.stderr)
sys.exit(1)
else:
- for script, pri in facilities[facility].iteritems():
+ for script, pri in facilities[facility].items():
if script != initfile:
start, stop = pri
stoppri = min(stoppri, stop-1)
for facility in shouldstop:
if facility not in facilities:
- print >> sys.stderr, 'Missing should-stop facility', facility, '(ignored)'
+ print('Missing should-stop facility', facility, '(ignored)', file=sys.stderr)
else:
- for script, pri in facilities[facility].iteritems():
+ for script, pri in facilities[facility].items():
if script != initfile:
start, stop = pri
stoppri = min(stoppri, stop-1)
if provides:
for facility in provides:
if facility[0] == '$':
- print >> sys.stderr, 'Ignoring system-provided facility', facility
+ print('Ignoring system-provided facility', facility, file=sys.stderr)
continue
- if not facilities.has_key(facility):
+ if facility not in facilities:
facilities[facility] = {}
facilities[facility][initfile] = (startpri, stoppri)
-#!/usr/bin/python -Es
+#!/usr/bin/python3 -Es
# lsb_release command for Debian
# (C) 2005-10 Chris Lawrence <lawrencc@debian.org>
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
-# Python3-compatible print() function
-from __future__ import print_function
-
from optparse import OptionParser
import sys
import os
def parse_apt_policy():
data = []
- C_env = os.environ.copy(); C_env['LC_ALL'] = 'C'
+ C_env = os.environ.copy(); C_env['LC_ALL'] = 'C.UTF-8'
policy = subprocess.Popen(['apt-cache','policy'],
env=C_env,
stdout=subprocess.PIPE,
-#!/usr/bin/python
+#!/usr/bin/python3
import sys
import os
import shutil
import socket
-import commands
+import subprocess
from tempfile import NamedTemporaryFile
from initdutils import load_lsbinstall_info, save_lsbinstall_info
)
def installed_message(objectname):
- print objectname, 'is installed'
+ print(objectname, 'is installed')
def handle_generic_install(options, args, location, showinstloc=False):
filename = args[0]
if os.path.exists(fileinfo):
try:
os.unlink(fileinfo)
- except (IOError, OSError, os.error), why:
- print >> sys.stderr, 'Removal of %s failed: %s' % (
- instloc, str(why))
+ except OSError as why:
+ print('Removal of %s failed: %s' % (
+ instloc, str(why)), file=sys.stderr)
sys.exit(1)
# Remove it from the database, even if it was previously removed
instloc = os.path.join(location, '%s.%s' % (options.package, basename))
if os.path.exists(instloc):
- print >> sys.stderr, 'Unable to install %s: %s exists' % (
- filename, instloc)
+ print('Unable to install %s: %s exists' % (
+ filename, instloc), file=sys.stderr)
sys.exit(1)
if not os.path.exists(location):
try:
os.makedirs(location)
- except (IOError, OSError, os.error), why:
- print >> sys.stderr, 'Unable to create %s to install %s: %s' % (
- location, filename, str(why))
+ except OSError as why:
+ print('Unable to create %s to install %s: %s' % (
+ location, filename, str(why)), file=sys.stderr)
sys.exit(1)
try:
shutil.copy2(filename, instloc)
- except (IOError, os.error), why:
- print >> sys.stderr, 'Installation of %s as %s failed: %s' % (
- filename, instloc, str(why))
+ except (IOError, os.error) as why:
+ print('Installation of %s as %s failed: %s' % (
+ filename, instloc, str(why)), file=sys.stderr)
sys.exit(1)
if showinstloc:
- print instloc
+ print(instloc)
filemap[(package, filename)] = instloc
save_lsbinstall_info(filemap)
pproto = args[0]
port, proto = pproto.split('/', 1)
port = int(port)
- except:
- print >> sys.stderr, 'You must specify a port/protocol pair as the first argument.'
+ except ValueError:
+ print('You must specify a port/protocol pair as the first argument.', file=sys.stderr)
sys.exit(2)
if options.check:
except socket.error:
sys.exit(1)
- print '%d/%s corresponds to service %s' % (port, proto, serv)
+ print('%d/%s corresponds to service %s' % (port, proto, serv))
return
sname = args[1]
laliases += [a]
elif name == lname or name in laliases:
# name shows up, but in wrong protocol/port
- print >> sys.stderr, 'Conflict between specified addition and /etc/services; aborting.'
+ print('Conflict between specified addition and /etc/services; aborting.', file=sys.stderr)
fpout.close()
os.unlink(newfname)
sys.exit(1)
line = '%15s %15s %s' % lname, lpproto, endbits
line = line.rstrip()
- print >> fpout, line
+ print(line, file=fpout)
fpin.close()
fpout.close()
return
fp = open('/etc/services', 'a')
- print >> fp, '%15s %15s %s # Added by lsbinstall for %s' % (
- sname, pproto, ' '.join(saliases), pkg)
+ print('%15s %15s %s # Added by lsbinstall for %s' % (
+ sname, pproto, ' '.join(saliases), pkg), file=fp)
fp.close()
def handle_inet(options, args, parser):
if options.remove:
parts = r'%s\s+.*\s+%s\s+.*' % (re.escape(alist[0], alist[1]))
- cmd += '--remove '+commands.mkarg(parts)
+ cmd += '--remove '+subprocess.mkarg(parts)
elif options.check:
return
else:
parser.error('The operand must have six colon-separated arguments.')
return
newalist = [alist[0], alist[2], alist[1]] + alist[3:]
- cmd += '--add '+commands.mkarg('\t'.join(newalist))
+ cmd += '--add '+subprocess.mkarg('\t'.join(newalist))
os.system(cmd)
pass
parser.error('Only one argument supported for %s' % options.type)
handle_man(options, args)
else:
- print >> sys.stderr, 'Unsupported type %s' % options.type
+ print('Unsupported type %s' % options.type, file=sys.stderr)
sys.exit(1)
if __name__ == '__main__':
-#!/usr/bin/python
+#!/usr/bin/python3
import sys, re, os, initdutils
else:
initfile = os.path.join('/etc/init.d', initfile)
else:
- print >> sys.stderr, 'Usage: %s /etc/init.d/<init-script>' % sys.argv[0]
+ print('Usage: %s /etc/init.d/<init-script>' % sys.argv[0], file=sys.stderr)
sys.exit(1)
headers = initdutils.scan_initfile(initfile)
entries[entry[0]] = entry[1]
facilities[facility] = entries
- for (initscript, needed) in depends.iteritems():
+ for (initscript, needed) in depends.items():
for facility in needed:
if facility[0] == "$":
continue
if not facilities.get(facility) and facility in provides:
- print >> sys.stderr, 'Unable to remove %s: %s needs %s\n' % (
- initfile, initscript, facility)
+ print('Unable to remove %s: %s needs %s\n' % (
+ initfile, initscript, facility), file=sys.stderr)
sys.exit(1)
if initfile in depends:
-#!/usr/bin/python
+#!/usr/bin/python3
# coding=utf-8
# Fake apt-cache python script to emulate policy output for test usage
-# Python3-compatible print() function
-from __future__ import print_function
-
import sys
import os
-#!/usr/bin/python
+#!/usr/bin/python3
# Fake dpkg-query python script to emulate output for test usage
-# Python3-compatible print() function
-from __future__ import print_function
-
import sys
import os
import random
-#!/usr/bin/python
+#!/usr/bin/python3
import unittest
import initdutils as iu
-#!/usr/bin/python
+#!/usr/bin/python3
# coding=utf-8
-from __future__ import unicode_literals
import unittest