[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: apt



On Sun, Feb 03, 2002 at 12:23:43AM -0500, utsl@quic.net wrote:

> I had problems with ftp-archive also. At different points, with different
> versions, and different versions of g++, it has segfaulted, failed to compile,
> and just plain won't work. I disabled it in the Makefile. I haven't tried real
> hard to fix it, because I felt there were other things that were more urgent.
> If you figure out what's wrong with it, I'd be quite interested...

The primary problem is that it uses ftw() calls which don't exist in
NetBSD. I've tried porting this to the fts API and it now compiles, but
I've obviously screwed up somewhere in that it segfaults instead...

> FWIW, I do have apt basically working on FreeBSD. It segfaulted quite a bit at
> first, but seems to be working better, now that I recompiled it with gcc 3.0.
> It might just be that the libstdc++ with 3.0 is better. I don't really know,
> but it helped a lot.

I've altered the patch so that it doesn't do any messing around with
_POSIX_C_SOURCE - new patch attached. Still needs environment.mak hacked,
I'll do that properly later on.

-- 
Matthew Garrett | mjg59@srcf.ucam.org
diff -u -r ftparchive/apt-ftparchive.cc ../apt-0.5.4.work/ftparchive/apt-ftparchive.cc
--- ftparchive/apt-ftparchive.cc	Tue Jun 26 02:50:27 2001
+++ ../apt-0.5.4.work/ftparchive/apt-ftparchive.cc	Sun Feb  3 14:54:58 2002
@@ -29,8 +29,7 @@
 
 #include "contents.h"
 #include "multicompress.h"
-#include "writer.h"    
-									/*}}}*/
+#include "writer.h"
 
 using namespace std;    
 ostream c0out(0);
diff -u -r ftparchive/cachedb.h ../apt-0.5.4.work/ftparchive/cachedb.h
--- ftparchive/cachedb.h	Tue Feb 20 07:03:18 2001
+++ ../apt-0.5.4.work/ftparchive/cachedb.h	Sun Feb  3 14:55:20 2002
@@ -11,7 +11,6 @@
 									/*}}}*/
 #ifndef CACHEDB_H
 #define CACHEDB_H
-
 #ifdef __GNUG__
 #pragma interface "cachedb.h"
 #endif 
@@ -69,7 +68,7 @@
    enum FlagList {FlControl = (1<<0),FlMD5=(1<<1),FlContents=(1<<2)};
    struct StatStore
    {
-      uint32_t st_mtime;          
+      struct timespec st_mtimespec;
       uint32_t Flags;
    } CurStat;
    struct StatStore OldStat;
@@ -115,5 +114,5 @@
    CacheDB(string DB) : Dbp(0), DebFile(0) {ReadyDB(DB);};
    ~CacheDB() {ReadyDB(string()); delete DebFile;};
 };
-    
+
 #endif
diff -u -r ftparchive/writer.cc ../apt-0.5.4.work/ftparchive/writer.cc
--- ftparchive/writer.cc	Tue Jun 26 02:50:27 2001
+++ ../apt-0.5.4.work/ftparchive/writer.cc	Sun Feb  3 02:56:37 2002
@@ -25,7 +25,7 @@
 
 #include <sys/types.h>
 #include <unistd.h>
-#include <ftw.h>
+#include <fts.h>
 #include <iostream>
     
 #include "cachedb.h"
@@ -69,19 +69,19 @@
 // ---------------------------------------------------------------------
 /* This is the FTW scanner, it processes each directory element in the 
    directory tree. */
-int FTWScanner::Scanner(const char *File,const struct stat *sb,int Flag)
+int FTWScanner::Scanner(const char *File,int Flag)
 {
-   if (Flag == FTW_DNR)
+   if (Flag == FTS_DNR)
    {
       Owner->NewLine(1);
       c1out << "W: Unable to read directory " << File << endl;
    }   
-   if (Flag == FTW_NS)
+   if (Flag == FTS_NS)
    {
       Owner->NewLine(1);
       c1out << "W: Unable to stat " << File << endl;
    }   
-   if (Flag != FTW_F)
+   if (Flag != FTS_F)
       return 0;
 
    // See if it is a .deb
@@ -139,7 +139,11 @@
 /* */
 bool FTWScanner::RecursiveScan(string Dir)
 {
-   /* If noprefix is set then jam the scan root in, so we don't generate
+   FTS *fts;
+   FTSENT *p;
+   char dirname[255];
+   char *dirlist[1];
+      /* If noprefix is set then jam the scan root in, so we don't generate
       link followed paths out of control */
    if (InternalPrefix.empty() == true)
    {
@@ -150,16 +154,16 @@
    
    // Do recursive directory searching
    Owner = this;
-   int Res = ftw(Dir.c_str(),Scanner,30);
-   
-   // Error treewalking?
-   if (Res != 0)
-   {
-      if (_error->PendingError() == false)
-	 _error->Errno("ftw","Tree walking failed");
-      return false;
+   strncpy(dirname,Dir.c_str(),255);
+   dirlist[0]=dirname;
+   if (!(fts = fts_open(dirlist,FTS_LOGICAL,0))) {
+	c1out << "Unable to open\n";
+	return false;
+   }  
+   while ((p = fts_read(fts)) != NULL) {
+          Scanner(p->fts_path, p->fts_info);
    }
-   
+   fts_close(fts); 
    return true;
 }
 									/*}}}*/
@@ -206,11 +210,11 @@
       }
       
       struct stat St;
-      int Flag = FTW_F;
+      int Flag = FTS_F;
       if (stat(FileName,&St) != 0)
-	 Flag = FTW_NS;
+	 Flag = FTS_NS;
 
-      if (Scanner(FileName,&St,Flag) != 0)
+      if (Scanner(FileName,Flag) != 0)
 	 break;
    }
   
diff -u -r ftparchive/writer.h ../apt-0.5.4.work/ftparchive/writer.h
--- ftparchive/writer.h	Tue Jun 26 02:50:27 2001
+++ ../apt-0.5.4.work/ftparchive/writer.h	Sun Feb  3 02:34:30 2002
@@ -44,7 +44,7 @@
    bool NoLinkAct;
    
    static FTWScanner *Owner;
-   static int Scanner(const char *File,const struct stat *sb,int Flag);
+   static int Scanner(const char *File,int Flag);
 
    bool Delink(string &FileName,const char *OriginalPath,
 	       unsigned long &Bytes,struct stat &St);

Reply to: