Fix build error and pkg -d behavior