tools/bmap-tools.git
10 years agoTransRead: accept the logger object
Artem Bityutskiy [Fri, 13 Sep 2013 09:55:14 +0000 (12:55 +0300)]
TransRead: accept the logger object

In order to improve user experience, I would like to print warnings when we
cannot open the URL for some time. This requires the TransRead object to accept
the logger object, or take the global one.

Change-Id: I4fc9f3d6544a2a699b6476dddf362aa127e81550
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoTransRead: handle the urllib2.URLError exception
Artem Bityutskiy [Fri, 13 Sep 2013 09:26:56 +0000 (12:26 +0300)]
TransRead: handle the urllib2.URLError exception

When opening an URL with urllib2, handle the URLError exceptions too.

This patch adds a new "except" statement instead of adding the exception object
to the existing array. The reason is that in the next commit we will need to
handle the urllib2.URLError exceptions a bit differently.

This patch also refactors the code a tiny bit as a preparation to the next
commit.

Change-Id: I69856aa8698b495c5a2450979db9384aad1b713a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoTODO: add another comment release-2.0 v2.6
Artem Bityutskiy [Mon, 19 Aug 2013 13:16:37 +0000 (16:16 +0300)]
TODO: add another comment

Change-Id: I8ae67484c49eefdbd0d030059a6a6a259ce8d33f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoRelease version 2.6
Artem Bityutskiy [Tue, 13 Aug 2013 11:56:24 +0000 (14:56 +0300)]
Release version 2.6

Change-Id: Ic0aba0b20847454b35c7dee9d50dccdbd2cf11fa
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agomake_a_release.sh: add few more reminders
Artem Bityutskiy [Fri, 16 Aug 2013 09:39:54 +0000 (12:39 +0300)]
make_a_release.sh: add few more reminders

Change-Id: Ifaf378a0b803a97ca3c15bb2b3adf8ffa73cdde9
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoTODO: add more entries
Artem Bityutskiy [Fri, 16 Aug 2013 09:38:59 +0000 (12:38 +0300)]
TODO: add more entries

Change-Id: I9cc5be56bb7f535fc20d50cc6ee1ffd5e708a138
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoREADME: document the make_a_release.sh script
Artem Bityutskiy [Thu, 15 Aug 2013 07:01:40 +0000 (10:01 +0300)]
README: document the make_a_release.sh script

Change-Id: Ie90e707d2546d66064a6ec9af61ce6216984b1a2
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoAdd the TODO list
Artem Bityutskiy [Wed, 14 Aug 2013 11:07:23 +0000 (14:07 +0300)]
Add the TODO list

Change-Id: Ib67bb47a25e3781ee6986693ed45fe22a418f343
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoTransRead: do not cache local uncompressed files
Artem Bityutskiy [Wed, 14 Aug 2013 10:58:34 +0000 (13:58 +0300)]
TransRead: do not cache local uncompressed files

When the file is already local and uncompressed, do not create a temporary copy
of it when 'local' is True.

On top of this, re-use own __init__ function to re-open the local copy of the
remote/compressed file.

Change-Id: I2093419ed2cfc6d40f73a47657682436b8932402
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agotests: cover .xz files too
Artem Bityutskiy [Wed, 14 Aug 2013 10:33:09 +0000 (13:33 +0300)]
tests: cover .xz files too

Change-Id: I4e8318174a0a92f7c795c0c5cc61aeeff7237442
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoTransRead: store all file descriptors in a list
Artem Bityutskiy [Wed, 14 Aug 2013 10:14:11 +0000 (13:14 +0300)]
TransRead: store all file descriptors in a list

This patch improves readability and does not do any functional changes.

In the TransRead module we have chains of file-like objects, every next element
of the chain is based on the previous one. And we store each element of the
chain in own variable like 'self._file_obj3', which is a bit ugly. Let's
introduce a 'self._f_objs' list, and just append there, and the last element is
always the final "transparent read" file descriptor.

Change-Id: I498130e9de35e65bddc7d3dbb4f47bdab795549e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agopackaging: remove unneeded files
Artem Bityutskiy [Wed, 14 Aug 2013 07:56:52 +0000 (10:56 +0300)]
packaging: remove unneeded files

I cannot really explain why these files were needed, but they are not needed
anymore, according to Ed Bartosh. So removing them with pleasure.

Change-Id: I8239416e603ed86f2e0302cc1a7c14a9ba94d2dd
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoRELEASE_NOTES: add changelog for release 2.6
Artem Bityutskiy [Tue, 13 Aug 2013 10:58:04 +0000 (13:58 +0300)]
RELEASE_NOTES: add changelog for release 2.6

Strictly speaking I've added a feature, so 2.6 is not just a bug-fix release,
but the feature is rather small and does not deserve a new major release.

Change-Id: Ice89d533a873687141412aaefe814eb3b221ac5f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoTransRead: uncompress 'tar.xz' files on-the-fly
Artem Bityutskiy [Tue, 13 Aug 2013 10:37:39 +0000 (13:37 +0300)]
TransRead: uncompress 'tar.xz' files on-the-fly

Change-Id: Ia8ed3c1c276510b3d63e831135f7ad6ce6bc1743
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoTransRead: uncompress .xz files on-the-fly
Artem Bityutskiy [Tue, 13 Aug 2013 10:12:33 +0000 (13:12 +0300)]
TransRead: uncompress .xz files on-the-fly

Change-Id: I401e20224bc2d0050b7c6354e346e10f13e99024
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoTransRead: close all the files
Artem Bityutskiy [Tue, 13 Aug 2013 09:46:16 +0000 (12:46 +0300)]
TransRead: close all the files

Although CPython reference-counts objects and destroys them when they are no
longer used, it is still good practice to close all the opened files
explicitly, especially if we are talking about a library.

