From 15d7e51550327bf49b95372f84bd0de4e896e7d7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 30 Jan 2009 20:55:20 +0100 Subject: [ABI break] merge support for http redirects, thanks to Jeff Licquia and Anthony Towns --- methods/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'methods/makefile') diff --git a/methods/makefile b/methods/makefile index d9481dbcc..78bdbc96f 100644 --- a/methods/makefile +++ b/methods/makefile @@ -7,7 +7,7 @@ include ../buildlib/defaults.mak BIN := $(BIN)/methods # FIXME.. -LIB_APT_PKG_MAJOR = 4.6 +LIB_APT_PKG_MAJOR = 4.7 APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR) # The file method -- cgit v1.2.3-70-g09d2 From 81e9789b12374073e848c73c79e235f82c14df44 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 9 Jun 2009 17:33:22 +0200 Subject: [ABI break] support '#' in apt.conf and /etc/apt/preferences (closes: #189866) --- apt-pkg/contrib/configuration.cc | 2 +- apt-pkg/init.h | 2 +- apt-pkg/makefile | 2 +- apt-pkg/policy.cc | 18 ++++++++++++++++-- apt-pkg/tagfile.cc | 21 ++++++++++++++++----- apt-pkg/tagfile.h | 5 ++++- debian/changelog | 5 +++++ methods/makefile | 2 +- 8 files changed, 45 insertions(+), 12 deletions(-) (limited to 'methods/makefile') diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index a82311a3f..80584d3ea 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -582,7 +582,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional, if (InQuote == true) continue; - if (*I == '/' && I + 1 != End && I[1] == '/') + if ((*I == '/' && I + 1 != End && I[1] == '/') || *I == '#') { End = I; break; diff --git a/apt-pkg/init.h b/apt-pkg/init.h index 6d8693be9..165299253 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -18,7 +18,7 @@ // See the makefile #define APT_PKG_MAJOR 4 -#define APT_PKG_MINOR 6 +#define APT_PKG_MINOR 8 #define APT_PKG_RELEASE 0 extern const char *pkgVersion; diff --git a/apt-pkg/makefile b/apt-pkg/makefile index 087f17740..059f8532b 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -13,7 +13,7 @@ include ../buildlib/defaults.mak # methods/makefile - FIXME LIBRARY=apt-pkg LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER) -MAJOR=4.7 +MAJOR=4.8 MINOR=0 SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil APT_DOMAIN:=libapt-pkg$(MAJOR) diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 8b083fd44..98576fc91 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -239,7 +239,21 @@ signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg) return 0; } /*}}}*/ - +// PreferenceSection class - Overriding the default TrimRecord method /*{{{*/ +// --------------------------------------------------------------------- +/* The preference file is a user generated file so the parser should + therefore be a bit more friendly by allowing comments and new lines + all over the place rather than forcing a special format */ +class PreferenceSection : public pkgTagSection +{ + void TrimRecord(bool BeforeRecord, const char* &End) + { + for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r' || Stop[0] == '#'); Stop++) + if (Stop[0] == '#') + Stop = (const char*) memchr(Stop,'\n',End-Stop); + } +}; + /*}}}*/ // ReadPinFile - Load the pin file into a Policy /*{{{*/ // --------------------------------------------------------------------- /* I'd like to see the preferences file store more than just pin information @@ -259,7 +273,7 @@ bool ReadPinFile(pkgPolicy &Plcy,string File) if (_error->PendingError() == true) return false; - pkgTagSection Tags; + PreferenceSection Tags; while (TF.Step(Tags) == true) { string Name = Tags.FindS("Package"); diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 893cb8ee7..7c5d15a58 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -81,7 +81,7 @@ bool pkgTagFile::Resize() End = Start + EndSize; return true; } - + /*}}}*/ // TagFile::Step - Advance to the next section /*{{{*/ // --------------------------------------------------------------------- /* If the Section Scanner fails we refill the buffer and try again. @@ -212,10 +212,12 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength) if (Stop == 0) return false; - + TagCount = 0; while (TagCount+1 < sizeof(Indexes)/sizeof(Indexes[0]) && Stop < End) { + TrimRecord(true,End); + // Start a new index and add it to the hash if (isspace(Stop[0]) == 0) { @@ -227,14 +229,14 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength) if (Stop == 0) return false; - + for (; Stop+1 < End && Stop[1] == '\r'; Stop++); // Double newline marks the end of the record if (Stop+1 < End && Stop[1] == '\n') { Indexes[TagCount] = Stop - Section; - for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r'); Stop++); + TrimRecord(false,End); return true; } @@ -244,6 +246,16 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength) return false; } /*}}}*/ +// TagSection::TrimRecord - Trim off any garbage before/after a record /*{{{*/ +// --------------------------------------------------------------------- +/* There should be exactly 2 newline at the end of the record, no more. */ +void pkgTagSection::TrimRecord(bool BeforeRecord, const char*& End) +{ + if (BeforeRecord == true) + return; + for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r'); Stop++); +} + /*}}}*/ // TagSection::Trim - Trim off any trailing garbage /*{{{*/ // --------------------------------------------------------------------- /* There should be exactly 1 newline at the end of the buffer, no more. */ @@ -390,7 +402,6 @@ bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags, return true; } /*}}}*/ - // TFRewrite - Rewrite a control record /*{{{*/ // --------------------------------------------------------------------- /* This writes the control record to stdout rewriting it as necessary. The diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 6536932dd..321329a23 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -27,7 +27,6 @@ class pkgTagSection { const char *Section; - const char *Stop; // We have a limit of 256 tags per section. unsigned int Indexes[256]; @@ -35,6 +34,9 @@ class pkgTagSection unsigned int TagCount; + protected: + const char *Stop; + public: inline bool operator ==(const pkgTagSection &rhs) {return Section == rhs.Section;}; @@ -49,6 +51,7 @@ class pkgTagSection bool Scan(const char *Start,unsigned long MaxLength); inline unsigned long size() const {return Stop - Section;}; void Trim(); + virtual void TrimRecord(bool BeforeRecord, const char* &End); inline unsigned int Count() const {return TagCount;}; inline void Get(const char *&Start,const char *&Stop,unsigned int I) const diff --git a/debian/changelog b/debian/changelog index 5d3a801a8..7947918a4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ apt (0.7.22) UNRELEASED; urgency=low + [ Christian Perrier ] * Documentation translations: - Fix a typo in apt-get(8) French translation. Closes: #525043 Thanks to Guillaume Delacour for spotting it. @@ -15,6 +16,10 @@ apt (0.7.22) UNRELEASED; urgency=low * Added translations - ast.po (Asturian by Marcos Alvareez Costales). Closes: #529007, #529730 + + [ David Kalnischkies ] + * [ABI break] support '#' in apt.conf and /etc/apt/preferences + (closes: #189866) -- Christian Perrier Wed, 22 Apr 2009 10:13:54 +0200 diff --git a/methods/makefile b/methods/makefile index 78bdbc96f..589f9fa1c 100644 --- a/methods/makefile +++ b/methods/makefile @@ -7,7 +7,7 @@ include ../buildlib/defaults.mak BIN := $(BIN)/methods # FIXME.. -LIB_APT_PKG_MAJOR = 4.7 +LIB_APT_PKG_MAJOR = 4.8 APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR) # The file method -- cgit v1.2.3-70-g09d2 From 8e372e79de1277f3508c20c2eb486165402e5afc Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 8 Jul 2009 14:39:32 +0200 Subject: prototype for libudev dlopen() type of cdrom detection --- methods/cdrom.cc | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- methods/makefile | 2 +- 2 files changed, 62 insertions(+), 5 deletions(-) (limited to 'methods/makefile') diff --git a/methods/cdrom.cc b/methods/cdrom.cc index 601bc11c9..0310b66cd 100644 --- a/methods/cdrom.cc +++ b/methods/cdrom.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -24,6 +25,23 @@ using namespace std; +struct udev; +struct udev_list_entry; + +// libudev dlopen stucture +struct udev_p { + 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_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); + struct udev *(*udev_enumerate_get_udev)(struct udev_enumerate *udev_enumerate); + const char *(*udev_list_entry_get_name)(struct udev_list_entry *list_entry); + const char *(*udev_device_get_devnode)(struct udev_device *udev_device); + struct udev_enumerate *(*udev_enumerate_new) (struct udev *udev); + struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *list_entry); +}; + class CDROMMethod : public pkgAcqMethod { bool DatabaseLoaded; @@ -31,11 +49,12 @@ class CDROMMethod : public pkgAcqMethod string CurrentID; string CDROM; bool MountedByApt; - + vector CdromDevices; + virtual bool Fetch(FetchItem *Itm); string GetID(string Name); virtual void Exit(); - + public: CDROMMethod(); @@ -50,14 +69,52 @@ CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly | DatabaseLoaded(false), MountedByApt(false) { + // see if we can get libudev + void *h = dlopen("libudev.so.0", RTLD_LAZY); + if (h) { + // the pointers for the udev struct + struct udev_p p; + p.udev_new = (udev* (*)(void)) dlsym(h, "udev_new"); + p.udev_enumerate_add_match_property = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_property"); + p.udev_enumerate_scan_devices = (int (*)(udev_enumerate*))dlsym(h, "udev_enumerate_scan_devices"); + p.udev_enumerate_get_list_entry = (udev_list_entry* (*)(udev_enumerate*))dlsym(h, "udev_enumerate_get_list_entry"); + p.udev_device_new_from_syspath = (udev_device* (*)(udev*, const char*))dlsym(h, "udev_device_new_from_syspath"); + p.udev_enumerate_get_udev = (udev* (*)(udev_enumerate*))dlsym(h, "udev_enumerate_get_udev"); + p.udev_list_entry_get_name = (const char* (*)(udev_list_entry*))dlsym(h, "udev_list_entry_get_name"); + p.udev_device_get_devnode = (const char* (*)(udev_device*))dlsym(h, "udev_device_get_devnode"); + p.udev_enumerate_new = (udev_enumerate* (*)(udev*))dlsym(h, "udev_enumerate_new"); + p.udev_list_entry_get_next = (udev_list_entry* (*)(udev_list_entry*))dlsym(h, "udev_list_entry_get_next"); + struct udev_enumerate *enumerate; + struct udev_list_entry *l, *devices; + struct udev *udev_ctx; + + udev_ctx = p.udev_new(); + enumerate = p.udev_enumerate_new (udev_ctx); + p.udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1"); + + p.udev_enumerate_scan_devices (enumerate); + devices = p.udev_enumerate_get_list_entry (enumerate); + for (l = devices; l != NULL; l = p.udev_list_entry_get_next (l)) + { + struct udev_device *udevice; + udevice = p.udev_device_new_from_syspath (p.udev_enumerate_get_udev (enumerate), p.udev_list_entry_get_name (l)); + if (udevice == NULL) + continue; + const char* devnode = p.udev_device_get_devnode(udevice); + //std::cerr << devnode << std::endl; + CdromDevices.push_back(string(devnode)); + } + } + + }; /*}}}*/ // CDROMMethod::Exit - Unmount the disc if necessary /*{{{*/ // --------------------------------------------------------------------- /* */ void CDROMMethod::Exit() -{ - if (MountedByApt == true) +{ + if (MountedByApt == true) UnmountCdrom(CDROM); } /*}}}*/ diff --git a/methods/makefile b/methods/makefile index 78bdbc96f..c447b4732 100644 --- a/methods/makefile +++ b/methods/makefile @@ -40,7 +40,7 @@ include $(PROGRAM_H) # The cdrom method PROGRAM=cdrom -SLIBS = -lapt-pkg $(INTLLIBS) +SLIBS = -lapt-pkg -ldl $(INTLLIBS) LIB_MAKES = apt-pkg/makefile SOURCE = cdrom.cc include $(PROGRAM_H) -- cgit v1.2.3-70-g09d2