Thermodynamics with friction. I. The Clausius inequality revisited