TransRead did not explicitely close the tar file object, and this patch fixes
this.

Additionally, add few useful commentaries.

Change-Id: Ib146be0a8e358bf208329932ca3a62ab2617f7bd
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoBmapCopy: fix a typo in error message
Artem Bityutskiy [Tue, 13 Aug 2013 10:38:50 +0000 (13:38 +0300)]
BmapCopy: fix a typo in error message

... add a missing whitespace.

Change-Id: I8d713263de9899ff314d83e69aae9f3a672c3285
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agobmaptools: put __init__ first
Artem Bityutskiy [Tue, 13 Aug 2013 09:26:54 +0000 (12:26 +0300)]
bmaptools: put __init__ first

It is just a common convention to put __init__ at the very beginning of the
class. And let's also put then the __del__ function to be the second.

So this patch does not do any functional modifications, just re-structuring.

Change-Id: I2ebdd8c4c54cf5bf3f9be21d7520b42865305dab
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agodebian: add a dependency to python-lzma
Artem Bityutskiy [Mon, 12 Aug 2013 15:16:06 +0000 (18:16 +0300)]
debian: add a dependency to python-lzma

We'll soon need it in order to support .xz files.

Change-Id: Iafcae3a81f64934ff6d7fdede070fe39e75a58e1
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agopackaging: add pyliblzma for Fedora dependencies
Artem Bityutskiy [Mon, 12 Aug 2013 15:01:53 +0000 (18:01 +0300)]
packaging: add pyliblzma for Fedora dependencies

Change-Id: I3fb1515c0ada923bc27a470979077f9c4e450f86
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agopackaging: remove tabs and extra white-spaces
Artem Bityutskiy [Mon, 12 Aug 2013 14:55:41 +0000 (17:55 +0300)]
packaging: remove tabs and extra white-spaces

Put one white-space after every keyword and do not try to align things, and
also do not use tabs. I think I saw this recommendation is the Fedore guide or
something, but not 100% sure. But at least this makes it easier to change the
spec file.

Change-Id: I6cee1b700287c9287637184978906af53862a04c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agomake_a_release.sh: use git send-email
Artem Bityutskiy [Sat, 10 Aug 2013 12:11:49 +0000 (15:11 +0300)]
make_a_release.sh: use git send-email

Use git send-email instead of mutt, since the mutt command we had does not
really work, and I am unable to find out how to make it work.

Additinally, inform about where to find packages for various distributions.

Change-Id: Ia6408683a4794377f0ebf9f6b5cd1dc1f8559ca3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoRelease version 2.5 v2.5
Artem Bityutskiy [Mon, 5 Aug 2013 07:07:28 +0000 (10:07 +0300)]
Release version 2.5

Change-Id: Ibeed08d6913893452bec9587297f2417808a6057
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agomake_a_release.sh: a script for cutting releases
Artem Bityutskiy [Mon, 5 Aug 2013 07:24:20 +0000 (10:24 +0300)]
make_a_release.sh: a script for cutting releases

Not complete, but a good start anyway. Intended to be used by me.

Change-Id: I64b7ef72ac8fe729f234f5d74847dc85225ccee0
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agopackaging: improve the summary text in RPM packaging
Artem Bityutskiy [Mon, 5 Aug 2013 07:15:23 +0000 (10:15 +0300)]
packaging: improve the summary text in RPM packaging

Change-Id: I71b36a801c4a4898bf73c8226f7a7495a2b8407c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agopackaging: use opensuse_bs macro
Artem Bityutskiy [Mon, 5 Aug 2013 07:11:22 +0000 (10:11 +0300)]
packaging: use opensuse_bs macro

The <CI_CNT>.<B_CNT> trick is OBS-specific, so wrap it with the 'opensuse_bs'
macro.

Change-Id: I817757ffdacddc32077b2876185220e880655ad7
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
10 years agoREADME: add more information for opensource community
Artem Bityutskiy [Fri, 2 Aug 2013 09:54:10 +0000 (12:54 +0300)]
README: add more information for opensource community

Plus some minor re-structuring.

Change-Id: I66c60057949ec6bd0ccdcb29c7fabf691a36bb43
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRemove junk back-slashes
Artem Bityutskiy [Thu, 4 Jul 2013 07:40:27 +0000 (10:40 +0300)]
Remove junk back-slashes

In Python we don't need the line-continuation "\" inside (), [], {}.

Suggested by Simon McVittie <simon.mcvittie@collabora.co.uk>.

Change-Id: I2c258cd1099e5c07bd710cd66854f6291c04f623
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-tools: make one-line comments comply with PEP257
Artem Bityutskiy [Thu, 4 Jul 2013 05:38:53 +0000 (08:38 +0300)]
bmap-tools: make one-line comments comply with PEP257

Change-Id: Ib40a22d44a56e1c7274e415a2ee67db99efc992f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-tools: do not use extra spaces to comply with PEP8
Artem Bityutskiy [Thu, 4 Jul 2013 05:18:39 +0000 (08:18 +0300)]
bmap-tools: do not use extra spaces to comply with PEP8

Apparently in python it is preferrable to avoid white-spaces when specifying
the default values.

Change-Id: I6d70de456358278df270e4107e90f760e8041b8d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agodebian: switch to debhelper 9
Simon McVittie [Mon, 1 Jul 2013 13:31:03 +0000 (14:31 +0100)]
debian: switch to debhelper 9

Debhelper 9 "compatibility level" is what's currently recommended.
Debian 7 and Ubuntu 12.04 both have a suitable debhelper version.

