Example #1
0
 def _save_state(self, with_dpkg_repack):
     # setup mock
     targetdir = self.tempdir
     # test
     clone = AptClone(cache_cls=MockAptCache)
     sourcedir = "./data/mock-system"
     clone.save_state(sourcedir, targetdir, with_dpkg_repack, with_dpkg_status=True)
     # verify that we got the tarfile
     tarname = os.path.join(targetdir, clone.CLONE_FILENAME)
     self.assertTrue(os.path.exists(tarname))
     with tarfile.open(tarname) as tar:
         #print(tar.getmembers())
         # verify members in tar
         members = [m.name for m in tar.getmembers()]
     self.assertTrue("./etc/apt/sources.list" in members)
     self.assertTrue("./var/lib/apt-clone/installed.pkgs" in members)
     self.assertTrue("./var/lib/apt-clone/foreign.pkgs" in members)
     self.assertTrue("./var/lib/apt-clone/extended_states" in members)
     self.assertTrue("./var/lib/apt-clone/dpkg-status" in members)
     self.assertTrue("./etc/apt/sources.list.d" in members)
     self.assertTrue("./etc/apt/preferences.d" in members)
     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.assertEqual(
         sorted(sources_list_d),
         sorted(
             ['./etc/apt/sources.list.d',
              './etc/apt/sources.list.d/ubuntu-mozilla-daily-ppa-maverick.list']))
def save_system_state(logdir):
    # save package state to be able to re-create failures
    try:
        from apt_clone import AptClone
    except ImportError:
        logging.error("failed to import AptClone")
        return
    target = os.path.join(logdir, "apt-clone_system_state.tar.gz")
    logging.debug("creating statefile: '%s'" % target)
    # this file may contain sensitive data so ensure we create with the
    # right umask
    old_umask = os.umask(0066)
    clone = AptClone()
    clone.save_state(sourcedir="/",
                     target=target,
                     with_dpkg_status=True,
                     scrub_sources=True)
    # reset umask
    os.umask(old_umask)
    # lspci output
    try:
        s = subprocess.Popen(["lspci", "-nn"],
                             stdout=subprocess.PIPE).communicate()[0]
        open(os.path.join(logdir, "lspci.txt"), "w").write(s)
    except OSError, e:
        logging.debug("lspci failed: %s" % e)
def save_system_state(logdir):
    # save package state to be able to re-create failures
    try:
        from apt_clone import AptClone
    except ImportError:
        logging.error("failed to import AptClone")
        return
    target = os.path.join(logdir, "apt-clone_system_state.tar.gz")
    logging.debug("creating statefile: '%s'" % target)
    clone = AptClone()
    clone.save_state(sourcedir="/", target=target, with_dpkg_status=True)
    # lspci output
    try:
        s=subprocess.Popen(["lspci","-nn"], stdout=subprocess.PIPE).communicate()[0]
        open(os.path.join(logdir, "lspci.txt"), "w").write(s)
    except OSError, e:
        logging.debug("lspci failed: %s" % e)
Example #4
0
 def _save_state(self, with_dpkg_repack):
     # setup mock
     targetdir = self.tempdir
     # test
     clone = AptClone(cache_cls=MockAptCache)
     sourcedir = "./data/mock-system"
     clone.save_state(sourcedir,
                      targetdir,
                      with_dpkg_repack,
                      with_dpkg_status=True)
     # verify that we got the tarfile
     tarname = os.path.join(targetdir, clone.CLONE_FILENAME)
     self.assertTrue(os.path.exists(tarname))
     with tarfile.open(tarname) as tar:
         #print(tar.getmembers())
         # verify members in tar
         members = [m.name for m in tar.getmembers()]
     self.assertTrue("./etc/apt/sources.list" in members)
     self.assertTrue("./var/lib/apt-clone/installed.pkgs" in members)
     self.assertTrue("./var/lib/apt-clone/foreign.pkgs" in members)
     self.assertTrue("./var/lib/apt-clone/extended_states" in members)
     self.assertTrue("./var/lib/apt-clone/dpkg-status" in members)
     self.assertTrue("./etc/apt/sources.list.d" in members)
     self.assertTrue("./etc/apt/preferences.d" in members)
     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.assertEqual(
         sorted(sources_list_d),
         sorted([
             './etc/apt/sources.list.d',
             './etc/apt/sources.list.d/ubuntu-mozilla-daily-ppa-maverick.list'
         ]))
def save_system_state(logdir):
    # save package state to be able to re-create failures
    try:
        from apt_clone import AptClone
    except ImportError:
        logging.error("failed to import AptClone")
        return
    target = os.path.join(logdir, "apt-clone_system_state.tar.gz")
    logging.debug("creating statefile: '%s'" % target)
    # this file may contain sensitive data so ensure we create with the
    # right umask
    old_umask = os.umask(0066)
    clone = AptClone()
    clone.save_state(sourcedir="/", target=target, with_dpkg_status=True,
        scrub_sources=True)
    # reset umask
    os.umask(old_umask)
    # lspci output
    try:
        s=subprocess.Popen(["lspci","-nn"], stdout=subprocess.PIPE).communicate()[0]
        open(os.path.join(logdir, "lspci.txt"), "w").write(s)
    except OSError, e:
        logging.debug("lspci failed: %s" % e)