~ubuntu-branches/ubuntu/raring/apt-clone/raring

« back to all changes in this revision

Viewing changes to apt_clone.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2011-10-19 14:54:15 UTC
  • mfrom: (0.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20111019145415-k92j5ejyz1kco359
Tags: 0.2.1
* apt-clone:
  - improve --help output (closes: #641864), thanks to
    Rogerio. Brito
* apt-clone.8:
  - add simple man page
* apt_clone.py:
  - fix tar prefix detection

Show diffs side-by-side

added added

removed removed

Lines of Context:
211
211
        if os.path.exists(source_parts):
212
212
            tar.add(source_parts, arcname="./etc/apt/sources.list.d")
213
213
 
 
214
    def _write_modified_files_from_etc(self, tar):
 
215
        #etcdir = os.path.join(apt_pkg.config.get("Dir"), "etc")
 
216
        pass
 
217
 
214
218
    def _dpkg_repack(self, tar):
215
219
        tdir = tempfile.mkdtemp()
216
220
        for pkgname in self.not_downloadable:
221
225
 
222
226
    # detect prefix
223
227
    def _detect_tarprefix(self, tar):
224
 
        if tar.getnames()[0].startswith("./"):
 
228
        print tar.getnames()
 
229
        if tar.getnames()[-1].startswith("./"):
225
230
            self.TARPREFIX = "./"
226
231
        else:
227
232
            self.TARPREFIX = ""
482
487
                entry.disabled = True
483
488
        sources.save()
484
489
 
 
490
    def _find_unowned_in_etc(self, sourcedir=""):
 
491
        if sourcedir:
 
492
            etcdir = os.path.join(sourcedir, "etc")
 
493
        else:
 
494
            etcdir = "/etc"
 
495
        # get all the files that dpkg "owns"
 
496
        owned = set()
 
497
        dpkg_basedir = os.path.dirname(apt_pkg.config.get("Dir::State::status"))
 
498
        for f in glob.glob(os.path.join(dpkg_basedir, "info", "*.list")):
 
499
            for line in open(f):
 
500
                if line.startswith("/etc/"):
 
501
                    owned.add(line.strip())
 
502
        # now go over etc
 
503
        unowned = set()
 
504
        for dirpath, dirnames, filenames in os.walk(etcdir):
 
505
            for name in filenames:
 
506
                fullname = os.path.join(dirpath[len(sourcedir):], name)
 
507
                if not fullname in owned:
 
508
                    unowned.add(fullname)
 
509
        return unowned
485
510
 
486
511
    def _find_modified_conffiles(self, sourcedir="/"):
487
512
        dpkg_status = sourcedir+apt_pkg.config.find("Dir::State::status")