Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

Mine
Monday, July 9th, 2007 at 3:12:58am UTC 

  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import os
  5. import deb822
  6.  
  7. def get_filenames(f):
  8.     base = os.path.dirname(f)
  9.     if f.endswith('.dsc'):
  10.         d = deb822.Dsc(file(f))
  11.     elif f.endswith('.changes'):
  12.         d = deb822.Changes(file(f))
  13.     return [os.path.join(base, elt['name']) for elt in d['Files']] + [f]
  14.  
  15. def get_distro(files_list):
  16.     "Runs sed on the .diff.gz to find what pbuilder to run."
  17.     ## Assumes that pbuilders are named in the pbuilder-sed , pbuilder-gutsy
  18.     ## style.
  19.  
  20.     for file in files_list:
  21.         if file.endswith('.changes'):
  22.             changes_file = file.open(file, 'r')
  23.             for line in changes_file.readlines():
  24.                 if line.split(';')[0].split()[-1] == True:
  25.                     return line.split(';')[0].split()[-1]
  26.  
  27. def get_dsc(files_list):
  28.     for file in files_list:
  29.         if file.endswith('.dsc'):
  30.             return file
  31.  
  32. if len (sys.argv) < 3:
  33.     print "Usage: drsync foo.dsc [OPTIONS...] [email protected]:/path/to/incomming"
  34.     print "See man rsync(1) for accepted Options"
  35.  
  36. dest = sys.argv[-1]
  37.  
  38. files = []
  39. for f in sys.argv[1:-1]:
  40.     files += get_filenames(f)
  41.  
  42. distro = get_distro(files)
  43.  
  44. if dest.endswith('/') == False:
  45.     rdsc = dest.split(':')[-1] + '/' + get_dsc(files)
  46. else:
  47.     rdsc = dest.split(':')[-1] + get_dsc(files)
  48.  
  49. os.execvp('rsync', ['rsync'] + files + [dest])
  50. os.execvp('ssh', ['ssh'] + [dest] + '": pbuilder-' + distro + 'build ' + rdsc)

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right