[pacman] don't reinstall if it is not needed

Use the option --needed when installing packages to avoid re-installing a package if it is already at last version.
Merge pull request #10264 from abique/patch-1

[pacman] don't reinstall if it is not needed