107
111
return urgency_map.get(n, 'low')
114
def sign_changes(changes, dsc):
115
# XXX cprov 2007-07-06: hardcoded file locations and parameters for
117
temp_filename = "unsigned-changes"
119
secret_keyring = "/srv/launchpad.net/dot-gnupg/secring.gpg"
120
pub_keyring = "/srv/launchpad.net/dot-gnupg/pubring.gpg"
122
filehandle = open(temp_filename, 'w')
123
filehandle.write(changes)
126
output_filename = "%s_%s_source.changes" % (
127
dsc["source"], dak_utils.re_no_epoch.sub('', dsc["version"]))
129
cmd = ("gpg --no-options --batch --no-tty --secret-keyring=%s "
130
"--keyring=%s --default-key=0x%s --output=%s --clearsign %s" %
131
(secret_keyring, pub_keyring, keyid, output_filename,
133
result, output = commands.getstatusoutput(cmd)
136
print " * command was '%s'" % (cmd)
137
print (dak_utils.prefix_multi_line_string(
138
output, " [gpg output:] "), "")
139
dak_utils.fubar("%s: signing .changes failed [return code: %s]." %
140
(output_filename, result))
142
os.unlink(temp_filename)
110
145
def parse_changelog(changelog_filename, previous_version):
111
146
if not os.path.exists(changelog_filename):
112
raise LaunchpadScriptFailure(
113
"debian/changelog not found in extracted source.")
147
dak_utils.fubar("debian/changelog not found in extracted source.")
114
148
urgency = urgency_to_numeric('low')
116
150
is_debian_changelog = 0
309
340
(gpg_pre, payload, gpg_post) = Dsc.split_gpg_and_payload(dsc_file)
310
341
if gpg_pre == [] and gpg_post == []:
311
raise LaunchpadScriptFailure(
312
"signature required for %s but not present" % dsc_filename)
342
dak_utils.fubar("signature required for %s but not present"
313
344
if signing_rules == "must be signed and valid":
314
345
if (gpg_pre[0] != "-----BEGIN PGP SIGNED MESSAGE-----" or
315
346
gpg_post[0] != "-----BEGIN PGP SIGNATURE-----"):
316
raise LaunchpadScriptFailure(
317
"signature for %s invalid %r %r" %
318
(dsc_filename, gpg_pre, gpg_post))
347
dak_utils.fubar("signature for %s invalid %r %r" % (
348
dsc_filename, gpg_pre, gpg_post))
320
350
dsc_files = dict((entry['name'], entry) for entry in dsc['files'])
321
351
check_dsc(dsc, current_sources, current_binaries)
607
627
% (pkg, dest_version, source_version))
610
percentages = Percentages(stat_count)
612
631
print ("Out-of-date BUT modified: %3d (%.2f%%)"
613
% (stat_cant_update, percentages.get_ratio(stat_cant_update)))
632
% (stat_cant_update, (float(stat_cant_update)/stat_count)*100))
614
633
print ("Updated: %3d (%.2f%%)"
615
% (stat_updated, percentages.get_ratio(stat_updated)))
634
% (stat_updated, (float(stat_updated)/stat_count)*100))
616
635
print ("Ubuntu Specific: %3d (%.2f%%)"
617
% (stat_us, percentages.get_ratio(stat_us)))
636
% (stat_us, (float(stat_us)/stat_count)*100))
618
637
print ("Up-to-date [Modified]: %3d (%.2f%%)"
619
% (stat_uptodate_modified, percentages.get_ratio(
620
stat_uptodate_modified)))
638
% (stat_uptodate_modified,
639
(float(stat_uptodate_modified)/stat_count)*100))
621
640
print ("Up-to-date: %3d (%.2f%%)"
622
% (stat_uptodate, percentages.get_ratio(stat_uptodate)))
641
% (stat_uptodate, (float(stat_uptodate)/stat_count)*100))
623
642
print ("Blacklisted: %3d (%.2f%%)"
624
% (stat_blacklisted, percentages.get_ratio(stat_blacklisted)))
643
% (stat_blacklisted, (float(stat_blacklisted)/stat_count)*100))
625
644
print ("Broken: %3d (%.2f%%)"
626
% (stat_broken, percentages.get_ratio(stat_broken)))
645
% (stat_broken, (float(stat_broken)/stat_count)*100))
627
646
print " -----------"
628
647
print "Total: %s" % (stat_count)
653
parser = optparse.OptionParser()
654
logger_options(parser)
655
parser.add_option("-a", "--all", dest="all",
656
default=False, action="store_true",
657
help="sync all packages")
658
parser.add_option("-b", "--requested-by", dest="requestor",
659
help="who the sync was requested by")
660
parser.add_option("-f", "--force", dest="force",
661
default=False, action="store_true",
662
help="force sync over the top of Ubuntu changes")
663
parser.add_option("-F", "--force-more", dest="forcemore",
664
default=False, action="store_true",
665
help="force sync even when components don't match")
666
parser.add_option("-n", "--noaction", dest="action",
667
default=True, action="store_false",
668
help="don't do anything")
670
# XXX cprov 2007-07-03: Why the heck doesn't -v provide by logger provide
672
parser.add_option("-V", "--moreverbose", dest="moreverbose",
673
default=False, action="store_true",
674
help="be even more verbose")
676
# Options controlling where to sync packages to:
677
parser.add_option("-c", "--to-component", dest="tocomponent",
678
help="limit syncs to packages in COMPONENT")
679
parser.add_option("-d", "--to-distro", dest="todistro",
680
default='ubuntu', help="sync to DISTRO")
681
parser.add_option("-s", "--to-suite", dest="tosuite",
682
help="sync to SUITE (aka distroseries)")
684
# Options controlling where to sync packages from:
685
parser.add_option("-C", "--from-component", dest="fromcomponent",
686
help="sync from COMPONENT")
687
parser.add_option("-D", "--from-distro", dest="fromdistro",
688
default='debian', help="sync from DISTRO")
689
parser.add_option("-S", "--from-suite", dest="fromsuite",
690
help="sync from SUITE (aka distroseries)")
691
parser.add_option("-B", "--blacklist", dest="blacklist_path",
692
default="/srv/launchpad.net/dak/sync-blacklist.txt",
693
help="Blacklist file path.")
696
(Options, arguments) = parser.parse_args()
698
distro = Options.fromdistro.lower()
699
if not Options.fromcomponent:
700
Options.fromcomponent = origins[distro]["default component"]
701
if not Options.fromsuite:
702
Options.fromsuite = origins[distro]["default suite"]
704
# Sanity checks on options
705
if not Options.all and not arguments:
707
"Need -a/--all or at least one package name as an argument.")
631
712
def objectize_options():
632
713
"""Parse given options.
708
class SyncSourceScript(LaunchpadScript):
710
def add_my_options(self):
711
self.parser.add_option("-a", "--all", dest="all",
712
default=False, action="store_true",
713
help="sync all packages")
714
self.parser.add_option("-b", "--requested-by", dest="requestor",
715
help="who the sync was requested by")
716
self.parser.add_option("-f", "--force", dest="force",
717
default=False, action="store_true",
718
help="force sync over the top of Ubuntu changes")
719
self.parser.add_option("-F", "--force-more", dest="forcemore",
720
default=False, action="store_true",
721
help="force sync even when components don't match")
722
self.parser.add_option("-n", "--noaction", dest="action",
723
default=True, action="store_false",
724
help="don't do anything")
726
# Options controlling where to sync packages to:
727
self.parser.add_option("-c", "--to-component", dest="tocomponent",
728
help="limit syncs to packages in COMPONENT")
729
self.parser.add_option("-d", "--to-distro", dest="todistro",
730
default='ubuntu', help="sync to DISTRO")
731
self.parser.add_option("-s", "--to-suite", dest="tosuite",
732
help="sync to SUITE (aka distroseries)")
734
# Options controlling where to sync packages from:
735
self.parser.add_option("-C", "--from-component", dest="fromcomponent",
736
help="sync from COMPONENT")
737
self.parser.add_option("-D", "--from-distro", dest="fromdistro",
738
default='debian', help="sync from DISTRO")
739
self.parser.add_option("-S", "--from-suite", dest="fromsuite",
740
help="sync from SUITE (aka distroseries)")
741
self.parser.add_option("-B", "--blacklist", dest="blacklist_path",
742
default="/srv/launchpad.net/dak/sync-blacklist.txt",
743
help="Blacklist file path.")
746
global Blacklisted, Library, Log, Options
749
Options = self.options
751
distro = Options.fromdistro.lower()
752
if not Options.fromcomponent:
753
Options.fromcomponent = origins[distro]["default component"]
754
if not Options.fromsuite:
755
Options.fromsuite = origins[distro]["default suite"]
757
# Sanity checks on options
758
if not Options.all and not self.args:
759
raise LaunchpadScriptFailure(
760
"Need -a/--all or at least one package name as an argument.")
763
Library = LibrarianClient()
767
Blacklisted = parseBlacklist(Options.blacklist_path)
769
origin = origins[Options.fromdistro]
770
origin["suite"] = Options.fromsuite
771
origin["component"] = Options.fromcomponent
773
Sources = read_Sources("Sources", origin)
774
Suite = read_current_source(
775
Options.tosuite, Options.tocomponent, self.args)
776
current_binaries = read_current_binaries(Options.tosuite)
777
do_diff(Sources, Suite, origin, self.args, current_binaries)
790
global Blacklisted, Library, Lock, Log, Options
794
arguments = options_setup()
796
Log = logger(Options, "sync-source")
798
Log.debug("Acquiring lock")
799
Lock = GlobalLock('/var/lock/launchpad-sync-source.lock')
800
Lock.acquire(blocking=True)
802
Log.debug("Initializing connection.")
803
execute_zcml_for_scripts()
804
initZopeless(dbuser="ro")
806
Library = LibrarianClient()
810
Blacklisted = parseBlacklist(Options.blacklist_path)
818
origin = origins[Options.fromdistro]
819
origin["suite"] = Options.fromsuite
820
origin["component"] = Options.fromcomponent
822
Sources = read_Sources("Sources", origin)
823
Suite = read_current_source(
824
Options.tosuite, Options.tocomponent, arguments)
825
current_binaries = read_current_binaries(Options.tosuite)
826
do_diff(Sources, Suite, origin, arguments, current_binaries)
780
829
if __name__ == '__main__':
781
SyncSourceScript('sync-source', 'ro').lock_and_run()