At the Debhelper 7 or 8 "compatibility level" we would have used
the deprecated python-support helper tool, whereas Debhelper 9 does
not have a default Python packaging tool: choose dh_python2, part
of the Debian/Ubuntu 'python' package since before Ubuntu 12.04
and currently the recommended option. This needs a dependency on
python-all (>= 2.7) so do that.

In the process, switch the XS-Python-Version field from the deprecated
keyword 'current' to ">= 2.7" (the recommended syntax),
and remove the deprecated XB-Python-Version field.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRemove stdeb-generated boilerplate from debian/rules
Simon McVittie [Mon, 1 Jul 2013 13:25:55 +0000 (14:25 +0100)]
Remove stdeb-generated boilerplate from debian/rules

This particular package doesn't contain any compiled code, let alone
f2py, so there's no point in doing strange things with compiler/linker
flags. If we gain any C code later, respecting the CFLAGS etc. is
recommended anyway, to pick up "hardening" flags.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agodebian/control: depend on python-setuptools instead of -distribute
Simon McVittie [Mon, 1 Jul 2013 13:19:03 +0000 (14:19 +0100)]
debian/control: depend on python-setuptools instead of -distribute

python-setuptools is the module we actually import, and
python-distribute has been merged into python-setuptools upstream.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agodebian/control: move to Section: utils
Simon McVittie [Mon, 1 Jul 2013 13:12:09 +0000 (14:12 +0100)]
debian/control: move to Section: utils

Packages that are primarily a command-line tool, like git-buildpackage
or offlineimap, usually go in the Section for that tool rather than
Section: python. If this package ends up primarily acting like a library,
it should produce a python-bmaptools package in Section: python,
but that doesn't seem necessary or appropriate until it has
third-party users.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoPut proper GPL declarations on the source files
Simon McVittie [Mon, 1 Jul 2013 13:08:24 +0000 (14:08 +0100)]
Put proper GPL declarations on the source files

This is GPL best-practice. I have assumed that this package is
intentionally placed under the GPL version 2 only (like Linux or
ConnMan), and not dual- or multiple-licensed under the GPL version 2
"or any later version" (like BlueZ).

As a result, the wording used is similar to what is recommended in
the GPL v2, but modified to omit the "or later" clause.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: fix-up a commentary
Artem Bityutskiy [Thu, 4 Jul 2013 04:57:07 +0000 (07:57 +0300)]
BmapCopy: fix-up a commentary

Wrap a very long line which appeared after PEP8-nization.

Change-Id: I0ba4ffdc835fc957fe6cea7b968b2b88af4206d7
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoUse machine-readable format for debian/copyright
Simon McVittie [Wed, 3 Jul 2013 17:29:41 +0000 (18:29 +0100)]
Use machine-readable format for debian/copyright

Change-Id: I0f17c9e02e7a816121ad0ba3a3d38c779bbcaf03
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-tools.spec: improve commentaries about Centos6 and argparse
Artem Bityutskiy [Thu, 4 Jul 2013 04:49:48 +0000 (07:49 +0300)]
bmap-tools.spec: improve commentaries about Centos6 and argparse

The previous comment was a bit confusing.

Change-Id: Iab06d0d486bf3d6a0e7f4bb6df7c991251be579c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agodebian/control: wrap and sort lists of (Build-)Depends
Simon McVittie [Mon, 1 Jul 2013 12:46:03 +0000 (13:46 +0100)]
debian/control: wrap and sort lists of (Build-)Depends

This minimizes VCS diff/conflicts when they change.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agorpm-packaging: improve the description
Artem Bityutskiy [Thu, 4 Jul 2013 04:45:19 +0000 (07:45 +0300)]
rpm-packaging: improve the description

Improve the tool description for rpm packages.

Change-Id: I8f8c47f2fc9188381ff573083cf06b6e276cdc16
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agodebian/control: add a longer Description
Simon McVittie [Mon, 1 Jul 2013 12:42:45 +0000 (13:42 +0100)]
debian/control: add a longer Description

This paragraph from the bmaptool documentation on tizen.org matches
what Debian packages typically have in their Description. The original
description didn't really indicate why you would prefer bmaptool over
alternatives like dd.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: correct logged warning
Simon McVittie [Wed, 3 Jul 2013 17:21:45 +0000 (18:21 +0100)]
BmapCopy: correct logged warning

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: also comply with PEP8 for multiline comments
Artem Bityutskiy [Wed, 3 Jul 2013 15:03:48 +0000 (18:03 +0300)]
tests: also comply with PEP8 for multiline comments

Change-Id: Ie43d8f4e682e5b8d83aa29aeb563ce81291bd707
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: use PEP8 commenting style
Artem Bityutskiy [Wed, 3 Jul 2013 14:00:41 +0000 (17:00 +0300)]
bmaptool: use PEP8 commenting style

No functional changes, just amend multiline comments to match PEP8's
recommendation.

Change-Id: I91aa25026d73d2b6fad4230705d2bc1f14d4fb91
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: downgrade inability to set sysfs parameters to a warning
Simon McVittie [Tue, 25 Jun 2013 11:56:28 +0000 (12:56 +0100)]
BmapCopy: downgrade inability to set sysfs parameters to a warning

On distributions where unprivileged users can write to removable
USB disks, this allows such a disk to be written with bmaptool
(albeit with non-optimal performance) without being root.

Artem: got some more explanations from Simon McVittie
<simon.mcvittie@collabora.co.uk> about why we don't just add a special
case for EPERM/EACCESS:

