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

Darwin Patches (was: Replaces and virtual packages)



Adam Heath wrote:
On Sun, 21 Oct 2001, Adam Heath wrote:

 Ah, I see the patch.  Looking it over now(some of this makes sense, and I'll
 apply it to HEAD).

Wichert: Should some of these be applied to the v1_9 branch, or just to HEAD?

I've interspersed my comments into the patch, between files.

Okay, some explanations from me...

- ohshit(_("file `%.250s' is corrupt - negative member length %zi"),debar,memberlen); + ohshit(FIX_PERCENT_ZI(_("file `%.250s' is corrupt - negative member length %zi")),debar,memberlen);

This whole FIX_PERCENT_ZI thing is there because Darwin's libc doesn't support %zi in *printf and *scanf. The macro and the associated function was the only fix I could come up with that:

 1) Fixes the problem on Darwin
 2) Doesn't add run-time overhead on other platforms
 3) Doesn't break i18n

I guess 3) is why I didn't use the macro on the sscanf, which of course is not a good idea for other platforms.

diff -ru dpkg-1.9.16/main/archives.c dpkg-1.9.16-patched/main/archives.c
--- dpkg-1.9.16/main/archives.c	Mon May 28 23:32:23 2001
+++ dpkg-1.9.16-patched/main/archives.c	Wed Jul 11 15:34:44 2001
@@ -547,12 +547,10 @@
     debug(dbg_eachfiledetail,"tarobject SymbolicLink creating");
 #ifdef HAVE_LCHOWN
     if (lchown(fnamenewvb.buf,
-#else
-    if (chown(fnamenewvb.buf,
-#endif
nifd->namenode->statoverride ? nifd->namenode->statoverride->uid : ti->UserID, nifd->namenode->statoverride ? nifd->namenode->statoverride->gid : ti->GroupID))
       ohshite(_("error setting ownership of symlink `%.255s'"),ti->Name);
+#endif
     break;
   case Directory:
     /* We've already checked for an existing directory. */
@@ -608,10 +606,8 @@
         ohshite(_("unable to make backup symlink for `%.255s'"),ti->Name);
 #ifdef HAVE_LCHOWN
       if (lchown(fnametmpvb.buf,stab.st_uid,stab.st_gid))
-#else
-      if (chown(fnametmpvb.buf,stab.st_uid,stab.st_gid))
-#endif
         ohshite(_("unable to chown backup symlink for `%.255s'"),ti->Name);
+#endif
     } else {
       debug(dbg_eachfiledetail,"tarobject nondirectory, `link' backup");
       if (link(fnamevb.buf,fnametmpvb.buf))

What is the reasoning for these changes?  Are there no symlinks on darwin?  If
that is true, an error should be given when trying to extract something that
has a symlink.

I actually posted this to the list some weeks ago and got no reply. Darwin does have symlinks, but it doesn't have lchown() and instead uses the owner of the containing directory when asked for the info. Using chown() instead is bad because it changes ownership of the link _target_. That is not only not the intended behaviour, but also leads to errors when the target doesn't exist. dpkg-deb tries to sort links to the back of the file list, but unfortunately there are packages which contain links to links, which can trigger errors. I first encountered that with gtk's gtkrc files.

diff -ru dpkg-1.9.16/main/configure.c dpkg-1.9.16-patched/main/configure.c
--- dpkg-1.9.16/main/configure.c	Thu Apr 26 20:48:49 2001
+++ dpkg-1.9.16-patched/main/configure.c	Wed Jul 11 15:01:45 2001
@@ -340,8 +340,10 @@
           " I do not mess up your careful work.\n"),
                     cdr.buf, cdr2.buf);

+#ifndef __APPLE__
             s= getenv(NOJOBCTRLSTOPENV);
             if (s && *s) {
+#endif
               fputs(_("Type `exit' when you're done.\n"),stderr);
               if (!(c1= m_fork())) {
                 s= getenv(SHELLENV);
@@ -351,11 +353,13 @@
               }
               while ((r= waitpid(c1,&status,0)) == -1 && errno == EINTR);
if (r != c1) { onerr_abort++; ohshite(_("wait for shell failed")); }
+#ifndef __APPLE__
             } else {
               fputs(_("Don't forget to foreground (`fg') this "
                     "process when you're done !\n"),stderr);
               kill(-getpgid(0),SIGTSTP);
             }
