Comment 2 for bug 1969421

Revision history for this message
Mike (web-g) wrote :

Ok I figured it out. You can close this ticket unless you think others might encounter the same issue.

I must have followed instructions like at https://wiki.aleen42.com/qa/dpkg.html to rename /var/lib/dpkg/info to /var/lib/dpkg/info.bak, and it was choking on the directory because head can't operate on a directory. I moved /var/lib/dpkg/info.bak somewhere else and it fixed the problem.

The post install script /var/lib/dpkg/info/dpkg.postinst contains the following code that will choke if there is a directory in /var/lib/dpkg/info/:

fixup_misplaced_alternatives()
(
  admindir=${DPKG_ADMINDIR:-/var/lib/dpkg}

  cd "$admindir"

  for file in *; do
    # Check whether this is a known file we do not want to act on.
    case "$file" in
    alternatives|\
    arch|\
    available|available-old|\
    cmethopt|methlock|methods|\
    diversions|diversions-old|\
    info|parts|triggers|updates|\
    lock|lock-frontend|\
    statoverride|statoverride-old|\
    status|status-old)
      # Ignore known files just to make sure.
      continue
      ;;
    *)
    esac

    # Check whether the file looks like an alternative state file.
    mode="$(head -1 "$file")"
    case "$mode" in
    auto|manual)
      # Looks like a state file, we will handle this one.
      echo "Moving misplaced alternative state file $admindir/$file..."
      mv "$file" "alternatives/$file"
      ;;
    *)
      echo "warning: unknown dpkg database file $admindir/$file is not a misplaced alternative state... leaving as is" 1>&2
      continue
      ;;
    esac
  done
)