diff --git a/debian/changelog b/debian/changelog index 22581a4..cee093a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,7 +10,7 @@ ubuntu-dev-tools (0.107) UNRELEASED; urgency=low - Remove null-entry from trailing comma in sorted lists - Add configurable debian directory location - Sort Architecture (LP: #681131) - - Add --sort-binary-packages (LP: #681119) + - Add --sort-binary-packages and --keep-first (LP: #681119) * dgetlp, grab-merge, pull-lp-source, syncpackage: Export DEB_VENDOR=Ubuntu when unpacking source packages. 3.0 (quilt) has optional per-vendor patch series. @@ -20,7 +20,7 @@ ubuntu-dev-tools (0.107) UNRELEASED; urgency=low * syncpackage: Fix error message for failed downloads. * sponsor-patch: Support building with sbuild (LP: #681242). - -- Benjamin Drung Fri, 26 Nov 2010 19:32:48 +0100 + -- Stefano Rivera Sat, 27 Nov 2010 09:22:03 +0200 ubuntu-dev-tools (0.106) experimental; urgency=low diff --git a/doc/wrap-and-sort.1 b/doc/wrap-and-sort.1 index 5e0e8ec..fee9ba4 100644 --- a/doc/wrap-and-sort.1 +++ b/doc/wrap-and-sort.1 @@ -47,6 +47,12 @@ field name) \fB\-b\fR, \fB\-\-sort\-binary\-packages\fR sort binary package paragraphs by name .TP +\fB\-k\fR, \fB\-\-keep\-first\fR +When sorting binary package paragraphs, leave the first one at the top. +Unqualified +.BR debhelper (7) +configuration files are applied to the first package. +.TP \fB\-n\fR, \fB\-\-no\-cleanup\fR do not remove trailing whitespaces .TP diff --git a/wrap-and-sort b/wrap-and-sort index c951636..1e43081 100755 --- a/wrap-and-sort +++ b/wrap-and-sort @@ -54,7 +54,8 @@ class Control(object): f.write(content.encode("utf-8")) f.close() - def wrap_and_sort(self, wrap_always, short_indent, sort_paragraphs): + def wrap_and_sort(self, wrap_always, short_indent, sort_paragraphs, + keep_first): for paragraph in self.paragraphs: for field in CONTROL_LIST_FIELDS: if field in paragraph: @@ -70,9 +71,10 @@ class Control(object): paragraph["Architecture"] = " ".join(archs) if sort_paragraphs: - # Sort with Source package first, by binary Package Name - key = lambda x: "" if "Source" in x else x["Package"] - self.paragraphs = sorted(self.paragraphs, key=key) + first = self.paragraphs[:1 + int(keep_first)] + sortable = self.paragraphs[1 + int(keep_first):] + key = lambda x: x.get("Package") + self.paragraphs = first + sorted(sortable, key=key) def _wrap_field(self, control, entry, wrap_always, short_indent, sort=True): packages = map(lambda x: x.strip(), control[entry].split(",")) @@ -144,7 +146,7 @@ def main(options): print control_file control = Control(control_file, options.cleanup) control.wrap_and_sort(options.wrap_always, options.short_indent, - options.sort_binary_packages) + options.sort_binary_packages, options.keep_first) control.save() copyright_files = filter(os.path.isfile, @@ -181,6 +183,12 @@ if __name__ == "__main__": help="Sort binary package paragraphs by name", dest="sort_binary_packages", action="store_true", default=False) + parser.add_option("-k", "--keep-first", + help="When sorting binary package paragraphs, leave the " + "first one at the top. Unqualified debhelper " + "configuration files are applied to the first " + "package.", + dest="keep_first", action="store_true", default=False) parser.add_option("-n", "--no-cleanup", help="don't cleanup whitespaces", dest="cleanup", action="store_false", default=True) parser.add_option("-d", "--debian-directory", dest="debian_directory",