+#endif
           }

         } while (!strchr("yino",cc));

No job control on darwin?

Job control is there alright, but for some unknown reason getpgid() isn't. :-( I was too lazy to add a proper autoconf test, sorry.

diff -ru dpkg-1.9.16/main/help.c dpkg-1.9.16-patched/main/help.c
--- dpkg-1.9.16/main/help.c	Sat Jun 30 16:34:30 2001
+++ dpkg-1.9.16-patched/main/help.c	Wed Jul 11 15:05:16 2001
@@ -69,7 +69,10 @@

 void checkpath(void) {
 /* Verify that some programs can be found in the PATH. */
-  static const char *const checklist[]= { "ldconfig",
+  static const char *const checklist[]= {
+#ifndef __APPLE__
+    "ldconfig",
+#endif
 #ifdef USE_START_STOP_DAEMON
     "start-stop-daemon",
 #endif

No ldconfig on darwin?

No, it's not necessary because the full path of libraries gets encoded into the executables (and into the libraries for that matter). Basically like -soname, but with the full path.

diff -ru dpkg-1.9.16/scripts/update-alternatives.pl dpkg-1.9.16-patched/scripts/update-alternatives.pl
--- dpkg-1.9.16/scripts/update-alternatives.pl	Sat Jun 16 21:53:59 2001
+++ dpkg-1.9.16-patched/scripts/update-alternatives.pl Wed Jul 11 15:37:30 2001
@@ -56,7 +56,7 @@
 sub quit { print STDERR "update-alternatives: @_\n"; exit(2); }
sub badusage { print STDERR "update-alternatives: @_\n\n"; &usageversion; exit(2); }

-$altdir= '/etc/alternatives';
+$altdir= '@ADMINPREFIX@/etc/alternatives';
 $admindir= $admindir . '/alternatives';
 $testmode= 0;
 $verbosemode= 0;

I don't see ADMINPREFIX defined.  What is this supposed to do?

It's replaced with sed before the patch is applied. The rest of dpkg adheres to the prefix set through the configure script...

There's also one more chunk which you probably missed because it's still in Fink's unstable section:

diff -ruN dpkg-1.9.17/main/processarc.c dpkg-1.9.17-patched/main/processarc.c
--- dpkg-1.9.17/main/processarc.c       Mon Apr 23 22:42:17 2001
+++ dpkg-1.9.17-patched/main/processarc.c       Fri Oct 19 11:34:10 2001
@@ -196,8 +196,8 @@
     pkg->files= nfmalloc(sizeof(struct filedetails));
     pkg->files->next= 0;
     pkg->files->name= pkg->files->msdosname= pkg->files->md5sum= 0;
-    pkg->files->size= nfmalloc(30);
   }
+  pkg->files->size= nfmalloc(30);
   sprintf(pkg->files->size,"%lu",(unsigned long)stab.st_size);

   if (cipaction->arg == act_avail) {

This fixes a segfault that occurs when a package with the same version is reinstalled that has changed sufficiently to increase the length of the Size field. When a package is already present, pkg->files->size already exists and is reused, but it's only allocated to fit. Some more analysis by Matthias Neeracher (who tracked this down) is in this SourceForge bug report: <http://sourceforge.net/tracker/index.php?func=detail&aid=467762&group_id=17203&atid=117203>

(Yes, I know it's BAD to change a package without incrementing the revision number. But it's useful while developing a package, and actually only packagers have been hit by this bug, while adjusting their own packages.)

-chrisp

--
chrisp a.k.a. Christoph Pfisterer   "Any sufficiently advanced
cp@chrisp.de - http://chrisp.de      bug is indistinguishable
PGP key & geek code available        from a feature."



Reply to: