[maemo-commits] [maemo-commits] r14883 - in projects/haf/trunk/apt: . apt-pkg/contrib debian
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Dec 6 18:14:00 EET 2007
- Previous message: [maemo-commits] r14882 - projects/haf/trunk/apt
- Next message: [maemo-commits] r14884 - in projects/haf/trunk/apt: . cmdline debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: marivoll Date: 2007-12-06 18:13:54 +0200 (Thu, 06 Dec 2007) New Revision: 14883 Modified: projects/haf/trunk/apt/README.maemo projects/haf/trunk/apt/apt-pkg/contrib/mmap.cc projects/haf/trunk/apt/apt-pkg/contrib/mmap.h projects/haf/trunk/apt/debian/changelog projects/haf/trunk/apt/mmap.patch Log: * Applied mmap.patch Modified: projects/haf/trunk/apt/README.maemo =================================================================== --- projects/haf/trunk/apt/README.maemo 2007-12-06 16:11:00 UTC (rev 14882) +++ projects/haf/trunk/apt/README.maemo 2007-12-06 16:13:54 UTC (rev 14883) @@ -17,3 +17,7 @@ Include a default Basic Authentication header in every HTTP request that identifies the hardware model of the device. + +- mmap.patch + +Make it work in filesystems that don't support writable mmaps. Modified: projects/haf/trunk/apt/apt-pkg/contrib/mmap.cc =================================================================== --- projects/haf/trunk/apt/apt-pkg/contrib/mmap.cc 2007-12-06 16:11:00 UTC (rev 14882) +++ projects/haf/trunk/apt/apt-pkg/contrib/mmap.cc 2007-12-06 16:13:54 UTC (rev 14883) @@ -31,13 +31,15 @@ #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> +#include <errno.h> + /*}}}*/ // MMap::MMap - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ MMap::MMap(FileFd &F,unsigned long Flags) : Flags(Flags), iSize(0), - Base(0) + Base(0), fd(0) { if ((Flags & NoImmMap) != NoImmMap) Map(F); @@ -47,7 +49,7 @@ // --------------------------------------------------------------------- /* */ MMap::MMap(unsigned long Flags) : Flags(Flags), iSize(0), - Base(0) + Base(0), fd(0) { } /*}}}*/ @@ -80,7 +82,26 @@ // Map it. Base = mmap(0,iSize,Prot,Map,Fd.Fd(),0); if (Base == (void *)-1) - return _error->Errno("mmap",_("Couldn't make mmap of %lu bytes"),iSize); + { + if (errno == ENODEV || errno == EINVAL) + { + // The filesystem doesn't support this particular kind of + // mmap. So we allocate a buffer and read the whole file + // into it. + // + int dupped_fd = dup (Fd.Fd()); + if (dupped_fd == -1) + return _error->Errno("mmap",_("Couldn't dup filedescriptor")); + + Base = new unsigned char[iSize]; + fd = new FileFd (dupped_fd); + if (!fd->Seek(0L) || !fd->Read(Base, iSize)) + return false; + } + else + return _error->Errno("mmap",_("Couldn't make mmap of %lu bytes"), + iSize); + } return true; } @@ -95,10 +116,19 @@ if (DoSync == true) Sync(); + + if (fd) + { + delete[] (char *)Base; + delete fd; + fd = NULL; + } + else + { + if (munmap((char *)Base,iSize) != 0) + _error->Warning("Unable to munmap"); + } - if (munmap((char *)Base,iSize) != 0) - _error->Warning("Unable to munmap"); - iSize = 0; Base = 0; return true; @@ -109,14 +139,24 @@ /* This is done in syncronous mode - the docs indicate that this will not return till all IO is complete */ bool MMap::Sync() -{ +{ if ((Flags & UnMapped) == UnMapped) return true; #ifdef _POSIX_SYNCHRONIZED_IO if ((Flags & ReadOnly) != ReadOnly) - if (msync((char *)Base,iSize,MS_SYNC) != 0) - return _error->Errno("msync","Unable to write mmap"); + { + if (fd) + { + if (!fd->Seek (0) || !fd->Write (Base, iSize)) + return false; + } + else + { + if (msync((char *)Base,iSize,MS_SYNC) != 0) + return _error->Errno("msync","Unable to write mmap"); + } + } #endif return true; } @@ -132,8 +172,20 @@ #ifdef _POSIX_SYNCHRONIZED_IO unsigned long PSize = sysconf(_SC_PAGESIZE); if ((Flags & ReadOnly) != ReadOnly) - if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start,MS_SYNC) != 0) - return _error->Errno("msync","Unable to write mmap"); + { + if (fd) + { + if (!fd->Seek (Start) + || !fd->Write (((char *)Base)+Start, Stop-Start)) + return false; + } + else + { + if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start, + MS_SYNC) != 0) + return _error->Errno("msync","Unable to write mmap"); + } + } #endif return true; } Modified: projects/haf/trunk/apt/apt-pkg/contrib/mmap.h =================================================================== --- projects/haf/trunk/apt/apt-pkg/contrib/mmap.h 2007-12-06 16:11:00 UTC (rev 14882) +++ projects/haf/trunk/apt/apt-pkg/contrib/mmap.h 2007-12-06 16:13:54 UTC (rev 14883) @@ -44,6 +44,12 @@ unsigned long iSize; void *Base; + // In case mmap can not be used, we keep a dup of the file + // descriptor that should have been mmaped so that we can write to + // the file in Sync(). + // + FileFd *fd; + bool Map(FileFd &Fd); bool Close(bool DoSync = true); Modified: projects/haf/trunk/apt/debian/changelog =================================================================== --- projects/haf/trunk/apt/debian/changelog 2007-12-06 16:11:00 UTC (rev 14882) +++ projects/haf/trunk/apt/debian/changelog 2007-12-06 16:13:54 UTC (rev 14883) @@ -2,6 +2,7 @@ * Applied maemostrip.diff * Applied http-tablet-identification.patch + * Applied mmap.patch -- Marius Vollmer <mvo at zagadka.de> Thu, 06 Dec 2007 17:15:19 +0200 Modified: projects/haf/trunk/apt/mmap.patch =================================================================== --- projects/haf/trunk/apt/mmap.patch 2007-12-06 16:11:00 UTC (rev 14882) +++ projects/haf/trunk/apt/mmap.patch 2007-12-06 16:13:54 UTC (rev 14883) @@ -1,7 +1,25 @@ -diff -rN -u old-apt/apt-pkg/contrib/mmap.cc new-apt/apt-pkg/contrib/mmap.cc ---- old-apt/apt-pkg/contrib/mmap.cc 2006-04-10 19:40:50.000000000 +0300 -+++ new-apt/apt-pkg/contrib/mmap.cc 2006-04-10 19:40:50.000000000 +0300 -@@ -35,13 +35,15 @@ +Index: apt-pkg/contrib/mmap.h +=================================================================== +--- apt-pkg/contrib/mmap.h (revision 14875) ++++ apt-pkg/contrib/mmap.h (working copy) +@@ -44,6 +44,12 @@ + unsigned long iSize; + void *Base; + ++ // In case mmap can not be used, we keep a dup of the file ++ // descriptor that should have been mmaped so that we can write to ++ // the file in Sync(). ++ // ++ FileFd *fd; ++ + bool Map(FileFd &Fd); + bool Close(bool DoSync = true); + +Index: apt-pkg/contrib/mmap.cc +=================================================================== +--- apt-pkg/contrib/mmap.cc (revision 14875) ++++ apt-pkg/contrib/mmap.cc (working copy) +@@ -31,13 +31,15 @@ #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> @@ -18,7 +36,7 @@ { if ((Flags & NoImmMap) != NoImmMap) Map(F); -@@ -51,7 +53,7 @@ +@@ -47,7 +49,7 @@ // --------------------------------------------------------------------- /* */ MMap::MMap(unsigned long Flags) : Flags(Flags), iSize(0), @@ -27,7 +45,7 @@ { } /*}}}*/ -@@ -84,7 +86,26 @@ +@@ -80,7 +82,26 @@ // Map it. Base = mmap(0,iSize,Prot,Map,Fd.Fd(),0); if (Base == (void *)-1) @@ -55,13 +73,10 @@ return true; } -@@ -99,9 +120,18 @@ +@@ -95,10 +116,19 @@ if (DoSync == true) Sync(); -- -- if (munmap((char *)Base,iSize) != 0) -- _error->Warning("Unable to munmap"); + + if (fd) + { @@ -75,9 +90,13 @@ + _error->Warning("Unable to munmap"); + } +- if (munmap((char *)Base,iSize) != 0) +- _error->Warning("Unable to munmap"); +- iSize = 0; Base = 0; -@@ -113,14 +143,24 @@ + return true; +@@ -109,14 +139,24 @@ /* This is done in syncronous mode - the docs indicate that this will not return till all IO is complete */ bool MMap::Sync() @@ -105,7 +124,7 @@ #endif return true; } -@@ -136,8 +176,20 @@ +@@ -132,8 +172,20 @@ #ifdef _POSIX_SYNCHRONIZED_IO unsigned long PSize = sysconf(_SC_PAGESIZE); if ((Flags & ReadOnly) != ReadOnly) @@ -128,19 +147,430 @@ #endif return true; } -diff -rN -u old-apt/apt-pkg/contrib/mmap.h new-apt/apt-pkg/contrib/mmap.h ---- old-apt/apt-pkg/contrib/mmap.h 2006-04-10 19:40:50.000000000 +0300 -+++ new-apt/apt-pkg/contrib/mmap.h 2006-04-10 19:41:00.000000000 +0300 -@@ -47,6 +47,12 @@ - unsigned long iSize; - void *Base; +Index: po/apt-all.pot +=================================================================== +--- po/apt-all.pot (revision 14875) ++++ po/apt-all.pot (working copy) +@@ -7,7 +7,7 @@ + msgstr "" + "Project-Id-Version: PACKAGE VERSION\n" + "Report-Msgid-Bugs-To: \n" +-"POT-Creation-Date: 2007-08-01 19:56-0300\n" ++"POT-Creation-Date: 2007-12-06 18:00+0200\n" + "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" + "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n" + "Language-Team: LANGUAGE <LL at li.org>\n" +@@ -155,8 +155,8 @@ + msgstr "" -+ // In case mmap can not be used, we keep a dup of the file -+ // descriptor that should have been mmaped so that we can write to -+ // the file in Sync(). -+ // -+ FileFd *fd; + #: cmdline/apt-cache.cc:1714 cmdline/apt-cdrom.cc:138 cmdline/apt-config.cc:70 +-#: cmdline/apt-extracttemplates.cc:225 ftparchive/apt-ftparchive.cc:547 +-#: cmdline/apt-get.cc:2585 cmdline/apt-sortpkgs.cc:144 ++#: cmdline/apt-extracttemplates.cc:225 cmdline/apt-get.cc:2585 ++#: cmdline/apt-sortpkgs.cc:144 + #, c-format + msgid "%s %s for %s compiled on %s %s\n" + msgstr "" +@@ -260,296 +260,6 @@ + msgid "Cannot get debconf version. Is debconf installed?" + msgstr "" + +-#: ftparchive/apt-ftparchive.cc:164 ftparchive/apt-ftparchive.cc:338 +-msgid "Package extension list is too long" +-msgstr "" +- +-#: ftparchive/apt-ftparchive.cc:166 ftparchive/apt-ftparchive.cc:180 +-#: ftparchive/apt-ftparchive.cc:203 ftparchive/apt-ftparchive.cc:253 +-#: ftparchive/apt-ftparchive.cc:267 ftparchive/apt-ftparchive.cc:289 +-#, c-format +-msgid "Error processing directory %s" +-msgstr "" +- +-#: ftparchive/apt-ftparchive.cc:251 +-msgid "Source extension list is too long" +-msgstr "" +- +-#: ftparchive/apt-ftparchive.cc:368 +-msgid "Error writing header to contents file" +-msgstr "" +- +-#: ftparchive/apt-ftparchive.cc:398 +-#, c-format +-msgid "Error processing contents %s" +-msgstr "" +- +-#: ftparchive/apt-ftparchive.cc:553 +-msgid "" +-"Usage: apt-ftparchive [options] command\n" +-"Commands: packages binarypath [overridefile [pathprefix]]\n" +-" sources srcpath [overridefile [pathprefix]]\n" +-" contents path\n" +-" release path\n" +-" generate config [groups]\n" +-" clean config\n" +-"\n" +-"apt-ftparchive generates index files for Debian archives. It supports\n" +-"many styles of generation from fully automated to functional replacements\n" +-"for dpkg-scanpackages and dpkg-scansources\n" +-"\n" +-"apt-ftparchive generates Package files from a tree of .debs. The\n" +-"Package file contains the contents of all the control fields from\n" +-"each package as well as the MD5 hash and filesize. An override file\n" +-"is supported to force the value of Priority and Section.\n" +-"\n" +-"Similarly apt-ftparchive generates Sources files from a tree of .dscs.\n" +-"The --source-override option can be used to specify a src override file\n" +-"\n" +-"The 'packages' and 'sources' command should be run in the root of the\n" +-"tree. BinaryPath should point to the base of the recursive search and \n" +-"override file should contain the override flags. Pathprefix is\n" +-"appended to the filename fields if present. Example usage from the \n" +-"Debian archive:\n" +-" apt-ftparchive packages dists/potato/main/binary-i386/ > \\\n" +-" dists/potato/main/binary-i386/Packages\n" +-"\n" +-"Options:\n" +-" -h This help text\n" +-" --md5 Control MD5 generation\n" +-" -s=? Source override file\n" +-" -q Quiet\n" +-" -d=? Select the optional caching database\n" +-" --no-delink Enable delinking debug mode\n" +-" --contents Control contents file generation\n" +-" -c=? Read this configuration file\n" +-" -o=? Set an arbitrary configuration option" +-msgstr "" +- +-#: ftparchive/apt-ftparchive.cc:759 +-msgid "No selections matched" +-msgstr "" +- +-#: ftparchive/apt-ftparchive.cc:832 +-#, c-format +-msgid "Some files are missing in the package file group `%s'" +-msgstr "" +- +-#: ftparchive/cachedb.cc:43 +-#, c-format +-msgid "DB was corrupted, file renamed to %s.old" +-msgstr "" +- +-#: ftparchive/cachedb.cc:61 +-#, c-format +-msgid "DB is old, attempting to upgrade %s" +-msgstr "" +- +-#: ftparchive/cachedb.cc:72 +-msgid "" +-"DB format is invalid. If you upgraded from a older version of apt, please " +-"remove and re-create the database." +-msgstr "" +- +-#: ftparchive/cachedb.cc:77 +-#, c-format +-msgid "Unable to open DB file %s: %s" +-msgstr "" +- +-#: ftparchive/cachedb.cc:123 apt-inst/extract.cc:178 apt-inst/extract.cc:190 +-#: apt-inst/extract.cc:207 apt-inst/deb/dpkgdb.cc:117 methods/gpgv.cc:272 +-#, c-format +-msgid "Failed to stat %s" +-msgstr "" +- +-#: ftparchive/cachedb.cc:238 +-msgid "Archive has no control record" +-msgstr "" +- +-#: ftparchive/cachedb.cc:444 +-msgid "Unable to get a cursor" +-msgstr "" +- +-#: ftparchive/writer.cc:75 +-#, c-format +-msgid "W: Unable to read directory %s\n" +-msgstr "" +- +-#: ftparchive/writer.cc:80 +-#, c-format +-msgid "W: Unable to stat %s\n" +-msgstr "" +- +-#: ftparchive/writer.cc:131 +-msgid "E: " +-msgstr "" +- +-#: ftparchive/writer.cc:133 +-msgid "W: " +-msgstr "" +- +-#: ftparchive/writer.cc:140 +-msgid "E: Errors apply to file " +-msgstr "" +- +-#: ftparchive/writer.cc:157 ftparchive/writer.cc:187 +-#, c-format +-msgid "Failed to resolve %s" +-msgstr "" +- +-#: ftparchive/writer.cc:169 +-msgid "Tree walking failed" +-msgstr "" +- +-#: ftparchive/writer.cc:194 +-#, c-format +-msgid "Failed to open %s" +-msgstr "" +- +-#: ftparchive/writer.cc:253 +-#, c-format +-msgid " DeLink %s [%s]\n" +-msgstr "" +- +-#: ftparchive/writer.cc:261 +-#, c-format +-msgid "Failed to readlink %s" +-msgstr "" +- +-#: ftparchive/writer.cc:265 +-#, c-format +-msgid "Failed to unlink %s" +-msgstr "" +- +-#: ftparchive/writer.cc:272 +-#, c-format +-msgid "*** Failed to link %s to %s" +-msgstr "" +- +-#: ftparchive/writer.cc:282 +-#, c-format +-msgid " DeLink limit of %sB hit.\n" +-msgstr "" +- +-#: ftparchive/writer.cc:386 +-msgid "Archive had no package field" +-msgstr "" +- +-#: ftparchive/writer.cc:394 ftparchive/writer.cc:609 +-#, c-format +-msgid " %s has no override entry\n" +-msgstr "" +- +-#: ftparchive/writer.cc:439 ftparchive/writer.cc:697 +-#, c-format +-msgid " %s maintainer is %s not %s\n" +-msgstr "" +- +-#: ftparchive/writer.cc:619 +-#, c-format +-msgid " %s has no source override entry\n" +-msgstr "" +- +-#: ftparchive/writer.cc:623 +-#, c-format +-msgid " %s has no binary override entry either\n" +-msgstr "" +- +-#: ftparchive/contents.cc:317 +-#, c-format +-msgid "Internal error, could not locate member %s" +-msgstr "" +- +-#: ftparchive/contents.cc:353 ftparchive/contents.cc:384 +-msgid "realloc - Failed to allocate memory" +-msgstr "" +- +-#: ftparchive/override.cc:34 ftparchive/override.cc:142 +-#, c-format +-msgid "Unable to open %s" +-msgstr "" +- +-#: ftparchive/override.cc:60 ftparchive/override.cc:166 +-#, c-format +-msgid "Malformed override %s line %lu #1" +-msgstr "" +- +-#: ftparchive/override.cc:74 ftparchive/override.cc:178 +-#, c-format +-msgid "Malformed override %s line %lu #2" +-msgstr "" +- +-#: ftparchive/override.cc:88 ftparchive/override.cc:191 +-#, c-format +-msgid "Malformed override %s line %lu #3" +-msgstr "" +- +-#: ftparchive/override.cc:127 ftparchive/override.cc:201 +-#, c-format +-msgid "Failed to read the override file %s" +-msgstr "" +- +-#: ftparchive/multicompress.cc:71 +-#, c-format +-msgid "Unknown compression algorithm '%s'" +-msgstr "" +- +-#: ftparchive/multicompress.cc:101 +-#, c-format +-msgid "Compressed output %s needs a compression set" +-msgstr "" +- +-#: ftparchive/multicompress.cc:168 methods/rsh.cc:91 +-msgid "Failed to create IPC pipe to subprocess" +-msgstr "" +- +-#: ftparchive/multicompress.cc:194 +-msgid "Failed to create FILE*" +-msgstr "" +- +-#: ftparchive/multicompress.cc:197 +-msgid "Failed to fork" +-msgstr "" +- +-#: ftparchive/multicompress.cc:211 +-msgid "Compress child" +-msgstr "" +- +-#: ftparchive/multicompress.cc:234 +-#, c-format +-msgid "Internal error, failed to create %s" +-msgstr "" +- +-#: ftparchive/multicompress.cc:285 +-msgid "Failed to create subprocess IPC" +-msgstr "" +- +-#: ftparchive/multicompress.cc:320 +-msgid "Failed to exec compressor " +-msgstr "" +- +-#: ftparchive/multicompress.cc:359 +-msgid "decompressor" +-msgstr "" +- +-#: ftparchive/multicompress.cc:402 +-msgid "IO to subprocess/file failed" +-msgstr "" +- +-#: ftparchive/multicompress.cc:454 +-msgid "Failed to read while computing MD5" +-msgstr "" +- +-#: ftparchive/multicompress.cc:471 +-#, c-format +-msgid "Problem unlinking %s" +-msgstr "" +- +-#: ftparchive/multicompress.cc:486 apt-inst/extract.cc:185 +-#, c-format +-msgid "Failed to rename %s to %s" +-msgstr "" +- + #: cmdline/apt-get.cc:121 + msgid "Y" + msgstr "" +@@ -1348,6 +1058,17 @@ + msgid "The diversion path is too long" + msgstr "" + ++#: apt-inst/extract.cc:178 apt-inst/extract.cc:190 apt-inst/extract.cc:207 ++#: apt-inst/deb/dpkgdb.cc:117 methods/gpgv.cc:272 ++#, c-format ++msgid "Failed to stat %s" ++msgstr "" + - bool Map(FileFd &Fd); - bool Close(bool DoSync = true); - ++#: apt-inst/extract.cc:185 ++#, c-format ++msgid "Failed to rename %s to %s" ++msgstr "" ++ + #: apt-inst/extract.cc:240 + #, c-format + msgid "The directory %s is being replaced by a non-directory" +@@ -1665,7 +1386,7 @@ + msgid "Unable to accept connection" + msgstr "" + +-#: methods/ftp.cc:864 methods/http.cc:959 methods/rsh.cc:303 ++#: methods/ftp.cc:864 methods/http.cc:974 methods/rsh.cc:303 + msgid "Problem hashing file" + msgstr "" + +@@ -1829,51 +1550,55 @@ + msgid "Unknown date format" + msgstr "" + +-#: methods/http.cc:774 ++#: methods/http.cc:789 + msgid "Select failed" + msgstr "" + +-#: methods/http.cc:779 ++#: methods/http.cc:794 + msgid "Connection timed out" + msgstr "" + +-#: methods/http.cc:802 ++#: methods/http.cc:817 + msgid "Error writing to output file" + msgstr "" + +-#: methods/http.cc:833 ++#: methods/http.cc:848 + msgid "Error writing to file" + msgstr "" + +-#: methods/http.cc:861 ++#: methods/http.cc:876 + msgid "Error writing to the file" + msgstr "" + +-#: methods/http.cc:875 ++#: methods/http.cc:890 + msgid "Error reading from server. Remote end closed connection" + msgstr "" + +-#: methods/http.cc:877 ++#: methods/http.cc:892 + msgid "Error reading from server" + msgstr "" + +-#: methods/http.cc:1104 ++#: methods/http.cc:1119 + msgid "Bad header data" + msgstr "" + +-#: methods/http.cc:1121 methods/http.cc:1176 ++#: methods/http.cc:1136 methods/http.cc:1191 + msgid "Connection failed" + msgstr "" + +-#: methods/http.cc:1228 ++#: methods/http.cc:1243 + msgid "Internal error" + msgstr "" + +-#: apt-pkg/contrib/mmap.cc:78 ++#: apt-pkg/contrib/mmap.cc:80 + msgid "Can't mmap an empty file" + msgstr "" + +-#: apt-pkg/contrib/mmap.cc:83 ++#: apt-pkg/contrib/mmap.cc:94 ++msgid "Couldn't dup filedescriptor" ++msgstr "" ++ ++#: apt-pkg/contrib/mmap.cc:102 + #, c-format + msgid "Couldn't make mmap of %lu bytes" + msgstr "" +@@ -2626,6 +2351,10 @@ + msgid "Could not patch file" + msgstr "" + ++#: methods/rsh.cc:91 ++msgid "Failed to create IPC pipe to subprocess" ++msgstr "" ++ + #: methods/rsh.cc:330 + msgid "Connection closed prematurely" + msgstr ""
- Previous message: [maemo-commits] r14882 - projects/haf/trunk/apt
- Next message: [maemo-commits] r14884 - in projects/haf/trunk/apt: . cmdline debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]