648
642
print "Total: %s" % (stat_count)
654
parser = optparse.OptionParser()
655
logger_options(parser)
656
parser.add_option("-a", "--all", dest="all",
657
default=False, action="store_true",
658
help="sync all packages")
659
parser.add_option("-b", "--requested-by", dest="requestor",
660
help="who the sync was requested by")
661
parser.add_option("-f", "--force", dest="force",
662
default=False, action="store_true",
663
help="force sync over the top of Ubuntu changes")
664
parser.add_option("-F", "--force-more", dest="forcemore",
665
default=False, action="store_true",
666
help="force sync even when components don't match")
667
parser.add_option("-n", "--noaction", dest="action",
668
default=True, action="store_false",
669
help="don't do anything")
671
# XXX cprov 2007-07-03: Why the heck doesn't -v provide by logger provide
673
parser.add_option("-V", "--moreverbose", dest="moreverbose",
674
default=False, action="store_true",
675
help="be even more verbose")
677
# Options controlling where to sync packages to:
678
parser.add_option("-c", "--to-component", dest="tocomponent",
679
help="limit syncs to packages in COMPONENT")
680
parser.add_option("-d", "--to-distro", dest="todistro",
681
default='ubuntu', help="sync to DISTRO")
682
parser.add_option("-s", "--to-suite", dest="tosuite",
683
help="sync to SUITE (aka distroseries)")
685
# Options controlling where to sync packages from:
686
parser.add_option("-C", "--from-component", dest="fromcomponent",
687
help="sync from COMPONENT")
688
parser.add_option("-D", "--from-distro", dest="fromdistro",
689
default='debian', help="sync from DISTRO")
690
parser.add_option("-S", "--from-suite", dest="fromsuite",
691
help="sync from SUITE (aka distroseries)")
692
parser.add_option("-B", "--blacklist", dest="blacklist_path",
693
default="/srv/launchpad.net/dak/sync-blacklist.txt",
694
help="Blacklist file path.")
697
(Options, arguments) = parser.parse_args()
699
distro = Options.fromdistro.lower()
700
if not Options.fromcomponent:
701
Options.fromcomponent = origins[distro]["default component"]
702
if not Options.fromsuite:
703
Options.fromsuite = origins[distro]["default suite"]
705
# Sanity checks on options
706
if not Options.all and not arguments:
708
"Need -a/--all or at least one package name as an argument.")
713
645
def objectize_options():
714
646
"""Parse given options.
791
global Blacklisted, Library, Lock, Log, Options
795
arguments = options_setup()
797
Log = logger(Options, "sync-source")
799
Log.debug("Acquiring lock")
800
Lock = GlobalLock('/var/lock/launchpad-sync-source.lock')
801
Lock.acquire(blocking=True)
803
Log.debug("Initializing connection.")
804
execute_zcml_for_scripts()
805
initZopeless(dbuser="ro")
807
Library = LibrarianClient()
811
Blacklisted = parseBlacklist(Options.blacklist_path)
819
origin = origins[Options.fromdistro]
820
origin["suite"] = Options.fromsuite
821
origin["component"] = Options.fromcomponent
823
Sources = read_Sources("Sources", origin)
824
Suite = read_current_source(
825
Options.tosuite, Options.tocomponent, arguments)
826
current_binaries = read_current_binaries(Options.tosuite)
827
do_diff(Sources, Suite, origin, arguments, current_binaries)
722
class SyncSourceScript(LaunchpadScript):
724
def add_my_options(self):
725
self.parser.add_option("-a", "--all", dest="all",
726
default=False, action="store_true",
727
help="sync all packages")
728
self.parser.add_option("-b", "--requested-by", dest="requestor",
729
help="who the sync was requested by")
730
self.parser.add_option("-f", "--force", dest="force",
731
default=False, action="store_true",
732
help="force sync over the top of Ubuntu changes")
733
self.parser.add_option("-F", "--force-more", dest="forcemore",
734
default=False, action="store_true",
735
help="force sync even when components don't match")
736
self.parser.add_option("-n", "--noaction", dest="action",
737
default=True, action="store_false",
738
help="don't do anything")
740
# Options controlling where to sync packages to:
741
self.parser.add_option("-c", "--to-component", dest="tocomponent",
742
help="limit syncs to packages in COMPONENT")
743
self.parser.add_option("-d", "--to-distro", dest="todistro",
744
default='ubuntu', help="sync to DISTRO")
745
self.parser.add_option("-s", "--to-suite", dest="tosuite",
746
help="sync to SUITE (aka distroseries)")
748
# Options controlling where to sync packages from:
749
self.parser.add_option("-C", "--from-component", dest="fromcomponent",
750
help="sync from COMPONENT")
751
self.parser.add_option("-D", "--from-distro", dest="fromdistro",
752
default='debian', help="sync from DISTRO")
753
self.parser.add_option("-S", "--from-suite", dest="fromsuite",
754
help="sync from SUITE (aka distroseries)")
755
self.parser.add_option("-B", "--blacklist", dest="blacklist_path",
756
default="/srv/launchpad.net/dak/sync-blacklist.txt",
757
help="Blacklist file path.")
760
global Blacklisted, Library, Log, Options
763
Options = self.options
765
distro = Options.fromdistro.lower()
766
if not Options.fromcomponent:
767
Options.fromcomponent = origins[distro]["default component"]
768
if not Options.fromsuite:
769
Options.fromsuite = origins[distro]["default suite"]
771
# Sanity checks on options
772
if not Options.all and not self.args:
774
"Need -a/--all or at least one package name as an argument.")
777
Library = LibrarianClient()
781
Blacklisted = parseBlacklist(Options.blacklist_path)
783
origin = origins[Options.fromdistro]
784
origin["suite"] = Options.fromsuite
785
origin["component"] = Options.fromcomponent
787
Sources = read_Sources("Sources", origin)
788
Suite = read_current_source(
789
Options.tosuite, Options.tocomponent, self.args)
790
current_binaries = read_current_binaries(Options.tosuite)
791
do_diff(Sources, Suite, origin, self.args, current_binaries)
830
794
if __name__ == '__main__':
795
SyncSourceScript('sync-source', 'ro').lock_and_run()