"""
> On 28/06/13 12:47, Artem Bityutskiy wrote:
> For a library, requiring the user to have a logger object is probably
> not the nicest thing. And usually libraries do not print error messages,
> they throw exceptions instead.

I made the logger optional: if the caller doesn't supply one, BmapCopy
will use logging.getLogger(__name__), i.e. the logger named
"bmaptools.BmapCopy", which appears to be best-practice for Python
logging. (You could use it for debug-logging too, if you wanted to.)

Having logger=None cause logging to be suppressed, instead of using the
logging module's defaults (which are to print 'No handlers could be
found for logger "foo.bar"' the first time you use it, and not log
anything...) would also be fine.

Libraries throw exceptions if they couldn't do what you asked, but I
think there's some room for a middle ground between "no, I can't" and
silent success.
"""

Fair enough, I think.

Hoewver, I massged the patch a bit and improved the warnings to make
them a bit more user-friendly and give users the idea what is the
consequence of the warning.

Change-Id: I644d9777b7bf9e97dbe002814f7d4e411a7618db
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: have a Logger object
Simon McVittie [Tue, 25 Jun 2013 11:54:45 +0000 (12:54 +0100)]
BmapCopy: have a Logger object

Artem: In some situations we may want inform about various happenings, see the
next patch for example. So let's teach the BmapCopy class to accept a 'logger'
object.

Change-Id: Idcfe6d7acfb8e327be39496898415e9f4b08d0dd
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agodebianisation: change versioning
Artem Bityutskiy [Wed, 3 Jul 2013 12:55:11 +0000 (15:55 +0300)]
debianisation: change versioning

Simon McVittie <simon.mcvittie@collabora.co.uk> requested this:

