Fix build when DEB is defined

Before submitting http://tracker.dev.opencascade.org/view.php?id=24510 I slightly edited our changes, but made a mistake and changed the scope of a variable.  Andrey fixed it, and performed more cleanup.
This branch contains cherry-picks of these commits.