mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
Move suspicious-source and wrap-and-sort from ubuntu-dev-tools into devscripts.
This commit is contained in:
parent
e9b5d0aa20
commit
e8b3a18c45
@ -28,10 +28,11 @@ import tempfile
|
|||||||
from launchpadlib.launchpad import Launchpad
|
from launchpadlib.launchpad import Launchpad
|
||||||
import lsb_release
|
import lsb_release
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.archive import UbuntuSourcePackage, DownloadError
|
from ubuntutools.archive import UbuntuSourcePackage, DownloadError
|
||||||
from ubuntutools.config import UDTConfig, ubu_email
|
from ubuntutools.config import UDTConfig, ubu_email
|
||||||
from ubuntutools.builder import get_builder
|
from ubuntutools.builder import get_builder
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
from ubuntutools.question import YesNoQuestion
|
from ubuntutools.question import YesNoQuestion
|
||||||
|
|
||||||
def error(msg):
|
def error(msg):
|
||||||
|
3
bitesize
3
bitesize
@ -27,7 +27,8 @@ from optparse import OptionParser
|
|||||||
from launchpadlib.launchpad import Launchpad
|
from launchpadlib.launchpad import Launchpad
|
||||||
from launchpadlib.errors import HTTPError
|
from launchpadlib.errors import HTTPError
|
||||||
|
|
||||||
from ubuntutools.logger import Logger
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
|
|
||||||
def error_out(msg):
|
def error_out(msg):
|
||||||
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,8 +1,8 @@
|
|||||||
ubuntu-dev-tools (0.124) UNRELEASED; urgency=low
|
ubuntu-dev-tools (0.124) UNRELEASED; urgency=low
|
||||||
|
|
||||||
[ Benjamin Drung ]
|
[ Benjamin Drung ]
|
||||||
* Move add-patch, edit-patch, and what-patch from ubuntu-dev-tools into
|
* Move add-patch, edit-patch, suspicious-source, what-patch, and wrap-and-sort
|
||||||
devscripts (Closes: #568481).
|
from ubuntu-dev-tools into devscripts (Closes: #568481).
|
||||||
|
|
||||||
[ Daniel Holbach ]
|
[ Daniel Holbach ]
|
||||||
* bitesize:
|
* bitesize:
|
||||||
@ -15,7 +15,7 @@ ubuntu-dev-tools (0.124) UNRELEASED; urgency=low
|
|||||||
* mk-sbuild:
|
* mk-sbuild:
|
||||||
- maintainer_name isn't mandatory any more (LP: #787051)
|
- maintainer_name isn't mandatory any more (LP: #787051)
|
||||||
|
|
||||||
-- Stefano Rivera <stefanor@debian.org> Mon, 23 May 2011 17:14:49 +0100
|
-- Benjamin Drung <bdrung@debian.org> Mon, 23 May 2011 23:38:51 +0200
|
||||||
|
|
||||||
ubuntu-dev-tools (0.123) unstable; urgency=low
|
ubuntu-dev-tools (0.123) unstable; urgency=low
|
||||||
|
|
||||||
|
5
debian/control
vendored
5
debian/control
vendored
@ -8,7 +8,7 @@ Vcs-Bzr: lp:ubuntu-dev-tools
|
|||||||
Vcs-Browser: https://code.launchpad.net/~ubuntu-dev/ubuntu-dev-tools/trunk
|
Vcs-Browser: https://code.launchpad.net/~ubuntu-dev/ubuntu-dev-tools/trunk
|
||||||
Build-Depends: dctrl-tools,
|
Build-Depends: dctrl-tools,
|
||||||
debhelper (>= 7.0.50~),
|
debhelper (>= 7.0.50~),
|
||||||
devscripts,
|
devscripts (>= 2.10.74~),
|
||||||
libwww-perl,
|
libwww-perl,
|
||||||
lsb-release,
|
lsb-release,
|
||||||
pylint,
|
pylint,
|
||||||
@ -111,12 +111,9 @@ Description: useful tools for Ubuntu developers
|
|||||||
- sponsor-patch - Downloads a patch from a Launchpad bug, patches the source
|
- sponsor-patch - Downloads a patch from a Launchpad bug, patches the source
|
||||||
package, and uploads it (to Ubuntu or a PPA)
|
package, and uploads it (to Ubuntu or a PPA)
|
||||||
- submittodebian - automatically send your changes to Debian as a bug report.
|
- submittodebian - automatically send your changes to Debian as a bug report.
|
||||||
- suspicious-source - outputs a list of files which are not common source
|
|
||||||
files.
|
|
||||||
- syncpackage - helper to prepare .changes file to upload synced packages
|
- syncpackage - helper to prepare .changes file to upload synced packages
|
||||||
- ubuntu-build - give commands to the Launchpad build daemons from the
|
- ubuntu-build - give commands to the Launchpad build daemons from the
|
||||||
command line.
|
command line.
|
||||||
- ubuntu-distro-info - provides information about Ubuntu's distributions.
|
- ubuntu-distro-info - provides information about Ubuntu's distributions.
|
||||||
- ubuntu-iso - output information of an Ubuntu ISO image.
|
- ubuntu-iso - output information of an Ubuntu ISO image.
|
||||||
- update-maintainer - script to update maintainer field in ubuntu packages.
|
- update-maintainer - script to update maintainer field in ubuntu packages.
|
||||||
- wrap-and-sort - wrap long lines and sort items in packaging files.
|
|
||||||
|
6
debian/copyright
vendored
6
debian/copyright
vendored
@ -175,29 +175,23 @@ Files: data/*
|
|||||||
doc/pull-debian-debdiff.1
|
doc/pull-debian-debdiff.1
|
||||||
doc/pull-debian-source.1
|
doc/pull-debian-source.1
|
||||||
doc/sponsor-patch.1
|
doc/sponsor-patch.1
|
||||||
doc/suspicious-source.1
|
|
||||||
doc/ubuntu-dev-tools.5
|
doc/ubuntu-dev-tools.5
|
||||||
doc/ubuntu-distro-info.1
|
doc/ubuntu-distro-info.1
|
||||||
doc/update-maintainer.1
|
doc/update-maintainer.1
|
||||||
doc/wrap-and-sort.1
|
|
||||||
pull-debian-debdiff
|
pull-debian-debdiff
|
||||||
pull-debian-source
|
pull-debian-source
|
||||||
sponsor-patch
|
sponsor-patch
|
||||||
suspicious-source
|
|
||||||
test-data/*
|
test-data/*
|
||||||
ubuntu-distro-info
|
ubuntu-distro-info
|
||||||
ubuntutools/archive.py
|
ubuntutools/archive.py
|
||||||
ubuntutools/builder.py
|
ubuntutools/builder.py
|
||||||
ubuntutools/config.py
|
ubuntutools/config.py
|
||||||
ubuntutools/control.py
|
|
||||||
ubuntutools/distro_info.py
|
ubuntutools/distro_info.py
|
||||||
ubuntutools/logger.py
|
|
||||||
ubuntutools/question.py
|
ubuntutools/question.py
|
||||||
ubuntutools/sponsor_patch/*
|
ubuntutools/sponsor_patch/*
|
||||||
ubuntutools/test/*
|
ubuntutools/test/*
|
||||||
ubuntutools/update_maintainer.py
|
ubuntutools/update_maintainer.py
|
||||||
update-maintainer
|
update-maintainer
|
||||||
wrap-and-sort
|
|
||||||
Copyright: 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
Copyright: 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
2010, Evan Broder <evan@ebroder.net>
|
2010, Evan Broder <evan@ebroder.net>
|
||||||
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
.\" Copyright (c) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
.\" purpose with or without fee is hereby granted, provided that the above
|
|
||||||
.\" copyright notice and this permission notice appear in all copies.
|
|
||||||
.\"
|
|
||||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
.\"
|
|
||||||
.TH SUSPICIOUS\-SOURCE 1 "August 2010" "ubuntu-dev-tools"
|
|
||||||
|
|
||||||
.SH NAME
|
|
||||||
suspicious\-source \- search for files that are not the GPL's
|
|
||||||
"preferred form of modification"
|
|
||||||
|
|
||||||
.SH SYNOPSIS
|
|
||||||
\fBsuspicious\-source\fP [\fIoptions\fR]
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
\fBsuspicious\-source\fP is a script that outputs a list of files which
|
|
||||||
are not common source files.
|
|
||||||
This should be run in the root of a source tree to find files which might
|
|
||||||
not be the "preferred form of modification" that the GPL and other licenses
|
|
||||||
require.
|
|
||||||
.PP
|
|
||||||
The files inside version control system directories (like
|
|
||||||
".bzr/" or "CVS/") are not considered.
|
|
||||||
|
|
||||||
.SH OPTIONS
|
|
||||||
.TP
|
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
|
||||||
show this help message and exit
|
|
||||||
.TP
|
|
||||||
\fB\-v\fR, \fB\-\-verbose\fR
|
|
||||||
print more information
|
|
||||||
.TP
|
|
||||||
\fB\-d\fR DIRECTORY, \fB\-\-directory\fR=\fIDIRECTORY\fR
|
|
||||||
check the files in the specified directory instead of the current directory
|
|
||||||
.TP
|
|
||||||
\fB\-m\fR MIMETYPE, \fB\-\-mimetype\fR=\fIMIMETYPE\fR
|
|
||||||
Add MIMETYPE to list of white-listed mime-types.
|
|
||||||
.TP
|
|
||||||
\fB\-e\fR EXTENSION, \fB\-\-extension\fR=\fIEXTENSION\fR
|
|
||||||
Add EXTENSION to list of white-listed extensions.
|
|
||||||
|
|
||||||
.SH AUTHORS
|
|
||||||
\fBsuspicious\-source\fP and this manpage has been written by
|
|
||||||
Benjamin Drung <bdrung@ubuntu.com>.
|
|
||||||
.PP
|
|
||||||
Both are released under the ISC license.
|
|
@ -1,74 +0,0 @@
|
|||||||
.\" Copyright (c) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
.\" purpose with or without fee is hereby granted, provided that the above
|
|
||||||
.\" copyright notice and this permission notice appear in all copies.
|
|
||||||
.\"
|
|
||||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
.\"
|
|
||||||
.TH WRAP\-AND\-SORT 1 "September 2010" "ubuntu-dev-tools"
|
|
||||||
.SH NAME
|
|
||||||
wrap-and-sort \- wrap long lines and sort items in packaging files
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B wrap-and-sort
|
|
||||||
[\fIoptions\fR]
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
\fBwrap\-and\-sort\fP wraps the package lists in Debian control files. By
|
|
||||||
default the lists will only split into multiple lines if the entries are longer
|
|
||||||
than 80 characters. \fBwrap\-and\-sort\fP sorts the package lists in Debian
|
|
||||||
control files and all .install files. Beside that \fBwrap\-and\-sort\fP removes
|
|
||||||
trailing spaces in these files.
|
|
||||||
.PP
|
|
||||||
This script should be run in the root of a Debian package tree. It searches for
|
|
||||||
control, control.in, copyright, copyright.in, install, and *.install in the
|
|
||||||
debian directory.
|
|
||||||
|
|
||||||
.SH OPTIONS
|
|
||||||
.TP
|
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
|
||||||
show this help message and exit
|
|
||||||
.TP
|
|
||||||
\fB\-a\fR, \fB\-\-wrap\-always\fR
|
|
||||||
wrap all package lists in the Debian control file
|
|
||||||
even if the entries are shorter than 80 characters and could fit in one line
|
|
||||||
line
|
|
||||||
.TP
|
|
||||||
\fB\-s\fR, \fB\-\-short\-indent\fR
|
|
||||||
only indent wrapped lines by one space (default is in\-line with the
|
|
||||||
field name)
|
|
||||||
.TP
|
|
||||||
\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
|
|
||||||
\fB\-d \fIPATH\fR, \fB\-\-debian\-directory\fR=\fIPATH\fR
|
|
||||||
location of the \fIdebian\fR directory (default: \fB./debian\fR)
|
|
||||||
.TP
|
|
||||||
\fB\-f\fI FILE\fR, \fB\-\-file\fR=\fIFILE\fR
|
|
||||||
Wrap and sort only the specified file.
|
|
||||||
You can specify this parameter multiple times.
|
|
||||||
All supported files will be processed if no files are specified.
|
|
||||||
.TP
|
|
||||||
\fB\-v\fR, \fB\-\-verbose\fR
|
|
||||||
print all files that are touched
|
|
||||||
|
|
||||||
.SH AUTHORS
|
|
||||||
\fBwrap\-and\-sort\fP and this manpage has been written by
|
|
||||||
Benjamin Drung <bdrung@ubuntu.com>.
|
|
||||||
.PP
|
|
||||||
Both are released under the ISC license.
|
|
@ -33,8 +33,9 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.distro_info import DebianDistroInfo
|
from ubuntutools.distro_info import DebianDistroInfo
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
import ubuntutools.misc
|
import ubuntutools.misc
|
||||||
|
|
||||||
class PbuilderDist:
|
class PbuilderDist:
|
||||||
|
@ -23,9 +23,10 @@ import sys
|
|||||||
import debian.debian_support
|
import debian.debian_support
|
||||||
import debian.changelog
|
import debian.changelog
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.archive import DebianSourcePackage, DownloadError
|
from ubuntutools.archive import DebianSourcePackage, DownloadError
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
|
|
||||||
def previous_version(package, version, distance):
|
def previous_version(package, version, distance):
|
||||||
"Given an (extracted) package, determine the version distance versions ago"
|
"Given an (extracted) package, determine the version distance versions ago"
|
||||||
|
@ -19,10 +19,11 @@
|
|||||||
import optparse
|
import optparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison
|
from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
from ubuntutools.distro_info import DebianDistroInfo
|
from ubuntutools.distro_info import DebianDistroInfo
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
|
|
||||||
def is_suite(version):
|
def is_suite(version):
|
||||||
"""If version could be considered to be a Debian suite, return the
|
"""If version could be considered to be a Debian suite, return the
|
||||||
|
@ -27,10 +27,11 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.archive import UbuntuSourcePackage, DownloadError
|
from ubuntutools.archive import UbuntuSourcePackage, DownloadError
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
from ubuntutools.distro_info import UbuntuDistroInfo
|
from ubuntutools.distro_info import UbuntuDistroInfo
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
from ubuntutools.lp.lpapicache import Distribution, Launchpad
|
from ubuntutools.lp.lpapicache import Distribution, Launchpad
|
||||||
from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
|
from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
|
||||||
PackageNotFoundException,
|
PackageNotFoundException,
|
||||||
|
2
setup.py
2
setup.py
@ -47,13 +47,11 @@ scripts = ['404main',
|
|||||||
'setup-packaging-environment',
|
'setup-packaging-environment',
|
||||||
'sponsor-patch',
|
'sponsor-patch',
|
||||||
'submittodebian',
|
'submittodebian',
|
||||||
'suspicious-source',
|
|
||||||
'syncpackage',
|
'syncpackage',
|
||||||
'ubuntu-build',
|
'ubuntu-build',
|
||||||
'ubuntu-distro-info',
|
'ubuntu-distro-info',
|
||||||
'ubuntu-iso',
|
'ubuntu-iso',
|
||||||
'update-maintainer',
|
'update-maintainer',
|
||||||
'wrap-and-sort',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -20,9 +20,10 @@ import shutil
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
from ubuntutools.builder import get_builder
|
from ubuntutools.builder import get_builder
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
from ubuntutools.sponsor_patch.sponsor_patch import sponsor_patch
|
from ubuntutools.sponsor_patch.sponsor_patch import sponsor_patch
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -1,145 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Copyright (c) 2010-2011, Benjamin Drung <bdrung@ubuntu.com>
|
|
||||||
#
|
|
||||||
# Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
# purpose with or without fee is hereby granted, provided that the above
|
|
||||||
# copyright notice and this permission notice appear in all copies.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
import optparse
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
|
|
||||||
try:
|
|
||||||
import magic
|
|
||||||
except ImportError:
|
|
||||||
Logger.error("Please install 'python-magic' in order to use this utility.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
DEFAULT_WHITELISTED_MIMETYPES = [
|
|
||||||
"application/vnd.font-fontforge-sfd", # font source: fontforge
|
|
||||||
"application/x-elc",
|
|
||||||
"application/x-empty",
|
|
||||||
"application/x-font-otf", # font object and source
|
|
||||||
"application/x-font-ttf", # font object and source
|
|
||||||
"application/x-font-woff", # font object and source
|
|
||||||
"application/x-symlink",
|
|
||||||
"application/xml",
|
|
||||||
"audio/x-wav",
|
|
||||||
"font/otf", # font object and source
|
|
||||||
"font/ttf", # font object and source
|
|
||||||
"image/gif",
|
|
||||||
"image/jpeg",
|
|
||||||
"image/png",
|
|
||||||
"image/svg+xml",
|
|
||||||
"image/vnd.adobe.photoshop",
|
|
||||||
"image/x-icns",
|
|
||||||
"image/x-ico",
|
|
||||||
"image/x-ms-bmp",
|
|
||||||
"image/x-portable-pixmap",
|
|
||||||
"message/rfc822",
|
|
||||||
"text/html",
|
|
||||||
"text/plain",
|
|
||||||
"text/rtf",
|
|
||||||
"text/troff",
|
|
||||||
"text/x-asm",
|
|
||||||
"text/x-c",
|
|
||||||
"text/x-c++",
|
|
||||||
"text/x-diff",
|
|
||||||
"text/x-fortran",
|
|
||||||
"text/x-java",
|
|
||||||
"text/x-lisp",
|
|
||||||
"text/x-m4",
|
|
||||||
"text/x-makefile",
|
|
||||||
"text/x-msdos-batch",
|
|
||||||
"text/x-pascal",
|
|
||||||
"text/x-perl",
|
|
||||||
"text/x-php",
|
|
||||||
"text/x-po",
|
|
||||||
"text/x-python",
|
|
||||||
"text/x-shellscript",
|
|
||||||
"text/x-tex",
|
|
||||||
"text/x-texinfo",
|
|
||||||
]
|
|
||||||
|
|
||||||
DEFAULT_WHITELISTED_EXTENSIONS = [
|
|
||||||
".fea", # font source format: Adobe Font Development Kit for OpenType
|
|
||||||
".fog", # font source format: Fontographer
|
|
||||||
".g2n", # font source format: fontforge
|
|
||||||
".gdh", # font source format: Graphite (headers)
|
|
||||||
".gdl", # font source format: Graphite
|
|
||||||
".glyph", # font source format: cross-toolkit UFO
|
|
||||||
".icns", # Apple Icon Image format
|
|
||||||
".java", # Java source files
|
|
||||||
".plate", # font source format: Spiro
|
|
||||||
".rsa",
|
|
||||||
".sfd", # font source format: fontforge
|
|
||||||
".sfdir", # font source format: fontforge
|
|
||||||
".ttx", # font source format: fonttools
|
|
||||||
".ufo", # font source format: cross-toolkit UFO
|
|
||||||
".vfb" # font source format: FontLab
|
|
||||||
".vtp", # font source format: OpenType (VOLT)
|
|
||||||
".xgf", # font source format: Xgridfit
|
|
||||||
]
|
|
||||||
|
|
||||||
def suspicious_source(whitelisted_mimetypes, whitelisted_extensions, directory,
|
|
||||||
verbose=False):
|
|
||||||
magic_cookie = magic.open(magic.MAGIC_MIME_TYPE)
|
|
||||||
magic_cookie.load()
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(directory):
|
|
||||||
for f in files:
|
|
||||||
mimetype = magic_cookie.file(os.path.join(root, f))
|
|
||||||
if mimetype not in whitelisted_mimetypes:
|
|
||||||
if not [x for x in whitelisted_extensions
|
|
||||||
if f.lower().endswith(x)]:
|
|
||||||
if verbose:
|
|
||||||
print "%s (%s)" % (os.path.join(root, f), mimetype)
|
|
||||||
else:
|
|
||||||
print os.path.join(root, f)
|
|
||||||
for vcs_dir in (".bzr", "CVS", ".git", ".svn"):
|
|
||||||
if vcs_dir in dirs:
|
|
||||||
dirs.remove(vcs_dir)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
script_name = os.path.basename(sys.argv[0])
|
|
||||||
usage = "%s [options]" % (script_name)
|
|
||||||
epilog = "See %s(1) for more info." % (script_name)
|
|
||||||
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
|
||||||
|
|
||||||
parser.add_option("-v", "--verbose", help="print more information",
|
|
||||||
dest="verbose", action="store_true", default=False)
|
|
||||||
parser.add_option("-d", "--directory",
|
|
||||||
help="check the files in the specified directory",
|
|
||||||
dest="directory", default=".")
|
|
||||||
parser.add_option("-m", "--mimetype", metavar="MIMETYPE",
|
|
||||||
help="Add MIMETYPE to list of whitelisted mimetypes.",
|
|
||||||
dest="whitelisted_mimetypes", action="append",
|
|
||||||
default=DEFAULT_WHITELISTED_MIMETYPES)
|
|
||||||
parser.add_option("-e", "--extension", metavar="EXTENSION",
|
|
||||||
help="Add EXTENSION to list of whitelisted extensions.",
|
|
||||||
dest="whitelisted_extensions", action="append",
|
|
||||||
default=DEFAULT_WHITELISTED_EXTENSIONS)
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
if len(args) != 0:
|
|
||||||
Logger.error("This script does not take any additional parameters.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
whitelisted_extensions = [x.lower() for x in options.whitelisted_extensions]
|
|
||||||
suspicious_source(options.whitelisted_mimetypes, whitelisted_extensions,
|
|
||||||
options.directory, options.verbose)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
@ -28,13 +28,14 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage,
|
from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage,
|
||||||
DownloadError)
|
DownloadError)
|
||||||
from ubuntutools.config import UDTConfig, ubu_email
|
from ubuntutools.config import UDTConfig, ubu_email
|
||||||
from ubuntutools.requestsync.mail import (getDebianSrcPkg
|
from ubuntutools.requestsync.mail import (getDebianSrcPkg
|
||||||
as requestsync_mail_getDebianSrcPkg)
|
as requestsync_mail_getDebianSrcPkg)
|
||||||
from ubuntutools.requestsync.lp import getDebianSrcPkg, getUbuntuSrcPkg
|
from ubuntutools.requestsync.lp import getDebianSrcPkg, getUbuntuSrcPkg
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
from ubuntutools.lp import udtexceptions
|
from ubuntutools.lp import udtexceptions
|
||||||
from ubuntutools.lp.lpapicache import Launchpad
|
from ubuntutools.lp.lpapicache import Launchpad
|
||||||
|
|
||||||
|
@ -40,8 +40,9 @@ import sys
|
|||||||
import debian.deb822
|
import debian.deb822
|
||||||
import debian.debian_support
|
import debian.debian_support
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
from ubuntutools.lp.lpapicache import (Launchpad, Distribution,
|
from ubuntutools.lp.lpapicache import (Launchpad, Distribution,
|
||||||
SourcePackagePublishingHistory)
|
SourcePackagePublishingHistory)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from ubuntutools.logger import Logger
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
def _build_preparation(result_directory):
|
def _build_preparation(result_directory):
|
||||||
"""prepares the builder for building a package"""
|
"""prepares the builder for building a package"""
|
||||||
|
@ -23,7 +23,7 @@ import shlex
|
|||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ubuntutools.logger import Logger
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
class UDTConfig(object):
|
class UDTConfig(object):
|
||||||
"""Ubuntu Dev Tools configuration file (devscripts config file) and
|
"""Ubuntu Dev Tools configuration file (devscripts config file) and
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
# control.py - Represents a debian/control file
|
|
||||||
#
|
|
||||||
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
|
||||||
#
|
|
||||||
# Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
# purpose with or without fee is hereby granted, provided that the above
|
|
||||||
# copyright notice and this permission notice appear in all copies.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
"""This module implements facilities to deal with Debian control."""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
import debian.deb822
|
|
||||||
|
|
||||||
def _insert_after(paragraph, item_before, new_item, new_value):
|
|
||||||
"""Insert new_item into directly after item_before
|
|
||||||
|
|
||||||
New items added to a dictionary are appended."""
|
|
||||||
item_found = False
|
|
||||||
for item in paragraph:
|
|
||||||
if item_found:
|
|
||||||
value = paragraph.pop(item)
|
|
||||||
paragraph[item] = value
|
|
||||||
if item == item_before:
|
|
||||||
item_found = True
|
|
||||||
paragraph[new_item] = new_value
|
|
||||||
if not item_found:
|
|
||||||
paragraph[new_item] = new_value
|
|
||||||
|
|
||||||
class Control(object):
|
|
||||||
"""Represents a debian/control file"""
|
|
||||||
|
|
||||||
def __init__(self, filename):
|
|
||||||
assert os.path.isfile(filename), "%s does not exist." % (filename)
|
|
||||||
self.filename = filename
|
|
||||||
sequence = open(filename)
|
|
||||||
self.paragraphs = list()
|
|
||||||
for paragraph in debian.deb822.Deb822.iter_paragraphs(sequence):
|
|
||||||
self.paragraphs.append(paragraph)
|
|
||||||
|
|
||||||
def get_maintainer(self):
|
|
||||||
"""Returns the value of the Maintainer field."""
|
|
||||||
return self.paragraphs[0].get("Maintainer")
|
|
||||||
|
|
||||||
def get_original_maintainer(self):
|
|
||||||
"""Returns the value of the XSBC-Original-Maintainer field."""
|
|
||||||
return self.paragraphs[0].get("XSBC-Original-Maintainer")
|
|
||||||
|
|
||||||
def save(self, filename=None):
|
|
||||||
"""Saves the control file."""
|
|
||||||
if filename:
|
|
||||||
self.filename = filename
|
|
||||||
content = u"\n".join([x.dump() for x in self.paragraphs])
|
|
||||||
control_file = open(self.filename, "w")
|
|
||||||
control_file.write(content.encode("utf-8"))
|
|
||||||
control_file.close()
|
|
||||||
|
|
||||||
def set_maintainer(self, maintainer):
|
|
||||||
"""Sets the value of the Maintainer field."""
|
|
||||||
self.paragraphs[0]["Maintainer"] = maintainer
|
|
||||||
|
|
||||||
def set_original_maintainer(self, original_maintainer):
|
|
||||||
"""Sets the value of the XSBC-Original-Maintainer field."""
|
|
||||||
if "XSBC-Original-Maintainer" in self.paragraphs[0]:
|
|
||||||
self.paragraphs[0]["XSBC-Original-Maintainer"] = original_maintainer
|
|
||||||
else:
|
|
||||||
_insert_after(self.paragraphs[0], "Maintainer",
|
|
||||||
"XSBC-Original-Maintainer", original_maintainer)
|
|
||||||
|
|
||||||
def strip_trailing_spaces(self):
|
|
||||||
"""Strips all trailing spaces from the control file."""
|
|
||||||
for paragraph in self.paragraphs:
|
|
||||||
for item in paragraph:
|
|
||||||
lines = paragraph[item].split("\n")
|
|
||||||
paragraph[item] = "\n".join([l.rstrip() for l in lines])
|
|
@ -1,68 +0,0 @@
|
|||||||
#
|
|
||||||
# logger.py - A simple logging helper class
|
|
||||||
#
|
|
||||||
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
|
||||||
#
|
|
||||||
# Permission to use, copy, modify, and/or distribute this software
|
|
||||||
# for any purpose with or without fee is hereby granted, provided
|
|
||||||
# that the above copyright notice and this permission notice appear
|
|
||||||
# in all copies.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
|
||||||
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
|
||||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
|
||||||
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
|
||||||
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
||||||
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def escape_arg(arg):
|
|
||||||
"Shell-escpae arg, if necessary"
|
|
||||||
if ' ' not in arg:
|
|
||||||
return arg
|
|
||||||
return '"%s"' % arg.replace('\\', r'\\').replace('"', r'\"')
|
|
||||||
|
|
||||||
class Logger(object):
|
|
||||||
script_name = os.path.basename(sys.argv[0])
|
|
||||||
verbose = False
|
|
||||||
|
|
||||||
stdout = sys.stdout
|
|
||||||
stderr = sys.stderr
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def command(cls, cmd):
|
|
||||||
if cls.verbose:
|
|
||||||
print >> cls.stdout, "%s: I: %s" % (cls.script_name,
|
|
||||||
" ".join(escape_arg(arg)
|
|
||||||
for arg in cmd))
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def debug(cls, message, *args):
|
|
||||||
if cls.verbose:
|
|
||||||
print >> cls.stderr, "%s: D: %s" % (cls.script_name, message % args)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def error(cls, message, *args):
|
|
||||||
print >> cls.stderr, "%s: Error: %s" % (cls.script_name, message % args)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def warn(cls, message, *args):
|
|
||||||
print >> cls.stderr, "%s: Warning: %s" % (cls.script_name,
|
|
||||||
message % args)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def info(cls, message, *args):
|
|
||||||
if cls.verbose:
|
|
||||||
print >> cls.stdout, "%s: I: %s" % (cls.script_name, message % args)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def normal(cls, message, *args):
|
|
||||||
print >> cls.stdout, "%s: %s" % (cls.script_name, message % args)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def set_verbosity(cls, verbose):
|
|
||||||
cls.verbose = verbose
|
|
@ -21,8 +21,9 @@ import urllib
|
|||||||
|
|
||||||
import debian.debian_support
|
import debian.debian_support
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.distro_info import DebianDistroInfo
|
from ubuntutools.distro_info import DebianDistroInfo
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
|
|
||||||
class BugTask(object):
|
class BugTask(object):
|
||||||
def __init__(self, bug_task, launchpad):
|
def __init__(self, bug_task, launchpad):
|
||||||
|
@ -26,8 +26,9 @@ import debian.changelog
|
|||||||
import debian.deb822
|
import debian.deb822
|
||||||
import launchpadlib.launchpad
|
import launchpadlib.launchpad
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.update_maintainer import update_maintainer
|
from ubuntutools.update_maintainer import update_maintainer
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
from ubuntutools.question import Question, YesNoQuestion, input_number
|
from ubuntutools.question import Question, YesNoQuestion, input_number
|
||||||
|
|
||||||
from ubuntutools.sponsor_patch.bugtask import BugTask
|
from ubuntutools.sponsor_patch.bugtask import BugTask
|
||||||
|
@ -26,9 +26,10 @@ import urllib2
|
|||||||
import debian.deb822
|
import debian.deb822
|
||||||
import mox
|
import mox
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
import ubuntutools.archive
|
import ubuntutools.archive
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
from ubuntutools.test import unittest
|
from ubuntutools.test import unittest
|
||||||
|
|
||||||
from ubuntutools.test.example_package import ExamplePackage
|
from ubuntutools.test.example_package import ExamplePackage
|
||||||
|
@ -22,8 +22,9 @@ from StringIO import StringIO
|
|||||||
|
|
||||||
import mox
|
import mox
|
||||||
|
|
||||||
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.config import UDTConfig, ubu_email
|
from ubuntutools.config import UDTConfig, ubu_email
|
||||||
from ubuntutools.logger import Logger
|
|
||||||
from ubuntutools.test import unittest
|
from ubuntutools.test import unittest
|
||||||
|
|
||||||
class ConfigTestCase(mox.MoxTestBase, unittest.TestCase):
|
class ConfigTestCase(mox.MoxTestBase, unittest.TestCase):
|
||||||
|
@ -23,7 +23,8 @@ import sys
|
|||||||
|
|
||||||
import mox
|
import mox
|
||||||
|
|
||||||
from ubuntutools.logger import Logger
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.test import unittest
|
from ubuntutools.test import unittest
|
||||||
from ubuntutools.update_maintainer import update_maintainer
|
from ubuntutools.update_maintainer import update_maintainer
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import re
|
|||||||
|
|
||||||
import debian.changelog
|
import debian.changelog
|
||||||
|
|
||||||
from ubuntutools.logger import Logger
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
# Prior May 2009 these Maintainers were used:
|
# Prior May 2009 these Maintainers were used:
|
||||||
_PREVIOUS_UBUNTU_MAINTAINER = (
|
_PREVIOUS_UBUNTU_MAINTAINER = (
|
||||||
|
225
wrap-and-sort
225
wrap-and-sort
@ -1,225 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
#
|
|
||||||
# Copyright (C) 2010-2011, Benjamin Drung <bdrung@ubuntu.com>
|
|
||||||
# 2010, Stefano Rivera <stefanor@ubuntu.com>
|
|
||||||
#
|
|
||||||
# Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
# purpose with or without fee is hereby granted, provided that the above
|
|
||||||
# copyright notice and this permission notice appear in all copies.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
import glob
|
|
||||||
import optparse
|
|
||||||
import os
|
|
||||||
import os.path
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from ubuntutools.control import Control
|
|
||||||
|
|
||||||
CONTROL_LIST_FIELDS = (
|
|
||||||
"Breaks",
|
|
||||||
"Build-Conflicts",
|
|
||||||
"Build-Depends",
|
|
||||||
"Build-Depends-Indep",
|
|
||||||
"Conflicts",
|
|
||||||
"Depends",
|
|
||||||
"Enhances",
|
|
||||||
"Provides",
|
|
||||||
"Recommends",
|
|
||||||
"Replaces",
|
|
||||||
"Suggests",
|
|
||||||
"Xb-Npp-MimeType",
|
|
||||||
)
|
|
||||||
|
|
||||||
SUPPORTED_FILES = (
|
|
||||||
"control",
|
|
||||||
"control.in",
|
|
||||||
"copyright",
|
|
||||||
"copyright.in",
|
|
||||||
"install",
|
|
||||||
"*.install",
|
|
||||||
)
|
|
||||||
|
|
||||||
class WrapAndSortControl(Control):
|
|
||||||
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:
|
|
||||||
self._wrap_field(paragraph, field, wrap_always,
|
|
||||||
short_indent)
|
|
||||||
if "Uploaders" in paragraph:
|
|
||||||
self._wrap_field(paragraph, "Uploaders", wrap_always,
|
|
||||||
short_indent, False)
|
|
||||||
if "Architecture" in paragraph:
|
|
||||||
archs = set(paragraph["Architecture"].split())
|
|
||||||
# Sort, with wildcard entries (such as linux-any) first:
|
|
||||||
archs = sorted(archs, key=lambda x: ("any" not in x, x))
|
|
||||||
paragraph["Architecture"] = " ".join(archs)
|
|
||||||
|
|
||||||
if sort_paragraphs:
|
|
||||||
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 = [x.strip() for x in control[entry].split(",")]
|
|
||||||
if sort:
|
|
||||||
# Remove duplicate entries
|
|
||||||
packages = set(packages)
|
|
||||||
# Not explicitly disallowed by Policy but known to break QA tools:
|
|
||||||
if "" in packages:
|
|
||||||
packages.remove("")
|
|
||||||
packages = sort_list(packages)
|
|
||||||
|
|
||||||
length = len(entry) + sum([2 + len(package) for package in packages])
|
|
||||||
if wrap_always or length > 80:
|
|
||||||
indentation = " "
|
|
||||||
if not short_indent:
|
|
||||||
indentation *= len(entry) + 2
|
|
||||||
packages_with_indention = [indentation + x for x in packages]
|
|
||||||
packages_with_indention = ",\n".join(packages_with_indention)
|
|
||||||
if short_indent:
|
|
||||||
control[entry] = "\n" + packages_with_indention
|
|
||||||
else:
|
|
||||||
control[entry] = packages_with_indention.strip()
|
|
||||||
else:
|
|
||||||
control[entry] = ", ".join(packages).strip()
|
|
||||||
|
|
||||||
|
|
||||||
class Install(object):
|
|
||||||
def __init__(self, filename):
|
|
||||||
self.content = None
|
|
||||||
self.filename = None
|
|
||||||
self.open(filename)
|
|
||||||
|
|
||||||
def open(self, filename):
|
|
||||||
assert os.path.isfile(filename), "%s does not exist." % (filename)
|
|
||||||
self.filename = filename
|
|
||||||
self.content = open(filename).readlines()
|
|
||||||
|
|
||||||
def save(self, filename=None):
|
|
||||||
if filename:
|
|
||||||
self.filename = filename
|
|
||||||
install_file = open(self.filename, "w")
|
|
||||||
install_file.write("".join(self.content))
|
|
||||||
install_file.close()
|
|
||||||
|
|
||||||
def sort(self):
|
|
||||||
self.content = sorted(self.content)
|
|
||||||
|
|
||||||
|
|
||||||
def remove_trailing_whitespaces(filename):
|
|
||||||
assert os.path.isfile(filename), "%s does not exist." % (filename)
|
|
||||||
content = open(filename).read().rstrip() + "\n"
|
|
||||||
lines = content.split("\n")
|
|
||||||
lines = [l.rstrip() for l in lines]
|
|
||||||
new_content = "\n".join(lines)
|
|
||||||
f = open(filename, "w")
|
|
||||||
f.write(new_content)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
def sort_list(unsorted_list):
|
|
||||||
normal = [x for x in unsorted_list if not x.startswith("${")]
|
|
||||||
param = [x for x in unsorted_list if x.startswith("${")]
|
|
||||||
return sorted(normal) + sorted(param)
|
|
||||||
|
|
||||||
def wrap_and_sort(options):
|
|
||||||
control_files = [f for f in options.files if re.search("/control[^/]*$", f)]
|
|
||||||
for control_file in control_files:
|
|
||||||
if options.verbose:
|
|
||||||
print control_file
|
|
||||||
control = WrapAndSortControl(control_file)
|
|
||||||
if options.cleanup:
|
|
||||||
control.strip_trailing_spaces()
|
|
||||||
control.wrap_and_sort(options.wrap_always, options.short_indent,
|
|
||||||
options.sort_binary_packages, options.keep_first)
|
|
||||||
control.save()
|
|
||||||
|
|
||||||
copyright_files = [f for f in options.files
|
|
||||||
if re.search("/copyright[^/]*$", f)]
|
|
||||||
for copyright_file in copyright_files:
|
|
||||||
if options.verbose:
|
|
||||||
print copyright_file
|
|
||||||
remove_trailing_whitespaces(copyright_file)
|
|
||||||
|
|
||||||
install_files = [f for f in options.files if re.search("install$", f)]
|
|
||||||
for install_file in sorted(install_files):
|
|
||||||
if options.verbose:
|
|
||||||
print install_file
|
|
||||||
install = Install(install_file)
|
|
||||||
install.sort()
|
|
||||||
install.save()
|
|
||||||
|
|
||||||
def get_files(debian_directory):
|
|
||||||
"""Returns a list of files that should be wrapped and sorted."""
|
|
||||||
files = []
|
|
||||||
for supported_files in SUPPORTED_FILES:
|
|
||||||
files.extend(glob.glob(os.path.join(debian_directory, supported_files)))
|
|
||||||
return files
|
|
||||||
|
|
||||||
def main():
|
|
||||||
script_name = os.path.basename(sys.argv[0])
|
|
||||||
usage = "%s [options]" % (script_name)
|
|
||||||
epilog = "See %s(1) for more info." % (script_name)
|
|
||||||
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
|
||||||
|
|
||||||
parser.add_option("-a", "--wrap-always", dest="wrap_always",
|
|
||||||
help="wrap lists even if they fit into one 80 character "
|
|
||||||
"long line", action="store_true", default=False)
|
|
||||||
parser.add_option("-s", "--short-indent", dest="short_indent",
|
|
||||||
help="only indent wrapped lines by one space (default is "
|
|
||||||
"in-line with the field name)",
|
|
||||||
action="store_true", default=False)
|
|
||||||
parser.add_option("-b", "--sort-binary-packages",
|
|
||||||
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",
|
|
||||||
help="location of the 'debian' directory (default: "
|
|
||||||
"./debian)", metavar="PATH", default="debian")
|
|
||||||
parser.add_option("-f", "--file", metavar="FILE",
|
|
||||||
dest="files", action="append", default=list(),
|
|
||||||
help="Wrap and sort only the specified file.")
|
|
||||||
parser.add_option("-v", "--verbose",
|
|
||||||
help="print all files that are touched",
|
|
||||||
dest="verbose", action="store_true", default=False)
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
if len(args) != 0:
|
|
||||||
parser.error("Unsupported additional parameters specified: %s" % \
|
|
||||||
", ".join(args))
|
|
||||||
|
|
||||||
if not os.path.isdir(options.debian_directory):
|
|
||||||
parser.error('Debian directory not found, expecting "%s".' % \
|
|
||||||
options.debian_directory)
|
|
||||||
|
|
||||||
not_found = [f for f in options.files if not os.path.isfile(f)]
|
|
||||||
if not_found:
|
|
||||||
parser.error('Specified files not found: %s' % ", ".join(not_found))
|
|
||||||
|
|
||||||
if not options.files:
|
|
||||||
options.files = get_files(options.debian_directory)
|
|
||||||
|
|
||||||
wrap_and_sort(options)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
Loading…
x
Reference in New Issue
Block a user