Package: dput Version: 0.9.2.21 Severity: normal Tags: patch Hi,
at Debcamp, I wrote a series of patches for dput, some of which apply to existing bug reports, and some others (mostly minor) don't, so here's the report for those. First an overview: delayed--help-fix Fixes --help for delayed/0-day dput-man-fix A minor fix for the synopis dput-README-fix Fixes some typos fix-upload-formating Removes the tabs in the uploading code, making the code more readable (required for the following patches) scp-fix-change_mode Adds debugging output no-terminal Don't print the progress information when the output is not a terminal unlink-option Adds a --unlink option (#181613) guess-distribution Guess the upload host based on the Distribution field (#348755) To make things easier, I'll attach all patches here, and also attach the relevant patches for the mentioned bug numbers there. Thanks, Christoph
Update --help for delayed/0.
Index: dput-0.9.2.21/dput
===================================================================
--- dput-0.9.2.21.orig/dput 2005-03-25 18:23:25.000000000 +0100
+++ dput-0.9.2.21/dput 2006-04-24 15:16:26.702549200 +0200
@@ -581,7 +581,7 @@ USAGE = """Usage: dput [host] <package(s
-c: Config file to parse.
-d: Activate debugging.
-D: Run dinstall after upload.
- -e: Upload to a delayed queue. Takes an argument from 1 to 15.
+ -e: Upload to a delayed queue. Takes an argument from 0 to 15.
-f: Force an upload.
-h: Display this help message.
-H: Display a list of hosts from the config file.
manpage: the 'changes' argument is not mandatory, and there can be many of them. Index: dput-0.9.2.21/dput.1 =================================================================== --- dput-0.9.2.21.orig/dput.1 2005-09-06 19:17:28.000000000 +0200 +++ dput-0.9.2.21/dput.1 2006-04-24 15:25:15.628928136 +0200 @@ -7,7 +7,7 @@ .B dput [\fIoptions\fR] [\fBhost\fR] -[\fBpackage.changes\fR] +\fBpackage.changes\fR ... .SH DESCRIPTION This is a tool for uploading Debian packages into the archive. You may specify to which host it should upload the file by passing it an
Fix some typos. Index: dput-0.9.2.21/README =================================================================== --- dput-0.9.2.21.orig/README 2002-10-15 08:46:07.000000000 +0200 +++ dput-0.9.2.21/README 2006-04-24 15:36:29.698013992 +0200 @@ -4,7 +4,7 @@ a few open bug reports and the code is i So I decided to start again and create a new tool for uploading packages into debian. This tool is dput, which will include more features -and be (hopefully) bugfree. It is written in python, since the author +and be (hopefully) bug free. It is written in python, since the author believes that python is a very good language. The features include: @@ -17,7 +17,7 @@ The features include: the package will be put on the correct server. * Running user-defined commands before and after an upload. -A lot of the tests can be run without really putting the packaging +A lot of the tests can be run without really putting the package into the archive. If you are still using PGP instead of GnuPG, please consider switching to
The vim modeline claimed that all tabs were 4 columns, which was wrong in
almost every case, making the code completely unreadable. This patch removes
all tabs from the source. Additionally, the wrong vim modeline is fixed.
Index: dput-0.9.2.21/dput
===================================================================
--- dput-0.9.2.21.orig/dput 2006-05-07 16:04:09.000000000 -0500
+++ dput-0.9.2.21/dput 2006-05-07 16:15:55.000000000 -0500
@@ -285,7 +285,7 @@ def verify_files(path, filename, host, c
change_file = os.path.join(path, name_of_file)
if debug:
- print "D: Validating contents of changes file %s" % change_file
+ print "D: Validating contents of changes file %s" % change_file
try:
chg_fd = open(change_file, 'r')
except IOError:
@@ -475,7 +475,7 @@ def dinstall_caller(filename, host, logi
if config.getboolean(host, 'run_dinstall') == 1 or dinstall:
if dputhelper.spawnv(os.P_WAIT, '/usr/bin/ssh', command):
print "Error occured while trying to connect, or while " +\
- "attempting to run dinstall."
+ "attempting to run dinstall."
sys.exit(1)
# Check if the caller has installed the package also on his system
@@ -501,45 +501,45 @@ def version_check(changes, debug):
if filename.find('.deb') != -1:
if debug:
print "D: Debian Package: %s" % filename
- dpkg_stdin,dpkg_stdout,dpkg_stderr = os.popen3('dpkg --field %s' %
filename)
- dpkg_stdin.close()
- dpkg_output = rfc822.Message(dpkg_stdout)
- dpkg_stdout.close()
- dpkg_stderr_output = dpkg_stderr.read()
- dpkg_stderr.close()
- if debug and dpkg_stderr_output:
- print "D: dpkg stderr output:",repr(dpkg_stderr_output)
- if dpkg_architecture and dpkg_output['architecture'] not in
['all',dpkg_architecture]:
- if debug:
- print "D: not install-checking %s due to arch mismatch"%filename
- else:
- package_name = dpkg_output['package']
- version_number = dpkg_output['version']
- if debug: print "D: Package to Check: %s" % package_name
- if debug: print "D: Version to Check: %s" % version_number
- files_to_check.append((package_name,version_number))
+ dpkg_stdin,dpkg_stdout,dpkg_stderr = os.popen3('dpkg --field %s' %
filename)
+ dpkg_stdin.close()
+ dpkg_output = rfc822.Message(dpkg_stdout)
+ dpkg_stdout.close()
+ dpkg_stderr_output = dpkg_stderr.read()
+ dpkg_stderr.close()
+ if debug and dpkg_stderr_output:
+ print "D: dpkg stderr output:",repr(dpkg_stderr_output)
+ if dpkg_architecture and dpkg_output['architecture'] not in
['all',dpkg_architecture]:
+ if debug:
+ print "D: not install-checking %s due to arch
mismatch"%filename
+ else:
+ package_name = dpkg_output['package']
+ version_number = dpkg_output['version']
+ if debug: print "D: Package to Check: %s" % package_name
+ if debug: print "D: Version to Check: %s" % version_number
+ files_to_check.append((package_name,version_number))
for file,version_to_check in files_to_check:
if debug: print "D: Name of Package: %s" % file
- dpkg_stdin,dpkg_stdout,dpkg_stderr = os.popen3('dpkg -s %s' % file)
- dpkg_stdin.close()
- dpkg_output = rfc822.Message(dpkg_stdout)
- dpkg_stdout.close()
- dpkg_stderr_output = dpkg_stderr.read()
- dpkg_stderr.close()
- if debug and dpkg_stderr_output:
- print "D: dpkg stderr output:",repr(dpkg_stderr_output)
- if dpkg_output.has_key('version'):
- installed_version = dpkg_output.dict['version']
+ dpkg_stdin,dpkg_stdout,dpkg_stderr = os.popen3('dpkg -s %s' % file)
+ dpkg_stdin.close()
+ dpkg_output = rfc822.Message(dpkg_stdout)
+ dpkg_stdout.close()
+ dpkg_stderr_output = dpkg_stderr.read()
+ dpkg_stderr.close()
+ if debug and dpkg_stderr_output:
+ print "D: dpkg stderr output:",repr(dpkg_stderr_output)
+ if dpkg_output.has_key('version'):
+ installed_version = dpkg_output.dict['version']
if debug: print "D: Installed-Version: %s" % installed_version
- if debug: print "D: Check-Version: %s" % \
- version_to_check
- if installed_version != version_to_check:
- print "Package to upload is not installed, but it appears " +\
- "you have an older version installed."
- else:
- print "Uninstalled Package. Test it before uploading it."
- sys.exit(1)
+ if debug: print "D: Check-Version: %s" % \
+ version_to_check
+ if installed_version != version_to_check:
+ print "Package to upload is not installed, but it appears " +\
+ "you have an older version installed."
+ else:
+ print "Uninstalled Package. Test it before uploading it."
+ sys.exit(1)
# Run a command that the user-defined in the config_file.
def execute_command(host, debug, type):
@@ -617,7 +617,7 @@ def main():
['debug', 'dinstall', 'check-only',
'check-version', 'config', 'force', 'help',
'host-list', 'lintian', 'passive', 'print',
'simulate',
- 'unchecked',
'delayed=', 'version'])
+ 'unchecked', 'delayed=', 'version'])
except getopt.error, msg:
print msg
sys.exit(1)
@@ -670,10 +670,10 @@ def main():
login = os.environ['USER']
if debug: print "D: Login: %s" % login
else:
- print "$USER not set, will use login."
- # Else use the current username
- login = pwd.getpwuid(os.getuid( ))[0]
- if debug:
+ print "$USER not set, will use login."
+ # Else use the current username
+ login = pwd.getpwuid(os.getuid( ))[0]
+ if debug:
print "D: User-ID: %s" % os.getuid()
print "D: Login: %s" % login
@@ -806,13 +806,13 @@ def main():
if (len(config.get(host, 'login')) != 0 and \
config.get(host, 'login') != 'username'):
login = config.get(host, 'login')
- if debug: print "D: Login %s from section %s used"%(login,host)
+ if debug: print "D: Login %s from section %s used"%(login,host)
elif (len(config.get('DEFAULT', 'login')) != 0 and \
config.get('DEFAULT', 'login') != 'username'):
login = config.get('DEFAULT', 'login')
- if debug: print "D: Default login %s used"%login
+ if debug: print "D: Default login %s used"%login
else:
- if debug: print "D: Neither host %s nor default login used. Using
%s" %(host,login)
+ if debug: print "D: Neither host %s nor default login used. Using
%s" %(host,login)
# Messy, yes. But it isn't referenced by the upload method anyway.
if config.get(host, 'method') == 'local':
@@ -820,22 +820,24 @@ def main():
else:
fqdn = config.get(host, 'fqdn')
incoming = config.get(host, 'incoming')
- if delay_upload:
- if int(delay_upload) == 0:
- print "Warning: You're trying to upload to DELAYED/0-day."
- if method=='ftp':
- print "Warning: If you get an error about not being able "\
- "to change the directory,\n" \
- " this is probably not " \
- "not a bug in dput, but rather a result of the\n"\
- " fact that debian.org's ftp upload"\
- "queues don't support delayed\n"\
- " uploads. Try gluck_delayed instead."
+
+ if delay_upload:
+ if int(delay_upload) == 0:
+ print "Warning: You're trying to upload to DELAYED/0-day."
+ if method=='ftp':
+ print "Warning: If you get an error about not being able "\
+ "to change the directory,\n" \
+ " this is probably not " \
+ "not a bug in dput, but rather a result of the\n"\
+ " fact that debian.org's ftp upload"\
+ "queues don't support delayed\n"\
+ " uploads. Try gluck_delayed instead."
if incoming[-1] == '/':
first_char = ''
else:
first_char = '/'
incoming += first_char + 'DELAYED/' + delay_upload + '-day'
+
# Do the actual upload
if not simulate:
if debug:
@@ -845,23 +847,23 @@ def main():
if method == 'ftp':
ftp_mode = config.getboolean(host, 'passive_ftp')
if ftp_passive_mode == 1: ftp_mode = 1
- if debug:
- if ftp_mode == 1:
- print "D: Using passive ftp"
- else:
- print "D: Using active ftp"
+ if debug:
+ if ftp_mode == 1:
+ print "D: Using passive ftp"
+ else:
+ print "D: Using active ftp"
upload_methods[method](
- fqdn, login, incoming,
- files_to_upload, debug, ftp_mode,
- progress=config.getint(host,'progress_indicator'))
+ fqdn, login, incoming,
+ files_to_upload, debug, ftp_mode,
+ progress=config.getint(host,'progress_indicator'))
elif method == 'scp':
if debug and config.getboolean(host, 'scp_compress'):
print "D: Setting compression for scp"
scp_compress = config.getboolean(host, 'scp_compress')
- ssh_config_options = filter(None, map(lambda x: x.strip(),
- config.get (host ,'ssh_config_options').split('\n')))
- if debug:
- print "D: ssh config options:\n "+'\n
'.join(ssh_config_options)
+ ssh_config_options = filter(None, map(lambda x: x.strip(),
+ config.get (host ,'ssh_config_options').split('\n')))
+ if debug:
+ print "D: ssh config options:\n "+'\n
'.join(ssh_config_options)
upload_methods[method](fqdn, login, incoming, \
files_to_upload, debug, scp_compress, ssh_config_options)
else:
@@ -907,4 +909,4 @@ if __name__ == '__main__':
main()
except KeyboardInterrupt:
print "exiting due to user interrupt."
-# vim: set expandtab tabstop=4 :
+# vim: set expandtab shiftwidth=4 :
Add debugging information and fix a typo.
Index: dput-0.9.2.21/scp.py
===================================================================
--- dput-0.9.2.21.orig/scp.py 2006-05-07 16:03:54.000000000 -0500
+++ dput-0.9.2.21/scp.py 2006-05-07 16:16:23.000000000 -0500
@@ -37,6 +37,8 @@ def upload(fqdn,login,incoming,files_to_
fix_command += ['-o', anopt]
fix_command += ['[EMAIL PROTECTED]' % (login, fqdn), 'chmod', '0644'] \
+ files_to_fix
+ print "D: Fixing some permissions"
+ print "D: %s" % fix_command
if dputhelper.spawnv(os.P_WAIT, '/usr/bin/ssh', fix_command):
- print "Error while fixing permission."
+ print "Error while fixing permissions."
sys.exit(1)
Don't let the ftp mode print progress information when the output is not a
terminal. Required to run from cron.
Requires the fix-upload-formating patch.
Index: dput-0.9.2.21/dput
===================================================================
--- dput-0.9.2.21.orig/dput 2006-05-07 16:34:25.000000000 -0500
+++ dput-0.9.2.21/dput 2006-05-10 13:37:33.000000000 -0500
@@ -852,10 +852,12 @@ def main():
print "D: Using passive ftp"
else:
print "D: Using active ftp"
+ progress = config.getint(host,'progress_indicator')
+ if not os.isatty(1):
+ progress = 0
upload_methods[method](
fqdn, login, incoming,
- files_to_upload, debug, ftp_mode,
- progress=config.getint(host,'progress_indicator'))
+ files_to_upload, debug, ftp_mode, progress)
elif method == 'scp':
if debug and config.getboolean(host, 'scp_compress'):
print "D: Setting compression for scp"
Allow to delete the uploaded files. Nice for building a local delayed queue in
a cronjob.
Index: dput-0.9.2.21debconf1/dput
===================================================================
--- dput-0.9.2.21debconf1.orig/dput 2006-05-10 13:38:43.000000000 -0500
+++ dput-0.9.2.21debconf1/dput 2006-05-10 19:21:15.000000000 -0500
@@ -31,7 +31,7 @@ config = None
upload_methods = {}
files_to_upload = []
simulate = unsigned_upload = delay_upload = 0
-debug = dinstall = check_only = 0
+debug = dinstall = check_only = unlink_files = 0
config_file = ''
dput_modules = ('')
@@ -93,6 +93,7 @@ def read_configs(extra_config, debug):
config.set('DEFAULT', 'allow_unsigned_uploads', '0')
config.set('DEFAULT', 'run_lintian', '0')
config.set('DEFAULT', 'run_dinstall', '0')
+ config.set('DEFAULT', 'unlink_files', '0')
config.set('DEFAULT', 'check_version', '0')
config.set('DEFAULT', 'scp_compress', '0')
config.set('DEFAULT', 'default_host_main', '')
@@ -591,6 +592,7 @@ USAGE = """Usage: dput [host] <package(s
-P: Use passive mode for ftp uploads.
-s: Simulate the upload only.
-u: Don't check GnuPG signature.
+ -U: Delete files after uploading.
-v: Display version information.
-V: Check the package version and then upload it.
"""
@@ -602,6 +604,7 @@ def main():
global check_only
global dinstall
global unsigned_upload
+ global unlink_files
global config_file
global delay_upload
@@ -613,11 +616,11 @@ def main():
# Parse Command Line Options.
try:
(opts, args) = getopt.getopt(sys.argv[1:],
- 'c:dDe:fhHlopPsuvV',
+ 'c:dDe:fhHlopPsuUvV',
['debug', 'dinstall', 'check-only',
'check-version', 'config', 'force', 'help',
'host-list', 'lintian', 'passive', 'print',
'simulate',
- 'unchecked', 'delayed=', 'version'])
+ 'unchecked', 'unlink', 'delayed=', 'version'])
except getopt.error, msg:
print msg
sys.exit(1)
@@ -651,6 +654,8 @@ def main():
simulate = 1
elif option in ('-u', '--unchecked'):
unsigned_upload = 1
+ elif option in ('-U', '--unlink'):
+ unlink_files = 1
elif option in ('-e', '--delayed'):
if arg in map(str, range(16)):
delay_upload = arg
@@ -883,6 +888,12 @@ def main():
create_upload_file(name_of_package, host, path, \
files_to_upload, debug)
print "Successfully uploaded packages."
+
+ # Optionally delete the files just uploaded
+ if unlink_files:
+ for file in files_to_upload:
+ os.unlink(file)
+ print "Deleted uploaded files."
else:
print "Simulated upload."
Index: dput-0.9.2.21debconf1/dput.1
===================================================================
--- dput-0.9.2.21debconf1.orig/dput.1 2006-05-10 13:38:42.000000000 -0500
+++ dput-0.9.2.21debconf1/dput.1 2006-05-10 13:38:43.000000000 -0500
@@ -73,6 +73,10 @@ unless specified otherwise in the config
.B --unchecked
\- don't check GnuPG signature on the changes file.
.P
+.BR "-U",
+.B --unlink
+\- delete files after uploading them.
+.P
.BR "-e",
.B --delayed
\- Upload to a DELAYED queue, rather than the usual Incoming. This
Index: dput-0.9.2.21/dput
===================================================================
--- dput-0.9.2.21.orig/dput 2006-05-09 16:11:12.000000000 -0500
+++ dput-0.9.2.21/dput 2006-05-10 13:36:42.000000000 -0500
@@ -91,6 +91,7 @@ def read_configs(extra_config, debug):
config.set('DEFAULT', 'method', 'scp')
config.set('DEFAULT', 'hash', 'md5')
config.set('DEFAULT', 'allow_unsigned_uploads', '0')
+ config.set('DEFAULT', 'distributions', '')
config.set('DEFAULT', 'run_lintian', '0')
config.set('DEFAULT', 'run_dinstall', '0')
config.set('DEFAULT', 'unlink_files', '0')
@@ -423,6 +424,8 @@ def run_lintian_test(changes_file):
# on information from the changes file.
def guess_upload_host(path, filename):
non_us = 0
+ distribution = ""
+ dist_re = re.compile(r'^Distribution: (.*)')
name_of_file = filename
changes_file = os.path.join(path, name_of_file)
@@ -434,9 +437,23 @@ def guess_upload_host(path, filename):
sys.exit(1)
lines = changes_file_fd.readlines()
for line in lines:
+ match = dist_re.search(line)
+ if match:
+ distribution = match.group(1)
if line.find('non-US/') != -1 or line.find('non-us/') != -1:
non_us = 1
- break
+
+ # Try to guess a host based on the Distribution: field
+ if distribution:
+ for section in config.sections():
+ host_dists = config.get(section, 'distributions')
+ if not host_dists:
+ continue
+ for host_dist in host_dists.split(','):
+ if distribution == host_dist.strip():
+ if debug:
+ print "D: guessing host %s based on distribution %s" %
(section, host_dist)
+ return section
if non_us:
if len(config.get('DEFAULT', 'default_host_non-us')) != 0:
@@ -694,8 +711,13 @@ def main():
print "Default Method: %s" % config.get('DEFAULT','method')
print
for section in config.sections():
- print "%s => %s (Upload method: %s)" % (section, \
- config.get(section,'fqdn'), config.get(section,'method'))
+ distributions = ""
+ if config.get(section,'distributions'):
+ distributions = ", distributions: %s" % \
+ config.get(section,'distributions')
+ print "%s => %s (Upload method: %s%s)" % (section, \
+ config.get(section,'fqdn'), config.get(section,'method'), \
+ distributions)
print
sys.exit(0)
Index: dput-0.9.2.21/dput.cf.5
===================================================================
--- dput-0.9.2.21.orig/dput.cf.5 2006-05-09 16:11:12.000000000 -0500
+++ dput-0.9.2.21/dput.cf.5 2006-05-10 13:36:42.000000000 -0500
@@ -74,6 +74,10 @@ use the sha algorithm for calculation
This defines if you are allowed to upload files without a GnuPG
signature to this host or not.
.TP
+.B distributions
+This defines a comma-separated list of distributions that this host accepts,
+used to guess the host to use when none is given on the command line.
+.TP
.B run_lintian
This option defines if lintian should be run before the package will
be uploaded or not. If the package is not lintian clean, the upload will
signature.asc
Description: Digital signature

