From 2311b3fe66d77d5a8ed3ce4e0878e2b7ef109bd3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 21 Feb 2011 09:32:05 +0100 Subject: doc/examples/configure-index: remove no longer used option NoConfigure --- doc/examples/configure-index | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 6119d67d0..03a37287d 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -385,7 +385,6 @@ DPkg { // let apt aggressivly use dpkg triggers NoTriggers "true"; - NoConfigure "true"; ConfigurePending "true"; // Probably don't want to use force-downgrade.. -- cgit v1.2.3 From 1aadba5adf0c32a44548baea9ba734336a578387 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 25 Feb 2011 12:29:13 +0100 Subject: * apt-pkg/deb/debindexfile.cc: - ignore missing deb-src files in /var/lib/apt/lists, thanks to Thorsten Spindler (LP: #85590) --- apt-pkg/deb/debindexfile.cc | 5 ++++- debian/changelog | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 9961b5ae4..1e8c04033 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -66,7 +66,10 @@ pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const string SourcesURI = _config->FindDir("Dir::State::lists") + URItoFileName(IndexURI("Sources")); string SourcesURIgzip = SourcesURI + ".gz"; - if (!FileExists(SourcesURI) && FileExists(SourcesURIgzip)) + + if (!FileExists(SourcesURI) && !FileExists(SourcesURIgzip)) + return NULL; + else if (!FileExists(SourcesURI) && FileExists(SourcesURIgzip)) SourcesURI = SourcesURIgzip; return new debSrcRecordParser(SourcesURI,this); diff --git a/debian/changelog b/debian/changelog index 986b6f876..68c83808b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,9 @@ apt (0.8.12) UNRELEASED; urgency=low mistake reported in bug LP: #641673, thanks to Robert Roth * merged lp:~evfool/apt/fix418552: - Grammar fix for bug LP: #418552, thanks to Robert Roth + * apt-pkg/deb/debindexfile.cc: + - ignore missing deb-src files in /var/lib/apt/lists, thanks + to Thorsten Spindler (LP: #85590) -- Michael Vogt Thu, 10 Feb 2011 17:37:56 +0100 -- cgit v1.2.3 From cfba4f6908927f46289f9fd945af02f12ee74412 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 3 Mar 2011 17:09:30 +0100 Subject: * apt-pkg/contrib/fileutl.cc, apt-pkg/deb/dpkgpm.cc: - honor Dpkg::Chroot-Directory in the RunScripts*() methods --- apt-pkg/contrib/fileutl.cc | 9 +++++++++ apt-pkg/deb/dpkgpm.cc | 9 +++++++++ debian/changelog | 2 ++ 3 files changed, 20 insertions(+) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 52f517ee0..935c4bebf 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -62,6 +62,15 @@ bool RunScripts(const char *Cnf) // This is the child if (Child == 0) { + if (_config->FindDir("DPkg::Chroot-Directory","/") != "/") + { + std::cerr << "Chrooting into " + << _config->FindDir("DPkg::Chroot-Directory") + << std::endl; + if (chroot(_config->FindDir("DPkg::Chroot-Directory","/").c_str()) != 0) + _exit(100); + } + if (chdir("/tmp/") != 0) _exit(100); diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 7d0d34a46..5747f1164 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -308,6 +308,15 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) SetCloseExec(STDIN_FILENO,false); SetCloseExec(STDERR_FILENO,false); + if (_config->FindDir("DPkg::Chroot-Directory","/") != "/") + { + std::cerr << "Chrooting into " + << _config->FindDir("DPkg::Chroot-Directory") + << std::endl; + if (chroot(_config->FindDir("DPkg::Chroot-Directory","/").c_str()) != 0) + _exit(100); + } + const char *Args[4]; Args[0] = "/bin/sh"; Args[1] = "-c"; diff --git a/debian/changelog b/debian/changelog index 68c83808b..ff5675a0c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ apt (0.8.12) UNRELEASED; urgency=low * apt-pkg/deb/debindexfile.cc: - ignore missing deb-src files in /var/lib/apt/lists, thanks to Thorsten Spindler (LP: #85590) + * apt-pkg/contrib/fileutl.cc, apt-pkg/deb/dpkgpm.cc: + - honor Dpkg::Chroot-Directory in the RunScripts*() methods -- Michael Vogt Thu, 10 Feb 2011 17:37:56 +0100 -- cgit v1.2.3 From b7bc31eb0bd71e2a3466df334a52a2c37c444d40 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 4 Mar 2011 21:17:00 +0100 Subject: apt-pkg/cdrom.{cc,h}: add udev_enumerate_add_match_sysattr to the libudev class --- apt-pkg/cdrom.cc | 1 + apt-pkg/cdrom.h | 1 + 2 files changed, 2 insertions(+) diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 04ace10a6..3dc7e9924 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -854,6 +854,7 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/ libudev_handle = h; udev_new = (udev* (*)(void)) dlsym(h, "udev_new"); udev_enumerate_add_match_property = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_property"); + udev_enumerate_add_match_sysattr = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_sysattr"); udev_enumerate_scan_devices = (int (*)(udev_enumerate*))dlsym(h, "udev_enumerate_scan_devices"); udev_enumerate_get_list_entry = (udev_list_entry* (*)(udev_enumerate*))dlsym(h, "udev_enumerate_get_list_entry"); udev_device_new_from_syspath = (udev_device* (*)(udev*, const char*))dlsym(h, "udev_device_new_from_syspath"); diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 14ca1d810..0fcdb6f1a 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -83,6 +83,7 @@ class pkgUdevCdromDevices /*{{{*/ void *libudev_handle; struct udev* (*udev_new)(void); int (*udev_enumerate_add_match_property)(struct udev_enumerate *udev_enumerate, const char *property, const char *value); + int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value); int (*udev_enumerate_scan_devices)(struct udev_enumerate *udev_enumerate); struct udev_list_entry* (*udev_enumerate_get_list_entry)(struct udev_enumerate *udev_enumerate); struct udev_device* (*udev_device_new_from_syspath)(struct udev *udev, const char *syspath); -- cgit v1.2.3 From ef38181605be2f7131bed9865d965300339389b5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 4 Mar 2011 22:24:09 +0100 Subject: apt-pkg/contrib/cdromutl.{cc,h}: add FindMountPointForDevice helper; apt-pkg/cdrom.cc: deal with missing FSTAB_DIR --- apt-pkg/cdrom.cc | 7 +++++++ apt-pkg/contrib/cdromutl.cc | 31 +++++++++++++++++++++++++++++++ apt-pkg/contrib/cdromutl.h | 1 + 3 files changed, 39 insertions(+) diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 3dc7e9924..86fe45fbe 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -882,6 +882,8 @@ pkgUdevCdromDevices::Scan() /*{{{*/ udev_ctx = udev_new(); enumerate = udev_enumerate_new (udev_ctx); udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1"); + //FIXME: just use removalble here to include usb etc + //udev_enumerate_add_match_sysattr(enumerate, "removable", "1"); udev_enumerate_scan_devices (enumerate); devices = udev_enumerate_get_list_entry (enumerate); @@ -894,6 +896,11 @@ pkgUdevCdromDevices::Scan() /*{{{*/ continue; const char* devnode = udev_device_get_devnode(udevice); const char* mountpath = udev_device_get_property_value(udevice, "FSTAB_DIR"); + if (mountpath == NULL) + mountpath = FindMountPointForDevice(devnode); + + if (_config->FindB("Debug::Acquire::cdrom", false)) + cerr << "found " << devnode << " mounted on " << mountpath << endl; // fill in the struct cdrom.DeviceName = string(devnode); diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 68b980407..cf1c0c29b 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -234,3 +235,33 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) return true; } /*}}}*/ + +// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ +char* FindMountPointForDevice(const char *devnode) +{ + char buf[255]; + char *out[10]; + int i=0; + + // this is the order that mount uses as well + const char *mount[] = { "/etc/mtab", + "/proc/mount", + NULL }; + + for (i=0; mount[i] != NULL; i++) { + if (FileExists(mount[i])) { + FILE *f=fopen(mount[i], "r"); + while ( fgets(buf, sizeof(buf), f) != NULL) { + if (strncmp(buf, devnode, strlen(devnode)) == 0) { + if(TokSplitString(' ', buf, out, 10)) + return strdup(out[1]); + } + } + fclose(f); + } + } + + return NULL; +} + + diff --git a/apt-pkg/contrib/cdromutl.h b/apt-pkg/contrib/cdromutl.h index 9d14249c5..4f0f90347 100644 --- a/apt-pkg/contrib/cdromutl.h +++ b/apt-pkg/contrib/cdromutl.h @@ -19,5 +19,6 @@ bool MountCdrom(string Path, string DeviceName=""); bool UnmountCdrom(string Path); bool IdentCdrom(string CD,string &Res,unsigned int Version = 2); bool IsMounted(string &Path); +char *FindMountPointForDevice(const char *device); #endif -- cgit v1.2.3 From f7cbd1fbc57bc13dfc2ebc246453ab0875d4151a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Mar 2011 11:20:05 +0100 Subject: apt-pkg/cdrom.h: move new member to the end to minimize ABI risk --- apt-pkg/cdrom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 0fcdb6f1a..5f67a3a94 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -83,7 +83,6 @@ class pkgUdevCdromDevices /*{{{*/ void *libudev_handle; struct udev* (*udev_new)(void); int (*udev_enumerate_add_match_property)(struct udev_enumerate *udev_enumerate, const char *property, const char *value); - int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value); int (*udev_enumerate_scan_devices)(struct udev_enumerate *udev_enumerate); struct udev_list_entry* (*udev_enumerate_get_list_entry)(struct udev_enumerate *udev_enumerate); struct udev_device* (*udev_device_new_from_syspath)(struct udev *udev, const char *syspath); @@ -93,6 +92,7 @@ class pkgUdevCdromDevices /*{{{*/ struct udev_enumerate *(*udev_enumerate_new) (struct udev *udev); struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *list_entry); const char* (*udev_device_get_property_value)(struct udev_device *udev_device, const char *key); + int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value); // end libudev dlopen public: -- cgit v1.2.3 From f4c4a24ea1cd8711c186c1c60b43f0bf0bc8af10 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Mar 2011 11:31:08 +0100 Subject: apt-pkg/cdrom.{cc,h}: add ScanForRemovable helper --- apt-pkg/cdrom.cc | 23 ++++++++++++++++------- apt-pkg/cdrom.h | 7 ++++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 86fe45fbe..deca6b4ac 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -868,8 +868,19 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/ return true; } /*}}}*/ + + /*{{{*/ +// compatiblity only with the old API/ABI, can be removed on the next +// ABI break +vector +pkgUdevCdromDevices::Scan() +{ + return ScanForRemovable(true); +}; + /*}}}*/ + /*{{{*/ vector -pkgUdevCdromDevices::Scan() /*{{{*/ +pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly) { vector cdrom_devices; struct udev_enumerate *enumerate; @@ -881,9 +892,10 @@ pkgUdevCdromDevices::Scan() /*{{{*/ udev_ctx = udev_new(); enumerate = udev_enumerate_new (udev_ctx); - udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1"); - //FIXME: just use removalble here to include usb etc - //udev_enumerate_add_match_sysattr(enumerate, "removable", "1"); + if (CdromOnly) + udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1"); + else + udev_enumerate_add_match_sysattr(enumerate, "removable", "1"); udev_enumerate_scan_devices (enumerate); devices = udev_enumerate_get_list_entry (enumerate); @@ -899,9 +911,6 @@ pkgUdevCdromDevices::Scan() /*{{{*/ if (mountpath == NULL) mountpath = FindMountPointForDevice(devnode); - if (_config->FindB("Debug::Acquire::cdrom", false)) - cerr << "found " << devnode << " mounted on " << mountpath << endl; - // fill in the struct cdrom.DeviceName = string(devnode); if (mountpath) { diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 5f67a3a94..032fae755 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -68,7 +68,7 @@ class pkgCdrom /*{{{*/ /*}}}*/ -// class that uses libudev to find cdrom devices dynamically +// class that uses libudev to find cdrom/removable devices dynamically struct CdromDevice /*{{{*/ { string DeviceName; @@ -101,7 +101,12 @@ class pkgUdevCdromDevices /*{{{*/ // try to open bool Dlopen(); + + // this is the new interface + vector ScanForRemovable(bool CdromOnly); + // FIXME: compat with the old interface/API/ABI only vector Scan(); + }; /*}}}*/ -- cgit v1.2.3 From 02aa6f67360bbd8f15c29fb0701badda99fc8c75 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Mar 2011 12:15:13 +0100 Subject: apt-pkg/contrib/cdromutl.{cc,h}: return string for mountpath; apt-pkg/cdrom.cc: use string --- apt-pkg/cdrom.cc | 11 ++++++++--- apt-pkg/contrib/cdromutl.cc | 6 +++--- apt-pkg/contrib/cdromutl.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index deca6b4ac..83438f1c4 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -907,13 +907,18 @@ pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly) if (udevice == NULL) continue; const char* devnode = udev_device_get_devnode(udevice); - const char* mountpath = udev_device_get_property_value(udevice, "FSTAB_DIR"); - if (mountpath == NULL) + + // try fstab_dir first + string mountpath; + const char* mp = udev_device_get_property_value(udevice, "FSTAB_DIR"); + if (mp) + mountpath = string(mp); + else mountpath = FindMountPointForDevice(devnode); // fill in the struct cdrom.DeviceName = string(devnode); - if (mountpath) { + if (mountpath != "") { cdrom.MountPath = mountpath; string s = string(mountpath); cdrom.Mounted = IsMounted(s); diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index cf1c0c29b..83c324f54 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -237,7 +237,7 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) /*}}}*/ // FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ -char* FindMountPointForDevice(const char *devnode) +string FindMountPointForDevice(const char *devnode) { char buf[255]; char *out[10]; @@ -254,14 +254,14 @@ char* FindMountPointForDevice(const char *devnode) while ( fgets(buf, sizeof(buf), f) != NULL) { if (strncmp(buf, devnode, strlen(devnode)) == 0) { if(TokSplitString(' ', buf, out, 10)) - return strdup(out[1]); + return string(out[1]); } } fclose(f); } } - return NULL; + return string(); } diff --git a/apt-pkg/contrib/cdromutl.h b/apt-pkg/contrib/cdromutl.h index 4f0f90347..38ed2996e 100644 --- a/apt-pkg/contrib/cdromutl.h +++ b/apt-pkg/contrib/cdromutl.h @@ -19,6 +19,6 @@ bool MountCdrom(string Path, string DeviceName=""); bool UnmountCdrom(string Path); bool IdentCdrom(string CD,string &Res,unsigned int Version = 2); bool IsMounted(string &Path); -char *FindMountPointForDevice(const char *device); +string FindMountPointForDevice(const char *device); #endif -- cgit v1.2.3 From c9952021ba65db0581f6053cd6d6e8bf7d563e8f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 10 Mar 2011 11:13:44 +0100 Subject: * apt-pkg/contrib/cdromutl.{cc,h}, apt-pkg/cdrom.{cc,h}: - deal with missing FSTAB_DIR when using libudev to discover cdrom - add experimental APT::cdrom::CdromOnly option (on by default). When this is set to false apt-cdrom will handle any removable deivce (like a usb-stick) as a "cdrom/dvd" source --- apt-pkg/cdrom.cc | 3 ++- debian/changelog | 5 +++++ doc/examples/configure-index | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 83438f1c4..55600fe57 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -875,7 +875,8 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/ vector pkgUdevCdromDevices::Scan() { - return ScanForRemovable(true); + bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true); + return ScanForRemovable(CdromOnly); }; /*}}}*/ /*{{{*/ diff --git a/debian/changelog b/debian/changelog index ff5675a0c..fba168110 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,11 @@ apt (0.8.12) UNRELEASED; urgency=low to Thorsten Spindler (LP: #85590) * apt-pkg/contrib/fileutl.cc, apt-pkg/deb/dpkgpm.cc: - honor Dpkg::Chroot-Directory in the RunScripts*() methods + * apt-pkg/contrib/cdromutl.{cc,h}, apt-pkg/cdrom.{cc,h}: + - deal with missing FSTAB_DIR when using libudev to discover cdrom + - add experimental APT::cdrom::CdromOnly option (on by default). + When this is set to false apt-cdrom will handle any removable + deivce (like a usb-stick) as a "cdrom/dvd" source -- Michael Vogt Thu, 10 Feb 2011 17:37:56 +0100 diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 03a37287d..6884e06e3 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -265,7 +265,10 @@ Acquire cdrom { // do auto detection of the cdrom mountpoint - AutoDetect "true"; + AutoDetect "true"; + // when auto-detecting, only look for cdrom/dvd. when this is false + // it will support any removable device as a "cdrom" source + CdromOnly "true"; // cdrom mountpoint (needs to be defined in fstab if AutoDetect is not used) mount "/cdrom"; -- cgit v1.2.3