mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
test: fix example package class
this class can be much simpler and more robust and doesn't require checking in the example package files to git
This commit is contained in:
parent
1b12d8b4e3
commit
0eaf71737d
4
.gitignore
vendored
4
.gitignore
vendored
@ -5,9 +5,7 @@ __pycache__/
|
|||||||
*.pyc
|
*.pyc
|
||||||
/build/
|
/build/
|
||||||
/.pybuild/
|
/.pybuild/
|
||||||
/test-data/example_1.0-1.debian.tar.xz
|
/test-data/
|
||||||
/test-data/example_1.0-1.dsc
|
|
||||||
/test-data/example_1.0.orig.tar.gz
|
|
||||||
/debian/python-ubuntutools/
|
/debian/python-ubuntutools/
|
||||||
/debian/python3-ubuntutools/
|
/debian/python3-ubuntutools/
|
||||||
/debian/ubuntu-dev-tools/
|
/debian/ubuntu-dev-tools/
|
||||||
|
1
debian/clean
vendored
1
debian/clean
vendored
@ -1,2 +1 @@
|
|||||||
*.egg-info/
|
*.egg-info/
|
||||||
test-data/example_*
|
|
||||||
|
1
debian/control
vendored
1
debian/control
vendored
@ -10,6 +10,7 @@ Build-Depends:
|
|||||||
dctrl-tools,
|
dctrl-tools,
|
||||||
debhelper-compat (= 12),
|
debhelper-compat (= 12),
|
||||||
devscripts (>= 2.11.0~),
|
devscripts (>= 2.11.0~),
|
||||||
|
dh-make,
|
||||||
dh-python,
|
dh-python,
|
||||||
distro-info (>= 0.2~),
|
distro-info (>= 0.2~),
|
||||||
flake8,
|
flake8,
|
||||||
|
3
debian/copyright
vendored
3
debian/copyright
vendored
@ -152,7 +152,6 @@ Files: doc/pull-debian-debdiff.1
|
|||||||
reverse-depends
|
reverse-depends
|
||||||
seeded-in-ubuntu
|
seeded-in-ubuntu
|
||||||
sponsor-patch
|
sponsor-patch
|
||||||
test-data/*
|
|
||||||
ubuntu-upload-permission
|
ubuntu-upload-permission
|
||||||
ubuntutools/archive.py
|
ubuntutools/archive.py
|
||||||
ubuntutools/builder.py
|
ubuntutools/builder.py
|
||||||
@ -167,7 +166,7 @@ Copyright: 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
|||||||
2010, Evan Broder <evan@ebroder.net>
|
2010, Evan Broder <evan@ebroder.net>
|
||||||
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||||
2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||||
2017-2019, Dan Streetman <ddstreet@canonical.com>
|
2017-2021, Dan Streetman <ddstreet@canonical.com>
|
||||||
License: ISC
|
License: ISC
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
1
debian/tests/control
vendored
1
debian/tests/control
vendored
@ -5,6 +5,7 @@ Restrictions: allow-stderr
|
|||||||
|
|
||||||
Test-Command: nosetests3 -v ubuntutools
|
Test-Command: nosetests3 -v ubuntutools
|
||||||
Depends:
|
Depends:
|
||||||
|
dh-make,
|
||||||
python3-nose,
|
python3-nose,
|
||||||
python3-setuptools,
|
python3-setuptools,
|
||||||
@,
|
@,
|
||||||
|
@ -1 +0,0 @@
|
|||||||
upstream
|
|
@ -1 +0,0 @@
|
|||||||
7
|
|
@ -1,12 +0,0 @@
|
|||||||
Source: example
|
|
||||||
Section: misc
|
|
||||||
Priority: extra
|
|
||||||
Maintainer: Ubuntu Developers <ubuntu-dev-team@lists.alioth.debian.org>
|
|
||||||
Build-Depends: debhelper (>= 7.0.50~)
|
|
||||||
Standards-Version: 3.9.1
|
|
||||||
|
|
||||||
Package: example
|
|
||||||
Architecture: all
|
|
||||||
Depends: ${misc:Depends}, ${shlibs:Depends}
|
|
||||||
Description: Example package for testing purposes
|
|
||||||
An example package used by the test suite. Useless.
|
|
@ -1,17 +0,0 @@
|
|||||||
Format: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=152
|
|
||||||
Source: https://launchpad.net/ubuntu-dev-tools
|
|
||||||
|
|
||||||
Files: *
|
|
||||||
Copyright: 2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
|
||||||
License: ISC
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
.
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
PERFORMANCE OF THIS SOFTWARE.
|
|
@ -1,4 +0,0 @@
|
|||||||
#!/usr/bin/make -f
|
|
||||||
|
|
||||||
%:
|
|
||||||
dh $@
|
|
@ -1 +0,0 @@
|
|||||||
3.0 (quilt)
|
|
@ -1 +0,0 @@
|
|||||||
abort-on-upstream-changes
|
|
@ -1 +0,0 @@
|
|||||||
compression=xz
|
|
@ -14,55 +14,69 @@
|
|||||||
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
import os.path
|
import os
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
from ubuntutools.version import Version
|
from ubuntutools.version import Version
|
||||||
|
|
||||||
|
|
||||||
class ExamplePackage(object):
|
class ExamplePackage(object):
|
||||||
def __init__(self, source='example', version='1.0-1'):
|
def __init__(self, source='example', version='1.0-1', destdir='test-data'):
|
||||||
self.source = source
|
self.source = source
|
||||||
self.version = Version(version)
|
self.version = Version(version)
|
||||||
self.srcdir = os.path.join('test-data', '%s-%s' % (source,
|
self.destdir = Path(destdir)
|
||||||
self.version.upstream_version))
|
|
||||||
if os.path.exists(self.srcdir):
|
|
||||||
shutil.rmtree(self.srcdir)
|
|
||||||
shutil.copytree('test-data/blank-example', self.srcdir)
|
|
||||||
|
|
||||||
def create_orig(self):
|
self.env = dict(os.environ)
|
||||||
"Create .orig.tar.gz"
|
self.env['DEBFULLNAME'] = 'Example'
|
||||||
orig = '%s_%s.orig.tar.gz' % (self.source,
|
self.env['DEBEMAIL'] = 'example@example.net'
|
||||||
self.version.upstream_version)
|
|
||||||
subprocess.check_call(
|
|
||||||
(
|
|
||||||
'tar',
|
|
||||||
'-czf', orig,
|
|
||||||
'--exclude', 'debian',
|
|
||||||
os.path.basename(self.srcdir),
|
|
||||||
),
|
|
||||||
cwd='test-data'
|
|
||||||
)
|
|
||||||
|
|
||||||
def changelog_entry(self, version=None, create=False):
|
@property
|
||||||
"Add a changelog entry"
|
def orig(self):
|
||||||
cmd = ['dch', '--noconf', '--preserve', '--package', self.source]
|
return self.destdir / f'{self.source}_{self.version.upstream_version}.orig.tar.xz'
|
||||||
if create:
|
|
||||||
cmd.append('--create')
|
@property
|
||||||
cmd += ['--newversion', version or self.version.full_version]
|
def debian(self):
|
||||||
cmd.append('')
|
return self.destdir / f'{self.source}_{self.version}.debian.tar.xz'
|
||||||
env = dict(os.environ)
|
|
||||||
env['DEBFULLNAME'] = 'Example'
|
@property
|
||||||
env['DEBEMAIL'] = 'example@example.net'
|
def dsc(self):
|
||||||
subprocess.check_call(cmd, env=env, cwd=self.srcdir)
|
return self.destdir / f'{self.source}_{self.version}.dsc'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dirname(self):
|
||||||
|
return f'{self.source}-{self.version.upstream_version}'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def content_filename(self):
|
||||||
|
return 'content'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def content_text(self):
|
||||||
|
return 'my content'
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
"Build source package"
|
with tempfile.TemporaryDirectory() as d:
|
||||||
self.changelog_entry(create=True)
|
self._create(Path(d))
|
||||||
(basename, dirname) = os.path.split(self.srcdir)
|
|
||||||
subprocess.check_call(('dpkg-source', '-b', dirname), cwd=basename)
|
|
||||||
|
|
||||||
def cleanup(self):
|
def _create(self, d):
|
||||||
"Remove srcdir"
|
pkgdir = d / self.dirname
|
||||||
shutil.rmtree(self.srcdir)
|
pkgdir.mkdir()
|
||||||
|
(pkgdir / self.content_filename).write_text(self.content_text)
|
||||||
|
|
||||||
|
# run dh_make to create orig tarball
|
||||||
|
subprocess.run('dh_make -sy --createorig'.split(),
|
||||||
|
check=True, env=self.env, cwd=str(pkgdir),
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
# run dpkg-source -b to create debian tar and dsc
|
||||||
|
subprocess.run(f'dpkg-source -b {self.dirname}'.split(),
|
||||||
|
check=True, env=self.env, cwd=str(d),
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
# move tarballs and dsc to destdir
|
||||||
|
self.destdir.mkdir(parents=True, exist_ok=True)
|
||||||
|
(d / self.orig.name).rename(self.orig)
|
||||||
|
(d / self.debian.name).rename(self.debian)
|
||||||
|
(d / self.dsc.name).rename(self.dsc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user