def test_gpg_info(self): if not (os.path.exists('/usr/bin/gpgv') and os.path.exists('/usr/share/keyrings/debian-keyring.gpg')): return unparsed_with_gpg = SIGNED_CHECKSUM_CHANGES_FILE % CHECKSUM_CHANGES_FILE deb822_from_str = deb822.Dsc(unparsed_with_gpg) result_from_str = deb822_from_str.get_gpg_info() deb822_from_file = deb822.Dsc(StringIO(unparsed_with_gpg)) result_from_file = deb822_from_file.get_gpg_info() deb822_from_lines = deb822.Dsc(unparsed_with_gpg.splitlines()) result_from_lines = deb822_from_lines.get_gpg_info() valid = { 'GOODSIG': ['D14219877A786561', 'John Wright <*****@*****.**>'], 'VALIDSIG': [ '8FEFE900783CF175827C2F65D14219877A786561', '2008-05-01', '1209623566', '0', '3', '0', '17', '2', '01', '8FEFE900783CF175827C2F65D14219877A786561' ], 'SIG_ID': ['j3UjSpdky92fcQISbm8W5PlwC/g', '2008-05-01', '1209623566'], } for result in result_from_str, result_from_file, result_from_lines: # The second part of the GOODSIG field could change if the primary # uid changes, so avoid checking that. Also, the first part of the # SIG_ID field has undergone at least one algorithm changein gpg, # so don't bother testing that either. self.assertEqual(set(result.keys()), set(valid.keys())) self.assertEqual(result['GOODSIG'][0], valid['GOODSIG'][0]) self.assertEqual(result['VALIDSIG'], valid['VALIDSIG']) self.assertEqual(result['SIG_ID'][1:], valid['SIG_ID'][1:])
def generate_satisfydepends(self): dsc_file = file(self.config.dsc) dsc = deb822.Dsc(dsc_file) dsc_file.close() if (dsc.has_key('Build-Depends')): depends = dsc['Build-Depends'] else: depends = None if (dsc.has_key('Build-Conflicts')): conflicts = dsc['Build-Conflicts'] else: conflicts = None s = Template(self.satisfydepends_control) v = {} v['ARCH'] = self.config.arch if depends: v['DEPENDS'] = "Depends: %s\n" % depends else: v['DEPENDS'] = "" if conflicts: v['CONFLICTS'] = "Conflicts: %s\n" % conflicts else: v['CONFLICTS'] = "" self.satisfydepends_control = s.safe_substitute(v)
def test_multivalued_field_contains_newline(self): """Multivalued field components are not allowed to contain newlines""" d = deb822.Dsc() # We don't check at set time, since one could easily modify the list # without deb822 knowing. We instead check at get time. d['Files'] = [{'md5sum': 'deadbeef', 'size': '9605', 'name': 'bad\n'}] self.assertRaises(ValueError, d.get_as_string, 'files')
def execute(self, client, _opt, args): if len(args) != 2: print( "usage: elbe prjrepo upload_pkg <project_dir> <deb/dsc/changes file>", file=sys.stderr) sys.exit(20) builddir = args[0] filename = args[1] print("\n--------------------------") print("Upload and Include Package") print("--------------------------") print("Check files...") filetype = os.path.splitext(filename)[1] # Check filetype if filetype not in ['.dsc', '.deb', '.changes']: print( "Error: Only .dsc, .deb or .changes files allowed to upload.") sys.exit(20) files = [filename] # list of all files which will be uploaded # Parse .dsc-File and append neccessary source files to files if filetype == '.dsc': for f in deb822.Dsc(open(filename))['Files']: files.append(f['name']) if filetype == '.changes': for f in deb822.Changes(open(filename))['Files']: files.append(f['name']) # Check whether all files are available abort = False for f in files: if not os.path.isfile(f): print("File %s not found." % f) abort = True # Abort if one or more source files are missing if abort: sys.exit(20) print("Start uploading file(s)...") for f in files: print("Upload %s..." % f) self.upload_file(client, f, builddir) print("Including Package in initvm...") client.service.include_package(builddir, os.path.basename(filename))
def copy_dsc_files(self): ok = False with open(self.config.dsc) as dsc_file: dsc_obj = deb822.Dsc(dsc_file) dsc_file.close() (path_head, path_tail) = os.path.split(self.config.dsc) print(path_head, path_tail) file_srcs = [self.config.dsc] for f in dsc_obj['Files']: file_srcs += [os.path.join(path_head, f['name'])] for f in file_srcs: print("I: Copying '%s' to '%s'" % (os.path.basename(f), self.build_location)) shutil.copy2(os.path.join(path_head, f), self.build_location) ok = True return ok