"In Debian packaging it's conventional for version numbers like "2.4-1"
to be the Debian package, and if derivatives need to fork it, they use a
version like "2.4-1ubuntu1" (or "2.4-0ubuntu1" if they package something
that isn't in Debian yet). You've been using version numbers like 2.4-1
as upstream versions, so for now I'll have to act like a derivative
distribution and use 2.4-1debian1 or something."

So let's become a "native" package in order to make live of derivative
distributions easier.

Change-Id: I0e77774c8bf186fe03cea1548e68a48466e90a8e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate: fix a typo in the bmap file comments
Artem Bityutskiy [Sat, 29 Jun 2013 11:21:23 +0000 (14:21 +0300)]
BmapCreate: fix a typo in the bmap file comments

zeoro -> zero

Change-Id: I0709004ddae37238a97439a165c12b4bfc7dc258
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: remove a left-over comment
Artem Bityutskiy [Fri, 28 Jun 2013 11:49:05 +0000 (14:49 +0300)]
BmapCopy: remove a left-over comment

Change-Id: Iaced0f210f7122fc800c6dac2c81fd6b185fee4d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoFix debian/changelog syntax
Simon McVittie [Tue, 25 Jun 2013 11:59:41 +0000 (12:59 +0100)]
Fix debian/changelog syntax

dpkg-source requires two spaces between the closing ">" around the
email address and the first letter of the date.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoAdd COPYING, a copy of the GPL v2
Simon McVittie [Tue, 25 Jun 2013 12:05:46 +0000 (13:05 +0100)]
Add COPYING, a copy of the GPL v2

This makes it considerably more straightforward for distributors
to comply with the GPL's requirement to accompany the package with
a copy of its license.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRelease version 2.4 v2.4
Artem Bityutskiy [Wed, 5 Jun 2013 15:19:12 +0000 (18:19 +0300)]
Release version 2.4

Change-Id: Ia947af3cb02a4e53873136c1be270139342f81f1
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agodocs: update man pages
Artem Bityutskiy [Wed, 5 Jun 2013 15:14:12 +0000 (18:14 +0300)]
docs: update man pages

Change-Id: I250b03151c9002b3f55fdf4cbe487ed8291047a0
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: amend commentaries
Artem Bityutskiy [Wed, 5 Jun 2013 15:06:46 +0000 (18:06 +0300)]
TransRead: amend commentaries

Update and fix spelling in several commentaries. No functional changes.

Change-Id: Idd2a6a5bc7485aa4d4cbea1490aea13169ea699e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRELEASE_NOTES: add a record for release 2.4
Artem Bityutskiy [Mon, 3 Jun 2013 12:57:57 +0000 (15:57 +0300)]
RELEASE_NOTES: add a record for release 2.4

Change-Id: Ie3177b1ad7cc9f0c03dd0ce1388ffb203d2bbe6b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: add support for ssh:// URLs
Artem Bityutskiy [Mon, 3 Jun 2013 12:47:37 +0000 (15:47 +0300)]
TransRead: add support for ssh:// URLs

This patch adds support for flashing from an SSH source. I need this
functionality, for example, when I build images on a remote host, but flash
them locally, and I want bmaptool to read the image directly from the SSH
host.

Unfortunately, liburl2 does not support ssh:// URLs, and there seem to be no
standard python libraries for such URLs. There is a "paramiko" python module,
but it is not a standard part of python, and not at least Tizen does not have
it, so I do not want to use it.

Thus, I use the system 'ssh' tool directly. Note, the paramiko module actually
does the same.

Both password and key authentication types are supported. In order to use
password authentication, the password has to be passed via URL:

bmaptool copy ssh://user:pass@host:path destination

If the URL does not contain a password, we assume key-based authentication is
configured.

Change-Id: Ief72b5bf9adc3e67f25009dc47a90767741826eb
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransFile: introduce "_force_fake_seek" attribute
Artem Bityutskiy [Mon, 3 Jun 2013 11:02:16 +0000 (14:02 +0300)]
TransFile: introduce "_force_fake_seek" attribute

TransFile object provide read interface to compressed and/or remote files.
TransFile objects also allow seeking files forward. When the file happens to be
a local uncompressed file, seeking is done using the native 'seek()' method.
Otherwise, we emulate this by just reading the required amount of bytes from the
file and discarding the data.

The way we detect whether we can seek using the native method or not is that we
call 'hasattr(file_obj, "seek")', and if the file object has the "seek()"
method, we use it.

However, there are situations when a files have the "seek()" method, but it is
not really usable. For example, stdout.

This patch introduces an internal attribute named "_force_fake_seek", which
will force fake seek implementation for such file objects.

We do not need this change right now, but will need it soon. So this is just a
preparation for the coming changes.

Change-Id: I0128499e7c3fba0b6aa665ece405ecb33085d4be
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRELEASE_NOTES: improve 2.3 release notes v2.3
Artem Bityutskiy [Tue, 7 May 2013 12:11:27 +0000 (15:11 +0300)]
RELEASE_NOTES: improve 2.3 release notes

Change-Id: If40be06cc19ed45419b4cef65e72a952a7b053cc
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRelease version 2.3
Artem Bityutskiy [Mon, 6 May 2013 08:00:48 +0000 (11:00 +0300)]
Release version 2.3

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agodocs: update release notes for release 2.3
Artem Bityutskiy [Mon, 6 May 2013 07:55:29 +0000 (10:55 +0300)]
docs: update release notes for release 2.3

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: verify bmap file checksum
Artem Bityutskiy [Mon, 6 May 2013 14:51:58 +0000 (17:51 +0300)]
BmapCopy: verify bmap file checksum

If bmap file format is greater than 1.3, verify its integrity by checking the
SHA1 checksum.

Change-Id: I2b1ed51d9eda71fe3f3681cc92314b1bcc83a23f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate: generate bmap file checksum
Artem Bityutskiy [Mon, 6 May 2013 14:25:39 +0000 (17:25 +0300)]
BmapCreate: generate bmap file checksum

I got a bug report recently and the investigation showed that it is caused by
corrupted bmap file. Once the user re-downloaded the bmap file, the problem
was solved.

This patch tries to improve robustness by protecting the bmap file with SHA1
checksum. At the very end we calculate the SHA1 checksum of the entire bmap
file with the in-file SHA1 value = all zeroes, and put the result to the bmap
file.

In order to verify the checksum, we will have to substitute the SHA1 checksum
with all zeroes again and calculate SHA1 of the file.

Change-Id: Ia8f109c8238a0e5e2e609f53255a699b35d72cde
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: fix pylint warning
Artem Bityutskiy [Mon, 6 May 2013 14:55:23 +0000 (17:55 +0300)]
TransRead: fix pylint warning

Remove an unused module.

Change-Id: I8f6ddc09d49fa4664130b7fc329ee417903529d7
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate: enable scalability optimization
Artem Bityutskiy [Mon, 6 May 2013 14:12:25 +0000 (17:12 +0300)]
BmapCreate: enable scalability optimization

This patch changes the layout of the bmap file a little bit. Before this
change, we wrote the mapped blocks count at the very end, because we only knew
at the very end.

In BmapCopy we need to know the amount of mapped blocks before we start
copying, and this forces us to read entire bmap file to find out the amount of
mapped blocks. This is not an issue when bmap file is small, but if it gets a
lot bigger, this becomes a lot slower.

In this patch, we change bmap file layout a little bit and now we put the
mapped block cound at the beginning of the bmap file. This makes it possible to
parse it more effeciently. This also makes it more human readable.

Change-Id: Id9466ed4a45678a60506d32abe17845e29b79b59
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: implement local caching
Artem Bityutskiy [Mon, 6 May 2013 12:45:04 +0000 (15:45 +0300)]
TransRead: implement local caching

Teach TransRead to cache remote and compressed files with local uncompressed
files, which makes it possible to use operations like mmap and so on. This
patch adds a 'local' parameter to the TransRead constructor which is 'False' by
default, and when it is 'True', TransRead creates a local copy of the back-end
file.

Change-Id: I1bef11c132bb2750c8cb983ff7cdc5180a75bb66
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: allow reading entire file
Artem Bityutskiy [Mon, 6 May 2013 12:13:49 +0000 (15:13 +0300)]
TransRead: allow reading entire file

The 'read()' method of python file objects does not require the user specifying
the size, and allows for negative size as well. In this case it just reads
entire file. Ament TransRead to also follow this convention.

Change-Id: I3c0c645d458654711f3dc7a832aaec427d4abd00
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptools: amend commentaries about file-like objects
Artem Bityutskiy [Mon, 6 May 2013 12:11:20 +0000 (15:11 +0300)]
bmaptools: amend commentaries about file-like objects

In some places we require true file objects, i.e., they should be backed by
real files. However, comments just tell about file-like objects. Amend the
comments.

Change-Id: I90934f18558c6e9e8706c7cd62702c301099283d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: improve error message
Artem Bityutskiy [Mon, 6 May 2013 10:16:46 +0000 (13:16 +0300)]
BmapCopy: improve error message

Change-Id: I350b7beb9491bde82bbdad8890f147a7f69d14ab
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: provide bmap version major and minor numbers
Artem Bityutskiy [Mon, 6 May 2013 10:04:36 +0000 (13:04 +0300)]
BmapCopy: provide bmap version major and minor numbers

Besides providing the full string version, provide also the major and minor
components of the version as ingegers. This is going to be useful soon.

Change-Id: Id2ae76cd46066ca8b6159e0232a7955de25eb404
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: do not feed stdout to BmapCreate
Artem Bityutskiy [Fri, 3 May 2013 13:48:40 +0000 (16:48 +0300)]
bmaptool: do not feed stdout to BmapCreate

We are going to modify BmapCreate to support bmap file checksum. And we'll have
to seek the bmap file. However, the problem is that bmaptool may feed
BmapCreate with stdout which is not seekable.

This patch changes bmaptool and makes it create a temporary file when the user
does not specify the output file, give it to BmapCreate, and then print the
contents of the file to stdout. We use the 'NamedTemporaryFile' python method
which automatically removes the file when the program crashes or is interrupted
with Ctrl-C.

Change-Id: I0ad16136111095b04cf3a0e9223c004b493c26de
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: assign user-friendly names to file objects
Artem Bityutskiy [Mon, 6 May 2013 09:29:22 +0000 (12:29 +0300)]
bmaptool: assign user-friendly names to file objects

Just like many things in python, BmapCopy assumes that file-like objects'
'name' attribute contains something user-frienly. And this is the case in most
of the cases, except one case. If the file object was created using
'os.fdopen()', the name will be '<fdopen>', instead of something user-friendly.
And bmaptool uses 'os.fdopen()' when opening block devices, because we need to
use special open flags. This results in poor error messages like this:

bmaptool: ERROR: wrote 187980 blocks from image
  'ivi-wayland-tizen-2.0a_20130501.1-sdb.raw.bz2' to '<fdopen>' ...

And the problem is that you cannot change the name - it is a read-only
attribute. This problem will probably be resolved in python 3, but not in 2.x,
see http://bugs.python.org/issue1625576

This patch works-around the problem by creating own simple dummy class which
overrides the name.

Change-Id: Ia6c8565c414c5e57d294d83c0fe5758e7b5aa518
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: do not truncate too far
Artem Bityutskiy [Fri, 3 May 2013 05:57:32 +0000 (08:57 +0300)]
tests: do not truncate too far

This patch changes the '_create_random_sparse_file()' function behavier a
little and teaches it to not truncate files too far. For example, if we
asked '_create_random_sparse_file()' to create an 8193 bytes sparse file,
it could do the following:

1. Map the first 4KiB block
2. Map the second 4KiB block
3. Truncate to 12KiB
4. And at the end truncate to 8183 bytes

This worked fine on ext4 - we ended up with a file with 2 first blocks mapped
and an unmapped block at the end. However, on btrfs this leads to a file with
all 3 blocks mapped (I assume 1 block = 4KiB). And this is not a bug, this is
just how btrfs allocates blocks and we cannot, generally speaking, make any
assumptions about the allocation algorithms.

This patch changes '_create_random_sparse_file()' and makes it avoid truncating
files too far. Namely, we will truncate only to the end of the last block.

Now the tests pass on btrfs (kernel version 3.8.6).

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
11 years agoRelease version 2.2 v2.2
Artem Bityutskiy [Mon, 11 Mar 2013 12:43:22 +0000 (14:43 +0200)]
Release version 2.2

Change-Id: I6bc0773f3faff84e53d46d5997d419ed349ea26a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRELEASE_NOTES: amendments and prepare for release 2.2
Artem Bityutskiy [Fri, 8 Mar 2013 09:09:27 +0000 (11:09 +0200)]
RELEASE_NOTES: amendments and prepare for release 2.2

Create own section for release 2.1, and start preparing for release 2.2 by
describing the 2.2 changes.

Change-Id: I621ae05085e2b6a432b66cc9d4ab9c968f38afba
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: support URLs with user name and password
Artem Bityutskiy [Fri, 8 Mar 2013 08:35:52 +0000 (10:35 +0200)]
TransRead: support URLs with user name and password

Markus Lehtonen reported that bmaptool does not support URLs which contain user
name and password, e.g., https://marquiz:qwerty@server.com/nice.image.bz2.

This patch adds the corresponding support. What we do is we first parse the URL
and try to figure out if it contains user name and password, and if it does,
open the URL with a specially build opener which supports authentication.

Change-Id: I517eb9ffd21ff5de6e9deac4c0cacffe82e53ad5
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: handle more exceptions
Artem Bityutskiy [Fri, 8 Mar 2013 07:50:31 +0000 (09:50 +0200)]
TransRead: handle more exceptions

Handle a couple of exceptions from httplib which may be caused by incorrect
URL. Just catch them, and re-raise with a more understandable error message.
The TransRead user will catch it and exit nicely, without a scary stackdupm
like this:

Traceback (most recent call last):
  File "./bmaptool", line 389, in <module>
    sys.exit(main())
  File "./bmaptool", line 373, in main
    args.func(args, log)
  File "./bmaptool", line 154, in copy_command
    copy_command_open_all(args, log)
  File "./bmaptool", line 109, in copy_command_open_all
    image_obj = TransRead.TransRead(args.image)
  File "/mnt/bigssd/dedekind/work/tizen/git/bmap-tools/bmaptools/TransRead.py", line 232, in __init__
    self._open_url(filepath)
  File "/mnt/bigssd/dedekind/work/tizen/git/bmap-tools/bmaptools/TransRead.py", line 210, in _open_url
    self._file_obj = opener.open(url)
  File "/usr/lib64/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.7/urllib2.py", line 418, in _open
    '_open', req)
  File "/usr/lib64/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 1215, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib64/python2.7/urllib2.py", line 1174, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "/usr/lib64/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/usr/lib64/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python2.7/httplib.py", line 814, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.7/httplib.py", line 776, in send
    self.connect()
  File "/usr/lib64/python2.7/httplib.py", line 1160, in connect
    self._tunnel()
  File "/usr/lib64/python2.7/httplib.py", line 741, in _tunnel
    (version, code, message) = response._read_status()
  File "/usr/lib64/python2.7/httplib.py", line 371, in _read_status
    raise BadStatusLine(line)
