404main, merge-changelog, pull-debian-debdiff, pull-debian-source:

Return 0 after showing help.
This commit is contained in:
Stefano Rivera 2010-12-22 16:53:58 +02:00
parent 8756577518
commit c4de897e2a
6 changed files with 25 additions and 14 deletions

View File

@ -112,7 +112,7 @@ def main():
# Check if the amount of arguments is correct # 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'): if len(sys.argv) < 2 or len(sys.argv) > 3 or sys.argv[1] in ('help', '-h', '--help'):
print 'Usage: %s <package name> [<distribution>]' % sys.argv[0] print 'Usage: %s <package name> [<distribution>]' % sys.argv[0]
sys.exit(1) sys.exit(0)
cache = apt.cache.Cache() cache = apt.cache.Cache()

4
debian/changelog vendored
View File

@ -16,6 +16,8 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low
* Add the beginnings of a test suite. (LP: #690386) * Add the beginnings of a test suite. (LP: #690386)
- Switch to setuptools, to support setup.py test. - Switch to setuptools, to support setup.py test.
- Test for that every script can run --help and return 0. - 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 * ubuntutools/common.py: Remove https_proxy unsetting code, working around
LP: #94130. 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 'str' object has no attribute 'startwith' crash caused by a typo.
- Fix crash if uploading to ubuntu without building the package before. - Fix crash if uploading to ubuntu without building the package before.
-- Stefano Rivera <stefanor@ubuntu.com> Wed, 22 Dec 2010 15:02:45 +0200 -- Stefano Rivera <stefanor@ubuntu.com> Wed, 22 Dec 2010 16:52:55 +0200
ubuntu-dev-tools (0.108) experimental; urgency=low ubuntu-dev-tools (0.108) experimental; urgency=low

View File

@ -20,7 +20,7 @@
import sys, re import sys, re
def usage(): def usage(exit=1):
print '''Usage: merge-changelog <left changelog> <right changelog> print '''Usage: merge-changelog <left changelog> <right changelog>
merge-changelog takes two changelogs that once shared a common source, 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 is useful if you need to manually merge a ubuntu package with a new
Debian release of the package. Debian release of the package.
''' '''
sys.exit(1) sys.exit(0)
######################################################################## ########################################################################
# Changelog Management # Changelog Management
@ -253,8 +253,10 @@ def deb_cmp(x, y):
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] in ('-h', '--help'):
usage(exit=0)
if len(sys.argv) != 3: if len(sys.argv) != 3:
usage() usage(exit=1)
left_changelog = sys.argv[1] left_changelog = sys.argv[1]
right_changelog = sys.argv[2] right_changelog = sys.argv[2]

View File

@ -115,6 +115,13 @@ sub download_source
return 1; return 1;
} }
sub usage
{
my ($exit) = @_;
print "Usage: $0 PKG VERSION\n";
exit $exit;
}
my $pkg = $ARGV[0]; my $pkg = $ARGV[0];
@ -123,8 +130,10 @@ my $just_fetch = ($ARGV[2] && $ARGV[2] eq "--fetch");
my $skip = $ARGV[2] || 1; my $skip = $ARGV[2] || 1;
$skip+=0; $skip+=0;
if (!defined($pkg) || !defined($version)) { if (defined($pkg) && ($pkg eq '--help' || $pkg eq '-h')) {
die "Usage: $0 PKG VERSION\n"; usage(0);
} elsif (!defined($pkg) || !defined($version)) {
usage(2);
} }

View File

@ -27,10 +27,10 @@ use AptPkg::Version;
die("Please install 'devscripts'\n") if(! grep -x "$_/dget", split(':',$ENV{'PATH'})); die("Please install 'devscripts'\n") if(! grep -x "$_/dget", split(':',$ENV{'PATH'}));
my($name)=basename($0); my($name)=basename($0);
my($package)=$ARGV[0] || &usage(); my($package)=$ARGV[0] || &usage(2);
my($help)=0; my($help)=0;
GetOptions('help' => \$help); GetOptions('help' => \$help);
&usage() if($help); &usage(0) if($help);
my($release)=$ARGV[1] || 'unstable'; my($release)=$ARGV[1] || 'unstable';
$release=&convertCodeName($release); $release=&convertCodeName($release);
&checkRelease($release); &checkRelease($release);
@ -132,7 +132,9 @@ sub getDSC {
} }
sub usage { sub usage {
die("USAGE: $name [-h] <source package> [target release]\n"); my($exit)=shift;
print("USAGE: $name [-h] <source package> [target release]\n");
exit($exit);
} }
sub invalidRelease { sub invalidRelease {
my($releases)=shift || die("Invalid Release!"); my($releases)=shift || die("Invalid Release!");

View File

@ -25,17 +25,13 @@ import setup
from ubuntutools.test import unittest from ubuntutools.test import unittest
BLACKLIST = { BLACKLIST = {
'404main': 'Returns non-zero after help',
'check-symbols': 'No Help', 'check-symbols': 'No Help',
'edit-patch': 'No Help', 'edit-patch': 'No Help',
'grep-merges': 'No Help', 'grep-merges': 'No Help',
'lp-project-upload': 'Returns non-zero after help. Leaving u-d-t in LP: #524680', 'lp-project-upload': 'Returns non-zero after help. Leaving u-d-t in LP: #524680',
'massfile': 'No Help. Leaves files in .', 'massfile': 'No Help. Leaves files in .',
'merge-changelog': 'Returns non-zero after help',
'mk-sbuild': 'Fires up apt-get before showing help', 'mk-sbuild': 'Fires up apt-get before showing help',
'pbuilder-dist-simple': 'No 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', 'pull-revu-source': 'Throws Error',
'setup-packaging-environment': 'Throws Error', 'setup-packaging-environment': 'Throws Error',
'submittodebian': 'No Help', 'submittodebian': 'No Help',