summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzr-builddeb/default.conf2
-rw-r--r--apt/package.py6
-rw-r--r--data/templates/Debian.info.in10
-rw-r--r--debian/changelog28
-rwxr-xr-xdebian/rules7
-rwxr-xr-xdoc/examples/config.py2
-rw-r--r--po/python-apt.pot100
-rw-r--r--python/apt_pkgmodule.cc15
-rw-r--r--python/cache.cc5
-rw-r--r--python/pkgsrcrecords.cc2
-rw-r--r--tests/hashsum_test.data1
-rw-r--r--tests/hashsum_test_with_zero.databin0 -> 7 bytes
-rw-r--r--tests/test_hashsums.py67
13 files changed, 184 insertions, 61 deletions
diff --git a/.bzr-builddeb/default.conf b/.bzr-builddeb/default.conf
new file mode 100644
index 00000000..3a08d607
--- /dev/null
+++ b/.bzr-builddeb/default.conf
@@ -0,0 +1,2 @@
+[BUILDDEB]
+native = True
diff --git a/apt/package.py b/apt/package.py
index e51ab98f..7f060b04 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -340,6 +340,12 @@ class Package(object):
return self.isInstalled and self._depcache.IsUpgradable(self._pkg)
isUpgradable = property(isUpgradable)
+ def isAutoRemovable(self):
+ """ Package is installed as a dependency and is no longer required
+ """
+ return self.isInstalled and self._depcache.IsGarbage(self._pkg)
+ isAutoRemovable = property(isAutoRemovable)
+
# size
def packageSize(self):
diff --git a/data/templates/Debian.info.in b/data/templates/Debian.info.in
index 8a5c94c5..de49717d 100644
--- a/data/templates/Debian.info.in
+++ b/data/templates/Debian.info.in
@@ -3,7 +3,7 @@ _ChangelogURI: http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changel
Suite: etch
RepositoryType: deb
BaseURI: http://http.us.debian.org/debian/
-MatchUri: ftp[0-9]*\.[a-z]\.debian\.org
+MatchURI: ftp[0-9]*\.[a-z]\.debian\.org
MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors
_Description: Debian 4.0 'Etch'
Component: main
@@ -26,7 +26,7 @@ _Description: Security updates
Suite: sarge
RepositoryType: deb
BaseURI: http://http.us.debian.org/debian/
-MatchUri: ftp[0-9]*\.[a-z]\.debian\.org
+MatchURI: ftp[0-9]*\.[a-z]\.debian\.org
MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors
_Description: Debian 3.1 'Sarge'
Component: main
@@ -49,7 +49,7 @@ _Description: Security updates
Suite: stable
RepositoryType: deb
BaseURI: http://http.us.debian.org/debian/
-MatchUri: ftp[0-9]*\.[a-z]\.debian\.org
+MatchURI: ftp[0-9]*\.[a-z]\.debian\.org
MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors
_Description: Debian current stable release
Component: main
@@ -62,7 +62,7 @@ _CompDescription: Non-DFSG-compatible Software
Suite: testing
RepositoryType: deb
BaseURI: http://http.us.debian.org/debian/
-MatchUri: ftp[0-9]*\.[a-z]\.debian\.org
+MatchURI: ftp[0-9]*\.[a-z]\.debian\.org
MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors
_Description: Debian testing
Component: main
@@ -75,7 +75,7 @@ _CompDescription: Non-DFSG-compatible Software
Suite: sid
RepositoryType: deb
BaseURI: http://http.us.debian.org/debian/
-MatchUri: ftp[0-9]*\.[a-z]\.debian\.org
+MatchURI: ftp[0-9]*\.[a-z]\.debian\.org
MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors
_Description: Debian 'Sid' (unstable)
Component: main
diff --git a/debian/changelog b/debian/changelog
index 7f329fdd..2ef58a7a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,31 @@
+python-apt (0.7.7) unstable; urgency=low
+
+ [ Emanuele Rocca ]
+ * data/templates/Debian.info.in:
+ - s/MatchUri/MatchURI/. Thanks, Gustavo Noronha Silva (closes: #487673)
+ * python/cache.cc:
+ - Throw an exception rather than segfaulting when GetCache() is called
+ before InitSystem() (closes: #369147)
+ * doc/examples/config.py:
+ - Fix config.py --help (closes: #257007)
+
+ [ Michael Vogt ]
+ * python/apt_pkgmodule.cc:
+ - fix bug in hashsum calculation when the original string
+ contains \0 charackters (thanks to Celso Providelo and
+ Ryan Hass for the test-case) LP: #243630
+ * tests/test_hashsums.py:
+ - add tests for the hashsum code
+ * apt/package.py:
+ - add "isAutoRemovable()" method
+ * python/pkgsrcrecords.cc:
+ - add "Record" attribute to the PkgSrcRecord to access the
+ full source record
+ * debian/rules:
+ - remove the arch-build target, we have bzr-builddeb now
+
+ -- Michael Vogt <mvo@debian.org> Tue, 22 Jul 2008 10:16:03 +0200
+
python-apt (0.7.6) unstable; urgency=low
* apt/cache.py:
diff --git a/debian/rules b/debian/rules
index 33d04a21..c8aff2f9 100755
--- a/debian/rules
+++ b/debian/rules
@@ -15,13 +15,6 @@ PKG=python-apt
DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p')
DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS)
-arch-build::
- rm -rf debian/arch-build
- mkdir -p debian/arch-build/$(PKG)-$(DEBVER)
- tar -c --exclude=arch-build --no-recursion -f - `bzr inventory` \
- | (cd debian/arch-build/$(PKG)-$(DEBVER);tar xf -)
- (cd debian/arch-build/$(PKG)-$(DEBVER) && $(DEB_BUILD_PROG))
-
build/python-apt-dbg::
set -e; \
for i in $(cdbs_python_build_versions); do \
diff --git a/doc/examples/config.py b/doc/examples/config.py
index cc1aae44..9d4e51fc 100755
--- a/doc/examples/config.py
+++ b/doc/examples/config.py
@@ -45,7 +45,7 @@ if Cnf.FindB("version", 0) == 1:
print "Version selected - 1.1"
if Cnf.FindB("help", 0) == 1:
- print apt_pkg.Package, apt_pkg.Version, "for", apt_pkg.Architecture, \
+ print "python-apt", apt_pkg.Version, \
"compiled on", apt_pkg.Date, apt_pkg.Time
print "Hi, I am the help text for this program"
sys.exit(0)
diff --git a/po/python-apt.pot b/po/python-apt.pot
index cac3604f..7125757c 100644
--- a/po/python-apt.pot
+++ b/po/python-apt.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-02-18 16:50+0100\n"
+"POT-Creation-Date: 2008-07-18 15:22+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -23,222 +23,232 @@ msgid "http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:8
+#: ../data/templates/Ubuntu.info.in:11
+msgid "Ubuntu 8.10 'Intrepid Ibex'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:28
+msgid "Cdrom with Ubuntu 8.10 'Intrepid Ibex'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:66
msgid "Ubuntu 8.04 'Hardy Heron'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:25
+#: ../data/templates/Ubuntu.info.in:83
msgid "Cdrom with Ubuntu 8.04 'Hardy Heron'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:60
+#: ../data/templates/Ubuntu.info.in:120
msgid "Ubuntu 7.10 'Gutsy Gibbon'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:77
+#: ../data/templates/Ubuntu.info.in:137
msgid "Cdrom with Ubuntu 7.10 'Gutsy Gibbon'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:112
+#: ../data/templates/Ubuntu.info.in:172
msgid "Ubuntu 7.04 'Feisty Fawn'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:129
+#: ../data/templates/Ubuntu.info.in:189
msgid "Cdrom with Ubuntu 7.04 'Feisty Fawn'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:163
+#: ../data/templates/Ubuntu.info.in:223
msgid "Ubuntu 6.10 'Edgy Eft'"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:168
+#: ../data/templates/Ubuntu.info.in:228
msgid "Community-maintained"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:172
+#: ../data/templates/Ubuntu.info.in:232
msgid "Proprietary drivers for devices"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:174
+#: ../data/templates/Ubuntu.info.in:234
msgid "Restricted software"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:180
+#: ../data/templates/Ubuntu.info.in:240
msgid "Cdrom with Ubuntu 6.10 'Edgy Eft'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:214
+#: ../data/templates/Ubuntu.info.in:274
msgid "Ubuntu 6.06 LTS 'Dapper Drake'"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:217
+#: ../data/templates/Ubuntu.info.in:277
msgid "Canonical-supported Open Source software"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:219
+#: ../data/templates/Ubuntu.info.in:279
msgid "Community-maintained (universe)"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:220
+#: ../data/templates/Ubuntu.info.in:280
msgid "Community-maintained Open Source software"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:222
+#: ../data/templates/Ubuntu.info.in:282
msgid "Non-free drivers"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:223
+#: ../data/templates/Ubuntu.info.in:283
msgid "Proprietary drivers for devices "
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:225
+#: ../data/templates/Ubuntu.info.in:285
msgid "Restricted software (Multiverse)"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:226
+#: ../data/templates/Ubuntu.info.in:286
msgid "Software restricted by copyright or legal issues"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:231
+#: ../data/templates/Ubuntu.info.in:291
msgid "Cdrom with Ubuntu 6.06 LTS 'Dapper Drake'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:243
+#: ../data/templates/Ubuntu.info.in:303
msgid "Important security updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:248
+#: ../data/templates/Ubuntu.info.in:308
msgid "Recommended updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:253
+#: ../data/templates/Ubuntu.info.in:313
msgid "Pre-released updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:258
+#: ../data/templates/Ubuntu.info.in:318
msgid "Unsupported updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:265
+#: ../data/templates/Ubuntu.info.in:325
msgid "Ubuntu 5.10 'Breezy Badger'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:278
+#: ../data/templates/Ubuntu.info.in:338
msgid "Cdrom with Ubuntu 5.10 'Breezy Badger'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:290
+#: ../data/templates/Ubuntu.info.in:350
msgid "Ubuntu 5.10 Security Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:295
+#: ../data/templates/Ubuntu.info.in:355
msgid "Ubuntu 5.10 Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:300
+#: ../data/templates/Ubuntu.info.in:360
msgid "Ubuntu 5.10 Backports"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:307
+#: ../data/templates/Ubuntu.info.in:367
msgid "Ubuntu 5.04 'Hoary Hedgehog'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:320
+#: ../data/templates/Ubuntu.info.in:380
msgid "Cdrom with Ubuntu 5.04 'Hoary Hedgehog'"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:323 ../data/templates/Debian.info.in:94
+#: ../data/templates/Ubuntu.info.in:383 ../data/templates/Debian.info.in:94
msgid "Officially supported"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:332
+#: ../data/templates/Ubuntu.info.in:392
msgid "Ubuntu 5.04 Security Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:337
+#: ../data/templates/Ubuntu.info.in:397
msgid "Ubuntu 5.04 Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:342
+#: ../data/templates/Ubuntu.info.in:402
msgid "Ubuntu 5.04 Backports"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:348
+#: ../data/templates/Ubuntu.info.in:408
msgid "Ubuntu 4.10 'Warty Warthog'"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:354
+#: ../data/templates/Ubuntu.info.in:414
msgid "Community-maintained (Universe)"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:356
+#: ../data/templates/Ubuntu.info.in:416
msgid "Non-free (Multiverse)"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:361
+#: ../data/templates/Ubuntu.info.in:421
msgid "Cdrom with Ubuntu 4.10 'Warty Warthog'"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:364
+#: ../data/templates/Ubuntu.info.in:424
msgid "No longer officially supported"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:366
+#: ../data/templates/Ubuntu.info.in:426
msgid "Restricted copyright"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:373
+#: ../data/templates/Ubuntu.info.in:433
msgid "Ubuntu 4.10 Security Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:378
+#: ../data/templates/Ubuntu.info.in:438
msgid "Ubuntu 4.10 Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:383
+#: ../data/templates/Ubuntu.info.in:443
msgid "Ubuntu 4.10 Backports"
msgstr ""
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index bbb21523..ab8ab33d 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -175,8 +175,11 @@ static PyObject *md5sum(PyObject *Self,PyObject *Args)
// Digest of a string.
if (PyString_Check(Obj) != 0)
{
+ char *s;
+ Py_ssize_t len;
MD5Summation Sum;
- Sum.Add(PyString_AsString(Obj));
+ PyString_AsStringAndSize(Obj, &s, &len);
+ Sum.Add((const unsigned char*)s, len);
return CppPyString(Sum.Result().Value());
}
@@ -212,8 +215,11 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args)
// Digest of a string.
if (PyString_Check(Obj) != 0)
{
+ char *s;
+ Py_ssize_t len;
SHA1Summation Sum;
- Sum.Add(PyString_AsString(Obj));
+ PyString_AsStringAndSize(Obj, &s, &len);
+ Sum.Add((const unsigned char*)s, len);
return CppPyString(Sum.Result().Value());
}
@@ -249,8 +255,11 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args)
// Digest of a string.
if (PyString_Check(Obj) != 0)
{
+ char *s;
+ Py_ssize_t len;
SHA256Summation Sum;
- Sum.Add(PyString_AsString(Obj));
+ PyString_AsStringAndSize(Obj, &s, &len);
+ Sum.Add((const unsigned char*)s, len);
return CppPyString(Sum.Result().Value());
}
diff --git a/python/cache.cc b/python/cache.cc
index 8accd4a7..fe5e8902 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -928,6 +928,11 @@ PyObject *TmpGetCache(PyObject *Self,PyObject *Args)
if (PyArg_ParseTuple(Args, "|O", &pyCallbackInst) == 0)
return 0;
+ if (_system == 0) {
+ PyErr_SetString(PyExc_ValueError,"_system not initialized");
+ return 0;
+ }
+
pkgCacheFile *Cache = new pkgCacheFile();
if(pyCallbackInst != 0) {
diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc
index 1a52e8f1..f7f5d7a2 100644
--- a/python/pkgsrcrecords.cc
+++ b/python/pkgsrcrecords.cc
@@ -89,6 +89,8 @@ static PyObject *PkgSrcRecordsAttr(PyObject *Self,char *Name)
return CppPyString(Struct.Last->Maintainer());
else if (strcmp("Section",Name) == 0)
return CppPyString(Struct.Last->Section());
+ else if (strcmp("Record",Name) == 0)
+ return CppPyString(Struct.Last->AsStr());
else if (strcmp("Binaries",Name) == 0) {
PyObject *List = PyList_New(0);
diff --git a/tests/hashsum_test.data b/tests/hashsum_test.data
new file mode 100644
index 00000000..19102815
--- /dev/null
+++ b/tests/hashsum_test.data
@@ -0,0 +1 @@
+foo \ No newline at end of file
diff --git a/tests/hashsum_test_with_zero.data b/tests/hashsum_test_with_zero.data
new file mode 100644
index 00000000..2ec9a6df
--- /dev/null
+++ b/tests/hashsum_test_with_zero.data
Binary files differ
diff --git a/tests/test_hashsums.py b/tests/test_hashsums.py
new file mode 100644
index 00000000..0cf6beb7
--- /dev/null
+++ b/tests/test_hashsums.py
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+
+import unittest
+import apt_pkg
+
+
+class testHashes(unittest.TestCase):
+ " test the hashsum functions against strings and files "
+
+ def testMD5(self):
+ # simple
+ s = "foo"
+ s_md5 = "acbd18db4cc2f85cedef654fccc4a4d8"
+ res = apt_pkg.md5sum(s)
+ self.assert_(res == s_md5)
+ # file
+ res = apt_pkg.md5sum(open("hashsum_test.data"))
+ self.assert_(res == s_md5)
+ # with zero (\0) in the string
+ s = "foo\0bar"
+ s_md5 = "f6f5f8cd0cb63668898ba29025ae824e"
+ res = apt_pkg.md5sum(s)
+ self.assert_(res == s_md5)
+ # file
+ res = apt_pkg.md5sum(open("hashsum_test_with_zero.data"))
+ self.assert_(res == s_md5)
+
+ def testSHA1(self):
+ # simple
+ s = "foo"
+ s_hash = "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"
+ res = apt_pkg.sha1sum(s)
+ self.assert_(res == s_hash)
+ # file
+ res = apt_pkg.sha1sum(open("hashsum_test.data"))
+ self.assert_(res == s_hash)
+ # with zero (\0) in the string
+ s = "foo\0bar"
+ s_hash = "e2c300a39311a2dfcaff799528415cb74c19317f"
+ res = apt_pkg.sha1sum(s)
+ self.assert_(res == s_hash)
+ # file
+ res = apt_pkg.sha1sum(open("hashsum_test_with_zero.data"))
+ self.assert_(res == s_hash)
+
+ def testSHA256(self):
+ # simple
+ s = "foo"
+ s_hash = \
+ "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"
+ res = apt_pkg.sha256sum(s)
+ self.assert_(res == s_hash)
+ # file
+ res = apt_pkg.sha256sum(open("hashsum_test.data"))
+ self.assert_(res == s_hash)
+ # with zero (\0) in the string
+ s = "foo\0bar"
+ s_hash = \
+ "d6b681bfce7155d44721afb79c296ef4f0fa80a9dd6b43c5cf74dd0f64c85512"
+ res = apt_pkg.sha256sum(s)
+ self.assert_(res == s_hash)
+ # file
+ res = apt_pkg.sha256sum(open("hashsum_test_with_zero.data"))
+ self.assert_(res == s_hash)
+
+if __name__ == "__main__":
+ unittest.main()