httplib.BadStatusLine: ''

Change-Id: I48c0f63a6c33c816eb8cc833aeb400682c0f861f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: introduce a helper for opening URLs
Artem Bityutskiy [Fri, 8 Mar 2013 07:47:42 +0000 (09:47 +0200)]
TransRead: introduce a helper for opening URLs

Indroduce an '_open_url()' helper method which opens an URL. This helper will
be useful soon, because we are going to make the URL opening a bit more
complex.

Change-Id: Iaab56d85eef46ed3f1ebc8be37950443100f4d84
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: relocate the close method
Artem Bityutskiy [Fri, 8 Mar 2013 07:45:31 +0000 (09:45 +0200)]
TransRead: relocate the close method

This is a minor change which relocates the 'close' method to a different place,
in order to keep all the file methods together.

Change-Id: I8a7e481d2788951500c6532bcd2af92bcad57827
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoREADME: minor typo fix
Artem Bityutskiy [Tue, 26 Feb 2013 09:13:12 +0000 (11:13 +0200)]
README: minor typo fix

Change-Id: Ifcd8b7b6a0172e47fb78f6115c4aaf9f826cd5c7
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agopackaging: correct dependencies for Centos6
Artem Bityutskiy [Mon, 25 Feb 2013 07:34:05 +0000 (09:34 +0200)]
packaging: correct dependencies for Centos6

