From e2b1181b6600d5dfb1f5e1ebd31d89ee9229db8c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 6 Feb 2007 14:40:45 +0100 Subject: * better cdrom support merged --- apt/cdrom.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 apt/cdrom.py (limited to 'apt/cdrom.py') diff --git a/apt/cdrom.py b/apt/cdrom.py new file mode 100644 index 00000000..d499b30a --- /dev/null +++ b/apt/cdrom.py @@ -0,0 +1,48 @@ + +import apt_pkg +from apt.progress import CdromProgress + +class Cdrom(object): + def __init__(self, progress=None, mountpoint=None, nomount=True): + """ Support for apt-cdrom like features. + Options: + - progress: optional progress.CdromProgress() subclass + - mountpoint: optional alternative mountpoint + - nomount: do not mess with mount/umount the CD + """ + self._cdrom = apt_pkg.GetCdrom() + if progress is None: + self._progress = apt.progress.CdromProgress() + else: + self._progress = progress + # see if we have a alternative mountpoint + if mountpoint is not None: + apt_pkg.Config.Set("Acquire::cdrom::mount",mountpoint) + # do not mess with mount points by default + if nomount is True: + apt_pkg.Config.Set("APT::CDROM::NoMount", "true") + else: + apt_pkg.Config.Set("APT::CDROM::NoMount", "false") + def add(self): + " add cdrom to the sources.list " + return self._cdrom.Add(self._progress) + def ident(self): + " identify the cdrom " + (res, ident) = self._cdrom.Ident(self._progress) + if res: + return ident + return None + @property + def inSourcesList(self): + " check if the cdrom is already in the current sources.list " + cdid = self.ident() + if cdid is None: + # FIXME: throw exception instead + return False + # FIXME: check sources.list.d/ as well + for line in open(apt_pkg.Config.FindFile("Dir::Etc::sourcelist")): + line = line.strip() + if not line.startswith("#") and cdid in line: + return True + return False + -- cgit v1.2.3 From 6b02ff1915b3dcd098474e1b9ccd5f89d6b777da Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 7 Mar 2007 11:07:56 +0100 Subject: * apt/cdrom.py: - fix bug in cdrom mountpoint handling --- apt/cdrom.py | 4 ++-- debian/changelog | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'apt/cdrom.py') diff --git a/apt/cdrom.py b/apt/cdrom.py index d499b30a..8d73339c 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -1,6 +1,6 @@ import apt_pkg -from apt.progress import CdromProgress +from progress import CdromProgress class Cdrom(object): def __init__(self, progress=None, mountpoint=None, nomount=True): @@ -12,7 +12,7 @@ class Cdrom(object): """ self._cdrom = apt_pkg.GetCdrom() if progress is None: - self._progress = apt.progress.CdromProgress() + self._progress = CdromProgress() else: self._progress = progress # see if we have a alternative mountpoint diff --git a/debian/changelog b/debian/changelog index 3ac73a8e..cab337f6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ python-apt (0.6.21) unstable; urgency=low - support candidateRecord, installedRecord * apt/cache.py: - fix rootdir + * apt/cdrom.py: + - fix bug in cdrom mountpoint handling -- -- cgit v1.2.3