Class: Rock::CLI::ReleaseAdmin

Inherits:
Thor
  • Object
show all
Defined in:
lib/rock/cli/release_admin.rb

Overview

Implementation of the rock-release admin subcommand

Defined Under Namespace

Classes: Maintainers

Constant Summary collapse

ROCK_VCS_LOCATIONS =
[
#/gitorious.*\/rock(?:-[\w-]+)?\//,
/github.*\/rock(?:-[\w-]+)?\//,
/github.*\/orocos-toolchain\//]
DEFAULT_MAILMAP =
File.expand_path("release_mailmap.yml", File.dirname(__FILE__))
RC_ANNOUNCEMENT_FROM =
"Rock Developers <rock-dev@dfki.de>"
RC_ANNOUNCEMENT_TEMPLATE_PATH =
File.expand_path(
File.join("..", "templates", "rock-release-announce-rc.email.template"),
File.dirname(__FILE__))

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authors_of[String]

List of package names for which this group of people are declared as authors, and for which no maintainer is explicitely declared

Returns:

  • ([String])


# File 'lib/rock/cli/release_admin.rb', line 365

#emails[String]

The list of maintainers emails, formatted as “Name &lt;email&gt;”

Returns:

  • ([String])


# File 'lib/rock/cli/release_admin.rb', line 365

#external_master_packages[String]

The name of the master-only packages maintained by this group of people, that are NOT managed within the Rock infrastructure

Returns:

  • ([String])


# File 'lib/rock/cli/release_admin.rb', line 365

#external_stable_packages[String]

The name of the packages present in stable, maintained by this group of people, that are NOT managed within the Rock infrastructure

Returns:

  • ([String])


# File 'lib/rock/cli/release_admin.rb', line 365

#maintainers_of[String]

List of package names for which this group of people are explicitely declared as maintainers

Returns:

  • ([String])


# File 'lib/rock/cli/release_admin.rb', line 365

#rock_master_packages[String]

The name of the master-only packages maintained by this group of people, that are managed within the Rock infrastructure

Returns:

  • ([String])


# File 'lib/rock/cli/release_admin.rb', line 365

#rock_stable_packages[String]

The name of the packages present in stable, maintained by this group of people, that are managed within the Rock infrastructure

Returns:

  • ([String])


# File 'lib/rock/cli/release_admin.rb', line 365

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


13
# File 'lib/rock/cli/release_admin.rb', line 13

def self.exit_on_failure?; true end

Instance Method Details

#announce_rc(rock_release_name) ⇒ Object



472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/rock/cli/release_admin.rb', line 472

def announce_rc(rock_release_name)
    template = ERB.new(File.read(RC_ANNOUNCEMENT_TEMPLATE_PATH), nil, "<>")

    all_maintainers, warnings = compute_maintainers do |pkg|
        # Only look at packages in rock. rock.core, rock.tutorials
        # and orocos.toolchain are handled differently
        pkg.package_set.name == 'rock'
    end

    warnings.each do |pkg_name, w|
        pkg = manifest.find_package(pkg_name)
        w.each do |line|
            ReleaseAdmin.warn "#{pkg.name}: #{line}"
        end
    end

    package_count = 0
    emails = Array.new
    all_maintainers.each do |m|
        packages = m.maintainers_of + m.authors_of + m.guessed_authors_of
        package_count += packages.size
        subject = "Let's prepare Rock #{rock_release_name}"
        subject_packages = Array.new
        remaining = 80 - subject.size - 10
        while !packages.empty? && (remaining > packages.first.size)
            subject_packages << packages.shift
            remaining -= subject_packages.last.size - 2
        end
        subject = "#{subject} (#{subject_packages.join(", ")}"
        if !packages.empty?
            subject = "#{subject} and #{packages.size} others)"
        else
            subject = "#{subject})"
        end
        emails << Hash[
            from: options[:from],
            to: m.emails,
            subject: subject,
            body: template.result(binding).encode('UTF-8', undef: :replace)
        ]
    end

    if options[:limit]
        emails = emails[0, [options[:limit], emails.size].min]
    end

    forced_to = options[:to]
    if !options[:sendgrid_user] || !options[:sendgrid_key]
        ReleaseAdmin.warn "No sendgrid user and key given, saving the emails on disk"
        emails.each_with_index do |m, i|
            ReleaseAdmin.info "writing #{i}.txt"
            File.open("#{i}.txt", 'w') do |io|
                io.puts "From: #{m[:from]}"
                io.puts "To: #{forced_to || m[:to].join(", ")}"
                io.puts "Subject: #{m[:subject]}"
                io.puts
                io.write m[:body]
            end
        end
    else
        require 'sendgrid-ruby'
        client = SendGrid::Client.new(api_user: options[:sendgrid_user], api_key: options[:sendgrid_key])
        emails.each do |m|
            email = SendGrid::Mail.new do |em|
                em.from = m[:from]
                em.to = Array(forced_to || m[:to])
                em.subject = m[:subject]
                em.text = m[:body]
            end
            client.send(email)
        end
    end
    ReleaseAdmin.info "notified maintainers of #{package_count} packages in #{emails.size} emails"
end

#checkoutObject



794
795
796
797
798
799
# File 'lib/rock/cli/release_admin.rb', line 794

def checkout
    Autobuild.do_update = true
    all_necessary_packages(manifest, options[:flavor].to_s).each do |pkg|
        pkg.autobuild.import(checkout_only: false, only_local: true)
    end
end

#create_pull_requests(source, target) ⇒ Object



924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
# File 'lib/rock/cli/release_admin.rb', line 924

def create_pull_requests(source, target)
    if source.nil? || target.nil?
        Autoproj.error "You must specify a branch"
        exit -1
    end
    if(target != "master")
        Autoproj.error "Wrong use"
        exit -1
    end

    local = options[:local]
    packages = all_necessary_packages(manifest,'master')

    packages.each do |pkg|
        pkg.autobuild.import(checkout_only: true)
    end

    excluded_by_user = options[:exclude].flat_map do |entry|
        entry.split(',')
    end

    # Deal with the packages that are managed within Rock
    packages_to_handle, packages_to_snapshot = packages.partition do |pkg|
        !excluded_by_user.include?(pkg.name) && rock_package?(pkg)
    end

    packages_to_handle.each do |pkg|
        pkg = pkg.autobuild
        importer = pkg.importer
        if importer.nil?
            Autoproj.error "No importer for #{pkg.name}"
            return -1
        end
        pkg.update(:only_local => true) #Can be done locally because update was done before
        needs_merge = !importer.run_git_bare(pkg,"branch", "-a", "--contains","remotes/autobuild/#{source}").any?{|e| e.strip == "remotes/autobuild/#{target}"}
        if needs_merge
            Autoproj.message "Package #{pkg.name} needs a merge creating pull-request"
            Dir.chdir(pkg.srcdir) do |dir|
                call = "hub pull-request -f -m 'Automatic rock-release PR: integrate rc-patches in master' -b #{target} -h #{source}"
                erg = system(call)
                if(!erg)
                    Autoproj.error "Could not run hub pull request for #{pkg.name}, result is #{$?}"
                end
            end
        end

    end
end

#create_rcObject



551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
# File 'lib/rock/cli/release_admin.rb', line 551

def create_rc
    # We checkout and branch all packages, not only the stable
    # ones, to ease release of new packages. This does not mean
    # that we're going to release all of them, of course !
    packages = all_necessary_packages(manifest, 'master')

    check_out_missing_packages('master')

    excluded_by_user = options[:exclude].flat_map do |entry|
        entry.split(',')
    end

    branch = options[:branch]
    versions = Array.new

    Autoproj.message "Creating the package sets RC branch"
    package_sets = manifest.each_remote_package_set.to_a
    package_sets.each_with_index do |pkg_set, i|
        Autoproj.message "  [#{i}/#{package_sets.size}] #{pkg_set.repository_id}"
        pkg = pkg_set.create_autobuild_package
        if options[:update] || !pkg.importer.has_commit?(pkg, "refs/remotes/autobuild/#{branch}")
            pkg.importer.run_git_bare(pkg, 'remote', 'update')
            pkg.importer.run_git_bare(pkg, 'push', 'autobuild', "+refs/remotes/autobuild/master:refs/heads/#{branch}")
        end
        versions << Hash["pkg_set:#{pkg_set.repository_id}" => Hash['branch' => branch]]
    end

    Autoproj.message "Creating the packages RC branch"
    # Deal with the packages that are managed within Rock
    packages_to_branch_out, packages_to_snapshot = packages.partition do |pkg|
        !excluded_by_user.include?(pkg.name) && rock_package?(pkg)
    end
    packages_to_branch_out.each_with_index do |pkg, i|
        Autoproj.message "  [#{i + 1}/#{packages_to_branch_out.size}] #{pkg.name}"
        pkg = pkg.autobuild
        if options[:update] || !pkg.importer.has_commit?(pkg, "refs/remotes/autobuild/#{branch}")
            pkg.importer.run_git_bare(pkg, 'remote', 'update')
            reference_branch =
                if Rock.flavors.package_in_flavor?(pkg.name, 'stable')
                    'stable'
                else 'master'
                end
            pkg.importer.run_git_bare(pkg, 'push', 'autobuild', "+refs/remotes/autobuild/#{reference_branch}:refs/heads/#{branch}")
        end
        versions << Hash[pkg.name => Hash['branch' => branch]]
    end

    #Finally update the release description file
    update_rc
end

#delete_labels(label) ⇒ Object



884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
# File 'lib/rock/cli/release_admin.rb', line 884

def delete_labels(label)
    if label.nil?
        Autoproj.error "You must specify a label"
        return -1
    end

    local = options[:local]
    packages = all_necessary_packages(manifest,'master')

    packages.each do |pkg|
        pkg.autobuild.import(checkout_only: true)
    end

    excluded_by_user = options[:exclude].flat_map do |entry|
        entry.split(',')
    end

    # Deal with the packages that are managed within Rock
    packages_to_handle, packages_to_snapshot = packages.partition do |pkg|
        !excluded_by_user.include?(pkg.name) && rock_package?(pkg)
    end

    packages_to_handle.each do |pkg|
        pkg = pkg.autobuild
        importer = pkg.importer
        if importer.nil?
            Autoproj.error "No importer for #{pkg.name}"
            return -1
        end
        begin
            importer.run_git_bare(pkg,"tag", "-d", label)
        rescue Autobuild::SubcommandFailed => e
            #TODO should not catched this way
        end
    end
end

#delete_rcObject



681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# File 'lib/rock/cli/release_admin.rb', line 681

def delete_rc
    packages = all_necessary_packages(manifest,'master')
    branch = options['branch']

    check_out_missing_packages('stable')

    packages.each do |pkg|
        pkg.autobuild.import(checkout_only: true)
    end

    excluded_by_user = options[:exclude].flat_map do |entry|
        entry.split(',')
    end

    # Deal with the packages that are managed within Rock
    packages_to_handle, packages_to_snapshot = packages.partition do |pkg|
        !excluded_by_user.include?(pkg.name) && rock_package?(pkg)
    end

    packages_to_handle.each do |pkg|
        pkg = pkg.autobuild
        importer = pkg.importer
        if importer.nil?
            Autoproj.warn "No importer for #{pkg.name}"
            #return -1
        end
        if importer.has_commit?(pkg, "refs/remotes/autobuild/#{branch}")
            importer.run_git_bare(pkg,"push", "autobuild", ":#{branch}")
        else
            Autoproj.warn "#{pkg.name} has no rc-branch"
        end
    end
end

#maintainer_infoObject



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/rock/cli/release_admin.rb', line 411

def maintainer_info
    require 'csv'

    if options[:mailmap]
        mailmap = YAML.load(File.read(options[:mailmap]))
    else
        mailmap = Hash.new
    end

    packages  = all_necessary_packages(manifest, 'master')
    packages += all_necessary_packages(manifest, 'stable')
    packages = packages.uniq(&:name).sort_by(&:name)

    info = Array.new
    packages.each do |pkg_def|
        manifest_xml = pkg_def.autobuild.description
        if rock_package?(pkg_def)
            maintainers = make_emails(manifest_xml.each_rock_maintainer.to_a + manifest_xml.each_maintainer.to_a, mailmap)
            maintainers = maintainers[0] + maintainers[1].map { |msg| "W: #{msg}" }
            authors     = make_emails(manifest_xml.each_author, mailmap)
            authors     = authors[0] + authors[1].map { |msg| "W: #{msg}" }
            git_authors = Array.new
            if maintainers.empty? && authors.empty?
                git_authors = guess_authors_from_git(pkg_def, mailmap: mailmap).first
            end
        else
            maintainers = make_emails(manifest_xml.each_rock_maintainer.to_a, mailmap)
            maintainers = maintainers[0] + maintainers[1].map { |msg| "W: #{msg}" }
            authors, git_authors = Array.new, Array.new
        end

        data = [[pkg_def.name], maintainers, authors, git_authors]
        line_count = data.map(&:size).max
        data.each do |arr|
            arr.concat([""] * (line_count - arr.size))
        end
        info.concat(data[0].zip(*data[1..-1]))
    end
    if options[:csv]
        info.each do |line|
            puts line.to_csv
        end
    else
        info.each do |line|
            puts line.join(" ")
        end
    end
end

#notes(release_name, last_release_name) ⇒ Object



802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
# File 'lib/rock/cli/release_admin.rb', line 802

def notes(release_name, last_release_name)
    packages = all_necessary_packages(manifest,"master")

    ops = Release.new
    last_versions_file = ops.fetch_version_file(last_release_name)
    last_versions = YAML.load(last_versions_file)

    last_packages_names = last_versions.map { |vcs| vcs.keys.first }.
        find_all { |name| name !~ /^pkg_set:/ }

    packages_names = packages.map { |pkg| pkg.autobuild.name }
    new_packages     = packages_names - last_packages_names
    obsolete_packages = last_packages_names - packages_names

    errors = Array.new
    status = Array.new
    packages.each do |pkg|
        pkg_name = pkg.autobuild.name
        next if new_packages.include?(pkg_name)
        next if obsolete_packages.include?(pkg_name)

        changes = package_changelog(pkg.autobuild, release_name, last_release_name)
        if changes
            status << changes
        else
            errors << pkg_name
        end
    end


    template = File.join(File.dirname(__FILE__),"..","templates", "rock-release-notes.md.template")
    erb = ERB.new(File.read(template))

    sort_info = release_name.split("-").last

    Autoproj.message "Creating Relase notes: #{File.join(config_dir,Release::RELEASE_NOTES)}"
    File.open(File.join(config_dir, Release::RELEASE_NOTES), 'w') do |io|
        io.write erb.result(binding)
    end
end

#prepare(release_name) ⇒ Object



976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
# File 'lib/rock/cli/release_admin.rb', line 976

def prepare(release_name)
    packages = all_necessary_packages(manifest,"master")

    Autoproj.message "Checking out missing packages"
    packages.each do |pkg|
        pkg.autobuild.import(checkout_only: true)
    end

    excluded_by_user = options[:exclude].flat_map do |entry|
        entry.split(',')
    end

    Autoproj.message "Tagging package sets"
    failed_package_sets = tag_rock_packages(
        manifest.each_remote_package_set.map(&:create_autobuild_package),
        release_name,
        branch: options[:branch])
    if !failed_package_sets.empty?
        raise "failed to prepare #{failed_package_sets.size} package sets"
    end

    Autoproj.message "Tagging all Rock-managed packages"
    # Deal with the packages that are managed within Rock
    packages_to_tag = packages.find_all do |pkg|
        !excluded_by_user.include?(pkg.name) && rock_package?(pkg)
    end
    failed_packages = tag_rock_packages(
        packages_to_tag.map(&:autobuild),
        release_name,
        branch: options[:branch])
    if !failed_packages.empty?
        raise "failed to prepare #{failed_packages.size} packages"
    end

    version_path = File.join(config_dir, Release::RELEASE_VERSIONS)
    Autoproj.message "Creating version file, and saving it in #{version_path}"
    ops = Autoproj::Ops::Snapshot.new(manifest, keep_going: false)
    versions = ops.snapshot_package_sets +
        ops.snapshot_packages(packages.map { |pkg| pkg.autobuild.name })
    versions = ops.sort_versions(versions)

    #Workaround filter out branch and label setting because branch will deleted after publishing the release
    versions.collect! do |a|
        elem = Hash.new
        a.each do |k,v|
            v.keep_if do |k2,v2|
                if k2 == "branch"
                    !(!v["branch"].nil? && !v["tag"].nil?)
                else
                    true
                end
            end
            elem[k] = v
        end
        elem
    end


    FileUtils.mkdir_p(File.dirname(version_path))
    File.open(version_path, 'w') do |io|
        YAML.dump(versions, io)
    end
    Autoproj.message "Done"
    Autoproj.message "Left to do:"
    Autoproj.message "  - create a release note file in autoproj/#{Release::RELEASE_NOTES}. A template file, created based on the package's changelog, can be created with"
    Autoproj.message "    rock-release admin notes #{release_name} LAST_RELEASE_NAME"
    Autoproj.message "  - commit the build configuration and tag it with the release name"
    Autoproj.message "  - push everything"
    Autoproj.message "  - delete the RC"
end

#push_labels(label) ⇒ Object



845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
# File 'lib/rock/cli/release_admin.rb', line 845

def push_labels(label)
    if label.nil?
        Autoproj.error "You must specify a label"
        return -1
    end

    local = options[:local]
    packages = all_necessary_packages(manifest,'master')

    packages.each do |pkg|
        pkg.autobuild.import(checkout_only: true)
    end

    excluded_by_user = options[:exclude].flat_map do |entry|
        entry.split(',')
    end

    # Deal with the packages that are managed within Rock
    packages_to_handle, packages_to_snapshot = packages.partition do |pkg|
        !excluded_by_user.include?(pkg.name) && rock_package?(pkg)
    end

    packages_to_handle.each do |pkg|
        pkg = pkg.autobuild
        importer = pkg.importer
        if importer.nil?
            Autoproj.error "No importer for #{pkg.name}"
            return -1
        end
        if !importer.repository.include? "gitorious"
            importer.run_git_bare(pkg,"push","autobuild", label)
        else
            Autoproj.warn "Workaround, you have to tag/commit pinning the branch for #{pkg.name} manually, because it is still on gitorious"
        end
    end
end

#push_to_stable(branch) ⇒ Object



717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
# File 'lib/rock/cli/release_admin.rb', line 717

def push_to_stable(branch)
    if(branch.nil?)
        Autoproj.error "Please pass the tagname of current release"
        return -1
    end
    packages = all_necessary_packages(manifest, 'stable')

    check_out_missing_packages('stable')

    excluded_by_user = options[:exclude].flat_map do |entry|
        entry.split(',')
    end
    versions = Array.new

    # Deal with the packages that are managed within Rock
    packages_to_handle, packages_to_snapshot = packages.partition do |pkg|
        !excluded_by_user.include?(pkg.name) && rock_package?(pkg)
    end

    failed_packages = []

    package_sets = manifest.each_remote_package_set.to_a

    #Make sure working copy is clean becasue we need to switch branches in the repros
    #TODO find another way?
    package_sets.each_with_index do |pkg_set, i|
        pkg = pkg_set.create_autobuild_package
        if pkg.importer.class.has_uncommitted_changes?(pkg)
            Autoproj.error "Could not process, because #{pkg.name} has uncommited changes"
            return -1
        end
    end
    packages_to_handle.each do |pkg|
        if pkg.autobuild.importer.class.has_uncommitted_changes?(pkg.autobuild)
            Autoproj.error "Could not process, because #{pkg.name} has uncommited changes"
            return -1
        end
    end

    packages_to_handle.each do |pkg|
        pkg = pkg.autobuild
        importer = pkg.importer
        pkg.importer.run_git_bare(pkg, 'remote', 'update')
        if !pkg.importer.run_git_bare(pkg, 'push', 'autobuild', "+refs/tags/#{branch}:refs/heads/stable")
            Autoproj.warn "postpruned: failed to push #{branch} state to stable for: #{pkg.name}"
            failed_packages << pkg
        end
        Autoproj.info "Pushed: #{pkg.name}"
    end

    finally_failed = []
    failed_packages.each do |pkg|
        if !pkg.importer.run_git(pkg,"checkout","-b","stable_merge","+refs/tags/#{branch}")
            finally_failed << pkg
        end
        if !pkg.importer.run_git(pkg,"merge","-s","ours","+refs/heads/stable")
            finally_failed << pkg
        end
        if !pkg.importer.run_git(pkg,"push","autobuild","stable_merge:stable_merge")
            finally_failed << pkg
        end
        call = "hub pull-request -f -m 'Automatic rock-release PR: integrate rc-branch in stable' -b stable -h stable_merge"
        erg = system(call)
        if(!erg)
            Autoproj.error "Could not run hub pull request for #{pkg.name}, result is #{$?}"
            finally_failed << pkg
        end
        Autoproj.error "Breaking here for #{pkg.name}, because PR creation is untested"
    end
    Autoproj.warn "Finally failed packages, please post-process them manually: "
    finally_failed.each do |pkg|
        Autoproj.warn pkg.name
    end
end

#update_rcObject



606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
# File 'lib/rock/cli/release_admin.rb', line 606

def update_rc
    branch = options[:branch]

    # We checkout and branch all packages, not only the stable
    # ones, to ease release of new packages. This does not mean
    # that we're going to release all of them, of course !
    packages = all_necessary_packages(manifest, 'master')

    excluded_by_user = options[:exclude].flat_map do |entry|
        entry.split(',')
    end

    check_out_missing_packages('master')

    # Deal with the packages that are managed within Rock
    packages_to_branch_out, packages_to_snapshot = packages.partition do |pkg|
        !excluded_by_user.include?(pkg.name) && rock_package?(pkg)
    end

    ops = Autoproj::Ops::Snapshot.new(manifest)
    versions = Array.new

    Autoproj.message "Query the package sets RC branch"
    package_sets = manifest.each_remote_package_set.to_a
    package_sets.each_with_index do |pkg_set, i|
        Autoproj.message "  [#{i}/#{package_sets.size}] #{pkg_set.repository_id}"
        pkg = pkg_set.create_autobuild_package
        if !pkg.importer.has_commit?(pkg, "refs/remotes/autobuild/#{branch}")
            raise "The package set #{pkg_set.name} hasn't the requested branch #{branch}, maybe create the rc-first"
        end
        versions << Hash["pkg_set:#{pkg_set.repository_id}" => Hash['branch' => branch]]
    end

    Autoproj.message "Query the packages RC branch"
    # Deal with the packages that are managed within Rock
    packages_to_branch_out, packages_to_snapshot = packages.partition do |pkg|
        !excluded_by_user.include?(pkg.name) && rock_package?(pkg)
    end
    packages_to_branch_out.each_with_index do |pkg, i|
        Autoproj.message "  [#{i + 1}/#{packages_to_branch_out.size}] #{pkg.name}"
        pkg = pkg.autobuild
        if !pkg.importer.has_commit?(pkg, "refs/remotes/autobuild/#{branch}")
            raise "The package #{pkg.name}  hasn't the requested branch #{branch}, maybe create the rc-first"
        end
        versions << Hash[pkg.name => Hash['branch' => branch]]
    end
    versions += ops.snapshot_packages(packages_to_snapshot.map { |pkg| pkg.autobuild.name })

    vcs = Autoproj::VCSDefinition.from_raw(Release::ROCK_RELEASE_INFO)
    buildconf = Autoproj::Ops::Tools.
        create_autobuild_package(vcs, "main configuration", config_dir)
    version_commit = Autoproj::Ops::Snapshot.create_commit(buildconf, Release::RELEASE_VERSIONS, "version file for tracking the release candidate") do |io|
        YAML.dump(versions, io)
    end
    notes_commit = Autoproj::Ops::Snapshot.create_commit(buildconf, Release::RELEASE_NOTES, "release notes file to please rock-release", version_commit) do |io|
        io.puts "This is an empty file meant to allow rock-release to see rock-rc as a release"
    end

    bootstrap_commit = Autoproj::Ops::Snapshot.create_commit(buildconf, "bootstrap.sh", "bootstrap.sh for this release", notes_commit) do |io|
        File.open(File.join(buildconf.srcdir,"bootstrap.sh")).readlines.each do |line|
            if line.include? "BOOTSTRAP_ARGS="
                io.puts "BOOTSTRAP_ARGS=branch=rock-rc"
            else
                io.puts line
            end
        end
    end
    buildconf.importer.run_git_bare(buildconf, 'branch', '-f', 'rock-rc', bootstrap_commit)
    buildconf.importer.run_git_bare(buildconf, 'push', '-f', buildconf.importer.push_to)
end