Centos6 uses python 2.6 which does not have the argparse module that we use.
However, there is a possibility to add the argparse module by installing the
'python-argparse' package which is available from 3rd party Centos6
repositories. Thus, add the corresponding dependency for Centos6.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
11 years agotest_fiemap: fix pylint warning
Artem Bityutskiy [Fri, 22 Feb 2013 09:22:34 +0000 (11:22 +0200)]
test_fiemap: fix pylint warning

Using builtins like 'filter()' is discouraged nowadays, and pylint generates
this warning:

W: 46,22:_check_ranges: Used builtin function 'filter'

Use a generator expression instead of the 'filter' built-in.

Change-Id: I0b07685967927a84804d443f22369d68da106af3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: disable a flals pylint warning
Artem Bityutskiy [Thu, 21 Feb 2013 12:00:13 +0000 (14:00 +0200)]
BmapCopy: disable a flals pylint warning

Silence this one:
W:275,0: Anomalous backslash in string: '\0'. String constant might be missing an r prefix.

Change-Id: I816d20f284154f2c424a35090461db5a265edcbb
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: fix writitng to a dm-zero device
Artem Bityutskiy [Thu, 21 Feb 2013 11:28:40 +0000 (13:28 +0200)]
BmapCopy: fix writitng to a dm-zero device

Dm-zero devices expose "none" in their '/sys/block/<disk>/queue/scheduler' file
and there is no current scheduler. Our code was assuming there is always the
current scheduler in brackets (e.g., "noop deadline [cfq]"), which lead to a
crash when writing to a dm-zero device:

Traceback (most recent call last):
  File "./bmaptool", line 389, in <module>
    sys.exit(main())
  File "./bmaptool", line 373, in main
    args.func(args, log)
  File "./bmaptool", line 192, in copy_command
    writer.copy(False, not args.no_verify)
  File "/mnt/bigssd/dedekind/work/tizen/tools/git/bmap-tools/bmaptools/BmapCopy.py", line 578, in copy
    self._tune_block_device()
  File "/mnt/bigssd/dedekind/work/tizen/tools/git/bmap-tools/bmaptools/BmapCopy.py", line 535, in _tune_block_device
    self._old_scheduler_value = match.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

This patch fixes the crash.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Change-Id: Ic13f4f69ee859244e5413d4b0b890d6c599becae

11 years agoTransRead: limit the amount of bytes we read at a time
Artem Bityutskiy [Thu, 21 Feb 2013 11:06:23 +0000 (13:06 +0200)]
TransRead: limit the amount of bytes we read at a time

In the function which implements fake seek forward we first calculate the
amount of bytes we have to read from the file to seek forward to the requisted
position, and then read that data in one go. However, the seek may be really
far forward, and we'll end up reading really a lot of data in one go, which
leads to high memory consumption.

This patch fixes the issue by limiting the amount of data we read in one go to
1MiB.

Change-Id: Idfdde2e432c216de34b4675e47c859f5e68a2928
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: print useful information in sace of MemoryError
Artem Bityutskiy [Thu, 21 Feb 2013 09:56:25 +0000 (11:56 +0200)]
bmaptool: print useful information in sace of MemoryError

Catch the MemoryError exception which means that the script ran out of memory
and print useful debugging information in this case (/proc/meminfo and
/proc/self/status).

Change-Id: Ie52b8426867366d5a5110f91f8731c8c9b3b7f54
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: silence few false pylint warnings
Artem Bityutskiy [Thu, 21 Feb 2013 09:00:49 +0000 (11:00 +0200)]
bmaptool: silence few false pylint warnings

W:339,0: Anomalous backslash in string: '\0'. String constant might be missing an r prefix.
W:340,0: Anomalous backslash in string: '\0'. String constant might be missing an r prefix.
W:341,0: Anomalous backslash in string: '\0'. String constant might be missing an r prefix.

Change-Id: I182700967c1efab7137ae368246e5a9537e14976
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: remove an unused variable
Artem Bityutskiy [Thu, 21 Feb 2013 08:40:10 +0000 (10:40 +0200)]
bmaptool: remove an unused variable

Change-Id: I71870ad52cdc4ea374ad1907526bd8d3c3dad6e0
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: minor white-space cleanup
Artem Bityutskiy [Thu, 21 Feb 2013 08:39:19 +0000 (10:39 +0200)]
bmaptool: minor white-space cleanup

Change-Id: I2c50ddf8c98819c9178133fc81943f4ef373d8a7
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoReally release version 2.1 v2.1
Artem Bityutskiy [Wed, 20 Feb 2013 12:27:47 +0000 (14:27 +0200)]
Really release version 2.1

