diff -Nru apt-clone-0.2.2ubuntu2/apt_clone.py apt-clone-0.2.2ubuntu3/apt_clone.py --- apt-clone-0.2.2ubuntu2/apt_clone.py 2012-08-09 20:09:45.000000000 +0000 +++ apt-clone-0.2.2ubuntu3/apt_clone.py 2012-12-14 23:23:18.000000000 +0000 @@ -207,16 +207,20 @@ tar.add(p, arcname="./etc/apt/trusted.gpg.d") def _write_state_sources_list(self, tar, scrub=False): - self._add_file_to_tar_with_password_check(tar, - apt_pkg.config.find_file("Dir::Etc::sourcelist"), scrub) + sources_list = apt_pkg.config.find_file("Dir::Etc::sourcelist") + self._add_file_to_tar_with_password_check(tar, sources_list, scrub, + "./etc/apt/sources.list") source_parts = apt_pkg.config.find_dir("Dir::Etc::sourceparts") if os.path.exists(source_parts): + tar.add(source_parts, arcname="./etc/apt/sources.list.d", + recursive=False) for source in os.listdir(source_parts): sources_file_name = '%s/%s' % (source_parts, source) self._add_file_to_tar_with_password_check(tar, - sources_file_name, scrub) + sources_file_name, scrub, + "./etc/apt/sources.list.d/"+source) - def _add_file_to_tar_with_password_check(self, tar, sources, scrub=False): + def _add_file_to_tar_with_password_check(self, tar, sources, scrub, arcname): if scrub: with tempfile.NamedTemporaryFile(mode='w') as source_copy: with open(sources, 'r') as f: @@ -228,9 +232,9 @@ else: source_copy.write(line) source_copy.flush() - tar.add(source_copy.name, arcname=".%s" % (sources)) + tar.add(source_copy.name, arcname=arcname) else: - tar.add(sources, arcname='.%s' % sources) + tar.add(sources, arcname=arcname) def _write_modified_files_from_etc(self, tar): #etcdir = os.path.join(apt_pkg.config.get("Dir"), "etc") diff -Nru apt-clone-0.2.2ubuntu2/debian/changelog apt-clone-0.2.2ubuntu3/debian/changelog --- apt-clone-0.2.2ubuntu2/debian/changelog 2012-08-09 20:11:25.000000000 +0000 +++ apt-clone-0.2.2ubuntu3/debian/changelog 2012-12-14 23:24:55.000000000 +0000 @@ -1,3 +1,11 @@ +apt-clone (0.2.2ubuntu3) precise-proposed; urgency=low + + * Ensure that /etc/apt/sources.list and /etc/apt/sources.list.d are put + at the right place in the tarball by hardcoding their location in the + tarball. (LP: #1066347) Thanks to Stéphane Graber for the patch. + + -- Brian Murray Fri, 14 Dec 2012 15:24:02 -0800 + apt-clone (0.2.2ubuntu2) precise-proposed; urgency=low * apt_clone.py: fix with syntax to work with python2.6 diff -Nru apt-clone-0.2.2ubuntu2/tests/data/mock-system/etc/apt/sources.list.d/ubuntu-mozilla-daily-ppa-maverick.list apt-clone-0.2.2ubuntu3/tests/data/mock-system/etc/apt/sources.list.d/ubuntu-mozilla-daily-ppa-maverick.list --- apt-clone-0.2.2ubuntu2/tests/data/mock-system/etc/apt/sources.list.d/ubuntu-mozilla-daily-ppa-maverick.list 2012-08-09 20:08:32.000000000 +0000 +++ apt-clone-0.2.2ubuntu3/tests/data/mock-system/etc/apt/sources.list.d/ubuntu-mozilla-daily-ppa-maverick.list 2012-12-14 23:21:38.000000000 +0000 @@ -1,6 +1,3 @@ -#disabled on upgrade to natty disabled on upgrade to natty -# deb http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu/ natty main -#disabled on upgrade to natty disabled on upgrade to natty -# deb-src http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu/ natty main +deb http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu/ lucid main diff -Nru apt-clone-0.2.2ubuntu2/tests/test_clone.py apt-clone-0.2.2ubuntu3/tests/test_clone.py --- apt-clone-0.2.2ubuntu2/tests/test_clone.py 2012-08-09 20:08:32.000000000 +0000 +++ apt-clone-0.2.2ubuntu3/tests/test_clone.py 2012-12-14 23:26:11.000000000 +0000 @@ -10,10 +10,7 @@ import tempfile import unittest -from StringIO import StringIO - -sys.path.insert(0, "..") -import apt_clone +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) from apt_clone import AptClone class MockAptCache(apt.Cache): @@ -25,6 +22,11 @@ class TestClone(unittest.TestCase): def setUp(self): + #clean custom apt config + for d in apt_pkg.config.keys(): + apt_pkg.config.clear(d) + apt_pkg.init_config() + # clean apt_pkg.config.set("Dir", "/") apt_pkg.config.set("dir::state::status", "/var/lib/dpkg/status") self.tempdir = tempfile.mkdtemp("apt-clone-tests") @@ -71,6 +73,12 @@ self.assertTrue("./etc/apt/preferences" in members) if clone.not_downloadable: self.assertEqual(clone.commands.repack_deb.called, with_dpkg_repack) + # ensure we have no duplicates in the sources.list.d + sources_list_d = [p for p in members + if p.startswith("./etc/apt/sources.list.d")] + self.assertCountEqual(sources_list_d, + ['./etc/apt/sources.list.d', + './etc/apt/sources.list.d/ubuntu-mozilla-daily-ppa-maverick.list']) @mock.patch("apt_clone.LowLevelCommands") def test_restore_state(self, mock_lowlevel):