From 3ac706401fd97c9e830e1a18cc8c674f6ee155d5 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 15:05:55 +0200 Subject: [PATCH 01/12] Test for that every script can run --help and return 0. --- debian/changelog | 3 +- setup.py | 111 +++++++++++++++++----------------- ubuntutools/test/test_help.py | 77 +++++++++++++++++++++++ 3 files changed, 136 insertions(+), 55 deletions(-) create mode 100644 ubuntutools/test/test_help.py diff --git a/debian/changelog b/debian/changelog index ae628b0..bda6af3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low DEBEMAIL. (LP: #665202) * Add the beginnings of a test suite. (LP: #690386) - Switch to setuptools, to support setup.py test. + - Test for that every script can run --help and return 0. * ubuntutools/common.py: Remove https_proxy unsetting code, working around LP: #94130. @@ -29,7 +30,7 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low - Fix 'str' object has no attribute 'startwith' crash caused by a typo. - Fix crash if uploading to ubuntu without building the package before. - -- Benjamin Drung Wed, 22 Dec 2010 00:51:48 +0100 + -- Stefano Rivera Wed, 22 Dec 2010 15:02:45 +0200 ubuntu-dev-tools (0.108) experimental; urgency=low diff --git a/setup.py b/setup.py index 938857e..fe1ae0f 100755 --- a/setup.py +++ b/setup.py @@ -13,57 +13,60 @@ if os.path.exists(changelog): if match: version = match.group(1) -setup(name='ubuntu-dev-tools', - version=version, - scripts=['404main', - 'backportpackage', - 'check-symbols', - 'dch-repeat', - 'dgetlp', - 'edit-patch', - 'errno', - 'get-branches', - 'get-build-deps', - 'grab-attachments', - 'grab-merge', - 'grep-merges', - 'hugdaylist', - 'import-bug-from-debian', - 'lp-list-bugs', - 'lp-project-upload', - 'lp-set-dup', - 'lp-shell', - 'manage-credentials', - 'massfile', - 'merge-changelog', - 'mk-sbuild', - 'pbuilder-dist', - 'pbuilder-dist-simple', - 'pull-debian-debdiff', - 'pull-debian-source', - 'pull-lp-source', - 'pull-revu-source', - 'requestsync', - 'reverse-build-depends', - 'setup-packaging-environment', - 'sponsor-patch', - 'submittodebian', - 'suspicious-source', - 'syncpackage', - 'ubuntu-build', - 'ubuntu-iso', - 'update-maintainer', - 'what-patch', - 'wrap-and-sort', - ], - packages=['ubuntutools', - 'ubuntutools/lp', - 'ubuntutools/requestsync', - 'ubuntutools/sponsor_patch', - 'ubuntutools/test', - ], - data_files=[('share/man/man1', glob.glob("doc/*.1")), - ('share/man/man5', glob.glob("doc/*.5")), - ], - test_suite='ubuntutools.test.discover', -) +scripts = ['404main', + 'backportpackage', + 'check-symbols', + 'dch-repeat', + 'dgetlp', + 'edit-patch', + 'errno', + 'get-branches', + 'get-build-deps', + 'grab-attachments', + 'grab-merge', + 'grep-merges', + 'hugdaylist', + 'import-bug-from-debian', + 'lp-list-bugs', + 'lp-project-upload', + 'lp-set-dup', + 'lp-shell', + 'manage-credentials', + 'massfile', + 'merge-changelog', + 'mk-sbuild', + 'pbuilder-dist', + 'pbuilder-dist-simple', + 'pull-debian-debdiff', + 'pull-debian-source', + 'pull-lp-source', + 'pull-revu-source', + 'requestsync', + 'reverse-build-depends', + 'setup-packaging-environment', + 'sponsor-patch', + 'submittodebian', + 'suspicious-source', + 'syncpackage', + 'ubuntu-build', + 'ubuntu-iso', + 'update-maintainer', + 'what-patch', + 'wrap-and-sort', + ] + +if __name__ == '__main__': + setup(name='ubuntu-dev-tools', + version=version, + scripts=scripts, + packages=['ubuntutools', + 'ubuntutools/lp', + 'ubuntutools/requestsync', + 'ubuntutools/sponsor_patch', + 'ubuntutools/test', + ], + data_files=[('share/man/man1', glob.glob("doc/*.1")), + ('share/man/man5', glob.glob("doc/*.5")), + ], + test_suite='ubuntutools.test.discover', + ) diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py new file mode 100644 index 0000000..71627ba --- /dev/null +++ b/ubuntutools/test/test_help.py @@ -0,0 +1,77 @@ +# test_help.py - Ensure scripts can run --help. +# +# Copyright (C) 2010, Stefano Rivera +# +# 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. + +import fcntl +import os +import select +import signal +import subprocess +import time + +import setup +from ubuntutools.test import unittest + +BLACKLIST = ['grep-merges', 'submittodebian'] +TIMEOUT = 5 + +def load_tests(loader, tests, pattern): + "Give HelpTestCase a chance to populate before loading its test cases" + suite = unittest.TestSuite() + HelpTestCase.populate() + suite.addTests(loader.loadTestsFromTestCase(HelpTestCase)) + return suite + +class HelpTestCase(unittest.TestCase): + @classmethod + def populate(cls): + for script in setup.scripts: + setattr(cls, 'test_' + script, cls.makeHelpTester(script)) + + @classmethod + def makeHelpTester(cls, script): + def tester(self): + if script in BLACKLIST: + raise unittest.SkipTest("Blacklisted") + + null = open('/dev/null', 'r') + p = subprocess.Popen(['./' + script, '--help'], + close_fds=True, stdin=null, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + started = time.time() + out = [] + + fds = [p.stdout.fileno(), p.stderr.fileno()] + for fd in fds: + fcntl.fcntl(fd, fcntl.F_SETFL, + fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK) + + while time.time() - started < TIMEOUT: + for fd in select.select(fds, [], fds, TIMEOUT)[0]: + out.append(os.read(fd, 1024)) + if p.poll() is not None: + break + + if p.poll() is None: + os.kill(signal.SIG_TERM) + time.sleep(1) + if p.poll() is None: + os.kill(signal.SIG_KILL) + + self.assertEqual(p.poll(), 0, + "%s failed to return usage within %i seconds.\n" + "Output:\n%s" + % (script, TIMEOUT, ''.join(out))) + return tester From b4a245b281764485f0ac16946331f2bb498b82fb Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 15:07:19 +0200 Subject: [PATCH 02/12] Append a1 to version number in pre-releases --- setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100755 => 100644 setup.py diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index fe1ae0f..88881b3 --- a/setup.py +++ b/setup.py @@ -8,10 +8,12 @@ import re # look/set what version we have changelog = "debian/changelog" if os.path.exists(changelog): - head=open(changelog).readline() - match = re.compile(".*\((.*)\).*").match(head) + head = open(changelog).readline() + match = re.compile(r'.*\((.+)\)\s+(\S+);\s+.*').match(head) if match: version = match.group(1) + if match.group(2) == 'UNRELEASED': + version += 'a1' scripts = ['404main', 'backportpackage', From 87565775189e20659d0c343f30035ac44679840f Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 16:28:36 +0200 Subject: [PATCH 03/12] Complete blacklist --- ubuntutools/test/test_help.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py index 71627ba..a6812cf 100644 --- a/ubuntutools/test/test_help.py +++ b/ubuntutools/test/test_help.py @@ -24,7 +24,23 @@ import time import setup from ubuntutools.test import unittest -BLACKLIST = ['grep-merges', 'submittodebian'] +BLACKLIST = { + '404main': 'Returns non-zero after help', + 'check-symbols': 'No Help', + 'edit-patch': 'No Help', + 'grep-merges': 'No Help', + 'lp-project-upload': 'Returns non-zero after help. Leaving u-d-t in LP: #524680', + 'massfile': 'No Help. Leaves files in .', + 'merge-changelog': 'Returns non-zero after help', + 'mk-sbuild': 'Fires up apt-get before showing help', + 'pbuilder-dist-simple': 'No Help', + 'pull-debian-debdiff': 'Returns non-zero after help', + 'pull-debian-source': 'Returns non-zero after help', + 'pull-revu-source': 'Throws Error', + 'setup-packaging-environment': 'Throws Error', + 'submittodebian': 'No Help', + 'ubuntu-iso': 'No Help', +} TIMEOUT = 5 def load_tests(loader, tests, pattern): @@ -44,7 +60,7 @@ class HelpTestCase(unittest.TestCase): def makeHelpTester(cls, script): def tester(self): if script in BLACKLIST: - raise unittest.SkipTest("Blacklisted") + raise unittest.SkipTest("Blacklisted: " + BLACKLIST[script]) null = open('/dev/null', 'r') p = subprocess.Popen(['./' + script, '--help'], From c4de897e2a8906b60782b87f120a620b470b98a9 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 16:53:58 +0200 Subject: [PATCH 04/12] 404main, merge-changelog, pull-debian-debdiff, pull-debian-source: Return 0 after showing help. --- 404main | 2 +- debian/changelog | 4 +++- merge-changelog | 8 +++++--- pull-debian-debdiff | 13 +++++++++++-- pull-debian-source | 8 +++++--- ubuntutools/test/test_help.py | 4 ---- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/404main b/404main index 3f3bb8f..9301f70 100755 --- a/404main +++ b/404main @@ -112,7 +112,7 @@ def main(): # Check if the amount of arguments is correct if len(sys.argv) < 2 or len(sys.argv) > 3 or sys.argv[1] in ('help', '-h', '--help'): print 'Usage: %s []' % sys.argv[0] - sys.exit(1) + sys.exit(0) cache = apt.cache.Cache() diff --git a/debian/changelog b/debian/changelog index bda6af3..105f335 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,8 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low * Add the beginnings of a test suite. (LP: #690386) - Switch to setuptools, to support setup.py test. - Test for that every script can run --help and return 0. + - 404main, merge-changelog, pull-debian-debdiff, pull-debian-source: + Return 0 after showing help. * ubuntutools/common.py: Remove https_proxy unsetting code, working around LP: #94130. @@ -30,7 +32,7 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low - Fix 'str' object has no attribute 'startwith' crash caused by a typo. - Fix crash if uploading to ubuntu without building the package before. - -- Stefano Rivera Wed, 22 Dec 2010 15:02:45 +0200 + -- Stefano Rivera Wed, 22 Dec 2010 16:52:55 +0200 ubuntu-dev-tools (0.108) experimental; urgency=low diff --git a/merge-changelog b/merge-changelog index 29e2d8a..d9f97fc 100755 --- a/merge-changelog +++ b/merge-changelog @@ -20,7 +20,7 @@ import sys, re -def usage(): +def usage(exit=1): print '''Usage: merge-changelog merge-changelog takes two changelogs that once shared a common source, @@ -28,7 +28,7 @@ merges them back together, and prints the merged result to stdout. This is useful if you need to manually merge a ubuntu package with a new Debian release of the package. ''' - sys.exit(1) + sys.exit(0) ######################################################################## # Changelog Management @@ -253,8 +253,10 @@ def deb_cmp(x, y): if __name__ == '__main__': + if len(sys.argv) > 1 and sys.argv[1] in ('-h', '--help'): + usage(exit=0) if len(sys.argv) != 3: - usage() + usage(exit=1) left_changelog = sys.argv[1] right_changelog = sys.argv[2] diff --git a/pull-debian-debdiff b/pull-debian-debdiff index bd5389f..e9e3e92 100755 --- a/pull-debian-debdiff +++ b/pull-debian-debdiff @@ -115,6 +115,13 @@ sub download_source return 1; } +sub usage +{ + my ($exit) = @_; + print "Usage: $0 PKG VERSION\n"; + exit $exit; +} + my $pkg = $ARGV[0]; @@ -123,8 +130,10 @@ my $just_fetch = ($ARGV[2] && $ARGV[2] eq "--fetch"); my $skip = $ARGV[2] || 1; $skip+=0; -if (!defined($pkg) || !defined($version)) { - die "Usage: $0 PKG VERSION\n"; +if (defined($pkg) && ($pkg eq '--help' || $pkg eq '-h')) { + usage(0); +} elsif (!defined($pkg) || !defined($version)) { + usage(2); } diff --git a/pull-debian-source b/pull-debian-source index aba22c8..297324f 100755 --- a/pull-debian-source +++ b/pull-debian-source @@ -27,10 +27,10 @@ use AptPkg::Version; die("Please install 'devscripts'\n") if(! grep -x "$_/dget", split(':',$ENV{'PATH'})); my($name)=basename($0); -my($package)=$ARGV[0] || &usage(); +my($package)=$ARGV[0] || &usage(2); my($help)=0; GetOptions('help' => \$help); -&usage() if($help); +&usage(0) if($help); my($release)=$ARGV[1] || 'unstable'; $release=&convertCodeName($release); &checkRelease($release); @@ -132,7 +132,9 @@ sub getDSC { } sub usage { - die("USAGE: $name [-h] [target release]\n"); + my($exit)=shift; + print("USAGE: $name [-h] [target release]\n"); + exit($exit); } sub invalidRelease { my($releases)=shift || die("Invalid Release!"); diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py index a6812cf..f2ec524 100644 --- a/ubuntutools/test/test_help.py +++ b/ubuntutools/test/test_help.py @@ -25,17 +25,13 @@ import setup from ubuntutools.test import unittest BLACKLIST = { - '404main': 'Returns non-zero after help', 'check-symbols': 'No Help', 'edit-patch': 'No Help', 'grep-merges': 'No Help', 'lp-project-upload': 'Returns non-zero after help. Leaving u-d-t in LP: #524680', 'massfile': 'No Help. Leaves files in .', - 'merge-changelog': 'Returns non-zero after help', 'mk-sbuild': 'Fires up apt-get before showing help', 'pbuilder-dist-simple': 'No Help', - 'pull-debian-debdiff': 'Returns non-zero after help', - 'pull-debian-source': 'Returns non-zero after help', 'pull-revu-source': 'Throws Error', 'setup-packaging-environment': 'Throws Error', 'submittodebian': 'No Help', From 9ba4809eed57ffdc244a882296e6b495c9a1aef0 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 16:56:05 +0200 Subject: [PATCH 05/12] Reverted: r876: Append a1 to version number in pre-releases --- setup.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) mode change 100644 => 100755 setup.py diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 88881b3..fe1ae0f --- a/setup.py +++ b/setup.py @@ -8,12 +8,10 @@ import re # look/set what version we have changelog = "debian/changelog" if os.path.exists(changelog): - head = open(changelog).readline() - match = re.compile(r'.*\((.+)\)\s+(\S+);\s+.*').match(head) + head=open(changelog).readline() + match = re.compile(".*\((.*)\).*").match(head) if match: version = match.group(1) - if match.group(2) == 'UNRELEASED': - version += 'a1' scripts = ['404main', 'backportpackage', From 96d72d83e253dbd310e77a0bcdc351daf8e02613 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 16:57:25 +0200 Subject: [PATCH 06/12] signals don't use underscores --- ubuntutools/test/test_help.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py index f2ec524..563687a 100644 --- a/ubuntutools/test/test_help.py +++ b/ubuntutools/test/test_help.py @@ -77,10 +77,10 @@ class HelpTestCase(unittest.TestCase): break if p.poll() is None: - os.kill(signal.SIG_TERM) + os.kill(signal.SIGTERM) time.sleep(1) if p.poll() is None: - os.kill(signal.SIG_KILL) + os.kill(signal.SIGKILL) self.assertEqual(p.poll(), 0, "%s failed to return usage within %i seconds.\n" From f55ab3d4653efdeebbc9a157ad329fc85f1b6e02 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 17:01:55 +0200 Subject: [PATCH 07/12] Provide pid when killing --- ubuntutools/test/test_help.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py index 563687a..a50864b 100644 --- a/ubuntutools/test/test_help.py +++ b/ubuntutools/test/test_help.py @@ -77,10 +77,10 @@ class HelpTestCase(unittest.TestCase): break if p.poll() is None: - os.kill(signal.SIGTERM) + os.kill(p.pid, signal.SIGTERM) time.sleep(1) if p.poll() is None: - os.kill(signal.SIGKILL) + os.kill(p.pid, signal.SIGKILL) self.assertEqual(p.poll(), 0, "%s failed to return usage within %i seconds.\n" From 4c0a650052cd7440c47706f0c402b2a0fe90944b Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 17:03:01 +0200 Subject: [PATCH 08/12] Blacklist get-build-deps --- ubuntutools/test/test_help.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py index a50864b..ac0c2dc 100644 --- a/ubuntutools/test/test_help.py +++ b/ubuntutools/test/test_help.py @@ -27,6 +27,7 @@ from ubuntutools.test import unittest BLACKLIST = { 'check-symbols': 'No Help', 'edit-patch': 'No Help', + 'get-build-deps': 'No Help, runs sudo', 'grep-merges': 'No Help', 'lp-project-upload': 'Returns non-zero after help. Leaving u-d-t in LP: #524680', 'massfile': 'No Help. Leaves files in .', From df6b32086b8895b9d03724c3c8b23b619b3eda53 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 17:09:29 +0200 Subject: [PATCH 09/12] Close /dev/null --- ubuntutools/test/test_help.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py index ac0c2dc..083c790 100644 --- a/ubuntutools/test/test_help.py +++ b/ubuntutools/test/test_help.py @@ -82,6 +82,7 @@ class HelpTestCase(unittest.TestCase): time.sleep(1) if p.poll() is None: os.kill(p.pid, signal.SIGKILL) + null.close() self.assertEqual(p.poll(), 0, "%s failed to return usage within %i seconds.\n" From 34b1991bdd983b7db88639f33c57884ed5256643 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 17:14:48 +0200 Subject: [PATCH 10/12] Fix pull-revu-source help, and return 0 --- debian/changelog | 7 ++++--- pull-revu-source | 9 ++++++--- ubuntutools/test/test_help.py | 1 - 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index 105f335..178bde7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,8 +16,9 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low * Add the beginnings of a test suite. (LP: #690386) - Switch to setuptools, to support setup.py test. - Test for that every script can run --help and return 0. - - 404main, merge-changelog, pull-debian-debdiff, pull-debian-source: - Return 0 after showing help. + - 404main, merge-changelog, pull-debian-debdiff, pull-debian-source, + pull-revu-source: + + Return 0 after showing help. * ubuntutools/common.py: Remove https_proxy unsetting code, working around LP: #94130. @@ -32,7 +33,7 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low - Fix 'str' object has no attribute 'startwith' crash caused by a typo. - Fix crash if uploading to ubuntu without building the package before. - -- Stefano Rivera Wed, 22 Dec 2010 16:52:55 +0200 + -- Stefano Rivera Wed, 22 Dec 2010 17:13:59 +0200 ubuntu-dev-tools (0.108) experimental; urgency=low diff --git a/pull-revu-source b/pull-revu-source index 1c6bbd4..9bce2f7 100755 --- a/pull-revu-source +++ b/pull-revu-source @@ -20,6 +20,7 @@ use warnings; use strict; +use File::Basename; use LWP::Simple; use Getopt::Long; @@ -27,10 +28,10 @@ die("Please install 'devscripts'\n") if(! grep -x "$_/dget", split(':',$ENV{'PAT my $REVU = "revu.ubuntuwire.com"; -my($package) = lc($ARGV[0]) || usage(); +my($package) = lc($ARGV[0]) || usage(2); my($help)=0; GetOptions('help' => \$help); -usage() if($help); +usage(0) if($help); dget(getURL()); @@ -47,6 +48,8 @@ sub dget { } sub usage { + my($exit) = @_; my($name)=basename($0); - die("USAGE: $name [-h] \n"); + print("USAGE: $name [-h] \n"); + exit($exit); } diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py index 083c790..4b8e339 100644 --- a/ubuntutools/test/test_help.py +++ b/ubuntutools/test/test_help.py @@ -33,7 +33,6 @@ BLACKLIST = { 'massfile': 'No Help. Leaves files in .', 'mk-sbuild': 'Fires up apt-get before showing help', 'pbuilder-dist-simple': 'No Help', - 'pull-revu-source': 'Throws Error', 'setup-packaging-environment': 'Throws Error', 'submittodebian': 'No Help', 'ubuntu-iso': 'No Help', From f74f07507b4776a26302fec087f53044dcf49f76 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 19:36:58 +0200 Subject: [PATCH 11/12] 404main: Return non-zero when arguments don't parse. --- 404main | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/404main b/404main index 9301f70..82d77a2 100755 --- a/404main +++ b/404main @@ -104,15 +104,20 @@ def find_main(cache, pack): process_deps(cache, deps) +def usage(exit): + print 'Usage: %s []' % sys.argv[0] + sys.exit(exit) def main(): global packages, distro # Check if the amount of arguments is correct - if len(sys.argv) < 2 or len(sys.argv) > 3 or sys.argv[1] in ('help', '-h', '--help'): - print 'Usage: %s []' % sys.argv[0] - sys.exit(0) + if len(sys.argv) > 1 and sys.argv[1] in ('help', '-h', '--help'): + usage(0) + + if len(sys.argv) < 2 or len(sys.argv) > 3: + usage(1) cache = apt.cache.Cache() From c6a82f8bc171b19b05369cead8f62aa348d489bd Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 19:48:50 +0200 Subject: [PATCH 12/12] merge-changelog: Return non-zero when arguments don't parse. --- merge-changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/merge-changelog b/merge-changelog index d9f97fc..5ec3c97 100755 --- a/merge-changelog +++ b/merge-changelog @@ -28,7 +28,7 @@ merges them back together, and prints the merged result to stdout. This is useful if you need to manually merge a ubuntu package with a new Debian release of the package. ''' - sys.exit(0) + sys.exit(exit) ######################################################################## # Changelog Management