Change-Id: I5560450707065676847828f2a7a2ffde67b50b7c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRelease version 2.1
Artem Bityutskiy [Mon, 18 Feb 2013 14:40:57 +0000 (16:40 +0200)]
Release version 2.1

Change-Id: Ib03595e0a404ec0a31efdf6a8aa84d49e656e78b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agotests: make tests work in Fedora 18
Artem Bityutskiy [Mon, 18 Feb 2013 14:47:58 +0000 (16:47 +0200)]
tests: make tests work in Fedora 18

The tests create many temporary files and run FIEMAP on them. However, in
Fedora 18 the '/tmp' is tmpfs which does not support FIEMAP, so 'nosetests'
fails. Let's use the current directory for the tests instead.

Change-Id: I2cc2d402fd15517e043e38188d3046876a11cbec
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: fix out of memory issues with bzip2 files
Artem Bityutskiy [Mon, 18 Feb 2013 14:25:06 +0000 (16:25 +0200)]
TransRead: fix out of memory issues with bzip2 files

This commit fixes a 'bmaptool copy' problem with the following symptom:

Traceback (most recent call last):
  File "./bmaptool", line 372, in <module>
    sys.exit(main())
  File "./bmaptool", line 369, in main
    args.func(args, setup_logger(loglevel))
  File "./bmaptool", line 191, in copy_command
    writer.copy(False, not args.no_verify)
  File "/opt/home/root/bmap/bmap-tools-2.0/bmaptools/BmapCopy.py", line 580, in copy
    BmapCopy.copy(self, sync, verify)
  File "/opt/home/root/bmap/bmap-tools-2.0/bmaptools/BmapCopy.py", line 368, in _get_data
    self._f_image.seek(first * self.block_size)
  File "/opt/home/root/bmap/bmap-tools-2.0/bmaptools/TransRead.py", line 247, in seek
    self._transfile_obj.seek(offset, whence)
  File "/opt/home/root/bmap/bmap-tools-2.0/bmaptools/TransRead.py", line 69, in seek
    self._pos = _fake_seek_forward(self, self._pos, offset, whence)
  File "/opt/home/root/bmap/bmap-tools-2.0/bmaptools/TransRead.py", line 33, in _fake_seek_forward
    buf = file_obj.read(to_read)
  File "/opt/home/root/bmap/bmap-tools-2.0/bmaptools/TransRead.py", line 102, in read
    data = self._read_from_buffer(size)
  File "/opt/home/root/bmap/bmap-tools-2.0/bmaptools/TransRead.py", line 81, in _read_from_buffer
    data = self._buffer[self._buffer_pos:self._buffer_pos + length]
MemoryError

The reason is that bmaptool runs out of memory when copying a bzip2-compressed
file which has large chunks of zeroes.

I experimented a bit with a 4GiB file full of zeroes and compressed with bzip2.
The memory consumption of 'bmaptool copy' was about 1.4GiB! The reason is that
we read 128KiB of compressed input and decompress them in one go, which results
in a huge output array. The situation with gzip2 is similar, but less severe.

This patch adds a 'chunk_size' parameter to the '_CompressedFile' class
constructor which we can use to limit the maximum amount of data we decompress
at a time. For .bz2 files I found 128bytes to be reasonable, and for gzip files
the default 128KiB seems to be just fine.

Change-Id: Iaeadb69e21332069f0de8b7ce40b7dc72e7b0e02
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTransRead: minor nicification
Artem Bityutskiy [Mon, 18 Feb 2013 13:57:38 +0000 (15:57 +0200)]
TransRead: minor nicification

The 'decompress_func' argument of the '_CompressedFile' class constructor is
optional, so make it be 'None' by default.

Change-Id: I94e8fc185ae4ccc3e1fc2312dc943908dc7ecdd9
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRELEASE_NOTES: tell that map page was added
Artem Bityutskiy [Fri, 18 Jan 2013 15:20:57 +0000 (17:20 +0200)]
RELEASE_NOTES: tell that map page was added

Change-Id: I9963416ec0c797664a8d4aeff755e73e5edef8c5
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agopackaging: add man pages
Artem Bityutskiy [Fri, 18 Jan 2013 14:40:38 +0000 (16:40 +0200)]
packaging: add man pages

Change-Id: Id52d41c844ccc25d0189484467674263876ac12e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRemove the TODO file
Artem Bityutskiy [Fri, 18 Jan 2013 14:29:11 +0000 (16:29 +0200)]
Remove the TODO file

.. as it is empty now.

Change-Id: I7a58e103cf65dba0706edc4f3a8ef5a8367cbcac
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoAdd bmaptool man page
Artem Bityutskiy [Fri, 18 Jan 2013 14:28:47 +0000 (16:28 +0200)]
Add bmaptool man page

Change-Id: I9a0e7b29e3d0506801f04000cd20eb4283c253b3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agodocs: move documentation to a separate sub-directory
Artem Bityutskiy [Fri, 18 Jan 2013 10:41:27 +0000 (12:41 +0200)]
docs: move documentation to a separate sub-directory

Change-Id: Ife1ba4593725f1691b1cfddd76ff034adecd54c5
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRELEASE_NOTES: a minor fix
Artem Bityutskiy [Fri, 18 Jan 2013 06:51:20 +0000 (08:51 +0200)]
RELEASE_NOTES: a minor fix

Change-Id: I67f781769d212da9e5ec1af337cfaf230f8647da
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRelease version 2.0 v2.0
Artem Bityutskiy [Thu, 17 Jan 2013 09:36:04 +0000 (11:36 +0200)]
Release version 2.0

Change-Id: I2b6233c43a52b4d4a405584e7f548c0128b22016
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>