Merge lp:~cjwatson/launchpad/remove-unembargo-package into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 15506
Proposed branch: lp:~cjwatson/launchpad/remove-unembargo-package
Merge into: lp:launchpad
Diff against target: 341 lines (+48/-208)
3 files modified
lib/lp/soyuz/scripts/packagecopier.py (+0/-72)
lib/lp/soyuz/scripts/tests/test_copypackage.py (+48/-117)
scripts/ftpmaster-tools/unembargo-package.py (+0/-19)
To merge this branch: bzr merge lp:~cjwatson/launchpad/remove-unembargo-package
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+112044@code.launchpad.net

Commit message

Remove unembargo-package.py, superseded by Archive.copyPackage(unembargo=True).

Description of the change

Following https://code.launchpad.net/~cjwatson/launchpad/pcj-reupload/+merge/111124 (and a few subsequent fixes), the Ubuntu security team should be able to use Archive.copyPackage(unembargo=True) rather than the old unembargo-package.py script, so we can remove the latter.

I've QAed the new method on dogfood, but I still need to do a smoke-test on production with the security team, currently planned for Wednesday. I won't land this at least until that's done.

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/scripts/packagecopier.py'
--- lib/lp/soyuz/scripts/packagecopier.py 2012-06-26 00:46:41 +0000
+++ lib/lp/soyuz/scripts/packagecopier.py 2012-06-26 09:53:26 +0000
@@ -7,7 +7,6 @@
77
8__all__ = [8__all__ = [
9 'PackageCopier',9 'PackageCopier',
10 'UnembargoSecurityPackage',
11 'CopyChecker',10 'CopyChecker',
12 'check_copy_permissions',11 'check_copy_permissions',
13 'do_copy',12 'do_copy',
@@ -1080,74 +1079,3 @@
1080 raise SoyuzScriptError(1079 raise SoyuzScriptError(
1081 "Can not sync between the same locations: '%s' to '%s'" % (1080 "Can not sync between the same locations: '%s' to '%s'" % (
1082 self.location, self.destination))1081 self.location, self.destination))
1083
1084
1085class UnembargoSecurityPackage(PackageCopier):
1086 """`SoyuzScript` that unembargoes security packages and their builds.
1087
1088 Security builds are done in the ubuntu-security private PPA.
1089 When they are ready to be unembargoed, this script will copy
1090 them from the PPA to the Ubuntu archive and re-upload any files
1091 from the restricted librarian into the non-restricted one.
1092
1093 This script simply wraps up PackageCopier with some nicer options.
1094
1095 An assumption is made, to reduce the number of command line options,
1096 that packages are always copied between the same distroseries. The user
1097 can, however, select which target pocket to unembargo into. This is
1098 useful to the security team when there are major version upgrades
1099 and they want to stage it through -proposed first for testing.
1100 """
1101
1102 usage = ("%prog [-d <distribution>] [-s <suite>] [--ppa <private ppa>] "
1103 "<package(s)>")
1104 description = ("Unembargo packages in a private PPA by copying to the "
1105 "specified location and re-uploading any files to the "
1106 "unrestricted librarian.")
1107
1108 def add_my_options(self):
1109 """Add -d, -s, dry-run and confirmation options."""
1110 SoyuzScript.add_distro_options(self)
1111 SoyuzScript.add_transaction_options(self)
1112
1113 self.parser.add_option(
1114 "-p", "--ppa", dest="archive_owner_name",
1115 default="ubuntu-security", action="store",
1116 help="Private PPA owner's name.")
1117
1118 self.parser.add_option(
1119 "--ppa-name", dest="archive_name",
1120 default="ppa", action="store",
1121 help="Private PPA name.")
1122
1123 def setUpCopierOptions(self):
1124 """Set up options needed by PackageCopier."""
1125 # Set up the options for PackageCopier that are needed in addition
1126 # to the ones that this class sets up.
1127 self.options.to_partner = False
1128 self.options.to_ppa = False
1129 self.options.partner_archive = None
1130 self.options.include_binaries = True
1131 self.options.unembargo = True
1132 self.options.to_distribution = self.options.distribution_name
1133 # The PackageCopier parent class uses options.suite as the source
1134 # suite, so we need to override it to remove the pocket since PPAs
1135 # are pocket-less.
1136 self.options.to_suite = self.options.suite
1137 self.options.suite = self.options.suite.split("-")[0]
1138 self.options.version = None
1139 self.options.component = None
1140
1141 def mainTask(self):
1142 """Invoke PackageCopier to copy the package(s) and re-upload files."""
1143 self.setUpCopierOptions()
1144
1145 # Generate the location for PackageCopier after overriding the
1146 # options.
1147 self.setupLocation()
1148
1149 # Invoke the package copy operation.
1150 copies = PackageCopier.mainTask(self)
1151
1152 # Return this for the benefit of the test suite.
1153 return copies
11541082
=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2012-06-25 08:35:33 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2012-06-26 09:53:26 +0000
@@ -74,7 +74,6 @@
74 do_copy,74 do_copy,
75 PackageCopier,75 PackageCopier,
76 re_upload_file,76 re_upload_file,
77 UnembargoSecurityPackage,
78 update_files_privacy,77 update_files_privacy,
79 )78 )
80from lp.soyuz.tests.test_publishing import SoyuzTestPublisher79from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
@@ -2915,95 +2914,32 @@
2915 distribution=ubuntu)2914 distribution=ubuntu)
29162915
2917 # Create a source and binary private publication.2916 # Create a source and binary private publication.
2918 hoary = ubuntu.getSeries('hoary')
2919 hoary.status = SeriesStatus.CURRENT
2920 test_publisher = self.getTestPublisher(hoary)
2921 ppa_source = test_publisher.getPubSource(
2922 archive=joe_private_ppa, version='1.0', distroseries=hoary)
2923 test_publisher.getPubBinaries(
2924 pub_source=ppa_source, distroseries=hoary)
2925 self.layer.txn.commit()
2926
2927 # Run the copy package script storing the logged information.
2928 copy_helper = self.getCopier(
2929 sourcename='foo', from_ppa='joe',
2930 include_binaries=True, from_suite='hoary',
2931 to_suite='hoary-security', unembargo=True)
2932 copied = copy_helper.mainTask()
2933
2934 # The private files are copied via a direct-copy request.
2935 self.assertEqual(len(copied), 3)
2936 self.assertEqual(
2937 ['INFO FROM: joe: hoary-RELEASE',
2938 'INFO TO: Primary Archive for Ubuntu Linux: hoary-SECURITY',
2939 'INFO Copy candidates:',
2940 'INFO \tfoo 1.0 in hoary',
2941 'INFO \tfoo-bin 1.0 in hoary hppa',
2942 'INFO \tfoo-bin 1.0 in hoary i386',
2943 'INFO Re-uploaded foo_1.0.dsc to librarian',
2944 'INFO Re-uploaded foo_1.0_source.changes to librarian',
2945 'INFO Re-uploaded foo-bin_1.0_all.deb to librarian',
2946 'INFO Re-uploaded foo-bin_1.0_i386.changes to librarian',
2947 'INFO Re-uploaded '
2948 'buildlog_ubuntu-hoary-i386.foo_1.0_FULLYBUILT.txt.gz to '
2949 'librarian',
2950 'INFO Copied:',
2951 'INFO \tfoo 1.0 in hoary',
2952 'INFO \tfoo-bin 1.0 in hoary hppa',
2953 'INFO \tfoo-bin 1.0 in hoary i386',
2954 'INFO 3 packages successfully copied.',
2955 ],
2956 copy_helper.logger.getLogBuffer().splitlines())
2957
2958 def testUnembargoing(self):
2959 """Test UnembargoSecurityPackage, which wraps PackagerCopier."""
2960 # Set up a private PPA.
2961 joe = self.factory.makePerson(name="joe")
2962 ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
2963 joe_private_ppa = self.factory.makeArchive(
2964 owner=joe, name='ppa', private=True,
2965 distribution=ubuntu)
2966
2967 # Setup a SoyuzTestPublisher object, so we can create publication
2968 # to be unembargoed.
2969 warty = ubuntu.getSeries('warty')2917 warty = ubuntu.getSeries('warty')
2970 test_publisher = self.getTestPublisher(warty)2918 test_publisher = self.getTestPublisher(warty)
2971
2972 # Create a source and binary pair to be unembargoed from the PPA.
2973 ppa_source = test_publisher.getPubSource(2919 ppa_source = test_publisher.getPubSource(
2974 archive=joe_private_ppa, version='1.1',2920 archive=joe_private_ppa, version='1.1', distroseries=warty,
2975 distroseries=warty,
2976 status=PackagePublishingStatus.PUBLISHED)2921 status=PackagePublishingStatus.PUBLISHED)
2977 other_source = test_publisher.getPubSource(2922 other_source = test_publisher.getPubSource(
2978 archive=joe_private_ppa, version='1.1',2923 archive=joe_private_ppa, version='1.1',
2979 sourcename="sourcefordiff", distroseries=warty,2924 sourcename="sourcefordiff", distroseries=warty,
2980 status=PackagePublishingStatus.PUBLISHED)2925 status=PackagePublishingStatus.PUBLISHED)
2981 test_publisher.addFakeChroots(warty)
2982 ppa_binaries = test_publisher.getPubBinaries(2926 ppa_binaries = test_publisher.getPubBinaries(
2983 pub_source=ppa_source, distroseries=warty,2927 pub_source=ppa_source, distroseries=warty,
2984 status=PackagePublishingStatus.PUBLISHED)2928 status=PackagePublishingStatus.PUBLISHED)
2929 self.layer.txn.commit()
29852930
2986 # Give the new source a private package diff.2931 # Give the new source a private package diff.
2987 sourcepackagerelease = other_source.sourcepackagerelease2932 spr = other_source.sourcepackagerelease
2988 diff_file = test_publisher.addMockFile("diff_file", restricted=True)2933 diff_file = test_publisher.addMockFile("diff_file", restricted=True)
2989 package_diff = sourcepackagerelease.requestDiffTo(2934 package_diff = spr.requestDiffTo(joe, ppa_source.sourcepackagerelease)
2990 joe, ppa_source.sourcepackagerelease)
2991 package_diff.diff_content = diff_file2935 package_diff.diff_content = diff_file
29922936
2993 # Prepare a *restricted* buildlog file for the Build instances.
2994 fake_buildlog = test_publisher.addMockFile(
2995 'foo_source.buildlog', restricted=True)
2996
2997 for build in ppa_source.getBuilds():
2998 build.log = fake_buildlog
2999
3000 # Add a restricted changelog file.2937 # Add a restricted changelog file.
3001 fake_changelog = test_publisher.addMockFile(2938 changelog = test_publisher.addMockFile("changelog", restricted=True)
3002 'changelog', restricted=True)2939 ppa_source.sourcepackagerelease.changelog = changelog
3003 ppa_source.sourcepackagerelease.changelog = fake_changelog
30042940
3005 # Create ancestry environment in the primary archive, so we can2941 # Create ancestry environment in the primary archive, so we can test
3006 # test unembargoed overrides.2942 # unembargoed overrides.
3007 ancestry_source = test_publisher.getPubSource(2943 ancestry_source = test_publisher.getPubSource(
3008 version='1.0', distroseries=warty,2944 version='1.0', distroseries=warty,
3009 status=PackagePublishingStatus.PUBLISHED)2945 status=PackagePublishingStatus.PUBLISHED)
@@ -3011,7 +2947,7 @@
3011 pub_source=ancestry_source, distroseries=warty,2947 pub_source=ancestry_source, distroseries=warty,
3012 status=PackagePublishingStatus.SUPERSEDED)2948 status=PackagePublishingStatus.SUPERSEDED)
30132949
3014 # Override the published ancestry source to 'universe'2950 # Override the published ancestry source to 'universe'.
3015 universe = getUtility(IComponentSet)['universe']2951 universe = getUtility(IComponentSet)['universe']
3016 ancestry_source.component = universe2952 ancestry_source.component = universe
30172953
@@ -3021,22 +2957,38 @@
30212957
3022 self.layer.txn.commit()2958 self.layer.txn.commit()
30232959
3024 # Now we can invoke the unembargo script and check its results.2960 # Run the copy package script storing the logged information.
3025 test_args = [2961 copy_helper = self.getCopier(
3026 "--ppa", "joe",2962 sourcename='foo', from_ppa='joe',
3027 "--ppa-name", "ppa",2963 include_binaries=True, from_suite='warty',
3028 "-s", "%s" % ppa_source.distroseries.name + "-security",2964 to_suite='warty-security', unembargo=True)
3029 "foo",2965 copied = copy_helper.mainTask()
3030 ]2966
30312967 # The private files are copied via a direct-copy request.
3032 script = UnembargoSecurityPackage(2968 self.checkCopies(copied, copy_helper.destination.archive, 3)
3033 name='unembargo', test_args=test_args)2969 self.assertEqual(
3034 script.logger = BufferLogger()2970 ['INFO FROM: joe: warty-RELEASE',
30352971 'INFO TO: Primary Archive for Ubuntu Linux: warty-SECURITY',
3036 copied = script.mainTask()2972 'INFO Copy candidates:',
30372973 'INFO \tfoo 1.1 in warty',
3038 # Check the results.2974 'INFO \tfoo-bin 1.1 in warty hppa',
3039 self.checkCopies(copied, script.destination.archive, 3)2975 'INFO \tfoo-bin 1.1 in warty i386',
2976 'INFO Re-uploaded foo_1.1.dsc to librarian',
2977 'INFO Re-uploaded diff_file to librarian',
2978 'INFO Re-uploaded foo_1.1_source.changes to librarian',
2979 'INFO Re-uploaded changelog to librarian',
2980 'INFO Re-uploaded foo-bin_1.1_all.deb to librarian',
2981 'INFO Re-uploaded foo-bin_1.1_i386.changes to librarian',
2982 'INFO Re-uploaded '
2983 'buildlog_ubuntu-warty-i386.foo_1.1_FULLYBUILT.txt.gz to '
2984 'librarian',
2985 'INFO Copied:',
2986 'INFO \tfoo 1.1 in warty',
2987 'INFO \tfoo-bin 1.1 in warty hppa',
2988 'INFO \tfoo-bin 1.1 in warty i386',
2989 'INFO 3 packages successfully copied.',
2990 ],
2991 copy_helper.logger.getLogBuffer().splitlines())
30402992
3041 # Check that the librarian files are all unrestricted now.2993 # Check that the librarian files are all unrestricted now.
3042 # We must commit the txn for SQL object to see the change.2994 # We must commit the txn for SQL object to see the change.
@@ -3071,43 +3023,22 @@
3071 published.pocket.title, "Security",3023 published.pocket.title, "Security",
3072 "Expected Security pocket, got %s" % published.pocket.title)3024 "Expected Security pocket, got %s" % published.pocket.title)
30733025
3074 def testUnembargoSuite(self):3026 def testUnembargoStableReleasePocketForbidden(self):
3075 """Test that passing different suites works as expected."""3027 """Unembargoing into release pocket of stable series is forbidden."""
3076 # Set up a private PPA.3028 # Set up a private PPA.
3077 joe = self.factory.makePerson(name="joe")3029 joe = self.factory.makePerson(name="joe")
3078 ubuntu = getUtility(IDistributionSet).getByName('ubuntu')3030 ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
3079 self.factory.makeArchive(3031 self.factory.makeArchive(
3080 owner=joe, name='ppa', private=True, distribution=ubuntu)3032 owner=joe, name='ppa', private=True, distribution=ubuntu)
30813033
3082 test_args = [3034 copy_helper = self.getCopier(
3083 "--ppa", "joe",3035 sourcename='foo', from_ppa='joe',
3084 "-s", "warty-backports",3036 include_binaries=True, from_suite='warty',
3085 "foo",3037 to_suite='warty', unembargo=True)
3086 ]
3087
3088 script = UnembargoSecurityPackage(
3089 name='unembargo', test_args=test_args)
3090 script.setUpCopierOptions()
3091 script.setupLocation()
3092 script.setupDestination()
3093 script.destination.distroseries.status = SeriesStatus.CURRENT
3094 script.checkPrivacyOptions()
3095 self.assertEqual("warty-backports", script.options.to_suite)
3096
3097 # Change the suite to one with the release pocket. It should copy
3098 # nothing as you're not allowed to unembargo into the release
3099 # pocket of a stable series.
3100 test_args[3] = "warty"
3101 script = UnembargoSecurityPackage(
3102 name='unembargo', test_args=test_args)
3103 script.logger = BufferLogger()
3104 script.setUpCopierOptions()
3105 script.setupLocation()
3106 script.setupDestination()
3107 self.assertRaisesWithContent(3038 self.assertRaisesWithContent(
3108 SoyuzScriptError,3039 SoyuzScriptError,
3109 "Can't unembargo into suite 'warty' of a distribution.",3040 "Can't unembargo into suite 'warty' of a distribution.",
3110 script.checkPrivacyOptions)3041 copy_helper.mainTask)
31113042
3112 def testCopyClosesBugs(self):3043 def testCopyClosesBugs(self):
3113 """Copying packages closes bugs.3044 """Copying packages closes bugs.
31143045
=== removed file 'scripts/ftpmaster-tools/unembargo-package.py'
--- scripts/ftpmaster-tools/unembargo-package.py 2011-12-29 05:29:36 +0000
+++ scripts/ftpmaster-tools/unembargo-package.py 1970-01-01 00:00:00 +0000
@@ -1,19 +0,0 @@
1#!/usr/bin/python -S
2#
3# Copyright 2009 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6# pylint: disable-msg=W0403
7"""Unembargo a package from the security private PPA."""
8
9import _pythonpath
10
11from lp.services.config import config
12from lp.soyuz.scripts.packagecopier import UnembargoSecurityPackage
13
14
15if __name__ == '__main__':
16 script = UnembargoSecurityPackage(
17 'unembargo-package', dbuser=config.archivepublisher.dbuser)
18 script.lock_and_run()
19