Ticket #39018: patch-src_remove.c.diff

File patch-src_remove.c.diff, 1.8 KB (added by cooljeanius (Eric Gallager), 11 years ago)

patch for src/remove.c

  • src/remove.c

    old new  
    334334        push_leftover(&leftover, namenode);
    335335        continue;
    336336      }
    337       if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf);
     337        if (errno != ENOTDIR) {
     338            /* XXX Hack:
     339             * dpkg includes /. in the packing list.
     340             * rmdir("/.") will return EINVAL. dpkg will
     341             * only attempt to remove /. when uninstalling
     342             * the last package on the system, which is why
     343             * Debian has never run into this issue. */
     344            if (errno == EINVAL && strcmp(fnvb.buf, "/.") == 0)
     345                continue;
     346            else
     347                ohshite(_("cannot remove `%.250s'"),fnvb.buf);
     348        }
    338349      debug(dbg_eachfiledetail, "removal_bulk unlinking '%s'", fnvb.buf);
    339350      if (secure_unlink(fnvb.buf))
    340351        ohshite(_("unable to securely remove '%.250s'"), fnvb.buf);
     
    425436      push_leftover(&leftover, namenode);
    426437      continue;
    427438    }
    428     if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf);
     439      if (errno != ENOTDIR) {
     440          /* XXX Hack:
     441           * dpkg includes /. in the packing list.
     442           * rmdir("/.") will return EINVAL. dpkg will
     443           * only attempt to remove /. when uninstalling
     444           * the last package on the system, which is why
     445           * Debian has never run into this issue. */
     446          if (errno == EINVAL && strcmp(fnvb.buf, "/.") == 0)
     447              continue;
     448          else
     449              ohshite(_("cannot remove `%.250s'"),fnvb.buf);
     450      }
    429451
    430452    if (lstat(fnvb.buf, &stab) == 0 && S_ISLNK(stab.st_mode)) {
    431453      debug(dbg_eachfiledetail, "removal_bulk is a symlink to a directory");